Merged V1.3 to HEAD (3180:3203, 3204:3217)

svn merge svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@3180 svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@3203 .
   svn merge svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@3204 svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@3217 .


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3407 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2006-07-26 11:00:06 +00:00
parent 595556f3c5
commit f4e00169ab
40 changed files with 1155 additions and 643 deletions

View File

@@ -42,6 +42,7 @@ import org.alfresco.repo.node.NodeServicePolicies.OnCreateStorePolicy;
import org.alfresco.repo.node.NodeServicePolicies.OnDeleteAssociationPolicy;
import org.alfresco.repo.node.NodeServicePolicies.OnDeleteChildAssociationPolicy;
import org.alfresco.repo.node.NodeServicePolicies.OnDeleteNodePolicy;
import org.alfresco.repo.node.NodeServicePolicies.OnMoveNodePolicy;
import org.alfresco.repo.node.NodeServicePolicies.OnRemoveAspectPolicy;
import org.alfresco.repo.node.NodeServicePolicies.OnUpdateNodePolicy;
import org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy;
@@ -96,6 +97,7 @@ public abstract class AbstractNodeServiceImpl implements NodeService
private ClassPolicyDelegate<OnCreateStorePolicy> onCreateStoreDelegate;
private ClassPolicyDelegate<BeforeCreateNodePolicy> beforeCreateNodeDelegate;
private ClassPolicyDelegate<OnCreateNodePolicy> onCreateNodeDelegate;
private ClassPolicyDelegate<OnMoveNodePolicy> onMoveNodeDelegate;
private ClassPolicyDelegate<BeforeUpdateNodePolicy> beforeUpdateNodeDelegate;
private ClassPolicyDelegate<OnUpdateNodePolicy> onUpdateNodeDelegate;
private ClassPolicyDelegate<OnUpdatePropertiesPolicy> onUpdatePropertiesDelegate;
@@ -161,6 +163,7 @@ public abstract class AbstractNodeServiceImpl implements NodeService
onCreateStoreDelegate = policyComponent.registerClassPolicy(NodeServicePolicies.OnCreateStorePolicy.class);
beforeCreateNodeDelegate = policyComponent.registerClassPolicy(NodeServicePolicies.BeforeCreateNodePolicy.class);
onCreateNodeDelegate = policyComponent.registerClassPolicy(NodeServicePolicies.OnCreateNodePolicy.class);
onMoveNodeDelegate = policyComponent.registerClassPolicy(NodeServicePolicies.OnMoveNodePolicy.class);
beforeUpdateNodeDelegate = policyComponent.registerClassPolicy(NodeServicePolicies.BeforeUpdateNodePolicy.class);
onUpdateNodeDelegate = policyComponent.registerClassPolicy(NodeServicePolicies.OnUpdateNodePolicy.class);
onUpdatePropertiesDelegate = policyComponent.registerClassPolicy(NodeServicePolicies.OnUpdatePropertiesPolicy.class);
@@ -227,6 +230,19 @@ public abstract class AbstractNodeServiceImpl implements NodeService
policy.onCreateNode(childAssocRef);
}
/**
* @see NodeServicePolicies.OnMoveNodePolicy#onMoveNode(ChildAssociationRef, ChildAssociationRef)
*/
protected void invokeOnMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef)
{
NodeRef childNodeRef = newChildAssocRef.getChildRef();
// get qnames to invoke against
Set<QName> qnames = getTypeAndAspectQNames(childNodeRef);
// execute policy for node type and aspects
NodeServicePolicies.OnMoveNodePolicy policy = onMoveNodeDelegate.get(childNodeRef, qnames);
policy.onMoveNode(oldChildAssocRef, newChildAssocRef);
}
/**
* @see NodeServicePolicies.BeforeUpdateNodePolicy#beforeUpdateNode(NodeRef)
*/

View File

@@ -1153,6 +1153,17 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
RegexQNamePattern.MATCH_ALL);
}
public static class MovePolicyTester implements NodeServicePolicies.OnMoveNodePolicy
{
public List<ChildAssociationRef> policyAssocRefs = new ArrayList<ChildAssociationRef>(2);
public void onMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef)
{
policyAssocRefs.add(oldChildAssocRef);
policyAssocRefs.add(newChildAssocRef);
}
};
public void testMoveNode() throws Exception
{
Map<QName, ChildAssociationRef> assocRefs = buildNodeGraph();
@@ -1163,12 +1174,24 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
NodeRef n5Ref = n5pn7Ref.getParentRef();
NodeRef n6Ref = n6pn8Ref.getParentRef();
NodeRef n8Ref = n6pn8Ref.getChildRef();
MovePolicyTester policy = new MovePolicyTester();
// bind to listen to the deletion of a node
policyComponent.bindClassBehaviour(
QName.createQName(NamespaceService.ALFRESCO_URI, "onMoveNode"),
policy,
new JavaBehaviour(policy, "onMoveNode"));
// move n8 to n5
ChildAssociationRef assocRef = nodeService.moveNode(
n8Ref,
n5Ref,
ASSOC_TYPE_QNAME_TEST_CHILDREN,
QName.createQName(BaseNodeServiceTest.NAMESPACE, "n5_p_n8"));
// check that the move policy was fired
assertEquals("Move policy not fired", 2, policy.policyAssocRefs.size());
// check that n6 is no longer the parent
List<ChildAssociationRef> n6ChildRefs = nodeService.getChildAssocs(
n6Ref,

View File

@@ -82,6 +82,17 @@ public interface NodeServicePolicies
public void onCreateNode(ChildAssociationRef childAssocRef);
}
public interface OnMoveNodePolicy extends ClassPolicy
{
/**
* Called when a node has been moved.
*
* @param oldChildAssocRef the child association reference prior to the move
* @param newChildAssocRef the child association reference after the move
*/
public void onMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef);
}
public interface BeforeUpdateNodePolicy extends ClassPolicy
{
/**

View File

@@ -434,6 +434,7 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
nodeDaoService.deleteChildAssoc(oldAssoc, false);
// create a new assoc
ChildAssoc newAssoc = nodeDaoService.newChildAssoc(newParentNode, nodeToMove, true, assocTypeQName, assocQName);
ChildAssociationRef newAssocRef = newAssoc.getChildAssocRef();
// If the node is moving stores, then drag the node hierarchy with it
if (movingStore)
@@ -463,6 +464,7 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
invokeOnUpdateNode(oldParentNode.getNodeRef());
invokeOnUpdateNode(newParentRef);
}
invokeOnMoveNode(oldAssocRef, newAssocRef);
// update the node status
nodeDaoService.recordChangeId(nodeToMoveRef);