diff --git a/config/alfresco/action-services-context.xml b/config/alfresco/action-services-context.xml
index 1ad56c09aa..7895119e3e 100644
--- a/config/alfresco/action-services-context.xml
+++ b/config/alfresco/action-services-context.xml
@@ -141,6 +141,16 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/config/alfresco/messages/action-config.properties b/config/alfresco/messages/action-config.properties
index a5147e41b8..b9b828cfa1 100644
--- a/config/alfresco/messages/action-config.properties
+++ b/config/alfresco/messages/action-config.properties
@@ -1,3 +1,13 @@
+# Action constraints
+compare-operations.equals=Equals
+compare-operations.contains=Contains
+compare-operations.begins=Begins With
+compare-operations.ends=Ends With
+compare-operations.greater_than=Greater Than
+compare-operations.greater_than_equal=Greater Than Or Equal To
+compare-operations.less_than=Less Than
+compare-operations.less_than_equal=Less Than Or Equal To
+
# Action conditions
no-condition.title=All Items
diff --git a/source/java/org/alfresco/repo/action/ActionServiceImpl.java b/source/java/org/alfresco/repo/action/ActionServiceImpl.java
index cfb8166acc..8d22240479 100644
--- a/source/java/org/alfresco/repo/action/ActionServiceImpl.java
+++ b/source/java/org/alfresco/repo/action/ActionServiceImpl.java
@@ -52,6 +52,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.CompositeActionCondition;
+import org.alfresco.service.cmr.action.ParameterConstraint;
import org.alfresco.service.cmr.action.ParameterizedItem;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
@@ -63,12 +64,12 @@ import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.util.GUID;
-import org.springframework.extensions.surf.util.PropertyCheck;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
+import org.springframework.extensions.surf.util.PropertyCheck;
/**
* Action service implementation
@@ -131,6 +132,11 @@ public class ActionServiceImpl implements
*/
private Map actionDefinitions = new HashMap();
+ /**
+ * All the parameter constraints
+ */
+ private Map parameterConstraints = new HashMap();
+
/**
* Set the application context
*
@@ -199,18 +205,7 @@ public class ActionServiceImpl implements
Map asynchronousActionExecutionQueues)
{
this.asynchronousActionExecutionQueues = asynchronousActionExecutionQueues;
- }
-
-// /**
-// * Get the asynchronous action execution queue
-// *
-// * @return the asynchronous action execution queue
-// */
-// public AsynchronousActionExecutionQueue getAsynchronousActionExecutionQueue()
-// {
-// return asynchronousActionExecutionQueue;
-// }
-//
+ }
public void init()
{
@@ -323,7 +318,23 @@ public class ActionServiceImpl implements
{
return new ArrayList(this.conditionDefinitions.values());
}
-
+
+ /**
+ * @see org.alfresco.service.cmr.action.ActionService#getParameterConstraint(java.lang.String)
+ */
+ public ParameterConstraint getParameterConstraint(String name)
+ {
+ return this.parameterConstraints.get(name);
+ }
+
+ /**
+ * @see org.alfresco.service.cmr.action.ActionService#getParameterConstraints()
+ */
+ public List getParameterConstraints()
+ {
+ return new ArrayList(this.parameterConstraints.values());
+ }
+
/**
* @see org.alfresco.service.cmr.action.ActionService#createActionCondition(java.lang.String)
*/
@@ -737,6 +748,14 @@ public class ActionServiceImpl implements
this.actionDefinitions.put(action.getName(), action);
}
+ /**
+ * @see org.alfresco.repo.action.RuntimeActionService#registerParameterConstraint(org.alfresco.service.cmr.action.ParameterConstraint)
+ */
+ public void registerParameterConstraint(ParameterConstraint parameterConstraint)
+ {
+ this.parameterConstraints.put(parameterConstraint.getName(), parameterConstraint);
+ }
+
/**
* Gets the action node ref from the action id
*
@@ -1654,7 +1673,6 @@ public class ActionServiceImpl implements
* Ensures that d:noderef properties are repointed if the target was also copied as part of the
* hierarchy.
*/
- @SuppressWarnings("unchecked")
public void onCopyComplete(
QName classRef,
NodeRef sourceNodeRef,
diff --git a/source/java/org/alfresco/repo/action/ActionServiceRemote.java b/source/java/org/alfresco/repo/action/ActionServiceRemote.java
index d9a392df65..520e29b662 100644
--- a/source/java/org/alfresco/repo/action/ActionServiceRemote.java
+++ b/source/java/org/alfresco/repo/action/ActionServiceRemote.java
@@ -37,7 +37,8 @@ import org.alfresco.service.cmr.action.ActionDefinition;
import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.action.ActionServiceTransport;
import org.alfresco.service.cmr.action.CompositeAction;
-import org.alfresco.service.cmr.action.CompositeActionCondition;
+import org.alfresco.service.cmr.action.CompositeActionCondition;
+import org.alfresco.service.cmr.action.ParameterConstraint;
import org.alfresco.service.cmr.repository.NodeRef;
/**
@@ -192,6 +193,22 @@ public class ActionServiceRemote implements ActionService
return fTransport.getActionDefinitions(fHolder.getTicket(), nodeRef);
}
+ /**
+ * @see org.alfresco.service.cmr.action.ActionService#getParameterConstraint(java.lang.String)
+ */
+ public ParameterConstraint getParameterConstraint(String name)
+ {
+ return fTransport.getParameterConstraint(fHolder.getTicket(), name);
+ }
+
+ /**
+ * @see org.alfresco.service.cmr.action.ActionService#getParameterConstraints()
+ */
+ public List getParameterConstraints()
+ {
+ return fTransport.getParameterConstraints(fHolder.getTicket());
+ }
+
/* (non-Javadoc)
* @see org.alfresco.service.cmr.action.ActionService#getActions(org.alfresco.service.cmr.repository.NodeRef)
*/
diff --git a/source/java/org/alfresco/repo/action/ActionServiceTransportImpl.java b/source/java/org/alfresco/repo/action/ActionServiceTransportImpl.java
index 9fa8e0cfd0..a445e6415b 100644
--- a/source/java/org/alfresco/repo/action/ActionServiceTransportImpl.java
+++ b/source/java/org/alfresco/repo/action/ActionServiceTransportImpl.java
@@ -36,6 +36,7 @@ import org.alfresco.service.cmr.action.ActionDefinition;
import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.action.ActionServiceTransport;
import org.alfresco.service.cmr.action.CompositeAction;
+import org.alfresco.service.cmr.action.ParameterConstraint;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.security.AuthenticationService;
@@ -213,6 +214,24 @@ public class ActionServiceTransportImpl implements ActionServiceTransport
fAuthenticationService.validate(ticket, null);
return fActionService.getActionDefinitions(nodeRef);
}
+
+ /**
+ * @see org.alfresco.service.cmr.action.ActionServiceTransport#getParameterConstraint(java.lang.String, java.lang.String)
+ */
+ public ParameterConstraint getParameterConstraint(String ticket, String name)
+ {
+ fAuthenticationService.validate(ticket, null);
+ return fActionService.getParameterConstraint(name);
+ }
+
+ /**
+ * @see org.alfresco.service.cmr.action.ActionServiceTransport#getParameterConstraints(java.lang.String)
+ */
+ public List getParameterConstraints(String ticket)
+ {
+ fAuthenticationService.validate(ticket, null);
+ return fActionService.getParameterConstraints();
+ }
/* (non-Javadoc)
* @see org.alfresco.service.cmr.action.ActionServiceTransport#getActions(java.lang.String, org.alfresco.service.cmr.repository.NodeRef)
diff --git a/source/java/org/alfresco/repo/action/ParameterDefinitionImpl.java b/source/java/org/alfresco/repo/action/ParameterDefinitionImpl.java
index 6466a2df3c..57072e547d 100644
--- a/source/java/org/alfresco/repo/action/ParameterDefinitionImpl.java
+++ b/source/java/org/alfresco/repo/action/ParameterDefinitionImpl.java
@@ -26,6 +26,7 @@ package org.alfresco.repo.action;
import java.io.Serializable;
+import org.alfresco.service.cmr.action.ParameterConstraint;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.namespace.QName;
@@ -61,6 +62,9 @@ public class ParameterDefinitionImpl implements ParameterDefinition, Serializabl
*/
private String displayLabel;
+ /** Parameter constraint name */
+ private String parameterConstraintName;
+
/**
* Indicates whether it is mandatory for the parameter to be set
*/
@@ -106,6 +110,28 @@ public class ParameterDefinitionImpl implements ParameterDefinition, Serializabl
this.isMandatory = isMandatory;
this.isMultiValued = isMultiValued;
}
+
+ /**
+ * Constructor
+ *
+ * @param name
+ * @param type
+ * @param isMandatory
+ * @param displayLabel
+ * @param isMultiValued
+ * @param parameterConstraintName
+ */
+ public ParameterDefinitionImpl(
+ String name,
+ QName type,
+ boolean isMandatory,
+ String displayLabel,
+ boolean isMultiValued,
+ String parameterConstraintName)
+ {
+ this(name, type, isMandatory, displayLabel, isMultiValued);
+ this.parameterConstraintName = parameterConstraintName;
+ }
/**
* @see org.alfresco.service.cmr.action.ParameterDefinition#getName()
@@ -146,4 +172,12 @@ public class ParameterDefinitionImpl implements ParameterDefinition, Serializabl
{
return this.displayLabel;
}
+
+ /**
+ * @see org.alfresco.service.cmr.action.ParameterDefinition#getParameterConstraintName()
+ */
+ public String getParameterConstraintName()
+ {
+ return this.parameterConstraintName;
+ }
}
diff --git a/source/java/org/alfresco/repo/action/RuntimeActionService.java b/source/java/org/alfresco/repo/action/RuntimeActionService.java
index c79c81c7b2..5a0f4cc1c0 100644
--- a/source/java/org/alfresco/repo/action/RuntimeActionService.java
+++ b/source/java/org/alfresco/repo/action/RuntimeActionService.java
@@ -29,26 +29,23 @@ import java.util.Set;
import org.alfresco.repo.action.evaluator.ActionConditionEvaluator;
import org.alfresco.repo.action.executer.ActionExecuter;
import org.alfresco.service.cmr.action.Action;
+import org.alfresco.service.cmr.action.ParameterConstraint;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
/**
+ * Runtime action service. This interface contains methods useful for integration with the action
+ * service at a lower level.
+ *
* @author Roy Wetherall
*/
public interface RuntimeActionService
{
/**
- *
+ * Post commit method
*/
void postCommit();
- /**
- * Get the asynchronous action queue.
- *
- * @return the asynchronous action queue
- */
- //AsynchronousActionExecutionQueue getAsynchronousActionExecutionQueue();
-
/**
* Register an action condition evaluator
*
@@ -62,9 +59,31 @@ public interface RuntimeActionService
* @param actionExecuter action executer
*/
void registerActionExecuter(ActionExecuter actionExecuter);
-
+
+ /**
+ * Register parameter constraint
+ *
+ * @param parameterConstraint parameter constraint
+ */
+ void registerParameterConstraint(ParameterConstraint parameterConstraint);
+
+ /**
+ * Create a new action based on an action node reference
+ *
+ * @param actionNodeRef action node reference
+ * @return Action action object
+ */
Action createAction(NodeRef actionNodeRef);
+ /**
+ * Create a action node reference
+ *
+ * @param action action object
+ * @param parentNodeRef parent node reference
+ * @param assocTypeName association type name
+ * @param assocName association name
+ * @return NodeRef created node reference
+ */
NodeRef createActionNodeRef(Action action, NodeRef parentNodeRef, QName assocTypeName, QName assocName);
/**
@@ -95,11 +114,4 @@ public interface RuntimeActionService
* @param actionedUponNodeRef the actioned upon node reference
*/
public void directActionExecution(Action action, NodeRef actionedUponNodeRef);
-
-// /**
-// * Gets a list of the actions that are pending post transaction
-// *
-// * @return list of pending actions
-// */
-// public List getPostTransactionPendingActions();
}
diff --git a/source/java/org/alfresco/repo/action/constraint/ActionParameterConstraintTest.java b/source/java/org/alfresco/repo/action/constraint/ActionParameterConstraintTest.java
new file mode 100644
index 0000000000..2ab396363a
--- /dev/null
+++ b/source/java/org/alfresco/repo/action/constraint/ActionParameterConstraintTest.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2005-2007 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program 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 General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+package org.alfresco.repo.action.constraint;
+
+import java.util.List;
+import java.util.Map;
+
+import org.alfresco.repo.action.evaluator.compare.ComparePropertyValueOperation;
+import org.alfresco.service.cmr.action.ActionService;
+import org.alfresco.service.cmr.action.ParameterConstraint;
+import org.alfresco.util.BaseSpringTest;
+
+/**
+ * Action parameter constraint unit test
+ *
+ * @author Roy Wetherall
+ */
+public class ActionParameterConstraintTest extends BaseSpringTest
+{
+ private static final String COMPARE_OP = "compare-operations";
+
+ private ActionService actionService;
+
+ /**
+ * @see org.springframework.test.AbstractTransactionalSpringContextTests#onSetUpInTransaction()
+ */
+ @SuppressWarnings("deprecation")
+ @Override
+ protected void onSetUpInTransaction() throws Exception
+ {
+ actionService = (ActionService)applicationContext.getBean("ActionService");
+ }
+
+ public void testGetConstraints()
+ {
+ List constraints = actionService.getParameterConstraints();
+
+ assertNotNull(constraints);
+ assertFalse(constraints.isEmpty());
+ }
+
+ public void testGetConstraint()
+ {
+ ParameterConstraint constraint = actionService.getParameterConstraint("junk");
+ assertNull(constraint);
+
+ constraint = actionService.getParameterConstraint(COMPARE_OP);
+ assertNotNull(constraint);
+ }
+
+ public void testCompareOperationsConstraint()
+ {
+ ParameterConstraint constraint = actionService.getParameterConstraint(COMPARE_OP);
+ assertNotNull(constraint);
+ assertEquals(COMPARE_OP, constraint.getName());
+
+ assertEquals("Ends With", constraint.getValueDisplayLabel(ComparePropertyValueOperation.ENDS.toString()));
+
+ Map values = constraint.getAllowableValues();
+ for (Map.Entry entry : values.entrySet())
+ {
+ System.out.println(entry.getKey() + " - " + entry.getValue());
+ }
+ }
+}
diff --git a/source/java/org/alfresco/repo/action/constraint/BaseParameterConstraint.java b/source/java/org/alfresco/repo/action/constraint/BaseParameterConstraint.java
new file mode 100644
index 0000000000..dca7e26416
--- /dev/null
+++ b/source/java/org/alfresco/repo/action/constraint/BaseParameterConstraint.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2009-2009 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program 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 General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have received a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+
+package org.alfresco.repo.action.constraint;
+
+import org.alfresco.repo.action.RuntimeActionService;
+import org.alfresco.service.cmr.action.ParameterConstraint;
+import org.springframework.beans.factory.BeanNameAware;
+
+/**
+ * Base implementation of a parameter constraint
+ *
+ * @author Roy Wetherall
+ */
+public abstract class BaseParameterConstraint implements ParameterConstraint,
+ BeanNameAware
+{
+ /** Constraint name */
+ protected String name;
+
+ /** Runtime action service */
+ protected RuntimeActionService actionService;
+
+ /**
+ * Init method
+ */
+ public void init()
+ {
+ actionService.registerParameterConstraint(this);
+ }
+
+ /**
+ * Set the action service
+ *
+ * @param actionService action service
+ */
+ public void setActionService(RuntimeActionService actionService)
+ {
+ this.actionService = actionService;
+ }
+
+ /**
+ * @see org.alfresco.service.cmr.action.ParameterConstraint#getName()
+ */
+ public String getName()
+ {
+ return this.name;
+ }
+
+ /**
+ * @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
+ */
+ public void setBeanName(String name)
+ {
+ this.name = name;
+ }
+}
diff --git a/source/java/org/alfresco/repo/action/constraint/EnumParameterConstraint.java b/source/java/org/alfresco/repo/action/constraint/EnumParameterConstraint.java
new file mode 100644
index 0000000000..f0a3b3abf9
--- /dev/null
+++ b/source/java/org/alfresco/repo/action/constraint/EnumParameterConstraint.java
@@ -0,0 +1,156 @@
+/*
+ * Copyright (C) 2009-2009 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program 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 General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have received a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+
+package org.alfresco.repo.action.constraint;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.alfresco.error.AlfrescoRuntimeException;
+import org.springframework.extensions.surf.util.I18NUtil;
+
+/**
+ * Enumerated type parameter constraint
+ *
+ * @author Roy Wetherall
+ */
+public class EnumParameterConstraint extends BaseParameterConstraint
+{
+ /** Enum class name */
+ private String enumClassName;
+
+ /** Enum clss */
+ private Class> enumClass;
+
+ /** Map of allowable values */
+ private Map allowableValues;
+
+ /**
+ * Set the enum class name
+ *
+ * @param enumClassName enum class name
+ */
+ public void setEnumClassName(String enumClassName)
+ {
+ this.enumClassName = enumClassName;
+ }
+
+ /**
+ * @see org.alfresco.service.cmr.action.ParameterConstraint#getAllowableValues()
+ */
+ public Map getAllowableValues()
+ {
+ if (this.allowableValues == null)
+ {
+ // Get the enum class
+ Class> enumClass = getEnumClass();
+
+ Object[] enumValues = enumClass.getEnumConstants();
+ this.allowableValues = new HashMap(enumValues.length);
+
+ for (Object enumValue : enumValues)
+ {
+ // Look up the I18N value
+ String displayLabel = getI18NLabel(enumClass.getName(), enumValue);
+
+ // Add to the map of allowed values
+ this.allowableValues.put(enumValue.toString(), displayLabel);
+ }
+ }
+
+ return this.allowableValues;
+ }
+
+ /**
+ * Get the enum class
+ *
+ * @return
+ */
+ private Class> getEnumClass()
+ {
+ if (this.enumClass == null)
+ {
+ try
+ {
+ // Check that a enum class name has specified
+ if (enumClassName == null || enumClassName.length() == 0)
+ {
+ throw new AlfrescoRuntimeException("No enum class has been defined");
+ }
+
+ // Get the enum class
+ Class> enumClass = Class.forName(enumClassName);
+
+ // Check that the class is an enum class
+ if (enumClass.isEnum() == true)
+ {
+ this.enumClass = enumClass;
+ }
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new AlfrescoRuntimeException("Unable to find enum class " + this.enumClassName, e);
+ }
+ }
+ return this.enumClass;
+ }
+
+ /**
+ * Get the I18N display label for a particular enum value
+ *
+ * @param enumClassName
+ * @param enumValue
+ * @return
+ */
+ private String getI18NLabel(String enumClassName, Object enumValue)
+ {
+ String result = enumValue.toString();
+ StringBuffer key = new StringBuffer(name).
+ append(".").
+ append(enumValue.toString().toLowerCase());
+ String i18n = I18NUtil.getMessage(key.toString());
+ if (i18n != null)
+ {
+ result = i18n;
+ }
+ return result;
+ }
+
+ /**
+ * @see org.alfresco.service.cmr.action.ParameterConstraint#getValueDisplayLabel(java.io.Serializable)
+ */
+ public String getValueDisplayLabel(String value)
+ {
+ return getAllowableValues().get(value);
+ }
+
+ /**
+ * @see org.alfresco.service.cmr.action.ParameterConstraint#isValidValue(java.io.Serializable)
+ */
+ public boolean isValidValue(String value)
+ {
+ return getAllowableValues().containsKey(value);
+ }
+}
diff --git a/source/java/org/alfresco/repo/action/evaluator/ComparePropertyValueEvaluator.java b/source/java/org/alfresco/repo/action/evaluator/ComparePropertyValueEvaluator.java
index b0f5cb9498..cc5cd67f6e 100644
--- a/source/java/org/alfresco/repo/action/evaluator/ComparePropertyValueEvaluator.java
+++ b/source/java/org/alfresco/repo/action/evaluator/ComparePropertyValueEvaluator.java
@@ -164,7 +164,7 @@ public class ComparePropertyValueEvaluator extends ActionConditionEvaluatorAbstr
paramList.add(new ParameterDefinitionImpl(PARAM_PROPERTY, DataTypeDefinition.QNAME, false, getParamDisplayLabel(PARAM_PROPERTY)));
paramList.add(new ParameterDefinitionImpl(PARAM_CONTENT_PROPERTY, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_CONTENT_PROPERTY)));
paramList.add(new ParameterDefinitionImpl(PARAM_VALUE, DataTypeDefinition.ANY, true, getParamDisplayLabel(PARAM_VALUE)));
- paramList.add(new ParameterDefinitionImpl(PARAM_OPERATION, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_OPERATION)));
+ paramList.add(new ParameterDefinitionImpl(PARAM_OPERATION, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_OPERATION), false, "compare-operations"));
}
/**
diff --git a/source/java/org/alfresco/repo/action/evaluator/ComparePropertyValueEvaluatorTest.java b/source/java/org/alfresco/repo/action/evaluator/ComparePropertyValueEvaluatorTest.java
index d01d1dcdae..6c5f9ab147 100644
--- a/source/java/org/alfresco/repo/action/evaluator/ComparePropertyValueEvaluatorTest.java
+++ b/source/java/org/alfresco/repo/action/evaluator/ComparePropertyValueEvaluatorTest.java
@@ -38,7 +38,11 @@ import org.alfresco.repo.dictionary.DictionaryDAO;
import org.alfresco.repo.dictionary.M2Model;
import org.alfresco.repo.dictionary.M2Property;
import org.alfresco.repo.dictionary.M2Type;
+import org.alfresco.service.cmr.action.ActionConditionDefinition;
+import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.action.ActionServiceException;
+import org.alfresco.service.cmr.action.ParameterConstraint;
+import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.ContentWriter;
@@ -75,6 +79,7 @@ public class ComparePropertyValueEvaluatorTest extends BaseSpringTest
private DictionaryDAO dictionaryDAO;
private NodeService nodeService;
private ContentService contentService;
+ private ActionService actionService;
private StoreRef testStoreRef;
private NodeRef rootNodeRef;
private NodeRef nodeRef;
@@ -93,6 +98,7 @@ public class ComparePropertyValueEvaluatorTest extends BaseSpringTest
/**
* @see org.springframework.test.AbstractTransactionalSpringContextTests#onSetUpInTransaction()
*/
+ @SuppressWarnings("deprecation")
@Override
protected void onSetUpInTransaction() throws Exception
{
@@ -101,6 +107,7 @@ public class ComparePropertyValueEvaluatorTest extends BaseSpringTest
this.nodeService = (NodeService)this.applicationContext.getBean("nodeService");
this.contentService = (ContentService)this.applicationContext.getBean("contentService");
+ actionService = (ActionService)applicationContext.getBean("actionService");
// Create the store and get the root node
this.testStoreRef = this.nodeService.createStore(
@@ -133,6 +140,20 @@ public class ComparePropertyValueEvaluatorTest extends BaseSpringTest
this.evaluator = (ComparePropertyValueEvaluator)this.applicationContext.getBean(ComparePropertyValueEvaluator.NAME);
}
+ public void testCheckParamDefintionWithConstraint()
+ {
+ ActionConditionDefinition def = evaluator.getActionConditionDefintion();
+ assertEquals(ComparePropertyValueEvaluator.NAME, def.getName());
+ ParameterDefinition paramDef = def.getParameterDefintion(ComparePropertyValueEvaluator.PARAM_OPERATION);
+ assertNotNull(paramDef);
+ assertEquals(ComparePropertyValueEvaluator.PARAM_OPERATION, paramDef.getName());
+ String constraintName = paramDef.getParameterConstraintName();
+ assertNotNull(constraintName);
+ ParameterConstraint paramConstraint = actionService.getParameterConstraint(constraintName);
+ assertNotNull(paramConstraint);
+ assertEquals("compare-operations", paramConstraint.getName());
+ }
+
/**
* Test numeric comparisions
*/
diff --git a/source/java/org/alfresco/service/cmr/action/ActionService.java b/source/java/org/alfresco/service/cmr/action/ActionService.java
index 941d9ca27c..4af505cda8 100644
--- a/source/java/org/alfresco/service/cmr/action/ActionService.java
+++ b/source/java/org/alfresco/service/cmr/action/ActionService.java
@@ -84,6 +84,23 @@ public interface ActionService
@Auditable(parameters = {})
List getActionConditionDefinitions();
+ /**
+ * Get a named parameter constraint
+ *
+ * @param name the name of the parameter constraint
+ * @return this parameter condition
+ */
+ @Auditable(parameters = {"name"})
+ ParameterConstraint getParameterConstraint(String name);
+
+ /**
+ * Get all the parameter constraints
+ *
+ * @return the list of all parameter constraints
+ */
+ @Auditable(parameters = {})
+ List getParameterConstraints();
+
/**
* Create a new action
*
diff --git a/source/java/org/alfresco/service/cmr/action/ActionServiceTransport.java b/source/java/org/alfresco/service/cmr/action/ActionServiceTransport.java
index 26103e004d..4802b95d68 100644
--- a/source/java/org/alfresco/service/cmr/action/ActionServiceTransport.java
+++ b/source/java/org/alfresco/service/cmr/action/ActionServiceTransport.java
@@ -29,7 +29,6 @@ import java.io.Serializable;
import java.util.List;
import java.util.Map;
-import org.alfresco.service.Auditable;
import org.alfresco.service.cmr.repository.NodeRef;
/**
@@ -74,10 +73,25 @@ public interface ActionServiceTransport
/**
* Get all the action condition definitions
*
- * @return the list of aciton condition definitions
+ * @return the list of action condition definitions
*/
List getActionConditionDefinitions(String ticket);
+ /**
+ * Get a named parameter constraint
+ *
+ * @param name the name of the parameter constraint
+ * @return this parameter condition
+ */
+ ParameterConstraint getParameterConstraint(String ticket, String name);
+
+ /**
+ * Get all the parameter constraints
+ *
+ * @return the list of all parameter constraints
+ */
+ List getParameterConstraints(String ticket);
+
/**
* Create a new action
*
diff --git a/source/java/org/alfresco/service/cmr/action/ParameterConstraint.java b/source/java/org/alfresco/service/cmr/action/ParameterConstraint.java
new file mode 100644
index 0000000000..d999e001d7
--- /dev/null
+++ b/source/java/org/alfresco/service/cmr/action/ParameterConstraint.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2009-2009 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program 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 General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have received a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+
+package org.alfresco.service.cmr.action;
+
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ * Parameter constraint. Helps to constraint the list of allowable values for a
+ *
+ * @author Roy Wetherall
+ */
+public interface ParameterConstraint
+{
+ /**
+ * Gets the unique name of the constraint
+ *
+ * @return String constraint name
+ */
+ String getName();
+
+ /**
+ * Indicates whether the provided value satisfies the constraint. True if it does, false otherwise.
+ *
+ * @return boolean true if valid, false otherwise
+ */
+ boolean isValidValue(String value);
+
+ /**
+ *
+ * @param value
+ * @return
+ */
+ String getValueDisplayLabel(String value);
+
+ /**
+ *
+ */
+ Map getAllowableValues();
+}
diff --git a/source/java/org/alfresco/service/cmr/action/ParameterDefinition.java b/source/java/org/alfresco/service/cmr/action/ParameterDefinition.java
index 74f751847b..a7bb83d22e 100644
--- a/source/java/org/alfresco/service/cmr/action/ParameterDefinition.java
+++ b/source/java/org/alfresco/service/cmr/action/ParameterDefinition.java
@@ -70,4 +70,11 @@ public interface ParameterDefinition
*/
public String getDisplayLabel();
+ /**
+ * Gets the parameter constraint name, null if none set.
+ *
+ * @return the parameter constraint name
+ */
+ public String getParameterConstraintName();
+
}