From ea41e5c553aa2da31024aacf7b77527f72b3eceb Mon Sep 17 00:00:00 2001 From: ehardon Date: Thu, 9 Apr 2020 12:16:33 +0300 Subject: [PATCH] RM-6645: Created WhitelistedDMActions for RM site - added whitelisted actions into the rm rule actions --- .../messages/actions.properties | 9 --- .../rm-action-context.xml | 37 ------------ .../rm-webscript-context.xml | 1 + .../scripts/rule/RmActionDefinitionsGet.java | 22 ++++++- .../scripts/rule/WhitelistedDMActions.java | 59 +++++++++++++++++++ 5 files changed, 79 insertions(+), 49 deletions(-) create mode 100644 rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/rule/WhitelistedDMActions.java diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/actions.properties b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/actions.properties index d66c28dd97..8095c5c74e 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/actions.properties +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/actions.properties @@ -46,15 +46,6 @@ isRecordType.description=Records have a specified record type # # i18n for Records Management Actions # - -# Archive -archiveAction.title=Archive to AWS Glacier -archiveAction.description=This marks the specified content to be transitioned to AWS Glacier. -# Restore -restoreAction.title=Restore from AWS Glacier -restoreAction.description=This marks the specified content to be temporary restored from AWS Glacier. -restoreAction.tier.display-label=Restoration tier -restoreAction.expiration-days.display-label=Expiration in days # Declare As Record create-record.title=Declare as Record create-record.description=Declares file as a record and optionally files it diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml index e4d3d4c4a4..d719d76697 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml @@ -1153,42 +1153,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml index aa823d1f99..3416f71190 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml @@ -527,6 +527,7 @@ class="org.alfresco.repo.web.scripts.rule.RmActionDefinitionsGet" parent="webscript"> + diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/rule/RmActionDefinitionsGet.java b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/rule/RmActionDefinitionsGet.java index f419eaf94c..1dee37479d 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/rule/RmActionDefinitionsGet.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/rule/RmActionDefinitionsGet.java @@ -36,6 +36,7 @@ import java.util.Set; import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction; import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; import org.alfresco.service.cmr.action.ActionDefinition; +import org.alfresco.service.cmr.action.ActionService; import org.springframework.extensions.webscripts.Cache; import org.springframework.extensions.webscripts.DeclarativeWebScript; import org.springframework.extensions.webscripts.Status; @@ -50,27 +51,42 @@ import org.springframework.extensions.webscripts.WebScriptRequest; public class RmActionDefinitionsGet extends DeclarativeWebScript { private RecordsManagementActionService recordsManagementActionService; + private ActionService extendedActionService; + + private List whitelistedActions = WhitelistedDMActions.getActionsList(); public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService) { this.recordsManagementActionService = recordsManagementActionService; } + public void setExtendedActionService(ActionService extendedActionService) + { + this.extendedActionService = extendedActionService; + } + /** * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache) */ @Override protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) { - List actions = recordsManagementActionService.getRecordsManagementActions(); - Set defs = new HashSet<>(actions.size()); - for (RecordsManagementAction action : actions) + List rmActions = recordsManagementActionService.getRecordsManagementActions(); + List actions = extendedActionService.getActionDefinitions(); + Set defs = new HashSet<>(rmActions.size()); + for (RecordsManagementAction action : rmActions) { if (action.isPublicAction()) { defs.add(action.getRecordsManagementActionDefinition()); } } + // If there are any DM whitelisted actions for RM add them in the rule actions + for (ActionDefinition actionDefinition: actions) { + if (whitelistedActions.contains(actionDefinition.getName())){ + defs.add(actionDefinition); + } + } Map model = new HashMap<>(); model.put("actiondefinitions", defs); diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/rule/WhitelistedDMActions.java b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/rule/WhitelistedDMActions.java new file mode 100644 index 0000000000..fb43f89ad4 --- /dev/null +++ b/rm-community/rm-community-repo/source/java/org/alfresco/repo/web/scripts/rule/WhitelistedDMActions.java @@ -0,0 +1,59 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2020 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * - + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * - + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * - + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * - + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.repo.web.scripts.rule; + +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/** + * Whitelisted DM actions in RM + */ +public enum WhitelistedDMActions +{ + ARCHIVE("archive"), + RESTORE("restore"); + + private final String value; + + WhitelistedDMActions(String value) + { + this.value = value; + } + + public String getValue() + { + return this.value; + } + + public static List getActionsList() + { + return Stream.of(WhitelistedDMActions.values()) + .map(WhitelistedDMActions::getValue) + .collect(Collectors.toList()); + } +}