Fixed bug with change transaction IDs not being recorded for nodes in a hierarchy during a store move.

Early invalid node checks (before firing policies).


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6157 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-07-04 11:26:41 +00:00
parent 01098ee76e
commit 2ba1ca92e9

View File

@@ -285,6 +285,9 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
Assert.notNull(assocTypeQName); Assert.notNull(assocTypeQName);
Assert.notNull(assocQName); Assert.notNull(assocQName);
// Get the parent node
Node parentNode = getNodeNotNull(parentRef);
// null property map is allowed // null property map is allowed
if (properties == null) if (properties == null)
{ {
@@ -324,8 +327,6 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
// We now have enough to declare the child association creation // We now have enough to declare the child association creation
invokeBeforeCreateChildAssociation(parentRef, childNodeRef, assocTypeQName, assocQName, true); invokeBeforeCreateChildAssociation(parentRef, childNodeRef, assocTypeQName, assocQName, true);
// Get the parent node
Node parentNode = getNodeNotNull(parentRef);
// Create the association // Create the association
ChildAssoc childAssoc = nodeDaoService.newChildAssoc( ChildAssoc childAssoc = nodeDaoService.newChildAssoc(
parentNode, parentNode,
@@ -520,12 +521,12 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
{ {
throw new InvalidTypeException(typeQName); throw new InvalidTypeException(typeQName);
} }
Node node = getNodeNotNull(nodeRef);
// Invoke policies // Invoke policies
invokeBeforeUpdateNode(nodeRef); invokeBeforeUpdateNode(nodeRef);
// Get the node and set the new type // Get the node and set the new type
Node node = getNodeNotNull(nodeRef);
node.setTypeQName(typeQName); node.setTypeQName(typeQName);
// Add the default aspects to the node (update the properties with any new default values) // Add the default aspects to the node (update the properties with any new default values)
@@ -553,12 +554,12 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
throw new InvalidAspectException("The aspect is invalid: " + aspectTypeQName, aspectTypeQName); throw new InvalidAspectException("The aspect is invalid: " + aspectTypeQName, aspectTypeQName);
} }
Node node = getNodeNotNull(nodeRef);
// Invoke policy behaviours // Invoke policy behaviours
invokeBeforeUpdateNode(nodeRef); invokeBeforeUpdateNode(nodeRef);
invokeBeforeAddAspect(nodeRef, aspectTypeQName); invokeBeforeAddAspect(nodeRef, aspectTypeQName);
Node node = getNodeNotNull(nodeRef);
// attach the properties to the current node properties // attach the properties to the current node properties
Map<QName, Serializable> nodeProperties = getPropertiesImpl(node); Map<QName, Serializable> nodeProperties = getPropertiesImpl(node);
@@ -740,13 +741,14 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
public ChildAssociationRef addChild(NodeRef parentRef, NodeRef childRef, QName assocTypeQName, QName assocQName) public ChildAssociationRef addChild(NodeRef parentRef, NodeRef childRef, QName assocTypeQName, QName assocQName)
{ {
// Invoke policy behaviours
invokeBeforeCreateChildAssociation(parentRef, childRef, assocTypeQName, assocQName, false);
// get the parent node and ensure that it is a container node // get the parent node and ensure that it is a container node
Node parentNode = getNodeNotNull(parentRef); Node parentNode = getNodeNotNull(parentRef);
// get the child node // get the child node
Node childNode = getNodeNotNull(childRef); Node childNode = getNodeNotNull(childRef);
// Invoke policy behaviours
invokeBeforeCreateChildAssociation(parentRef, childRef, assocTypeQName, assocQName, false);
// make the association // make the association
ChildAssoc assoc = nodeDaoService.newChildAssoc( ChildAssoc assoc = nodeDaoService.newChildAssoc(
parentNode, parentNode,
@@ -924,6 +926,9 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
public Serializable getProperty(NodeRef nodeRef, QName qname) throws InvalidNodeRefException public Serializable getProperty(NodeRef nodeRef, QName qname) throws InvalidNodeRefException
{ {
// get the property from the node
Node node = getNodeNotNull(nodeRef);
// spoof referencable properties // spoof referencable properties
if (qname.equals(ContentModel.PROP_STORE_PROTOCOL)) if (qname.equals(ContentModel.PROP_STORE_PROTOCOL))
{ {
@@ -938,9 +943,6 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
return nodeRef.getId(); return nodeRef.getId();
} }
// get the property from the node
Node node = getNodeNotNull(nodeRef);
if (qname.equals(ContentModel.PROP_NODE_DBID)) if (qname.equals(ContentModel.PROP_NODE_DBID))
{ {
return node.getId(); return node.getId();
@@ -1041,12 +1043,12 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
{ {
Assert.notNull(qname); Assert.notNull(qname);
// Invoke policy behaviours
invokeBeforeUpdateNode(nodeRef);
// get the node // get the node
Node node = getNodeNotNull(nodeRef); Node node = getNodeNotNull(nodeRef);
// Invoke policy behaviours
invokeBeforeUpdateNode(nodeRef);
// Do the set operation // Do the set operation
Map<QName, Serializable> propertiesBefore = getPropertiesImpl(node); Map<QName, Serializable> propertiesBefore = getPropertiesImpl(node);
Map<QName, Serializable> propertiesAfter = setPropertyImpl(node, qname, value); Map<QName, Serializable> propertiesAfter = setPropertyImpl(node, qname, value);
@@ -1094,12 +1096,12 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
throw new UnsupportedOperationException("The property " + qname + " may not be removed individually"); throw new UnsupportedOperationException("The property " + qname + " may not be removed individually");
} }
// Invoke policy behaviours
invokeBeforeUpdateNode(nodeRef);
// Get the node // Get the node
Node node = getNodeNotNull(nodeRef); Node node = getNodeNotNull(nodeRef);
// Invoke policy behaviours
invokeBeforeUpdateNode(nodeRef);
// Get the values before // Get the values before
Map<QName, Serializable> propertiesBefore = getPropertiesImpl(node); Map<QName, Serializable> propertiesBefore = getPropertiesImpl(node);
// Remove the property // Remove the property
@@ -1610,6 +1612,7 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
for (NodeStatus oldNodeStatus : nodeStatusesById.values()) for (NodeStatus oldNodeStatus : nodeStatusesById.values())
{ {
Node nodeToMove = oldNodeStatus.getNode(); Node nodeToMove = oldNodeStatus.getNode();
NodeRef oldNodeRef = nodeToMove.getNodeRef();
nodeToMove.setStore(store); nodeToMove.setStore(store);
NodeRef newNodeRef = nodeToMove.getNodeRef(); NodeRef newNodeRef = nodeToMove.getNodeRef();
@@ -1619,6 +1622,10 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
NodeStatus newNodeStatus = nodeDaoService.getNodeStatus(newNodeRef, true); NodeStatus newNodeStatus = nodeDaoService.getNodeStatus(newNodeRef, true);
newNodeStatus.setNode(nodeToMove); newNodeStatus.setNode(nodeToMove);
// Record change IDs
nodeDaoService.recordChangeId(oldNodeRef);
nodeDaoService.recordChangeId(newNodeRef);
invokeOnUpdateNode(newNodeRef); invokeOnUpdateNode(newNodeRef);
} }
} }