parameters, boolean throwException);
/**
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RMDelegateAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RMDelegateAction.java
new file mode 100644
index 0000000000..3593a4ed6d
--- /dev/null
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RMDelegateAction.java
@@ -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 .
+ */
+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.
+ *
+ * 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 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 getParameterDefintions()
+ {
+ return delegateActionExecuter.getActionDefinition().getParameterDefinitions();
+ }
+}
diff --git a/rm-server/source/java/org/alfresco/repo/action/ExtendedActionDefinition.java b/rm-server/source/java/org/alfresco/repo/action/ExtendedActionDefinition.java
new file mode 100644
index 0000000000..0ba40438eb
--- /dev/null
+++ b/rm-server/source/java/org/alfresco/repo/action/ExtendedActionDefinition.java
@@ -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 .
+ */
+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 getApplicableKinds();
+}
diff --git a/rm-server/source/java/org/alfresco/repo/action/ExtendedActionDefinitionImpl.java b/rm-server/source/java/org/alfresco/repo/action/ExtendedActionDefinitionImpl.java
new file mode 100644
index 0000000000..ba85e48b52
--- /dev/null
+++ b/rm-server/source/java/org/alfresco/repo/action/ExtendedActionDefinitionImpl.java
@@ -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 .
+ */
+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 applicableKinds;
+
+ /**
+ * Default constructor.
+ *
+ * @param name action definition name
+ */
+ public ExtendedActionDefinitionImpl(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * @param applicableKinds applicable kinds
+ */
+ public void setApplicableKinds(Set applicableKinds)
+ {
+ this.applicableKinds = applicableKinds;
+ }
+
+ /**
+ * @see org.alfresco.repo.action.ExtendedActionDefinition#getApplicableKinds()
+ */
+ @Override
+ public Set getApplicableKinds()
+ {
+ return applicableKinds;
+ }
+}
diff --git a/rm-server/source/java/org/alfresco/repo/action/ExtendedActionServiceImpl.java b/rm-server/source/java/org/alfresco/repo/action/ExtendedActionServiceImpl.java
new file mode 100644
index 0000000000..276afa81ae
--- /dev/null
+++ b/rm-server/source/java/org/alfresco/repo/action/ExtendedActionServiceImpl.java
@@ -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 .
+ */
+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 getActionDefinitions(NodeRef nodeRef)
+ {
+ List result = null;
+
+ // first use the base implementation to get the list of action definitions
+ List 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(actionDefinitions.size());
+
+ // check each action definition
+ for (ActionDefinition actionDefinition : actionDefinitions)
+ {
+ if (actionDefinition instanceof ExtendedActionDefinition)
+ {
+ if (kind != null)
+ {
+ Set 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;
+ }
+}
diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/ExtendedActionServiceTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/ExtendedActionServiceTest.java
new file mode 100644
index 0000000000..3221803611
--- /dev/null
+++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/ExtendedActionServiceTest.java
@@ -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 .
+ */
+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()
+ {
+ public Void run()
+ {
+ List 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 list, String actionName)
+ {
+ boolean result = false;
+
+ for (ActionDefinition actionDefinition : list)
+ {
+ if (actionDefinition.getName().equals(actionName) == true)
+ {
+ result = true;
+ break;
+ }
+ }
+
+ return result;
+ }
+}
diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestDmAction.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestDmAction.java
new file mode 100644
index 0000000000..9106e3dd3b
--- /dev/null
+++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/TestDmAction.java
@@ -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 .
+ */
+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 paramDefs)
+ {
+ }
+}
diff --git a/rm-server/test/resources/test-context.xml b/rm-server/test/resources/test-context.xml
index 133a87ebea..17529af0a3 100644
--- a/rm-server/test/resources/test-context.xml
+++ b/rm-server/test/resources/test-context.xml
@@ -24,7 +24,9 @@
-
+
+
+
@@ -32,6 +34,55 @@
+
+
+
+
+
+
+
+
+
+
+
+ RECORD
+
+
+
+
+
+
+
+
+
+
+
+
+ RECORD
+ RECORD_FOLDER
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ RECORD
+
+
+
+