diff --git a/pom.xml b/pom.xml index fe6c021..941bf1a 100644 --- a/pom.xml +++ b/pom.xml @@ -49,33 +49,48 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + org.gcube.distribution + maven-portal-bom + 3.6.0 + pom + import + + + com.google.gwt + gwt-user + + + com.google.gwt + gwt-servlet + + + com.google.gwt + gwt-dev + + + + + + + + javax.servlet + javax.servlet-api + 3.1.0 + provided + + + + xml-apis + xml-apis + 1.4.01 + provided + + com.google.gwt gwt-servlet @@ -113,25 +128,25 @@ org.gcube.resources.discovery ic-client - [1.0.0, 2.0.0-SNAPSHOT) + provided org.gcube.core common-scope-maps - [1.1.0, 2.0.0-SNAPSHOT) - provided + + compile org.gcube.common.portal portal-manager - [2.4.1,3.0.0-SNAPSHOT) + provided org.gcube.dvos usermanagement-core - [2.4.1,3.0.0-SNAPSHOT) + provided @@ -140,6 +155,12 @@ [1.0.0,2.0.0-SNAPSHOT) compile + + org.gcube.application + geoportal-data-common + [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) + compile + org.gcube.application geoportal-client @@ -155,25 +176,25 @@ com.liferay.portal portal-service - 6.2.5 + provided javax.portlet portlet-api - 2.0 + provided org.slf4j slf4j-log4j12 - 1.6.4 + provided org.slf4j slf4j-api - 1.6.4 + provided diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/GeoportalDataViewer.gwt.xml b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/GeoportalDataViewer.gwt.xml index 632941b..6a5dd72 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/GeoportalDataViewer.gwt.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/GeoportalDataViewer.gwt.xml @@ -11,6 +11,8 @@ + + diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java index 2eff654..255e06b 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java @@ -2,6 +2,8 @@ package org.gcube.portlets.user.geoportaldataviewer.client; import java.util.Iterator; +import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; +import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEventHandler; import org.gcube.portlets.user.geoportaldataviewer.client.events.ClosedViewDetailsEvent; @@ -13,8 +15,6 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMini import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEventHandler; import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils; import org.gcube.portlets.user.geoportaldataviewer.client.ui.GeonaDataViewMainPanel; -import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataViewerProfile; -import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaItemRef; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem; import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java index 390044f..87b956b 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java @@ -2,8 +2,8 @@ package org.gcube.portlets.user.geoportaldataviewer.client; import java.util.List; -import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataViewerProfile; -import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaItemRef; +import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; +import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject; @@ -100,13 +100,4 @@ public interface GeoportalDataViewerService extends RemoteService { */ GeoNaItemRef getPublicLinksFor(GeoNaItemRef item) throws Exception; - /** - * Gets the short url. - * - * @param longUrl the long url - * @return the short url - * @throws Exception the exception - */ - String getShortUrl(String longUrl) throws Exception; - } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java index 74c2af7..048ee65 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java @@ -2,8 +2,8 @@ package org.gcube.portlets.user.geoportaldataviewer.client; import java.util.List; -import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataViewerProfile; -import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaItemRef; +import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; +import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject; @@ -50,5 +50,4 @@ public interface GeoportalDataViewerServiceAsync { void getPublicLinksFor(GeoNaItemRef item, AsyncCallback asyncCallback); - void getShortUrl(String longUrl, AsyncCallback callback); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java index b105793..ffd49ce 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java @@ -185,11 +185,13 @@ public class LayerManager { } //If recordId not passed, I'm using the first feature returned - if(feature==null && recordId==null) { + if(recordId==null) { feature = features.get(0); }else { //the recordId to show has been passed but not found into list of FeatureRow - return; + if(feature==null) { + return; + } } Map> entries = feature.getMapProperties(); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/ShowDetailsEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/ShowDetailsEvent.java index 7b83887..9358360 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/ShowDetailsEvent.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/ShowDetailsEvent.java @@ -1,6 +1,6 @@ package org.gcube.portlets.user.geoportaldataviewer.client.events; -import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaItemRef; +import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow; import com.google.gwt.event.shared.GwtEvent; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/DetailsPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/DetailsPanel.java index 42f3604..3b0f9d6 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/DetailsPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/DetailsPanel.java @@ -1,8 +1,8 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui; +import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; 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.shared.GeoNaItemRef; import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV; import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.RecordDV; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java index a60c0d9..913d5ae 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java @@ -1,7 +1,7 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui; +import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM; -import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaItemRef; import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV; import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.RecordDV; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/dialogs/DialogShareableLink.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/dialogs/DialogShareableLink.java index 019f76f..8da0679 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/dialogs/DialogShareableLink.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/dialogs/DialogShareableLink.java @@ -1,9 +1,9 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui.dialogs; +import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; +import org.gcube.application.geoportalcommon.shared.PublicLink; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync; -import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaItemRef; -import org.gcube.portlets.user.geoportaldataviewer.shared.PublicLink; import com.github.gwtbootstrap.client.ui.Alert; import com.github.gwtbootstrap.client.ui.Button; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java index 9ef4f01..33c88aa 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java @@ -2,6 +2,7 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui.products.concessio import java.util.List; +import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync; import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils; @@ -10,7 +11,6 @@ import org.gcube.portlets.user.geoportaldataviewer.client.ui.dialogs.DialogShare import org.gcube.portlets.user.geoportaldataviewer.client.ui.images.ThumbnailImageView; import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.MapView; import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.CustomFlexTable; -import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaItemRef; import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV; import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.LayerConcessioneDV; import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.RelazioneScavoDV; @@ -170,12 +170,12 @@ public class ConcessioneView extends Composite { customTable.addNextKeyValue("ID Licenza", concessioneDV.getLicenzaID()); } - if (concessioneDV.getTitolareLicenza() != null) { - customTable.addNextKeyValue("Titolare Licenza", concessioneDV.getTitolareLicenza()); + if (concessioneDV.getTitolariLicenza() != null) { + customTable.addNextKeyValues("Titolare Licenza", concessioneDV.getTitolariLicenza(), GeoportalDataViewerConstants.NEW_LINE_BR); } - if (concessioneDV.getTitolareCopyright() != null) { - customTable.addNextKeyValue("Titolare Copyright", concessioneDV.getTitolareCopyright()); + if (concessioneDV.getTitolariCopyright() != null) { + customTable.addNextKeyValues("Titolare Copyright", concessioneDV.getTitolariCopyright(),GeoportalDataViewerConstants.NEW_LINE_BR); } shareButton.setType(ButtonType.LINK); @@ -313,15 +313,26 @@ public class ConcessioneView extends Composite { List immagini = concessioneDV.getImmaginiRappresentative(); if (immagini != null && immagini.size() > 0) { imagesPanel.setVisible(true); - int i = 0; + boolean addedImage = false; + imagesPanel.add(thumbNails); for (UploadedImageDV uploadedImageDV : immagini) { - if (i == 0) - imagesPanel.add(thumbNails); - - thumbNails.add(new ThumbnailImageView(uploadedImageDV, viewImageButtonVisible, openImageButtonVisible)); + + if(uploadedImageDV.getPolicy()==null || uploadedImageDV.getPolicy().equalsIgnoreCase("OPEN")) { + thumbNails.add(new ThumbnailImageView(uploadedImageDV, viewImageButtonVisible, openImageButtonVisible)); + addedImage = true; + }else { + if(myLogin!=null) { + thumbNails.add(new ThumbnailImageView(uploadedImageDV, viewImageButtonVisible, openImageButtonVisible)); + addedImage = true; + } + } + + } + + if(!addedImage) { + imagesPanel.remove(thumbNails); } } - } public ConcessioneDV getConcessioneDV() { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConvertToDataViewModel.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConvertToDataViewModel.java index ea86208..2ca93be 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConvertToDataViewModel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConvertToDataViewModel.java @@ -87,8 +87,8 @@ public class ConvertToDataViewModel { theConcessione.setResponsabile(concessione.getResponsabile()); theConcessione.setRisorseCorrelate(concessione.getRisorseCorrelate()); theConcessione.setSoggetto(concessione.getSoggetto()); - theConcessione.setTitolareCopyright(concessione.getTitolareCopyright()); - theConcessione.setTitolareLicenza(concessione.getTitolareLicenza()); + theConcessione.setTitolariCopyright(concessione.getTitolareCopyright()); + theConcessione.setTitolariLicenza(concessione.getTitolareLicenza()); theConcessione.setTitolari(concessione.getTitolari()); theConcessione.setVersion(concessione.getVersion()); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoNaDataViewerProfileReader.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoNaDataViewerProfileReader.java deleted file mode 100644 index c231cb5..0000000 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoNaDataViewerProfileReader.java +++ /dev/null @@ -1,202 +0,0 @@ -package org.gcube.portlets.user.geoportaldataviewer.server; - -import static org.gcube.resources.discovery.icclient.ICFactory.client; - -import java.io.StringReader; -import java.net.URLDecoder; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathFactory; - -import org.gcube.common.resources.gcore.utils.XPathHelper; -import org.gcube.common.scope.api.ScopeProvider; -import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataViewerProfile; -import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem; -import org.gcube.resources.discovery.client.api.DiscoveryClient; -import org.gcube.resources.discovery.client.queries.api.Query; -import org.gcube.resources.discovery.client.queries.impl.QueryBox; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; - - - -/** - * The Class GeoNaViewerProfileReader. - * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * - * Nov 12, 2020 - */ -public class GeoNaDataViewerProfileReader { - - private static final String RESOURCE_PROFILE_BODY = "/Resource/Profile/Body"; - /** - * - */ - public static final String SECONDARY_TYPE = "ApplicationProfile"; - public static final String WORKSPACE_EXPLORER_APP_NAME = "GeoNa-Viewer-Profile"; - - private Logger logger = LoggerFactory.getLogger(GeoNaDataViewerProfileReader.class); - private String secondaryType; - private String scope; - private String appID; - - /** - * Instantiates a new application profile reader. - * - * @param appID the app id - */ - public GeoNaDataViewerProfileReader(String appID) { - - this.appID = appID; - this.secondaryType = SECONDARY_TYPE; - this.scope = ScopeProvider.instance.get(); - } - - /** - * Read profile from infrastrucure. - * - * @return the map - */ - public GeoNaDataViewerProfile readProfileFromInfrastrucure() throws Exception { - - String queryString = getGcubeGenericQueryString(secondaryType, appID); - logger.info("Scope "+scope+", trying to perform query: "+queryString); - - try { - - if (scope == null) - throw new Exception("Scope is null, set scope into ScopeProvider"); - - GeoNaDataViewerProfile profile = new GeoNaDataViewerProfile(); - - logger.info("Trying to fetch ApplicationProfile in the scope: " + scope + ", SecondaryType: " - + secondaryType + ", AppId: " + appID); - Query q = new QueryBox(queryString); - DiscoveryClient client = client(); - List appProfile = client.submit(q); - - if (appProfile == null || appProfile.size() == 0) - throw new ApplicationProfileNotFoundException("ApplicationProfile with SecondaryType: " + secondaryType - + ", AppId: " + appID + " is not registered in the scope: " + scope); - else { - String elem = appProfile.get(0); - DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - Document doc = docBuilder.parse(new InputSource(new StringReader(elem))); - - XPathHelper helper = new XPathHelper(doc.getDocumentElement()); - - List currValue = null; - String xPathExp = RESOURCE_PROFILE_BODY+"/RestrictedPortletURL/text()"; - currValue = helper.evaluate(xPathExp); - if (currValue != null && currValue.size() > 0) { - profile.setRestrictedPortletURL(currValue.get(0)); - }else - throw new Exception("I'm not able to read the path: "+xPathExp); - - xPathExp = RESOURCE_PROFILE_BODY+"/OpenPortletURL/text()"; - currValue = helper.evaluate(xPathExp); - if (currValue != null && currValue.size() > 0) { - profile.setOpenPortletURL(currValue.get(0)); - }else - throw new Exception("I'm not able to read the path: "+xPathExp); - - - XPath xPath = XPathFactory.newInstance().newXPath(); - NodeList nodeList = (NodeList) xPath.compile("/Resource/Profile/Body/AvailableLayers/Layer") - .evaluate(doc, XPathConstants.NODESET); - - Map mapLayers = new HashMap(nodeList.getLength()); - - for (int i = 0; i < nodeList.getLength(); i++) { - Node layerNode = nodeList.item(i); - if (layerNode.getNodeType() == Node.ELEMENT_NODE) { - Element eElement = (Element) layerNode; - String layerType = eElement.getElementsByTagName("Type").item(0).getTextContent(); - String wmsLink = eElement.getElementsByTagName("WMSLink").item(0).getTextContent(); - String decodedURL = URLDecoder.decode(wmsLink, "UTF-8"); - LayerItem layer = new LayerItem(); - layer.setWmsLink(decodedURL); - mapLayers.put(layerType.toLowerCase(), layer); - } - } - - profile.setMapLayers(mapLayers); - logger.info("returning: "+profile); - return profile; - } - - } catch (Exception e) { - logger.error("Error while trying to read the " + SECONDARY_TYPE + " with SecondaryType " - + WORKSPACE_EXPLORER_APP_NAME + " from scope " + scope, e); - return null; - } finally { - - } - - } - - /** - * Gets the gcube generic query string. - * - * @param secondaryType the secondary type - * @param appId the app id - * @return the gcube generic query string - */ - public static String getGcubeGenericQueryString(String secondaryType, String appId) { - - return "for $profile in collection('/db/Profiles/GenericResource')//Resource " - + "where $profile/Profile/SecondaryType/string() eq '" + secondaryType - + "' and $profile/Profile/Body/AppId/string() " + " eq '" + appId + "'" + "return $profile"; - } - - /** - * Gets the secondary type. - * - * @return the secondary type - */ - public String getSecondaryType() { - return secondaryType; - } - - /** - * Gets the scope. - * - * @return the scope - */ - public String getScope() { - return scope; - } - - @Override - public String toString() { - return "GeoNaViewerProfileReader [secondaryType=" + secondaryType + ", scope=" + scope + ", appID=" + appID - + "]"; - } - - /* - public static void main(String[] args) throws Exception { - ScopeProvider.instance.set("/gcube/devNext/NextNext"); - GeoNaDataViewerProfileReader gdvp = new GeoNaDataViewerProfileReader("geoportal-data-viewer-app"); - GeoNaDataViewerProfile profile = gdvp.readProfileFromInfrastrucure(); - System.out.println(profile.getRestrictedPortletURL()); - System.out.println(profile.getOpenPortletURL()); - - if(profile.getMapLayers()!=null) { - for (String type : profile.getMapLayers().keySet()) { - System.out.println("key: "+type+", value: "+profile.getMapLayers().get(type)); - } - } - }*/ -} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java index 8253e09..e3f2865 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java @@ -1,9 +1,6 @@ package org.gcube.portlets.user.geoportaldataviewer.server; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; @@ -12,16 +9,16 @@ import java.util.Map; import org.gcube.application.geoportal.client.legacy.ConcessioniManager; import org.gcube.application.geoportal.common.model.legacy.Concessione; import org.gcube.application.geoportal.common.model.legacy.UploadedImage; -import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; +import org.gcube.application.geoportalcommon.GeoNaDataViewerProfileReader; +import org.gcube.application.geoportalcommon.GeoportalCommon; +import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; +import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; 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.util.SessionUtil; import org.gcube.portlets.user.geoportaldataviewer.server.util.URLParserUtil; -import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataViewerProfile; -import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaItemRef; import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult; -import org.gcube.portlets.user.geoportaldataviewer.shared.PublicLink; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject; @@ -31,7 +28,6 @@ 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.geoportaldataviewer.shared.products.ConcessioneDV; import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV; -import org.gcube.portlets.user.urlshortener.UrlShortener; import org.gcube.spatial.data.geoutility.GeoNcWMSMetadataUtility; import org.gcube.spatial.data.geoutility.bean.LayerStyles; import org.gcube.spatial.data.geoutility.bean.LayerZAxis; @@ -361,8 +357,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme LOG.info("getGeoNaDataViewProfile called"); SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); - GeoNaDataViewerProfileReader gdvp = new GeoNaDataViewerProfileReader("geoportal-data-viewer-app"); - GeoNaDataViewerProfile profile = gdvp.readProfileFromInfrastrucure(); + GeoportalCommon gc = new GeoportalCommon(); + org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile profile = gc.getGeoNaDataViewProfile(null); LOG.info("Returning profile: "+profile); return profile; } @@ -371,7 +367,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme @Override public GeoNaItemRef getPublicLinksFor(GeoNaItemRef item) throws Exception { LOG.info("getPublicLinksFor called for: " + item); - + try { if (item == null) @@ -382,33 +378,10 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme if(item.getItemType()==null) throw new Exception("Bad request, the item type is null"); - - GeoNaDataViewerProfile geonaDataProfile = getGeoNaDataViewProfile(); - //Restricted Link - String link = String.format("%s?%s=%s&%s=%s", - geonaDataProfile.getRestrictedPortletURL(), - GeoportalDataViewerConstants.GET_GEONA_ITEM_ID, - item.getItemId(), - GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE, - item.getItemType()); - - String shortUrl = getShortUrl(link); - item.setRestrictedLink(new PublicLink(link, shortUrl)); - - //Open Link - link = String.format("%s?%s=%s&%s=%s", - geonaDataProfile.getOpenPortletURL(), - GeoportalDataViewerConstants.GET_GEONA_ITEM_ID, - item.getItemId(), - GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE, - item.getItemType()); - - shortUrl = getShortUrl(link); - item.setOpenLink(new PublicLink(link, shortUrl)); - - LOG.info("returning: " + item); - return item; + SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); + GeoportalCommon gc = new GeoportalCommon(); + return gc.getPublicLinksFor(item); } catch (Exception e) { LOG.error("Error on getPublicLinksFor for: " + item, e); @@ -416,44 +389,6 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme } } - @Override - public String getShortUrl(String longUrl) throws Exception { - LOG.info("getShortUrl called for " + longUrl); - - if(longUrl==null) - return longUrl; - - UrlShortener shortener = SessionUtil.getUrlShortener(this.getThreadLocalRequest()); - - try { - - if (shortener != null && shortener.isAvailable()) { - String toShort = longUrl; - String[] splitted = toShort.split("\\?"); - LOG.debug("Splitted long URL is: "+Arrays.asList(splitted)); - String link = toShort; - if (splitted.length > 1) { - LOG.debug("Query string detected, encoding it..."); - String encodedQuery = splitted[1]; - try { - encodedQuery = URLEncoder.encode(splitted[1], "UTF-8"); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - - } - LOG.debug("encodedQuery is: "+encodedQuery); - link = String.format("%s?%s", splitted[0], encodedQuery); - } - return shortener.shorten(link); - } - return longUrl; - - } catch (Exception e) { - LOG.error("Error on shortening the longURL "+longUrl, e); - return null; - } - } - public boolean isSessionExpired() throws Exception { return SessionUtil.isSessionExpired(this.getThreadLocalRequest()); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/GeoNaDataViewerProfile.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/GeoNaDataViewerProfile.java deleted file mode 100644 index d528ee2..0000000 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/GeoNaDataViewerProfile.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.gcube.portlets.user.geoportaldataviewer.shared; - -import java.io.Serializable; -import java.util.Map; - -import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem; - -import com.google.gwt.user.client.rpc.IsSerializable; - - -/** - * The Class GeoNaDataViewerProfile. - * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * - * Nov 13, 2020 - */ -public class GeoNaDataViewerProfile implements IsSerializable, Serializable{ - - /** - * - */ - private static final long serialVersionUID = 8583236018312392009L; - private String restrictedPortletURL; - private String openPortletURL; - //the key is the layer type - private Map mapLayers; - - /** - * Instantiates a new geo na data viewer profile. - */ - public GeoNaDataViewerProfile() { - - } - - /** - * Gets the restricted portlet URL. - * - * @return the restricted portlet URL - */ - public String getRestrictedPortletURL() { - return restrictedPortletURL; - } - - /** - * Sets the restricted portlet URL. - * - * @param restrictedPortletURL the new restricted portlet URL - */ - public void setRestrictedPortletURL(String restrictedPortletURL) { - this.restrictedPortletURL = restrictedPortletURL; - } - - /** - * Gets the open portlet URL. - * - * @return the open portlet URL - */ - public String getOpenPortletURL() { - return openPortletURL; - } - - /** - * Sets the open portlet URL. - * - * @param openPortletURL the new open portlet URL - */ - public void setOpenPortletURL(String openPortletURL) { - this.openPortletURL = openPortletURL; - } - - /** - * Gets the map layers. - * - * @return the map layers - */ - public Map getMapLayers() { - return mapLayers; - } - - /** - * Sets the map layers. - * - * @param mapLayers the map layers - */ - public void setMapLayers(Map mapLayers) { - this.mapLayers = mapLayers; - } - - /** - * To string. - * - * @return the string - */ - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("GeoNaDataViewerProfile [restrictedPortletURL="); - builder.append(restrictedPortletURL); - builder.append(", openPortletURL="); - builder.append(openPortletURL); - builder.append(", mapLayers="); - builder.append(mapLayers); - builder.append("]"); - return builder.toString(); - } - - -} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/GeoNaItemRef.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/GeoNaItemRef.java deleted file mode 100644 index efa776b..0000000 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/GeoNaItemRef.java +++ /dev/null @@ -1,156 +0,0 @@ -package org.gcube.portlets.user.geoportaldataviewer.shared; - -import java.io.Serializable; - -/** - * The Class GeoNaItemRef. - * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * - * Nov 17, 2020 - */ -public class GeoNaItemRef implements Serializable { - - /** - * - */ - private static final long serialVersionUID = -7021431511279022193L; - - private Long itemId; - private String itemType; - private String itemName; - - private PublicLink restrictedLink; - private PublicLink openLink; - - /** - * Instantiates a new geo na object. - */ - public GeoNaItemRef() { - - } - - /** - * Instantiates a new geo na object. - * - * @param itemId the item id - * @param itemType the item type - */ - public GeoNaItemRef(Long itemId, String itemType) { - super(); - this.itemId = itemId; - this.itemType = itemType; - } - - /** - * Gets the item id. - * - * @return the item id - */ - public Long getItemId() { - return itemId; - } - - /** - * Sets the item id. - * - * @param itemId the new item id - */ - public void setItemId(Long itemId) { - this.itemId = itemId; - } - - /** - * Gets the item type. - * - * @return the item type - */ - public String getItemType() { - return itemType; - } - - /** - * Sets the item type. - * - * @param itemType the new item type - */ - public void setItemType(String itemType) { - this.itemType = itemType; - } - - /** - * Gets the item name. - * - * @return the item name - */ - public String getItemName() { - return itemName; - } - - /** - * Sets the item name. - * - * @param itemName the new item name - */ - public void setItemName(String itemName) { - this.itemName = itemName; - } - - - - /** - * Gets the restricted link. - * - * @return the restricted link - */ - public PublicLink getRestrictedLink() { - return restrictedLink; - } - - /** - * Sets the restricted link. - * - * @param restrictedLink the new restricted link - */ - public void setRestrictedLink(PublicLink restrictedLink) { - this.restrictedLink = restrictedLink; - } - - /** - * Gets the open link. - * - * @return the open link - */ - public PublicLink getOpenLink() { - return openLink; - } - - /** - * Sets the open link. - * - * @param openLink the new open link - */ - public void setOpenLink(PublicLink openLink) { - this.openLink = openLink; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("GeoNaItemRef [itemId="); - builder.append(itemId); - builder.append(", itemType="); - builder.append(itemType); - builder.append(", itemName="); - builder.append(itemName); - builder.append(", restrictedLink="); - builder.append(restrictedLink); - builder.append(", openLink="); - builder.append(openLink); - builder.append("]"); - return builder.toString(); - } - - - -} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/PublicLink.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/PublicLink.java deleted file mode 100644 index 41b5d3e..0000000 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/PublicLink.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * - */ -package org.gcube.portlets.user.geoportaldataviewer.shared; - -import java.io.Serializable; - - -/** - * The Class PublicLink. - * - * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it - * Sep 13, 2016 - */ -public class PublicLink implements Serializable { - - /** - * - */ - private static final long serialVersionUID = -8157172818802297440L; - - private String completeURL; - private String shortURL; - - /** - * Instantiates a new public link. - */ - public PublicLink() { - - } - - /** - * Instantiates a new public link. - * - * @param completeURL the complete url - * @param shortURL the short url - */ - public PublicLink(String completeURL, String shortURL) { - super(); - this.completeURL = completeURL; - this.shortURL = shortURL; - } - - /** - * Gets the complete url. - * - * @return the completeURL - */ - public String getCompleteURL() { - return completeURL; - } - - /** - * Gets the short url. - * - * @return the shortURL - */ - public String getShortURL() { - return shortURL; - } - - /** - * Sets the complete url. - * - * @param completeURL the completeURL to set - */ - public void setCompleteURL(String completeURL) { - this.completeURL = completeURL; - } - - /** - * Sets the short url. - * - * @param shortURL the shortURL to set - */ - public void setShortURL(String shortURL) { - this.shortURL = shortURL; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("PublicLink [completeURL="); - builder.append(completeURL); - builder.append(", shortURL="); - builder.append(shortURL); - builder.append("]"); - return builder.toString(); - } -} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/ConcessioneDV.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/ConcessioneDV.java index 16cdca2..077d905 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/ConcessioneDV.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/ConcessioneDV.java @@ -12,13 +12,12 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.Uploade import com.google.gwt.user.client.rpc.IsSerializable; - /** * The Class ConcessioneDV. * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Nov 4, 2020 + * Nov 4, 2020 */ public class ConcessioneDV extends RecordDV implements Serializable, IsSerializable { @@ -64,10 +63,10 @@ public class ConcessioneDV extends RecordDV implements Serializable, IsSerializa private String dataFineProgetto; /** The titolare licenza. */ - private String titolareLicenza; + private List titolariLicenza; /** The titolare copyright. */ - private String titolareCopyright; + private List titolariCopyright; /** The parole chiave libere. */ private List paroleChiaveLibere; @@ -320,39 +319,39 @@ public class ConcessioneDV extends RecordDV implements Serializable, IsSerializa } /** - * Gets the titolare licenza. + * Gets the titolari licenza. * - * @return the titolare licenza + * @return the titolari licenza */ - public String getTitolareLicenza() { - return titolareLicenza; + public List getTitolariLicenza() { + return titolariLicenza; } /** - * Sets the titolare licenza. + * Sets the titolari licenza. * - * @param titolareLicenza the new titolare licenza + * @param titolariLicenza the new titolari licenza */ - public void setTitolareLicenza(String titolareLicenza) { - this.titolareLicenza = titolareLicenza; + public void setTitolariLicenza(List titolariLicenza) { + this.titolariLicenza = titolariLicenza; } /** - * Gets the titolare copyright. + * Gets the titolari copyright. * - * @return the titolare copyright + * @return the titolari copyright */ - public String getTitolareCopyright() { - return titolareCopyright; + public List getTitolariCopyright() { + return titolariCopyright; } /** - * Sets the titolare copyright. + * Sets the titolari copyright. * - * @param titolareCopyright the new titolare copyright + * @param titolariCopyright the new titolari copyright */ - public void setTitolareCopyright(String titolareCopyright) { - this.titolareCopyright = titolareCopyright; + public void setTitolariCopyright(List titolariCopyright) { + this.titolariCopyright = titolariCopyright; } /** @@ -508,7 +507,6 @@ public class ConcessioneDV extends RecordDV implements Serializable, IsSerializa return genericContent; } - /** * Sets the generic content. * @@ -518,15 +516,10 @@ public class ConcessioneDV extends RecordDV implements Serializable, IsSerializa this.genericContent = genericContent; } - /** - * To string. - * - * @return the string - */ @Override public String toString() { StringBuilder builder = new StringBuilder(); - builder.append("Concessione [introduzione="); + builder.append("ConcessioneDV [introduzione="); builder.append(introduzione); builder.append(", descrizioneContenuto="); builder.append(descrizioneContenuto); @@ -550,10 +543,10 @@ public class ConcessioneDV extends RecordDV implements Serializable, IsSerializa builder.append(dataInizioProgetto); builder.append(", dataFineProgetto="); builder.append(dataFineProgetto); - builder.append(", titolareLicenza="); - builder.append(titolareLicenza); - builder.append(", titolareCopyright="); - builder.append(titolareCopyright); + builder.append(", titolariLicenza="); + builder.append(titolariLicenza); + builder.append(", titolariCopyright="); + builder.append(titolariCopyright); builder.append(", paroleChiaveLibere="); builder.append(paroleChiaveLibere); builder.append(", paroleChiaveICCD="); @@ -562,8 +555,20 @@ public class ConcessioneDV extends RecordDV implements Serializable, IsSerializa builder.append(centroidLat); builder.append(", centroidLong="); builder.append(centroidLong); + builder.append(", relazioneScavo="); + builder.append(relazioneScavo); + builder.append(", immaginiRappresentative="); + builder.append(immaginiRappresentative); + builder.append(", posizionamentoScavo="); + builder.append(posizionamentoScavo); + builder.append(", pianteFineScavo="); + builder.append(pianteFineScavo); + builder.append(", genericContent="); + builder.append(genericContent); builder.append("]"); return builder.toString(); } + + } diff --git a/src/main/resources/org/gcube/portlets/user/geoportaldataviewer/GeoportalDataViewer.gwt.xml b/src/main/resources/org/gcube/portlets/user/geoportaldataviewer/GeoportalDataViewer.gwt.xml index 632941b..6a5dd72 100644 --- a/src/main/resources/org/gcube/portlets/user/geoportaldataviewer/GeoportalDataViewer.gwt.xml +++ b/src/main/resources/org/gcube/portlets/user/geoportaldataviewer/GeoportalDataViewer.gwt.xml @@ -11,6 +11,8 @@ + + diff --git a/src/main/webapp/GeoportalDataViewer.css b/src/main/webapp/GeoportalDataViewer.css index cd63fd6..f3f55f0 100644 --- a/src/main/webapp/GeoportalDataViewer.css +++ b/src/main/webapp/GeoportalDataViewer.css @@ -103,6 +103,7 @@ body { font-size: 14px; padding: 10px; color: #333; + text-align: justify; } #page-view-details .my-custom-flex-table { @@ -210,9 +211,9 @@ body { border: 1px solid #ddd; border-radius: 4px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.055); - margin-right: 10px; + padding-right: 10px; margin-bottom: 10px; - width: 99%; + width: 98%; } .style-layer table {