RM-5012 - generate identifier on record declare

This commit is contained in:
Ana Bozianu
2017-05-17 14:55:06 +03:00
parent 18b58d9d4c
commit 205b77c65d
3 changed files with 22 additions and 5 deletions

View File

@@ -853,7 +853,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
// make the document a record
makeRecord(nodeRef);
appendIdentifierToName(nodeService, nodeRef);
generateRecordIdentifier(nodeService, identifierService, nodeRef);
if (latestVersionRecord != null)
{
@@ -1063,7 +1063,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
// make record
makeRecord(record);
appendIdentifierToName(nodeService, record);
generateRecordIdentifier(nodeService, identifierService, record);
// remove added copy assocs
List<AssociationRef> recordAssocs = nodeService.getTargetAssocs(record, ContentModel.ASSOC_ORIGINAL);
@@ -1198,7 +1198,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
{
// make record
makeRecord(record);
appendIdentifierToName(nodeService, record);
generateRecordIdentifier(nodeService, identifierService, record);
}
return record;
@@ -1811,7 +1811,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
{
if (nodeService.exists(nodeRef) && !nodeService.hasAspect(nodeRef, ContentModel.ASPECT_HIDDEN) && !nodeService.hasAspect(nodeRef, ContentModel.ASPECT_LOCKABLE))
{
appendIdentifierToName(nodeService, nodeRef);
generateRecordIdentifier(nodeService, identifierService, record);
}
}

View File

@@ -31,6 +31,7 @@ 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.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.rest.framework.Operation;
import org.alfresco.rest.framework.WebApiDescription;
import org.alfresco.rest.framework.resource.EntityResource;
@@ -42,6 +43,7 @@ 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.service.transaction.TransactionService;
import org.alfresco.util.ParameterCheck;
import org.springframework.beans.factory.InitializingBean;
@@ -59,6 +61,7 @@ public class FilesEntityResource implements InitializingBean
private FilePlanService filePlanService;
private FileFolderService fileFolderService;
private RecordService recordService;
private TransactionService transactionService;
public void setAuthenticationUtil(AuthenticationUtil authenticationUtil)
{
@@ -85,6 +88,11 @@ public class FilesEntityResource implements InitializingBean
this.nodesModelFactory = nodesModelFactory;
}
public void setTransactionService(TransactionService transactionService)
{
this.transactionService = transactionService;
}
@Operation("declare")
@WebApiDescription(title = "Declare as record", description="Declare a file as record.")
public Record declareAsRecord(String fileId, Void body, Parameters parameters, WithResponse withResponse)
@@ -104,7 +112,15 @@ public class FilesEntityResource implements InitializingBean
// Create the record
NodeRef file = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, fileId);
recordService.createRecord(filePlan, file, !hideRecord);
RetryingTransactionCallback<Void> callback = new RetryingTransactionCallback<Void>()
{
public Void execute()
{
recordService.createRecord(filePlan, file, !hideRecord);
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(callback, false, true);
// Return record state
FileInfo info = fileFolderService.getFileInfo(file);