AnsweredAssumed Answered

Some problems in Advanced Workflow

Question asked by richard_tsai on Apr 25, 2007
Latest reply on Aug 13, 2007 by jdbrown
Hi! there,
   My users want a workflow like
(document inbound)=>reviewer(assign assignees)=>cosign==>closed.
So, I created a workflow template like parallelreview and a javascript to invoke the workflow. The workflow basically works, but I still have some problems as follows… (( Your help is appreciated! Thanks.. ))
1. Where can I see the whole workflow status?
2. Since I use inbound event to trigger my javascript. I don't hope a document has multiple workflows simutaneously. So, How can I know if there is a workflow associated to this document?
3. How can I set daily notification, if some tasks are overdue?
4. When user approve/reject in cosign, there's an AccessDeny exception
16:30:59,941 ERROR [ui.common.Utils] A system error happened during the operation: Failed to signal transition 'Submit To Reviewers' from workflow task 'jbpm$63'
org.alfresco.service.cmr.workflow.WorkflowException: Failed to signal transition
'Submit To Reviewers' from workflow task 'jbpm$63'

        at org.alfresco.repo.workflow.jbpm.JBPMEngine.endTask(JBPMEngine.java:10
64)
        at org.alfresco.repo.workflow.WorkflowServiceImpl.endTask(WorkflowServic
eImpl.java:347)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflecti
on(AopUtils.java:335)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJo
inpoint(ReflectiveMethodInvocation.java:181)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
ReflectiveMethodInvocation.java:148)
        at org.springframework.aop.support.DelegatingIntroductionInterceptor.inv
oke(DelegatingIntroductionInterceptor.java:116)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
ReflectiveMethodInvocation.java:170)
        at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterc
eptor.invoke(AlwaysProceedMethodInterceptor.java:40)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
ReflectiveMethodInvocation.java:170)
        at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethod
Interceptor.invoke(ExceptionTranslatorMethodInterceptor.java:49)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
ReflectiveMethodInvocation.java:170)
        at org.alfresco.repo.audit.AuditComponentImpl.auditImpl(AuditComponentIm
pl.java:219)
        at org.alfresco.repo.audit.AuditComponentImpl.audit(AuditComponentImpl.j
ava:165)
        at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInte
rceptor.java:69)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
ReflectiveMethodInvocation.java:170)
        at org.springframework.transaction.interceptor.TransactionInterceptor.in
voke(TransactionInterceptor.java:96)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
ReflectiveMethodInvocation.java:170)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynami
cAopProxy.java:176)
        at $Proxy22.endTask(Unknown Source)
        at org.alfresco.web.bean.workflow.ManageTaskDialog.transition(ManageTask
Dialog.java:389)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java
:129)
        at org.apache.myfaces.application.ActionListenerImpl.processAction(Actio
nListenerImpl.java:63)
        at javax.faces.component.UICommand.broadcast(UICommand.java:106)
        at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:9
0)
        at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1
64)
        at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(Lifecycl
eImpl.java:316)
        at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java
:86)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:105)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
        at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(Authentica
tionFilter.java:81)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:202)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:178)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:126)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:105)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:107)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:148)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:869)
        at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p
rocessConnection(Http11BaseProtocol.java:664)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
int.java:527)
        at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFol
lowerWorkerThread.java:80)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:684)
        at java.lang.Thread.run(Thread.java:595)
Caused by: org.jbpm.graph.def.DelegationException
        at org.jbpm.graph.def.GraphElement.raiseException(GraphElement.java:352)

        at org.jbpm.graph.def.GraphElement$$FastClassByCGLIB$$7a7d6aa6.invoke(<g
enerated>)
        at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:163)
        at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializ
er.java:161)
        at org.jbpm.graph.def.ProcessDefinition$$EnhancerByCGLIB$$5b20137f.raise
Exception(<generated>)
        at org.jbpm.graph.def.GraphElement.raiseException(GraphElement.java:346)

        at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:249)
        at org.jbpm.graph.def.GraphElement.executeActions(GraphElement.java:212)

        at org.jbpm.graph.def.GraphElement.fireAndPropagateEvent(GraphElement.ja
va:182)
        at org.jbpm.graph.def.GraphElement.fireEvent(GraphElement.java:166)
        at org.jbpm.graph.def.Node.enter(Node.java:301)
        at org.jbpm.graph.def.Node$$FastClassByCGLIB$$d187eeda.invoke(<generated
>)
        at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:163)
        at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializ
