@Test(timeout = 60000) public void testGetStatus_InvalidRef() throws Exception { setUpConfigFiles(); String ref = "invalid-ref"; MockHttpServletRequest servletStatusRequest = new MockHttpServletRequest( "GET", "/print/status/" + ref + ".json"); MockHttpServletResponse servletStatusResponse = new MockHttpServletResponse(); servlet.getStatus(ref, servletStatusRequest, servletStatusResponse); assertEquals(HttpStatus.NOT_FOUND.value(), servletStatusResponse.getStatus()); }
@RequestMapping(value = STATUS_URL + "/{referenceId:\\S+}.json", method = RequestMethod.GET) public final void getStatus( @PathVariable final String referenceId, final HttpServletRequest statusRequest, final HttpServletResponse statusResponse) { MDC.put(Processor.MDC_JOB_ID_KEY, referenceId); setNoCache(statusResponse); try { PrintJobStatus status = this.jobManager.getStatus(referenceId); setContentType(statusResponse); try (PrintWriter writer = statusResponse.getWriter()) { JSONWriter json = new JSONWriter(writer); json.object(); { json.key(JSON_DONE).value(status.isDone()); json.key(JSON_STATUS).value(status.getStatus().toString().toLowerCase()); json.key(JSON_ELAPSED_TIME).value(status.getElapsedTime()); json.key(JSON_WAITING_TIME).value(status.getWaitingTime()); if (!StringUtils.isEmpty(status.getError())) { json.key(JSON_ERROR).value(status.getError()); } addDownloadLinkToJson(statusRequest, referenceId, json); } json.endObject(); } } catch (JSONException | IOException e) { throw ExceptionUtils.getRuntimeException(e); } catch (NoSuchReferenceException e) { error(statusResponse, e.getMessage(), HttpStatus.NOT_FOUND); } }
MapPrinterServlet extends BaseMapServlet { @RequestMapping(value = STATUS_URL + "/{referenceId:\\S+}.json", method = RequestMethod.GET) public final void getStatus( @PathVariable final String referenceId, final HttpServletRequest statusRequest, final HttpServletResponse statusResponse) { MDC.put(Processor.MDC_JOB_ID_KEY, referenceId); setNoCache(statusResponse); try { PrintJobStatus status = this.jobManager.getStatus(referenceId); setContentType(statusResponse); try (PrintWriter writer = statusResponse.getWriter()) { JSONWriter json = new JSONWriter(writer); json.object(); { json.key(JSON_DONE).value(status.isDone()); json.key(JSON_STATUS).value(status.getStatus().toString().toLowerCase()); json.key(JSON_ELAPSED_TIME).value(status.getElapsedTime()); json.key(JSON_WAITING_TIME).value(status.getWaitingTime()); if (!StringUtils.isEmpty(status.getError())) { json.key(JSON_ERROR).value(status.getError()); } addDownloadLinkToJson(statusRequest, referenceId, json); } json.endObject(); } } catch (JSONException | IOException e) { throw ExceptionUtils.getRuntimeException(e); } catch (NoSuchReferenceException e) { error(statusResponse, e.getMessage(), HttpStatus.NOT_FOUND); } } }
MapPrinterServlet extends BaseMapServlet { @RequestMapping(value = STATUS_URL + "/{referenceId:\\S+}.json", method = RequestMethod.GET) public final void getStatus( @PathVariable final String referenceId, final HttpServletRequest statusRequest, final HttpServletResponse statusResponse) { MDC.put(Processor.MDC_JOB_ID_KEY, referenceId); setNoCache(statusResponse); try { PrintJobStatus status = this.jobManager.getStatus(referenceId); setContentType(statusResponse); try (PrintWriter writer = statusResponse.getWriter()) { JSONWriter json = new JSONWriter(writer); json.object(); { json.key(JSON_DONE).value(status.isDone()); json.key(JSON_STATUS).value(status.getStatus().toString().toLowerCase()); json.key(JSON_ELAPSED_TIME).value(status.getElapsedTime()); json.key(JSON_WAITING_TIME).value(status.getWaitingTime()); if (!StringUtils.isEmpty(status.getError())) { json.key(JSON_ERROR).value(status.getError()); } addDownloadLinkToJson(statusRequest, referenceId, json); } json.endObject(); } } catch (JSONException | IOException e) { throw ExceptionUtils.getRuntimeException(e); } catch (NoSuchReferenceException e) { error(statusResponse, e.getMessage(), HttpStatus.NOT_FOUND); } } @Autowired  MapPrinterServlet(
            final JobManager jobManager, final List<ReportLoader> reportLoaders,
            final MapPrinterFactory printerFactory, final ApplicationContext context,
            final ServletInfo servletInfo, final MapPrinterFactory mapPrinterFactory); }
