Class MapPrinterServlet

java.lang.Object
org.mapfish.print.servlet.BaseMapServlet
org.mapfish.print.servlet.MapPrinterServlet

@Controller public class MapPrinterServlet extends BaseMapServlet
The default servlet.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The url path to cancel a print task.
    static final String
    The url path for capabilities requests.
    static final String
    The url path to create and get a report.
    static final String
    The url path to get a sample print request.
    static final String
    The url path to get the list of fonts available to geotools.
    static final String
    The application ID which indicates the configuration file to load.
    static final String
    The json tag referring to the attributes.
    static final String
    If the job is done (value is true) or not (value is false).
    static final String
    The json key in the create report and status responses containing a link to download the report.
    static final String
    The elapsed time in ms from the point the job started.
    static final String
    The key containing an error message for failed jobs.
    static final String
    The JSON key in the request spec that contains the java font family name.
    static final String
    The JSON key in the request spec that contains the font families names.
    static final String
    The JSON key in the request spec that contains the font families names.
    static final String
    The JSON key in the request spec that contains the font name.
    static final String
    The JSON key in the request spec that contains the font styles.
    static final String
    The JSON key in the request spec that contains the font weight.
    static final String
    The JSON key in the request spec that contains the font config fonts.
    static final String
    The JSON key in the request spec that contains the outputFormat.
    static final String
    The JSON key in the request spec that contains the Jasper report fonts.
    static final String
    The key containing the print job reference ID in the create report response.
    static final String
    The json property to add the request headers from the print request.
    static final String
    The status of the job.
    static final String
    The json key in the create report response containing a link to get the status of the print job.
    static final String
    A rough estimate for the time in ms the job still has to wait in the queue until it starts processing.
    static final String
    The url path to list all registered configurations.
    static final String
    The url path to create a print task and to get a finished print.
    static final String
    The url path to get the status for a print task.
  • Constructor Summary

    Constructors
    Constructor
    Description
    MapPrinterServlet(JobManager jobManager, List<ReportLoader> reportLoaders, MapPrinterFactory printerFactory, org.springframework.context.ApplicationContext context, ServletInfo servletInfo, MapPrinterFactory mapPrinterFactory, com.codahale.metrics.MetricRegistry metricRegistry)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    cancelPath(String referenceId, javax.servlet.http.HttpServletResponse statusResponse)
    Cancel a job.
    final void
    cancelSpecificAppId(String appId, String referenceId, javax.servlet.http.HttpServletResponse statusResponse)
    Cancel a job.
    final void
    createReport(String appId, String format, String requestData, javax.servlet.http.HttpServletRequest createReportRequest, javax.servlet.http.HttpServletResponse createReportResponse)
    Add the print job to the job queue.
    final void
    createReport(String format, String requestData, javax.servlet.http.HttpServletRequest createReportRequest, javax.servlet.http.HttpServletResponse createReportResponse)
    Add the print job to the job queue.
    final void
    createReportAndGet(String appId, String format, String requestData, boolean inline, javax.servlet.http.HttpServletRequest createReportRequest, javax.servlet.http.HttpServletResponse createReportResponse)
    add the print job to the job queue.
    final void
    createReportAndGetNoAppId(String format, String requestData, boolean inline, javax.servlet.http.HttpServletRequest createReportRequest, javax.servlet.http.HttpServletResponse createReportResponse)
    add the print job to the job queue.
    final void
    getCapabilities(boolean pretty, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse capabilitiesResponse)
    To get (in JSON) the information about the available formats and CO.
    final void
    getCapabilities(String appId, boolean pretty, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse capabilitiesResponse)
    To get (in JSON) the information about the available formats and CO.
    final void
    getExampleRequest(String appId, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse getExampleResponse)
    Get a sample request for the app.
    final void
    getExampleRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse getExampleResponse)
    Get a sample request for the app.
    protected final org.json.JSONObject
    getHeaders(javax.servlet.http.HttpServletRequest httpServletRequest)
    Read the headers from the request.
    final void
    getReportPath(String referenceId, boolean inline, javax.servlet.http.HttpServletResponse getReportResponse)
    To get the PDF created previously.
    final void
    getReportSpecificAppId(String appId, String referenceId, boolean inline, javax.servlet.http.HttpServletResponse getReportResponse)
    To get the PDF created previously.
    final void
    getStatusPath(String referenceId, javax.servlet.http.HttpServletRequest statusRequest, javax.servlet.http.HttpServletResponse statusResponse)
    Get a status report on a job.
    final void
    getStatusSpecificAppId(String appId, String referenceId, javax.servlet.http.HttpServletRequest statusRequest, javax.servlet.http.HttpServletResponse statusResponse)
    Get a status report on a job.
    final void
    listAppIds(javax.servlet.http.HttpServletResponse listAppsResponse)
    To get (in JSON) the information about the available formats and CO.
    final void
    listAvailableFonts(javax.servlet.http.HttpServletResponse response)
    List the available fonts on the system.
    final void
    setMaxCreateAndGetWaitTimeInSeconds(long maxCreateAndGetWaitTimeInSeconds)
    Maximum time to wait for a createAndGet request to complete before returning an error.

    Methods inherited from class org.mapfish.print.servlet.BaseMapServlet

    error, getBaseUrl, setCache, setCacheDuration, setNoCache

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • CAPABILITIES_URL

      public static final String CAPABILITIES_URL
      The url path for capabilities requests.
      See Also:
    • LIST_APPS_URL

      public static final String LIST_APPS_URL
      The url path to list all registered configurations.
      See Also:
    • EXAMPLE_REQUEST_URL

      public static final String EXAMPLE_REQUEST_URL
      The url path to get a sample print request.
      See Also:
    • CREATE_AND_GET_URL

      public static final String CREATE_AND_GET_URL
      The url path to create and get a report.
      See Also:
    • STATUS_URL

      public static final String STATUS_URL
      The url path to get the status for a print task.
      See Also:
    • CANCEL_URL

      public static final String CANCEL_URL
      The url path to cancel a print task.
      See Also:
    • REPORT_URL

      public static final String REPORT_URL
      The url path to create a print task and to get a finished print.
      See Also:
    • FONTS_URL

      public static final String FONTS_URL
      The url path to get the list of fonts available to geotools.
      See Also:
    • JSON_ERROR

      public static final String JSON_ERROR
      The key containing an error message for failed jobs.
      See Also:
    • JSON_APP

      public static final String JSON_APP
      The application ID which indicates the configuration file to load.
      See Also:
    • JSON_DONE

      public static final String JSON_DONE
      If the job is done (value is true) or not (value is false).

      Part of the getStatus(String, String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) response.

      See Also:
    • JSON_STATUS

      public static final String JSON_STATUS
      The status of the job. One of the following values:
      • waiting
      • running
      • finished
      • canceled
      • error
      Part of the getStatus(String, String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) response
      See Also:
    • JSON_ELAPSED_TIME

      public static final String JSON_ELAPSED_TIME
      The elapsed time in ms from the point the job started. If the job is finished, this is the duration it took to process the job.

      Part of the getStatus(String, String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) response.

      See Also:
    • JSON_WAITING_TIME

      public static final String JSON_WAITING_TIME
      A rough estimate for the time in ms the job still has to wait in the queue until it starts processing.

      Part of the getStatus(String, String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) response.

      See Also:
    • JSON_PRINT_JOB_REF

      public static final String JSON_PRINT_JOB_REF
      The key containing the print job reference ID in the create report response.
      See Also:
    • JSON_OUTPUT_FORMAT

      public static final String JSON_OUTPUT_FORMAT
      The JSON key in the request spec that contains the outputFormat. This value will be put into the spec by the servlet. there is not need for the post to do this.
      See Also:
    • JSON_ATTRIBUTES

      public static final String JSON_ATTRIBUTES
      The json tag referring to the attributes.
      See Also:
    • JSON_REQUEST_HEADERS

      public static final String JSON_REQUEST_HEADERS
      The json property to add the request headers from the print request.

      The request headers from the print request are needed by certain processors, the headers are added to the request JSON data for those processors.

      See Also:
    • JSON_OUTPUT_JASPERREPORT_FONTS

      public static final String JSON_OUTPUT_JASPERREPORT_FONTS
      The JSON key in the request spec that contains the Jasper report fonts.
      See Also:
    • JSON_OUTPUT_FONTS

      public static final String JSON_OUTPUT_FONTS
      The JSON key in the request spec that contains the font config fonts.
      See Also:
    • JSON_OUTPUT_FONT_FAMILY

      public static final String JSON_OUTPUT_FONT_FAMILY
      The JSON key in the request spec that contains the java font family name.
      See Also:
    • JSON_OUTPUT_FONTCONFIG

      public static final String JSON_OUTPUT_FONTCONFIG
      The JSON key in the request spec that contains the font families names.
      See Also:
    • JSON_OUTPUT_FONTCONFIG_FAMILIES

      public static final String JSON_OUTPUT_FONTCONFIG_FAMILIES
      The JSON key in the request spec that contains the font families names.
      See Also:
    • JSON_OUTPUT_FONTCONFIG_NAME

      public static final String JSON_OUTPUT_FONTCONFIG_NAME
      The JSON key in the request spec that contains the font name.
      See Also:
    • JSON_OUTPUT_FONTCONFIG_STYLES

      public static final String JSON_OUTPUT_FONTCONFIG_STYLES
      The JSON key in the request spec that contains the font styles.
      See Also:
    • JSON_OUTPUT_FONTCONFIG_WEIGHT

      public static final String JSON_OUTPUT_FONTCONFIG_WEIGHT
      The JSON key in the request spec that contains the font weight.
      See Also:
  • Constructor Details

  • Method Details

    • getStatusSpecificAppId

      @RequestMapping(value="/{appId}/status/{referenceId:\\S+}.json", method=GET) public final void getStatusSpecificAppId(@Nonnull @PathVariable String appId, @Nonnull @PathVariable String referenceId, javax.servlet.http.HttpServletRequest statusRequest, javax.servlet.http.HttpServletResponse statusResponse)
      Get a status report on a job. Returns the following json:
      
        {"time":0,"count":0,"done":false}
       
      Parameters:
      appId - the app ID
      referenceId - the job reference
      statusRequest - the request object
      statusResponse - the response object
    • getStatusPath

      @RequestMapping(value="/status/{referenceId:\\S+}.json", method=GET) public final void getStatusPath(@Nonnull @PathVariable String referenceId, javax.servlet.http.HttpServletRequest statusRequest, javax.servlet.http.HttpServletResponse statusResponse)
      Get a status report on a job. Returns the following json:
      
        {"time":0,"count":0,"done":false}
       
      Parameters:
      referenceId - the job reference
      statusRequest - the request object
      statusResponse - the response object
    • cancelSpecificAppId

      @RequestMapping(value="/{appId}/cancel/{referenceId:\\S+}", method=DELETE) public final void cancelSpecificAppId(@Nonnull @PathVariable String appId, @Nonnull @PathVariable String referenceId, javax.servlet.http.HttpServletResponse statusResponse)
      Cancel a job.

      Even if a job was already finished, subsequent status requests will return that the job was canceled.

      Parameters:
      appId - the app ID
      referenceId - the job reference
      statusResponse - the response object
    • cancelPath

      @RequestMapping(value="/cancel/{referenceId:\\S+}", method=DELETE) public final void cancelPath(@Nonnull @PathVariable String referenceId, javax.servlet.http.HttpServletResponse statusResponse)
      Cancel a job.

      Even if a job was already finished, subsequent status requests will return that the job was canceled.

      Parameters:
      referenceId - the job reference
      statusResponse - the response object
    • createReport

      @RequestMapping(value="/{appId}/report.{format:\\w+}", method=POST) public final void createReport(@Nonnull @PathVariable String appId, @PathVariable String format, @RequestBody String requestData, javax.servlet.http.HttpServletRequest createReportRequest, javax.servlet.http.HttpServletResponse createReportResponse) throws NoSuchAppException
      Add the print job to the job queue.
      Parameters:
      appId - the id of the app to get the request for.
      format - the format of the returned report
      requestData - a json formatted string with the request data required to perform the report generation.
      createReportRequest - the request object
      createReportResponse - the response object
      Throws:
      NoSuchAppException
    • getReportSpecificAppId

      @RequestMapping(value="/{appId}/report/{referenceId:\\S+}", method=GET) public final void getReportSpecificAppId(@Nonnull @PathVariable String appId, @Nonnull @PathVariable String referenceId, @RequestParam(value="inline",defaultValue="false") boolean inline, javax.servlet.http.HttpServletResponse getReportResponse) throws IOException, javax.servlet.ServletException
      To get the PDF created previously.
      Parameters:
      appId - the app ID
      referenceId - the path to the file.
      inline - whether to inline the
      getReportResponse - the response object
      Throws:
      IOException
      javax.servlet.ServletException
    • getReportPath

      @RequestMapping(value="/report/{referenceId:\\S+}", method=GET) public final void getReportPath(@Nonnull @PathVariable String referenceId, @RequestParam(value="inline",defaultValue="false") boolean inline, javax.servlet.http.HttpServletResponse getReportResponse) throws IOException, javax.servlet.ServletException
      To get the PDF created previously.
      Parameters:
      referenceId - the job reference
      inline - whether to inline the
      getReportResponse - the response object
      Throws:
      IOException
      javax.servlet.ServletException
    • createReport

      @RequestMapping(value="/report.{format:\\w+}", method=POST) public final void createReport(@PathVariable String format, @RequestBody String requestData, javax.servlet.http.HttpServletRequest createReportRequest, javax.servlet.http.HttpServletResponse createReportResponse) throws NoSuchAppException
      Add the print job to the job queue.
      Parameters:
      format - the format of the returned report
      requestData - a json formatted string with the request data required to perform the report generation.
      createReportRequest - the request object
      createReportResponse - the response object
      Throws:
      NoSuchAppException
    • createReportAndGet

      @RequestMapping(value="/{appId}/buildreport.{format:\\w+}", method=POST) public final void createReportAndGet(@Nonnull @PathVariable String appId, @PathVariable String format, @RequestBody String requestData, @RequestParam(value="inline",defaultValue="false") boolean inline, javax.servlet.http.HttpServletRequest createReportRequest, javax.servlet.http.HttpServletResponse createReportResponse) throws IOException, javax.servlet.ServletException, InterruptedException, NoSuchAppException
      add the print job to the job queue.
      Parameters:
      appId - the id of the app to get the request for.
      format - the format of the returned report
      requestData - a json formatted string with the request data required to perform the report generation.
      inline - whether to inline the content
      createReportRequest - the request object
      createReportResponse - the response object
      Throws:
      IOException
      javax.servlet.ServletException
      InterruptedException
      NoSuchAppException
    • createReportAndGetNoAppId

      @RequestMapping(value="/buildreport.{format:\\w+}", method=POST) public final void createReportAndGetNoAppId(@PathVariable String format, @RequestBody String requestData, @RequestParam(value="inline",defaultValue="false") boolean inline, javax.servlet.http.HttpServletRequest createReportRequest, javax.servlet.http.HttpServletResponse createReportResponse) throws IOException, javax.servlet.ServletException, InterruptedException, NoSuchAppException
      add the print job to the job queue.
      Parameters:
      format - the format of the returned report
      requestData - a json formatted string with the request data required to perform the report generation.
      inline - whether to inline the content
      createReportRequest - the request object
      createReportResponse - the response object
      Throws:
      IOException
      javax.servlet.ServletException
      InterruptedException
      NoSuchAppException
    • listAppIds

      @RequestMapping(value="/apps.json", method=GET) public final void listAppIds(javax.servlet.http.HttpServletResponse listAppsResponse) throws javax.servlet.ServletException, IOException
      To get (in JSON) the information about the available formats and CO.
      Parameters:
      listAppsResponse - the response object
      Throws:
      javax.servlet.ServletException
      IOException
    • getCapabilities

      @RequestMapping(value="/capabilities.json", method=GET) public final void getCapabilities(@RequestParam(value="pretty",defaultValue="false") boolean pretty, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse capabilitiesResponse) throws javax.servlet.ServletException, IOException
      To get (in JSON) the information about the available formats and CO.
      Parameters:
      pretty - if true then pretty print the capabilities
      request - the request
      capabilitiesResponse - the response object
      Throws:
      javax.servlet.ServletException
      IOException
    • getCapabilities

      @RequestMapping(value="/{appId}/capabilities.json", method=GET) public final void getCapabilities(@Nonnull @PathVariable String appId, @RequestParam(value="pretty",defaultValue="false") boolean pretty, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse capabilitiesResponse) throws javax.servlet.ServletException, IOException
      To get (in JSON) the information about the available formats and CO.
      Parameters:
      appId - the name of the "app" or in other words, a mapping to the configuration file for this request.
      pretty - if true then pretty print the capabilities
      request - the request
      capabilitiesResponse - the response object
      Throws:
      javax.servlet.ServletException
      IOException
    • getExampleRequest

      @RequestMapping(value="/exampleRequest.json", method=GET) public final void getExampleRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse getExampleResponse) throws IOException
      Get a sample request for the app. An empty response may be returned if there is not example request.
      Parameters:
      request - the request object
      getExampleResponse - the response object
      Throws:
      IOException
    • getExampleRequest

      @RequestMapping(value="{appId}/exampleRequest.json", method=GET) public final void getExampleRequest(@Nonnull @PathVariable String appId, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse getExampleResponse) throws IOException
      Get a sample request for the app. An empty response may be returned if there is not example request.
      Parameters:
      appId - the id of the app to get the request for.
      request - the request object
      getExampleResponse - the response object
      Throws:
      IOException
    • listAvailableFonts

      @RequestMapping("/fonts") public final void listAvailableFonts(javax.servlet.http.HttpServletResponse response)
      List the available fonts on the system.
      Parameters:
      response - the response object
    • setMaxCreateAndGetWaitTimeInSeconds

      public final void setMaxCreateAndGetWaitTimeInSeconds(long maxCreateAndGetWaitTimeInSeconds)
      Maximum time to wait for a createAndGet request to complete before returning an error.
      Parameters:
      maxCreateAndGetWaitTimeInSeconds - the maximum time in seconds to wait for a report to be generated.
    • getHeaders

      protected final org.json.JSONObject getHeaders(javax.servlet.http.HttpServletRequest httpServletRequest)
      Read the headers from the request.
      Parameters:
      httpServletRequest - the request object