AnsweredAssumed Answered

Problem with move action in an advanced workflow

Question asked by kraph on Mar 29, 2007
Latest reply on Mar 24, 2010 by hsohaib
Hello,
I made an advanced workflow which is similar to the "review pooled workflow". My workflow allow a group of person to approve or reject a document like in the review pooled workflow  and if the document is approved, the document is moved to a space.

I have some problem with the move action. Indeed, if the person who moves the document to the space doesn't have coordinator rights on the spaces (source and destination), i get a security error.
Why is the right Collaborator not  enough ?
I also try to do the move action automaticaly, like in a previous topic, but the action does nothing.
Can anyone help me.

I'll give you the workflow definition and the workflow model.

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

<process-definition
  xmlns="urn:jbpm.org:jpdl-3.1"  name="cwf:publicationWorkflow">
   <swimlane name="initiator"></swimlane>
   <start-state name="start">
      <task name="cwf:envoiRedactionTask" swimlane="initiator">
      </task>
      <transition name="debutRedaction" to="redaction"></transition>
   </start-state>

   <task-node name="redaction">
      <task name="cwf:redactionTask" swimlane="initiator">
         <event type="task-create">
            <script>
               if (bpm_workflowDescription != void) taskInstance.description = bpm_workflowDescription;
               if (bpm_workflowDueDate != void) taskInstance.dueDate = bpm_workflowDueDate;
               if (bpm_workflowPriority != void) taskInstance.priority = bpm_workflowPriority;
            </script>
         </event>
      </task>
      <transition name="demandeApprobation" to="approbation">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
           <script>
               for (var i = 0; i &lt; bpm_package.children.length; i++)
               {
                   bpm_package.children[i].properties["casw:etatdocument"] = 0;
                   bpm_package.children[i].properties["casw:statutdocument"] = "En attente approbation";
                   bpm_package.children[i].properties["casw:commentaires"] = " ";
                   bpm_package.children[i].save();
               }

               var templatemodel=companyhome.childByNamePath('notify_approbation_doc.ftl');
               var txtMail = bpm_package.children[0].processTemplate(templatemodel);
               var mail = actions.create("mail");
               mail.parameters.to = "myaddress";
               mail.parameters.subject = "Demande de validation du document " + bpm_workflowDescription;
               mail.parameters.from = initiator.properties["cm:email"];
               mail.parameters.text = txtMail;
               mail.execute(bpm_package);
           </script>
         </action>
      </transition>
   </task-node>
  
   <swimlane name="approbateur">
        <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
            <pooledactors>#{cwf_groupApprobateur}</pooledactors>
        </assignment>   
    </swimlane>

   <task-node name="approbation">
      <task name="cwf:approbationTask" swimlane="approbateur">
         <event type="task-create">
            <script>
               if (bpm_workflowDescription != void) taskInstance.description = bpm_workflowDescription;
               if (bpm_workflowDueDate != void) taskInstance.dueDate = bpm_workflowDueDate;
               if (bpm_workflowPriority != void) taskInstance.priority = bpm_workflowPriority;
            </script>
         </event>
         <event type="task-end">
            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
               <script>
                  <variable name="bpm_assignee" access="write"/>
                  <expression>
                     if (taskInstance.actorId != null)
                        people.getPerson(taskInstance.actorId);
                     else
                        person;
                  </expression>
               </script>
            </action>
         </event>
      </task>
      <transition name="approuver" to="auto">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
           <script>
              for (var i = 0; i &lt; bpm_package.children.length; i++)
              {
                  bpm_package.children[i].properties["casw:etatdocument"] = 1;
                  bpm_package.children[i].properties["casw:statutdocument"] = "En attente publication";
                  bpm_package.children[i].properties["casw:commentaires"] = cwf_commentaire;
                  bpm_package.children[i].save();
              }
              if (cwf_notifyMe)
              {
                 var templatemodel=companyhome.childByNamePath('notify_approbation_doc.ftl');
                 var txtMail = bpm_package.children[0].processTemplate(templatemodel);

                 var mail = actions.create("mail");
                 mail.parameters.to = initiator.properties["cm:email"];
                 mail.parameters.subject = "Approbation du document " + bpm_workflowDescription;
                 mail.parameters.from = bpm_assignee.properties["cm:email"];
                 mail.parameters.text = txtMail;
                 mail.execute(bpm_package);
              }
           </script>
         </action>
      </transition>
      <transition name="rejeter" to="redaction">
          <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
           <script>
               for (var i = 0; i &lt; bpm_package.children.length; i++)
               {
                   bpm_package.children[i].properties["casw:etatdocument"] = -1;
                   bpm_package.children[i].properties["casw:commentaires"] = cwf_commentaire;
                   bpm_package.children[i].properties["casw:statutdocument"] = "En cours de redaction";
                   bpm_package.children[i].save();
               }

              if (cwf_notifyMe)
              {
                 var templatemodel=companyhome.childByNamePath('notify_approbation_doc.ftl');
                 var txtMail = bpm_package.children[0].processTemplate(templatemodel);

                 var mail = actions.create("mail");
                 mail.parameters.to = initiator.properties["cm:email"];
                 mail.parameters.subject = "Approbation du document " + bpm_workflowDescription;
                 mail.parameters.from = bpm_assignee.properties["cm:email"];
                 mail.parameters.text = txtMail;
                 mail.execute(bpm_package);
              }
           </script>
         </action>
      </transition>
   </task-node>

   <node name="auto">
      <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
              <script>
              var dest = cwf_publicationSpace;
              logger.log("Dossier pub :" + dest.name);
               for (var i = 0; i &lt; bpm_package.children.length; i++)
               {
                   bpm_package.children[i].properties["casw:etatdocument"] = 2;
                   bpm_package.children[i].properties["casw:commentaires"] = " ";
                   bpm_package.children[i].properties["casw:statutdocument"] = "Publie";
                   bpm_package.children[i].save();
                   logger.log("Deplacement0 :" + bpm_package.children[i].displayPath );
                   bpm_package.children[i].move(dest);
                   logger.log("Deplacement1 :" + bpm_package.children[i].displayPath );
               }
              
               executionContext.leaveNode();
              </script>
      </action>
      <transition name="" to="end"/>
   </node>
   <end-state name="end"></end-state>
