RM-6645: Created WhitelistedDMActions for RM site

- added whitelisted actions into the rm rule actions
This commit is contained in:
ehardon
2020-04-09 12:16:33 +03:00
parent 67beca33d4
commit ea41e5c553
5 changed files with 79 additions and 49 deletions

View File

@@ -46,15 +46,6 @@ isRecordType.description=Records have a specified record type
# #
# i18n for Records Management Actions # 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 # Declare As Record
create-record.title=Declare as Record create-record.title=Declare as Record
create-record.description=Declares file as a record and optionally files it create-record.description=Declares file as a record and optionally files it

View File

@@ -1153,42 +1153,5 @@
<property name="publicAction" value="false"/> <property name="publicAction" value="false"/>
<property name="auditable" value="false"/> <property name="auditable" value="false"/>
</bean> </bean>
<!-- Glacier Archive action -->
<bean id="archiveAction_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean"
parent="rmProxyAction" lazy-init="true">
<property name="target">
<ref bean="archiveAction" />
</property>
<property name="interceptorNames">
<list>
<idref bean="allow_security" />
</list>
</property>
</bean>
<bean id="archiveAction" class="org.alfresco.module.org_alfresco_module_rm.action.impl.DelegateAction"
parent="rmAction" lazy-init="true">
<property name="publicAction" value="true" />
<property name="delegateAction" ref="archive" />
</bean>
<!-- Glacier Restore action -->
<bean id="restoreAction_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean"
parent="rmProxyAction" lazy-init="true">
<property name="target">
<ref bean="restoreAction" />
</property>
<property name="interceptorNames">
<list>
<idref bean="allow_security" />
</list>
</property>
</bean>
<bean id="restoreAction" class="org.alfresco.module.org_alfresco_module_rm.action.impl.DelegateAction"
parent="rmAction" lazy-init="true">
<property name="publicAction" value="true" />
<property name="delegateAction" ref="restore" />
</bean>
</beans> </beans>

View File

@@ -527,6 +527,7 @@
class="org.alfresco.repo.web.scripts.rule.RmActionDefinitionsGet" class="org.alfresco.repo.web.scripts.rule.RmActionDefinitionsGet"
parent="webscript"> parent="webscript">
<property name="recordsManagementActionService" ref="RecordsManagementActionService"/> <property name="recordsManagementActionService" ref="RecordsManagementActionService"/>
<property name="extendedActionService" ref="actionService"/>
</bean> </bean>
<!-- REST impl for GET Action Condition Defitions for RM --> <!-- REST impl for GET Action Condition Defitions for RM -->

View File

@@ -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.RecordsManagementAction;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService;
import org.alfresco.service.cmr.action.ActionDefinition; 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.Cache;
import org.springframework.extensions.webscripts.DeclarativeWebScript; import org.springframework.extensions.webscripts.DeclarativeWebScript;
import org.springframework.extensions.webscripts.Status; import org.springframework.extensions.webscripts.Status;
@@ -50,27 +51,42 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
public class RmActionDefinitionsGet extends DeclarativeWebScript public class RmActionDefinitionsGet extends DeclarativeWebScript
{ {
private RecordsManagementActionService recordsManagementActionService; private RecordsManagementActionService recordsManagementActionService;
private ActionService extendedActionService;
private List<String> whitelistedActions = WhitelistedDMActions.getActionsList();
public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService) public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService)
{ {
this.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) * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache)
*/ */
@Override @Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{ {
List<RecordsManagementAction> actions = recordsManagementActionService.getRecordsManagementActions(); List<RecordsManagementAction> rmActions = recordsManagementActionService.getRecordsManagementActions();
Set<ActionDefinition> defs = new HashSet<>(actions.size()); List<ActionDefinition> actions = extendedActionService.getActionDefinitions();
for (RecordsManagementAction action : actions) Set<ActionDefinition> defs = new HashSet<>(rmActions.size());
for (RecordsManagementAction action : rmActions)
{ {
if (action.isPublicAction()) if (action.isPublicAction())
{ {
defs.add(action.getRecordsManagementActionDefinition()); 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<String, Object> model = new HashMap<>(); Map<String, Object> model = new HashMap<>();
model.put("actiondefinitions", defs); model.put("actiondefinitions", defs);

View File

@@ -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 <http://www.gnu.org/licenses/>.
* #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<String> getActionsList()
{
return Stream.of(WhitelistedDMActions.values())
.map(WhitelistedDMActions::getValue)
.collect(Collectors.toList());
}
}