mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-21 18:09:20 +00:00
Merged HEAD (5.2) to 5.2.N (5.2.1)
126563 jkaabimofrad: Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2) 124538 jvonka: RA-896: Nodes API - fix list children filter - return all results if no filter specified - return 400 if both isFile and isFolder are true, or nodeType is specified along with isFile or isFolder git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@126909 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1087,13 +1087,25 @@ public class NodesImpl implements Nodes
|
||||
includeFiles = isFile;
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
String nodeTypeStr = propertyWalker.getProperty(PARAM_NODETYPE, WhereClauseParser.EQUALS, String.class);
|
||||
if ((nodeTypeStr != null) && (! nodeTypeStr.isEmpty()))
|
||||
{
|
||||
if ((isFile != null) || (isFolder != null))
|
||||
{
|
||||
throw new InvalidArgumentException("Invalid filter - nodeType and isFile/isFolder are mutually exclusive");
|
||||
}
|
||||
|
||||
Pair<QName, Boolean> pair = parseNodeTypeFilter(nodeTypeStr);
|
||||
filterNodeTypeQName = pair.getFirst();
|
||||
filterIncludeSubTypes = pair.getSecond();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
List<SortColumn> sortCols = parameters.getSorting();
|
||||
@@ -1129,8 +1141,11 @@ public class NodesImpl implements Nodes
|
||||
PagingRequest pagingRequest = Util.getPagingRequest(paging);
|
||||
|
||||
final PagingResults<FileInfo> pagingResults;
|
||||
if ((filterNodeTypeQName != null) || (Boolean.FALSE.equals(includeFiles) && Boolean.FALSE.equals(includeFolders)))
|
||||
if (((includeFiles == null) && (includeFolders == null)) ||
|
||||
(filterNodeTypeQName != null) ||
|
||||
(Boolean.FALSE.equals(includeFiles) && Boolean.FALSE.equals(includeFolders)))
|
||||
{
|
||||
// either no filtering or some filtering (but not just files or folders)
|
||||
if (filterNodeTypeQName == null)
|
||||
{
|
||||
filterNodeTypeQName = ContentModel.TYPE_CMOBJECT;
|
||||
@@ -1144,19 +1159,9 @@ public class NodesImpl implements Nodes
|
||||
}
|
||||
else
|
||||
{
|
||||
// files and/or folders only
|
||||
if ((includeFiles == null) && (includeFolders == null))
|
||||
{
|
||||
// no filtering
|
||||
includeFiles = true;
|
||||
includeFolders = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// some filtering
|
||||
includeFiles = (includeFiles != null ? includeFiles : false);
|
||||
includeFolders = (includeFolders != null ? includeFolders : false);
|
||||
}
|
||||
// files or folders only
|
||||
includeFiles = (includeFiles != null ? includeFiles : false);
|
||||
includeFolders = (includeFolders != null ? includeFolders : false);
|
||||
|
||||
pagingResults = fileFolderService.list(parentNodeRef, includeFiles, includeFolders, ignoreQNames, sortProps, pagingRequest);
|
||||
}
|
||||
|
@@ -1738,13 +1738,19 @@ public class NodeApiTest extends AbstractBaseApiTest
|
||||
|
||||
Paging paging = getPaging(0, Integer.MAX_VALUE);
|
||||
|
||||
// no filtering
|
||||
|
||||
HttpResponse response = getAll(myChildrenUrl, user1, paging, null, 200);
|
||||
List<Node> nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
|
||||
checkNodeIds(nodes, allIds);
|
||||
|
||||
// filtering, via where clause - folders
|
||||
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("where", "(nodeType='cm:folder')");
|
||||
|
||||
HttpResponse response = getAll(myChildrenUrl, user1, paging, params, 200);
|
||||
List<Node> nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
|
||||
response = getAll(myChildrenUrl, user1, paging, params, 200);
|
||||
nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
|
||||
checkNodeIds(nodes, folderIds);
|
||||
|
||||
params = new HashMap<>();
|
||||
@@ -1784,15 +1790,6 @@ public class NodeApiTest extends AbstractBaseApiTest
|
||||
nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
|
||||
checkNodeIds(nodes, fileIds);
|
||||
|
||||
// filtering, via where clause - files and folders
|
||||
|
||||
params = new HashMap<>();
|
||||
params.put("where", "(isFile=true AND isFolder=true)");
|
||||
|
||||
response = getAll(myChildrenUrl, user1, paging, params, 200);
|
||||
nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
|
||||
checkNodeIds(nodes, folderAndFileIds);
|
||||
|
||||
// filtering, via where clause - non-folders / non-files
|
||||
|
||||
params = new HashMap<>();
|
||||
@@ -1815,6 +1812,20 @@ public class NodeApiTest extends AbstractBaseApiTest
|
||||
response = getAll(myChildrenUrl, user1, paging, params, 200);
|
||||
nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
|
||||
checkNodeIds(nodes, objIds);
|
||||
|
||||
// -ve - node cannot be both a file and a folder
|
||||
params = new HashMap<>();
|
||||
params.put("where", "(isFile=true AND isFolder=true)");
|
||||
getAll(myChildrenUrl, user1, paging, params, 400);
|
||||
|
||||
// -ve - nodeType and isFile/isFolder are mutually exclusive
|
||||
params = new HashMap<>();
|
||||
params.put("where", "(nodeType='cm:object' AND isFolder=true)");
|
||||
getAll(myChildrenUrl, user1, paging, params, 400);
|
||||
|
||||
params = new HashMap<>();
|
||||
params.put("where", "(nodeType='cm:object' AND isFile=true)");
|
||||
getAll(myChildrenUrl, user1, paging, params, 400);
|
||||
}
|
||||
|
||||
private void checkNodeIds(List<Node> nodes, List<String> nodeIds)
|
||||
|
Reference in New Issue
Block a user