Passed to the geoportal-data-mapper component [#24978]

pull/14/head
Francesco Mangiacrapa 12 months ago
parent 2d4bfbee38
commit 9d059ca4e9

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/geoportal-data-viewer-app-3.3.1/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/geoportal-data-viewer-app-3.4.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-3.3.1/WEB-INF/classes" path="src/main/resources">
<classpathentry excluding="**" kind="src" output="target/geoportal-data-viewer-app-3.4.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-3.3.1/WEB-INF/classes"/>
<classpathentry kind="output" path="target/geoportal-data-viewer-app-3.4.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-3.3.1
lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-3.4.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">
@ -61,8 +61,34 @@
<wb-module deploy-name="geoportal-data-viewer-app-3.3.1">
<wb-module deploy-name="geoportal-data-viewer-app-3.4.0-SNAPSHOT">
@ -125,7 +151,20 @@
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
@ -188,7 +227,20 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
@ -251,7 +303,20 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
@ -314,7 +379,20 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
@ -377,13 +455,20 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="metadata-profile-form-builder-widget-2.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/metadata-profile-form-builder-widget/metadata-profile-form-builder-widget">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="geoportal-data-common-2.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-common/geoportal-data-common">
<dependency-type>uses</dependency-type>
</dependent-module>
@ -446,7 +531,20 @@
<property name="java-output-path" value="/geoportal-data-viewer-app/target/geoportal-data-viewer-app-0.0.1-SNAPSHOT/WEB-INF/classes"/>
@ -509,7 +607,20 @@
<property name="context-root" value="geoportal-data-viewer-app"/>
@ -572,7 +683,20 @@
</wb-module>

@ -4,7 +4,7 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v3.4.0-SNAPSHOT] - 2023-04-13
## [v3.4.0-SNAPSHOT] - 2023-05-05
- Integrated the geoportal-data-mapper component [#24978]

@ -20,7 +20,7 @@
<properties>
<!-- Convenience property to set the GWT version -->
<gwt.version>2.10.0</gwt.version>
<gwt.version>2.9.0</gwt.version>
<gwt.compiler.style>PRETTY</gwt.compiler.style>
<gson.version>2.6.2</gson.version>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
@ -55,7 +55,7 @@
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId>
<version>3.7.0</version>
<version>3.8.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@ -110,6 +110,12 @@
<version>2.3.2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.gcube.application</groupId>
<artifactId>geoportal-data-mapper</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.gcube.spatial.data</groupId>
<artifactId>geo-utility</artifactId>

@ -1010,9 +1010,9 @@ public class LayerManager {
}
});
final Button buttonViewLayers = new Button("Zoom to Layers");
final Button buttonViewLayers = new Button("Zoom in...");
buttonViewLayers.getElement().setId("go-to-layers");
buttonViewLayers.getElement().setTitle("Zoom to Layers");
buttonViewLayers.getElement().setTitle("Zoom in...");
buttonViewLayers.setType(ButtonType.LINK);
if (olMap.getCurrentZoomLevel() >= OLMapManager.LAYER_DETAIL_MAX_RESOLUTION) {
@ -1202,9 +1202,9 @@ public class LayerManager {
}
});
final Button buttonViewLayers = new Button("Zoom to Layers");
final Button buttonViewLayers = new Button("Zoom in...");
buttonViewLayers.getElement().setId("go-to-layers");
buttonViewLayers.getElement().setTitle("Zoom to Layers");
buttonViewLayers.getElement().setTitle("Zoom in...");
buttonViewLayers.setType(ButtonType.LINK);
if (olMap.getCurrentZoomLevel() >= OLMapManager.LAYER_DETAIL_MAX_RESOLUTION) {

@ -61,6 +61,7 @@ import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescrip
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
import org.gcube.application.geoportalcommon.util.URLParserUtil;
import org.gcube.application.geoportaldatamapper.Geoportal_JSON_Mapper;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerService;
import org.gcube.portlets.user.geoportaldataviewer.server.gis.FeatureParser;
@ -117,7 +118,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
public static enum COMMON_IMAGES_FORMAT {
gif, png, jpeg, jpg, bmp, tif, tiff, svg, avif, webp
}
public static enum CENTROID_LAYER_INDEX_FLAG {
PUBLIC("public"), PRIVATE("internal");
@ -130,7 +131,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
public String getId() {
return id;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
@ -139,7 +140,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
builder.append("]");
return builder.toString();
}
}
/**
@ -350,9 +351,9 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
if (item.getProfileID() == null)
throw new Exception("Bad request, the profileID is null");
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
String gcubeScope = SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
GeoportalCommon gc = new GeoportalCommon();
return gc.getPublicLinksFor(item, true);
return gc.getPublicLinksFor(gcubeScope, item, true);
} catch (Exception e) {
LOG.error("Error on getPublicLinksFor for: " + item, e);
@ -490,24 +491,27 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
// TODO constant
coll.setIndexes(new ArrayList());
LOG.debug("Checking if " + u.getId() + " is GIS Indexed. Index flag needed is '" + setIndexFlag+"'");
LOG.debug("Checking if " + u.getId() + " is GIS Indexed. Index flag needed is '"
+ setIndexFlag + "'");
IndexLayerDV toAdd = getLayerIndex(ucdConfig, setIndexFlag);
if(toAdd!=null) {
if (toAdd != null) {
coll.getIndexes().add(toAdd);
}
// Using the public centroid layer as default
if (coll.getIndexes().isEmpty()) {
LOG.info("No available GIS Index for collection " + coll.getUcd().getName() +" with flag "+setIndexFlag.getId());
LOG.info("No available GIS Index for collection " + coll.getUcd().getName()
+ " with flag " + setIndexFlag.getId());
setIndexFlag = CENTROID_LAYER_INDEX_FLAG.PUBLIC;
LOG.info("Prevent fallback - getting the GIS index with flag '"+setIndexFlag.getId() + "' available");
LOG.info("Prevent fallback - getting the GIS index with flag '" + setIndexFlag.getId()
+ "' available");
toAdd = getLayerIndex(ucdConfig, setIndexFlag);
if(toAdd!=null) {
if (toAdd != null) {
coll.getIndexes().add(toAdd);
}
}
if(!coll.getIndexes().isEmpty())
if (!coll.getIndexes().isEmpty())
config.getAvailableCollections().put(coll.getUcd().getId(), coll);
} catch (Throwable t) {
@ -526,16 +530,15 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
}.execute().getResult();
}
private IndexLayerDV getLayerIndex(Configuration ucdConfig, CENTROID_LAYER_INDEX_FLAG flag) {
for (Index index : ucdConfig.getIndexes()) {
try {
IndexLayerDV toAdd = ConvertToDataValueObjectModel.convert(index);
LOG.trace("Discovered index: "+toAdd);
if (toAdd.getFlag().compareToIgnoreCase(flag.getId())==0) {
LOG.debug("Layer index found for flag: "+flag + ", returning");
LOG.trace("Discovered index: " + toAdd);
if (toAdd.getFlag().compareToIgnoreCase(flag.getId()) == 0) {
LOG.debug("Layer index found for flag: " + flag + ", returning");
return toAdd;
}
} catch (Exception e) {
@ -544,7 +547,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
LOG.error("Unable to check index ", t);
}
}
return null;
}
@ -700,7 +703,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
filter.setProjection(projectionForIDs);
ResultSetPaginatedDataIDs searchedDataIDs = new ResultSetPaginatedDataIDs();
Integer totalProjectForProfile = SessionUtil.getTotalDocumentForProfileID(getThreadLocalRequest(),
theProfileID);
@ -818,8 +821,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
LOG.info("Access policy for discovering the layers is: " + accessPolicy);
String filesetParentJSONPath = null;
//(see ticket #24390)
// (see ticket #24390)
if (accessPolicy.equals(ACCESS_POLICY.OPEN)) {
// Filtering for ACCESS_POLICY.OPEN from the fileset when the username is not in
// session. IAM
@ -944,10 +947,10 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
theProjectDV.setProfileName(ucd.getName());
TemporalReferenceDV temporalReference = temporalReferenceForProject(theProject);
if (temporalReference == null)
temporalReference = new TemporalReferenceDV();
theProjectDV.setTemporalReference(temporalReference);
ProjectView projectView = Geoportal_JSON_Mapper.loadProjectView(theProjectDV, scope, userName);
@ -1319,7 +1322,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
break;
Entry<String, Object> entry = entrySetsIt.next();
documentAsMap.put(entry.getKey(), entry.getValue()!=null?entry.getValue().toString():null);
documentAsMap.put(entry.getKey(), entry.getValue() != null ? entry.getValue().toString() : null);
i++;
}
@ -1656,7 +1659,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
}
theResponseString = response.toString();
//LOG.trace(theResponseString);
// LOG.trace(theResponseString);
if (LOG.isDebugEnabled()) {
LOG.debug("getWFSResponse is empty? " + theResponseString.isEmpty());

@ -1,66 +0,0 @@
//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,93 +0,0 @@
package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accesspolicy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class GeoNACheckAccessPolicy.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Sep 9, 2021
*/
public class GeoNACheckAccessPolicy {
private static final Logger LOG = LoggerFactory.getLogger(GeoNACheckAccessPolicy.class);
/**
* The Enum ACCESS_POLICY.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Sep 8, 2021
*/
public static enum ACCESS_POLICY {
OPEN, RESTICTED
}
/**
* Checks if is open access.
*
* @param policy the policy
* @return true, if is open access
*/
private static boolean isOpenAccess(String policy) {
if (policy == null || policy.equalsIgnoreCase(ACCESS_POLICY.OPEN.name())) {
return true;
}
return false;
}
/**
* Checks if is restricted access.
*
* @param policy the policy
* @return true, if is restricted access
*/
private static boolean isRestrictedAccess(String policy) {
if (policy == null || policy.equalsIgnoreCase(ACCESS_POLICY.RESTICTED.name())) {
return true;
}
return false;
}
/**
* Checks if is accessible accoding to access policies
*
* @param policy the policy
* @param myLogin the my login
* @return true, if is accessible
*/
public static boolean isAccessible(String policy, String myLogin) {
boolean bool = isOpenAccess(policy);
if (bool) {
// is open access
return true;
}
//From here managing is NOT OPEN access
if (myLogin == null || myLogin.isEmpty()) {
// here is not open and the user is not authenticated
return false;
}
// Here the login is not null, so checking if the access to item is RESTICTED
bool = isRestrictedAccess(policy);
if (bool) {
// is restricted access
return true;
}
// Here the user is authenticated, but the policy is not managed, so returning
// true
return true;
}
}

@ -26,7 +26,6 @@ public class GeoNaSpatialQueryResult implements Serializable {
// Map with couple (mongoId concessione, list of uploaded GNAImages for the
// concessione)
private Map<String, List<PayloadDV>> mapImages = null;
// private ProjectDV projectDV;
/**
* Instantiates a new geo na data object.
@ -35,15 +34,6 @@ public class GeoNaSpatialQueryResult implements Serializable {
}
// public void setProjectDV(ProjectDV projectDV) {
// this.projectDV = projectDV;
//
// }
//
// public ProjectDV getProjectDV() {
// return projectDV;
// }
/**
* Gets the features.
*

@ -1,131 +0,0 @@
package org.gcube.portlets.user.geoportaldataviewer.shared;
import java.util.ArrayList;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.FilesetDV;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.PayloadDV;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.CategoryWrapper;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper;
/**
* The Class MetaDataProfileBeanExt.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Nov 23, 2022
*/
public class MetaDataProfileBeanExt extends MetaDataProfileBean implements Cloneable {
/**
*
*/
private static final long serialVersionUID = 2518128223147908835L;
private List<FilesetDV> listFileset = null;
/**
* Instantiates a new meta data profile bean ext.
*/
public MetaDataProfileBeanExt() {
super();
}
/**
* Instantiates a new meta data profile bean ext.
*
* @param type the type
* @param title the title
* @param metadataFields the metadata fields
* @param categories the categories
*/
public MetaDataProfileBeanExt(String type, String title, List<MetadataFieldWrapper> metadataFields,
List<CategoryWrapper> categories) {
super(type, title, metadataFields, categories);
}
/**
* Gets the list fileset.
*
* @return the list fileset
*/
public List<FilesetDV> getListFileset() {
if (listFileset == null)
listFileset = new ArrayList<FilesetDV>();
return listFileset;
}
/**
* Sets the list fileset.
*
* @param listFileset the new list fileset
*/
public void setListFileset(List<FilesetDV> listFileset) {
this.listFileset = listFileset;
}
@Override
protected MetaDataProfileBeanExt clone() throws CloneNotSupportedException {
MetaDataProfileBeanExt clonedMDPBE = new MetaDataProfileBeanExt();
clonedMDPBE.setTitle(this.getTitle());
clonedMDPBE.setType(this.getType());
ArrayList<FilesetDV> newListFileset = new ArrayList<FilesetDV>();
for (FilesetDV filesetDV : this.getListFileset()) {
FilesetDV newFileset = new FilesetDV();
for (PayloadDV payloadDV : filesetDV.getListPayload()) {
PayloadDV newPayloadDV = new PayloadDV();
newPayloadDV.setLink(payloadDV.getLink());
newPayloadDV.setMimetype(payloadDV.getMimetype());
newPayloadDV.setName(payloadDV.getName());
newPayloadDV.setStorageID(payloadDV.getStorageID());
newFileset.addPayloadDV(newPayloadDV);
}
newListFileset.add(newFileset);
}
clonedMDPBE.setListFileset(newListFileset);
ArrayList<MetadataFieldWrapper> newListMetadataFieldWrapper = new ArrayList<MetadataFieldWrapper>();
for (MetadataFieldWrapper mfw : this.getMetadataFields()) {
MetadataFieldWrapper newMfw = new MetadataFieldWrapper();
newMfw.setAsGroup(mfw.getAsGroup());
newMfw.setAsTag(mfw.getAsTag());
newMfw.setCurrentValue(mfw.getCurrentValue());
newMfw.setDefaultValue(mfw.getDefaultValue());
newMfw.setFieldId(mfw.getFieldId());
newMfw.setFieldName(mfw.getFieldName());
newMfw.setFieldNameFromCategory(mfw.getFieldNameFromCategory());
newMfw.setMandatory(mfw.getMandatory());
newMfw.setMaxOccurs(mfw.getMaxOccurs());
newMfw.setMultiSelection(mfw.isMultiSelection());
newMfw.setNote(mfw.getNote());
newMfw.setOwnerCategory(mfw.getOwnerCategory());
newMfw.setType(mfw.getType());
newMfw.setValidator(mfw.getValidator());
newMfw.setVocabulary(mfw.getVocabulary());
newListMetadataFieldWrapper.add(newMfw);
}
clonedMDPBE.setMetadataFields(newListMetadataFieldWrapper);
return clonedMDPBE;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("MetaDataProfileBeanExt [getType()=");
builder.append(getType());
builder.append(", getTitle()=");
builder.append(getTitle());
builder.append(", getMetadataFields()=");
builder.append(getMetadataFields());
builder.append("]");
return builder.toString();
}
}

@ -1,50 +0,0 @@
package org.gcube.portlets.user.geoportaldataviewer.shared;
import java.io.Serializable;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
public class ProjectEdit implements Serializable {
/**
*
*/
private static final long serialVersionUID = 2885327516680245601L;
private ProjectDV theProjectDV;
private List<MetaDataProfileBeanExt> theProfileBeans;
public ProjectEdit() {
}
public ProjectDV getTheProjectDV() {
return theProjectDV;
}
public List<MetaDataProfileBeanExt> getTheProfileBeans() {
return theProfileBeans;
}
public void setTheProjectDV(ProjectDV theProjectDV) {
this.theProjectDV = theProjectDV;
}
public void setTheProfileBeans(List<MetaDataProfileBeanExt> theProfileBeans) {
this.theProfileBeans = theProfileBeans;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("ProjectEdit [theProjectDV=");
builder.append(theProjectDV);
builder.append(", theProfileBeans=");
builder.append(theProfileBeans);
builder.append("]");
return builder.toString();
}
}

@ -36,13 +36,11 @@ import org.gcube.application.geoportalcommon.shared.geoportal.materialization.in
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
import org.gcube.application.geoportalcommon.shared.geoportal.project.TemporalReferenceDV;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.application.geoportaldatamapper.Geoportal_JSON_Mapper;
import org.gcube.application.geoportaldatamapper.shared.ProjectEdit;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.geoportaldataviewer.server.Geoportal_JSON_Mapper;
import org.gcube.portlets.user.geoportaldataviewer.shared.ProjectEdit;
import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
/**
* The Class GeoportalViewer_Tests.

Loading…
Cancel
Save