1 17 package org.alfresco.repo.rule.ruletrigger; 18 19 import org.alfresco.service.cmr.dictionary.ClassDefinition; 20 import org.alfresco.service.cmr.dictionary.DataTypeDefinition; 21 import org.alfresco.service.cmr.dictionary.DictionaryService; 22 import org.alfresco.service.cmr.dictionary.PropertyDefinition; 23 import org.alfresco.service.cmr.repository.ChildAssociationRef; 24 import org.alfresco.service.namespace.QName; 25 import org.apache.commons.logging.Log; 26 import org.apache.commons.logging.LogFactory; 27 28 35 public class CreateNodeRuleTrigger extends SingleChildAssocRefPolicyRuleTrigger 36 { 37 40 private static Log logger = LogFactory.getLog(CreateNodeRuleTrigger.class); 41 42 DictionaryService dictionaryService; 43 44 public void setDictionaryService(DictionaryService dictionaryService) 45 { 46 this.dictionaryService = dictionaryService; 47 } 48 49 public void policyBehaviour(ChildAssociationRef childAssocRef) 50 { 51 boolean triggerRule = false; 54 QName type = this.nodeService.getType(childAssocRef.getChildRef()); 55 ClassDefinition classDefinition = this.dictionaryService.getClass(type); 56 if (classDefinition != null) 57 { 58 for (PropertyDefinition propertyDefinition : classDefinition.getProperties().values()) 59 { 60 if (propertyDefinition.getDataType().getName().equals(DataTypeDefinition.CONTENT) == true) 61 { 62 triggerRule = true; 63 break; 64 } 65 } 66 } 67 68 if (triggerRule == false) 69 { 70 if (logger.isDebugEnabled() == true) 71 { 72 logger.debug( 73 "Create node rule trigger fired for parent node " + 74 this.nodeService.getType(childAssocRef.getParentRef()).toString() + " " + childAssocRef.getParentRef() + 75 " and child node " + 76 this.nodeService.getType(childAssocRef.getChildRef()).toString() + " " + childAssocRef.getChildRef()); 77 } 78 79 triggerRules(childAssocRef.getParentRef(), childAssocRef.getChildRef()); 80 } 81 } 82 } 83 | Popular Tags |