diff --git a/.classpath b/.classpath
index 1e06bac..61bb68c 100644
--- a/.classpath
+++ b/.classpath
@@ -1,12 +1,12 @@
-
+
-
+
@@ -35,5 +35,5 @@
-
+
diff --git a/.settings/com.gwtplugins.gdt.eclipse.core.prefs b/.settings/com.gwtplugins.gdt.eclipse.core.prefs
index c7e650c..3f0dc49 100644
--- a/.settings/com.gwtplugins.gdt.eclipse.core.prefs
+++ b/.settings/com.gwtplugins.gdt.eclipse.core.prefs
@@ -1,4 +1,4 @@
eclipse.preferences.version=1
-lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-3.3.1-SNAPSHOT
+lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-3.4.0-SNAPSHOT
warSrcDir=src/main/webapp
warSrcDirIsOutput=false
diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component
index 9a5da7b..7653269 100644
--- a/.settings/org.eclipse.wst.common.component
+++ b/.settings/org.eclipse.wst.common.component
@@ -1,5 +1,5 @@
-
+
@@ -58,8 +58,48 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -119,7 +159,27 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -179,7 +239,27 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -239,7 +319,27 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -299,7 +399,27 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -359,10 +479,27 @@
-
- uses
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -422,7 +559,27 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -482,7 +639,27 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -542,7 +719,27 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 236459d..cbeb265 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,10 @@
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-05-11
+
+- Integrated the geoportal-data-mapper component [#24978]
+
## [v3.3.1] - 2023-03-30
- Just including new dependencies
diff --git a/README.md b/README.md
index af49df6..7bd7250 100644
--- a/README.md
+++ b/README.md
@@ -16,9 +16,13 @@ The GeoPortal Data Viewer App is an application to access, discovery and navigat
* Vis-Timeline v7.x [VisTimeline](https://github.com/visjs/vis-timeline) is licensed under [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0) and MIT
* Handlebarsjs v4.x [Handlebarsjs](https://handlebarsjs.com/) is licensed under MIT
+## Architecture
+
+
+
## Documentation
-N/A
+Geoportal Service Documentation is available at [gCube CMS Suite](https://geoportal.d4science.org/geoportal-service/docs/index.html)
## Change log
diff --git a/pom.xml b/pom.xml
index 3d7d692..52d3748 100644
--- a/pom.xml
+++ b/pom.xml
@@ -14,13 +14,13 @@
org.gcube.portlets.user
geoportal-data-viewer-app
war
- 3.3.1
+ 3.4.0-SNAPSHOT
GeoPortal Data Viewer App
The GeoPortal Data Viewer App is an application to access, discovery and navigate the Geoportal projects/documents by a Web-Map Interface
- 2.10.0
+ 2.9.0
PRETTY
2.6.2
${project.build.directory}/${project.build.finalName}
@@ -55,7 +55,7 @@
org.gcube.distribution
maven-portal-bom
- 3.7.0
+ 3.8.0-SNAPSHOT
pom
import
@@ -135,13 +135,6 @@
usermanagement-core
provided
-
- org.gcube.portlets.user
- gcube-url-shortener
- [1.0.0,2.0.0-SNAPSHOT)
- compile
-
-
org.projectlombok
@@ -150,30 +143,12 @@
provided
-
- org.gcube.portlets.widgets
- metadata-profile-form-builder-widget
- [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)
+ org.gcube.application
+ geoportal-data-mapper
+ [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)
compile
-
-
-
- com.fasterxml.jackson.core
- jackson-core
-
-
- com.fasterxml.jackson.core
- jackson-databind
-
-
- de.grundid.opendatalab
- geojson-jackson
-
-
-
org.gcube.application
geoportal-data-common
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 3aa4d72..3f35d3e 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
@@ -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) {
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/SectionViewer.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/SectionViewer.java
index 746fc71..6ae6b18 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/SectionViewer.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/SectionViewer.java
@@ -124,7 +124,7 @@ public class SectionViewer extends Composite {
List files = subDocumentView.getListFiles();
if (files != null) {
for (FilesetDV fileset : files) {
- showLinkToDownloadWsContent(fileset.getName(), fileset.getListPayload());
+ showLinkToDownloadWsContent(fileset.getGcubeProfileFieldName(), fileset.getListPayload());
}
}
}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GcubeProfilesMetadataForUCD.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GcubeProfilesMetadataForUCD.java
deleted file mode 100644
index 4c1c242..0000000
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GcubeProfilesMetadataForUCD.java
+++ /dev/null
@@ -1,68 +0,0 @@
-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 listMetadataProfileBean;
-
- public GcubeProfilesMetadataForUCD() {
-
- }
-
- public GcubeProfilesMetadataForUCD(String profileID, GcubeProfileDV gcubeProfile,
- List listMetadataProfileBean) {
-
- this.profileID = profileID;
- this.gcubeProfile = gcubeProfile;
- this.listMetadataProfileBean = listMetadataProfileBean;
- }
-
- public String getProfileID() {
- return profileID;
- }
-
- public GcubeProfileDV getGcubeProfile() {
- return gcubeProfile;
- }
-
- public List getListMetadataProfileBean() {
- return listMetadataProfileBean;
- }
-
- public void setProfileID(String profileID) {
- this.profileID = profileID;
- }
-
- public void setGcubeProfile(GcubeProfileDV gcubeProfile) {
- this.gcubeProfile = gcubeProfile;
- }
-
- public void setListMetadataProfileBean(List 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();
- }
-
-}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GcubeProfilesPerUCDIdCache.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GcubeProfilesPerUCDIdCache.java
deleted file mode 100644
index 524a69f..0000000
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GcubeProfilesPerUCDIdCache.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/**
- *
- */
-
-package org.gcube.portlets.user.geoportaldataviewer.server;
-
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-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.geoportal.GeoportalClientCaller;
-import org.gcube.application.geoportalcommon.geoportal.UseCaseDescriptorCaller;
-import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV;
-import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV;
-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.common.scope.api.ScopeProvider;
-import org.gcube.portlets.widgets.mpformbuilder.server.MetadataProfileFormBuilderServiceImpl;
-import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-import com.google.common.cache.RemovalListener;
-import com.google.common.cache.RemovalNotification;
-
-/**
- * The Class GcubeProfilesPerUCDIdCache.
- *
- * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
- *
- * Oct 12, 2022
- */
-public class GcubeProfilesPerUCDIdCache {
-
- private static Logger LOG = LoggerFactory.getLogger(GcubeProfilesPerUCDIdCache.class);
-
- private static LoadingCache>> gCubeProfilesPerProfileIDCache;
-
- static {
-
- CacheLoader>> loader = new CacheLoader>>() {
- @Override
- public LinkedHashMap> load(String scope) throws Exception {
- LOG.info("Loading the cache for scope: " + scope);
- return loadGcubeProfilesForUCDIdInTheScope(scope);
- }
- };
-
- RemovalListener>> removalListener = new RemovalListener>>() {
- public void onRemoval(
- RemovalNotification>> removal) {
- LOG.info(GcubeProfilesPerUCDIdCache.class.getSimpleName() + " cache expired");
- }
- };
-
- gCubeProfilesPerProfileIDCache = CacheBuilder.newBuilder().maximumSize(1000)
- .expireAfterWrite(30, TimeUnit.MINUTES).removalListener(removalListener).build(loader);
-
- LOG.info("cache instancied");
- }
-
- /**
- * Gets the.
- *
- * @param scope the scope
- * @return the geonetwork instance
- * @throws Exception
- */
- public static LinkedHashMap> get(String scope) throws Exception {
- LOG.info("GcubeProfilesPerUCDIdCache get - called in the scope: " + scope);
- LinkedHashMap> map = gCubeProfilesPerProfileIDCache.get(scope);
- LOG.info("GcubeProfilesPerUCDIdCache returning map null? " + (map==null));
- return map;
- }
-
- /**
- * Load geonetwork instance.
- *
- * @param scope the scope
- * @return the linked hash map
- * @throws Exception the exception
- */
- private static LinkedHashMap> loadGcubeProfilesForUCDIdInTheScope(
- String scope) throws Exception {
- LOG.info("loadGcubeProfilesForUCDIdInTheScope called in the scope: " + scope);
-
- LinkedHashMap> linkedMap_UCDId_gCubeProfiles = new LinkedHashMap>();
- try {
- ScopeProvider.instance.set(scope);
- UseCaseDescriptorCaller clientUCD = GeoportalClientCaller.useCaseDescriptors();
- List 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 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 listGcubeProfiles = (List) config.getConfiguration();
- LOG.debug("List of GcubeProfileDV are: " + listGcubeProfiles);
-
- List listProfilesBean = new ArrayList();
- // Loading Metadata Profile from IS
- MetadataProfileFormBuilderServiceImpl metaProfileBUilder = new MetadataProfileFormBuilderServiceImpl();
-
- for (GcubeProfileDV gcubeProfileDV : listGcubeProfiles) {
- ScopeProvider.instance.set(scope);
- GcubeProfilesMetadataForUCD gCubeProfileMetadataForUCD = new GcubeProfilesMetadataForUCD();
- List listProfiles = metaProfileBUilder.getProfilesInTheScopeForName(scope,
- 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);
-
- if (LOG.isDebugEnabled()) {
- for (String key : linkedMap_UCDId_gCubeProfiles.keySet()) {
- LOG.debug("For key '" + key + "' got profiles: " + linkedMap_UCDId_gCubeProfiles.get(key));
- }
- }
-
- }
-
- } catch (Exception e) {
- String erroMsg = "Error occurred on preloadgCubeProfilesForUCDs: ";
- LOG.error(erroMsg, e);
- }
-
- LOG.info("GcubeProfilesPerUCDIdCache loaded with " + linkedMap_UCDId_gCubeProfiles.size() + " item/s");
- return linkedMap_UCDId_gCubeProfiles;
- }
-}
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 d267fc8..95855fc 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
@@ -61,6 +61,8 @@ 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.GcubeProfilesPerUCDIdCache;
+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 +119,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 +132,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
public String getId() {
return id;
}
-
+
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
@@ -139,7 +141,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
builder.append("]");
return builder.toString();
}
-
+
}
/**
@@ -350,9 +352,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 +492,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 +531,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 +548,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
LOG.error("Unable to check index ", t);
}
}
-
+
return null;
}
@@ -700,7 +704,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
filter.setProjection(projectionForIDs);
ResultSetPaginatedDataIDs searchedDataIDs = new ResultSetPaginatedDataIDs();
-
+
Integer totalProjectForProfile = SessionUtil.getTotalDocumentForProfileID(getThreadLocalRequest(),
theProfileID);
@@ -818,8 +822,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 +948,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 +1323,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
break;
Entry 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 +1660,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());
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/Geoportal_JSON_Mapper.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/Geoportal_JSON_Mapper.java
index e30f206..70343ad 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/Geoportal_JSON_Mapper.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/Geoportal_JSON_Mapper.java
@@ -1,1032 +1,1032 @@
-package org.gcube.portlets.user.geoportaldataviewer.server;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.function.Function;
-
-import org.bson.Document;
-import org.gcube.application.geoportal.client.utils.Serialization;
-import org.gcube.application.geoportal.common.model.document.access.Access;
-import org.gcube.application.geoportal.common.model.document.access.AccessPolicy;
-import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
-import org.gcube.application.geoportalcommon.geoportal.access.GeportalCheckAccessPolicy;
-import org.gcube.application.geoportalcommon.geoportal.serdes.Payload;
-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.materialization.GCubeSDIViewerLayerDV;
-import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.BBOXDV;
-import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.FilesetDV;
-import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.PayloadDV;
-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.view.ProjectView;
-import org.gcube.application.geoportalcommon.shared.geoportal.view.SectionView;
-import org.gcube.application.geoportalcommon.shared.geoportal.view.SubDocumentView;
-import org.gcube.portlets.user.geoportaldataviewer.server.GeoportalDataViewerServiceImpl.ImageDetector;
-import org.gcube.portlets.user.geoportaldataviewer.server.util.URLParserUtil;
-import org.gcube.portlets.user.geoportaldataviewer.shared.MetaDataProfileBeanExt;
-import org.gcube.portlets.user.geoportaldataviewer.shared.ProjectEdit;
-import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
-import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper;
-import org.json.JSONArray;
-import org.json.JSONObject;
-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.jayway.jsonpath.JsonPath;
-import com.jayway.jsonpath.spi.json.JsonOrgJsonProvider;
-
-/**
- * The Class Geoportal_JSON_Mapper.
- *
- * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
- *
- * Oct 24, 2022
- */
-public class Geoportal_JSON_Mapper {
-
- public static final String _PAYLOADS = "_payloads";
-
- public static final String _MATERIALIZATIONS = "_materializations";
-
- public static final String _TYPE_GCUBE_SDI_LAYER = "gcube-sdi-layer";
-
- private static final Logger LOG = LoggerFactory.getLogger(Geoportal_JSON_Mapper.class);
-
- public static final String FILESET = "fileset";
-
- public static final String _OGC_LINKS = "_ogcLinks";
-
- public static final String _BBOX = "_bbox";
-
- public static final String _TYPE = "_type";
-
- public static final String JSON_$_POINTER = "$";
-
- public static final String _THEDOCUMENT = "_theDocument";
-
- public static ProjectEdit loadProjectEdit(ProjectDV theProjectDV, String scope, String username) throws Exception {
-
- String theWholeProjectAsJSON = theProjectDV.getTheDocument().getDocumentAsJSON();
-
- LOG.debug("theProjectDV as JSON: " + theWholeProjectAsJSON);
- LOG.debug("theProjectDV as MAP: " + theProjectDV.getTheDocument().getDocumentAsMap());
-
- ProjectEdit projectView = new ProjectEdit();
- projectView.setTheProjectDV(theProjectDV);
-
- LinkedHashMap> linkedMap_UCDId_gCubeProfiles = GcubeProfilesPerUCDIdCache
- .get(scope);
-
- // NO UCD defined, applying 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");
- Document sectionDoc = Document.parse(theProjectDV.getTheDocument().getDocumentAsJSON());
-
- // Creating one Project with one SectionView and SubDocumentView
- String wholeSectionDoc = sectionDoc.toJson();
-
- List listFiles = new ArrayList();
-
- // Reading Fileset _payloads
- String filesetJSONPath = String.format("%s.%s", JSON_$_POINTER, FILESET);
- List listPayloads = readPayloadsForFileset(filesetJSONPath, wholeSectionDoc);
- FilesetDV filesetDV = new FilesetDV();
- filesetDV.setName(FILESET);
- for (Payload payload : listPayloads) {
- PayloadDV payloadDV = ConvertToDataValueObjectModel.toPayloadDV(payload);
- filesetDV.addPayloadDV(payloadDV);
- listFiles.add(filesetDV);
- }
- }
-
- List listProfilesBean = linkedMap_UCDId_gCubeProfiles
- .get(theProjectDV.getProfileID());
-
- com.jayway.jsonpath.Configuration configuration = com.jayway.jsonpath.Configuration.builder()
- .jsonProvider(new JsonOrgJsonProvider()).build();
-
- // LinkedHashMap mapOfProfilesBeanExt = new
- // LinkedHashMap();
-
- ArrayList listOfProfilesBeanExt = new ArrayList();
-
- // Reading the Project according to list of Profile defined in the UCD
- for (GcubeProfilesMetadataForUCD gcubeProfileMetaForUCD : listProfilesBean) {
-
- GcubeProfileDV gcubeProfileDV = gcubeProfileMetaForUCD.getGcubeProfile();
+//package org.gcube.portlets.user.geoportaldataviewer.server;
+//
+//import java.util.ArrayList;
+//import java.util.HashMap;
+//import java.util.LinkedHashMap;
+//import java.util.List;
+//import java.util.function.Function;
+//
+//import org.bson.Document;
+//import org.gcube.application.geoportal.client.utils.Serialization;
+//import org.gcube.application.geoportal.common.model.document.access.Access;
+//import org.gcube.application.geoportal.common.model.document.access.AccessPolicy;
+//import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
+//import org.gcube.application.geoportalcommon.geoportal.access.GeportalCheckAccessPolicy;
+//import org.gcube.application.geoportalcommon.geoportal.serdes.Payload;
+//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.materialization.GCubeSDIViewerLayerDV;
+//import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.BBOXDV;
+//import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.FilesetDV;
+//import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.PayloadDV;
+//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.view.ProjectView;
+//import org.gcube.application.geoportalcommon.shared.geoportal.view.SectionView;
+//import org.gcube.application.geoportalcommon.shared.geoportal.view.SubDocumentView;
+//import org.gcube.portlets.user.geoportaldataviewer.server.GeoportalDataViewerServiceImpl.ImageDetector;
+//import org.gcube.portlets.user.geoportaldataviewer.server.util.URLParserUtil;
+//import org.gcube.portlets.user.geoportaldataviewer.shared.MetaDataProfileBeanExt;
+//import org.gcube.portlets.user.geoportaldataviewer.shared.ProjectEdit;
+//import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
+//import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper;
+//import org.json.JSONArray;
+//import org.json.JSONObject;
+//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.jayway.jsonpath.JsonPath;
+//import com.jayway.jsonpath.spi.json.JsonOrgJsonProvider;
+//
+///**
+// * The Class Geoportal_JSON_Mapper.
+// *
+// * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
+// *
+// * Oct 24, 2022
+// */
+//public class Geoportal_JSON_Mapper {
+//
+// public static final String _PAYLOADS = "_payloads";
+//
+// public static final String _MATERIALIZATIONS = "_materializations";
+//
+// public static final String _TYPE_GCUBE_SDI_LAYER = "gcube-sdi-layer";
+//
+// private static final Logger LOG = LoggerFactory.getLogger(Geoportal_JSON_Mapper.class);
+//
+// public static final String FILESET = "fileset";
+//
+// public static final String _OGC_LINKS = "_ogcLinks";
+//
+// public static final String _BBOX = "_bbox";
+//
+// public static final String _TYPE = "_type";
+//
+// public static final String JSON_$_POINTER = "$";
+//
+// public static final String _THEDOCUMENT = "_theDocument";
+//
+// public static ProjectEdit loadProjectEdit(ProjectDV theProjectDV, String scope, String username) throws Exception {
+//
+// String theWholeProjectAsJSON = theProjectDV.getTheDocument().getDocumentAsJSON();
+//
+// LOG.debug("theProjectDV as JSON: " + theWholeProjectAsJSON);
+// LOG.debug("theProjectDV as MAP: " + theProjectDV.getTheDocument().getDocumentAsMap());
+//
+// ProjectEdit projectView = new ProjectEdit();
+// projectView.setTheProjectDV(theProjectDV);
+//
+// LinkedHashMap> linkedMap_UCDId_gCubeProfiles = GcubeProfilesPerUCDIdCache
+// .get(scope);
+//
+// // NO UCD defined, applying 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");
+// Document sectionDoc = Document.parse(theProjectDV.getTheDocument().getDocumentAsJSON());
+//
+// // Creating one Project with one SectionView and SubDocumentView
+// String wholeSectionDoc = sectionDoc.toJson();
+//
+// List listFiles = new ArrayList();
+//
+// // Reading Fileset _payloads
+// String filesetJSONPath = String.format("%s.%s", JSON_$_POINTER, FILESET);
+// List listPayloads = readPayloadsForFileset(filesetJSONPath, wholeSectionDoc);
+// FilesetDV filesetDV = new FilesetDV();
+// filesetDV.setGcubeProfileFieldName(FILESET);
+// for (Payload payload : listPayloads) {
+// PayloadDV payloadDV = ConvertToDataValueObjectModel.toPayloadDV(payload);
+// filesetDV.addPayloadDV(payloadDV);
+// listFiles.add(filesetDV);
+// }
+// }
+//
+// List listProfilesBean = linkedMap_UCDId_gCubeProfiles
+// .get(theProjectDV.getProfileID());
+//
+// com.jayway.jsonpath.Configuration configuration = com.jayway.jsonpath.Configuration.builder()
+// .jsonProvider(new JsonOrgJsonProvider()).build();
+//
+// // LinkedHashMap mapOfProfilesBeanExt = new
+// // LinkedHashMap();
+//
+// ArrayList listOfProfilesBeanExt = new ArrayList();
+//
+// // 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());
+//
+// System.out.println("\n\n##### Sto creando la sezione: " + 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 = null;
+// Object data = null;
+// try {
+// theSectionJsonPath = JsonPath.compile(sectionJSONPath);
+// data = theSectionJsonPath.read(theWholeProjectAsJSON, configuration);
+// } catch (Exception e) {
+// LOG.warn("Error on searching the section " + sectionJSONPath + " in the JSON Project: "
+// + theWholeProjectAsJSON);
+// continue;
+// }
+//
+// 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 listBSONDocument = new ArrayList();
+// if (data instanceof org.json.JSONObject) {
+// String jsonString = data.toString();
+// LOG.debug("the JSON to string: " + jsonString);
+// Document sectionDoc = Document.parse(jsonString);
+// 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);
+// listBSONDocument.add(sectionDoc);
+// }
+// }
+//
+// LOG.debug("Result for " + gcubeProfileDV.getSectionName() + " is: " + listBSONDocument);
+// List theProfileBeans = gcubeProfileMetaForUCD.getListMetadataProfileBean();
+// MetaDataProfileBean theProfileBean = theProfileBeans.get(0);
+//
+// // For each bson.Document filling the MetaDataProfileBean and its file
+// for (int i = 0; i < listBSONDocument.size(); i++) {
+//
+// System.out.println("DOCUMENT number " + i + " of the section: " + theProfileBean.getTitle());
+// MetaDataProfileBeanExt theProfileBeanExt = new MetaDataProfileBeanExt();
+// theProfileBeanExt.setCategories(theProfileBean.getCategories());
+// theProfileBeanExt.setTitle(theProfileBean.getTitle());
+// theProfileBeanExt.setType(theProfileBean.getType());
+//
+//// System.out.println("\nPRINTING PROJECT VIEW ON START: ");
+//// for (int j = 0; j < listOfProfilesBeanExt.size(); j++) {
+//// MetaDataProfileBeanExt metaDataProfileBeanExt = listOfProfilesBeanExt.get(j);
+//// System.out.println("MetaDataProfileBeanExt index: " + j + " "+metaDataProfileBeanExt.getType() +" "+metaDataProfileBeanExt.hashCode());
+//// int z = 0;
+//// for (MetadataFieldWrapper mfw : metaDataProfileBeanExt.getMetadataFields()) {
+//// System.out.println("\t MetadataFieldWrapper index: " + z++ + " " + mfw);
+//// }
+//// }
+//
+// Document fromSectionDoc = listBSONDocument.get(i);
+// LOG.debug("\n\nNew section DOC for index " + i + " is: "
+// + new JSONObject(fromSectionDoc.toJson()).toString(2));
+// // Creating the corresponding MetaDataProfileBeanExt for each section
+//
+// // Reading policy and license statically
+// // eg. "_access":{"_policy":"OPEN","_license":"CC0-1.0"}}
+// Document docAccess = null;
+// Access access = null;
+// try {
+// docAccess = fromSectionDoc.get("_access", Document.class);
+// System.out.println("docAccess is: " + docAccess);
+// access = new Access();
+// access.setPolicy(AccessPolicy.valueOf(docAccess.getString("_policy")));
+// access.setLicense(docAccess.getString("_license"));
+// // Access. access.get("_policy");
+// // access.get("_license");
+// System.out.println("access is: " + access);
+// } catch (Exception e) {
+// e.printStackTrace();
+// }
+//
+// // List copyOfMetadataFields = new
+// // ArrayList(theProfileBean.getMetadataFields());
+// // int forIndex = 0;
+//
+// List cloneListOfMFW = cloneList(theProfileBean.getMetadataFields());
+//
+// for (MetadataFieldWrapper metadataField : cloneListOfMFW) {
+//
+// String theFieldName = metadataField.getFieldId() != null ? metadataField.getFieldId()
+// : metadataField.getFieldName();
+// LOG.debug("reading theFieldName: " + theFieldName);
+// Object theOBJFieldValue = fromSectionDoc.get(theFieldName);
+// metadataField.setCurrentValue(theOBJFieldValue + "");
+//
+// if (access != null) {
+// if (theFieldName.equalsIgnoreCase("policy")) {
+// metadataField.setCurrentValue(access.getPolicy().name());
+// } else if (theFieldName.equalsIgnoreCase("licenseID")) {
+// metadataField.setCurrentValue(access.getLicense());
+// }
+// }
+// // copyOfMetadataFields.set(forIndex++, metadataField);
+// }
+//
+// LOG.debug("Before assigning it Metadata fields are: " + cloneListOfMFW);
+//
+// theProfileBeanExt.setMetadataFields(new ArrayList(cloneListOfMFW));
+// LOG.debug("Metadata fields are: " + theProfileBeanExt.getMetadataFields());
+//
+// // Reading filePaths
+// List filePaths = gcubeProfileDV.getFilePaths();
+// List listLayers = new ArrayList();
+//
+// // READING fileset* field ACCORDING TO filePaths OF THE 'gcubeProfiles' CONFIG
+// if (filePaths != null) {
+// String fromSectionDocJSON = fromSectionDoc.toJson();
+// List listFiles = new ArrayList();
+//// List listLayers = new ArrayList();
+// for (FilePathDV filePath : filePaths) {
+//
+// // Reading Fileset _payloads
+// String filesetJSONPath = String.format("%s.%s", JSON_$_POINTER, filePath.getFieldName());
+// List listPayloads = readPayloadsForFileset(filesetJSONPath, fromSectionDocJSON);
+// FilesetDV filesetDV = new FilesetDV();
+// filesetDV.setGcubeProfileFieldName(filePath.getGcubeProfileFieldName());
+// for (Payload payload : listPayloads) {
+// PayloadDV payloadDV = ConvertToDataValueObjectModel.toPayloadDV(payload);
+// filesetDV.addPayloadDV(payloadDV);
+//
+// }
+// listFiles.add(filesetDV);
+//
+// // Reading Fileset _materializations
+// // listLayers = readGcubeSDILayersForFileset(filesetJSONPath,
+// // fromSectionDocJSON);
+// // theProfileBeanExt.set
+//
+// }
+//
+// theProfileBeanExt.setListFileset(listFiles);
+// }
+//
+// System.out.println("\nputting theProfileBeanExt: " + theProfileBeanExt);
+// listOfProfilesBeanExt.add(theProfileBeanExt);
+//
+//// System.out.println("\nPRINTING PROJECT VIEW ON END: ");
+//// for (int j = 0; j < listOfProfilesBeanExt.size(); j++) {
+//// MetaDataProfileBeanExt metaDataProfileBeanExt = listOfProfilesBeanExt.get(j);
+//// System.out.println("MetaDataProfileBeanExt index: " + j + " "+metaDataProfileBeanExt.getType() +" "+metaDataProfileBeanExt.hashCode());
+//// int z = 0;
+//// for (MetadataFieldWrapper mfw : metaDataProfileBeanExt.getMetadataFields()) {
+//// System.out.println("\t MetadataFieldWrapper index: " + z++ + " " + mfw);
+//// }
+//// }
+////
+//// System.out.println(listProfileBeansExt.get(listProfileBeansExt.size()-1));
+// // Geoportal_JSON_Mapper.prettyPrintProjectEdit(projectView);
+// }
+//
+// }
+//
+// projectView.setTheProfileBeans(listOfProfilesBeanExt);
+//
+// // Geoportal_JSON_Mapper.prettyPrintProjectEdit(projectView);
+//
+// return projectView;
+// }
+//
+// public static List cloneList(List list) {
+// List listCloned = new ArrayList(list.size());
+//
+// Function cloneWrapper = (mfw) -> {
+//
+// 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());
+//
+// return newMfw;
+//
+// };
+//
+// for (MetadataFieldWrapper item : list) {
+// MetadataFieldWrapper cloned = cloneWrapper.apply(item);
+// listCloned.add(cloned);
+// }
+// return listCloned;
+// }
+//
+// /**
+// * Load project view.
+// *
+// * @param theProjectDV the the project DV
+// * @param scope the scope
+// * @param username the username
+// * @return the project view
+// * @throws Exception the exception
+// */
+// public static ProjectView loadProjectView(ProjectDV theProjectDV, String scope, String username) throws Exception {
+//
+// 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> linkedMap_UCDId_gCubeProfiles = GcubeProfilesPerUCDIdCache
+// .get(scope);
+//
+// // NO UCD defined, applying 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();
+//
+// Document sectionDoc = Document.parse(theProjectDV.getTheDocument().getDocumentAsJSON());
+// boolean isAccessibleSection = isAccessibleSectionAccordingToPolicy(sectionDoc, JSON_$_POINTER, username);
+//
+// // If is accessible
+// if (isAccessibleSection) {
+//
+// // Creating one Project with one SectionView and SubDocumentView
+// String wholeSectionDoc = sectionDoc.toJson();
+// subDocumentView.setMetadataAsJSON(wholeSectionDoc);
+//
+// List listFiles = new ArrayList();
+// List listImages = new ArrayList();
+// List listLayers = new ArrayList();
+//
+// // Reading Fileset _payloads
+// String filesetJSONPath = String.format("%s.%s", JSON_$_POINTER, FILESET);
+// List listPayloads = readPayloadsForFileset(filesetJSONPath, wholeSectionDoc);
+// FilesetDV filesetDV = new FilesetDV();
+// filesetDV.setGcubeProfileFieldName(FILESET);
+// 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.setListImages(listImages);
+// subDocumentView.setListFiles(listFiles);
+//
+// // Reading Fileset _materializations / layers
+// listLayers = readGcubeSDILayersForFileset(filesetJSONPath, wholeSectionDoc);
+//
+// subDocumentView.setListLayers(listLayers);
+// sectionView.addSubDocument(subDocumentView);
+// projectView.addSectionView(sectionView);
+//
+// }
+//
+// }
+//
+// List listProfilesBean = linkedMap_UCDId_gCubeProfiles
+// .get(theProjectDV.getProfileID());
+//
+// 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());
-
- System.out.println("\n\n##### Sto creando la sezione: " + 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 = null;
- Object data = null;
- try {
- theSectionJsonPath = JsonPath.compile(sectionJSONPath);
- data = theSectionJsonPath.read(theWholeProjectAsJSON, configuration);
- } catch (Exception e) {
- LOG.warn("Error on searching the section " + sectionJSONPath + " in the JSON Project: "
- + theWholeProjectAsJSON);
- continue;
- }
-
- 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 listBSONDocument = new ArrayList();
- if (data instanceof org.json.JSONObject) {
- String jsonString = data.toString();
- LOG.debug("the JSON to string: " + jsonString);
- Document sectionDoc = Document.parse(jsonString);
- 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);
- listBSONDocument.add(sectionDoc);
- }
- }
-
- LOG.debug("Result for " + gcubeProfileDV.getSectionName() + " is: " + listBSONDocument);
- List theProfileBeans = gcubeProfileMetaForUCD.getListMetadataProfileBean();
- MetaDataProfileBean theProfileBean = theProfileBeans.get(0);
-
- // For each bson.Document filling the MetaDataProfileBean and its file
- for (int i = 0; i < listBSONDocument.size(); i++) {
-
- System.out.println("DOCUMENT number " + i + " of the section: " + theProfileBean.getTitle());
- MetaDataProfileBeanExt theProfileBeanExt = new MetaDataProfileBeanExt();
- theProfileBeanExt.setCategories(theProfileBean.getCategories());
- theProfileBeanExt.setTitle(theProfileBean.getTitle());
- theProfileBeanExt.setType(theProfileBean.getType());
-
-// System.out.println("\nPRINTING PROJECT VIEW ON START: ");
-// for (int j = 0; j < listOfProfilesBeanExt.size(); j++) {
-// MetaDataProfileBeanExt metaDataProfileBeanExt = listOfProfilesBeanExt.get(j);
-// System.out.println("MetaDataProfileBeanExt index: " + j + " "+metaDataProfileBeanExt.getType() +" "+metaDataProfileBeanExt.hashCode());
-// int z = 0;
-// for (MetadataFieldWrapper mfw : metaDataProfileBeanExt.getMetadataFields()) {
-// System.out.println("\t MetadataFieldWrapper index: " + z++ + " " + mfw);
-// }
+// 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 = null;
+// Object data = null;
+// try {
+// theSectionJsonPath = JsonPath.compile(sectionJSONPath);
+// data = theSectionJsonPath.read(theWholeProjectAsJSON, configuration);
+// } catch (Exception e) {
+// LOG.warn("Error on searching the section " + sectionJSONPath + " in the JSON Project: "
+// + theWholeProjectAsJSON);
+// continue;
+// }
+//
+// 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 listBSONDocument = new ArrayList();
+// 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);
// }
-
- Document fromSectionDoc = listBSONDocument.get(i);
- LOG.debug("\n\nNew section DOC for index " + i + " is: "
- + new JSONObject(fromSectionDoc.toJson()).toString(2));
- // Creating the corresponding MetaDataProfileBeanExt for each section
-
- // Reading policy and license statically
- // eg. "_access":{"_policy":"OPEN","_license":"CC0-1.0"}}
- Document docAccess = null;
- Access access = null;
- try {
- docAccess = fromSectionDoc.get("_access", Document.class);
- System.out.println("docAccess is: " + docAccess);
- access = new Access();
- access.setPolicy(AccessPolicy.valueOf(docAccess.getString("_policy")));
- access.setLicense(docAccess.getString("_license"));
- // Access. access.get("_policy");
- // access.get("_license");
- System.out.println("access is: " + access);
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- // List copyOfMetadataFields = new
- // ArrayList(theProfileBean.getMetadataFields());
- // int forIndex = 0;
-
- List cloneListOfMFW = cloneList(theProfileBean.getMetadataFields());
-
- for (MetadataFieldWrapper metadataField : cloneListOfMFW) {
-
- String theFieldName = metadataField.getFieldId() != null ? metadataField.getFieldId()
- : metadataField.getFieldName();
- LOG.debug("reading theFieldName: " + theFieldName);
- Object theOBJFieldValue = fromSectionDoc.get(theFieldName);
- metadataField.setCurrentValue(theOBJFieldValue + "");
-
- if (access != null) {
- if (theFieldName.equalsIgnoreCase("policy")) {
- metadataField.setCurrentValue(access.getPolicy().name());
- } else if (theFieldName.equalsIgnoreCase("licenseID")) {
- metadataField.setCurrentValue(access.getLicense());
- }
- }
- // copyOfMetadataFields.set(forIndex++, metadataField);
- }
-
- LOG.debug("Before assigning it Metadata fields are: " + cloneListOfMFW);
-
- theProfileBeanExt.setMetadataFields(new ArrayList(cloneListOfMFW));
- LOG.debug("Metadata fields are: " + theProfileBeanExt.getMetadataFields());
-
- // Reading filePaths
- List filePaths = gcubeProfileDV.getFilePaths();
- List listLayers = new ArrayList();
-
- // READING fileset* field ACCORDING TO filePaths OF THE 'gcubeProfiles' CONFIG
- if (filePaths != null) {
- String fromSectionDocJSON = fromSectionDoc.toJson();
- List listFiles = new ArrayList();
+//
+// } 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 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 filePaths = gcubeProfileDV.getFilePaths();
+//
+// // READING fileset* field ACCORDING TO filePaths OF THE 'gcubeProfiles' CONFIG
+// if (filePaths != null) {
+// String fromSectionDocJSON = fromSectionDoc.toJson();
+// List listFiles = new ArrayList();
+// List listImages = new ArrayList();
// List listLayers = new ArrayList();
- for (FilePathDV filePath : filePaths) {
-
- // Reading Fileset _payloads
- String filesetJSONPath = String.format("%s.%s", JSON_$_POINTER, filePath.getFieldName());
- List listPayloads = readPayloadsForFileset(filesetJSONPath, fromSectionDocJSON);
- FilesetDV filesetDV = new FilesetDV();
- filesetDV.setName(filePath.getGcubeProfileFieldName());
- for (Payload payload : listPayloads) {
- PayloadDV payloadDV = ConvertToDataValueObjectModel.toPayloadDV(payload);
- filesetDV.addPayloadDV(payloadDV);
-
- }
- listFiles.add(filesetDV);
-
- // Reading Fileset _materializations
- // listLayers = readGcubeSDILayersForFileset(filesetJSONPath,
- // fromSectionDocJSON);
- // theProfileBeanExt.set
-
- }
-
- theProfileBeanExt.setListFileset(listFiles);
- }
-
- System.out.println("\nputting theProfileBeanExt: " + theProfileBeanExt);
- listOfProfilesBeanExt.add(theProfileBeanExt);
-
-// System.out.println("\nPRINTING PROJECT VIEW ON END: ");
-// for (int j = 0; j < listOfProfilesBeanExt.size(); j++) {
-// MetaDataProfileBeanExt metaDataProfileBeanExt = listOfProfilesBeanExt.get(j);
-// System.out.println("MetaDataProfileBeanExt index: " + j + " "+metaDataProfileBeanExt.getType() +" "+metaDataProfileBeanExt.hashCode());
-// int z = 0;
-// for (MetadataFieldWrapper mfw : metaDataProfileBeanExt.getMetadataFields()) {
-// System.out.println("\t MetadataFieldWrapper index: " + z++ + " " + mfw);
+// for (FilePathDV filePath : filePaths) {
+//
+// // Reading Fileset _payloads
+// String filesetJSONPath = String.format("%s.%s", JSON_$_POINTER, filePath.getFieldName());
+// List listPayloads = readPayloadsForFileset(filesetJSONPath, fromSectionDocJSON);
+// if(LOG.isDebugEnabled()) {
+// for (Payload payload : listPayloads) {
+// LOG.debug("read payload: " + payload);
+// }
+// }
+//
+// FilesetDV filesetImages = new FilesetDV();
+// FilesetDV filesetFiles = new FilesetDV();
+//
+// for (Payload payload : listPayloads) {
+// PayloadDV payloadDV = ConvertToDataValueObjectModel.toPayloadDV(payload);
+// //filesetDV.addPayloadDV(payloadDV);
+// boolean isImage = ImageDetector.isImage(payload.getMimetype());
+//
+// if (isImage) {
+// filesetImages.setGcubeProfileFieldName(filePath.getGcubeProfileFieldName());
+// filesetImages.addPayloadDV(payloadDV);
+// } else {
+// filesetFiles.addPayloadDV(payloadDV);
+// filesetFiles.setGcubeProfileFieldName(filePath.getGcubeProfileFieldName());
+// }
+// }
+//
+// //Setting only if one element exists
+// if(filesetImages.getListPayload()!=null && filesetImages.getListPayload().size()>0) {
+// listImages.add(filesetImages);
+// }
+// if(filesetFiles.getListPayload()!=null && filesetFiles.getListPayload().size()>0) {
+// listFiles.add(filesetFiles);
+// }
+//
+// // Reading Fileset _materializations
+// listLayers = readGcubeSDILayersForFileset(filesetJSONPath, fromSectionDocJSON);
+//
+// }
+// subDocumentView.setListFiles(listFiles);
+// subDocumentView.setListImages(listImages);
+// subDocumentView.setListLayers(listLayers);
+// }
+//
+// sectionView.addSubDocument(subDocumentView);
+//
+// }
+//
+// projectView.addSectionView(sectionView);
+// }
+//
+// LOG.debug("returning the projectView: " + projectView);
+// return projectView;
+// }
+//
+// /**
+// * Read payloads for fileset.
+// *
+// * @param filesetJSONPath the fileset JSON path
+// * @param sectionJSONDocument the section JSON document
+// * @return the list
+// */
+// public static List readPayloadsForFileset(String filesetJSONPath, String sectionJSONDocument) {
+// LOG.debug("readPayloadsForFileset called");
+//
+// List listPayloads = new ArrayList();
+// String _payloadsJSONPath = String.format("%s.%s", filesetJSONPath, _PAYLOADS);
+// try {
+// com.jayway.jsonpath.Configuration configuration = com.jayway.jsonpath.Configuration.builder()
+// .jsonProvider(new JsonOrgJsonProvider()).build();
+//
+// LOG.debug("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.warn("Error on reading the JSON Path " + _payloadsJSONPath + " in the doc " + sectionJSONDocument, e);
+// }
+//
+// return listPayloads;
+//
+// }
+//
+// /**
+// * Read images for fileset.
+// *
+// * @param parentJSONPath the parent JSON path
+// * @param sectionJSONDocument the section JSON document
+// * @param limitToFirstOneFound the limit to first one found
+// * @return the list
+// */
+// public static List readImagesForFileset(String parentJSONPath, String sectionJSONDocument,
+// boolean limitToFirstOneFound) {
+// LOG.info("readImagesForFileset called");
+//
+// List listImages = new ArrayList();
+// com.jayway.jsonpath.Configuration config = com.jayway.jsonpath.Configuration.builder()
+// .jsonProvider(new JsonOrgJsonProvider()).build();
+// // Reading Fileset _payloads
+// String filesetJSONPath = String.format("%s.%s", parentJSONPath, _PAYLOADS);
+// LOG.debug("Reading sectionPath {} into section document {}", filesetJSONPath, sectionJSONDocument);
+// JsonPath theSectionPolycJsonPath = JsonPath.compile(filesetJSONPath);
+// Object _filesets = theSectionPolycJsonPath.read(sectionJSONDocument, config);
+//
+// List payloads = new ArrayList();
+// List listPayloads = recursiveFetchingPayloads(config, _filesets, payloads);
+// for (Payload payload : listPayloads) {
+// boolean isImage = ImageDetector.isImage(payload.getMimetype());
+// if (isImage) {
+// PayloadDV payloadDV = ConvertToDataValueObjectModel.toPayloadDV(payload);
+// listImages.add(payloadDV);
+// if (limitToFirstOneFound && listImages.size() == 1)
+// return listImages;
+// }
+// }
+//
+// LOG.debug("readImagesForFileset returning listOfImages: " + listImages);
+// return listImages;
+//
+// }
+//
+// /**
+// * Read gcube SDI layers for fileset.
+// *
+// * @param materializationParentJSONPath the materialization parent JSON path
+// * @param sectionJSONDocument the section JSON document
+// * @return the list
+// */
+// public static List readGcubeSDILayersForFileset(String materializationParentJSONPath,
+// String sectionJSONDocument) {
+// LOG.info("readGcubeSDILayersForFileset called");
+//
+// List listSDILayers = new ArrayList();
+// // _materializations AT THE MOMENT ARE ONLY OF TYPE gcube-sdi-layer. I'm adding
+// // the filtering "_type": "gcube-sdi-layer" to be sure of reading SDI layer
+// String _materializationsJSONPath = String.format("%s.%s[?(@._type=='%s')]", materializationParentJSONPath,
+// _MATERIALIZATIONS, _TYPE_GCUBE_SDI_LAYER);
+// // [?(@._access._policy=='%s')]
+//
+// try {
+// com.jayway.jsonpath.Configuration configurationJSONSmart = com.jayway.jsonpath.Configuration.builder()
+// .jsonProvider(new JsonOrgJsonProvider()).build();
+//
+// LOG.debug("GcubeSDILayers Reading sectionPath {} into section document {}", _materializationsJSONPath,
+// sectionJSONDocument);
+//
+// JsonPath theSectionMaterializationJsonPath = JsonPath.compile(_materializationsJSONPath);
+// Object _materializations = theSectionMaterializationJsonPath.read(sectionJSONDocument,
+// configurationJSONSmart);
+//
+// LOG.trace("_materializations.class(): " + _materializations.getClass());
+//
+// listSDILayers = recursiveFetchingLayers(configurationJSONSmart, _materializations, listSDILayers);
+//
+// } catch (Exception e) {
+// LOG.debug("Error on reading the JSON Path " + _materializationsJSONPath + " in the doc "
+// + sectionJSONDocument, e);
+// }
+// LOG.info("returning list of layers {}", listSDILayers);
+// return listSDILayers;
+//
+// }
+//
+// /**
+// * Recursive fetching layers.
+// *
+// * @param config the config
+// * @param objectJSON the object JSON
+// * @param listSDILayers the list SDI layers
+// * @return the list
+// */
+// private static List recursiveFetchingLayers(com.jayway.jsonpath.Configuration config,
+// Object objectJSON, List listSDILayers) {
+//
+// if (objectJSON == null)
+// return listSDILayers;
+//
+// if (objectJSON instanceof JSONArray) {
+// JSONArray theJsonArray = (JSONArray) objectJSON;
+// LOG.debug("jsonArray: " + theJsonArray.toString(3));
+//
+// for (int i = 0; i < theJsonArray.length(); i++) {
+// recursiveFetchingLayers(config, theJsonArray.get(i), listSDILayers);
+// }
+// } else if (objectJSON instanceof JSONObject) {
+// JSONObject theJsonObject = (JSONObject) objectJSON;
+// LOG.debug("theJSONObject: " + theJsonObject.toString(3));
+// GCubeSDIViewerLayerDV gsdiLayer = converLayer(config, theJsonObject);
+// listSDILayers.add(gsdiLayer);
+// }
+//
+// return listSDILayers;
+// }
+//
+// /**
+// * Recursive fetching payloads.
+// *
+// * @param config the config
+// * @param objectJSON the object JSON
+// * @param payloads the payloads
+// * @return the list
+// */
+// public static List recursiveFetchingPayloads(com.jayway.jsonpath.Configuration config, Object objectJSON,
+// List payloads) {
+// LOG.debug("recursiveFetchingPayloads called");
+//
+// if (objectJSON == null)
+// return payloads;
+//
+// if (objectJSON instanceof JSONArray) {
+// JSONArray theJsonArray = (JSONArray) objectJSON;
+// LOG.trace("jsonArray: " + theJsonArray.toString(3));
+//
+// for (int i = 0; i < theJsonArray.length(); i++) {
+// payloads = recursiveFetchingPayloads(config, theJsonArray.get(i), payloads);
+// }
+// } else if (objectJSON instanceof JSONObject) {
+// JSONObject toStringPayloads = (JSONObject) objectJSON;
+// LOG.trace("The _payloads is a String {}", toStringPayloads.toString(3));
+// Payload payload;
+// try {
+// payload = Serialization.read(toStringPayloads.toString(), Payload.class);
+// payloads.add(payload);
+// } catch (Exception e) {
+// LOG.warn("Error on converting the JSON Boject " + toStringPayloads + "as "
+// + Payload.class.getSimpleName() + e.getMessage());
+// }
+//
+// }
+//
+// return payloads;
+//
+// }
+//
+// /**
+// * Conver layer.
+// *
+// * @param config the config
+// * @param thJsonObject the th json object
+// * @return the g cube SDI viewer layer DV
+// */
+// // TODO THIS PART SHOULD BE REVISITED/OPTIMIZED
+// private static GCubeSDIViewerLayerDV converLayer(com.jayway.jsonpath.Configuration config,
+// JSONObject thJsonObject) {
+// LOG.debug("converLayer called for " + thJsonObject);
+//
+// GCubeSDIViewerLayerDV gsdiLayer = new GCubeSDIViewerLayerDV();
+// try {
+// String theType = thJsonObject.getString(_TYPE);
+// gsdiLayer.setType(theType);
+// LOG.debug(_TYPE + " is: " + theType);
+// } catch (Exception e) {
+// LOG.warn("No " + _TYPE + " found", e);
+// }
+// String toSerializeJSONOBJ = thJsonObject.toString();
+// String jsonPath = null;
+// try {
+// jsonPath = String.format("%s.%s", JSON_$_POINTER, _BBOX);
+// HashMap bbox = JsonPath.using(config).parse(toSerializeJSONOBJ).read(jsonPath,
+// HashMap.class);
+// BBOXDV bboxDV = new BBOXDV(bbox);
+// gsdiLayer.setBbox(bboxDV);
+// LOG.debug(_BBOX + " is: " + bboxDV);
+// } catch (Exception e) {
+// LOG.warn(jsonPath + " error: ", e);
+// }
+// try {
+// jsonPath = String.format("%s.%s", JSON_$_POINTER, _OGC_LINKS);
+// String jsonString = JsonPath.using(config).parse(toSerializeJSONOBJ).read(jsonPath).toString();
+// Gson gson = new Gson();
+// HashMap map = gson.fromJson(jsonString, HashMap.class);
+// gsdiLayer.setOgcLinks(map);
+// LOG.debug(_OGC_LINKS + " are: " + map);
+// } catch (Exception e) {
+// LOG.warn(jsonPath + " error: ", e);
+// }
+//
+// try {
+// String wmsLink = gsdiLayer.getWMSLink();
+// if (wmsLink != null) {
+// String layerName = URLParserUtil.extractValueOfParameterFromURL("layers", wmsLink);
+// gsdiLayer.setLayerName(layerName);
+// }
+// } catch (Exception e) {
+// LOG.warn(jsonPath + " error: ", e);
+// }
+//
+// LOG.debug("converLayer returning: " + gsdiLayer);
+// return gsdiLayer;
+// }
+//
+// /**
+// * 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
+// */
+// public static 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 static boolean checkAccessPolicy(String sectionDocumentJSON, String myLogin) {
+// LOG.info("checkAccessPolicy called");
+// // CHECKING THE POLICY
+// // see ticket #24390
+// // First reading the access policy from the fileset
+// String accessPolicyPath = JSON_$_POINTER + ".fileset._access._policy";
+// boolean isAccessible = true;
+// try {
+// com.jayway.jsonpath.Configuration configuration = com.jayway.jsonpath.Configuration.builder()
+// .jsonProvider(new JsonOrgJsonProvider()).build();
+//
+// LOG.debug("Reading access policy at {} into section document {}", accessPolicyPath, sectionDocumentJSON);
+// String _policy = null;
+// try {
+// JsonPath theSectionPolycJsonPath = JsonPath.compile(accessPolicyPath);
+// _policy = theSectionPolycJsonPath.read(sectionDocumentJSON, configuration).toString();
+//
+// if (_policy == null)
+// throw new Exception("Policy is null");
+//
+// } catch (Exception e) {
+// LOG.debug("Access policy not found in: " + accessPolicyPath);
+// }
+//
+// // If policy does not exist into fileset, reading from the parent section
+// if (_policy == null) {
+// accessPolicyPath = JSON_$_POINTER + "._access._policy";
+// LOG.debug("Reading access policy at {} into section document {}", accessPolicyPath,
+// sectionDocumentJSON);
+// try {
+// JsonPath theSectionPolycJsonPath = JsonPath.compile(accessPolicyPath);
+// _policy = theSectionPolycJsonPath.read(sectionDocumentJSON, configuration).toString();
+//
+// if (_policy == null)
+// throw new Exception("Policy is null");
+//
+// } catch (Exception e) {
+// LOG.debug("Access policy not found in: " + accessPolicyPath);
+// }
+// }
+//
+// LOG.debug("The section {} has policy {}", accessPolicyPath, _policy);
+// isAccessible = GeportalCheckAccessPolicy.isAccessible(_policy, myLogin);
+// } catch (Exception e) {
+// LOG.error(accessPolicyPath + " not found. Check OK");
+// }
+// LOG.info("It is {} accessible the section {} accessible? {}", isAccessible, sectionDocumentJSON);
+// return isAccessible;
+// }
+//
+// /**
+// * Sanitize document value.
+// *
+// * @param toDoc the to doc
+// * @param fieldLabel the field label
+// * @param theObjectFieldValue the the object field value
+// * @return the document
+// */
+// private static 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, toString.trim());
+// } 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;
+// }
+//
+// /**
+// * Pretty print JSON.
+// *
+// * @param jsonString the json string
+// * @return the string
+// */
+// private static String prettyPrintJSON(String jsonString) {
+//
+// Gson gson = new GsonBuilder().setPrettyPrinting().create();
+// JsonObject jsonObject = new JsonParser().parse(jsonString).getAsJsonObject();
+// return gson.toJson(jsonObject);
+// }
+//
+// /**
+// * Pretty print project view.
+// *
+// * @param projectView the project view
+// */
+// public static void prettyPrintProjectView(ProjectView projectView) {
+//
+// 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.getGcubeProfileFieldName());
+// for (PayloadDV payload : filesetDV.getListPayload()) {
+// System.out.println("********* Payload: " + payload);
+// }
// }
// }
-//
-// System.out.println(listProfileBeansExt.get(listProfileBeansExt.size()-1));
- // Geoportal_JSON_Mapper.prettyPrintProjectEdit(projectView);
- }
-
- }
-
- projectView.setTheProfileBeans(listOfProfilesBeanExt);
-
- // Geoportal_JSON_Mapper.prettyPrintProjectEdit(projectView);
-
- return projectView;
- }
-
- public static List cloneList(List list) {
- List listCloned = new ArrayList(list.size());
-
- Function cloneWrapper = (mfw) -> {
-
- 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());
-
- return newMfw;
-
- };
-
- for (MetadataFieldWrapper item : list) {
- MetadataFieldWrapper cloned = cloneWrapper.apply(item);
- listCloned.add(cloned);
- }
- return listCloned;
- }
-
- /**
- * Load project view.
- *
- * @param theProjectDV the the project DV
- * @param scope the scope
- * @param username the username
- * @return the project view
- * @throws Exception the exception
- */
- public static ProjectView loadProjectView(ProjectDV theProjectDV, String scope, String username) throws Exception {
-
- 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> linkedMap_UCDId_gCubeProfiles = GcubeProfilesPerUCDIdCache
- .get(scope);
-
- // NO UCD defined, applying 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();
-
- Document sectionDoc = Document.parse(theProjectDV.getTheDocument().getDocumentAsJSON());
- boolean isAccessibleSection = isAccessibleSectionAccordingToPolicy(sectionDoc, JSON_$_POINTER, username);
-
- // If is accessible
- if (isAccessibleSection) {
-
- // Creating one Project with one SectionView and SubDocumentView
- String wholeSectionDoc = sectionDoc.toJson();
- subDocumentView.setMetadataAsJSON(wholeSectionDoc);
-
- List listFiles = new ArrayList();
- List listImages = new ArrayList();
- List listLayers = new ArrayList();
-
- // Reading Fileset _payloads
- String filesetJSONPath = String.format("%s.%s", JSON_$_POINTER, FILESET);
- List listPayloads = readPayloadsForFileset(filesetJSONPath, wholeSectionDoc);
- FilesetDV filesetDV = new FilesetDV();
- filesetDV.setName(FILESET);
- 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.setListImages(listImages);
- subDocumentView.setListFiles(listFiles);
-
- // Reading Fileset _materializations / layers
- listLayers = readGcubeSDILayersForFileset(filesetJSONPath, wholeSectionDoc);
-
- subDocumentView.setListLayers(listLayers);
- sectionView.addSubDocument(subDocumentView);
- projectView.addSectionView(sectionView);
-
- }
-
- }
-
- List listProfilesBean = linkedMap_UCDId_gCubeProfiles
- .get(theProjectDV.getProfileID());
-
- 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 = null;
- Object data = null;
- try {
- theSectionJsonPath = JsonPath.compile(sectionJSONPath);
- data = theSectionJsonPath.read(theWholeProjectAsJSON, configuration);
- } catch (Exception e) {
- LOG.warn("Error on searching the section " + sectionJSONPath + " in the JSON Project: "
- + theWholeProjectAsJSON);
- continue;
- }
-
- 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 listBSONDocument = new ArrayList();
- 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 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 filePaths = gcubeProfileDV.getFilePaths();
-
- // READING fileset* field ACCORDING TO filePaths OF THE 'gcubeProfiles' CONFIG
- if (filePaths != null) {
- String fromSectionDocJSON = fromSectionDoc.toJson();
- List listFiles = new ArrayList();
- List listImages = new ArrayList();
- List listLayers = new ArrayList();
- for (FilePathDV filePath : filePaths) {
-
- // Reading Fileset _payloads
- String filesetJSONPath = String.format("%s.%s", JSON_$_POINTER, filePath.getFieldName());
- List listPayloads = readPayloadsForFileset(filesetJSONPath, fromSectionDocJSON);
- if(LOG.isDebugEnabled()) {
- for (Payload payload : listPayloads) {
- LOG.debug("read payload: " + payload);
- }
- }
-
- FilesetDV filesetImages = new FilesetDV();
- FilesetDV filesetFiles = new FilesetDV();
-
- for (Payload payload : listPayloads) {
- PayloadDV payloadDV = ConvertToDataValueObjectModel.toPayloadDV(payload);
- //filesetDV.addPayloadDV(payloadDV);
- boolean isImage = ImageDetector.isImage(payload.getMimetype());
-
- if (isImage) {
- filesetImages.setName(filePath.getGcubeProfileFieldName());
- filesetImages.addPayloadDV(payloadDV);
- } else {
- filesetFiles.addPayloadDV(payloadDV);
- filesetFiles.setName(filePath.getGcubeProfileFieldName());
- }
- }
-
- //Setting only if one element exists
- if(filesetImages.getListPayload()!=null && filesetImages.getListPayload().size()>0) {
- listImages.add(filesetImages);
- }
- if(filesetFiles.getListPayload()!=null && filesetFiles.getListPayload().size()>0) {
- listFiles.add(filesetFiles);
- }
-
- // Reading Fileset _materializations
- listLayers = readGcubeSDILayersForFileset(filesetJSONPath, fromSectionDocJSON);
-
- }
- subDocumentView.setListFiles(listFiles);
- subDocumentView.setListImages(listImages);
- subDocumentView.setListLayers(listLayers);
- }
-
- sectionView.addSubDocument(subDocumentView);
-
- }
-
- projectView.addSectionView(sectionView);
- }
-
- LOG.debug("returning the projectView: " + projectView);
- return projectView;
- }
-
- /**
- * Read payloads for fileset.
- *
- * @param filesetJSONPath the fileset JSON path
- * @param sectionJSONDocument the section JSON document
- * @return the list
- */
- public static List readPayloadsForFileset(String filesetJSONPath, String sectionJSONDocument) {
- LOG.debug("readPayloadsForFileset called");
-
- List listPayloads = new ArrayList();
- String _payloadsJSONPath = String.format("%s.%s", filesetJSONPath, _PAYLOADS);
- try {
- com.jayway.jsonpath.Configuration configuration = com.jayway.jsonpath.Configuration.builder()
- .jsonProvider(new JsonOrgJsonProvider()).build();
-
- LOG.debug("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.warn("Error on reading the JSON Path " + _payloadsJSONPath + " in the doc " + sectionJSONDocument, e);
- }
-
- return listPayloads;
-
- }
-
- /**
- * Read images for fileset.
- *
- * @param parentJSONPath the parent JSON path
- * @param sectionJSONDocument the section JSON document
- * @param limitToFirstOneFound the limit to first one found
- * @return the list
- */
- public static List readImagesForFileset(String parentJSONPath, String sectionJSONDocument,
- boolean limitToFirstOneFound) {
- LOG.info("readImagesForFileset called");
-
- List listImages = new ArrayList();
- com.jayway.jsonpath.Configuration config = com.jayway.jsonpath.Configuration.builder()
- .jsonProvider(new JsonOrgJsonProvider()).build();
- // Reading Fileset _payloads
- String filesetJSONPath = String.format("%s.%s", parentJSONPath, _PAYLOADS);
- LOG.debug("Reading sectionPath {} into section document {}", filesetJSONPath, sectionJSONDocument);
- JsonPath theSectionPolycJsonPath = JsonPath.compile(filesetJSONPath);
- Object _filesets = theSectionPolycJsonPath.read(sectionJSONDocument, config);
-
- List payloads = new ArrayList();
- List listPayloads = recursiveFetchingPayloads(config, _filesets, payloads);
- for (Payload payload : listPayloads) {
- boolean isImage = ImageDetector.isImage(payload.getMimetype());
- if (isImage) {
- PayloadDV payloadDV = ConvertToDataValueObjectModel.toPayloadDV(payload);
- listImages.add(payloadDV);
- if (limitToFirstOneFound && listImages.size() == 1)
- return listImages;
- }
- }
-
- LOG.debug("readImagesForFileset returning listOfImages: " + listImages);
- return listImages;
-
- }
-
- /**
- * Read gcube SDI layers for fileset.
- *
- * @param materializationParentJSONPath the materialization parent JSON path
- * @param sectionJSONDocument the section JSON document
- * @return the list
- */
- public static List readGcubeSDILayersForFileset(String materializationParentJSONPath,
- String sectionJSONDocument) {
- LOG.info("readGcubeSDILayersForFileset called");
-
- List listSDILayers = new ArrayList();
- // _materializations AT THE MOMENT ARE ONLY OF TYPE gcube-sdi-layer. I'm adding
- // the filtering "_type": "gcube-sdi-layer" to be sure of reading SDI layer
- String _materializationsJSONPath = String.format("%s.%s[?(@._type=='%s')]", materializationParentJSONPath,
- _MATERIALIZATIONS, _TYPE_GCUBE_SDI_LAYER);
- // [?(@._access._policy=='%s')]
-
- try {
- com.jayway.jsonpath.Configuration configurationJSONSmart = com.jayway.jsonpath.Configuration.builder()
- .jsonProvider(new JsonOrgJsonProvider()).build();
-
- LOG.debug("GcubeSDILayers Reading sectionPath {} into section document {}", _materializationsJSONPath,
- sectionJSONDocument);
-
- JsonPath theSectionMaterializationJsonPath = JsonPath.compile(_materializationsJSONPath);
- Object _materializations = theSectionMaterializationJsonPath.read(sectionJSONDocument,
- configurationJSONSmart);
-
- LOG.trace("_materializations.class(): " + _materializations.getClass());
-
- listSDILayers = recursiveFetchingLayers(configurationJSONSmart, _materializations, listSDILayers);
-
- } catch (Exception e) {
- LOG.debug("Error on reading the JSON Path " + _materializationsJSONPath + " in the doc "
- + sectionJSONDocument, e);
- }
- LOG.info("returning list of layers {}", listSDILayers);
- return listSDILayers;
-
- }
-
- /**
- * Recursive fetching layers.
- *
- * @param config the config
- * @param objectJSON the object JSON
- * @param listSDILayers the list SDI layers
- * @return the list
- */
- private static List recursiveFetchingLayers(com.jayway.jsonpath.Configuration config,
- Object objectJSON, List listSDILayers) {
-
- if (objectJSON == null)
- return listSDILayers;
-
- if (objectJSON instanceof JSONArray) {
- JSONArray theJsonArray = (JSONArray) objectJSON;
- LOG.debug("jsonArray: " + theJsonArray.toString(3));
-
- for (int i = 0; i < theJsonArray.length(); i++) {
- recursiveFetchingLayers(config, theJsonArray.get(i), listSDILayers);
- }
- } else if (objectJSON instanceof JSONObject) {
- JSONObject theJsonObject = (JSONObject) objectJSON;
- LOG.debug("theJSONObject: " + theJsonObject.toString(3));
- GCubeSDIViewerLayerDV gsdiLayer = converLayer(config, theJsonObject);
- listSDILayers.add(gsdiLayer);
- }
-
- return listSDILayers;
- }
-
- /**
- * Recursive fetching payloads.
- *
- * @param config the config
- * @param objectJSON the object JSON
- * @param payloads the payloads
- * @return the list
- */
- public static List recursiveFetchingPayloads(com.jayway.jsonpath.Configuration config, Object objectJSON,
- List payloads) {
- LOG.debug("recursiveFetchingPayloads called");
-
- if (objectJSON == null)
- return payloads;
-
- if (objectJSON instanceof JSONArray) {
- JSONArray theJsonArray = (JSONArray) objectJSON;
- LOG.trace("jsonArray: " + theJsonArray.toString(3));
-
- for (int i = 0; i < theJsonArray.length(); i++) {
- payloads = recursiveFetchingPayloads(config, theJsonArray.get(i), payloads);
- }
- } else if (objectJSON instanceof JSONObject) {
- JSONObject toStringPayloads = (JSONObject) objectJSON;
- LOG.trace("The _payloads is a String {}", toStringPayloads.toString(3));
- Payload payload;
- try {
- payload = Serialization.read(toStringPayloads.toString(), Payload.class);
- payloads.add(payload);
- } catch (Exception e) {
- LOG.warn("Error on converting the JSON Boject " + toStringPayloads + "as "
- + Payload.class.getSimpleName() + e.getMessage());
- }
-
- }
-
- return payloads;
-
- }
-
- /**
- * Conver layer.
- *
- * @param config the config
- * @param thJsonObject the th json object
- * @return the g cube SDI viewer layer DV
- */
- // TODO THIS PART SHOULD BE REVISITED/OPTIMIZED
- private static GCubeSDIViewerLayerDV converLayer(com.jayway.jsonpath.Configuration config,
- JSONObject thJsonObject) {
- LOG.debug("converLayer called for " + thJsonObject);
-
- GCubeSDIViewerLayerDV gsdiLayer = new GCubeSDIViewerLayerDV();
- try {
- String theType = thJsonObject.getString(_TYPE);
- gsdiLayer.setType(theType);
- LOG.debug(_TYPE + " is: " + theType);
- } catch (Exception e) {
- LOG.warn("No " + _TYPE + " found", e);
- }
- String toSerializeJSONOBJ = thJsonObject.toString();
- String jsonPath = null;
- try {
- jsonPath = String.format("%s.%s", JSON_$_POINTER, _BBOX);
- HashMap bbox = JsonPath.using(config).parse(toSerializeJSONOBJ).read(jsonPath,
- HashMap.class);
- BBOXDV bboxDV = new BBOXDV(bbox);
- gsdiLayer.setBbox(bboxDV);
- LOG.debug(_BBOX + " is: " + bboxDV);
- } catch (Exception e) {
- LOG.warn(jsonPath + " error: ", e);
- }
- try {
- jsonPath = String.format("%s.%s", JSON_$_POINTER, _OGC_LINKS);
- String jsonString = JsonPath.using(config).parse(toSerializeJSONOBJ).read(jsonPath).toString();
- Gson gson = new Gson();
- HashMap map = gson.fromJson(jsonString, HashMap.class);
- gsdiLayer.setOgcLinks(map);
- LOG.debug(_OGC_LINKS + " are: " + map);
- } catch (Exception e) {
- LOG.warn(jsonPath + " error: ", e);
- }
-
- try {
- String wmsLink = gsdiLayer.getWMSLink();
- if (wmsLink != null) {
- String layerName = URLParserUtil.extractValueOfParameterFromURL("layers", wmsLink);
- gsdiLayer.setLayerName(layerName);
- }
- } catch (Exception e) {
- LOG.warn(jsonPath + " error: ", e);
- }
-
- LOG.debug("converLayer returning: " + gsdiLayer);
- return gsdiLayer;
- }
-
- /**
- * 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
- */
- public static 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 static boolean checkAccessPolicy(String sectionDocumentJSON, String myLogin) {
- LOG.info("checkAccessPolicy called");
- // CHECKING THE POLICY
- // see ticket #24390
- // First reading the access policy from the fileset
- String accessPolicyPath = JSON_$_POINTER + ".fileset._access._policy";
- boolean isAccessible = true;
- try {
- com.jayway.jsonpath.Configuration configuration = com.jayway.jsonpath.Configuration.builder()
- .jsonProvider(new JsonOrgJsonProvider()).build();
-
- LOG.debug("Reading access policy at {} into section document {}", accessPolicyPath, sectionDocumentJSON);
- String _policy = null;
- try {
- JsonPath theSectionPolycJsonPath = JsonPath.compile(accessPolicyPath);
- _policy = theSectionPolycJsonPath.read(sectionDocumentJSON, configuration).toString();
-
- if (_policy == null)
- throw new Exception("Policy is null");
-
- } catch (Exception e) {
- LOG.debug("Access policy not found in: " + accessPolicyPath);
- }
-
- // If policy does not exist into fileset, reading from the parent section
- if (_policy == null) {
- accessPolicyPath = JSON_$_POINTER + "._access._policy";
- LOG.debug("Reading access policy at {} into section document {}", accessPolicyPath,
- sectionDocumentJSON);
- try {
- JsonPath theSectionPolycJsonPath = JsonPath.compile(accessPolicyPath);
- _policy = theSectionPolycJsonPath.read(sectionDocumentJSON, configuration).toString();
-
- if (_policy == null)
- throw new Exception("Policy is null");
-
- } catch (Exception e) {
- LOG.debug("Access policy not found in: " + accessPolicyPath);
- }
- }
-
- LOG.debug("The section {} has policy {}", accessPolicyPath, _policy);
- isAccessible = GeportalCheckAccessPolicy.isAccessible(_policy, myLogin);
- } catch (Exception e) {
- LOG.error(accessPolicyPath + " not found. Check OK");
- }
- LOG.info("It is {} accessible the section {} accessible? {}", isAccessible, sectionDocumentJSON);
- return isAccessible;
- }
-
- /**
- * Sanitize document value.
- *
- * @param toDoc the to doc
- * @param fieldLabel the field label
- * @param theObjectFieldValue the the object field value
- * @return the document
- */
- private static 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, toString.trim());
- } 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;
- }
-
- /**
- * Pretty print JSON.
- *
- * @param jsonString the json string
- * @return the string
- */
- private static String prettyPrintJSON(String jsonString) {
-
- Gson gson = new GsonBuilder().setPrettyPrinting().create();
- JsonObject jsonObject = new JsonParser().parse(jsonString).getAsJsonObject();
- return gson.toJson(jsonObject);
- }
-
- /**
- * Pretty print project view.
- *
- * @param projectView the project view
- */
- public static void prettyPrintProjectView(ProjectView projectView) {
-
- 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);
- }
- }
- }
- System.out.println("***** Layers");
- if (subDocument.getListLayers() != null) {
- for (GCubeSDIViewerLayerDV layer : subDocument.getListLayers()) {
- System.out.println("******* Layer type: " + layer.getType());
- System.out.println("******* Layer: " + layer);
- }
- }
- i++;
- }
-
- }
- }
-
- /**
- * Pretty print project view.
- *
- * @param projectView the project view
- */
- public static void prettyPrintProjectEdit(ProjectEdit projectEdit) {
-
- for (MetaDataProfileBeanExt mpb : projectEdit.getTheProfileBeans()) {
- System.out.println("\n\n###### Title: " + mpb.getTitle() + " - Type: " + mpb.getType() + " ######");
- int i = 1;
- for (MetadataFieldWrapper fieldWrapper : mpb.getMetadataFields()) {
- System.out.println("## " + MetadataFieldWrapper.class.getSimpleName() + " n." + i);
- System.out.println("***** Metadata");
- // System.out.println(mfw);
- System.out.println("\tfieldId: " + fieldWrapper.getFieldId() + ", fieldName: "
- + fieldWrapper.getFieldName() + ", CurrentValue: " + fieldWrapper.getCurrentValue());
- i++;
- }
- i = 1;
- System.out.println("***** Files");
- for (FilesetDV fileSet : mpb.getListFileset()) {
- System.out.println("## " + FilesetDV.class.getSimpleName() + " n." + i);
- System.out.println(fileSet);
- i++;
- }
-
- }
- }
-
-}
+// System.out.println("***** Images");
+// if (subDocument.getListImages() != null) {
+// for (FilesetDV filesetDV : subDocument.getListImages()) {
+// System.out.println("******* Image Fileset name: " + filesetDV.getGcubeProfileFieldName());
+// for (PayloadDV payload : filesetDV.getListPayload()) {
+// System.out.println("********* Payload: " + payload);
+// }
+// }
+// }
+// System.out.println("***** Layers");
+// if (subDocument.getListLayers() != null) {
+// for (GCubeSDIViewerLayerDV layer : subDocument.getListLayers()) {
+// System.out.println("******* Layer type: " + layer.getType());
+// System.out.println("******* Layer: " + layer);
+// }
+// }
+// i++;
+// }
+//
+// }
+// }
+//
+// /**
+// * Pretty print project view.
+// *
+// * @param projectView the project view
+// */
+// public static void prettyPrintProjectEdit(ProjectEdit projectEdit) {
+//
+// for (MetaDataProfileBeanExt mpb : projectEdit.getTheProfileBeans()) {
+// System.out.println("\n\n###### Title: " + mpb.getTitle() + " - Type: " + mpb.getType() + " ######");
+// int i = 1;
+// for (MetadataFieldWrapper fieldWrapper : mpb.getMetadataFields()) {
+// System.out.println("## " + MetadataFieldWrapper.class.getSimpleName() + " n." + i);
+// System.out.println("***** Metadata");
+// // System.out.println(mfw);
+// System.out.println("\tfieldId: " + fieldWrapper.getFieldId() + ", fieldName: "
+// + fieldWrapper.getFieldName() + ", CurrentValue: " + fieldWrapper.getCurrentValue());
+// i++;
+// }
+// i = 1;
+// System.out.println("***** Files");
+// for (FilesetDV fileSet : mpb.getListFileset()) {
+// System.out.println("## " + FilesetDV.class.getSimpleName() + " n." + i);
+// System.out.println(fileSet);
+// i++;
+// }
+//
+// }
+// }
+//
+//}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioniMongoService.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioniMongoService.java
deleted file mode 100644
index eab41d3..0000000
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioniMongoService.java
+++ /dev/null
@@ -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); }
-// */
-//
-//}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accesspolicy/GeoNACheckAccessPolicy.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accesspolicy/GeoNACheckAccessPolicy.java
deleted file mode 100644
index 6eeda7a..0000000
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accesspolicy/GeoNACheckAccessPolicy.java
+++ /dev/null
@@ -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;
- }
-
-}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/GeoNaSpatialQueryResult.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/GeoNaSpatialQueryResult.java
index afa2d4c..7929b7b 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/GeoNaSpatialQueryResult.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/GeoNaSpatialQueryResult.java
@@ -26,7 +26,6 @@ public class GeoNaSpatialQueryResult implements Serializable {
// Map with couple (mongoId concessione, list of uploaded GNAImages for the
// concessione)
private Map> 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.
*
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/MetaDataProfileBeanExt.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/MetaDataProfileBeanExt.java
deleted file mode 100644
index abe93b4..0000000
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/MetaDataProfileBeanExt.java
+++ /dev/null
@@ -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 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 metadataFields,
- List categories) {
- super(type, title, metadataFields, categories);
- }
-
- /**
- * Gets the list fileset.
- *
- * @return the list fileset
- */
- public List getListFileset() {
- if (listFileset == null)
- listFileset = new ArrayList();
- return listFileset;
- }
-
- /**
- * Sets the list fileset.
- *
- * @param listFileset the new list fileset
- */
- public void setListFileset(List listFileset) {
- this.listFileset = listFileset;
- }
-
- @Override
- protected MetaDataProfileBeanExt clone() throws CloneNotSupportedException {
-
- MetaDataProfileBeanExt clonedMDPBE = new MetaDataProfileBeanExt();
- clonedMDPBE.setTitle(this.getTitle());
- clonedMDPBE.setType(this.getType());
- ArrayList newListFileset = new ArrayList();
- 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 newListMetadataFieldWrapper = new ArrayList();
-
- 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();
- }
-
-}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/ProjectEdit.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/ProjectEdit.java
deleted file mode 100644
index aa8c2f9..0000000
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/ProjectEdit.java
+++ /dev/null
@@ -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 theProfileBeans;
-
- public ProjectEdit() {
-
- }
-
- public ProjectDV getTheProjectDV() {
- return theProjectDV;
- }
-
- public List getTheProfileBeans() {
- return theProfileBeans;
- }
-
- public void setTheProjectDV(ProjectDV theProjectDV) {
- this.theProjectDV = theProjectDV;
- }
-
- public void setTheProfileBeans(List 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();
- }
-
-}
diff --git a/src/test/java/org/gcube/portlets/user/geoportaldataviewer/GeoportalViewer_Tests.java b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/GeoportalViewer_Tests.java
index b7afce7..52a085a 100644
--- a/src/test/java/org/gcube/portlets/user/geoportaldataviewer/GeoportalViewer_Tests.java
+++ b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/GeoportalViewer_Tests.java
@@ -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.