Added access policy filtering on reading layers for project ID

animated_map
parent acc6be29d8
commit 047db1e848

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</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>
<attribute name="maven.pomderived" value="true"/>
</attributes>
@ -35,5 +35,5 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/geoportal-data-viewer-app-3.0.1-SNAPSHOT/WEB-INF/classes"/>
<classpathentry kind="output" path="target/geoportal-data-viewer-app-3.1.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

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

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
@ -38,8 +38,10 @@
<wb-module deploy-name="geoportal-data-viewer-app-3.0.1-SNAPSHOT">
<wb-module deploy-name="geoportal-data-viewer-app-3.1.0-SNAPSHOT">
@ -79,7 +81,8 @@
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
@ -119,7 +122,8 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
@ -159,7 +163,8 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
@ -199,7 +204,8 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
@ -239,10 +245,14 @@
<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">
<dependency-type>uses</dependency-type>
</dependent-module>
@ -282,7 +292,8 @@
<property name="java-output-path" value="/geoportal-data-viewer-app/target/geoportal-data-viewer-app-0.0.1-SNAPSHOT/WEB-INF/classes"/>
@ -322,7 +333,8 @@
<property name="context-root" value="geoportal-data-viewer-app"/>
@ -362,7 +374,8 @@
</wb-module>

