From 7b328dfa6ce9394facf5f49d92417af729b562e4 Mon Sep 17 00:00:00 2001 From: Ana Bozianu Date: Wed, 16 Nov 2016 15:26:52 +0200 Subject: [PATCH 1/3] RM-4373 - made transfer and hold containers editable --- .../capability/rm-capabilities-fileplan-context.xml | 11 +++++++++++ .../capability/rm-capabilities-freeze-context.xml | 3 ++- .../capability/rm-capabilities-group-context.xml | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-fileplan-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-fileplan-context.xml index e8eeae8602..f5811bddb5 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-fileplan-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-fileplan-context.xml @@ -94,4 +94,15 @@ + + + + + + TRANSFER_CONTAINER + TRANSFER + + + \ No newline at end of file diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-freeze-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-freeze-context.xml index 5a1cceb841..3de1c78472 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-freeze-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-freeze-context.xml @@ -4,7 +4,7 @@ - + @@ -30,6 +30,7 @@ + HOLD_CONTAINER HOLD diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-group-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-group-context.xml index 91a50ef89d..87e4ea0edc 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-group-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-group-context.xml @@ -44,6 +44,7 @@ + @@ -62,6 +63,7 @@ + From c782ce305bb9852bf4eac1d0bb40920b6a50f3fd Mon Sep 17 00:00:00 2001 From: Ana Bozianu Date: Wed, 16 Nov 2016 16:40:53 +0200 Subject: [PATCH 2/3] RM-4373 - added filling condition for editing transfer container and transfer nodes --- .../capability/rm-capabilities-fileplan-context.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-fileplan-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-fileplan-context.xml index f5811bddb5..1d5e045a92 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-fileplan-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-fileplan-context.xml @@ -104,5 +104,10 @@ TRANSFER + + + + + \ No newline at end of file From 891f67782a109696203e013297d2152d75ee2e18 Mon Sep 17 00:00:00 2001 From: Ana Bozianu Date: Wed, 16 Nov 2016 17:40:48 +0200 Subject: [PATCH 3/3] RM-4373 - make transfers non editable because the rule inheritance is disabled on transfer container --- .../messages/action-service.properties | 1 + .../rma/aspect/FilePlanComponentAspect.java | 4 +-- .../model/rma/type/TransferType.java | 36 ++++++++++++++++--- .../transfer/TransferServiceImpl.java | 2 ++ 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/action-service.properties b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/action-service.properties index fe9a6d959e..3d36f0ec7c 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/action-service.properties +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/action-service.properties @@ -44,4 +44,5 @@ rm.action.multiple.children.type-error-message=Operation failed. Children of typ rm.action.create.transfer.container.child-error-message=Operation failed. Creation is not allowed in Transfer Container. rm.action.create.transfer.child-error-message=Operation failed. Creation is not allowed in Transfer Folders. rm.action.create.record.folder.child-error-message=Only records can be created in record folders but it was {0} +rm.action.transfer-non-editable=The metadata of transfer nodes is not editable. diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/FilePlanComponentAspect.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/FilePlanComponentAspect.java index 4def09023c..7b9cae0f0c 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/FilePlanComponentAspect.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/FilePlanComponentAspect.java @@ -129,7 +129,7 @@ public class FilePlanComponentAspect extends BaseBehaviourBean ) public void onUpdateProperties(final NodeRef nodeRef, final Map before, final Map after) { - AuthenticationUtil.runAs(new RunAsWork() + AuthenticationUtil.runAsSystem(new RunAsWork() { @Override public Void doWork() @@ -141,7 +141,7 @@ public class FilePlanComponentAspect extends BaseBehaviourBean return null; } - }, AuthenticationUtil.getAdminUserName()); + }); } /** diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/TransferType.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/TransferType.java index aa8be553e4..770f84ed91 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/TransferType.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/TransferType.java @@ -27,6 +27,9 @@ package org.alfresco.module.org_alfresco_module_rm.model.rma.type; +import java.io.Serializable; +import java.util.Map; + import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; import org.alfresco.repo.node.NodeServicePolicies; import org.alfresco.repo.node.integrity.IntegrityException; @@ -34,6 +37,8 @@ import org.alfresco.repo.policy.annotation.Behaviour; import org.alfresco.repo.policy.annotation.BehaviourBean; import org.alfresco.repo.policy.annotation.BehaviourKind; import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; import org.springframework.extensions.surf.util.I18NUtil; /** @@ -43,10 +48,15 @@ import org.springframework.extensions.surf.util.I18NUtil; * @since 2.6 */ @BehaviourBean(defaultType = "rma:transfer") -public class TransferType extends BaseBehaviourBean implements NodeServicePolicies.OnCreateChildAssociationPolicy +public class TransferType extends BaseBehaviourBean + implements NodeServicePolicies.OnCreateChildAssociationPolicy, + NodeServicePolicies.OnUpdatePropertiesPolicy { private final static String MSG_ERROR_ADD_CHILD_TO_TRANSFER = "rm.action.create.transfer.child-error-message"; - private static final String BEHAVIOUR_NAME = "onCreateChildAssocsForTransferType"; + private final static String MSG_ERROR_EDIT_TRANSFER_PROPERTIES = "rm.action.transfer-non-editable"; + + private static final String CREATE_CHILD_BEHAVIOUR_NAME = "onCreateChildAssocsForTransferType"; + private static final String EDIT_PROPERTIES_BEHAVIOUR_NAME = "onEditTransferProperties"; /** * Disable the behaviours for this transaction @@ -54,7 +64,8 @@ public class TransferType extends BaseBehaviourBean implements NodeServicePolici */ public void disable() { - getBehaviour(BEHAVIOUR_NAME).disable(); + getBehaviour(CREATE_CHILD_BEHAVIOUR_NAME).disable(); + getBehaviour(EDIT_PROPERTIES_BEHAVIOUR_NAME).disable(); } /** @@ -63,7 +74,8 @@ public class TransferType extends BaseBehaviourBean implements NodeServicePolici */ public void enable() { - getBehaviour(BEHAVIOUR_NAME).enable(); + getBehaviour(CREATE_CHILD_BEHAVIOUR_NAME).enable(); + getBehaviour(EDIT_PROPERTIES_BEHAVIOUR_NAME).enable(); } /** @@ -73,10 +85,24 @@ public class TransferType extends BaseBehaviourBean implements NodeServicePolici @Behaviour ( kind = BehaviourKind.ASSOCIATION, - name = BEHAVIOUR_NAME + name = CREATE_CHILD_BEHAVIOUR_NAME ) public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean isNewNode) { throw new IntegrityException(I18NUtil.getMessage(MSG_ERROR_ADD_CHILD_TO_TRANSFER), null); } + + @Override + @Behaviour + ( + kind = BehaviourKind.CLASS, + name = EDIT_PROPERTIES_BEHAVIOUR_NAME + ) + public void onUpdateProperties(NodeRef nodeRef, Map before, Map after) + { + if(!authenticationUtil.isRunAsUserTheSystemUser()) + { + throw new IntegrityException(I18NUtil.getMessage(MSG_ERROR_EDIT_TRANSFER_PROPERTIES), null); + } + } } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/transfer/TransferServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/transfer/TransferServiceImpl.java index be3775462f..b075a43904 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/transfer/TransferServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/transfer/TransferServiceImpl.java @@ -182,6 +182,7 @@ public class TransferServiceImpl extends ServiceBaseImpl NodeRef transferContainer = filePlanService.getTransferContainer(root); transferContainerType.disable(); + transferType.disable(); try { transferNodeRef = nodeService.createNode(transferContainer, @@ -194,6 +195,7 @@ public class TransferServiceImpl extends ServiceBaseImpl finally { transferContainerType.enable(); + transferType.enable(); } // Bind the hold node reference to the transaction AlfrescoTransactionSupport.bindResource(KEY_TRANSFER_NODEREF, transferNodeRef);