1 17 package org.alfresco.repo.rule.ruletrigger; 18 19 import java.util.List ; 20 21 import org.alfresco.repo.content.ContentServicePolicies; 22 import org.alfresco.repo.policy.JavaBehaviour; 23 import org.alfresco.service.cmr.repository.ChildAssociationRef; 24 import org.alfresco.service.cmr.repository.NodeRef; 25 26 29 public class OnContentUpdateRuleTrigger extends RuleTriggerAbstractBase 30 implements ContentServicePolicies.OnContentUpdatePolicy 31 { 32 33 private boolean onNewContent = false; 34 35 36 private boolean triggerParentRules = true; 37 38 43 public void setOnNewContent(boolean onNewContent) 44 { 45 this.onNewContent = onNewContent; 46 } 47 48 53 public void setTriggerParentRules(boolean triggerParentRules) 54 { 55 this.triggerParentRules = triggerParentRules; 56 } 57 58 61 public void registerRuleTrigger() 62 { 63 this.policyComponent.bindClassBehaviour( 65 ContentServicePolicies.ON_CONTENT_UPDATE, 66 this, 67 new JavaBehaviour(this, "onContentUpdate")); 68 } 69 70 73 public void onContentUpdate(NodeRef nodeRef, boolean newContent) 74 { 75 if (newContent == this.onNewContent) 76 { 77 if (triggerParentRules == true) 78 { 79 List <ChildAssociationRef> parentsAssocRefs = this.nodeService.getParentAssocs(nodeRef); 80 for (ChildAssociationRef parentAssocRef : parentsAssocRefs) 81 { 82 triggerRules(parentAssocRef.getParentRef(), nodeRef); 83 } 84 } 85 else 86 { 87 triggerRules(nodeRef, nodeRef); 88 } 89 } 90 } 91 92 } 93 | Popular Tags |