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 java.lang.String
CANCEL_URL
The url path to cancel a print task.static java.lang.String
CAPABILITIES_URL
The url path for capabilities requests.static java.lang.String
CREATE_AND_GET_URL
The url path to create and get a report.static java.lang.String
EXAMPLE_REQUEST_URL
The url path to get a sample print request.static java.lang.String
FONTS_URL
The url path to get the list of fonts available to geotools.static java.lang.String
JSON_APP
The application ID which indicates the configuration file to load.static java.lang.String
JSON_ATTRIBUTES
The json tag referring to the attributes.static java.lang.String
JSON_DONE
If the job is done (value is true) or not (value is false).static java.lang.String
JSON_DOWNLOAD_LINK
The json key in the create report and status responses containing a link to download the report.static java.lang.String
JSON_ELAPSED_TIME
The elapsed time in ms from the point the job started.static java.lang.String
JSON_ERROR
The key containing an error message for failed jobs.static java.lang.String
JSON_OUTPUT_FONT_FAMILY
The JSON key in the request spec that contains the java font family name.static java.lang.String
JSON_OUTPUT_FONTCONFIG
The JSON key in the request spec that contains the font families names.static java.lang.String
JSON_OUTPUT_FONTCONFIG_FAMILIES
The JSON key in the request spec that contains the font families names.static java.lang.String
JSON_OUTPUT_FONTCONFIG_NAME
The JSON key in the request spec that contains the font name.static java.lang.String
JSON_OUTPUT_FONTCONFIG_STYLES
The JSON key in the request spec that contains the font styles.static java.lang.String
JSON_OUTPUT_FONTCONFIG_WEIGHT
The JSON key in the request spec that contains the font weight.static java.lang.String
JSON_OUTPUT_FONTS
The JSON key in the request spec that contains the font config fonts.static java.lang.String
JSON_OUTPUT_FORMAT
The JSON key in the request spec that contains the outputFormat.static java.lang.String
JSON_OUTPUT_JASPERREPORT_FONTS
The JSON key in the request spec that contains the Jasper report fonts.static java.lang.String
JSON_PRINT_JOB_REF
The key containing the print job reference ID in the create report response.static java.lang.String
JSON_REQUEST_HEADERS
The json property to add the request headers from the print request.static java.lang.String
JSON_STATUS
The status of the job.static java.lang.String
JSON_STATUS_LINK
The json key in the create report response containing a link to get the status of the print job.static java.lang.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.static java.lang.String
LIST_APPS_URL
The url path to list all registered configurations.static java.lang.String
REPORT_URL
The url path to create a print task and to get a finished print.static java.lang.String
STATUS_URL
The url path to get the status for a print task.
-
Constructor Summary
Constructors Constructor Description MapPrinterServlet(JobManager jobManager, java.util.List<ReportLoader> reportLoaders, MapPrinterFactory printerFactory, org.springframework.context.ApplicationContext context, ServletInfo servletInfo, MapPrinterFactory mapPrinterFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancel(java.lang.String applicationId, java.lang.String referenceId, javax.servlet.http.HttpServletResponse statusResponse)
Cancel a job.void
cancelPath(java.lang.String referenceId, javax.servlet.http.HttpServletResponse statusResponse)
Cancel a job.void
cancelSpecificAppId(java.lang.String appId, java.lang.String referenceId, javax.servlet.http.HttpServletResponse statusResponse)
Cancel a job.void
createReport(java.lang.String appId, java.lang.String format, java.lang.String requestData, javax.servlet.http.HttpServletRequest createReportRequest, javax.servlet.http.HttpServletResponse createReportResponse)
Add the print job to the job queue.void
createReport(java.lang.String format, java.lang.String requestData, javax.servlet.http.HttpServletRequest createReportRequest, javax.servlet.http.HttpServletResponse createReportResponse)
Add the print job to the job queue.void
createReportAndGet(java.lang.String appId, java.lang.String format, java.lang.String requestData, boolean inline, javax.servlet.http.HttpServletRequest createReportRequest, javax.servlet.http.HttpServletResponse createReportResponse)
add the print job to the job queue.void
createReportAndGetNoAppId(java.lang.String format, java.lang.String requestData, boolean inline, javax.servlet.http.HttpServletRequest createReportRequest, javax.servlet.http.HttpServletResponse createReportResponse)
add the print job to the job queue.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.void
getCapabilities(java.lang.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.void
getExampleRequest(java.lang.String appId, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse getExampleResponse)
Get a sample request for the app.void
getExampleRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse getExampleResponse)
Get a sample request for the app.protected org.json.JSONObject
getHeaders(javax.servlet.http.HttpServletRequest httpServletRequest)
Read the headers from the request.void
getReport(java.lang.String applicationId, java.lang.String referenceId, boolean inline, javax.servlet.http.HttpServletResponse getReportResponse)
To get the PDF created previously.void
getReportPath(java.lang.String referenceId, boolean inline, javax.servlet.http.HttpServletResponse getReportResponse)
To get the PDF created previously.void
getReportSpecificAppId(java.lang.String appId, java.lang.String referenceId, boolean inline, javax.servlet.http.HttpServletResponse getReportResponse)
To get the PDF created previously.void
getStatus(java.lang.String applicationId, java.lang.String referenceId, javax.servlet.http.HttpServletRequest statusRequest, javax.servlet.http.HttpServletResponse statusResponse)
Get a status report on a job.void
getStatusPath(java.lang.String referenceId, javax.servlet.http.HttpServletRequest statusRequest, javax.servlet.http.HttpServletResponse statusResponse)
Get a status report on a job.void
getStatusSpecificAppId(java.lang.String appId, java.lang.String referenceId, javax.servlet.http.HttpServletRequest statusRequest, javax.servlet.http.HttpServletResponse statusResponse)
Get a status report on a job.void
listAppIds(javax.servlet.http.HttpServletResponse listAppsResponse)
To get (in JSON) the information about the available formats and CO.void
listAvailableFonts(javax.servlet.http.HttpServletResponse response)
List the available fonts on the system.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
cleanUpName, error, error, findReplacement, getBaseUrl, setCache, setCacheDuration, setNoCache
-
-
-
-
Field Detail
-
CAPABILITIES_URL
public static final java.lang.String CAPABILITIES_URL
The url path for capabilities requests.- See Also:
- Constant Field Values
-
LIST_APPS_URL
public static final java.lang.String LIST_APPS_URL
The url path to list all registered configurations.- See Also:
- Constant Field Values
-
EXAMPLE_REQUEST_URL
public static final java.lang.String EXAMPLE_REQUEST_URL
The url path to get a sample print request.- See Also:
- Constant Field Values
-
CREATE_AND_GET_URL
public static final java.lang.String CREATE_AND_GET_URL
The url path to create and get a report.- See Also:
- Constant Field Values
-
STATUS_URL
public static final java.lang.String STATUS_URL
The url path to get the status for a print task.- See Also:
- Constant Field Values
-
CANCEL_URL
public static final java.lang.String CANCEL_URL
The url path to cancel a print task.- See Also:
- Constant Field Values
-
REPORT_URL
public static final java.lang.String REPORT_URL
The url path to create a print task and to get a finished print.- See Also:
- Constant Field Values
-
FONTS_URL
public static final java.lang.String FONTS_URL
The url path to get the list of fonts available to geotools.- See Also:
- Constant Field Values
-
JSON_ERROR
public static final java.lang.String JSON_ERROR
The key containing an error message for failed jobs.- See Also:
- Constant Field Values
-
JSON_APP
public static final java.lang.String JSON_APP
The application ID which indicates the configuration file to load.- See Also:
- Constant Field Values
-
JSON_DONE
public static final java.lang.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:
- Constant Field Values
-
JSON_STATUS
public static final java.lang.String JSON_STATUS
The status of the job. One of the following values:- waiting
- running
- finished
- canceled
- error
getStatus(String, String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
response- See Also:
- Constant Field Values
-
JSON_ELAPSED_TIME
public static final java.lang.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:
- Constant Field Values
-
JSON_WAITING_TIME
public static final java.lang.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:
- Constant Field Values
-
JSON_PRINT_JOB_REF
public static final java.lang.String JSON_PRINT_JOB_REF
The key containing the print job reference ID in the create report response.- See Also:
- Constant Field Values
-
JSON_STATUS_LINK
public static final java.lang.String JSON_STATUS_LINK
The json key in the create report response containing a link to get the status of the print job.- See Also:
- Constant Field Values
-
JSON_DOWNLOAD_LINK
public static final java.lang.String JSON_DOWNLOAD_LINK
The json key in the create report and status responses containing a link to download the report.- See Also:
- Constant Field Values
-
JSON_OUTPUT_FORMAT
public static final java.lang.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:
- Constant Field Values
-
JSON_ATTRIBUTES
public static final java.lang.String JSON_ATTRIBUTES
The json tag referring to the attributes.- See Also:
- Constant Field Values
-
JSON_REQUEST_HEADERS
public static final java.lang.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:
- Constant Field Values
-
JSON_OUTPUT_JASPERREPORT_FONTS
public static final java.lang.String JSON_OUTPUT_JASPERREPORT_FONTS
The JSON key in the request spec that contains the Jasper report fonts.- See Also:
- Constant Field Values
-
JSON_OUTPUT_FONTS
public static final java.lang.String JSON_OUTPUT_FONTS
The JSON key in the request spec that contains the font config fonts.- See Also:
- Constant Field Values
-
JSON_OUTPUT_FONT_FAMILY
public static final java.lang.String JSON_OUTPUT_FONT_FAMILY
The JSON key in the request spec that contains the java font family name.- See Also:
- Constant Field Values
-
JSON_OUTPUT_FONTCONFIG
public static final java.lang.String JSON_OUTPUT_FONTCONFIG
The JSON key in the request spec that contains the font families names.- See Also:
- Constant Field Values
-
JSON_OUTPUT_FONTCONFIG_FAMILIES
public static final java.lang.String JSON_OUTPUT_FONTCONFIG_FAMILIES
The JSON key in the request spec that contains the font families names.- See Also:
- Constant Field Values
-
JSON_OUTPUT_FONTCONFIG_NAME
public static final java.lang.String JSON_OUTPUT_FONTCONFIG_NAME
The JSON key in the request spec that contains the font name.- See Also:
- Constant Field Values
-
JSON_OUTPUT_FONTCONFIG_STYLES
public static final java.lang.String JSON_OUTPUT_FONTCONFIG_STYLES
The JSON key in the request spec that contains the font styles.- See Also:
- Constant Field Values
-
JSON_OUTPUT_FONTCONFIG_WEIGHT
public static final java.lang.String JSON_OUTPUT_FONTCONFIG_WEIGHT
The JSON key in the request spec that contains the font weight.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MapPrinterServlet
@Autowired public MapPrinterServlet(JobManager jobManager, java.util.List<ReportLoader> reportLoaders, MapPrinterFactory printerFactory, org.springframework.context.ApplicationContext context, ServletInfo servletInfo, MapPrinterFactory mapPrinterFactory)
-
-
Method Detail
-
getStatusSpecificAppId
@RequestMapping(value="/{appId}/status/{referenceId:\\S+}.json", method=GET) public final void getStatusSpecificAppId(@Nonnull @PathVariable java.lang.String appId, @Nonnull @PathVariable java.lang.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 IDreferenceId
- the job referencestatusRequest
- the request objectstatusResponse
- the response object
-
getStatusPath
@RequestMapping(value="/status/{referenceId:\\S+}.json", method=GET) public final void getStatusPath(@Nonnull @PathVariable java.lang.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 referencestatusRequest
- the request objectstatusResponse
- the response object
-
getStatus
public final void getStatus(@Nonnull java.lang.String applicationId, @Nonnull java.lang.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:
applicationId
- the application IDreferenceId
- the job referencestatusRequest
- the request objectstatusResponse
- the response object
-
cancelSpecificAppId
@RequestMapping(value="/{appId}/cancel/{referenceId:\\S+}", method=DELETE) public final void cancelSpecificAppId(@Nonnull @PathVariable java.lang.String appId, @Nonnull @PathVariable java.lang.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 IDreferenceId
- the job referencestatusResponse
- the response object
-
cancelPath
@RequestMapping(value="/cancel/{referenceId:\\S+}", method=DELETE) public final void cancelPath(@Nonnull @PathVariable java.lang.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 referencestatusResponse
- the response object
-
cancel
public final void cancel(@Nonnull java.lang.String applicationId, @Nonnull java.lang.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:
applicationId
- the application IDreferenceId
- the job referencestatusResponse
- the response object
-
createReport
@RequestMapping(value="/{appId}/report.{format:\\w+}", method=POST) public final void createReport(@Nonnull @PathVariable java.lang.String appId, @PathVariable java.lang.String format, @RequestBody java.lang.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 reportrequestData
- a json formatted string with the request data required to perform the report generation.createReportRequest
- the request objectcreateReportResponse
- the response object- Throws:
NoSuchAppException
-
getReportSpecificAppId
@RequestMapping(value="/{appId}/report/{referenceId:\\S+}", method=GET) public final void getReportSpecificAppId(@Nonnull @PathVariable java.lang.String appId, @Nonnull @PathVariable java.lang.String referenceId, @RequestParam(value="inline",defaultValue="false") boolean inline, javax.servlet.http.HttpServletResponse getReportResponse) throws java.io.IOException, javax.servlet.ServletException
To get the PDF created previously.- Parameters:
appId
- the app IDreferenceId
- the path to the file.inline
- whether or not to inline thegetReportResponse
- the response object- Throws:
java.io.IOException
javax.servlet.ServletException
-
getReportPath
@RequestMapping(value="/report/{referenceId:\\S+}", method=GET) public final void getReportPath(@Nonnull @PathVariable java.lang.String referenceId, @RequestParam(value="inline",defaultValue="false") boolean inline, javax.servlet.http.HttpServletResponse getReportResponse) throws java.io.IOException, javax.servlet.ServletException
To get the PDF created previously.- Parameters:
referenceId
- the job referenceinline
- whether or not to inline thegetReportResponse
- the response object- Throws:
java.io.IOException
javax.servlet.ServletException
-
getReport
public final void getReport(@Nonnull java.lang.String applicationId, @Nonnull java.lang.String referenceId, boolean inline, javax.servlet.http.HttpServletResponse getReportResponse) throws java.io.IOException, javax.servlet.ServletException
To get the PDF created previously.- Parameters:
applicationId
- the application IDreferenceId
- the job referenceinline
- whether or not to inline thegetReportResponse
- the response object- Throws:
java.io.IOException
javax.servlet.ServletException
-
createReport
@RequestMapping(value="/report.{format:\\w+}", method=POST) public final void createReport(@PathVariable java.lang.String format, @RequestBody java.lang.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 reportrequestData
- a json formatted string with the request data required to perform the report generation.createReportRequest
- the request objectcreateReportResponse
- the response object- Throws:
NoSuchAppException
-
createReportAndGet
@RequestMapping(value="/{appId}/buildreport.{format:\\w+}", method=POST) public final void createReportAndGet(@Nonnull @PathVariable java.lang.String appId, @PathVariable java.lang.String format, @RequestBody java.lang.String requestData, @RequestParam(value="inline",defaultValue="false") boolean inline, javax.servlet.http.HttpServletRequest createReportRequest, javax.servlet.http.HttpServletResponse createReportResponse) throws java.io.IOException, javax.servlet.ServletException, java.lang.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 reportrequestData
- a json formatted string with the request data required to perform the report generation.inline
- whether or not to inline the contentcreateReportRequest
- the request objectcreateReportResponse
- the response object- Throws:
java.io.IOException
javax.servlet.ServletException
java.lang.InterruptedException
NoSuchAppException
-
createReportAndGetNoAppId
@RequestMapping(value="/buildreport.{format:\\w+}", method=POST) public final void createReportAndGetNoAppId(@PathVariable java.lang.String format, @RequestBody java.lang.String requestData, @RequestParam(value="inline",defaultValue="false") boolean inline, javax.servlet.http.HttpServletRequest createReportRequest, javax.servlet.http.HttpServletResponse createReportResponse) throws java.io.IOException, javax.servlet.ServletException, java.lang.InterruptedException, NoSuchAppException
add the print job to the job queue.- Parameters:
format
- the format of the returned reportrequestData
- a json formatted string with the request data required to perform the report generation.inline
- whether or not to inline the contentcreateReportRequest
- the request objectcreateReportResponse
- the response object- Throws:
java.io.IOException
javax.servlet.ServletException
java.lang.InterruptedException
NoSuchAppException
-
listAppIds
@RequestMapping(value="/apps.json", method=GET) public final void listAppIds(javax.servlet.http.HttpServletResponse listAppsResponse) throws javax.servlet.ServletException, java.io.IOException
To get (in JSON) the information about the available formats and CO.- Parameters:
listAppsResponse
- the response object- Throws:
javax.servlet.ServletException
java.io.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, java.io.IOException
To get (in JSON) the information about the available formats and CO.- Parameters:
pretty
- if true then pretty print the capabilitiesrequest
- the requestcapabilitiesResponse
- the response object- Throws:
javax.servlet.ServletException
java.io.IOException
-
getCapabilities
@RequestMapping(value="/{appId}/capabilities.json", method=GET) public final void getCapabilities(@Nonnull @PathVariable java.lang.String appId, @RequestParam(value="pretty",defaultValue="false") boolean pretty, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse capabilitiesResponse) throws javax.servlet.ServletException, java.io.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 capabilitiesrequest
- the requestcapabilitiesResponse
- the response object- Throws:
javax.servlet.ServletException
java.io.IOException
-
getExampleRequest
@RequestMapping(value="/exampleRequest.json", method=GET) public final void getExampleRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse getExampleResponse) throws java.io.IOException
Get a sample request for the app. An empty response may be returned if there is not example request.- Parameters:
request
- the request objectgetExampleResponse
- the response object- Throws:
java.io.IOException
-
getExampleRequest
@RequestMapping(value="{appId}/exampleRequest.json", method=GET) public final void getExampleRequest(@Nonnull @PathVariable java.lang.String appId, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse getExampleResponse) throws java.io.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 objectgetExampleResponse
- the response object- Throws:
java.io.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
-
-