diff --git a/distro/changelog.xml b/distro/changelog.xml index 01d17f6..94d5d79 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -149,7 +149,14 @@ [Incident #16671] Fixing Catalogue Resolver in case of working with INFRASTRUCTURE and VO scope - [Incident #16713] GN harvesting from CKAN does not work properly + [Incident #16713] GN harvesting from CKAN does not work + properly + + + + [Incident #17180] Bug fixes \ No newline at end of file diff --git a/pom.xml b/pom.xml index ba7c5ce..f8b23f7 100644 --- a/pom.xml +++ b/pom.xml @@ -9,9 +9,9 @@ org.gcube.data.transfer uri-resolver - 2.1.0-SNAPSHOT + 2.1.1-SNAPSHOT war - The URI Resolver is an HTTP URI resolver implemented as an REST service which gives access trough HTTP to different gcube Resolvers and gCube Applications. + The URI Resolver is an HTTP URI resolver implemented as an REST service which gives access trough HTTP to different gcube Resolvers and gCube Applications. scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/data-transfer/${project.artifactId} diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/GisResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/GisResolver.java index b6c9e27..79f0d6e 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/GisResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/GisResolver.java @@ -26,6 +26,7 @@ import org.gcube.datatransfer.resolver.gis.entity.GisLayerItem; import org.gcube.datatransfer.resolver.gis.exception.GeonetworkInstanceException; import org.gcube.datatransfer.resolver.init.UriResolverSmartGearManagerInit; import org.gcube.datatransfer.resolver.services.error.ExceptionManager; +import org.gcube.spatial.data.geonetwork.LoginLevel; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -192,18 +193,23 @@ public class GisResolver { * @return the gis layer for layer uuid * @throws Exception the exception */ - protected GisLayerItem getGisLayerForLayerUUID(HttpServletRequest req, String scope, String gisUUID) throws Exception{ + public GisLayerItem getGisLayerForLayerUUID(HttpServletRequest req, String scope, String gisUUID) throws Exception{ try { GeonetworkInstance gi = null; try { gi = LoadingGeonetworkInstanceCache.get(scope); + }catch(ExecutionException | InvalidCacheLoadException e){ logger.error("Error on getting the Geonetwork Instance from cache for scope "+scope, e); throw ExceptionManager.wrongParameterException(req, "Error on getting the Geonetwork Instance from cache for scope "+scope+". Is it registered for this scope: "+scope+"?", this.getClass(), help); } if(gi==null) throw new Exception("GeonetworkInstance not instanciable in the scope: "+scope); + + LoginLevel toLoginLevel = LoginLevel.SCOPE; + logger.info("Performing authentication on GN with "+LoginLevel.class.getSimpleName()+" "+toLoginLevel); + gi.getGeonetworkPublisher().login(toLoginLevel); GisLayerItem gisLayerItem = MetadataConverter.getWMSOnLineResource(gi, gisUUID); return gisLayerItem; diff --git a/src/test/java/CatalogueResolverTest.java b/src/test/java/CatalogueResolverTest.java index 06bd337..123b132 100644 --- a/src/test/java/CatalogueResolverTest.java +++ b/src/test/java/CatalogueResolverTest.java @@ -23,7 +23,7 @@ public class CatalogueResolverTest { try { - ScopeProvider.instance.set("/d4science.research-infrastructures.eu"); + ScopeProvider.instance.set("/d4science.research-infrastructures.eu/gCubeApps/BiodiversityLab"); //ScopeProvider.instance.set("/d4science.research-infrastructures.eu"); GatewayCKANCatalogueReference ckanCatalogueReference = CkanCatalogueConfigurationsReader.loadCatalogueEndPoints(); System.out.println(ckanCatalogueReference.toString()); diff --git a/src/test/java/GisResolverTest.java b/src/test/java/GisResolverTest.java index 95a2c21..b209b06 100644 --- a/src/test/java/GisResolverTest.java +++ b/src/test/java/GisResolverTest.java @@ -1,5 +1,6 @@ - - +import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.datatransfer.resolver.gis.entity.GisLayerItem; +import org.gcube.datatransfer.resolver.services.GisResolver; /** * @@ -10,31 +11,44 @@ * Sep 7, 2016 */ public class GisResolverTest { - - - /*public void resolve(){ + + static String scope = "/d4science.research-infrastructures.eu/gCubeApps/BiodiversityLab"; + static String gisUUID = "6b99efdf-2202-4b6f-aaa3-7e10e0bf09f4"; + public static void main(String[] args) { GisResolver gisResolver = new GisResolver(); - String scope = "/gcube/devsec/devVRE"; - String UUID = "177e1c3c-4a22-4ad9-b015-bfc443d16cb8"; + ScopeProvider.instance.set(scope); + //ServerParameters geonetworkParams = getCachedServerParameters(scope); try { - ServerParameters geonetworkParams = gisResolver.getCachedServerParameters(scope); - String wmsRequest = gisResolver.getLayerWmsRequest(scope, UUID, geonetworkParams); - System.out.println("Final url is: " + wmsRequest); - wmsRequest = URLEncoder.encode(wmsRequest, UTF_8); - System.out.println("Encoded WMS request is: " + wmsRequest); - String gisPortletUrl = gisResolver.getGisViewerApplicationURL(scope); - System.out.println("Gis Viewer Application url is: " + gisPortletUrl); -// logger.info("WmsRequest is: " + wmsRequest); -// wmsRequest = encodeURLWithParamDelimiter(wmsRequest); -// logger.info("Encoded url is: " + wmsRequest); -// wmsRequest = appendParamReplacement(wmsRequest); - gisPortletUrl+="?wmsrequest="+wmsRequest; - - System.out.println(gisPortletUrl); -// urlRedirect(req, resp, gisPortletUrl); + GisLayerItem gisLayerItem = gisResolver.getGisLayerForLayerUUID(null, scope, gisUUID); } catch (Exception e) { - // TODO Auto-generated catch block e.printStackTrace(); } - }*/ + } + + +// public void resolve(){ +// GisResolver gisResolver = new GisResolver(); +// String scope = "/gcube/devsec/devVRE"; +// String UUID = "177e1c3c-4a22-4ad9-b015-bfc443d16cb8"; +// try { +// ServerParameters geonetworkParams = gisResolver.getCachedServerParameters(scope); +// String wmsRequest = gisResolver.getLayerWmsRequest(scope, UUID, geonetworkParams); +// System.out.println("Final url is: " + wmsRequest); +// wmsRequest = URLEncoder.encode(wmsRequest, UTF_8); +// System.out.println("Encoded WMS request is: " + wmsRequest); +// String gisPortletUrl = gisResolver.getGisViewerApplicationURL(scope); +// System.out.println("Gis Viewer Application url is: " + gisPortletUrl); +//// logger.info("WmsRequest is: " + wmsRequest); +//// wmsRequest = encodeURLWithParamDelimiter(wmsRequest); +//// logger.info("Encoded url is: " + wmsRequest); +//// wmsRequest = appendParamReplacement(wmsRequest); +// gisPortletUrl+="?wmsrequest="+wmsRequest; +// +// System.out.println(gisPortletUrl); +//// urlRedirect(req, resp, gisPortletUrl); +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } }