cancel
Showing results for 
Search instead for 
Did you mean: 

Identity Service for Process Engine Only - No Explorer

taruntyagi
Champ in-the-making
Champ in-the-making
Hi

We intend to use Activiti within a J2EE Spring application. There will be user tasks and groups.
I have tried implementing custom user and group entity managers , but they never seem to be called when a user task is assigned or
when I query tasks for a user or group.

I suppose , the process engine is always able to figure out the users or groups related to a user task based on the process definition itself.
For example,

1) I set the candidate group of a user task in process definition
2) I query for all tasks for the group (No method from Identity service classes is triggered)
3) I claim the task for a user (Again no method called in Identity service classes)
4) I query all tasks for the user - The relevant task is returned (Again no method called in Identity service classes )

It seems to be the case that Identity Service classes are applicable only when users and groups are managed via Explorer.
My tests are in a JUNIT, using H2 database.

Can someone kindly confirm this assumption or understanding , or please provide an example scenario where Identity Service may be called when executing processes using Process Engine in embedded mode.

Thanks in Advance Smiley Happy

Regards
Tarun
5 REPLIES 5

frederikherema1
Star Contributor
Star Contributor
Your assumption is partially correct Smiley Wink

1. Adding assignee, candidate groups, candidate starters, … to the process definitions and task will not trigger any identity-related calls. The engine is implemented (explicit choice to keep the implementation as flexible as possible) in such a way that there is NO explicit checking of identities against the user-management. So *any* value for assignee will work, even if it's not a valid user. If you want to have this enforces, the layer above the engine API (your code) should check this.

2. When requesting tasks assigned to a specific user, the Identity management is indeed not used. Only when calling TaskService.taskCandidateUser(…), all groups for that user will be requested from the identity-management and included in the query - the resulting tasks include tasks where user X is a candidate explicitly and also all tasks where you're member of at least one candidate group…

Does this clarify it for you?

arnoldschrijve1
Champ on-the-rise
Champ on-the-rise
I may add another thing I just found out which may be helpful. And that is that some of the examples of using custom session factories, that can be found by googling, return the UserEntityManager.class and GroupEntityManager.class abstract classes in getSessionType() instead of the interface UserIdentityManager, GroupIdentityManager. So if you started from that code it won't work.

After changing this my custom group + user managers are called:

<java>

package com.example.workflow.identity;

import org.activiti.engine.impl.interceptor.Session;
import org.activiti.engine.impl.interceptor.SessionFactory;
import org.activiti.engine.impl.persistence.entity.UserIdentityManager;

public class CustomUserManagerFactory implements SessionFactory {

@Override
public Class<?> getSessionType() {
  return UserIdentityManager.class;
}

@Override
public Session openSession() {
  return new CustomUserManager();
}

}

</java>

arnoldschrijve1
Champ on-the-rise
Champ on-the-rise
I created a pull request to add some info on this in the User Guide: https://github.com/Activiti/Activiti/pull/354

taruntyagi
Champ in-the-making
Champ in-the-making
Thanks frederikheremans, this really helps and actually clarified a wrong assumption. It is clear to me that Identity Service will be used to fetch groups of a user when we search tasks for a 'candidate user'. This is not used, if we are searching for assigned tasks. Makes sense as well.

Thanks to aschrijver, I was actually making the mistake you mentioned. My Factory class was returning the type as MyCustomUser / Group class. I did debug until to look at all session factories and thought it did not look OK. But the code for custom identityservice was taken from a blog page , and I thought that's the way it should be done Smiley Happy

With the change you suggested, my identity service is getting called and working as expected.

Thanks for your help.

Regards
Tarun

edgarjoao
Champ in-the-making
Champ in-the-making
/