use of org.alfresco.rest.api.model.Action in project alfresco-remote-api by Alfresco.
the class ActionsImpl method executeAction.
@Override
public Action executeAction(Action action, Parameters parameters) {
if (action == null) {
throw new InvalidArgumentException("action is null");
}
if (action.getActionDefinitionId() == null || action.getActionDefinitionId().isEmpty()) {
throw new InvalidArgumentException("action.actionDefinitionId is null or empty");
}
org.alfresco.service.cmr.action.ActionDefinition actionDef = null;
try {
actionDef = actionService.getActionDefinition(action.getActionDefinitionId());
} catch (NoSuchBeanDefinitionException nsbdx) {
// Intentionally empty.
}
// the result of getActionDefinition can be null and not throw the exception.
if (actionDef == null) {
throw new EntityNotFoundException(action.getActionDefinitionId());
}
// targetId is optional, however, currently targetId must be a valid node ID.
NodeRef actionedUponNodeRef = null;
if (action.getTargetId() != null && !action.getTargetId().isEmpty()) {
// Does it exist in the repo?
actionedUponNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, action.getTargetId());
if (!nodeService.exists(actionedUponNodeRef)) {
throw new EntityNotFoundException(action.getTargetId());
}
}
org.alfresco.service.cmr.action.Action cmrAction;
if (action.getParams() != null && !action.getParams().isEmpty()) {
cmrAction = actionService.createAction(action.getActionDefinitionId(), extractActionParams(actionDef, action.getParams()));
} else {
cmrAction = actionService.createAction(action.getActionDefinitionId());
}
actionService.executeAction(cmrAction, actionedUponNodeRef, true, true);
// Create user result.
Action result = new Action();
result.setId(cmrAction.getId());
return result;
}
Aggregations