use of jp.ossc.nimbus.service.scheduler2.ScheduleManageException in project nimbus by nimbus-org.
the class ScheduleManagerServlet method processScheduleMasterResponse.
/**
* スケジュールマスタ検索リクエスト処理を行う。<p>
*
* @param req HTTPリクエスト
* @param resp HTTPレスポンス
* @param responseType レスポンス種別
* @exception ServletException
* @exception IOException
*/
protected void processScheduleMasterResponse(HttpServletRequest req, HttpServletResponse resp, String responseType) throws ServletException, IOException {
String masterId = getParameter(req, "search_masterId");
String masterGroupId = getParameter(req, "search_masterGroupId");
Exception exception = null;
List scheduleMasters = null;
if (masterId != null && masterId.length() != 0) {
try {
ScheduleMaster scheduleMaster = scheduleManager.findScheduleMaster(masterId);
if (scheduleMaster != null) {
scheduleMasters = new ArrayList(1);
scheduleMasters.add(scheduleMaster);
}
} catch (ScheduleManageException e) {
exception = e;
}
} else if (masterGroupId != null && masterGroupId.length() != 0) {
try {
scheduleMasters = scheduleManager.findScheduleMasters(masterGroupId);
} catch (ScheduleManageException e) {
exception = e;
}
} else {
try {
scheduleMasters = scheduleManager.findAllScheduleMasters();
} 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("scheduleMasters", scheduleMasters);
} 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 {
resp.setContentType("text/html;charset=UTF-8");
if (exception != null) {
buf.append(exception(exception));
} else {
buf.append("<html>");
buf.append(header(HEADER_SCHEDULE_MASTER));
buf.append("<body>");
buf.append(scheduleMasterSearchCondition(getCurrentPath(req), masterId, masterGroupId));
buf.append(scheduleMasters(req, scheduleMasters));
buf.append("</body>");
buf.append("</html>");
}
}
resp.getWriter().println(buf.toString());
}
use of jp.ossc.nimbus.service.scheduler2.ScheduleManageException in project nimbus by nimbus-org.
the class ScheduleManagerServlet method processMakeScheduleResponse.
/**
* スケジュール作成リクエスト処理を行う。<p>
*
* @param req HTTPリクエスト
* @param resp HTTPレスポンス
* @param responseType レスポンス種別
* @exception ServletException
* @exception IOException
*/
protected void processMakeScheduleResponse(HttpServletRequest req, HttpServletResponse resp, String responseType) throws ServletException, IOException {
Date date = null;
try {
date = getDateParameter(req, "date", "yyyyMMdd", true);
} catch (ParseException e) {
resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Parameter 'date' is illegal." + e.toString());
return;
}
Exception exception = null;
List schedules = null;
try {
schedules = scheduleManager.makeSchedule(date);
} 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("schedules", schedules);
} 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 {
processScheduleMasterResponse(req, resp, responseType);
return;
}
}
resp.getWriter().println(buf.toString());
}
Aggregations