AnsweredAssumed Answered

Eexample workflow in Wrox Professional Alfresco Book

Question asked by bajwaya on Jun 1, 2011
Latest reply on Mar 18, 2013 by himanshuk4u
Hello,

I attempted to use the example code from the 'Professional Alfresco' book by Wrox Press.  The code is available from http://www.wrox.com/WileyCDA/WroxTitle/Professional-Alfresco-Practical-Solutions-for-Enterprise-Content-Management.productCd-0470571047,descCd-DOWNLOAD.html

I tried from Alfresco Community Edition 3.4 with bundled installer for Windows, and also the Enterprise trial version for Windows.

When I try to deploy the workflow from the workflow console, using the command:

deploy alfresco/extension/workflow/my_review_and_approve_processdefinition.xml

The log file (in tomcat/logs) is updated with this warning:

16:43:11,612 User:admin WARN  [repo.dictionary.DictionaryDAO] Type not found: {http://www.alfresco.org/model/workflow/1.0}mySubmitReviewTask
16:43:11,637 User:admin WARN  [repo.dictionary.DictionaryDAO] Type not found: {http://www.alfresco.org/model/workflow/1.0}mySubmitReviewTask

I undeployed the workflow and restarted the server.  The error logged is:

org.alfresco.error.AlfrescoRuntimeException: 05010003 Workflow deployment failed
   at org.alfresco.repo.workflow.WorkflowDeployer.init(WorkflowDeployer.java:330)
   at org.alfresco.repo.workflow.WorkflowDeployer$1.doWork(WorkflowDeployer.java:437)
   at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:508)
   at org.alfresco.repo.workflow.WorkflowDeployer.onBootstrap(WorkflowDeployer.java:433)
   at org.springframework.extensions.surf.util.AbstractLifecycleBean.onApplicationEvent(AbstractLifecycleBean.java:56)
   at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97)
   at org.alfresco.repo.management.SafeApplicationEventMulticaster.multicastEvent(SafeApplicationEventMulticaster.java:78)
   at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:294)
   at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:858)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:419)
   at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:261)
   at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:192)
   at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
   at org.alfresco.web.app.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:63)
   at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3972)
   at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467)
   at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
   at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
   at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
   at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:637)
   at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:563)
   at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:498)
   at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
   at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
   at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
   at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
   at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
   at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
   at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
   at org.apache.catalina.core.StandardService.start(StandardService.java:519)
   at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
   at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
   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.catalina.startup.Bootstrap.start(Bootstrap.java:289)
   at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: 05010002 Could not import bootstrap model alfresco/extension/workflow/myReviewAndApproveModel.xml
   at org.alfresco.repo.dictionary.DictionaryBootstrap.onDictionaryInit(DictionaryBootstrap.java:158)
   at org.alfresco.repo.dictionary.DictionaryBootstrap.bootstrap(DictionaryBootstrap.java:105)
   at org.alfresco.repo.workflow.WorkflowDeployer.init(WorkflowDeployer.java:260)
   … 37 more
Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: 05010001 Failed to compile model wf:myReviewAndApproveModel
   at org.alfresco.repo.dictionary.CompiledModel.<init>(CompiledModel.java:106)
   at org.alfresco.repo.dictionary.M2Model.compile(M2Model.java:128)
   at org.alfresco.repo.dictionary.DictionaryDAOImpl.putModel(DictionaryDAOImpl.java:270)
   at org.alfresco.repo.dictionary.DictionaryBootstrap.onDictionaryInit(DictionaryBootstrap.java:154)
   … 39 more
Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: 05010000 Cannot define class wf:mySubmitReviewTask as namespace http://www.alfresco.org/model/workflow/1.0 is not defined by model wf:myReviewAndApproveModel
   at org.alfresco.repo.dictionary.M2ClassDefinition.<init>(M2ClassDefinition.java:88)
   at org.alfresco.repo.dictionary.M2TypeDefinition.<init>(M2TypeDefinition.java:41)
   at org.alfresco.repo.dictionary.CompiledModel.constructDefinitions(CompiledModel.java:147)
   at org.alfresco.repo.dictionary.CompiledModel.<init>(CompiledModel.java:88)
   … 42 more

The code from the example was installed as follows.

alfresco/extension/myWorkflowBootstrap-context.xml :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC
'-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>

   <bean id="myworkflows.workflowBootstrap" parent="workflowDeployer">
      <property name="models">
         <list>
            <!– Task Model associated with above process definition –>
            <value>alfresco/extension/workflow/myReviewAndApproveModel.xml</value>
         </list>
      </property>
      <property name="workflowDefinitions">
         <list>
            <props>
               <prop key="engineId">jbpm</prop>
               <prop key="location">
                  alfresco/extension/workflow/my_review_and_approve_processdefinition.xml
               </prop>
               <prop key="mimetype">text/xml</prop>
               <prop key="redeploy">true</prop>
            </props>
         </list>
      </property>
      <property name="labels">
         <list>
            <!– Resource Bundle associated with above process definition –>
            <value>alfresco/extension/messages/my_review_and_approve_messages</value>
         </list>
      </property>
   </bean>
</beans>

alfresco/extension/workflow/my_review_and_approve_processdefinition.xml :