MapPrinterServlet extends BaseMapServlet { @RequestMapping(value = STATUS_URL + "/{referenceId:\\S+}.json", method = RequestMethod.GET) public final void getStatus( @PathVariable final String referenceId, final HttpServletRequest statusRequest, final HttpServletResponse statusResponse) { MDC.put(Processor.MDC_JOB_ID_KEY, referenceId); setNoCache(statusResponse); try { PrintJobStatus status = this.jobManager.getStatus(referenceId); setContentType(statusResponse); try (PrintWriter writer = statusResponse.getWriter()) { JSONWriter json = new JSONWriter(writer); json.object(); { json.key(JSON_DONE).value(status.isDone()); json.key(JSON_STATUS).value(status.getStatus().toString().toLowerCase()); json.key(JSON_ELAPSED_TIME).value(status.getElapsedTime()); json.key(JSON_WAITING_TIME).value(status.getWaitingTime()); if (!StringUtils.isEmpty(status.getError())) { json.key(JSON_ERROR).value(status.getError()); } addDownloadLinkToJson(statusRequest, referenceId, json); } json.endObject(); } } catch (JSONException | IOException e) { throw ExceptionUtils.getRuntimeException(e); } catch (NoSuchReferenceException e) { error(statusResponse, e.getMessage(), HttpStatus.NOT_FOUND); } } @Autowired  MapPrinterServlet(
            final JobManager jobManager, final List<ReportLoader> reportLoaders,
            final MapPrinterFactory printerFactory, final ApplicationContext context,
            final ServletInfo servletInfo, final MapPrinterFactory mapPrinterFactory); @RequestMapping(value = "/{appId}" + STATUS_URL + "/{referenceId:\\S+}.json", method = RequestMethod.GET) final void getStatusSpecificAppId(
            @SuppressWarnings("unused") @PathVariable final String appId,
            @PathVariable final String referenceId,
            final HttpServletRequest statusRequest,
            final HttpServletResponse statusResponse); @RequestMapping(value = STATUS_URL + "/{referenceId:\\S+}.json", method = RequestMethod.GET) final void getStatus(
            @PathVariable final String referenceId,
            final HttpServletRequest statusRequest,
            final HttpServletResponse statusResponse); @RequestMapping(value = "/{appId}" + CANCEL_URL + "/{referenceId:\\S+}", method = RequestMethod.DELETE) final void cancelSpecificAppId(
            @SuppressWarnings("unused") @PathVariable final String appId,
            @PathVariable final String referenceId,
            final HttpServletResponse statusResponse); @RequestMapping(value = CANCEL_URL + "/{referenceId:\\S+}", method = RequestMethod.DELETE) final void cancel(
            @PathVariable final String referenceId,
            final HttpServletResponse statusResponse); @RequestMapping(value = "/{appId}" + REPORT_URL + ".{format:\\w+}", method = RequestMethod.POST) final void createReport(
            @PathVariable final String appId,
            @PathVariable final String format,
            @RequestBody final String requestData,
            final HttpServletRequest createReportRequest,
            final HttpServletResponse createReportResponse); @RequestMapping(value = "/{appId}" + REPORT_URL + "/{referenceId:\\S+}", method = RequestMethod.GET) final void getReportSpecificAppId(
            @SuppressWarnings("unused") @PathVariable final String appId,
            @PathVariable final String referenceId,
            @RequestParam(value = "inline", defaultValue = "false") final boolean inline,
            final HttpServletResponse getReportResponse); @RequestMapping(value = REPORT_URL + "/{referenceId:\\S+}", method = RequestMethod.GET) final void getReport(
            @PathVariable final String referenceId,
            @RequestParam(value = "inline", defaultValue = "false") final boolean inline,
            final HttpServletResponse getReportResponse); @RequestMapping(value = REPORT_URL + ".{format:\\w+}", method = RequestMethod.POST) final void createReport(
            @PathVariable final String format,
            @RequestBody final String requestData,
            final HttpServletRequest createReportRequest,
            final HttpServletResponse createReportResponse); @RequestMapping(value = "/{appId}" + CREATE_AND_GET_URL + ".{format:\\w+}", method = RequestMethod.POST) final void createReportAndGet(
            @PathVariable final String appId,
            @PathVariable final String format,
            @RequestBody final String requestData,
            @RequestParam(value = "inline", defaultValue = "false") final boolean inline,
            final HttpServletRequest createReportRequest,
            final HttpServletResponse createReportResponse); @RequestMapping(value = CREATE_AND_GET_URL + ".{format:\\w+}", method = RequestMethod.POST) final void createReportAndGetNoAppId(
            @PathVariable final String format,
            @RequestBody final String requestData,
            @RequestParam(value = "inline", defaultValue = "false") final boolean inline,
            final HttpServletRequest createReportRequest,
            final HttpServletResponse createReportResponse); @RequestMapping(value = LIST_APPS_URL, method = RequestMethod.GET) final void listAppIds(
            final HttpServletResponse listAppsResponse); @RequestMapping(value = CAPABILITIES_URL, method = RequestMethod.GET) final void getCapabilities(
            @RequestParam(value = "pretty", defaultValue = "false") final boolean pretty,
            final HttpServletRequest request,
            final HttpServletResponse capabilitiesResponse); @RequestMapping(value = "/{appId}" + CAPABILITIES_URL, method = RequestMethod.GET) final void getCapabilities(
            @PathVariable final String appId,
            @RequestParam(value = "pretty", defaultValue = "false") final boolean pretty,
            final HttpServletRequest request,
            final HttpServletResponse capabilitiesResponse); @RequestMapping(value = EXAMPLE_REQUEST_URL, method = RequestMethod.GET) final void getExampleRequest(
            final HttpServletRequest request,
            final HttpServletResponse getExampleResponse); @RequestMapping(value = "{appId}" + EXAMPLE_REQUEST_URL, method = RequestMethod.GET) final void getExampleRequest(
            @PathVariable final String appId,
            final HttpServletRequest request,
            final HttpServletResponse getExampleResponse); @RequestMapping(value = FONTS_URL) @ResponseBody final String listAvailableFonts(); final void setMaxCreateAndGetWaitTimeInSeconds(final long maxCreateAndGetWaitTimeInSeconds); }
