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)
126449 jkaabimofrad: Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2) 122013 jvonka: Nodes (FileFolder) API - add isContent (in addition to isFolder) to node info RA-828, RA-741 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@126794 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -248,6 +248,7 @@ public class NodesImpl implements Nodes
|
|||||||
ContentModel.PROP_WORKING_COPY_OWNER);
|
ContentModel.PROP_WORKING_COPY_OWNER);
|
||||||
|
|
||||||
private final static String PARAM_ISFOLDER = "isFolder";
|
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_SUBTYPES = "subTypes";
|
||||||
|
|
||||||
private final static String PARAM_NAME = "name";
|
private final static String PARAM_NAME = "name";
|
||||||
@@ -277,8 +278,9 @@ public class NodesImpl implements Nodes
|
|||||||
MAP_PARAM_QNAME = Collections.unmodifiableMap(aMap);
|
MAP_PARAM_QNAME = Collections.unmodifiableMap(aMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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_NODETYPE, PARAM_SUBTYPES}));
|
new HashSet<>(Arrays.asList(new String[] {PARAM_ISFOLDER, PARAM_ISCONTENT, PARAM_NODETYPE, PARAM_SUBTYPES}));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Validates that node exists.
|
* Validates that node exists.
|
||||||
@@ -677,8 +679,9 @@ public class NodesImpl implements Nodes
|
|||||||
{
|
{
|
||||||
// not direct folder (or file) ...
|
// not direct folder (or file) ...
|
||||||
// might be sub-type of cm:cmobject (or a cm:link pointing to cm:cmobject or possibly even another cm:link)
|
// might be sub-type of cm:cmobject (or a cm:link pointing to cm:cmobject or possibly even another cm:link)
|
||||||
node = new Document(nodeRef, parentNodeRef, properties, mapUserInfo, sr);
|
node = new Node(nodeRef, parentNodeRef, properties, mapUserInfo, sr);
|
||||||
node.setIsFolder(false);
|
node.setIsFolder(false);
|
||||||
|
node.setIsContent(false);
|
||||||
}
|
}
|
||||||
else if (type.equals(Type.DOCUMENT))
|
else if (type.equals(Type.DOCUMENT))
|
||||||
{
|
{
|
||||||
@@ -686,7 +689,6 @@ public class NodesImpl implements Nodes
|
|||||||
}
|
}
|
||||||
else if (type.equals(Type.FOLDER))
|
else if (type.equals(Type.FOLDER))
|
||||||
{
|
{
|
||||||
// container/folder
|
|
||||||
node = new Folder(nodeRef, parentNodeRef, properties, mapUserInfo, sr);
|
node = new Folder(nodeRef, parentNodeRef, properties, mapUserInfo, sr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -927,11 +929,23 @@ 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);
|
||||||
if (isFolder != null)
|
Boolean isContent = propertyWalker.getProperty(PARAM_ISCONTENT, WhereClauseParser.EQUALS, Boolean.class);
|
||||||
|
|
||||||
|
if ((isFolder != null) && (isContent != null))
|
||||||
|
{
|
||||||
|
includeFiles = isContent;
|
||||||
|
includeFolders = isFolder;
|
||||||
|
}
|
||||||
|
else if (isFolder != null)
|
||||||
{
|
{
|
||||||
includeFiles = !isFolder;
|
includeFiles = !isFolder;
|
||||||
includeFolders = isFolder;
|
includeFolders = isFolder;
|
||||||
}
|
}
|
||||||
|
else if (isContent != null)
|
||||||
|
{
|
||||||
|
includeFiles = isContent;
|
||||||
|
includeFolders = !isContent;
|
||||||
|
}
|
||||||
|
|
||||||
String nodeTypeStr = propertyWalker.getProperty(PARAM_NODETYPE, WhereClauseParser.EQUALS, String.class);
|
String nodeTypeStr = propertyWalker.getProperty(PARAM_NODETYPE, WhereClauseParser.EQUALS, String.class);
|
||||||
if ((nodeTypeStr != null) && (! nodeTypeStr.isEmpty()))
|
if ((nodeTypeStr != null) && (! nodeTypeStr.isEmpty()))
|
||||||
@@ -961,6 +975,7 @@ public class NodesImpl implements Nodes
|
|||||||
List<Pair<QName, Boolean>> sortProps = null;
|
List<Pair<QName, Boolean>> sortProps = null;
|
||||||
if ((sortCols != null) && (sortCols.size() > 0))
|
if ((sortCols != null) && (sortCols.size() > 0))
|
||||||
{
|
{
|
||||||
|
// TODO should we allow isContent in sort (and map to reverse of isFolder) ?
|
||||||
sortProps = new ArrayList<>(sortCols.size());
|
sortProps = new ArrayList<>(sortCols.size());
|
||||||
for (SortColumn sortCol : sortCols)
|
for (SortColumn sortCol : sortCols)
|
||||||
{
|
{
|
||||||
|
@@ -62,7 +62,8 @@ public class Document extends Node
|
|||||||
contentInfo = new ContentInfo(mimeType, mimeTypeName, cd.getSize(), cd.getEncoding());
|
contentInfo = new ContentInfo(mimeType, mimeTypeName, cd.getSize(), cd.getEncoding());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isFolder = false;
|
setIsFolder(false);
|
||||||
|
setIsContent(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -49,7 +49,9 @@ public class Folder extends Node
|
|||||||
public Folder(NodeRef nodeRef, NodeRef parentNodeRef, Map<QName, Serializable> nodeProps, Map<String, UserInfo> mapUserInfo, ServiceRegistry sr)
|
public Folder(NodeRef nodeRef, NodeRef parentNodeRef, Map<QName, Serializable> nodeProps, Map<String, UserInfo> mapUserInfo, ServiceRegistry sr)
|
||||||
{
|
{
|
||||||
super(nodeRef, parentNodeRef, nodeProps, mapUserInfo, sr);
|
super(nodeRef, parentNodeRef, nodeProps, mapUserInfo, sr);
|
||||||
this.isFolder = true;
|
|
||||||
|
setIsFolder(true);
|
||||||
|
setIsContent(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -64,6 +64,7 @@ public class Node implements Comparable<Node>
|
|||||||
protected UserInfo modifiedByUser;
|
protected UserInfo modifiedByUser;
|
||||||
|
|
||||||
protected Boolean isFolder;
|
protected Boolean isFolder;
|
||||||
|
protected Boolean isContent;
|
||||||
protected Boolean isLink;
|
protected Boolean isLink;
|
||||||
|
|
||||||
protected NodeRef parentNodeRef;
|
protected NodeRef parentNodeRef;
|
||||||
@@ -260,6 +261,16 @@ public class Node implements Comparable<Node>
|
|||||||
this.isFolder = isFolder;
|
this.isFolder = isFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean getIsContent()
|
||||||
|
{
|
||||||
|
return isContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsContent(Boolean isContent)
|
||||||
|
{
|
||||||
|
this.isContent = isContent;
|
||||||
|
}
|
||||||
|
|
||||||
public Boolean getIsLink()
|
public Boolean getIsLink()
|
||||||
{
|
{
|
||||||
return isLink;
|
return isLink;
|
||||||
@@ -298,10 +309,11 @@ public class Node implements Comparable<Node>
|
|||||||
return "Node [nodeRef=" + nodeRef + ", type=" + prefixTypeQName + ", name=" + name + ", title="
|
return "Node [nodeRef=" + nodeRef + ", type=" + prefixTypeQName + ", name=" + name + ", title="
|
||||||
+ title + ", description=" + description + ", createdAt="
|
+ title + ", description=" + description + ", createdAt="
|
||||||
+ createdAt + ", modifiedAt=" + modifiedAt + ", createdByUser=" + createdByUser + ", modifiedBy="
|
+ createdAt + ", modifiedAt=" + modifiedAt + ", createdByUser=" + createdByUser + ", modifiedBy="
|
||||||
+ modifiedByUser + ", pathInfo =" + pathInfo +"]";
|
+ modifiedByUser + ", isFolder =" + isFolder + ", isContent =" + isContent + ", pathInfo =" + pathInfo +"]";
|
||||||
}
|
}
|
||||||
|
|
||||||
// here to allow POST /nodes/{id}/children when creating empty file with specified content.mimeType
|
// here to allow POST /nodes/{id}/children when creating empty file with specified content.mimeType
|
||||||
|
// also allows list of results to be returned as "nodes"
|
||||||
|
|
||||||
protected ContentInfo contentInfo;
|
protected ContentInfo contentInfo;
|
||||||
|
|
||||||
|
@@ -267,12 +267,16 @@ public class NodeApiTest extends AbstractBaseApiTest
|
|||||||
assertEquals(4, nodes.size());
|
assertEquals(4, nodes.size());
|
||||||
assertEquals(folder2, nodes.get(0).getName());
|
assertEquals(folder2, nodes.get(0).getName());
|
||||||
assertTrue(nodes.get(0).getIsFolder());
|
assertTrue(nodes.get(0).getIsFolder());
|
||||||
|
assertFalse(nodes.get(0).getIsContent());
|
||||||
assertEquals(folder1, nodes.get(1).getName());
|
assertEquals(folder1, nodes.get(1).getName());
|
||||||
assertTrue(nodes.get(1).getIsFolder());
|
assertTrue(nodes.get(1).getIsFolder());
|
||||||
|
assertFalse(nodes.get(1).getIsContent());
|
||||||
assertEquals(content2, nodes.get(2).getName());
|
assertEquals(content2, nodes.get(2).getName());
|
||||||
assertFalse(nodes.get(2).getIsFolder());
|
assertFalse(nodes.get(2).getIsFolder());
|
||||||
|
assertTrue(nodes.get(2).getIsContent());
|
||||||
assertEquals(content1, nodes.get(3).getName());
|
assertEquals(content1, nodes.get(3).getName());
|
||||||
assertFalse(nodes.get(3).getIsFolder());
|
assertFalse(nodes.get(3).getIsFolder());
|
||||||
|
assertTrue(nodes.get(3).getIsContent());
|
||||||
|
|
||||||
// Order by folders last and modified date first
|
// Order by folders last and modified date first
|
||||||
orderBy = Collections.singletonMap("orderBy", "isFolder ASC,modifiedAt DESC");
|
orderBy = Collections.singletonMap("orderBy", "isFolder ASC,modifiedAt DESC");
|
||||||
@@ -457,17 +461,21 @@ public class NodeApiTest extends AbstractBaseApiTest
|
|||||||
assertEquals(2, nodes.size());
|
assertEquals(2, nodes.size());
|
||||||
|
|
||||||
assertTrue(nodes.get(0).getIsFolder());
|
assertTrue(nodes.get(0).getIsFolder());
|
||||||
assertTrue(nodes.get(1).getIsFolder());
|
assertFalse(nodes.get(0).getIsContent());
|
||||||
assertTrue(folderIds.contains(nodes.get(0).getId()));
|
assertTrue(folderIds.contains(nodes.get(0).getId()));
|
||||||
|
|
||||||
|
assertTrue(nodes.get(1).getIsFolder());
|
||||||
|
assertFalse(nodes.get(1).getIsContent());
|
||||||
assertTrue(folderIds.contains(nodes.get(1).getId()));
|
assertTrue(folderIds.contains(nodes.get(1).getId()));
|
||||||
|
|
||||||
// filtering, via where clause - content only
|
// filtering, via where clause - content only
|
||||||
params = new LinkedHashMap<>();
|
params = new LinkedHashMap<>();
|
||||||
params.put("where", "(isFolder=false)");
|
params.put("where", "(isContent=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());
|
||||||
assertFalse(nodes.get(0).getIsFolder());
|
assertFalse(nodes.get(0).getIsFolder());
|
||||||
|
assertTrue(nodes.get(0).getIsContent());
|
||||||
assertTrue(contentIds.contains(nodes.get(0).getId()));
|
assertTrue(contentIds.contains(nodes.get(0).getId()));
|
||||||
|
|
||||||
// list children via relativePath
|
// list children via relativePath
|
||||||
@@ -614,6 +622,7 @@ public class NodeApiTest extends AbstractBaseApiTest
|
|||||||
assertNotNull(myFilesNodeId);
|
assertNotNull(myFilesNodeId);
|
||||||
assertEquals(user1, node.getName());
|
assertEquals(user1, node.getName());
|
||||||
assertTrue(node.getIsFolder());
|
assertTrue(node.getIsFolder());
|
||||||
|
assertFalse(node.getIsContent());
|
||||||
|
|
||||||
NodeRef myHomeNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, myFilesNodeId);
|
NodeRef myHomeNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, myFilesNodeId);
|
||||||
NodeRef userHomesNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, node.getParentId());
|
NodeRef userHomesNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, node.getParentId());
|
||||||
@@ -759,6 +768,7 @@ public class NodeApiTest extends AbstractBaseApiTest
|
|||||||
assertNotNull(myFilesNodeId);
|
assertNotNull(myFilesNodeId);
|
||||||
assertEquals(user1, node.getName());
|
assertEquals(user1, node.getName());
|
||||||
assertTrue(node.getIsFolder());
|
assertTrue(node.getIsFolder());
|
||||||
|
assertFalse(node.getIsContent());
|
||||||
assertNull(node.getPath()); // note: path can be optionally "select"'ed - see separate test
|
assertNull(node.getPath()); // note: path can be optionally "select"'ed - see separate test
|
||||||
|
|
||||||
response = getSingle(NodesEntityResource.class, user1, Nodes.PATH_SHARED, null, 200);
|
response = getSingle(NodesEntityResource.class, user1, Nodes.PATH_SHARED, null, 200);
|
||||||
@@ -767,6 +777,7 @@ public class NodeApiTest extends AbstractBaseApiTest
|
|||||||
assertNotNull(sharedFilesNodeId);
|
assertNotNull(sharedFilesNodeId);
|
||||||
assertEquals("Shared", node.getName());
|
assertEquals("Shared", node.getName());
|
||||||
assertTrue(node.getIsFolder());
|
assertTrue(node.getIsFolder());
|
||||||
|
assertFalse(node.getIsContent());
|
||||||
assertNull(node.getPath());
|
assertNull(node.getPath());
|
||||||
|
|
||||||
//Delete user1's home
|
//Delete user1's home
|
||||||
@@ -2001,6 +2012,7 @@ public class NodeApiTest extends AbstractBaseApiTest
|
|||||||
assertNotNull(docResp.getModifiedAt());
|
assertNotNull(docResp.getModifiedAt());
|
||||||
assertNotNull(docResp.getModifiedByUser());
|
assertNotNull(docResp.getModifiedByUser());
|
||||||
assertFalse(docResp.getIsFolder());
|
assertFalse(docResp.getIsFolder());
|
||||||
|
assertTrue(docResp.getIsContent());
|
||||||
assertNull(docResp.getIsLink());
|
assertNull(docResp.getIsLink());
|
||||||
assertEquals("cm:content", docResp.getNodeType());
|
assertEquals("cm:content", docResp.getNodeType());
|
||||||
assertNotNull(docResp.getParentId());
|
assertNotNull(docResp.getParentId());
|
||||||
|
@@ -28,14 +28,14 @@ package org.alfresco.rest.api.tests.client.data;
|
|||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Representation of a document node (initially for client tests for File Folder API)
|
* Representation of a document node - initially for client tests for Nodes (aka File Folder) API
|
||||||
*
|
*
|
||||||
* @author janv
|
* @author janv
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Document extends Node
|
public class Document extends Node
|
||||||
{
|
{
|
||||||
private ContentInfo content;
|
private ContentInfo contentInfo;
|
||||||
|
|
||||||
public Document() {
|
public Document() {
|
||||||
super();
|
super();
|
||||||
@@ -43,12 +43,12 @@ public class Document extends Node
|
|||||||
|
|
||||||
public ContentInfo getContent()
|
public ContentInfo getContent()
|
||||||
{
|
{
|
||||||
return content;
|
return contentInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setContent(ContentInfo content)
|
public void setContent(ContentInfo contentInfo)
|
||||||
{
|
{
|
||||||
this.content = content;
|
this.contentInfo = contentInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -60,6 +60,6 @@ public class Document extends Node
|
|||||||
|
|
||||||
Document other = (Document) o;
|
Document other = (Document) o;
|
||||||
|
|
||||||
content.expected(((Document) o).getContent());
|
contentInfo.expected(other.getContent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -28,7 +28,7 @@ package org.alfresco.rest.api.tests.client.data;
|
|||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Representation of a folder node (initially for client tests for File Folder API)
|
* Representation of a folder node - initially for client tests for Nodes (aka File Folder) API
|
||||||
*
|
*
|
||||||
* @author janv
|
* @author janv
|
||||||
*/
|
*/
|
||||||
|
@@ -37,7 +37,7 @@ import static org.junit.Assert.assertNull;
|
|||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Representation of a node (for client tests for File Folder API)
|
* Representation of a node - initially for client tests for Nodes (aka File Folder) API
|
||||||
*
|
*
|
||||||
* @author janv
|
* @author janv
|
||||||
*/
|
*/
|
||||||
@@ -52,6 +52,7 @@ public class Node
|
|||||||
protected UserInfo modifiedByUser;
|
protected UserInfo modifiedByUser;
|
||||||
|
|
||||||
protected Boolean isFolder;
|
protected Boolean isFolder;
|
||||||
|
protected Boolean isContent;
|
||||||
protected Boolean isLink;
|
protected Boolean isLink;
|
||||||
|
|
||||||
protected String parentId;
|
protected String parentId;
|
||||||
@@ -121,9 +122,19 @@ public class Node
|
|||||||
return isFolder;
|
return isFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsFolder(Boolean folder)
|
public void setIsFolder(Boolean isFolder)
|
||||||
{
|
{
|
||||||
isFolder = folder;
|
this.isFolder = isFolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getIsContent()
|
||||||
|
{
|
||||||
|
return isContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsContent(Boolean isContent)
|
||||||
|
{
|
||||||
|
this.isContent = isContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getIsLink()
|
public Boolean getIsLink()
|
||||||
@@ -269,6 +280,7 @@ public class Node
|
|||||||
}
|
}
|
||||||
|
|
||||||
AssertUtil.assertEquals("isFolder", isFolder, other.getIsFolder());
|
AssertUtil.assertEquals("isFolder", isFolder, other.getIsFolder());
|
||||||
|
AssertUtil.assertEquals("isContent", isContent, other.getIsContent());
|
||||||
AssertUtil.assertEquals("isLink", isLink, other.getIsLink());
|
AssertUtil.assertEquals("isLink", isLink, other.getIsLink());
|
||||||
|
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
|
Reference in New Issue
Block a user