Merged API-STRIKES-BACK (5.2.0) to HEAD (5.2)

126200 jvonka: Node Associations - follow-on to r126104 to provide initial impl for both peer & child assocs
   - experimental -> pending detailed review & discussion (and tests)


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@127569 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jamal Kaabi-Mofrad
2016-06-02 21:39:39 +00:00
parent f3b786ec57
commit 4e8f965a36
8 changed files with 370 additions and 93 deletions

View File

@@ -46,6 +46,7 @@ import org.alfresco.rest.antlr.WhereClauseParser;
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.ContentInfo;
import org.alfresco.rest.api.model.Document;
import org.alfresco.rest.api.model.Folder;
@@ -894,6 +895,31 @@ public class NodesImpl implements Nodes
node.setAllowableOperations((allowableOperations.size() > 0 )? allowableOperations : null);
}
if (includeParam.contains(PARAM_INCLUDE_ASSOCIATION))
{
// Ugh ... can we optimise this and return the actual assoc directly (via FileFolderService/GetChildrenCQ) ?
ChildAssociationRef parentAssocRef = nodeService.getPrimaryParent(nodeRef);
if (! parentAssocRef.getParentRef().equals(parentNodeRef))
{
List<ChildAssociationRef> parentAssocRefs = nodeService.getParentAssocs(nodeRef);
for (ChildAssociationRef pAssocRef : parentAssocRefs)
{
if (pAssocRef.getParentRef().equals(parentNodeRef))
{
// for now, assume same parent/child cannot appear more than once (due to unique name)
parentAssocRef = pAssocRef;
break;
}
}
}
AssocChild childAssoc = new AssocChild(
parentAssocRef.getTypeQName().toPrefixString(namespaceService),
parentAssocRef.isPrimary(),
parentAssocRef.getQName().toPrefixString(namespaceService));
node.setAssociation(childAssoc);
}
node.setNodeType(nodeTypeQName.toPrefixString(namespaceService));
node.setPath(pathInfo);