String wfActionAssign = request.getParameter("wfActionAssign");
String wfActionComments = request.getParameter("wfActionComments");
String wfActionId = request.getParameter("wfActionId");
String wfCons = request.getParameter("wfCons");
WorkflowAPI wapi = APILocator.getWorkflowAPI();
WorkflowAction action = null;
try{
action = wapi.findAction(wfActionId, getUser());
if (action == null) {
throw new ServletException("No such workflow action");
}
}
catch(Exception e){
Logger.error(this.getClass(), e.getMessage(), e);
writeError(response, e.getMessage());
return;
}
StringTokenizer st = new StringTokenizer(wfCons, ",");
String x = null;
while(st.hasMoreTokens()){
try{
x = st.nextToken();
if(!UtilMethods.isSet(x)){
continue;
}
Identifier id = APILocator.getIdentifierAPI().find(x);
Contentlet con = null;
try{
con = APILocator.getContentletAPI().findContentletByIdentifier(id.getId(), false, APILocator.getLanguageAPI().getDefaultLanguage().getId(), getUser(), false);
}
catch(Exception e){
}
if(con == null || ! UtilMethods.isSet(con.getInode())){
List<Language> langs = APILocator.getLanguageAPI().getLanguages();
for(Language lang : langs){
con = (Contentlet) APILocator.getContentletAPI().findContentletByIdentifier(id.getId(), false, lang.getId(), getUser(), false);
if(con != null && UtilMethods.isSet(con.getInode())){
break;
}
}
}
if(action.requiresCheckout()){
Contentlet c = APILocator.getContentletAPI().checkout(con.getInode(), getUser(), true);
c.setStringProperty("wfActionId", action.getId());
c.setStringProperty("wfActionComments", wfActionComments);
c.setStringProperty("wfActionAssign", wfActionAssign);
c = APILocator.getContentletAPI().checkin(c, getUser(), true);
}
else{
con.setStringProperty("wfActionId", action.getId());
con.setStringProperty("wfActionComments", wfActionComments);
con.setStringProperty("wfActionAssign", wfActionAssign);
wapi.fireWorkflowNoCheckin(con, getUser());