As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
system.content.eagerOrphanCleanup = true
public class TestBehaviour implements NodeServicePolicies.OnCreateNodePolicy { private Behaviour onCreateNode; private PolicyComponent policyComponent; private NodeService nodeService; private Log log = LogFactory.getLog(TestBehaviour.class); public void setPolicyComponent(PolicyComponent policyComponent) { this.policyComponent = policyComponent; } public void setNodeService(NodeService nodeService) { this.nodeService = nodeService; } public void init() { this.onCreateNode = new JavaBehaviour(this, "onCreateNode", Behaviour.NotificationFrequency.TRANSACTION_COMMIT); this.policyComponent.bindClassBehaviour( QNAME.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode"), "cm:content", this.onCreateNode); } @Override public void onCreateNode(ChildAssociationRef childAssociationRef) { NodeRef nodeRef = childAssociationRef.getParentRef(); QName titleProperty = QNAME.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "description"); log.warn(titleProperty.toString()); log.warn(nodeRef.getId()); try { nodeService.setProperty(childAssociationRef.getChildRef(), titleProperty, "Test Behaviour"); log.warn("onCreateNode OK"); } catch (InvalidNodeRefException _e) { log.error("ERRORE onCreateNode"); } } }
<bean id="testBehaviour" class="local.lab.TestBehaviour" init-method="init"> <property name="policyComponent"> <ref bean="policyComponent" /> </property> <property name="nodeService"> <ref bean="NodeService"/> </property> </bean>