From 13663a06c0adfc91db114339c5899dcd1b0757cb Mon Sep 17 00:00:00 2001 From: Tuna Aksoy Date: Thu, 7 Feb 2013 15:41:22 +0000 Subject: [PATCH] RM-579: Restore the creator of the document when a records manager rejects the record git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@46374 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../record/RecordServiceImpl.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java index 9a41a1ff83..673500bb27 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java @@ -58,6 +58,7 @@ import org.alfresco.service.cmr.security.OwnableService; import org.alfresco.service.cmr.security.PermissionService; import org.alfresco.service.namespace.QName; import org.alfresco.util.ParameterCheck; +import org.apache.commons.lang.StringUtils; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; @@ -105,7 +106,7 @@ public class RecordServiceImpl implements RecordService, /** Policy component */ private PolicyComponent policyComponent; - + /** Ownable service */ private OwnableService ownableService; @@ -211,7 +212,7 @@ public class RecordServiceImpl implements RecordService, { this.ownableService = ownableService; } - + /** * Init method */ @@ -337,11 +338,11 @@ public class RecordServiceImpl implements RecordService, // get the documents readers Long aclId = nodeService.getNodeAclId(nodeRef); Set readers = permissionService.getReaders(aclId); - Set writers = permissionService.getWriters(aclId); - - // add the current owner to the list of extended writers + Set writers = permissionService.getWriters(aclId); + + // add the current owner to the list of extended writers String owner = ownableService.getOwner(nodeRef); - + // remove the owner ownableService.setOwner(nodeRef, OwnableService.NO_OWNER); @@ -555,6 +556,14 @@ public class RecordServiceImpl implements RecordService, aspectProperties.put(PROP_RECORD_REJECTION_REASON, reason); nodeService.addAspect(nodeRef, ASPECT_RECORD_REJECTION_DETAILS, aspectProperties); + // Restore the owner of the document + String documentOwner = (String) nodeService.getProperty(nodeRef, PROP_RECORD_ORIGINATING_USER_ID); + if (StringUtils.isBlank(documentOwner)) + { + throw new AlfrescoRuntimeException("Unable to find the creator of document."); + } + ownableService.setOwner(nodeRef, documentOwner); + // send an email to the record creator notificationHelper.recordRejectedEmailNotification(nodeRef);