I need to add the groups the user belong to the column “Accepted By” in the task search results porlet.
What is the best way to get the groups the user belongs to based on the information provided by getTaskDisplayProvider().getAcceptedPrincipalsListProvider();
Task Engine does not support assigning task to groups. Only to individual users and roles
It also does not support accepting a task by a group, only by individual users.
But it seems like what you are really looking for is for a way to discover and display just groups (or roles) which user who accepted a task is a member of.
TaskDisplayProvider.getAcceptedPrincipalsListProvider() returns you list of display names of accepted users, this is not what you need. Instead you need to obtain list of user IDs who accepted a task, from .getTaskInfo().getAcceptedByList() (where is managed bean representing current task)
Having the IDs of the user you now can determine groups and roles user is a member of using common directory service APIs. Details about this API can be found at:
The code you would need is something like this:
IDirectorySession s = DirectorySystemFactory.getDirectorySystem().createSession();
s.getGroupMembership(userID);
It seems that the format returned by getAcceptedByList() is not what getGroupMembership() needs. I get an Exception with the message
Invalid Object ID
getAcceptedByList() returns the user names as a String
getGroupMembership() expects a principalId: what format principalId must be (just the username, the DN…)? I tryied with different combinations and always got the same exception.