<?xml version="1.0" encoding="UTF-8"?>
<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="wf:myReviewAndApprove">

   <swimlane name="initiator" />

   <swimlane name="reviewer">
      <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
         <actor>#{bpm_assignee}</actor>
      </assignment>
   </swimlane>

   <start-state name="start">
      <task name="wf:mySubmitReviewTask" swimlane="initiator" />
      <transition name="" to="review" />
   </start-state>

   <task-node name="review">
      <task name="wf:myReviewTask" swimlane="reviewer" />
      <transition name="approve" to="approve" />
      <transition name="reject" to="reject" />
   </task-node>

   <node name="approve">
      <event type="node-enter">
         <script>
            <variable name="reviewResult" access="write" />
            <expression>
               reviewResult = "approved";
            </expression>
         </script>
      </event>
      <transition to="completed" />
   </node>

   <node name="reject">
      <event type="node-enter">
         <script>
            <variable name="reviewResult" access="write" />
            <expression>
               reviewResult = "rejected";
            </expression>
         </script>
      </event>
      <transition to="completed" />
   </node>

   <task-node name="completed">
      <event type="node-enter">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               var mail = actions.create("mail");
               mail.parameters.to =
                  initiator.properties["cm:email"];
               mail.parameters.subject =
                  "Review Task " + bpm_workflowDescription;
               mail.parameters.from
               =bpm_assignee.properties["cm:email"];
               mail.parameters.text=
                  "The article has been " + reviewResult + ".";
               mail.execute(bpm_package);
            </script>
         </action>
      </event>
      <task name="wf:myCompleteReviewTask" swimlane="initiator" />
      <transition name="" to="end" />
   </task-node>

   <end-state name="end" />

</process-definition>

alfresco/extension/workflow/myReviewAndApproveModel.xml :

<?xml version="1.0" encoding="UTF-8"?>

<model name="wf:myReviewAndApproveModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <description>Example Review And Approve Task Model</description>
   <author>Alfresco</author>
   <version>1.0</version>

   <imports>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" />
      <import uri="http://www.alfresco.org/model/bpm/1.0" prefix="bpm" />
      <import uri="http://www.alfresco.org/model/workflow/1.0" prefix="wf" />
   </imports>

   <!– NOTE:  I also tried removing the last import above and uses namespaces as shown in http://wiki.alfresco.com/wiki/WorkflowAdministration#Step_2:_Create_the_Task_Model , this resulted in error that the namespace is already defined –>

   <types>

      <type name="wf:mySubmitReviewTask">
         <parent>bpm:startTask</parent>
         <mandatory-aspects>
            <aspect>bpm:assignee</aspect>
         </mandatory-aspects>
      </type>

      <type name="wf:myReviewTask">
         <parent>bpm:workflowTask</parent>
         <overrides>
            <property name="bpm:packageItemActionGroup">
               <default>edit_package_item_actions</default>
            </property>
         </overrides>
      </type>

      <type name="wf:myCompleteReviewTask">
         <parent>bpm:workflowTask</parent>
         <mandatory-aspects>
            <aspect>bpm:assignee</aspect>
         </mandatory-aspects>
      </type>

   </types>

</model>

alfresco/extension/messages/my_review_and_approve_messages.properties :

# Review & Approve Workflow
wf_myReviewAndApprove.workflow.title = My Review & Approve
wf_myReviewAndApprove.workflow.description = Review & approval of an article

# Review & Approve Task Definitions
wf_myReviewAndApproveModel.title = My Review And Approve Model
wf_myReviewAndApproveModel.description = Model for Review And Approve workflow.
wf_myReviewAndApproveModel.type.wf_mySubmitReviewTask.title=Submit Article
wf_myReviewAndApproveModel.type.wf_mySubmitReviewTask.description=Submit article for review.
wf_myReviewAndApproveModel.type.wf_myReviewTask.title=Review Article
wf_myReviewAndApproveModel.type.wf_myReviewTask.description=Review article and Approve or Reject it.
wf_myReviewAndApproveModel.type.wf_myCompleteReviewTask.title=Review Completed
wf_myReviewAndApproveModel.type.wf_myCompleteReviewTask.description=The review process is complete.

# Review & Approve Process Definitions
wf_myReviewAndApprove.node.start.title = Start
wf_myReviewAndApprove.node.start.description = Start
wf_myReviewAndApprove.node.review.title=Review
wf_myReviewAndApprove.node.review.description=Review
wf_myReviewAndApprove.node.review.transition.reject.title=Reject
wf_myReviewAndApprove.node.review.transition.reject.description=Reject
wf_myReviewAndApprove.node.review.transition.approve.title=Approve
wf_myReviewAndApprove.node.review.transition.approve.description=Approve
wf_myReviewAndApprove.node.rejected.title=Rejected
wf_myReviewAndApprove.node.rejected.description=Rejected
wf_myReviewAndApprove.node.approved.title=Approved
wf_myReviewAndApprove.node.approved.description=Approved
wf_myReviewAndApprove.node.completed.title=Completed
wf_myReviewAndApprove.node.completed.description=Completed
wf_myReviewAndApprove.task.wf_myCompletedTask.title=Completed
wf_myReviewAndApprove.task.wf_myCompletedTask.description=Completed
wf_myReviewAndApprove.node.end.title=End
wf_myReviewAndApprove.node.end.description=End

Thank you.

Outcomes