diff --git a/geoportal-service/src/main/java/org/gcube/application/geoportal/service/utils/UserUtils.java b/geoportal-service/src/main/java/org/gcube/application/geoportal/service/utils/UserUtils.java index f8c1996..aac65f6 100644 --- a/geoportal-service/src/main/java/org/gcube/application/geoportal/service/utils/UserUtils.java +++ b/geoportal-service/src/main/java/org/gcube/application/geoportal/service/utils/UserUtils.java @@ -27,14 +27,19 @@ public class UserUtils { log.debug("Context is {}, checking tokens..",context); ClientInfo client = null; + Set roles=new HashSet<>(); try{ client = AuthorizationProvider.instance.get().getClient(); + roles= new HashSet<>(client.getRoles()); }catch(Throwable e) { log.warn("Unable to get client info ",e); + roles = new HashSet<>(); } + + AuthenticatedUser toReturn = - new AuthenticatedUser(client,new HashSet<>(client.getRoles()), AccessTokenProvider.instance.get(),SecurityTokenProvider.instance.get(),context); + new AuthenticatedUser(client,roles, AccessTokenProvider.instance.get(),SecurityTokenProvider.instance.get(),context); log.info("Current User is {} ",toReturn); return toReturn; diff --git a/sdi-plugins/src/main/java/org/gcube/application/cms/sdi/plugins/SDIIndexerPlugin.java b/sdi-plugins/src/main/java/org/gcube/application/cms/sdi/plugins/SDIIndexerPlugin.java index da1b74e..3669cbe 100644 --- a/sdi-plugins/src/main/java/org/gcube/application/cms/sdi/plugins/SDIIndexerPlugin.java +++ b/sdi-plugins/src/main/java/org/gcube/application/cms/sdi/plugins/SDIIndexerPlugin.java @@ -31,6 +31,7 @@ import org.gcube.application.geoportal.common.model.document.Project; import org.gcube.application.geoportal.common.model.document.filesets.sdi.GCubeSDILayer; import org.gcube.application.geoportal.common.model.rest.ConfigurationException; import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor; +import org.geojson.Crs; import org.geojson.GeoJsonObject; import org.geojson.LngLatAlt; import org.geojson.Point; @@ -157,7 +158,6 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin centroidDoc.put("geom", wkt); - throw new Exception("Not yet implemented"); } else{ // unable to use current Spatial reference, try evaluating it log.debug("UseCaseDescriptor {} : Getting evaluation paths from useCaseDescriptor.. ", useCaseDescriptor.getId()); @@ -188,18 +188,20 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin log.info("Evaluated BBOX {} ",toSet); String wkt = String .format("POINT (%1$f %2$f) ", pointX, pointY); + //TODO support altitude + Double pointZ= 0d; centroidDoc.put("geom",wkt); - Point toSetgeoJSON = new Point(); - LngLatAlt pointCoordinates = new LngLatAlt(); - pointCoordinates.setLongitude(pointX); - pointCoordinates.setLatitude(pointY); - toSetgeoJSON.setCoordinates(pointCoordinates); - toSetgeoJSON.setBbox(toSet.asGeoJSONArray()); - reference = new SpatialReference(toSetgeoJSON); + Point point = new Point(); + point.setCoordinates(new LngLatAlt(pointX,pointY,pointZ)); + point.setBbox(toSet.asGeoJSONArray()); + //TODO Manage CRS + point.setCrs(new Crs()); + reference = new SpatialReference(Serialization.asDocument(point)); + log.info("UCD {} project {}, Setting Spatial Reference {} ",useCaseDescriptor.getId(),project.getId(),Serialization.write(reference)); report.addIdentificationReference(reference); } diff --git a/sdi-plugins/src/test/java/org/gcube/application/cms/sdi/plugins/GeoJSONTests.java b/sdi-plugins/src/test/java/org/gcube/application/cms/sdi/plugins/GeoJSONTests.java new file mode 100644 index 0000000..7151447 --- /dev/null +++ b/sdi-plugins/src/test/java/org/gcube/application/cms/sdi/plugins/GeoJSONTests.java @@ -0,0 +1,42 @@ +package org.gcube.application.cms.sdi.plugins; + +import com.fasterxml.jackson.core.JsonProcessingException; +import org.gcube.application.cms.serialization.Serialization; +import org.gcube.application.geoportal.common.model.document.filesets.sdi.GCubeSDILayer; +import org.gcube.application.geoportal.common.model.document.identification.SpatialReference; +import org.geojson.Crs; +import org.geojson.GeoJsonObject; +import org.geojson.LngLatAlt; +import org.geojson.Point; +import org.geotoolkit.referencing.CRS; +import org.junit.Test; + +import java.io.IOException; + +public class GeoJSONTests { + + @Test + public void checkFullCircle() throws IOException { + Point point = new Point(); + point.setCoordinates(new LngLatAlt(13,12,0)); + point.setCrs(new Crs()); + point.setBbox(GCubeSDILayer.BBOX.WORLD.asGeoJSONArray()); + + String value = Serialization.write(point); + System.out.println("String is "+value); + GeoJsonObject obj = Serialization.read(value, GeoJsonObject.class); + System.out.println("OBJ is "+obj); + obj = Serialization.convert(point,GeoJsonObject.class); + System.out.println("Converted obj is "+obj); + + SpatialReference reference =new SpatialReference(Serialization.asDocument(point)); + String referenceString= Serialization.write(reference); + System.out.println("Serialized reference is "+referenceString); + reference=Serialization.read(referenceString,SpatialReference.class); + + System.out.println("Deserialized reference is "+reference); + obj = Serialization.convert(reference.getGeoJson(),GeoJsonObject.class); + System.out.println("Converted from spatial reference is "+obj); + + } +}