AnsweredAssumed Answered

Override AssignmentHandler

Question asked by skank on Jul 30, 2010
Latest reply on Jul 30, 2010 by skank

I'm trying to implement a new AssignmentHandler, with no success.

    <task-node name="Read">
        <task name="my:read">
            <assignment class="com.workflow.handler.MyAssignmentHandler" />
            <event type="task-create">

Here is MyAssignmentHandler :

public class MyAssignmentHandler implements AssignmentHandler {

    public void assign(Assignable assignable, ExecutionContext ec) throws Exception {
        NodeService nodeservice = (NodeService) FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "NodeService");

        JBPMNodeList assigneesNode = (JBPMNodeList) ec.getContextInstance().getVariable("bpm_assignees");
        String[] pooledActors = new String[assigneesNode.size()];

        for (int i = 0; i < assigneesNode.size(); i++) {
            Map<QName, Serializable> contextProps = new HashMap<QName, Serializable>();
            contextProps = nodeservice.getProperties(assigneesNode.get(i).getNodeRef());
            pooledActors[i] = (String)contextProps.get(ContentModel.PROP_USERNAME);

I've read in the wiki ( that "The JBoss jBPM Identity Component is not yet plugged into Alfresco User management and thus cannot be used for swimlane and task assignments."

But I've checked the source code of org.alfresco.repo.workflow.jbpm.AlfrescoAssignment and I'm doing quite the same (especially the mapAuthorityToName method) :

     * Convert Alfresco authority to actor id
     * @param authority
     * @return  actor id
    private String mapAuthorityToName(ScriptNode authority, boolean allowGroup)
        String name = null;
        QName type = authority.getQNameType();
        if (dictionaryService.isSubClass(type, ContentModel.TYPE_PERSON))
            name = (String)authority.getProperties().get(ContentModel.PROP_USERNAME);
        else if (allowGroup && dictionaryService.isSubClass(type, ContentModel.TYPE_AUTHORITY_CONTAINER))
            name = authorityDAO.getAuthorityName(authority.getNodeRef());
        else if (type.equals(ContentModel.TYPE_AUTHORITY))
            name = authorityDAO.getAuthorityName(authority.getNodeRef());
        return name;

This method takes the username of the person and returns it as a string for jBPM. (My "assigneesNode" is also a list of person nodes).

Anybody has an idea ?