/** * v1 service implementation to get a list of workflows, with filtering or interested windows * embedded in the request object */ @SuppressWarnings("unchecked") private JSONObject getCoordinatorJobs(HttpServletRequest request) throws XServletException { JSONObject json = new JSONObject(); try { String filter = request.getParameter(RestConstants.JOBS_FILTER_PARAM); String startStr = request.getParameter(RestConstants.OFFSET_PARAM); String lenStr = request.getParameter(RestConstants.LEN_PARAM); int start = (startStr != null) ? Integer.parseInt(startStr) : 1; start = (start < 1) ? 1 : start; int len = (lenStr != null) ? Integer.parseInt(lenStr) : 50; len = (len < 1) ? 50 : len; CoordinatorEngine coordEngine = Services.get() .get(CoordinatorEngineService.class) .getCoordinatorEngine(getUser(request), getAuthToken(request)); CoordinatorJobInfo jobs = coordEngine.getCoordJobs(filter, start, len); List<CoordinatorJobBean> jsonJobs = jobs.getCoordJobs(); json.put(JsonTags.COORDINATOR_JOBS, CoordinatorJobBean.toJSONArray(jsonJobs)); json.put(JsonTags.COORD_JOB_TOTAL, jobs.getTotal()); json.put(JsonTags.COORD_JOB_OFFSET, jobs.getStart()); json.put(JsonTags.COORD_JOB_LEN, jobs.getLen()); } catch (CoordinatorEngineException ex) { throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex); } return json; }