@Test(timeout = 60000) public void testCreateReport_2Requests_Success_NoAppId() throws Exception { doCreateAndPollAndGetReport((@Nullable MockHttpServletRequest servletCreateRequest) -> { try { final MockHttpServletResponse servletCreateResponse = new MockHttpServletResponse(); String requestData = loadRequestDataAsString(); servlet.createReport("png", requestData, servletCreateRequest, servletCreateResponse); final MockHttpServletResponse dummyResponse = new MockHttpServletResponse(); servlet.createReport("png", requestData, servletCreateRequest, dummyResponse); return servletCreateResponse; } catch (Exception e) { throw new AssertionError(e); } }); }
@RequestMapping(value = "/{appId}" + REPORT_URL + ".{format:\\w+}", method = RequestMethod.POST) public final void createReport( @PathVariable final String appId, @PathVariable final String format, @RequestBody final String requestData, final HttpServletRequest createReportRequest, final HttpServletResponse createReportResponse) throws NoSuchAppException { setNoCache(createReportResponse); String ref = createAndSubmitPrintJob(appId, format, requestData, createReportRequest, createReportResponse); if (ref == null) { error(createReportResponse, "Failed to create a print job", HttpStatus.INTERNAL_SERVER_ERROR); return; } createReportResponse.setContentType("application/json; charset=utf-8"); try (PrintWriter writer = createReportResponse.getWriter()) { JSONWriter json = new JSONWriter(writer); json.object(); { json.key(JSON_PRINT_JOB_REF).value(ref); String statusURL = getBaseUrl(createReportRequest) + STATUS_URL + "/" + ref + ".json"; json.key(JSON_STATUS_LINK).value(statusURL); addDownloadLinkToJson(createReportRequest, ref, json); } json.endObject(); } catch (JSONException | IOException e) { LOGGER.warn("Error generating the JSON response", e); } }
MapPrinterServlet extends BaseMapServlet { @RequestMapping(value = "/{appId}" + REPORT_URL + ".{format:\\w+}", method = RequestMethod.POST) public final void createReport( @PathVariable final String appId, @PathVariable final String format, @RequestBody final String requestData, final HttpServletRequest createReportRequest, final HttpServletResponse createReportResponse) throws NoSuchAppException { setNoCache(createReportResponse); String ref = createAndSubmitPrintJob(appId, format, requestData, createReportRequest, createReportResponse); if (ref == null) { error(createReportResponse, "Failed to create a print job", HttpStatus.INTERNAL_SERVER_ERROR); return; } createReportResponse.setContentType("application/json; charset=utf-8"); try (PrintWriter writer = createReportResponse.getWriter()) { JSONWriter json = new JSONWriter(writer); json.object(); { json.key(JSON_PRINT_JOB_REF).value(ref); String statusURL = getBaseUrl(createReportRequest) + STATUS_URL + "/" + ref + ".json"; json.key(JSON_STATUS_LINK).value(statusURL); addDownloadLinkToJson(createReportRequest, ref, json); } json.endObject(); } catch (JSONException | IOException e) { LOGGER.warn("Error generating the JSON response", e); } } }
MapPrinterServlet extends BaseMapServlet { @RequestMapping(value = "/{appId}" + REPORT_URL + ".{format:\\w+}", method = RequestMethod.POST) public final void createReport( @PathVariable final String appId, @PathVariable final String format, @RequestBody final String requestData, final HttpServletRequest createReportRequest, final HttpServletResponse createReportResponse) throws NoSuchAppException { setNoCache(createReportResponse); String ref = createAndSubmitPrintJob(appId, format, requestData, createReportRequest, createReportResponse); if (ref == null) { error(createReportResponse, "Failed to create a print job", HttpStatus.INTERNAL_SERVER_ERROR); return; } createReportResponse.setContentType("application/json; charset=utf-8"); try (PrintWriter writer = createReportResponse.getWriter()) { JSONWriter json = new JSONWriter(writer); json.object(); { json.key(JSON_PRINT_JOB_REF).value(ref); String statusURL = getBaseUrl(createReportRequest) + STATUS_URL + "/" + ref + ".json"; json.key(JSON_STATUS_LINK).value(statusURL); addDownloadLinkToJson(createReportRequest, ref, json); } json.endObject(); } catch (JSONException | IOException e) { LOGGER.warn("Error generating the JSON response", e); } } @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 = "/{appId}" + REPORT_URL + ".{format:\\w+}", method = RequestMethod.POST) public final void createReport( @PathVariable final String appId, @PathVariable final String format, @RequestBody final String requestData, final HttpServletRequest createReportRequest, final HttpServletResponse createReportResponse) throws NoSuchAppException { setNoCache(createReportResponse); String ref = createAndSubmitPrintJob(appId, format, requestData, createReportRequest, createReportResponse); if (ref == null) { error(createReportResponse, "Failed to create a print job", HttpStatus.INTERNAL_SERVER_ERROR); return; } createReportResponse.setContentType("application/json; charset=utf-8"); try (PrintWriter writer = createReportResponse.getWriter()) { JSONWriter json = new JSONWriter(writer); json.object(); { json.key(JSON_PRINT_JOB_REF).value(ref); String statusURL = getBaseUrl(createReportRequest) + STATUS_URL + "/" + ref + ".json"; json.key(JSON_STATUS_LINK).value(statusURL); addDownloadLinkToJson(createReportRequest, ref, json); } json.endObject(); } catch (JSONException | IOException e) { LOGGER.warn("Error generating the JSON response", e); } } @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 = "/{appId}" + REPORT_URL + ".{format:\\w+}", method = RequestMethod.POST) public final void createReport( @PathVariable final String appId, @PathVariable final String format, @RequestBody final String requestData, final HttpServletRequest createReportRequest, final HttpServletResponse createReportResponse) throws NoSuchAppException { setNoCache(createReportResponse); String ref = createAndSubmitPrintJob(appId, format, requestData, createReportRequest, createReportResponse); if (ref == null) { error(createReportResponse, "Failed to create a print job", HttpStatus.INTERNAL_SERVER_ERROR); return; } createReportResponse.setContentType("application/json; charset=utf-8"); try (PrintWriter writer = createReportResponse.getWriter()) { JSONWriter json = new JSONWriter(writer); json.object(); { json.key(JSON_PRINT_JOB_REF).value(ref); String statusURL = getBaseUrl(createReportRequest) + STATUS_URL + "/" + ref + ".json"; json.key(JSON_STATUS_LINK).value(statusURL); addDownloadLinkToJson(createReportRequest, ref, json); } json.endObject(); } catch (JSONException | IOException e) { LOGGER.warn("Error generating the JSON response", e); } } @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; }