@Controller public class MapPrinterServlet extends BaseMapServlet
| Modifier and Type | Field and 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 create a print task and to get a finished print.
|
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_FORMAT
The JSON key in the request spec that contains the outputFormat.
|
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_SPEC
The json property name of the property that contains the request spec.
|
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 and Description |
|---|
MapPrinterServlet() |
| Modifier and Type | Method and Description |
|---|---|
void |
cancel(java.lang.String referenceId,
javax.servlet.http.HttpServletResponse statusResponse)
Cancel a job.
|
void |
cancelSpecificAppId(java.lang.String referenceId,
javax.servlet.http.HttpServletResponse statusResponse)
Cancel a job.
|
java.lang.String |
createAndSubmitPrintJob(java.lang.String appId,
java.lang.String format,
java.lang.String requestDataRaw,
javax.servlet.http.HttpServletRequest httpServletRequest,
javax.servlet.http.HttpServletResponse httpServletResponse)
Start a print job.
|
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 |
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 |
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,
java.lang.String jsonpCallback,
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,
java.lang.String jsonpCallback,
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 jsonpCallback,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse getExampleResponse)
Get a sample request for the app.
|
void |
getExampleRequest(java.lang.String appId,
java.lang.String jsonpCallback,
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 referenceId,
boolean inline,
javax.servlet.http.HttpServletResponse getReportResponse)
To get the PDF created previously.
|
void |
getReportSpecificAppId(java.lang.String referenceId,
boolean inline,
javax.servlet.http.HttpServletResponse getReportResponse)
To get the PDF created previously.
|
void |
getStatus(java.lang.String referenceId,
java.lang.String jsonpCallback,
javax.servlet.http.HttpServletRequest statusRequest,
javax.servlet.http.HttpServletResponse statusResponse)
Get a status report on a job.
|
void |
getStatusSpecificAppId(java.lang.String referenceId,
java.lang.String jsonpCallback,
javax.servlet.http.HttpServletRequest statusRequest,
javax.servlet.http.HttpServletResponse statusResponse)
Get a status report on a job.
|
void |
listAppIds(java.lang.String jsonpCallback,
javax.servlet.http.HttpServletResponse listAppsResponse)
To get (in JSON) the information about the available formats and CO.
|
java.lang.String |
listAvailableFonts()
List the available fonts on the system.
|
static PJsonObject |
parseJson(java.lang.String requestDataRaw,
javax.servlet.http.HttpServletResponse httpServletResponse)
Parse the print request json data.
|
protected void |
sendReportFile(PrintJobStatus metadata,
javax.servlet.http.HttpServletResponse httpServletResponse,
ReportLoader reportLoader,
java.net.URI reportURI,
boolean inline)
Copy the PDF into the output stream.
|
void |
setMaxCreateAndGetWaitTimeInSeconds(long maxCreateAndGetWaitTimeInSeconds)
Maximum time to wait for a createAndGet request to complete before returning an error.
|
cleanUpName, error, error, findReplacement, getBaseUrl, setCache, setCacheDuration, setNoCachepublic static final java.lang.String CAPABILITIES_URL
public static final java.lang.String LIST_APPS_URL
public static final java.lang.String EXAMPLE_REQUEST_URL
public static final java.lang.String CREATE_AND_GET_URL
public static final java.lang.String STATUS_URL
public static final java.lang.String CANCEL_URL
public static final java.lang.String REPORT_URL
public static final java.lang.String FONTS_URL
public static final java.lang.String JSON_ERROR
public static final java.lang.String JSON_APP
public static final java.lang.String JSON_SPEC
public static final java.lang.String JSON_DONE
getStatus(String, String, javax.servlet.http.HttpServletRequest,
javax.servlet.http.HttpServletResponse) response.public static final java.lang.String JSON_STATUS
getStatus(String, String, javax.servlet.http.HttpServletRequest,
javax.servlet.http.HttpServletResponse) responsepublic static final java.lang.String JSON_ELAPSED_TIME
getStatus(String, String, javax.servlet.http.HttpServletRequest,
javax.servlet.http.HttpServletResponse) response.public static final java.lang.String JSON_WAITING_TIME
getStatus(String, String, javax.servlet.http.HttpServletRequest,
javax.servlet.http.HttpServletResponse) response.public static final java.lang.String JSON_PRINT_JOB_REF
public static final java.lang.String JSON_STATUS_LINK
public static final java.lang.String JSON_DOWNLOAD_LINK
public static final java.lang.String JSON_OUTPUT_FORMAT
public static final java.lang.String JSON_ATTRIBUTES
public static final java.lang.String JSON_REQUEST_HEADERS
The request headers from the print request are needed by certain processors, the headers are added to the request JSON data for those processors.
public static PJsonObject parseJson(java.lang.String requestDataRaw, javax.servlet.http.HttpServletResponse httpServletResponse)
requestDataRaw - the request json in string formhttpServletResponse - the response object to use for returning errors if needed@RequestMapping(value="/{appId}/status/{referenceId:\\S+}.json",
method=GET)
public final void getStatusSpecificAppId(@PathVariable
java.lang.String referenceId,
@RequestParam(value="jsonp",defaultValue="")
java.lang.String jsonpCallback,
javax.servlet.http.HttpServletRequest statusRequest,
javax.servlet.http.HttpServletResponse statusResponse)
{"time":0,"count":0,"done":false}
referenceId - the job referencejsonpCallback - if given the result is returned with a function call wrapped around itstatusRequest - the request objectstatusResponse - the response object@RequestMapping(value="/status/{referenceId:\\S+}.json",
method=GET)
public final void getStatus(@PathVariable
java.lang.String referenceId,
@RequestParam(value="jsonp",defaultValue="")
java.lang.String jsonpCallback,
javax.servlet.http.HttpServletRequest statusRequest,
javax.servlet.http.HttpServletResponse statusResponse)
{"time":0,"count":0,"done":false}
referenceId - the job referencejsonpCallback - if given the result is returned with a function call wrapped around itstatusRequest - the request objectstatusResponse - the response object@RequestMapping(value="/{appId}/cancel/{referenceId:\\S+}",
method=DELETE)
public final void cancelSpecificAppId(@PathVariable
java.lang.String referenceId,
javax.servlet.http.HttpServletResponse statusResponse)
Even if a job was already finished, subsequent status requests will return that the job was canceled.
referenceId - the job referencestatusResponse - the response object@RequestMapping(value="/cancel/{referenceId:\\S+}",
method=DELETE)
public final void cancel(@PathVariable
java.lang.String referenceId,
javax.servlet.http.HttpServletResponse statusResponse)
Even if a job was already finished, subsequent status requests will return that the job was canceled.
referenceId - the job referencestatusResponse - the response object@RequestMapping(value="/{appId}/report.{format:\\w+}",
method=POST)
public final void createReport(@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 org.json.JSONException,
NoSuchAppException
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 objectorg.json.JSONExceptionNoSuchAppException@RequestMapping(value="/{appId}/report/{referenceId:\\S+}",
method=GET)
public final void getReportSpecificAppId(@PathVariable
java.lang.String referenceId,
@RequestParam(value="inline",defaultValue="false")
boolean inline,
javax.servlet.http.HttpServletResponse getReportResponse)
throws java.io.IOException,
javax.servlet.ServletException
referenceId - the path to the file.inline - whether or not to inline thegetReportResponse - the response objectjava.io.IOExceptionjavax.servlet.ServletException@RequestMapping(value="/report/{referenceId:\\S+}",
method=GET)
public final void getReport(@PathVariable
java.lang.String referenceId,
@RequestParam(value="inline",defaultValue="false")
boolean inline,
javax.servlet.http.HttpServletResponse getReportResponse)
throws java.io.IOException,
javax.servlet.ServletException
referenceId - the path to the file.inline - whether or not to inline thegetReportResponse - the response objectjava.io.IOExceptionjavax.servlet.ServletException@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 org.json.JSONException,
NoSuchAppException
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 objectorg.json.JSONExceptionNoSuchAppException@RequestMapping(value="/{appId}/buildreport.{format:\\w+}",
method=POST)
public final void createReportAndGet(@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,
org.json.JSONException,
NoSuchAppException
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 objectjava.io.IOExceptionjavax.servlet.ServletExceptionjava.lang.InterruptedExceptionorg.json.JSONExceptionNoSuchAppException@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,
org.json.JSONException,
NoSuchAppException
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 objectjava.io.IOExceptionjavax.servlet.ServletExceptionjava.lang.InterruptedExceptionorg.json.JSONExceptionNoSuchAppException@RequestMapping(value="/apps.json",
method=GET)
public final void listAppIds(@RequestParam(value="jsonp",defaultValue="")
java.lang.String jsonpCallback,
javax.servlet.http.HttpServletResponse listAppsResponse)
throws javax.servlet.ServletException,
java.io.IOException
jsonpCallback - if given the result is returned with a function call wrapped around itlistAppsResponse - the response objectjavax.servlet.ServletExceptionjava.io.IOException@RequestMapping(value="/capabilities.json",
method=GET)
public final void getCapabilities(@RequestParam(value="pretty",defaultValue="false")
boolean pretty,
@RequestParam(value="jsonp",defaultValue="")
java.lang.String jsonpCallback,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse capabilitiesResponse)
throws javax.servlet.ServletException,
java.io.IOException,
org.json.JSONException
pretty - if true then pretty print the capabilitiesjsonpCallback - if given the result is returned with a function call wrapped around itrequest - the requestcapabilitiesResponse - the response objectjavax.servlet.ServletExceptionjava.io.IOExceptionorg.json.JSONException@RequestMapping(value="/{appId}/capabilities.json",
method=GET)
public final void getCapabilities(@PathVariable
java.lang.String appId,
@RequestParam(value="pretty",defaultValue="false")
boolean pretty,
@RequestParam(value="jsonp",defaultValue="")
java.lang.String jsonpCallback,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse capabilitiesResponse)
throws javax.servlet.ServletException,
java.io.IOException,
org.json.JSONException
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 capabilitiesjsonpCallback - if given the result is returned with a function call wrapped around itrequest - the requestcapabilitiesResponse - the response objectjavax.servlet.ServletExceptionjava.io.IOExceptionorg.json.JSONException@RequestMapping(value="/exampleRequest.json",
method=GET)
public final void getExampleRequest(@RequestParam(value="jsonp",defaultValue="")
java.lang.String jsonpCallback,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse getExampleResponse)
throws javax.servlet.ServletException,
java.io.IOException
jsonpCallback - if given the result is returned with a function call wrapped around itrequest - the request objectgetExampleResponse - the response objectjavax.servlet.ServletExceptionjava.io.IOException@RequestMapping(value="{appId}/exampleRequest.json",
method=GET)
public final void getExampleRequest(@PathVariable
java.lang.String appId,
@RequestParam(value="jsonp",defaultValue="")
java.lang.String jsonpCallback,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse getExampleResponse)
throws java.io.IOException
appId - the id of the app to get the request for.jsonpCallback - if given the result is returned with a function call wrapped around itrequest - the request objectgetExampleResponse - the response objectjava.io.IOException@RequestMapping(value="/fonts") @ResponseBody public final java.lang.String listAvailableFonts()
public final void setMaxCreateAndGetWaitTimeInSeconds(long maxCreateAndGetWaitTimeInSeconds)
maxCreateAndGetWaitTimeInSeconds - the maximum time in seconds to wait for a report to be
generated.protected final void sendReportFile(PrintJobStatus metadata, javax.servlet.http.HttpServletResponse httpServletResponse, ReportLoader reportLoader, java.net.URI reportURI, boolean inline) throws java.io.IOException
metadata - the client request datahttpServletResponse - the response objectreportLoader - the object used for loading the reportreportURI - the uri of the reportinline - whether or not to inline the contentjava.io.IOExceptionprotected final org.json.JSONObject getHeaders(javax.servlet.http.HttpServletRequest httpServletRequest)
throws org.json.JSONException
httpServletRequest - the request objectorg.json.JSONExceptionpublic final java.lang.String createAndSubmitPrintJob(java.lang.String appId,
java.lang.String format,
java.lang.String requestDataRaw,
javax.servlet.http.HttpServletRequest httpServletRequest,
javax.servlet.http.HttpServletResponse httpServletResponse)
throws org.json.JSONException,
NoSuchAppException
appId - the id of the printer appformat - the format of the returned report.requestDataRaw - the request json in string formhttpServletRequest - the request objecthttpServletResponse - the response objectorg.json.JSONExceptionNoSuchAppException