use of org.apache.oozie.CoordinatorEngineException in project oozie by apache.
the class V2JobServlet method getWfActionByJobIdAndName.
@Override
protected JSONObject getWfActionByJobIdAndName(HttpServletRequest request, HttpServletResponse response) throws XServletException, IOException {
CoordinatorEngine coordEngine = Services.get().get(CoordinatorEngineService.class).getCoordinatorEngine(getUser(request));
String jobId = getResourceName(request);
String action = request.getParameter(RestConstants.ACTION_NAME_PARAM);
String startStr = request.getParameter(RestConstants.OFFSET_PARAM);
String lenStr = request.getParameter(RestConstants.LEN_PARAM);
String timeZoneId = request.getParameter(RestConstants.TIME_ZONE_PARAM);
timeZoneId = (timeZoneId == null) ? "GMT" : timeZoneId;
if (action == null) {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ErrorCode.E0305, RestConstants.ACTION_NAME_PARAM);
}
int offset = (startStr != null) ? Integer.parseInt(startStr) : 1;
offset = (offset < 1) ? 1 : offset;
/**
* set default number of wf actions to be retrieved to
* default number of coordinator actions to be retrieved
*/
int defaultLen = ConfigurationService.getInt(COORD_ACTIONS_DEFAULT_LENGTH);
int len = (lenStr != null) ? Integer.parseInt(lenStr) : 0;
len = getCoordinatorJobLength(defaultLen, len);
try {
JSONObject json = new JSONObject();
List<CoordinatorWfActionBean> coordWfActions = coordEngine.getWfActionByJobIdAndName(jobId, action, offset, len);
JSONArray array = new JSONArray();
for (CoordinatorWfActionBean coordWfAction : coordWfActions) {
array.add(coordWfAction.toJSONObject(timeZoneId));
}
json.put(JsonTags.COORDINATOR_JOB_ID, jobId);
json.put(JsonTags.COORDINATOR_WF_ACTIONS, array);
return json;
} catch (CoordinatorEngineException ex) {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
}
}
Aggregations