public void save(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
WorkflowAPI wapi = APILocator.getWorkflowAPI();
try {
String actionClassId = request.getParameter("actionClassId");
WorkflowActionClass wac = wapi.findActionClass(actionClassId);
WorkFlowActionlet actionlet = wapi.findActionlet(wac.getClazz());
List<WorkflowActionletParameter> params = actionlet.getParameters();
Map<String, WorkflowActionClassParameter> enteredParams = wapi.findParamsForActionClass(wac);
List<WorkflowActionClassParameter> newParams = new ArrayList<WorkflowActionClassParameter>();
String userIds = null;
for (WorkflowActionletParameter expectedParam : params) {
WorkflowActionClassParameter enteredParam = enteredParams.get(expectedParam.getKey());
if (enteredParam == null) {
enteredParam = new WorkflowActionClassParameter();
}
enteredParam.setActionClassId(wac.getId());
enteredParam.setKey(expectedParam.getKey());
enteredParam.setValue(request.getParameter("acp-" + expectedParam.getKey()));
newParams.add(enteredParam);
userIds = enteredParam.getValue();
//Validate userIds or emails
String errors = expectedParam.hasError(userIds);
if(errors != null){
writeError(response, errors);
return;
}
}
wapi.saveWorkflowActionClassParameters(newParams);
response.getWriter().println(wac.getId() + ":" + wac.getName());
} catch (Exception e) {
Logger.error(this.getClass(), e.getMessage(), e);
writeError(response, e.getMessage());
}
}