use of org.apache.oozie.BaseEngineException in project oozie by apache.
the class V1JobsServlet method submitWorkflowJob.
/**
* v1 service implementation to submit a workflow job
*/
@SuppressWarnings("unchecked")
private JSONObject submitWorkflowJob(HttpServletRequest request, Configuration conf) throws XServletException {
JSONObject json = new JSONObject();
try {
String action = request.getParameter(RestConstants.ACTION_PARAM);
if (action != null && !action.equals(RestConstants.JOB_ACTION_START) && !action.equals(RestConstants.JOB_ACTION_DRYRUN)) {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ErrorCode.E0303, RestConstants.ACTION_PARAM, action);
}
boolean startJob = (action != null);
String user = conf.get(OozieClient.USER_NAME);
DagEngine dagEngine = Services.get().get(DagEngineService.class).getDagEngine(user);
String id;
boolean dryrun = false;
if (action != null) {
dryrun = (action.equals(RestConstants.JOB_ACTION_DRYRUN));
}
if (dryrun) {
id = dagEngine.dryRunSubmit(conf);
} else {
id = dagEngine.submitJob(conf, startJob);
}
json.put(JsonTags.JOB_ID, id);
} catch (BaseEngineException ex) {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
}
return json;
}
use of org.apache.oozie.BaseEngineException in project oozie by apache.
the class V0JobServlet method streamJobLog.
/*
* v0 service method to stream a job log into response object
*/
@Override
protected void streamJobLog(HttpServletRequest request, HttpServletResponse response) throws XServletException, IOException {
DagEngine dagEngine = Services.get().get(DagEngineService.class).getDagEngine(getUser(request));
String jobId = getResourceName(request);
try {
dagEngine.streamLog(jobId, response.getWriter(), request.getParameterMap());
} catch (BaseEngineException ex) {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
}
}
Aggregations