Starting migration to UCD

cms_23940
Francesco Mangiacrapa 2 years ago
parent 0065ff35f1
commit 6363c2ea5e

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

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

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
@ -17,8 +17,14 @@
<wb-module deploy-name="geoportal-data-viewer-app-2.4.0">
<wb-module deploy-name="geoportal-data-viewer-app-3.0.0-SNAPSHOT">
@ -37,7 +43,10 @@
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
@ -56,7 +65,10 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
@ -75,7 +87,10 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
@ -94,7 +109,10 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
@ -113,7 +131,10 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
@ -132,7 +153,10 @@
<property name="java-output-path" value="/geoportal-data-viewer-app/target/geoportal-data-viewer-app-0.0.1-SNAPSHOT/WEB-INF/classes"/>
@ -151,7 +175,10 @@
<property name="context-root" value="geoportal-data-viewer-app"/>
@ -170,7 +197,10 @@
</wb-module>

@ -4,11 +4,13 @@
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).
## [v2.4.1-SNAPSHOT] - 2022-09-28
## [v3.0.0-SNAPSHOT] - 2022-10-11
- [#23940] Passed to CMS-UCD
- [#23906] Tested building on jenkins with JDK_11
## [v2.4.1-SNAPSHOT] - 2022-09-28
- [#23906] Tested building on jenkins with JDK_11
## [v2.4.0] - 2022-09-07

@ -14,7 +14,7 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>geoportal-data-viewer-app</artifactId>
<packaging>war</packaging>
<version>2.4.1-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
<name>GeoPortal Data Viewer App</name>
<description>The GeoPortal Data Viewer App is an application to access, discovery and navigate the GeoNa products by a Web-Map Interface</description>
@ -157,40 +157,46 @@
</dependency>
<!-- END -->
<!-- FORCING THESE DEPENDENCIES IN ORDER TO USE THE "OLD" CONCESSIONI CLIENT/MODEL -->
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>metadata-profile-discovery</artifactId>
<version>[1.0.0-SNAPSHOT, 1.1.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.application</groupId>
<artifactId>geoportal-data-common</artifactId>
<version>[1.0.0-SNAPSHOT, 1.5.0-SNAPSHOT)</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.gcube.application</groupId>
<artifactId>geoportal-client</artifactId>
<version>[1.0.0, 1.1.0-SNAPSHOT)</version>
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>metadata-profile-form-builder-widget</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<scope>compile</scope>
<!-- does not remove these exclusions, there are conflict with jackson
2.7 used by geo-json dependency -->
<exclusions>
<exclusion>
<groupId>org.gcube.resources.discovery</groupId>
<artifactId>ic-client</artifactId>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</exclusion>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<groupId>de.grundid.opendatalab</groupId>
<artifactId>geojson-jackson</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- END FORCING -->
<dependency>
<groupId>org.gcube.application</groupId>
<artifactId>geoportal-data-common</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>2.7.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
@ -221,6 +227,7 @@
<!-- <version>1.6.4</version> -->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>

@ -1,17 +1,17 @@
package org.gcube.portlets.user.geoportaldataviewer.client;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
import org.gcube.application.geoportalcommon.shared.ItemField;
import org.gcube.application.geoportalcommon.shared.LayerItem;
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER;
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.model.RecordDV;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
@ -55,7 +55,6 @@ import com.google.gwt.core.client.ScriptInjector;
import com.google.gwt.event.logical.shared.ResizeEvent;
import com.google.gwt.event.logical.shared.ResizeHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HTML;
@ -112,9 +111,9 @@ public class GeoportalDataViewer implements EntryPoint {
private static List<BaseMapLayer> listBaseMapLayers = null;
private List<ItemField> displayFields = new ArrayList<ItemField>();
private List<ItemField> sortByFields = new ArrayList<ItemField>();
private List<ItemField> searchByFields = new ArrayList<ItemField>();
private List<ItemFieldDV> displayFields = new ArrayList<ItemFieldDV>();
private List<ItemFieldDV> sortByFields = new ArrayList<ItemFieldDV>();
private List<ItemFieldDV> searchByFields = new ArrayList<ItemFieldDV>();
/**
* This is the entry point method.
@ -135,7 +134,7 @@ public class GeoportalDataViewer implements EntryPoint {
RootPanel.get(APP_DIV).add(loaderApp);
GeoportalDataViewerServiceAsync.Util.getInstance().listOfFieldsForSearching(new AsyncCallback<List<ItemField>>() {
GeoportalDataViewerServiceAsync.Util.getInstance().listOfFieldsForSearching(new AsyncCallback<List<ItemFieldDV>>() {
@Override
public void onFailure(Throwable caught) {
@ -144,10 +143,10 @@ public class GeoportalDataViewer implements EntryPoint {
}
@Override
public void onSuccess(List<ItemField> result) {
public void onSuccess(List<ItemFieldDV> result) {
GWT.log("Loaded item fields: "+result);
for (ItemField itemField : result) {
for (ItemFieldDV itemField : result) {
if(itemField.isDisplayAsResult()) {
displayFields.add(itemField);
}
@ -165,7 +164,9 @@ public class GeoportalDataViewer implements EntryPoint {
GWT.log("List display fields: "+result);
SearchingFilter initialSortFilter = new SearchingFilter();
initialSortFilter.setOrder(ORDER.ASC);
initialSortFilter.setOrderByFields(Arrays.asList(new ItemField("Name", Arrays.asList("name"), true, true, true)));
//TODO MUST BE REVISITED
//initialSortFilter.setOrderByFields(Arrays.asList(new ItemField("Name", Arrays.asList("name"), true, true, true)));
mainPanel = new GeonaDataViewMainPanel(applicationBus, getClientHeight(),sortByFields,searchByFields,initialSortFilter);
RootPanel.get(APP_DIV).add(mainPanel);
@ -263,7 +264,10 @@ public class GeoportalDataViewer implements EntryPoint {
geonaDataViewerProfile = profile;
GWT.log("Profile: " + geonaDataViewerProfile);
Iterator<String> it;
String theItemType = paramGeonaItemType;
String theItemType = null;
if (theItemType == null) {
it = geonaDataViewerProfile.getMapLayers().keySet().iterator();
it.hasNext();
@ -272,10 +276,10 @@ public class GeoportalDataViewer implements EntryPoint {
LayerItem layerItem = geonaDataViewerProfile.getMapLayers().get(theItemType);
if (layerItem == null) {
Window.alert("Not detected any layer with type: " + theItemType);
return;
}
// if (layerItem == null) {
// Window.alert("Not detected any layer with type: " + theItemType);
// return;
// }
GWT.log("ON module load The layerItem is: " + layerItem);
String layerName = URLUtil.getValueOfParameter("layers", layerItem.getWmsLink());
@ -333,39 +337,55 @@ public class GeoportalDataViewer implements EntryPoint {
public void onShowDetails(ShowDetailsEvent showDetailsEvent) {
GWT.log("Fired event: " + showDetailsEvent);
String geonaMongoId = showDetailsEvent.getGeonaMongoID();
String projectID = showDetailsEvent.getGeonaMongoID();
String profileID = showDetailsEvent.getGeonaItemType();
if (geonaMongoId == null) {
if (projectID == null) {
Window.alert("Item Id not found");
return;
}
// TODO
boolean found = false;
GWT.log("Product with id: " + geonaMongoId + " found? " + found);
if (!found) {
if (showDetailsEvent.getGeonaItemType().equalsIgnoreCase("Concessione")) {
GeoportalDataViewerServiceAsync.Util.getInstance().getConcessioneForId(geonaMongoId,
new AsyncCallback<ConcessioneDV>() {
@Override
public void onFailure(Throwable caught) {
Window.alert(caught.getMessage());
mainPanel.hidePanelDetails();
GWT.log("Product with id: " + projectID + " found? " + found);
GeoportalDataViewerServiceAsync.Util.getInstance().getProjectViewForId(profileID, projectID, new AsyncCallback<ProjectView>() {
}
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
}
@Override
public void onSuccess(ConcessioneDV concessioneDV) {
GWT.log("Showing: " + concessioneDV);
mainPanel.showAsDetails(concessioneDV, showDetailsEvent.getGeonaItemRef());
}
});
@Override
public void onSuccess(ProjectView result) {
mainPanel.showAsDetails(result, showDetailsEvent.getGeonaItemRef());
}
}
});
// if (!found) {
//
// if (showDetailsEvent.getGeonaItemType().equalsIgnoreCase("Concessione")) {
//
// GeoportalDataViewerServiceAsync.Util.getInstance().getConcessioneForId(geonaMongoId,
// new AsyncCallback<ConcessioneDV>() {
//
// @Override
// public void onFailure(Throwable caught) {
// Window.alert(caught.getMessage());
// mainPanel.hidePanelDetails();
//
// }
//
// @Override
// public void onSuccess(ConcessioneDV concessioneDV) {
// GWT.log("Showing: " + concessioneDV);
// mainPanel.showAsDetails(concessioneDV, showDetailsEvent.getGeonaItemRef());
// }
// });
// }
// }
}
});
@ -378,6 +398,8 @@ public class GeoportalDataViewer implements EntryPoint {
try {
GWT.log("onLayerRendered Timer PART MUST BE REVISITED");
/*
attempt = 0;
if (paramGeonaItemID != null) {
@ -388,6 +410,10 @@ public class GeoportalDataViewer implements EntryPoint {
public void run() {
attempt++;
GWT.log("waiting get record: " + attempt);
RecordDV record = mainPanel.getDisplayedRecord();
if (record != null) {
this.cancel();
@ -404,11 +430,12 @@ public class GeoportalDataViewer implements EntryPoint {
};
timer.scheduleRepeating(1000);
}
}
*/
} catch (Exception e) {
// TODO: handle exception
}
LAYER_TYPE layerType = addedLayerToMapEvent.getLayerType();
if (layerType != null) {

@ -106,5 +106,72 @@ public class GeoportalDataViewerConstants {
public static native String toJsonObj(Object object)/*-{
return JSON.stringify(object);
}-*/;
/**
* Json to HTML.
*
* @param jsonTxt the json txt
* @return the string
*/
public static native String jsonToTableHTML(String jsonTxt)/*-{
try {
var jsonObj = JSON.parse(jsonTxt);
if (jsonObj.length == undefined)
jsonObj = [ jsonObj ]
//console.log(jsonObj.length)
// EXTRACT VALUE FOR HTML HEADER.
var col = [];
for (var i = 0; i < jsonObj.length; i++) {
for ( var key in jsonObj[i]) {
//console.log('key json' +key)
if (col.indexOf(key) === -1) {
col.push(key);
}
}
}
// CREATE DYNAMIC TABLE.
var table = document.createElement("table");
try {
table.classList.add("my-html-table");
} catch (e) {
console.log('invalid css add', e);
}
// ADD JSON DATA TO THE TABLE AS ROWS.
for (var i = 0; i < col.length; i++) {
tr = table.insertRow(-1);
var firstCell = tr.insertCell(-1);
//firstCell.style.cssText="font-weight: bold; text-align: center; vertical-align: middle;";
firstCell.innerHTML = col[i];
for (var j = 0; j < jsonObj.length; j++) {
var tabCell = tr.insertCell(-1);
var theValue = jsonObj[j][col[i]];
//console.log("the value: "+theValue);
if (Object.prototype.toString.call(theValue) === '[object Array]') {
var formattedValueArray = "";
for (var k = 0; k < theValue.length; k++) {
var theValueArray = theValue[k];
//console.log(theValueArray);
formattedValueArray += theValueArray + "<br>";
}
tabCell.innerHTML = formattedValueArray;
} else {
tabCell.innerHTML = theValue;
}
}
}
return table.outerHTML;
} catch (e) {
console.log('invalid json', e);
return jsonTxt;
}
}-*/;
}

@ -4,9 +4,10 @@ import java.util.List;
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
import org.gcube.application.geoportalcommon.shared.ItemField;
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV;
@ -136,7 +137,7 @@ public interface GeoportalDataViewerService extends RemoteService {
* @return the list
* @throws Exception
*/
List<ItemField> listOfFieldsForSearching() throws Exception;
List<ItemFieldDV> listOfFieldsForSearching() throws Exception;
/**
* Gets the list concessioni.
@ -151,4 +152,14 @@ public interface GeoportalDataViewerService extends RemoteService {
ResultSetPaginatedData getListConcessioni(Integer start, Integer limit, SearchingFilter filter,
boolean reloadFromService) throws Exception;
/**
* Gets the project view for id.
*
* @param profileID the profile ID
* @param projectID the project ID
* @return the project view for id
* @throws Exception the exception
*/
ProjectView getProjectViewForId(String profileID, String projectID) throws Exception;
}

@ -4,9 +4,10 @@ import java.util.List;
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
import org.gcube.application.geoportalcommon.shared.ItemField;
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV;
@ -63,9 +64,11 @@ public interface GeoportalDataViewerServiceAsync {
void getListBaseLayers(AsyncCallback<List<BaseMapLayer>> callback);
void listOfFieldsForSearching(AsyncCallback<List<ItemField>> callback);
void listOfFieldsForSearching(AsyncCallback<List<ItemFieldDV>> callback);
void getListConcessioni(Integer start, Integer limit, SearchingFilter filter, boolean reloadFromService,
AsyncCallback<ResultSetPaginatedData> callback);
void getProjectViewForId(String profileID, String projectID, AsyncCallback<ProjectView> callback);
}

@ -1,10 +1,9 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.model.RecordDV;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ClosedViewDetailsEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.products.concessioni.ConcessioneView;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project.ProjectViewer;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
@ -33,7 +32,7 @@ public class DetailsPanel extends Composite {
@UiField
HTMLPanel detailsHTMLPanel;
private RecordDV displayedRecord = null;
private ProjectView displayedProject = null;
private HandlerManager applicationBus;
@ -63,15 +62,17 @@ public class DetailsPanel extends Composite {
}
public void showDetailsFor(ConcessioneDV cdv, GeoNaItemRef geonaItemRef) {
this.displayedRecord = cdv;
public void showDetailsFor(ProjectView result, GeoNaItemRef geonaItemRef) {
this.displayedProject = result;
datailsContainerPanel.clear();
if(detailsHTMLPanel.getParent()!=null) {
detailsHTMLPanel.getParent().getElement().setScrollTop(0);
}
datailsContainerPanel.add(new ConcessioneView(geonaItemRef, cdv));
//datailsContainerPanel.add(new ConcessioneView(geonaItemRef, result));
datailsContainerPanel.add(new ProjectViewer(geonaItemRef, result));
showPanelDetails();
}
@ -80,13 +81,13 @@ public class DetailsPanel extends Composite {
}
public void hidePanelDetails() {
this.displayedRecord = null;
this.displayedProject = null;
datailsContainerPanel.clear();
detailsHTMLPanel.setVisible(false);
}
public RecordDV getDisplayedRecord() {
return displayedRecord;
public ProjectView getDisplayedProject() {
return displayedProject;
}
}

@ -3,10 +3,9 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
import org.gcube.application.geoportalcommon.shared.ItemField;
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.model.RecordDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ChangeMapLayerEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.MapExtentToEvent;
@ -91,25 +90,25 @@ public class GeonaDataViewMainPanel extends Composite {
@UiField
Button linkLayers;
@UiField
DropdownButton searchFacilityButton;
@UiField
ScrollPanel overlayLayersPanel;
@UiField
ScrollPanel searchFacilityPanel;
@UiField
HTMLPanel panelAttribution;
@UiField
HTMLPanel panelBaseLayers;
@UiField
DropdownButton linkMap;
@UiField
DropdownButton linkPresetLocation;
@ -118,18 +117,20 @@ public class GeonaDataViewMainPanel extends Composite {
private OpenLayerMap map;
private HandlerManager applicationBus;
private SearchFacilityUI searchFacility;
/**
* Instantiates a new geona data view main panel.
*
* @param applicationBus the application bus
* @param mapHeight the map height
* @param applicationBus the application bus
* @param mapHeight the map height
* @param sortByFields the sort by fields
* @param searchForFields the search for fields
* @param initialSortFilter the initial sort filter
*/
public GeonaDataViewMainPanel(HandlerManager applicationBus, int mapHeight, List<ItemField> sortByFields,
List<ItemField> searchForFields, SearchingFilter initialSortFilter) {
public GeonaDataViewMainPanel(HandlerManager applicationBus, int mapHeight, List<ItemFieldDV> sortByFields,
List<ItemFieldDV> searchForFields, SearchingFilter initialSortFilter) {
initWidget(uiBinder.createAndBindUi(this));
this.applicationBus = applicationBus;
mapPanel = new MapPanel(mapHeight + "px");
@ -150,11 +151,11 @@ public class GeonaDataViewMainPanel extends Composite {
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());
searchFacility = new SearchFacilityUI(applicationBus, sortByFields, searchForFields, initialSortFilter);
searchFacility.setSearchButton(searchFacilityButton);
searchFacilityButton.setIcon(IconType.SEARCH);
@ -164,16 +165,19 @@ public class GeonaDataViewMainPanel extends Composite {
@Override
public void execute() {
searchFacilityPanel.getElement().getParentElement().getStyle().setOpacity(0.9);
}
});
// layersDDB.setToggle(true);
bindEvents();
}
/**
* Bind events.
*/
private void bindEvents() {
linkLayers.addClickHandler(new ClickHandler() {
@ -190,17 +194,17 @@ public class GeonaDataViewMainPanel extends Composite {
}
}
});
searchFacilityButton.addDomHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
//event.preventDefault();
// event.preventDefault();
event.stopPropagation();
}
}, ClickEvent.getType());
}
/**
@ -217,6 +221,9 @@ public class GeonaDataViewMainPanel extends Composite {
}
/**
* Sets the overlay panel max height.
*/
private void setOverlayPanelMaxHeight() {
String overlMH = mapPanel.getOffsetHeight() - 130 + "px";
@ -311,11 +318,11 @@ public class GeonaDataViewMainPanel extends Composite {
/**
* Show as details.
*
* @param concessioneDV the concessione DV
* @param geonaItemRef the geona item ref
* @param result the result
* @param geonaItemRef the geona item ref
*/
public void showAsDetails(ConcessioneDV concessioneDV, GeoNaItemRef geonaItemRef) {
detailsPanel.showDetailsFor(concessioneDV, geonaItemRef);
public void showAsDetails(ProjectView result, GeoNaItemRef geonaItemRef) {
detailsPanel.showDetailsFor(result, geonaItemRef);
}
@ -327,13 +334,14 @@ public class GeonaDataViewMainPanel extends Composite {
}
/**
* Gets the displyed record.
* Gets the displayed record.
*
* @return the displyed record
* @return the displayed record
*/
public RecordDV getDisplayedRecord() {
return detailsPanel.getDisplayedRecord();
public ProjectView getDisplayedRecord() {
return detailsPanel.getDisplayedProject();
}
/**
@ -361,6 +369,9 @@ public class GeonaDataViewMainPanel extends Composite {
// layersDDBClickEvent();
}
/**
* Layers DDB click event.
*/
private void layersDDBClickEvent() {
linkLayers.fireEvent(new GwtEvent<ClickHandler>() {
@Override
@ -386,6 +397,11 @@ public class GeonaDataViewMainPanel extends Composite {
// layersDDBClickEvent();
}
/**
* Sets the map attribution.
*
* @param attribution the new map attribution
*/
public void setMapAttribution(String attribution) {
panelAttribution.clear();
Label label = new Label("Base Map Credits");
@ -393,39 +409,43 @@ public class GeonaDataViewMainPanel extends Composite {
panelAttribution.add(label);
panelAttribution.add(p);
}
/**
* Sets the base layers.
*
* @param listBaseLayers the new base layers
*/
public void setBaseLayers(List<BaseMapLayer> listBaseLayers) {
if(listBaseLayers==null)
if (listBaseLayers == null)
return;
int i = 0;
for (BaseMapLayer baseMapLayer : listBaseLayers) {
RadioButton radio = new RadioButton("base-layer");
radio.setText(baseMapLayer.getName());
if(i==0) {
if (i == 0) {
radio.setValue(true, false);
}
radio.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
applicationBus.fireEvent(new ChangeMapLayerEvent(baseMapLayer));
}
});
SimplePanel sp = new SimplePanel(radio);
sp.getElement().addClassName("form-inline");
sp.getElement().addClassName("map-layers-radio");
panelBaseLayers.add(sp);
i++;
}
}
}
}

@ -6,21 +6,15 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
import org.gcube.application.geoportalcommon.shared.ItemField;
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
import org.gcube.application.geoportalcommon.shared.SearchingFilter.LOGICAL_OP;
import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER;
import org.gcube.application.geoportalcommon.shared.WhereClause;
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
import org.gcube.portlets.user.geoportaldataviewer.client.events.SearchPerformedEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowPopupOnCentroiEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon;
import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil;
import com.github.gwtbootstrap.client.ui.Alert;
import com.github.gwtbootstrap.client.ui.Button;
@ -30,7 +24,6 @@ import com.github.gwtbootstrap.client.ui.NavLink;
import com.github.gwtbootstrap.client.ui.TextBox;
import com.github.gwtbootstrap.client.ui.constants.AlertType;
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.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
@ -44,7 +37,6 @@ import com.google.gwt.uibinder.client.UiField;
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.FlexTable;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
@ -85,9 +77,9 @@ public class SearchFacilityUI extends Composite {
@UiField
HorizontalPanel toogleSortBy;
private List<ItemField> searchForFields;
private List<ItemFieldDV> searchForFields;
private List<ItemField> sortByFields;
private List<ItemFieldDV> sortByFields;
private SearchingFilter currentSortFilter;
@ -117,7 +109,7 @@ public class SearchFacilityUI extends Composite {
* @param searchForFields the search for fields
* @param initialSortFilter the initial sort filter
*/
public SearchFacilityUI(HandlerManager appManagerBus, List<ItemField> sortByFields, List<ItemField> searchForFields,
public SearchFacilityUI(HandlerManager appManagerBus, List<ItemFieldDV> sortByFields, List<ItemFieldDV> searchForFields,
SearchingFilter initialSortFilter) {
initWidget(uiBinder.createAndBindUi(this));
this.searchForFields = searchForFields;
@ -140,7 +132,7 @@ public class SearchFacilityUI extends Composite {
* @param direction the direction
* @return the string
*/
private String toLabelFilter(ItemField itemField, ORDER direction) {
private String toLabelFilter(ItemFieldDV itemField, ORDER direction) {
String labelFilter = itemField.getDisplayName() + LABEL_FILTER_SEPARATOR + direction.name();
return labelFilter;
}
@ -150,7 +142,7 @@ public class SearchFacilityUI extends Composite {
*/
private void bindEvents() {
for (ItemField record_FIELD : sortByFields) {
for (ItemFieldDV record_FIELD : sortByFields) {
if(record_FIELD.isSortable()) {
String labelASC = toLabelFilter(record_FIELD, ORDER.ASC);
String labelDESC = toLabelFilter(record_FIELD, ORDER.DESC);
@ -169,7 +161,7 @@ public class SearchFacilityUI extends Composite {
}
});
for (ItemField record_FIELD : searchForFields) {
for (ItemFieldDV record_FIELD : searchForFields) {
GWT.log("search for: "+record_FIELD);
if(record_FIELD.isSearchable()) {
listBoxSearchFor.addItem(record_FIELD.getDisplayName());
@ -264,7 +256,11 @@ public class SearchFacilityUI extends Composite {
@Override
public void onSuccess(ResultSetPaginatedData result) {
Window.alert("searchConcessioni must be revisited");
/*
appManagerBus.fireEvent(new SearchPerformedEvent(result.getData(),false));
setSearchEnabled(true);
latestResult = result;
@ -306,7 +302,7 @@ public class SearchFacilityUI extends Composite {
}
i = 1;
for (ConcessioneDV concessione : result.getData()) {
for (DocumentDV concessione : result.getData()) {
int j = -1;
NavLink locateOnMap = new NavLink("Show");
@ -344,32 +340,13 @@ public class SearchFacilityUI extends Composite {
ft.setWidget(i, ++j, new HTML(toDisplayList(concessione.getParoleChiaveICCD())));
}
// List<UploadedImageDV> listImg = concessione.getImmaginiRappresentative();
// GWT.log(listImg.toString());
// boolean imagePreviewFound = false;
// if (listImg != null && listImg.size() > 0) {
//
// UploadedImageDV uImg = listImg.get(0);
//
// if (uImg != null && uImg.getListWsContent() != null
// && uImg.getListWsContent().size() > 0) {
// WorkspaceContentDV wsc = uImg.getListWsContent().get(0);
// String image = "<img style=\"width:50px;height:50px;\" src='" + wsc.getLink()
// + "' alt='" + wsc.getName() + "'>";
// ft.setWidget(i, 2, new HTML(image));
// imagePreviewFound = true;
// }
// }
//
// if (!imagePreviewFound) {
// ft.setWidget(i, 2, new Image(GNAImages.ICONS.italyIcon()));
// }
i++;
}
panelResults.add(ft);
*/
}
});
@ -421,8 +398,8 @@ public class SearchFacilityUI extends Composite {
SearchingFilter sortFilter = null;
try {
ItemField recordField = null;
for (ItemField value : sortByFields) {
ItemFieldDV recordField = null;
for (ItemFieldDV value : sortByFields) {
if (array[0].equalsIgnoreCase(value.getDisplayName())) {
recordField = value;
break;
@ -451,7 +428,7 @@ public class SearchFacilityUI extends Composite {
List<String> listOfSeachingFields = new ArrayList<String>();
for (ItemField recordField : searchForFields) {
for (ItemFieldDV recordField : searchForFields) {
if (recordField.getDisplayName().equals(listBoxSearchFor.getSelectedValue())) {
listOfSeachingFields = recordField.getJsonFields();
continue;

@ -0,0 +1,201 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.gallery;
import java.util.Set;
import org.gcube.application.geoportalcommon.shared.geoportal.view.FilesetDV;
import org.gcube.application.geoportalcommon.shared.geoportal.view.PayloadDV;
import org.gcube.application.geoportalcommon.shared.geoportal.view.SectionView;
import org.gcube.application.geoportalcommon.shared.geoportal.view.SubDocumentView;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONParser;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.json.client.JSONValue;
import com.google.gwt.user.client.Random;
import com.google.gwt.user.client.ui.HTMLPanel;
/**
* The Class ImagesSectionGallery.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Jul 21, 2021
*/
public class ImagesSectionGallery {
private HTMLPanel galleryPanel;
private String galleryDivId;
private SectionView sectionView;
/**
* Show gallery.
*
* @param json_array_images the json array images
* @param galleryDivId the gallery div id
*/
private native void showGallery(JavaScriptObject json_array_images, String galleryDivId) /*-{
console.log("showing: " + json_array_images)
var waitForJQuery = setInterval(
function() {
if (typeof $wnd.$ != 'undefined') {
$wnd
.$("#" + galleryDivId)
.nanogallery2(
{
thumbnailHeight : '200 XS150 SM150', // RESPONSIVE THUMBNAIL HEIGHT: default=200px, XS resolution=150px, SM resolution=150px
thumbnailWidth : '218 XS150 SM150', // RESPONSIVE THUMBNAIL WIDTH: auto
thumbnailAlignment : 'left',
thumbnailBorderHorizontal : 0,
thumbnailBorderVertical : 0,
thumbnailGutterWidth : '10 XS10 SM10',
thumbnailGutterHeight : '10 XS10 SM10',
// THUMBNAIL TOOLS & LABEL
thumbnailLabel : {
display : true,
position : 'onBottom',
align : 'left'
},
thumbnailToolbarImage : {
bottomLeft : 'display'
},
// replace the default DISPLAY tool icon
icons : {
thumbnailDisplay : '<i class="fa fa-long-arrow-right" aria-hidden="true"></i> display'
},
// DISPLAY ANIMATION
galleryDisplayTransition : 'slideUp',
galleryDisplayTransitionDuration : 1000,
thumbnailDisplayTransition : 'scaleDown',
thumbnailDisplayTransitionDuration : 300,
thumbnailDisplayInterval : 50,
// THUMBNAIL'S HOVER ANIMATION
//thumbnailBuildInit2 : 'tools_font-size_1.5em|title_font-size_1.5em',
thumbnailHoverEffect2 : 'imageScaleIn80|tools_opacity_0_1|tools_translateX_-30px_0px|title_opacity_1_0|title_translateX_0px_-30px',
touchAnimation : true,
touchAutoOpenDelay : 800,
// GALLERY THEME
galleryTheme : {
thumbnail : {
borderRadius : '2px !important',
background : '#ffffff !important',
titleShadow : 'none !important',
titleColor : '#696969 !important',
labelBackground : '#f3f3f3 !important'
},
thumbnailIcon : {
color : '#000',
shadow : 'none'
},
},
viewerToolbar : {
display : true,
standard : 'minimizeButton, label',
minimized : 'minimizeButton, label, fullscreenButton, downloadButton'
},
viewerTools : {
topLeft : 'pageCounter',
topRight : 'playPauseButton, zoomButton, fullscreenButton, downloadButton, closeButton'
},
// DEEP LINKING
locationHash : false,
items : json_array_images
})
clearInterval(waitForJQuery);
}
}, 200);
}-*/;
/**
* Instantiates a new images section gallery.
*
* @param sectionView the section view
*/
public ImagesSectionGallery(SectionView sectionView) {
this.galleryDivId = "nanogallery" + Random.nextInt() + Random.nextInt();
this.galleryPanel = new HTMLPanel("<div id='" + galleryDivId + "'></div>");
this.sectionView = sectionView;
}
/**
* Gets the gallery panel.
*
* @return the gallery panel
*/
public HTMLPanel getGalleryPanel() {
return galleryPanel;
}
/**
* Fill gallery.
*/
public void fillGallery() {
JSONArray jsonArray = new JSONArray();
int index = 0;
for (SubDocumentView subdoc : sectionView.getListSubDocuments()) {
JSONValue meta = JSONParser.parseStrict(subdoc.getMetadataAsJSON());
for (FilesetDV image : subdoc.getListImages()) {
if (image.getListPayload() != null) {
for (PayloadDV payloadDV : image.getListPayload()) {
JSONObject json = new JSONObject();
json.put("src", new JSONString(payloadDV.getLink()));
json.put("srct", new JSONString(payloadDV.getLink()));
json.put("downloadURL", new JSONString(payloadDV.getLink()));
json.put("title", new JSONString(getFirstValueOfJSON(meta)));
json.put("description", new JSONString(meta.toString()));
jsonArray.set(index, json);
index++;
}
}
}
}
showGallery(jsonArray.getJavaScriptObject(), galleryDivId);
}
/**
* Gets the first value of JSON.
*
* @param metadata the metadata
* @return the first value of JSON
*/
public String getFirstValueOfJSON(JSONValue metadata) {
String value = "";
if (metadata == null)
return value;
if (metadata.isArray() != null) {
JSONArray array = (JSONArray) metadata;
for (int i = 0; i < array.size(); i++) {
JSONObject object = (JSONObject) array.get(i);
Set<String> set = object.keySet();
value = object.get(set.iterator().next()).toString();
}
} else if (metadata.isObject() != null) {
JSONObject object = (JSONObject) metadata;
Set<String> set = object.keySet();
value = object.get(set.iterator().next()).toString();
} else if (metadata.isString() != null) {
value = metadata.toString();
}
return value;
}
}

@ -0,0 +1,176 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.application.geoportalcommon.shared.geoportal.view.SectionView;
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;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.dialogs.DialogShareableLink;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil;
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.client.ui.map.MapView;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.CustomFlexTable;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.PageHeader;
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.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
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.HTMLPanel;
import com.google.gwt.user.client.ui.Widget;
import ol.Coordinate;
public class ProjectViewer extends Composite {
private static ProjectViewerUiBinder uiBinder = GWT.create(ProjectViewerUiBinder.class);
interface ProjectViewerUiBinder extends UiBinder<Widget, ProjectViewer> {
}
@UiField
PageHeader title;
@UiField
HTMLPanel pageViewDetails;
@UiField
Button shareButton;
@UiField
Button expandButton;
private ProjectView projectView;
private CustomFlexTable customTable = new CustomFlexTable();
private GeoNaItemRef geonaItemRef;
private String myLogin;
private boolean viewImageButtonVisible = true;
private boolean openImageButtonVisible = true;
private ProjectViewer() {
initWidget(uiBinder.createAndBindUi(this));
pageViewDetails.getElement().setId("page-view-details");
}
public ProjectViewer(GeoNaItemRef item, ProjectView projectView) {
this(item, projectView, true, true);
}
public ProjectViewer(GeoNaItemRef item, ProjectView projectView, boolean viewImageButtonVisible,
boolean openImageButtonVisible) {
this();
GWT.log("Rendering " + projectView.getTheProjectDV().getId());
this.projectView = projectView;
this.geonaItemRef = item;
this.viewImageButtonVisible = viewImageButtonVisible;
this.openImageButtonVisible = openImageButtonVisible;
title.setText("Project: "+projectView.getTheProjectDV().getProfileID());
shareButton.setType(ButtonType.LINK);
shareButton.setIcon(IconType.SHARE);
shareButton.setTitle("Get a link to share with...");
shareButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
DialogShareableLink dg = new DialogShareableLink(geonaItemRef, null);
}
});
expandButton.setType(ButtonType.LINK);
expandButton.setIcon(IconType.EXPAND);
expandButton.setTitle("Show this view in new Window");
expandButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Window.alert("Expand must be revisited");
/*
ProjectViewer cv = new ProjectViewer(geonaItemRef, concessioneDV, false, openImageButtonVisible);
cv.setExpandViewButtonVisible(false);
int width = Window.getClientWidth() * 75 / 100;
int height = Window.getClientHeight() * 70 / 100;
ModalWindow mw = new ModalWindow(concessioneDV.getNome(), width, height);
mw.add(cv);
mw.setCaller(ProjectViewer.this);
// mw.setWidth(900);
mw.show();
*/
}
});
GeoportalDataViewerServiceAsync.Util.getInstance().getMyLogin(new AsyncCallback<String>() {
@Override
public void onSuccess(String result) {
myLogin = result;
addCentroidMap();
}
@Override
public void onFailure(Throwable caught) {
}
});
for (SectionView sectionView : projectView.getListSections()) {
SectionViewer sectionViewer = new SectionViewer(sectionView);
pageViewDetails.add(sectionViewer);
}
}
private void addCentroidMap() {
Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY);
Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857);
MapView mapView = new MapView(transformedCenterCoordinate,
GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON, "70%", "300px");
Window.alert("addCentroidMap must be revisited");
// if (concessioneDV != null && concessioneDV.getCentroidLat() != null
// && concessioneDV.getCentroidLong() != null) {
// Coordinate coord = new Coordinate(concessioneDV.getCentroidLong(), concessioneDV.getCentroidLat());
// Coordinate transfCoord = MapUtils.transformCoordiante(coord, MAP_PROJECTION.EPSG_4326.getName(),
// MAP_PROJECTION.EPSG_3857.getName());
// // Coordinate invertedCoordinate = MapUtils.reverseCoordinate(coord);
// boolean authenticatedUser = myLogin != null ? true : false;
// mapView.addMarker(transfCoord, authenticatedUser);
// mapViewPanel.add(mapView);
// } else if (concessioneDV != null) {
// GeoportalDataViewerConstants
// .printJs("I cannot add centroid as maker one or both coordinates are null. Lat: "
// + concessioneDV.getCentroidLong() + ", Long:" + concessioneDV.getCentroidLat());
// }
}
public ProjectView getProjectView() {
return projectView;
}
protected void setExpandViewButtonVisible(boolean bool) {
expandButton.setVisible(bool);
}
}

@ -0,0 +1,44 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
.margin-left-10 {
margin-left: 10px;
}
.font-size-h1-22 h1 {
font-size: 22px;
}
.align-to-right {
right: 20px;
position: absolute;
}
.the-title h1 {
font-size: 28px;
}
.margin-bottom-10 {
margin-bottom: 10px;
}
.width-100 {
width: 100%;
}
</ui:style>
<g:HTMLPanel ui:field="pageViewDetails">
<!-- <g:HTMLPanel ui:field="sharePanel" -->
<!-- addStyleNames="{style.align-to-right}"> -->
<!-- </g:HTMLPanel> -->
<b:PageHeader ui:field="title"
addStyleNames="{style.the-title}"></b:PageHeader>
<g:HorizontalPanel
addStyleNames="{style.margin-bottom-10}">
<b:Button ui:field="shareButton">Share</b:Button>
<b:Button ui:field="expandButton">Expand</b:Button>
</g:HorizontalPanel>
</g:HTMLPanel>
</ui:UiBinder>

@ -0,0 +1,9 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
</ui:style>
<g:HTMLPanel ui:field="recordDVPanel">
</g:HTMLPanel>
</ui:UiBinder>

@ -0,0 +1,65 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.geoportal.view.SectionView;
import org.gcube.application.geoportalcommon.shared.geoportal.view.SubDocumentView;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.gallery.ImagesSectionGallery;
import com.github.gwtbootstrap.client.ui.PageHeader;
import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget;
public class SectionViewer extends Composite {
private static SectionViewerUiBinder uiBinder = GWT.create(SectionViewerUiBinder.class);
interface SectionViewerUiBinder extends UiBinder<Widget, SectionViewer> {
}
private SectionView sectionView;
@UiField
HTMLPanel sectionPanelContainer;
@UiField
PageHeader sectionTitle;
public SectionViewer(SectionView sectionView) {
initWidget(uiBinder.createAndBindUi(this));
this.sectionView = sectionView;
List<SubDocumentView> subDocuments = sectionView.getListSubDocuments();
sectionTitle.setTitle(sectionView.getSectionTitle());
sectionTitle.setText(sectionView.getSectionTitle());
boolean displayAsGallery = false;
for (SubDocumentView subDocumentView : subDocuments) {
if (subDocumentView.getListImages() != null && subDocumentView.getListImages().size() > 0) {
displayAsGallery = true;
break;
}
}
//Displaying the whole section as a Gallery
if (displayAsGallery) {
ImagesSectionGallery sectionGallery = new ImagesSectionGallery(sectionView);
sectionPanelContainer.add(sectionGallery.getGalleryPanel());
sectionGallery.fillGallery();
} else {
for (SubDocumentView subDocumentView : subDocuments) {
String table = GeoportalDataViewerConstants.jsonToTableHTML(subDocumentView.getMetadataAsJSON());
sectionPanelContainer.add(new HTML(table));
}
}
}
}

@ -0,0 +1,38 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
.margin-left-10 {
margin-left: 10px;
}
.font-size-h1-22 h1 {
font-size: 22px;
}
.align-to-right {
right: 20px;
position: absolute;
}
.the-title h1 {
font-size: 28px;
}
.margin-bottom-10 {
margin-bottom: 10px;
}
.width-100 {
width: 100%;
}
</ui:style>
<g:HTMLPanel ui:field="sectionPanelContainer">
<g:HTMLPanel
addStyleNames="{style.margin-left-10}">
<b:PageHeader addStyleNames="{style.font-size-h1-22}" ui:field="sectionTitle"></b:PageHeader>
</g:HTMLPanel>
</g:HTMLPanel>
</ui:UiBinder>

@ -14,7 +14,7 @@ import com.google.gwt.user.client.ui.HTMLPanel;
/**
* The Class ImagesGallery.
* The Class ImagesSectionGallery.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*

@ -0,0 +1,68 @@
package org.gcube.portlets.user.geoportaldataviewer.server;
import java.io.Serializable;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
public class GcubeProfilesMetadataForUCD implements Serializable {
/**
*
*/
private static final long serialVersionUID = -8953445402356442872L;
private String profileID;
private GcubeProfileDV gcubeProfile;
private List<MetaDataProfileBean> listMetadataProfileBean;
public GcubeProfilesMetadataForUCD() {
}
public GcubeProfilesMetadataForUCD(String profileID, GcubeProfileDV gcubeProfile,
List<MetaDataProfileBean> listMetadataProfileBean) {
this.profileID = profileID;
this.gcubeProfile = gcubeProfile;
this.listMetadataProfileBean = listMetadataProfileBean;
}
public String getProfileID() {
return profileID;
}
public GcubeProfileDV getGcubeProfile() {
return gcubeProfile;
}
public List<MetaDataProfileBean> getListMetadataProfileBean() {
return listMetadataProfileBean;
}
public void setProfileID(String profileID) {
this.profileID = profileID;
}
public void setGcubeProfile(GcubeProfileDV gcubeProfile) {
this.gcubeProfile = gcubeProfile;
}
public void setListMetadataProfileBean(List<MetaDataProfileBean> listMetadataProfileBean) {
this.listMetadataProfileBean = listMetadataProfileBean;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("GcubeProfilesMetadataForUCD [profileID=");
builder.append(profileID);
builder.append(", gcubeProfile=");
builder.append(gcubeProfile);
builder.append(", listMetadataProfileBean=");
builder.append(listMetadataProfileBean);
builder.append("]");
return builder.toString();
}
}

@ -0,0 +1,26 @@
package org.gcube.portlets.user.geoportaldataviewer.server;
import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@WebListener
public class GeoportalDataViewerHttpSessionListener implements HttpSessionListener {
private static final Logger LOG = LoggerFactory.getLogger(GeoportalDataViewerHttpSessionListener.class);
@Override
public void sessionDestroyed(HttpSessionEvent event) {
LOG.info("sessionDestroyed called");
}
@Override
public void sessionCreated(HttpSessionEvent arg0) {
LOG.info("sessionCreated called. Session id is: "+arg0.getSession().getId());
new GeoportalDataViewerServiceImpl().preloadgCubeProfilesForUCDs();
}
}

@ -10,31 +10,43 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.gcube.application.geoportal.common.model.legacy.Concessione;
import org.gcube.application.geoportal.common.model.legacy.LayerConcessione;
import org.gcube.application.geoportal.common.model.legacy.UploadedImage;
import org.gcube.application.geoportalcommon.ConvertToDataViewModel;
import org.bson.Document;
import org.gcube.application.geoportal.client.utils.Serialization;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.HandlerDeclaration;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
import org.gcube.application.geoportalcommon.GeoportalCommon;
import org.gcube.application.geoportalcommon.MongoServiceCommon;
import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
import org.gcube.application.geoportalcommon.geoportal.UseCaseDescriptorCaller;
import org.gcube.application.geoportalcommon.geoportal.access.GeportalCheckAccessPolicy;
import org.gcube.application.geoportalcommon.geoportal.serdes.Payload;
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
import org.gcube.application.geoportalcommon.shared.ItemField;
import org.gcube.application.geoportalcommon.shared.LayerItem;
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.FilePathDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_CONFIGURATION_TYPE;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA_HANDLER;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.HandlerDeclarationDV;
import org.gcube.application.geoportalcommon.shared.geoportal.view.FilesetDV;
import org.gcube.application.geoportalcommon.shared.geoportal.view.PayloadDV;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.application.geoportalcommon.shared.geoportal.view.SectionView;
import org.gcube.application.geoportalcommon.shared.geoportal.view.SubDocumentView;
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
import org.gcube.application.geoportalcommon.shared.products.BaseConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.model.AbstractRelazioneScavoDV;
import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.model.RelazioneScavoDV;
import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV;
import org.gcube.application.geoportalcommon.util.URLParserUtil;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerService;
import org.gcube.portlets.user.geoportaldataviewer.server.gis.FeatureParser;
import org.gcube.portlets.user.geoportaldataviewer.server.gis.WMSUrlValidator;
import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.ConcessioniMongoServiceIdentityProxy;
import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accesspolicy.GeoNACheckAccessPolicy;
import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.GeoportalServiceIdentityProxy;
import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
@ -44,15 +56,25 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformation
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.Styles;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.ZAxis;
import org.gcube.portlets.user.urlshortener.UrlShortener;
import org.gcube.portlets.widgets.mpformbuilder.server.MetadataProfileFormBuilderServiceImpl;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper;
import org.gcube.spatial.data.geoutility.GeoNcWMSMetadataUtility;
import org.gcube.spatial.data.geoutility.bean.LayerStyles;
import org.gcube.spatial.data.geoutility.bean.LayerZAxis;
import org.gcube.spatial.data.geoutility.bean.WmsParameters;
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
import org.json.JSONArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.spi.json.JsonOrgJsonProvider;
/**
* The server side implementation of the RPC service.
@ -70,6 +92,38 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
private static final String CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE = "MAP_IMAGE_PREVIEW_FOR_CONCESSIONE";
public static final String JSON_$_POINTER = "$";
public static enum COMMON_IMAGES_FORMAT {
gif, png, jpeg, jpg, bmp, tif, tiff, svg, avif, webp
}
public static class ImageDetector {
private static String[] getNames(Class<? extends Enum<?>> e) {
return Arrays.stream(e.getEnumConstants()).map(Enum::name).toArray(String[]::new);
}
public static List<String> listFormatImages;
static {
String[] arrayImgs = ImageDetector.getNames(COMMON_IMAGES_FORMAT.class);
listFormatImages = Arrays.asList(arrayImgs);
}
public static boolean isImage(String mimeType) {
if (mimeType == null || mimeType.isEmpty())
return false;
String inputImageFormat = mimeType.replaceAll("image/", "");
return listFormatImages.contains(inputImageFormat);
}
}
/**
* Gets the GNA data viewe config profile.
*
@ -221,83 +275,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
return getUploadedImagesForId(this.getThreadLocalRequest(), itemType, itemId, maxImages);
}
/**
* Gets the layers for id.
*
* @param itemType the item type
* @param itemId the item id
* @return the layers for id
* @throws Exception the exception
*/
@Override
public List<LayerConcessioneDV> getLayersForId(String itemType, String itemId) throws Exception {
LOG.info("getLayersForId [itemId: " + itemId + ", itemType: " + itemType + "] called");
if (itemType == null)
throw new Exception("Invalid parameter. The itemType is null");
if (itemId == null)
throw new Exception("Invalid parameter. The itemId is null");
List<LayerConcessioneDV> listLayers = null;
try {
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
String userName = null;
try {
userName = SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername();
} catch (Exception e) {
LOG.info("User not found in session, the userName for cecking policy will be null");
}
if (itemType.equalsIgnoreCase("concessione")) {
LOG.info("Trying to get concessione for id " + itemId);
ConcessioniMongoServiceIdentityProxy cms = new ConcessioniMongoServiceIdentityProxy(
this.getThreadLocalRequest());
Concessione concessione = cms.getItemById(itemId);
BaseConcessioneDV baseConcessione = ConvertToDataViewModel.toBaseConcessione(concessione);
if (concessione != null) {
LOG.info("For id " + itemId + ", got concessione " + concessione.getNome() + " from service");
listLayers = new ArrayList<LayerConcessioneDV>();
if (concessione.getPianteFineScavo() != null) {
for (LayerConcessione lc : concessione.getPianteFineScavo()) {
if (GeoNACheckAccessPolicy.isAccessible(lc.getPolicy().name(), userName)) {
listLayers.add(ConvertToDataViewModel.toLayerConcessione(lc, baseConcessione));
}
}
LayerConcessione lcPosizionamento = concessione.getPosizionamentoScavo();
if (lcPosizionamento != null) {
if (GeoNACheckAccessPolicy.isAccessible(lcPosizionamento.getPolicy().name(), userName)) {
LayerConcessioneDV thePosizScavo = ConvertToDataViewModel
.toLayerConcessione(lcPosizionamento, baseConcessione);
if (thePosizScavo != null)
listLayers.add(thePosizScavo);
}
}
}
} else
throw new Exception("Concessione with id '" + itemId + "' not available");
}
LOG.info("For id " + itemId + ", returning " + listLayers.size() + " layer/s");
return listLayers;
} catch (Exception e) {
String erroMsg = "Layers are not available for " + Concessione.class.getSimpleName() + " with id " + itemId;
LOG.error(erroMsg, e);
throw new Exception(erroMsg);
}
}
/**
* Gets the concessione for id.
@ -310,6 +288,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
public ConcessioneDV getConcessioneForId(String mongoId) throws Exception {
LOG.info("getConcessioneForId " + mongoId + " called");
throw new Exception("getConcessioneForId must be removed!");
/*
ConcessioneDV concessionDV = null;
if (mongoId == null)
@ -318,8 +298,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
try {
LOG.info("Trying to get record for id " + mongoId);
ConcessioniMongoServiceIdentityProxy cms = new ConcessioniMongoServiceIdentityProxy(
this.getThreadLocalRequest());
GeoportalServiceIdentityProxy cms = new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
Concessione concessione = cms.getItemById(mongoId);
LOG.info("Got concessione for mongoId: " + mongoId);
@ -414,7 +393,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
LOG.error(erroMsg, e);
throw new Exception(erroMsg);
}
*/
}
/**
@ -648,7 +627,9 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
String itemId, Integer maxImages) throws Exception {
LOG.info("getUploadedImagesForId [itemId: " + itemId + ", itemType: " + itemType + "] called");
if (itemType == null)
throw new Exception("getUploadedImagesForId must be revisited");
/*if (itemType == null)
throw new Exception("Invalid parameter. The itemType is null");
if (itemId == null)
@ -661,7 +642,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
if (itemType.equalsIgnoreCase("concessione")) {
LOG.info("Trying to get concessione for id " + itemId);
ConcessioniMongoServiceIdentityProxy cms = new ConcessioniMongoServiceIdentityProxy(httpServletRequest);
GeoportalServiceIdentityProxy cms = new GeoportalServiceIdentityProxy(httpServletRequest);
Concessione concessione = cms.getItemById(itemId);
if (concessione != null) {
LOG.info("For id " + itemId + ", got concessione " + concessione.getNome() + " from service");
@ -687,7 +668,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
+ Concessione.class.getSimpleName() + " with id " + itemId;
LOG.error(erroMsg, e);
throw new Exception(erroMsg);
}
}*/
}
@ -717,13 +698,51 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
* @throws Exception the exception
*/
@Override
public List<ItemField> listOfFieldsForSearching() throws Exception {
public List<ItemFieldDV> listOfFieldsForSearching() throws Exception {
LOG.info("listOfFieldsForSearching called");
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
GNADataViewerConfigProfile profile = getGNADataVieweConfigProfile();
return profile.getListItemFields();
}
/**
*
*
*
*
*
*
*
*
*
*
*
*
*
*
* NEW CODE HERE
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
/**
* Gets the list concessioni.
*
@ -740,18 +759,22 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
LOG.info("getListConcessioni called wit start: " + start + ", limit: " + limit + ", filter: " + filter);
try {
// setting identity as D4S User or KC client
new ConcessioniMongoServiceIdentityProxy(this.getThreadLocalRequest());
SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
MongoServiceCommon serviceCommon = new MongoServiceCommon();
// TODO MUST BE REPLACED BY COUNT
List<Concessione> listOfConcessioni = SessionUtil.getListOfConcessioni(getThreadLocalRequest(),
reloadFromService);
int listConcessioniSize = listOfConcessioni.size();
ResultSetPaginatedData searchedData = serviceCommon.queryOnMongo(listConcessioniSize, start, limit, filter,
"concessione");
return searchedData;
throw new Exception("getListConcessioni must be revisited!!!!");
/*
*
* // setting identity as D4S User or KC client new
* GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
* SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
* MongoServiceCommon serviceCommon = new MongoServiceCommon(); // TODO MUST BE
* REPLACED BY COUNT List<Concessione> listOfConcessioni =
* SessionUtil.getListOfConcessioni(getThreadLocalRequest(), reloadFromService);
* int listConcessioniSize = listOfConcessioni.size();
*
* ResultSetPaginatedData searchedData =
* serviceCommon.queryOnMongo(listConcessioniSize, start, limit, filter,
* "concessione"); return searchedData;
*/
} catch (Exception e) {
LOG.error("Error on loading paginated and filtered list of concessioni: ", e);
@ -760,4 +783,519 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
}
/**
* Preloadg cube profiles for UC ds.
*/
public void preloadgCubeProfilesForUCDs() {
LOG.info("preloadgCubeProfilesForUCDs called");
try {
String currentContext = SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
LOG.info("preloadgCubeProfilesForUCDs context: "+currentContext);
UseCaseDescriptorCaller clientUCD = GeoportalClientCaller.useCaseDescriptors();
SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
List<UseCaseDescriptor> listUCDs = clientUCD.getList();
LOG.debug("listUCDs: "+listUCDs);
for (UseCaseDescriptor ucd : listUCDs) {
LOG.info("Loaded UCD for ID: " + ucd.getId());
String profileID = ucd.getId();
GEOPORTAL_DATA_HANDLER theHandler = GEOPORTAL_DATA_HANDLER.geoportal_data_entry;
List<HandlerDeclaration> handlers = ucd.getHandlersByType(theHandler.getType());
if (handlers.size() == 0) {
LOG.warn("No handler " + theHandler + "found into UCD " + ucd.getId() + ", continue...");
continue;
}
// Loading Handler gcube_profiles
HandlerDeclaration dataEntryHandler = handlers.get(0);
HandlerDeclarationDV handlerGcubeProfiles = ConvertToDataValueObjectModel
.toHandlerDeclarationDV(dataEntryHandler, ucd, GEOPORTAL_CONFIGURATION_TYPE.gcube_profiles);
LOG.debug("Handler " + GEOPORTAL_CONFIGURATION_TYPE.gcube_profiles + " for PROFILE_ID: " + ucd.getId());
LOG.debug("" + handlerGcubeProfiles);
ConfigurationDV<?> config = handlerGcubeProfiles.getConfiguration();
// List of gCube Profiles defined in the UCD
List<GcubeProfileDV> listGcubeProfiles = (List<GcubeProfileDV>) config.getConfiguration();
LOG.debug("List of GcubeProfileDV are: " + listGcubeProfiles);
List<GcubeProfilesMetadataForUCD> listProfilesBean = new ArrayList<GcubeProfilesMetadataForUCD>();
// Loading Metadata Profile from IS
MetadataProfileFormBuilderServiceImpl metaProfileBUilder = new MetadataProfileFormBuilderServiceImpl();
LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>> linkedMap_UCDId_gCubeProfiles = new LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>>();
for (GcubeProfileDV gcubeProfileDV : listGcubeProfiles) {
String context = SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
GcubeProfilesMetadataForUCD gCubeProfileMetadataForUCD = new GcubeProfilesMetadataForUCD();
List<MetaDataProfileBean> listProfiles = metaProfileBUilder.getProfilesInTheScopeForName(context,
gcubeProfileDV.getGcubeSecondaryType(), gcubeProfileDV.getGcubeName());
String key = gcubeProfileDV.getGcubeSecondaryType() + gcubeProfileDV.getGcubeName();
LOG.debug("for key: " + key + " readi profiles: " + listGcubeProfiles);
gCubeProfileMetadataForUCD.setGcubeProfile(gcubeProfileDV);
gCubeProfileMetadataForUCD.setListMetadataProfileBean(listProfiles);
listProfilesBean.add(gCubeProfileMetadataForUCD);
}
linkedMap_UCDId_gCubeProfiles.put(ucd.getId(), listProfilesBean);
for (String key : linkedMap_UCDId_gCubeProfiles.keySet()) {
LOG.debug("For key '" + key + "' got profiles: " + linkedMap_UCDId_gCubeProfiles.get(key));
}
SessionUtil.setMap_UCDId_gCubeProfiles(getThreadLocalRequest(), profileID,
linkedMap_UCDId_gCubeProfiles);
}
} catch (Exception e) {
String erroMsg = "Error occurred on preloadgCubeProfilesForUCDs: ";
LOG.error(erroMsg, e);
}
}
/**
* Gets the layers for id.
*
* @param itemType the item type
* @param itemId the item id
* @return the layers for id
* @throws Exception the exception
*/
@Override
public List<LayerConcessioneDV> getLayersForId(String itemType, String itemId) throws Exception {
LOG.info("getLayersForId [itemId: " + itemId + ", itemType: " + itemType + "] called");
throw new Exception("getLayersForId must be revisited!!!");
/*
* if (itemType == null) throw new
* Exception("Invalid parameter. The itemType is null");
*
* if (itemId == null) throw new
* Exception("Invalid parameter. The itemId is null");
*
* List<LayerConcessioneDV> listLayers = null;
*
* try {
*
* SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); String
* userName = null; try { userName =
* SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername(); }
* catch (Exception e) { LOG.
* info("User not found in session, the userName for cecking policy will be null"
* ); }
*
* if (itemType.equalsIgnoreCase("concessione")) {
*
* LOG.info("Trying to get concessione for id " + itemId);
* GeoportalServiceIdentityProxy cms = new
* GeoportalServiceIdentityProxy(this.getThreadLocalRequest()); Concessione
* concessione = cms.getItemById(itemId);
*
* BaseConcessioneDV baseConcessione =
* ConvertToDataViewModel.toBaseConcessione(concessione); if (concessione !=
* null) { LOG.info("For id " + itemId + ", got concessione " +
* concessione.getNome() + " from service"); listLayers = new
* ArrayList<LayerConcessioneDV>(); if (concessione.getPianteFineScavo() !=
* null) {
*
* for (LayerConcessione lc : concessione.getPianteFineScavo()) { if
* (GeoNACheckAccessPolicy.isAccessible(lc.getPolicy().name(), userName)) {
* listLayers.add(ConvertToDataViewModel.toLayerConcessione(lc,
* baseConcessione)); } }
*
* LayerConcessione lcPosizionamento = concessione.getPosizionamentoScavo();
*
* if (lcPosizionamento != null) {
*
* if (GeoNACheckAccessPolicy.isAccessible(lcPosizionamento.getPolicy().name(),
* userName)) {
*
* LayerConcessioneDV thePosizScavo = ConvertToDataViewModel
* .toLayerConcessione(lcPosizionamento, baseConcessione); if (thePosizScavo !=
* null) listLayers.add(thePosizScavo); } }
*
* }
*
* } else throw new Exception("Concessione with id '" + itemId +
* "' not available"); } LOG.info("For id " + itemId + ", returning " +
* listLayers.size() + " layer/s"); return listLayers;
*
* } catch (Exception e) { String erroMsg = "Layers are not available for " +
* Concessione.class.getSimpleName() + " with id " + itemId; LOG.error(erroMsg,
* e); throw new Exception(erroMsg); }
*
*/
}
/**
* Gets the project view for id.
*
* @param profileID the profile ID
* @param projectID the project ID
* @return the project view for id
* @throws Exception the exception
*/
@Override
public ProjectView getProjectViewForId(String profileID, String projectID) throws Exception {
LOG.info("getProjectForId profileID: " + profileID + ", projectID: " + projectID + "called");
if (profileID == null || projectID == null)
throw new Exception("Invalid parameter. Either profileID or projectID is null");
try {
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
String userName = null;
try {
userName = SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername();
} catch (Exception e) {
LOG.info("User not found in session, the userName for cecking policy will be null");
}
LOG.info("Trying to get project for id " + profileID);
GeoportalServiceIdentityProxy cms = new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
ProjectDV theProjectDV = cms.getProjectByID(profileID, projectID);
String theWholeProjectAsJSON = theProjectDV.getTheDocument().getDocumentAsJSON();
LOG.debug("theProjectDV as JSON: " + theWholeProjectAsJSON);
LOG.debug("theProjectDV as MAP: " + theProjectDV.getTheDocument().getDocumentAsMap());
ProjectView projectView = new ProjectView();
projectView.setTheProjectDV(theProjectDV);
LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>> linkedMap_UCDId_gCubeProfiles = SessionUtil
.getMap_UCDId_gCubeProfiles(getThreadLocalRequest(), profileID);
if(linkedMap_UCDId_gCubeProfiles==null) {
preloadgCubeProfilesForUCDs();
linkedMap_UCDId_gCubeProfiles = SessionUtil
.getMap_UCDId_gCubeProfiles(getThreadLocalRequest(), profileID);
}
// NO UCD defined, applyong default
if (linkedMap_UCDId_gCubeProfiles.size() == 0) {
LOG.warn("No " + GEOPORTAL_CONFIGURATION_TYPE.gcube_profiles + " found in the UCD");
LOG.info("Applying default business logic to display the project");
SectionView sectionView = new SectionView();
sectionView.setSectionTitle("Document");
SubDocumentView subDocumentView = new SubDocumentView();
subDocumentView.setMetadataAsJSON(theProjectDV.getTheDocument().getDocumentAsJSON());
sectionView.addSubDocument(subDocumentView);
projectView.addSectionView(sectionView);
}
List<GcubeProfilesMetadataForUCD> listProfilesBean = linkedMap_UCDId_gCubeProfiles.get(profileID);
com.jayway.jsonpath.Configuration configuration = com.jayway.jsonpath.Configuration.builder()
.jsonProvider(new JsonOrgJsonProvider()).build();
// Reading the Project according to list of Profile defined in the UCD
for (GcubeProfilesMetadataForUCD gcubeProfileMetaForUCD : listProfilesBean) {
GcubeProfileDV gcubeProfileDV = gcubeProfileMetaForUCD.getGcubeProfile();
SectionView sectionView = new SectionView();
sectionView.setSectionTitle(gcubeProfileDV.getSectionTitle());
LOG.debug("\n\nThe profile is: " + gcubeProfileDV);
// Building JSON/section full PATH and section name
String sectionJSONPath = "";
String parentPathFromProfile = gcubeProfileDV.getParentName() == null ? ""
: gcubeProfileDV.getParentName();
String theSectionName = gcubeProfileDV.getSectionName();
if (theSectionName.compareTo(JSON_$_POINTER) == 0
|| theSectionName.compareTo(JSON_$_POINTER + ".") == 0) {
sectionJSONPath = JSON_$_POINTER;
theSectionName = "";
} else {
sectionJSONPath = String.format("%s%s",
parentPathFromProfile.endsWith(".") ? parentPathFromProfile : parentPathFromProfile + ".",
theSectionName);
}
LOG.debug("The sectionJSONPath is: " + sectionJSONPath);
JsonPath theSectionJsonPath = JsonPath.compile(sectionJSONPath);
Object data = theSectionJsonPath.read(theWholeProjectAsJSON, configuration);
LOG.debug("Data is instace of: " + data.getClass());
LOG.debug("data to string: " + data.toString());
// Splitting the General Document in bson.Document according to list of
// GcubeProfiles
List<Document> listBSONDocument = new ArrayList<Document>();
if (data instanceof org.json.JSONObject) {
String jsonString = data.toString();
LOG.debug("the JSON to string: " + jsonString);
Document sectionDoc = Document.parse(jsonString);
boolean isAccessibleSection = isAccessibleSectionAccordingToPolicy(sectionDoc, sectionJSONPath,
userName);
if (isAccessibleSection) {
listBSONDocument.add(sectionDoc);
}
} else if (data instanceof org.json.JSONArray) {
org.json.JSONArray dataArray = (org.json.JSONArray) data;
for (int i = 0; i < dataArray.length(); i++) {
String jsonString = dataArray.get(i).toString();
LOG.debug("the array " + i + " JSON to string: " + jsonString);
Document sectionDoc = Document.parse(jsonString);
boolean isAccessibleSection = isAccessibleSectionAccordingToPolicy(sectionDoc, sectionJSONPath,
userName);
if (isAccessibleSection) {
listBSONDocument.add(sectionDoc);
}
}
}
LOG.debug("Result for " + gcubeProfileDV.getSectionName() + " is: " + listBSONDocument);
List<MetaDataProfileBean> theProfileBeans = gcubeProfileMetaForUCD.getListMetadataProfileBean();
MetaDataProfileBean theProfileBean = theProfileBeans.get(0);
// For each bson.Document creating the SubDocumentView
for (int i = 0; i < listBSONDocument.size(); i++) {
Document fromSectionDoc = listBSONDocument.get(i);
SubDocumentView subDocumentView = new SubDocumentView();
Document toSectionDoc = new Document();
// Filling the SubDocumentView metadata with the metadataField.getFieldName()
// read from the Profile
for (MetadataFieldWrapper metadataField : theProfileBean.getMetadataFields()) {
String theFieldName = metadataField.getFieldId() != null ? metadataField.getFieldId()
: metadataField.getFieldName();
LOG.debug("reading theFieldName: " + theFieldName);
Object theOBJFieldValue = fromSectionDoc.get(theFieldName);
// NB: Using ALWAYS THE metadataField.getFieldName() as LABEL
toSectionDoc = sanitizeDocumentValue(toSectionDoc, metadataField.getFieldName(),
theOBJFieldValue);
}
String subToJSON = toSectionDoc.toJson();
LOG.debug("theSubSetionDoc is: " + subToJSON);
subDocumentView.setMetadataAsJSON(toSectionDoc.toJson());
// Reading filePaths
List<FilePathDV> filePaths = gcubeProfileDV.getFilePaths();
// READING fileset* field ACCORDING TO filePaths OF THE 'gcubeProfiles' CONFIG
if (filePaths != null) {
String fromSectionDocJSON = fromSectionDoc.toJson();
List<FilesetDV> listFiles = new ArrayList<FilesetDV>();
List<FilesetDV> listImages = new ArrayList<FilesetDV>();
for (FilePathDV filePath : filePaths) {
String filesetJSONPath = String.format("%s.%s", JSON_$_POINTER, filePath.getFieldName());
List<Payload> listPayloads = readPayloadsForFileset(filesetJSONPath, fromSectionDocJSON);
FilesetDV filesetDV = new FilesetDV();
filesetDV.setName(filePath.getGcubeProfileFieldName());
for (Payload payload : listPayloads) {
PayloadDV payloadDV = ConvertToDataValueObjectModel.toPayloadDV(payload);
filesetDV.addPayloadDV(payloadDV);
boolean isImage = ImageDetector.isImage(payload.getMimetype());
if (isImage) {
listImages.add(filesetDV);
} else {
listFiles.add(filesetDV);
}
}
}
subDocumentView.setListFiles(listFiles);
subDocumentView.setListImages(listImages);
}
sectionView.addSubDocument(subDocumentView);
}
projectView.addSectionView(sectionView);
}
// for (SectionView section : projectView.getListSections()) {
// System.out.println("\n\n###### Section Title: " + section.getSectionTitle() + " ######");
// int i = 1;
// for (SubDocumentView subDocument : section.getListSubDocuments()) {
// System.out.println("## " + SubDocumentView.class.getSimpleName() + " n." + i);
// System.out.println("***** Metadata");
// System.out.println(prettyPrintJSON(subDocument.getMetadataAsJSON()));
// System.out.println("***** Files");
// if (subDocument.getListFiles() != null) {
// for (FilesetDV filesetDV : subDocument.getListFiles()) {
// System.out.println("******* File Fileset name: " + filesetDV.getName());
// for (PayloadDV payload : filesetDV.getListPayload()) {
// System.out.println("********* Payload: " + payload);
// }
// }
// }
// System.out.println("***** Images");
// if (subDocument.getListImages() != null) {
// for (FilesetDV filesetDV : subDocument.getListImages()) {
// System.out.println("******* Image Fileset name: " + filesetDV.getName());
// for (PayloadDV payload : filesetDV.getListPayload()) {
// System.out.println("********* Payload: " + payload);
// }
// }
// }
// i++;
// }
//
// }
return projectView;
} catch (Exception e) {
String erroMsg = "Error occurred on creating projectView for id: " + projectID;
LOG.error(erroMsg, e);
throw new Exception(erroMsg);
}
}
/**
* Read payloads for fileset.
*
* @param filesetJSONPath the fileset JSON path
* @param sectionJSONDocument the section JSON document
* @return the list
*/
private List<Payload> readPayloadsForFileset(String filesetJSONPath, String sectionJSONDocument) {
LOG.debug("readPayloadsForFileset called");
List<Payload> listPayloads = new ArrayList<Payload>();
String _payloadsJSONPath = String.format("%s.%s", filesetJSONPath, "_payloads");
try {
com.jayway.jsonpath.Configuration configuration = com.jayway.jsonpath.Configuration.builder()
.jsonProvider(new JsonOrgJsonProvider()).build();
LOG.info("Reading sectionPath at {} into section document {}", _payloadsJSONPath, sectionJSONDocument);
JsonPath theSectionPolycJsonPath = JsonPath.compile(_payloadsJSONPath);
Object _payloads = theSectionPolycJsonPath.read(sectionJSONDocument, configuration).toString();
if (_payloads instanceof String) {
String toStringPayloads = (String) _payloads;
LOG.trace("The _payloads is a String {}", toStringPayloads);
JSONArray jsonArray = new JSONArray(toStringPayloads);
for (int i = 0; i < jsonArray.length(); i++) {
Payload payloadDV = Serialization.read(jsonArray.getJSONObject(i).toString(), Payload.class);
listPayloads.add(payloadDV);
}
}
LOG.info("returning list of payloads {}", listPayloads);
} catch (Exception e) {
LOG.error("Error on reading the JSON Path {} in the doc {} ", _payloadsJSONPath, sectionJSONDocument);
e.printStackTrace();
}
return listPayloads;
}
/**
* Checks if is accessible section according to policy.
*
* @param section the section
* @param sectionJSONPath the section JSON path
* @param myLogin the my login
* @return true, if is accessible section according to policy
*/
private boolean isAccessibleSectionAccordingToPolicy(Document section, String sectionJSONPath, String myLogin) {
LOG.debug("isAccessibleSectionAccordingToPolicy called");
boolean isAccessible = true;
// Skipping the root, going to check the access_policy of subsections
if (sectionJSONPath.compareTo(JSON_$_POINTER) != 0) {
isAccessible = checkAccessPolicy(section.toJson(), myLogin);
}
return isAccessible;
}
/**
* Check access policy.
*
* @param sectionDocumentJSON the section document JSON
* @param myLogin the my login
* @return true, if successful
*/
private boolean checkAccessPolicy(String sectionDocumentJSON, String myLogin) {
LOG.debug("checkAccessPolicy called");
// CHECKING THE POLICY
String accessPolicyPath = JSON_$_POINTER + "._access._policy";
boolean isAccessible = true;
try {
com.jayway.jsonpath.Configuration configuration = com.jayway.jsonpath.Configuration.builder()
.jsonProvider(new JsonOrgJsonProvider()).build();
LOG.info("Reading access policy at {} into section document {}", accessPolicyPath, sectionDocumentJSON);
JsonPath theSectionPolycJsonPath = JsonPath.compile(accessPolicyPath);
String _policy = theSectionPolycJsonPath.read(sectionDocumentJSON, configuration).toString();
LOG.info("The section {} has policy {}", accessPolicyPath, _policy);
isAccessible = GeportalCheckAccessPolicy.isAccessible(_policy, myLogin);
} catch (Exception e) {
LOG.error(accessPolicyPath + " not found. Check OK");
}
LOG.info("Is the section {} accessible? {}", sectionDocumentJSON, isAccessible);
return isAccessible;
}
/**
* Pretty print JSON.
*
* @param jsonString the json string
* @return the string
*/
private String prettyPrintJSON(String jsonString) {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
JsonObject jsonObject = new JsonParser().parse(jsonString).getAsJsonObject();
return gson.toJson(jsonObject);
}
/**
* Sanitize document value.
*
* @param toDoc the to doc
* @param fieldLabel the field label
* @param theObjectFieldValue the the object field value
* @return the document
*/
private Document sanitizeDocumentValue(Document toDoc, String fieldLabel, Object theObjectFieldValue) {
if (theObjectFieldValue != null) {
if (theObjectFieldValue instanceof String) {
String toString = (String) theObjectFieldValue;
if (toString != null && !toString.isEmpty()) {
toDoc.append(fieldLabel, theObjectFieldValue);
} else {
LOG.debug("Skipping String field " + fieldLabel + " its value is null or empty");
}
} else if (theObjectFieldValue instanceof ArrayList) {
ArrayList toArrayList = (ArrayList) theObjectFieldValue;
if (toArrayList != null && !toArrayList.isEmpty()) {
toDoc.append(fieldLabel, theObjectFieldValue);
} else {
LOG.debug("Skipping ArrayList field " + fieldLabel + " its value is null or empty");
}
} else {
toDoc.append(fieldLabel, theObjectFieldValue);
}
} else {
LOG.debug("Skipping field " + fieldLabel + " its value is null or empty");
}
return toDoc;
}
}

@ -1,66 +1,66 @@
package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice;
import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.statefulMongoConcessioni;
import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI;
import org.gcube.application.geoportal.common.model.legacy.Concessione;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class ConcessioniMongoService.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Sep 23, 2021
*/
public class ConcessioniMongoService {
private static final Logger LOG = LoggerFactory.getLogger(ConcessioniMongoService.class);
/**
* Instantiates a new concessioni mongo service.
*/
protected ConcessioniMongoService() {
}
/**
* Gets the item by id.
*
* @param mongoItemId the mongo item id
* @return the item by id
* @throws Exception the exception
*/
protected Concessione getItemById(String mongoItemId) throws Exception {
LOG.info("called getItemById: " + mongoItemId);
ConcessioniManagerI concessioniManager = statefulMongoConcessioni().build();
// Returning item by Id
return concessioniManager.getById(mongoItemId);
}
/**
* To concessione.
*
* @param jsonString the json string
* @return the concessione
*/
protected Concessione toConcessione(String jsonString) {
LOG.info("toConcessione called");
try {
return org.gcube.application.geoportal.client.utils.Serialization.read(jsonString, Concessione.class);
} catch (Exception e) {
LOG.warn("Error on serializing: ", e);
return null;
}
}
/*
* For testing public Concessione iamClientGetItemBy(HttpServletRequest request,
* String mongoItemId, String clientId, String secret) throws Exception { String
* scope = SessionUtil.getCurrentContext(request, true); return
* iamClientGetItemBy(scope, mongoItemId, clientId, secret); }
*/
}
//package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice;
//
//import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.statefulMongoConcessioni;
//
//import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI;
//import org.gcube.application.geoportal.common.model.legacy.Concessione;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//
//
///**
// * The Class ConcessioniMongoService.
// *
// * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
// *
// * Sep 23, 2021
// */
//public class ConcessioniMongoService {
//
// private static final Logger LOG = LoggerFactory.getLogger(ConcessioniMongoService.class);
//
// /**
// * Instantiates a new concessioni mongo service.
// */
// protected ConcessioniMongoService() {
// }
//
// /**
// * Gets the item by id.
// *
// * @param mongoItemId the mongo item id
// * @return the item by id
// * @throws Exception the exception
// */
// protected Concessione getItemById(String mongoItemId) throws Exception {
// LOG.info("called getItemById: " + mongoItemId);
// ConcessioniManagerI concessioniManager = statefulMongoConcessioni().build();
// // Returning item by Id
// return concessioniManager.getById(mongoItemId);
// }
//
//
// /**
// * To concessione.
// *
// * @param jsonString the json string
// * @return the concessione
// */
// protected Concessione toConcessione(String jsonString) {
// LOG.info("toConcessione called");
// try {
// return org.gcube.application.geoportal.client.utils.Serialization.read(jsonString, Concessione.class);
// } catch (Exception e) {
// LOG.warn("Error on serializing: ", e);
// return null;
// }
// }
//
// /*
// * For testing public Concessione iamClientGetItemBy(HttpServletRequest request,
// * String mongoItemId, String clientId, String secret) throws Exception { String
// * scope = SessionUtil.getCurrentContext(request, true); return
// * iamClientGetItemBy(scope, mongoItemId, clientId, secret); }
// */
//
//}

@ -1,80 +0,0 @@
package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice;
import javax.servlet.http.HttpServletRequest;
import org.gcube.application.geoportal.common.model.legacy.Concessione;
import org.gcube.common.portal.PortalContext;
import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentity.GcubeIdentity;
import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentity.IAMClientIdentity;
import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentity.UserIdentity;
import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class ConcessioniMongoServiceIdentityProxy.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Sep 23, 2021
*/
public class ConcessioniMongoServiceIdentityProxy {
private static final Logger LOG = LoggerFactory.getLogger(ConcessioniMongoServiceIdentityProxy.class);
private GcubeIdentity gCubeIdentity;
/**
* Instantiates a new concessioni mongo service proxy.
*
* @param request the request
* @throws Exception the exception
*/
public ConcessioniMongoServiceIdentityProxy(HttpServletRequest request) throws Exception {
SessionUtil.getCurrentContext(request, true);
PortalContext pContext = PortalContext.getConfiguration();
String username = null;
try {
username = pContext.getCurrentUser(request).getUsername();
if(username==null || username.isEmpty())
throw new Exception("Invalid username");
}catch (Exception e) {
LOG.info("Username not detected in session");
username = null; //to be sure that is null and not empty string
}
if (username != null) {
LOG.info("User detected, using its identity");
gCubeIdentity = new UserIdentity();
} else {
LOG.info("User not detected, using IAM Client identity");
gCubeIdentity = new IAMClientIdentity();
}
gCubeIdentity.setIdentity(request);
}
/**
* Gets the item by id.
*
* @param mongoItemId the mongo item id
* @return the item by id
* @throws Exception the exception
*/
public Concessione getItemById(String mongoItemId) throws Exception {
try {
// Obtain the client
ConcessioniMongoService concessioniManager = new ConcessioniMongoService();
// Returning item by Id
return concessioniManager.getItemById(mongoItemId);
}catch(Exception e) {
LOG.error("Error on reading itemById: "+mongoItemId, e);
throw(e);
}finally {
gCubeIdentity.resetIdentity();
}
}
}

@ -0,0 +1,82 @@
package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice;
import javax.servlet.http.HttpServletRequest;
import org.gcube.application.geoportal.common.model.document.Project;
import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
import org.gcube.application.geoportalcommon.ProjectDVBuilder;
import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
import org.gcube.application.geoportalcommon.geoportal.ProjectsCaller;
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
import org.gcube.common.portal.PortalContext;
import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentity.GcubeIdentity;
import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentity.IAMClientIdentity;
import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentity.UserIdentity;
import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class GeoportalServiceIdentityProxy.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Sep 23, 2021
*/
public class GeoportalServiceIdentityProxy {
private static final Logger LOG = LoggerFactory.getLogger(GeoportalServiceIdentityProxy.class);
private GcubeIdentity gCubeIdentity;
/**
* Instantiates a new concessioni mongo service proxy.
*
* @param request the request
* @throws Exception the exception
*/
public GeoportalServiceIdentityProxy(HttpServletRequest request) throws Exception {
SessionUtil.getCurrentContext(request, true);
PortalContext pContext = PortalContext.getConfiguration();
String username = null;
try {
username = pContext.getCurrentUser(request).getUsername();
if (username == null || username.isEmpty())
throw new Exception("Invalid username");
} catch (Exception e) {
LOG.info("Username not detected in session");
username = null; // to be sure that is null and not empty string
}
if (username != null) {
LOG.info("User detected, using its identity");
gCubeIdentity = new UserIdentity();
} else {
LOG.info("User not detected, using IAM Client identity");
gCubeIdentity = new IAMClientIdentity();
}
gCubeIdentity.setIdentity(request);
}
/**
* Gets the project by ID.
*
* @param profileID the profile ID
* @param projectID the project ID
* @return the project by ID
* @throws Exception the exception
*/
public ProjectDV getProjectByID(String profileID, String projectID) throws Exception {
ProjectsCaller clientPrj = GeoportalClientCaller.projects();
Project theProject = clientPrj.getProjectByID(profileID, projectID);
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
return ConvertToDataValueObjectModel.toProjectDV(theProject, projectBuilder);
/*
* try { // Obtain the client ConcessioniMongoService concessioniManager = new
* ConcessioniMongoService(); // Returning item by Id return
* concessioniManager.getItemById(mongoItemId); }catch(Exception e) {
* LOG.error("Error on reading itemById: "+mongoItemId, e); throw(e); }finally {
* gCubeIdentity.resetIdentity(); }
*/
}
}

@ -3,21 +3,19 @@
*/
package org.gcube.portlets.user.geoportaldataviewer.server.util;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.gcube.application.geoportal.common.model.legacy.Concessione;
import org.gcube.application.geoportal.common.rest.MongoConcessioni;
import org.gcube.application.geoportalcommon.MongoServiceCommon;
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.portal.PortalContext;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.geoportaldataviewer.server.GNABaseMapsResourceReader;
import org.gcube.portlets.user.geoportaldataviewer.server.GcubeProfilesMetadataForUCD;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import org.gcube.portlets.user.urlshortener.UrlShortener;
import org.gcube.vomanagement.usermanagement.GroupManager;
@ -39,6 +37,8 @@ import com.liferay.portal.service.UserLocalServiceUtil;
* Oct 20, 2020
*/
public class SessionUtil {
private static final String MAP_UCD_ID_TO_GCUBE_PROFILES = "MAP_UCD_ID_TO_GCUBE_PROFILES";
/** The log. */
private static Logger LOG = LoggerFactory.getLogger(SessionUtil.class);
@ -181,6 +181,24 @@ public class SessionUtil {
return shortener;
}
public static LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>> getMap_UCDId_gCubeProfiles(
HttpServletRequest httpServletRequest, String profileID) {
HttpSession session = httpServletRequest.getSession();
return (LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>>) session
.getAttribute(MAP_UCD_ID_TO_GCUBE_PROFILES +"_"+profileID);
}
public static void setMap_UCDId_gCubeProfiles(HttpServletRequest httpServletRequest,
String profileID, LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>> map) {
HttpSession session = httpServletRequest.getSession();
session.setAttribute(MAP_UCD_ID_TO_GCUBE_PROFILES +"_"+profileID, map);
}
/**
* Gets the GNA base maps.
@ -218,7 +236,8 @@ public class SessionUtil {
boolean reloadFromService) throws Exception {
HttpSession session = httpServletRequest.getSession();
List<Concessione> listOfConcessioni = (List<Concessione>) session.getAttribute(LIST_OF_CONCESSIONI);
throw new Exception("getListConcessioni must be revisited!!!!");
/*
// setting null to force reloading from service
if (reloadFromService)
listOfConcessioni = null;
@ -241,11 +260,14 @@ public class SessionUtil {
// LOG.debug("Got list of concessioni from client mongo: " + listOfConcessioni);
session.setAttribute(LIST_OF_CONCESSIONI, listOfConcessioni);
LOG.info("Saved in session list of concessioni from client mongo with size: " + listOfConcessioni.size());
} else
LOG.info("list of concessioni presents in session, using it");
LOG.info("read list of concessioni with size: " + listOfConcessioni.size());
return listOfConcessioni;
*/
}
/**

@ -510,4 +510,21 @@ body {
padding-right: 5px;
cursor: pointer;
}
.my-html-table {
padding: 5px;
margin-left: 10px;
margin-bottom: 10px;
margin-right: 5px;
}
.my-html-table td {
padding: 5px 0;
}
.my-html-table td:first-child {
color: gray;
padding-right: 15px;
width: 120px;
}

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
@ -15,9 +16,25 @@
<servlet-class>org.gcube.portlets.user.geoportaldataviewer.server.GeoportalDataViewerServiceImpl</servlet-class>
</servlet>
<servlet>
<servlet-name>mpformbuilderServlet</servlet-name>
<servlet-class>org.gcube.portlets.widgets.mpformbuilder.server.MetadataProfileFormBuilderServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>mpformbuilderServlet</servlet-name>
<url-pattern>/GeoportalDataViewer/mpformbuilderservice</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>geoportalDataViewerServlet</servlet-name>
<url-pattern>/GeoportalDataViewer/geoportaldataviewerservice</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.gcube.portlets.user.geoportaldataviewer.server.GeoportalDataViewerHttpSessionListener</listener-class>
</listener>
</web-app>

@ -1,11 +1,5 @@
package org.gcube.portlets.user.geoportaldataviewer;
import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.statefulMongoConcessioni;
import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI;
import org.gcube.application.geoportal.common.model.legacy.Concessione;
import org.gcube.application.geoportalcommon.ConvertToDataViewModel;
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider;
@ -27,7 +21,7 @@ public class ConcessioneReader {
public void readConcessione() throws Exception {
System.out.println("getConcessioneForId " + mongoConcessioneID + "called");
ConcessioneDV concessionDV = null;
/*ConcessioneDV concessionDV = null;
if (mongoConcessioneID == null)
throw new Exception("Invalid parameter. The Id is null");
@ -54,7 +48,7 @@ public class ConcessioneReader {
} catch (Exception e) {
String erroMsg = Concessione.class.getSimpleName() + " with id " + mongoConcessioneID + " not available";
throw new Exception(erroMsg);
}
}*/
}
}

@ -25,7 +25,7 @@ public class IAMClient {
System.out.println("Read credentials: " + credentials);
Concessione concessione;
try {
// concessione = new ConcessioniMongoServiceIdentityProxy();
// concessione = new GeoportalServiceIdentityProxy();
// System.out.println("Get concessione: " + concessione);
} catch (Exception e) {

Loading…
Cancel
Save