mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Feature/rm 4639 rest api refactoring 2
This commit is contained in:
@@ -28,8 +28,11 @@
|
||||
package org.alfresco.rm.rest.api;
|
||||
|
||||
import org.alfresco.rest.api.Nodes;
|
||||
import org.alfresco.rest.api.model.Node;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.servlet.FormData;
|
||||
|
||||
/**
|
||||
* RM Nodes API
|
||||
@@ -37,6 +40,7 @@ import org.alfresco.service.namespace.QName;
|
||||
* @author Ana Bozianu
|
||||
* @since 2.6
|
||||
*/
|
||||
@Deprecated
|
||||
public interface RMNodes extends Nodes
|
||||
{
|
||||
public static String PATH_FILE_PLAN = "-filePlan-";
|
||||
@@ -47,10 +51,13 @@ public interface RMNodes extends Nodes
|
||||
public static String PARAM_INCLUDE_HAS_RETENTION_SCHEDULE = "hasRetentionSchedule";
|
||||
public static String PARAM_INCLUDE_IS_CLOSED = "isClosed";
|
||||
public static String PARAM_INCLUDE_IS_COMPLETED = "isCompleted";
|
||||
public static String PARAM_INCLUDE_TRANSFER_PDF_INDICATOR = "transferPDFIndicator";
|
||||
public static String PARAM_INCLUDE_TRANSFER_LOCATION = "transferLocation";
|
||||
public static String PARAM_INCLUDE_TRANSFER_ACCESSION_INDICATOR = "transferAccessionIndicator";
|
||||
|
||||
/**
|
||||
* Gets or creates the relative path starting from the provided parent folder.
|
||||
* The method decides the type of the created elements considering the
|
||||
* The method decides the type of the created elements considering the
|
||||
* parent container's type and the type of the node to be created.
|
||||
* @param parentFolderNodeId the parent folder to start from
|
||||
* @param relativePath the relative path
|
||||
@@ -58,4 +65,46 @@ public interface RMNodes extends Nodes
|
||||
* @return reference to the last element of the created path
|
||||
*/
|
||||
public NodeRef getOrCreatePath(String parentFolderNodeId, String relativePath, QName nodeTypeQName);
|
||||
|
||||
/**
|
||||
* Validates if the component with provided id and provided parameters belongs to the current endpoint.
|
||||
*
|
||||
* @param filePlanComponentId - file plan component id to check
|
||||
* @param parameters - provided parameters
|
||||
* @param requestedTypeQName - the requested type that identifies the endpoint we are in
|
||||
*/
|
||||
public void validateNodeType(String filePlanComponentId, Parameters parameters, QName requestedTypeQName);
|
||||
|
||||
/**
|
||||
* Validates if the component with provided id and provided parameters from formData belongs to the current endpoint.
|
||||
*
|
||||
* @param filePlanComponentId - file plan component id to check
|
||||
* @param formData - provided formData
|
||||
* @param requestedTypeQName - the requested type that identifies the endpoint we are in
|
||||
*/
|
||||
public void validateNodeType(String filePlanComponentId, FormData formData, QName requestedTypeQName);
|
||||
|
||||
/**
|
||||
* Validates if the component with provided id, relativePath from new created filePlanComponent and provided parameters belongs to the current endpoint.
|
||||
*
|
||||
* @param filePlanComponentId - file plan component id to check
|
||||
* @param filePlanComponentInfo - new created file plan component info
|
||||
* @param parameters - provided parameters
|
||||
* @param requestedTypeQName - the requested type that identifies the endpoint we are in
|
||||
*/
|
||||
public void validateNodeType(String filePlanComponentId, Node filePlanComponentInfo, Parameters parameters, QName requestedTypeQName);
|
||||
|
||||
/**
|
||||
* Validates if the filePlanComponent with provided id is a record.
|
||||
*
|
||||
* @param filePlanComponentId
|
||||
*/
|
||||
public void validateRecord(String filePlanComponentId);
|
||||
|
||||
/**
|
||||
* Helper method to obtain file plan type or null if the rm site does not exist.
|
||||
*
|
||||
* @return file plan type or null
|
||||
*/
|
||||
public QName getFilePlanType();
|
||||
}
|
||||
|
@@ -28,10 +28,9 @@
|
||||
package org.alfresco.rm.rest.api;
|
||||
|
||||
import org.alfresco.rest.api.Sites;
|
||||
import org.alfresco.rest.api.model.Site;
|
||||
import org.alfresco.rest.api.model.SiteUpdate;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rm.rest.api.model.RMSite;
|
||||
import org.alfresco.rm.rest.api.model.SiteUpdate;
|
||||
|
||||
/**
|
||||
* RM Sites API
|
||||
@@ -73,14 +72,4 @@ public interface RMSites extends Sites
|
||||
* @param parameters
|
||||
*/
|
||||
void deleteRMSite(String siteId, Parameters parameters);
|
||||
|
||||
/**
|
||||
* TODO Copied from Sites interface because was not available in 5.2.a-EA. To be removed after upgrading.
|
||||
*
|
||||
* @param siteId
|
||||
* @param site
|
||||
* @param parameters
|
||||
* @return
|
||||
*/
|
||||
Site updateSite(String siteId, SiteUpdate site, Parameters parameters);
|
||||
}
|
||||
|
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api;
|
||||
|
||||
import org.alfresco.rest.api.model.Node;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rm.rest.api.model.TargetContainer;
|
||||
|
||||
/**
|
||||
* Records API
|
||||
*
|
||||
* @author Ana Bozianu
|
||||
* @since 2.6
|
||||
*/
|
||||
public interface Records
|
||||
{
|
||||
public static final String PARAM_HIDE_RECORD = "hideRecord";
|
||||
|
||||
/**
|
||||
* Creates a record from a file
|
||||
*
|
||||
* @param fileId the id of a non record file
|
||||
* @param parameters the {@link Parameters} object to get the parameters passed into the request
|
||||
* @return information about the created record
|
||||
*/
|
||||
public Node declareFileAsRecord(String fileId, Parameters parameters);
|
||||
|
||||
/**
|
||||
* Files a record into th fileplan.
|
||||
* If the record is already filed it links the record to the target folder
|
||||
*
|
||||
* @param recordId the id of the record do file/link
|
||||
* @param target the target parent folder
|
||||
* @param parameters the {@link Parameters} object to get the parameters passed into the request
|
||||
* @return information about the new state of the record
|
||||
*/
|
||||
public Node fileOrLinkRecord(String recordId, TargetContainer target, Parameters parameters);
|
||||
}
|
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.fileplancomponents;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.rest.api.model.Node;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.WebApiParam;
|
||||
import org.alfresco.rest.framework.core.exceptions.ApiException;
|
||||
import org.alfresco.rest.framework.resource.RelationshipResource;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.MultiPartRelationshipResourceAction;
|
||||
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.rest.framework.webscripts.WithResponse;
|
||||
import org.alfresco.rm.rest.api.RMNodes;
|
||||
import org.springframework.extensions.webscripts.servlet.FormData;
|
||||
|
||||
/**
|
||||
* An implementation of an Entity Resource for a fileplan component
|
||||
*
|
||||
* @author Ana Bozianu
|
||||
* @since 2.6
|
||||
*/
|
||||
@RelationshipResource(name="children", entityResource = FileplanComponentsEntityResource.class, title = "Children of fileplan component")
|
||||
public class FileplanComponentChildrenRelation implements RelationshipResourceAction.Read<Node>,
|
||||
RelationshipResourceAction.Create<Node>,
|
||||
MultiPartRelationshipResourceAction.Create<Node>
|
||||
{
|
||||
private RMNodes nodes;
|
||||
|
||||
public void setNodes(RMNodes nodes)
|
||||
{
|
||||
this.nodes = nodes;
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Return a paged list of fileplan components for the container identified by parentFolderNodeId")
|
||||
public CollectionWithPagingInfo<Node> readAll(String parentFolderNodeId, Parameters parameters)
|
||||
{
|
||||
return nodes.listChildren(parentFolderNodeId, parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title="Create one (or more) nodes as children of container identified by parentFolderNodeId")
|
||||
public List<Node> create(String parentFolderNodeId, List<Node> nodeInfos, Parameters parameters)
|
||||
{
|
||||
List<Node> result = new ArrayList<>(nodeInfos.size());
|
||||
|
||||
for (Node nodeInfo : nodeInfos)
|
||||
{
|
||||
result.add(nodes.createNode(parentFolderNodeId, nodeInfo, parameters));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Upload file content and meta-data into the repository.")
|
||||
@WebApiParam(name = "formData", title = "A single form data", description = "A single form data which holds FormFields.")
|
||||
public Node create(String parentFolderNodeId, FormData formData, Parameters parameters, WithResponse withResponse)
|
||||
{
|
||||
try
|
||||
{
|
||||
return nodes.upload(parentFolderNodeId, formData, parameters);
|
||||
}
|
||||
catch (ApiException apiException)
|
||||
{
|
||||
/*
|
||||
* The upload method encapsulates most exceptions that can occur on node creation in an ApiException.
|
||||
* To allow the API framework to correctly map the exception to the API error code we throw the original exception.
|
||||
*/
|
||||
Throwable originalException = apiException.getCause();
|
||||
if (originalException != null && originalException instanceof RuntimeException)
|
||||
{
|
||||
throw (RuntimeException) originalException;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw apiException;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,93 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.fileplancomponents;
|
||||
|
||||
import org.alfresco.rest.api.model.Node;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.WebApiParam;
|
||||
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
|
||||
import org.alfresco.rest.framework.resource.EntityResource;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rm.rest.api.RMNodes;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
/**
|
||||
* Fileplan component children
|
||||
*
|
||||
* @author Ana Bozianu
|
||||
* @since 2.6
|
||||
*/
|
||||
@EntityResource(name="fileplan-components", title = "Fileplan Components")
|
||||
public class FileplanComponentsEntityResource implements
|
||||
EntityResourceAction.ReadById<Node>,
|
||||
EntityResourceAction.Delete,
|
||||
EntityResourceAction.Update<Node>,
|
||||
InitializingBean
|
||||
{
|
||||
private RMNodes nodes;
|
||||
private String PARAM_PERMANENT = "permanent";
|
||||
|
||||
public void setNodes(RMNodes nodes)
|
||||
{
|
||||
this.nodes = nodes;
|
||||
}
|
||||
|
||||
@WebApiDescription(title = "Get Node Information", description = "Get information for the fileplan component with id 'nodeId'")
|
||||
@WebApiParam(name = "nodeId", title = "The node id")
|
||||
public Node readById(String nodeId, Parameters parameters)
|
||||
{
|
||||
return nodes.getFolderOrDocument(nodeId, parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title="Updates a node (file or folder) with id 'nodeId'")
|
||||
public Node update(String nodeId, Node nodeInfo, Parameters parameters)
|
||||
{
|
||||
return nodes.updateNode(nodeId, nodeInfo, parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Delete Node", description="Delete the file or folder with id 'nodeId'. Folder will cascade delete")
|
||||
public void delete(String nodeId, Parameters parameters)
|
||||
{
|
||||
String permanentParameter = parameters.getParameter(PARAM_PERMANENT);
|
||||
if(permanentParameter != null)
|
||||
{
|
||||
throw new InvalidArgumentException("DELETE does not support parameter: permanent");
|
||||
}
|
||||
nodes.deleteNode(nodeId, parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
ParameterCheck.mandatory("nodes", this.nodes);
|
||||
}
|
||||
}
|
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.fileplans;
|
||||
|
||||
import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.checkNotBlank;
|
||||
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
|
||||
import java.util.AbstractList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.repo.node.getchildren.FilterProp;
|
||||
import org.alfresco.rest.api.impl.Util;
|
||||
import org.alfresco.rest.api.model.UserInfo;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
||||
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.rm.rest.api.impl.ApiNodesModelFactory;
|
||||
import org.alfresco.rm.rest.api.impl.FilePlanComponentsApiUtils;
|
||||
import org.alfresco.rm.rest.api.impl.SearchTypesFactory;
|
||||
import org.alfresco.rm.rest.api.model.FilePlan;
|
||||
import org.alfresco.rm.rest.api.model.RecordCategory;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
/**
|
||||
* File plan children relation
|
||||
*
|
||||
* @author Ramona Popa
|
||||
* @since 2.6
|
||||
*/
|
||||
@RelationshipResource(name="categories", entityResource = FilePlanEntityResource.class, title = "Category children of file plan")
|
||||
public class FilePlanChildrenRelation implements RelationshipResourceAction.Read<RecordCategory>,
|
||||
RelationshipResourceAction.Create<RecordCategory>, InitializingBean
|
||||
{
|
||||
/** Record category type */
|
||||
public static final String RECORD_CATEGORY_TYPE = "rma:recordCategory";
|
||||
|
||||
private FilePlanComponentsApiUtils apiUtils;
|
||||
private FileFolderService fileFolderService;
|
||||
private ApiNodesModelFactory nodesModelFactory;
|
||||
private SearchTypesFactory searchTypesFactory;
|
||||
|
||||
public void setApiUtils(FilePlanComponentsApiUtils apiUtils)
|
||||
{
|
||||
this.apiUtils = apiUtils;
|
||||
}
|
||||
|
||||
public void setFileFolderService(FileFolderService fileFolderService)
|
||||
{
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
public void setNodesModelFactory(ApiNodesModelFactory nodesModelFactory)
|
||||
{
|
||||
this.nodesModelFactory = nodesModelFactory;
|
||||
}
|
||||
|
||||
public void setSearchTypesFactory(SearchTypesFactory searchTypesFactory)
|
||||
{
|
||||
this.searchTypesFactory = searchTypesFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
ParameterCheck.mandatory("apiUtils", this.apiUtils);
|
||||
ParameterCheck.mandatory("fileFolderService", this.fileFolderService);
|
||||
ParameterCheck.mandatory("nodesModelFactory", this.nodesModelFactory);
|
||||
ParameterCheck.mandatory("searchTypesFactory", this.searchTypesFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Return a paged list of file plan children (record categories) for the container identified by 'filePlanId'")
|
||||
public CollectionWithPagingInfo<RecordCategory> readAll(String filePlanId, Parameters parameters)
|
||||
{
|
||||
// validate parameters
|
||||
checkNotBlank("filePlanId", filePlanId);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
QName filePlanType = apiUtils.getFilePlanType();
|
||||
if(filePlanType == null)// rm site not created
|
||||
{
|
||||
throw new EntityNotFoundException(filePlanId);
|
||||
}
|
||||
NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(filePlanId, filePlanType);
|
||||
|
||||
// list record categories
|
||||
Set<QName> searchTypeQNames = searchTypesFactory.buildSearchTypesForFilePlanEndpoint();
|
||||
|
||||
//FIXME this param null
|
||||
List<FilterProp> filterProps = apiUtils.getListChildrenFilterProps(parameters, null);
|
||||
|
||||
final PagingResults<FileInfo> pagingResults = fileFolderService.list(parentNodeRef,
|
||||
null,
|
||||
searchTypeQNames,
|
||||
null,
|
||||
apiUtils.getSortProperties(parameters),
|
||||
filterProps,
|
||||
Util.getPagingRequest(parameters.getPaging()));
|
||||
|
||||
final List<FileInfo> page = pagingResults.getPage();
|
||||
Map<String, UserInfo> mapUserInfo = new HashMap<>();
|
||||
List<RecordCategory> nodes = new AbstractList<RecordCategory>()
|
||||
{
|
||||
@Override
|
||||
public RecordCategory get(int index)
|
||||
{
|
||||
FileInfo info = page.get(index);
|
||||
return nodesModelFactory.createRecordCategory(info, parameters, mapUserInfo, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size()
|
||||
{
|
||||
return page.size();
|
||||
}
|
||||
};
|
||||
|
||||
FilePlan sourceEntity = null;
|
||||
if (parameters.includeSource())
|
||||
{
|
||||
FileInfo info = fileFolderService.getFileInfo(parentNodeRef);
|
||||
sourceEntity = nodesModelFactory.createFilePlan(info, parameters, mapUserInfo, true);
|
||||
}
|
||||
|
||||
return CollectionWithPagingInfo.asPaged(parameters.getPaging(), nodes, pagingResults.hasMoreItems(),
|
||||
pagingResults.getTotalResultCount().getFirst(), sourceEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title="Create one (or more) record categories as children of container identified by 'filePlanId'")
|
||||
public List<RecordCategory> create(String filePlanId, List<RecordCategory> nodeInfos, Parameters parameters)
|
||||
{
|
||||
checkNotBlank("filePlanId", filePlanId);
|
||||
mandatory("nodeInfos", nodeInfos);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
QName filePlanType = apiUtils.getFilePlanType();
|
||||
if(filePlanType == null)// rm site not created
|
||||
{
|
||||
throw new EntityNotFoundException(filePlanId);
|
||||
}
|
||||
NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(filePlanId, filePlanType);
|
||||
|
||||
List<RecordCategory> result = new ArrayList<>(nodeInfos.size());
|
||||
Map<String, UserInfo> mapUserInfo = new HashMap<>();
|
||||
for (RecordCategory nodeInfo : nodeInfos)
|
||||
{
|
||||
// Create the node
|
||||
NodeRef newNode = apiUtils.createRMNode(parentNodeRef, nodeInfo.getName(), RECORD_CATEGORY_TYPE, nodeInfo.getProperties(), nodeInfo.getAspectNames());
|
||||
FileInfo info = fileFolderService.getFileInfo(newNode);
|
||||
result.add(nodesModelFactory.createRecordCategory(info, parameters, mapUserInfo, false));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.fileplans;
|
||||
|
||||
import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.checkNotBlank;
|
||||
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
|
||||
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.EntityResourceAction;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rm.rest.api.impl.ApiNodesModelFactory;
|
||||
import org.alfresco.rm.rest.api.impl.FilePlanComponentsApiUtils;
|
||||
import org.alfresco.rm.rest.api.model.FilePlan;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
/**
|
||||
* File plan entity resource
|
||||
*
|
||||
* @author Ramona Popa
|
||||
* @since 2.6
|
||||
*/
|
||||
@EntityResource(name = "file-plans", title = "File plans")
|
||||
public class FilePlanEntityResource
|
||||
implements EntityResourceAction.ReadById<FilePlan>, EntityResourceAction.Update<FilePlan>, InitializingBean
|
||||
{
|
||||
|
||||
private FilePlanComponentsApiUtils apiUtils;
|
||||
private FileFolderService fileFolderService;
|
||||
private ApiNodesModelFactory nodesModelFactory;
|
||||
|
||||
public void setApiUtils(FilePlanComponentsApiUtils apiUtils)
|
||||
{
|
||||
this.apiUtils = apiUtils;
|
||||
}
|
||||
|
||||
public void setFileFolderService(FileFolderService fileFolderService)
|
||||
{
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
public void setNodesModelFactory(ApiNodesModelFactory nodesModelFactory)
|
||||
{
|
||||
this.nodesModelFactory = nodesModelFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
ParameterCheck.mandatory("apiUtils", this.apiUtils);
|
||||
ParameterCheck.mandatory("fileFolderService", this.fileFolderService);
|
||||
ParameterCheck.mandatory("nodesModelFactory", this.nodesModelFactory);
|
||||
}
|
||||
|
||||
@WebApiDescription(title = "Get file plan information", description = "Get information for a file plan with id 'filePlanId'")
|
||||
@WebApiParam(name = "filePlanId", title = "The file plan id")
|
||||
public FilePlan readById(String filePlanId, Parameters parameters)
|
||||
{
|
||||
checkNotBlank("filePlanId", filePlanId);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
QName filePlanType = apiUtils.getFilePlanType();
|
||||
if(filePlanType == null)// rm site not created
|
||||
{
|
||||
throw new EntityNotFoundException(filePlanId);
|
||||
}
|
||||
NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(filePlanId, filePlanType);
|
||||
|
||||
FileInfo info = fileFolderService.getFileInfo(nodeRef);
|
||||
|
||||
return nodesModelFactory.createFilePlan(info, parameters, null, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Update file plan", description = "Updates a filePlan with id 'filePlanId'")
|
||||
public FilePlan update(String filePlanId, FilePlan filePlanInfo, Parameters parameters)
|
||||
{
|
||||
checkNotBlank("filePlanId", filePlanId);
|
||||
mandatory("filePlanInfo", filePlanInfo);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
QName filePlanType = apiUtils.getFilePlanType();
|
||||
if(filePlanType == null)// rm site not created
|
||||
{
|
||||
throw new EntityNotFoundException(filePlanId);
|
||||
}
|
||||
NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(filePlanId, filePlanType);
|
||||
apiUtils.updateNode(nodeRef, filePlanInfo, parameters);
|
||||
|
||||
FileInfo info = fileFolderService.getFileInfo(nodeRef);
|
||||
return nodesModelFactory.createFilePlan(info, parameters, null, false);
|
||||
}
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
/**
|
||||
* Package info that defines the Information Governance File Plans REST API
|
||||
*
|
||||
* @author Ramona Popa
|
||||
* @since 2.6
|
||||
*/
|
||||
@WebApi(name="gs", scope=Api.SCOPE.PUBLIC, version=1)
|
||||
package org.alfresco.rm.rest.api.fileplans;
|
||||
import org.alfresco.rest.framework.Api;
|
||||
import org.alfresco.rest.framework.WebApi;
|
@@ -27,14 +27,21 @@
|
||||
|
||||
package org.alfresco.rm.rest.api.files;
|
||||
|
||||
import org.alfresco.rest.api.model.Node;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.rest.framework.Operation;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.resource.EntityResource;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rest.framework.webscripts.WithResponse;
|
||||
import org.alfresco.rm.rest.api.Records;
|
||||
import org.alfresco.rm.rest.api.model.TargetContainer;
|
||||
import org.alfresco.rm.rest.api.impl.ApiNodesModelFactory;
|
||||
import org.alfresco.rm.rest.api.model.Record;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
@@ -47,23 +54,70 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
@EntityResource(name="files", title = "Files")
|
||||
public class FilesEntityResource implements InitializingBean
|
||||
{
|
||||
private Records records;
|
||||
private ApiNodesModelFactory nodesModelFactory;
|
||||
private AuthenticationUtil authenticationUtil;
|
||||
private FilePlanService filePlanService;
|
||||
private FileFolderService fileFolderService;
|
||||
private RecordService recordService;
|
||||
|
||||
public void setRecords(Records records)
|
||||
public void setAuthenticationUtil(AuthenticationUtil authenticationUtil)
|
||||
{
|
||||
this.records = records;
|
||||
this.authenticationUtil = authenticationUtil;
|
||||
}
|
||||
|
||||
public void setFilePlanService(FilePlanService filePlanService)
|
||||
{
|
||||
this.filePlanService = filePlanService;
|
||||
}
|
||||
|
||||
public void setFileFolderService(FileFolderService fileFolderService)
|
||||
{
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
public void setRecordService(RecordService recordService)
|
||||
{
|
||||
this.recordService = recordService;
|
||||
}
|
||||
|
||||
public void setNodesModelFactory(ApiNodesModelFactory nodesModelFactory)
|
||||
{
|
||||
this.nodesModelFactory = nodesModelFactory;
|
||||
}
|
||||
|
||||
@Operation("declare")
|
||||
@WebApiDescription(title = "Declare as record", description="Declare a file as record.")
|
||||
public Node declareAsRecord(String fileId, Void body, Parameters parameters, WithResponse withResponse)
|
||||
public Record declareAsRecord(String fileId, Void body, Parameters parameters, WithResponse withResponse)
|
||||
{
|
||||
return records.declareFileAsRecord(fileId, parameters);
|
||||
// Get fileplan
|
||||
NodeRef filePlan = authenticationUtil.runAsSystem(new RunAsWork<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef doWork()
|
||||
{
|
||||
return filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
|
||||
}
|
||||
});
|
||||
|
||||
// default false (if not provided)
|
||||
boolean hideRecord = Boolean.valueOf(parameters.getParameter(Record.PARAM_HIDE_RECORD));
|
||||
|
||||
// Create the record
|
||||
NodeRef file = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, fileId);
|
||||
recordService.createRecord(filePlan, file, !hideRecord);
|
||||
|
||||
// Return record state
|
||||
FileInfo info = fileFolderService.getFileInfo(file);
|
||||
return nodesModelFactory.createRecord(info, parameters, null, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
ParameterCheck.mandatory("records", this.records);
|
||||
ParameterCheck.mandatory("nodesModelFactory", nodesModelFactory);
|
||||
ParameterCheck.mandatory("authenticationUtil", authenticationUtil);
|
||||
ParameterCheck.mandatory("filePlanService", filePlanService);
|
||||
ParameterCheck.mandatory("fileFolderService", fileFolderService);
|
||||
ParameterCheck.mandatory("recordService", recordService);
|
||||
}
|
||||
}
|
||||
|
@@ -27,11 +27,11 @@
|
||||
|
||||
/**
|
||||
* Package info that defines the Information Governance Files REST API
|
||||
*
|
||||
*
|
||||
* @author Ana Bozianu
|
||||
* @since 2.6
|
||||
*/
|
||||
@WebApi(name="ig", scope=Api.SCOPE.PUBLIC, version=1)
|
||||
@WebApi(name="gs", scope=Api.SCOPE.PUBLIC, version=1)
|
||||
package org.alfresco.rm.rest.api.files;
|
||||
import org.alfresco.rest.framework.Api;
|
||||
import org.alfresco.rest.framework.WebApi;
|
@@ -0,0 +1,839 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.impl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.rest.api.Nodes;
|
||||
import org.alfresco.rest.api.model.ContentInfo;
|
||||
import org.alfresco.rest.api.model.Node;
|
||||
import org.alfresco.rest.api.model.UserInfo;
|
||||
import org.alfresco.rest.framework.jacksonextensions.BeanPropertiesFilter;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rm.rest.api.model.FilePlan;
|
||||
import org.alfresco.rm.rest.api.model.RMNode;
|
||||
import org.alfresco.rm.rest.api.model.Record;
|
||||
import org.alfresco.rm.rest.api.model.RecordCategory;
|
||||
import org.alfresco.rm.rest.api.model.RecordCategoryChild;
|
||||
import org.alfresco.rm.rest.api.model.RecordFolder;
|
||||
import org.alfresco.rm.rest.api.model.Transfer;
|
||||
import org.alfresco.rm.rest.api.model.TransferChild;
|
||||
import org.alfresco.rm.rest.api.model.TransferContainer;
|
||||
import org.alfresco.rm.rest.api.model.UnfiledChild;
|
||||
import org.alfresco.rm.rest.api.model.UnfiledContainer;
|
||||
import org.alfresco.rm.rest.api.model.UnfiledContainerChild;
|
||||
import org.alfresco.rm.rest.api.model.UnfiledRecordFolder;
|
||||
import org.alfresco.rm.rest.api.model.UnfiledRecordFolderChild;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.security.PersonService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Utility class containing Alfresco and RM java services required by the API
|
||||
* endpoints
|
||||
*
|
||||
* @author Ana Bozianu
|
||||
* @since 2.6
|
||||
*/
|
||||
public class ApiNodesModelFactory
|
||||
{
|
||||
|
||||
// excluded namespaces (aspects, properties, assoc types)
|
||||
public static final List<String> EXCLUDED_NS = Arrays.asList(NamespaceService.SYSTEM_MODEL_1_0_URI);
|
||||
|
||||
// excluded aspects
|
||||
public static final List<QName> EXCLUDED_ASPECTS = Arrays.asList();
|
||||
|
||||
// excluded properties
|
||||
public static final List<QName> EXCLUDED_PROPS = Arrays.asList(
|
||||
// top-level minimal info
|
||||
ContentModel.PROP_NAME, ContentModel.PROP_MODIFIER, ContentModel.PROP_MODIFIED, ContentModel.PROP_CREATOR,
|
||||
ContentModel.PROP_CREATED, ContentModel.PROP_CONTENT,
|
||||
// other - TBC
|
||||
ContentModel.PROP_INITIAL_VERSION, ContentModel.PROP_AUTO_VERSION_PROPS, ContentModel.PROP_AUTO_VERSION);
|
||||
|
||||
private NodeService nodeService;
|
||||
private NamespaceService namespaceService;
|
||||
private Nodes nodes;
|
||||
private FilePlanComponentsApiUtils apiUtils;
|
||||
private PersonService personService;
|
||||
private DispositionService dispositionService;
|
||||
private ServiceRegistry serviceRegistry;
|
||||
|
||||
public NodeService getNodeService()
|
||||
{
|
||||
return nodeService;
|
||||
}
|
||||
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
public NamespaceService getNamespaceService()
|
||||
{
|
||||
return namespaceService;
|
||||
}
|
||||
|
||||
public void setNamespaceService(NamespaceService namespaceService)
|
||||
{
|
||||
this.namespaceService = namespaceService;
|
||||
}
|
||||
|
||||
public void setNodes(Nodes nodes)
|
||||
{
|
||||
this.nodes = nodes;
|
||||
}
|
||||
|
||||
public void setApiUtils(FilePlanComponentsApiUtils apiUtils)
|
||||
{
|
||||
this.apiUtils = apiUtils;
|
||||
}
|
||||
|
||||
public void setPersonService(PersonService personService)
|
||||
{
|
||||
this.personService = personService;
|
||||
}
|
||||
|
||||
public DispositionService getDispositionService()
|
||||
{
|
||||
return dispositionService;
|
||||
}
|
||||
|
||||
public void setDispositionService(DispositionService dispositionService)
|
||||
{
|
||||
this.dispositionService = dispositionService;
|
||||
}
|
||||
|
||||
public void setServiceRegistry(ServiceRegistry serviceRegistry)
|
||||
{
|
||||
this.serviceRegistry = serviceRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method that sets the basic information for most of the node types.
|
||||
*
|
||||
* @param rmNode
|
||||
* @param info
|
||||
* @param propertyFilter
|
||||
* @param isMinimalInfo
|
||||
*/
|
||||
private void mapBasicInfo(RMNode rmNode, FileInfo info, BeanPropertiesFilter propertyFilter, Map<String, UserInfo> mapUserInfo,
|
||||
boolean isMinimalInfo)
|
||||
{
|
||||
if (propertyFilter.isAllowed(RMNode.PARAM_ID))
|
||||
{
|
||||
rmNode.setNodeRef(info.getNodeRef());
|
||||
}
|
||||
if (propertyFilter.isAllowed(RMNode.PARAM_PARENT_ID))
|
||||
{
|
||||
rmNode.setParentId(nodeService.getPrimaryParent(info.getNodeRef()).getParentRef());
|
||||
}
|
||||
if (propertyFilter.isAllowed(RMNode.PARAM_NAME))
|
||||
{
|
||||
rmNode.setName(info.getName());
|
||||
}
|
||||
if (propertyFilter.isAllowed(RMNode.PARAM_NODE_TYPE))
|
||||
{
|
||||
rmNode.setNodeType(info.getType().toPrefixString(namespaceService));
|
||||
}
|
||||
if (propertyFilter.isAllowed(RMNode.PARAM_MODIFIED_AT))
|
||||
{
|
||||
rmNode.setModifiedAt(info.getModifiedDate());
|
||||
}
|
||||
if (propertyFilter.isAllowed(RMNode.PARAM_MODIFIED_BY_USER))
|
||||
{
|
||||
if (mapUserInfo == null)
|
||||
{
|
||||
mapUserInfo = new HashMap<>(2);
|
||||
}
|
||||
UserInfo modifer = Node.lookupUserInfo((String) info.getProperties().get(ContentModel.PROP_MODIFIER), mapUserInfo,
|
||||
personService);
|
||||
rmNode.setModifiedByUser(modifer);
|
||||
}
|
||||
if (propertyFilter.isAllowed(RMNode.PARAM_CREATED_AT))
|
||||
{
|
||||
rmNode.setCreatedAt(info.getCreatedDate());
|
||||
}
|
||||
if (propertyFilter.isAllowed(RMNode.PARAM_CREATED_BY_USER))
|
||||
{
|
||||
if (mapUserInfo == null)
|
||||
{
|
||||
mapUserInfo = new HashMap<>(2);
|
||||
}
|
||||
UserInfo creator = Node.lookupUserInfo((String) info.getProperties().get(ContentModel.PROP_CREATOR), mapUserInfo,
|
||||
personService);
|
||||
rmNode.setCreatedByUser(creator);
|
||||
}
|
||||
if (!isMinimalInfo && propertyFilter.isAllowed(RMNode.PARAM_ASPECT_NAMES))
|
||||
{
|
||||
rmNode.setAspectNames(mapFromNodeAspects(nodeService.getAspects(info.getNodeRef())));
|
||||
}
|
||||
if (!isMinimalInfo && propertyFilter.isAllowed(RMNode.PARAM_PROPERTIES))
|
||||
{
|
||||
rmNode.setProperties(mapFromNodeProperties(info.getProperties()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method that sets the optional information for most of the node types.
|
||||
*
|
||||
* @param rmNode
|
||||
* @param info
|
||||
* @param includeParam
|
||||
* @param isMinimalInfo
|
||||
*/
|
||||
private void mapOptionalInfo(RMNode rmNode, FileInfo info, List<String> includeParam, boolean isMinimalInfo)
|
||||
{
|
||||
if (includeParam == null || includeParam.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (includeParam.contains(RMNode.PARAM_ALLOWABLE_OPERATIONS))
|
||||
{
|
||||
rmNode.setAllowableOperations(apiUtils.getAllowableOperations(info.getNodeRef(), info.getType()));
|
||||
}
|
||||
if (includeParam.contains(RMNode.PARAM_PATH))
|
||||
{
|
||||
rmNode.setPath(apiUtils.lookupPathInfo(info.getNodeRef()));
|
||||
}
|
||||
if (isMinimalInfo && includeParam.contains(RMNode.PARAM_ASPECT_NAMES))
|
||||
{
|
||||
rmNode.setAspectNames(mapFromNodeAspects(nodeService.getAspects(info.getNodeRef())));
|
||||
}
|
||||
if (isMinimalInfo && includeParam.contains(RMNode.PARAM_PROPERTIES))
|
||||
{
|
||||
rmNode.setProperties(mapFromNodeProperties(info.getProperties()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method that sets the information for unfiled child type.
|
||||
*
|
||||
* @param unfiledChild
|
||||
* @param info
|
||||
* @param propertyFilter
|
||||
*/
|
||||
private void mapUnfiledChildInfo(UnfiledChild unfiledChild, FileInfo info, BeanPropertiesFilter propertyFilter)
|
||||
{
|
||||
if (RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER.equals(info.getType()))
|
||||
{
|
||||
if (propertyFilter.isAllowed(UnfiledChild.PARAM_IS_UNFILED_RECORD_FOLDER))
|
||||
{
|
||||
unfiledChild.setIsUnfiledRecordFolder(true);
|
||||
}
|
||||
if (propertyFilter.isAllowed(UnfiledChild.PARAM_IS_RECORD))
|
||||
{
|
||||
unfiledChild.setIsRecord(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (propertyFilter.isAllowed(UnfiledChild.PARAM_IS_UNFILED_RECORD_FOLDER))
|
||||
{
|
||||
unfiledChild.setIsUnfiledRecordFolder(false);
|
||||
}
|
||||
if (propertyFilter.isAllowed(UnfiledChild.PARAM_IS_RECORD))
|
||||
{
|
||||
unfiledChild.setIsRecord(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method that sets the information for transfer container type.
|
||||
*
|
||||
* @param transferContainer
|
||||
* @param info
|
||||
* @param propertyFilter
|
||||
*/
|
||||
private void mapTransferContainerInfo(TransferContainer transferContainer, FileInfo info, Map<String, UserInfo> mapUserInfo, BeanPropertiesFilter propertyFilter, List<String> includeParam, boolean isMinimalInfo)
|
||||
{
|
||||
if (propertyFilter.isAllowed(RMNode.PARAM_ID))
|
||||
{
|
||||
transferContainer.setNodeRef(info.getNodeRef());
|
||||
}
|
||||
if (propertyFilter.isAllowed(RMNode.PARAM_PARENT_ID))
|
||||
{
|
||||
transferContainer.setParentId(nodeService.getPrimaryParent(info.getNodeRef()).getParentRef());
|
||||
}
|
||||
if (propertyFilter.isAllowed(RMNode.PARAM_NAME))
|
||||
{
|
||||
transferContainer.setName(info.getName());
|
||||
}
|
||||
if (propertyFilter.isAllowed(RMNode.PARAM_NODE_TYPE))
|
||||
{
|
||||
transferContainer.setNodeType(info.getType().toPrefixString(namespaceService));
|
||||
}
|
||||
if (propertyFilter.isAllowed(RMNode.PARAM_MODIFIED_AT))
|
||||
{
|
||||
transferContainer.setModifiedAt(info.getModifiedDate());
|
||||
}
|
||||
if (propertyFilter.isAllowed(RMNode.PARAM_MODIFIED_BY_USER))
|
||||
{
|
||||
if (mapUserInfo == null)
|
||||
{
|
||||
mapUserInfo = new HashMap<>(2);
|
||||
}
|
||||
UserInfo modifer = Node.lookupUserInfo((String) info.getProperties().get(ContentModel.PROP_MODIFIER), mapUserInfo,
|
||||
personService);
|
||||
transferContainer.setModifiedByUser(modifer);
|
||||
}
|
||||
if (propertyFilter.isAllowed(RMNode.PARAM_CREATED_AT))
|
||||
{
|
||||
transferContainer.setCreatedAt(info.getCreatedDate());
|
||||
}
|
||||
if (propertyFilter.isAllowed(RMNode.PARAM_CREATED_BY_USER))
|
||||
{
|
||||
if (mapUserInfo == null)
|
||||
{
|
||||
mapUserInfo = new HashMap<>(2);
|
||||
}
|
||||
UserInfo creator = Node.lookupUserInfo((String) info.getProperties().get(ContentModel.PROP_CREATOR), mapUserInfo,
|
||||
personService);
|
||||
transferContainer.setCreatedByUser(creator);
|
||||
}
|
||||
if (!isMinimalInfo && propertyFilter.isAllowed(RMNode.PARAM_ASPECT_NAMES))
|
||||
{
|
||||
transferContainer.setAspectNames(mapFromNodeAspects(nodeService.getAspects(info.getNodeRef())));
|
||||
}
|
||||
if (!isMinimalInfo && propertyFilter.isAllowed(RMNode.PARAM_PROPERTIES))
|
||||
{
|
||||
transferContainer.setProperties(mapFromNodeProperties(info.getProperties()));
|
||||
}
|
||||
|
||||
//optional parameters
|
||||
if (includeParam == null || includeParam.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (includeParam.contains(RMNode.PARAM_ALLOWABLE_OPERATIONS))
|
||||
{
|
||||
transferContainer.setAllowableOperations(apiUtils.getAllowableOperations(info.getNodeRef(), info.getType()));
|
||||
}
|
||||
if (isMinimalInfo && includeParam.contains(RMNode.PARAM_ASPECT_NAMES))
|
||||
{
|
||||
transferContainer.setAspectNames(mapFromNodeAspects(nodeService.getAspects(info.getNodeRef())));
|
||||
}
|
||||
if (isMinimalInfo && includeParam.contains(RMNode.PARAM_PROPERTIES))
|
||||
{
|
||||
transferContainer.setProperties(mapFromNodeProperties(info.getProperties()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method that sets the information for transfer type.
|
||||
*
|
||||
* @param transfer
|
||||
* @param info
|
||||
* @param propertyFilter
|
||||
*/
|
||||
private void mapTransferInfo(Transfer transfer, FileInfo info, Map<String, UserInfo> mapUserInfo, BeanPropertiesFilter propertyFilter, List<String> includeParam, boolean isMinimalInfo)
|
||||
{
|
||||
if (propertyFilter.isAllowed(RMNode.PARAM_ID))
|
||||
{
|
||||
transfer.setNodeRef(info.getNodeRef());
|
||||
}
|
||||
if (propertyFilter.isAllowed(RMNode.PARAM_PARENT_ID))
|
||||
{
|
||||
transfer.setParentId(nodeService.getPrimaryParent(info.getNodeRef()).getParentRef());
|
||||
}
|
||||
if (propertyFilter.isAllowed(RMNode.PARAM_NAME))
|
||||
{
|
||||
transfer.setName(info.getName());
|
||||
}
|
||||
if (propertyFilter.isAllowed(RMNode.PARAM_NODE_TYPE))
|
||||
{
|
||||
transfer.setNodeType(info.getType().toPrefixString(namespaceService));
|
||||
}
|
||||
if (propertyFilter.isAllowed(RMNode.PARAM_CREATED_AT))
|
||||
{
|
||||
transfer.setCreatedAt(info.getCreatedDate());
|
||||
}
|
||||
if (propertyFilter.isAllowed(RMNode.PARAM_CREATED_BY_USER))
|
||||
{
|
||||
if (mapUserInfo == null)
|
||||
{
|
||||
mapUserInfo = new HashMap<>(2);
|
||||
}
|
||||
UserInfo creator = Node.lookupUserInfo((String) info.getProperties().get(ContentModel.PROP_CREATOR), mapUserInfo,
|
||||
personService);
|
||||
transfer.setCreatedByUser(creator);
|
||||
}
|
||||
if (!isMinimalInfo && propertyFilter.isAllowed(RMNode.PARAM_ASPECT_NAMES))
|
||||
{
|
||||
transfer.setAspectNames(mapFromNodeAspects(nodeService.getAspects(info.getNodeRef())));
|
||||
}
|
||||
if (!isMinimalInfo && propertyFilter.isAllowed(RMNode.PARAM_PROPERTIES))
|
||||
{
|
||||
transfer.setProperties(mapFromNodeProperties(info.getProperties()));
|
||||
}
|
||||
|
||||
//optional parameters
|
||||
if (isMinimalInfo && includeParam == null || includeParam.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (includeParam.contains(RMNode.PARAM_ALLOWABLE_OPERATIONS))
|
||||
{
|
||||
transfer.setAllowableOperations(apiUtils.getAllowableOperations(info.getNodeRef(), info.getType()));
|
||||
}
|
||||
if (isMinimalInfo && includeParam.contains(RMNode.PARAM_ASPECT_NAMES))
|
||||
{
|
||||
transfer.setAspectNames(mapFromNodeAspects(nodeService.getAspects(info.getNodeRef())));
|
||||
}
|
||||
if (isMinimalInfo && includeParam.contains(RMNode.PARAM_PROPERTIES))
|
||||
{
|
||||
transfer.setProperties(mapFromNodeProperties(info.getProperties()));
|
||||
}
|
||||
if ((!isMinimalInfo && propertyFilter.isAllowed(Transfer.PARAM_TRANSFER_ACCESSION_INDICATOR)) || (isMinimalInfo && includeParam.contains(Transfer.PARAM_TRANSFER_ACCESSION_INDICATOR)))
|
||||
{
|
||||
transfer.setTransferAccessionIndicator((Boolean) nodeService.getProperty(info.getNodeRef(), RecordsManagementModel.PROP_TRANSFER_ACCESSION_INDICATOR));
|
||||
}
|
||||
if ((!isMinimalInfo && propertyFilter.isAllowed(Transfer.PARAM_TRANSFER_LOCATION)) || (isMinimalInfo && includeParam.contains(Transfer.PARAM_TRANSFER_LOCATION)))
|
||||
{
|
||||
transfer.setTransferLocation((String) nodeService.getProperty(info.getNodeRef(), RecordsManagementModel.PROP_TRANSFER_LOCATION));
|
||||
}
|
||||
if ((!isMinimalInfo && propertyFilter.isAllowed(Transfer.PARAM_TRANSFER_PDF_INDICATOR)) || (isMinimalInfo && includeParam.contains(Transfer.PARAM_TRANSFER_PDF_INDICATOR)))
|
||||
{
|
||||
transfer.setTransferPDFIndicator((Boolean) nodeService.getProperty(info.getNodeRef(), RecordsManagementModel.PROP_TRANSFER_PDF_INDICATOR));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method that sets the information for transfer child type.
|
||||
*
|
||||
* @param transferChild
|
||||
* @param info
|
||||
* @param propertyFilter
|
||||
*/
|
||||
private void mapTransferChildInfo(TransferChild transferChild, FileInfo info, List<String> includeParam, boolean isMinimalInfo)
|
||||
{
|
||||
if (includeParam == null || includeParam.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (RecordsManagementModel.TYPE_RECORD_FOLDER.equals(info.getType()))
|
||||
{
|
||||
if (isMinimalInfo && includeParam.contains(TransferChild.PARAM_IS_RECORD_FOLDER))
|
||||
{
|
||||
transferChild.setIsRecordFolder(true);
|
||||
}
|
||||
if (isMinimalInfo && includeParam.contains(TransferChild.PARAM_IS_RECORD))
|
||||
{
|
||||
transferChild.setIsRecord(false);
|
||||
}
|
||||
if(isMinimalInfo && includeParam.contains(RMNode.PARAM_IS_CLOSED))
|
||||
{
|
||||
transferChild.setIsClosed((Boolean) nodeService.getProperty(info.getNodeRef(), RecordsManagementModel.PROP_IS_CLOSED));
|
||||
}
|
||||
if(isMinimalInfo && includeParam.contains(TransferChild.PARAM_IS_COMPLETED))
|
||||
{
|
||||
transferChild.setIsCompleted(null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isMinimalInfo && includeParam.contains(TransferChild.PARAM_IS_RECORD_FOLDER))
|
||||
{
|
||||
transferChild.setIsRecordFolder(false);
|
||||
}
|
||||
if (isMinimalInfo && includeParam.contains(TransferChild.PARAM_IS_RECORD))
|
||||
{
|
||||
transferChild.setIsRecord(true);
|
||||
}
|
||||
if(isMinimalInfo && includeParam.contains(RMNode.PARAM_IS_CLOSED))
|
||||
{
|
||||
transferChild.setIsClosed(null);
|
||||
}
|
||||
if(isMinimalInfo && includeParam.contains(TransferChild.PARAM_IS_COMPLETED))
|
||||
{
|
||||
transferChild.setIsCompleted(nodeService.hasAspect(info.getNodeRef(), RecordsManagementModel.ASPECT_DECLARED_RECORD));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method that sets the information for record category child type.
|
||||
*
|
||||
* @param recordCategoryChild the record category child to set the fields to
|
||||
* @param info info of the record category child
|
||||
* @param includeParam the requested include parameters
|
||||
* @param propertyFilter
|
||||
*/
|
||||
private void mapRecordCategoryChildInfo(RecordCategoryChild recordCategoryChild, FileInfo info, List<String> includeParam, BeanPropertiesFilter propertyFilter, boolean isMinimalInfo)
|
||||
{
|
||||
if (isMinimalInfo && (includeParam == null || includeParam.isEmpty()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(RecordsManagementModel.TYPE_RECORD_FOLDER.equals(info.getType()))
|
||||
{
|
||||
if((!isMinimalInfo && propertyFilter.isAllowed(RecordCategoryChild.PARAM_IS_RECORD_FOLDER)) || (isMinimalInfo && includeParam.contains(RecordCategoryChild.PARAM_IS_RECORD_FOLDER)))
|
||||
{
|
||||
recordCategoryChild.setIsRecordFolder(true);
|
||||
}
|
||||
if((!isMinimalInfo && propertyFilter.isAllowed(RecordCategoryChild.PARAM_IS_RECORD_CATEGORY)) || (isMinimalInfo && includeParam.contains(RecordCategoryChild.PARAM_IS_RECORD_CATEGORY)))
|
||||
{
|
||||
recordCategoryChild.setIsRecordCategory(false);
|
||||
}
|
||||
if((!isMinimalInfo && propertyFilter.isAllowed(RMNode.PARAM_IS_CLOSED)) || (isMinimalInfo && includeParam.contains(RMNode.PARAM_IS_CLOSED)))
|
||||
{
|
||||
recordCategoryChild.setIsClosed((Boolean) nodeService.getProperty(info.getNodeRef(), RecordsManagementModel.PROP_IS_CLOSED));
|
||||
}
|
||||
if((!isMinimalInfo && propertyFilter.isAllowed(RMNode.PARAM_HAS_RETENTION_SCHEDULE)) || (isMinimalInfo && includeParam.contains(RMNode.PARAM_HAS_RETENTION_SCHEDULE)))
|
||||
{
|
||||
recordCategoryChild.setHasRetentionSchedule(null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if((!isMinimalInfo && propertyFilter.isAllowed(RecordCategoryChild.PARAM_IS_RECORD_FOLDER)) || (isMinimalInfo && includeParam.contains(RecordCategoryChild.PARAM_IS_RECORD_FOLDER)))
|
||||
{
|
||||
recordCategoryChild.setIsRecordFolder(false);
|
||||
}
|
||||
if((!isMinimalInfo && propertyFilter.isAllowed(RecordCategoryChild.PARAM_IS_RECORD_CATEGORY)) || (isMinimalInfo && includeParam.contains(RecordCategoryChild.PARAM_IS_RECORD_CATEGORY)))
|
||||
{
|
||||
recordCategoryChild.setIsRecordCategory(true);
|
||||
}
|
||||
if((!isMinimalInfo && propertyFilter.isAllowed(RMNode.PARAM_HAS_RETENTION_SCHEDULE)) || (isMinimalInfo && includeParam.contains(RMNode.PARAM_HAS_RETENTION_SCHEDULE)))
|
||||
{
|
||||
DispositionSchedule ds = dispositionService.getDispositionSchedule(info.getNodeRef());
|
||||
recordCategoryChild.setHasRetentionSchedule(ds !=null ? true : false);
|
||||
}
|
||||
if((!isMinimalInfo && propertyFilter.isAllowed(RMNode.PARAM_IS_CLOSED)) || (isMinimalInfo && includeParam.contains(RMNode.PARAM_IS_CLOSED)))
|
||||
{
|
||||
recordCategoryChild.setIsClosed(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Utility method that maps record specific fields
|
||||
*
|
||||
* @param record the record to set the fields to
|
||||
* @param info info of the record
|
||||
* @param includeParam the requested include parameters
|
||||
*/
|
||||
private void mapRecordInfo(Record record, FileInfo info, List<String> includeParam)
|
||||
{
|
||||
if (includeParam == null || includeParam.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (includeParam.contains(Record.PARAM_IS_COMPLETED))
|
||||
{
|
||||
record.setIsCompleted(nodeService.hasAspect(info.getNodeRef(), RecordsManagementModel.ASPECT_DECLARED_RECORD));
|
||||
}
|
||||
if(includeParam.contains(Record.PARAM_CONTENT))
|
||||
{
|
||||
Serializable val = info.getProperties().get(ContentModel.PROP_CONTENT);
|
||||
|
||||
if ((val != null) && (val instanceof ContentData)) {
|
||||
ContentData cd = (ContentData)val;
|
||||
String mimeType = cd.getMimetype();
|
||||
String mimeTypeName = serviceRegistry.getMimetypeService().getDisplaysByMimetype().get(mimeType);
|
||||
ContentInfo contentInfo = new ContentInfo(mimeType, mimeTypeName, cd.getSize(), cd.getEncoding());
|
||||
record.setContent(contentInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method that converts a set of QName aspects into a list of String aspects
|
||||
*
|
||||
* @param properties
|
||||
*/
|
||||
private List<String> mapFromNodeAspects(Set<QName> nodeAspects)
|
||||
{
|
||||
return nodes.mapFromNodeAspects(nodeAspects, EXCLUDED_NS, EXCLUDED_ASPECTS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method that converts a map of QName properties into a map of String properties
|
||||
*
|
||||
* @param properties
|
||||
* @return a map of String properties
|
||||
*/
|
||||
private Map<String, Object> mapFromNodeProperties(Map<QName, Serializable> properties)
|
||||
{
|
||||
return nodes.mapFromNodeProperties(properties, new ArrayList<>(), new HashMap<>(), EXCLUDED_NS, EXCLUDED_PROPS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an object of type FilePlan
|
||||
*
|
||||
* @param info info of the file plan
|
||||
* @param propertyFilter
|
||||
* @param includeParam
|
||||
* @param mapUserInfo
|
||||
* @param isMinimalInfo
|
||||
* @return FilePlan object
|
||||
*/
|
||||
public FilePlan createFilePlan(FileInfo info, Parameters parameters, Map<String, UserInfo> mapUserInfo, boolean isMinimalInfo)
|
||||
{
|
||||
FilePlan filePlan = new FilePlan();
|
||||
mapBasicInfo(filePlan, info, parameters.getFilter(), mapUserInfo, isMinimalInfo);
|
||||
mapOptionalInfo(filePlan, info, parameters.getInclude(), isMinimalInfo);
|
||||
return filePlan;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an object of type RecordCategory
|
||||
*
|
||||
* @param info info of the record category
|
||||
* @param propertyFilter
|
||||
* @param includeParam
|
||||
* @param mapUserInfo
|
||||
* @param isMinimalInfo
|
||||
* @return RecordCategory object
|
||||
*/
|
||||
public RecordCategory createRecordCategory(FileInfo info, Parameters parameters, Map<String, UserInfo> mapUserInfo,
|
||||
boolean isMinimalInfo)
|
||||
{
|
||||
RecordCategory recordCategory = new RecordCategory();
|
||||
mapBasicInfo(recordCategory, info, parameters.getFilter(), mapUserInfo, isMinimalInfo);
|
||||
mapOptionalInfo(recordCategory, info, parameters.getInclude(), isMinimalInfo);
|
||||
|
||||
if (parameters.getInclude().contains(RMNode.PARAM_HAS_RETENTION_SCHEDULE))
|
||||
{
|
||||
DispositionSchedule ds = dispositionService.getDispositionSchedule(info.getNodeRef());
|
||||
recordCategory.setHasRetentionSchedule(ds !=null ? true : false);
|
||||
}
|
||||
|
||||
return recordCategory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an object of type RecordCategory
|
||||
*
|
||||
* @param info
|
||||
* @param propertyFilter
|
||||
* @param includeParam
|
||||
* @param mapUserInfo
|
||||
* @param isMinimalInfo
|
||||
* @return RecordCategory object
|
||||
*/
|
||||
public RecordFolder createRecordFolder(FileInfo info, Parameters parameters, Map<String, UserInfo> mapUserInfo,
|
||||
boolean isMinimalInfo)
|
||||
{
|
||||
RecordFolder recordFolder = new RecordFolder();
|
||||
mapBasicInfo(recordFolder, info, parameters.getFilter(), mapUserInfo, isMinimalInfo);
|
||||
mapOptionalInfo(recordFolder, info, parameters.getInclude(), isMinimalInfo);
|
||||
|
||||
if (parameters.getInclude().contains(RMNode.PARAM_IS_CLOSED))
|
||||
{
|
||||
recordFolder.setIsClosed((Boolean) nodeService.getProperty(info.getNodeRef(), RecordsManagementModel.PROP_IS_CLOSED));
|
||||
}
|
||||
|
||||
return recordFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an object of type UnfiledContainer
|
||||
*
|
||||
* @param info
|
||||
* @param propertyFilter
|
||||
* @param includeParam
|
||||
* @param mapUserInfo
|
||||
* @param isMinimalInfo
|
||||
* @return UnfiledContainer object
|
||||
*/
|
||||
public UnfiledContainer createUnfiledContainer(FileInfo info, Parameters parameters, Map<String, UserInfo> mapUserInfo,
|
||||
boolean isMinimalInfo)
|
||||
{
|
||||
UnfiledContainer unfiledContainer = new UnfiledContainer();
|
||||
mapBasicInfo(unfiledContainer, info, parameters.getFilter(), mapUserInfo, isMinimalInfo);
|
||||
mapOptionalInfo(unfiledContainer, info, parameters.getInclude(), isMinimalInfo);
|
||||
return unfiledContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an object of type TransferContainer
|
||||
*
|
||||
* @param info
|
||||
* @param propertyFilter
|
||||
* @param includeParam
|
||||
* @param mapUserInfo
|
||||
* @param isMinimalInfo
|
||||
* @return UnfiledContainer object
|
||||
*/
|
||||
public TransferContainer createTransferContainer(FileInfo info, Parameters parameters, Map<String, UserInfo> mapUserInfo,
|
||||
boolean isMinimalInfo)
|
||||
{
|
||||
TransferContainer transferContainer = new TransferContainer();
|
||||
mapTransferContainerInfo(transferContainer, info, mapUserInfo, parameters.getFilter(), parameters.getInclude(), isMinimalInfo);
|
||||
return transferContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an object of type Transfer
|
||||
*
|
||||
* @param info
|
||||
* @param propertyFilter
|
||||
* @param includeParam
|
||||
* @param mapUserInfo
|
||||
* @param isMinimalInfo
|
||||
* @return UnfiledContainer object
|
||||
*/
|
||||
public Transfer createTransfer(FileInfo info, Parameters parameters, Map<String, UserInfo> mapUserInfo,
|
||||
boolean isMinimalInfo)
|
||||
{
|
||||
Transfer transfer = new Transfer();
|
||||
mapTransferInfo(transfer, info, mapUserInfo, parameters.getFilter(), parameters.getInclude(), isMinimalInfo);
|
||||
return transfer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an object of type TransferChild
|
||||
*
|
||||
* @param info
|
||||
* @param propertyFilter
|
||||
* @param includeParam
|
||||
* @param mapUserInfo
|
||||
* @param isMinimalInfo
|
||||
* @return UnfiledContainer object
|
||||
*/
|
||||
public TransferChild createTransferChild(FileInfo info, Parameters parameters, Map<String, UserInfo> mapUserInfo,
|
||||
boolean isMinimalInfo)
|
||||
{
|
||||
TransferChild transferChild = new TransferChild();
|
||||
mapBasicInfo(transferChild, info, parameters.getFilter(), mapUserInfo, isMinimalInfo);
|
||||
mapOptionalInfo(transferChild, info, parameters.getInclude(), isMinimalInfo);
|
||||
mapTransferChildInfo(transferChild, info, parameters.getInclude(), isMinimalInfo);
|
||||
return transferChild;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an object of type UnfiledContainerChild
|
||||
*
|
||||
* @param info
|
||||
* @param parameters
|
||||
* @param mapUserInfo
|
||||
* @param isMinimalInfo
|
||||
* @return UnfiledContainerChild object
|
||||
*/
|
||||
public UnfiledContainerChild createUnfiledContainerChild(FileInfo info, Parameters parameters, Map<String, UserInfo> mapUserInfo,
|
||||
boolean isMinimalInfo)
|
||||
{
|
||||
UnfiledContainerChild unfiledContainerChild = new UnfiledContainerChild();
|
||||
mapBasicInfo(unfiledContainerChild, info, parameters.getFilter(), mapUserInfo, isMinimalInfo);
|
||||
mapOptionalInfo(unfiledContainerChild, info, parameters.getInclude(), isMinimalInfo);
|
||||
mapUnfiledChildInfo(unfiledContainerChild, info, parameters.getFilter());
|
||||
return unfiledContainerChild;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an object of type UnfiledRecordFolder
|
||||
*
|
||||
* @param info
|
||||
* @param parameters
|
||||
* @param mapUserInfo
|
||||
* @param isMinimalInfo
|
||||
* @return UnfiledRecordFolder object
|
||||
*/
|
||||
public UnfiledRecordFolder createUnfiledRecordFolder(FileInfo info, Parameters parameters, Map<String, UserInfo> mapUserInfo,
|
||||
boolean isMinimalInfo)
|
||||
{
|
||||
UnfiledRecordFolder unfiledChild = new UnfiledRecordFolder();
|
||||
mapBasicInfo(unfiledChild, info, parameters.getFilter(), mapUserInfo, isMinimalInfo);
|
||||
mapOptionalInfo(unfiledChild, info, parameters.getInclude(), isMinimalInfo);
|
||||
return unfiledChild;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an object of type UnfiledRecordFolderChild
|
||||
*
|
||||
* @param info
|
||||
* @param parameters
|
||||
* @param mapUserInfo
|
||||
* @param isMinimalInfo
|
||||
* @return UnfiledRecordFolderChild object
|
||||
*/
|
||||
public UnfiledRecordFolderChild createUnfiledRecordFolderChild(FileInfo info, Parameters parameters, Map<String, UserInfo> mapUserInfo,
|
||||
boolean isMinimalInfo)
|
||||
{
|
||||
UnfiledRecordFolderChild unfiledRecordFolderChild = new UnfiledRecordFolderChild();
|
||||
mapBasicInfo(unfiledRecordFolderChild, info, parameters.getFilter(), mapUserInfo, isMinimalInfo);
|
||||
mapOptionalInfo(unfiledRecordFolderChild, info, parameters.getInclude(), isMinimalInfo);
|
||||
mapUnfiledChildInfo(unfiledRecordFolderChild, info, parameters.getFilter());
|
||||
return unfiledRecordFolderChild;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an object of type RecordCategoryChild
|
||||
*
|
||||
* @param info
|
||||
* @param parameters
|
||||
* @param mapUserInfo
|
||||
* @param isMinimalInfo
|
||||
* @return
|
||||
*/
|
||||
public RecordCategoryChild createRecordCategoryChild(FileInfo info, Parameters parameters, Map<String, UserInfo> mapUserInfo,
|
||||
boolean isMinimalInfo)
|
||||
{
|
||||
RecordCategoryChild recordCategoryChild = new RecordCategoryChild();
|
||||
mapBasicInfo(recordCategoryChild, info, parameters.getFilter(), mapUserInfo, isMinimalInfo);
|
||||
mapOptionalInfo(recordCategoryChild, info, parameters.getInclude(), isMinimalInfo);
|
||||
mapRecordCategoryChildInfo(recordCategoryChild, info, parameters.getInclude(), parameters.getFilter(), isMinimalInfo);
|
||||
return recordCategoryChild;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an object of type Record
|
||||
*
|
||||
* @param info
|
||||
* @param parameters
|
||||
* @param mapUserInfo
|
||||
* @param isMinimalInfo
|
||||
* @return
|
||||
*/
|
||||
public Record createRecord(FileInfo info, Parameters parameters, Map<String, UserInfo> mapUserInfo, boolean isMinimalInfo)
|
||||
{
|
||||
Record record = new Record();
|
||||
mapBasicInfo(record, info, parameters.getFilter(), mapUserInfo, isMinimalInfo);
|
||||
mapOptionalInfo(record, info, parameters.getInclude(), isMinimalInfo);
|
||||
mapRecordInfo(record, info, parameters.getInclude());
|
||||
return record;
|
||||
}
|
||||
}
|
@@ -0,0 +1,961 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.impl;
|
||||
|
||||
import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.checkNotBlank;
|
||||
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Serializable;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil;
|
||||
import org.alfresco.repo.content.ContentLimitViolationException;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.model.filefolder.FileFolderServiceImpl.InvalidTypeException;
|
||||
import org.alfresco.repo.node.getchildren.FilterProp;
|
||||
import org.alfresco.repo.node.getchildren.FilterPropBoolean;
|
||||
import org.alfresco.repo.node.getchildren.GetChildrenCannedQuery;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.repo.tenant.TenantUtil;
|
||||
import org.alfresco.rest.antlr.WhereClauseParser;
|
||||
import org.alfresco.rest.api.Activities;
|
||||
import org.alfresco.rest.api.Nodes;
|
||||
import org.alfresco.rest.api.model.PathInfo;
|
||||
import org.alfresco.rest.api.model.PathInfo.ElementInfo;
|
||||
import org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException;
|
||||
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
||||
import org.alfresco.rest.framework.core.exceptions.InsufficientStorageException;
|
||||
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
|
||||
import org.alfresco.rest.framework.core.exceptions.NotFoundException;
|
||||
import org.alfresco.rest.framework.core.exceptions.RequestEntityTooLargeException;
|
||||
import org.alfresco.rest.framework.resource.content.BinaryResource;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rest.framework.resource.parameters.where.Query;
|
||||
import org.alfresco.rest.framework.resource.parameters.where.QueryHelper;
|
||||
import org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker;
|
||||
import org.alfresco.rm.rest.api.RMSites;
|
||||
import org.alfresco.rm.rest.api.model.RMNode;
|
||||
import org.alfresco.rm.rest.api.model.RMSite;
|
||||
import org.alfresco.rm.rest.api.model.TransferContainer;
|
||||
import org.alfresco.service.cmr.activities.ActivityInfo;
|
||||
import org.alfresco.service.cmr.activities.ActivityPoster;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.lock.NodeLockedException;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ContentIOException;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.DuplicateChildNodeNameException;
|
||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.Path;
|
||||
import org.alfresco.service.cmr.repository.Path.Element;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.cmr.usage.ContentQuotaException;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.social.InternalServerErrorException;
|
||||
|
||||
import net.sf.acegisecurity.vote.AccessDecisionVoter;
|
||||
|
||||
/**
|
||||
* Utility class that handles common api endpoint tasks
|
||||
*
|
||||
* @author Ana Bozianu
|
||||
* @since 2.6
|
||||
*/
|
||||
public class FilePlanComponentsApiUtils
|
||||
{
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(SearchTypesFactory.class);
|
||||
|
||||
public static final String FILE_PLAN_ALIAS = "-filePlan-";
|
||||
public static final String TRANSFERS_ALIAS = "-transfers-";
|
||||
public static final String UNFILED_ALIAS = "-unfiled-";
|
||||
public static final String HOLDS_ALIAS = "-holds-";
|
||||
public static final String RM_SITE_ID = "rm";
|
||||
//public static String PARAM_RELATIVE_PATH = "relativePath";
|
||||
|
||||
// excluded properties
|
||||
public static final List<QName> TYPES_CAN_CREATE = Arrays.asList(
|
||||
RecordsManagementModel.TYPE_FILE_PLAN,
|
||||
RecordsManagementModel.TYPE_RECORD_CATEGORY,
|
||||
RecordsManagementModel.TYPE_RECORD_FOLDER,
|
||||
RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER,
|
||||
RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER,
|
||||
RecordsManagementModel.TYPE_HOLD_CONTAINER);
|
||||
|
||||
/** RM Nodes API */
|
||||
private Nodes nodes;
|
||||
private FileFolderService fileFolderService;
|
||||
private FilePlanService filePlanService;
|
||||
private NodeService nodeService;
|
||||
private ContentService contentService;
|
||||
private MimetypeService mimetypeService;
|
||||
private DictionaryService dictionaryService;
|
||||
private CapabilityService capabilityService;
|
||||
private PermissionService permissionService;
|
||||
private RecordService recordService;
|
||||
private AuthenticationUtil authenticationUtil;
|
||||
private ActivityPoster activityPoster;
|
||||
private RMSites sites;
|
||||
|
||||
public void setNodes(Nodes nodes)
|
||||
{
|
||||
this.nodes = nodes;
|
||||
}
|
||||
|
||||
public void setFileFolderService(FileFolderService fileFolderService)
|
||||
{
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
public void setFilePlanService(FilePlanService filePlanService)
|
||||
{
|
||||
this.filePlanService = filePlanService;
|
||||
}
|
||||
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
public void setContentService(ContentService contentService)
|
||||
{
|
||||
this.contentService = contentService;
|
||||
}
|
||||
|
||||
public void setMimetypeService(MimetypeService mimetypeService)
|
||||
{
|
||||
this.mimetypeService = mimetypeService;
|
||||
}
|
||||
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
public void setCapabilityService(CapabilityService capabilityService)
|
||||
{
|
||||
this.capabilityService = capabilityService;
|
||||
}
|
||||
|
||||
public void setPermissionService(PermissionService permissionService)
|
||||
{
|
||||
this.permissionService = permissionService;
|
||||
}
|
||||
|
||||
public void setRecordService(RecordService recordService)
|
||||
{
|
||||
this.recordService = recordService;
|
||||
}
|
||||
|
||||
public void setAuthenticationUtil(AuthenticationUtil authenticationUtil)
|
||||
{
|
||||
this.authenticationUtil = authenticationUtil;
|
||||
}
|
||||
|
||||
public void setActivityPoster(ActivityPoster poster)
|
||||
{
|
||||
this.activityPoster = poster;
|
||||
}
|
||||
|
||||
public void setSites(RMSites sites)
|
||||
{
|
||||
this.sites = sites;
|
||||
}
|
||||
|
||||
/**
|
||||
* lookup node and validate type
|
||||
*
|
||||
* @param nodeId
|
||||
* @param expectedNodeType
|
||||
* @return
|
||||
* @throws EntityNotFoundException
|
||||
*/
|
||||
public NodeRef lookupAndValidateNodeType(String nodeId, QName expectedNodeType) throws EntityNotFoundException
|
||||
{
|
||||
return lookupAndValidateNodeType(nodeId, expectedNodeType, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* lookup node by id and relative path and validate type
|
||||
*
|
||||
* @param nodeId
|
||||
* @param expectedNodeType
|
||||
* @param relativePath
|
||||
* @return
|
||||
* @throws EntityNotFoundException
|
||||
*/
|
||||
public NodeRef lookupAndValidateNodeType(String nodeId, QName expectedNodeType, String relativePath) throws EntityNotFoundException
|
||||
{
|
||||
return lookupAndValidateNodeType(nodeId, expectedNodeType, relativePath, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* lookup node by id and relative path and validate type
|
||||
*
|
||||
* @param nodeId
|
||||
* @param expectedNodeType
|
||||
* @param relativePath
|
||||
* @return
|
||||
* @throws EntityNotFoundException
|
||||
*/
|
||||
public NodeRef lookupAndValidateNodeType(String nodeId, QName expectedNodeType, String relativePath, boolean readOnlyRelativePath) throws EntityNotFoundException
|
||||
{
|
||||
ParameterCheck.mandatoryString("nodeId", nodeId);
|
||||
ParameterCheck.mandatory("expectedNodeType", expectedNodeType);
|
||||
|
||||
/*
|
||||
* Lookup by placeholder
|
||||
*/
|
||||
NodeRef nodeRef;
|
||||
if (nodeId.equals(FILE_PLAN_ALIAS))
|
||||
{
|
||||
NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
|
||||
if (filePlan != null)
|
||||
{
|
||||
nodeRef = filePlan;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new EntityNotFoundException(nodeId);
|
||||
}
|
||||
}
|
||||
else if (nodeId.equals(TRANSFERS_ALIAS))
|
||||
{
|
||||
NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
|
||||
if (filePlan != null)
|
||||
{
|
||||
nodeRef = filePlanService.getTransferContainer(filePlan);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new EntityNotFoundException(nodeId);
|
||||
}
|
||||
}
|
||||
else if (nodeId.equals(UNFILED_ALIAS))
|
||||
{
|
||||
NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
|
||||
if (filePlan != null)
|
||||
{
|
||||
nodeRef = filePlanService.getUnfiledContainer(filePlan);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new EntityNotFoundException(nodeId);
|
||||
}
|
||||
}
|
||||
else if (nodeId.equals(HOLDS_ALIAS))
|
||||
{
|
||||
NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
|
||||
if (filePlan != null)
|
||||
{
|
||||
nodeRef = filePlanService.getHoldContainer(filePlan);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new EntityNotFoundException(nodeId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, nodeId);
|
||||
}
|
||||
|
||||
QName nodeType = nodeService.getType(nodeRef);
|
||||
if (!nodeType.equals(expectedNodeType))
|
||||
{
|
||||
throw new InvalidArgumentException("The given id:'" + nodeId + "' (nodeType:" + nodeType.toString()
|
||||
+ ") is not valid for this endpoint. Expected nodeType is:" + expectedNodeType.toString());
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(relativePath))
|
||||
{
|
||||
nodeRef = lookupAndValidateRelativePath(nodeRef, relativePath, readOnlyRelativePath, expectedNodeType);
|
||||
}
|
||||
return nodeRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* @param parameters
|
||||
* @return
|
||||
*/
|
||||
public List<Pair<QName, Boolean>> getSortProperties(Parameters parameters)
|
||||
{
|
||||
List<Pair<QName, Boolean>> sortProps = new ArrayList<>();
|
||||
sortProps.add(new Pair<>(GetChildrenCannedQuery.SORT_QNAME_NODE_TYPE, true));
|
||||
sortProps.add(new Pair<>(ContentModel.PROP_NAME, true));
|
||||
return sortProps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write content to file
|
||||
*
|
||||
* @param nodeRef the node to write the content to
|
||||
* @param fileName the name of the file (used for guessing the file's mimetype)
|
||||
* @param stream the input stream to write
|
||||
* @param guessEncoding whether to guess stream encoding
|
||||
*/
|
||||
public void writeContent(NodeRef nodeRef, String fileName, InputStream stream, boolean guessEncoding)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true);
|
||||
|
||||
String mimeType = mimetypeService.guessMimetype(fileName);
|
||||
if ((mimeType != null) && (!mimeType.equals(MimetypeMap.MIMETYPE_BINARY)))
|
||||
{
|
||||
// quick/weak guess based on file extension
|
||||
writer.setMimetype(mimeType);
|
||||
} else
|
||||
{
|
||||
// stronger guess based on file stream
|
||||
writer.guessMimetype(fileName);
|
||||
}
|
||||
|
||||
InputStream is = null;
|
||||
|
||||
if (guessEncoding)
|
||||
{
|
||||
is = new BufferedInputStream(stream);
|
||||
is.mark(1024);
|
||||
writer.setEncoding(guessEncoding(is, mimeType, false));
|
||||
try
|
||||
{
|
||||
is.reset();
|
||||
} catch (IOException ioe)
|
||||
{
|
||||
if (LOGGER.isWarnEnabled())
|
||||
{
|
||||
LOGGER.warn("Failed to reset stream after trying to guess encoding: " + ioe.getMessage());
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
is = stream;
|
||||
}
|
||||
|
||||
writer.putContent(is);
|
||||
}
|
||||
catch (ContentQuotaException cqe)
|
||||
{
|
||||
throw new InsufficientStorageException();
|
||||
}
|
||||
catch (ContentLimitViolationException clv)
|
||||
{
|
||||
throw new RequestEntityTooLargeException(clv.getMessage());
|
||||
}
|
||||
catch (ContentIOException cioe)
|
||||
{
|
||||
if (cioe.getCause() instanceof NodeLockedException)
|
||||
{
|
||||
throw (NodeLockedException)cioe.getCause();
|
||||
}
|
||||
throw cioe;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method that guesses the encoding of a stream of data
|
||||
* @param in the stream to guess the encoding for
|
||||
* @param mimeType the mimetype of the file
|
||||
* @param close if true the stream will be closed at the end
|
||||
* @return the stream encoding
|
||||
*/
|
||||
private String guessEncoding(InputStream in, String mimeType, boolean close)
|
||||
{
|
||||
String encoding = "UTF-8";
|
||||
try
|
||||
{
|
||||
if (in != null)
|
||||
{
|
||||
Charset charset = mimetypeService.getContentCharsetFinder().getCharset(in, mimeType);
|
||||
encoding = charset.name();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
if (close && (in != null))
|
||||
{
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
if (LOGGER.isWarnEnabled())
|
||||
{
|
||||
LOGGER.warn("Failed to close stream after trying to guess encoding: " + ioe.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
return encoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method that creates a relative path if it doesn't already exist
|
||||
* The relative path will be build with nodes of the type specified in nodesType
|
||||
* If the relative path already exists the method validates if the last element is of type nodesType
|
||||
* The method does not validate the type of parentNodeRef
|
||||
*
|
||||
* @param parentNodeRef the first node of the path
|
||||
* @param relativePath a string representing the relative path in the format "Folder1/Folder2/Folder3"
|
||||
* @param nodesType the type of all the containers in the path
|
||||
* @return the last element of the relative path
|
||||
*/
|
||||
public NodeRef lookupAndValidateRelativePath(final NodeRef parentNodeRef, String relativePath, QName nodesType)
|
||||
{
|
||||
return lookupAndValidateRelativePath(parentNodeRef, relativePath, false, nodesType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method that creates a relative path if it doesn't already exist and if relative path is not read only.
|
||||
* If relative path is read only an exception will be thrown if the provided relative path does not exist.
|
||||
* The relative path will be build with nodes of the type specified in nodesType
|
||||
* If the relative path already exists the method validates if the last element is of type nodesType
|
||||
* The method does not validate the type of parentNodeRef
|
||||
*
|
||||
* @param parentNodeRef the first node of the path
|
||||
* @param relativePath a string representing the relative path in the format "Folder1/Folder2/Folder3"
|
||||
* @param readOnlyRelativePath the flag that indicates if the relativePath should be created if doesn't exist or not
|
||||
* @param nodesType the type of all the containers in the path
|
||||
* @return the last element of the relative path
|
||||
*/
|
||||
public NodeRef lookupAndValidateRelativePath(final NodeRef parentNodeRef, String relativePath, boolean readOnlyRelativePath, QName nodesType)
|
||||
{
|
||||
mandatory("parentNodeRef", parentNodeRef);
|
||||
mandatory("nodesType", nodesType);
|
||||
if (StringUtils.isBlank(relativePath))
|
||||
{
|
||||
return parentNodeRef;
|
||||
}
|
||||
List<String> pathElements = getPathElements(relativePath);
|
||||
if (pathElements.isEmpty())
|
||||
{
|
||||
return parentNodeRef;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the latest existing path element
|
||||
*/
|
||||
NodeRef lastNodeRef = parentNodeRef;
|
||||
int i = 0;
|
||||
for (; i < pathElements.size(); i++)
|
||||
{
|
||||
final String pathElement = pathElements.get(i);
|
||||
final NodeRef contextParentNodeRef = lastNodeRef;
|
||||
// Navigation should not check permissions
|
||||
NodeRef child = authenticationUtil.runAsSystem(new RunAsWork<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef doWork() throws Exception
|
||||
{
|
||||
return nodeService.getChildByName(contextParentNodeRef, ContentModel.ASSOC_CONTAINS, pathElement);
|
||||
}
|
||||
});
|
||||
|
||||
if(child == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
lastNodeRef = child;
|
||||
}
|
||||
if(i == pathElements.size())
|
||||
{
|
||||
QName nodeType = nodeService.getType(lastNodeRef);
|
||||
if(!nodeType.equals(nodesType))
|
||||
{
|
||||
throw new InvalidArgumentException("The given id:'"+ parentNodeRef.getId() +"' and the relative path '"+ relativePath + "' reach a node type invalid for this endpoint."
|
||||
+ " Expected nodeType is:" + nodesType.toString() + ". Actual nodeType is:" + nodeType);
|
||||
}
|
||||
return lastNodeRef;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!readOnlyRelativePath)
|
||||
{
|
||||
pathElements = pathElements.subList(i, pathElements.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotFoundException("The entity with relativePath: " + relativePath + " was not found.");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Starting from the latest existing element create the rest of the elements
|
||||
*/
|
||||
if(nodesType.equals(RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER))
|
||||
{
|
||||
for (String pathElement : pathElements)
|
||||
{
|
||||
lastNodeRef = fileFolderService.create(lastNodeRef, pathElement, RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER).getNodeRef();
|
||||
}
|
||||
}
|
||||
else if(nodesType.equals(RecordsManagementModel.TYPE_RECORD_CATEGORY))
|
||||
{
|
||||
for (String pathElement : pathElements)
|
||||
{
|
||||
lastNodeRef = filePlanService.createRecordCategory(lastNodeRef, pathElement);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Throw internal error as this method should not be called for other types
|
||||
throw new InternalServerErrorException("Creating relative path of type '" + nodesType + "' not suported for this endpoint");
|
||||
}
|
||||
|
||||
return lastNodeRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method that parses a string representing a file path and returns a list of element names
|
||||
* @param path the file path represented as a string
|
||||
* @return a list of file path element names
|
||||
*/
|
||||
private List<String> getPathElements(String path)
|
||||
{
|
||||
final List<String> pathElements = new ArrayList<>();
|
||||
if (path != null && path.trim().length() > 0)
|
||||
{
|
||||
// There is no need to check for leading and trailing "/"
|
||||
final StringTokenizer tokenizer = new StringTokenizer(path, "/");
|
||||
while (tokenizer.hasMoreTokens())
|
||||
{
|
||||
pathElements.add(tokenizer.nextToken().trim());
|
||||
}
|
||||
}
|
||||
return pathElements;
|
||||
}
|
||||
/**
|
||||
* Helper method that converts a map of String properties into a map of QName properties
|
||||
* @param props
|
||||
* @return a map of properties
|
||||
*/
|
||||
public Map<QName, Serializable> mapToNodeProperties(Map<String, Object> properties)
|
||||
{
|
||||
Map<QName, Serializable> response = null;
|
||||
if(properties != null)
|
||||
{
|
||||
response = nodes.mapToNodeProperties(properties);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an RM node
|
||||
*
|
||||
* @param parentNodeRef the parent of the node
|
||||
* @param name the name of the new node
|
||||
* @param type the type of the node
|
||||
* @param properties properties to set on the new node
|
||||
* @param aspects aspects to set on the new node
|
||||
* @return the new node
|
||||
*/
|
||||
public NodeRef createRMNode(NodeRef parentNodeRef, String name, String type, Map<String, Object> properties, List<String> aspects)
|
||||
{
|
||||
mandatory("parentNodeRef", parentNodeRef);
|
||||
checkNotBlank(RMNode.PARAM_NAME, name);
|
||||
checkNotBlank(RMNode.PARAM_NODE_TYPE, type);
|
||||
|
||||
// Create the node
|
||||
NodeRef newNodeRef = null;
|
||||
try
|
||||
{
|
||||
QName typeQName = nodes.createQName(type);
|
||||
newNodeRef = fileFolderService.create(parentNodeRef, name, typeQName).getNodeRef();
|
||||
|
||||
// Set the provided properties if any
|
||||
Map<QName, Serializable> qnameProperties = mapToNodeProperties(properties);
|
||||
if (qnameProperties != null)
|
||||
{
|
||||
nodeService.addProperties(newNodeRef, qnameProperties);
|
||||
}
|
||||
|
||||
// If electronic record create empty content
|
||||
if (!typeQName.equals(RecordsManagementModel.TYPE_NON_ELECTRONIC_DOCUMENT)
|
||||
&& dictionaryService.isSubClass(typeQName, ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
writeContent(newNodeRef, name, new ByteArrayInputStream("".getBytes()), false);
|
||||
}
|
||||
|
||||
// Add the provided aspects if any
|
||||
if (aspects != null)
|
||||
{
|
||||
nodes.addCustomAspects(newNodeRef, aspects, ApiNodesModelFactory.EXCLUDED_ASPECTS);
|
||||
}
|
||||
}
|
||||
catch (InvalidTypeException ex)
|
||||
{
|
||||
throw new InvalidArgumentException("The given type:'" + type + "' is invalid '");
|
||||
}
|
||||
|
||||
return newNodeRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload a record
|
||||
*
|
||||
* @param parentNodeRef the parent of the record
|
||||
* @param name the name of the record
|
||||
* @param type the type of the record (if null the record's type will be cm:content)
|
||||
* @param properties properties to set (can be null)
|
||||
* @param stream the stream to write
|
||||
* @return the new record
|
||||
*/
|
||||
public NodeRef uploadRecord(NodeRef parentNodeRef, String name, String type, Map<String, Object> properties, InputStream stream)
|
||||
{
|
||||
checkNotBlank(RMNode.PARAM_NAME, name);
|
||||
mandatory("stream", stream);
|
||||
|
||||
// Create the node
|
||||
QName typeQName = StringUtils.isBlank(type) ? ContentModel.TYPE_CONTENT : nodes.createQName(type);
|
||||
if(!dictionaryService.isSubClass(typeQName, ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
throw new InvalidArgumentException("Can only upload type of cm:content: " + typeQName);
|
||||
}
|
||||
NodeRef newNodeRef = fileFolderService.create(parentNodeRef, name, typeQName).getNodeRef();
|
||||
|
||||
// Write content
|
||||
writeContent(newNodeRef, name, stream, true);
|
||||
|
||||
// Set the provided properties if any
|
||||
Map<QName, Serializable> qnameProperties = mapToNodeProperties(properties);
|
||||
if(qnameProperties != null)
|
||||
{
|
||||
nodeService.addProperties(newNodeRef, qnameProperties);
|
||||
}
|
||||
|
||||
return newNodeRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a List of filter properties specified by request parameters.
|
||||
* @param parameters The {@link Parameters} object to get the parameters passed into the request
|
||||
* including:
|
||||
* - filter, sort & paging params (where, orderBy, skipCount, maxItems)
|
||||
* @return The list of {@link FilterProp}. Can be null.
|
||||
*/
|
||||
public List<FilterProp> getListChildrenFilterProps(Parameters parameters, Set<String> listFolderChildrenEqualsQueryProperties)
|
||||
{
|
||||
|
||||
List<FilterProp> filterProps = null;
|
||||
Query q = parameters.getQuery();
|
||||
if (q != null)
|
||||
{
|
||||
MapBasedQueryWalker propertyWalker = new MapBasedQueryWalker(listFolderChildrenEqualsQueryProperties, null);
|
||||
QueryHelper.walk(q, propertyWalker);
|
||||
|
||||
Boolean isPrimary = propertyWalker.getProperty(RMNode.PARAM_ISPRIMARY, WhereClauseParser.EQUALS, Boolean.class);
|
||||
|
||||
if (isPrimary != null)
|
||||
{
|
||||
filterProps = new ArrayList<>(1);
|
||||
filterProps.add(new FilterPropBoolean(GetChildrenCannedQuery.FILTER_QNAME_NODE_IS_PRIMARY, isPrimary));
|
||||
}
|
||||
Boolean isClosed = propertyWalker.getProperty(RMNode.PARAM_IS_CLOSED, WhereClauseParser.EQUALS, Boolean.class);
|
||||
if (isClosed != null)
|
||||
{
|
||||
filterProps = new ArrayList<>(1);
|
||||
filterProps.add(new FilterPropBoolean(RecordsManagementModel.PROP_IS_CLOSED, isClosed));
|
||||
}
|
||||
//TODO see how we can filter for categories that have retention schedule
|
||||
// Boolean hasRetentionSchedule = propertyWalker.getProperty(RMNode.PARAM_HAS_RETENTION_SCHEDULE, WhereClauseParser.EQUALS, Boolean.class);
|
||||
// if (hasRetentionSchedule != null)
|
||||
// {
|
||||
// filterProps = new ArrayList<>(1);
|
||||
// }
|
||||
}
|
||||
return filterProps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method that updates a node's name and properties
|
||||
* @param nodeRef the node to update
|
||||
* @param updateInfo information to update the record with
|
||||
* @param parameters request parameters
|
||||
*/
|
||||
public void updateNode(NodeRef nodeRef, RMNode updateInfo, Parameters parameters)
|
||||
{
|
||||
Map<QName, Serializable> props = new HashMap<>(0);
|
||||
|
||||
if (updateInfo.getProperties() != null)
|
||||
{
|
||||
props = mapToNodeProperties(updateInfo.getProperties());
|
||||
}
|
||||
|
||||
String name = updateInfo.getName();
|
||||
if ((name != null) && (!name.isEmpty()))
|
||||
{
|
||||
// update node name if needed
|
||||
props.put(ContentModel.PROP_NAME, name);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// update node properties - note: null will unset the specified property
|
||||
nodeService.addProperties(nodeRef, props);
|
||||
}
|
||||
catch (DuplicateChildNodeNameException dcne)
|
||||
{
|
||||
throw new ConstraintViolatedException(dcne.getMessage());
|
||||
}
|
||||
|
||||
// update aspects
|
||||
List<String> aspectNames = updateInfo.getAspectNames();
|
||||
nodes.updateCustomAspects(nodeRef, aspectNames, ApiNodesModelFactory.EXCLUDED_ASPECTS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a record
|
||||
*
|
||||
* @param recordId the id of the record to validate
|
||||
* @return
|
||||
*/
|
||||
public NodeRef validateRecord(String recordId) throws InvalidArgumentException
|
||||
{
|
||||
NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, recordId);
|
||||
if(!recordService.isRecord(nodeRef))
|
||||
{
|
||||
throw new IllegalArgumentException("The given id:'"+ recordId +"' is not valid for this endpoint. This endpoint only supports records.");
|
||||
}
|
||||
return nodeRef;
|
||||
}
|
||||
|
||||
public BinaryResource getContent(NodeRef nodeRef, Parameters parameters, boolean recordActivity)
|
||||
{
|
||||
return nodes.getContent(nodeRef, parameters, recordActivity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method that updates a transfer container's name and properties
|
||||
*
|
||||
* @param nodeRef the node to update
|
||||
* @param transferContainerInfo information to update the transfer container with
|
||||
* @param parameters request parameters
|
||||
*/
|
||||
public void updateTransferContainer(NodeRef nodeRef, TransferContainer transferContainerInfo, Parameters parameters)
|
||||
{
|
||||
Map<QName, Serializable> props = new HashMap<>(0);
|
||||
|
||||
if (transferContainerInfo.getProperties() != null)
|
||||
{
|
||||
props = mapToNodeProperties(transferContainerInfo.getProperties());
|
||||
}
|
||||
|
||||
String name = transferContainerInfo.getName();
|
||||
if ((name != null) && (!name.isEmpty()))
|
||||
{
|
||||
// update node name if needed
|
||||
props.put(ContentModel.PROP_NAME, name);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// update node properties - note: null will unset the specified property
|
||||
nodeService.addProperties(nodeRef, props);
|
||||
}
|
||||
catch (DuplicateChildNodeNameException dcne)
|
||||
{
|
||||
throw new ConstraintViolatedException(dcne.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method that generates allowable operation for the provided node
|
||||
* @param nodeRef the node to get the allowable operations for
|
||||
* @param type the type of the provided nodeRef
|
||||
* @return a sublist of [{@link Nodes.OP_DELETE}, {@link Nodes.OP_CREATE}, {@link Nodes.OP_UPDATE}] representing the allowable operations for the provided node
|
||||
*/
|
||||
protected List<String> getAllowableOperations(NodeRef nodeRef, QName typeQName)
|
||||
{
|
||||
List<String> allowableOperations = new ArrayList<>();
|
||||
|
||||
boolean isFilePlan = typeQName.equals(RecordsManagementModel.TYPE_FILE_PLAN);
|
||||
boolean isTransferContainer = typeQName.equals(RecordsManagementModel.TYPE_TRANSFER_CONTAINER);
|
||||
boolean isUnfiledContainer = typeQName.equals(RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER);
|
||||
boolean isHoldsContainer = typeQName.equals(RecordsManagementModel.TYPE_HOLD_CONTAINER);
|
||||
boolean isSpecialContainer = isFilePlan || isTransferContainer || isUnfiledContainer || isHoldsContainer;
|
||||
|
||||
// DELETE
|
||||
if(!isSpecialContainer &&
|
||||
capabilityService.getCapability("Delete").evaluate(nodeRef) == AccessDecisionVoter.ACCESS_GRANTED)
|
||||
{
|
||||
allowableOperations.add(Nodes.OP_DELETE);
|
||||
}
|
||||
|
||||
// CREATE
|
||||
if(TYPES_CAN_CREATE.contains(typeQName) &&
|
||||
capabilityService.getCapability("FillingPermissionOnly").evaluate(nodeRef) == AccessDecisionVoter.ACCESS_GRANTED)
|
||||
{
|
||||
allowableOperations.add(Nodes.OP_CREATE);
|
||||
}
|
||||
|
||||
// UPDATE
|
||||
if (capabilityService.getCapability("Update").evaluate(nodeRef) == AccessDecisionVoter.ACCESS_GRANTED)
|
||||
{
|
||||
allowableOperations.add(Nodes.OP_UPDATE);
|
||||
}
|
||||
|
||||
return allowableOperations;
|
||||
}
|
||||
|
||||
protected PathInfo lookupPathInfo(NodeRef nodeRefIn)
|
||||
{
|
||||
List<ElementInfo> pathElements = new ArrayList<>();
|
||||
Boolean isComplete = Boolean.TRUE;
|
||||
final Path nodePath = nodeService.getPath(nodeRefIn);;
|
||||
final int pathIndex = 2;
|
||||
|
||||
for (int i = nodePath.size() - pathIndex; i >= 0; i--)
|
||||
{
|
||||
Element element = nodePath.get(i);
|
||||
if (element instanceof Path.ChildAssocElement)
|
||||
{
|
||||
ChildAssociationRef elementRef = ((Path.ChildAssocElement) element).getRef();
|
||||
if (elementRef.getParentRef() != null)
|
||||
{
|
||||
NodeRef childNodeRef = elementRef.getChildRef();
|
||||
if (permissionService.hasPermission(childNodeRef, PermissionService.READ) == AccessStatus.ALLOWED)
|
||||
{
|
||||
Serializable nameProp = nodeService.getProperty(childNodeRef, ContentModel.PROP_NAME);
|
||||
pathElements.add(0, new ElementInfo(childNodeRef.getId(), nameProp.toString()));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Just return the pathInfo up to the location where the user has access
|
||||
isComplete = Boolean.FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String pathStr = null;
|
||||
if (pathElements.size() > 0)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(120);
|
||||
for (PathInfo.ElementInfo e : pathElements)
|
||||
{
|
||||
sb.append("/").append(e.getName());
|
||||
}
|
||||
pathStr = sb.toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
// There is no path element, so set it to null in order to be
|
||||
// ignored by Jackson during serialisation
|
||||
isComplete = null;
|
||||
}
|
||||
return new PathInfo(pathStr, isComplete, pathElements);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to obtain file plan type or null if the rm site does not exist.
|
||||
*
|
||||
* @return file plan type or null
|
||||
*/
|
||||
public QName getFilePlanType()
|
||||
{
|
||||
NodeRef filePlanNodeRef = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
|
||||
if(filePlanNodeRef != null)
|
||||
{
|
||||
return nodeService.getType(filePlanNodeRef);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Posts activities for given fileInfo
|
||||
*
|
||||
* @param fileInfo
|
||||
* @param parentNodeRef
|
||||
* @param activityType
|
||||
*/
|
||||
public void postActivity(FileInfo fileInfo, NodeRef parentNodeRef, String activityType)
|
||||
{
|
||||
ActivityInfo activityInfo = null;
|
||||
RMSite rmSite = sites.getRMSite(RM_SITE_ID);
|
||||
if (rmSite != null && !rmSite.getId().equals(""))
|
||||
{
|
||||
if (fileInfo != null)
|
||||
{
|
||||
boolean isContent = dictionaryService.isSubClass(fileInfo.getType(), ContentModel.TYPE_CONTENT);
|
||||
|
||||
if (isContent)
|
||||
{
|
||||
activityInfo = new ActivityInfo(null, parentNodeRef, RM_SITE_ID, fileInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LOGGER.isDebugEnabled())
|
||||
{
|
||||
LOGGER.debug("Non-site activity, so ignored " + fileInfo.getNodeRef());
|
||||
}
|
||||
}
|
||||
|
||||
if (activityInfo == null)
|
||||
return; // Nothing to do.
|
||||
|
||||
if (activityType != null)
|
||||
{
|
||||
activityPoster.postFileFolderActivity(activityType, null, TenantUtil.getCurrentDomain(), activityInfo.getSiteId(),
|
||||
activityInfo.getParentNodeRef(), activityInfo.getNodeRef(), activityInfo.getFileName(), Activities.APP_TOOL,
|
||||
Activities.RESTAPI_CLIENT, activityInfo.getFileInfo());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,497 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.impl;
|
||||
|
||||
import java.security.InvalidParameterException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.rest.api.Nodes;
|
||||
import org.alfresco.rest.api.impl.NodesImpl;
|
||||
import org.alfresco.rest.api.model.Node;
|
||||
import org.alfresco.rest.api.model.UserInfo;
|
||||
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
||||
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rm.rest.api.RMNodes;
|
||||
import org.alfresco.rm.rest.api.model.FileplanComponentNode;
|
||||
import org.alfresco.rm.rest.api.model.RecordCategoryNode;
|
||||
import org.alfresco.rm.rest.api.model.RecordFolderNode;
|
||||
import org.alfresco.rm.rest.api.model.RecordNode;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.extensions.webscripts.servlet.FormData;
|
||||
|
||||
import net.sf.acegisecurity.vote.AccessDecisionVoter;
|
||||
|
||||
/**
|
||||
* Centralizes access to the repository.
|
||||
*
|
||||
* @author Ana Bozianu
|
||||
* @since 2.6
|
||||
*/
|
||||
public class RMNodesImpl extends NodesImpl implements RMNodes
|
||||
{
|
||||
private enum RMNodeType
|
||||
{
|
||||
// Note: ordered
|
||||
CATEGORY, RECORD_FOLDER, FILE
|
||||
}
|
||||
|
||||
private FilePlanService filePlanService;
|
||||
private NodeService nodeService;
|
||||
private RecordsManagementServiceRegistry serviceRegistry;
|
||||
private DictionaryService dictionaryService;
|
||||
private DispositionService dispositionService;
|
||||
private CapabilityService capabilityService;
|
||||
private FileFolderService fileFolderService;
|
||||
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
this.nodeService = serviceRegistry.getNodeService();
|
||||
this.dictionaryService = serviceRegistry.getDictionaryService();
|
||||
this.dispositionService = serviceRegistry.getDispositionService();
|
||||
}
|
||||
|
||||
public void setRecordsManagementServiceRegistry(RecordsManagementServiceRegistry serviceRegistry)
|
||||
{
|
||||
this.serviceRegistry = serviceRegistry;
|
||||
}
|
||||
|
||||
public void setFilePlanService(FilePlanService filePlanService)
|
||||
{
|
||||
this.filePlanService = filePlanService;
|
||||
}
|
||||
|
||||
public void setCapabilityService(CapabilityService capabilityService)
|
||||
{
|
||||
this.capabilityService = capabilityService;
|
||||
}
|
||||
|
||||
public void setFileFolderService(FileFolderService fileFolderService)
|
||||
{
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node getFolderOrDocument(final NodeRef nodeRef, NodeRef parentNodeRef, QName nodeTypeQName, List<String> includeParam, Map<String, UserInfo> mapUserInfo)
|
||||
{
|
||||
Node originalNode = super.getFolderOrDocument(nodeRef, parentNodeRef, nodeTypeQName, includeParam, mapUserInfo);
|
||||
|
||||
if(nodeTypeQName == null)
|
||||
{
|
||||
nodeTypeQName = nodeService.getType(nodeRef);
|
||||
}
|
||||
|
||||
RMNodeType type = getType(nodeTypeQName, nodeRef);
|
||||
FileplanComponentNode node = null;
|
||||
if (mapUserInfo == null)
|
||||
{
|
||||
mapUserInfo = new HashMap<>(2);
|
||||
}
|
||||
|
||||
if (type == null)
|
||||
{
|
||||
if (filePlanService.isFilePlanComponent(nodeRef))
|
||||
{
|
||||
node = new FileplanComponentNode(originalNode);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidParameterException("The provided node is not a fileplan component");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case CATEGORY:
|
||||
RecordCategoryNode categoryNode = new RecordCategoryNode(originalNode);
|
||||
if (includeParam.contains(PARAM_INCLUDE_HAS_RETENTION_SCHEDULE))
|
||||
{
|
||||
DispositionSchedule ds = dispositionService.getDispositionSchedule(nodeRef);
|
||||
categoryNode.setHasRetentionSchedule(ds!=null?true:false);
|
||||
}
|
||||
node = categoryNode;
|
||||
break;
|
||||
case RECORD_FOLDER:
|
||||
RecordFolderNode rfNode = new RecordFolderNode(originalNode);
|
||||
if (includeParam.contains(PARAM_INCLUDE_IS_CLOSED))
|
||||
{
|
||||
rfNode.setIsClosed((Boolean) nodeService.getProperty(nodeRef, RecordsManagementModel.PROP_IS_CLOSED));
|
||||
}
|
||||
node = rfNode;
|
||||
break;
|
||||
case FILE:
|
||||
RecordNode rNode = new RecordNode(originalNode);
|
||||
if (includeParam.contains(PARAM_INCLUDE_IS_COMPLETED))
|
||||
{
|
||||
rNode.setIsCompleted(nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_DECLARED_RECORD));
|
||||
}
|
||||
node = rNode;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (includeParam.contains(PARAM_INCLUDE_ALLOWABLEOPERATIONS))
|
||||
{
|
||||
// If the user does not have any of the mapped permissions then "allowableOperations" is not returned (rather than an empty array)
|
||||
List<String> allowableOperations = getAllowableOperations(nodeRef, type);
|
||||
node.setAllowableOperations((allowableOperations.size() > 0 )? allowableOperations : null);
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method that generates allowable operation for the provided node
|
||||
* @param nodeRef the node to get the allowable operations for
|
||||
* @param type the type of the provided nodeRef
|
||||
* @return a sublist of [{@link Nodes.OP_DELETE}, {@link Nodes.OP_CREATE}, {@link Nodes.OP_UPDATE}] representing the allowable operations for the provided node
|
||||
*/
|
||||
private List<String> getAllowableOperations(NodeRef nodeRef, RMNodeType type)
|
||||
{
|
||||
List<String> allowableOperations = new ArrayList<>();
|
||||
|
||||
NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
|
||||
boolean isFilePlan = nodeRef.equals(filePlan);
|
||||
boolean isTransferContainer = nodeRef.equals(filePlanService.getTransferContainer(filePlan));
|
||||
boolean isUnfiledContainer = nodeRef.equals(filePlanService.getUnfiledContainer(filePlan));
|
||||
boolean isHoldsContainer = nodeRef.equals(filePlanService.getHoldContainer(filePlan)) ;
|
||||
boolean isSpecialContainer = isFilePlan || isTransferContainer || isUnfiledContainer || isHoldsContainer;
|
||||
|
||||
// DELETE
|
||||
if(!isSpecialContainer &&
|
||||
capabilityService.getCapability("Delete").evaluate(nodeRef) == AccessDecisionVoter.ACCESS_GRANTED)
|
||||
{
|
||||
allowableOperations.add(OP_DELETE);
|
||||
}
|
||||
|
||||
// CREATE
|
||||
if(type != RMNodeType.FILE &&
|
||||
!isTransferContainer &&
|
||||
capabilityService.getCapability("FillingPermissionOnly").evaluate(nodeRef) == AccessDecisionVoter.ACCESS_GRANTED)
|
||||
{
|
||||
allowableOperations.add(OP_CREATE);
|
||||
}
|
||||
|
||||
// UPDATE
|
||||
if (capabilityService.getCapability("Update").evaluate(nodeRef) == AccessDecisionVoter.ACCESS_GRANTED)
|
||||
{
|
||||
allowableOperations.add(OP_UPDATE);
|
||||
}
|
||||
|
||||
return allowableOperations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeRef validateNode(String nodeId)
|
||||
{
|
||||
ParameterCheck.mandatoryString("nodeId", nodeId);
|
||||
|
||||
if (nodeId.equals(PATH_FILE_PLAN))
|
||||
{
|
||||
NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
|
||||
if (filePlan != null)
|
||||
{
|
||||
return filePlan;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new EntityNotFoundException(nodeId);
|
||||
}
|
||||
}
|
||||
else if (nodeId.equals(PATH_TRANSFERS))
|
||||
{
|
||||
NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
|
||||
if (filePlan != null)
|
||||
{
|
||||
return filePlanService.getTransferContainer(filePlan);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new EntityNotFoundException(nodeId);
|
||||
}
|
||||
}
|
||||
else if (nodeId.equals(PATH_UNFILED))
|
||||
{
|
||||
NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
|
||||
if (filePlan != null)
|
||||
{
|
||||
return filePlanService.getUnfiledContainer(filePlan);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new EntityNotFoundException(nodeId);
|
||||
}
|
||||
}
|
||||
else if (nodeId.equals(PATH_HOLDS))
|
||||
{
|
||||
NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
|
||||
if (filePlan != null)
|
||||
{
|
||||
return filePlanService.getHoldContainer(filePlan);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new EntityNotFoundException(nodeId);
|
||||
}
|
||||
}
|
||||
|
||||
return super.validateNode(nodeId);
|
||||
}
|
||||
|
||||
private RMNodeType getType(QName typeQName, NodeRef nodeRef)
|
||||
{
|
||||
// quick check for common types
|
||||
if (typeQName.equals(RecordsManagementModel.TYPE_RECORD_FOLDER))
|
||||
{
|
||||
return RMNodeType.RECORD_FOLDER;
|
||||
}
|
||||
if (typeQName.equals(RecordsManagementModel.TYPE_RECORD_CATEGORY))
|
||||
{
|
||||
return RMNodeType.CATEGORY;
|
||||
}
|
||||
if (typeQName.equals(ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
return RMNodeType.FILE;
|
||||
}
|
||||
|
||||
// check subclasses
|
||||
if (dictionaryService.isSubClass(typeQName, ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
return RMNodeType.FILE;
|
||||
}
|
||||
if (dictionaryService.isSubClass(typeQName, RecordsManagementModel.TYPE_RECORD_FOLDER))
|
||||
{
|
||||
return RMNodeType.RECORD_FOLDER;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Pair<Set<QName>, Set<QName>> buildSearchTypesAndIgnoreAspects(QName nodeTypeQName, boolean includeSubTypes, Set<QName> ignoreQNameTypes, Boolean includeFiles, Boolean includeFolders)
|
||||
{
|
||||
Pair<Set<QName>, Set<QName>> searchTypesAndIgnoreAspects = super.buildSearchTypesAndIgnoreAspects(nodeTypeQName, includeSubTypes, ignoreQNameTypes, includeFiles, includeFolders);
|
||||
Set<QName> searchTypeQNames = searchTypesAndIgnoreAspects.getFirst();
|
||||
Set<QName> ignoreAspectQNames = searchTypesAndIgnoreAspects.getSecond();
|
||||
|
||||
searchTypeQNames.remove(RecordsManagementModel.TYPE_HOLD_CONTAINER);
|
||||
searchTypeQNames.remove(RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER);
|
||||
searchTypeQNames.remove(RecordsManagementModel.TYPE_TRANSFER_CONTAINER);
|
||||
|
||||
searchTypeQNames.remove(RecordsManagementModel.TYPE_DISPOSITION_SCHEDULE);
|
||||
searchTypeQNames.remove(RecordsManagementModel.TYPE_DISPOSITION_ACTION);
|
||||
searchTypeQNames.remove(RecordsManagementModel.TYPE_DISPOSITION_ACTION_DEFINITION);
|
||||
|
||||
return new Pair<>(searchTypeQNames, ignoreAspectQNames);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node createNode(String parentFolderNodeId, Node nodeInfo, Parameters parameters)
|
||||
{
|
||||
// create RM path if needed and call the super method with the last element of the created path
|
||||
String relativePath = nodeInfo.getRelativePath();
|
||||
|
||||
// Get the type of the node to be created
|
||||
String nodeType = nodeInfo.getNodeType();
|
||||
if ((nodeType == null) || nodeType.isEmpty())
|
||||
{
|
||||
throw new InvalidArgumentException("Node type is expected: "+parentFolderNodeId+","+nodeInfo.getName());
|
||||
}
|
||||
QName nodeTypeQName = createQName(nodeType);
|
||||
|
||||
// Get or create the path
|
||||
NodeRef parentNodeRef = getOrCreatePath(parentFolderNodeId, relativePath, nodeTypeQName);
|
||||
|
||||
// Set relative path to null as we pass the last element from the path
|
||||
nodeInfo.setRelativePath(null);
|
||||
|
||||
return super.createNode(parentNodeRef.getId(), nodeInfo, parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node upload(String parentFolderNodeId, FormData formData, Parameters parameters)
|
||||
{
|
||||
if (formData == null || !formData.getIsMultiPart())
|
||||
{
|
||||
throw new InvalidArgumentException("The request content-type is not multipart: "+parentFolderNodeId);
|
||||
}
|
||||
|
||||
for (FormData.FormField field : formData.getFields())
|
||||
{
|
||||
if(field.getName().equalsIgnoreCase("relativepath"))
|
||||
{
|
||||
// Create the path if it does not exist
|
||||
getOrCreatePath(parentFolderNodeId, getStringOrNull(field.getValue()), ContentModel.TYPE_CONTENT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return super.upload(parentFolderNodeId, formData, parameters);
|
||||
}
|
||||
|
||||
private String getStringOrNull(String value)
|
||||
{
|
||||
if (StringUtils.isNotEmpty(value))
|
||||
{
|
||||
return value.equalsIgnoreCase("null") ? null : value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeRef getOrCreatePath(String parentFolderNodeId, String relativePath, QName nodeTypeQName)
|
||||
{
|
||||
NodeRef parentNodeRef = validateOrLookupNode(parentFolderNodeId, null);
|
||||
|
||||
if (relativePath == null)
|
||||
{
|
||||
return parentNodeRef;
|
||||
}
|
||||
List<String> pathElements = getPathElements(relativePath);
|
||||
if (pathElements.isEmpty())
|
||||
{
|
||||
return parentNodeRef;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the latest existing path element
|
||||
*/
|
||||
int i = 0;
|
||||
for (; i < pathElements.size(); i++)
|
||||
{
|
||||
final String pathElement = pathElements.get(i);
|
||||
final NodeRef contextParentNodeRef = parentNodeRef;
|
||||
// Navigation should not check permissions
|
||||
NodeRef child = AuthenticationUtil.runAsSystem(new RunAsWork<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef doWork() throws Exception
|
||||
{
|
||||
return nodeService.getChildByName(contextParentNodeRef, ContentModel.ASSOC_CONTAINS, pathElement);
|
||||
}
|
||||
});
|
||||
|
||||
if(child == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
parentNodeRef = child;
|
||||
}
|
||||
if(i == pathElements.size())
|
||||
{
|
||||
return parentNodeRef;
|
||||
}
|
||||
else
|
||||
{
|
||||
pathElements = pathElements.subList(i, pathElements.size());
|
||||
}
|
||||
|
||||
/*
|
||||
* Starting from the latest existing element create the rest of the elements
|
||||
*/
|
||||
QName parentNodeType = nodeService.getType(parentNodeRef);
|
||||
if(dictionaryService.isSubClass(parentNodeType, RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER) ||
|
||||
dictionaryService.isSubClass(parentNodeType, RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER))
|
||||
{
|
||||
for (String pathElement : pathElements)
|
||||
{
|
||||
// Create unfiled record folder
|
||||
parentNodeRef = fileFolderService.create(parentNodeRef, pathElement, RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER).getNodeRef();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Outside the unfiled record container the path elements are record categories
|
||||
* except the last element which is a record folder if the created node is of type content
|
||||
*/
|
||||
Iterator<String> iterator = pathElements.iterator();
|
||||
while(iterator.hasNext())
|
||||
{
|
||||
String pathElement = iterator.next();
|
||||
|
||||
if(!iterator.hasNext() && dictionaryService.isSubClass(nodeTypeQName, ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
// last element, create record folder if the node to be created is content
|
||||
parentNodeRef = fileFolderService.create(parentNodeRef, pathElement, RecordsManagementModel.TYPE_RECORD_FOLDER).getNodeRef();
|
||||
}
|
||||
else
|
||||
{
|
||||
// create record category
|
||||
parentNodeRef = filePlanService.createRecordCategory(parentNodeRef, pathElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return parentNodeRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method that parses a string representing a file path and returns a list of element names
|
||||
* @param path the file path represented as a string
|
||||
* @return a list of file path element names
|
||||
*/
|
||||
private List<String> getPathElements(String path)
|
||||
{
|
||||
final List<String> pathElements = new ArrayList<>();
|
||||
if (path != null && path.trim().length() > 0)
|
||||
{
|
||||
// There is no need to check for leading and trailing "/"
|
||||
final StringTokenizer tokenizer = new StringTokenizer(path, "/");
|
||||
while (tokenizer.hasMoreTokens())
|
||||
{
|
||||
pathElements.add(tokenizer.nextToken().trim());
|
||||
}
|
||||
}
|
||||
return pathElements;
|
||||
}
|
||||
|
||||
}
|
@@ -27,31 +27,19 @@
|
||||
|
||||
package org.alfresco.rm.rest.api.impl;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.site.SiteServiceException;
|
||||
import org.alfresco.rest.api.impl.SiteImportPackageHandler;
|
||||
import org.alfresco.rest.api.impl.SitesImpl;
|
||||
import org.alfresco.rest.api.model.Site;
|
||||
import org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException;
|
||||
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
||||
import org.alfresco.rest.api.model.SiteUpdate;
|
||||
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rm.rest.api.RMSites;
|
||||
import org.alfresco.rm.rest.api.model.RMSite;
|
||||
import org.alfresco.rm.rest.api.model.RMSiteCompliance;
|
||||
import org.alfresco.rm.rest.api.model.SiteUpdate;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.site.SiteInfo;
|
||||
import org.alfresco.service.cmr.site.SiteService;
|
||||
import org.alfresco.service.cmr.site.SiteVisibility;
|
||||
import org.alfresco.service.cmr.view.ImportPackageHandler;
|
||||
import org.alfresco.service.cmr.view.ImporterBinding;
|
||||
import org.alfresco.service.cmr.view.ImporterContentCache;
|
||||
import org.alfresco.service.cmr.view.ImporterProgress;
|
||||
import org.alfresco.service.cmr.view.Location;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
@@ -79,134 +67,19 @@ public class RMSitesImpl extends SitesImpl implements RMSites
|
||||
return new RMSite(site, compliance);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO remove when upgrading to 5.2.N. We'll need to only extend the extended method createSite(Site) and use the siteService method that gets site type as parameter
|
||||
*/
|
||||
@Override
|
||||
public Site createSite(Site site, Parameters parameters)
|
||||
protected SiteInfo createSite(Site site)
|
||||
{
|
||||
site = validateSite(site);
|
||||
|
||||
SiteInfo siteInfo = null;
|
||||
try
|
||||
{
|
||||
siteInfo = siteService.createSite(RM_SITE_PRESET, RM_SITE_ID, site.getTitle(), site.getDescription(),
|
||||
SiteVisibility.PUBLIC, getRMSiteType((RMSite) site));
|
||||
}
|
||||
catch (SiteServiceException sse)
|
||||
{
|
||||
if (sse.getMsgId().equals("site_service.unable_to_create"))
|
||||
{
|
||||
throw new ConstraintViolatedException(sse.getMessage());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw sse;
|
||||
}
|
||||
}
|
||||
|
||||
String siteId = siteInfo.getShortName();
|
||||
NodeRef siteNodeRef = siteInfo.getNodeRef();
|
||||
|
||||
// import default/fixed preset Share surf config
|
||||
importSite(siteId, siteNodeRef);
|
||||
|
||||
// pre-create doclib
|
||||
siteService.createContainer(siteId, SiteService.DOCUMENT_LIBRARY, ContentModel.TYPE_FOLDER, null);
|
||||
|
||||
// default false (if not provided)
|
||||
boolean skipAddToFavorites = Boolean.valueOf(parameters.getParameter(PARAM_SKIP_ADDTOFAVORITES));
|
||||
if (skipAddToFavorites == false)
|
||||
{
|
||||
String personId = AuthenticationUtil.getFullyAuthenticatedUser();
|
||||
favouritesService.addFavourite(personId, siteNodeRef); // ignore result
|
||||
}
|
||||
|
||||
return getSite(siteInfo, true);
|
||||
return siteService.createSite(RM_SITE_PRESET, RM_SITE_ID, site.getTitle(), site.getDescription(), SiteVisibility.PUBLIC, getRMSiteType((RMSite) site));
|
||||
}
|
||||
|
||||
/**
|
||||
* Copied from SitesImpl since we didn't had access to it.
|
||||
*
|
||||
* TODO to remove when upgrading to 5.2.N
|
||||
*
|
||||
* @param siteInfo
|
||||
* @param includeRole
|
||||
* @return
|
||||
*/
|
||||
private Site getSite(SiteInfo siteInfo, boolean includeRole)
|
||||
{
|
||||
// set the site id to the short name (to deal with case sensitivity issues with using the siteId from the url)
|
||||
String siteId = siteInfo.getShortName();
|
||||
String role = null;
|
||||
if (includeRole)
|
||||
{
|
||||
role = getSiteRole(siteId);
|
||||
}
|
||||
return new Site(siteInfo, role);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copied from SitesImpl since we didn't had access to it.
|
||||
*
|
||||
* TODO to be removed when upgrading to 5.2.N
|
||||
*
|
||||
* @param siteId
|
||||
* @param siteNodeRef
|
||||
*/
|
||||
private void importSite(final String siteId, final NodeRef siteNodeRef)
|
||||
{
|
||||
ImportPackageHandler acpHandler = new SiteImportPackageHandler(siteSurfConfig, siteId);
|
||||
Location location = new Location(siteNodeRef);
|
||||
ImporterBinding binding = new ImporterBinding()
|
||||
{
|
||||
@Override
|
||||
public String getValue(String key)
|
||||
{
|
||||
if (key.equals("siteId"))
|
||||
{
|
||||
return siteId;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID_BINDING getUUIDBinding()
|
||||
{
|
||||
return UUID_BINDING.CREATE_NEW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QName[] getExcludedClasses()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowReferenceWithinTransaction()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImporterContentCache getImportConentCache()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
};
|
||||
importerService.importView(acpHandler, location, binding, (ImporterProgress)null);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is copied from SitesImpl since we could not access it since it is private.
|
||||
*
|
||||
* TODO change this to protected and override validate method from core when upgrading to 5.2.N
|
||||
*
|
||||
* Even if the method it will be protected in core, we still need to override since we don't need to check if the visibility is set since for RM site it is always PUBLIC.
|
||||
* We also don't need to generate the id from title, or to check the id, since the id is always rm.
|
||||
* @param site
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
protected Site validateSite(Site site)
|
||||
{
|
||||
// site title - mandatory
|
||||
@@ -269,46 +142,6 @@ public class RMSitesImpl extends SitesImpl implements RMSites
|
||||
return compliance;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO copied from core 5.2.N since we don't have it in 5.2.a-EA version. To be removed when upgrading.
|
||||
* @param siteId
|
||||
* @param update
|
||||
* @param parameters
|
||||
* @return
|
||||
*/
|
||||
public Site updateSite(String siteId, SiteUpdate update, Parameters parameters)
|
||||
{
|
||||
// Get the site by ID (aka short name)
|
||||
SiteInfo siteInfo = validateSite(siteId);
|
||||
if (siteInfo == null)
|
||||
{
|
||||
// site does not exist
|
||||
throw new EntityNotFoundException(siteId);
|
||||
}
|
||||
|
||||
// Bind any provided values to the site info, allowing for "partial" updates.
|
||||
if (update.getTitle() != null)
|
||||
{
|
||||
siteInfo.setTitle(update.getTitle());
|
||||
}
|
||||
if (update.getDescription() != null)
|
||||
{
|
||||
siteInfo.setDescription(update.getDescription());
|
||||
}
|
||||
if (update.getVisibility() != null)
|
||||
{
|
||||
siteInfo.setVisibility(update.getVisibility());
|
||||
}
|
||||
|
||||
// Validate the new details
|
||||
validateSite(new Site(siteInfo, null));
|
||||
|
||||
// Perform the actual update.
|
||||
siteService.updateSite(siteInfo);
|
||||
|
||||
return getSite(siteId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets RM site type based on compliance.
|
||||
*
|
||||
|
@@ -1,202 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.impl;
|
||||
|
||||
import java.security.InvalidParameterException;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil;
|
||||
import org.alfresco.repo.node.integrity.IntegrityException;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.rest.api.model.Node;
|
||||
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rm.rest.api.RMNodes;
|
||||
import org.alfresco.rm.rest.api.Records;
|
||||
import org.alfresco.rm.rest.api.model.TargetContainer;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.model.FileExistsException;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileNotFoundException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.dao.ConcurrencyFailureException;
|
||||
import org.springframework.extensions.surf.util.ParameterCheck;
|
||||
|
||||
/**
|
||||
* Centralizes access to record services
|
||||
*
|
||||
* @author Ana Bozianu
|
||||
* @since 2.6
|
||||
*/
|
||||
public class RecordsImpl implements Records, InitializingBean
|
||||
{
|
||||
protected RecordService recordService;
|
||||
protected FilePlanService filePlanService;
|
||||
protected NodeService nodeService;
|
||||
protected FileFolderService fileFolderService;
|
||||
protected DictionaryService dictionaryService;
|
||||
protected AuthenticationUtil authenticationUtil;
|
||||
protected RMNodes nodes;
|
||||
|
||||
public void setRecordService(RecordService recordService)
|
||||
{
|
||||
this.recordService = recordService;
|
||||
}
|
||||
|
||||
public void setFilePlanService(FilePlanService filePlanService)
|
||||
{
|
||||
this.filePlanService = filePlanService;
|
||||
}
|
||||
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
public void setFileFolderService(FileFolderService fileFolderService)
|
||||
{
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
public void setAuthenticationUtil(AuthenticationUtil authenticationUtil)
|
||||
{
|
||||
this.authenticationUtil = authenticationUtil;
|
||||
}
|
||||
|
||||
public void setNodes(RMNodes nodes)
|
||||
{
|
||||
this.nodes = nodes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node declareFileAsRecord(String fileId, Parameters parameters)
|
||||
{
|
||||
// Get file to be declared
|
||||
NodeRef fileNodeRef = nodes.validateNode(fileId) ;
|
||||
|
||||
// Get fileplan
|
||||
NodeRef filePlan = authenticationUtil.runAsSystem(new RunAsWork<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef doWork()
|
||||
{
|
||||
return filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
|
||||
}
|
||||
});
|
||||
|
||||
// default false (if not provided)
|
||||
boolean hideRecord = Boolean.valueOf(parameters.getParameter(PARAM_HIDE_RECORD));
|
||||
|
||||
// Create the record
|
||||
recordService.createRecord(filePlan, fileNodeRef, !hideRecord);
|
||||
|
||||
// Get information about the new record
|
||||
return nodes.getFolderOrDocument(fileId, parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node fileOrLinkRecord(String recordId, TargetContainer target, Parameters parameters)
|
||||
{
|
||||
if(StringUtils.isBlank(target.getTargetParentId()) && StringUtils.isBlank(target.getRelativePath()))
|
||||
{
|
||||
throw new InvalidParameterException("No target folder information was provided");
|
||||
}
|
||||
|
||||
// Get record
|
||||
NodeRef record = nodes.validateNode(recordId);
|
||||
|
||||
// Get record folder to file/link the record to
|
||||
String parentContainerId = target.getTargetParentId();
|
||||
if(parentContainerId == null || parentContainerId.isEmpty())
|
||||
{
|
||||
// If target container not provided get fileplan
|
||||
parentContainerId = authenticationUtil.runAsSystem(new RunAsWork<String>()
|
||||
{
|
||||
@Override
|
||||
public String doWork()
|
||||
{
|
||||
return filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID).getId();
|
||||
}
|
||||
});
|
||||
}
|
||||
NodeRef parentRecordFolder = nodes.getOrCreatePath(parentContainerId, target.getRelativePath(), ContentModel.TYPE_CONTENT);
|
||||
|
||||
// Check if the target is a record folder
|
||||
if(!dictionaryService.isSubClass(nodeService.getType(parentRecordFolder), RecordsManagementModel.TYPE_RECORD_FOLDER))
|
||||
{
|
||||
throw new InvalidArgumentException("The provided target parent is not a record folder");
|
||||
}
|
||||
|
||||
// Get the current parent type to decide if we link or move the record
|
||||
NodeRef primaryParent = nodeService.getPrimaryParent(record).getParentRef();
|
||||
if(dictionaryService.isSubClass(nodeService.getType(primaryParent), RecordsManagementModel.TYPE_RECORD_FOLDER))
|
||||
{
|
||||
recordService.link(record, parentRecordFolder);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
fileFolderService.moveFrom(record, primaryParent, parentRecordFolder, null);
|
||||
}
|
||||
catch (FileExistsException e)
|
||||
{
|
||||
throw new IntegrityException(e.getMessage(), null);
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
throw new ConcurrencyFailureException("The record was deleted while filing it", e);
|
||||
}
|
||||
}
|
||||
|
||||
// Get the record info
|
||||
return nodes.getFolderOrDocument(recordId, parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
ParameterCheck.mandatory("recordService", recordService);
|
||||
ParameterCheck.mandatory("filePlanService", filePlanService);
|
||||
ParameterCheck.mandatory("nodes", nodes);
|
||||
ParameterCheck.mandatory("nodeService", nodeService);
|
||||
ParameterCheck.mandatory("fileFolderService", fileFolderService);
|
||||
ParameterCheck.mandatory("dictionaryService", dictionaryService);
|
||||
}
|
||||
}
|
@@ -0,0 +1,292 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.impl;
|
||||
|
||||
import java.security.InvalidParameterException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.rest.antlr.WhereClauseParser;
|
||||
import org.alfresco.rest.api.Nodes;
|
||||
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rest.framework.resource.parameters.where.Query;
|
||||
import org.alfresco.rest.framework.resource.parameters.where.QueryHelper;
|
||||
import org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker;
|
||||
import org.alfresco.rm.rest.api.model.RMNode;
|
||||
import org.alfresco.rm.rest.api.model.RecordCategoryChild;
|
||||
import org.alfresco.rm.rest.api.model.UnfiledChild;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.Pair;
|
||||
|
||||
/**
|
||||
* Utility class that handles common api endpoint tasks
|
||||
*
|
||||
* @author Ana Bozianu
|
||||
* @since 2.6
|
||||
*/
|
||||
public class SearchTypesFactory
|
||||
{
|
||||
private DictionaryService dictionaryService;
|
||||
private Nodes nodes;
|
||||
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
public void setNodes(Nodes nodes)
|
||||
{
|
||||
this.nodes = nodes;
|
||||
}
|
||||
|
||||
public Set<QName> buildSearchTypesForFilePlanEndpoint()
|
||||
{
|
||||
Set<QName> searchTypeQNames = new HashSet<>();
|
||||
searchTypeQNames.add(RecordsManagementModel.TYPE_RECORD_CATEGORY);
|
||||
return searchTypeQNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to build search types for unfiled container and unfiled record folders endpoints
|
||||
* @param parameters
|
||||
* @param listFolderChildrenEqualsQueryProperties
|
||||
* @return
|
||||
*/
|
||||
public Set<QName> buildSearchTypesForUnfiledEndpoint(Parameters parameters, Set<String> listFolderChildrenEqualsQueryProperties)
|
||||
{
|
||||
Set<QName> searchTypeQNames = new HashSet<>();
|
||||
|
||||
Query q = parameters.getQuery();
|
||||
|
||||
boolean includeUnfiledRecordFolders = false;
|
||||
boolean includeRecords = false;
|
||||
boolean includeSubTypes = false;
|
||||
|
||||
if (q != null)
|
||||
{
|
||||
// filtering via "where" clause
|
||||
MapBasedQueryWalker propertyWalker = new MapBasedQueryWalker(listFolderChildrenEqualsQueryProperties, null);
|
||||
QueryHelper.walk(q, propertyWalker);
|
||||
|
||||
Boolean isUnfiledRecordFolder = propertyWalker.getProperty(UnfiledChild.PARAM_IS_UNFILED_RECORD_FOLDER,
|
||||
WhereClauseParser.EQUALS, Boolean.class);
|
||||
Boolean isRecord = propertyWalker.getProperty(UnfiledChild.PARAM_IS_RECORD, WhereClauseParser.EQUALS, Boolean.class);
|
||||
if ((isUnfiledRecordFolder != null && isUnfiledRecordFolder.booleanValue()) || (isRecord != null && !isRecord.booleanValue()))
|
||||
{
|
||||
includeUnfiledRecordFolders = true;
|
||||
}
|
||||
else if ((isUnfiledRecordFolder != null && !isUnfiledRecordFolder.booleanValue()) || (isRecord != null && isRecord.booleanValue()))
|
||||
{
|
||||
includeRecords = true;
|
||||
}
|
||||
|
||||
String nodeTypeQNameStr = propertyWalker.getProperty(UnfiledChild.PARAM_NODE_TYPE, WhereClauseParser.EQUALS, String.class);
|
||||
QName filterNodeTypeQName;
|
||||
if (nodeTypeQNameStr != null)
|
||||
{
|
||||
if ((isUnfiledRecordFolder != null) || (isRecord != null))
|
||||
{
|
||||
throw new InvalidArgumentException("Invalid filter - nodeType and isUnfiledRecordFolder/isRecord are mutually exclusive");
|
||||
}
|
||||
|
||||
Pair<QName, Boolean> pair = parseNodeTypeFilter(nodeTypeQNameStr);
|
||||
filterNodeTypeQName = pair.getFirst();
|
||||
includeSubTypes = pair.getSecond();
|
||||
|
||||
if (nodeTypeQNameStr.equals(RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER))
|
||||
{
|
||||
includeUnfiledRecordFolders = true;
|
||||
}
|
||||
else if (filterNodeTypeQName.equals(ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
includeRecords = true;
|
||||
}
|
||||
else if (dictionaryService.isSubClass(filterNodeTypeQName, ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
searchTypeQNames.add(filterNodeTypeQName);
|
||||
if (includeSubTypes)
|
||||
{
|
||||
Collection<QName> qnames = dictionaryService.getSubTypes(filterNodeTypeQName, true);
|
||||
searchTypeQNames.addAll(qnames);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidParameterException("Filter nodeType: " + nodeTypeQNameStr + " is invalid for this endpoint");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
includeRecords = true;
|
||||
includeUnfiledRecordFolders = true;
|
||||
includeSubTypes = true;
|
||||
}
|
||||
|
||||
if (includeUnfiledRecordFolders)
|
||||
{
|
||||
searchTypeQNames.add(RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER);
|
||||
}
|
||||
if (includeRecords)
|
||||
{
|
||||
|
||||
if (includeSubTypes)
|
||||
{
|
||||
Collection<QName> qnames = dictionaryService.getSubTypes(ContentModel.TYPE_CONTENT, true);
|
||||
searchTypeQNames.addAll(qnames);
|
||||
}
|
||||
else
|
||||
{
|
||||
searchTypeQNames.add(ContentModel.TYPE_CONTENT);
|
||||
searchTypeQNames.add(RecordsManagementModel.TYPE_NON_ELECTRONIC_DOCUMENT);
|
||||
}
|
||||
}
|
||||
return searchTypeQNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to build search types for categories endpoint
|
||||
* @param parameters
|
||||
* @param listRecordCategoryChildrenEqualsQueryProperties
|
||||
* @return
|
||||
*/
|
||||
public Set<QName> buildSearchTypesCategoriesEndpoint(Parameters parameters, Set<String> listRecordCategoryChildrenEqualsQueryProperties)
|
||||
{
|
||||
Set<QName> searchTypeQNames = new HashSet<>();
|
||||
|
||||
Query q = parameters.getQuery();
|
||||
|
||||
boolean includeRecordFolders = false;
|
||||
boolean includeRecordCategories = false;
|
||||
|
||||
if (q != null)
|
||||
{
|
||||
// filtering via "where" clause
|
||||
MapBasedQueryWalker propertyWalker = new MapBasedQueryWalker(listRecordCategoryChildrenEqualsQueryProperties, null);
|
||||
QueryHelper.walk(q, propertyWalker);
|
||||
|
||||
Boolean isRecordFolder = propertyWalker.getProperty(RecordCategoryChild.PARAM_IS_RECORD_FOLDER,
|
||||
WhereClauseParser.EQUALS, Boolean.class);
|
||||
Boolean isRecordCategory = propertyWalker.getProperty(RecordCategoryChild.PARAM_IS_RECORD_CATEGORY, WhereClauseParser.EQUALS, Boolean.class);
|
||||
if ((isRecordFolder != null && isRecordFolder.booleanValue()) || (isRecordCategory != null && !isRecordCategory.booleanValue()))
|
||||
{
|
||||
includeRecordFolders = true;
|
||||
}
|
||||
else if ((isRecordFolder != null && !isRecordFolder.booleanValue()) || (isRecordCategory != null && isRecordCategory.booleanValue()))
|
||||
{
|
||||
includeRecordCategories = true;
|
||||
}
|
||||
|
||||
String nodeTypeQNameStr = propertyWalker.getProperty(RecordCategoryChild.PARAM_NODE_TYPE, WhereClauseParser.EQUALS, String.class);
|
||||
QName filterNodeTypeQName;
|
||||
if (nodeTypeQNameStr != null)
|
||||
{
|
||||
if ((isRecordFolder != null) || (isRecordCategory != null))
|
||||
{
|
||||
throw new InvalidArgumentException("Invalid filter - nodeType and isRecordFolder/isRecordCategory are mutually exclusive");
|
||||
}
|
||||
|
||||
Pair<QName, Boolean> pair = parseNodeTypeFilter(nodeTypeQNameStr);
|
||||
filterNodeTypeQName = pair.getFirst();
|
||||
if (nodeTypeQNameStr.equals(RecordsManagementModel.TYPE_RECORD_FOLDER))
|
||||
{
|
||||
includeRecordFolders = true;
|
||||
}
|
||||
else if (filterNodeTypeQName.equals(RecordsManagementModel.TYPE_RECORD_CATEGORY))
|
||||
{
|
||||
includeRecordCategories = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidParameterException("Filter nodeType: " + nodeTypeQNameStr + " is invalid for this endpoint");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
includeRecordCategories = true;
|
||||
includeRecordFolders = true;
|
||||
}
|
||||
|
||||
if (includeRecordFolders)
|
||||
{
|
||||
searchTypeQNames.add(RecordsManagementModel.TYPE_RECORD_FOLDER);
|
||||
}
|
||||
if (includeRecordCategories)
|
||||
{
|
||||
searchTypeQNames.add(RecordsManagementModel.TYPE_RECORD_CATEGORY);
|
||||
}
|
||||
return searchTypeQNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to build search types for transfer containers endpoint
|
||||
* @return
|
||||
*/
|
||||
public Set<QName> buildSearchTypesForTransferContainersEndpoint()
|
||||
{
|
||||
Set<QName> searchTypeQNames = new HashSet<>();
|
||||
searchTypeQNames.add(RecordsManagementModel.TYPE_TRANSFER);
|
||||
return searchTypeQNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to parse the nodeType filter
|
||||
* default nodeType filtering is without subTypes (unless nodeType value is suffixed with ' INCLUDESUBTYPES')
|
||||
* @param nodeTypeStr
|
||||
* @return
|
||||
*/
|
||||
private Pair<QName, Boolean> parseNodeTypeFilter(String nodeTypeStr)
|
||||
{
|
||||
boolean filterIncludeSubTypes = false;
|
||||
|
||||
int idx = nodeTypeStr.lastIndexOf(' ');
|
||||
if (idx > 0)
|
||||
{
|
||||
String suffix = nodeTypeStr.substring(idx);
|
||||
if (suffix.equalsIgnoreCase(" " + RMNode.PARAM_INCLUDE_SUBTYPES))
|
||||
{
|
||||
filterIncludeSubTypes = true;
|
||||
nodeTypeStr = nodeTypeStr.substring(0, idx);
|
||||
}
|
||||
}
|
||||
|
||||
QName filterNodeTypeQName = nodes.createQName(nodeTypeStr);
|
||||
if (dictionaryService.getType(filterNodeTypeQName) == null)
|
||||
{
|
||||
throw new InvalidParameterException("Filter nodeType: " + nodeTypeStr + " is invalid");
|
||||
}
|
||||
|
||||
return new Pair<>(filterNodeTypeQName, filterIncludeSubTypes);
|
||||
}
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.model;
|
||||
|
||||
/**
|
||||
* Concrete class carrying general information for an unfiled container
|
||||
*
|
||||
* @author Ana Bozianu
|
||||
* @since 2.6
|
||||
*/
|
||||
public class FilePlan extends RMNode
|
||||
{
|
||||
public FilePlan()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
}
|
@@ -1,106 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.rest.api.model.Node;
|
||||
import org.alfresco.rest.api.model.UserInfo;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Concrete class carrying general information for a fileplan component node
|
||||
*
|
||||
* @author Ana Bozianu
|
||||
* @since 2.6
|
||||
*/
|
||||
public class FileplanComponentNode extends Node
|
||||
{
|
||||
protected Boolean isCategory;
|
||||
protected Boolean isRecordFolder;
|
||||
|
||||
public FileplanComponentNode(NodeRef nodeRef, NodeRef parentNodeRef, Map<QName, Serializable> nodeProps, Map<String, UserInfo> mapUserInfo, ServiceRegistry sr)
|
||||
{
|
||||
super(nodeRef, parentNodeRef, nodeProps, mapUserInfo, sr);
|
||||
defineType();
|
||||
}
|
||||
|
||||
public FileplanComponentNode(Node node)
|
||||
{
|
||||
this.nodeRef = node.getNodeRef();
|
||||
this.name = node.getName();
|
||||
this.createdAt = node.getCreatedAt();
|
||||
this.modifiedAt = node.getModifiedAt();
|
||||
this.createdByUser = node.getCreatedByUser();
|
||||
this.modifiedByUser = node.getModifiedByUser();
|
||||
this.archivedAt = node.getArchivedAt();
|
||||
this.archivedByUser = node.getArchivedByUser();
|
||||
this.parentNodeRef = node.getParentId();
|
||||
this.pathInfo = node.getPath();
|
||||
this.prefixTypeQName = node.getNodeType();
|
||||
this.relativePath = node.getRelativePath();
|
||||
this.secondaryChildren = node.getSecondaryChildren();
|
||||
this.targets = node.getTargets();
|
||||
this.aspectNames = node.getAspectNames();
|
||||
this.properties =node.getProperties();
|
||||
this.allowableOperations = node.getAllowableOperations();
|
||||
this.contentInfo = node.getContent();
|
||||
this.description = node.getDescription();
|
||||
defineType();
|
||||
}
|
||||
|
||||
protected void defineType()
|
||||
{
|
||||
isCategory = false;
|
||||
isRecordFolder = false;
|
||||
isFile = false;
|
||||
}
|
||||
|
||||
public Boolean getIsCategory()
|
||||
{
|
||||
return isCategory;
|
||||
}
|
||||
|
||||
public Boolean getIsRecordFolder()
|
||||
{
|
||||
return isRecordFolder;
|
||||
}
|
||||
|
||||
public void setIsCategory(Boolean isCategory)
|
||||
{
|
||||
this.isCategory = isCategory;
|
||||
}
|
||||
|
||||
public void setIsRecordFolder(Boolean isRecordFolder)
|
||||
{
|
||||
this.isRecordFolder = isRecordFolder;
|
||||
}
|
||||
}
|
@@ -0,0 +1,223 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.model;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.rest.api.model.PathInfo;
|
||||
import org.alfresco.rest.api.model.UserInfo;
|
||||
import org.alfresco.rest.framework.resource.UniqueId;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Abstract base class carrying general information for an RM node
|
||||
*
|
||||
* @author Ana Bozianu
|
||||
* @since 2.6
|
||||
*/
|
||||
public abstract class RMNode
|
||||
{
|
||||
public static final String PARAM_ID = "id";
|
||||
public static final String PARAM_PARENT_ID = "parentId";
|
||||
public static final String PARAM_NAME = "name";
|
||||
public static final String PARAM_NODE_TYPE = "nodeType";
|
||||
public static final String PARAM_CREATED_AT = "createdAt";
|
||||
public static final String PARAM_MODIFIED_AT = "modifiedAt";
|
||||
public static final String PARAM_CREATED_BY_USER = "createdByUser";
|
||||
public static final String PARAM_MODIFIED_BY_USER = "modifiedByUser";
|
||||
|
||||
public static final String PARAM_ASPECT_NAMES = "aspectNames";
|
||||
public static final String PARAM_PROPERTIES = "properties";
|
||||
public static final String PARAM_PATH = "path";
|
||||
public static final String PARAM_ALLOWABLE_OPERATIONS = "allowableOperations";
|
||||
|
||||
public static final String PARAM_ISPRIMARY = "isPrimary";
|
||||
|
||||
public static final String PARAM_INCLUDE_SUBTYPES = "INCLUDESUBTYPES";
|
||||
|
||||
public static final String PARAM_HAS_RETENTION_SCHEDULE = "hasRetentionSchedule";
|
||||
public static final String PARAM_IS_CLOSED = "isClosed";
|
||||
|
||||
public static final String FILE_PLAN_TYPE = "rma:filePlan";
|
||||
public static final String RECORD_CATEGORY_TYPE = "rma:recordCategory";
|
||||
public static final String RECORD_FOLDER_TYPE = "rma:recordFolder";
|
||||
public static final String RECORD_TYPE = "rma:record"; // generic record type
|
||||
public static final String UNFILED_RECORD_FOLDER_TYPE = "rma:unfiledRecordFolder";
|
||||
public static final String TRANSFER_TYPE = "rma:transfer";
|
||||
public static final String TRANSFER_CONTAINER_TYPE = "rma:transferContainer";
|
||||
public static final String UNFILED_CONTAINER_TYPE = "rma:unfiledRecordContainer";
|
||||
public static final String FOLDER_TYPE = "cm:folder";
|
||||
public static final String CONTENT_TYPE = "cm:content";
|
||||
public static final String NON_ELECTRONIC_RECORD_TYPE = "rma:nonElectronicDocument";
|
||||
|
||||
// required properties
|
||||
protected NodeRef nodeRef;
|
||||
protected NodeRef parentNodeRef;
|
||||
protected String name;
|
||||
protected String nodeType;
|
||||
|
||||
protected Date createdAt;
|
||||
protected Date modifiedAt;
|
||||
protected UserInfo createdByUser;
|
||||
protected UserInfo modifiedByUser;
|
||||
|
||||
// optional properties
|
||||
protected List<String> aspectNames;
|
||||
protected Map<String, Object> properties;
|
||||
protected PathInfo path;
|
||||
protected List<String> allowableOperations;
|
||||
|
||||
public RMNode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@UniqueId
|
||||
public NodeRef getNodeRef()
|
||||
{
|
||||
return nodeRef;
|
||||
}
|
||||
|
||||
public void setNodeRef(NodeRef nodeRef)
|
||||
{
|
||||
this.nodeRef = nodeRef;
|
||||
}
|
||||
|
||||
public NodeRef getParentId()
|
||||
{
|
||||
return parentNodeRef;
|
||||
}
|
||||
|
||||
public void setParentId(NodeRef parentNodeRef)
|
||||
{
|
||||
this.parentNodeRef = parentNodeRef;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getNodeType()
|
||||
{
|
||||
return nodeType;
|
||||
}
|
||||
|
||||
public void setNodeType(String nodeType)
|
||||
{
|
||||
this.nodeType = nodeType;
|
||||
}
|
||||
|
||||
public Date getCreatedAt()
|
||||
{
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Date createdAt)
|
||||
{
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public Date getModifiedAt()
|
||||
{
|
||||
return modifiedAt;
|
||||
}
|
||||
|
||||
public void setModifiedAt(Date modifiedAt)
|
||||
{
|
||||
this.modifiedAt = modifiedAt;
|
||||
}
|
||||
|
||||
public UserInfo getCreatedByUser()
|
||||
{
|
||||
return createdByUser;
|
||||
}
|
||||
|
||||
public void setCreatedByUser(UserInfo createdByUser)
|
||||
{
|
||||
this.createdByUser = createdByUser;
|
||||
}
|
||||
|
||||
public UserInfo getModifiedByUser()
|
||||
{
|
||||
return modifiedByUser;
|
||||
}
|
||||
|
||||
public void setModifiedByUser(UserInfo modifiedByUser)
|
||||
{
|
||||
this.modifiedByUser = modifiedByUser;
|
||||
}
|
||||
|
||||
public List<String> getAspectNames()
|
||||
{
|
||||
return aspectNames;
|
||||
}
|
||||
|
||||
public void setAspectNames(List<String> aspectNames)
|
||||
{
|
||||
this.aspectNames = aspectNames;
|
||||
}
|
||||
|
||||
public Map<String, Object> getProperties()
|
||||
{
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(Map<String, Object> properties)
|
||||
{
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public PathInfo getPath()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(PathInfo path)
|
||||
{
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public List<String> getAllowableOperations()
|
||||
{
|
||||
return allowableOperations;
|
||||
}
|
||||
|
||||
public void setAllowableOperations(List<String> allowableOperations)
|
||||
{
|
||||
this.allowableOperations = allowableOperations;
|
||||
}
|
||||
|
||||
}
|
@@ -27,6 +27,9 @@
|
||||
|
||||
package org.alfresco.rm.rest.api.model;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.rest.api.model.Site;
|
||||
import org.alfresco.service.cmr.site.SiteInfo;
|
||||
|
||||
@@ -38,7 +41,9 @@ import org.alfresco.service.cmr.site.SiteInfo;
|
||||
*/
|
||||
public class RMSite extends Site
|
||||
{
|
||||
public static final String COMPLIANCE = "compliance";
|
||||
private RMSiteCompliance compliance;
|
||||
private Map<String, Boolean> setRMFields = new HashMap<>(7);
|
||||
|
||||
public RMSiteCompliance getCompliance()
|
||||
{
|
||||
@@ -48,6 +53,18 @@ public class RMSite extends Site
|
||||
public void setCompliance(RMSiteCompliance compliance)
|
||||
{
|
||||
this.compliance = compliance;
|
||||
setRMFields.put(COMPLIANCE, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wasSet(String fieldName)
|
||||
{
|
||||
if(COMPLIANCE.equalsIgnoreCase(fieldName))
|
||||
{
|
||||
Boolean b = setRMFields.get(fieldName);
|
||||
return (b != null ? b : false);
|
||||
}
|
||||
return super.wasSet(fieldName);
|
||||
}
|
||||
|
||||
public RMSite()
|
||||
@@ -57,19 +74,19 @@ public class RMSite extends Site
|
||||
|
||||
public RMSite(Site site, RMSiteCompliance compliance)
|
||||
{
|
||||
this.id = site.getId();
|
||||
this.guid = site.getGuid();
|
||||
this.title = site.getTitle();
|
||||
this.description = site.getDescription();
|
||||
this.visibility = site.getVisibility();
|
||||
this.role = site.getRole();
|
||||
this.compliance = compliance;
|
||||
setId(site.getId());
|
||||
setGuid(site.getGuid());
|
||||
setTitle(site.getTitle());
|
||||
setDescription(site.getDescription());
|
||||
setVisibility(site.getVisibility());
|
||||
setRole(site.getRole());
|
||||
setCompliance(compliance);
|
||||
}
|
||||
|
||||
public RMSite(SiteInfo siteInfo, String role, RMSiteCompliance compliance)
|
||||
{
|
||||
super(siteInfo, role);
|
||||
this.compliance = compliance;
|
||||
setCompliance(compliance);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -24,45 +24,24 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.rest.api.model.Node;
|
||||
import org.alfresco.rest.api.model.UserInfo;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.rest.api.model.ContentInfo;
|
||||
|
||||
/**
|
||||
* Concrete class carrying specific information for a record
|
||||
* Concrete class carrying information for a record
|
||||
*
|
||||
* @author Ana Bozianu
|
||||
* @since 2.6
|
||||
*/
|
||||
public class RecordNode extends FileplanComponentNode
|
||||
public class Record extends RMNode
|
||||
{
|
||||
private Boolean isCompleted;
|
||||
public static final String PARAM_HIDE_RECORD = "hideRecord";
|
||||
public static final String PARAM_IS_COMPLETED = "isCompleted";
|
||||
public static final String PARAM_CONTENT = "content";
|
||||
|
||||
public RecordNode(NodeRef nodeRef, NodeRef parentNodeRef, Map<QName, Serializable> nodeProps, Map<String, UserInfo> mapUserInfo, ServiceRegistry sr)
|
||||
{
|
||||
super(nodeRef, parentNodeRef, nodeProps, mapUserInfo, sr);
|
||||
}
|
||||
|
||||
public RecordNode(Node node)
|
||||
{
|
||||
super(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void defineType()
|
||||
{
|
||||
setIsFile(true);
|
||||
setIsCategory(false);
|
||||
setIsRecordFolder(false);
|
||||
}
|
||||
protected Boolean isCompleted;
|
||||
protected ContentInfo content;
|
||||
|
||||
public Boolean getIsCompleted()
|
||||
{
|
||||
@@ -73,4 +52,14 @@ public class RecordNode extends FileplanComponentNode
|
||||
{
|
||||
this.isCompleted = isCompleted;
|
||||
}
|
||||
|
||||
public ContentInfo getContent()
|
||||
{
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(ContentInfo content)
|
||||
{
|
||||
this.content = content;
|
||||
}
|
||||
}
|
@@ -27,41 +27,20 @@
|
||||
|
||||
package org.alfresco.rm.rest.api.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.rest.api.model.Node;
|
||||
import org.alfresco.rest.api.model.UserInfo;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Concrete class carrying specific information for a category
|
||||
*
|
||||
* @author Ana Bozianu
|
||||
* Concrete class carrying general information for an record category
|
||||
*
|
||||
* @author Ramona Popa
|
||||
* @since 2.6
|
||||
*/
|
||||
public class RecordCategoryNode extends FileplanComponentNode
|
||||
public class RecordCategory extends RMNode
|
||||
{
|
||||
|
||||
protected Boolean hasRetentionSchedule;
|
||||
|
||||
public RecordCategoryNode(NodeRef nodeRef, NodeRef parentNodeRef, Map<QName, Serializable> nodeProps, Map<String, UserInfo> mapUserInfo, ServiceRegistry sr)
|
||||
public RecordCategory()
|
||||
{
|
||||
super(nodeRef, parentNodeRef, nodeProps, mapUserInfo, sr);
|
||||
}
|
||||
|
||||
public RecordCategoryNode(Node node)
|
||||
{
|
||||
super(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void defineType()
|
||||
{
|
||||
setIsCategory(true);
|
||||
setIsRecordFolder(false);
|
||||
setIsFile(false);
|
||||
super();
|
||||
}
|
||||
|
||||
public Boolean getHasRetentionSchedule()
|
||||
@@ -73,4 +52,5 @@ public class RecordCategoryNode extends FileplanComponentNode
|
||||
{
|
||||
this.hasRetentionSchedule = hasRetentionSchedule;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.model;
|
||||
|
||||
/**
|
||||
* Concrete class carrying information for a record category child.
|
||||
*
|
||||
* @author Silviu Dinuta
|
||||
* @since 2.6
|
||||
*/
|
||||
public class RecordCategoryChild extends RMNode
|
||||
{
|
||||
public static final String PARAM_IS_RECORD_FOLDER = "isRecordFolder";
|
||||
public static final String PARAM_IS_RECORD_CATEGORY = "isRecordCategory";
|
||||
public static final String PARAM_IS_CLOSED = "isClosed";
|
||||
public static final String PARAM_HAS_RETENTION_SCHEDULE = "hasRetentionSchedule";
|
||||
|
||||
private Boolean isRecordCategory;
|
||||
private Boolean isRecordFolder;
|
||||
private Boolean hasRetentionSchedule;
|
||||
private String relativePath;
|
||||
private Boolean isClosed;
|
||||
|
||||
public RecordCategoryChild()
|
||||
{
|
||||
}
|
||||
|
||||
public Boolean getIsRecordCategory()
|
||||
{
|
||||
return isRecordCategory;
|
||||
}
|
||||
|
||||
public void setIsRecordCategory(Boolean isRecordCategory)
|
||||
{
|
||||
this.isRecordCategory = isRecordCategory;
|
||||
}
|
||||
|
||||
public Boolean getIsRecordFolder()
|
||||
{
|
||||
return isRecordFolder;
|
||||
}
|
||||
|
||||
public void setIsRecordFolder(Boolean isRecordFolder)
|
||||
{
|
||||
this.isRecordFolder = isRecordFolder;
|
||||
}
|
||||
|
||||
public Boolean getHasRetentionSchedule()
|
||||
{
|
||||
return hasRetentionSchedule;
|
||||
}
|
||||
|
||||
public void setHasRetentionSchedule(Boolean hasRetentionSchedule)
|
||||
{
|
||||
this.hasRetentionSchedule = hasRetentionSchedule;
|
||||
}
|
||||
|
||||
public String getRelativePath()
|
||||
{
|
||||
return relativePath;
|
||||
}
|
||||
|
||||
public void setRelativePath(String relativePath)
|
||||
{
|
||||
this.relativePath = relativePath;
|
||||
}
|
||||
|
||||
public Boolean getIsClosed()
|
||||
{
|
||||
return isClosed;
|
||||
}
|
||||
|
||||
public void setIsClosed(Boolean isClosed)
|
||||
{
|
||||
this.isClosed = isClosed;
|
||||
}
|
||||
}
|
@@ -27,41 +27,21 @@
|
||||
|
||||
package org.alfresco.rm.rest.api.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.rest.api.model.Node;
|
||||
import org.alfresco.rest.api.model.UserInfo;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Concrete class carrying specific information for a record folder
|
||||
*
|
||||
* @author Ana Bozianu
|
||||
* Concrete class carrying general information for a record folder
|
||||
*
|
||||
* @author Ramona Popa
|
||||
* @since 2.6
|
||||
*/
|
||||
public class RecordFolderNode extends FileplanComponentNode
|
||||
public class RecordFolder extends RMNode
|
||||
{
|
||||
public static final String PARAM_IS_CLOSED = "isClosed";
|
||||
|
||||
private Boolean isClosed;
|
||||
|
||||
public RecordFolderNode(NodeRef nodeRef, NodeRef parentNodeRef, Map<QName, Serializable> nodeProps, Map<String, UserInfo> mapUserInfo, ServiceRegistry sr)
|
||||
public RecordFolder()
|
||||
{
|
||||
super(nodeRef, parentNodeRef, nodeProps, mapUserInfo, sr);
|
||||
}
|
||||
|
||||
public RecordFolderNode(Node node)
|
||||
{
|
||||
super(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void defineType()
|
||||
{
|
||||
setIsRecordFolder(true);
|
||||
setIsCategory(false);
|
||||
setIsFile(false);
|
||||
super();
|
||||
}
|
||||
|
||||
public Boolean getIsClosed()
|
||||
@@ -73,4 +53,5 @@ public class RecordFolderNode extends FileplanComponentNode
|
||||
{
|
||||
this.isClosed = isClosed;
|
||||
}
|
||||
|
||||
}
|
@@ -1,117 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.model;
|
||||
|
||||
import org.alfresco.service.cmr.site.SiteVisibility;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* TODO Just copied this from latest core version, to be removed when we'll upgrade from 5.2.a-EA
|
||||
*
|
||||
* Class representing a site update API operation.
|
||||
*
|
||||
* @author Matt Ward
|
||||
* @since 5.2
|
||||
*/
|
||||
public class SiteUpdate implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private String title;
|
||||
private String description;
|
||||
private SiteVisibility visibility;
|
||||
|
||||
public SiteUpdate(String title, String description, SiteVisibility visibility)
|
||||
{
|
||||
this.title = title;
|
||||
this.description = description;
|
||||
this.visibility = visibility;
|
||||
}
|
||||
|
||||
public String getTitle()
|
||||
{
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title)
|
||||
{
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description)
|
||||
{
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public SiteVisibility getVisibility()
|
||||
{
|
||||
return visibility;
|
||||
}
|
||||
|
||||
public void setVisibility(SiteVisibility visibility)
|
||||
{
|
||||
this.visibility = visibility;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
SiteUpdate that = (SiteUpdate) o;
|
||||
|
||||
if (title != null ? !title.equals(that.title) : that.title != null) return false;
|
||||
if (description != null ? !description.equals(that.description) : that.description != null) return false;
|
||||
return visibility == that.visibility;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
int result = title != null ? title.hashCode() : 0;
|
||||
result = 31 * result + (description != null ? description.hashCode() : 0);
|
||||
result = 31 * result + (visibility != null ? visibility.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "SiteUpdate{" +
|
||||
"title='" + title + '\'' +
|
||||
", description='" + description + '\'' +
|
||||
", visibility=" + visibility +
|
||||
'}';
|
||||
}
|
||||
}
|
@@ -36,7 +36,6 @@ package org.alfresco.rm.rest.api.model;
|
||||
public class TargetContainer
|
||||
{
|
||||
String targetParentId;
|
||||
String relativePath;
|
||||
|
||||
public TargetContainer()
|
||||
{
|
||||
@@ -52,22 +51,11 @@ public class TargetContainer
|
||||
this.targetParentId = targetParentId;
|
||||
}
|
||||
|
||||
public String getRelativePath()
|
||||
{
|
||||
return relativePath;
|
||||
}
|
||||
|
||||
public void setRelativePath(String relativePath)
|
||||
{
|
||||
this.relativePath = relativePath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
final StringBuilder sb = new StringBuilder("NodeTarget{");
|
||||
final StringBuilder sb = new StringBuilder("TargetContainer{");
|
||||
sb.append("targetParentId=").append(targetParentId);
|
||||
sb.append(", relativePath='").append(relativePath).append('\'');
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
|
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.model;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.rest.api.model.UserInfo;
|
||||
import org.alfresco.rest.framework.resource.UniqueId;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* POJO object carrying information of a transfer node
|
||||
*
|
||||
* @author Silviu Dinuta
|
||||
* @since 2.6
|
||||
*
|
||||
*/
|
||||
public class Transfer
|
||||
{
|
||||
public static final String PARAM_TRANSFER_ACCESSION_INDICATOR = "transferAccessionIndicator";
|
||||
public static final String PARAM_TRANSFER_LOCATION = "transferLocation";
|
||||
public static final String PARAM_TRANSFER_PDF_INDICATOR = "transferPDFIndicator";
|
||||
|
||||
protected NodeRef nodeRef;
|
||||
protected NodeRef parentNodeRef;
|
||||
protected String name;
|
||||
protected String nodeType;
|
||||
|
||||
protected Date createdAt;
|
||||
protected UserInfo createdByUser;
|
||||
// optional properties
|
||||
protected List<String> aspectNames;
|
||||
protected Map<String, Object> properties;
|
||||
protected List<String> allowableOperations;
|
||||
private Boolean transferPDFIndicator;
|
||||
private String transferLocation;
|
||||
private Boolean transferAccessionIndicator;
|
||||
|
||||
public Transfer()
|
||||
{
|
||||
}
|
||||
|
||||
@UniqueId
|
||||
public NodeRef getNodeRef()
|
||||
{
|
||||
return nodeRef;
|
||||
}
|
||||
|
||||
public void setNodeRef(NodeRef nodeRef)
|
||||
{
|
||||
this.nodeRef = nodeRef;
|
||||
}
|
||||
|
||||
public NodeRef getParentId()
|
||||
{
|
||||
return parentNodeRef;
|
||||
}
|
||||
|
||||
public void setParentId(NodeRef parentNodeRef)
|
||||
{
|
||||
this.parentNodeRef = parentNodeRef;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getNodeType()
|
||||
{
|
||||
return nodeType;
|
||||
}
|
||||
|
||||
public void setNodeType(String nodeType)
|
||||
{
|
||||
this.nodeType = nodeType;
|
||||
}
|
||||
|
||||
public Date getCreatedAt()
|
||||
{
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Date createdAt)
|
||||
{
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public UserInfo getCreatedByUser()
|
||||
{
|
||||
return createdByUser;
|
||||
}
|
||||
|
||||
public void setCreatedByUser(UserInfo createdByUser)
|
||||
{
|
||||
this.createdByUser = createdByUser;
|
||||
}
|
||||
|
||||
public List<String> getAspectNames()
|
||||
{
|
||||
return aspectNames;
|
||||
}
|
||||
|
||||
public void setAspectNames(List<String> aspectNames)
|
||||
{
|
||||
this.aspectNames = aspectNames;
|
||||
}
|
||||
|
||||
public Map<String, Object> getProperties()
|
||||
{
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(Map<String, Object> properties)
|
||||
{
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public List<String> getAllowableOperations()
|
||||
{
|
||||
return allowableOperations;
|
||||
}
|
||||
|
||||
public void setAllowableOperations(List<String> allowableOperations)
|
||||
{
|
||||
this.allowableOperations = allowableOperations;
|
||||
}
|
||||
|
||||
public Boolean getTransferPDFIndicator()
|
||||
{
|
||||
return transferPDFIndicator;
|
||||
}
|
||||
|
||||
public void setTransferPDFIndicator(Boolean transferPDFIndicator)
|
||||
{
|
||||
this.transferPDFIndicator = transferPDFIndicator;
|
||||
}
|
||||
|
||||
public String getTransferLocation()
|
||||
{
|
||||
return transferLocation;
|
||||
}
|
||||
|
||||
public void setTransferLocation(String transferLocation)
|
||||
{
|
||||
this.transferLocation = transferLocation;
|
||||
}
|
||||
|
||||
public Boolean getTransferAccessionIndicator()
|
||||
{
|
||||
return transferAccessionIndicator;
|
||||
}
|
||||
|
||||
public void setTransferAccessionIndicator(Boolean transferAccessionIndicator)
|
||||
{
|
||||
this.transferAccessionIndicator = transferAccessionIndicator;
|
||||
}
|
||||
}
|
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.model;
|
||||
|
||||
/**
|
||||
* POJO object carrying information of a transfer child
|
||||
*
|
||||
* @author Silviu Dinuta
|
||||
* @since 2.6
|
||||
*/
|
||||
public class TransferChild extends RMNode
|
||||
{
|
||||
public static final String PARAM_IS_COMPLETED = "isCompleted";
|
||||
public static final String PARAM_IS_RECORD_FOLDER = "isRecordFolder";
|
||||
public static final String PARAM_IS_RECORD = "isRecord";
|
||||
|
||||
protected Boolean isCompleted;
|
||||
protected Boolean isClosed;
|
||||
protected Boolean isRecordFolder;
|
||||
protected Boolean isRecord;
|
||||
|
||||
public TransferChild()
|
||||
{
|
||||
}
|
||||
|
||||
public Boolean getIsCompleted()
|
||||
{
|
||||
return isCompleted;
|
||||
}
|
||||
|
||||
public void setIsCompleted(Boolean isCompleted)
|
||||
{
|
||||
this.isCompleted = isCompleted;
|
||||
}
|
||||
|
||||
public Boolean getIsClosed()
|
||||
{
|
||||
return isClosed;
|
||||
}
|
||||
|
||||
public void setIsClosed(Boolean isClosed)
|
||||
{
|
||||
this.isClosed = isClosed;
|
||||
}
|
||||
|
||||
public Boolean getIsRecordFolder()
|
||||
{
|
||||
return isRecordFolder;
|
||||
}
|
||||
|
||||
public void setIsRecordFolder(Boolean isRecordFolder)
|
||||
{
|
||||
this.isRecordFolder = isRecordFolder;
|
||||
}
|
||||
|
||||
public Boolean getIsRecord()
|
||||
{
|
||||
return isRecord;
|
||||
}
|
||||
|
||||
public void setIsRecord(Boolean isRecord)
|
||||
{
|
||||
this.isRecord = isRecord;
|
||||
}
|
||||
}
|
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.model;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.rest.api.model.UserInfo;
|
||||
import org.alfresco.rest.framework.resource.UniqueId;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Silviu Dinuta
|
||||
* @since 2.6
|
||||
*/
|
||||
public class TransferContainer
|
||||
{
|
||||
protected NodeRef nodeRef;
|
||||
protected NodeRef parentNodeRef;
|
||||
protected String name;
|
||||
protected String nodeType;
|
||||
|
||||
protected Date createdAt;
|
||||
protected UserInfo createdByUser;
|
||||
protected Date modifiedAt;
|
||||
protected UserInfo modifiedByUser;
|
||||
// optional properties
|
||||
protected List<String> aspectNames;
|
||||
protected Map<String, Object> properties;
|
||||
protected List<String> allowableOperations;
|
||||
|
||||
public TransferContainer()
|
||||
{
|
||||
}
|
||||
|
||||
@UniqueId
|
||||
public NodeRef getNodeRef()
|
||||
{
|
||||
return nodeRef;
|
||||
}
|
||||
|
||||
public void setNodeRef(NodeRef nodeRef)
|
||||
{
|
||||
this.nodeRef = nodeRef;
|
||||
}
|
||||
|
||||
public NodeRef getParentId()
|
||||
{
|
||||
return parentNodeRef;
|
||||
}
|
||||
|
||||
public void setParentId(NodeRef parentNodeRef)
|
||||
{
|
||||
this.parentNodeRef = parentNodeRef;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getNodeType()
|
||||
{
|
||||
return nodeType;
|
||||
}
|
||||
|
||||
public void setNodeType(String nodeType)
|
||||
{
|
||||
this.nodeType = nodeType;
|
||||
}
|
||||
|
||||
public Date getCreatedAt()
|
||||
{
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Date createdAt)
|
||||
{
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public Date getModifiedAt()
|
||||
{
|
||||
return modifiedAt;
|
||||
}
|
||||
|
||||
public void setModifiedAt(Date modifiedAt)
|
||||
{
|
||||
this.modifiedAt = modifiedAt;
|
||||
}
|
||||
|
||||
public UserInfo getCreatedByUser()
|
||||
{
|
||||
return createdByUser;
|
||||
}
|
||||
|
||||
public void setCreatedByUser(UserInfo createdByUser)
|
||||
{
|
||||
this.createdByUser = createdByUser;
|
||||
}
|
||||
|
||||
public UserInfo getModifiedByUser()
|
||||
{
|
||||
return modifiedByUser;
|
||||
}
|
||||
|
||||
public void setModifiedByUser(UserInfo modifiedByUser)
|
||||
{
|
||||
this.modifiedByUser = modifiedByUser;
|
||||
}
|
||||
|
||||
public List<String> getAspectNames()
|
||||
{
|
||||
return aspectNames;
|
||||
}
|
||||
|
||||
public void setAspectNames(List<String> aspectNames)
|
||||
{
|
||||
this.aspectNames = aspectNames;
|
||||
}
|
||||
|
||||
public Map<String, Object> getProperties()
|
||||
{
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(Map<String, Object> properties)
|
||||
{
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public List<String> getAllowableOperations()
|
||||
{
|
||||
return allowableOperations;
|
||||
}
|
||||
|
||||
public void setAllowableOperations(List<String> allowableOperations)
|
||||
{
|
||||
this.allowableOperations = allowableOperations;
|
||||
}
|
||||
}
|
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
/**
|
||||
* Abstract class carrying information for an unfiled container or unfiled record folder child
|
||||
*
|
||||
* @author Ana Bozianu
|
||||
* @since 2.6
|
||||
*/
|
||||
public abstract class UnfiledChild extends RMNode
|
||||
{
|
||||
public static final String PARAM_IS_UNFILED_RECORD_FOLDER = "isUnfiledRecordFolder";
|
||||
public static final String PARAM_IS_RECORD = "isRecord";
|
||||
|
||||
protected Boolean isUnfiledRecordFolder;
|
||||
protected Boolean isRecord;
|
||||
|
||||
public Boolean getIsUnfiledRecordFolder()
|
||||
{
|
||||
return isUnfiledRecordFolder;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setIsUnfiledRecordFolder(Boolean isUnfiledRecordFolder)
|
||||
{
|
||||
this.isUnfiledRecordFolder = isUnfiledRecordFolder;
|
||||
}
|
||||
|
||||
public Boolean getIsRecord()
|
||||
{
|
||||
return isRecord;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public void setIsRecord(Boolean isRecord)
|
||||
{
|
||||
this.isRecord = isRecord;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.model;
|
||||
|
||||
/**
|
||||
* Concrete class carrying general information for an unfiled container
|
||||
*
|
||||
* @author Ana Bozianu
|
||||
* @since 2.6
|
||||
*/
|
||||
public class UnfiledContainer extends RMNode
|
||||
{
|
||||
public UnfiledContainer()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.rm.rest.api.model;
|
||||
|
||||
/**
|
||||
* Specific POJO object carrying information for an unfiled container child
|
||||
*
|
||||
* @author Ana Bozianu
|
||||
* @since 2.6
|
||||
*/
|
||||
public class UnfiledContainerChild extends UnfiledChild
|
||||
{
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.model;
|
||||
|
||||
/**
|
||||
* Concrete class carrying specific information for an unfiled record folder
|
||||
*
|
||||
* @author Ramona Popa
|
||||
* @since 2.6
|
||||
*/
|
||||
public class UnfiledRecordFolder extends RMNode
|
||||
{
|
||||
public UnfiledRecordFolder()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.rm.rest.api.model;
|
||||
|
||||
/**
|
||||
* Specific POJO object carrying information for an unfiled record folder child
|
||||
*
|
||||
* @author Ana Bozianu
|
||||
* @since 2.6
|
||||
*/
|
||||
public class UnfiledRecordFolderChild extends UnfiledChild
|
||||
{
|
||||
protected String relativePath;
|
||||
|
||||
public UnfiledRecordFolderChild()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public void setRelativePath(String relativePath)
|
||||
{
|
||||
this.relativePath = relativePath;
|
||||
}
|
||||
|
||||
public String getRelativePath()
|
||||
{
|
||||
return relativePath;
|
||||
}
|
||||
}
|
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.rm.rest.api.model;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.extensions.surf.util.Content;
|
||||
import org.springframework.extensions.webscripts.servlet.FormData;
|
||||
|
||||
/**
|
||||
* Encapsulates the elements of an upload request
|
||||
*
|
||||
* @author Ana Bozianu
|
||||
* @since 2.6
|
||||
*/
|
||||
public class UploadInfo
|
||||
{
|
||||
private String fileName;
|
||||
private String nodeType;
|
||||
private String relativePath;
|
||||
private Content content;
|
||||
private Map<String, Object> properties;
|
||||
|
||||
public UploadInfo(FormData formData)
|
||||
{
|
||||
for (FormData.FormField field : formData.getFields())
|
||||
{
|
||||
switch (field.getName().toLowerCase())
|
||||
{
|
||||
case "name":
|
||||
fileName = getStringOrNull(field.getValue());
|
||||
break;
|
||||
case "nodetype":
|
||||
nodeType = getStringOrNull(field.getValue());
|
||||
break;
|
||||
case "relativepath":
|
||||
relativePath = getStringOrNull(field.getValue());
|
||||
break;
|
||||
case "filedata":
|
||||
if (field.getIsFile())
|
||||
{
|
||||
fileName = (fileName != null ? fileName : field.getFilename());
|
||||
content = field.getContent();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
final String propName = field.getName();
|
||||
if (propName.indexOf(QName.NAMESPACE_PREFIX) > -1)
|
||||
{
|
||||
properties.put(propName, field.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(fileName) || content == null)
|
||||
{
|
||||
throw new InvalidArgumentException("Required parameters are missing");
|
||||
}
|
||||
}
|
||||
|
||||
private String getStringOrNull(String value)
|
||||
{
|
||||
if (StringUtils.isNotEmpty(value))
|
||||
{
|
||||
return value.equalsIgnoreCase("null") ? null : value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getFileName()
|
||||
{
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public String getNodeType()
|
||||
{
|
||||
return nodeType;
|
||||
}
|
||||
|
||||
public String getRelativePath()
|
||||
{
|
||||
return relativePath;
|
||||
}
|
||||
|
||||
public Content getContent()
|
||||
{
|
||||
return content;
|
||||
}
|
||||
|
||||
public Map<String, Object> getProperties()
|
||||
{
|
||||
return properties;
|
||||
}
|
||||
}
|
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.recordcategories;
|
||||
|
||||
import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.checkNotBlank;
|
||||
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.rest.api.Nodes;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.WebApiParam;
|
||||
import org.alfresco.rest.framework.resource.EntityResource;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rm.rest.api.impl.ApiNodesModelFactory;
|
||||
import org.alfresco.rm.rest.api.impl.FilePlanComponentsApiUtils;
|
||||
import org.alfresco.rm.rest.api.model.RecordCategory;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
/**
|
||||
* Record category entity resource
|
||||
*
|
||||
* @author Ana Bozianu
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.6
|
||||
*/
|
||||
@EntityResource(name="record-categories", title = "Record Categories")
|
||||
public class RecordCategoriesEntityResource implements
|
||||
EntityResourceAction.ReadById<RecordCategory>,
|
||||
EntityResourceAction.Delete,
|
||||
EntityResourceAction.Update<RecordCategory>,
|
||||
InitializingBean
|
||||
{
|
||||
private FilePlanComponentsApiUtils apiUtils;
|
||||
private FileFolderService fileFolderService;
|
||||
private ApiNodesModelFactory nodesModelFactory;
|
||||
|
||||
public void setApiUtils(FilePlanComponentsApiUtils apiUtils)
|
||||
{
|
||||
this.apiUtils = apiUtils;
|
||||
}
|
||||
|
||||
public void setFileFolderService(FileFolderService fileFolderService)
|
||||
{
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
public void setNodesModelFactory(ApiNodesModelFactory nodesModelFactory)
|
||||
{
|
||||
this.nodesModelFactory = nodesModelFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
mandatory("apiUtils", apiUtils);
|
||||
mandatory("fileFolderService", fileFolderService);
|
||||
mandatory("apiNodesModelFactory", nodesModelFactory);
|
||||
}
|
||||
|
||||
@WebApiDescription(title = "Get record category information", description = "Gets information for a record category with id 'recordCategoryId'")
|
||||
@WebApiParam(name = "recordCategoryId", title = "The record category id")
|
||||
public RecordCategory readById(String recordCategoryId, Parameters parameters)
|
||||
{
|
||||
checkNotBlank("recordCategoryId", recordCategoryId);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
String relativePath = parameters.getParameter(Nodes.PARAM_RELATIVE_PATH);
|
||||
|
||||
NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(recordCategoryId, RecordsManagementModel.TYPE_RECORD_CATEGORY, relativePath, true);
|
||||
|
||||
FileInfo info = fileFolderService.getFileInfo(nodeRef);
|
||||
|
||||
return nodesModelFactory.createRecordCategory(info, parameters, null, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title="Update record category", description = "Updates a record category with id 'recordCategoryId'")
|
||||
public RecordCategory update(String recordCategoryId, RecordCategory recordCategoryInfo, Parameters parameters)
|
||||
{
|
||||
checkNotBlank("recordCategoryId", recordCategoryId);
|
||||
mandatory("recordCategoryInfo", recordCategoryInfo);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(recordCategoryId, RecordsManagementModel.TYPE_RECORD_CATEGORY);
|
||||
apiUtils.updateNode(nodeRef, recordCategoryInfo, parameters);
|
||||
|
||||
FileInfo info = fileFolderService.getFileInfo(nodeRef);
|
||||
return nodesModelFactory.createRecordCategory(info, parameters, null, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Delete record category", description="Deletes a record category with id 'recordCategoryId'")
|
||||
public void delete(String recordCategoryId, Parameters parameters)
|
||||
{
|
||||
checkNotBlank("recordCategoryId", recordCategoryId);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(recordCategoryId, RecordsManagementModel.TYPE_RECORD_CATEGORY);
|
||||
|
||||
fileFolderService.delete(nodeRef);
|
||||
}
|
||||
}
|
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.recordcategories;
|
||||
|
||||
import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.checkNotBlank;
|
||||
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
|
||||
import java.util.AbstractList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.repo.node.getchildren.FilterProp;
|
||||
import org.alfresco.rest.api.Nodes;
|
||||
import org.alfresco.rest.api.impl.Util;
|
||||
import org.alfresco.rest.api.model.UserInfo;
|
||||
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.rm.rest.api.impl.ApiNodesModelFactory;
|
||||
import org.alfresco.rm.rest.api.impl.FilePlanComponentsApiUtils;
|
||||
import org.alfresco.rm.rest.api.impl.SearchTypesFactory;
|
||||
import org.alfresco.rm.rest.api.model.RMNode;
|
||||
import org.alfresco.rm.rest.api.model.RecordCategory;
|
||||
import org.alfresco.rm.rest.api.model.RecordCategoryChild;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* Record category children relation
|
||||
*
|
||||
* @author Ana Bozianu
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.6
|
||||
*/
|
||||
@RelationshipResource(name="children", entityResource = RecordCategoriesEntityResource.class, title = "Children of a record category")
|
||||
public class RecordCategoryChildrenRelation implements RelationshipResourceAction.Read<RecordCategoryChild>,
|
||||
RelationshipResourceAction.Create<RecordCategoryChild>
|
||||
{
|
||||
private final static Set<String> LIST_RECORD_CATEGORY_CHILDREN_EQUALS_QUERY_PROPERTIES = new HashSet<>(Arrays
|
||||
.asList(new String[] { RecordCategoryChild.PARAM_IS_RECORD_CATEGORY, RecordCategoryChild.PARAM_IS_RECORD_FOLDER,
|
||||
RecordCategoryChild.PARAM_IS_CLOSED, RecordCategoryChild.PARAM_HAS_RETENTION_SCHEDULE, RMNode.PARAM_NODE_TYPE }));
|
||||
|
||||
private FilePlanComponentsApiUtils apiUtils;
|
||||
private SearchTypesFactory searchTypesFactory;
|
||||
private FileFolderService fileFolderService;
|
||||
private ApiNodesModelFactory nodesModelFactory;
|
||||
|
||||
public void setApiUtils(FilePlanComponentsApiUtils apiUtils)
|
||||
{
|
||||
this.apiUtils = apiUtils;
|
||||
}
|
||||
|
||||
public void setSearchTypesFactory(SearchTypesFactory searchTypesFactory)
|
||||
{
|
||||
this.searchTypesFactory = searchTypesFactory;
|
||||
}
|
||||
|
||||
public void setFileFolderService(FileFolderService fileFolderService)
|
||||
{
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
public void setNodesModelFactory(ApiNodesModelFactory nodesModelFactory)
|
||||
{
|
||||
this.nodesModelFactory = nodesModelFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Return a paged list of record category children for the container identified by 'recordCategoryId'")
|
||||
public CollectionWithPagingInfo<RecordCategoryChild> readAll(String recordCategoryId, Parameters parameters)
|
||||
{
|
||||
checkNotBlank("recordCategoryId", recordCategoryId);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
String relativePath = parameters.getParameter(Nodes.PARAM_RELATIVE_PATH);
|
||||
NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(recordCategoryId, RecordsManagementModel.TYPE_RECORD_CATEGORY, relativePath, true);
|
||||
|
||||
// list record categories and record folders
|
||||
Set<QName> searchTypeQNames = searchTypesFactory.buildSearchTypesCategoriesEndpoint(parameters, LIST_RECORD_CATEGORY_CHILDREN_EQUALS_QUERY_PROPERTIES);
|
||||
List<FilterProp> filterProps = apiUtils.getListChildrenFilterProps(parameters, LIST_RECORD_CATEGORY_CHILDREN_EQUALS_QUERY_PROPERTIES);
|
||||
|
||||
final PagingResults<FileInfo> pagingResults = fileFolderService.list(parentNodeRef,
|
||||
null,
|
||||
searchTypeQNames,
|
||||
null,
|
||||
apiUtils.getSortProperties(parameters),
|
||||
filterProps,
|
||||
Util.getPagingRequest(parameters.getPaging()));
|
||||
|
||||
final List<FileInfo> page = pagingResults.getPage();
|
||||
Map<String, UserInfo> mapUserInfo = new HashMap<>();
|
||||
List<RecordCategoryChild> nodes = new AbstractList<RecordCategoryChild>()
|
||||
{
|
||||
@Override
|
||||
public RecordCategoryChild get(int index)
|
||||
{
|
||||
FileInfo info = page.get(index);
|
||||
return nodesModelFactory.createRecordCategoryChild(info, parameters, mapUserInfo, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size()
|
||||
{
|
||||
return page.size();
|
||||
}
|
||||
};
|
||||
|
||||
RecordCategory sourceEntity = null;
|
||||
if (parameters.includeSource())
|
||||
{
|
||||
FileInfo info = fileFolderService.getFileInfo(parentNodeRef);
|
||||
sourceEntity = nodesModelFactory.createRecordCategory(info, parameters, mapUserInfo, true);
|
||||
}
|
||||
|
||||
return CollectionWithPagingInfo.asPaged(parameters.getPaging(), nodes, pagingResults.hasMoreItems(), pagingResults.getTotalResultCount().getFirst(), sourceEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title="Create one (or more) nodes as children of a record category identified by 'recordCategoryId'")
|
||||
public List<RecordCategoryChild> create(String recordCategoryId, List<RecordCategoryChild> nodeInfos, Parameters parameters)
|
||||
{
|
||||
checkNotBlank("recordCategoryId", recordCategoryId);
|
||||
mandatory("nodeInfos", nodeInfos);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(recordCategoryId, RecordsManagementModel.TYPE_RECORD_CATEGORY);
|
||||
|
||||
List<RecordCategoryChild> result = new ArrayList<>(nodeInfos.size());
|
||||
Map<String, UserInfo> mapUserInfo = new HashMap<>();
|
||||
for (RecordCategoryChild nodeInfo : nodeInfos)
|
||||
{
|
||||
// Resolve the parent node
|
||||
NodeRef nodeParent = parentNodeRef;
|
||||
if(StringUtils.isNoneBlank(nodeInfo.getRelativePath()))
|
||||
{
|
||||
nodeParent = apiUtils.lookupAndValidateRelativePath(parentNodeRef, nodeInfo.getRelativePath(), RecordsManagementModel.TYPE_RECORD_CATEGORY);
|
||||
}
|
||||
|
||||
// Create the node
|
||||
NodeRef newNode = apiUtils.createRMNode(nodeParent, nodeInfo.getName(), nodeInfo.getNodeType(), nodeInfo.getProperties(), nodeInfo.getAspectNames());
|
||||
FileInfo info = fileFolderService.getFileInfo(newNode);
|
||||
result.add(nodesModelFactory.createRecordCategoryChild(info, parameters, mapUserInfo, false));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -26,12 +26,12 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Package info that defines the Information Governance Fileplan Components REST API
|
||||
*
|
||||
* Package info that defines the Information Governance Record Categories REST API
|
||||
*
|
||||
* @author Ana Bozianu
|
||||
* @since 2.6
|
||||
*/
|
||||
@WebApi(name="ig", scope=Api.SCOPE.PUBLIC, version=1)
|
||||
package org.alfresco.rm.rest.api.fileplancomponents;
|
||||
@WebApi(name="gs", scope=Api.SCOPE.PUBLIC, version=1)
|
||||
package org.alfresco.rm.rest.api.recordcategories;
|
||||
import org.alfresco.rest.framework.Api;
|
||||
import org.alfresco.rest.framework.WebApi;
|
@@ -0,0 +1,223 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.recordfolders;
|
||||
|
||||
import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.checkNotBlank;
|
||||
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
|
||||
import java.util.AbstractList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.repo.activities.ActivityType;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.rest.api.impl.Util;
|
||||
import org.alfresco.rest.api.model.UserInfo;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.WebApiParam;
|
||||
import org.alfresco.rest.framework.resource.RelationshipResource;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.MultiPartRelationshipResourceAction;
|
||||
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.rest.framework.webscripts.WithResponse;
|
||||
import org.alfresco.rm.rest.api.impl.ApiNodesModelFactory;
|
||||
import org.alfresco.rm.rest.api.impl.FilePlanComponentsApiUtils;
|
||||
import org.alfresco.rm.rest.api.impl.SearchTypesFactory;
|
||||
import org.alfresco.rm.rest.api.model.Record;
|
||||
import org.alfresco.rm.rest.api.model.RecordFolder;
|
||||
import org.alfresco.rm.rest.api.model.UnfiledContainerChild;
|
||||
import org.alfresco.rm.rest.api.model.UploadInfo;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.springframework.extensions.webscripts.servlet.FormData;
|
||||
|
||||
/**
|
||||
* Record folder children relation
|
||||
*
|
||||
* @author Ramona Popa
|
||||
* @since 2.6
|
||||
*/
|
||||
@RelationshipResource(name = "records", entityResource = RecordFolderEntityResource.class, title = "Children of a record folder")
|
||||
public class RecordFolderChildrenRelation implements RelationshipResourceAction.Read<Record>, RelationshipResourceAction.Create<Record>,
|
||||
MultiPartRelationshipResourceAction.Create<Record>
|
||||
{
|
||||
private FilePlanComponentsApiUtils apiUtils;
|
||||
private SearchTypesFactory searchTypesFactory;
|
||||
private FileFolderService fileFolderService;
|
||||
private ApiNodesModelFactory nodesModelFactory;
|
||||
private TransactionService transactionService;
|
||||
|
||||
public void setApiUtils(FilePlanComponentsApiUtils apiUtils)
|
||||
{
|
||||
this.apiUtils = apiUtils;
|
||||
}
|
||||
|
||||
public void setSearchTypesFactory(SearchTypesFactory searchTypesFactory)
|
||||
{
|
||||
this.searchTypesFactory = searchTypesFactory;
|
||||
}
|
||||
|
||||
public void setFileFolderService(FileFolderService fileFolderService)
|
||||
{
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
public void setNodesModelFactory(ApiNodesModelFactory nodesModelFactory)
|
||||
{
|
||||
this.nodesModelFactory = nodesModelFactory;
|
||||
}
|
||||
|
||||
public void setTransactionService(TransactionService transactionService)
|
||||
{
|
||||
this.transactionService = transactionService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Return a paged list of records for the record folder identified by 'recordFolderId'")
|
||||
public CollectionWithPagingInfo<Record> readAll(String recordFolderId, Parameters parameters)
|
||||
{
|
||||
checkNotBlank("recordFolderId", recordFolderId);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(recordFolderId, RecordsManagementModel.TYPE_RECORD_FOLDER);
|
||||
|
||||
// list record folders
|
||||
// FIXME searchParam
|
||||
Set<QName> searchTypeQNames = searchTypesFactory.buildSearchTypesForUnfiledEndpoint(parameters, null);
|
||||
|
||||
final PagingResults<FileInfo> pagingResults = fileFolderService.list(parentNodeRef, null, searchTypeQNames, null,
|
||||
apiUtils.getSortProperties(parameters), null, Util.getPagingRequest(parameters.getPaging()));
|
||||
|
||||
final List<FileInfo> page = pagingResults.getPage();
|
||||
Map<String, UserInfo> mapUserInfo = new HashMap<>();
|
||||
List<Record> nodes = new AbstractList<Record>()
|
||||
{
|
||||
@Override
|
||||
public Record get(int index)
|
||||
{
|
||||
FileInfo info = page.get(index);
|
||||
return nodesModelFactory.createRecord(info, parameters, mapUserInfo, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size()
|
||||
{
|
||||
return page.size();
|
||||
}
|
||||
};
|
||||
|
||||
RecordFolder sourceEntity = null;
|
||||
if (parameters.includeSource())
|
||||
{
|
||||
FileInfo info = fileFolderService.getFileInfo(parentNodeRef);
|
||||
sourceEntity = nodesModelFactory.createRecordFolder(info, parameters, mapUserInfo, true);
|
||||
}
|
||||
|
||||
return CollectionWithPagingInfo.asPaged(parameters.getPaging(), nodes, pagingResults.hasMoreItems(),
|
||||
pagingResults.getTotalResultCount().getFirst(), sourceEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Create one (or more) records as children of a record folder identified by 'recordFolderId'")
|
||||
public List<Record> create(String recordFolderId, List<Record> nodeInfos, Parameters parameters)
|
||||
{
|
||||
checkNotBlank("recordFolderId", recordFolderId);
|
||||
mandatory("nodeInfos", nodeInfos);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(recordFolderId, RecordsManagementModel.TYPE_RECORD_FOLDER);
|
||||
|
||||
RetryingTransactionCallback<List<NodeRef>> callback = new RetryingTransactionCallback<List<NodeRef>>()
|
||||
{
|
||||
public List<NodeRef> execute()
|
||||
{
|
||||
List<NodeRef> createdNodes = new LinkedList<>();
|
||||
for (Record nodeInfo : nodeInfos)
|
||||
{
|
||||
NodeRef newNodeRef = apiUtils.createRMNode(parentNodeRef, nodeInfo.getName(), nodeInfo.getNodeType(), nodeInfo.getProperties(), nodeInfo.getAspectNames());
|
||||
createdNodes.add(newNodeRef);
|
||||
}
|
||||
return createdNodes;
|
||||
}
|
||||
};
|
||||
List<NodeRef> createdNodes = transactionService.getRetryingTransactionHelper().doInTransaction(callback);
|
||||
|
||||
// Get the nodes info
|
||||
List<Record> result = new LinkedList<>();
|
||||
Map<String, UserInfo> mapUserInfo = new HashMap<>();
|
||||
for(NodeRef newNodeRef : createdNodes)
|
||||
{
|
||||
FileInfo info = fileFolderService.getFileInfo(newNodeRef);
|
||||
apiUtils.postActivity(info, parentNodeRef, ActivityType.FILE_ADDED);
|
||||
result.add(nodesModelFactory.createRecord(info, parameters, mapUserInfo, false));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Upload file content and meta-data into the repository.")
|
||||
@WebApiParam(name = "formData", title = "A single form data", description = "A single form data which holds FormFields.")
|
||||
public Record create(String recordFolderId, FormData formData, Parameters parameters, WithResponse withResponse)
|
||||
{
|
||||
checkNotBlank("recordFolderId", recordFolderId);
|
||||
mandatory("formData", formData);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
// Retrieve the input data and resolve the parent node
|
||||
final UploadInfo uploadInfo = new UploadInfo(formData);
|
||||
final NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(recordFolderId, RecordsManagementModel.TYPE_RECORD_FOLDER,
|
||||
uploadInfo.getRelativePath());
|
||||
|
||||
// Create the record
|
||||
RetryingTransactionCallback<NodeRef> callback = new RetryingTransactionCallback<NodeRef>()
|
||||
{
|
||||
public NodeRef execute()
|
||||
{
|
||||
return apiUtils.uploadRecord(parentNodeRef, uploadInfo.getFileName(), uploadInfo.getNodeType(), uploadInfo.getProperties(),
|
||||
uploadInfo.getContent().getInputStream());
|
||||
}
|
||||
};
|
||||
NodeRef newNode = transactionService.getRetryingTransactionHelper().doInTransaction(callback);
|
||||
|
||||
// Get file info for response
|
||||
FileInfo info = fileFolderService.getFileInfo(newNode);
|
||||
apiUtils.postActivity(info, parentNodeRef, ActivityType.FILE_ADDED);
|
||||
return nodesModelFactory.createRecord(info, parameters, null, false);
|
||||
}
|
||||
}
|
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.recordfolders;
|
||||
|
||||
import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.checkNotBlank;
|
||||
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.WebApiParam;
|
||||
import org.alfresco.rest.framework.resource.EntityResource;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rm.rest.api.impl.ApiNodesModelFactory;
|
||||
import org.alfresco.rm.rest.api.impl.FilePlanComponentsApiUtils;
|
||||
import org.alfresco.rm.rest.api.model.RecordFolder;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
/**
|
||||
* Record folder entity resource
|
||||
*
|
||||
* @author Ana Bozianu
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.6
|
||||
*/
|
||||
@EntityResource(name = "record-folders", title = "Record Folders")
|
||||
public class RecordFolderEntityResource implements EntityResourceAction.ReadById<RecordFolder>, EntityResourceAction.Delete,
|
||||
EntityResourceAction.Update<RecordFolder>, InitializingBean
|
||||
{
|
||||
|
||||
private FilePlanComponentsApiUtils apiUtils;
|
||||
private FileFolderService fileFolderService;
|
||||
private ApiNodesModelFactory nodesModelFactory;
|
||||
|
||||
public void setApiUtils(FilePlanComponentsApiUtils apiUtils)
|
||||
{
|
||||
this.apiUtils = apiUtils;
|
||||
}
|
||||
|
||||
public void setFileFolderService(FileFolderService fileFolderService)
|
||||
{
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
public void setNodesModelFactory(ApiNodesModelFactory nodesModelFactory)
|
||||
{
|
||||
this.nodesModelFactory = nodesModelFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
mandatory("apiUtils", apiUtils);
|
||||
mandatory("fileFolderService", fileFolderService);
|
||||
mandatory("apiNodesModelFactory", nodesModelFactory);
|
||||
}
|
||||
|
||||
@WebApiDescription(title = "Get record folder information", description = "Gets information for a record folder with id 'recordFolderId'")
|
||||
@WebApiParam(name = "recordFolderId", title = "The record folder id")
|
||||
public RecordFolder readById(String recordFolderId, Parameters parameters)
|
||||
{
|
||||
checkNotBlank("recordFolderId", recordFolderId);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(recordFolderId, RecordsManagementModel.TYPE_RECORD_FOLDER);
|
||||
|
||||
FileInfo info = fileFolderService.getFileInfo(nodeRef);
|
||||
|
||||
return nodesModelFactory.createRecordFolder(info, parameters, null, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Update record folder", description = "Updates a record folder with id 'recordFolderId'")
|
||||
public RecordFolder update(String recordFolderId, RecordFolder recordFolderInfo, Parameters parameters)
|
||||
{
|
||||
checkNotBlank("recordFolderId", recordFolderId);
|
||||
mandatory("recordFolderInfo", recordFolderInfo);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(recordFolderId, RecordsManagementModel.TYPE_RECORD_FOLDER);
|
||||
apiUtils.updateNode(nodeRef, recordFolderInfo, parameters);
|
||||
|
||||
FileInfo info = fileFolderService.getFileInfo(nodeRef);
|
||||
return nodesModelFactory.createRecordFolder(info, parameters, null, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Delete record folder", description = "Deletes a record folder with id 'recordFolderId'")
|
||||
public void delete(String recordFolderId, Parameters parameters)
|
||||
{
|
||||
checkNotBlank("recordFolderId", recordFolderId);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(recordFolderId, RecordsManagementModel.TYPE_RECORD_FOLDER);
|
||||
|
||||
fileFolderService.delete(nodeRef);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
/**
|
||||
* Package info that defines the Information Governance Record Folders REST API
|
||||
*
|
||||
* @author Ana Bozianu
|
||||
* @since 2.6
|
||||
*/
|
||||
@WebApi(name="gs", scope=Api.SCOPE.PUBLIC, version=1)
|
||||
package org.alfresco.rm.rest.api.recordfolders;
|
||||
import org.alfresco.rest.framework.Api;
|
||||
import org.alfresco.rest.framework.WebApi;
|
@@ -27,73 +27,202 @@
|
||||
|
||||
package org.alfresco.rm.rest.api.records;
|
||||
|
||||
import org.alfresco.rest.api.model.Node;
|
||||
import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.checkNotBlank;
|
||||
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||
import org.alfresco.repo.activities.ActivityType;
|
||||
import org.alfresco.repo.node.integrity.IntegrityException;
|
||||
import org.alfresco.rest.framework.BinaryProperties;
|
||||
import org.alfresco.rest.framework.Operation;
|
||||
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.BinaryResource;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rest.framework.webscripts.WithResponse;
|
||||
import org.alfresco.rm.rest.api.RMNodes;
|
||||
import org.alfresco.rm.rest.api.Records;
|
||||
import org.alfresco.rm.rest.api.impl.ApiNodesModelFactory;
|
||||
import org.alfresco.rm.rest.api.impl.FilePlanComponentsApiUtils;
|
||||
import org.alfresco.rm.rest.api.model.Record;
|
||||
import org.alfresco.rm.rest.api.model.TargetContainer;
|
||||
import org.alfresco.service.cmr.activities.ActivityPoster;
|
||||
import org.alfresco.service.cmr.model.FileExistsException;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.model.FileNotFoundException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.dao.ConcurrencyFailureException;
|
||||
|
||||
/**
|
||||
* An implementation of an Entity Resource for a record
|
||||
*
|
||||
* @author Ana Bozianu
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.6
|
||||
*/
|
||||
@EntityResource(name="records", title = "Records")
|
||||
public class RecordsEntityResource implements BinaryResourceAction.Read,
|
||||
EntityResourceAction.ReadById<Record>,
|
||||
EntityResourceAction.Delete,
|
||||
EntityResourceAction.Update<Record>,
|
||||
InitializingBean
|
||||
{
|
||||
|
||||
private RMNodes nodes;
|
||||
private Records records;
|
||||
private ApiNodesModelFactory nodesModelFactory;
|
||||
private FilePlanComponentsApiUtils apiUtils;
|
||||
private FileFolderService fileFolderService;
|
||||
private RecordService recordService;
|
||||
private NodeService nodeService;
|
||||
|
||||
public void setNodes(RMNodes nodes)
|
||||
public void setNodesModelFactory(ApiNodesModelFactory nodesModelFactory)
|
||||
{
|
||||
this.nodes = nodes;
|
||||
this.nodesModelFactory = nodesModelFactory;
|
||||
}
|
||||
|
||||
public void setRecords(Records records)
|
||||
public void setApiUtils(FilePlanComponentsApiUtils apiUtils)
|
||||
{
|
||||
this.records = records;
|
||||
this.apiUtils = apiUtils;
|
||||
}
|
||||
|
||||
public void setRecordService(RecordService recordService)
|
||||
{
|
||||
this.recordService = recordService;
|
||||
}
|
||||
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
public void setFileFolderService(FileFolderService fileFolderService)
|
||||
{
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
/**
|
||||
* Download content
|
||||
*
|
||||
*
|
||||
* @param recordId the id of the record to get the content from
|
||||
* @param parameters {@link Parameters}
|
||||
* @return binary content resource
|
||||
* @throws EntityNotFoundException
|
||||
*/
|
||||
@Override
|
||||
@WebApiDescription(title = "Download content", description = "Download content")
|
||||
@WebApiDescription(title = "Download content", description = "Download content for a record with id 'recordId'")
|
||||
@BinaryProperties({"content"})
|
||||
public BinaryResource readProperty(String recordId, Parameters parameters) throws EntityNotFoundException
|
||||
{
|
||||
return nodes.getContent(recordId, parameters, true);
|
||||
checkNotBlank("recordId", recordId);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
NodeRef record = apiUtils.validateRecord(recordId);
|
||||
if(nodeService.getType(record).equals(RecordsManagementModel.TYPE_NON_ELECTRONIC_DOCUMENT))
|
||||
{
|
||||
throw new IllegalArgumentException("Cannot read content from Non-electronic record " + recordId + ".");
|
||||
}
|
||||
BinaryResource content = apiUtils.getContent(record, parameters, true);
|
||||
NodeRef primaryParent = nodeService.getPrimaryParent(record).getParentRef();
|
||||
FileInfo info = fileFolderService.getFileInfo(record);
|
||||
apiUtils.postActivity(info, primaryParent, ActivityPoster.DOWNLOADED);
|
||||
return content;
|
||||
}
|
||||
|
||||
@Operation("file")
|
||||
@WebApiDescription(title = "File record", description="File a record into fileplan.")
|
||||
public Node fileRecord(String recordId, TargetContainer target, Parameters parameters, WithResponse withResponse)
|
||||
public Record fileRecord(String recordId, TargetContainer target, Parameters parameters, WithResponse withResponse)
|
||||
{
|
||||
return records.fileOrLinkRecord(recordId, target, parameters);
|
||||
checkNotBlank("recordId", recordId);
|
||||
mandatory("target", target);
|
||||
mandatory("targetParentId", target.getTargetParentId());
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
// Get record and target folder
|
||||
NodeRef record = apiUtils.validateRecord(recordId);
|
||||
NodeRef targetRecordFolder = apiUtils.lookupAndValidateNodeType(target.getTargetParentId(), RecordsManagementModel.TYPE_RECORD_FOLDER);
|
||||
|
||||
// Get the current parent type to decide if we link or move the record
|
||||
NodeRef primaryParent = nodeService.getPrimaryParent(record).getParentRef();
|
||||
if(RecordsManagementModel.TYPE_RECORD_FOLDER.equals(nodeService.getType(primaryParent)))
|
||||
{
|
||||
recordService.link(record, targetRecordFolder);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
fileFolderService.moveFrom(record, primaryParent, targetRecordFolder, null);
|
||||
}
|
||||
catch (FileExistsException e)
|
||||
{
|
||||
throw new IntegrityException(e.getMessage(), null);
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
throw new ConcurrencyFailureException("The record was deleted while filing it", e);
|
||||
}
|
||||
}
|
||||
|
||||
// return record state
|
||||
FileInfo info = fileFolderService.getFileInfo(record);
|
||||
return nodesModelFactory.createRecord(info, parameters, null, false);
|
||||
}
|
||||
|
||||
@WebApiDescription(title = "Get record information", description = "Gets information for a record with id 'recordId'")
|
||||
@WebApiParam(name = "recordId", title = "The record id")
|
||||
public Record readById(String recordId, Parameters parameters)
|
||||
{
|
||||
checkNotBlank("recordId", recordId);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
NodeRef record = apiUtils.validateRecord(recordId);
|
||||
FileInfo info = fileFolderService.getFileInfo(record);
|
||||
return nodesModelFactory.createRecord(info, parameters, null, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title="Update record", description = "Updates a record with id 'recordId'")
|
||||
public Record update(String recordId, Record recordInfo, Parameters parameters)
|
||||
{
|
||||
checkNotBlank("recordId", recordId);
|
||||
mandatory("recordInfo", recordInfo);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
// Get record
|
||||
NodeRef record = apiUtils.validateRecord(recordId);
|
||||
|
||||
// update info
|
||||
apiUtils.updateNode(record, recordInfo, parameters);
|
||||
|
||||
// return record state
|
||||
FileInfo info = fileFolderService.getFileInfo(record);
|
||||
apiUtils.postActivity(info, recordInfo.getParentId(), ActivityType.FILE_UPDATED);
|
||||
return nodesModelFactory.createRecord(info, parameters, null, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Delete record", description="Deletes a record with id 'recordId'")
|
||||
public void delete(String recordId, Parameters parameters)
|
||||
{
|
||||
checkNotBlank("recordId", recordId);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
NodeRef record = apiUtils.validateRecord(recordId);
|
||||
fileFolderService.delete(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
ParameterCheck.mandatory("nodes", this.nodes);
|
||||
ParameterCheck.mandatory("records", this.records);
|
||||
ParameterCheck.mandatory("nodesModelFactory", nodesModelFactory);
|
||||
ParameterCheck.mandatory("apiUtils", apiUtils);
|
||||
ParameterCheck.mandatory("fileFolderService", fileFolderService);
|
||||
ParameterCheck.mandatory("recordService", recordService);
|
||||
ParameterCheck.mandatory("nodeService", nodeService);
|
||||
}
|
||||
}
|
||||
|
@@ -27,11 +27,11 @@
|
||||
|
||||
/**
|
||||
* Package info that defines the Information Governance Records REST API
|
||||
*
|
||||
*
|
||||
* @author Ana Bozianu
|
||||
* @since 2.6
|
||||
*/
|
||||
@WebApi(name="ig", scope=Api.SCOPE.PUBLIC, version=1)
|
||||
@WebApi(name="gs", scope=Api.SCOPE.PUBLIC, version=1)
|
||||
package org.alfresco.rm.rest.api.records;
|
||||
import org.alfresco.rest.framework.Api;
|
||||
import org.alfresco.rest.framework.WebApi;
|
@@ -31,13 +31,14 @@ import java.security.InvalidParameterException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.rest.api.model.Site;
|
||||
import org.alfresco.rest.api.model.SiteUpdate;
|
||||
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
|
||||
import org.alfresco.rest.framework.resource.EntityResource;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rm.rest.api.RMSites;
|
||||
import org.alfresco.rm.rest.api.model.RMSite;
|
||||
import org.alfresco.rm.rest.api.model.SiteUpdate;
|
||||
|
||||
/**
|
||||
* RM Site operations
|
||||
@@ -46,7 +47,7 @@ import org.alfresco.rm.rest.api.model.SiteUpdate;
|
||||
* @since 2.6
|
||||
*
|
||||
*/
|
||||
@EntityResource(name = "ig-sites", title = "IG Sites")
|
||||
@EntityResource(name = "gs-sites", title = "GS Sites")
|
||||
public class RMSiteEntityResource implements EntityResourceAction.Delete, EntityResourceAction.Create<RMSite>,
|
||||
EntityResourceAction.Update<RMSite>, EntityResourceAction.ReadById<RMSite>
|
||||
{
|
||||
@@ -90,38 +91,7 @@ public class RMSiteEntityResource implements EntityResourceAction.Delete, Entity
|
||||
throw new InvalidParameterException("The Update is supported only for siteId = rm.");
|
||||
}
|
||||
|
||||
// Until REPO-110 is solved, we need to explicitly test for the presence of fields
|
||||
// on the Site object that aren't valid SiteUpdate fields. Once REPO-110 is solved,
|
||||
// the update method will take a SiteUpdate as a parameter rather than a Site
|
||||
// and only the correct fields will be exposed. Any attempt to access illegal fields
|
||||
// should then result in the framework returning a 400 automatically.
|
||||
if (site.getId() != null)
|
||||
{
|
||||
throw new InvalidArgumentException("Site update does not support field: id");
|
||||
}
|
||||
if (site.getGuid() != null)
|
||||
{
|
||||
throw new InvalidArgumentException("Site update does not support field: guid");
|
||||
}
|
||||
if (site.getRole() != null)
|
||||
{
|
||||
throw new InvalidArgumentException("Site update does not support field: role");
|
||||
}
|
||||
if (site.getCompliance() != null)
|
||||
{
|
||||
throw new InvalidArgumentException("Site update does not support field: compliance");
|
||||
}
|
||||
if (site.getVisibility() != null)
|
||||
{
|
||||
throw new InvalidArgumentException("Site update does not support field: visibility");
|
||||
}
|
||||
|
||||
// Bind valid fields to a SiteUpdate instance.
|
||||
final String title = site.getTitle();
|
||||
final String description = site.getDescription();
|
||||
SiteUpdate update = new SiteUpdate(title, description, null);
|
||||
|
||||
return sites.updateRMSite(siteId, update, parameters);
|
||||
return sites.updateRMSite(siteId, convert(site), parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -133,4 +103,50 @@ public class RMSiteEntityResource implements EntityResourceAction.Delete, Entity
|
||||
}
|
||||
return sites.getRMSite(siteId);
|
||||
}
|
||||
|
||||
protected SiteUpdate convert(RMSite site)
|
||||
{
|
||||
// Until REPO-110 is solved, we need to explicitly test for the presence of fields
|
||||
// on the Site object that aren't valid SiteUpdate fields. Once REPO-110 is solved,
|
||||
// the update method will take a SiteUpdate as a parameter rather than a Site
|
||||
// and only the correct fields will be exposed. Any attempt to access illegal fields
|
||||
// should then result in the framework returning a 400 automatically.
|
||||
if (site.wasSet(Site.ID))
|
||||
{
|
||||
throw new InvalidArgumentException("Site update does not support field: id");
|
||||
}
|
||||
if (site.wasSet(Site.GUID))
|
||||
{
|
||||
throw new InvalidArgumentException("Site update does not support field: guid");
|
||||
}
|
||||
if (site.wasSet(Site.ROLE))
|
||||
{
|
||||
throw new InvalidArgumentException("Site update does not support field: role");
|
||||
}
|
||||
if (site.wasSet(Site.PRESET))
|
||||
{
|
||||
throw new InvalidArgumentException("Site update does not support field: preset");
|
||||
}
|
||||
if (site.wasSet(RMSite.COMPLIANCE))
|
||||
{
|
||||
throw new InvalidArgumentException("Site update does not support field: compliance");
|
||||
}
|
||||
if (site.wasSet(Site.VISIBILITY))
|
||||
{
|
||||
throw new InvalidArgumentException("Site update does not support field: visibility");
|
||||
}
|
||||
|
||||
// Bind valid fields to a SiteUpdate instance.
|
||||
SiteUpdate siteUpdate = new SiteUpdate();
|
||||
if (site.wasSet(Site.TITLE))
|
||||
{
|
||||
siteUpdate.setTitle(site.getTitle());
|
||||
}
|
||||
if (site.wasSet(Site.DESCRIPTION))
|
||||
{
|
||||
siteUpdate.setDescription(site.getDescription());
|
||||
}
|
||||
|
||||
return siteUpdate;
|
||||
}
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@
|
||||
* @author Silviu Dinuta
|
||||
* @since 2.6
|
||||
*/
|
||||
@WebApi(name="ig", scope=Api.SCOPE.PUBLIC, version=1)
|
||||
@WebApi(name="gs", scope=Api.SCOPE.PUBLIC, version=1)
|
||||
package org.alfresco.rm.rest.api.sites;
|
||||
import org.alfresco.rest.framework.Api;
|
||||
import org.alfresco.rest.framework.WebApi;
|
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.transfercontainers;
|
||||
|
||||
import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.checkNotBlank;
|
||||
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
|
||||
import java.util.AbstractList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.rest.api.impl.Util;
|
||||
import org.alfresco.rest.api.model.UserInfo;
|
||||
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.rm.rest.api.impl.ApiNodesModelFactory;
|
||||
import org.alfresco.rm.rest.api.impl.FilePlanComponentsApiUtils;
|
||||
import org.alfresco.rm.rest.api.impl.SearchTypesFactory;
|
||||
import org.alfresco.rm.rest.api.model.Transfer;
|
||||
import org.alfresco.rm.rest.api.model.TransferContainer;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Transfer Container children relation
|
||||
*
|
||||
* @author Silviu Dinuta
|
||||
* @since 2.6
|
||||
*/
|
||||
@RelationshipResource(name="transfers", entityResource = TransferContainerEntityResource.class, title = "Children of a transfer container")
|
||||
public class TransferContainerChildrenRelation implements RelationshipResourceAction.Read<Transfer>
|
||||
{
|
||||
private FilePlanComponentsApiUtils apiUtils;
|
||||
private SearchTypesFactory searchTypesFactory;
|
||||
private FileFolderService fileFolderService;
|
||||
private ApiNodesModelFactory nodesModelFactory;
|
||||
|
||||
public void setApiUtils(FilePlanComponentsApiUtils apiUtils)
|
||||
{
|
||||
this.apiUtils = apiUtils;
|
||||
}
|
||||
|
||||
public void setSearchTypesFactory(SearchTypesFactory searchTypesFactory)
|
||||
{
|
||||
this.searchTypesFactory = searchTypesFactory;
|
||||
}
|
||||
|
||||
public void setFileFolderService(FileFolderService fileFolderService)
|
||||
{
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
public void setNodesModelFactory(ApiNodesModelFactory nodesModelFactory)
|
||||
{
|
||||
this.nodesModelFactory = nodesModelFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Return a paged list of transfers for the transfer container identified by 'transferContainerId'")
|
||||
public CollectionWithPagingInfo<Transfer> readAll(String transferContainerId, Parameters parameters)
|
||||
{
|
||||
checkNotBlank("transferContainerId", transferContainerId);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(transferContainerId, RecordsManagementModel.TYPE_TRANSFER_CONTAINER);
|
||||
|
||||
// list transfers
|
||||
Set<QName> searchTypeQNames = searchTypesFactory.buildSearchTypesForTransferContainersEndpoint();
|
||||
|
||||
final PagingResults<FileInfo> pagingResults = fileFolderService.list(parentNodeRef,
|
||||
null,
|
||||
searchTypeQNames,
|
||||
null,
|
||||
apiUtils.getSortProperties(parameters),
|
||||
null,
|
||||
Util.getPagingRequest(parameters.getPaging()));
|
||||
|
||||
final List<FileInfo> page = pagingResults.getPage();
|
||||
Map<String, UserInfo> mapUserInfo = new HashMap<>();
|
||||
List<Transfer> nodes = new AbstractList<Transfer>()
|
||||
{
|
||||
@Override
|
||||
public Transfer get(int index)
|
||||
{
|
||||
FileInfo info = page.get(index);
|
||||
return nodesModelFactory.createTransfer(info, parameters, mapUserInfo, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size()
|
||||
{
|
||||
return page.size();
|
||||
}
|
||||
};
|
||||
|
||||
TransferContainer sourceEntity = null;
|
||||
if (parameters.includeSource())
|
||||
{
|
||||
FileInfo info = fileFolderService.getFileInfo(parentNodeRef);
|
||||
sourceEntity = nodesModelFactory.createTransferContainer(info, parameters, mapUserInfo, true);
|
||||
}
|
||||
|
||||
return CollectionWithPagingInfo.asPaged(parameters.getPaging(), nodes, pagingResults.hasMoreItems(),
|
||||
pagingResults.getTotalResultCount().getFirst(), sourceEntity);
|
||||
}
|
||||
}
|
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.transfercontainers;
|
||||
|
||||
import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.checkNotBlank;
|
||||
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
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.EntityResourceAction;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rm.rest.api.impl.ApiNodesModelFactory;
|
||||
import org.alfresco.rm.rest.api.impl.FilePlanComponentsApiUtils;
|
||||
import org.alfresco.rm.rest.api.model.TransferContainer;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
/**
|
||||
* Transfer Container entity resource
|
||||
*
|
||||
* @author Silviu Dinuta
|
||||
* @since 2.6
|
||||
*/
|
||||
@EntityResource(name="transfer-containers", title = "Transfer Containers")
|
||||
public class TransferContainerEntityResource implements
|
||||
EntityResourceAction.ReadById<TransferContainer>,
|
||||
EntityResourceAction.Update<TransferContainer>,
|
||||
InitializingBean
|
||||
{
|
||||
private FilePlanComponentsApiUtils apiUtils;
|
||||
private FileFolderService fileFolderService;
|
||||
private ApiNodesModelFactory nodesModelFactory;
|
||||
|
||||
public void setApiUtils(FilePlanComponentsApiUtils apiUtils)
|
||||
{
|
||||
this.apiUtils = apiUtils;
|
||||
}
|
||||
|
||||
public void setFileFolderService(FileFolderService fileFolderService)
|
||||
{
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
public void setNodesModelFactory(ApiNodesModelFactory nodesModelFactory)
|
||||
{
|
||||
this.nodesModelFactory = nodesModelFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
mandatory("apiUtils", apiUtils);
|
||||
mandatory("fileFolderService", fileFolderService);
|
||||
mandatory("apiNodesModelFactory", nodesModelFactory);
|
||||
}
|
||||
|
||||
@WebApiDescription(title = "Get transfer container information", description = "Gets information for a transfer container with id 'transferContainerId'")
|
||||
@WebApiParam(name = "transferContainerId", title = "The transfer container id")
|
||||
@Override
|
||||
public TransferContainer readById(String transferContainerId, Parameters parameters) throws EntityNotFoundException
|
||||
{
|
||||
checkNotBlank("transferContainerId", transferContainerId);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(transferContainerId, RecordsManagementModel.TYPE_TRANSFER_CONTAINER);
|
||||
|
||||
FileInfo info = fileFolderService.getFileInfo(nodeRef);
|
||||
|
||||
return nodesModelFactory.createTransferContainer(info, parameters, null, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title="Update transfer container", description = "Updates a transfer container with id 'transferContainerId'")
|
||||
public TransferContainer update(String transferContainerId, TransferContainer transferContainerInfo, Parameters parameters)
|
||||
{
|
||||
checkNotBlank("transferContainerId", transferContainerId);
|
||||
mandatory("transferContainerInfo", transferContainerInfo);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(transferContainerId, RecordsManagementModel.TYPE_TRANSFER_CONTAINER);
|
||||
apiUtils.updateTransferContainer(nodeRef, transferContainerInfo, parameters);
|
||||
|
||||
FileInfo info = fileFolderService.getFileInfo(nodeRef);
|
||||
return nodesModelFactory.createTransferContainer(info, parameters, null, false);
|
||||
}
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
/**
|
||||
* Package info that defines Alfresco Governance Services transfer-containers REST API
|
||||
*
|
||||
* @author Silviu Dinuta
|
||||
* @since 2.6
|
||||
*/
|
||||
@WebApi(name="gs", scope=Api.SCOPE.PUBLIC, version=1)
|
||||
package org.alfresco.rm.rest.api.transfercontainers;
|
||||
import org.alfresco.rest.framework.Api;
|
||||
import org.alfresco.rest.framework.WebApi;
|
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.transfers;
|
||||
|
||||
import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.checkNotBlank;
|
||||
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
|
||||
import java.util.AbstractList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.rest.api.impl.Util;
|
||||
import org.alfresco.rest.api.model.UserInfo;
|
||||
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.rm.rest.api.impl.ApiNodesModelFactory;
|
||||
import org.alfresco.rm.rest.api.impl.FilePlanComponentsApiUtils;
|
||||
import org.alfresco.rm.rest.api.impl.SearchTypesFactory;
|
||||
import org.alfresco.rm.rest.api.model.Transfer;
|
||||
import org.alfresco.rm.rest.api.model.TransferChild;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Transfer children relation
|
||||
*
|
||||
* @author Silviu Dinuta
|
||||
* @since 2.6
|
||||
*/
|
||||
@RelationshipResource(name="children", entityResource = TransferEntityResource.class, title = "Children of a transfer")
|
||||
public class TransferChildrenRelation implements RelationshipResourceAction.Read<TransferChild>
|
||||
{
|
||||
private FilePlanComponentsApiUtils apiUtils;
|
||||
private SearchTypesFactory searchTypesFactory;
|
||||
private FileFolderService fileFolderService;
|
||||
private ApiNodesModelFactory nodesModelFactory;
|
||||
|
||||
public void setApiUtils(FilePlanComponentsApiUtils apiUtils)
|
||||
{
|
||||
this.apiUtils = apiUtils;
|
||||
}
|
||||
|
||||
public void setSearchTypesFactory(SearchTypesFactory searchTypesFactory)
|
||||
{
|
||||
this.searchTypesFactory = searchTypesFactory;
|
||||
}
|
||||
|
||||
public void setFileFolderService(FileFolderService fileFolderService)
|
||||
{
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
public void setNodesModelFactory(ApiNodesModelFactory nodesModelFactory)
|
||||
{
|
||||
this.nodesModelFactory = nodesModelFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Return a paged list of record folders or records for the transfer identified by 'transferId'")
|
||||
public CollectionWithPagingInfo<TransferChild> readAll(String transferId, Parameters parameters)
|
||||
{
|
||||
checkNotBlank("transferId", transferId);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(transferId, RecordsManagementModel.TYPE_TRANSFER);
|
||||
|
||||
// list record folder, electronic record or non electronic record
|
||||
final PagingResults<FileInfo> pagingResults = fileFolderService.list(parentNodeRef,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
apiUtils.getSortProperties(parameters),
|
||||
null,
|
||||
Util.getPagingRequest(parameters.getPaging()));
|
||||
|
||||
final List<FileInfo> page = pagingResults.getPage();
|
||||
Map<String, UserInfo> mapUserInfo = new HashMap<>();
|
||||
List<TransferChild> nodes = new AbstractList<TransferChild>()
|
||||
{
|
||||
@Override
|
||||
public TransferChild get(int index)
|
||||
{
|
||||
FileInfo info = page.get(index);
|
||||
return nodesModelFactory.createTransferChild(info, parameters, mapUserInfo, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size()
|
||||
{
|
||||
return page.size();
|
||||
}
|
||||
};
|
||||
|
||||
Transfer sourceEntity = null;
|
||||
if (parameters.includeSource())
|
||||
{
|
||||
FileInfo info = fileFolderService.getFileInfo(parentNodeRef);
|
||||
sourceEntity = nodesModelFactory.createTransfer(info, parameters, mapUserInfo, true);
|
||||
}
|
||||
|
||||
return CollectionWithPagingInfo.asPaged(parameters.getPaging(), nodes, pagingResults.hasMoreItems(),
|
||||
pagingResults.getTotalResultCount().getFirst(), sourceEntity);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.transfers;
|
||||
|
||||
import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.checkNotBlank;
|
||||
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
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.EntityResourceAction;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rm.rest.api.impl.ApiNodesModelFactory;
|
||||
import org.alfresco.rm.rest.api.impl.FilePlanComponentsApiUtils;
|
||||
import org.alfresco.rm.rest.api.model.Transfer;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
/**
|
||||
* Transfer entity resource
|
||||
*
|
||||
* @author Silviu Dinuta
|
||||
* @since 2.6
|
||||
*/
|
||||
@EntityResource(name="transfers", title = "Transfers")
|
||||
public class TransferEntityResource implements
|
||||
EntityResourceAction.ReadById<Transfer>,
|
||||
InitializingBean
|
||||
{
|
||||
private FilePlanComponentsApiUtils apiUtils;
|
||||
private FileFolderService fileFolderService;
|
||||
private ApiNodesModelFactory nodesModelFactory;
|
||||
|
||||
public void setApiUtils(FilePlanComponentsApiUtils apiUtils)
|
||||
{
|
||||
this.apiUtils = apiUtils;
|
||||
}
|
||||
|
||||
public void setFileFolderService(FileFolderService fileFolderService)
|
||||
{
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
public void setNodesModelFactory(ApiNodesModelFactory nodesModelFactory)
|
||||
{
|
||||
this.nodesModelFactory = nodesModelFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
mandatory("apiUtils", apiUtils);
|
||||
mandatory("fileFolderService", fileFolderService);
|
||||
mandatory("apiNodesModelFactory", nodesModelFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Get transfer information", description = "Gets information for a transfer with id 'transferId'")
|
||||
@WebApiParam(name = "transferId", title = "The transfer id")
|
||||
public Transfer readById(String transferId, Parameters parameters) throws EntityNotFoundException
|
||||
{
|
||||
checkNotBlank("transferId", transferId);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(transferId, RecordsManagementModel.TYPE_TRANSFER);
|
||||
|
||||
FileInfo info = fileFolderService.getFileInfo(nodeRef);
|
||||
|
||||
return nodesModelFactory.createTransfer(info, parameters, null, false);
|
||||
}
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
/**
|
||||
* Package info that defines Alfresco Governance Services transfers REST API
|
||||
*
|
||||
* @author Silviu Dinuta
|
||||
* @since 2.6
|
||||
*/
|
||||
@WebApi(name="gs", scope=Api.SCOPE.PUBLIC, version=1)
|
||||
package org.alfresco.rm.rest.api.transfers;
|
||||
import org.alfresco.rest.framework.Api;
|
||||
import org.alfresco.rest.framework.WebApi;
|
@@ -0,0 +1,237 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.unfiledcontainers;
|
||||
|
||||
import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.checkNotBlank;
|
||||
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
|
||||
import java.util.AbstractList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.repo.activities.ActivityType;
|
||||
import org.alfresco.repo.node.getchildren.FilterProp;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.rest.api.impl.Util;
|
||||
import org.alfresco.rest.api.model.UserInfo;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.WebApiParam;
|
||||
import org.alfresco.rest.framework.resource.RelationshipResource;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.MultiPartRelationshipResourceAction;
|
||||
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.rest.framework.webscripts.WithResponse;
|
||||
import org.alfresco.rm.rest.api.impl.ApiNodesModelFactory;
|
||||
import org.alfresco.rm.rest.api.impl.FilePlanComponentsApiUtils;
|
||||
import org.alfresco.rm.rest.api.impl.SearchTypesFactory;
|
||||
import org.alfresco.rm.rest.api.model.RMNode;
|
||||
import org.alfresco.rm.rest.api.model.UnfiledChild;
|
||||
import org.alfresco.rm.rest.api.model.UnfiledContainer;
|
||||
import org.alfresco.rm.rest.api.model.UnfiledContainerChild;
|
||||
import org.alfresco.rm.rest.api.model.UploadInfo;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.springframework.extensions.webscripts.servlet.FormData;
|
||||
|
||||
|
||||
/**
|
||||
* Unfiled container children relation
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @author Ana Bozianu
|
||||
* @since 2.6
|
||||
*/
|
||||
@RelationshipResource(name="children", entityResource = UnfiledContainerEntityResource.class, title = "Children of an unfiled container")
|
||||
public class UnfiledContainerChildrenRelation implements RelationshipResourceAction.Read<UnfiledContainerChild>,
|
||||
RelationshipResourceAction.Create<UnfiledContainerChild>,
|
||||
MultiPartRelationshipResourceAction.Create<UnfiledContainerChild>
|
||||
{
|
||||
|
||||
private final static Set<String> LIST_UNFILED_CONTAINER_CHILDREN_EQUALS_QUERY_PROPERTIES =
|
||||
new HashSet<>(Arrays.asList(new String[] {UnfiledChild.PARAM_IS_UNFILED_RECORD_FOLDER, UnfiledChild.PARAM_IS_RECORD, RMNode.PARAM_NODE_TYPE}));
|
||||
|
||||
private FilePlanComponentsApiUtils apiUtils;
|
||||
private SearchTypesFactory searchTypesFactory;
|
||||
private FileFolderService fileFolderService;
|
||||
private ApiNodesModelFactory nodesModelFactory;
|
||||
private TransactionService transactionService;
|
||||
|
||||
public void setApiUtils(FilePlanComponentsApiUtils apiUtils)
|
||||
{
|
||||
this.apiUtils = apiUtils;
|
||||
}
|
||||
|
||||
public void setSearchTypesFactory(SearchTypesFactory searchTypesFactory)
|
||||
{
|
||||
this.searchTypesFactory = searchTypesFactory;
|
||||
}
|
||||
|
||||
public void setFileFolderService(FileFolderService fileFolderService)
|
||||
{
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
public void setNodesModelFactory(ApiNodesModelFactory nodesModelFactory)
|
||||
{
|
||||
this.nodesModelFactory = nodesModelFactory;
|
||||
}
|
||||
|
||||
public void setTransactionService(TransactionService transactionService)
|
||||
{
|
||||
this.transactionService = transactionService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Return a paged list of unfiled container children for the container identified by 'unfiledContainerId'")
|
||||
public CollectionWithPagingInfo<UnfiledContainerChild> readAll(String unfiledContainerId, Parameters parameters)
|
||||
{
|
||||
// validate parameters
|
||||
checkNotBlank("unfiledContainerId", unfiledContainerId);
|
||||
mandatory("parameters", parameters);
|
||||
NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(unfiledContainerId, RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER);
|
||||
|
||||
// list unfiled record folders and records
|
||||
Set<QName> searchTypeQNames = searchTypesFactory.buildSearchTypesForUnfiledEndpoint(parameters, LIST_UNFILED_CONTAINER_CHILDREN_EQUALS_QUERY_PROPERTIES);
|
||||
|
||||
List<FilterProp> filterProps = apiUtils.getListChildrenFilterProps(parameters, LIST_UNFILED_CONTAINER_CHILDREN_EQUALS_QUERY_PROPERTIES);
|
||||
|
||||
final PagingResults<FileInfo> pagingResults = fileFolderService.list(parentNodeRef,
|
||||
null,
|
||||
searchTypeQNames,
|
||||
null,
|
||||
apiUtils.getSortProperties(parameters),
|
||||
filterProps,
|
||||
Util.getPagingRequest(parameters.getPaging()));
|
||||
|
||||
final List<FileInfo> page = pagingResults.getPage();
|
||||
Map<String, UserInfo> mapUserInfo = new HashMap<>();
|
||||
List<UnfiledContainerChild> nodes = new AbstractList<UnfiledContainerChild>()
|
||||
{
|
||||
@Override
|
||||
public UnfiledContainerChild get(int index)
|
||||
{
|
||||
FileInfo info = page.get(index);
|
||||
return nodesModelFactory.createUnfiledContainerChild(info, parameters, mapUserInfo, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size()
|
||||
{
|
||||
return page.size();
|
||||
}
|
||||
};
|
||||
|
||||
UnfiledContainer sourceEntity = null;
|
||||
if (parameters.includeSource())
|
||||
{
|
||||
FileInfo info = fileFolderService.getFileInfo(parentNodeRef);
|
||||
sourceEntity = nodesModelFactory.createUnfiledContainer(info, parameters, mapUserInfo, true);
|
||||
}
|
||||
|
||||
return CollectionWithPagingInfo.asPaged(parameters.getPaging(), nodes, pagingResults.hasMoreItems(),
|
||||
pagingResults.getTotalResultCount().getFirst(), sourceEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title="Create one (or more) nodes as children of a unfiled container identified by 'unfiledContainerId'")
|
||||
public List<UnfiledContainerChild> create(String unfiledContainerId, final List<UnfiledContainerChild> nodeInfos, Parameters parameters)
|
||||
{
|
||||
checkNotBlank("unfiledContainerId", unfiledContainerId);
|
||||
mandatory("nodeInfos", nodeInfos);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
final NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(unfiledContainerId, RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER);
|
||||
|
||||
// Create the nodes
|
||||
RetryingTransactionCallback<List<NodeRef>> callback = new RetryingTransactionCallback<List<NodeRef>>()
|
||||
{
|
||||
public List<NodeRef> execute()
|
||||
{
|
||||
List<NodeRef> createdNodes = new LinkedList<>();
|
||||
for (UnfiledContainerChild nodeInfo : nodeInfos)
|
||||
{
|
||||
NodeRef newNodeRef = apiUtils.createRMNode(parentNodeRef, nodeInfo.getName(), nodeInfo.getNodeType(), nodeInfo.getProperties(), nodeInfo.getAspectNames());
|
||||
createdNodes.add(newNodeRef);
|
||||
}
|
||||
return createdNodes;
|
||||
}
|
||||
};
|
||||
List<NodeRef> createdNodes = transactionService.getRetryingTransactionHelper().doInTransaction(callback);
|
||||
|
||||
// Get the nodes info
|
||||
List<UnfiledContainerChild> result = new LinkedList<>();
|
||||
Map<String, UserInfo> mapUserInfo = new HashMap<>();
|
||||
for(NodeRef newNodeRef : createdNodes)
|
||||
{
|
||||
FileInfo info = fileFolderService.getFileInfo(newNodeRef);
|
||||
apiUtils.postActivity(info, parentNodeRef, ActivityType.FILE_ADDED);
|
||||
result.add(nodesModelFactory.createUnfiledContainerChild(info, parameters, mapUserInfo, false));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Upload file content and meta-data into a unfiled record container identified by 'unfiledContainerId'.")
|
||||
@WebApiParam(name = "formData", title = "A single form data", description = "A single form data which holds FormFields.")
|
||||
public UnfiledContainerChild create(String unfiledContainerId, FormData formData, Parameters parameters, WithResponse withResponse)
|
||||
{
|
||||
checkNotBlank("unfiledContainerId", unfiledContainerId);
|
||||
mandatory("formData", formData);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
UploadInfo uploadInfo = new UploadInfo(formData);
|
||||
|
||||
NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(unfiledContainerId, RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER);
|
||||
RetryingTransactionCallback<NodeRef> callback = new RetryingTransactionCallback<NodeRef>()
|
||||
{
|
||||
public NodeRef execute()
|
||||
{
|
||||
return apiUtils.uploadRecord(parentNodeRef, uploadInfo.getFileName(), uploadInfo.getNodeType(), uploadInfo.getProperties(), uploadInfo.getContent().getInputStream());
|
||||
}
|
||||
};
|
||||
NodeRef newNode = transactionService.getRetryingTransactionHelper().doInTransaction(callback);
|
||||
|
||||
// Get file info for response
|
||||
FileInfo info = fileFolderService.getFileInfo(newNode);
|
||||
apiUtils.postActivity(info, parentNodeRef, ActivityType.FILE_ADDED);
|
||||
return nodesModelFactory.createUnfiledContainerChild(info, parameters, null, false);
|
||||
}
|
||||
}
|
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.unfiledcontainers;
|
||||
|
||||
import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.checkNotBlank;
|
||||
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.repo.activities.ActivityType;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.WebApiParam;
|
||||
import org.alfresco.rest.framework.resource.EntityResource;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rm.rest.api.impl.ApiNodesModelFactory;
|
||||
import org.alfresco.rm.rest.api.impl.FilePlanComponentsApiUtils;
|
||||
import org.alfresco.rm.rest.api.model.UnfiledContainer;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
/**
|
||||
* Unfiled container entity resource
|
||||
*
|
||||
* @author Ana Bozianu
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.6
|
||||
*/
|
||||
@EntityResource(name = "unfiled-containers", title = "Unfiled containers")
|
||||
public class UnfiledContainerEntityResource
|
||||
implements EntityResourceAction.ReadById<UnfiledContainer>, EntityResourceAction.Update<UnfiledContainer>, InitializingBean
|
||||
{
|
||||
|
||||
private FilePlanComponentsApiUtils apiUtils;
|
||||
private FileFolderService fileFolderService;
|
||||
private ApiNodesModelFactory nodesModelFactory;
|
||||
|
||||
public void setApiUtils(FilePlanComponentsApiUtils apiUtils)
|
||||
{
|
||||
this.apiUtils = apiUtils;
|
||||
}
|
||||
|
||||
public void setFileFolderService(FileFolderService fileFolderService)
|
||||
{
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
public void setNodesModelFactory(ApiNodesModelFactory nodesModelFactory)
|
||||
{
|
||||
this.nodesModelFactory = nodesModelFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
mandatory("apiUtils", apiUtils);
|
||||
mandatory("fileFolderService", fileFolderService);
|
||||
mandatory("apiNodesModelFactory", nodesModelFactory);
|
||||
}
|
||||
|
||||
@WebApiDescription(title = "Get unfiled container information", description = "Gets information for a unfiled container with id 'unfiledContainerId'")
|
||||
@WebApiParam(name = "unfiledContainerId", title = "The unfiled container id")
|
||||
public UnfiledContainer readById(String unfiledContainerId, Parameters parameters)
|
||||
{
|
||||
checkNotBlank("unfiledContainerId", unfiledContainerId);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(unfiledContainerId, RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER);
|
||||
|
||||
FileInfo info = fileFolderService.getFileInfo(nodeRef);
|
||||
|
||||
return nodesModelFactory.createUnfiledContainer(info, parameters, null, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Update unfiled record container", description = "Updates an unfiled record container with id 'unfiledContainerId'")
|
||||
public UnfiledContainer update(String unfiledContainerId, UnfiledContainer unfiledContainerInfo, Parameters parameters)
|
||||
{
|
||||
checkNotBlank("unfiledContainerId", unfiledContainerId);
|
||||
mandatory("unfiledContainerInfo", unfiledContainerInfo);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(unfiledContainerId, RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER);
|
||||
apiUtils.updateNode(nodeRef, unfiledContainerInfo, parameters);
|
||||
|
||||
FileInfo info = fileFolderService.getFileInfo(nodeRef);
|
||||
apiUtils.postActivity(info, unfiledContainerInfo.getParentId(), ActivityType.FILE_UPDATED);
|
||||
return nodesModelFactory.createUnfiledContainer(info, parameters, null, false);
|
||||
}
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
/**
|
||||
* Package info that defines the Information Governance Unfiled Containers REST API
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.6
|
||||
*/
|
||||
@WebApi(name="gs", scope=Api.SCOPE.PUBLIC, version=1)
|
||||
package org.alfresco.rm.rest.api.unfiledcontainers;
|
||||
import org.alfresco.rest.framework.Api;
|
||||
import org.alfresco.rest.framework.WebApi;
|
@@ -0,0 +1,246 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.unfiledrecordfolders;
|
||||
|
||||
import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.checkNotBlank;
|
||||
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
|
||||
import java.util.AbstractList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.repo.activities.ActivityType;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.rest.api.Nodes;
|
||||
import org.alfresco.rest.api.impl.Util;
|
||||
import org.alfresco.rest.api.model.UserInfo;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.WebApiParam;
|
||||
import org.alfresco.rest.framework.resource.RelationshipResource;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.MultiPartRelationshipResourceAction;
|
||||
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.rest.framework.webscripts.WithResponse;
|
||||
import org.alfresco.rm.rest.api.impl.ApiNodesModelFactory;
|
||||
import org.alfresco.rm.rest.api.impl.FilePlanComponentsApiUtils;
|
||||
import org.alfresco.rm.rest.api.impl.SearchTypesFactory;
|
||||
import org.alfresco.rm.rest.api.model.RMNode;
|
||||
import org.alfresco.rm.rest.api.model.UnfiledChild;
|
||||
import org.alfresco.rm.rest.api.model.UnfiledContainerChild;
|
||||
import org.alfresco.rm.rest.api.model.UnfiledRecordFolder;
|
||||
import org.alfresco.rm.rest.api.model.UnfiledRecordFolderChild;
|
||||
import org.alfresco.rm.rest.api.model.UploadInfo;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.extensions.webscripts.servlet.FormData;
|
||||
|
||||
/**
|
||||
* Unfiled Record folder children relation
|
||||
*
|
||||
* @author Ramona Popa
|
||||
* @since 2.6
|
||||
*/
|
||||
@RelationshipResource(name="children", entityResource = UnfiledRecordFolderEntityResource.class, title = "Children of an unfiled record folder")
|
||||
public class UnfiledRecordFolderChildrenRelation implements RelationshipResourceAction.Read<UnfiledRecordFolderChild>,
|
||||
RelationshipResourceAction.Create<UnfiledRecordFolderChild>,
|
||||
MultiPartRelationshipResourceAction.Create<UnfiledRecordFolderChild>
|
||||
{
|
||||
private final static Set<String> LIST_UNFILED_RECORD_FOLDER_CHILDREN_EQUALS_QUERY_PROPERTIES = new HashSet<>(Arrays
|
||||
.asList(new String[] { UnfiledChild.PARAM_IS_UNFILED_RECORD_FOLDER, UnfiledChild.PARAM_IS_RECORD, RMNode.PARAM_NODE_TYPE }));
|
||||
|
||||
private FilePlanComponentsApiUtils apiUtils;
|
||||
private SearchTypesFactory searchTypesFactory;
|
||||
private FileFolderService fileFolderService;
|
||||
private ApiNodesModelFactory nodesModelFactory;
|
||||
private TransactionService transactionService;
|
||||
|
||||
public void setApiUtils(FilePlanComponentsApiUtils apiUtils)
|
||||
{
|
||||
this.apiUtils = apiUtils;
|
||||
}
|
||||
|
||||
public void setSearchTypesFactory(SearchTypesFactory searchTypesFactory)
|
||||
{
|
||||
this.searchTypesFactory = searchTypesFactory;
|
||||
}
|
||||
|
||||
public void setFileFolderService(FileFolderService fileFolderService)
|
||||
{
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
public void setNodesModelFactory(ApiNodesModelFactory nodesModelFactory)
|
||||
{
|
||||
this.nodesModelFactory = nodesModelFactory;
|
||||
}
|
||||
|
||||
public void setTransactionService(TransactionService transactionService)
|
||||
{
|
||||
this.transactionService = transactionService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Return a paged list of unfiled container children for the container identified by 'unfiledContainerId'")
|
||||
public CollectionWithPagingInfo<UnfiledRecordFolderChild> readAll(String unfileRecordFolderId, Parameters parameters)
|
||||
{
|
||||
checkNotBlank("unfileRecordFolderId", unfileRecordFolderId);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
String relativePath = parameters.getParameter(Nodes.PARAM_RELATIVE_PATH);
|
||||
NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(unfileRecordFolderId, RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER, relativePath, true);
|
||||
|
||||
// list unfiled record folders and records
|
||||
Set<QName> searchTypeQNames = searchTypesFactory.buildSearchTypesForUnfiledEndpoint(parameters, LIST_UNFILED_RECORD_FOLDER_CHILDREN_EQUALS_QUERY_PROPERTIES);
|
||||
|
||||
final PagingResults<FileInfo> pagingResults = fileFolderService.list(parentNodeRef,
|
||||
null,
|
||||
searchTypeQNames,
|
||||
null,
|
||||
apiUtils.getSortProperties(parameters),
|
||||
null,
|
||||
Util.getPagingRequest(parameters.getPaging()));
|
||||
|
||||
final List<FileInfo> page = pagingResults.getPage();
|
||||
Map<String, UserInfo> mapUserInfo = new HashMap<>();
|
||||
List<UnfiledRecordFolderChild> nodes = new AbstractList<UnfiledRecordFolderChild>()
|
||||
{
|
||||
@Override
|
||||
public UnfiledRecordFolderChild get(int index)
|
||||
{
|
||||
FileInfo info = page.get(index);
|
||||
return nodesModelFactory.createUnfiledRecordFolderChild(info, parameters, mapUserInfo, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size()
|
||||
{
|
||||
return page.size();
|
||||
}
|
||||
};
|
||||
|
||||
UnfiledRecordFolder sourceEntity = null;
|
||||
if (parameters.includeSource())
|
||||
{
|
||||
FileInfo info = fileFolderService.getFileInfo(parentNodeRef);
|
||||
sourceEntity = nodesModelFactory.createUnfiledRecordFolder(info, parameters, mapUserInfo, true);
|
||||
}
|
||||
|
||||
return CollectionWithPagingInfo.asPaged(parameters.getPaging(), nodes, pagingResults.hasMoreItems(), pagingResults.getTotalResultCount().getFirst(), sourceEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Create one (or more) nodes as children of a unfiled record folder identified by 'unfiledRecordFolderId'")
|
||||
public List<UnfiledRecordFolderChild> create(String unfiledRecordFolderId, final List<UnfiledRecordFolderChild> nodeInfos, Parameters parameters)
|
||||
{
|
||||
checkNotBlank("unfiledRecordFolderId", unfiledRecordFolderId);
|
||||
mandatory("nodeInfos", nodeInfos);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(unfiledRecordFolderId, RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER);
|
||||
|
||||
// Create the children
|
||||
RetryingTransactionCallback<List<NodeRef>> callback = new RetryingTransactionCallback<List<NodeRef>>()
|
||||
{
|
||||
public List<NodeRef> execute()
|
||||
{
|
||||
List<NodeRef> createdNodes = new LinkedList<>();
|
||||
for (UnfiledRecordFolderChild nodeInfo : nodeInfos)
|
||||
{
|
||||
NodeRef nodeParent;
|
||||
if(StringUtils.isNoneBlank(nodeInfo.getRelativePath()))
|
||||
{
|
||||
nodeParent = apiUtils.lookupAndValidateRelativePath(parentNodeRef, nodeInfo.getRelativePath(), RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER);
|
||||
}
|
||||
else
|
||||
{
|
||||
nodeParent = parentNodeRef;
|
||||
}
|
||||
|
||||
NodeRef newNodeRef = apiUtils.createRMNode(nodeParent, nodeInfo.getName(), nodeInfo.getNodeType(), nodeInfo.getProperties(), nodeInfo.getAspectNames());
|
||||
createdNodes.add(newNodeRef);
|
||||
}
|
||||
return createdNodes;
|
||||
}
|
||||
};
|
||||
List<NodeRef> createdNodes = transactionService.getRetryingTransactionHelper().doInTransaction(callback);
|
||||
|
||||
// Get the nodes info
|
||||
List<UnfiledRecordFolderChild> result = new LinkedList<>();
|
||||
Map<String, UserInfo> mapUserInfo = new HashMap<>();
|
||||
for(NodeRef newNodeRef : createdNodes)
|
||||
{
|
||||
FileInfo info = fileFolderService.getFileInfo(newNodeRef);
|
||||
apiUtils.postActivity(info, parentNodeRef, ActivityType.FILE_ADDED);
|
||||
result.add(nodesModelFactory.createUnfiledRecordFolderChild(info, parameters, mapUserInfo, false));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Upload file content and meta-data into the repository.")
|
||||
@WebApiParam(name = "formData", title = "A single form data", description = "A single form data which holds FormFields.")
|
||||
public UnfiledRecordFolderChild create(String unfiledRecordFolderId, FormData formData, Parameters parameters, WithResponse withResponse)
|
||||
{
|
||||
checkNotBlank("unfiledRecordFolderId", unfiledRecordFolderId);
|
||||
mandatory("formData", formData);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
// Retrieve the input data and resolve the parent node
|
||||
final UploadInfo uploadInfo = new UploadInfo(formData);
|
||||
final NodeRef parentNodeRef = apiUtils.lookupAndValidateNodeType(unfiledRecordFolderId, RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER, uploadInfo.getRelativePath());
|
||||
|
||||
// Create the record
|
||||
RetryingTransactionCallback<NodeRef> callback = new RetryingTransactionCallback<NodeRef>()
|
||||
{
|
||||
public NodeRef execute()
|
||||
{
|
||||
return apiUtils.uploadRecord(parentNodeRef, uploadInfo.getFileName(), uploadInfo.getNodeType(), uploadInfo.getProperties(), uploadInfo.getContent().getInputStream());
|
||||
}
|
||||
};
|
||||
NodeRef newNode = transactionService.getRetryingTransactionHelper().doInTransaction(callback);
|
||||
|
||||
// Get file info for response
|
||||
FileInfo info = fileFolderService.getFileInfo(newNode);
|
||||
apiUtils.postActivity(info, parentNodeRef, ActivityType.FILE_ADDED);
|
||||
return nodesModelFactory.createUnfiledRecordFolderChild(info, parameters, null, false);
|
||||
}
|
||||
}
|
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.unfiledrecordfolders;
|
||||
|
||||
import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.checkNotBlank;
|
||||
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.repo.activities.ActivityType;
|
||||
import org.alfresco.rest.api.Nodes;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.WebApiParam;
|
||||
import org.alfresco.rest.framework.resource.EntityResource;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rm.rest.api.impl.ApiNodesModelFactory;
|
||||
import org.alfresco.rm.rest.api.impl.FilePlanComponentsApiUtils;
|
||||
import org.alfresco.rm.rest.api.model.UnfiledRecordFolder;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
/**
|
||||
* Unfiled record folder entity resource
|
||||
*
|
||||
* @author Ramona Popa
|
||||
* @since 2.6
|
||||
*/
|
||||
@EntityResource(name = "unfiled-record-folders", title = "Unfiled Record Folders")
|
||||
public class UnfiledRecordFolderEntityResource implements EntityResourceAction.ReadById<UnfiledRecordFolder>,
|
||||
EntityResourceAction.Delete,
|
||||
EntityResourceAction.Update<UnfiledRecordFolder>, InitializingBean
|
||||
|
||||
{
|
||||
private FilePlanComponentsApiUtils apiUtils;
|
||||
private FileFolderService fileFolderService;
|
||||
private ApiNodesModelFactory nodesModelFactory;
|
||||
public void setApiUtils(FilePlanComponentsApiUtils apiUtils)
|
||||
{
|
||||
this.apiUtils = apiUtils;
|
||||
}
|
||||
|
||||
public void setFileFolderService(FileFolderService fileFolderService)
|
||||
{
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
public void setNodesModelFactory(ApiNodesModelFactory nodesModelFactory)
|
||||
{
|
||||
this.nodesModelFactory = nodesModelFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
mandatory("apiUtils", apiUtils);
|
||||
mandatory("fileFolderService", fileFolderService);
|
||||
mandatory("apiNodesModelFactory", nodesModelFactory);
|
||||
}
|
||||
|
||||
@WebApiDescription(title = "Get unfiled record folder information", description = "Gets information for an unfiled record folder with id 'unfiledRecordFolderId'")
|
||||
@WebApiParam(name = "unfiledRecordFolderId", title = "The unfiled record folder id")
|
||||
public UnfiledRecordFolder readById(String unfiledRecordFolderId, Parameters parameters)
|
||||
{
|
||||
checkNotBlank("unfiledRecordFolderId", unfiledRecordFolderId);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
String relativePath = parameters.getParameter(Nodes.PARAM_RELATIVE_PATH);
|
||||
|
||||
NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(unfiledRecordFolderId, RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER, relativePath, true);
|
||||
|
||||
FileInfo info = fileFolderService.getFileInfo(nodeRef);
|
||||
|
||||
return nodesModelFactory.createUnfiledRecordFolder(info, parameters, null, false);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Update unfiled record folder", description = "Updates an unfiled record folder with id 'unfiledRecordFolderId'")
|
||||
public UnfiledRecordFolder update(String unfiledRecordFolderId, UnfiledRecordFolder unfiledRecordFolderInfo, Parameters parameters)
|
||||
{
|
||||
checkNotBlank("unfiledRecordFolderId", unfiledRecordFolderId);
|
||||
mandatory("unfiledRecordFolderInfo", unfiledRecordFolderInfo);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(unfiledRecordFolderId, RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER);
|
||||
apiUtils.updateNode(nodeRef, unfiledRecordFolderInfo, parameters);
|
||||
|
||||
FileInfo info = fileFolderService.getFileInfo(nodeRef);
|
||||
apiUtils.postActivity(info, unfiledRecordFolderInfo.getParentId(), ActivityType.FILE_UPDATED);
|
||||
return nodesModelFactory.createUnfiledRecordFolder(info, parameters, null, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Delete unfiled record folder", description = "Deletes an unfiled record folder with id 'unfiledRecordFolderId'")
|
||||
public void delete(String unfiledRecordFolderId, Parameters parameters)
|
||||
{
|
||||
checkNotBlank("unfiledRecordFolderId", unfiledRecordFolderId);
|
||||
mandatory("parameters", parameters);
|
||||
|
||||
NodeRef nodeRef = apiUtils.lookupAndValidateNodeType(unfiledRecordFolderId, RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER);
|
||||
|
||||
fileFolderService.delete(nodeRef);
|
||||
}
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* 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/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
/**
|
||||
* Package info that defines the Information Governance Unfiled Record Folders REST API
|
||||
*
|
||||
* @author Ramona Popa
|
||||
* @since 2.6
|
||||
*/
|
||||
@WebApi(name="gs", scope=Api.SCOPE.PUBLIC, version=1)
|
||||
package org.alfresco.rm.rest.api.unfiledrecordfolders;
|
||||
import org.alfresco.rest.framework.Api;
|
||||
import org.alfresco.rest.framework.WebApi;
|
Reference in New Issue
Block a user