</process-definition>

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

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

    <description>Publication Process Model</description>
    <author>RKI</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/content/1.0" prefix="cm"/>
    <import uri="http://www.alfresco.org/model/bpm/1.0" prefix="bpm"/>
    <import uri="http://www.alfresco.org/model/user/1.0" prefix="usr"/>
  </imports>

  <namespaces>
    <namespace uri="publicationWorkflow.workflow.model" prefix="cwf"/>
  </namespaces>
 
  <types>
    <type name="cwf:envoiRedactionTask">
       <parent>bpm:startTask</parent>
       <properties>
           <property name="cwf:notifyMe">
               <type>d:boolean</type>
               <default>false</default>
           </property>
       </properties>
       <mandatory-aspects>
           <aspect>cwf:groupApprobateur</aspect>
           <aspect>cwf:groupLecteurClient</aspect>
           <aspect>cwf:publicationSpace</aspect>
       </mandatory-aspects>
    </type>
   
    <type name="cwf:redactionTask">
       <parent>bpm:workflowTask</parent>
       <overrides>
           <property name="bpm:packageItemActionGroup">
               <default>edit_package_item_actions</default>
           </property>
       </overrides>
    </type>

    <type name="cwf:approbationTask">
       <parent>bpm:workflowTask</parent>
       <properties>
           <property name="cwf:commentaire">
               <type>d:text</type>
               <default> </default>
           </property>
       </properties>
       <overrides>
           <property name="bpm:packageItemActionGroup">
               <default>edit_package_item_actions</default>
           </property>
       </overrides>
    </type>
  </types>

  <aspects>
      <aspect name="cwf:groupApprobateur">
          <associations>
              <association name="cwf:groupApprobateur">
                  <title>Groupe des approbateurs</title>             
                  <source>
                      <mandatory>false</mandatory>
                      <many>false</many>
                  </source>
                  <target>
                      <!– TODO: Refactor when group is pulled into content model –>
                      <class>usr:authorityContainer</class>
                      <mandatory>true</mandatory>
                      <many>false</many>
                  </target>
              </association>
          </associations>
      </aspect>
     
      <aspect name="cwf:groupLecteurClient">
          <associations>
              <association name="cwf:groupLecteurClient">
                  <title>Groupe des approbateurs</title>             
                  <source>
                      <mandatory>false</mandatory>
                      <many>false</many>
                  </source>
                  <target>
                      <!– TODO: Refactor when group is pulled into content model –>
                      <class>usr:authorityContainer</class>
                      <mandatory>true</mandatory>
                      <many>false</many>
                  </target>
              </association>
          </associations>
      </aspect>

      <aspect name="cwf:publicationSpace">
          <associations>
              <association name="cwf:publicationSpace">
                  <title>Espace de publication</title>
                  <source>
                      <mandatory>false</mandatory>
                      <many>false</many>
                  </source>
                  <target>
                      <class>cm:folder</class>
                      <mandatory>true</mandatory>
                      <many>false</many>
                  </target>
              </association>
          </associations>
      </aspect>
  </aspects>

</model>

Thank you by advance
Kraph

Outcomes