@Test(timeout = 60000) public void testCancel() throws Exception { setUpConfigFiles(); final MockHttpServletRequest servletCreateRequest = new MockHttpServletRequest(); final MockHttpServletResponse servletCreateResponse = new MockHttpServletResponse(); String requestData = loadRequestDataAsString(); servlet.createReport("png", requestData, servletCreateRequest, servletCreateResponse); final PJsonObject createResponseJson = parseJSONObjectFromString(servletCreateResponse.getContentAsString()); assertTrue(createResponseJson.has(MapPrinterServlet.JSON_PRINT_JOB_REF)); assertEquals(HttpStatus.OK.value(), servletCreateResponse.getStatus()); String ref = createResponseJson.getString(MapPrinterServlet.JSON_PRINT_JOB_REF); MockHttpServletResponse servletCancelResponse = new MockHttpServletResponse(); servlet.cancel(ref, servletCancelResponse); assertEquals(HttpStatus.OK.value(), servletCancelResponse.getStatus()); final MockHttpServletRequest statusRequest = new MockHttpServletRequest(); final MockHttpServletResponse statusResponse = new MockHttpServletResponse(); servlet.getStatus(ref, statusRequest, statusResponse); final PJsonObject statusJson = parseJSONObjectFromString(statusResponse.getContentAsString()); assertEquals("true", statusJson.getString(MapPrinterServlet.JSON_DONE)); assertEquals("task cancelled", statusJson.getString(MapPrinterServlet.JSON_ERROR)); assertEquals("cancelled", statusJson.getString(MapPrinterServlet.JSON_STATUS)); }
@RequestMapping(value = CANCEL_URL + "/{referenceId:\\S+}", method = RequestMethod.DELETE) public final void cancel( @PathVariable final String referenceId, final HttpServletResponse statusResponse) { MDC.put(Processor.MDC_JOB_ID_KEY, referenceId); setNoCache(statusResponse); try { this.jobManager.cancel(referenceId); } catch (NoSuchReferenceException e) { error(statusResponse, e.getMessage(), HttpStatus.NOT_FOUND); } }
MapPrinterServlet extends BaseMapServlet { @RequestMapping(value = CANCEL_URL + "/{referenceId:\\S+}", method = RequestMethod.DELETE) public final void cancel( @PathVariable final String referenceId, final HttpServletResponse statusResponse) { MDC.put(Processor.MDC_JOB_ID_KEY, referenceId); setNoCache(statusResponse); try { this.jobManager.cancel(referenceId); } catch (NoSuchReferenceException e) { error(statusResponse, e.getMessage(), HttpStatus.NOT_FOUND); } } }
MapPrinterServlet extends BaseMapServlet { @RequestMapping(value = CANCEL_URL + "/{referenceId:\\S+}", method = RequestMethod.DELETE) public final void cancel( @PathVariable final String referenceId, final HttpServletResponse statusResponse) { MDC.put(Processor.MDC_JOB_ID_KEY, referenceId); setNoCache(statusResponse); try { this.jobManager.cancel(referenceId); } 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 = CANCEL_URL + "/{referenceId:\\S+}", method = RequestMethod.DELETE) public final void cancel( @PathVariable final String referenceId, final HttpServletResponse statusResponse) { MDC.put(Processor.MDC_JOB_ID_KEY, referenceId); setNoCache(statusResponse); try { this.jobManager.cancel(referenceId); } 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 = CANCEL_URL + "/{referenceId:\\S+}", method = RequestMethod.DELETE) public final void cancel( @PathVariable final String referenceId, final HttpServletResponse statusResponse) { MDC.put(Processor.MDC_JOB_ID_KEY, referenceId); setNoCache(statusResponse); try { this.jobManager.cancel(referenceId); } 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; }