throw new XServletException(HttpServletResponse.SC_UNAUTHORIZED, ex);
}
DagEngine dagEngine = Services.get().get(DagEngineService.class).getDagEngine(getUser(request),
getAuthToken(request));
CoordinatorEngine coordEngine = Services.get().get(CoordinatorEngineService.class).getCoordinatorEngine(
getUser(request), getAuthToken(request));
try {
String action = request.getParameter(RestConstants.ACTION_PARAM);
if (action.equals(RestConstants.JOB_ACTION_START)) {
stopCron();
dagEngine.start(jobId);
startCron();
response.setStatus(HttpServletResponse.SC_OK);
}
else if (action.equals(RestConstants.JOB_ACTION_RESUME)) {
stopCron();
dagEngine.resume(jobId);
startCron();
response.setStatus(HttpServletResponse.SC_OK);
}
else if (action.equals(RestConstants.JOB_ACTION_SUSPEND)) {
stopCron();
dagEngine.suspend(jobId);
startCron();
response.setStatus(HttpServletResponse.SC_OK);
}
else if (action.equals(RestConstants.JOB_ACTION_KILL)) {
stopCron();
dagEngine.kill(jobId);
startCron();
response.setStatus(HttpServletResponse.SC_OK);
}
else if (action.equals(RestConstants.JOB_ACTION_RERUN)) {
validateContentType(request, RestConstants.XML_CONTENT_TYPE);
XConfiguration conf = new XConfiguration(request.getInputStream());
stopCron();
conf = conf.trim();
conf = conf.resolve();
JobsServlet.validateJobConfiguration(conf);
checkAuthorizationForApp(getUser(request), conf);
dagEngine.reRun(jobId, conf);
startCron();
response.setStatus(HttpServletResponse.SC_OK);
}
else if (action.equals(RestConstants.JOB_COORD_ACTION_RERUN)) {
validateContentType(request, RestConstants.XML_CONTENT_TYPE);
stopCron();
String rerunType = request.getParameter(RestConstants.JOB_COORD_RERUN_TYPE_PARAM);
String scope = request.getParameter(RestConstants.JOB_COORD_RERUN_SCOPE_PARAM);
String refresh = request.getParameter(RestConstants.JOB_COORD_RERUN_REFRESH_PARAM);
String noCleanup = request.getParameter(RestConstants.JOB_COORD_RERUN_NOCLEANUP_PARAM);
CoordinatorActionInfo coordInfo = coordEngine.reRun(jobId, rerunType, scope, Boolean.valueOf(refresh),
Boolean.valueOf(noCleanup));
List<CoordinatorActionBean> actions = coordInfo.getCoordActions();
JSONObject json = new JSONObject();
json.put(JsonTags.COORDINATOR_ACTIONS, CoordinatorActionBean.toJSONArray(actions));
startCron();