Compare commits

...

25 Commits

Author SHA1 Message Date
Francesco Mangiacrapa 8bcda493da commented modal on Export facility 2024-05-08 12:10:32 +02:00
Francesco Mangiacrapa 3e568b58b4 Managed USERNAME parameter to perform the request to exporter service on
behalf of the user.
2024-05-07 12:45:29 +02:00
Francesco Mangiacrapa 3aa7f6462f updated form submit 2024-05-06 14:41:58 +02:00
Francesco Mangiacrapa 9ec3696203 no putting user header in Production mode 2024-05-06 12:31:13 +02:00
Francesco Mangiacrapa 13c271ca37 updated logs 2024-05-06 12:03:41 +02:00
Francesco Mangiacrapa 7c1f0ad829 updated Export facility 2024-05-06 11:41:28 +02:00
Francesco Mangiacrapa 0224f787c1 Moved to doPost method 2024-05-03 17:03:26 +02:00
Francesco Mangiacrapa ee4524139e Passed to the new KC-client [#27398] 2024-05-03 15:43:10 +02:00
Francesco Mangiacrapa 7d3e9544f5 added log 2024-05-03 11:45:18 +02:00
Francesco Mangiacrapa 269592914f added setVisible to Export button 2024-05-03 11:41:34 +02:00
Francesco Mangiacrapa aa8a9c931f updated parameters 2024-04-30 11:45:16 +02:00
Francesco Mangiacrapa 473d93ea7b removed unused classes. Refactored class 2024-04-30 11:09:39 +02:00
Francesco Mangiacrapa 48111e6525 updated maven-portal-bom at 3.8.0-SNAPSHOT 2024-04-29 17:15:23 +02:00
Francesco Mangiacrapa 63f168dcf9 updated content-type 2024-04-29 16:53:42 +02:00
Francesco Mangiacrapa 528c82cae5 setting USER_ID_ATTR_NAME 2024-04-29 16:43:34 +02:00
Francesco Mangiacrapa 7d4e363c9f trying to set CONTEXT_ID_PARAMETER 2024-04-29 16:18:25 +02:00
Francesco Mangiacrapa 2fae3ee31a updated code 2024-04-29 15:11:57 +02:00
Francesco Mangiacrapa c2a930b112 Added GCubeClientContext in gwt.xml and used before call the
GeoportalExporterAction Servlet
2024-04-29 15:02:34 +02:00
Francesco Mangiacrapa 50fac5143d removed unused code 2024-04-29 14:30:01 +02:00
Francesco Mangiacrapa 1f5db2eb16 added log 2024-04-24 15:20:36 +02:00
Francesco Mangiacrapa 9e49f6f281 integrated the GeoportalExporterActionServlet 2024-04-24 14:46:34 +02:00
Francesco Mangiacrapa b8be15921e Updated label 2023-11-27 10:59:02 +01:00
Francesco Mangiacrapa b266279a9f Updated buttons order 2023-11-22 16:20:19 +01:00
Francesco Mangiacrapa 9713bfb0a8 fixing contentType in the response 2023-11-22 16:18:14 +01:00
Francesco Mangiacrapa 90192d2085 Integrated the "Export as PDF" facility [#26026] 2023-11-22 16:09:03 +01:00
38 changed files with 1050 additions and 192 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/geoportal-data-viewer-app-3.6.0/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/geoportal-data-viewer-app-3.7.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
@ -30,5 +30,10 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/geoportal-data-viewer-app-3.6.0/WEB-INF/classes"/>
<classpathentry excluding="**" kind="src" output="target/geoportal-data-viewer-app-3.7.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/geoportal-data-viewer-app-3.7.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

View File

@ -1,4 +1,4 @@
eclipse.preferences.version=1
lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-3.6.0
lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-3.7.0-SNAPSHOT
warSrcDir=src/main/webapp
warSrcDirIsOutput=false

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
@ -99,8 +99,74 @@
<wb-module deploy-name="geoportal-data-viewer-app-3.6.0">
<wb-module deploy-name="geoportal-data-viewer-app-3.7.0-SNAPSHOT">
@ -201,7 +267,40 @@
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
@ -302,7 +401,40 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
@ -403,7 +535,40 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
@ -504,7 +669,60 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
@ -605,7 +823,40 @@
<property name="java-output-path" value="/geoportal-data-viewer-app/target/geoportal-data-viewer-app-0.0.1-SNAPSHOT/WEB-INF/classes"/>
@ -706,7 +957,40 @@
<property name="context-root" value="geoportal-data-viewer-app"/>
@ -807,7 +1091,40 @@
</wb-module>

View File

@ -4,6 +4,12 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v3.7.0-SNAPSHOT]
- Provided the "Export as PDF" facility [#26026]
- Integrated the GeoportalExporter as service [#27321]
- Passed to the new KC-client [#27398]
## [v3.6.0]
- GUI optimization [#25461]

11
pom.xml
View File

@ -14,7 +14,7 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>geoportal-data-viewer-app</artifactId>
<packaging>war</packaging>
<version>3.6.0</version>
<version>3.7.0-SNAPSHOT</version>
<name>GeoPortal Data Viewer App</name>
<description>The GeoPortal Data Viewer App is an application to access, discovery and navigate the Geoportal projects/documents by a Web-Map Interface</description>
@ -56,7 +56,7 @@
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId>
<version>3.7.0</version>
<version>3.8.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@ -175,8 +175,13 @@
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>keycloak-client</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<version>[2.0.0, 3.0.0-SNAPSHOT)</version>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.gcube.common</groupId> -->
<!-- <artifactId>authorization-utils</artifactId> -->
<!-- <version>[2.0.0, 3.0.0-SNAPSHOT)</version> -->
<!-- </dependency> -->
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-service</artifactId>

View File

@ -17,11 +17,17 @@
<inherits name="com.google.gwt.json.JSON" />
<inherits
name='org.gcube.portal.clientcontext.GCubeClientContext' />
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits -->
<servlet path="/geoportalexporterservice"
class="org.gcube.portlets.user.geoportaldataviewer.server.GeoportalExporterActionServlet" />
<!-- Specify the app entry point class. -->
<entry-point
class='org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewer' />

View File

@ -64,7 +64,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerMap;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerMap.CQL_FACILITY_ORIGIN;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAImages;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GeoportalImages;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.GeonaDataViewMainPanel;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project.relation.TimelineManagerStatus;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.OLGeoJSONUtil;
@ -150,7 +150,7 @@ public class GeoportalDataViewer implements EntryPoint {
int attempt = 0;
private LoaderIcon loaderApp = new LoaderIcon("Loading application... please wait",
new com.google.gwt.user.client.ui.Image(GNAImages.ICONS.spinnerEarth()));
new com.google.gwt.user.client.ui.Image(GeoportalImages.ICONS.spinnerEarth()));
private HTML attributionDiv = new HTML();
@ -543,7 +543,7 @@ public class GeoportalDataViewer implements EntryPoint {
Modal errorModal = new Modal(true, true);
errorModal.setCloseVisible(true);
errorModal.setTitle("Oops...");
Image geoportalError = new Image(GNAImages.ICONS.warningError());
Image geoportalError = new Image(GeoportalImages.ICONS.warningError());
FlowPanel errorPanelMsg = new FlowPanel();
errorPanelMsg.getElement().addClassName("general_warning");
errorPanelMsg.add(geoportalError);
@ -1072,7 +1072,7 @@ public class GeoportalDataViewer implements EntryPoint {
* @return the general error panel
*/
private FlowPanel getGeneralErrorPanel() {
Image geoportalError = new Image(GNAImages.ICONS.geoportaServiceError());
Image geoportalError = new Image(GeoportalImages.ICONS.geoportaServiceError());
FlowPanel errorPanelMsg = new FlowPanel();
errorPanelMsg.getElement().addClassName("general_error");
errorPanelMsg.add(geoportalError);

View File

@ -3,6 +3,7 @@ package org.gcube.portlets.user.geoportaldataviewer.client;
import org.gcube.application.geoportalcommon.ConvertToDataViewModel;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayersMapParameters;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.i18n.client.DateTimeFormat;
@ -14,7 +15,16 @@ import com.google.gwt.i18n.client.DateTimeFormat;
* Nov 24, 2020
*/
public class GeoportalDataViewerConstants {
//Geoportal_Exporter_ACTION_SERVLET
public static final String UCD_ID_PARAMETER = "ucdID";
public static final String PROIECT_ID_PARAMETER = "projectID";
public static final String CONTEXT_ID_PARAMETER = "c_id";
public static final String USER_ID_PARAMETER = "u_id";
public static final String USERNAME_PARAMETER = "usn";
public static final String GEOPORTAL_EXPORT_ACTION_SERVLET = GWT.getModuleBaseURL()
+ "geoportalexporterservice";
public static final int TABLET_WIDTH = 1601;
public static final String MAP_DIV = "map";
@ -40,12 +50,9 @@ public class GeoportalDataViewerConstants {
public static final String PROJECT_ID_KEY_FEATURE = "projectid";
public static enum GisToolbarFacilities {
COLLECTION("Collection", "Open the collections"),
MAP("Map", "Select the base Map"),
OVERLAY("Overlay", "Add overlay layers"),
SEARCH("Search", "Search in the collections"),
FILTER("Filter", "Apply spatial filtering"),
LAYERS("Layers", "Layers added to Map"),
COLLECTION("Collection", "Open the collections"), MAP("Map", "Select the base Map"),
OVERLAY("Overlay", "Add overlay layers"), SEARCH("Search", "Search in the collections"),
FILTER("Filter", "Apply spatial filtering"), LAYERS("Layers", "Layers added to Map"),
PRESET_LOCATION("Preset Location", "Center the Map to Location");
String name;

View File

@ -14,7 +14,7 @@ import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GC
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA_HANDLER;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoportalSpatialQueryResult;
import org.gcube.portlets.user.geoportaldataviewer.shared.ItemFieldsResponse;
import org.gcube.portlets.user.geoportaldataviewer.shared.ResultSetPaginatedDataIDs;
import org.gcube.portlets.user.geoportaldataviewer.shared.ViewerConfiguration;
@ -57,8 +57,8 @@ public interface GeoportalDataViewerService extends RemoteService {
* @return the data result
* @throws Exception the exception
*/
List<GeoNaSpatialQueryResult> getDataResult(List<LayerObject> layerObjects, String mapSrsName, BoundsMap mapBBOX,
int maxWFSFeature, double zoomLevel) throws Exception;
List<GeoportalSpatialQueryResult> getDataResult(List<LayerObject> layerObjects, String mapSrsName,
BoundsMap mapBBOX, int maxWFSFeature, double zoomLevel) throws Exception;
/**
* Gets the my login.
@ -104,7 +104,7 @@ public interface GeoportalDataViewerService extends RemoteService {
* @param zoomLevel the zoom level
* @return the WFS features
*/
List<GeoNaSpatialQueryResult> getWFSFeatures(List<LayerObject> layerObjects, String mapSrsName,
List<GeoportalSpatialQueryResult> getWFSFeatures(List<LayerObject> layerObjects, String mapSrsName,
BoundsMap selectBBOX, int maxWFSFeature, double zoomLevel);
/**
@ -229,4 +229,6 @@ public interface GeoportalDataViewerService extends RemoteService {
Integer getCountFor(String profileID, String phase, String status);
Boolean checkExportAsPDFConfig();
}

View File

@ -14,7 +14,7 @@ import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GC
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA_HANDLER;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoportalSpatialQueryResult;
import org.gcube.portlets.user.geoportaldataviewer.shared.ItemFieldsResponse;
import org.gcube.portlets.user.geoportaldataviewer.shared.ResultSetPaginatedDataIDs;
import org.gcube.portlets.user.geoportaldataviewer.shared.ViewerConfiguration;
@ -48,7 +48,7 @@ public interface GeoportalDataViewerServiceAsync {
void parseWmsRequest(String wmsRequest, String layerName, AsyncCallback<GeoInformationForWMSRequest> callback);
void getDataResult(List<LayerObject> layerObjects, String mapSrsName, BoundsMap mapBBOX, int maxWFSFeature,
double zoomLevel, AsyncCallback<List<GeoNaSpatialQueryResult>> callback);
double zoomLevel, AsyncCallback<List<GeoportalSpatialQueryResult>> callback);
void getMyLogin(AsyncCallback<String> callback);
@ -60,7 +60,7 @@ public interface GeoportalDataViewerServiceAsync {
AsyncCallback<List<GCubeSDIViewerLayerDV>> asyncCallback);
void getWFSFeatures(List<LayerObject> layerObjects, String mapSrsName, BoundsMap selectBBOX, int maxWFSFeature,
double zoomLevel, AsyncCallback<List<GeoNaSpatialQueryResult>> callback);
double zoomLevel, AsyncCallback<List<GeoportalSpatialQueryResult>> callback);
void getListBaseLayers(AsyncCallback<List<BaseMapLayer>> callback);
@ -93,4 +93,6 @@ public interface GeoportalDataViewerServiceAsync {
void getCountFor(String profileID, String phase, String status, AsyncCallback<Integer> callback);
void checkExportAsPDFConfig(AsyncCallback<Boolean> callback);
}

View File

@ -40,7 +40,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.ui.ModalWindow;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project.ProjectUtil;
import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil;
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoportalSpatialQueryResult;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
@ -190,7 +190,7 @@ public class LayerManager {
GeoportalDataViewerServiceAsync.Util.getInstance().getDataResult(listLO, olMap.getProjectionCode(),
mapBBOX, GeoportalDataViewerConstants.MAX_WFS_FEATURES, olMap.getCurrentZoomLevel(),
new AsyncCallback<List<GeoNaSpatialQueryResult>>() {
new AsyncCallback<List<GeoportalSpatialQueryResult>>() {
@Override
public void onFailure(Throwable caught) {
@ -199,7 +199,7 @@ public class LayerManager {
}
@Override
public void onSuccess(List<GeoNaSpatialQueryResult> listGeonaDataObjects) {
public void onSuccess(List<GeoportalSpatialQueryResult> listGeonaDataObjects) {
if (listGeonaDataObjects == null)
return;
@ -221,7 +221,7 @@ public class LayerManager {
List<FeatureRow> theFeatures = null;
// TODO SWTCH FOR EARCH ITEM TYPE
for (final GeoNaSpatialQueryResult geoNaDataObject : listGeonaDataObjects) {
for (final GeoportalSpatialQueryResult geoNaDataObject : listGeonaDataObjects) {
GWT.log("GeoNaDataObject: " + geoNaDataObject);
List<FeatureRow> features = geoNaDataObject.getFeatures();
LayerItem layerItem = geoNaDataObject.getSourceLayerObject().getLayerItem();
@ -709,7 +709,7 @@ public class LayerManager {
* @param listGeoNaDataObject the list geo na data object
* @param queryClick the query click
*/
public void showPopupInfoForLayer(List<GeoNaSpatialQueryResult> listGeoNaDataObject, ExtentWrapped queryClick) {
public void showPopupInfoForLayer(List<GeoportalSpatialQueryResult> listGeoNaDataObject, ExtentWrapped queryClick) {
GWT.log("showPopupInfoForLayer called for " + listGeoNaDataObject);
ScrollPanel scrollPanel = new ScrollPanel();
@ -767,7 +767,7 @@ public class LayerManager {
// }
String prevProjectId = "";
for (GeoNaSpatialQueryResult geoNaSpatialQueryResult : listGeoNaDataObject) {
for (GeoportalSpatialQueryResult geoNaSpatialQueryResult : listGeoNaDataObject) {
try {
Set<String> indexLayers = mapIndexLayerObjects.keySet();
@ -1123,7 +1123,7 @@ public class LayerManager {
* @param feature the feature
* @param onFailureCenterTo the on failure center to
*/
public void showPopupInfoForCentroidLayer(GeoNaSpatialQueryResult geoNaDataObject, FeatureRow feature,
public void showPopupInfoForCentroidLayer(GeoportalSpatialQueryResult geoNaDataObject, FeatureRow feature,
Coordinate onFailureCenterTo) {
GWT.log("showPopupInfoForCentroidLayer showing feature: " + feature);
GWT.log("showPopupInfoForCentroidLayer showing layerObject: " + geoNaDataObject.getSourceLayerObject());

View File

@ -8,7 +8,7 @@ import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewer;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAImages;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GeoportalImages;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery.TYPE;
@ -87,7 +87,7 @@ public class LightOpenLayerMap {
private ol.layer.Vector geometryLayer;
private String markerURL = GNAImages.ICONS.mapMarkerIcon().getURL();
private String markerURL = GeoportalImages.ICONS.mapMarkerIcon().getURL();
private LayerOrder layerOrder = new LayerOrder();

View File

@ -4,7 +4,7 @@ import com.github.gwtbootstrap.client.ui.constants.BaseIconType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ClientBundle;
public interface GNAIcons extends ClientBundle {
public interface GeoportalIcons extends ClientBundle {
/** My custom base icon collection */
public enum CustomIconType implements BaseIconType {
@ -15,7 +15,7 @@ public interface GNAIcons extends ClientBundle {
/** Inject the icon's css once at first usage */
static {
GNAImages icons = GWT.create(GNAImages.class);
GeoportalImages icons = GWT.create(GeoportalImages.class);
icons.css().ensureInjected();
}

View File

@ -5,13 +5,13 @@ import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.CssResource;
import com.google.gwt.resources.client.ImageResource;
public interface GNAImages extends ClientBundle {
public interface GeoportalImages extends ClientBundle {
/** Get access to the css resource during gwt compilation */
@Source("baseIcons.css")
CssResource css();
public static final GNAImages ICONS = GWT.create(GNAImages.class);
public static final GeoportalImages ICONS = GWT.create(GeoportalImages.class);
/**
* Our sample image icon. Makes the image resource for the gwt-compiler's css

View File

@ -22,8 +22,8 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.ChangeMapLayerE
import org.gcube.portlets.user.geoportaldataviewer.client.events.MapExtentToEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.collections.OpenCollectionEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerMap;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAIcons;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAImages;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GeoportalIcons;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GeoportalImages;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.search.SearchFacilityUI;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.crossfiltering.CrossFilteringLayerPanel;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.customoverlays.OverlayCustomLayerPanel;
@ -193,19 +193,19 @@ public class GeonaDataViewMainPanel extends Composite {
dataBoxSelection.setIcon(IconType.BOOKMARK);
removeQuery.setIcon(IconType.REMOVE);
Image italyImg = new Image(GNAImages.ICONS.italyIcon());
Image italyImg = new Image(GeoportalImages.ICONS.italyIcon());
italyImg.getElement().getStyle().setPaddingLeft(20, Unit.PX);
extentToItaly.getElement().appendChild(italyImg.getElement());
extentToItaly.setWidth("140px");
Image worldImg = new Image(GNAImages.ICONS.worldIcon());
Image worldImg = new Image(GeoportalImages.ICONS.worldIcon());
worldImg.getElement().getStyle().setPaddingLeft(20, Unit.PX);
extentToEarth.getElement().appendChild(worldImg.getElement());
extentToEarth.setWidth("140px");
// linkMap.setCustomIconStyle(GNAIcons.CustomIconType.MAP.get());
linkPresetLocation.setCustomIconStyle(GNAIcons.CustomIconType.PRESET_LOCATION.get());
linkLayers.setCustomIconStyle(GNAIcons.CustomIconType.LAYERS.get());
// linkMap.setCustomIconStyle(GeoportalIcons.CustomIconType.MAP.get());
linkPresetLocation.setCustomIconStyle(GeoportalIcons.CustomIconType.PRESET_LOCATION.get());
linkLayers.setCustomIconStyle(GeoportalIcons.CustomIconType.LAYERS.get());
openCollectionDropDown.setIcon(IconType.COMPASS);

View File

@ -4,9 +4,11 @@ import java.util.List;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
import org.gcube.application.geoportalcommon.shared.geoportal.project.RelationshipDV;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.application.geoportalcommon.shared.geoportal.view.SectionView;
import org.gcube.portal.clientcontext.client.GCubeClientContext;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
@ -22,9 +24,11 @@ import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.P
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.MapView;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.Modal;
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.FormElement;
import com.google.gwt.dom.client.UListElement;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
@ -35,8 +39,17 @@ import com.google.gwt.user.client.Random;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.FormPanel;
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent;
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteHandler;
import com.google.gwt.user.client.ui.FormPanel.SubmitEvent;
import com.google.gwt.user.client.ui.FormPanel.SubmitHandler;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Hidden;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import ol.Coordinate;
@ -83,6 +96,9 @@ public class ProjectViewer extends Composite {
@UiField
Button expandButton;
@UiField
Button exportButton;
@UiField
Button relationshipsButton;
@ -136,6 +152,22 @@ public class ProjectViewer extends Composite {
this.geoportalItemReferences = geoportalItemRefs;
this.applicationBus = applicationBus;
GeoportalDataViewerServiceAsync.Util.getInstance().checkExportAsPDFConfig(new AsyncCallback<Boolean>() {
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
}
@Override
public void onSuccess(Boolean result) {
GWT.log("Export as PDF visible: " + result);
exportButton.setVisible(result);
}
});
final String theTitle = projectView.getTheProjectDV().getProfileName() != null
? projectView.getTheProjectDV().getProfileName()
: "Project ID: " + projectView.getTheProjectDV().getId();
@ -183,6 +215,79 @@ public class ProjectViewer extends Composite {
}
});
exportButton.setType(ButtonType.LINK);
exportButton.setIcon(IconType.FILE);
exportButton.setTitle("Export as PDF");
exportButton.setVisible(false);
exportButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
String theProjectName = "";
try {
theProjectName = (String) projectView.getTheProjectDV().getTheDocument().getFirstEntryOfMap()
.getValue();
theProjectName = theProjectName != null ? theProjectName
: "Project ID: " + projectView.getTheProjectDV().getId();
} catch (Exception e) {
// TODO: handle exception
}
// Reading contextId and userId from GCubeClientContext
String currentContextId = GCubeClientContext.getCurrentContextId();
String currentUserId = GCubeClientContext.getCurrentUserId();
ProjectDV thePDV = projectView.getTheProjectDV();
final String targetWindow = "target_window_" + Random.nextInt() + "_" + Random.nextInt();
final FormPanel form = new FormPanel();
final FormElement fe = form.getElement().cast();
//NewBrowserWindow theNewTabWindow = NewBrowserWindow.open("", "", null);
RootPanel.get().add(form);
VerticalPanel panel = new VerticalPanel();
form.setWidget(panel);
form.setAction(GeoportalDataViewerConstants.GEOPORTAL_EXPORT_ACTION_SERVLET);
form.setEncoding(FormPanel.ENCODING_URLENCODED);
form.setMethod(FormPanel.METHOD_POST);
panel.add(new Hidden(GeoportalDataViewerConstants.UCD_ID_PARAMETER, thePDV.getProfileID()));
panel.add(new Hidden(GeoportalDataViewerConstants.PROIECT_ID_PARAMETER, thePDV.getId()));
panel.add(new Hidden(GeoportalDataViewerConstants.CONTEXT_ID_PARAMETER, currentContextId));
panel.add(new Hidden(GeoportalDataViewerConstants.USER_ID_PARAMETER, currentUserId));
if(myLogin!=null) {
panel.add(new Hidden(GeoportalDataViewerConstants.USERNAME_PARAMETER, myLogin));
}
// final Modal contactinServiceModal = new Modal(true, true);
// contactinServiceModal.setCloseVisible(false);
// contactinServiceModal.setTitle("Export");
// FlowPanel panelMsg = new FlowPanel();
// panelMsg.add(new HTML("Contacting the service..."));
// contactinServiceModal.add(panelMsg);
// contactinServiceModal.show();
// Add an event handler to the form.
form.addSubmitHandler(new SubmitHandler() {
public void onSubmit(SubmitEvent event) {
GWT.log("onSubmit done");
fe.setTarget(targetWindow);
}
});
form.addSubmitCompleteHandler(new SubmitCompleteHandler() {
public void onSubmitComplete(SubmitCompleteEvent event) {
GWT.log("onSubmitComplete done");
//contactinServiceModal.hide();
}
});
form.submit();
}
});
relationshipsButton.setType(ButtonType.LINK);
relationshipsButton.setIcon(IconType.LINK);
relationshipsButton.setTitle("Show Relationships of this Project");
@ -240,14 +345,6 @@ public class ProjectViewer extends Composite {
public void onClick(ClickEvent event) {
boolean visible = toc_list_container.isVisible();
setTocContentVisible(!visible);
// if (visible) {
// toc_list_container.setVisible(false);
// reduceToc.setIcon(IconType.PLUS_SIGN_ALT);
// } else {
// toc_list_container.setVisible(true);
// reduceToc.setIcon(IconType.MINUS_SIGN_ALT);
// }
}
});

View File

@ -44,9 +44,10 @@
<g:HorizontalPanel
addStyleNames="functionalities-style">
<b:Button ui:field="shareButton">Share</b:Button>
<b:Button ui:field="exportButton">Export</b:Button>
<b:Button ui:field="expandButton">Expand</b:Button>
<b:Button ui:field="relationshipsButton">Relationships</b:Button>
<b:Button ui:field="addLayersToMap">Add Layers to Map</b:Button>
<b:Button ui:field="addLayersToMap">Add Layers</b:Button>
</g:HorizontalPanel>
<g:HTMLPanel ui:field="centroidPanel"></g:HTMLPanel>
<g:HTMLPanel ui:field="tableOfContentPanel"

View File

@ -7,7 +7,7 @@ import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEvent.EVENT_SOURCE;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAImages;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GeoportalImages;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project.ProjectUtil;
import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon;
@ -45,7 +45,7 @@ public class TimelineRelationPanel extends Composite {
Anchor timelinePopupCloser;
private LoaderIcon loaderData = new LoaderIcon("Loading data... please wait",
new Image(GNAImages.ICONS.spinnerClock()));
new Image(GeoportalImages.ICONS.spinnerClock()));
private TimelineRelationPanel instance = this;

View File

@ -8,7 +8,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerSer
import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent.DO_LAYER_ACTION;
import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent.SwapLayer;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAImages;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GeoportalImages;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project.ProjectUtil;
import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon;
import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil;
@ -50,11 +50,11 @@ public class DragDropLayer extends FlowPanel {
private static DragDropLayer draggingTarget = null;
final boolean droppable;
private Label labelLayerName;
private Image imgLayerVisible = new Image(GNAImages.ICONS.layerVisible());
private Image imgLayerInvisible = new Image(GNAImages.ICONS.layerInvisible());
private Image imgLayerVisible = new Image(GeoportalImages.ICONS.layerVisible());
private Image imgLayerInvisible = new Image(GeoportalImages.ICONS.layerInvisible());
private Image imgLocate = new Image(GNAImages.ICONS.locate());
private Image imgLocateNone = new Image(GNAImages.ICONS.locateNone());
private Image imgLocate = new Image(GeoportalImages.ICONS.locate());
private Image imgLocateNone = new Image(GeoportalImages.ICONS.locateNone());
private boolean locateEnabled = false;
private HTML buttonLocate = new HTML();

View File

@ -9,7 +9,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerCon
import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.LightOpenLayerMap;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAIcons;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GeoportalIcons;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.Location;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.PLACE;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
@ -86,7 +86,7 @@ public class MapView extends Composite {
theMapPanel.setWidth(internalMapWidth);
theMapPanel.setHeight(internalMapHeight);
linkMap.setCustomIconStyle(GNAIcons.CustomIconType.MAP.get());
linkMap.setCustomIconStyle(GeoportalIcons.CustomIconType.MAP.get());
Scheduler.get().scheduleDeferred(new ScheduledCommand() {

View File

@ -3,7 +3,7 @@
*/
package org.gcube.portlets.user.geoportaldataviewer.client.util;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAImages;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GeoportalImages;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
@ -18,7 +18,7 @@ import com.google.gwt.user.client.ui.Image;
public class LoaderIcon extends HorizontalPanel{
private Image imgLoading = new Image(GNAImages.ICONS.loading());
private Image imgLoading = new Image(GeoportalImages.ICONS.loading());
private HTML txtLoading = new HTML("");
/**

View File

@ -69,6 +69,7 @@ import org.gcube.application.geoportalcommon.util.StringUtil;
import org.gcube.application.geoportalcommon.util.URLParserUtil;
import org.gcube.application.geoportaldatamapper.GcubeProfilesPerUCDIdCache;
import org.gcube.application.geoportaldatamapper.Geoportal_JSON_Mapper;
import org.gcube.application.geoportaldatamapper.exporter.Geoportal_PDF_Exporter;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerService;
import org.gcube.portlets.user.geoportaldataviewer.server.gis.FeatureParser;
@ -80,7 +81,7 @@ import org.gcube.portlets.user.geoportaldataviewer.server.util.HTTPRequestUtil;
import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil;
import org.gcube.portlets.user.geoportaldataviewer.server.util.TemporalComparatorUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.GCubeCollection;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoportalSpatialQueryResult;
import org.gcube.portlets.user.geoportaldataviewer.shared.ItemFieldsResponse;
import org.gcube.portlets.user.geoportaldataviewer.shared.ResultSetPaginatedDataIDs;
import org.gcube.portlets.user.geoportaldataviewer.shared.ViewerConfiguration;
@ -413,14 +414,14 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
* @return the WFS features
*/
@Override
public List<GeoNaSpatialQueryResult> getWFSFeatures(List<LayerObject> layerObjects, String mapSrsName,
public List<GeoportalSpatialQueryResult> getWFSFeatures(List<LayerObject> layerObjects, String mapSrsName,
BoundsMap selectBBOX, int maxWFSFeature, double zoomLevel) {
LOG.info("getWFSFeatures called");
List<GeoNaSpatialQueryResult> listDAO = new ArrayList<GeoNaSpatialQueryResult>(layerObjects.size());
List<GeoportalSpatialQueryResult> listDAO = new ArrayList<GeoportalSpatialQueryResult>(layerObjects.size());
for (LayerObject layerObject : layerObjects) {
GeoNaSpatialQueryResult geoDAO = new GeoNaSpatialQueryResult();
GeoportalSpatialQueryResult geoDAO = new GeoportalSpatialQueryResult();
List<FeatureRow> features = FeatureParser.getWFSFeatures(layerObject.getLayerItem(), mapSrsName, selectBBOX,
maxWFSFeature);
LOG.debug("For layer name: " + layerObject.getLayerItem().getName() + " got features: " + features);
@ -617,56 +618,6 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
}
// public Map<String, List<GroupedLayersDV>> getAvaiableCrossFilteringLayers() {
//
// Map<String, List<GroupedLayersDV>> mapProfileIDOvelayLayers = new LinkedHashMap<>();
//
// // Reading UCDs Collections from the session
// Map<String, UseCaseDescriptor> ucdCollections = SessionUtil.getAvailableCollections(getThreadLocalRequest());
//
// for (String profileId : ucdCollections.keySet()) {
//
// UseCaseDescriptor u = ucdCollections.get(profileId);
//
// // Loading geoportal_grouped_overlay_layers if exists
// GEOPORTAL_DATA_HANDLER theHandler = GEOPORTAL_DATA_HANDLER.geoportal_grouped_cross_filtering;
// List<HandlerDeclaration> handlers = u.getHandlersByType(theHandler.getType());
//
// if (handlers != null && handlers.size() > 0) {
// // Loading Handler gcube_profiles
// HandlerDeclaration handler = handlers.get(0);
// List<GroupedLayersDV> listGroupedCustomLayers = null;
// try {
//
// HandlerDeclarationDV handlerDV = ConvertToDataValueObjectModel.toHandlerDeclarationDV(handler, u,
// GEOPORTAL_CONFIGURATION_TYPE.grouped_overlay_layers);
//
// if (handler != null) {
// ConfigurationDV<?> config = handlerDV.getConfiguration();
// switch (config.getConfigurationType()) {
// case grouped_overlay_layers:
// listGroupedCustomLayers = (List<GroupedLayersDV>) config.getConfiguration();
// break;
// default:
// break;
// }
// }
// } catch (Exception e) {
// LOG.error("Error on loading {} config for ucd Id {}. Returning null",
// GEOPORTAL_CONFIGURATION_TYPE.grouped_overlay_layers, u.getId());
// }
//
// mapProfileIDOvelayLayers.put(profileId, listGroupedCustomLayers);
// } else {
// LOG.warn("No handler " + theHandler + "found into UCD " + u.getId() + ", continue...");
// mapProfileIDOvelayLayers.put(profileId, null);
// }
// }
//
// return mapProfileIDOvelayLayers;
//
// }
/**
* Gets the layer index.
*
@ -1248,7 +1199,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
* @throws Exception the exception
*/
@Override
public List<GeoNaSpatialQueryResult> getDataResult(List<LayerObject> layerObjects, String mapSrsName,
public List<GeoportalSpatialQueryResult> getDataResult(List<LayerObject> layerObjects, String mapSrsName,
BoundsMap selectBBOX, int maxWFSFeature, double zoomLevel) throws Exception {
LOG.info("getDataResult called");
@ -1263,13 +1214,13 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
+ ", zoomLevel: " + zoomLevel);
}
List<GeoNaSpatialQueryResult> listDAO = new ArrayList<GeoNaSpatialQueryResult>(layerObjects.size());
List<GeoportalSpatialQueryResult> listDAO = new ArrayList<GeoportalSpatialQueryResult>(layerObjects.size());
try {
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
for (LayerObject layerObject : layerObjects) {
GeoNaSpatialQueryResult geoDAO = new GeoNaSpatialQueryResult();
GeoportalSpatialQueryResult geoDAO = new GeoportalSpatialQueryResult();
List<FeatureRow> features = FeatureParser.getWFSFeatures(layerObject.getLayerItem(), mapSrsName,
selectBBOX, maxWFSFeature);
LOG.debug("For layer name: " + layerObject.getLayerItem().getName() + " got features: " + features);
@ -1878,4 +1829,24 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
return integer;
}
@Override
public Boolean checkExportAsPDFConfig() {
LOG.debug("checkExportAsPDFConfig called");
Boolean configChecked = null;
try {
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
configChecked = SessionUtil.getCheckConfigForPFDExporter(this.getThreadLocalRequest());
if(configChecked==null) {
Geoportal_PDF_Exporter gpdfe = new Geoportal_PDF_Exporter();
configChecked = gpdfe.checkConfig();
SessionUtil.setCheckConfigForPFDExporter(this.getThreadLocalRequest(), configChecked);
}
LOG.info("Does the 'Export As PDF' config exists? " + configChecked);
} catch (Exception e) {
LOG.error("Error occurred in checkExportAsPDFConfig", e);
}
return configChecked;
}
}

View File

@ -0,0 +1,257 @@
/**
*
*/
package org.gcube.portlets.user.geoportaldataviewer.server;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Enumeration;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.IOUtils;
import org.apache.http.client.methods.HttpGet;
import org.gcube.common.portal.PortalContext;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.GeoportalServiceIdentityProxy;
import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil;
import org.gcube.portlets.user.uriresolvermanager.geoportal.GeoportalExporterAPI;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class GeoportalExporterActionServlet.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Apr 23, 2024
*/
public class GeoportalExporterActionServlet extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 6037090280489238565L;
protected static Logger logger = LoggerFactory.getLogger(GeoportalExporterActionServlet.class);
/**
* {@inheritDoc}
*/
@Override
public void init() throws ServletException {
super.init();
logger.trace(GeoportalExporterActionServlet.class.getSimpleName() + " ready.");
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
logger.info("doPost Called");
serveRequest(req, resp);
}
/**
* Do get.
*
* @param req the req
* @param resp the resp
* @throws IOException Signals that an I/O exception has occurred.
* @throws ServletException the servlet exception
*/
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
logger.info("doGet Called");
sendError(resp,
"The request cannot be served (via http GET). Please retry by using the Export facility provided by Data-Viewer UI");
}
/**
* Serve request.
*
* @param req the req
* @param resp the resp
* @throws IOException Signals that an I/O exception has occurred.
*/
public void serveRequest(HttpServletRequest req, HttpServletResponse resp) throws IOException {
// setSecretManager();
String projectID = req.getParameter(GeoportalDataViewerConstants.PROIECT_ID_PARAMETER);
String ucdID = req.getParameter(GeoportalDataViewerConstants.UCD_ID_PARAMETER);
String contextID = req.getParameter(GeoportalDataViewerConstants.CONTEXT_ID_PARAMETER);
String userID = req.getParameter(GeoportalDataViewerConstants.USER_ID_PARAMETER);
String username = req.getParameter(GeoportalDataViewerConstants.USERNAME_PARAMETER);
// logger.info("serveRequest called with [projectID: " + projectID + ", ucdID: " + ucdID + ", contextID: " + contextID+"]");
logger.info("serveRequest called with [projectID: " + projectID + ", ucdID: " + ucdID + ", contextID: "
+ contextID + ", userID: " + userID + ", username: " + username + "]");
if (contextID == null || contextID.isEmpty())
sendError(resp, "Bad Request. No context found!");
PortalContext pContext = PortalContext.getConfiguration();
String scope = pContext.getCurrentScope(contextID);
logger.info("The scope is {}", scope);
try {
// Setting header required to {@PortalContext}
MutableHttpServletRequest mutableRequest = new MutableHttpServletRequest(req);
mutableRequest.putHeader(PortalContext.VRE_ID_ATTR_NAME, contextID);
// DEV MODE
if (!SessionUtil.isIntoPortal()) {
logger.info("DEBUG MODE, putting header " + PortalContext.USER_ID_ATTR_NAME);
mutableRequest.putHeader(PortalContext.USER_ID_ATTR_NAME, userID);
}
// IF USERNAME exists, add the userID to request. So performing the request to
// exporter service on behalf of the user.
if (username != null) {
logger.info("Username found, putting header " + PortalContext.USER_ID_ATTR_NAME);
mutableRequest.putHeader(PortalContext.USER_ID_ATTR_NAME, userID);
}
ScopeProvider.instance.set(scope);
GeoportalServiceIdentityProxy identity = new GeoportalServiceIdentityProxy(mutableRequest);
String theToken = identity.getToken();
String theIdentity = identity.getIdentity();
logger.info("The identity is {}", theIdentity);
GeoportalExporterAPI geoportalExporterAPI = new GeoportalExporterAPI();
URL urlRequest = geoportalExporterAPI.exportProject("pdf", ucdID, projectID, false);
String urlToRedirect = urlRequest.toString();
logger.info("Performing request to {} with identity description {}", urlToRedirect,
identity.getDescription());
logger.info("Token is {}", theToken.substring(0, 20) + "_MASKED_TOKEN");
InputStream is = performHttpRequestToSGService(urlToRedirect, theIdentity, theToken);
resp.setContentType("text/html; charset=utf-8");
IOUtils.copy(is, resp.getOutputStream());
resp.flushBuffer();
} catch (Exception e) {
logger.error("Error occurred when exporting the Project with id: " + projectID, e);
sendError(resp, "Error occurred when exporting the Project. Error is: " + e.getMessage());
return;
}
}
/**
* Perform http request to SG service.
*
* @param urlToService the url to service
* @param identity the identity
* @param token the token
* @return the input stream
* @throws IOException Signals that an I/O exception has occurred.
*/
public static InputStream performHttpRequestToSGService(String urlToService, String identity, String token)
throws IOException {
logger.debug("performHttpRequestToSGService called");
try {
URL url = new URL(urlToService);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
// timeout at 60sec
conn.setConnectTimeout(6000);
conn.setDoOutput(true);
if (token.length() > 50) {
// is JWT TOKEN
conn.setRequestProperty("Authorization", "Bearer " + token);
} else {
// is legacy Token
conn.setRequestProperty("gcube-token", token);
}
conn.setRequestProperty("Content-Type", "text/html");
conn.setRequestMethod("GET");
logger.debug("performHttpRequestToSGService done, returning");
return conn.getInputStream();
} catch (IOException e) {
logger.error("Error on performing request to url " + urlToService, e);
throw e;
}
}
/**
* Sets the headers to target.
*
* @param httpSource the http source
* @param response the response
* @return the http servlet response
*/
public static HttpServletResponse setHeadersToTarget(HttpServletRequest httpSource, HttpServletResponse response) {
Enumeration<String> headersNames = httpSource.getHeaderNames();
while (headersNames.hasMoreElements()) {
String headerName = (String) headersNames.nextElement();
Enumeration<String> values = httpSource.getHeaders(headerName);
while (values.hasMoreElements()) {
String value = values.nextElement();
logger.info("Copying header {} with value {}", headerName, value);
response.addHeader(headerName, value);
}
}
return response;
}
/**
* Sets the headers to target.
*
* @param httpSource the http source
* @param httpTarget the http target
* @return the http get
*/
public static HttpGet setHeadersToTarget(HttpServletRequest httpSource, HttpGet httpTarget) {
Enumeration<String> headersNames = httpSource.getHeaderNames();
while (headersNames.hasMoreElements()) {
String headerName = (String) headersNames.nextElement();
Enumeration<String> values = httpSource.getHeaders(headerName);
while (values.hasMoreElements()) {
String value = values.nextElement();
logger.info("Copying header {} with value {}", headerName, value);
httpTarget.addHeader(headerName, value);
}
}
return httpTarget;
}
/**
* Sets the headers to response.
*
* @param httpSource the http source
* @param httpTarget the http target
* @return the http get
*/
public static HttpGet setHeadersToResponse(HttpServletRequest httpSource, HttpGet httpTarget) {
Enumeration<String> headersNames = httpSource.getHeaderNames();
while (headersNames.hasMoreElements()) {
String headerName = (String) headersNames.nextElement();
Enumeration<String> values = httpSource.getHeaders(headerName);
while (values.hasMoreElements()) {
String value = values.nextElement();
logger.info("Copying header {} with value {}", headerName, value);
httpTarget.addHeader(headerName, value);
}
}
return httpTarget;
}
/**
* Send response.
*
* @param response the response
* @param message the message
* @throws IOException Signals that an I/O exception has occurred.
*/
protected void sendError(HttpServletResponse response, String message) throws IOException {
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
response.setContentType("text/html");
response.getWriter().write("<html><head><title>Error</title></head><body>" + message + "</body></html>");
response.flushBuffer();
}
}

View File

@ -0,0 +1,53 @@
package org.gcube.portlets.user.geoportaldataviewer.server;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
final class MutableHttpServletRequest extends HttpServletRequestWrapper {
// holds custom header and value mapping
private final Map<String, String> customHeaders;
public MutableHttpServletRequest(HttpServletRequest request){
super(request);
this.customHeaders = new HashMap<String, String>();
}
public void putHeader(String name, String value){
this.customHeaders.put(name, value);
}
public String getHeader(String name) {
// check the custom headers first
String headerValue = customHeaders.get(name);
if (headerValue != null){
return headerValue;
}
// else return from into the original wrapped object
return ((HttpServletRequest) getRequest()).getHeader(name);
}
public Enumeration<String> getHeaderNames() {
// create a set of the custom header names
Set<String> set = new HashSet<String>(customHeaders.keySet());
// now add the headers from the wrapped request object
@SuppressWarnings("unchecked")
Enumeration<String> e = ((HttpServletRequest) getRequest()).getHeaderNames();
while (e.hasMoreElements()) {
// add the names of the request headers into the list
String n = e.nextElement();
set.add(n);
}
// create an enumeration from the set and return
return Collections.enumeration(set);
}
}

View File

@ -22,9 +22,9 @@ public class GeoportalServiceIdentityProxy {
private static final Logger LOG = LoggerFactory.getLogger(GeoportalServiceIdentityProxy.class);
private GcubeIdentity gCubeIdentity;
private boolean isUser = false;
private boolean isIAMClient = false;
/**
@ -57,12 +57,24 @@ public class GeoportalServiceIdentityProxy {
gCubeIdentity.setIdentity(request);
}
public boolean isUser() {
return isUser;
}
public boolean isIAMClient() {
return isIAMClient;
}
public String getDescription() {
return gCubeIdentity.getIdentityDescription();
}
public String getToken() {
return gCubeIdentity.getToken();
}
public String getIdentity() {
return gCubeIdentity.getIdentity();
}
}

View File

@ -2,16 +2,15 @@ package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessid
import javax.servlet.http.HttpServletRequest;
/**
* The Interface GcubeIdentity.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Sep 23, 2021
* Sep 23, 2021
*/
public interface GcubeIdentity {
/**
* Sets the identity.
*
@ -19,10 +18,32 @@ public interface GcubeIdentity {
* @throws Exception the exception
*/
public void setIdentity(HttpServletRequest httpRequest) throws Exception;
/**
* Reset identity.
*/
public void resetIdentity();
/**
* Gets the identity description.
*
* @return the identity description
*/
public String getIdentityDescription();
/**
* Gets the identity.
*
* @return the identity
*/
public String getIdentity();
/**
* Gets the token.
*
* @return the token
*/
public String getToken();
}

View File

@ -16,18 +16,23 @@ public class IAMClientIdentity implements GcubeIdentity {
private static final Logger LOG = LoggerFactory.getLogger(IAMClientIdentity.class);
private String previousUMAToken = null;
private String currentUMAToken = null;
private String clientId = null;
private static final String IAM_CLIENT_CREDENTIALS = "IAM_CLIENT_CREDENTIALS";
@Override
public void setIdentity(HttpServletRequest httpRequest) throws Exception {
LOG.info("setIdentity called");
String currentScope = SessionUtil.getCurrentContext(httpRequest, true);
IAMClientCredentials credentials = sessionGetIAMClientCredentials(httpRequest);
LOG.info("the scope is {}", currentScope);
IAMClientCredentials credentials = sessionGetIAMClientCredentials(httpRequest);
try {
if(credentials==null) {
if (credentials == null) {
credentials = IAMClientCredentialsReader.getCredentials();
sessionSetIAMClientCredentials(httpRequest,credentials);
sessionSetIAMClientCredentials(httpRequest, credentials);
}
} catch (Exception e) {
LOG.error("Error on discovering IAM Client credentials", e);
@ -35,16 +40,16 @@ public class IAMClientIdentity implements GcubeIdentity {
}
LOG.trace("Read credentials: " + credentials);
String umaAcessToken = null;
String clientId = credentials.getClientId();
clientId = credentials.getClientId();
String clientSecret = credentials.getClientSecret();
try {
LOG.info("Querying KeycloakClientFactory to get UMA token..");
TokenResponse tr = KeycloakClientFactory.newInstance().queryUMAToken(clientId, clientSecret, currentScope,
TokenResponse tr = KeycloakClientFactory.newInstance().queryUMAToken(currentScope, clientId, clientSecret, currentScope,
null);
umaAcessToken = tr.getAccessToken();
if (umaAcessToken != null && !umaAcessToken.isEmpty()) {
currentUMAToken = tr.getAccessToken();
if (currentUMAToken != null && !currentUMAToken.isEmpty()) {
LOG.info("UMA Access Token read correctly");
} else {
LOG.error("UMA Access Token NOT RETRIEVED!!!");
@ -56,6 +61,8 @@ public class IAMClientIdentity implements GcubeIdentity {
try {
LOG.debug("JWT token: " + currentUMAToken.substring(0, 20) + "_MASKED_TOKEN_");
try {
// Here the previousUMAToken should be null
previousUMAToken = AccessTokenProvider.instance.get();
@ -64,10 +71,9 @@ public class IAMClientIdentity implements GcubeIdentity {
// silent
}
LOG.debug("JWT token: " + umaAcessToken.substring(0, 20) + "_MASKED_TOKEN_");
LOG.info("Setting clientId '" + clientId + "' identity by JWT token in the "
+ AccessTokenProvider.class.getSimpleName());
AccessTokenProvider.instance.set(umaAcessToken);
AccessTokenProvider.instance.set(currentUMAToken);
} catch (Exception e) {
LOG.error(e.getMessage(), e);
throw new Exception(e.getMessage());
@ -75,6 +81,11 @@ public class IAMClientIdentity implements GcubeIdentity {
}
@Override
public String getToken() {
return currentUMAToken;
}
@Override
public void resetIdentity() {
LOG.info("resetIdentity called");
@ -82,7 +93,7 @@ public class IAMClientIdentity implements GcubeIdentity {
LOG.info("resetIdentity to previous AccessToken");
}
/**
* Gets the IAM client credentials.
*
@ -103,7 +114,7 @@ public class IAMClientIdentity implements GcubeIdentity {
* Sets the IAM client credentials.
*
* @param httpRequest the http request
* @param iamCC the iam CC
* @param iamCC the iam CC
*/
public static void sessionSetIAMClientCredentials(HttpServletRequest httpRequest, IAMClientCredentials iamCC) {
HttpSession session = httpRequest.getSession();
@ -114,4 +125,15 @@ public class IAMClientIdentity implements GcubeIdentity {
}
}
@Override
public String getIdentityDescription() {
return "ClientId: " + clientId;
}
@Override
public String getIdentity() {
return clientId;
}
}

View File

@ -3,6 +3,7 @@ package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessid
import javax.servlet.http.HttpServletRequest;
import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil;
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -10,13 +11,19 @@ public class UserIdentity implements GcubeIdentity {
private static final Logger LOG = LoggerFactory.getLogger(UserIdentity.class);
private HttpServletRequest httpRequest;
private GCubeUser user;
public UserIdentity() {
}
@Override
public void setIdentity(HttpServletRequest httpRequest) throws Exception {
LOG.info("setIdentity called");
SessionUtil.getCurrentToken(httpRequest, true);
this.httpRequest = httpRequest;
SessionUtil.getCurrentToken(this.httpRequest, true);
user = SessionUtil.getCurrentUser(this.httpRequest);
}
@ -25,4 +32,20 @@ public class UserIdentity implements GcubeIdentity {
LOG.info("resetIdentity called, doing nothing");
// doing nothing
}
@Override
public String getToken() {
return SessionUtil.getCurrentToken(this.httpRequest, true);
}
@Override
public String getIdentityDescription() {
return user != null ? "user: " + user.getUsername() : "null";
}
@Override
public String getIdentity() {
return user.getUsername();
}
}

View File

@ -55,6 +55,8 @@ public class SessionUtil {
private static final String UCD_COLLECTIONS_SESSION = "THE_UCD_COLLECTIONS";
private static final String CHECKED_CONFIG_FOR_PDF_EXPORTER = "CHECKED_CONFIG_FOR_PDF_EXPORTER";
/**
* Checks if is into portal.
*
@ -345,4 +347,14 @@ public class SessionUtil {
return (Map<String, UseCaseDescriptor>) session.getAttribute(UCD_COLLECTIONS_SESSION);
}
public static Boolean getCheckConfigForPFDExporter(HttpServletRequest httpServletRequest) {
HttpSession session = httpServletRequest.getSession();
return (Boolean) session.getAttribute(CHECKED_CONFIG_FOR_PDF_EXPORTER);
}
public static void setCheckConfigForPFDExporter(HttpServletRequest httpServletRequest, Boolean configChecked) {
HttpSession session = httpServletRequest.getSession();
session.setAttribute(CHECKED_CONFIG_FOR_PDF_EXPORTER, configChecked);
}
}

View File

@ -3,7 +3,7 @@ package org.gcube.portlets.user.geoportaldataviewer.server.util;
import java.util.Comparator;
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoportalSpatialQueryResult;
/**
* The Class TemporalComparatorUtil.
@ -12,7 +12,7 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResul
*
* Nov 18, 2022
*/
public class TemporalComparatorUtil implements Comparator<GeoNaSpatialQueryResult> {
public class TemporalComparatorUtil implements Comparator<GeoportalSpatialQueryResult> {
/**
* Compare.
@ -22,7 +22,7 @@ public class TemporalComparatorUtil implements Comparator<GeoNaSpatialQueryResul
* @return the int
*/
@Override
public int compare(GeoNaSpatialQueryResult a, GeoNaSpatialQueryResult b) {
public int compare(GeoportalSpatialQueryResult a, GeoportalSpatialQueryResult b) {
if (a == null || a.getSourceLayerObject() == null || a.getSourceLayerObject().getProjectDV() == null) {
return -1;
}

View File

@ -9,13 +9,13 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow;
/**
* The Class GeoNaSpatialQueryResult.
* The Class GeoportalSpatialQueryResult.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jul 30, 2021
*/
public class GeoNaSpatialQueryResult implements Serializable {
public class GeoportalSpatialQueryResult implements Serializable {
/**
*
@ -23,14 +23,14 @@ public class GeoNaSpatialQueryResult implements Serializable {
private static final long serialVersionUID = 3513120677727206958L;
private List<FeatureRow> features;
private LayerObject sourceLayerObject;
// Map with couple (mongoId concessione, list of uploaded GNAImages for the
// concessione)
// Map with couple (mongoId project, list of uploaded GeoportalImages for the
// project)
private Map<String, List<PayloadDV>> mapImages = null;
/**
* Instantiates a new geo na data object.
*/
public GeoNaSpatialQueryResult() {
public GeoportalSpatialQueryResult() {
}
@ -91,7 +91,7 @@ public class GeoNaSpatialQueryResult implements Serializable {
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("GeoNaSpatialQueryResult [features=");
builder.append("GeoportalSpatialQueryResult [features=");
builder.append(features);
builder.append(", sourceLayerObject=");
builder.append(sourceLayerObject);

View File

@ -1,16 +0,0 @@
package org.gcube.portlets.user.geoportaldataviewer.shared.gis;
import java.io.Serializable;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Data
public class DisplayCategory implements Serializable {
String title;
String description;
}

View File

@ -1,13 +0,0 @@
package org.gcube.portlets.user.geoportaldataviewer.shared.gis;
import java.util.Map;
public class OverlayWMSLayer {
private String title;
private String name;
private String wmsServiceBaseURL;
private boolean display;
private Map<String, String> mapProperties;
}

View File

@ -17,11 +17,17 @@
<inherits name="com.google.gwt.json.JSON" />
<inherits
name='org.gcube.portal.clientcontext.GCubeClientContext' />
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits -->
<servlet path="/geoportalexporterservice"
class="org.gcube.portlets.user.geoportaldataviewer.server.GeoportalExporterActionServlet" />
<!-- Specify the app entry point class. -->
<entry-point
class='org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewer' />

View File

@ -15,7 +15,17 @@
<servlet-name>geoportalDataViewerServlet</servlet-name>
<servlet-class>org.gcube.portlets.user.geoportaldataviewer.server.GeoportalDataViewerServiceImpl</servlet-class>
</servlet>
<!-- <servlet> -->
<!-- <servlet-name>geoportalWaitingServerActionServlet</servlet-name> -->
<!-- <servlet-class>org.gcube.portlets.user.geoportaldataviewer.server.WatingServerActionServlet</servlet-class> -->
<!-- </servlet> -->
<servlet>
<servlet-name>geoportalExporterServerActionServlet</servlet-name>
<servlet-class>org.gcube.portlets.user.geoportaldataviewer.server.GeoportalExporterActionServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>mpformbuilderServlet</servlet-name>
<servlet-class>org.gcube.portlets.widgets.mpformbuilder.server.MetadataProfileFormBuilderServiceImpl</servlet-class>
@ -31,5 +41,15 @@
<servlet-name>geoportalDataViewerServlet</servlet-name>
<url-pattern>/GeoportalDataViewer/geoportaldataviewerservice</url-pattern>
</servlet-mapping>
<!-- <servlet-mapping> -->
<!-- <servlet-name>geoportalWaitingServerActionServlet</servlet-name> -->
<!-- <url-pattern>/GeoportalDataViewer/geoportaldataviewerwaitingservice</url-pattern> -->
<!-- </servlet-mapping> -->
<servlet-mapping>
<servlet-name>geoportalExporterServerActionServlet</servlet-name>
<url-pattern>/GeoportalDataViewer/geoportalexporterservice</url-pattern>
</servlet-mapping>
</web-app>

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -0,0 +1,42 @@
/**
*
*/
package org.gcube.portlets.user.geoportaldataviewer;
import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.io.IOUtils;
import org.gcube.portlets.user.geoportaldataviewer.server.GeoportalExporterActionServlet;
/**
* The Class GeoportalExporterActionServletTest.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Apr 24, 2024
*/
public class GeoportalExporterActionServletTest {
/**
* The main method.
*
* @param args the arguments
*/
public static void main(String[] args) {
String url = "https://data.dev.d4science.org/geoportal/export/pdf/profiledConcessioni/661d2c6f8804530afb90b132";
String identity = "francesco.mangiacrapa";
String token = "";
System.out.println("Start");
InputStream response;
try {
response = GeoportalExporterActionServlet.performHttpRequestToSGService(url, identity, token);
System.out.println(IOUtils.toString(response));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("End");
}
}