use of org.alfresco.service.cmr.action.ActionServiceException in project alfresco-repository by Alfresco.
the class CompareMimeTypeEvaluator method evaluateImpl.
/**
* @see org.alfresco.repo.action.evaluator.ActionConditionEvaluatorAbstractBase#evaluateImpl(org.alfresco.service.cmr.action.ActionCondition, org.alfresco.service.cmr.repository.NodeRef)
*/
public boolean evaluateImpl(ActionCondition actionCondition, NodeRef actionedUponNodeRef) {
QName propertyQName = (QName) actionCondition.getParameterValue(ComparePropertyValueEvaluator.PARAM_PROPERTY);
if (propertyQName == null) {
// Default to the standard content property
actionCondition.setParameterValue(ComparePropertyValueEvaluator.PARAM_PROPERTY, ContentModel.PROP_CONTENT);
} else {
// Ensure that we are dealing with a content property
QName propertyTypeQName = null;
PropertyDefinition propertyDefintion = this.dictionaryService.getProperty(propertyQName);
if (propertyDefintion != null) {
propertyTypeQName = propertyDefintion.getDataType().getName();
if (DataTypeDefinition.CONTENT.equals(propertyTypeQName) == false) {
throw new ActionServiceException(ERRID_NOT_A_CONTENT_TYPE);
}
} else {
throw new ActionServiceException(ERRID_NO_PROPERTY_DEFINTION_FOUND);
}
}
// Set the operation to equals
actionCondition.setParameterValue(ComparePropertyValueEvaluator.PARAM_OPERATION, ComparePropertyValueOperation.EQUALS.toString());
// Set the content property to be MIMETYPE
actionCondition.setParameterValue(ComparePropertyValueEvaluator.PARAM_CONTENT_PROPERTY, ContentPropertyName.MIME_TYPE.toString());
return super.evaluateImpl(actionCondition, actionedUponNodeRef);
}
use of org.alfresco.service.cmr.action.ActionServiceException in project alfresco-repository by Alfresco.
the class ExporterActionExecuter method executeImpl.
/**
* @see org.alfresco.repo.action.executer.ActionExecuter#execute(Action, NodeRef)
*/
public void executeImpl(Action ruleAction, NodeRef actionedUponNodeRef) {
File zipFile = null;
try {
String packageName = (String) ruleAction.getParameterValue(PARAM_PACKAGE_NAME);
File dataFile = new File(packageName);
File contentDir = new File(packageName);
// create a temporary file to hold the zip
zipFile = TempFileProvider.createTempFile(TEMP_FILE_PREFIX, ACPExportPackageHandler.ACP_EXTENSION);
ACPExportPackageHandler zipHandler = new ACPExportPackageHandler(new FileOutputStream(zipFile), dataFile, contentDir, mimetypeService);
ExporterCrawlerParameters params = new ExporterCrawlerParameters();
boolean includeChildren = true;
Boolean withKids = (Boolean) ruleAction.getParameterValue(PARAM_INCLUDE_CHILDREN);
if (withKids != null) {
includeChildren = withKids.booleanValue();
}
params.setCrawlChildNodes(includeChildren);
boolean includeSelf = false;
Boolean andMe = (Boolean) ruleAction.getParameterValue(PARAM_INCLUDE_SELF);
if (andMe != null) {
includeSelf = andMe.booleanValue();
}
params.setCrawlSelf(includeSelf);
params.setExportFrom(new Location(actionedUponNodeRef));
// perform the actual export
this.exporterService.exportView(zipHandler, params, null);
// now the export is done we need to create a node in the repository
// to hold the exported package
NodeRef zip = createExportZip(ruleAction, actionedUponNodeRef);
ContentWriter writer = this.contentService.getWriter(zip, ContentModel.PROP_CONTENT, true);
writer.setEncoding((String) ruleAction.getParameterValue(PARAM_ENCODING));
writer.setMimetype(MimetypeMap.MIMETYPE_ACP);
writer.putContent(zipFile);
} catch (FileNotFoundException fnfe) {
throw new ActionServiceException("export.package.error", fnfe);
} finally {
// try and delete the temporary file
if (zipFile != null) {
zipFile.delete();
}
}
}
use of org.alfresco.service.cmr.action.ActionServiceException in project alfresco-repository by Alfresco.
the class DatePropertyValueComparator method compare.
/**
* @see org.alfresco.repo.action.evaluator.compare.PropertyValueComparator#compare(java.io.Serializable, java.io.Serializable, org.alfresco.repo.action.evaluator.compare.ComparePropertyValueOperation)
*/
public boolean compare(Serializable propertyValue, Serializable compareValue, ComparePropertyValueOperation operation) {
boolean result = false;
if (operation == null) {
operation = ComparePropertyValueOperation.EQUALS;
}
Date propertyDate = getDate(propertyValue);
Date compareDate = getDate(compareValue);
switch(operation) {
case EQUALS:
{
result = propertyDate.equals(compareDate);
break;
}
case LESS_THAN:
{
result = propertyDate.before(compareDate);
break;
}
case LESS_THAN_EQUAL:
{
result = (propertyDate.equals(compareDate) || propertyDate.before(compareDate));
break;
}
case GREATER_THAN:
{
result = propertyDate.after(compareDate);
break;
}
case GREATER_THAN_EQUAL:
{
result = (propertyDate.equals(compareDate) || propertyDate.after(compareDate));
break;
}
default:
{
// Raise an invalid operation exception
throw new ActionServiceException(MSGID_INVALID_OPERATION, new Object[] { operation.toString() });
}
}
return result;
}
use of org.alfresco.service.cmr.action.ActionServiceException in project alfresco-repository by Alfresco.
the class RuleServiceImpl method getSavedRuleFolderAssoc.
/**
* Gets the saved rule folder reference
*
* @param nodeRef the node reference
* @return the node reference
*/
public ChildAssociationRef getSavedRuleFolderAssoc(NodeRef nodeRef) {
ChildAssociationRef result = null;
List<ChildAssociationRef> assocs = this.runtimeNodeService.getChildAssocs(nodeRef, RuleModel.ASSOC_RULE_FOLDER, RuleModel.ASSOC_RULE_FOLDER);
if (assocs.size() > 1) {
throw new ActionServiceException("There is more than one rule folder, which is invalid.");
} else if (assocs.size() == 1) {
result = assocs.get(0);
}
return result;
}
use of org.alfresco.service.cmr.action.ActionServiceException in project alfresco-repository by Alfresco.
the class ActionServiceImpl method getQueue.
/**
* Get the queue to use for asynchronous execution of the given action.
*/
private AsynchronousActionExecutionQueue getQueue(Action action) {
ActionExecuter executer = (ActionExecuter) this.applicationContext.getBean(action.getActionDefinitionName());
AsynchronousActionExecutionQueue queue = null;
String queueName = executer.getQueueName();
if (queueName == null) {
queue = asynchronousActionExecutionQueues.get("");
} else {
queue = asynchronousActionExecutionQueues.get(queueName);
}
if (queue == null) {
// can't get queue
throw new ActionServiceException("Unable to get AsynchronousActionExecutionQueue name: " + queueName);
}
return queue;
}
Aggregations