From 376dff7857c7c89469423c2d2ff9b5ac8d9fe852 Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Thu, 14 Mar 2013 07:47:56 +0000 Subject: [PATCH] RM: bug fixes * various behaviour needed to be executed as rmadmin * indicator shows for rejected record in collab site * can not see "create record" action in UI for rejected record git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@48068 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../rm-capabilities-condition-context.xml | 7 ++ .../rm-model-context.xml | 1 + .../RecordsManagementServiceImpl.java | 16 +++- .../model/behaviour/RecordContainerType.java | 77 ++++++++++++------- .../RecordsManagementSearchBehaviour.java | 21 +++-- .../RecordsManagementNotificationHelper.java | 3 +- .../record/RecordServiceImpl.java | 2 +- 7 files changed, 86 insertions(+), 41 deletions(-) diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-condition-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-condition-context.xml index 71bdcdb97f..caf3e20a14 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-condition-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-condition-context.xml @@ -156,5 +156,12 @@ parent="capabilityCondition.base" class="org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition.IsRecordCategoryCondition"> + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml index b0bb6b05a1..f12ed72a23 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml @@ -56,6 +56,7 @@ parent="org_alfresco_module_rm_BaseBehaviour"> + oldProps, Map newProps) + public void onChangeToAnyRmProperty(final NodeRef node, final Map oldProps, final Map newProps) { - if (nodeService.exists(node) == true) + serviceRegistry.getFilePlanAuthenticationService().runAsRmAdmin(new RunAsWork() { - this.lookupAndExecuteScripts(node, oldProps, newProps); - } + @Override + public Void doWork() throws Exception + { + if (nodeService.exists(node) == true) + { + RecordsManagementServiceImpl.this.lookupAndExecuteScripts(node, oldProps, newProps); + } + + return null; + }}); } /** diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordContainerType.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordContainerType.java index ebed90b439..3f34e5deed 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordContainerType.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordContainerType.java @@ -21,6 +21,7 @@ package org.alfresco.module.org_alfresco_module_rm.model.behaviour; import org.alfresco.model.ContentModel; import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.module.org_alfresco_module_rm.security.FilePlanAuthenticationService; import org.alfresco.repo.node.NodeServicePolicies; import org.alfresco.repo.policy.JavaBehaviour; import org.alfresco.repo.policy.PolicyComponent; @@ -55,6 +56,9 @@ public class RecordContainerType implements RecordsManagementModel, /** Identity service */ private IdentifierService recordsManagementIdentifierService; + /** File plan authentication service */ + private FilePlanAuthenticationService filePlanAuthenticationService; + /** * Set the policy component * @param policyComponent policy component @@ -84,6 +88,14 @@ public class RecordContainerType implements RecordsManagementModel, this.dictionaryService = dictionaryService; } + /** + * @param filePlanAuthenticationService file plan authentication service + */ + public void setFilePlanAuthenticationService(FilePlanAuthenticationService filePlanAuthenticationService) + { + this.filePlanAuthenticationService = filePlanAuthenticationService; + } + /** * Set the identity service * @@ -114,37 +126,46 @@ public class RecordContainerType implements RecordsManagementModel, * Deal with something created within a record container */ @Override - public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean isNewNode) + public void onCreateChildAssociation(final ChildAssociationRef childAssocRef, boolean isNewNode) { - // Get the elements of the created association - final NodeRef child = childAssocRef.getChildRef(); - QName childType = nodeService.getType(child); - - // We only care about "folder" or sub-types - if (dictionaryService.isSubClass(childType, ContentModel.TYPE_FOLDER) == true) - { - if (dictionaryService.isSubClass(childType, ContentModel.TYPE_SYSTEM_FOLDER) == true) + filePlanAuthenticationService.runAsRmAdmin(new RunAsWork() + { + @Override + public Void doWork() throws Exception { - // this is a rule container, make sure it is an file plan component - nodeService.addAspect(child, ASPECT_FILE_PLAN_COMPONENT, null); - } - else - { - // We need to automatically cast the created folder to RM type if it is a plain folder - // This occurs if the RM folder has been created via IMap, WebDav, etc - if (nodeService.hasAspect(child, ASPECT_FILE_PLAN_COMPONENT) == false) - { - // TODO it may not always be a record folder ... perhaps if the current user is a admin it would be a record category?? - - // Assume any created folder is a rma:recordFolder - nodeService.setType(child, TYPE_RECORD_FOLDER); - } + // Get the elements of the created association + final NodeRef child = childAssocRef.getChildRef(); + QName childType = nodeService.getType(child); + + // We only care about "folder" or sub-types + if (dictionaryService.isSubClass(childType, ContentModel.TYPE_FOLDER) == true) + { + if (dictionaryService.isSubClass(childType, ContentModel.TYPE_SYSTEM_FOLDER) == true) + { + // this is a rule container, make sure it is an file plan component + nodeService.addAspect(child, ASPECT_FILE_PLAN_COMPONENT, null); + } + else + { + // We need to automatically cast the created folder to RM type if it is a plain folder + // This occurs if the RM folder has been created via IMap, WebDav, etc + if (nodeService.hasAspect(child, ASPECT_FILE_PLAN_COMPONENT) == false) + { + // TODO it may not always be a record folder ... perhaps if the current user is a admin it would be a record category?? + + // Assume any created folder is a rma:recordFolder + nodeService.setType(child, TYPE_RECORD_FOLDER); + } - // Catch all to generate the rm id (assuming it doesn't already have one!) - setIdenifierProperty(child); - } - - } + // Catch all to generate the rm id (assuming it doesn't already have one!) + setIdenifierProperty(child); + } + } + + return null; + } + }); + } /** diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java index 846c7577c9..7a375b4f01 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java @@ -334,14 +334,23 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel }); } - public void recordFolderCreate(ChildAssociationRef childAssocRef) + public void recordFolderCreate(final ChildAssociationRef childAssocRef) { - NodeRef nodeRef = childAssocRef.getChildRef(); - if (nodeService.exists(nodeRef) == true) + AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork() { - applySearchAspect(nodeRef); - setupDispositionScheduleProperties(nodeRef); - } + @Override + public Void doWork() throws Exception + { + NodeRef nodeRef = childAssocRef.getChildRef(); + if (nodeService.exists(nodeRef) == true) + { + applySearchAspect(nodeRef); + setupDispositionScheduleProperties(nodeRef); + } + + return null; + } + }); } private void setupDispositionScheduleProperties(NodeRef recordOrFolder) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/notification/RecordsManagementNotificationHelper.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/notification/RecordsManagementNotificationHelper.java index e2ec49e806..925239a349 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/notification/RecordsManagementNotificationHelper.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/notification/RecordsManagementNotificationHelper.java @@ -310,14 +310,13 @@ public class RecordsManagementNotificationHelper implements RecordsManagementMod * * @param record rejected record */ - public void recordRejectedEmailNotification(NodeRef record, String recordId) + public void recordRejectedEmailNotification(NodeRef record, String recordId, String recordCreator) { ParameterCheck.mandatory("record", record); if (canSendRejectEmail(record) == true) { String site = siteService.getSite(record).getShortName(); - String recordCreator = (String) nodeService.getProperty(record, PROP_RECORD_ORIGINATING_USER_ID); String rejectReason = (String) nodeService.getProperty(record, PROP_RECORD_REJECTION_REASON); String rejectedPerson = (String) nodeService.getProperty(record, PROP_RECORD_REJECTION_USER_ID); Date rejectDate = (Date) nodeService.getProperty(record, PROP_RECORD_REJECTION_DATE); 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 0bcd24fb50..68b32e05b4 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 @@ -573,7 +573,7 @@ public class RecordServiceImpl implements RecordService, ownableService.setOwner(nodeRef, documentOwner); // send an email to the record creator - notificationHelper.recordRejectedEmailNotification(nodeRef, recordId); + notificationHelper.recordRejectedEmailNotification(nodeRef, recordId, documentOwner); return null; }