AnsweredAssumed Answered

New noderef for same content while in workflow.

Question asked by dynamolalit on Nov 18, 2010
Hi,

I am using alfresco 3.2 over Tomcat 6 & JDK 1.6. I am using a workflow using below def file. I am moving file to a temporary space while it is in workflow & once it is approved, i am moving it back to original space.For this workflow, i have a number of approvers which can approve the content.


<?xml version="1.0" encoding="UTF-8"?>
<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="KPDocsReview">
    <swimlane name="initiator" />

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

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

    <task-node name="review">
        <task name="wf:reviewTask" swimlane="reviewer">
          <event type="task-create">  
         <script>
               <variable name="wfFlag" access="write"/>
               <expression>
                  wfFlag = "Moved";
               </expression>
            </script>               
            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
         <runas>jindaladmin</runas>
            <script>
               logger.log("\n*************** In Workflow,Moving content to Under Review Space. ***************");                 executionContext.setVariable("wfFlag", wfFlag);
               logger.log("wfFlag in Approval Workflow : "+wfFlag);
               var userName = person.properties.userName;
               logger.log("userName in KM Approval Workflow : "+userName);
               executionContext.setVariable("userName", userName);
               for (var i = 0; i &lt; bpm_package.children.length; i++) {   
                  var docName = bpm_package.children[i].name;
                  logger.log("Content name in KM Approval Workflow : "+docName);
                  executionContext.setVariable("docName", docName);                
                  var nodeRef = bpm_package.children[i].nodeRef;               
                  logger.log("nodeRef in KM Approval Workflow :"+nodeRef);
                  executionContext.setVariable("nodeRef", nodeRef);
                  var docParentRef = bpm_package.children[i].parent.nodeRef;
                  logger.log("docParentRef "+docParentRef);
                  executionContext.setVariable("docParentRef", docParentRef);   
                  var myPath = bpm_package.children[i].url;
                  logger.log("myPath  "+myPath);
                  var docPath = bpm_package.children[i].displayPath;
                  logger.log("docPath in KM Approval Workflow : "+docPath);
                  executionContext.setVariable("docPath", docPath);
               }               
               var finalLoc = companyhome.childByNamePath("/Jindal Knowledge Management/Under Review");
               var targetNodeRef = finalLoc.nodeRef;
               logger.log("targetNodeRef "+targetNodeRef);
               executionContext.setVariable("targetNodeRef", targetNodeRef);   
               var userHomeRef = userhome.nodeRef;
               logger.log("userHomeRef "+userHomeRef);
               executionContext.setVariable("userHomeRef", userHomeRef);   
               var originalLocation = bpm_package.children[0].displayPath;
               var originalLocation2 = originalLocation.substring(8);
               logger.log("originalLocation2 "+originalLocation2);
               logger.log("originalLocation "+originalLocation);
               executionContext.setVariable("originalLocation",originalLocation);
               executionContext.setVariable("originalLocation2",originalLocation2);               
            </script>
         </action> 
         <action class="com.jindal.alfresco.km.bpm.KMReviewProcessAction" name="test123"/>      
         </event>
        </task>
        <transition name="Approve" to="approved" />
        <transition name="Disapprove" to="rejected" />
    </task-node>

    <node name="rejected">
        <event type="node-leave">
      <script>
               <variable name="wfFlag" access="write"/>
               <expression>
                  wfFlag = "Rejected";
               </expression>
            </script>            
                  <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
               <runas>jindaladmin</runas>
            <script>
               logger.log("\n*************** In Disapproval Process, Moving content to My Home. ***************");
               <!– Send a notification email to the initiator –>
                   var mail = actions.create("mail");
                  mail.parameters.to = initiator.properties["cm:email"];
                  logger.log("mail.parameters.to in disapproval "+mail.parameters.to);
                  mail.parameters.subject = "KM Workflow Content Disapproval Email.";
                  mail.parameters.from = "kmadmin@jindalsteel.com";
                  mail.parameters.text = "Hi!
                  \n\n
                  Your content named  " + "\'" +bpm_package.children[0].name+ "\'" + "  has not been approved.
                  \n
                  \n
                  You can access the disapproved content in your My Home location in KM Repository.
                  \n
                  \n
                  This is an auto generated email, please do not respond to it.
                  \n\n\n
                  Thanks.
                  ";
                  logger.log("mail.parameters.text "+mail.parameters.text);
                  mail.execute(bpm_package);
                  logger.log("Disapproval Mail Sent!");
            </script>
            </action>
            <action class="com.jindal.alfresco.km.bpm.KMReviewProcessAction" name="test123"/>
           </event>
        <transition name="" to="end" />
    </node>

    <node name="approved">       
         <event type="node-leave">
         <script>
               <variable name="wfFlag" access="write"/>
               <expression>
                  wfFlag = "Approved";
               </expression>
            </script>               
            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
         <runas>jindaladmin</runas>
            <script>
               logger.log("\n*************** In Approval Process,changing Owner to JindalAdmin , Moving content back to original location. ***************");
               var origLoc = executionContext.getVariable("originalLocation2");
               logger.log("origLoc in approval : "+origLoc);
               var wFContent = bpm_package.children[0].content;
               bpm_package.children[0].owner = "jindaladmin";   
               <!– Send a notification email to the initiator –>
                  var mail = actions.create("mail");
                  logger.log("mail "+mail);
                  mail.parameters.to = initiator.properties["cm:email"];
                  logger.log("mail.parameters.to : "+mail.parameters.to);
                  mail.parameters.subject = "KM Workflow Content Approval Email.";
                  logger.log("mail.parameters.subject : "+mail.parameters.subject);
                  mail.parameters.from = "kmadmin@jindalsteel.com";
                  logger.log("mail.parameters.from : "+mail.parameters.from);
                  mail.parameters.text = "Congratulations!!
                  \n
                  \n
                  Your Knowledge Management Contribution " + "\'" + bpm_package.children[0].name + "\'" + " has been approved and published!!
                  \n
                  \n
                  You can access the approved content at following location in KM Repository -
                  \n
                  \n"
                  +origLoc+
                  "\n
                  \n
                  This is an auto generated email, please do not respond to it.
                  \n\n\n
                  Thanks.
                  ";
                  logger.log("mail.parameters.text : "+mail.parameters.text);                  
                  mail.execute(bpm_package);                               
                   logger.log("Approval Mail Sent!");
            </script>
         </action> 
         <action class="com.jindal.alfresco.km.bpm.KMReviewProcessAction" name="test123"/>               
           </event>
        <transition name="" to="end" />
    </node>
   
    <end-state name="end" />

