if (!UtilMethods.isSet(workflowActionId)) {
if (scheme.isMandatory() ) {
throw new DotWorkflowException(LanguageUtil.get(firingUser, "message.workflow.error.mandatory.action.type") + contentlet.getStructure().getName());
}
return;
}
try{
action = getWorkflowAPI().findAction(workflowActionId, user);
}
catch(Exception ex){
throw new DotWorkflowException(LanguageUtil.get(firingUser, "message.workflow.error.invalid.action") + contentlet.getStringProperty(Contentlet.WORKFLOW_ACTION_KEY));
}
if(action.requiresCheckout()){
try{
APILocator.getContentletAPI().canLock(contentlet, user);
}
catch(Exception ex){
throw new DotWorkflowException(LanguageUtil.get(firingUser, "message.workflow.error.content.requires.lock") + contentlet.getStructure().getName());
}
}
if (UtilMethods.isSet(contentlet.getStringProperty(Contentlet.WORKFLOW_ASSIGN_KEY))) {
nextAssign = getRoleAPI().loadRoleById(contentlet.getStringProperty(Contentlet.WORKFLOW_ASSIGN_KEY));
}
if(!UtilMethods.isSet(nextAssign)){
nextAssign = getRoleAPI().loadRoleById(action.getNextAssign());
}
// if the action's next assign is the "System User", we assign to the user executing the workflow
if((!UtilMethods.isSet(nextAssign)) || getRoleAPI().loadCMSAnonymousRole().getId().equals(nextAssign.getId())){
nextAssign = getRoleAPI().loadRoleByKey(user.getUserId());
}
if(UtilMethods.isSet(Contentlet.WORKFLOW_COMMENTS_KEY)){
workflowMessage = contentlet.getStringProperty(Contentlet.WORKFLOW_COMMENTS_KEY);
}
nextStep = getWorkflowAPI().findStep(action.getNextStep());
step = getWorkflowAPI().findStep(action.getStepId());
actionClasses = getWorkflowAPI().findActionClasses(action);
if(task != null && UtilMethods.isSet(task.getId())){
history = getWorkflowAPI().findWorkflowHistory(task);
}
} catch (Exception e) {
throw new DotWorkflowException(e.getMessage());
}
}