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

122675 jvonka: Nodes (FileFolder) API - return isFile in node info (renamed from isContent) in addition to isFolder
   - follow-on, to fix where clause
   RA-828, RA-741


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@126494 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jamal Kaabi-Mofrad
2016-05-10 11:12:21 +00:00
parent 691d4999b7
commit 2ae2eb7e78
3 changed files with 50 additions and 44 deletions

View File

@@ -36,15 +36,13 @@ import org.springframework.extensions.webscripts.servlet.FormData;
/**
* File Folder (Nodes) API
*
* @author steveglover
* @author janv
* @author Jamal Kaabi-Mofrad
* @author Gethin James
* @author steveglover
*/
public interface Nodes
{
String PATH_ROOT = "-root-";
String PATH_MY = "-my-";
String PATH_SHARED = "-shared-";
/**
* Get the node representation for the given node.
*
@@ -179,4 +177,35 @@ public interface Nodes
* @return true if the type of the given nodeRef is a sub-class of another class, otherwise false
*/
boolean isSubClass(NodeRef nodeRef, QName ofClassQName, boolean validateNodeRef);
/**
* API Constants - query parameters, etc
*/
String PATH_ROOT = "-root-";
String PATH_MY = "-my-";
String PATH_SHARED = "-shared-";
String PARAM_RELATIVE_PATH = "relativePath";
String PARAM_AUTO_RENAME = "autoRename";
String PARAM_PERMANENT = "permanent";
String PARAM_SELECT_PROPERTIES = "properties";
String PARAM_SELECT_PATH = "path";
String PARAM_SELECT_ASPECTNAMES = "aspectNames";
String PARAM_SELECT_ISLINK = "isLink";
String PARAM_ISFOLDER = "isFolder";
String PARAM_ISFILE = "isFile";
String PARAM_INCLUDE_SUBTYPES = "INCLUDESUBTYPES";
String PARAM_NAME = "name";
String PARAM_CREATEDAT = "createdAt";
String PARAM_MODIFIEDAT = "modifiedAt";
String PARAM_CREATEBYUSER = "createdByUser";
String PARAM_MODIFIEDBYUSER = "modifiedByUser";
String PARAM_MIMETYPE = "mimeType";
String PARAM_SIZEINBYTES = "sizeInBytes";
String PARAM_NODETYPE = "nodeType";
}

View File

