diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-public-rest-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-public-rest-context.xml
index 900c93fba3..b711326ba6 100644
--- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-public-rest-context.xml
+++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-public-rest-context.xml
@@ -145,6 +145,7 @@
+
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/files/FilesEntityResource.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/files/FilesEntityResource.java
index 08b6b0e76c..3295fd3095 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/files/FilesEntityResource.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/files/FilesEntityResource.java
@@ -28,6 +28,7 @@
package org.alfresco.rm.rest.api.files;
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.security.authentication.AuthenticationUtil.RunAsWork;
@@ -38,6 +39,8 @@ 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.impl.ApiNodesModelFactory;
+import org.alfresco.rm.rest.api.impl.FilePlanComponentsApiUtils;
+import org.alfresco.rm.rest.api.model.RMNode;
import org.alfresco.rm.rest.api.model.Record;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.model.FileInfo;
@@ -57,12 +60,18 @@ import org.springframework.beans.factory.InitializingBean;
public class FilesEntityResource implements InitializingBean
{
private ApiNodesModelFactory nodesModelFactory;
+ private FilePlanComponentsApiUtils apiUtils;
private AuthenticationUtil authenticationUtil;
private FilePlanService filePlanService;
private FileFolderService fileFolderService;
private RecordService recordService;
private TransactionService transactionService;
+ public void setApiUtils(FilePlanComponentsApiUtils apiUtils)
+ {
+ this.apiUtils = apiUtils;
+ }
+
public void setAuthenticationUtil(AuthenticationUtil authenticationUtil)
{
this.authenticationUtil = authenticationUtil;
@@ -110,13 +119,20 @@ public class FilesEntityResource implements InitializingBean
// default false (if not provided)
boolean hideRecord = Boolean.valueOf(parameters.getParameter(Record.PARAM_HIDE_RECORD));
+ // Get record folder, if provided
+ final NodeRef targetRecordFolder = extractAndValidateTargetRecordFolder(parameters);
+
// Create the record
NodeRef file = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, fileId);
RetryingTransactionCallback callback = new RetryingTransactionCallback()
{
public Void execute()
{
- recordService.createRecord(filePlan, file, !hideRecord);
+ recordService.createRecord(filePlan, file, targetRecordFolder, !hideRecord);
+ if (targetRecordFolder != null)
+ {
+ recordService.file(file);
+ }
return null;
}
};
@@ -127,6 +143,19 @@ public class FilesEntityResource implements InitializingBean
return nodesModelFactory.createRecord(info, parameters, null, false);
}
+ /* Helper method to determine the target record folder, if given */
+ private NodeRef extractAndValidateTargetRecordFolder(Parameters parameters)
+ {
+ // Get record folder, if provided
+ NodeRef targetParent = null;
+ String targetParentId = parameters.getParameter(RMNode.PARAM_PARENT_ID);
+ if (targetParentId != null)
+ {
+ targetParent = apiUtils.lookupAndValidateNodeType(targetParentId, RecordsManagementModel.TYPE_RECORD_FOLDER);
+ }
+ return targetParent;
+ }
+
@Override
public void afterPropertiesSet() throws Exception
{
diff --git a/rm-community/rm-community-rest-api-explorer/src/main/webapp/definitions/gs-core-api.yaml b/rm-community/rm-community-rest-api-explorer/src/main/webapp/definitions/gs-core-api.yaml
index 09f746fbf1..a25735996d 100644
--- a/rm-community/rm-community-rest-api-explorer/src/main/webapp/definitions/gs-core-api.yaml
+++ b/rm-community/rm-community-rest-api-explorer/src/main/webapp/definitions/gs-core-api.yaml
@@ -1842,7 +1842,7 @@ paths:
tags:
- files
summary: Declare as record
- description: Declares the file **fileId** in the unfiled records container. The original file is moved to the Records Management site and a secondary parent association is created in the file's original site.
+ description: Declares the file **fileId** in the unfiled records container. The original file is moved to the Records Management site and a secondary parent association is created in the file's original site. Optionally, a destination record folder may be specified, enabling the record to be filed directly into that folder.
operationId: declareRecord
parameters:
- name: fileId
@@ -1855,6 +1855,11 @@ paths:
description: Flag to indicate whether the record should be hidden from the current parent folder.
type: boolean
default: false
+ - name: parentId
+ in: query
+ description: The identifier of the destination record folder.
+ required: false
+ type: string
- $ref: '#/parameters/recordEntryIncludeParam'
- $ref: '#/parameters/fieldsParam'
consumes: