diff --git a/config/alfresco/public-rest-context.xml b/config/alfresco/public-rest-context.xml
index bd97c0a7a2..db84cfbfa5 100644
--- a/config/alfresco/public-rest-context.xml
+++ b/config/alfresco/public-rest-context.xml
@@ -480,6 +480,7 @@
+
diff --git a/source/java/org/alfresco/rest/api/Nodes.java b/source/java/org/alfresco/rest/api/Nodes.java
index 398e542ca0..64661e5845 100644
--- a/source/java/org/alfresco/rest/api/Nodes.java
+++ b/source/java/org/alfresco/rest/api/Nodes.java
@@ -30,6 +30,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.alfresco.rest.api.model.AssocChild;
+import org.alfresco.rest.api.model.AssocTarget;
import org.alfresco.rest.api.model.Document;
import org.alfresco.rest.api.model.Folder;
import org.alfresco.rest.api.model.Node;
@@ -223,6 +225,26 @@ public interface Nodes
*/
QName createQName(String qnameStr);
+ QName getAssocType(String assocTypeQNameStr);
+
+ QName getAssocType(String assocTypeQNameStr, boolean mandatory);
+
+ /**
+ *
+ * @param parentNodeId
+ * @param entities
+ * @return
+ */
+ List addChildren(String parentNodeId, List entities);
+
+ /**
+ *
+ * @param sourceNodeId
+ * @param entities
+ * @return
+ */
+ List addTargets(String sourceNodeId, List entities);
+
/**
* API Constants - query parameters, etc
*/
diff --git a/source/java/org/alfresco/rest/api/impl/NodesImpl.java b/source/java/org/alfresco/rest/api/impl/NodesImpl.java
index d3c2269fd2..58d8554933 100644
--- a/source/java/org/alfresco/rest/api/impl/NodesImpl.java
+++ b/source/java/org/alfresco/rest/api/impl/NodesImpl.java
@@ -56,6 +56,7 @@ import org.alfresco.rest.api.Activities;
import org.alfresco.rest.api.Nodes;
import org.alfresco.rest.api.QuickShareLinks;
import org.alfresco.rest.api.model.AssocChild;
+import org.alfresco.rest.api.model.AssocTarget;
import org.alfresco.rest.api.model.ContentInfo;
import org.alfresco.rest.api.model.Document;
import org.alfresco.rest.api.model.Folder;
@@ -64,6 +65,7 @@ import org.alfresco.rest.api.model.PathInfo;
import org.alfresco.rest.api.model.PathInfo.ElementInfo;
import org.alfresco.rest.api.model.QuickShareLink;
import org.alfresco.rest.api.model.UserInfo;
+import org.alfresco.rest.api.nodes.NodeAssocService;
import org.alfresco.rest.framework.core.exceptions.ApiException;
import org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException;
import org.alfresco.rest.framework.core.exceptions.DisabledServiceException;
@@ -100,6 +102,7 @@ import org.alfresco.service.cmr.model.FileExistsException;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.model.FileNotFoundException;
+import org.alfresco.service.cmr.repository.AssociationExistsException;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.ContentService;
@@ -198,6 +201,7 @@ public class NodesImpl implements Nodes
private SiteService siteService;
private ActivityPoster poster;
private RetryingTransactionHelper retryingTransactionHelper;
+ private NodeAssocService nodeAssocService;
private enum Activity_Type
{
@@ -289,6 +293,13 @@ public class NodesImpl implements Nodes
this.poster = poster;
}
+ // Introduces permissions for Node Assoc (see public-rest-context.xml)
+ public void setNodeAssocService(NodeAssocService nodeAssocService)
+ {
+ this.nodeAssocService = nodeAssocService;
+ }
+
+
// excluded namespaces (aspects, properties, assoc types)
private static final List EXCLUDED_NS = Arrays.asList(NamespaceService.SYSTEM_MODEL_1_0_URI);
@@ -1586,6 +1597,18 @@ public class NodesImpl implements Nodes
writer.putContent("");
}
+ // eg. to create mandatory assoc(s)
+
+ if (nodeInfo.getTargets() != null)
+ {
+ addTargets(nodeRef.getId(), nodeInfo.getTargets());
+ }
+
+ if (nodeInfo.getSecondaryChildren() != null)
+ {
+ addChildren(nodeRef.getId(), nodeInfo.getSecondaryChildren());
+ }
+
Node newNode = getFolderOrDocument(nodeRef.getId(), parameters);
/* RA-834: commented-out since not currently applicable for empty file
@@ -1612,6 +1635,105 @@ public class NodesImpl implements Nodes
return parentNodeRef;
}
+ public List addChildren(String parentNodeId, List entities)
+ {
+ NodeRef parentNodeRef = validateNode(parentNodeId);
+
+ List result = new ArrayList<>(entities.size());
+
+ for (AssocChild assoc : entities)
+ {
+ QName assocTypeQName = getAssocType(assoc.getAssocType());
+
+ try
+ {
+ NodeRef childNodeRef = validateNode(assoc.getChildId());
+
+ String nodeName = (String)nodeService.getProperty(childNodeRef, ContentModel.PROP_NAME);
+ QName assocChildQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName(nodeName));
+
+ nodeService.addChild(parentNodeRef, childNodeRef, assocTypeQName, assocChildQName);
+ }
+ catch (AssociationExistsException aee)
+ {
+ throw new ConstraintViolatedException(aee.getMessage());
+ }
+ catch (DuplicateChildNodeNameException dcne)
+ {
+ throw new ConstraintViolatedException(dcne.getMessage());
+ }
+
+ result.add(assoc);
+ }
+
+ return result;
+ }
+
+ public List addTargets(String sourceNodeId, List entities)
+ {
+ List result = new ArrayList<>(entities.size());
+
+ NodeRef srcNodeRef = validateNode(sourceNodeId);
+
+ for (AssocTarget assoc : entities)
+ {
+ String assocTypeStr = assoc.getAssocType();
+ QName assocTypeQName = getAssocType(assocTypeStr);
+
+ String targetNodeId = assoc.getTargetId();
+
+ try
+ {
+ NodeRef tgtNodeRef = validateNode(targetNodeId);
+ nodeAssocService.createAssociation(srcNodeRef, tgtNodeRef, assocTypeQName);
+ }
+ catch (AssociationExistsException aee)
+ {
+ throw new ConstraintViolatedException("Node association '"+assocTypeStr+"' already exists from "+sourceNodeId+" to "+targetNodeId);
+ }
+ catch (IllegalArgumentException iae)
+ {
+ // note: for now, we assume it is invalid assocType - alternatively, we could attempt to pre-validate via dictionary.getAssociation
+ throw new InvalidArgumentException(sourceNodeId+","+assocTypeStr+","+targetNodeId);
+ }
+
+ result.add(assoc);
+ }
+ return result;
+ }
+
+ public QName getAssocType(String assocTypeQNameStr)
+ {
+ return getAssocType(assocTypeQNameStr, true);
+ }
+
+ public QName getAssocType(String assocTypeQNameStr, boolean mandatory)
+ {
+ QName assocType = null;
+
+ if ((assocTypeQNameStr != null) && (! assocTypeQNameStr.isEmpty()))
+ {
+ assocType = createQName(assocTypeQNameStr);
+ if (dictionaryService.getAssociation(assocType) == null)
+ {
+ throw new InvalidArgumentException("Unknown assocType: " + assocTypeQNameStr);
+ }
+
+ if (EXCLUDED_NS.contains(assocType.getNamespaceURI()))
+ {
+ throw new InvalidArgumentException("Invalid assocType: " + assocTypeQNameStr);
+ }
+ }
+
+ if (mandatory && (assocType == null))
+ {
+ throw new InvalidArgumentException("Missing assocType");
+ }
+
+ return assocType;
+ }
+
+
private NodeRef createNodeImpl(NodeRef parentNodeRef, String nodeName, QName nodeTypeQName, Map props)
{
NodeRef newNode = null;
diff --git a/source/java/org/alfresco/rest/api/model/Node.java b/source/java/org/alfresco/rest/api/model/Node.java
index f071e23517..ce999eaf8a 100644
--- a/source/java/org/alfresco/rest/api/model/Node.java
+++ b/source/java/org/alfresco/rest/api/model/Node.java
@@ -75,8 +75,11 @@ public class Node implements Comparable
protected PathInfo pathInfo;
protected String prefixTypeQName;
- // note: currently only used for create request
+ // please note: these are currently only used (optionally) for node create request
protected String relativePath;
+ protected List secondaryChildren;
+ protected List targets;
+
protected List aspectNames;
protected Map properties;
@@ -304,14 +307,14 @@ public class Node implements Comparable
this.allowableOperations = allowableOperations;
}
- public String getRelativePath()
+ public List getTargets()
{
- return relativePath;
+ return targets;
}
- public void setRelativePath(String relativePath)
+ public void setTargets(List targets)
{
- this.relativePath = relativePath;
+ this.targets = targets;
}
public Date getArchivedAt()
@@ -350,6 +353,26 @@ public class Node implements Comparable
return EqualsHelper.nullSafeEquals(getNodeRef(), node.getNodeRef());
}
+ public String getRelativePath()
+ {
+ return relativePath;
+ }
+
+ public void setRelativePath(String relativePath)
+ {
+ this.relativePath = relativePath;
+ }
+
+ public List getSecondaryChildren()
+ {
+ return secondaryChildren;
+ }
+
+ public void setSecondaryChildren(List secondaryChildren)
+ {
+ this.secondaryChildren = secondaryChildren;
+ }
+
@Override
public int compareTo(Node node)
{
diff --git a/source/java/org/alfresco/rest/api/nodes/AbstractNodeRelation.java b/source/java/org/alfresco/rest/api/nodes/AbstractNodeRelation.java
index bf3964862c..7ab1dd6b84 100644
--- a/source/java/org/alfresco/rest/api/nodes/AbstractNodeRelation.java
+++ b/source/java/org/alfresco/rest/api/nodes/AbstractNodeRelation.java
@@ -24,7 +24,6 @@ import org.alfresco.rest.api.model.Assoc;
import org.alfresco.rest.api.model.AssocChild;
import org.alfresco.rest.api.model.Node;
import org.alfresco.rest.api.model.UserInfo;
-import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
import org.alfresco.rest.framework.resource.parameters.Paging;
import org.alfresco.rest.framework.resource.parameters.Parameters;
@@ -101,37 +100,6 @@ public class AbstractNodeRelation implements InitializingBean
this.dictionaryService = sr.getDictionaryService();
}
- protected QName getAssocType(String assocTypeQNameStr)
- {
- return getAssocType(assocTypeQNameStr, true);
- }
-
- protected QName getAssocType(String assocTypeQNameStr, boolean mandatory)
- {
- QName assocType = null;
-
- if ((assocTypeQNameStr != null) && (! assocTypeQNameStr.isEmpty()))
- {
- assocType = nodes.createQName(assocTypeQNameStr);
- if (dictionaryService.getAssociation(assocType) == null)
- {
- throw new InvalidArgumentException("Unknown assocType: " + assocTypeQNameStr);
- }
-
- if (EXCLUDED_NS.contains(assocType.getNamespaceURI()))
- {
- throw new InvalidArgumentException("Invalid assocType: " + assocTypeQNameStr);
- }
- }
-
- if (mandatory && (assocType == null))
- {
- throw new InvalidArgumentException("Missing "+PARAM_ASSOC_TYPE);
- }
-
- return assocType;
- }
-
protected QNamePattern getAssocTypeFromWhereElseAll(Parameters parameters)
{
QNamePattern assocTypeQNamePattern = RegexQNamePattern.MATCH_ALL;
@@ -145,7 +113,7 @@ public class AbstractNodeRelation implements InitializingBean
String assocTypeQNameStr = propertyWalker.getProperty(PARAM_ASSOC_TYPE, WhereClauseParser.EQUALS, String.class);
if (assocTypeQNameStr != null)
{
- assocTypeQNamePattern = getAssocType(assocTypeQNameStr);
+ assocTypeQNamePattern = nodes.getAssocType(assocTypeQNameStr);
}
}
diff --git a/source/java/org/alfresco/rest/api/nodes/NodeChildrenRelation.java b/source/java/org/alfresco/rest/api/nodes/NodeChildrenRelation.java
index b5dc363c14..0584040e12 100644
--- a/source/java/org/alfresco/rest/api/nodes/NodeChildrenRelation.java
+++ b/source/java/org/alfresco/rest/api/nodes/NodeChildrenRelation.java
@@ -53,8 +53,10 @@ import org.springframework.extensions.webscripts.servlet.FormData;
* @author Jamal Kaabi-Mofrad
*/
@RelationshipResource(name = "children", entityResource = NodesEntityResource.class, title = "Folder children")
-public class NodeChildrenRelation implements RelationshipResourceAction.Read, RelationshipResourceAction.Create,
- MultiPartRelationshipResourceAction.Create, InitializingBean
+public class NodeChildrenRelation implements
+ RelationshipResourceAction.Read,
+ RelationshipResourceAction.Create,
+ MultiPartRelationshipResourceAction.Create, InitializingBean
{
private Nodes nodes;
@@ -108,7 +110,6 @@ public class NodeChildrenRelation implements RelationshipResourceAction.Read result = new ArrayList<>(nodeInfos.size());
- // TODO should we prevent batch create when we introduce new batch/bulk operation API ?
for (Node nodeInfo : nodeInfos)
{
result.add(nodes.createNode(parentFolderNodeId, nodeInfo, parameters));
diff --git a/source/java/org/alfresco/rest/api/nodes/NodeParentsRelation.java b/source/java/org/alfresco/rest/api/nodes/NodeParentsRelation.java
index b17a1c0c2d..1ffd4d3940 100644
--- a/source/java/org/alfresco/rest/api/nodes/NodeParentsRelation.java
+++ b/source/java/org/alfresco/rest/api/nodes/NodeParentsRelation.java
@@ -79,7 +79,7 @@ public class NodeParentsRelation extends AbstractNodeRelation implements Relatio
String assocTypeQNameStr = propertyWalker.getProperty(PARAM_ASSOC_TYPE, WhereClauseParser.EQUALS, String.class);
if (assocTypeQNameStr != null)
{
- assocTypeQNameParam = getAssocType(assocTypeQNameStr);
+ assocTypeQNameParam = nodes.getAssocType(assocTypeQNameStr);
}
}
diff --git a/source/java/org/alfresco/rest/api/nodes/NodeSecondaryChildrenRelation.java b/source/java/org/alfresco/rest/api/nodes/NodeSecondaryChildrenRelation.java
index c86ecf1c4a..b41e31750d 100644
--- a/source/java/org/alfresco/rest/api/nodes/NodeSecondaryChildrenRelation.java
+++ b/source/java/org/alfresco/rest/api/nodes/NodeSecondaryChildrenRelation.java
@@ -18,27 +18,21 @@
*/
package org.alfresco.rest.api.nodes;
-import org.alfresco.model.ContentModel;
import org.alfresco.rest.api.model.AssocChild;
import org.alfresco.rest.api.model.Node;
import org.alfresco.rest.framework.WebApiDescription;
-import org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException;
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
import org.alfresco.rest.framework.resource.RelationshipResource;
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
import org.alfresco.rest.framework.resource.parameters.Parameters;
-import org.alfresco.service.cmr.repository.AssociationExistsException;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
-import org.alfresco.service.cmr.repository.DuplicateChildNodeNameException;
import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.QNamePattern;
import org.alfresco.service.namespace.RegexQNamePattern;
-import java.util.ArrayList;
import java.util.List;
/**
@@ -88,37 +82,9 @@ public class NodeSecondaryChildrenRelation extends AbstractNodeRelation implemen
@Override
@WebApiDescription(title="Add secondary child assoc")
- public List create(String parentNodeId, List entity, Parameters parameters)
+ public List create(String parentNodeId, List entities, Parameters parameters)
{
- List result = new ArrayList<>(entity.size());
-
- NodeRef parentNodeRef = nodes.validateNode(parentNodeId);
-
- for (AssocChild assoc : entity)
- {
- QName assocTypeQName = getAssocType(assoc.getAssocType());
-
- try
- {
- NodeRef childNodeRef = nodes.validateNode(assoc.getChildId());
-
- String nodeName = (String)nodeService.getProperty(childNodeRef, ContentModel.PROP_NAME);
- QName assocChildQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName(nodeName));
-
- nodeService.addChild(parentNodeRef, childNodeRef, assocTypeQName, assocChildQName);
- }
- catch (AssociationExistsException aee)
- {
- throw new ConstraintViolatedException(aee.getMessage());
- }
- catch (DuplicateChildNodeNameException dcne)
- {
- throw new ConstraintViolatedException(dcne.getMessage());
- }
-
- result.add(assoc);
- }
- return result;
+ return nodes.addChildren(parentNodeId, entities);
}
@Override
@@ -129,7 +95,7 @@ public class NodeSecondaryChildrenRelation extends AbstractNodeRelation implemen
NodeRef childNodeRef = nodes.validateNode(childNodeId);
String assocTypeStr = parameters.getParameter(PARAM_ASSOC_TYPE);
- QName assocTypeQName = getAssocType(assocTypeStr, false);
+ QName assocTypeQName = nodes.getAssocType(assocTypeStr, false);
List assocRefs = nodeService.getChildAssocs(parentNodeRef);
diff --git a/source/java/org/alfresco/rest/api/nodes/NodeTargetsRelation.java b/source/java/org/alfresco/rest/api/nodes/NodeTargetsRelation.java
index 7d23d55c7a..12cf3fd807 100644
--- a/source/java/org/alfresco/rest/api/nodes/NodeTargetsRelation.java
+++ b/source/java/org/alfresco/rest/api/nodes/NodeTargetsRelation.java
@@ -21,22 +21,17 @@ package org.alfresco.rest.api.nodes;
import org.alfresco.rest.api.model.AssocTarget;
import org.alfresco.rest.api.model.Node;
import org.alfresco.rest.framework.WebApiDescription;
-import org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException;
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
-import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
import org.alfresco.rest.framework.resource.RelationshipResource;
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
import org.alfresco.rest.framework.resource.parameters.Parameters;
-import org.alfresco.service.cmr.repository.AssociationExistsException;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef;
-import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.QNamePattern;
import org.alfresco.service.namespace.RegexQNamePattern;
-import java.util.ArrayList;
import java.util.List;
/**
@@ -72,37 +67,9 @@ public class NodeTargetsRelation extends AbstractNodeRelation implements
@Override
@WebApiDescription(title="Add node assoc")
- public List create(String sourceNodeId, List entity, Parameters parameters)
+ public List create(String sourceNodeId, List entities, Parameters parameters)
{
- List result = new ArrayList<>(entity.size());
-
- NodeRef srcNodeRef = nodes.validateNode(sourceNodeId);
-
- for (AssocTarget assoc : entity)
- {
- String assocTypeStr = assoc.getAssocType();
- QName assocTypeQName = getAssocType(assocTypeStr);
-
- String targetNodeId = assoc.getTargetId();
-
- try
- {
- NodeRef tgtNodeRef = nodes.validateNode(targetNodeId);
- nodeAssocService.createAssociation(srcNodeRef, tgtNodeRef, assocTypeQName);
- }
- catch (AssociationExistsException aee)
- {
- throw new ConstraintViolatedException("Node association '"+assocTypeStr+"' already exists from "+sourceNodeId+" to "+targetNodeId);
- }
- catch (IllegalArgumentException iae)
- {
- // note: for now, we assume it is invalid assocType - alternatively, we could attempt to pre-validate via dictionary.getAssociation
- throw new InvalidArgumentException(sourceNodeId+","+assocTypeStr+","+targetNodeId);
- }
-
- result.add(assoc);
- }
- return result;
+ return nodes.addTargets(sourceNodeId, entities);
}
@Override
@@ -113,7 +80,7 @@ public class NodeTargetsRelation extends AbstractNodeRelation implements
NodeRef tgtNodeRef = nodes.validateNode(targetNodeId);
String assocTypeStr = parameters.getParameter(PARAM_ASSOC_TYPE);
- QNamePattern assocTypeQName = getAssocType(assocTypeStr, false);
+ QNamePattern assocTypeQName = nodes.getAssocType(assocTypeStr, false);
if (assocTypeQName == null)
{
diff --git a/source/test-java/org/alfresco/rest/api/tests/NodeAssociationsApiTest.java b/source/test-java/org/alfresco/rest/api/tests/NodeAssociationsApiTest.java
index 1528104032..76b963b743 100644
--- a/source/test-java/org/alfresco/rest/api/tests/NodeAssociationsApiTest.java
+++ b/source/test-java/org/alfresco/rest/api/tests/NodeAssociationsApiTest.java
@@ -1198,6 +1198,77 @@ public class NodeAssociationsApiTest extends AbstractBaseApiTest
}
}
+ @Test
+ public void testCreateNodeWithAssocs() throws Exception
+ {
+ // as user 1
+ String myFolderNodeId = getMyNodeId(user1);
+
+ // create node with some assocs in a single call
+
+ // create folder
+ Node n = new Node();
+ n.setName("f1");
+ n.setNodeType(TYPE_CM_FOLDER);
+ n.setAspectNames(Arrays.asList(ASPECT_CM_PREFERENCES));
+ HttpResponse response = post(getNodeChildrenUrl(myFolderNodeId), user1, toJsonAsStringNonNull(n), 201);
+ String f1Id = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Node.class).getId();
+
+ // create content node
+ String o1Name = "o1";
+ n = new Node();
+ n.setName(o1Name);
+ n.setNodeType(TYPE_CM_CONTENT);
+ response = post(getNodeChildrenUrl(f1Id), user1, toJsonAsStringNonNull(n), 201);
+ String o1Id = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Node.class).getId();
+
+ String o2Name = "o2";
+ n = new Node();
+ n.setName(o2Name);
+ n.setNodeType(TYPE_CM_CONTENT);
+ response = post(getNodeChildrenUrl(f1Id), user1, toJsonAsStringNonNull(n), 201);
+ String o2Id = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Node.class).getId();
+
+ // create folder node with some assocs
+ String f2Name = "f2";
+ n = new Node();
+ n.setName(f2Name);
+ n.setNodeType(TYPE_CM_FOLDER);
+
+ AssocChild secChild = new AssocChild(o1Id, ASSOC_TYPE_CM_CONTAINS);
+ n.setSecondaryChildren(Collections.singletonList(secChild));
+
+ AssocTarget tgt = new AssocTarget(o2Id, ASSOC_TYPE_CM_REFERENCES);
+ n.setTargets(Collections.singletonList(tgt));
+
+ response = post(getNodeChildrenUrl(myFolderNodeId), user1, toJsonAsStringNonNull(n), 201);
+ String f2Id = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Node.class).getId();
+
+ try
+ {
+ Paging paging = getPaging(0, 100);
+
+ response = getAll(getNodeSecondaryChildrenUrl(f2Id), user1, paging, null, 200);
+ List nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
+ assertEquals(1, nodes.size());
+ assertEquals(o1Id, nodes.get(0).getId());
+
+ response = getAll(getNodeTargetsUrl(f2Id), user1, paging, null, 200);
+ nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
+ assertEquals(1, nodes.size());
+ assertEquals(o2Id, nodes.get(0).getId());
+
+ // TODO test model with mandatory aspect
+ }
+ finally
+ {
+ // some cleanup
+ Map params = Collections.singletonMap(Nodes.PARAM_PERMANENT, "true");
+ delete(URL_NODES, user1, f1Id, params, 204);
+ delete(URL_NODES, user1, f2Id, params, 204);
+ }
+ }
+
@Override
public String getScope()
{
diff --git a/source/test-java/org/alfresco/rest/api/tests/client/data/Node.java b/source/test-java/org/alfresco/rest/api/tests/client/data/Node.java
index 0a8d385aaf..6b5d6c272b 100644
--- a/source/test-java/org/alfresco/rest/api/tests/client/data/Node.java
+++ b/source/test-java/org/alfresco/rest/api/tests/client/data/Node.java
@@ -25,6 +25,9 @@
*/
package org.alfresco.rest.api.tests.client.data;
+import org.alfresco.rest.api.model.AssocChild;
+import org.alfresco.rest.api.model.AssocTarget;
+
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -70,7 +73,10 @@ public class Node
protected List allowableOperations;
- protected String relativePath; // optionally used in create node request
+ // please note: these are currently only used (optionally) for node create request
+ protected String relativePath;
+ protected List secondaryChildren;
+ protected List targets;
public Node()
{
@@ -246,6 +252,7 @@ public class Node
this.allowableOperations = allowableOperations;
}
+
public String getRelativePath()
{
return relativePath;
@@ -256,6 +263,27 @@ public class Node
this.relativePath = relativePath;
}
+ public List getSecondaryChildren()
+ {
+ return secondaryChildren;
+ }
+
+ public void setSecondaryChildren(List secondaryChildren)
+ {
+ this.secondaryChildren = secondaryChildren;
+ }
+
+ public List getTargets()
+ {
+ return targets;
+ }
+
+ public void setTargets(List targets)
+ {
+ this.targets = targets;
+ }
+
+
// note: can be child or peer (latter has assocType only)
protected Association association;