if (requestHeaders.length() > 0) {
specJson.getInternalObj().getJSONObject(JSON_ATTRIBUTES).put(JSON_REQUEST_HEADERS, requestHeaders);
}
String ref = UUID.randomUUID().toString() + "@" + this.servletInfo.getServletId();
PrintJob job = this.context.getBean(PrintJob.class);
job.setReferenceId(ref);
job.setRequestData(specJson);
job.setSecurityContext(SecurityContextHolder.getContext());
// check that we have authorization and configure the job so it can only be access by users with sufficient authorization
final String templateName = specJson.getString(Constants.JSON_LAYOUT_KEY);
final MapPrinter mapPrinter = this.mapPrinterFactory.create(appId);
final Template template = mapPrinter.getConfiguration().getTemplate(templateName);
job.configureAccess(template);
try {
this.jobManager.submit(job);
} catch (RuntimeException exc) {
LOGGER.error("Error when creating job", exc);