mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-638: A records admin can choose from a specialised list of RM relevant conditions when defining a records rule
* refactor how we extend the rule's UI * existing rule's UI is left uneffected .. config no longer needs to be overriden .. so custom config will not effect RM * web scripts overriden to use RM specific action and condition UI config * actions and conditions not added to general pool of those available from the rules service ... means no filtering is required on the main UI * module filter used to override component and redirect to the overridden webscripts * server side support of records management conditions added * isFiled and isDeclared conditions added * TODO .. still a couple of lose ends to tie up git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@48659 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -17,7 +17,9 @@
|
||||
<bean id="rmCapabilityConditionEvaluator"
|
||||
parent="action-condition-evaluator"
|
||||
abstract="true"
|
||||
class="org.alfresco.module.org_alfresco_module_rm.action.evaluator.CapabilityConditionEvaluator"/>
|
||||
class="org.alfresco.module.org_alfresco_module_rm.action.evaluator.CapabilityConditionEvaluator">
|
||||
<property name="recordsManagementActionService" ref="recordsManagementActionService" />
|
||||
</bean>
|
||||
|
||||
<bean id="isDeclared" parent="rmCapabilityConditionEvaluator">
|
||||
<property name="capabilityCondition" ref="capabilityCondition.declared"/>
|
||||
|
@@ -764,6 +764,7 @@
|
||||
<value>
|
||||
<![CDATA[
|
||||
org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService.getRecordsManagementActions=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService.getRecordsManagementActionConditions=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService.getDispositionActions=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService.getRecordsManagementAction=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService.getDispositionAction=RM_ALLOW
|
||||
|
@@ -514,14 +514,7 @@
|
||||
<bean id="webscript.org.alfresco.repository.rule.rm-actiondefinitions.get"
|
||||
class="org.alfresco.repo.web.scripts.rule.RmActionDefinitionsGet"
|
||||
parent="webscript">
|
||||
<property name="actionService" ref="ActionService"/>
|
||||
</bean>
|
||||
|
||||
<!-- REST impl for GET Action Defitions for DM -->
|
||||
<bean id="webscript.org.alfresco.repository.rule.dm-actiondefinitions.get"
|
||||
class="org.alfresco.repo.web.scripts.rule.DmActionDefinitionsGet"
|
||||
parent="webscript">
|
||||
<property name="actionService" ref="ActionService"/>
|
||||
<property name="recordsManagementActionService" ref="RecordsManagementActionService"/>
|
||||
</bean>
|
||||
|
||||
<!-- REST impl for GET Action Condition Defitions for RM -->
|
||||
@@ -529,12 +522,7 @@
|
||||
class="org.alfresco.repo.web.scripts.rule.RmActionConditionDefinitionsGet"
|
||||
parent="webscript">
|
||||
<property name="actionService" ref="ActionService"/>
|
||||
</bean>
|
||||
|
||||
<bean id="webscript.org.alfresco.repository.rule.dm-actionconditiondefinitions.get"
|
||||
class="org.alfresco.repo.web.scripts.rule.DmActionConditionDefinitionsGet"
|
||||
parent="webscript">
|
||||
<property name="actionService" ref="ActionService"/>
|
||||
<property name="recordsManagementActionService" ref="RecordsManagementActionService"/>
|
||||
</bean>
|
||||
|
||||
<!-- REST impl for GET Class Definitions for RM/DM -->
|
||||
|
@@ -1,8 +0,0 @@
|
||||
<webscript>
|
||||
<shortname>Get action condition definition collection for DM</shortname>
|
||||
<description>Gets a collection of the available action condition definitions in DM.</description>
|
||||
<url>/api/rm/dm-actionconditiondefinitions</url>
|
||||
<format default="json">argument</format>
|
||||
<authentication>user</authentication>
|
||||
<transaction allow="readonly">required</transaction>
|
||||
</webscript>
|
@@ -1 +0,0 @@
|
||||
<#include "actionconditiondefinitions.get.json.ftl">
|
@@ -1,8 +0,0 @@
|
||||
<webscript>
|
||||
<shortname>Get action definition collection for DM</shortname>
|
||||
<description>Gets a collection of the available action definitions in DM.</description>
|
||||
<url>/api/rm/dm-actiondefinitions</url>
|
||||
<format default="json">argument</format>
|
||||
<authentication>user</authentication>
|
||||
<transaction allow="readonly">required</transaction>
|
||||
</webscript>
|
@@ -1 +0,0 @@
|
||||
<#include "actiondefinitions.get.json.ftl">
|
@@ -297,6 +297,15 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe
|
||||
return actionDefinition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction#getRecordsManagementActionDefinition()
|
||||
*/
|
||||
@Override
|
||||
public RecordsManagementActionDefinition getRecordsManagementActionDefinition()
|
||||
{
|
||||
return (RecordsManagementActionDefinition)getActionDefinition();
|
||||
}
|
||||
|
||||
/**
|
||||
* Init method
|
||||
*/
|
||||
@@ -322,6 +331,7 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe
|
||||
*
|
||||
* @return boolean true if public, false otherwise
|
||||
*/
|
||||
@Override
|
||||
public boolean isPublicAction()
|
||||
{
|
||||
return publicAction;
|
||||
@@ -631,4 +641,6 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe
|
||||
|
||||
return eligible;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -74,4 +74,18 @@ public interface RecordsManagementAction
|
||||
* @return the target nodeRef
|
||||
*/
|
||||
public NodeRef getImplicitTargetNodeRef();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @since 2.1
|
||||
*/
|
||||
public RecordsManagementActionDefinition getRecordsManagementActionDefinition();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @since 2.1
|
||||
*/
|
||||
public boolean isPublicAction();
|
||||
}
|
||||
|
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.action;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Record Management Action Condition
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public interface RecordsManagementActionCondition
|
||||
{
|
||||
/**
|
||||
* Get the name of the action condition
|
||||
*
|
||||
* @return String action condition name
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Get the label of the action condition
|
||||
*
|
||||
* @return String action condition label
|
||||
*/
|
||||
public String getLabel();
|
||||
|
||||
/**
|
||||
* Get the description of the action condition
|
||||
*
|
||||
* @return String action condition description
|
||||
*/
|
||||
public String getDescription();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public RecordsManagementActionConditionDefinition getRecordsManagementActionConditionDefinition();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isPublicCondition();
|
||||
}
|
@@ -18,6 +18,8 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.action;
|
||||
|
||||
import org.alfresco.service.cmr.action.ActionConditionDefinition;
|
||||
|
||||
/**
|
||||
* Records management condition definition.
|
||||
*
|
||||
@@ -26,6 +28,6 @@ package org.alfresco.module.org_alfresco_module_rm.action;
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public interface RecordsManagementActionConditionDefinition
|
||||
public interface RecordsManagementActionConditionDefinition extends ActionConditionDefinition
|
||||
{
|
||||
}
|
||||
|
@@ -23,6 +23,9 @@ import java.util.List;
|
||||
import org.alfresco.repo.action.evaluator.ActionConditionEvaluatorAbstractBase;
|
||||
import org.alfresco.service.cmr.action.ActionConditionDefinition;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Records management action condition evaluator abstract base implementation.
|
||||
@@ -31,7 +34,91 @@ import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
* @since 2.1
|
||||
*/
|
||||
public abstract class RecordsManagementActionConditionEvaluatorAbstractBase extends ActionConditionEvaluatorAbstractBase
|
||||
implements RecordsManagementActionCondition,
|
||||
BeanNameAware
|
||||
{
|
||||
/** records management action service */
|
||||
private RecordsManagementActionService recordsManagementActionService;
|
||||
|
||||
/** bean name */
|
||||
private String name;
|
||||
|
||||
/** public condition */
|
||||
protected boolean publicCondition = true;
|
||||
|
||||
/**
|
||||
* @param recordsManagementActionService records management action service
|
||||
*/
|
||||
public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService)
|
||||
{
|
||||
this.recordsManagementActionService = recordsManagementActionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.evaluator.ActionConditionEvaluatorAbstractBase#init()
|
||||
*/
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
// override to prevent condition being registered with the core action service
|
||||
recordsManagementActionService.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPublicCondition(boolean publicCondition)
|
||||
{
|
||||
this.publicCondition = publicCondition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.CommonResourceAbstractBase#setBeanName(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setBeanName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAction#getName()
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction#getLabel()
|
||||
*/
|
||||
public String getLabel()
|
||||
{
|
||||
String label = I18NUtil.getMessage(this.getTitleKey());
|
||||
|
||||
if (label == null)
|
||||
{
|
||||
// default to the name of the action with first letter capitalised
|
||||
label = StringUtils.capitalize(this.name);
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction#getDescription()
|
||||
*/
|
||||
public String getDescription()
|
||||
{
|
||||
String desc = I18NUtil.getMessage(this.getDescriptionKey());
|
||||
|
||||
if (desc == null)
|
||||
{
|
||||
// default to the name of the action with first letter capitalised
|
||||
desc = StringUtils.capitalize(this.name);
|
||||
}
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.evaluator.ActionConditionEvaluatorAbstractBase#getActionConditionDefintion()
|
||||
*
|
||||
@@ -62,4 +149,22 @@ public abstract class RecordsManagementActionConditionEvaluatorAbstractBase exte
|
||||
// No param implementation by default
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionCondition#isPublicCondition()
|
||||
*/
|
||||
@Override
|
||||
public boolean isPublicCondition()
|
||||
{
|
||||
return publicCondition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionCondition#getRecordsManagementActionConditionDefinition()
|
||||
*/
|
||||
@Override
|
||||
public RecordsManagementActionConditionDefinition getRecordsManagementActionConditionDefinition()
|
||||
{
|
||||
return (RecordsManagementActionConditionDefinition)getActionConditionDefintion();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -21,6 +21,7 @@ package org.alfresco.module.org_alfresco_module_rm.action;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.FilePlanComponentKind;
|
||||
import org.alfresco.service.cmr.action.ActionDefinition;
|
||||
|
||||
/**
|
||||
* Extended action definition interface.
|
||||
@@ -28,7 +29,7 @@ import org.alfresco.module.org_alfresco_module_rm.FilePlanComponentKind;
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public interface RecordsManagementActionDefinition
|
||||
public interface RecordsManagementActionDefinition extends ActionDefinition
|
||||
{
|
||||
/**
|
||||
* @return list of applicable file plan component kinds
|
||||
|
@@ -39,6 +39,13 @@ public interface RecordsManagementActionService
|
||||
*/
|
||||
List<RecordsManagementAction> getRecordsManagementActions();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @since 2.1
|
||||
*/
|
||||
List<RecordsManagementActionCondition> getRecordsManagementActionConditions();
|
||||
|
||||
/**
|
||||
* Get a list of the available disposition actions. A disposition action is a records
|
||||
* management action that can be used when defining disposition instructions.
|
||||
@@ -112,4 +119,11 @@ public interface RecordsManagementActionService
|
||||
* @param rmAction records management action
|
||||
*/
|
||||
void register(RecordsManagementAction rmAction);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param rmCondition
|
||||
* @since 2.1
|
||||
*/
|
||||
void register(RecordsManagementActionCondition rmCondition);
|
||||
}
|
||||
|
@@ -55,7 +55,8 @@ public class RecordsManagementActionServiceImpl implements RecordsManagementActi
|
||||
private static Log logger = LogFactory.getLog(RecordsManagementActionServiceImpl.class);
|
||||
|
||||
/** Registered records management actions */
|
||||
private Map<String, RecordsManagementAction> rmActions = new HashMap<String, RecordsManagementAction>(6);
|
||||
private Map<String, RecordsManagementAction> rmActions = new HashMap<String, RecordsManagementAction>(13);
|
||||
private Map<String, RecordsManagementActionCondition> rmConditions = new HashMap<String, RecordsManagementActionCondition>(13);
|
||||
private Map<String, RecordsManagementAction> dispositionActions = new HashMap<String, RecordsManagementAction>(4);
|
||||
|
||||
/** Policy component */
|
||||
@@ -114,6 +115,14 @@ public class RecordsManagementActionServiceImpl implements RecordsManagementActi
|
||||
}
|
||||
}
|
||||
|
||||
public void register(RecordsManagementActionCondition rmCondition)
|
||||
{
|
||||
if (rmConditions.containsKey(rmCondition.getName()) == false)
|
||||
{
|
||||
rmConditions.put(rmCondition.getName(), rmCondition);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke beforeRMActionExecution policy
|
||||
*
|
||||
@@ -156,6 +165,17 @@ public class RecordsManagementActionServiceImpl implements RecordsManagementActi
|
||||
return Collections.unmodifiableList(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService#getRecordsManagementActionConditions()
|
||||
*/
|
||||
@Override
|
||||
public List<RecordsManagementActionCondition> getRecordsManagementActionConditions()
|
||||
{
|
||||
List<RecordsManagementActionCondition> result = new ArrayList<RecordsManagementActionCondition>(rmConditions.size());
|
||||
result.addAll(rmConditions.values());
|
||||
return Collections.unmodifiableList(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService#getDispositionActions(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
|
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2012 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.action.evaluator;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionConditionEvaluatorAbstractBase;
|
||||
import org.alfresco.repo.action.evaluator.ActionConditionEvaluator;
|
||||
import org.alfresco.service.cmr.action.ActionCondition;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Records management action condition who's implementation is delegated to an existing
|
||||
* action condition.
|
||||
* <p>
|
||||
* Useful for creating a RM version of an existing action condition implementation.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public class DelegateActionCondition extends RecordsManagementActionConditionEvaluatorAbstractBase
|
||||
{
|
||||
/** Delegate action evaluator */
|
||||
private ActionConditionEvaluator actionConditionEvaluator;
|
||||
|
||||
/**
|
||||
* @param actionEvaluator action evaluator
|
||||
*/
|
||||
public void setActionConditionEvaluator(ActionConditionEvaluator actionConditionEvaluator)
|
||||
{
|
||||
this.actionConditionEvaluator = actionConditionEvaluator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.evaluator.ActionConditionEvaluatorAbstractBase#evaluateImpl(org.alfresco.service.cmr.action.ActionCondition, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected boolean evaluateImpl(ActionCondition actionCondition, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
return actionConditionEvaluator.evaluate(actionCondition, actionedUponNodeRef);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.ParameterizedItemAbstractBase#getParameterDefintions()
|
||||
*/
|
||||
@Override
|
||||
protected List<ParameterDefinition> getParameterDefintions()
|
||||
{
|
||||
return actionConditionEvaluator.getActionConditionDefintion().getParameterDefinitions();
|
||||
}
|
||||
|
||||
}
|
@@ -18,11 +18,9 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.capability;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService;
|
||||
import org.alfresco.repo.action.RuntimeActionService;
|
||||
import org.alfresco.repo.action.executer.ActionExecuter;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.springframework.aop.framework.ProxyFactoryBean;
|
||||
|
||||
@@ -60,10 +58,10 @@ public class RMActionProxyFactoryBean extends ProxyFactoryBean
|
||||
{
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
if (((RMActionExecuterAbstractBase)getTargetSource().getTarget()).isPublicAction() == true)
|
||||
{
|
||||
runtimeActionService.registerActionExecuter((ActionExecuter) getObject());
|
||||
}
|
||||
// if (((RMActionExecuterAbstractBase)getTargetSource().getTarget()).isPublicAction() == true)
|
||||
// {
|
||||
// runtimeActionService.registerActionExecuter((ActionExecuter) getObject());
|
||||
// }
|
||||
recordsManagementActionService.register((RecordsManagementAction) getObject());
|
||||
return null;
|
||||
}
|
||||
|
@@ -1,116 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2012 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.rule;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionConditionDefinition;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionDefinition;
|
||||
import org.alfresco.service.cmr.action.ActionConditionDefinition;
|
||||
import org.alfresco.service.cmr.action.ActionDefinition;
|
||||
import org.alfresco.service.cmr.action.ActionService;
|
||||
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
||||
|
||||
/**
|
||||
* An abstract class for the java backed webscripts to get the filtered action definition list.
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.1
|
||||
*/
|
||||
public class AbstractActionDefinitionsGet extends DeclarativeWebScript
|
||||
{
|
||||
private ActionService actionService;
|
||||
|
||||
public void setActionService(ActionService actionService)
|
||||
{
|
||||
this.actionService = actionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a model with the filtered action definitions
|
||||
*
|
||||
* @param removeRmRelatedActionDefs if true the rm related action definitions will be removed, otherwise dm related actions
|
||||
* @return Map<String, Object> the model with the filtered action definitions
|
||||
*/
|
||||
protected Map<String, Object> getModelWithFilteredActionDefinitions(boolean removeRmRelatedActionDefs)
|
||||
{
|
||||
// get all action definitions and filter them
|
||||
List<ActionDefinition> actiondefinitions = filterActionDefinitons(actionService.getActionDefinitions(), removeRmRelatedActionDefs);
|
||||
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
model.put("actiondefinitions", actiondefinitions);
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param removeRmDefs
|
||||
* @return
|
||||
*/
|
||||
protected Map<String, Object> getModelWithFilteredActionConditionDefinitions(boolean removeRmDefs)
|
||||
{
|
||||
List<ActionConditionDefinition> defs = filterActionConditionDefinitons(actionService.getActionConditionDefinitions(), removeRmDefs);
|
||||
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
model.put("actionconditiondefinitions", defs);
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the action definition list
|
||||
*
|
||||
* @param actionDefinitions the list of action definitions to filter
|
||||
* @param removeRmRelatedActionDefs if true the rm related action definitions will be removed, otherwise dm related actions
|
||||
* @return List<ActionDefinition> the filtered list of action definitions
|
||||
*/
|
||||
private List<ActionDefinition> filterActionDefinitons(List<ActionDefinition> actionDefinitions, boolean removeRmRelatedActionDefs)
|
||||
{
|
||||
for (Iterator<ActionDefinition> iterator = actionDefinitions.iterator(); iterator.hasNext();)
|
||||
{
|
||||
if ((iterator.next() instanceof RecordsManagementActionDefinition) == removeRmRelatedActionDefs)
|
||||
{
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
return actionDefinitions;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param defs
|
||||
* @param removeRmRelated
|
||||
* @return
|
||||
*/
|
||||
private List<ActionConditionDefinition> filterActionConditionDefinitons(List<ActionConditionDefinition> defs, boolean removeRmRelated)
|
||||
{
|
||||
for (Iterator<ActionConditionDefinition> iterator = defs.iterator(); iterator.hasNext();)
|
||||
{
|
||||
if ((iterator.next() instanceof RecordsManagementActionConditionDefinition) == removeRmRelated)
|
||||
{
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
return defs;
|
||||
}
|
||||
}
|
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.rule;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.extensions.webscripts.Cache;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
|
||||
/**
|
||||
* Implementation for java backed webscript to get the DM related action condition definition list.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public class DmActionConditionDefinitionsGet extends AbstractActionDefinitionsGet
|
||||
{
|
||||
/**
|
||||
* @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<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||
{
|
||||
return getModelWithFilteredActionConditionDefinitions(true);
|
||||
}
|
||||
}
|
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.rule;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.extensions.webscripts.Cache;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
|
||||
/**
|
||||
* Implementation for java backed webscript to get the DM related action definition list.
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.1
|
||||
*/
|
||||
public class DmActionDefinitionsGet extends AbstractActionDefinitionsGet
|
||||
{
|
||||
/**
|
||||
* @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<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||
{
|
||||
return getModelWithFilteredActionDefinitions(true);
|
||||
}
|
||||
}
|
@@ -18,9 +18,17 @@
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.rule;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionCondition;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService;
|
||||
import org.alfresco.service.cmr.action.ActionConditionDefinition;
|
||||
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;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
|
||||
@@ -30,14 +38,44 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public class RmActionConditionDefinitionsGet extends AbstractActionDefinitionsGet
|
||||
public class RmActionConditionDefinitionsGet extends DeclarativeWebScript
|
||||
{
|
||||
private ActionService actionService;
|
||||
|
||||
private RecordsManagementActionService recordsManagementActionService;
|
||||
|
||||
public void setActionService(ActionService actionService)
|
||||
{
|
||||
this.actionService = actionService;
|
||||
}
|
||||
|
||||
public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService)
|
||||
{
|
||||
this.recordsManagementActionService = recordsManagementActionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||
{
|
||||
return getModelWithFilteredActionConditionDefinitions(false);
|
||||
List<ActionConditionDefinition> dmDefs = actionService.getActionConditionDefinitions();
|
||||
List<RecordsManagementActionCondition> conditions = recordsManagementActionService.getRecordsManagementActionConditions();
|
||||
|
||||
List<ActionConditionDefinition> defs = new ArrayList<ActionConditionDefinition>(dmDefs.size()+conditions.size());
|
||||
defs.addAll(dmDefs);
|
||||
for (RecordsManagementActionCondition condition: conditions)
|
||||
{
|
||||
if (condition.isPublicCondition() == true)
|
||||
{
|
||||
defs.add(condition.getRecordsManagementActionConditionDefinition());
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
model.put("actionconditiondefinitions", defs);
|
||||
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
@@ -18,9 +18,17 @@
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.rule;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
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.springframework.extensions.webscripts.Cache;
|
||||
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
|
||||
@@ -30,14 +38,34 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
* @author Tuna Aksoy
|
||||
* @since 2.1
|
||||
*/
|
||||
public class RmActionDefinitionsGet extends AbstractActionDefinitionsGet
|
||||
public class RmActionDefinitionsGet extends DeclarativeWebScript
|
||||
{
|
||||
private RecordsManagementActionService recordsManagementActionService;
|
||||
|
||||
public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService)
|
||||
{
|
||||
this.recordsManagementActionService = recordsManagementActionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||
{
|
||||
return getModelWithFilteredActionDefinitions(false);
|
||||
List<RecordsManagementAction> actions = recordsManagementActionService.getRecordsManagementActions();
|
||||
Set<ActionDefinition> defs = new HashSet<ActionDefinition>(actions.size());
|
||||
for (RecordsManagementAction action : actions)
|
||||
{
|
||||
if (action.isPublicAction() == true)
|
||||
{
|
||||
defs.add(action.getRecordsManagementActionDefinition());
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
model.put("actiondefinitions", defs);
|
||||
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user