Alfresco - approving a task in a workflow

I integrate the applet into the workflow in Alfresco. I created a new button org/alfresco/components/form/controls/workflow/activiti-transitions.ftlhere

  ...

    <button onclick="changePDF(); this.disabled=true; return false;"> Change </button>
    <div id="pdfTexto" style="width:1000px;height:1000px"></div>
        <div class="applet">
            <script type="text/javascript">
                deploy();
            </script>
        </div>
    </#if>

And this change button (via javascript applet) invokes the functionality of the applet, which makes changes to the file of the corresponding workflow. After that I want to put "Approved"how the button does it accept. But I want to do this only after the changes take effect. My applet returns "ok"when the changes are completed (the POST request is completed), after that I want to put "Approved"and redirect to the same page as the "accept" buttons for redirection. In the summary, after "ok", do what the accept button does.

: http://localhost:8080/share/proxy/alfresco/api/upload...

? , ?

: :

 var form = new FormData();
     form.append("prop_wf_reviewOutcome","Approve");
     form.append("prop_bpm_comment","good");
     form.append("prop_transitions","Next");
     var requestTask = new XMLHttpRequest();
         requestTask[Alfresco.util.CSRFPolicy.getHeader()] = Alfresco.util.CSRFPolicy.getToken();
         requestTask.open("POST", "http://localhost:8080/share/proxy/alfresco/api/task/"+ taskidVar+ "/formprocessor" + "?" + Alfresco.util.CSRFPolicy.getParameter() + "=" + encodeURIComponent(Alfresco.util.CSRFPolicy.getToken()));
         requestTask.send(form);

"".

+4
1

, :

package com.someco.alfresco.policy;

import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.ContentServicePolicies;
import org.alfresco.repo.policy.Behaviour;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class DocumentUpdatePolicy implements ContentServicePolicies.OnContentUpdatePolicy {
    private final Log logger = LogFactory.getLog(getClass());

    private PolicyComponent policyComponent;    
    private NodeService nodeService;    

    public void init() {
        this.policyComponent.bindClassBehaviour(
                QName.createQName(NamespaceService.ALFRESCO_URI, "onContentUpdate"),
                ContentModel.TYPE_CONTENT,
                new JavaBehaviour(this, "onContentUpdate", Behaviour.NotificationFrequency.EVERY_EVENT));
    }

    @Override
    public void onContentUpdate(NodeRef nodeRef, boolean newContent) {

        logger.debug("Called on: " + nodeRef);
        if (null == nodeRef || !nodeService.exists(nodeRef)) {
            logger.error("Wrong nodeRef");
            /* This can happen in some circumstances */
            /* Do you want to just ignore it or do something ? You decide */
            return;
        }

        /* Here goes the code to update the task */
    }

    public void setPolicyComponent(final PolicyComponent policyComponent) {
        this.policyComponent = policyComponent;
    }

    public void setNodeService(NodeService nodeService) {
        this.nodeService = nodeService;
    }


}

Spring:

<bean id="onDocumentUpdatePolicy" class="com.someco.alfresco.policy.DocumentUpdatePolicy">
    <property name="policyComponent">
        <ref bean="policyComponent" />
    </property>
    <property name="nodeService">
        <ref bean="NodeService" />
    </property>
</bean>
+5

Source: https://habr.com/ru/post/1628653/


All Articles