Problem with permissions and create folder in workflow

cancel
Showing results for 
Search instead for 
Did you mean: 
magarcia_sm
Active Member II

Problem with permissions and create folder in workflow

Hi there

We have problems to set permissions on the folders you are working in a workflow.
We give permission in the first script run, but when we run the workflow tells us that we have no permissions.
Any idea what could be the problem?
And by the way, he wanted to know if the way to create the folder is correct.

Thanks a lot in advance!!

The code is this:


<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <process id="hula" name="HULA" isExecutable="true">
    <exclusiveGateway id="exclusivegateway1" name="Exclusive Gateway"></exclusiveGateway>
    <exclusiveGateway id="exclusivegateway2" name="Exclusive Gateway"></exclusiveGateway>
    <endEvent id="endevent1" name="End"></endEvent>
    <serviceTask id="inicio" name="Inicio - Mover al espacio del Jefe correspondiente" activiti:class="org.alfresco.repo.workflow.activiti.script.AlfrescoScriptDelegate">
      <extensionElements>
        <activiti:field name="script">
          <activiti:string><![CDATA[var rechazadasUserHome = null;
if(userhome.childByNamePath("Rechazadas") == null){
   rechazadasUserHome = userhome.createFolder("Rechazadas");
} else {
   rechazadasUserHome = userhome.childByNamePath("Rechazadas");
}
rechazadasUserHome.setPermission("Write", "GROUP_GERENTES");

var jefCar = companyhome.childByNamePath("HULA/Jefes/Jef_Cardiologia");
jefCar.setPermission("Write", "GROUP_FAC_CARDIOLOGIA");

var pendientesGerencia = companyhome.childByNamePath("HULA/Gerencia/Pendientes");
pendientesGerencia.setPermission("Write", "GROUP_JEFES");

var test = bpm_package;
var doc = test.children[0];
var departamento = doc.properties["hula:departamento"];
var myNode = companyhome.childByNamePath("HULA/Jefes/Jef_"+departamento);
doc.properties["hula:estado"]="Revision_Jefe_servicio";
doc.save();
doc.move(myNode);]]></activiti:string>
        </activiti:field>
      </extensionElements>
    </serviceTask>
    <sequenceFlow id="flow2" sourceRef="inicio" targetRef="revision_jefe"></sequenceFlow>
    <userTask id="revision_jefe" name="Revision Primer Nivel" activiti:assignee="jefe" activiti:formKey="wf:activitiReviewTask">
      <extensionElements>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[var test = bpm_package;
var doc = test.children[0];
if(task.getVariableLocal('wf_reviewOutcome') == 'Approve') {
   doc.properties["hula:estado"]="Revision_Gerencia";
       doc.save();
} else {
   doc.properties["hula:estado"]="Cancelacion_Jefe_Servicio";
       doc.save();
}
execution.setVariable('wf_reviewOutcome', doc.properties["hula:estado"]);]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <sequenceFlow id="flow3" sourceRef="revision_jefe" targetRef="exclusivegateway1"></sequenceFlow>
    <serviceTask id="mover_departamento_gerentes" name="Mover a Gerencia" activiti:class="org.alfresco.repo.workflow.activiti.script.AlfrescoScriptDelegate">
      <extensionElements>
        <activiti:field name="script">
          <activiti:string><![CDATA[var test = bpm_package;
var doc = test.children[0];
var myNode = companyhome.childByNamePath("HULA/Gerencia/Pendientes");
doc.properties["hula:estado"]="Revision_Gerencia";
doc.save();
doc.move(myNode);]]></activiti:string>
        </activiti:field>
      </extensionElements>
    </serviceTask>
    <sequenceFlow id="flow4" sourceRef="exclusivegateway1" targetRef="mover_departamento_gerentes">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${wf_reviewOutcome == "Revision_Gerencia"}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow5" sourceRef="exclusivegateway1" targetRef="mover_user_home">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${wf_reviewOutcome == "Cancelacion_Jefe_Servicio"}]]></conditionExpression>
    </sequenceFlow>
    <userTask id="revision_gerente" name="Revision Segundo Nivel" activiti:assignee="gerente" activiti:formKey="wf:activitiReviewTask">
      <extensionElements>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[var test = bpm_package;
                     var doc = test.children[0];
                       if(task.getVariableLocal('wf_reviewOutcome') == 'Approve') {
                        doc.properties["hula:estado"]="Aprobado";
                         doc.save();
                       } else {
                        doc.properties["hula:estado"]="Cancelado";
                         doc.save();
                       }
                   execution.setVariable('wf_reviewOutcome', doc.properties["hula:estado"]);]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <sequenceFlow id="flow6" sourceRef="mover_departamento_gerentes" targetRef="revision_gerente"></sequenceFlow>
    <sequenceFlow id="flow7" sourceRef="revision_gerente" targetRef="exclusivegateway2"></sequenceFlow>
    <sequenceFlow id="flow8" sourceRef="exclusivegateway2" targetRef="mover_autorizadas_gerencia">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${wf_reviewOutcome == "Aprobado"}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow9" sourceRef="exclusivegateway2" targetRef="mover_user_home">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${wf_reviewOutcome == "Cancelado"}]]></conditionExpression>
    </sequenceFlow>
    <serviceTask id="mover_user_home" name="Mover a User Home" activiti:class="org.alfresco.repo.workflow.activiti.script.AlfrescoScriptDelegate">
      <extensionElements>
        <activiti:field name="script">
          <activiti:string><![CDATA[var test = bpm_package;
var doc = test.children[0];
var departamento = doc.properties["hula:departamento"];
var myNode = companyhome.childByNamePath("HULA/Facultativos/Fac_"+departamento);
doc.properties["hula:estado"]="Inicio";
doc.save();
doc.move(myNode);]]></activiti:string>
        </activiti:field>
      </extensionElements>
    </serviceTask>
    <serviceTask id="mover_autorizadas_gerencia" name="Mover a autorizadas Gerencia" activiti:class="org.alfresco.repo.workflow.activiti.script.AlfrescoScriptDelegate">
      <extensionElements>
        <activiti:field name="script">
          <activiti:string><![CDATA[var test = bpm_package;
var doc = test.children[0];
var myNode = companyhome.childByNamePath("HULA/Gerencia/Aprobados");
doc.properties["hula:estado"]="Aprobado";
doc.save();
doc.move(myNode);]]></activiti:string>
        </activiti:field>
      </extensionElements>
    </serviceTask>
    <sequenceFlow id="flow10" sourceRef="mover_autorizadas_gerencia" targetRef="endevent1"></sequenceFlow>
    <exclusiveGateway id="exclusivegateway3" name="Exclusive Gateway"></exclusiveGateway>
    <sequenceFlow id="flow13" sourceRef="exclusivegateway3" targetRef="inicio">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${wf_reviewOutcome == "Aprobado_Facultativo"}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow14" sourceRef="exclusivegateway3" targetRef="endevent1">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${wf_reviewOutcome == "Cancelacion_Facultativo"}]]></conditionExpression>
    </sequenceFlow>
    <userTask id="alfrescoUsertask1" name="Revision Facultativo" activiti:assignee="fac_cardiologia" activiti:formKey="wf:activitiReviewTask">
      <extensionElements>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[var test = bpm_package;
                     var doc = test.children[0];
                       if(task.getVariableLocal('wf_reviewOutcome') == 'Approve') {
                        doc.properties["hula:estado"]="Aprobado_Facultativo";
                         doc.save();
                       } else {
                        doc.properties["hula:estado"]="Cancelacion_Facultativo";
                         doc.save();
                       }
                   execution.setVariable('wf_reviewOutcome', doc.properties["hula:estado"]);]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <sequenceFlow id="flow11" sourceRef="mover_user_home" targetRef="alfrescoUsertask1"></sequenceFlow>
    <sequenceFlow id="flow12" sourceRef="alfrescoUsertask1" targetRef="exclusivegateway3"></sequenceFlow>
    <startEvent id="startevent1" name="Start" activiti:formKey="bpm:startTask"></startEvent>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="inicio"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_hula">
    <bpmndi:BPMNPlane bpmnElement="hula" id="BPMNPlane_hula">
      <bpmndi:BPMNShape bpmnElement="exclusivegateway1" id="BPMNShape_exclusivegateway1">
        <omgdc:Bounds height="40.0" width="40.0" x="279.0" y="19.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="exclusivegateway2" id="BPMNShape_exclusivegateway2">
        <omgdc:Bounds height="40.0" width="40.0" x="434.0" y="187.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="437.0" y="340.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="inicio" id="BPMNShape_inicio">
        <omgdc:Bounds height="69.0" width="131.0" x="77.0" y="119.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="revision_jefe" id="BPMNShape_revision_jefe">
        <omgdc:Bounds height="60.0" width="105.0" x="90.0" y="10.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="mover_departamento_gerentes" id="BPMNShape_mover_departamento_gerentes">
        <omgdc:Bounds height="55.0" width="105.0" x="402.0" y="12.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="revision_gerente" id="BPMNShape_revision_gerente">
        <omgdc:Bounds height="55.0" width="105.0" x="402.0" y="98.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="mover_user_home" id="BPMNShape_mover_user_home">
        <omgdc:Bounds height="55.0" width="105.0" x="247.0" y="178.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="mover_autorizadas_gerencia" id="BPMNShape_mover_autorizadas_gerencia">
        <omgdc:Bounds height="55.0" width="105.0" x="402.0" y="252.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="exclusivegateway3" id="BPMNShape_exclusivegateway3">
        <omgdc:Bounds height="40.0" width="40.0" x="122.0" y="277.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="alfrescoUsertask1" id="BPMNShape_alfrescoUsertask1">
        <omgdc:Bounds height="55.0" width="105.0" x="247.0" y="270.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="10.0" y="136.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="142.0" y="119.0"></omgdi:waypoint>
        <omgdi:waypoint x="142.0" y="70.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
        <omgdi:waypoint x="195.0" y="40.0"></omgdi:waypoint>
        <omgdi:waypoint x="279.0" y="39.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
        <omgdi:waypoint x="319.0" y="39.0"></omgdi:waypoint>
        <omgdi:waypoint x="402.0" y="39.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
        <omgdi:waypoint x="299.0" y="59.0"></omgdi:waypoint>
        <omgdi:waypoint x="299.0" y="178.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
        <omgdi:waypoint x="454.0" y="67.0"></omgdi:waypoint>
        <omgdi:waypoint x="454.0" y="98.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow7" id="BPMNEdge_flow7">
        <omgdi:waypoint x="454.0" y="153.0"></omgdi:waypoint>
        <omgdi:waypoint x="454.0" y="187.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow8" id="BPMNEdge_flow8">
        <omgdi:waypoint x="454.0" y="227.0"></omgdi:waypoint>
        <omgdi:waypoint x="454.0" y="252.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow9" id="BPMNEdge_flow9">
        <omgdi:waypoint x="434.0" y="207.0"></omgdi:waypoint>
        <omgdi:waypoint x="352.0" y="205.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow10" id="BPMNEdge_flow10">
        <omgdi:waypoint x="454.0" y="307.0"></omgdi:waypoint>
        <omgdi:waypoint x="454.0" y="340.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow13" id="BPMNEdge_flow13">
        <omgdi:waypoint x="142.0" y="277.0"></omgdi:waypoint>
        <omgdi:waypoint x="142.0" y="188.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow14" id="BPMNEdge_flow14">
        <omgdi:waypoint x="142.0" y="317.0"></omgdi:waypoint>
        <omgdi:waypoint x="142.0" y="357.0"></omgdi:waypoint>
        <omgdi:waypoint x="437.0" y="357.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow11" id="BPMNEdge_flow11">
        <omgdi:waypoint x="299.0" y="233.0"></omgdi:waypoint>
        <omgdi:waypoint x="299.0" y="270.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow12" id="BPMNEdge_flow12">
        <omgdi:waypoint x="247.0" y="297.0"></omgdi:waypoint>
        <omgdi:waypoint x="162.0" y="297.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="45.0" y="153.0"></omgdi:waypoint>
        <omgdi:waypoint x="77.0" y="153.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
1 Reply
venzia
Senior Member

Re: Problem with permissions and create folder in workflow

Hi, can you provide alfresco.log info related with the permissions error?
The folder creation looks fine but I don't understand why are you creating "Rechazadas" folders inside userHome's to apply permissions to other groups later. Normally is not a good practise to "expose" shared content in userHomes.
By the way, if you want to continue the conversation in Spanish for sure more people could help to you.

Cheers!