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)
126494 jkaabimofrad: 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/BRANCHES/DEV/5.2.N/root@126838 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -43,15 +43,13 @@ import org.springframework.extensions.webscripts.servlet.FormData;
|
|||||||
/**
|
/**
|
||||||
* File Folder (Nodes) API
|
* File Folder (Nodes) API
|
||||||
*
|
*
|
||||||
* @author steveglover
|
|
||||||
* @author janv
|
* @author janv
|
||||||
|
* @author Jamal Kaabi-Mofrad
|
||||||
|
* @author Gethin James
|
||||||
|
* @author steveglover
|
||||||
*/
|
*/
|
||||||
public interface Nodes
|
public interface Nodes
|
||||||
{
|
{
|
||||||
String PATH_ROOT = "-root-";
|
|
||||||
String PATH_MY = "-my-";
|
|
||||||
String PATH_SHARED = "-shared-";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the node representation for the given node.
|
* Get the node representation for the given node.
|
||||||
*
|
*
|
||||||
@@ -186,4 +184,35 @@ public interface Nodes
|
|||||||
* @return true if the type of the given nodeRef is a sub-class of another class, otherwise false
|
* @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);
|
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";
|
||||||
}
|
}
|
||||||
|
@@ -145,15 +145,6 @@ public class NodesImpl implements Nodes
|
|||||||
DOCUMENT, FOLDER
|
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 NodeService nodeService;
|
||||||
private DictionaryService dictionaryService;
|
private DictionaryService dictionaryService;
|
||||||
private FileFolderService fileFolderService;
|
private FileFolderService fileFolderService;
|
||||||
@@ -256,20 +247,6 @@ public class NodesImpl implements Nodes
|
|||||||
ContentModel.PROP_LOCK_OWNER,
|
ContentModel.PROP_LOCK_OWNER,
|
||||||
ContentModel.PROP_WORKING_COPY_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;
|
private final static Map<String,QName> MAP_PARAM_QNAME;
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
@@ -290,7 +267,7 @@ public class NodesImpl implements Nodes
|
|||||||
|
|
||||||
// list children filtering (via where clause)
|
// list children filtering (via where clause)
|
||||||
private final static Set<String> LIST_FOLDER_CHILDREN_EQUALS_QUERY_PROPERTIES =
|
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.
|
* Validates that node exists.
|
||||||
@@ -963,11 +940,11 @@ public class NodesImpl implements Nodes
|
|||||||
QueryHelper.walk(q, propertyWalker);
|
QueryHelper.walk(q, propertyWalker);
|
||||||
|
|
||||||
Boolean isFolder = propertyWalker.getProperty(PARAM_ISFOLDER, WhereClauseParser.EQUALS, Boolean.class);
|
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;
|
includeFolders = isFolder;
|
||||||
}
|
}
|
||||||
else if (isFolder != null)
|
else if (isFolder != null)
|
||||||
@@ -975,10 +952,10 @@ public class NodesImpl implements Nodes
|
|||||||
includeFiles = !isFolder;
|
includeFiles = !isFolder;
|
||||||
includeFolders = isFolder;
|
includeFolders = isFolder;
|
||||||
}
|
}
|
||||||
else if (isContent != null)
|
else if (isFile != null)
|
||||||
{
|
{
|
||||||
includeFiles = isContent;
|
includeFiles = isFile;
|
||||||
includeFolders = !isContent;
|
includeFolders = !isFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
String nodeTypeStr = propertyWalker.getProperty(PARAM_NODETYPE, WhereClauseParser.EQUALS, String.class);
|
String nodeTypeStr = propertyWalker.getProperty(PARAM_NODETYPE, WhereClauseParser.EQUALS, String.class);
|
||||||
|
@@ -416,7 +416,7 @@ public class NodeApiTest extends AbstractBaseApiTest
|
|||||||
|
|
||||||
// filtering, via where clause - folders only
|
// filtering, via where clause - folders only
|
||||||
params = new LinkedHashMap<>();
|
params = new LinkedHashMap<>();
|
||||||
params.put("where", "(isFolder=true)");
|
params.put("where", "("+Nodes.PARAM_ISFOLDER+"=true)");
|
||||||
response = getAll(myChildrenUrl, user1, paging, params, 200);
|
response = getAll(myChildrenUrl, user1, paging, params, 200);
|
||||||
nodes = jacksonUtil.parseEntries(response.getJsonResponse(), Document.class);
|
nodes = jacksonUtil.parseEntries(response.getJsonResponse(), Document.class);
|
||||||
assertEquals(2, nodes.size());
|
assertEquals(2, nodes.size());
|
||||||
@@ -431,7 +431,7 @@ public class NodeApiTest extends AbstractBaseApiTest
|
|||||||
|
|
||||||
// filtering, via where clause - content only
|
// filtering, via where clause - content only
|
||||||
params = new LinkedHashMap<>();
|
params = new LinkedHashMap<>();
|
||||||
params.put("where", "(isContent=true)");
|
params.put("where", "("+Nodes.PARAM_ISFILE+"=true)");
|
||||||
response = getAll(myChildrenUrl, user1, paging, params, 200);
|
response = getAll(myChildrenUrl, user1, paging, params, 200);
|
||||||
nodes = jacksonUtil.parseEntries(response.getJsonResponse(), Document.class);
|
nodes = jacksonUtil.parseEntries(response.getJsonResponse(), Document.class);
|
||||||
assertEquals(1, nodes.size());
|
assertEquals(1, nodes.size());
|
||||||
@@ -441,20 +441,20 @@ public class NodeApiTest extends AbstractBaseApiTest
|
|||||||
|
|
||||||
// list children via relativePath
|
// list children via relativePath
|
||||||
|
|
||||||
params = Collections.singletonMap("relativePath", folder1);
|
params = Collections.singletonMap(Nodes.PARAM_RELATIVE_PATH, folder1);
|
||||||
response = getAll(myChildrenUrl, user1, paging, params, 200);
|
response = getAll(myChildrenUrl, user1, paging, params, 200);
|
||||||
nodes = jacksonUtil.parseEntries(response.getJsonResponse(), Document.class);
|
nodes = jacksonUtil.parseEntries(response.getJsonResponse(), Document.class);
|
||||||
assertEquals(1, nodes.size());
|
assertEquals(1, nodes.size());
|
||||||
assertEquals(contentF1_Id, nodes.get(0).getId());
|
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);
|
response = getAll(rootChildrenUrl, user1, paging, params, 200);
|
||||||
nodes = jacksonUtil.parseEntries(response.getJsonResponse(), Document.class);
|
nodes = jacksonUtil.parseEntries(response.getJsonResponse(), Document.class);
|
||||||
assertEquals(1, nodes.size());
|
assertEquals(1, nodes.size());
|
||||||
assertEquals(contentF2_Id, nodes.get(0).getId());
|
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.
|
// -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);
|
getAll(myChildrenUrl, user1, paging, params, 400);
|
||||||
|
|
||||||
paging = getPaging(0, 10);
|
paging = getPaging(0, 10);
|
||||||
@@ -470,19 +470,19 @@ public class NodeApiTest extends AbstractBaseApiTest
|
|||||||
getAll(getChildrenUrl(myFilesNodeRef), user2, paging, 403);
|
getAll(getChildrenUrl(myFilesNodeRef), user2, paging, 403);
|
||||||
|
|
||||||
// -ve test - try to list children using relative path to unknown node
|
// -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);
|
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
|
// -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);
|
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)
|
// -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);
|
getAll(myChildrenUrl, user1, paging, params, 400);
|
||||||
|
|
||||||
// -ve test - list folder children for non-folder node with relative path should return 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);
|
getAll(getChildrenUrl(contentNodeRef), user1, paging, params, 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user