@@ -138,15 +138,6 @@ public class NodesImpl implements Nodes
DOCUMENT, FOLDER
}
private final static String PARAM_RELATIVE_PATH = "relativePath";
private final static String PARAM_AUTO_RENAME = "autoRename";
private final static String PARAM_PERMANENT = "permanent";
private final static String PARAM_SELECT_PROPERTIES = "properties";
private final static String PARAM_SELECT_PATH = "path";
private final static String PARAM_SELECT_ASPECTNAMES = "aspectNames";
private final static String PARAM_SELECT_ISLINK = "isLink";
private NodeService nodeService;
private DictionaryService dictionaryService;
private FileFolderService fileFolderService;
@@ -249,20 +240,6 @@ public class NodesImpl implements Nodes
ContentModel.PROP_LOCK_OWNER,
ContentModel.PROP_WORKING_COPY_OWNER);
private final static String PARAM_ISFOLDER = "isFolder";
private final static String PARAM_ISCONTENT = "isContent";
private final static String PARAM_INCLUDE_SUBTYPES = "INCLUDESUBTYPES";
private final static String PARAM_NAME = "name";
private final static String PARAM_CREATEDAT = "createdAt";
private final static String PARAM_MODIFIEDAT = "modifiedAt";
private final static String PARAM_CREATEBYUSER = "createdByUser";
private final static String PARAM_MODIFIEDBYUSER = "modifiedByUser";
private final static String PARAM_MIMETYPE = "mimeType";
private final static String PARAM_SIZEINBYTES = "sizeInBytes";
private final static String PARAM_NODETYPE = "nodeType";
private final static Map<String,QName> MAP_PARAM_QNAME;
static
{
@@ -283,7 +260,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}));
new HashSet<>(Arrays.asList(new String[] {PARAM_ISFOLDER, PARAM_ISFILE, PARAM_NODETYPE}));
/*
* Validates that node exists.
@@ -956,11 +933,11 @@ public class NodesImpl implements Nodes
QueryHelper.walk(q, propertyWalker);
Boolean isFolder = propertyWalker.getProperty(PARAM_ISFOLDER, WhereClauseParser.EQUALS, Boolean.class);
Boolean isContent = propertyWalker.getProperty(PARAM_ISCONTENT, WhereClauseParser.EQUALS, Boolean.class);
Boolean isFile = propertyWalker.getProperty(PARAM_ISFILE, WhereClauseParser.EQUALS, Boolean.class);
if ((isFolder != null) && (isContent != null))
if ((isFolder != null) && (isFile != null))
{
includeFiles = isContent;
includeFiles = isFile;
includeFolders = isFolder;
}
else if (isFolder != null)
@@ -968,10 +945,10 @@ public class NodesImpl implements Nodes
includeFiles = !isFolder;
includeFolders = isFolder;
}
else if (isContent != null)
else if (isFile != null)
{
includeFiles = isContent;
includeFolders = !isContent;
includeFiles = isFile;
includeFolders = !isFile;
}
String nodeTypeStr = propertyWalker.getProperty(PARAM_NODETYPE, WhereClauseParser.EQUALS, String.class);

View File

@@ -416,7 +416,7 @@ public class NodeApiTest extends AbstractBaseApiTest
// filtering, via where clause - folders only
params = new LinkedHashMap<>();
params.put("where", "(isFolder=true)");
params.put("where", "("+Nodes.PARAM_ISFOLDER+"=true)");
response = getAll(myChildrenUrl, user1, paging, params, 200);
nodes = jacksonUtil.parseEntries(response.getJsonResponse(), Document.class);
assertEquals(2, nodes.size());
@@ -431,7 +431,7 @@ public class NodeApiTest extends AbstractBaseApiTest
// filtering, via where clause - content only
params = new LinkedHashMap<>();
params.put("where", "(isContent=true)");
params.put("where", "("+Nodes.PARAM_ISFILE+"=true)");
response = getAll(myChildrenUrl, user1, paging, params, 200);
nodes = jacksonUtil.parseEntries(response.getJsonResponse(), Document.class);
assertEquals(1, nodes.size());
@@ -441,20 +441,20 @@ public class NodeApiTest extends AbstractBaseApiTest
// list children via relativePath
params = Collections.singletonMap("relativePath", folder1);
params = Collections.singletonMap(Nodes.PARAM_RELATIVE_PATH, folder1);
response = getAll(myChildrenUrl, user1, paging, params, 200);
nodes = jacksonUtil.parseEntries(response.getJsonResponse(), Document.class);
assertEquals(1, nodes.size());
assertEquals(contentF1_Id, nodes.get(0).getId());
params = Collections.singletonMap("relativePath", "User Homes/" + user1 + "/" + folder2);
params = Collections.singletonMap(Nodes.PARAM_RELATIVE_PATH, "User Homes/" + user1 + "/" + folder2);
response = getAll(rootChildrenUrl, user1, paging, params, 200);
nodes = jacksonUtil.parseEntries(response.getJsonResponse(), Document.class);
assertEquals(1, nodes.size());
assertEquals(contentF2_Id, nodes.get(0).getId());
// -ve test - Invalid QName (Namespace prefix cm... is not mapped to a namespace URI) for the orderBy parameter.
params = Collections.singletonMap("orderBy", "isFolder DESC,cm" + System.currentTimeMillis() + ":modified DESC");
params = Collections.singletonMap("orderBy", Nodes.PARAM_ISFOLDER+" DESC,cm" + System.currentTimeMillis() + ":modified DESC");
getAll(myChildrenUrl, user1, paging, params, 400);
paging = getPaging(0, 10);
@@ -470,19 +470,19 @@ public class NodeApiTest extends AbstractBaseApiTest
getAll(getChildrenUrl(myFilesNodeRef), user2, paging, 403);
// -ve test - try to list children using relative path to unknown node
params = Collections.singletonMap("relativePath", "User Homes/" + user1 + "/unknown");
params = Collections.singletonMap(Nodes.PARAM_RELATIVE_PATH, "User Homes/" + user1 + "/unknown");
getAll(rootChildrenUrl, user1, paging, params, 404);
// -ve test - try to list children using relative path to node for which user does not have read permission
params = Collections.singletonMap("relativePath", "User Homes/" + user2);
params = Collections.singletonMap(Nodes.PARAM_RELATIVE_PATH, "User Homes/" + user2);
getAll(rootChildrenUrl, user1, paging, params, 403);
// -ve test - try to list children using relative path to node that is of wrong type (ie. not a folder/container)
params = Collections.singletonMap("relativePath", folder1 + "/" + contentF1);
params = Collections.singletonMap(Nodes.PARAM_RELATIVE_PATH, folder1 + "/" + contentF1);
getAll(myChildrenUrl, user1, paging, params, 400);
// -ve test - list folder children for non-folder node with relative path should return 400
params = Collections.singletonMap("relativePath", "/unknown");
params = Collections.singletonMap(Nodes.PARAM_RELATIVE_PATH, "/unknown");
getAll(getChildrenUrl(contentNodeRef), user1, paging, params, 400);
}