List<WorkflowTask> tasks=wapi.findExpiredTasks();
for (WorkflowTask task : tasks) {
String stepId=task.getStatus();
WorkflowStep step=wapi.findStep(stepId);
String actionId=step.getEscalationAction();
WorkflowAction action=wapi.findAction(actionId, APILocator.getUserAPI().getSystemUser());
Logger.info(this, "Task '"+task.getTitle()+"' " +
"on contentlet id '"+task.getWebasset()+"' "+
"timeout on step '"+step.getName()+"' " +
"excecuting escalation action '"+action.getName()+"'");
// find contentlet for default language
Contentlet def=APILocator.getContentletAPI().findContentletByIdentifier(task.getWebasset(), false,
APILocator.getLanguageAPI().getDefaultLanguage().getId(),
APILocator.getUserAPI().getSystemUser(), false);
String inode=def.getInode();
Contentlet c;
// if the worflow requires a checkin
if(action.requiresCheckout()){
c = APILocator.getContentletAPI().checkout(inode, APILocator.getUserAPI().getSystemUser(), false);
c.setStringProperty("wfActionId", action.getId());
c.setStringProperty("wfActionComments", wfActionComments);
c.setStringProperty("wfActionAssign", wfActionAssign);
c = APILocator.getContentletAPI().checkin(c, APILocator.getUserAPI().getSystemUser(), false);
}
// if the worflow requires a checkin
else{
c = APILocator.getContentletAPI().find(inode, APILocator.getUserAPI().getSystemUser(), false);
c.setStringProperty("wfActionId", action.getId());
c.setStringProperty("wfActionComments", wfActionComments);
c.setStringProperty("wfActionAssign", wfActionAssign);
wapi.fireWorkflowNoCheckin(c, APILocator.getUserAPI().getSystemUser());
}
}