mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM Action extensions to core service:
* rm actions can be applicable to only certain 'kinds' of RM artifacts * when retrieveing with context, RM actions are only applicable to RM artifacts and vice verca for DM objects * delegate RM action available to be configured against existing DM actions * unit tests git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@45699 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
|
||||
|
||||
<beans>
|
||||
|
||||
<bean id="permissionServiceImpl" class="org.alfresco.repo.security.permissions.impl.RMPermissionServiceImpl" init-method="init">
|
||||
<property name="nodeService">
|
||||
<ref bean="mtAwareNodeService" />
|
||||
</property>
|
||||
<property name="tenantService">
|
||||
<ref bean="tenantService"/>
|
||||
</property>
|
||||
<property name="dictionaryService">
|
||||
<ref bean="dictionaryService" />
|
||||
</property>
|
||||
<property name="permissionsDaoComponent">
|
||||
<ref bean="permissionsDaoComponent" />
|
||||
</property>
|
||||
<property name="modelDAO">
|
||||
<ref bean="permissionsModelDAO" />
|
||||
</property>
|
||||
<property name="authorityService">
|
||||
<ref bean="authorityService" />
|
||||
</property>
|
||||
<property name="accessCache">
|
||||
<ref bean="permissionsAccessCache" />
|
||||
</property>
|
||||
<property name="readersCache">
|
||||
<ref bean="readersCache" />
|
||||
</property>
|
||||
<property name="readersDeniedCache">
|
||||
<ref bean="readersDeniedCache" />
|
||||
</property>
|
||||
<property name="policyComponent">
|
||||
<ref bean="policyComponent" />
|
||||
</property>
|
||||
<property name="aclDAO">
|
||||
<ref bean="aclDAO" />
|
||||
</property>
|
||||
<property name="ownableService">
|
||||
<ref bean="ownableService" />
|
||||
</property>
|
||||
<property name="anyDenyDenies">
|
||||
<value>${security.anyDenyDenies}</value>
|
||||
</property>
|
||||
<property name="dynamicAuthorities">
|
||||
<list>
|
||||
<ref bean="ownerDynamicAuthority" />
|
||||
<ref bean="lockOwnerDynamicAuthority" />
|
||||
<ref bean="extendedReaderDynamicAuthority" />
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="extendedReaderDynamicAuthority" class="org.alfresco.module.org_alfresco_module_rm.security.ExtendedReaderDynamicAuthority" />
|
||||
|
||||
<!-- Action Service -->
|
||||
<bean id="actionService" class="org.alfresco.repo.action.ExtendedActionServiceImpl" init-method="init">
|
||||
|
||||
<property name="recordsManagementService" ref="RecordsManagementService" />
|
||||
|
||||
<property name="policyComponent">
|
||||
<ref bean="policyComponent" />
|
||||
</property>
|
||||
<property name="nodeService">
|
||||
<ref bean="NodeService" />
|
||||
</property>
|
||||
<property name="searchService">
|
||||
<ref bean="ADMSearchService" />
|
||||
</property>
|
||||
<property name="authenticationContext">
|
||||
<ref bean="authenticationContext" />
|
||||
</property>
|
||||
<property name="actionTrackingService">
|
||||
<ref bean="actionTrackingService" />
|
||||
</property>
|
||||
<property name="dictionaryService">
|
||||
<ref bean="DictionaryService" />
|
||||
</property>
|
||||
<property name="monitor">
|
||||
<ref bean="actionServiceMonitor"/>
|
||||
</property>
|
||||
|
||||
<property name="asynchronousActionExecutionQueues">
|
||||
<map>
|
||||
<!-- This is the default async queue -->
|
||||
<entry key="">
|
||||
<ref bean="defaultAsynchronousActionExecutionQueue"/>
|
||||
</entry>
|
||||
<entry key="deployment">
|
||||
<ref bean="deploymentAsynchronousActionExecutionQueue"/>
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
@@ -2,56 +2,8 @@
|
||||
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
|
||||
|
||||
<beans>
|
||||
<bean id="permissionServiceImpl" class="org.alfresco.repo.security.permissions.impl.RMPermissionServiceImpl" init-method="init">
|
||||
<property name="nodeService">
|
||||
<ref bean="mtAwareNodeService" />
|
||||
</property>
|
||||
<property name="tenantService">
|
||||
<ref bean="tenantService"/>
|
||||
</property>
|
||||
<property name="dictionaryService">
|
||||
<ref bean="dictionaryService" />
|
||||
</property>
|
||||
<property name="permissionsDaoComponent">
|
||||
<ref bean="permissionsDaoComponent" />
|
||||
</property>
|
||||
<property name="modelDAO">
|
||||
<ref bean="permissionsModelDAO" />
|
||||
</property>
|
||||
<property name="authorityService">
|
||||
<ref bean="authorityService" />
|
||||
</property>
|
||||
<property name="accessCache">
|
||||
<ref bean="permissionsAccessCache" />
|
||||
</property>
|
||||
<property name="readersCache">
|
||||
<ref bean="readersCache" />
|
||||
</property>
|
||||
<property name="readersDeniedCache">
|
||||
<ref bean="readersDeniedCache" />
|
||||
</property>
|
||||
<property name="policyComponent">
|
||||
<ref bean="policyComponent" />
|
||||
</property>
|
||||
<property name="aclDAO">
|
||||
<ref bean="aclDAO" />
|
||||
</property>
|
||||
<property name="ownableService">
|
||||
<ref bean="ownableService" />
|
||||
</property>
|
||||
<property name="anyDenyDenies">
|
||||
<value>${security.anyDenyDenies}</value>
|
||||
</property>
|
||||
<property name="dynamicAuthorities">
|
||||
<list>
|
||||
<ref bean="ownerDynamicAuthority" />
|
||||
<ref bean="lockOwnerDynamicAuthority" />
|
||||
<ref bean="extendedReaderDynamicAuthority" />
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="extendedReaderDynamicAuthority" class="org.alfresco.module.org_alfresco_module_rm.security.ExtendedReaderDynamicAuthority" />
|
||||
<import resource="classpath:alfresco/module/org_alfresco_module_rm/extended-repository-context.xml"/>
|
||||
|
||||
<!-- Bootstrap records management data -->
|
||||
<bean id="org_alfresco_module_rm_bootstrapData"
|
||||
|
@@ -251,7 +251,6 @@
|
||||
<bean id="reviewed" class="org.alfresco.module.org_alfresco_module_rm.vital.ReviewedAction" parent="rmAction" depends-on="rmCycleVitalRecordsCapability" />
|
||||
|
||||
<!-- declare record -->
|
||||
<!-- fileable?? -->
|
||||
|
||||
<bean id="declareRecord_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
||||
<property name="target">
|
||||
@@ -275,6 +274,7 @@
|
||||
</bean>
|
||||
|
||||
<bean id="declareRecord" class="org.alfresco.module.org_alfresco_module_rm.action.impl.DeclareRecordAction" parent="rmAction">
|
||||
<property name="publicAction" value="true"/>
|
||||
</bean>
|
||||
|
||||
<!-- undeclare record -->
|
||||
|
@@ -21,9 +21,12 @@ package org.alfresco.module.org_alfresco_module_rm.action;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
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.FilePlanComponentKind;
|
||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService;
|
||||
@@ -39,8 +42,10 @@ import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService;
|
||||
import org.alfresco.repo.action.ExtendedActionDefinitionImpl;
|
||||
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ActionDefinition;
|
||||
import org.alfresco.service.cmr.action.ActionService;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
@@ -117,12 +122,8 @@ public abstract class RMActionExecuterAbstractBase extends ActionExecuterAbstra
|
||||
/** Freeze Service */
|
||||
protected FreezeService freezeService;
|
||||
|
||||
// protected LinkedList<AbstractCapability> capabilities = new LinkedList<AbstractCapability>();;
|
||||
|
||||
/** Default constructor */
|
||||
public RMActionExecuterAbstractBase()
|
||||
{
|
||||
}
|
||||
/** List of kinds for which this action is applicable */
|
||||
protected Set<FilePlanComponentKind> applicableKinds = new HashSet<FilePlanComponentKind>();
|
||||
|
||||
/**
|
||||
* Set the namespace service
|
||||
@@ -250,16 +251,53 @@ public abstract class RMActionExecuterAbstractBase extends ActionExecuterAbstra
|
||||
this.recordService = recordService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param recordsManagementAdminService records management admin service
|
||||
*/
|
||||
public void setRecordsManagementAdminService(RecordsManagementAdminService recordsManagementAdminService)
|
||||
{
|
||||
this.recordsManagementAdminService = recordsManagementAdminService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return records management admin service
|
||||
*/
|
||||
public RecordsManagementAdminService getRecordsManagementAdminService()
|
||||
{
|
||||
return recordsManagementAdminService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param applicableKinds kinds that this action is applicable for
|
||||
*/
|
||||
public void setApplicableKinds(String[] applicableKinds)
|
||||
{
|
||||
for(String kind : applicableKinds)
|
||||
{
|
||||
this.applicableKinds.add(FilePlanComponentKind.valueOf(kind));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#createActionDefinition(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
protected ActionDefinition createActionDefinition(String name)
|
||||
{
|
||||
return new ExtendedActionDefinitionImpl(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#getActionDefinition()
|
||||
*/
|
||||
@Override
|
||||
public ActionDefinition getActionDefinition()
|
||||
{
|
||||
ActionDefinition actionDefinition = super.getActionDefinition();
|
||||
((ExtendedActionDefinitionImpl)this.actionDefinition).setApplicableKinds(applicableKinds);
|
||||
return actionDefinition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init method
|
||||
*/
|
||||
@@ -307,7 +345,7 @@ public abstract class RMActionExecuterAbstractBase extends ActionExecuterAbstra
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction#getLabel()
|
||||
*/
|
||||
public String getLabel()
|
||||
@@ -323,7 +361,7 @@ public abstract class RMActionExecuterAbstractBase extends ActionExecuterAbstra
|
||||
return label;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction#getDescription()
|
||||
*/
|
||||
public String getDescription()
|
||||
@@ -410,6 +448,12 @@ public abstract class RMActionExecuterAbstractBase extends ActionExecuterAbstra
|
||||
return isExecutableImpl(filePlanComponent, parameters, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param filePlanComponent
|
||||
* @param parameters
|
||||
* @param throwException
|
||||
* @return
|
||||
*/
|
||||
protected abstract boolean isExecutableImpl(NodeRef filePlanComponent, Map<String, Serializable> parameters, boolean throwException);
|
||||
|
||||
/**
|
||||
|
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.action.executer.ActionExecuter;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Records management action who's implementation is delegated to an existing Action.
|
||||
* <p>
|
||||
* Useful for creating a RM version of an existing action implementation.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public class RMDelegateAction extends RMActionExecuterAbstractBase
|
||||
{
|
||||
/** Delegate action executer*/
|
||||
private ActionExecuter delegateActionExecuter;
|
||||
|
||||
/**
|
||||
* @param delegateActionExecuter delegate action executer
|
||||
*/
|
||||
public void setDelegateAction(ActionExecuter delegateActionExecuter)
|
||||
{
|
||||
this.delegateActionExecuter = delegateActionExecuter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase#isExecutableImpl(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, boolean)
|
||||
*/
|
||||
@Override
|
||||
protected boolean isExecutableImpl(NodeRef filePlanComponent, Map<String, Serializable> parameters, boolean throwException)
|
||||
{
|
||||
// always return true as we can't determine anything useful from the delegate action
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
delegateActionExecuter.execute(action, actionedUponNodeRef);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.ParameterizedItemAbstractBase#getParameterDefintions()
|
||||
*/
|
||||
@Override
|
||||
protected List<ParameterDefinition> getParameterDefintions()
|
||||
{
|
||||
return delegateActionExecuter.getActionDefinition().getParameterDefinitions();
|
||||
}
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.action;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.FilePlanComponentKind;
|
||||
|
||||
/**
|
||||
* Extended action definition interface.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public interface ExtendedActionDefinition
|
||||
{
|
||||
/**
|
||||
* @return list of applicable file plan component kinds
|
||||
*/
|
||||
Set<FilePlanComponentKind> getApplicableKinds();
|
||||
}
|
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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.action;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.FilePlanComponentKind;
|
||||
|
||||
/**
|
||||
* Extended action definition implementation.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public class ExtendedActionDefinitionImpl extends ActionDefinitionImpl implements ExtendedActionDefinition
|
||||
{
|
||||
/** generated serial version id */
|
||||
private static final long serialVersionUID = -5226538434707253206L;
|
||||
|
||||
/** Applicable kinds */
|
||||
private Set<FilePlanComponentKind> applicableKinds;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*
|
||||
* @param name action definition name
|
||||
*/
|
||||
public ExtendedActionDefinitionImpl(String name)
|
||||
{
|
||||
super(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param applicableKinds applicable kinds
|
||||
*/
|
||||
public void setApplicableKinds(Set<FilePlanComponentKind> applicableKinds)
|
||||
{
|
||||
this.applicableKinds = applicableKinds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.ExtendedActionDefinition#getApplicableKinds()
|
||||
*/
|
||||
@Override
|
||||
public Set<FilePlanComponentKind> getApplicableKinds()
|
||||
{
|
||||
return applicableKinds;
|
||||
}
|
||||
}
|
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* 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.action;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.FilePlanComponentKind;
|
||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
|
||||
import org.alfresco.service.cmr.action.ActionDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Extended action service implementation.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public class ExtendedActionServiceImpl extends ActionServiceImpl
|
||||
{
|
||||
/** Records management service */
|
||||
private RecordsManagementService recordsManagementService;
|
||||
|
||||
/**
|
||||
* @param recordsManagementService records management service
|
||||
*/
|
||||
public void setRecordsManagementService(RecordsManagementService recordsManagementService)
|
||||
{
|
||||
this.recordsManagementService = recordsManagementService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.ActionServiceImpl#getActionDefinitions(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public List<ActionDefinition> getActionDefinitions(NodeRef nodeRef)
|
||||
{
|
||||
List<ActionDefinition> result = null;
|
||||
|
||||
// first use the base implementation to get the list of action definitions
|
||||
List<ActionDefinition> actionDefinitions = super.getActionDefinitions(nodeRef);
|
||||
|
||||
if (nodeRef == null)
|
||||
{
|
||||
// nothing to filter
|
||||
result = actionDefinitions;
|
||||
}
|
||||
else
|
||||
{
|
||||
// get the file component kind of the node reference
|
||||
FilePlanComponentKind kind = recordsManagementService.getFilePlanComponentKind(nodeRef);
|
||||
result = new ArrayList<ActionDefinition>(actionDefinitions.size());
|
||||
|
||||
// check each action definition
|
||||
for (ActionDefinition actionDefinition : actionDefinitions)
|
||||
{
|
||||
if (actionDefinition instanceof ExtendedActionDefinition)
|
||||
{
|
||||
if (kind != null)
|
||||
{
|
||||
Set<FilePlanComponentKind> applicableKinds = ((ExtendedActionDefinition)actionDefinition).getApplicableKinds();
|
||||
if (applicableKinds == null || applicableKinds.size() == 0 || applicableKinds.contains(kind))
|
||||
{
|
||||
// an RM action can only act on a RM artifact
|
||||
result.add(actionDefinition);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (kind == null)
|
||||
{
|
||||
// a non-RM action can only act on a non-RM artifact
|
||||
result.add(actionDefinition);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* 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.test.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.service.cmr.action.ActionDefinition;
|
||||
import org.alfresco.service.cmr.action.ActionService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
|
||||
/**
|
||||
* Extended action service test.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public class ExtendedActionServiceTest extends BaseRMTestCase
|
||||
{
|
||||
/** Services */
|
||||
protected ActionService dmActionService;
|
||||
protected PermissionService dmPermissionService;
|
||||
|
||||
/** Action names */
|
||||
public static final String TEST_ACTION = "testAction";
|
||||
public static final String TEST_ACTION_2 = "testAction2";
|
||||
public static final String TEST_DM_ACTION = "testDMAction";
|
||||
public static final String RECORD_ONLY_ACTION = "recordOnlyAction";
|
||||
public static final String RECORD_AND_FOLDER_ONLY_ACTION = "recordandFolderOnlyAction";
|
||||
public static final String DELEGATE_ACTION = "rmDelegateAction";
|
||||
|
||||
|
||||
@Override
|
||||
protected void initServices()
|
||||
{
|
||||
super.initServices();
|
||||
dmActionService = (ActionService) applicationContext.getBean("ActionService");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isUserTest()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCollaborationSiteTest()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isRecordTest()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void testAvailableActions()
|
||||
{
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
public Void run()
|
||||
{
|
||||
List<ActionDefinition> result = dmActionService.getActionDefinitions(recordOne);
|
||||
assertNotNull(result);
|
||||
assertFalse(containsAction(result, TEST_ACTION));
|
||||
assertTrue(containsAction(result, TEST_ACTION_2));
|
||||
assertFalse(containsAction(result, TEST_DM_ACTION));
|
||||
assertTrue(containsAction(result, RECORD_ONLY_ACTION));
|
||||
assertTrue(containsAction(result, RECORD_AND_FOLDER_ONLY_ACTION));
|
||||
assertTrue(containsAction(result, DELEGATE_ACTION));
|
||||
|
||||
result = dmActionService.getActionDefinitions(rmFolder);
|
||||
assertNotNull(result);
|
||||
assertFalse(containsAction(result, TEST_ACTION));
|
||||
assertTrue(containsAction(result, TEST_ACTION_2));
|
||||
assertFalse(containsAction(result, TEST_DM_ACTION));
|
||||
assertFalse(containsAction(result, RECORD_ONLY_ACTION));
|
||||
assertTrue(containsAction(result, RECORD_AND_FOLDER_ONLY_ACTION));
|
||||
assertFalse(containsAction(result, DELEGATE_ACTION));
|
||||
|
||||
result = dmActionService.getActionDefinitions(rmContainer);
|
||||
assertNotNull(result);
|
||||
assertFalse(containsAction(result, TEST_ACTION));
|
||||
assertTrue(containsAction(result, TEST_ACTION_2));
|
||||
assertFalse(containsAction(result, TEST_DM_ACTION));
|
||||
assertFalse(containsAction(result, RECORD_ONLY_ACTION));
|
||||
assertFalse(containsAction(result, RECORD_AND_FOLDER_ONLY_ACTION));
|
||||
assertFalse(containsAction(result, DELEGATE_ACTION));
|
||||
|
||||
result = dmActionService.getActionDefinitions(dmDocument);
|
||||
assertNotNull(result);
|
||||
assertFalse(containsAction(result, TEST_ACTION));
|
||||
assertFalse(containsAction(result, TEST_ACTION_2));
|
||||
assertTrue(containsAction(result, TEST_DM_ACTION));
|
||||
assertFalse(containsAction(result, RECORD_ONLY_ACTION));
|
||||
assertFalse(containsAction(result, RECORD_AND_FOLDER_ONLY_ACTION));
|
||||
assertFalse(containsAction(result, DELEGATE_ACTION));
|
||||
|
||||
result = dmActionService.getActionDefinitions(dmFolder);
|
||||
assertNotNull(result);
|
||||
assertFalse(containsAction(result, TEST_ACTION));
|
||||
assertFalse(containsAction(result, TEST_ACTION_2));
|
||||
assertTrue(containsAction(result, TEST_DM_ACTION));
|
||||
assertFalse(containsAction(result, RECORD_ONLY_ACTION));
|
||||
assertFalse(containsAction(result, RECORD_AND_FOLDER_ONLY_ACTION));
|
||||
assertFalse(containsAction(result, DELEGATE_ACTION));
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean containsAction(List<ActionDefinition> list, String actionName)
|
||||
{
|
||||
boolean result = false;
|
||||
|
||||
for (ActionDefinition actionDefinition : list)
|
||||
{
|
||||
if (actionDefinition.getName().equals(actionName) == true)
|
||||
{
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.test.util;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
||||
*/
|
||||
public class TestDmAction extends ActionExecuterAbstractBase
|
||||
{
|
||||
@Override
|
||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addParameterDefinitions(List<ParameterDefinition> paramDefs)
|
||||
{
|
||||
}
|
||||
}
|
@@ -24,7 +24,9 @@
|
||||
<ref bean="testAction2"/>
|
||||
</property>
|
||||
</bean>
|
||||
<bean id="testAction2" class="org.alfresco.module.org_alfresco_module_rm.test.util.TestAction2" parent="rmAction"/>
|
||||
<bean id="testAction2" class="org.alfresco.module.org_alfresco_module_rm.test.util.TestAction2" parent="rmAction">
|
||||
<property name="publicAction" value="true"/>
|
||||
</bean>
|
||||
<bean id="testActionParams_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
||||
<property name="target">
|
||||
<ref bean="testActionParams"/>
|
||||
@@ -32,6 +34,55 @@
|
||||
</bean>
|
||||
<bean id="testActionParams" class="org.alfresco.module.org_alfresco_module_rm.test.util.TestActionParams" parent="rmAction"/>
|
||||
|
||||
<!-- Applicability tests -->
|
||||
|
||||
<bean id="recordOnlyAction_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
||||
<property name="target">
|
||||
<ref bean="recordOnlyAction"/>
|
||||
</property>
|
||||
</bean>
|
||||
<bean id="recordOnlyAction" class="org.alfresco.module.org_alfresco_module_rm.test.util.TestAction2" parent="rmAction">
|
||||
<property name="publicAction" value="true"/>
|
||||
<property name="applicableKinds">
|
||||
<list>
|
||||
<value>RECORD</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
<bean id="recordandFolderOnlyAction_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
||||
<property name="target">
|
||||
<ref bean="recordandFolderOnlyAction"/>
|
||||
</property>
|
||||
</bean>
|
||||
<bean id="recordandFolderOnlyAction" class="org.alfresco.module.org_alfresco_module_rm.test.util.TestAction2" parent="rmAction">
|
||||
<property name="publicAction" value="true"/>
|
||||
<property name="applicableKinds">
|
||||
<list>
|
||||
<value>RECORD</value>
|
||||
<value>RECORD_FOLDER</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- Test DM action -->
|
||||
<bean id="testDMAction" class="org.alfresco.module.org_alfresco_module_rm.test.util.TestDmAction" parent="action-executer"/>
|
||||
|
||||
<!-- RM delegate -->
|
||||
<bean id="rmDelegateAction_proxy" class="org.alfresco.module.org_alfresco_module_rm.capability.RMActionProxyFactoryBean" parent="rmProxyAction" init-method="registerAction">
|
||||
<property name="target">
|
||||
<ref bean="rmDelegateAction"/>
|
||||
</property>
|
||||
</bean>
|
||||
<bean id="rmDelegateAction" class="org.alfresco.module.org_alfresco_module_rm.action.RMDelegateAction" parent="rmAction">
|
||||
<property name="publicAction" value="true"/>
|
||||
<property name="delegateAction" ref="testDMAction" />
|
||||
<property name="applicableKinds">
|
||||
<list>
|
||||
<value>RECORD</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- Make sure the job doesn't fire during the test -->
|
||||
<bean id="scheduledPublishUpdatesJobTrigger" class="org.alfresco.util.CronTriggerBean">
|
||||
<property name="jobDetail">
|
||||
|
Reference in New Issue
Block a user