@ -35,6 +35,8 @@ import org.gcube.application.geoportalcommon.ProjectDVBuilder;
import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
import org.gcube.application.geoportalcommon.geoportal.ProjectsCaller;
import org.gcube.application.geoportalcommon.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.GeoportalItemReferences;
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
@ -642,7 +644,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
// Saving client PROJECTION
LinkedHashMap<String, Object> originalProjection = filter.getProjection();
// Setting PROJECTION ONLY FOR PROEJCT ID
LinkedHashMap<String, Object> projectionForIDs = new LinkedHashMap<String, Object>();
projectionForIDs.put(Project.ID, 1);
@ -662,26 +664,26 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
LOG.info("Total Docs read from config: " + totalProjectForProfile);
// 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,
filter);
//Getting the Project IDs from the Iterable
// Getting the Project IDs from the Iterable
Iterable<Project> itP = () -> projectsIDs;
Stream<Project> targetStream = StreamSupport.stream(itP.spliterator(), false);
List<String> listProjectIDs = targetStream.map(Project::getId).collect(Collectors.toList());
searchedDataIDs.setResultSetProjectIDs(listProjectIDs);
//Total number of Projects are exactly listProjectIDs.size()
// Total number of Projects are exactly listProjectIDs.size()
int totalItems = listProjectIDs.size();
searchedDataIDs.setTotalItems(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
filter.setProjection(originalProjection);
// LIMIT IS FROM CLIENT
Iterator<Project> projects = client.queryOnMongo(theProfileID, totalItems, start, limit,
filter);
Iterator<Project> projects = client.queryOnMongo(theProfileID, totalItems, start, limit, filter);
searchedDataIDs.setClientStartIndex(start);
searchedDataIDs.setLimit(limit);
@ -749,24 +751,38 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
try {
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
String username = null;
try {
SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername();
username = SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername();
} 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());
Project theProject = GeoportalClientCaller.projects().getProjectByID(profileID, projectID);
String jsonDocument = theProject.getTheDocument().toJson();
LOG.trace("JSON Project is: " + jsonDocument);
String materializationParentJSONPath = String.format("%s..%s", Geoportal_JSON_Mapper.JSON_$_POINTER,
Geoportal_JSON_Mapper.FILESET);
LOG.debug("Checking access policy for the layer...");
ACCESS_POLICY accessPolicy = GeportalCheckAccessPolicy.accessPolicyFromSessionLogin(username);
LOG.info("Access policy for discovering the layers is: " + accessPolicy);
listLayers = Geoportal_JSON_Mapper.readGcubeSDILayersForFileset(materializationParentJSONPath,
jsonDocument);
String filesetParentJSONPath = null;
//(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");
return listLayers;
@ -973,11 +989,12 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
public List<GeoNaSpatialQueryResult> getDataResult(List<LayerObject> layerObjects, String mapSrsName,
BoundsMap selectBBOX, int maxWFSFeature, double zoomLevel) throws Exception {
LOG.info("getDataResult called");
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()) {
LOG.debug("getDataResult parmeters layerObjects: " + layerObjects,
", mapSrsName: " + mapSrsName + ", selectBBOX: " + selectBBOX + ", maxWFSFeature: " + maxWFSFeature
@ -1007,8 +1024,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
// Expected more than 1 feature for the BBOX of the Map
FeatureRow fRow = features.get(0);
//using only the first feature returned from BBOX of the Map
//when querying the centroid layers
// using only the first feature returned from BBOX of the Map
// when querying the centroid layers
geoDAO.setFeatures(Arrays.asList(fRow));
if (fRow.getMapProperties() != null) {
List<String> productIDs = fRow.getMapProperties()
@ -1137,11 +1154,11 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
}
LOG.info("returning " + listDAO.size() + " geona data objects");
if(LOG.isDebugEnabled()) {
if (LOG.isDebugEnabled()) {
LOG.debug("returning " + listDAO + " geona data objects");
}
return listDAO;
}

@ -55,6 +55,8 @@ public class Geoportal_JSON_Mapper {
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";
@ -68,7 +70,7 @@ public class Geoportal_JSON_Mapper {
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();
@ -112,19 +114,20 @@ public class Geoportal_JSON_Mapper {
com.jayway.jsonpath.Configuration configuration = com.jayway.jsonpath.Configuration.builder()
.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>();
// 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());
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 = "";
@ -178,17 +181,16 @@ public class Geoportal_JSON_Mapper {
LOG.debug("Result for " + gcubeProfileDV.getSectionName() + " is: " + listBSONDocument);
List<MetaDataProfileBean> 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());
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);
@ -198,56 +200,57 @@ public class Geoportal_JSON_Mapper {
// 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
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"}}
// 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);
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) {
// Access. access.get("_policy");
// access.get("_license");
System.out.println("access is: " + access);
} catch (Exception e) {
e.printStackTrace();
}
//List<MetadataFieldWrapper> copyOfMetadataFields = new ArrayList<MetadataFieldWrapper>(theProfileBean.getMetadataFields());
//int forIndex = 0;
// List<MetadataFieldWrapper> copyOfMetadataFields = new
// ArrayList<MetadataFieldWrapper>(theProfileBean.getMetadataFields());
// int forIndex = 0;
List<MetadataFieldWrapper> 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(theOBJFieldValue + "");
if (access != null) {
if (theFieldName.equalsIgnoreCase("policy")) {
metadataField.setCurrentValue(access.getPolicy().name());
}else if(theFieldName.equalsIgnoreCase("licenseID")) {
} else if (theFieldName.equalsIgnoreCase("licenseID")) {
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));
LOG.debug("Metadata fields are: "+theProfileBeanExt.getMetadataFields());
LOG.debug("Metadata fields are: " + theProfileBeanExt.getMetadataFields());
// Reading filePaths
List<FilePathDV> filePaths = gcubeProfileDV.getFilePaths();
@ -272,17 +275,18 @@ public class Geoportal_JSON_Mapper {
}
// Reading Fileset _materializations
//listLayers = readGcubeSDILayersForFileset(filesetJSONPath, fromSectionDocJSON);
//theProfileBeanExt.set
// listLayers = readGcubeSDILayersForFileset(filesetJSONPath,
// fromSectionDocJSON);
// theProfileBeanExt.set
}
theProfileBeanExt.setListFileset(listFiles);
}
System.out.println("\nputting theProfileBeanExt: "+theProfileBeanExt);
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);
@ -294,15 +298,15 @@ public class Geoportal_JSON_Mapper {
// }
//
// System.out.println(listProfileBeansExt.get(listProfileBeansExt.size()-1));
//Geoportal_JSON_Mapper.prettyPrintProjectEdit(projectView);
// Geoportal_JSON_Mapper.prettyPrintProjectEdit(projectView);
}
}
projectView.setTheProfileBeans(listOfProfilesBeanExt);
//Geoportal_JSON_Mapper.prettyPrintProjectEdit(projectView);
// Geoportal_JSON_Mapper.prettyPrintProjectEdit(projectView);
return projectView;
}
@ -647,22 +651,29 @@ public class Geoportal_JSON_Mapper {
LOG.info("readGcubeSDILayersForFileset called");
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 {
com.jayway.jsonpath.Configuration configurationJSONSmart = com.jayway.jsonpath.Configuration.builder()
.jsonProvider(new JsonOrgJsonProvider()).build();
LOG.debug("Reading sectionPath {} into section document {}", _materializationsJSONPath, sectionJSONDocument);
JsonPath theSectionPolycJsonPath = JsonPath.compile(_materializationsJSONPath);
Object _materializations = theSectionPolycJsonPath.read(sectionJSONDocument, configurationJSONSmart);
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.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);
}
LOG.info("returning list of layers {}", listSDILayers);
@ -686,14 +697,14 @@ public class Geoportal_JSON_Mapper {
if (objectJSON instanceof JSONArray) {
JSONArray theJsonArray = (JSONArray) objectJSON;
LOG.trace("jsonArray: " + theJsonArray.toString(3));
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.trace("theJSONObject: " + theJsonObject.toString(3));
LOG.debug("theJSONObject: " + theJsonObject.toString(3));
GCubeSDIViewerLayerDV gsdiLayer = converLayer(config, theJsonObject);
listSDILayers.add(gsdiLayer);
}
@ -806,7 +817,7 @@ public class Geoportal_JSON_Mapper {
* @param myLogin the my login
* @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) {
LOG.debug("isAccessibleSectionAccordingToPolicy called");
boolean isAccessible = true;
@ -829,8 +840,8 @@ public class Geoportal_JSON_Mapper {
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
// see ticket #24390
// First reading the access policy from the fileset
String accessPolicyPath = JSON_$_POINTER + ".fileset._access._policy";
boolean isAccessible = true;
try {
@ -842,36 +853,37 @@ public class Geoportal_JSON_Mapper {
try {
JsonPath theSectionPolycJsonPath = JsonPath.compile(accessPolicyPath);
_policy = theSectionPolycJsonPath.read(sectionDocumentJSON, configuration).toString();
if(_policy==null)
if (_policy == null)
throw new Exception("Policy is null");
}catch (Exception e) {
LOG.debug("Access policy not found in: "+accessPolicyPath);
} 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) {
// 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);
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)
if (_policy == null)
throw new Exception("Policy is null");
}catch (Exception e) {
LOG.debug("Access policy not found in: "+accessPolicyPath);
} 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("Is the section {} accessible? {}", sectionDocumentJSON, isAccessible);
LOG.info("It is {} accessible the section {} accessible? {}", isAccessible, sectionDocumentJSON);
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.ProjectsCaller;
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.shared.SearchingFilter;
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.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
/**
* The Class GeoportalViewer_Tests.
@ -54,14 +57,15 @@ public class GeoportalViewer_Tests {
private ProjectsCaller clientProjects;
private static String CONTEXT = "/pred4s/preprod/preVRE";
private static String TOKEN = ""; //preVRE
//private static String CONTEXT = "/pred4s/preprod/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 TOKEN = ""; // devVRE
private static String PROFILE_ID = "profiledConcessioni";
private static String PROJECT_ID = "637ceb4d21dd0d6fb9f24706";
private static String PROJECT_ID = "6388ea6ca1e60e66b7b584e0";
private static String USERNAME = "francesco.mangiacrapa";
@ -99,7 +103,7 @@ public class GeoportalViewer_Tests {
}
}
// @Test
//@Test
public void getLayersForId() {
System.out.println("getLayersForId [profileID: " + PROFILE_ID + ", projectID: " + PROJECT_ID + "] called");
@ -112,10 +116,26 @@ public class GeoportalViewer_Tests {
Project project = clientProjects.getProjectByID(PROFILE_ID, PROJECT_ID);
String jsonDocument = project.getTheDocument().toJson();
System.out.println("JSON Project is: " + jsonDocument);
ACCESS_POLICY accessPolicy = GeportalCheckAccessPolicy.accessPolicyFromSessionLogin(null);
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);
// String materializationParentJSONPath = String.format("%s..%s", Geoportal_JSON_Mapper.JSON_$_POINTER,
// Geoportal_JSON_Mapper.FILESET);
//
listLayers = Geoportal_JSON_Mapper.readGcubeSDILayersForFileset(materializationParentJSONPath,
jsonDocument);

Loading…
Cancel
Save