diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/GeoportalExporter.java b/src/main/java/org/gcube/datatransfer/resolver/services/GeoportalExporter.java index 737d58c..0ad14e7 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/GeoportalExporter.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/GeoportalExporter.java @@ -31,6 +31,7 @@ import org.gcube.datatransfer.resolver.geoportal.exporter.HTML_Page; import org.gcube.datatransfer.resolver.services.error.ExceptionManager; import org.gcube.datatransfer.resolver.services.exceptions.BadRequestException; import org.gcube.datatransfer.resolver.util.SingleFileStreamingOutput; +import org.gcube.datatransfer.resolver.util.Util; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -110,10 +111,11 @@ public class GeoportalExporter { if (userAgentName != null) { LOG.info("Serving request as User-Agent {}", userAgentName); final String pollingCode = ucdID + "_" + projectID + "_" + System.currentTimeMillis(); - String viewPdfURL = req.getServletPath() + "/view/" + pollingCode; + String serviceViewPDF_URL = String.format("%s/%s/view/%s", Util.getServerURL(req), + req.getContextPath(), pollingCode); String entity = HTML_Page.entityHTMLMessage("Exporting as PDF...", - "The project with id: " + projectID, true, viewPdfURL); + "The project with id: " + projectID, true, serviceViewPDF_URL); try { Thread t = new Thread() { @@ -123,7 +125,7 @@ public class GeoportalExporter { FileReference pdfRef = null; FetchPDF fetchPDF = new FetchPDF(pdfRef, pollingCode, 0); map.put(pollingCode, fetchPDF); - + pdfRef = exportAsPDF(req, ucdID, projectID, null, context, user); fetchPDF.setFileRef(pdfRef); map.put(pollingCode, fetchPDF); @@ -220,22 +222,36 @@ public class GeoportalExporter { try { - JsonObject jsonObject = new JsonObject(); FetchPDF fetchedPDF = map.get(pdfCode); - LOG.info("FileReference at code {} is {}", pdfCode, fetchedPDF.getFileRef()); - String theURL = null; - if (fetchedPDF.getFileRef()==null) { - fetchedPDF.incrementAttempt(); - if(fetchedPDF.getMAX_RETRY()