1 17 package org.alfresco.repo.node.index; 18 19 import org.alfresco.model.ContentModel; 20 import org.alfresco.repo.node.NodeServicePolicies; 21 import org.alfresco.repo.policy.JavaBehaviour; 22 import org.alfresco.repo.policy.PolicyComponent; 23 import org.alfresco.repo.search.Indexer; 24 import org.alfresco.service.cmr.repository.ChildAssociationRef; 25 import org.alfresco.service.cmr.repository.NodeRef; 26 import org.alfresco.service.cmr.repository.StoreRef; 27 import org.alfresco.service.namespace.NamespaceService; 28 import org.alfresco.service.namespace.QName; 29 30 36 public class NodeIndexer 37 implements NodeServicePolicies.BeforeCreateStorePolicy, 38 NodeServicePolicies.OnCreateNodePolicy, 39 NodeServicePolicies.OnUpdateNodePolicy, 40 NodeServicePolicies.OnDeleteNodePolicy, 41 NodeServicePolicies.OnCreateChildAssociationPolicy, 42 NodeServicePolicies.OnDeleteChildAssociationPolicy 43 { 44 45 private PolicyComponent policyComponent; 46 47 private Indexer indexer; 48 49 52 public void setPolicyComponent(PolicyComponent policyComponent) 53 { 54 this.policyComponent = policyComponent; 55 } 56 57 60 public void setIndexer(Indexer indexer) 61 { 62 this.indexer = indexer; 63 } 64 65 68 private void init() 69 { 70 policyComponent.bindClassBehaviour( 71 QName.createQName(NamespaceService.ALFRESCO_URI, "beforeCreateStore"), 72 ContentModel.TYPE_STOREROOT, 73 new JavaBehaviour(this, "beforeCreateStore")); 74 policyComponent.bindClassBehaviour( 75 QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode"), 76 this, 77 new JavaBehaviour(this, "onCreateNode")); 78 policyComponent.bindClassBehaviour( 79 QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateNode"), 80 this, 81 new JavaBehaviour(this, "onUpdateNode")); 82 policyComponent.bindClassBehaviour( 83 QName.createQName(NamespaceService.ALFRESCO_URI, "onDeleteNode"), 84 this, 85 new JavaBehaviour(this, "onDeleteNode")); 86 policyComponent.bindAssociationBehaviour( 87 QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateChildAssociation"), 88 this, 89 new JavaBehaviour(this, "onCreateChildAssociation")); 90 policyComponent.bindAssociationBehaviour( 91 QName.createQName(NamespaceService.ALFRESCO_URI, "onDeleteChildAssociation"), 92 this, 93 new JavaBehaviour(this, "onDeleteChildAssociation")); 94 } 95 96 public void beforeCreateStore(QName nodeTypeQName, StoreRef storeRef) 97 { 98 } 100 101 public void onCreateNode(ChildAssociationRef childAssocRef) 102 { 103 indexer.createNode(childAssocRef); 104 } 105 106 public void onUpdateNode(NodeRef nodeRef) 107 { 108 indexer.updateNode(nodeRef); 109 } 110 111 public void onDeleteNode(ChildAssociationRef childAssocRef) 112 { 113 indexer.deleteNode(childAssocRef); 114 } 115 116 public void onCreateChildAssociation(ChildAssociationRef childAssocRef) 117 { 118 indexer.createChildRelationship(childAssocRef); 119 } 120 121 public void onDeleteChildAssociation(ChildAssociationRef childAssocRef) 122 { 123 indexer.deleteChildRelationship(childAssocRef); 124 } 125 } 126 | Popular Tags |