export_to_pdf #8

Merged
francesco.mangiacrapa merged 84 commits from export_to_pdf into master 2024-06-28 15:17:39 +02:00
1 changed files with 8 additions and 4 deletions
Showing only changes of commit f9f1f3bf1f - Show all commits

View File

@ -147,11 +147,14 @@ public class GeoportalExporter {
try {
LOG.info("Serving request as getAsURL...");
FileReference pdfRef = exportAsPDF(req, ucdID, projectID, null, context, user);
return Response.ok(pdfRef.getStorageVolatileURL().toURI()).build();
} catch (URISyntaxException e) {
String theURL = pdfRef.getStorageVolatileURL().toString();
LOG.info("returning URL {}", theURL);
return Response.ok(theURL).build();
} catch (Exception e) {
LOG.error("Error on performing export by url", e);
throw ExceptionManager.internalErrorException(req,
"Sorry, error occurred when generating the project URL", this.getClass(), helpURI);
"Sorry, error occurred when generating the project URL. Error is: " + e.getMessage(),
this.getClass(), helpURI);
}
}
@ -185,6 +188,7 @@ public class GeoportalExporter {
String entity = HTML_Page.entityHTMLMessage("Exporting as PDF...",
"The project with id: " + projectID, true, serviceViewPDF_URL);
LOG.info("returning waiting HTML page");
return Response.ok(entity).encoding("UTF-8").header(ConstantsResolver.CONTENT_TYPE, "text/html")
.build();
} else {
@ -193,7 +197,7 @@ public class GeoportalExporter {
// returning as stream
InputStream input = pdfRef.getStorageVolatileURL().openStream();
StreamingOutput so = new SingleFileStreamingOutput(input);
LOG.info("returning project streaming...");
return Response.ok(so)
.header(ConstantsResolver.CONTENT_DISPOSITION,
"inline; filename=\"" + pdfRef.getFileName() + "\"")