Merged V3.2 to HEAD

17294: Fix for ETHREEOH-3194 - It's impossible to find Blogs and Discussions by title.
   17301: Activity Service fixes (ETHREEOH-1362 & ETHREEOH-1741)
   17302: Fix for ETHREEOH-2849 JPG to GIF transformation fails when using imagemagick cmd line options listed in our wiki
   17305: AVM - fix AVMStoreDescriptor ( creator/createDate) returned by getStores
   17306: Fix for ETHREEOH-1578 - Incorrect behavior of Calendar in Month view ...
   17318: Merged V3.1 to V3.2
      17317: Fix for ETHREEOH-3236 It is impossible to change start location, everything is reverted to My Alfresco
   17320: Merged V3.1 to V3.2
      17287 - Fix for ETHREEOH-110- It is impossible to browse events by tags
   17326: iBatis mapping fixes for AVM on Oracle (including ETHREEOH-3205)
   17327: Merged V3.1 to V3.2
      17324: Fix for ETHREEOH-2723 Script error appears when trying to edit Home Space Name for user
   17329: Merged V3.1 to V3.2
      17180: Merged V2.2 to V3.1
         17164: Fixes for deletion of large hierarchies: (ETHREEOH-2161 and ETHREEOH-2650)
         17179: (RECORD ONLY) Merged V3.1 to V2.2 ...
   17330: Fix for SiteActivityTest failure (caused by earlier -ve test data)
   17331: Merged V3.1 to V3.2
      17190: Further fixes for ETHREEOH-2161: Delete process hangs when deleting large directory structure (with rules applied)
      17207: Fix fallout from work on ETHREEOH-2161: Delete process hangs when deleting large directory structure (with rules applied)
      17215: Added back firing of policies for archive stores
   17351: Build fix check in to DBNodeService.    Will be followed by full fix when available.
   17353: Applied TransactionListenerAdapter
___________________________________________________________________
Modified: svn:mergeinfo
   Reverse-merged /alfresco/BRANCHES/V3.1:r13091
   Merged /alfresco/BRANCHES/V2.2:r13089,13091,14190-14191,14199,14210,14216,14229,14655,14825,14869,17164,17179
   Merged /alfresco/BRANCHES/V3.1:r17180,17190,17207,17215,17287,17317,17324
   Merged /alfresco/BRANCHES/V3.2:r17294,17301-17302,17305-17306,17318,17320,17326-17327,17329-17331,17351,17353


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@18056 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2010-01-15 11:09:09 +00:00
parent 354faccbc3
commit e2fbd4a8de
24 changed files with 1671 additions and 1446 deletions

View File

