Merged HEAD (5.2) to 5.2.N (5.2.1)

126349 jkaabimofrad: Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2)
      118692 jvonka: Merge from DEV/SABRE_JANV1 (part 2) - RA-613 / RA-655
      - File Folder API (PoC - experimental WIP)
      - TODO add tests +review backwards compat' (eg. favs)


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@126694 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ancuta Morarasu
2016-05-11 10:44:49 +00:00
parent 3a5a22da8d
commit d3b503759b
12 changed files with 917 additions and 452 deletions

View File

@@ -38,7 +38,7 @@ import java.util.List;
* @author janv
*/
@RelationshipResource(name = "children", entityResource = NodesEntityResource.class, title = "Folder children")
public class NodeChildrenRelation implements RelationshipResourceAction.Read<Node>, RelationshipResourceAction.Create<Folder>, InitializingBean
public class NodeChildrenRelation implements RelationshipResourceAction.Read<Node>, RelationshipResourceAction.Create<Node>, InitializingBean
{
private Nodes nodes;
@@ -84,22 +84,22 @@ public class NodeChildrenRelation implements RelationshipResourceAction.Read<Nod
}
/**
* Create one or more sub-folders below parent folder. Note: can also use well-known alias, eg. -root- or -my-
* Create one or more nodes (folder or empty file) below parent folder.
*
* TODO also consider option to create path - eg. by passing name path in name (see Sparta API as an example) ... or should this be a separate API ?
* Note: for parent folder nodeId, can also use well-known alias, eg. -root- or -my-
*
* If parentFolderNodeId does not exist, EntityNotFoundException (status 404).
* If parentFolderNodeId does not represent a folder, InvalidArgumentException (status 400).
*/
@Override
@WebApiDescription(title="Create one (or more) folder(s) as a child of folder identified by parentFolderNodeId")
public List<Folder> create(String parentFolderNodeId, List<Folder> folderInfos, Parameters parameters)
@WebApiDescription(title="Create one (or more) nodes as children of folder identified by parentFolderNodeId")
public List<Node> create(String parentFolderNodeId, List<Node> nodeInfos, Parameters parameters)
{
List<Folder> result = new ArrayList<>(folderInfos.size());
List<Node> result = new ArrayList<>(nodeInfos.size());
for (Folder folderInfo : folderInfos)
for (Node nodeInfo : nodeInfos)
{
result.add(nodes.createFolder(parentFolderNodeId, folderInfo, parameters));
result.add(nodes.createNode(parentFolderNodeId, nodeInfo, parameters));
}
return result;

View File

@@ -27,23 +27,32 @@ package org.alfresco.rest.api.nodes;
import org.alfresco.rest.api.Nodes;
import org.alfresco.rest.api.model.Node;
import org.alfresco.rest.framework.BinaryProperties;
import org.alfresco.rest.framework.WebApiDescription;
import org.alfresco.rest.framework.WebApiParam;
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
import org.alfresco.rest.framework.resource.EntityResource;
import org.alfresco.rest.framework.resource.actions.interfaces.BinaryResourceAction;
import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction;
import org.alfresco.rest.framework.resource.content.BasicContentInfo;
import org.alfresco.rest.framework.resource.content.BinaryResource;
import org.alfresco.rest.framework.resource.parameters.Parameters;
import org.alfresco.util.ParameterCheck;
import org.springframework.beans.factory.InitializingBean;
import java.io.InputStream;
/**
* An implementation of an Entity Resource for a Node
* An implementation of an Entity Resource for a Node (file or folder)
*
* @author sglover
* @author Gethin James
* @author janv
*/
@EntityResource(name="nodes", title = "Nodes")
public class NodesEntityResource implements EntityResourceAction.ReadById<Node>, EntityResourceAction.Delete, EntityResourceAction.Update<Node>, InitializingBean
public class NodesEntityResource implements
EntityResourceAction.ReadById<Node>, EntityResourceAction.Delete, EntityResourceAction.Update<Node>,
BinaryResourceAction.Read, BinaryResourceAction.Update, InitializingBean
{
private Nodes nodes;
@@ -61,13 +70,10 @@ public class NodesEntityResource implements EntityResourceAction.ReadById<Node>,
/**
* Returns information regarding the node 'nodeId' - folder or document
*
* TODO other metadata/properties & permissions etc ...
*
* @param nodeId String id of node (folder or document) - will also accept well-known aliases, eg. "-root-" or "-my-"
*
* Optional parameters:
* - path
* - incPrimaryPath
*/
@WebApiDescription(title = "Get Node Information", description = "Get information for the node with id 'nodeId'")
@WebApiParam(name = "nodeId", title = "The node id")
@@ -76,15 +82,30 @@ public class NodesEntityResource implements EntityResourceAction.ReadById<Node>,
return nodes.getFolderOrDocument(nodeId, parameters);
}
@Override
@WebApiDescription(title = "Download content", description = "Download content")
@BinaryProperties({"content"})
public BinaryResource readProperty(String fileNodeId, Parameters parameters) throws EntityNotFoundException
{
return nodes.getContent(fileNodeId, parameters);
}
@Override
@WebApiDescription(title = "Upload content", description = "Upload content")
@BinaryProperties({"content"})
public void update(String fileNodeId, BasicContentInfo contentInfo, InputStream stream, Parameters parameters)
{
nodes.updateContent(fileNodeId, contentInfo, stream, parameters);
}
/**
* Update info on the node 'nodeId' - folder or document
*
* Initially, name, title &/or description. Note: changing name is a "rename" (and must be unique within the current parent folder).
*
* TODO other metadata/properties & permissions etc ...
* Can update name (which is a "rename" and hence must be unique within the current parent folder)
* or update other properties.
*
* @param nodeId String nodeId of node (folder or document)
* @param nodeInfo node entity with info to update (eg. name, title, description ...)
* @param nodeInfo node entity with info to update (eg. name, properties ...)
* @param parameters
* @return
*/