mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merge remote-tracking branch 'remotes/origin/feature/RM-6792_V1RestAPI' into feature/RM-6796_DeclareAndFileTests
This commit is contained in:
@@ -145,6 +145,7 @@
|
||||
<property name="recordService" ref="RecordService"/>
|
||||
<property name="authenticationUtil" ref="rm.authenticationUtil"/>
|
||||
<property name="transactionService" ref="transactionService" />
|
||||
<property name="apiUtils" ref="apiUtils" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.alfresco.rm.rest.api.transfercontainers.TransferContainerEntityResource">
|
||||
|
@@ -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<Void> callback = new RetryingTransactionCallback<Void>()
|
||||
{
|
||||
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
|
||||
{
|
||||
|
@@ -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:
|
||||
|
Reference in New Issue
Block a user