Displaying an Alert if an error occurs on adding a layer to Map (#24471)

This commit is contained in:
Francesco Mangiacrapa 2023-01-25 10:46:17 +01:00
parent 69e5216645
commit 5221d2a6b5
4 changed files with 49 additions and 43 deletions

View File

@ -23,6 +23,7 @@
@ -69,6 +70,7 @@
@ -115,6 +117,7 @@
@ -161,6 +164,7 @@
@ -207,6 +211,7 @@
@ -253,6 +258,7 @@
@ -275,9 +281,7 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="geoportal-data-common-2.0.1.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-common/geoportal-data-common">
<dependency-type>uses</dependency-type>
</dependent-module>
@ -348,6 +352,7 @@
@ -394,6 +399,7 @@
@ -440,6 +446,7 @@

View File

@ -101,9 +101,11 @@ public class LayersSectionViewer extends Composite {
BBOXDV bbox = layer.getBbox();
if(bbox!=null) {
try {
if(!GWT.isProdMode()) {
if (bbox != null) {
if (!GWT.isProdMode()) {
GWT.log("bbox: " + bbox);
// GWT.log("bbox keys: " + bbox.keySet());
// GWT.log("bbox values: " + bbox.values());
@ -116,7 +118,7 @@ public class LayersSectionViewer extends Composite {
BoundsMap bounds = new BoundsMap(bbox.getMinX(), bbox.getMinY(), bbox.getMaxX(), bbox.getMaxY(), "");
GWT.log("bounds: " + bounds);
mapView.addWMSLayer(mapServerHost, layerName, bounds);
}else {
} else {
Alert alert = new Alert();
alert.setType(AlertType.ERROR);
alert.setText("No BBOX found for this layer");
@ -124,6 +126,15 @@ public class LayersSectionViewer extends Composite {
layerPanel.add(alert);
}
} catch (Exception e) {
Alert alert = new Alert();
alert.setType(AlertType.ERROR);
alert.setHTML("Error on adding the layer to Map. Please check its WMS link: <br/>"+layer.getWMSLink());
alert.getElement().getStyle().setProperty("wordBreak", "break-all");
alert.setClose(false);
layerPanel.add(alert);
}
String htmlLinkId = mapView.getPanelMapElementId() + "-image-download";
@ -138,18 +149,6 @@ public class LayersSectionViewer extends Composite {
@Override
public void onClick(ClickEvent event) {
// DOWNLOAD only the layer by Geoserver
/*
* Map<String, String> mapLayerURLs =
* mapView.getLightOLSM().getLayerURLsProperty(); Collection<String> layerURLs =
* mapLayerURLs.values(); ArrayList<String> layers = new
* ArrayList<String>(layerURLs); exportPDF(layers.get(0)); String layerURL =
* mapLayerURLs.get(layerDV.getLayerName()); GWT.log("layerDV name is: " +
* layerDV.getLayerName()); if (layerURL != null) Window.open(layerURL,
* "_blank", null);
*/
downloadAttempt++;
if (downloadAttempt > 3) {
@ -160,7 +159,6 @@ public class LayersSectionViewer extends Composite {
// DOWNLOAD the OSM + layer by canvas
downloadMap(mapView.getLightOLM().getMap(), mapView.getPanelMapElementId(), htmlLinkId, filename,
mimeType);
// mapExport(mapView.getLightOLSM().getMap(), mapView.getPanelMapElementId());
}
});

View File

@ -577,6 +577,7 @@ public class Geoportal_JSON_Mapper {
projectView.addSectionView(sectionView);
}
LOG.debug("returning the projectView: " + projectView);
return projectView;
}

View File

@ -59,13 +59,13 @@ public class GeoportalViewer_Tests {
//private static String CONTEXT = "/pred4s/preprod/preVRE";
private static String CONTEXT = "/d4science.research-infrastructures.eu/D4OS/GNA";
private static String TOKEN = ""; //GNA
private static String TOKEN = "ae9c0e67-68ca-42de-899b-015a98e4619b-843339462"; //GNA
//private static String CONTEXT = "/gcube/devsec/devVRE";
//private static String TOKEN = ""; // devVRE
private static String PROFILE_ID = "profiledConcessioni";
private static String PROJECT_ID = "6388ea6ca1e60e66b7b584e0";
private static String PROJECT_ID = "63c6c0f1a1e60e66b7b588fe";
private static String USERNAME = "francesco.mangiacrapa";
@ -83,7 +83,7 @@ public class GeoportalViewer_Tests {
clientProjects = GeoportalClientCaller.projects();
}
// @Test
@Test
public void getProjectViewForID() {
try {