1 17 package org.alfresco.repo.rule.ruletrigger; 18 19 import org.alfresco.repo.policy.JavaBehaviour; 20 import org.alfresco.service.cmr.repository.AssociationRef; 21 import org.alfresco.service.cmr.rule.RuleServiceException; 22 import org.alfresco.service.namespace.NamespaceService; 23 import org.alfresco.service.namespace.QName; 24 25 public class SingleAssocRefPolicyRuleTrigger extends RuleTriggerAbstractBase 26 { 27 private static final String ERR_POLICY_NAME_NOT_SET = "Unable to register rule trigger since policy name has not been set."; 28 29 private String policyNamespace = NamespaceService.ALFRESCO_URI; 30 31 private String policyName; 32 33 public void setPolicyNamespace(String policyNamespace) 34 { 35 this.policyNamespace = policyNamespace; 36 } 37 38 public void setPolicyName(String policyName) 39 { 40 this.policyName = policyName; 41 } 42 43 46 public void registerRuleTrigger() 47 { 48 if (policyName == null) 49 { 50 throw new RuleServiceException(ERR_POLICY_NAME_NOT_SET); 51 } 52 53 this.policyComponent.bindAssociationBehaviour( 54 QName.createQName(this.policyNamespace, this.policyName), 55 this, 56 new JavaBehaviour(this, "policyBehaviour")); 57 } 58 59 public void policyBehaviour(AssociationRef assocRef) 60 { 61 triggerRules(assocRef.getSourceRef(), assocRef.getTargetRef()); 62 } 63 } 64 | Popular Tags |