updated export

This commit is contained in:
Francesco Mangiacrapa 2024-04-23 12:19:01 +02:00
parent 3fa182d803
commit f9f1f3bf1f
1 changed files with 8 additions and 4 deletions

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() + "\"")