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

118663 jvonka: Merge from DEV/SABRE_JANV1 (part 1)
   File Folder API (PoC - experimental WIP)
   - relates to RA-613
   - initial file folder CRUD including
   - * list folder children (minimal info by default) 
       with sorting, paging & optional isFolder=true/false
   - * create folders or (empty) files
   - * get node info
       with id, name, nodeType, auditable props, properties (not sys:referencable), aspectNames, ...
   - * put node info
   - * put content (upload file)
   - * get content (download file)
   - * delete node (cascade for folder)
   - * support for well-known folder alias, -root-, -my-, -shared-
   - TODO add tests


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@126348 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jamal Kaabi-Mofrad
2016-05-10 10:26:10 +00:00
parent 095b910fd1
commit 4810279cb7
9 changed files with 617 additions and 36 deletions

View File

@@ -5,6 +5,7 @@ import java.math.BigInteger;
import java.util.Map;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.apache.chemistry.opencmis.commons.PropertyIds;
import org.apache.chemistry.opencmis.commons.data.Properties;
@@ -14,6 +15,7 @@ import org.apache.chemistry.opencmis.commons.data.PropertyData;
* Representation of a document node.
*
* @author steveglover
* @author janv
*
*/
public class Document extends Node
@@ -26,7 +28,8 @@ public class Document extends Node
{
super();
}
/*
public Document(NodeRef nodeRef, Properties properties)
{
super(nodeRef, properties);
@@ -36,10 +39,11 @@ public class Document extends Node
this.sizeInBytes = (BigInteger)getValue(props, PropertyIds.CONTENT_STREAM_LENGTH);
this.versionLabel = (String)getValue(props, PropertyIds.VERSION_LABEL);
}
*/
public Document(NodeRef nodeRef, Map<QName, Serializable> nodeProps)
public Document(NodeRef nodeRef, Map<QName, Serializable> nodeProps, NamespaceService namespaceService)
{
super(nodeRef, nodeProps);
super(nodeRef, nodeProps, namespaceService);
}
public String getMimeType()
@@ -57,6 +61,11 @@ public class Document extends Node
return versionLabel;
}
public Boolean getIsFolder()
{
return false;
}
@Override
public String toString()
{

View File

@@ -4,6 +4,7 @@ import java.io.Serializable;
import java.util.Map;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.apache.chemistry.opencmis.commons.data.Properties;
@@ -11,6 +12,7 @@ import org.apache.chemistry.opencmis.commons.data.Properties;
* Representation of a folder node.
*
* @author steveglover
* @author janv
*
*/
public class Folder extends Node
@@ -20,14 +22,21 @@ public class Folder extends Node
super();
}
/*
public Folder(NodeRef nodeRef, Properties properties)
{
super(nodeRef, properties);
}
*/
public Folder(NodeRef nodeRef, Map<QName, Serializable> nodeProps)
public Folder(NodeRef nodeRef, Map<QName, Serializable> nodeProps, NamespaceService namespaceService)
{
super(nodeRef, nodeProps);
super(nodeRef, nodeProps, namespaceService);
}
public Boolean getIsFolder()
{
return true;
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012 Alfresco Software Limited.
* Copyright (C) 2005-2015 Alfresco Software Limited.
*
* This file is part of Alfresco
*
@@ -19,13 +19,19 @@
package org.alfresco.rest.api.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import org.alfresco.model.ContentModel;
import org.alfresco.rest.framework.resource.UniqueId;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.EqualsHelper;
import org.apache.chemistry.opencmis.commons.PropertyIds;
@@ -37,20 +43,45 @@ import org.apache.chemistry.opencmis.commons.data.PropertyData;
*
* @author steveglover
* @author Gethin James
* @author janv
*/
public class Node implements Comparable<Node>
{
protected NodeRef nodeRef;
protected String name;
protected String title;
protected NodeRef guid;
protected NodeRef guid; // TODO review - do we need for favorites (backwards compat') ?
protected String description;
protected Date createdAt;
protected Date modifiedAt;
protected String createdBy;
protected String modifiedBy;
public Node(NodeRef nodeRef, Map<QName, Serializable> nodeProps)
protected String primaryPath;
protected String prefixTypeQName;
protected Map<String, Serializable> props;
private static final List<QName> EXCLUDED_PROPS = Arrays.asList(
ContentModel.PROP_NAME,
ContentModel.PROP_TITLE,
ContentModel.PROP_DESCRIPTION,
ContentModel.PROP_MODIFIER,
ContentModel.PROP_MODIFIED,
ContentModel.PROP_CREATOR,
ContentModel.PROP_CREATED,
ContentModel.PROP_CONTENT,
ContentModel.PROP_LOCALE,
ContentModel.PROP_NODE_UUID,
ContentModel.PROP_STORE_IDENTIFIER,
ContentModel.PROP_STORE_PROTOCOL,
ContentModel.PROP_NODE_DBID,
ContentModel.PROP_INITIAL_VERSION,
ContentModel.PROP_AUTO_VERSION_PROPS,
ContentModel.PROP_AUTO_VERSION);
// TODO fixme !
public Node(NodeRef nodeRef, Map<QName, Serializable> nodeProps, NamespaceService namespaceService)
{
if(nodeRef == null)
{
@@ -58,7 +89,7 @@ public class Node implements Comparable<Node>
}
this.nodeRef = nodeRef;
mapProperties(nodeProps);
mapProperties(nodeProps, namespaceService);
}
protected Object getValue(Map<String, PropertyData<?>> props, String name)
@@ -68,14 +99,19 @@ public class Node implements Comparable<Node>
return value;
}
/*
public Node(NodeRef nodeRef, Properties properties)
{
this.nodeRef = nodeRef;
Map<String, PropertyData<?>> props = properties.getProperties();
this.guid = nodeRef;
this.name = (String)getValue(props, PropertyIds.NAME);
this.title = (String)getValue(props, ContentModel.PROP_TITLE.toString());
this.guid = nodeRef;
this.description = (String)getValue(props, PropertyIds.DESCRIPTION);
GregorianCalendar cal = (GregorianCalendar)getValue(props, PropertyIds.CREATION_DATE);
this.createdAt = cal.getTime();
cal = (GregorianCalendar)getValue(props, PropertyIds.LAST_MODIFICATION_DATE);
@@ -83,21 +119,34 @@ public class Node implements Comparable<Node>
this.createdBy = (String)getValue(props, PropertyIds.CREATED_BY);
this.modifiedBy = (String)getValue(props, PropertyIds.LAST_MODIFIED_BY);
}
*/
public Node()
{
}
protected void mapProperties(Map<QName, Serializable> nodeProps)
protected void mapProperties(Map<QName, Serializable> nodeProps, NamespaceService namespaceService)
{
// TODO review backwards compat' for favorites & others (eg. set guid explicitly where still needed)
//this.guid = nodeRef;
this.name = (String)nodeProps.get(ContentModel.PROP_NAME);
this.guid = nodeRef;
this.title = (String)nodeProps.get(ContentModel.PROP_TITLE);
this.description = (String)nodeProps.get(ContentModel.PROP_DESCRIPTION);
this.createdAt = (Date)nodeProps.get(ContentModel.PROP_CREATED);
this.createdBy = (String)nodeProps.get(ContentModel.PROP_CREATOR);
this.modifiedAt = (Date)nodeProps.get(ContentModel.PROP_MODIFIED);
this.modifiedBy = (String)nodeProps.get(ContentModel.PROP_MODIFIER);
this.description = (String)nodeProps.get(ContentModel.PROP_DESCRIPTION);
this.props = new HashMap<>(nodeProps.size());
for (Map.Entry<QName, Serializable> entry : nodeProps.entrySet()) {
QName propQName = entry.getKey();
if (! EXCLUDED_PROPS.contains(propQName)) {
props.put(entry.getKey().toPrefixString(namespaceService), entry.getValue());
}
}
}
public void setGuid(NodeRef guid)
@@ -175,6 +224,30 @@ public class Node implements Comparable<Node>
this.createdBy = createdBy;
}
public String getPrimaryPath()
{
return primaryPath;
}
public void setPrimaryPath(String primaryPath)
{
this.primaryPath = primaryPath;
}
public String getType()
{
return prefixTypeQName;
}
public void setType(String prefixType)
{
this.prefixTypeQName = prefixType;
}
public Map getProperties() {
return this.props;
}
public boolean equals(Object other)
{
if(this == other)
@@ -200,9 +273,9 @@ public class Node implements Comparable<Node>
@Override
public String toString()
{
return "Node [nodeRef=" + nodeRef + ", name=" + name + ", title="
return "Node [nodeRef=" + nodeRef + ", type=" + prefixTypeQName + ", name=" + name + ", title="
+ title + ", description=" + description + ", createdAt="
+ createdAt + ", modifiedAt=" + modifiedAt + ", createdBy=" + createdBy + ", modifiedBy="
+ modifiedBy + "]";
+ modifiedBy + ", primaryPath =" + primaryPath +"]";
}
}