</process-definition>

But for a number of content, i can see that it is trying to move it to temporary space a number of times &  with each try it is using a new noderef which does not exists in repository.There is only a single copy of such contents, as i have checked in repository.

Content is already moved with original noderef but workflow still tries to move it using various random & unique noderefs again & again which do not exist in repository as i check in node browser showing error as below:

Error while moving content to Under Review Existing file or folder: 'file name' already exists

Finally on console, it throws following hibernate error:


14:23:43,301 User:dilipc ERROR [ui.common.Utils] Failed to create content due to error: could not update: [org.alfresco.
repo.domain.hibernate.ChildAssocImpl#258933]; nested exception is org.hibernate.exception.ConstraintViolationException:
could not update: [org.alfresco.repo.domain.hibernate.ChildAssocImpl#258933]
org.springframework.dao.DataIntegrityViolationException: could not update: [org.alfresco.repo.domain.hibernate.ChildAsso
cImpl#258933]; nested exception is org.hibernate.exception.ConstraintViolationException: could not update: [org.alfresco
.repo.domain.hibernate.ChildAssocImpl#258933]
Caused by: org.hibernate.exception.ConstraintViolationException: could not update: [org.alfresco.repo.domain.hibernate.C
hildAssocImpl#258933]
        at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
        at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2430)
        at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2312)
        at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2612)
        at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:96)
        at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:322)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:306)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:183)
        at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:29
8)
        at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
        at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
        at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
        at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
        at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:578)

        at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTran
sactionManager.java:662)
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransaction
Manager.java:632)
        at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(Transact
ionAspectSupport.java:314)
        at org.alfresco.util.transaction.SpringAwareUserTransaction.commit(SpringAwareUserTransaction.java:467)
        at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:349)
        at org.alfresco.web.bean.dialog.BaseDialogBean.finish(BaseDialogBean.java:130)
        at org.alfresco.web.bean.dialog.DialogManager.finish(DialogManager.java:534)
        at sun.reflect.GeneratedMethodAccessor1056.invoke(Unknown Source)
        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 com.keembay.alfresco.web.app.servlet.CASAuthenticationFilter.doFilter(CASAuthenticationFilter.java:149)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.alfresco.repo.web.filter.beans.NullFilter.doFilter(NullFilter.java:74)
        at sun.reflect.GeneratedMethodAccessor719.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.
java:122)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at $Proxy220.doFilter(Unknown Source)
        at org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:88)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at edu.yale.its.tp.cas.client.filter.CASFilter.doFilter(CASFilter.java:317)
        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$SocketProcessor.run(JIoEndpoint.java:354)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:619)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '1035-34-15377446
27-strong and weak organisational culture and be' for key 'parent_node_id'
        at sun.reflect.GeneratedConstructorAccessor489.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
        at com.mysql.jdbc.Util.getInstance(Util.java:381)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1015)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3515)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3447)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1951)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2101)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2554)
        at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1761)
        at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2046)
        at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1964)
        at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1949)
        at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:102)
        at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:102)
        at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2412)

I am not sure what is happening & system's performance reduces drastically.I would appreciate for any help.

Outcomes