er.java:161)
        at org.jbpm.graph.def.Node$$EnhancerByCGLIB$$f867670f.enter(<generated>)

        at org.jbpm.graph.def.Transition.take(Transition.java:119)
        at org.jbpm.graph.def.Node.leave(Node.java:383)
        at org.jbpm.graph.node.TaskNode.leave(TaskNode.java:198)
        at org.jbpm.graph.node.TaskNode$$FastClassByCGLIB$$923668a4.invoke(<gene
rated>)
        at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:163)
        at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializ
er.java:161)
        at org.jbpm.graph.node.TaskNode$$EnhancerByCGLIB$$32ad5d59.leave(<genera
ted>)
        at org.jbpm.graph.exe.Token.signal(Token.java:174)
        at org.jbpm.graph.exe.Token.signal(Token.java:145)
        at org.jbpm.graph.exe.Token$$FastClassByCGLIB$$74df1c6e.invoke(<generate
d>)
        at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:163)
        at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializ
er.java:161)
        at org.jbpm.graph.exe.Token$$EnhancerByCGLIB$$a4f60da3.signal(<generated
>)
        at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:444)
        at org.alfresco.repo.workflow.jbpm.WorkflowTaskInstance.end(WorkflowTask
Instance.java:126)
        at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:383)
        at org.alfresco.repo.workflow.jbpm.JBPMEngine$19.doInJbpm(JBPMEngine.jav
a:1049)
        at org.springmodules.workflow.jbpm31.JbpmTemplate$1.doInHibernate(JbpmTe
mplate.java:87)
        at org.springframework.orm.hibernate3.HibernateTemplate.execute(Hibernat
eTemplate.java:365)
        at org.springframework.orm.hibernate3.HibernateTemplate.execute(Hibernat
eTemplate.java:333)
        at org.springmodules.workflow.jbpm31.JbpmTemplate.execute(JbpmTemplate.j
ava:80)
        at org.alfresco.repo.workflow.jbpm.JBPMEngine.endTask(JBPMEngine.java:10
17)
        … 52 more
Caused by: org.alfresco.repo.security.permissions.AccessDeniedException: Access
Denied.  You do not have the appropriate permissions to perform this operation.

        at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethod
Interceptor.invoke(ExceptionTranslatorMethodInterceptor.java:53)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
ReflectiveMethodInvocation.java:170)
        at org.alfresco.repo.audit.AuditComponentImpl.audit(AuditComponentImpl.j
ava:204)
        at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInte
rceptor.java:69)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
ReflectiveMethodInvocation.java:170)
        at org.springframework.transaction.interceptor.TransactionInterceptor.in
voke(TransactionInterceptor.java:96)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
ReflectiveMethodInvocation.java:170)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynami
cAopProxy.java:176)
        at $Proxy12.getProperties(Unknown Source)
        at org.alfresco.repo.jscript.Node.getProperties(Node.java:441)
        at org.alfresco.repo.jscript.Node.toString(Node.java:1615)
        at java.lang.String.valueOf(String.java:2615)
        at java.lang.StringBuffer.append(StringBuffer.java:220)
        at java.util.AbstractMap.toString(AbstractMap.java:598)
        at java.lang.String.valueOf(String.java:2615)
        at java.lang.StringBuffer.append(StringBuffer.java:220)
        at org.jbpm.graph.action.Script.eval(Script.java:121)
        at org.jbpm.graph.action.Script.eval(Script.java:72)
        at org.jbpm.graph.action.Script.execute(Script.java:61)
        at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:235)
        … 82 more
Caused by: net.sf.acegisecurity.AccessDeniedException: Access is denied.
        at net.sf.acegisecurity.vote.AffirmativeBased.decide(AffirmativeBased.ja
va:86)
        at net.sf.acegisecurity.intercept.AbstractSecurityInterceptor.beforeInvo
cation(AbstractSecurityInterceptor.java:394)
        at net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInter
