Added `geoportalexport_prj` header parameter, see #28580
This commit is contained in:
parent
1ec9e1a5bf
commit
edc4b82dfc
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -60,8 +60,14 @@
|
|||
|
||||
|
||||
|
||||
<wb-module deploy-name="uri-resolver-2.10.0">
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-module deploy-name="uri-resolver-2.10.1-SNAPSHOT">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -123,7 +129,10 @@
|
|||
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -185,7 +194,10 @@
|
|||
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -247,7 +259,10 @@
|
|||
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -309,7 +324,34 @@
|
|||
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||
|
||||
|
||||
<dependent-module archiveName="uri-resolver-manager-1.8.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/uri-resolver-manager/uri-resolver-manager">
|
||||
|
||||
<dependency-type>uses</dependency-type>
|
||||
|
||||
</dependent-module>
|
||||
|
||||
<dependent-module archiveName="geoportal-client-1.2.2.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-client/geoportal-client">
|
||||
|
||||
<dependency-type>uses</dependency-type>
|
||||
|
||||
</dependent-module>
|
||||
|
||||
<dependent-module archiveName="geoportal-common-1.1.1.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-common/geoportal-common">
|
||||
|
||||
<dependency-type>uses</dependency-type>
|
||||
|
||||
</dependent-module>
|
||||
|
||||
<dependent-module archiveName="concessioni-model-1.0.4.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/concessioni-model/concessioni-model">
|
||||
|
||||
<dependency-type>uses</dependency-type>
|
||||
|
||||
</dependent-module>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -371,7 +413,10 @@
|
|||
|
||||
|
||||
<property name="context-root" value="uri-resolver"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -433,7 +478,10 @@
|
|||
|
||||
|
||||
<property name="java-output-path" value="/uri-resolver/target/classes"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -495,7 +543,10 @@
|
|||
|
||||
|
||||
</wb-module>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
## [v2.10.1-SNAPSHOT]
|
||||
|
||||
- Geoportal Exporter: added static pages as freemarker templates
|
||||
- Bug fixing: `createLink` method in the GeoportalExport service [#28641]
|
||||
- Bug fixing: `createLink` method in the GeoportalExporter service [#28641]
|
||||
- Bug fixing: `export` method in the GeoportalExporter service [#28580]
|
||||
|
||||
## [v2.10.0]
|
||||
|
||||
|
|
|
|||
|
|
@ -9,46 +9,72 @@ import java.io.IOException;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Generates HTML messages for the Geoportal Exporter.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Jan 21, 2025
|
||||
*/
|
||||
public class GeoportalHTMLMessageGenerator {
|
||||
|
||||
private static final String ERROR_PAGE_FTL = "error_page.ftl";
|
||||
private static final String ERROR_PAGE_FTL = "error_page.ftl";
|
||||
private static final String GEOPORTAL_EXPORTER_WAITING_PAGE_FTL = "geoportal_exporter_waiting_page.ftl";
|
||||
private static final Configuration cfg = new Configuration(Configuration.VERSION_2_3_32);
|
||||
|
||||
static {
|
||||
cfg.setClassForTemplateLoading(GeoportalHTMLMessageGenerator.class, "./templates");
|
||||
cfg.setDefaultEncoding("UTF-8");
|
||||
}
|
||||
static {
|
||||
cfg.setClassForTemplateLoading(GeoportalHTMLMessageGenerator.class, "./templates");
|
||||
cfg.setDefaultEncoding("UTF-8");
|
||||
}
|
||||
|
||||
public static String entityHTMLMessage(String action, String message, boolean waiting, String viewPdfURL) {
|
||||
try {
|
||||
Template template = cfg.getTemplate(GEOPORTAL_EXPORTER_WAITING_PAGE_FTL);
|
||||
Map<String, Object> dataModel = new HashMap<>();
|
||||
dataModel.put("action", action);
|
||||
dataModel.put("message", message);
|
||||
dataModel.put("waiting", waiting);
|
||||
dataModel.put("viewPdfURL", viewPdfURL);
|
||||
/**
|
||||
* Entity HTML message.
|
||||
*
|
||||
* @param geoportalexport_prj the geoportalexport prj
|
||||
* @param action the action
|
||||
* @param message the message
|
||||
* @param waiting the waiting
|
||||
* @param viewPdfURL the view pdf URL
|
||||
* @return the string
|
||||
*/
|
||||
public static String entityHTMLMessage(String geoportalexport_prj, String action, String message, boolean waiting,
|
||||
String viewPdfURL) {
|
||||
try {
|
||||
Template template = cfg.getTemplate(GEOPORTAL_EXPORTER_WAITING_PAGE_FTL);
|
||||
Map<String, Object> dataModel = new HashMap<>();
|
||||
dataModel.put("geoportalexport_prj", geoportalexport_prj);
|
||||
dataModel.put("action", action);
|
||||
dataModel.put("message", message);
|
||||
dataModel.put("waiting", waiting);
|
||||
dataModel.put("viewPdfURL", viewPdfURL);
|
||||
|
||||
StringWriter writer = new StringWriter();
|
||||
template.process(dataModel, writer);
|
||||
return writer.toString();
|
||||
} catch (IOException | TemplateException e) {
|
||||
throw new RuntimeException("Error while generating HTML message", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getErrorPage(String action, String message) {
|
||||
try {
|
||||
Template template = cfg.getTemplate(ERROR_PAGE_FTL);
|
||||
Map<String, Object> dataModel = new HashMap<>();
|
||||
dataModel.put("action", action);
|
||||
dataModel.put("message", message);
|
||||
StringWriter writer = new StringWriter();
|
||||
template.process(dataModel, writer);
|
||||
return writer.toString();
|
||||
} catch (IOException | TemplateException e) {
|
||||
throw new RuntimeException("Error while generating HTML message", e);
|
||||
}
|
||||
}
|
||||
|
||||
StringWriter writer = new StringWriter();
|
||||
template.process(dataModel, writer);
|
||||
return writer.toString();
|
||||
} catch (IOException | TemplateException e) {
|
||||
throw new RuntimeException("Error while generating HTML error page", e);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Gets the error page.
|
||||
*
|
||||
* @param action the action
|
||||
* @param message the message
|
||||
* @return the error page
|
||||
*/
|
||||
public static String getErrorPage(String action, String message) {
|
||||
try {
|
||||
Template template = cfg.getTemplate(ERROR_PAGE_FTL);
|
||||
Map<String, Object> dataModel = new HashMap<>();
|
||||
dataModel.put("action", action);
|
||||
dataModel.put("message", message);
|
||||
|
||||
StringWriter writer = new StringWriter();
|
||||
template.process(dataModel, writer);
|
||||
return writer.toString();
|
||||
} catch (IOException | TemplateException e) {
|
||||
throw new RuntimeException("Error while generating HTML error page", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,18 +28,23 @@
|
|||
</style>
|
||||
<script type="text/javascript">
|
||||
async function fetchPDF_URL() {
|
||||
try {
|
||||
const response = await fetch('${viewPdfURL}', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
return response.json();
|
||||
} catch (error) {
|
||||
showError("Error when exporting PDF :-(");
|
||||
console.error("error: "+error);
|
||||
}
|
||||
try {
|
||||
const headers = {
|
||||
'Content-Type': 'application/json'
|
||||
};
|
||||
<#if geoportalexport_prj?has_content>
|
||||
headers['geoportalexport_prj'] = '${geoportalexport_prj}';
|
||||
</#if>
|
||||
|
||||
const response = await fetch('${viewPdfURL}', {
|
||||
method: 'GET',
|
||||
headers: headers
|
||||
});
|
||||
return response.json();
|
||||
} catch (error) {
|
||||
showError("Error when exporting PDF :-(");
|
||||
console.error("error: " + error);
|
||||
}
|
||||
}
|
||||
async function playPDFPoll() {
|
||||
const response_object = await fetchPDF_URL();
|
||||
|
|
|
|||
|
|
@ -52,6 +52,9 @@ import org.slf4j.LoggerFactory;
|
|||
@Path("geoportal")
|
||||
public class GeoportalExporter {
|
||||
|
||||
//This parameter is used for sticky session on load balancer, see #28580
|
||||
private static final String GEOPORTALEXPORT_PRJ = "geoportalexport_prj";
|
||||
|
||||
private static final String JOB_CODE = "jobCode";
|
||||
|
||||
public static final String EXPORT_TYPE = "type";
|
||||
|
|
@ -107,6 +110,10 @@ public class GeoportalExporter {
|
|||
checkPathParameterNotNull(req, EXPORT_TYPE, export_type);
|
||||
checkPathParameterNotNull(req, PATH_USECASE_ID, ucdID);
|
||||
checkPathParameterNotNull(req, PATH_PROJECT_ID, projectID);
|
||||
|
||||
|
||||
String geoportalexport_prj = (String) req.getHeader(GEOPORTALEXPORT_PRJ);
|
||||
LOG.info("geoportalexport_prj header: " + geoportalexport_prj);
|
||||
|
||||
boolean getAsURL = false;
|
||||
try {
|
||||
|
|
@ -189,7 +196,7 @@ public class GeoportalExporter {
|
|||
String serviceViewPDF_URL = String.format("%s/%s/view/%s", Util.getServerURL(req), "geoportal",
|
||||
jobCode);
|
||||
|
||||
String entity = GeoportalHTMLMessageGenerator.entityHTMLMessage("Exporting as PDF...",
|
||||
String entity = GeoportalHTMLMessageGenerator.entityHTMLMessage(geoportalexport_prj,"Exporting as PDF...",
|
||||
"The project with id: " + projectID, true, serviceViewPDF_URL);
|
||||
|
||||
LOG.info("returning waiting HTML page");
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ import resources.GetAllInfrastructureScopes;
|
|||
public class SE_Harvester_from_IS {
|
||||
|
||||
// GN CONFIGURATIONS
|
||||
public static String rootScope = "/d4science.research-infrastructures.eu";
|
||||
// static String rootScope = "/pred4s";
|
||||
// public static String rootScope = "/d4science.research-infrastructures.eu";
|
||||
static String rootScope = "/pred4s/preprod/preVRE";
|
||||
// static String rootScope = "/gcube";
|
||||
public static final String platformName = "geoserver";
|
||||
public static final String category = "Gis";
|
||||
|
|
|
|||
Loading…
Reference in New Issue