assocRefs = nodeService.getChildAssocs(
+ rootNodeRef,
+ ContentModel.ASSOC_CHILDREN,
+ QNAME_ASSOC_ML_ROOT);
+ if (assocRefs.size() != 1)
{
- if (rs.length() > 0)
- {
- NodeRef mlRootNodeRef = rs.getNodeRef(0);
- // done
- return mlRootNodeRef;
- }
- else
- {
- throw new AlfrescoRuntimeException(
- "Unable to find bootstrap location for ML Root using query: " + searchParametersMLRoot.getQuery());
- }
- }
- finally
- {
- rs.close();
+ throw new AlfrescoRuntimeException(
+ "Unable to find bootstrap location for ML Root using query: " + QNAME_ASSOC_ML_ROOT);
}
+ NodeRef mlRootNodeRef = assocRefs.get(0).getChildRef();
+ // Done
+ return mlRootNodeRef;
}
private static final QName QNAME_ML_CONTAINER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "mlContainer");
@@ -962,11 +948,6 @@ public class MultilingualContentServiceImpl implements MultilingualContentServic
this.nodeService = nodeService;
}
- public void setSearchService(SearchService searchService)
- {
- this.searchService = searchService;
- }
-
public void setPermissionService(PermissionService permissionService)
{
this.permissionService = permissionService;
diff --git a/source/java/org/alfresco/repo/node/BaseNodeServiceTest.java b/source/java/org/alfresco/repo/node/BaseNodeServiceTest.java
index de37f923e3..8e256cdc0b 100644
--- a/source/java/org/alfresco/repo/node/BaseNodeServiceTest.java
+++ b/source/java/org/alfresco/repo/node/BaseNodeServiceTest.java
@@ -277,7 +277,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
*
* Level 0: root
* Level 1: root_p_n1 root_p_n2
- * Level 2: n1_p_n3 n2_p_n4 n1_n4 n2_p_n5
+ * Level 2: n1_p_n3 n2_p_n4 n1_n4 n2_p_n5 n1_n8
* Level 3: n3_p_n6 n4_n6 n5_p_n7
* Level 4: n6_p_n8 n7_n8
*
@@ -408,6 +408,10 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
assoc = nodeService.addChild(n7, n8, ASSOC_TYPE_QNAME_TEST_CHILDREN, qname);
ret.put(qname, assoc);
+ qname = QName.createQName(ns, "n1_n8");
+ assoc = nodeService.addChild(n1, n8, ASSOC_TYPE_QNAME_TEST_CHILDREN, qname);
+ ret.put(qname, assoc);
+
// // flush and clear
// getSession().flush();
// getSession().clear();
@@ -1464,7 +1468,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
QName.createQName("pathA"),
TYPE_QNAME_TEST_MANY_PROPERTIES).getChildRef();
- for (int inc = 0; inc < 5; inc++)
+ for (int inc = 0; inc < 6; inc++)
{
System.out.println("----------------------------------------------");
int collectionSize = (int) Math.pow(10, inc);
@@ -1581,7 +1585,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
// get a child node's parents
NodeRef n8Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE, "n6_p_n8")).getChildRef();
List parentAssocs = nodeService.getParentAssocs(n8Ref);
- assertEquals("Incorrect number of parents", 2, parentAssocs.size());
+ assertEquals("Incorrect number of parents", 3, parentAssocs.size());
assertTrue("Expected assoc not found", parentAssocs.contains(n6pn8Ref));
assertTrue("Expected assoc not found", parentAssocs.contains(n7n8Ref));
@@ -1613,22 +1617,25 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
NodeRef n1Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE,"root_p_n1")).getChildRef();
ChildAssociationRef n1pn3Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE,"n1_p_n3"));
ChildAssociationRef n1n4Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE,"n1_n4"));
+ ChildAssociationRef n1n8Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE,"n1_n8"));
// get the parent node's children
List childAssocRefs = nodeService.getChildAssocs(n1Ref);
- assertEquals("Incorrect number of children", 2, childAssocRefs.size());
+ assertEquals("Incorrect number of children", 3, childAssocRefs.size());
// checks that the order of the children is correct
assertEquals("First child added to n1 was primary to n3: Order of refs is wrong",
n1pn3Ref, childAssocRefs.get(0));
assertEquals("Second child added to n1 was to n4: Order of refs is wrong",
n1n4Ref, childAssocRefs.get(1));
// now set the child ordering explicitly - change the order
- nodeService.setChildAssociationIndex(n1pn3Ref, 1);
+ nodeService.setChildAssociationIndex(n1pn3Ref, 2);
+ nodeService.setChildAssociationIndex(n1n8Ref, 1);
nodeService.setChildAssociationIndex(n1n4Ref, 0);
// repeat
childAssocRefs = nodeService.getChildAssocs(n1Ref);
- assertEquals("Order of refs is wrong", n1pn3Ref, childAssocRefs.get(1));
+ assertEquals("Order of refs is wrong", n1pn3Ref, childAssocRefs.get(2));
+ assertEquals("Order of refs is wrong", n1n8Ref, childAssocRefs.get(1));
assertEquals("Order of refs is wrong", n1n4Ref, childAssocRefs.get(0));
// get the child associations based on pattern
@@ -1645,6 +1652,35 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
RegexQNamePattern.MATCH_ALL);
}
+ public void testGetChildAssocsByChildType() throws Exception
+ {
+ /*
+ * Level 2: n1_p_n3 n2_p_n4 n1_n4 n2_p_n5 n1_n8
+ * Containers: n1, n3, n4
+ * Files: n8
+ */
+ Map assocRefs = buildNodeGraph();
+ NodeRef n1Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE,"root_p_n1")).getChildRef();
+ NodeRef n8Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE,"n6_p_n8")).getChildRef();
+ ChildAssociationRef n1pn3Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE,"n1_p_n3"));
+ ChildAssociationRef n1n4Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE,"n1_n4"));
+ ChildAssociationRef n1n8Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE,"n1_n8"));
+
+ // Get N1's container children
+ List childAssocRefsContainers = nodeService.getChildAssocs(
+ n1Ref,
+ Collections.singleton(ContentModel.TYPE_CONTAINER));
+ assertEquals("Incorrect number of cm:container children", 2, childAssocRefsContainers.size());
+ assertTrue("Expected assoc not found", childAssocRefsContainers.contains(n1pn3Ref));
+ assertTrue("Expected assoc not found", childAssocRefsContainers.contains(n1n4Ref));
+ // Get N1's container children
+ List childAssocRefsFiles = nodeService.getChildAssocs(
+ n1Ref,
+ Collections.singleton(BaseNodeServiceTest.TYPE_QNAME_TEST_CONTENT));
+ assertEquals("Incorrect number of test:content children", 1, childAssocRefsFiles.size());
+ assertTrue("Expected assoc not found", childAssocRefsFiles.contains(n1n8Ref));
+ }
+
public static class MovePolicyTester implements NodeServicePolicies.OnMoveNodePolicy
{
public List policyAssocRefs = new ArrayList(2);
@@ -1852,7 +1888,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
// get all paths for n8
paths = nodeService.getPaths(n8Ref, false);
- assertEquals("Incorrect path count", 5, paths.size()); // n6 is a root as well
+ assertEquals("Incorrect path count", 6, paths.size()); // n6 is a root as well
// check that each path element has parent node ref, qname and child node ref
for (Path path : paths)
{
diff --git a/source/java/org/alfresco/repo/node/ConcurrentNodeServiceTest.java b/source/java/org/alfresco/repo/node/ConcurrentNodeServiceTest.java
index d0c01503ec..248439ddae 100644
--- a/source/java/org/alfresco/repo/node/ConcurrentNodeServiceTest.java
+++ b/source/java/org/alfresco/repo/node/ConcurrentNodeServiceTest.java
@@ -232,7 +232,16 @@ public class ConcurrentNodeServiceTest extends TestCase
}
}
- // Test it
+ /*
+ * Builds a graph of child associations as follows:
+ *
+ * Level 0: root
+ * Level 1: root_p_n1 root_p_n2
+ * Level 2: n1_p_n3 n2_p_n4 n1_n4 n2_p_n5 n1_n8
+ * Level 3: n3_p_n6 n4_n6 n5_p_n7
+ * Level 4: n6_p_n8 n7_n8
+ *
+ */
RetryingTransactionCallback