Support for action parameter constraints added to action service

An action parameter constraint provides a way to list the valid values that an action or action constraint parameter can take.  This
means more information about the action or action condition is available to the user of the action.
  
Currently there is only an implementation for enum parameter values, but this will be extended as the existing action implementations
are reviewed and value constraints are added as required.

The REST API can now be extended to provide this additional information.



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@18489 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2010-02-08 04:37:45 +00:00
parent 79852d5b1b
commit 8c2c15c5c9
16 changed files with 599 additions and 35 deletions

View File

@@ -141,6 +141,16 @@
</property>
</bean>
<!-- Action parameter constraints -->
<bean id="action-constraint" abstract="true" init-method="init">
<property name="actionService" ref="actionService"/>
</bean>
<bean id="compare-operations" class="org.alfresco.repo.action.constraint.EnumParameterConstraint" parent="action-constraint">
<property name="enumClassName" value="org.alfresco.repo.action.evaluator.compare.ComparePropertyValueOperation" />
</bean>
<!-- Action Conditions -->
<bean id="action-condition-evaluator" abstract="true" init-method="init">

View File

@@ -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

View File

@@ -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<String, ActionDefinition> actionDefinitions = new HashMap<String, ActionDefinition>();
/**
* All the parameter constraints
*/
private Map<String, ParameterConstraint> parameterConstraints = new HashMap<String, ParameterConstraint>();
/**
* Set the application context
*
@@ -201,17 +207,6 @@ public class ActionServiceImpl implements
this.asynchronousActionExecutionQueues = asynchronousActionExecutionQueues;
}
// /**
// * Get the asynchronous action execution queue
// *
// * @return the asynchronous action execution queue
// */
// public AsynchronousActionExecutionQueue getAsynchronousActionExecutionQueue()
// {
// return asynchronousActionExecutionQueue;
// }
//
public void init()
{
PropertyCheck.mandatory(this, "policyComponent", policyComponent);
@@ -324,6 +319,22 @@ public class ActionServiceImpl implements
return new ArrayList<ActionConditionDefinition>(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<ParameterConstraint> getParameterConstraints()
{
return new ArrayList<ParameterConstraint>(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 <b>d:noderef</b> properties are repointed if the target was also copied as part of the
* hierarchy.
*/
@SuppressWarnings("unchecked")
public void onCopyComplete(
QName classRef,
NodeRef sourceNodeRef,

View File

@@ -38,6 +38,7 @@ 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.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<ParameterConstraint> getParameterConstraints()
{
return fTransport.getParameterConstraints(fHolder.getTicket());
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.action.ActionService#getActions(org.alfresco.service.cmr.repository.NodeRef)
*/

View File

@@ -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;
@@ -214,6 +215,24 @@ public class ActionServiceTransportImpl implements ActionServiceTransport
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<ParameterConstraint> 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)
*/

View File

@@ -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
*/
@@ -107,6 +111,28 @@ public class ParameterDefinitionImpl implements ParameterDefinition, Serializabl
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;
}
}

View File

@@ -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
*
@@ -63,8 +60,30 @@ public interface RuntimeActionService
*/
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<PendingAction> getPostTransactionPendingActions();
}

View File

@@ -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<ParameterConstraint> 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<String, String> values = constraint.getAllowableValues();
for (Map.Entry<String, String> entry : values.entrySet())
{
System.out.println(entry.getKey() + " - " + entry.getValue());
}
}
}

View File

@@ -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;
}
}

View File

@@ -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<String, String> 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<String, String> getAllowableValues()
{
if (this.allowableValues == null)
{
// Get the enum class
Class<?> enumClass = getEnumClass();
Object[] enumValues = enumClass.getEnumConstants();
this.allowableValues = new HashMap<String, String>(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);
}
}

View File

@@ -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"));
}
/**

View File

@@ -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
*/

View File

@@ -84,6 +84,23 @@ public interface ActionService
@Auditable(parameters = {})
List<ActionConditionDefinition> 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<ParameterConstraint> getParameterConstraints();
/**
* Create a new action
*

View File

@@ -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<ActionConditionDefinition> 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<ParameterConstraint> getParameterConstraints(String ticket);
/**
* Create a new action
*

View File

@@ -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<String, String> getAllowableValues();
}

View File

@@ -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();
}