diff --git a/config/alfresco/action-services-context.xml b/config/alfresco/action-services-context.xml
index f0bde50bad..5053cd534a 100644
--- a/config/alfresco/action-services-context.xml
+++ b/config/alfresco/action-services-context.xml
@@ -14,6 +14,9 @@
+
+
+
@@ -203,6 +206,11 @@
+
+
+ {http://www.alfresco.org/model/content/1.0}content
+
+
+
+
+ {http://www.alfresco.org/model/content/1.0}content
+
+
@@ -243,6 +256,11 @@
+
+
+ {http://www.alfresco.org/model/content/1.0}content
+
+
@@ -291,6 +309,11 @@
+
+
+ {http://www.alfresco.org/model/content/1.0}content
+
+
diff --git a/source/java/org/alfresco/repo/action/ActionDefinitionImpl.java b/source/java/org/alfresco/repo/action/ActionDefinitionImpl.java
index 2eaa034498..91fc5a6ea8 100644
--- a/source/java/org/alfresco/repo/action/ActionDefinitionImpl.java
+++ b/source/java/org/alfresco/repo/action/ActionDefinitionImpl.java
@@ -16,7 +16,10 @@
*/
package org.alfresco.repo.action;
+import java.util.List;
+
import org.alfresco.service.cmr.action.ActionDefinition;
+import org.alfresco.service.namespace.QName;
/**
* Rule action implementation class
@@ -35,6 +38,9 @@ public class ActionDefinitionImpl extends ParameterizedItemDefinitionImpl
* The rule action executor
*/
private String ruleActionExecutor;
+
+ /** List of applicable types */
+ private List applicableTypes;
/**
* Constructor
@@ -65,4 +71,24 @@ public class ActionDefinitionImpl extends ParameterizedItemDefinitionImpl
{
return ruleActionExecutor;
}
+
+ /**
+ * Gets the list of applicable types
+ *
+ * @return the list of qnames
+ */
+ public List getApplicableTypes()
+ {
+ return this.applicableTypes;
+ }
+
+ /**
+ * Sets the list of applicable types
+ *
+ * @param applicableTypes the applicable types
+ */
+ public void setApplicableTypes(List applicableTypes)
+ {
+ this.applicableTypes = applicableTypes;
+ }
}
diff --git a/source/java/org/alfresco/repo/action/ActionServiceImpl.java b/source/java/org/alfresco/repo/action/ActionServiceImpl.java
index a16a2ceccb..f7dad34e08 100644
--- a/source/java/org/alfresco/repo/action/ActionServiceImpl.java
+++ b/source/java/org/alfresco/repo/action/ActionServiceImpl.java
@@ -38,6 +38,7 @@ import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.action.ActionServiceException;
import org.alfresco.service.cmr.action.CompositeAction;
import org.alfresco.service.cmr.action.ParameterizedItem;
+import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
@@ -98,6 +99,9 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
*/
private SearchService searchService;
+ /** The dictionary service */
+ private DictionaryService dictionaryService;
+
/** The authentication component */
private AuthenticationComponent authenticationComponent;
@@ -161,6 +165,16 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
this.authenticationComponent = authenticationComponent;
}
+ /**
+ * Set the dictionary service
+ *
+ * @param dictionaryService the dictionary service
+ */
+ public void setDictionaryService(DictionaryService dictionaryService)
+ {
+ this.dictionaryService = dictionaryService;
+ }
+
/**
* Set the asynchronous action execution queue
*
@@ -217,6 +231,44 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
{
return new ArrayList(this.actionDefinitions.values());
}
+
+ /**
+ * @see org.alfresco.service.cmr.action.ActionService#getActionDefinitions(org.alfresco.service.cmr.repository.NodeRef)
+ */
+ public List getActionDefinitions(NodeRef nodeRef)
+ {
+ if (nodeRef == null)
+ {
+ return getActionDefinitions();
+ }
+ else
+ {
+ // TODO for now we will only filter by type, we will introduce filtering by aspect later
+ QName nodeType = this.nodeService.getType(nodeRef);
+ List result = new ArrayList();
+ for (ActionDefinition actionDefinition : getActionDefinitions())
+ {
+ List appliciableTypes = actionDefinition.getApplicableTypes();
+ if (appliciableTypes != null && appliciableTypes.isEmpty() == false)
+ {
+ for (QName applicableType : actionDefinition.getApplicableTypes())
+ {
+ if (this.dictionaryService.isSubClass(nodeType, applicableType))
+ {
+ result.add(actionDefinition);
+ break;
+ }
+ }
+ }
+ else
+ {
+ result.add(actionDefinition);
+ }
+ }
+
+ return result;
+ }
+ }
/**
* @see org.alfresco.service.cmr.action.ActionService#getActionConditionDefinition(java.lang.String)
diff --git a/source/java/org/alfresco/repo/action/ActionServiceImplTest.java b/source/java/org/alfresco/repo/action/ActionServiceImplTest.java
index d339852e14..6af845cda7 100644
--- a/source/java/org/alfresco/repo/action/ActionServiceImplTest.java
+++ b/source/java/org/alfresco/repo/action/ActionServiceImplTest.java
@@ -55,6 +55,7 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest
private static final String BAD_NAME = "badName";
private NodeRef nodeRef;
+ private NodeRef folder;
@Override
protected void onSetUpInTransaction() throws Exception
@@ -71,6 +72,12 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest
this.nodeRef,
ContentModel.PROP_CONTENT,
new ContentData(null, MimetypeMap.MIMETYPE_TEXT_PLAIN, 0L, null));
+ this.folder = this.nodeService.createNode(
+ this.rootNodeRef,
+ ContentModel.ASSOC_CHILDREN,
+ QName.createQName("{test}testFolder"),
+ ContentModel.TYPE_FOLDER).getChildRef();
+
}
/**
@@ -94,11 +101,17 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest
List defintions = this.actionService.getActionDefinitions();
assertNotNull(defintions);
assertFalse(defintions.isEmpty());
+ int totalCount = defintions.size();
for (ActionDefinition definition : defintions)
{
System.out.println(definition.getTitle());
}
+
+ // Get the action defintions for a folder type (there should be less than the total available)
+ List definitions = this.actionService.getActionDefinitions(this.folder);
+ assertNotNull(definitions);
+ assertTrue(totalCount > definitions.size());
}
/**
diff --git a/source/java/org/alfresco/repo/action/executer/ActionExecuterAbstractBase.java b/source/java/org/alfresco/repo/action/executer/ActionExecuterAbstractBase.java
index 72f70ba498..ecce2db509 100644
--- a/source/java/org/alfresco/repo/action/executer/ActionExecuterAbstractBase.java
+++ b/source/java/org/alfresco/repo/action/executer/ActionExecuterAbstractBase.java
@@ -16,11 +16,15 @@
*/
package org.alfresco.repo.action.executer;
+import java.util.ArrayList;
+import java.util.List;
+
import org.alfresco.repo.action.ActionDefinitionImpl;
import org.alfresco.repo.action.ParameterizedItemAbstractBase;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.namespace.QName;
/**
* Rule action executor abstract base.
@@ -38,6 +42,9 @@ public abstract class ActionExecuterAbstractBase extends ParameterizedItemAbstra
* Indicated whether the action is public or internal
*/
protected boolean publicAction = true;
+
+ /** List of types and aspects for which this action is applicable */
+ protected List applicableTypes = new ArrayList();
/**
* Init method
@@ -59,6 +66,19 @@ public abstract class ActionExecuterAbstractBase extends ParameterizedItemAbstra
{
this.publicAction = publicAction;
}
+
+ /**
+ * Set the list of types for which this action is applicable
+ *
+ * @param applicableTypes arry of applicable types
+ */
+ public void setApplicableTypes(String[] applicableTypes)
+ {
+ for (String type : applicableTypes)
+ {
+ this.applicableTypes.add(QName.createQName(type));
+ }
+ }
/**
* Get rule action definition
@@ -75,6 +95,7 @@ public abstract class ActionExecuterAbstractBase extends ParameterizedItemAbstra
((ActionDefinitionImpl)this.actionDefinition).setAdhocPropertiesAllowed(getAdhocPropertiesAllowed());
((ActionDefinitionImpl)this.actionDefinition).setRuleActionExecutor(this.name);
((ActionDefinitionImpl)this.actionDefinition).setParameterDefinitions(getParameterDefintions());
+ ((ActionDefinitionImpl)this.actionDefinition).setApplicableTypes(this.applicableTypes);
}
return this.actionDefinition;
}
diff --git a/source/java/org/alfresco/service/cmr/action/ActionDefinition.java b/source/java/org/alfresco/service/cmr/action/ActionDefinition.java
index 0c19c2b975..e5df61b3cf 100644
--- a/source/java/org/alfresco/service/cmr/action/ActionDefinition.java
+++ b/source/java/org/alfresco/service/cmr/action/ActionDefinition.java
@@ -16,6 +16,10 @@
*/
package org.alfresco.service.cmr.action;
+import java.util.List;
+
+import org.alfresco.service.namespace.QName;
+
/**
@@ -25,5 +29,10 @@ package org.alfresco.service.cmr.action;
*/
public interface ActionDefinition extends ParameterizedItemDefinition
{
-
+ /**
+ * Gets a list of the types that this action item is applicable for
+ *
+ * @return list of types
+ */
+ public List getApplicableTypes();
}
diff --git a/source/java/org/alfresco/service/cmr/action/ActionService.java b/source/java/org/alfresco/service/cmr/action/ActionService.java
index 7d2605c677..10ef0b641b 100644
--- a/source/java/org/alfresco/service/cmr/action/ActionService.java
+++ b/source/java/org/alfresco/service/cmr/action/ActionService.java
@@ -43,6 +43,15 @@ public interface ActionService
* @return the list action definitions
*/
List getActionDefinitions();
+
+ /**
+ * Get all the action definitions that are applicable for the given node, based on
+ * its type and aspects.
+ *
+ * @param nodeRef the node reference
+ * @return a list of applicable action definitions
+ */
+ List getActionDefinitions(NodeRef nodeRef);
/**
* Get a named action condition definition