<?xml version="1.0" encoding="UTF-8"?>
<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="afwf:workflowTest">
<swimlane name="initiator" />
<swimlane name="validator">
<assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
<pooledactors>#{people.getGroup('GROUP_Administrator')}</pooledactors>
</assignment>
</swimlane>
<start-state name="start">
<task name="bpm:startTask" swimlane="initiator" />
<transition to="IsPending">
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
<variable name="bpm_package" access="read" />
<variable name="statusValue" access="read,write"/>
<expression>
statusValue = bpm_package.children[0].properties["af:status"];
</expression>
</script>
</action>
</transition>
</start-state>
<decision name="IsPending">
<transition to="end" name="NoValidationNeeded">
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
<variable name="statusValue" access="read" />
<expression>
logger.log("No validation needed, because status is set to '" + statusValue + "' need 'Pending'");
</expression>
</script>
</action>
</transition>
<transition to="Validation" name="ValidationNeeded">
<condition>#{statusValue == "Pending"}</condition>
</transition>
</decision>
<task-node name="Validation">
<task name="afwf:validation" swimlane="validator" />
<transition to="IsValid" name="approved"></transition>
<transition to="Correction" name="reject"></transition>
</task-node>
<task-node name="Correction">
<task name="afwf:correction" swimlane="initiator" />
<transition to="IsPending" name="done">
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
<variable name="bpm_package" access="read" />
<variable name="statusValue" access="read,write"/>
<expression>
statusValue = bpm_package.children[0].properties["af:status"];
</expression>
</script>
</action>
</transition>
</task-node>
<node name="IsValid">
<transition to="end">
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
<runas>admin</runas>
<variable name="bpm_package" access="read" />
<expression>
logger.log("Is in IsValid");
if(bpm_package.children[0].properties["af:status"] == "Pending"){
bpm_package.children[0].properties["af:status"] = "In";
logger.log("Status set to 'In'");
}
</expression>
</script>
</action>
</transition>
</node>
<end-state name="end">
<event type="node-enter">
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
<expression>
logger.log("End of the Physical Archive Validation !");
</expression>
</script>
</action>
</event>
</end-state>
</process-definition>
19:46:30,375 ERROR [org.alfresco.web.ui.common.Utils] A system error happened during the operation: org.mozilla.javascript.Undefined cannot be cast to org.alfresco.repo.workflow.jbpm.JBPMNode
java.lang.ClassCastException: org.mozilla.javascript.Undefined cannot be cast to org.alfresco.repo.workflow.jbpm.JBPMNode
at org.alfresco.repo.workflow.jbpm.JBPMEngine.createWorkflowInstance(JBPMEngine.java:2775)
at org.alfresco.repo.workflow.jbpm.JBPMEngine.createWorkflowPath(JBPMEngine.java:2673)
at org.alfresco.repo.workflow.jbpm.JBPMEngine.createWorkflowTask(JBPMEngine.java:2830)
at org.alfresco.repo.workflow.jbpm.JBPMEngine$26.doInJbpm(JBPMEngine.java:1711)
at org.springmodules.workflow.jbpm31.JbpmTemplate$1.doInHibernate(JbpmTemplate.java:87)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:338)
at org.springmodules.workflow.jbpm31.JbpmTemplate.execute(JbpmTemplate.java:80)
at org.alfresco.repo.workflow.jbpm.JBPMEngine.endTask(JBPMEngine.java:1670)
at org.alfresco.repo.workflow.WorkflowServiceImpl.endTask(WorkflowServiceImpl.java:544)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:177)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:40)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:49)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.alfresco.repo.audit.AuditComponentImpl.auditImpl(AuditComponentImpl.java:301)
at org.alfresco.repo.audit.AuditComponentImpl.audit(AuditComponentImpl.java:229)
at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:69)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy51.endTask(Unknown Source)
at org.alfresco.web.bean.workflow.ManageTaskDialog.transition(ManageTaskDialog.java:390)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:132)
at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:61)
at javax.faces.component.UICommand.broadcast(UICommand.java:109)
at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171)
at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
1.- Après la tâche "Correction", j'ai fais une réassignation pour "statusValue",
mais ça ne marche pas car ce retourne toujours vers "Validation" (et donc on ne sort pas de la boucle).
bpm_package.children[0].properties["af:status"]
vaut toujours "Pending".
2.- "bpm_package.children[0].properties["af:status"] = "In";" n'a aucun effet et laisse la valeur
à "Pending". Normal me direz-vous, car je n'ai pas mit "write" en plus de "read", le problème quand je
fais ça j'obtiens une erreur :
org.mozilla.javascript.Undefined cannot be cast to org.alfresco.repo.workflow.jbpm.JBPMNode
me permet de te conseiller d'utiliser plutot la variable de processus équivalente pour le status du process <decision name="CheckAvailability">
<handler class="com.koossery.tuto.decision.VerifyOrderDecisionHandler"></handler>
<transition to="Deliver" name="trDeliver"></transition>
<transition to="GetFromStock" name="trGetFromStock"></transition>
</decision>
package com.koossery.tuto.decision;
import org.apache.log4j.Logger;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.graph.node.DecisionHandler;
import com.koossery.tuto.util.CommonConstants;
/**
* Implementation of a decision handler whose path will be follow by our process.
* Here we use a very simple decision handler which compares two process variables
* in order to decide if there are enough good in the stock..
*
* @author Landry
*/
public class VerifyOrderDecisionHandler implements DecisionHandler {
private Logger logger = Logger.getLogger(VerifyOrderDecisionHandler.class);
private static final long serialVersionUID = -3976908331266033330L;
public String decide(ExecutionContext executionContext) throws Exception {
String result = null;
try {
String nodeName = executionContext.getContextInstance().getProcessInstance().getRootToken().getNode().getName();
logger.info("You are now in node: "+nodeName);
//Get the process variable name goodsOrdered representing the number of goods ordered
Integer goodsOrdered = (Integer)executionContext.
getContextInstance().getVariable(CommonConstants.PROCESS_VARIABLE_GOODSORDERED);
logger.info("Goods ordered "+goodsOrdered.intValue());
//Get the process variable name goodInStock representing the number of goods in Stock
Integer goodsInStock = (Integer)executionContext.
getContextInstance().getVariable(CommonConstants.PROCESS_VARIABLE_GOODSINSTOCK);
logger.info("Goods in stock "+goodsInStock.intValue());
/**
* Here is where decision is taken.
* If the number of goods ordered is superior to the amount in stock then return
* GetFromStock transition name. Otherwise, return Deviser transition name.
*/
if (goodsOrdered.intValue() > goodsInStock.intValue()) {
result = CommonConstants.TRANSITION_TO_GETFROMSTOCK;
}
else {
result = CommonConstants.TRANSITION_TO_DELIVER;
}
} catch (Exception e) {
String message= "Erreur DETAIL TECHNIQUE="+e.getMessage();
logger.error(message);
throw e;
}
return result;
}
}
L'idée d'utiliser "une variable globale tempon" ne semble pas mauvaise (même si je n'ai aucune idée comme mettre ceci en place) le seul problème c'est que le statut de ce fichier sera utilisé pour d'autres processus de workflow et il est important de trouver un moment de modifier le contenu du fichier comme indiqué (càd avec le workflow). Peut-être y a-t-il un moyen détourné d'y arriver ? —————–>>>
Sinon y a-t-il un moyen de débuter le workflow une fois toutes les informations fournies ? (par exemple en cliquant sur le bouton OK de la page des propriétés). ———–>>>
<script>
<variable name="bpm_package" access="read" />
<expression>
if(bpm_package.children[0].properties["af:status"] == "Pending"){
bpm_package.children[0].properties["af:status"] = "In";
bpm_package.children[0].save();
}
</expression>
</script>
14:57:53,515 ERROR [org.alfresco.repo.action.AsynchronousActionExecutionQueueImpl] Failed to execute asynchronous action: Action[ id=9a7858e3-0dc4-4752-8b3b-8e436b43cd0f, node=workspace://SpacesStore/9a7858e3-0dc4-4752-8b3b-8e436b43cd0f ]
org.alfresco.scripts.ScriptException: Failed to execute script 'workspace://SpacesStore/6eec7f56-58c6-4d2e-b68e-c34c32574c03': Access Denied. You do not have the appropriate permissions to perform this operation.
at org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:184)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:177)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:40)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:49)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.alfresco.repo.audit.AuditComponentImpl.auditImpl(AuditComponentImpl.java:301)
at org.alfresco.repo.audit.AuditComponentImpl.audit(AuditComponentImpl.java:229)
at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:69)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy180.executeScript(Unknown Source)
at org.alfresco.repo.action.executer.ScriptActionExecuter.executeImpl(ScriptActionExecuter.java:157)
at org.alfresco.repo.action.executer.ActionExecuterAbstractBase.execute(ActionExecuterAbstractBase.java:127)
at org.alfresco.repo.action.ActionServiceImpl.directActionExecution(ActionServiceImpl.java:592)
at org.alfresco.repo.action.executer.CompositeActionExecuter.executeImpl(CompositeActionExecuter.java:72)
at org.alfresco.repo.action.executer.ActionExecuterAbstractBase.execute(ActionExecuterAbstractBase.java:127)
at org.alfresco.repo.action.ActionServiceImpl.directActionExecution(ActionServiceImpl.java:592)
at org.alfresco.repo.action.ActionServiceImpl.executeActionImpl(ActionServiceImpl.java:529)
at org.alfresco.repo.action.AsynchronousActionExecutionQueueImpl$ActionExecutionWrapper$1$1.execute(AsynchronousActionExecutionQueueImpl.java:369)
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:320)
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:227)
at org.alfresco.repo.action.AsynchronousActionExecutionQueueImpl$ActionExecutionWrapper$1.doWork(AsynchronousActionExecutionQueueImpl.java:378)
at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:437)
at org.alfresco.repo.action.AsynchronousActionExecutionQueueImpl$ActionExecutionWrapper.run(AsynchronousActionExecutionQueueImpl.java:381)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
at java.lang.Thread.run(Thread.java:619)
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.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:53)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.alfresco.repo.audit.AuditComponentImpl.auditImpl(AuditComponentImpl.java:301)
at org.alfresco.repo.audit.AuditComponentImpl.audit(AuditComponentImpl.java:229)
at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:69)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy7.getProperty(Unknown Source)
at org.alfresco.repo.processor.ScriptServiceImpl.getScriptProcessor(ScriptServiceImpl.java:339)
at org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:175)
… 35 more
Caused by: net.sf.acegisecurity.AccessDeniedException: Access is denied.
at net.sf.acegisecurity.vote.AffirmativeBased.decide(AffirmativeBased.java:86)
at net.sf.acegisecurity.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:394)
at net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:77)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:49)
… 46 more
Content from pre 2016 and from language groups that have been closed.
Content is read-only.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.