cancel
Showing results for 
Search instead for 
Did you mean: 

How to query group members from Alfresco

srobinson
Champ in-the-making
Champ in-the-making
I would like to know how to query for group members in a service task.  We are managing the users through Alfresco (4.2.d).  I have seen information on how to use an LDAP server, but not how to retrieve members of a group from Alfresco.  In the IdentityService I see how to query for the group, but I do not see how the Group object would give me the group members.

Any help on this is greatly appreciated.

Thanks,

- Shannon
5 REPLIES 5

frederikherema1
Star Contributor
Star Contributor
If you're using alfresco, use the Alfresco services for fetching groups (I guess yo should use the AuthorityService or PersonService), not the activiti indentity-service.

srobinson
Champ in-the-making
Champ in-the-making
How exactly do you access the authorityService bean from within your service class or listener?

Thanks for the response.

- Shannon

frederikherema1
Star Contributor
Star Contributor
You can define your listeners in spring and extend the "baseJavaDelegate" spring-bean, which has the service-registry injected by default. It also registers itself as a "safe" bean to use in activiti-alfresco:


<bean id="baseJavaDelegate" class="org.alfresco.repo.workflow.activiti.BaseJavaDelegate"
        abstract="true">
        <property name="serviceRegistry" ref="ServiceRegistry" />
        <property name="beanRegistry" ref="activitiBeanRegistry" />
    </bean>

Afterwards, you can use delegate by referencing it's "name" (defaults to getClass().getSimpleName()) in an activiti:delegateExpression=${MyCustomDelegate}

srobinson
Champ in-the-making
Champ in-the-making
I have a few follow up questions … Would I use only the bean name in the delegate expression or do I call a method on the bean to execute my logic or will the framework handle calling the appropriate method?  Is there any need to fetch the bean or is the bean registration in the -context.xml file all that is needed for Activiti to pick up its registration in any delegation?  Is the bean stored as a process variable or is Activiti Spring bean aware?  Also, would this logic have to be implemented as a listener or could it be defined as the activiti:class?

Thanks again for all the help.

- Shannon

frederikherema1
Star Contributor
Star Contributor
That's a lot of questions… Smiley Tongue

  • Activiti in Alfresco DOESN'T have full access to the full spring-context due to security reasons.

  • Instead, there is an ActivitiBeanRegistry that contains what beans are exposed in expressions. If you use the "baseJavaDelegate" or "baseExecutionListener" as spring-parent bean when defining the bean in your custom context.xml file, the beans will get registered automatically.

  • The beans will be registered under the getClass().getSimpleName(), unless the "getName()" method on the BaseJavaDelegate-superclass you created, overrides this method. So the name you should use in activiti:delegateExpression is that name.

  • You CAN still use the activiti:class="org.mycompany.MyDelegate" off course, but then you'll have to figure out a different way to access the alfresco-servies, since the delegate-class will be created using Activiti, independent and unaware of spring-context.

  • You can use both variables and registered-beans in your expressions. The beans itself are NOT stored as variables…