updated GeoportalExporter
This commit is contained in:
parent
e382719f30
commit
f3ccc3b134
|
@ -57,7 +57,7 @@ public class HTML_Page {
|
||||||
+ " }\n"
|
+ " }\n"
|
||||||
+ " }\n"
|
+ " }\n"
|
||||||
+ " async function playPDFPoll() {\n"
|
+ " async function playPDFPoll() {\n"
|
||||||
+ " let response_object = await fetchPDF_URL();\n"
|
+ " const response_object = await fetchPDF_URL();\n"
|
||||||
+ " let isJsonResponse = isJsonString(response_object);\n"
|
+ " let isJsonResponse = isJsonString(response_object);\n"
|
||||||
+ " if (isJsonResponse) {\n"
|
+ " if (isJsonResponse) {\n"
|
||||||
+ " console.log(\"json response \" + response_object);\n"
|
+ " console.log(\"json response \" + response_object);\n"
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.gcube.datatransfer.resolver.services.error.ExceptionManager;
|
||||||
import org.gcube.datatransfer.resolver.services.exceptions.BadRequestException;
|
import org.gcube.datatransfer.resolver.services.exceptions.BadRequestException;
|
||||||
import org.gcube.datatransfer.resolver.util.SingleFileStreamingOutput;
|
import org.gcube.datatransfer.resolver.util.SingleFileStreamingOutput;
|
||||||
import org.gcube.datatransfer.resolver.util.Util;
|
import org.gcube.datatransfer.resolver.util.Util;
|
||||||
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -173,8 +174,8 @@ public class GeoportalExporter {
|
||||||
this.getClass(), helpURI);
|
this.getClass(), helpURI);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return Response.status(Status.NOT_FOUND)
|
return Response
|
||||||
.entity(GeoportalExporter.class.getSimpleName()
|
.status(Status.NOT_FOUND).entity(GeoportalExporter.class.getSimpleName()
|
||||||
+ "seems to be not configured in the context: " + context)
|
+ "seems to be not configured in the context: " + context)
|
||||||
.type(MediaType.TEXT_PLAIN).build();
|
.type(MediaType.TEXT_PLAIN).build();
|
||||||
}
|
}
|
||||||
|
@ -230,16 +231,19 @@ public class GeoportalExporter {
|
||||||
throws WebApplicationException {
|
throws WebApplicationException {
|
||||||
|
|
||||||
LOG.info(this.getClass().getSimpleName() + " viewPDF - GET starts...");
|
LOG.info(this.getClass().getSimpleName() + " viewPDF - GET starts...");
|
||||||
LOG.info("param " + PDF_CODE + ": {}", pdfCode);
|
LOG.info("viewPDF param " + PDF_CODE + ": {}", pdfCode);
|
||||||
|
|
||||||
FetchPDF fetchedPDF = map.get(pdfCode);
|
FetchPDF fetchedPDF = map.get(pdfCode);
|
||||||
LOG.info("FileReference at code {} is {}", pdfCode, fetchedPDF);
|
LOG.info("viewPDF FileReference at code {} is {}", pdfCode, fetchedPDF);
|
||||||
|
|
||||||
|
JSONObject theJson = new JSONObject();
|
||||||
|
theJson.put("state", Status.NOT_FOUND.toString());
|
||||||
|
theJson.put("url", "");
|
||||||
|
|
||||||
if (fetchedPDF == null) {
|
if (fetchedPDF == null) {
|
||||||
LOG.info("returning not found");
|
String json = theJson.toString();
|
||||||
return Response.status(Status.NOT_FOUND)
|
LOG.info("viewPDF returning not found: "+json);
|
||||||
.entity(HTML_Page.getErrorPage("Job not created", "No job found with id " + pdfCode))
|
return Response.status(Status.OK).entity(json).build();
|
||||||
.type(MediaType.TEXT_HTML).build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -263,9 +267,10 @@ public class GeoportalExporter {
|
||||||
map.put(pdfCode, null);
|
map.put(pdfCode, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonObject jsonObject = new JsonObject();
|
theJson.put("state", "OK");
|
||||||
jsonObject.addProperty("url", theURL);
|
theJson.put("url", theURL);
|
||||||
String json = jsonObject.toString();
|
String json = theJson.toString();
|
||||||
|
LOG.info("viewPDF returning OK: "+json);
|
||||||
return Response.ok(json).build();
|
return Response.ok(json).build();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
Loading…
Reference in New Issue