I want to create an Alfresco Webservice in Java that create a Folder with a specific rule. Until now the webservice creates the folder and the rule. The problem is that I want to add an actionCondition to my rule that do the same job as "Unless all criteria are met" when you try to create the rule in Alfresco Share.
I want to move all the documents to other folder unless this document is an HMTL.
There is a
CompareMimeTypeEvaluator.class
But it performs the "If all criteria are met" and I want the opposite.
What I did is I created a this Comparator:
public class CompareMismatchEvaluator extends ActionConditionEvaluatorAbstractBase
{
private static Log logger = LogFactory.getLog(CompareMismatchEvaluator.class);
/**
* Evaluator constants
*/
public static final String NAME = "compare-mime-type";
public static final String PARAM_PROPERTY = "property";
public static final String PARAM_VALUE = "value";
/**
*
*/
private static final String ERRID_NOT_A_CONTENT_TYPE = "compare_mime_type_evaluator.not_a_content_type";
private static final String ERRID_NO_PROPERTY_DEFINTION_FOUND = "compare_mime_type_evaluator.no_property_definition_found";
private NodeService nodeService;
/**
* @see org.alfresco.repo.action.evaluator.ActionConditionEvaluatorAbstractBase#evaluateImpl(org.alfresco.service.cmr.action.ActionCondition, org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
public boolean evaluateImpl(ActionCondition actionCondition, NodeRef actionedUponNodeRef)
{
QName propertyQName = (QName) actionCondition.getParameterValue(PARAM_PROPERTY);
// Get the original value and the value to match
Serializable propertyValue = nodeService.getProperty(actionedUponNodeRef, propertyQName);
Serializable compareValue = actionCondition.getParameterValue(PARAM_VALUE);
logger.debug("Comparing : " + propertyValue + " - - - " + compareValue);
return !propertyValue.equals(compareValue);
}
/**
* @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List)
*/
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
{
paramList.add(new ParameterDefinitionImpl(PARAM_PROPERTY, DataTypeDefinition.QNAME, false, getParamDisplayLabel(PARAM_PROPERTY)));
paramList.add(new ParameterDefinitionImpl(PARAM_VALUE, DataTypeDefinition.ANY, true, getParamDisplayLabel(PARAM_VALUE), false, "ac-mimetypes"));
}
}
But this comparator gives the same result as CompareMimeTypeEvaluator.class. So any idea how to get this right ?