ceptor.invoke(MethodSecurityInterceptor.java:77)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
ReflectiveMethodInvocation.java:170)
        at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethod
Interceptor.invoke(ExceptionTranslatorMethodInterceptor.java:49)
        … 101 more

My workflow template: mpmdocflow_processdefinition.xml
<?xml version="1.0" encoding="UTF-8"?>

<process-definition
  xmlns="urn:jbpm.org:jpdl-3.1"  name="wf:mpmdocflow">
    <swimlane name="initiator"></swimlane>
    <swimlane name="reviewer">
        <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
            <actor>#{bpm_assignee}</actor>
        </assignment>   
    </swimlane>
<!–
    <start-state name="start">
       <task name="wf:submitParallelReviewTask" swimlane="reviewer" />
       <transition name="submit" to="startreview"></transition>
    </start-state>
–>   
    <start-state name="start">
       <task name="wf:submitReviewTask" swimlane="initiator" />
       <transition name="" to="reviewertask"></transition>
    </start-state>

   <task-node name="reviewertask">
      <task name="wf:submitParallelReviewTask" swimlane="reviewer"></task>
      <transition name="Submit To Reviewers" to="startreview"></transition>
   </task-node>
    <node name="startreview">
        <action class="org.alfresco.repo.workflow.jbpm.ForEachFork">
            <foreach>#{bpm_assignees}</foreach>
            <var>reviewer</var>
        </action>
        <event type="node-enter">
            <script>
                <variable name="wf_approveCount" access="write" />
                <expression>
                    wf_approveCount = 0;
                </expression>
            </script>
        </event>
        <transition name="review" to="review" />
    </node>

    <task-node name="review">
        <task name="wf:reviewTask">
            <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
               <actor>#{reviewer}</actor>
            </assignment>
        </task>
        <transition name="reject" to="endreview" />
        <transition name="approve" to="endreview">
            <script>
                <variable name="wf_approveCount" access="read,write" />
                <expression>
                    wf_approveCount = wf_approveCount +1;
                 </expression>
            </script>
        </transition>
    </task-node>

    <join name="endreview">
        <transition to="isapproved" />
    </join>

    <decision name="isapproved">
        <event type="node-enter">
           <script>
              <variable name="wf_reviewerCount" access="write"/>
              <variable name="wf_requiredPercent" access="write"/>
              <variable name="wf_actualPercent" access="write"/>
              <expression>
                  wf_requiredPercent = wf_requiredApprovePercent;
                  wf_reviewerCount = bpm_assignees.size();
                  wf_actualPercent = ((wf_approveCount * 100) / wf_reviewerCount);
              </expression>
           </script>
        </event>
        <transition name="reject" to="rejected" />
        <transition name="approve" to="approved">
            <condition>#{wf_actualPercent >= wf_requiredApprovePercent}</condition>
        </transition>
    </decision>
              
    <task-node name="rejected">
        <task name="wf:rejectedParallelTask" swimlane="initiator" />
        <transition to="end" />
    </task-node>

    <task-node name="approved">
        <task name="wf:approvedParallelTask" swimlane="initiator" />
        <transition to="end" />
    </task-node>

    <end-state name="end"/>


</process-definition>
My javascript which is invoked in document in bound event
if (document.isDocument) {
    var workflow = actions.create("start-workflow");
    workflow.parameters.workflowName = "jbpm$wf:mpmdocflow";
    workflow.parameters["bpm:workflowDescription"] = document.name;
    if (document.displayPath.startsWith("/Company Home/MPM/EE")) {
        //logger.log("EE case");
        workflow.parameters["bpm:initiator"] = people.getPerson("richard_tsai");
        workflow.parameters["bpm:assignee"] = people.getPerson("richard_tsai");
    } else if (document.displayPath.startsWith("/Company Home/MPM/ME parts")) {
        //logger.log("ME case");
        workflow.parameters["bpm:initiator"] = people.getPerson("richard_tsai");
        workflow.parameters["bpm:assignee"] = people.getPerson("richard_tsai");
    }
    var futureDate = new Date();
    futureDate.setDate(futureDate.getDate() + 7);
    workflow.parameters["bpm:workflowDueDate"] = futureDate;
    workflow.execute(document);
}

Outcomes