mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
125603 rmunteanu: Merged 5.1.1 (5.1.1) to 5.1.N (5.1.2) 125484 slanglois: MNT-16155 Update source headers - remove old Copyrights from Java and JSP dource files git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@125781 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
94 lines
3.7 KiB
Java
94 lines
3.7 KiB
Java
package org.alfresco.repo.node;
|
|
|
|
import org.alfresco.model.ContentModel;
|
|
import org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy;
|
|
import org.alfresco.repo.node.NodeServicePolicies.OnDeleteChildAssociationPolicy;
|
|
import org.alfresco.repo.node.NodeServicePolicies.OnMoveNodePolicy;
|
|
import org.alfresco.repo.policy.Behaviour;
|
|
import org.alfresco.repo.policy.JavaBehaviour;
|
|
import org.alfresco.repo.policy.PolicyComponent;
|
|
import org.alfresco.repo.solr.SOLRTrackingComponent;
|
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
|
import org.alfresco.service.cmr.repository.NodeRef;
|
|
import org.alfresco.service.cmr.repository.NodeRef.Status;
|
|
import org.alfresco.service.cmr.repository.NodeService;
|
|
|
|
/**
|
|
* @author Andy
|
|
* @since 5.1
|
|
*/
|
|
public class CascadeUpdateAspect implements OnCreateChildAssociationPolicy, OnDeleteChildAssociationPolicy, OnMoveNodePolicy
|
|
{
|
|
private PolicyComponent policyComponent;
|
|
private NodeService nodeService;
|
|
private SOLRTrackingComponent solrTrackingComponent;
|
|
|
|
|
|
public void setPolicyComponent(PolicyComponent policyComponent)
|
|
{
|
|
this.policyComponent = policyComponent;
|
|
}
|
|
|
|
public void setNodeService(NodeService nodeService)
|
|
{
|
|
this.nodeService = nodeService;
|
|
}
|
|
|
|
public void setSolrTrackingComponent(SOLRTrackingComponent solrTrackingComponent)
|
|
{
|
|
this.solrTrackingComponent = solrTrackingComponent;
|
|
}
|
|
|
|
/**
|
|
* Initialise method
|
|
*/
|
|
public void init()
|
|
{
|
|
// need to listen to:
|
|
// invokeOnCreateChildAssociation(newParentAssocRef, false);
|
|
// invokeOnDeleteChildAssociation(oldParentAssocRef);
|
|
// invokeOnMoveNode(oldParentAssocRef, newParentAssocRef);
|
|
// categories affect paths via membership (not paths beneath nodes that are categories)
|
|
// - only changing category structure requires a cascade not changing a node's on a categories
|
|
|
|
this.policyComponent.bindAssociationBehaviour(OnCreateChildAssociationPolicy.QNAME,
|
|
ContentModel.TYPE_BASE,
|
|
new JavaBehaviour(this, "onCreateChildAssociation", Behaviour.NotificationFrequency.EVERY_EVENT));
|
|
this.policyComponent.bindAssociationBehaviour(OnDeleteChildAssociationPolicy.QNAME,
|
|
ContentModel.TYPE_BASE,
|
|
new JavaBehaviour(this, "onDeleteChildAssociation", Behaviour.NotificationFrequency.EVERY_EVENT));
|
|
this.policyComponent.bindClassBehaviour(OnMoveNodePolicy.QNAME,
|
|
ContentModel.TYPE_BASE,
|
|
new JavaBehaviour(this, "onMoveNode", Behaviour.NotificationFrequency.EVERY_EVENT));
|
|
}
|
|
|
|
@Override
|
|
public void onMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef)
|
|
{
|
|
markCascadeUpdate(oldChildAssocRef.getChildRef());
|
|
markCascadeUpdate(newChildAssocRef.getChildRef());
|
|
}
|
|
|
|
@Override
|
|
public void onDeleteChildAssociation(ChildAssociationRef childAssocRef)
|
|
{
|
|
markCascadeUpdate(childAssocRef.getChildRef());
|
|
}
|
|
|
|
@Override
|
|
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean isNewNode)
|
|
{
|
|
if(!isNewNode)
|
|
{
|
|
markCascadeUpdate(childAssocRef.getChildRef());
|
|
}
|
|
}
|
|
|
|
private void markCascadeUpdate(NodeRef nodeRef)
|
|
{
|
|
Status status = nodeService.getNodeStatus(nodeRef);
|
|
nodeService.setProperty(status.getNodeRef(), ContentModel.PROP_CASCADE_CRC, solrTrackingComponent.getCRC(status.getDbId()));
|
|
nodeService.setProperty(status.getNodeRef(), ContentModel.PROP_CASCADE_TX, status.getDbTxnId());
|
|
}
|
|
}
|