Hello. I need to change owner property of document, for this i use next code
behaviourFilter.disableBehaviour(nodeRef, ContentModel.ASPECT_AUDITABLE); nodeService.setProperty(nodeRef, ContentModel.PROP_CREATOR, NEW_DOCUMENT_OWNER); nodeService.setProperty(nodeRef, ContentModel.PROP_MODIFIER, NEW_DOCUMENT_OWNER);
behaviourFilter.enableBehaviour(nodeRef, ContentModel.ASPECT_AUDITABLE);
in service task of workflow in class ChangeDocumentsOwner implements JavaDelegate.
I call this file in file.bpmn20.xml
<serviceTask id="servicetask1" name="Service Task" activiti:async="true" activiti:class="org.alfresco.repo.workflow.activiti.script.ChangeDocumentsOwner"></serviceTask>
But i can't get behaviourFilter instance. nodeService instance i got from the next code
Map<Object, Object> registeredBeans = Context.getProcessEngineConfiguration().getBeans();
ServiceRegistry registry = (ServiceRegistry)registeredBeans.get(ActivitiConstants.SERVICE_REGISTRY_BEAN_KEY);
NodeService nodeService = registry.getNodeService();
I tried to register bean ChangeDocumentsOwner
<bean id="ChangeDocumentsOwner" class="org.alfresco.repo.workflow.activiti.script.ChangeDocumentsOwner" parent="webscript"> <property name="nodeService" ref="NodeService" /> <property name="behaviourFilter" ref="policyBehaviourFilter" /> </bean>
but properties was null. Can i get behaviourFilter instance? Or, maybe there are other solutions to my problem?
Solved! Go to Solution.
Problem was in bean and call inside service task.
Correct code
<serviceTask id="servicetask1" name="Service Task" activiti:async="true" activiti:delegateExpression="${ChangeDocumentsOwner}"></serviceTask>and
<bean id="AbstractChangeDocumentsOwner" parent="baseJavaDelegate" abstract="true" depends-on="activitiBeanRegistry" /> <bean id="ChangeDocumentsOwner" parent="AbstractChangeDocumentsOwner" class="org.alfresco.repo.workflow.activiti.script.ChangeDocumentsOwner"> <property name="nodeService" ref="NodeService" /> <property name="behaviourFilter" ref="policyBhaviourFilter" /> </bean>
Problem was in bean and call inside service task.
Correct code
<serviceTask id="servicetask1" name="Service Task" activiti:async="true" activiti:delegateExpression="${ChangeDocumentsOwner}"></serviceTask>and
<bean id="AbstractChangeDocumentsOwner" parent="baseJavaDelegate" abstract="true" depends-on="activitiBeanRegistry" /> <bean id="ChangeDocumentsOwner" parent="AbstractChangeDocumentsOwner" class="org.alfresco.repo.workflow.activiti.script.ChangeDocumentsOwner"> <property name="nodeService" ref="NodeService" /> <property name="behaviourFilter" ref="policyBhaviourFilter" /> </bean>
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
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.