use of jp.ossc.nimbus.service.scheduler2.ScheduleDepends in project nimbus by nimbus-org.
the class ScheduleManagerServlet method processAddResponse.
/**
* スケジュール追加リクエスト処理を行う。<p>
*
* @param req HTTPリクエスト
* @param resp HTTPレスポンス
* @param responseType レスポンス種別
* @exception ServletException
* @exception IOException
*/
protected void processAddResponse(HttpServletRequest req, HttpServletResponse resp, String responseType) throws ServletException, IOException {
String masterId = getParameter(req, "masterId");
Date time = null;
try {
time = getDateParameter(req, "time", "yyyyMMddHHmmssSSS", true);
} catch (ParseException e) {
resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Parameter 'time' is illegal." + e.toString());
return;
}
String taskName = getParameter(req, "taskName");
String input = getParameter(req, "input");
String[] depends = getParameterValues(req, "depends");
ScheduleDepends[] dependsArray = null;
if (depends != null) {
dependsArray = new ScheduleDepends[depends.length];
for (int i = 0; i < dependsArray.length; i++) {
dependsArray[i] = new DefaultScheduleDepends(depends[i], false);
}
}
String executorKey = getParameter(req, "executorKey");
String executorType = getParameter(req, "executorType");
Long retryInterval = getLongParameter(req, "retryInterval");
Date retryEndTime = null;
try {
retryEndTime = getDateParameter(req, "retryEndTime", "yyyyMMddHHmmssSSS", false);
} catch (ParseException e) {
resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Parameter 'retryEndTime' is illegal." + e.toString());
return;
}
Long maxDelayTime = getLongParameter(req, "maxDelayTime");
Exception exception = null;
DefaultSchedule schedule = null;
try {
schedule = new DefaultSchedule(masterId, null, time, taskName, input, dependsArray, null, null, null, executorKey, executorType, retryInterval == null ? 0l : retryInterval.longValue(), retryEndTime, maxDelayTime == null ? 0l : maxDelayTime.longValue());
scheduleManager.addSchedule(schedule);
} catch (ScheduleManageException e) {
exception = e;
}
final StringBuilder buf = new StringBuilder();
if ("json".equals(responseType)) {
resp.setContentType("application/json;charset=UTF-8");
Map jsonMap = new HashMap();
if (exception == null) {
jsonMap.put("schedule", schedule);
} else {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
exception.printStackTrace(pw);
pw.flush();
jsonMap.put("exception", sw.toString());
}
buf.append(toStringConverter.convertToObject(jsonConverter.convertToStream(jsonMap)));
} else {
if (exception != null) {
resp.setContentType("text/html;charset=UTF-8");
buf.append(exception(exception));
} else {
processScheduleResponse(req, resp, responseType);
return;
}
}
resp.getWriter().println(buf.toString());
}
Aggregations