mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD (5.2) to 5.2.N (5.2.1)
127587 jkaabimofrad: Merged API-STRIKES-BACK (5.2.0) to HEAD (5.2) 127040 jvonka: Node Associations - child & peer - exclude "sys" namespace - common code for listing - RA-745, 920, RA-921, RA-930, RA-742, RA-918, RA-919 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@127679 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -287,7 +287,7 @@ public class NodesImpl implements Nodes
|
|||||||
this.poster = poster;
|
this.poster = poster;
|
||||||
}
|
}
|
||||||
|
|
||||||
// excluded namespaces (aspects and properties)
|
// excluded namespaces (aspects, properties, assoc types)
|
||||||
private static final List<String> EXCLUDED_NS = Arrays.asList(NamespaceService.SYSTEM_MODEL_1_0_URI);
|
private static final List<String> EXCLUDED_NS = Arrays.asList(NamespaceService.SYSTEM_MODEL_1_0_URI);
|
||||||
|
|
||||||
// excluded aspects
|
// excluded aspects
|
||||||
@@ -906,7 +906,9 @@ public class NodesImpl implements Nodes
|
|||||||
{
|
{
|
||||||
// Ugh ... can we optimise this and return the actual assoc directly (via FileFolderService/GetChildrenCQ) ?
|
// Ugh ... can we optimise this and return the actual assoc directly (via FileFolderService/GetChildrenCQ) ?
|
||||||
ChildAssociationRef parentAssocRef = nodeService.getPrimaryParent(nodeRef);
|
ChildAssociationRef parentAssocRef = nodeService.getPrimaryParent(nodeRef);
|
||||||
if (! parentAssocRef.getParentRef().equals(parentNodeRef))
|
|
||||||
|
// note: parentAssocRef.parentRef can be null for -root- node !
|
||||||
|
if ((parentAssocRef == null) || (parentAssocRef.getParentRef() == null) || (! parentAssocRef.getParentRef().equals(parentNodeRef)))
|
||||||
{
|
{
|
||||||
List<ChildAssociationRef> parentAssocRefs = nodeService.getParentAssocs(nodeRef);
|
List<ChildAssociationRef> parentAssocRefs = nodeService.getParentAssocs(nodeRef);
|
||||||
for (ChildAssociationRef pAssocRef : parentAssocRefs)
|
for (ChildAssociationRef pAssocRef : parentAssocRefs)
|
||||||
@@ -920,11 +922,18 @@ public class NodesImpl implements Nodes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AssocChild childAssoc = new AssocChild(
|
if (parentAssocRef != null)
|
||||||
parentAssocRef.getTypeQName().toPrefixString(namespaceService),
|
{
|
||||||
parentAssocRef.isPrimary());
|
QName assocTypeQName = parentAssocRef.getTypeQName();
|
||||||
|
if ((assocTypeQName != null) && (! EXCLUDED_NS.contains(assocTypeQName.getNamespaceURI())))
|
||||||
|
{
|
||||||
|
AssocChild childAssoc = new AssocChild(
|
||||||
|
assocTypeQName.toPrefixString(namespaceService),
|
||||||
|
parentAssocRef.isPrimary());
|
||||||
|
|
||||||
node.setAssociation(childAssoc);
|
node.setAssociation(childAssoc);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
node.setNodeType(nodeTypeQName.toPrefixString(namespaceService));
|
node.setNodeType(nodeTypeQName.toPrefixString(namespaceService));
|
||||||
|
@@ -21,14 +21,10 @@ package org.alfresco.rest.api.nodes;
|
|||||||
import org.alfresco.rest.antlr.WhereClauseParser;
|
import org.alfresco.rest.antlr.WhereClauseParser;
|
||||||
import org.alfresco.rest.api.Nodes;
|
import org.alfresco.rest.api.Nodes;
|
||||||
import org.alfresco.rest.api.model.Assoc;
|
import org.alfresco.rest.api.model.Assoc;
|
||||||
import org.alfresco.rest.api.model.AssocTarget;
|
import org.alfresco.rest.api.model.AssocChild;
|
||||||
import org.alfresco.rest.api.model.Node;
|
import org.alfresco.rest.api.model.Node;
|
||||||
import org.alfresco.rest.api.model.UserInfo;
|
import org.alfresco.rest.api.model.UserInfo;
|
||||||
import org.alfresco.rest.framework.WebApiDescription;
|
|
||||||
import org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException;
|
|
||||||
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
|
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.CollectionWithPagingInfo;
|
||||||
import org.alfresco.rest.framework.resource.parameters.Paging;
|
import org.alfresco.rest.framework.resource.parameters.Paging;
|
||||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||||
@@ -37,11 +33,10 @@ import org.alfresco.rest.framework.resource.parameters.where.QueryHelper;
|
|||||||
import org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker;
|
import org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker;
|
||||||
import org.alfresco.service.ServiceRegistry;
|
import org.alfresco.service.ServiceRegistry;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
import org.alfresco.service.cmr.repository.AssociationExistsException;
|
|
||||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||||
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
import org.alfresco.service.cmr.repository.StoreRef;
|
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.service.namespace.QNamePattern;
|
import org.alfresco.service.namespace.QNamePattern;
|
||||||
@@ -65,6 +60,9 @@ public class AbstractNodeRelation implements InitializingBean
|
|||||||
{
|
{
|
||||||
public final static String PARAM_ASSOC_TYPE = "assocType";
|
public final static String PARAM_ASSOC_TYPE = "assocType";
|
||||||
|
|
||||||
|
// excluded namespaces (assoc types)
|
||||||
|
protected static final List<String> EXCLUDED_NS = Arrays.asList(NamespaceService.SYSTEM_MODEL_1_0_URI);
|
||||||
|
|
||||||
private final static Set<String> WHERE_PARAMS =
|
private final static Set<String> WHERE_PARAMS =
|
||||||
new HashSet<>(Arrays.asList(new String[] {PARAM_ASSOC_TYPE}));
|
new HashSet<>(Arrays.asList(new String[] {PARAM_ASSOC_TYPE}));
|
||||||
|
|
||||||
@@ -95,29 +93,30 @@ public class AbstractNodeRelation implements InitializingBean
|
|||||||
this.dictionaryService = sr.getDictionaryService();
|
this.dictionaryService = sr.getDictionaryService();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected QName getAssocType(String prefixAssocTypeStr)
|
protected QName getAssocType(String assocTypeQNameStr)
|
||||||
{
|
{
|
||||||
return getAssocType(prefixAssocTypeStr, true, true);
|
return getAssocType(assocTypeQNameStr, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected QName getAssocType(String prefixAssocTypeStr, boolean mandatory, boolean validate)
|
protected QName getAssocType(String assocTypeQNameStr, boolean mandatory)
|
||||||
{
|
{
|
||||||
QName assocType = null;
|
QName assocType = null;
|
||||||
|
|
||||||
if ((prefixAssocTypeStr != null) && (! prefixAssocTypeStr.isEmpty()))
|
if ((assocTypeQNameStr != null) && (! assocTypeQNameStr.isEmpty()))
|
||||||
{
|
{
|
||||||
assocType = QName.createQName(prefixAssocTypeStr, namespaceService);
|
assocType = nodes.createQName(assocTypeQNameStr);
|
||||||
|
if (dictionaryService.getAssociation(assocType) == null)
|
||||||
if (validate)
|
|
||||||
{
|
{
|
||||||
if (dictionaryService.getAssociation(assocType) == null)
|
throw new InvalidArgumentException("Unknown assocType: " + assocTypeQNameStr);
|
||||||
{
|
}
|
||||||
throw new InvalidArgumentException("Unknown filter assocType: "+prefixAssocTypeStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (EXCLUDED_NS.contains(assocType.getNamespaceURI()))
|
||||||
|
{
|
||||||
|
throw new InvalidArgumentException("Invalid assocType: " + assocTypeQNameStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (mandatory)
|
|
||||||
|
if (mandatory && (assocType == null))
|
||||||
{
|
{
|
||||||
throw new InvalidArgumentException("Missing "+PARAM_ASSOC_TYPE);
|
throw new InvalidArgumentException("Missing "+PARAM_ASSOC_TYPE);
|
||||||
}
|
}
|
||||||
@@ -144,4 +143,82 @@ public class AbstractNodeRelation implements InitializingBean
|
|||||||
|
|
||||||
return assocTypeQNamePattern;
|
return assocTypeQNamePattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected CollectionWithPagingInfo<Node> listNodePeerAssocs(List<AssociationRef> assocRefs, Parameters parameters, boolean returnTarget)
|
||||||
|
{
|
||||||
|
Map<QName, String> qnameMap = new HashMap<>(3);
|
||||||
|
|
||||||
|
Map<String, UserInfo> mapUserInfo = new HashMap<>(10);
|
||||||
|
|
||||||
|
List<String> includeParam = parameters.getInclude();
|
||||||
|
|
||||||
|
List<Node> collection = new ArrayList<Node>(assocRefs.size());
|
||||||
|
for (AssociationRef assocRef : assocRefs)
|
||||||
|
{
|
||||||
|
// minimal info by default (unless "include"d otherwise)
|
||||||
|
NodeRef nodeRef = (returnTarget ? assocRef.getTargetRef() : assocRef.getSourceRef());
|
||||||
|
|
||||||
|
Node node = nodes.getFolderOrDocument(nodeRef, null, null, includeParam, mapUserInfo);
|
||||||
|
|
||||||
|
QName assocTypeQName = assocRef.getTypeQName();
|
||||||
|
|
||||||
|
if (! EXCLUDED_NS.contains(assocTypeQName.getNamespaceURI()))
|
||||||
|
{
|
||||||
|
String assocType = qnameMap.get(assocTypeQName);
|
||||||
|
if (assocType == null)
|
||||||
|
{
|
||||||
|
assocType = assocTypeQName.toPrefixString(namespaceService);
|
||||||
|
qnameMap.put(assocTypeQName, assocType);
|
||||||
|
}
|
||||||
|
|
||||||
|
node.setAssociation(new Assoc(assocType));
|
||||||
|
|
||||||
|
collection.add(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Paging paging = parameters.getPaging();
|
||||||
|
return CollectionWithPagingInfo.asPaged(paging, collection, false, collection.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected CollectionWithPagingInfo<Node> listNodeChildAssocs(List<ChildAssociationRef> childAssocRefs, Parameters parameters, Boolean isPrimary, boolean returnChild)
|
||||||
|
{
|
||||||
|
Map<QName, String> qnameMap = new HashMap<>(3);
|
||||||
|
|
||||||
|
Map<String, UserInfo> mapUserInfo = new HashMap<>(10);
|
||||||
|
|
||||||
|
List<String> includeParam = parameters.getInclude();
|
||||||
|
|
||||||
|
List<Node> collection = new ArrayList<Node>(childAssocRefs.size());
|
||||||
|
for (ChildAssociationRef childAssocRef : childAssocRefs)
|
||||||
|
{
|
||||||
|
if (isPrimary == null || (isPrimary == childAssocRef.isPrimary()))
|
||||||
|
{
|
||||||
|
// minimal info by default (unless "include"d otherwise)
|
||||||
|
NodeRef nodeRef = (returnChild ? childAssocRef.getChildRef() : childAssocRef.getParentRef());
|
||||||
|
|
||||||
|
Node node = nodes.getFolderOrDocument(nodeRef, null, null, includeParam, mapUserInfo);
|
||||||
|
|
||||||
|
QName assocTypeQName = childAssocRef.getTypeQName();
|
||||||
|
|
||||||
|
if (!EXCLUDED_NS.contains(assocTypeQName.getNamespaceURI()))
|
||||||
|
{
|
||||||
|
String assocType = qnameMap.get(assocTypeQName);
|
||||||
|
if (assocType == null)
|
||||||
|
{
|
||||||
|
assocType = assocTypeQName.toPrefixString(namespaceService);
|
||||||
|
qnameMap.put(assocTypeQName, assocType);
|
||||||
|
}
|
||||||
|
|
||||||
|
node.setAssociation(new AssocChild(assocType, childAssocRef.isPrimary()));
|
||||||
|
|
||||||
|
|
||||||
|
collection.add(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Paging paging = parameters.getPaging();
|
||||||
|
return CollectionWithPagingInfo.asPaged(paging, collection, false, collection.size());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,25 +18,18 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.rest.api.nodes;
|
package org.alfresco.rest.api.nodes;
|
||||||
|
|
||||||
import org.alfresco.rest.api.model.AssocChild;
|
|
||||||
import org.alfresco.rest.api.model.Node;
|
import org.alfresco.rest.api.model.Node;
|
||||||
import org.alfresco.rest.api.model.UserInfo;
|
|
||||||
import org.alfresco.rest.framework.WebApiDescription;
|
import org.alfresco.rest.framework.WebApiDescription;
|
||||||
import org.alfresco.rest.framework.resource.RelationshipResource;
|
import org.alfresco.rest.framework.resource.RelationshipResource;
|
||||||
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
|
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
|
||||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||||
import org.alfresco.rest.framework.resource.parameters.Paging;
|
|
||||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.namespace.QName;
|
|
||||||
import org.alfresco.service.namespace.QNamePattern;
|
import org.alfresco.service.namespace.QNamePattern;
|
||||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Node Parents
|
* Node Parents
|
||||||
@@ -60,43 +53,16 @@ public class NodeParentsRelation extends AbstractNodeRelation implements Relatio
|
|||||||
|
|
||||||
QNamePattern assocTypeQNameParam = getAssocTypeFromWhereElseAll(parameters);
|
QNamePattern assocTypeQNameParam = getAssocTypeFromWhereElseAll(parameters);
|
||||||
|
|
||||||
List<ChildAssociationRef> assocRefs = null;
|
List<ChildAssociationRef> childAssocRefs = null;
|
||||||
if (assocTypeQNameParam.equals(RegexQNamePattern.MATCH_ALL))
|
if (assocTypeQNameParam.equals(RegexQNamePattern.MATCH_ALL))
|
||||||
{
|
{
|
||||||
assocRefs = nodeService.getParentAssocs(childNodeRef);
|
childAssocRefs = nodeService.getParentAssocs(childNodeRef);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assocRefs = nodeService.getParentAssocs(childNodeRef, assocTypeQNameParam, RegexQNamePattern.MATCH_ALL);
|
childAssocRefs = nodeService.getParentAssocs(childNodeRef, assocTypeQNameParam, RegexQNamePattern.MATCH_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<QName, String> qnameMap = new HashMap<>(3);
|
return listNodeChildAssocs(childAssocRefs, parameters, null, false);
|
||||||
|
|
||||||
Map<String, UserInfo> mapUserInfo = new HashMap<>(10);
|
|
||||||
|
|
||||||
List<String> includeParam = parameters.getInclude();
|
|
||||||
|
|
||||||
List<Node> collection = new ArrayList<>(assocRefs.size());
|
|
||||||
for (ChildAssociationRef assocRef : assocRefs)
|
|
||||||
{
|
|
||||||
// minimal info by default (unless "include"d otherwise)
|
|
||||||
Node node = nodes.getFolderOrDocument(assocRef.getParentRef(), null, null, includeParam, mapUserInfo);
|
|
||||||
|
|
||||||
QName assocTypeQName = assocRef.getTypeQName();
|
|
||||||
|
|
||||||
String assocType = qnameMap.get(assocTypeQName);
|
|
||||||
if (assocType == null)
|
|
||||||
{
|
|
||||||
assocType = assocTypeQName.toPrefixString(namespaceService);
|
|
||||||
qnameMap.put(assocTypeQName, assocType);
|
|
||||||
}
|
|
||||||
|
|
||||||
node.setAssociation(new AssocChild(assocType, assocRef.isPrimary()));
|
|
||||||
|
|
||||||
collection.add(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
Paging paging = parameters.getPaging();
|
|
||||||
return CollectionWithPagingInfo.asPaged(paging, collection, false, collection.size());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -21,7 +21,6 @@ package org.alfresco.rest.api.nodes;
|
|||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.rest.api.model.AssocChild;
|
import org.alfresco.rest.api.model.AssocChild;
|
||||||
import org.alfresco.rest.api.model.Node;
|
import org.alfresco.rest.api.model.Node;
|
||||||
import org.alfresco.rest.api.model.UserInfo;
|
|
||||||
import org.alfresco.rest.framework.WebApiDescription;
|
import org.alfresco.rest.framework.WebApiDescription;
|
||||||
import org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException;
|
import org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException;
|
||||||
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
||||||
@@ -29,7 +28,6 @@ import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
|
|||||||
import org.alfresco.rest.framework.resource.RelationshipResource;
|
import org.alfresco.rest.framework.resource.RelationshipResource;
|
||||||
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
|
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
|
||||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||||
import org.alfresco.rest.framework.resource.parameters.Paging;
|
|
||||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||||
import org.alfresco.service.cmr.repository.AssociationExistsException;
|
import org.alfresco.service.cmr.repository.AssociationExistsException;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
@@ -41,9 +39,7 @@ import org.alfresco.service.namespace.QNamePattern;
|
|||||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Node Secondary Children
|
* Node Secondary Children
|
||||||
@@ -77,46 +73,17 @@ public class NodeSecondaryChildrenRelation extends AbstractNodeRelation implemen
|
|||||||
|
|
||||||
QNamePattern assocTypeQNameParam = getAssocTypeFromWhereElseAll(parameters);
|
QNamePattern assocTypeQNameParam = getAssocTypeFromWhereElseAll(parameters);
|
||||||
|
|
||||||
List<ChildAssociationRef> assocRefs = null;
|
List<ChildAssociationRef> childAssocRefs = null;
|
||||||
if (assocTypeQNameParam.equals(RegexQNamePattern.MATCH_ALL))
|
if (assocTypeQNameParam.equals(RegexQNamePattern.MATCH_ALL))
|
||||||
{
|
{
|
||||||
assocRefs = nodeService.getChildAssocs(parentNodeRef);
|
childAssocRefs = nodeService.getChildAssocs(parentNodeRef);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assocRefs = nodeService.getChildAssocs(parentNodeRef, assocTypeQNameParam, RegexQNamePattern.MATCH_ALL);
|
childAssocRefs = nodeService.getChildAssocs(parentNodeRef, assocTypeQNameParam, RegexQNamePattern.MATCH_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<QName, String> qnameMap = new HashMap<>(3);
|
return listNodeChildAssocs(childAssocRefs, parameters, false, true);
|
||||||
|
|
||||||
Map<String, UserInfo> mapUserInfo = new HashMap<>(10);
|
|
||||||
|
|
||||||
List<String> includeParam = parameters.getInclude();
|
|
||||||
|
|
||||||
List<Node> collection = new ArrayList<>(assocRefs.size());
|
|
||||||
for (ChildAssociationRef assocRef : assocRefs)
|
|
||||||
{
|
|
||||||
if (! assocRef.isPrimary())
|
|
||||||
{
|
|
||||||
// minimal info by default (unless "include"d otherwise)
|
|
||||||
Node node = nodes.getFolderOrDocument(assocRef.getChildRef(), null, null, includeParam, mapUserInfo);
|
|
||||||
|
|
||||||
QName assocTypeQName = assocRef.getTypeQName();
|
|
||||||
String assocType = qnameMap.get(assocTypeQName);
|
|
||||||
if (assocType == null)
|
|
||||||
{
|
|
||||||
assocType = assocTypeQName.toPrefixString(namespaceService);
|
|
||||||
qnameMap.put(assocTypeQName, assocType);
|
|
||||||
}
|
|
||||||
|
|
||||||
node.setAssociation(new AssocChild(assocType, assocRef.isPrimary()));
|
|
||||||
|
|
||||||
collection.add(node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Paging paging = parameters.getPaging();
|
|
||||||
return CollectionWithPagingInfo.asPaged(paging, collection, false, collection.size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -162,7 +129,7 @@ public class NodeSecondaryChildrenRelation extends AbstractNodeRelation implemen
|
|||||||
NodeRef childNodeRef = nodes.validateNode(childNodeId);
|
NodeRef childNodeRef = nodes.validateNode(childNodeId);
|
||||||
|
|
||||||
String assocTypeStr = parameters.getParameter(PARAM_ASSOC_TYPE);
|
String assocTypeStr = parameters.getParameter(PARAM_ASSOC_TYPE);
|
||||||
QName assocTypeQName = getAssocType(assocTypeStr, false, true);
|
QName assocTypeQName = getAssocType(assocTypeStr, false);
|
||||||
|
|
||||||
List<ChildAssociationRef> assocRefs = nodeService.getChildAssocs(parentNodeRef);
|
List<ChildAssociationRef> assocRefs = nodeService.getChildAssocs(parentNodeRef);
|
||||||
|
|
||||||
|
@@ -18,49 +18,17 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.rest.api.nodes;
|
package org.alfresco.rest.api.nodes;
|
||||||
|
|
||||||
import org.activiti.engine.history.HistoricActivityInstance;
|
|
||||||
import org.alfresco.repo.web.scripts.admin.NodeBrowserPost;
|
|
||||||
import org.alfresco.rest.antlr.WhereClauseParser;
|
|
||||||
import org.alfresco.rest.api.Nodes;
|
|
||||||
import org.alfresco.rest.api.model.Assoc;
|
|
||||||
import org.alfresco.rest.api.model.Comment;
|
|
||||||
import org.alfresco.rest.api.model.Node;
|
import org.alfresco.rest.api.model.Node;
|
||||||
import org.alfresco.rest.api.model.UserInfo;
|
|
||||||
import org.alfresco.rest.framework.WebApiDescription;
|
import org.alfresco.rest.framework.WebApiDescription;
|
||||||
import org.alfresco.rest.framework.WebApiParam;
|
|
||||||
import org.alfresco.rest.framework.WebApiParameters;
|
|
||||||
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
|
|
||||||
import org.alfresco.rest.framework.resource.RelationshipResource;
|
import org.alfresco.rest.framework.resource.RelationshipResource;
|
||||||
import org.alfresco.rest.framework.resource.actions.interfaces.MultiPartRelationshipResourceAction;
|
|
||||||
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
|
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
|
||||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||||
import org.alfresco.rest.framework.resource.parameters.Paging;
|
|
||||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||||
import org.alfresco.rest.framework.resource.parameters.where.Query;
|
|
||||||
import org.alfresco.rest.framework.resource.parameters.where.QueryHelper;
|
|
||||||
import org.alfresco.rest.framework.webscripts.WithResponse;
|
|
||||||
import org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker;
|
|
||||||
import org.alfresco.rest.workflow.api.model.Activity;
|
|
||||||
import org.alfresco.service.ServiceRegistry;
|
|
||||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
|
||||||
import org.alfresco.service.cmr.repository.StoreRef;
|
|
||||||
import org.alfresco.service.cmr.search.ResultSetRow;
|
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
|
||||||
import org.alfresco.service.namespace.QName;
|
|
||||||
import org.alfresco.service.namespace.QNamePattern;
|
import org.alfresco.service.namespace.QNamePattern;
|
||||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
|
||||||
import org.alfresco.util.ParameterCheck;
|
|
||||||
import org.alfresco.util.PropertyCheck;
|
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
|
||||||
import org.springframework.extensions.webscripts.servlet.FormData;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Node Sources - list node (peer) associations from target to sources
|
* Node Sources - list node (peer) associations from target to sources
|
||||||
@@ -85,31 +53,6 @@ public class NodeSourcesRelation extends AbstractNodeRelation implements Relatio
|
|||||||
|
|
||||||
List<AssociationRef> assocRefs = nodeService.getSourceAssocs(targetNodeRef, assocTypeQNameParam);
|
List<AssociationRef> assocRefs = nodeService.getSourceAssocs(targetNodeRef, assocTypeQNameParam);
|
||||||
|
|
||||||
Map<QName, String> qnameMap = new HashMap<>(3);
|
return listNodePeerAssocs(assocRefs, parameters, false);
|
||||||
|
|
||||||
Map<String, UserInfo> mapUserInfo = new HashMap<>(10);
|
|
||||||
|
|
||||||
List<String> includeParam = parameters.getInclude();
|
|
||||||
|
|
||||||
List<Node> collection = new ArrayList<Node>(assocRefs.size());
|
|
||||||
for (AssociationRef assocRef : assocRefs)
|
|
||||||
{
|
|
||||||
// minimal info by default (unless "include"d otherwise)
|
|
||||||
Node node = nodes.getFolderOrDocument(assocRef.getSourceRef(), null, null, includeParam, mapUserInfo);
|
|
||||||
|
|
||||||
QName assocTypeQName = assocRef.getTypeQName();
|
|
||||||
String assocType = qnameMap.get(assocTypeQName);
|
|
||||||
if (assocType == null)
|
|
||||||
{
|
|
||||||
assocType = assocTypeQName.toPrefixString(namespaceService);
|
|
||||||
qnameMap.put(assocTypeQName, assocType);
|
|
||||||
}
|
|
||||||
node.setAssociation(new Assoc(assocType));
|
|
||||||
|
|
||||||
collection.add(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
Paging paging = parameters.getPaging();
|
|
||||||
return CollectionWithPagingInfo.asPaged(paging, collection, false, collection.size());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,10 +18,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.rest.api.nodes;
|
package org.alfresco.rest.api.nodes;
|
||||||
|
|
||||||
import org.alfresco.rest.api.model.Assoc;
|
|
||||||
import org.alfresco.rest.api.model.AssocTarget;
|
import org.alfresco.rest.api.model.AssocTarget;
|
||||||
import org.alfresco.rest.api.model.Node;
|
import org.alfresco.rest.api.model.Node;
|
||||||
import org.alfresco.rest.api.model.UserInfo;
|
|
||||||
import org.alfresco.rest.framework.WebApiDescription;
|
import org.alfresco.rest.framework.WebApiDescription;
|
||||||
import org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException;
|
import org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException;
|
||||||
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
||||||
@@ -29,7 +27,6 @@ import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
|
|||||||
import org.alfresco.rest.framework.resource.RelationshipResource;
|
import org.alfresco.rest.framework.resource.RelationshipResource;
|
||||||
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
|
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
|
||||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||||
import org.alfresco.rest.framework.resource.parameters.Paging;
|
|
||||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||||
import org.alfresco.service.cmr.repository.AssociationExistsException;
|
import org.alfresco.service.cmr.repository.AssociationExistsException;
|
||||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||||
@@ -40,9 +37,7 @@ import org.alfresco.service.namespace.QNamePattern;
|
|||||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Node Targets
|
* Node Targets
|
||||||
@@ -72,32 +67,7 @@ public class NodeTargetsRelation extends AbstractNodeRelation implements
|
|||||||
|
|
||||||
List<AssociationRef> assocRefs = nodeService.getTargetAssocs(sourceNodeRef, assocTypeQNameParam);
|
List<AssociationRef> assocRefs = nodeService.getTargetAssocs(sourceNodeRef, assocTypeQNameParam);
|
||||||
|
|
||||||
Map<QName, String> qnameMap = new HashMap<>(3);
|
return listNodePeerAssocs(assocRefs, parameters, true);
|
||||||
|
|
||||||
Map<String, UserInfo> mapUserInfo = new HashMap<>(10);
|
|
||||||
|
|
||||||
List<String> includeParam = parameters.getInclude();
|
|
||||||
|
|
||||||
List<Node> collection = new ArrayList<>(assocRefs.size());
|
|
||||||
for (AssociationRef assocRef : assocRefs)
|
|
||||||
{
|
|
||||||
// minimal info by default (unless "include"d otherwise)
|
|
||||||
Node node = nodes.getFolderOrDocument(assocRef.getTargetRef(), null, null, includeParam, mapUserInfo);
|
|
||||||
|
|
||||||
QName assocTypeQName = assocRef.getTypeQName();
|
|
||||||
String assocType = qnameMap.get(assocTypeQName);
|
|
||||||
if (assocType == null)
|
|
||||||
{
|
|
||||||
assocType = assocTypeQName.toPrefixString(namespaceService);
|
|
||||||
qnameMap.put(assocTypeQName, assocType);
|
|
||||||
}
|
|
||||||
node.setAssociation(new Assoc(assocType));
|
|
||||||
|
|
||||||
collection.add(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
Paging paging = parameters.getPaging();
|
|
||||||
return CollectionWithPagingInfo.asPaged(paging, collection, false, collection.size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -143,7 +113,7 @@ public class NodeTargetsRelation extends AbstractNodeRelation implements
|
|||||||
NodeRef tgtNodeRef = nodes.validateNode(targetNodeId);
|
NodeRef tgtNodeRef = nodes.validateNode(targetNodeId);
|
||||||
|
|
||||||
String assocTypeStr = parameters.getParameter(PARAM_ASSOC_TYPE);
|
String assocTypeStr = parameters.getParameter(PARAM_ASSOC_TYPE);
|
||||||
QNamePattern assocTypeQName = getAssocType(assocTypeStr, false, true);
|
QNamePattern assocTypeQName = getAssocType(assocTypeStr, false);
|
||||||
|
|
||||||
if (assocTypeQName == null)
|
if (assocTypeQName == null)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user