MapPrinterServlet extends BaseMapServlet { @RequestMapping(value = STATUS_URL + "/{referenceId:\\S+}.json", method = RequestMethod.GET) public final void getStatus( @PathVariable final String referenceId, final HttpServletRequest statusRequest, final HttpServletResponse statusResponse) { MDC.put(Processor.MDC_JOB_ID_KEY, referenceId); setNoCache(statusResponse); try { PrintJobStatus status = this.jobManager.getStatus(referenceId); setContentType(statusResponse); try (PrintWriter writer = statusResponse.getWriter()) { JSONWriter json = new JSONWriter(writer); json.object(); { json.key(JSON_DONE).value(status.isDone()); json.key(JSON_STATUS).value(status.getStatus().toString().toLowerCase()); json.key(JSON_ELAPSED_TIME).value(status.getElapsedTime()); json.key(JSON_WAITING_TIME).value(status.getWaitingTime()); if (!StringUtils.isEmpty(status.getError())) { json.key(JSON_ERROR).value(status.getError()); } addDownloadLinkToJson(statusRequest, referenceId, json); } json.endObject(); } } catch (JSONException | IOException e) { throw ExceptionUtils.getRuntimeException(e); } catch (NoSuchReferenceException e) { error(statusResponse, e.getMessage(), HttpStatus.NOT_FOUND); } } @Autowired  MapPrinterServlet(
            final JobManager jobManager, final List<ReportLoader> reportLoaders,
            final MapPrinterFactory printerFactory, final ApplicationContext context,
            final ServletInfo servletInfo, final MapPrinterFactory mapPrinterFactory); @RequestMapping(value = "/{appId}" + STATUS_URL + "/{referenceId:\\S+}.json", method = RequestMethod.GET) final void getStatusSpecificAppId(
            @SuppressWarnings("unused") @PathVariable final String appId,
            @PathVariable final String referenceId,
            final HttpServletRequest statusRequest,
            final HttpServletResponse statusResponse); @RequestMapping(value = STATUS_URL + "/{referenceId:\\S+}.json", method = RequestMethod.GET) final void getStatus(
            @PathVariable final String referenceId,
            final HttpServletRequest statusRequest,
            final HttpServletResponse statusResponse); @RequestMapping(value = "/{appId}" + CANCEL_URL + "/{referenceId:\\S+}", method = RequestMethod.DELETE) final void cancelSpecificAppId(
            @SuppressWarnings("unused") @PathVariable final String appId,
            @PathVariable final String referenceId,
            final HttpServletResponse statusResponse); @RequestMapping(value = CANCEL_URL + "/{referenceId:\\S+}", method = RequestMethod.DELETE) final void cancel(
            @PathVariable final String referenceId,
            final HttpServletResponse statusResponse); @RequestMapping(value = "/{appId}" + REPORT_URL + ".{format:\\w+}", method = RequestMethod.POST) final void createReport(
            @PathVariable final String appId,
            @PathVariable final String format,
            @RequestBody final String requestData,
            final HttpServletRequest createReportRequest,
            final HttpServletResponse createReportResponse); @RequestMapping(value = "/{appId}" + REPORT_URL + "/{referenceId:\\S+}", method = RequestMethod.GET) final void getReportSpecificAppId(
            @SuppressWarnings("unused") @PathVariable final String appId,
            @PathVariable final String referenceId,
            @RequestParam(value = "inline", defaultValue = "false") final boolean inline,
            final HttpServletResponse getReportResponse); @RequestMapping(value = REPORT_URL + "/{referenceId:\\S+}", method = RequestMethod.GET) final void getReport(
            @PathVariable final String referenceId,
            @RequestParam(value = "inline", defaultValue = "false") final boolean inline,
            final HttpServletResponse getReportResponse); @RequestMapping(value = REPORT_URL + ".{format:\\w+}", method = RequestMethod.POST) final void createReport(
            @PathVariable final String format,
            @RequestBody final String requestData,
            final HttpServletRequest createReportRequest,
            final HttpServletResponse createReportResponse); @RequestMapping(value = "/{appId}" + CREATE_AND_GET_URL + ".{format:\\w+}", method = RequestMethod.POST) final void createReportAndGet(
            @PathVariable final String appId,
            @PathVariable final String format,
            @RequestBody final String requestData,
            @RequestParam(value = "inline", defaultValue = "false") final boolean inline,
            final HttpServletRequest createReportRequest,
            final HttpServletResponse createReportResponse); @RequestMapping(value = CREATE_AND_GET_URL + ".{format:\\w+}", method = RequestMethod.POST) final void createReportAndGetNoAppId(
            @PathVariable final String format,
            @RequestBody final String requestData,
            @RequestParam(value = "inline", defaultValue = "false") final boolean inline,
            final HttpServletRequest createReportRequest,
            final HttpServletResponse createReportResponse); @RequestMapping(value = LIST_APPS_URL, method = RequestMethod.GET) final void listAppIds(
            final HttpServletResponse listAppsResponse); @RequestMapping(value = CAPABILITIES_URL, method = RequestMethod.GET) final void getCapabilities(
            @RequestParam(value = "pretty", defaultValue = "false") final boolean pretty,
            final HttpServletRequest request,
            final HttpServletResponse capabilitiesResponse); @RequestMapping(value = "/{appId}" + CAPABILITIES_URL, method = RequestMethod.GET) final void getCapabilities(
            @PathVariable final String appId,
            @RequestParam(value = "pretty", defaultValue = "false") final boolean pretty,
            final HttpServletRequest request,
            final HttpServletResponse capabilitiesResponse); @RequestMapping(value = EXAMPLE_REQUEST_URL, method = RequestMethod.GET) final void getExampleRequest(
            final HttpServletRequest request,
            final HttpServletResponse getExampleResponse); @RequestMapping(value = "{appId}" + EXAMPLE_REQUEST_URL, method = RequestMethod.GET) final void getExampleRequest(
            @PathVariable final String appId,
            final HttpServletRequest request,
            final HttpServletResponse getExampleResponse); @RequestMapping(value = FONTS_URL) @ResponseBody final String listAvailableFonts(); final void setMaxCreateAndGetWaitTimeInSeconds(final long maxCreateAndGetWaitTimeInSeconds); static final String CAPABILITIES_URL; static final String LIST_APPS_URL; static final String EXAMPLE_REQUEST_URL; static final String CREATE_AND_GET_URL; static final String STATUS_URL; static final String CANCEL_URL; static final String REPORT_URL; static final String FONTS_URL; static final String JSON_ERROR; static final String JSON_APP; static final String JSON_DONE; static final String JSON_STATUS; static final String JSON_ELAPSED_TIME; static final String JSON_WAITING_TIME; static final String JSON_PRINT_JOB_REF; static final String JSON_STATUS_LINK; static final String JSON_DOWNLOAD_LINK; static final String JSON_OUTPUT_FORMAT; static final String JSON_ATTRIBUTES; static final String JSON_REQUEST_HEADERS; }