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)
126348 jkaabimofrad: 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/BRANCHES/DEV/5.2.N/root@126693 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2015 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.rest.api.nodes;
|
||||
|
||||
import org.alfresco.rest.api.Nodes;
|
||||
import org.alfresco.rest.api.model.Folder;
|
||||
import org.alfresco.rest.api.model.Node;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.resource.RelationshipResource;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* TODO ... work-in-progress
|
||||
*
|
||||
* @author janv
|
||||
*/
|
||||
@RelationshipResource(name = "children", entityResource = NodesEntityResource.class, title = "Folder children")
|
||||
public class NodeChildrenRelation implements RelationshipResourceAction.Read<Node>, RelationshipResourceAction.Create<Folder>, InitializingBean
|
||||
{
|
||||
private Nodes nodes;
|
||||
|
||||
public void setNodes(Nodes nodes)
|
||||
{
|
||||
this.nodes = nodes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet()
|
||||
{
|
||||
ParameterCheck.mandatory("nodes", this.nodes);
|
||||
}
|
||||
|
||||
/**
|
||||
* List folder children - returns a filtered/sorted/paged list of nodes that are immediate children of the parent folder
|
||||
*
|
||||
* TODO filtering, sorting, ...
|
||||
* TODO metadata/properties & permissions etc ...
|
||||
*
|
||||
* @param parentFolderNodeId String id of parent folder - will also accept aliases "-root-" (Company Home) or "-my-" (current user's home folder)
|
||||
*
|
||||
* Optional query parameters:
|
||||
*
|
||||
* - incFiles
|
||||
* - incFolders
|
||||
*
|
||||
* - properties
|
||||
* - where
|
||||
* - orderBy
|
||||
*
|
||||
* - skipCount
|
||||
* - maxItems
|
||||
*
|
||||
* If parentFolderNodeId does not exist, EntityNotFoundException (status 404).
|
||||
* If parentFolderNodeId does not represent a folder, InvalidArgumentException (status 400).
|
||||
*/
|
||||
@Override
|
||||
@WebApiDescription(title = "Return a paged list of nodes for the document/folder identified by parentFolderNodeId")
|
||||
public CollectionWithPagingInfo<Node> readAll(String parentFolderNodeId, Parameters parameters)
|
||||
{
|
||||
return nodes.getChildren(parentFolderNodeId, parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create one or more sub-folders below parent folder. Note: can also use well-known alias, eg. -root- or -my-
|
||||
*
|
||||
* 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 ?
|
||||
*
|
||||
* 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)
|
||||
{
|
||||
List<Folder> result = new ArrayList<>(folderInfos.size());
|
||||
|
||||
for (Folder folderInfo : folderInfos)
|
||||
{
|
||||
result.add(nodes.createFolder(parentFolderNodeId, folderInfo, parameters));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user