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)
126589 jkaabimofrad: Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2) 124819 jvonka: RA-896 - List Node Children filtering - additional fixes & tests, when filtering by isFile &/or isFolder git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@126934 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1115,12 +1115,12 @@ public class NodesImpl implements Nodes
|
|||||||
|
|
||||||
if (isFile != null)
|
if (isFile != null)
|
||||||
{
|
{
|
||||||
includeFiles = isFile;
|
includeFiles = isFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Boolean.TRUE.equals(includeFiles) && Boolean.TRUE.equals(includeFolders))
|
if (Boolean.TRUE.equals(includeFiles) && Boolean.TRUE.equals(includeFolders))
|
||||||
{
|
{
|
||||||
throw new InvalidArgumentException("Invalid filter (isFile=true and isFolder = true) - a node cannot be both a file and a folder");
|
throw new InvalidArgumentException("Invalid filter (isFile=true and isFolder=true) - a node cannot be both a file and a folder");
|
||||||
}
|
}
|
||||||
|
|
||||||
String nodeTypeStr = propertyWalker.getProperty(PARAM_NODETYPE, WhereClauseParser.EQUALS, String.class);
|
String nodeTypeStr = propertyWalker.getProperty(PARAM_NODETYPE, WhereClauseParser.EQUALS, String.class);
|
||||||
@@ -1135,8 +1135,6 @@ public class NodesImpl implements Nodes
|
|||||||
filterNodeTypeQName = pair.getFirst();
|
filterNodeTypeQName = pair.getFirst();
|
||||||
filterIncludeSubTypes = pair.getSecond();
|
filterIncludeSubTypes = pair.getSecond();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<SortColumn> sortCols = parameters.getSorting();
|
List<SortColumn> sortCols = parameters.getSorting();
|
||||||
@@ -1172,30 +1170,49 @@ public class NodesImpl implements Nodes
|
|||||||
PagingRequest pagingRequest = Util.getPagingRequest(paging);
|
PagingRequest pagingRequest = Util.getPagingRequest(paging);
|
||||||
|
|
||||||
final PagingResults<FileInfo> pagingResults;
|
final PagingResults<FileInfo> pagingResults;
|
||||||
if (((includeFiles == null) && (includeFolders == null)) ||
|
|
||||||
(filterNodeTypeQName != null) ||
|
// notes (see also earlier validation checks):
|
||||||
(Boolean.FALSE.equals(includeFiles) && Boolean.FALSE.equals(includeFolders)))
|
// - node type filtering is mutually exclusive from isFile/isFolder, can optionally also include sub-types
|
||||||
|
// - isFile & isFolder cannot both be true
|
||||||
|
// - (isFile=false) means any other types/sub-types (other than files)
|
||||||
|
// - (isFolder=false) means any other types/sub-types (other than folders)
|
||||||
|
// - (isFile=false and isFolder=false) means any types/sub-types (other than files or folders)
|
||||||
|
|
||||||
|
if (filterNodeTypeQName == null)
|
||||||
{
|
{
|
||||||
// either no filtering or some filtering (but not just files or folders)
|
if (Boolean.FALSE.equals(includeFiles) && Boolean.FALSE.equals(includeFolders))
|
||||||
if (filterNodeTypeQName == null)
|
|
||||||
{
|
{
|
||||||
|
includeFiles = false;
|
||||||
|
includeFolders = false;
|
||||||
|
|
||||||
filterNodeTypeQName = ContentModel.TYPE_CMOBJECT;
|
filterNodeTypeQName = ContentModel.TYPE_CMOBJECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
Pair<Set<QName>, Set<QName>> pair = buildSearchTypesAndIgnoreAspects(filterNodeTypeQName, filterIncludeSubTypes, ignoreQNames, includeFiles, includeFolders);
|
if (includeFiles != null)
|
||||||
Set<QName> searchTypeQNames = pair.getFirst();
|
{
|
||||||
Set<QName> ignoreAspectQNames = pair.getSecond();
|
if ((! includeFiles) && (includeFolders == null))
|
||||||
|
{
|
||||||
|
// isFile=false
|
||||||
|
filterNodeTypeQName = ContentModel.TYPE_CMOBJECT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pagingResults = fileFolderService.list(parentNodeRef, searchTypeQNames, ignoreAspectQNames, sortProps, pagingRequest);
|
if (includeFolders != null)
|
||||||
|
{
|
||||||
|
if ((! includeFolders) && (includeFiles == null))
|
||||||
|
{
|
||||||
|
// isFolder=false
|
||||||
|
filterNodeTypeQName = ContentModel.TYPE_CMOBJECT;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// files or folders only
|
|
||||||
includeFiles = (includeFiles != null ? includeFiles : false);
|
|
||||||
includeFolders = (includeFolders != null ? includeFolders : false);
|
|
||||||
|
|
||||||
pagingResults = fileFolderService.list(parentNodeRef, includeFiles, includeFolders, ignoreQNames, sortProps, pagingRequest);
|
Pair<Set<QName>, Set<QName>> pair = buildSearchTypesAndIgnoreAspects(filterNodeTypeQName, filterIncludeSubTypes, ignoreQNames, includeFiles, includeFolders);
|
||||||
}
|
Set<QName> searchTypeQNames = pair.getFirst();
|
||||||
|
Set<QName> ignoreAspectQNames = pair.getSecond();
|
||||||
|
|
||||||
|
pagingResults = fileFolderService.list(parentNodeRef, searchTypeQNames, ignoreAspectQNames, sortProps, pagingRequest);
|
||||||
|
|
||||||
|
|
||||||
final Map<String, UserInfo> mapUserInfo = new HashMap<>(10);
|
final Map<String, UserInfo> mapUserInfo = new HashMap<>(10);
|
||||||
|
|
||||||
@@ -1253,34 +1270,32 @@ public class NodesImpl implements Nodes
|
|||||||
|
|
||||||
protected Pair<Set<QName>, Set<QName>> buildSearchTypesAndIgnoreAspects(QName nodeTypeQName, boolean includeSubTypes, Set<QName> ignoreQNameTypes, Boolean includeFiles, Boolean includeFolders)
|
protected Pair<Set<QName>, Set<QName>> buildSearchTypesAndIgnoreAspects(QName nodeTypeQName, boolean includeSubTypes, Set<QName> ignoreQNameTypes, Boolean includeFiles, Boolean includeFolders)
|
||||||
{
|
{
|
||||||
Set<QName> searchTypeQNames = new HashSet<QName>(100);
|
Set<QName> searchTypeQNames = new HashSet<>(100);
|
||||||
Set<QName> ignoreAspectQNames = null;
|
Set<QName> ignoreAspectQNames = null;
|
||||||
|
|
||||||
// Build a list of (sub-)types
|
if (nodeTypeQName != null)
|
||||||
if (includeSubTypes)
|
|
||||||
{
|
{
|
||||||
Collection<QName> qnames = dictionaryService.getSubTypes(nodeTypeQName, true);
|
// Build a list of (sub-)types
|
||||||
searchTypeQNames.addAll(qnames);
|
if (includeSubTypes)
|
||||||
}
|
{
|
||||||
searchTypeQNames.add(nodeTypeQName);
|
Collection<QName> qnames = dictionaryService.getSubTypes(nodeTypeQName, true);
|
||||||
|
searchTypeQNames.addAll(qnames);
|
||||||
|
}
|
||||||
|
searchTypeQNames.add(nodeTypeQName);
|
||||||
|
|
||||||
// Remove 'system' folders
|
// Remove 'system' folders
|
||||||
if (includeSubTypes)
|
if (includeSubTypes)
|
||||||
{
|
{
|
||||||
Collection<QName> qnames = dictionaryService.getSubTypes(ContentModel.TYPE_SYSTEM_FOLDER, true);
|
Collection<QName> qnames = dictionaryService.getSubTypes(ContentModel.TYPE_SYSTEM_FOLDER, true);
|
||||||
searchTypeQNames.removeAll(qnames);
|
searchTypeQNames.removeAll(qnames);
|
||||||
|
}
|
||||||
|
searchTypeQNames.remove(ContentModel.TYPE_SYSTEM_FOLDER);
|
||||||
}
|
}
|
||||||
searchTypeQNames.remove(ContentModel.TYPE_SYSTEM_FOLDER);
|
|
||||||
|
|
||||||
if (includeFiles != null)
|
if (includeFiles != null)
|
||||||
{
|
{
|
||||||
if (includeFiles)
|
if (includeFiles)
|
||||||
{
|
{
|
||||||
if (! dictionaryService.isSubClass(ContentModel.TYPE_CONTENT, nodeTypeQName))
|
|
||||||
{
|
|
||||||
throw new InvalidArgumentException("Cannot filter for isFile since not sub-type of: "+nodeTypeQName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (includeSubTypes)
|
if (includeSubTypes)
|
||||||
{
|
{
|
||||||
Collection<QName> qnames = dictionaryService.getSubTypes(ContentModel.TYPE_CONTENT, true);
|
Collection<QName> qnames = dictionaryService.getSubTypes(ContentModel.TYPE_CONTENT, true);
|
||||||
@@ -1300,17 +1315,20 @@ public class NodesImpl implements Nodes
|
|||||||
{
|
{
|
||||||
if (includeFolders)
|
if (includeFolders)
|
||||||
{
|
{
|
||||||
if (! dictionaryService.isSubClass(ContentModel.TYPE_FOLDER, nodeTypeQName))
|
|
||||||
{
|
|
||||||
throw new InvalidArgumentException("Cannot filter for isFolder since not sub-type of: "+nodeTypeQName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (includeSubTypes)
|
if (includeSubTypes)
|
||||||
{
|
{
|
||||||
Collection<QName> qnames = dictionaryService.getSubTypes(ContentModel.TYPE_FOLDER, true);
|
Collection<QName> qnames = dictionaryService.getSubTypes(ContentModel.TYPE_FOLDER, true);
|
||||||
searchTypeQNames.addAll(qnames);
|
searchTypeQNames.addAll(qnames);
|
||||||
}
|
}
|
||||||
searchTypeQNames.add(ContentModel.TYPE_FOLDER);
|
searchTypeQNames.add(ContentModel.TYPE_FOLDER);
|
||||||
|
|
||||||
|
// Remove 'system' folders
|
||||||
|
if (includeSubTypes)
|
||||||
|
{
|
||||||
|
Collection<QName> qnames = dictionaryService.getSubTypes(ContentModel.TYPE_SYSTEM_FOLDER, true);
|
||||||
|
searchTypeQNames.removeAll(qnames);
|
||||||
|
}
|
||||||
|
searchTypeQNames.remove(ContentModel.TYPE_SYSTEM_FOLDER);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1322,7 +1340,7 @@ public class NodesImpl implements Nodes
|
|||||||
|
|
||||||
if (ignoreQNameTypes != null)
|
if (ignoreQNameTypes != null)
|
||||||
{
|
{
|
||||||
Set<QName> ignoreQNamesNotSearchTypes = new HashSet<QName>(ignoreQNameTypes);
|
Set<QName> ignoreQNamesNotSearchTypes = new HashSet<>(ignoreQNameTypes);
|
||||||
ignoreQNamesNotSearchTypes.removeAll(searchTypeQNames);
|
ignoreQNamesNotSearchTypes.removeAll(searchTypeQNames);
|
||||||
ignoreQNamesNotSearchTypes.remove(ContentModel.TYPE_SYSTEM_FOLDER);
|
ignoreQNamesNotSearchTypes.remove(ContentModel.TYPE_SYSTEM_FOLDER);
|
||||||
|
|
||||||
@@ -1339,7 +1357,7 @@ public class NodesImpl implements Nodes
|
|||||||
|
|
||||||
private Set<QName> getAspectsToIgnore(Set<QName> ignoreQNames)
|
private Set<QName> getAspectsToIgnore(Set<QName> ignoreQNames)
|
||||||
{
|
{
|
||||||
Set<QName> ignoreQNameAspects = new HashSet<QName>(ignoreQNames.size());
|
Set<QName> ignoreQNameAspects = new HashSet<>(ignoreQNames.size());
|
||||||
for (QName qname : ignoreQNames)
|
for (QName qname : ignoreQNames)
|
||||||
{
|
{
|
||||||
if (dictionaryService.getAspect(qname) != null)
|
if (dictionaryService.getAspect(qname) != null)
|
||||||
|
@@ -1737,6 +1737,14 @@ public class NodeApiTest extends AbstractBaseApiTest
|
|||||||
folderAndFileIds.addAll(folderIds);
|
folderAndFileIds.addAll(folderIds);
|
||||||
folderAndFileIds.addAll(fileIds);
|
folderAndFileIds.addAll(fileIds);
|
||||||
|
|
||||||
|
List<String> notFileIds = new ArrayList<>(folderCnt+objCnt);
|
||||||
|
notFileIds.addAll(folderIds);
|
||||||
|
notFileIds.addAll(objIds);
|
||||||
|
|
||||||
|
List<String> notFolderIds = new ArrayList<>(fileCnt+objCnt);
|
||||||
|
notFolderIds.addAll(fileIds);
|
||||||
|
notFolderIds.addAll(objIds);
|
||||||
|
|
||||||
Paging paging = getPaging(0, Integer.MAX_VALUE);
|
Paging paging = getPaging(0, Integer.MAX_VALUE);
|
||||||
|
|
||||||
// no filtering
|
// no filtering
|
||||||
@@ -1814,6 +1822,22 @@ public class NodeApiTest extends AbstractBaseApiTest
|
|||||||
nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
|
nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
|
||||||
checkNodeIds(nodes, objIds);
|
checkNodeIds(nodes, objIds);
|
||||||
|
|
||||||
|
// filtering, via where clause - not files
|
||||||
|
params = new HashMap<>();
|
||||||
|
params.put("where", "(isFile=false)");
|
||||||
|
|
||||||
|
response = getAll(myChildrenUrl, user1, paging, params, 200);
|
||||||
|
nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
|
||||||
|
checkNodeIds(nodes, notFileIds);
|
||||||
|
|
||||||
|
// filtering, via where clause - not folders
|
||||||
|
params = new HashMap<>();
|
||||||
|
params.put("where", "(isFolder=false)");
|
||||||
|
|
||||||
|
response = getAll(myChildrenUrl, user1, paging, params, 200);
|
||||||
|
nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
|
||||||
|
checkNodeIds(nodes, notFolderIds);
|
||||||
|
|
||||||
// -ve - node cannot be both a file and a folder
|
// -ve - node cannot be both a file and a folder
|
||||||
params = new HashMap<>();
|
params = new HashMap<>();
|
||||||
params.put("where", "(isFile=true AND isFolder=true)");
|
params.put("where", "(isFile=true AND isFolder=true)");
|
||||||
|
Reference in New Issue
Block a user