@@ -1008,54 +1008,92 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
{
private NodeService nodeService;
private List<NodeRef> deletedNodeRefs;
private List<NodeRef> beforeDeleteNodeRefs;
public BadOnDeleteNodePolicy(NodeService nodeService, List<NodeRef> deletedNodeRefs)
private boolean onDeleteCreateChild = true;
public BadOnDeleteNodePolicy(NodeService nodeService,
List<NodeRef> beforeDeleteNodeRefs,
List<NodeRef> deletedNodeRefs)
{
this.nodeService = nodeService;
this.beforeDeleteNodeRefs = beforeDeleteNodeRefs;
this.deletedNodeRefs = deletedNodeRefs;
}
public void beforeDeleteNode(NodeRef nodeRef)
{
// add a new child to the child, i.e. just before it is deleted
ChildAssociationRef assocRef = nodeService.createNode(
// add the child to the list
beforeDeleteNodeRefs.add(nodeRef);
if(onDeleteCreateChild)
{
// add a new child to the child, i.e. just before it is deleted
ChildAssociationRef assocRef = nodeService.createNode(
nodeRef,
ASSOC_TYPE_QNAME_TEST_CHILDREN,
QName.createQName("pre-delete new child"),
ContentModel.TYPE_CONTAINER);
// set some child node properties
nodeService.setProperty(nodeRef, PROP_QNAME_BOOLEAN_VALUE, "true");
// add an aspect to the child
nodeService.addAspect(nodeRef, ASPECT_QNAME_TEST_TITLED, null);
// set some child node properties
nodeService.setProperty(nodeRef, PROP_QNAME_BOOLEAN_VALUE, "true");
// add an aspect to the child
nodeService.addAspect(nodeRef, ASPECT_QNAME_TEST_TITLED, null);
}
}
public void onDeleteNode(ChildAssociationRef childAssocRef, boolean isArchivedNode)
{
// add the child to the list
deletedNodeRefs.add(childAssocRef.getChildRef());
// now perform some nasties on the node's parent, i.e. add a new child
NodeRef parentRef = childAssocRef.getParentRef();
NodeRef childRef = childAssocRef.getChildRef();
ChildAssociationRef assocRef = nodeService.createNode(
if(onDeleteCreateChild)
{
// now perform some nasties on the node's parent, i.e. add a new child
NodeRef parentRef = childAssocRef.getParentRef();
NodeRef childRef = childAssocRef.getChildRef();
ChildAssociationRef assocRef = nodeService.createNode(
parentRef,
ASSOC_TYPE_QNAME_TEST_CHILDREN,
QName.createQName("post-delete new child"),
ContentModel.TYPE_CONTAINER);
}
}
private void setOnDeleteCreateChild(boolean onDeleteCreateChild)
{
this.onDeleteCreateChild = onDeleteCreateChild;
}
private boolean isOnDeleteCreateChild()
{
return onDeleteCreateChild;
}
}
public void testDelete() throws Exception
{
final List<NodeRef> beforeDeleteNodeRefs = new ArrayList<NodeRef>(5);
final List<NodeRef> deletedNodeRefs = new ArrayList<NodeRef>(5);
NodeServicePolicies.OnDeleteNodePolicy policy = new BadOnDeleteNodePolicy(nodeService, deletedNodeRefs);
BadOnDeleteNodePolicy nasty = new BadOnDeleteNodePolicy(nodeService, beforeDeleteNodeRefs, deletedNodeRefs);
nasty.setOnDeleteCreateChild(false);
NodeServicePolicies.OnDeleteNodePolicy policy = nasty;
// bind to listen to the deletion of a node
policyComponent.bindClassBehaviour(
QName.createQName(NamespaceService.ALFRESCO_URI, "onDeleteNode"),
policy,
new JavaBehaviour(policy, "onDeleteNode"));
policyComponent.bindClassBehaviour(
QName.createQName(NamespaceService.ALFRESCO_URI, "beforeDeleteNode"),
policy,
new JavaBehaviour(policy, "beforeDeleteNode"));
// build the node and commit the node graph
Map<QName, ChildAssociationRef> assocRefs = buildNodeGraph(nodeService, rootNodeRef);
NodeRef n1Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "root_p_n1")).getChildRef();
@@ -1072,11 +1110,86 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
assertEquals("Node not cascade deleted", 0, countNodesByReference(n6Ref));
assertEquals("Node not cascade deleted", 0, countNodesByReference(n8Ref));
// check before delete delete policy has been called
assertTrue("n1Ref before delete policy not called", beforeDeleteNodeRefs.contains(n1Ref));
assertTrue("n3Ref before delete policy not called", beforeDeleteNodeRefs.contains(n3Ref));
assertTrue("n6Ref before delete policy not called", beforeDeleteNodeRefs.contains(n6Ref));
assertTrue("n8Ref before delete policy not called", beforeDeleteNodeRefs.contains(n8Ref));
// check delete policy has been called
assertTrue("n1Ref delete policy not called", deletedNodeRefs.contains(n1Ref));
assertTrue("n3Ref delete policy not called", deletedNodeRefs.contains(n3Ref));
assertTrue("n6Ref delete policy not called", deletedNodeRefs.contains(n6Ref));
assertTrue("n8Ref delete policy not called", deletedNodeRefs.contains(n8Ref));
// commit to check
setComplete();
endTransaction();
}
// /**
// * This test is similar to the test above but the delete policies do nasty stuff such as
// * creating children of the soon to be deleted children.
// *
// * In particular, it verifies that we don't get stuck in an infinite loop.
// * @throws Exception
// */
// public void testDeleteWithBadlyBehavedPolicies() throws Exception
// {
// try
// {
// final List<NodeRef> beforeDeleteNodeRefs = new ArrayList<NodeRef>(5);
// final List<NodeRef> deletedNodeRefs = new ArrayList<NodeRef>(5);
//
// BadOnDeleteNodePolicy nasty = new BadOnDeleteNodePolicy(nodeService, beforeDeleteNodeRefs, deletedNodeRefs);
// nasty.setOnDeleteCreateChild(true);
// NodeServicePolicies.OnDeleteNodePolicy policy = nasty;
//
// // bind to listen to the deletion of a node
// policyComponent.bindClassBehaviour(
// QName.createQName(NamespaceService.ALFRESCO_URI, "onDeleteNode"),
// policy,
// new JavaBehaviour(policy, "onDeleteNode"));
//
// policyComponent.bindClassBehaviour(
// QName.createQName(NamespaceService.ALFRESCO_URI, "beforeDeleteNode"),
// policy,
// new JavaBehaviour(policy, "beforeDeleteNode"));
//
// // build the node and commit the node graph
// Map<QName, ChildAssociationRef> assocRefs = buildNodeGraph(nodeService, rootNodeRef);
// NodeRef n1Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "root_p_n1")).getChildRef();
// NodeRef n3Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n1_p_n3")).getChildRef();
// NodeRef n4Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n2_p_n4")).getChildRef();
// NodeRef n6Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n3_p_n6")).getChildRef();
// NodeRef n8Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n6_p_n8")).getChildRef();
//
// // delete n1
// nodeService.deleteNode(n1Ref);
//
// // turn off nasty policy - may upset other tests
// nasty.setOnDeleteCreateChild(false);
//
// // Just a cut down set of tests to validate that something has happened, the real point of the test is to see how
// // the end of the transaction fails.
//
// assertEquals("Node not directly deleted", 0, countNodesByReference(n1Ref));
// assertTrue("n1Ref before delete policy not called", beforeDeleteNodeRefs.contains(n1Ref));
// assertTrue("n1Ref delete policy not called", deletedNodeRefs.contains(n1Ref));
//
// // commit to check
// setComplete();
// endTransaction();
// fail("test has not detected orphan children");
// }
// catch (Exception e)
// {
// // We expect to get here with this test.
// e.printStackTrace();
// }
// }
@SuppressWarnings("unchecked")
private int countChildrenOfNode(NodeRef nodeRef)
{