简体   繁体   中英

Reassigning "initiator" in Alfresco Activiti workflow

I am trying to re-assign the "initiator" in my Alfresco Activiti Workflow to an "admin" to prevent the original initiator from modifying the workflow. This is working except the workflow only appears in the Original Initiator's "Workflows I've Started" dropdown. It doesn't appear in the "admins'" "Workflows I've started". Does anyone know what I need to change to actually fully change the workflow to this new person?

@Override
    public void notify(final DelegateExecution execution) {
        AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>() {
            @Override
            public Object doWork() throws Exception {
                System.out.println("in SetInitiatorListener");
                ActivitiScriptNode initiatorScriptNode = (ActivitiScriptNode) execution.getVariable("initiator");
        execution.setVariable(UtilModel.WORKFLOW_FINANCE_ORIGINAL_INITIATOR_SCRIPT_NODE, initiatorScriptNode);
            execution.setVariable(UtilModel.WORKFLOW_FINANCE_ORIGINAL_INITIATOR_USERNAME, initiatorScriptNode.getProperties().get("userName"));
            NodeRef initiatorNodeRef = initiatorScriptNode.getNodeRef();
            if (workFlowType.getExpressionText().equals("pcardis")) {
                execution.setVariable(UtilModel.WORKFLOW_FINANCE_PCARD_ORIGINAL_INITIATOR_NODE, initiatorNodeRef);
            } else {
                execution.setVariable(UtilModel.WORKFLOW_FINANCE_JOURNAL_VOUCHER_ORIGINAL_INITIATOR_NODE, initiatorNodeRef);
            }

            String path = templatePath.getExpressionText();
            System.out.println("path:" + path);
            Properties ownerMappings = templateUtil.loadTemplates(path);
            String ownerString = ownerMappings.getProperty(workFlowType.getExpressionText()); // pcardis?
            if (ownerString == null) { // try catagory
                String category = (String) execution.getVariable(UtilModel.WORKFLOW_FINANCE_JOURNAL_VOUCHER_CATEGORY);
                System.out.println("category:" + category);
                if (category != null) {
                    ownerString = ownerMappings.getProperty(category);
                }
            }
            if (ownerString == null) { // else DEFAULT
                ownerString = ownerMappings.getProperty("DEFAULT");
            }
            NodeRef newInitiatorNodeRef = personService.getPerson(ownerString);
            ActivitiScriptNode asn = new ActivitiScriptNode(newInitiatorNodeRef, serviceRegistry);
            execution.setVariable("initiator", asn);               
            execution.setVariable("initiatorhome", asn);      
            //execution.setVariable("originalInitiatorScriptNode", asn);

            return null;
        }
    }, AuthenticationUtil.getAdminUserName());
}

An approach here would be to rewrite the WorkflowPermissionInterceptor, specifically WorkflowPermissionInterceptor#isInitiatorOrAssignee(). This method should return false for the invoked methods that the initiator should not be allowed access.

If this is an Enterprise project, you need to get this type of change signed off from Alfresco Support, otherwise you run the risk of putting the implementation in an unsupported state.

This answer does an address your question, but it addresses your problem. By changing rewriting the interceptor, you can prevent the initiator from being able to modify the workflow tasks (unless they are an admin user or an assignee).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM