Fixed policy calls when moving nodes between stores

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2845 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2006-05-11 15:13:06 +00:00
parent 9a69bf2e6a
commit dc6044f6dc

View File

@@ -409,19 +409,24 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
// get the old parent // get the old parent
Node oldParentNode = oldAssoc.getParent(); Node oldParentNode = oldAssoc.getParent();
// Invoke policy behaviour boolean movingStore = !nodeToMoveRef.getStoreRef().equals(newParentRef.getStoreRef());
invokeBeforeDeleteChildAssociation(oldAssocRef);
invokeBeforeCreateChildAssociation(newParentRef, nodeToMoveRef, assocTypeQName, assocQName);
invokeBeforeUpdateNode(oldParentNode.getNodeRef()); // old parent will be updated
invokeBeforeUpdateNode(newParentRef); // new parent ditto
// If the node is moving stores, then drag the node hierarchy with it // data needed for policy invocation
if (!nodeToMoveRef.getStoreRef().equals(newParentRef.getStoreRef())) QName nodeToMoveTypeQName = nodeToMove.getTypeQName();
Set<QName> nodeToMoveAspects = nodeToMove.getAspects();
// Invoke policy behaviour
if (movingStore)
{ {
Store newStore = newParentNode.getStore(); invokeBeforeDeleteNode(nodeToMoveRef);
moveNodeToStore(nodeToMove, newStore); invokeBeforeCreateNode(newParentRef, assocTypeQName, assocQName, nodeToMoveTypeQName);
// the node reference will have changed too }
nodeToMoveRef = nodeToMove.getNodeRef(); else
{
invokeBeforeDeleteChildAssociation(oldAssocRef);
invokeBeforeCreateChildAssociation(newParentRef, nodeToMoveRef, assocTypeQName, assocQName);
invokeBeforeUpdateNode(oldParentNode.getNodeRef()); // old parent will be updated
invokeBeforeUpdateNode(newParentRef); // new parent ditto
} }
// remove the child assoc from the old parent // remove the child assoc from the old parent
@@ -430,14 +435,32 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
// create a new assoc // create a new assoc
ChildAssoc newAssoc = nodeDaoService.newChildAssoc(newParentNode, nodeToMove, true, assocTypeQName, assocQName); ChildAssoc newAssoc = nodeDaoService.newChildAssoc(newParentNode, nodeToMove, true, assocTypeQName, assocQName);
// If the node is moving stores, then drag the node hierarchy with it
if (movingStore)
{
// do the move
Store newStore = newParentNode.getStore();
moveNodeToStore(nodeToMove, newStore);
// the node reference will have changed too
nodeToMoveRef = nodeToMove.getNodeRef();
}
// check that no cyclic relationships have been created // check that no cyclic relationships have been created
getPaths(nodeToMoveRef, false); getPaths(nodeToMoveRef, false);
// invoke policy behaviour // invoke policy behaviour
invokeOnCreateChildAssociation(newAssoc.getChildAssocRef()); if (movingStore)
invokeOnDeleteChildAssociation(oldAssoc.getChildAssocRef()); {
invokeOnUpdateNode(oldParentNode.getNodeRef()); invokeOnDeleteNode(oldAssocRef, nodeToMoveTypeQName, nodeToMoveAspects);
invokeOnUpdateNode(newParentRef); invokeOnCreateNode(newAssoc.getChildAssocRef());
}
else
{
invokeOnCreateChildAssociation(newAssoc.getChildAssocRef());
invokeOnDeleteChildAssociation(oldAssoc.getChildAssocRef());
invokeOnUpdateNode(oldParentNode.getNodeRef());
invokeOnUpdateNode(newParentRef);
}
// update the node status // update the node status
nodeDaoService.recordChangeId(nodeToMoveRef); nodeDaoService.recordChangeId(nodeToMoveRef);
@@ -1342,11 +1365,12 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
nodeToMove.setStore(store); nodeToMove.setStore(store);
NodeRef newNodeRef = nodeToMove.getNodeRef(); NodeRef newNodeRef = nodeToMove.getNodeRef();
// update change statuses
String txnId = AlfrescoTransactionSupport.getTransactionId(); String txnId = AlfrescoTransactionSupport.getTransactionId();
// update old status
NodeStatus oldNodeStatus = nodeDaoService.getNodeStatus(oldNodeRef, true); NodeStatus oldNodeStatus = nodeDaoService.getNodeStatus(oldNodeRef, true);
oldNodeStatus.setNode(null); oldNodeStatus.setNode(null);
oldNodeStatus.setChangeTxnId(txnId); oldNodeStatus.setChangeTxnId(txnId);
// create the new status
NodeStatus newNodeStatus = nodeDaoService.getNodeStatus(newNodeRef, true); NodeStatus newNodeStatus = nodeDaoService.getNodeStatus(newNodeRef, true);
newNodeStatus.setNode(nodeToMove); newNodeStatus.setNode(nodeToMove);
newNodeStatus.setChangeTxnId(txnId); newNodeStatus.setChangeTxnId(txnId);