Added access policy filtering on reading layers for project ID
This commit is contained in:
parent
acc6be29d8
commit
047db1e848
|
@ -1,12 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" output="target/geoportal-data-viewer-app-3.0.1-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
<classpathentry kind="src" output="target/geoportal-data-viewer-app-3.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="optional" value="true"/>
|
<attribute name="optional" value="true"/>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry excluding="**" kind="src" output="target/geoportal-data-viewer-app-3.0.1-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
<classpathentry excluding="**" kind="src" output="target/geoportal-data-viewer-app-3.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
|
@ -35,5 +35,5 @@
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="output" path="target/geoportal-data-viewer-app-3.0.1-SNAPSHOT/WEB-INF/classes"/>
|
<classpathentry kind="output" path="target/geoportal-data-viewer-app-3.1.0-SNAPSHOT/WEB-INF/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-3.0.1-SNAPSHOT
|
lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-3.1.0-SNAPSHOT
|
||||||
warSrcDir=src/main/webapp
|
warSrcDir=src/main/webapp
|
||||||
warSrcDirIsOutput=false
|
warSrcDirIsOutput=false
|
||||||
|
|
|
@ -38,7 +38,9 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<wb-module deploy-name="geoportal-data-viewer-app-3.0.1-SNAPSHOT">
|
|
||||||
|
<wb-module deploy-name="geoportal-data-viewer-app-3.1.0-SNAPSHOT">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -97,6 +99,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -137,6 +140,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -177,6 +181,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -217,6 +222,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -239,8 +245,11 @@
|
||||||
|
|
||||||
|
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||||
|
|
||||||
<dependent-module archiveName="geoportal-data-common-2.0.1.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-common/geoportal-data-common">
|
<dependent-module archiveName="geoportal-data-common-2.0.1.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-common/geoportal-data-common">
|
||||||
|
|
||||||
<dependency-type>uses</dependency-type>
|
<dependency-type>uses</dependency-type>
|
||||||
|
|
||||||
</dependent-module>
|
</dependent-module>
|
||||||
|
|
||||||
|
|
||||||
|
@ -260,6 +269,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -300,6 +310,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -340,6 +351,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -381,6 +393,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,8 @@ import org.gcube.application.geoportalcommon.ProjectDVBuilder;
|
||||||
import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
|
import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
|
||||||
import org.gcube.application.geoportalcommon.geoportal.ProjectsCaller;
|
import org.gcube.application.geoportalcommon.geoportal.ProjectsCaller;
|
||||||
import org.gcube.application.geoportalcommon.geoportal.UseCaseDescriptorCaller;
|
import org.gcube.application.geoportalcommon.geoportal.UseCaseDescriptorCaller;
|
||||||
|
import org.gcube.application.geoportalcommon.geoportal.access.GeportalCheckAccessPolicy;
|
||||||
|
import org.gcube.application.geoportalcommon.geoportal.access.GeportalCheckAccessPolicy.ACCESS_POLICY;
|
||||||
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
|
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
|
||||||
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
|
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
|
||||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
||||||
|
@ -662,26 +664,26 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
||||||
LOG.info("Total Docs read from config: " + totalProjectForProfile);
|
LOG.info("Total Docs read from config: " + totalProjectForProfile);
|
||||||
|
|
||||||
// FIRST QUERY TO RETRIEVE IDs
|
// FIRST QUERY TO RETRIEVE IDs
|
||||||
// LIMIT IS NULL AND START = 0 MEANS THAT IT IS EQUAL TO NUMBER TOTAL OF DOCUMENTS
|
// LIMIT IS NULL AND START = 0 MEANS THAT IT IS EQUAL TO NUMBER TOTAL OF
|
||||||
|
// DOCUMENTS
|
||||||
final Iterator<Project> projectsIDs = client.queryOnMongo(theProfileID, totalProjectForProfile, 0, null,
|
final Iterator<Project> projectsIDs = client.queryOnMongo(theProfileID, totalProjectForProfile, 0, null,
|
||||||
filter);
|
filter);
|
||||||
|
|
||||||
//Getting the Project IDs from the Iterable
|
// Getting the Project IDs from the Iterable
|
||||||
Iterable<Project> itP = () -> projectsIDs;
|
Iterable<Project> itP = () -> projectsIDs;
|
||||||
Stream<Project> targetStream = StreamSupport.stream(itP.spliterator(), false);
|
Stream<Project> targetStream = StreamSupport.stream(itP.spliterator(), false);
|
||||||
List<String> listProjectIDs = targetStream.map(Project::getId).collect(Collectors.toList());
|
List<String> listProjectIDs = targetStream.map(Project::getId).collect(Collectors.toList());
|
||||||
searchedDataIDs.setResultSetProjectIDs(listProjectIDs);
|
searchedDataIDs.setResultSetProjectIDs(listProjectIDs);
|
||||||
//Total number of Projects are exactly listProjectIDs.size()
|
// Total number of Projects are exactly listProjectIDs.size()
|
||||||
int totalItems = listProjectIDs.size();
|
int totalItems = listProjectIDs.size();
|
||||||
searchedDataIDs.setTotalItems(totalItems);
|
searchedDataIDs.setTotalItems(totalItems);
|
||||||
LOG.info("Total IDs read from query: " + totalItems);
|
LOG.info("Total IDs read from query: " + totalItems);
|
||||||
|
|
||||||
//NOW PERFORMING THE (REAL) SECOND QUERY FROM CLIENT
|
// NOW PERFORMING THE (REAL) SECOND QUERY FROM CLIENT
|
||||||
// SETTING ORIGINAL PROJECTION FROM CLIENT
|
// SETTING ORIGINAL PROJECTION FROM CLIENT
|
||||||
filter.setProjection(originalProjection);
|
filter.setProjection(originalProjection);
|
||||||
// LIMIT IS FROM CLIENT
|
// LIMIT IS FROM CLIENT
|
||||||
Iterator<Project> projects = client.queryOnMongo(theProfileID, totalItems, start, limit,
|
Iterator<Project> projects = client.queryOnMongo(theProfileID, totalItems, start, limit, filter);
|
||||||
filter);
|
|
||||||
|
|
||||||
searchedDataIDs.setClientStartIndex(start);
|
searchedDataIDs.setClientStartIndex(start);
|
||||||
searchedDataIDs.setLimit(limit);
|
searchedDataIDs.setLimit(limit);
|
||||||
|
@ -749,24 +751,38 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
||||||
try {
|
try {
|
||||||
|
|
||||||
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
||||||
|
String username = null;
|
||||||
try {
|
try {
|
||||||
SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername();
|
username = SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.info("User not found in session, the userName for checking policy will be null");
|
LOG.info("User not found in session, the userName for checking the policy will be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.info("Trying to get project for id " + profileID);
|
LOG.trace("Trying to get project for id " + projectID);
|
||||||
|
|
||||||
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
|
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
|
||||||
Project theProject = GeoportalClientCaller.projects().getProjectByID(profileID, projectID);
|
Project theProject = GeoportalClientCaller.projects().getProjectByID(profileID, projectID);
|
||||||
String jsonDocument = theProject.getTheDocument().toJson();
|
String jsonDocument = theProject.getTheDocument().toJson();
|
||||||
LOG.trace("JSON Project is: " + jsonDocument);
|
LOG.trace("JSON Project is: " + jsonDocument);
|
||||||
|
|
||||||
String materializationParentJSONPath = String.format("%s..%s", Geoportal_JSON_Mapper.JSON_$_POINTER,
|
LOG.debug("Checking access policy for the layer...");
|
||||||
Geoportal_JSON_Mapper.FILESET);
|
ACCESS_POLICY accessPolicy = GeportalCheckAccessPolicy.accessPolicyFromSessionLogin(username);
|
||||||
|
LOG.info("Access policy for discovering the layers is: " + accessPolicy);
|
||||||
|
|
||||||
listLayers = Geoportal_JSON_Mapper.readGcubeSDILayersForFileset(materializationParentJSONPath,
|
String filesetParentJSONPath = null;
|
||||||
jsonDocument);
|
|
||||||
|
//(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
|
||||||
|
// identity is running, no logged in user.
|
||||||
|
filesetParentJSONPath = String.format("%s..%s[?(@._access._policy=='%s')]",
|
||||||
|
Geoportal_JSON_Mapper.JSON_$_POINTER, Geoportal_JSON_Mapper.FILESET, accessPolicy);
|
||||||
|
} else {
|
||||||
|
// Accessing to all fileset (with any ACCESS_POLICY) when the user is logged in.
|
||||||
|
filesetParentJSONPath = String.format("%s..%s", Geoportal_JSON_Mapper.JSON_$_POINTER,
|
||||||
|
Geoportal_JSON_Mapper.FILESET);
|
||||||
|
}
|
||||||
|
|
||||||
|
listLayers = Geoportal_JSON_Mapper.readGcubeSDILayersForFileset(filesetParentJSONPath, jsonDocument);
|
||||||
|
|
||||||
LOG.info("For projectID " + projectID + ", returning " + listLayers.size() + " layer/s");
|
LOG.info("For projectID " + projectID + ", returning " + listLayers.size() + " layer/s");
|
||||||
return listLayers;
|
return listLayers;
|
||||||
|
@ -975,7 +991,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
||||||
LOG.info("getDataResult called");
|
LOG.info("getDataResult called");
|
||||||
|
|
||||||
for (LayerObject layerObject : layerObjects) {
|
for (LayerObject layerObject : layerObjects) {
|
||||||
LOG.info("ProfileID: "+layerObject.getProfileID() + ", ProjectID: " +layerObject.getProjectID() + ", TYPE: "+layerObject.getType());
|
LOG.info("ProfileID: " + layerObject.getProfileID() + ", ProjectID: " + layerObject.getProjectID()
|
||||||
|
+ ", TYPE: " + layerObject.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LOG.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
|
@ -1007,8 +1024,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
||||||
|
|
||||||
// Expected more than 1 feature for the BBOX of the Map
|
// Expected more than 1 feature for the BBOX of the Map
|
||||||
FeatureRow fRow = features.get(0);
|
FeatureRow fRow = features.get(0);
|
||||||
//using only the first feature returned from BBOX of the Map
|
// using only the first feature returned from BBOX of the Map
|
||||||
//when querying the centroid layers
|
// when querying the centroid layers
|
||||||
geoDAO.setFeatures(Arrays.asList(fRow));
|
geoDAO.setFeatures(Arrays.asList(fRow));
|
||||||
if (fRow.getMapProperties() != null) {
|
if (fRow.getMapProperties() != null) {
|
||||||
List<String> productIDs = fRow.getMapProperties()
|
List<String> productIDs = fRow.getMapProperties()
|
||||||
|
@ -1138,7 +1155,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
||||||
|
|
||||||
LOG.info("returning " + listDAO.size() + " geona data objects");
|
LOG.info("returning " + listDAO.size() + " geona data objects");
|
||||||
|
|
||||||
if(LOG.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
LOG.debug("returning " + listDAO + " geona data objects");
|
LOG.debug("returning " + listDAO + " geona data objects");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,8 @@ public class Geoportal_JSON_Mapper {
|
||||||
|
|
||||||
public static final String _MATERIALIZATIONS = "_materializations";
|
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);
|
private static final Logger LOG = LoggerFactory.getLogger(Geoportal_JSON_Mapper.class);
|
||||||
|
|
||||||
public static final String FILESET = "fileset";
|
public static final String FILESET = "fileset";
|
||||||
|
@ -113,7 +115,8 @@ public class Geoportal_JSON_Mapper {
|
||||||
com.jayway.jsonpath.Configuration configuration = com.jayway.jsonpath.Configuration.builder()
|
com.jayway.jsonpath.Configuration configuration = com.jayway.jsonpath.Configuration.builder()
|
||||||
.jsonProvider(new JsonOrgJsonProvider()).build();
|
.jsonProvider(new JsonOrgJsonProvider()).build();
|
||||||
|
|
||||||
//LinkedHashMap<Integer, MetaDataProfileBeanExt> mapOfProfilesBeanExt = new LinkedHashMap<Integer, MetaDataProfileBeanExt>();
|
// LinkedHashMap<Integer, MetaDataProfileBeanExt> mapOfProfilesBeanExt = new
|
||||||
|
// LinkedHashMap<Integer, MetaDataProfileBeanExt>();
|
||||||
|
|
||||||
ArrayList<MetaDataProfileBeanExt> listOfProfilesBeanExt = new ArrayList<MetaDataProfileBeanExt>();
|
ArrayList<MetaDataProfileBeanExt> listOfProfilesBeanExt = new ArrayList<MetaDataProfileBeanExt>();
|
||||||
|
|
||||||
|
@ -124,7 +127,7 @@ public class Geoportal_JSON_Mapper {
|
||||||
// SectionView sectionView = new SectionView();
|
// SectionView sectionView = new SectionView();
|
||||||
// sectionView.setSectionTitle(gcubeProfileDV.getSectionTitle());
|
// sectionView.setSectionTitle(gcubeProfileDV.getSectionTitle());
|
||||||
|
|
||||||
System.out.println("\n\n##### Sto creando la sezione: "+gcubeProfileDV.getSectionTitle());
|
System.out.println("\n\n##### Sto creando la sezione: " + gcubeProfileDV.getSectionTitle());
|
||||||
LOG.debug("\n\nThe profile is: " + gcubeProfileDV);
|
LOG.debug("\n\nThe profile is: " + gcubeProfileDV);
|
||||||
// Building JSON/section full PATH and section name
|
// Building JSON/section full PATH and section name
|
||||||
String sectionJSONPath = "";
|
String sectionJSONPath = "";
|
||||||
|
@ -179,11 +182,10 @@ public class Geoportal_JSON_Mapper {
|
||||||
List<MetaDataProfileBean> theProfileBeans = gcubeProfileMetaForUCD.getListMetadataProfileBean();
|
List<MetaDataProfileBean> theProfileBeans = gcubeProfileMetaForUCD.getListMetadataProfileBean();
|
||||||
MetaDataProfileBean theProfileBean = theProfileBeans.get(0);
|
MetaDataProfileBean theProfileBean = theProfileBeans.get(0);
|
||||||
|
|
||||||
|
|
||||||
// For each bson.Document filling the MetaDataProfileBean and its file
|
// For each bson.Document filling the MetaDataProfileBean and its file
|
||||||
for (int i = 0; i < listBSONDocument.size(); i++) {
|
for (int i = 0; i < listBSONDocument.size(); i++) {
|
||||||
|
|
||||||
System.out.println("DOCUMENT number "+i+ " of the section: "+theProfileBean.getTitle());
|
System.out.println("DOCUMENT number " + i + " of the section: " + theProfileBean.getTitle());
|
||||||
MetaDataProfileBeanExt theProfileBeanExt = new MetaDataProfileBeanExt();
|
MetaDataProfileBeanExt theProfileBeanExt = new MetaDataProfileBeanExt();
|
||||||
theProfileBeanExt.setCategories(theProfileBean.getCategories());
|
theProfileBeanExt.setCategories(theProfileBean.getCategories());
|
||||||
theProfileBeanExt.setTitle(theProfileBean.getTitle());
|
theProfileBeanExt.setTitle(theProfileBean.getTitle());
|
||||||
|
@ -199,30 +201,31 @@ public class Geoportal_JSON_Mapper {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
Document fromSectionDoc = listBSONDocument.get(i);
|
Document fromSectionDoc = listBSONDocument.get(i);
|
||||||
LOG.debug("\n\nNew section DOC for index " + i + " is: " + new JSONObject(fromSectionDoc.toJson()).toString(2));
|
LOG.debug("\n\nNew section DOC for index " + i + " is: "
|
||||||
//Creating the corresponding MetaDataProfileBeanExt for each section
|
+ new JSONObject(fromSectionDoc.toJson()).toString(2));
|
||||||
|
// Creating the corresponding MetaDataProfileBeanExt for each section
|
||||||
|
|
||||||
//Reading policy and license statically
|
// Reading policy and license statically
|
||||||
//eg. "_access":{"_policy":"OPEN","_license":"CC0-1.0"}}
|
// eg. "_access":{"_policy":"OPEN","_license":"CC0-1.0"}}
|
||||||
Document docAccess = null;
|
Document docAccess = null;
|
||||||
Access access = null;
|
Access access = null;
|
||||||
try {
|
try {
|
||||||
docAccess = fromSectionDoc.get("_access", Document.class);
|
docAccess = fromSectionDoc.get("_access", Document.class);
|
||||||
System.out.println("docAccess is: "+docAccess);
|
System.out.println("docAccess is: " + docAccess);
|
||||||
access = new Access();
|
access = new Access();
|
||||||
access.setPolicy(AccessPolicy.valueOf(docAccess.getString("_policy")));
|
access.setPolicy(AccessPolicy.valueOf(docAccess.getString("_policy")));
|
||||||
access.setLicense(docAccess.getString("_license"));
|
access.setLicense(docAccess.getString("_license"));
|
||||||
// Access. access.get("_policy");
|
// Access. access.get("_policy");
|
||||||
// access.get("_license");
|
// access.get("_license");
|
||||||
System.out.println("access is: "+access);
|
System.out.println("access is: " + access);
|
||||||
}catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
//List<MetadataFieldWrapper> copyOfMetadataFields = new ArrayList<MetadataFieldWrapper>(theProfileBean.getMetadataFields());
|
// List<MetadataFieldWrapper> copyOfMetadataFields = new
|
||||||
//int forIndex = 0;
|
// ArrayList<MetadataFieldWrapper>(theProfileBean.getMetadataFields());
|
||||||
|
// int forIndex = 0;
|
||||||
|
|
||||||
List<MetadataFieldWrapper> cloneListOfMFW = cloneList(theProfileBean.getMetadataFields());
|
List<MetadataFieldWrapper> cloneListOfMFW = cloneList(theProfileBean.getMetadataFields());
|
||||||
|
|
||||||
|
@ -232,22 +235,22 @@ public class Geoportal_JSON_Mapper {
|
||||||
: metadataField.getFieldName();
|
: metadataField.getFieldName();
|
||||||
LOG.debug("reading theFieldName: " + theFieldName);
|
LOG.debug("reading theFieldName: " + theFieldName);
|
||||||
Object theOBJFieldValue = fromSectionDoc.get(theFieldName);
|
Object theOBJFieldValue = fromSectionDoc.get(theFieldName);
|
||||||
metadataField.setCurrentValue(theOBJFieldValue+"");
|
metadataField.setCurrentValue(theOBJFieldValue + "");
|
||||||
|
|
||||||
if(access!=null) {
|
if (access != null) {
|
||||||
if(theFieldName.equalsIgnoreCase("policy")) {
|
if (theFieldName.equalsIgnoreCase("policy")) {
|
||||||
metadataField.setCurrentValue(access.getPolicy().name());
|
metadataField.setCurrentValue(access.getPolicy().name());
|
||||||
}else if(theFieldName.equalsIgnoreCase("licenseID")) {
|
} else if (theFieldName.equalsIgnoreCase("licenseID")) {
|
||||||
metadataField.setCurrentValue(access.getLicense());
|
metadataField.setCurrentValue(access.getLicense());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//copyOfMetadataFields.set(forIndex++, metadataField);
|
// copyOfMetadataFields.set(forIndex++, metadataField);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.debug("Before assigning it Metadata fields are: "+cloneListOfMFW);
|
LOG.debug("Before assigning it Metadata fields are: " + cloneListOfMFW);
|
||||||
|
|
||||||
theProfileBeanExt.setMetadataFields(new ArrayList<MetadataFieldWrapper>(cloneListOfMFW));
|
theProfileBeanExt.setMetadataFields(new ArrayList<MetadataFieldWrapper>(cloneListOfMFW));
|
||||||
LOG.debug("Metadata fields are: "+theProfileBeanExt.getMetadataFields());
|
LOG.debug("Metadata fields are: " + theProfileBeanExt.getMetadataFields());
|
||||||
|
|
||||||
// Reading filePaths
|
// Reading filePaths
|
||||||
List<FilePathDV> filePaths = gcubeProfileDV.getFilePaths();
|
List<FilePathDV> filePaths = gcubeProfileDV.getFilePaths();
|
||||||
|
@ -272,15 +275,16 @@ public class Geoportal_JSON_Mapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reading Fileset _materializations
|
// Reading Fileset _materializations
|
||||||
//listLayers = readGcubeSDILayersForFileset(filesetJSONPath, fromSectionDocJSON);
|
// listLayers = readGcubeSDILayersForFileset(filesetJSONPath,
|
||||||
//theProfileBeanExt.set
|
// fromSectionDocJSON);
|
||||||
|
// theProfileBeanExt.set
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
theProfileBeanExt.setListFileset(listFiles);
|
theProfileBeanExt.setListFileset(listFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("\nputting theProfileBeanExt: "+theProfileBeanExt);
|
System.out.println("\nputting theProfileBeanExt: " + theProfileBeanExt);
|
||||||
listOfProfilesBeanExt.add(theProfileBeanExt);
|
listOfProfilesBeanExt.add(theProfileBeanExt);
|
||||||
|
|
||||||
// System.out.println("\nPRINTING PROJECT VIEW ON END: ");
|
// System.out.println("\nPRINTING PROJECT VIEW ON END: ");
|
||||||
|
@ -294,14 +298,14 @@ public class Geoportal_JSON_Mapper {
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// System.out.println(listProfileBeansExt.get(listProfileBeansExt.size()-1));
|
// System.out.println(listProfileBeansExt.get(listProfileBeansExt.size()-1));
|
||||||
//Geoportal_JSON_Mapper.prettyPrintProjectEdit(projectView);
|
// Geoportal_JSON_Mapper.prettyPrintProjectEdit(projectView);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
projectView.setTheProfileBeans(listOfProfilesBeanExt);
|
projectView.setTheProfileBeans(listOfProfilesBeanExt);
|
||||||
|
|
||||||
//Geoportal_JSON_Mapper.prettyPrintProjectEdit(projectView);
|
// Geoportal_JSON_Mapper.prettyPrintProjectEdit(projectView);
|
||||||
|
|
||||||
return projectView;
|
return projectView;
|
||||||
}
|
}
|
||||||
|
@ -647,22 +651,29 @@ public class Geoportal_JSON_Mapper {
|
||||||
LOG.info("readGcubeSDILayersForFileset called");
|
LOG.info("readGcubeSDILayersForFileset called");
|
||||||
|
|
||||||
List<GCubeSDIViewerLayerDV> listSDILayers = new ArrayList<GCubeSDIViewerLayerDV>();
|
List<GCubeSDIViewerLayerDV> listSDILayers = new ArrayList<GCubeSDIViewerLayerDV>();
|
||||||
String _materializationsJSONPath = String.format("%s.%s", materializationParentJSONPath, _MATERIALIZATIONS);
|
// _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 {
|
try {
|
||||||
com.jayway.jsonpath.Configuration configurationJSONSmart = com.jayway.jsonpath.Configuration.builder()
|
com.jayway.jsonpath.Configuration configurationJSONSmart = com.jayway.jsonpath.Configuration.builder()
|
||||||
.jsonProvider(new JsonOrgJsonProvider()).build();
|
.jsonProvider(new JsonOrgJsonProvider()).build();
|
||||||
|
|
||||||
LOG.debug("Reading sectionPath {} into section document {}", _materializationsJSONPath, sectionJSONDocument);
|
LOG.debug("GcubeSDILayers Reading sectionPath {} into section document {}", _materializationsJSONPath,
|
||||||
JsonPath theSectionPolycJsonPath = JsonPath.compile(_materializationsJSONPath);
|
sectionJSONDocument);
|
||||||
Object _materializations = theSectionPolycJsonPath.read(sectionJSONDocument, configurationJSONSmart);
|
|
||||||
|
JsonPath theSectionMaterializationJsonPath = JsonPath.compile(_materializationsJSONPath);
|
||||||
|
Object _materializations = theSectionMaterializationJsonPath.read(sectionJSONDocument,
|
||||||
|
configurationJSONSmart);
|
||||||
|
|
||||||
LOG.trace("_materializations.class(): " + _materializations.getClass());
|
LOG.trace("_materializations.class(): " + _materializations.getClass());
|
||||||
|
|
||||||
listSDILayers = recursiveFetchingLayers(configurationJSONSmart, _materializations, listSDILayers);
|
listSDILayers = recursiveFetchingLayers(configurationJSONSmart, _materializations, listSDILayers);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.warn("Error on reading the JSON Path " + _materializationsJSONPath + " in the doc "
|
LOG.debug("Error on reading the JSON Path " + _materializationsJSONPath + " in the doc "
|
||||||
+ sectionJSONDocument, e);
|
+ sectionJSONDocument, e);
|
||||||
}
|
}
|
||||||
LOG.info("returning list of layers {}", listSDILayers);
|
LOG.info("returning list of layers {}", listSDILayers);
|
||||||
|
@ -686,14 +697,14 @@ public class Geoportal_JSON_Mapper {
|
||||||
|
|
||||||
if (objectJSON instanceof JSONArray) {
|
if (objectJSON instanceof JSONArray) {
|
||||||
JSONArray theJsonArray = (JSONArray) objectJSON;
|
JSONArray theJsonArray = (JSONArray) objectJSON;
|
||||||
LOG.trace("jsonArray: " + theJsonArray.toString(3));
|
LOG.debug("jsonArray: " + theJsonArray.toString(3));
|
||||||
|
|
||||||
for (int i = 0; i < theJsonArray.length(); i++) {
|
for (int i = 0; i < theJsonArray.length(); i++) {
|
||||||
recursiveFetchingLayers(config, theJsonArray.get(i), listSDILayers);
|
recursiveFetchingLayers(config, theJsonArray.get(i), listSDILayers);
|
||||||
}
|
}
|
||||||
} else if (objectJSON instanceof JSONObject) {
|
} else if (objectJSON instanceof JSONObject) {
|
||||||
JSONObject theJsonObject = (JSONObject) objectJSON;
|
JSONObject theJsonObject = (JSONObject) objectJSON;
|
||||||
LOG.trace("theJSONObject: " + theJsonObject.toString(3));
|
LOG.debug("theJSONObject: " + theJsonObject.toString(3));
|
||||||
GCubeSDIViewerLayerDV gsdiLayer = converLayer(config, theJsonObject);
|
GCubeSDIViewerLayerDV gsdiLayer = converLayer(config, theJsonObject);
|
||||||
listSDILayers.add(gsdiLayer);
|
listSDILayers.add(gsdiLayer);
|
||||||
}
|
}
|
||||||
|
@ -806,7 +817,7 @@ public class Geoportal_JSON_Mapper {
|
||||||
* @param myLogin the my login
|
* @param myLogin the my login
|
||||||
* @return true, if is accessible section according to policy
|
* @return true, if is accessible section according to policy
|
||||||
*/
|
*/
|
||||||
private static boolean isAccessibleSectionAccordingToPolicy(Document section, String sectionJSONPath,
|
public static boolean isAccessibleSectionAccordingToPolicy(Document section, String sectionJSONPath,
|
||||||
String myLogin) {
|
String myLogin) {
|
||||||
LOG.debug("isAccessibleSectionAccordingToPolicy called");
|
LOG.debug("isAccessibleSectionAccordingToPolicy called");
|
||||||
boolean isAccessible = true;
|
boolean isAccessible = true;
|
||||||
|
@ -829,8 +840,8 @@ public class Geoportal_JSON_Mapper {
|
||||||
private static boolean checkAccessPolicy(String sectionDocumentJSON, String myLogin) {
|
private static boolean checkAccessPolicy(String sectionDocumentJSON, String myLogin) {
|
||||||
LOG.info("checkAccessPolicy called");
|
LOG.info("checkAccessPolicy called");
|
||||||
// CHECKING THE POLICY
|
// CHECKING THE POLICY
|
||||||
//see ticket #24390
|
// see ticket #24390
|
||||||
//First reading the access policy from the fileset
|
// First reading the access policy from the fileset
|
||||||
String accessPolicyPath = JSON_$_POINTER + ".fileset._access._policy";
|
String accessPolicyPath = JSON_$_POINTER + ".fileset._access._policy";
|
||||||
boolean isAccessible = true;
|
boolean isAccessible = true;
|
||||||
try {
|
try {
|
||||||
|
@ -843,26 +854,27 @@ public class Geoportal_JSON_Mapper {
|
||||||
JsonPath theSectionPolycJsonPath = JsonPath.compile(accessPolicyPath);
|
JsonPath theSectionPolycJsonPath = JsonPath.compile(accessPolicyPath);
|
||||||
_policy = theSectionPolycJsonPath.read(sectionDocumentJSON, configuration).toString();
|
_policy = theSectionPolycJsonPath.read(sectionDocumentJSON, configuration).toString();
|
||||||
|
|
||||||
if(_policy==null)
|
if (_policy == null)
|
||||||
throw new Exception("Policy is null");
|
throw new Exception("Policy is null");
|
||||||
|
|
||||||
}catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.debug("Access policy not found in: "+accessPolicyPath);
|
LOG.debug("Access policy not found in: " + accessPolicyPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
//If policy does not exist into fileset, reading from the parent section
|
// If policy does not exist into fileset, reading from the parent section
|
||||||
if(_policy==null) {
|
if (_policy == null) {
|
||||||
accessPolicyPath = JSON_$_POINTER + "._access._policy";
|
accessPolicyPath = JSON_$_POINTER + "._access._policy";
|
||||||
LOG.debug("Reading access policy at {} into section document {}", accessPolicyPath, sectionDocumentJSON);
|
LOG.debug("Reading access policy at {} into section document {}", accessPolicyPath,
|
||||||
|
sectionDocumentJSON);
|
||||||
try {
|
try {
|
||||||
JsonPath theSectionPolycJsonPath = JsonPath.compile(accessPolicyPath);
|
JsonPath theSectionPolycJsonPath = JsonPath.compile(accessPolicyPath);
|
||||||
_policy = theSectionPolycJsonPath.read(sectionDocumentJSON, configuration).toString();
|
_policy = theSectionPolycJsonPath.read(sectionDocumentJSON, configuration).toString();
|
||||||
|
|
||||||
if(_policy==null)
|
if (_policy == null)
|
||||||
throw new Exception("Policy is null");
|
throw new Exception("Policy is null");
|
||||||
|
|
||||||
}catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.debug("Access policy not found in: "+accessPolicyPath);
|
LOG.debug("Access policy not found in: " + accessPolicyPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -871,7 +883,7 @@ public class Geoportal_JSON_Mapper {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error(accessPolicyPath + " not found. Check OK");
|
LOG.error(accessPolicyPath + " not found. Check OK");
|
||||||
}
|
}
|
||||||
LOG.info("Is the section {} accessible? {}", sectionDocumentJSON, isAccessible);
|
LOG.info("It is {} accessible the section {} accessible? {}", isAccessible, sectionDocumentJSON);
|
||||||
return isAccessible;
|
return isAccessible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,8 @@ import org.gcube.application.geoportalcommon.ProjectDVBuilder;
|
||||||
import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
|
import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
|
||||||
import org.gcube.application.geoportalcommon.geoportal.ProjectsCaller;
|
import org.gcube.application.geoportalcommon.geoportal.ProjectsCaller;
|
||||||
import org.gcube.application.geoportalcommon.geoportal.UseCaseDescriptorCaller;
|
import org.gcube.application.geoportalcommon.geoportal.UseCaseDescriptorCaller;
|
||||||
|
import org.gcube.application.geoportalcommon.geoportal.access.GeportalCheckAccessPolicy;
|
||||||
|
import org.gcube.application.geoportalcommon.geoportal.access.GeportalCheckAccessPolicy.ACCESS_POLICY;
|
||||||
import org.gcube.application.geoportalcommon.geoportal.util.GisUtil;
|
import org.gcube.application.geoportalcommon.geoportal.util.GisUtil;
|
||||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
||||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter.LOGICAL_OP;
|
import org.gcube.application.geoportalcommon.shared.SearchingFilter.LOGICAL_OP;
|
||||||
|
@ -40,6 +42,7 @@ import org.gcube.portlets.user.geoportaldataviewer.server.Geoportal_JSON_Mapper;
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.shared.ProjectEdit;
|
import org.gcube.portlets.user.geoportaldataviewer.shared.ProjectEdit;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class GeoportalViewer_Tests.
|
* The Class GeoportalViewer_Tests.
|
||||||
|
@ -54,14 +57,15 @@ public class GeoportalViewer_Tests {
|
||||||
|
|
||||||
private ProjectsCaller clientProjects;
|
private ProjectsCaller clientProjects;
|
||||||
|
|
||||||
private static String CONTEXT = "/pred4s/preprod/preVRE";
|
//private static String CONTEXT = "/pred4s/preprod/preVRE";
|
||||||
private static String TOKEN = ""; //preVRE
|
private static String CONTEXT = "/d4science.research-infrastructures.eu/D4OS/GNA";
|
||||||
|
private static String TOKEN = ""; //GNA
|
||||||
|
|
||||||
//private static String CONTEXT = "/gcube/devsec/devVRE";
|
//private static String CONTEXT = "/gcube/devsec/devVRE";
|
||||||
//private static String TOKEN = ""; // devVRE
|
//private static String TOKEN = ""; // devVRE
|
||||||
|
|
||||||
private static String PROFILE_ID = "profiledConcessioni";
|
private static String PROFILE_ID = "profiledConcessioni";
|
||||||
private static String PROJECT_ID = "637ceb4d21dd0d6fb9f24706";
|
private static String PROJECT_ID = "6388ea6ca1e60e66b7b584e0";
|
||||||
|
|
||||||
private static String USERNAME = "francesco.mangiacrapa";
|
private static String USERNAME = "francesco.mangiacrapa";
|
||||||
|
|
||||||
|
@ -99,7 +103,7 @@ public class GeoportalViewer_Tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Test
|
//@Test
|
||||||
public void getLayersForId() {
|
public void getLayersForId() {
|
||||||
System.out.println("getLayersForId [profileID: " + PROFILE_ID + ", projectID: " + PROJECT_ID + "] called");
|
System.out.println("getLayersForId [profileID: " + PROFILE_ID + ", projectID: " + PROJECT_ID + "] called");
|
||||||
|
|
||||||
|
@ -113,9 +117,25 @@ public class GeoportalViewer_Tests {
|
||||||
String jsonDocument = project.getTheDocument().toJson();
|
String jsonDocument = project.getTheDocument().toJson();
|
||||||
System.out.println("JSON Project is: " + jsonDocument);
|
System.out.println("JSON Project is: " + jsonDocument);
|
||||||
|
|
||||||
String materializationParentJSONPath = String.format("%s..%s", Geoportal_JSON_Mapper.JSON_$_POINTER,
|
ACCESS_POLICY accessPolicy = GeportalCheckAccessPolicy.accessPolicyFromSessionLogin(null);
|
||||||
Geoportal_JSON_Mapper.FILESET);
|
|
||||||
|
|
||||||
|
String materializationParentJSONPath = null;
|
||||||
|
|
||||||
|
if(accessPolicy.equals(ACCESS_POLICY.OPEN)) {
|
||||||
|
//Filtering for ACCESS_POLICY.OPEN when the username is not in session. IAM identity is running, no logged in user.
|
||||||
|
materializationParentJSONPath = String.format("%s..%s[?(@._access._policy=='%s')]", Geoportal_JSON_Mapper.JSON_$_POINTER,
|
||||||
|
Geoportal_JSON_Mapper.FILESET, accessPolicy);
|
||||||
|
}else {
|
||||||
|
//Accessing to all fileset (with any ACCESS_POLICY) when the user is logged in.
|
||||||
|
materializationParentJSONPath = String.format("%s..%s", Geoportal_JSON_Mapper.JSON_$_POINTER,
|
||||||
|
Geoportal_JSON_Mapper.FILESET);
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("jsonPathQuery is: "+materializationParentJSONPath);
|
||||||
|
|
||||||
|
// String materializationParentJSONPath = String.format("%s..%s", Geoportal_JSON_Mapper.JSON_$_POINTER,
|
||||||
|
// Geoportal_JSON_Mapper.FILESET);
|
||||||
|
//
|
||||||
listLayers = Geoportal_JSON_Mapper.readGcubeSDILayersForFileset(materializationParentJSONPath,
|
listLayers = Geoportal_JSON_Mapper.readGcubeSDILayersForFileset(materializationParentJSONPath,
|
||||||
jsonDocument);
|
jsonDocument);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue