Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2)

122140 jvonka: Nodes (FileFolder) API - update listChildren 'where' filtering (inc tests) for nodeType + optionally including sub-types
   - for example: where=(nodeType='cm:link includeSubTypes')
   RA-811, RA-634


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@126451 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jamal Kaabi-Mofrad
2016-05-10 10:57:20 +00:00
parent ac73cc618d
commit 2795628608
2 changed files with 54 additions and 23 deletions

View File

@@ -242,7 +242,8 @@ public class NodesImpl implements Nodes
private final static String PARAM_ISFOLDER = "isFolder";
private final static String PARAM_ISCONTENT = "isContent";
private final static String PARAM_SUBTYPES = "subTypes";
private final static String PARAM_INCLUDE_SUBTYPES = "INCLUDESUBTYPES";
private final static String PARAM_NAME = "name";
private final static String PARAM_CREATEDAT = "createdAt";
@@ -273,7 +274,7 @@ public class NodesImpl implements Nodes
// list children filtering (via where clause)
private final static Set<String> LIST_FOLDER_CHILDREN_EQUALS_QUERY_PROPERTIES =
new HashSet<>(Arrays.asList(new String[] {PARAM_ISFOLDER, PARAM_ISCONTENT, PARAM_NODETYPE, PARAM_SUBTYPES}));
new HashSet<>(Arrays.asList(new String[] {PARAM_ISFOLDER, PARAM_ISCONTENT, PARAM_NODETYPE}));
/*
* Validates that node exists.
@@ -948,24 +949,9 @@ public class NodesImpl implements Nodes
String nodeTypeStr = propertyWalker.getProperty(PARAM_NODETYPE, WhereClauseParser.EQUALS, String.class);
if ((nodeTypeStr != null) && (! nodeTypeStr.isEmpty()))
{
filterIncludeSubTypes = false; // default nodeType filtering is without subTypes (unless subTypes = true)
filterNodeTypeQName = createQName(nodeTypeStr);
if (dictionaryService.getType(filterNodeTypeQName) == null)
{
throw new InvalidArgumentException("Unknown filter nodeType: "+nodeTypeStr);
}
}
// optionally used with nodeType filter (default is *not* to include sub-types)
Boolean subTypes = propertyWalker.getProperty(PARAM_SUBTYPES, WhereClauseParser.EQUALS, Boolean.class);
if (subTypes != null)
{
if (nodeTypeStr == null)
{
throw new InvalidArgumentException("Expected nodeType and subTypes (not just subTypes) filter: "+parentNodeRef.getId());
}
filterIncludeSubTypes = subTypes;
Pair<QName, Boolean> pair = parseNodeTypeFilter(nodeTypeStr);
filterNodeTypeQName = pair.getFirst();
filterIncludeSubTypes = pair.getSecond();
}
}
@@ -1045,6 +1031,30 @@ public class NodesImpl implements Nodes
return CollectionWithPagingInfo.asPaged(paging, nodes, pagingResults.hasMoreItems(), pagingResults.getTotalResultCount().getFirst());
}
private Pair<QName,Boolean> parseNodeTypeFilter(String nodeTypeStr)
{
boolean filterIncludeSubTypes = false; // default nodeType filtering is without subTypes (unless nodeType value is suffixed with ' INCLUDESUBTYPES')
int idx = nodeTypeStr.lastIndexOf(' ');
if (idx > 0)
{
String suffix = nodeTypeStr.substring(idx);
if (suffix.equalsIgnoreCase(" "+PARAM_INCLUDE_SUBTYPES))
{
filterIncludeSubTypes = true;
nodeTypeStr = nodeTypeStr.substring(0, idx);
}
}
QName filterNodeTypeQName = createQName(nodeTypeStr);
if (dictionaryService.getType(filterNodeTypeQName) == null)
{
throw new InvalidArgumentException("Unknown filter nodeType: "+nodeTypeStr);
}
return new Pair<>(filterNodeTypeQName, filterIncludeSubTypes);
}
protected Pair<Set<QName>, Set<QName>> buildSearchTypesAndIgnoreAspects(QName filterNodeTypeQName, boolean filterIncludeSubTypes, Set<QName> ignoreQNameTypes)
{
Set<QName> searchTypeQNames = new HashSet<QName>(100);