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/HEAD/root@126449 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jamal Kaabi-Mofrad
2016-05-10 10:57:02 +00:00
parent 412880e8d9
commit df9a17f35f
8 changed files with 75 additions and 21 deletions

View File

@@ -241,6 +241,7 @@ public class NodesImpl implements Nodes
ContentModel.PROP_WORKING_COPY_OWNER);
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_NAME = "name";
@@ -270,8 +271,9 @@ public class NodesImpl implements Nodes
MAP_PARAM_QNAME = Collections.unmodifiableMap(aMap);
}
// 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_NODETYPE, PARAM_SUBTYPES}));
new HashSet<>(Arrays.asList(new String[] {PARAM_ISFOLDER, PARAM_ISCONTENT, PARAM_NODETYPE, PARAM_SUBTYPES}));
/*
* Validates that node exists.
@@ -670,8 +672,9 @@ public class NodesImpl implements Nodes
{
// 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)
node = new Document(nodeRef, parentNodeRef, properties, mapUserInfo, sr);
node = new Node(nodeRef, parentNodeRef, properties, mapUserInfo, sr);
node.setIsFolder(false);
node.setIsContent(false);
}
else if (type.equals(Type.DOCUMENT))
{
@@ -679,7 +682,6 @@ public class NodesImpl implements Nodes
}
else if (type.equals(Type.FOLDER))
{
// container/folder
node = new Folder(nodeRef, parentNodeRef, properties, mapUserInfo, sr);
}
else
@@ -920,11 +922,23 @@ public class NodesImpl implements Nodes
QueryHelper.walk(q, propertyWalker);
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;
includeFolders = isFolder;
}
else if (isContent != null)
{
includeFiles = isContent;
includeFolders = !isContent;
}
String nodeTypeStr = propertyWalker.getProperty(PARAM_NODETYPE, WhereClauseParser.EQUALS, String.class);
if ((nodeTypeStr != null) && (! nodeTypeStr.isEmpty()))
@@ -954,6 +968,7 @@ public class NodesImpl implements Nodes
List<Pair<QName, Boolean>> sortProps = null;
if ((sortCols != null) && (sortCols.size() > 0))
{
// TODO should we allow isContent in sort (and map to reverse of isFolder) ?
sortProps = new ArrayList<>(sortCols.size());
for (SortColumn sortCol : sortCols)
{

View File

@@ -55,7 +55,8 @@ public class Document extends Node
contentInfo = new ContentInfo(mimeType, mimeTypeName, cd.getSize(), cd.getEncoding());
}
this.isFolder = false;
setIsFolder(false);
setIsContent(true);
}
@Override

View File

@@ -42,7 +42,9 @@ public class Folder extends Node
public Folder(NodeRef nodeRef, NodeRef parentNodeRef, Map<QName, Serializable> nodeProps, Map<String, UserInfo> mapUserInfo, ServiceRegistry sr)
{
super(nodeRef, parentNodeRef, nodeProps, mapUserInfo, sr);
this.isFolder = true;
setIsFolder(true);
setIsContent(false);
}
@Override

View File

@@ -57,6 +57,7 @@ public class Node implements Comparable<Node>
protected UserInfo modifiedByUser;
protected Boolean isFolder;
protected Boolean isContent;
protected Boolean isLink;
protected NodeRef parentNodeRef;
@@ -253,6 +254,16 @@ public class Node implements Comparable<Node>
this.isFolder = isFolder;
}
public Boolean getIsContent()
{
return isContent;
}
public void setIsContent(Boolean isContent)
{
this.isContent = isContent;
}
public Boolean getIsLink()
{
return isLink;
@@ -291,10 +302,11 @@ public class Node implements Comparable<Node>
return "Node [nodeRef=" + nodeRef + ", type=" + prefixTypeQName + ", name=" + name + ", title="
+ title + ", description=" + description + ", createdAt="
+ 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
// also allows list of results to be returned as "nodes"
protected ContentInfo contentInfo;