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:
@@ -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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user