From 09289b4a31fb6e466f6b9c99e8ea0cbbd3794ded Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 6 Apr 2020 16:11:55 +0200 Subject: [PATCH 1/3] Bug #18951 Added business logic to manage the CKAN hostname via property file --- .classpath | 5 +- .settings/org.eclipse.jdt.core.prefs | 2 + .../resolver/catalogue/ItemCatalogueURLs.java | 1 + .../CatalogueStaticConfigurations.java | 142 ++++++++++++++++++ .../CkanCatalogueConfigurationsReader.java | 98 ++++-------- .../GatewayCKANCatalogueReference.java | 66 ++++++-- ...tacatalogue_urls_configurations.properties | 14 ++ .../datacatalogueconfiguration.properties | 7 - .../resolver/services/CatalogueResolver.java | 21 ++- src/test/java/CatalogueNameExtractor.java | 23 +++ src/test/resources/.gitignore | 1 + 11 files changed, 286 insertions(+), 94 deletions(-) create mode 100644 src/main/java/org/gcube/datatransfer/resolver/catalogue/resource/CatalogueStaticConfigurations.java create mode 100644 src/main/java/org/gcube/datatransfer/resolver/catalogue/resource/datacatalogue_urls_configurations.properties delete mode 100644 src/main/java/org/gcube/datatransfer/resolver/catalogue/resource/datacatalogueconfiguration.properties create mode 100644 src/test/java/CatalogueNameExtractor.java diff --git a/.classpath b/.classpath index 107e885..27073a0 100644 --- a/.classpath +++ b/.classpath @@ -8,15 +8,15 @@ + - - + @@ -29,5 +29,6 @@ + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index a5c7673..43c8195 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -3,7 +3,9 @@ org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore org.eclipse.jdt.core.compiler.release=disabled org.eclipse.jdt.core.compiler.source=1.7 diff --git a/src/main/java/org/gcube/datatransfer/resolver/catalogue/ItemCatalogueURLs.java b/src/main/java/org/gcube/datatransfer/resolver/catalogue/ItemCatalogueURLs.java index d6b74f0..bc11793 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/catalogue/ItemCatalogueURLs.java +++ b/src/main/java/org/gcube/datatransfer/resolver/catalogue/ItemCatalogueURLs.java @@ -23,6 +23,7 @@ public class ItemCatalogueURLs { private String itemName; private boolean isPublicItem; + private String privateVRECataloguePortletURL; private String publicVRECataloguePortletURL; private String publicGatewayCataloguePortletURL; diff --git a/src/main/java/org/gcube/datatransfer/resolver/catalogue/resource/CatalogueStaticConfigurations.java b/src/main/java/org/gcube/datatransfer/resolver/catalogue/resource/CatalogueStaticConfigurations.java new file mode 100644 index 0000000..07cb718 --- /dev/null +++ b/src/main/java/org/gcube/datatransfer/resolver/catalogue/resource/CatalogueStaticConfigurations.java @@ -0,0 +1,142 @@ +package org.gcube.datatransfer.resolver.catalogue.resource; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Arrays; +import java.util.List; +import java.util.Properties; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * The Class CatalogueStaticConfigurations. + * + * @author Francesco Mangiacrapa at ISTI-CNR Pisa (Italy) + * Apr 6, 2020 + */ +public class CatalogueStaticConfigurations{ + + /** The Constant LOG. */ + private static final Logger LOG = LoggerFactory.getLogger(CatalogueStaticConfigurations.class); + + /** The Constant PREFIX_FOR_PORTAL_RELATIVE_URL_TO_CATALOGUE. */ + static final String PREFIX_FOR_PORTAL_RELATIVE_URL_TO_CATALOGUE = "PREFIX_FOR_PORTAL_RELATIVE_URL_TO_CATALOGUE"; + + /** The Constant BALANCER_AND_CKAN_PREFIXES_USED_FOR_HOSTNAME. */ + static final String BALANCER_AND_CKAN_PREFIXES_USED_FOR_HOSTNAME = "BALANCER_AND_CKAN_PREFIXES_USED_FOR_HOSTNAME"; + + /** The Constant DATACATALOGUE_URLs_CONFIGURATIONS_PROPERTIES. */ + static final String DATACATALOGUE_URLs_CONFIGURATIONS_PROPERTIES = "datacatalogue_urls_configurations.properties"; + + /** The prefix to be used for catalogue URL. */ + private String prefixToBeUsedForCatalogueURL; + + /** The prefixes used for ckan hostname. */ + private List prefixesUsedForCkanHostname; + + /** + * Instantiates a new static configurations. + */ + public CatalogueStaticConfigurations() { + loadCataloguePortalURLsConfigurations(); + } + + + /** + * Load catalogue portal URLs configurations. + */ + private void loadCataloguePortalURLsConfigurations(){ + Properties prop = new Properties(); + try { + + InputStream in = CkanCatalogueConfigurationsReader.class.getResourceAsStream(DATACATALOGUE_URLs_CONFIGURATIONS_PROPERTIES); + // load a properties file + prop.load(in); + + // get the property value + String property = prop.getProperty(PREFIX_FOR_PORTAL_RELATIVE_URL_TO_CATALOGUE); + prefixToBeUsedForCatalogueURL = property; + + // get the property value + property = prop.getProperty(BALANCER_AND_CKAN_PREFIXES_USED_FOR_HOSTNAME); + if(property.contains(",")) { + String[] values = property.split(","); + prefixesUsedForCkanHostname = Arrays.asList(values); + }else { + prefixesUsedForCkanHostname = Arrays.asList(property); + } + + } catch (IOException e) { + LOG.error("An error occurred on read property file: "+DATACATALOGUE_URLs_CONFIGURATIONS_PROPERTIES, e); + } + } + + + /** + * Extract catalogue name from a ckan or balancer hostname. + * + * @param privateCKANCatalogueURL the private CKAN catalogue URL + * @return the catalogue name + * + * e.g. Returns "-bb" for "ckan-bb" + */ + private String extractCatalogueName(String privateCKANCatalogueURL) { + + String toPrivateCKANCatalogueURL = privateCKANCatalogueURL; + LOG.debug("Private Catalogue URL is: "+toPrivateCKANCatalogueURL); + //removing protocol HTTPs or HTTP + toPrivateCKANCatalogueURL = toPrivateCKANCatalogueURL.replaceFirst("https://", ""); + toPrivateCKANCatalogueURL = toPrivateCKANCatalogueURL.replaceFirst("http://", ""); + LOG.debug("Removed HTTP[s] protocol, now I have: "+toPrivateCKANCatalogueURL); + for (String prefix :prefixesUsedForCkanHostname) { + LOG.trace(prefix+ " found as prefix of: "+privateCKANCatalogueURL); + if(toPrivateCKANCatalogueURL.startsWith(prefix)) { + toPrivateCKANCatalogueURL = toPrivateCKANCatalogueURL.replaceFirst(prefix, ""); //removing prefix + String catalogueName = toPrivateCKANCatalogueURL.substring(0,toPrivateCKANCatalogueURL.indexOf(".d4science")); + LOG.info("Catalogue Name extration returning value: "+catalogueName); + return catalogueName; + } + } + + LOG.info("Catalogue Name extration returning null"); + return null; + } + + + /** + * Builds the relative URL to public catalogue gateway. + * + * @param privateCKANCatalogueURL the private CKAN catalogue URL + * + * @return the relative URL that must be used for Public Catalogue Gateway + */ + public String buildRelativeURLToPublicCatalogueGateway(String privateCKANCatalogueURL) { + LOG.info("Trying to build the Catalogue Gateway URL using the prefix: "+prefixToBeUsedForCatalogueURL); + LOG.debug("The prefixes to build the URL for Public Catalogue published at Gateway level are: "+prefixesUsedForCkanHostname); + String catalogueName = extractCatalogueName(privateCKANCatalogueURL); + catalogueName = catalogueName == null? "":catalogueName; + String toNormalizedNameForURL = catalogueName.replaceAll("\\.", "-"); + String publicCatalogueGatewayURL = String.format("%s%s", prefixToBeUsedForCatalogueURL,toNormalizedNameForURL); + LOG.info("The Catalogue Gateway URL built is: "+publicCatalogueGatewayURL); + return publicCatalogueGatewayURL; + } + + /** + * Gets the prefixes used for ckan hostname. + * + * @return the prefixes used for ckan hostname + */ + public List getPrefixesUsedForCkanHostname() { + return prefixesUsedForCkanHostname; + } + + /** + * Gets the prefix to be used for catalogue URL. + * + * @return the prefix to be used for catalogue URL + */ + public String getPrefixToBeUsedForCatalogueURL() { + return prefixToBeUsedForCatalogueURL; + } +} \ No newline at end of file diff --git a/src/main/java/org/gcube/datatransfer/resolver/catalogue/resource/CkanCatalogueConfigurationsReader.java b/src/main/java/org/gcube/datatransfer/resolver/catalogue/resource/CkanCatalogueConfigurationsReader.java index f664242..3b1e59e 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/catalogue/resource/CkanCatalogueConfigurationsReader.java +++ b/src/main/java/org/gcube/datatransfer/resolver/catalogue/resource/CkanCatalogueConfigurationsReader.java @@ -8,13 +8,10 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static org.gcube.resources.discovery.icclient.ICFactory.client; -import java.io.IOException; -import java.io.InputStream; import java.io.StringReader; import java.net.URI; import java.util.List; import java.util.Map; -import java.util.Properties; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -38,6 +35,7 @@ import eu.trentorise.opendata.jackan.exceptions.CkanException; import eu.trentorise.opendata.jackan.model.CkanDataset; +// TODO: Auto-generated Javadoc /** * The Class CkanCatalogueConfigurationsReader. * @@ -46,13 +44,17 @@ import eu.trentorise.opendata.jackan.model.CkanDataset; */ public class CkanCatalogueConfigurationsReader { + //private static final String PREFIX_FOR_PORTAL_RELATIVE_URL_TO_CATALOGUE = "PREFIX_FOR_PORTAL_RELATIVE_URL_TO_CATALOGUE"; + /** The Constant logger. */ + //private static final String BALANCER_AND_CKAN_PREFIXES_USED_FOR_HOSTNAME = "BALANCER_AND_CKAN_PREFIXES_USED_FOR_HOSTNAME"; private static final Logger logger = LoggerFactory.getLogger(CkanCatalogueConfigurationsReader.class); + + /** The Constant APPLICATION_PROFILE_NAME. */ public final static String APPLICATION_PROFILE_NAME = "CkanPortlet"; - private static final String DATACATALOGUECONFIGURATION_PROPERTIES = "datacatalogueconfiguration.properties"; - + /** - * Load catalogue end points through the ckan-util-library + * Load catalogue end points through the ckan-util-library. * * @return the gateway ckan catalogue reference * @throws Exception the exception @@ -64,13 +66,13 @@ public class CkanCatalogueConfigurationsReader { DataCatalogueImpl catalogueImpl = CatalogueServiceEndpointReader.getDataCatalogueImpl(); Map accessLevelMap = catalogueImpl.getMapAccessURLToCatalogue(); - links.setMapAccessURLToCatalogue(accessLevelMap); + for (ACCESS_LEVEL_TO_CATALOGUE_PORTLET accessLevel : accessLevelMap.keySet()) { + links.setCatalogueURL(accessLevelMap.get(accessLevel), accessLevel); + } + + //String publicVREPortletURL = accessLevelMap.get(ACCESS_LEVEL_TO_CATALOGUE_PORTLET.PUBLIC_VRE); String privatePortletURL = accessLevelMap.get(ACCESS_LEVEL_TO_CATALOGUE_PORTLET.PRIVATE_VRE); - links.setPrivateVREPortletURL(privatePortletURL); - String publicVREPortletURL = accessLevelMap.get(ACCESS_LEVEL_TO_CATALOGUE_PORTLET.PUBLIC_VRE); - links.setPublicVREPortletURL(publicVREPortletURL); String publicGatewayPortletURL = accessLevelMap.get(ACCESS_LEVEL_TO_CATALOGUE_PORTLET.PUBLIC_GATEWAY); - links.setPublicGatewayPortletURL(publicGatewayPortletURL); try{ //If a catalogue gateway portlet URL is not provided/read from GR, building it @@ -79,13 +81,14 @@ public class CkanCatalogueConfigurationsReader { URI toURL = new URI(privatePortletURL); String publicURL = privatePortletURL.startsWith("https://")?"https://"+toURL.getHost():"http://"+toURL.getHost(); //It returns the string "catalogue" - String prefixToPublicCtlg = getRelativeURLToCatalogue(); - //Replacing for example "ckan-bb" with "catalogue-bb" - String publicCatalogueName = extractCatalogueName(catalogueImpl.getCatalogueUrl(), prefixToPublicCtlg); - links.setPublicGatewayPortletURL(publicURL+"/"+publicCatalogueName); + CatalogueStaticConfigurations staticConf = new CatalogueStaticConfigurations(); + //Replacing for example "ckan-bb" with "[PREFIXES-TO-CATALOGUE-URL]-bb" (e.g catalogue-bb) + String relativeURLWithCatalogueName = staticConf.buildRelativeURLToPublicCatalogueGateway(catalogueImpl.getCatalogueUrl()); + String toGatewayPortletURL = String.format("%s/%s", publicURL, relativeURLWithCatalogueName); + links.setCatalogueURL(toGatewayPortletURL, ACCESS_LEVEL_TO_CATALOGUE_PORTLET.PUBLIC_GATEWAY); } }catch(Exception e){ - logger.warn("Erron on generating public catalogue URL from private URL: "+privatePortletURL, e); + logger.warn("Erron on creating public catalogue URL from private URL: "+privatePortletURL, e); } //Getting the CKAN Portlet URL for current scope @@ -99,22 +102,7 @@ public class CkanCatalogueConfigurationsReader { return links; } - /** - * Extract catalogue name. - * - * @param privateCKANCatalogueURL the private ckan catalogue url - * @param replaceCKANWith the replace ckan with - * @return the string - */ - public static String extractCatalogueName(String privateCKANCatalogueURL, String replaceCKANWith){ - - privateCKANCatalogueURL = privateCKANCatalogueURL.replaceFirst("https://ckan", replaceCKANWith); - privateCKANCatalogueURL = privateCKANCatalogueURL.replaceFirst("http://ckan", replaceCKANWith); - return privateCKANCatalogueURL.substring(0,privateCKANCatalogueURL.indexOf(".")); - - } - - + /** * Retrieve a ckan dataset given its id. The CkanClient is used, without api key. The result is null also when the dataset is private. * @@ -187,44 +175,20 @@ public class CkanCatalogueConfigurationsReader { } /** - * Gets the relative url to catalogue. + * The main method. * - * @return the relative url to catalogue + * @param args the arguments */ - private static String getRelativeURLToCatalogue(){ - Properties prop = new Properties(); - String relativeURLToCatalogue = null; + public static void main(String[] args) { + + ScopeProvider.instance.set("/gcube/devsec/devVRE"); try { - InputStream in = CkanCatalogueConfigurationsReader.class.getResourceAsStream(DATACATALOGUECONFIGURATION_PROPERTIES); - // load a properties file - prop.load(in); - // get the property value - relativeURLToCatalogue = prop.getProperty("PORTAL_RELATIVE_URL_TO_CATALOGUE"); - - if(relativeURLToCatalogue==null || relativeURLToCatalogue.isEmpty()) - return "catalogue"; - - } catch (IOException e) { - logger.error("An error occurred on read property file: "+DATACATALOGUECONFIGURATION_PROPERTIES, e); + GatewayCKANCatalogueReference links = CkanCatalogueConfigurationsReader.loadCatalogueEndPoints(); + System.out.println(links); + } + catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); } - return relativeURLToCatalogue; } - -// /** -// * The main method. -// * -// * @param args the arguments -// */ -// public static void main(String[] args) { -// -// ScopeProvider.instance.set("/gcube/devsec/devVRE"); -// try { -// GatewayCKANCatalogueReference links = CkanCatalogueConfigurationsReader.loadCatalogueEndPoints(); -// System.out.println(links); -// } -// catch (Exception e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } } diff --git a/src/main/java/org/gcube/datatransfer/resolver/catalogue/resource/GatewayCKANCatalogueReference.java b/src/main/java/org/gcube/datatransfer/resolver/catalogue/resource/GatewayCKANCatalogueReference.java index 6d64c53..8bc4e8d 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/catalogue/resource/GatewayCKANCatalogueReference.java +++ b/src/main/java/org/gcube/datatransfer/resolver/catalogue/resource/GatewayCKANCatalogueReference.java @@ -4,17 +4,17 @@ package org.gcube.datatransfer.resolver.catalogue.resource; import java.io.Serializable; +import java.util.HashMap; import java.util.Map; import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogueRunningCluster.ACCESS_LEVEL_TO_CATALOGUE_PORTLET; import lombok.AllArgsConstructor; -import lombok.Getter; import lombok.NoArgsConstructor; -import lombok.Setter; import lombok.ToString; +// TODO: Auto-generated Javadoc /** * The Class GatewayCKANCatalogueReference. * @@ -23,27 +23,65 @@ import lombok.ToString; * Nov 12, 2019 */ - @AllArgsConstructor @NoArgsConstructor -@Getter -@Setter @ToString public class GatewayCKANCatalogueReference implements Serializable{ - /** - * - */ + /** The Constant serialVersionUID. */ private static final long serialVersionUID = 1L; + /** The scope. */ private String scope; - - private String privateVREPortletURL; - private String publicVREPortletURL; - private String publicGatewayPortletURL; - + + /** The ckan URL. */ private String ckanURL; - public Map mapAccessURLToCatalogue; + /** The map access URL to catalogue. */ + private Map mapAccessURLToCatalogue; + + + /** + * Gets the catalogue URL. + * + * @param accessLevel the access level + * @return the catalogue URL + */ + public String getCatalogueURL(ACCESS_LEVEL_TO_CATALOGUE_PORTLET accessLevel) { + + return mapAccessURLToCatalogue.get(accessLevel); + } + + /** + * Sets the catalogue URL. + * + * @param catalogueURL the catalogue URL + * @param accessLevel the access level + */ + protected void setCatalogueURL(String catalogueURL, ACCESS_LEVEL_TO_CATALOGUE_PORTLET accessLevel) { + + if(mapAccessURLToCatalogue==null) + mapAccessURLToCatalogue = new HashMap(); + + mapAccessURLToCatalogue.put(accessLevel, catalogueURL); + } + + public String getScope() { + return scope; + } + + public void setScope(String scope) { + this.scope = scope; + } + + public String getCkanURL() { + return ckanURL; + } + + public void setCkanURL(String ckanURL) { + this.ckanURL = ckanURL; + } + + } diff --git a/src/main/java/org/gcube/datatransfer/resolver/catalogue/resource/datacatalogue_urls_configurations.properties b/src/main/java/org/gcube/datatransfer/resolver/catalogue/resource/datacatalogue_urls_configurations.properties new file mode 100644 index 0000000..be71723 --- /dev/null +++ b/src/main/java/org/gcube/datatransfer/resolver/catalogue/resource/datacatalogue_urls_configurations.properties @@ -0,0 +1,14 @@ +# Property file +# +# author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it +# created 11/2017 +# updated 03/2020 +# +# BALANCER_AND_CKAN_PREFIXES_USED_FOR_HOSTNAME +# eg. for https://ckan-territoriaperti.d4science.org is ckan +# eg. for https://ckan-imarine.d4science.org is ckan +# eg. for https://catalogue.d4science.org is catalogue +# + +PREFIX_FOR_PORTAL_RELATIVE_URL_TO_CATALOGUE = catalogue +BALANCER_AND_CKAN_PREFIXES_USED_FOR_HOSTNAME = ckan,catalogue \ No newline at end of file diff --git a/src/main/java/org/gcube/datatransfer/resolver/catalogue/resource/datacatalogueconfiguration.properties b/src/main/java/org/gcube/datatransfer/resolver/catalogue/resource/datacatalogueconfiguration.properties deleted file mode 100644 index c4729dc..0000000 --- a/src/main/java/org/gcube/datatransfer/resolver/catalogue/resource/datacatalogueconfiguration.properties +++ /dev/null @@ -1,7 +0,0 @@ -# Property files -# -# author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it -# created 11/2017 -# - -PORTAL_RELATIVE_URL_TO_CATALOGUE = catalogue \ No newline at end of file diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/CatalogueResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/CatalogueResolver.java index 3937732..c8a652d 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/CatalogueResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/CatalogueResolver.java @@ -18,6 +18,7 @@ import javax.ws.rs.core.Response; import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.impl.ScopeBean; import org.gcube.common.scope.impl.ScopeBean.Type; +import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogueRunningCluster.ACCESS_LEVEL_TO_CATALOGUE_PORTLET; import org.gcube.datatransfer.resolver.ConstantsResolver; import org.gcube.datatransfer.resolver.caches.LoadingMapOfScopeCache; import org.gcube.datatransfer.resolver.catalogue.CatalogueRequest; @@ -223,13 +224,25 @@ public class CatalogueResolver { } } - String publicGatewayPorltetURL = String.format("%s?path=/%s/%s",ckanCatalogueReference.getPublicGatewayPortletURL(),entityContextValue, entityName); - String privateVREPortletURL = String.format("%s?path=/%s/%s",ckanCatalogueReference.getPrivateVREPortletURL(),entityContextValue, entityName); + String publicGatewayPorltetURL = String.format("%s?path=/%s/%s", + ckanCatalogueReference.getCatalogueURL(ACCESS_LEVEL_TO_CATALOGUE_PORTLET.PUBLIC_GATEWAY), + entityContextValue, + entityName); + + String privateVREPortletURL = String.format("%s?path=/%s/%s", + ckanCatalogueReference.getCatalogueURL(ACCESS_LEVEL_TO_CATALOGUE_PORTLET.PRIVATE_VRE), + entityContextValue, + entityName); + //Checking if the public VRE portlet URL is available (so it was read from GR) String publicVREPortletURL = null; - if(ckanCatalogueReference.getPublicVREPortletURL()!=null && !ckanCatalogueReference.getPublicVREPortletURL().isEmpty()) { + String toCheckPublicVREPortletURL = ckanCatalogueReference.getCatalogueURL(ACCESS_LEVEL_TO_CATALOGUE_PORTLET.PUBLIC_VRE); + if(toCheckPublicVREPortletURL!=null && !toCheckPublicVREPortletURL.isEmpty()) { //here the catalogue is available/deployed as public at VRE level - publicVREPortletURL = String.format("%s?path=/%s/%s",ckanCatalogueReference.getPublicVREPortletURL(),entityContextValue, entityName); + publicVREPortletURL = String.format("%s?path=/%s/%s", + toCheckPublicVREPortletURL, + entityContextValue, + entityName); } return new ItemCatalogueURLs(entityName, isPublicItem, privateVREPortletURL, publicVREPortletURL, publicGatewayPorltetURL); }catch (Exception e) { diff --git a/src/test/java/CatalogueNameExtractor.java b/src/test/java/CatalogueNameExtractor.java new file mode 100644 index 0000000..a38ab90 --- /dev/null +++ b/src/test/java/CatalogueNameExtractor.java @@ -0,0 +1,23 @@ +import org.gcube.datatransfer.resolver.catalogue.resource.CatalogueStaticConfigurations; +import org.junit.Test; + +public class CatalogueNameExtractor { + + String[] CKANs = new String[] { + "https://ckan-grsf-admin2.d4science.org", + "https://ckan.pre.d4science.org/", + "https://ckan-aginfra.d4science.org", + "https://catalogue-imarine.d4science.org/" }; + + @Test + public void extraCatalogueName() { + CatalogueStaticConfigurations staticConf = new CatalogueStaticConfigurations(); + + for (int i = 0; i < CKANs.length; i++) { + System.out.println(CKANs[i]); + staticConf.buildRelativeURLToPublicCatalogueGateway(CKANs[i]); + System.out.println("\n\n"); + } + } + +} diff --git a/src/test/resources/.gitignore b/src/test/resources/.gitignore index 5513774..c04ed84 100644 --- a/src/test/resources/.gitignore +++ b/src/test/resources/.gitignore @@ -10,3 +10,4 @@ /gCubeApps.gcubekey /gcube.gcubekey /preprod.gcubekey +/pred4s.gcubekey From f33a106bc6de8a90e8153b85dc865bc1c822e01c Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 6 Apr 2020 16:19:57 +0200 Subject: [PATCH 2/3] updated pom and changelog --- changelog.xml | 212 +++++++++++++++++++++++++++++++------------------- pom.xml | 2 +- 2 files changed, 132 insertions(+), 82 deletions(-) diff --git a/changelog.xml b/changelog.xml index 5a3dbe1..4b4211f 100644 --- a/changelog.xml +++ b/changelog.xml @@ -1,135 +1,185 @@ - - [Feature #18038] Catalogue Resolver: resolve a public ITEM URL to the public VRE Catalogue (if available) + + [Bug #18951] URI-Resolver: redirect to catalogue public item + must manage the case 'catalogue-' - - - [Feature #17630] Support parametric Content-Disposition + + + [Feature #18038] Catalogue Resolver: resolve a public ITEM URL + to the public VRE Catalogue (if available) - [Bug #17650] Bug #17650: URI-Resolver: HEAD request to + + + [Feature #17630] Support parametric Content-Disposition + + [Bug #17650] Bug #17650: URI-Resolver: HEAD request to StorageID link does not return the "content-disposition - - - [Incident #17180] Bug fixes + + + [Incident #17180] Bug fixes - - - [Feature #16263] Added new dataminer-invocation-model + + + [Feature #16263] Added new dataminer-invocation-model - [Task #16296] Bug fixes + [Task #16296] Bug fixes - [Task #16471] Tested Catalogue Resolver backward compatibility + [Task #16471] Tested Catalogue Resolver backward compatibility - [Incident #16671] Fixing Catalogue Resolver in case of working + [Incident #16671] Fixing Catalogue Resolver in case of working with INFRASTRUCTURE and VO scope - [Incident #16713] GN harvesting from CKAN does not work + [Incident #16713] GN harvesting from CKAN does not work properly - - - [Task #12740] Developed as web-service by using jersey + + + [Task #12740] Developed as web-service by using jersey framework - [Task #12294] Created the resolver 'parthenosregistry' + [Task #12294] Created the resolver 'parthenosregistry' - [Task #13006] Fixing issue on resolving public Catalogues + [Task #13006] Fixing issue on resolving public Catalogues - [Task #12969] Create the new resolvers: "Analitycs" and + [Task #12969] Create the new resolvers: "Analitycs" and "Knime" - + [Feature #13072] Provide Metadata of a public link - - - [Task #10070] Catalogue Resolver enhancement: resolve + + + [Task #10070] Catalogue Resolver enhancement: resolve public/private items to public/private catalogue - - - [Task #9538] Geonetwork-Uri Resolver enhancement: provide new + + + [Task #9538] Geonetwork-Uri Resolver enhancement: provide new filters and improve current ones - - - [Feature #9108] Edit the GenericResource + + + [Feature #9108] Edit the GenericResource (ApplicationProfile-Gis Viewer Application) - - - [Feature #8494] Remove GeoServices query from URI-Resolver + + + [Feature #8494] Remove GeoServices query from URI-Resolver - - - [Feature #7350] GeoExplorer Resolver: resolve a GeoExplorer + + + [Feature #7350] GeoExplorer Resolver: resolve a GeoExplorer Link - [Task #7626] Fix issue on set/reset scope + [Task #7626] Fix issue on set/reset scope - [Task #7807] Provide a check for HAProxy - - - [Task #6492] Catalogue Resolver: "improve"/"build better" + [Task #7807] Provide a check for HAProxy + + + [Task #6492] Catalogue Resolver: "improve"/"build better" public URLs to products - [Task #6952] Catalogue Resolver: update on the fly the + [Task #6952] Catalogue Resolver: update on the fly the Application Profile for VRE's used to resolve Product URL - - - [Task #6119] Provide CatalogueResolver: get/resolve a link to + + + [Task #6119] Provide CatalogueResolver: get/resolve a link to a CKAN Entity - [Task #6262] Catalogue Resolver: get/resolve a direct link + [Task #6262] Catalogue Resolver: get/resolve a direct link - - - Removed scope provider from several resolver - - - [Feature #4207] Uri Resolver upgrade: it must support new + + + Removed scope provider from several resolver + + + [Feature #4207] Uri Resolver upgrade: it must support new Geonetwork Manager - [Task #4250] Geonetwork Resolver upgrade: it must return only + [Task #4250] Geonetwork Resolver upgrade: it must return only "private" Metadata Ids for CKAN harversting - - - [Task #3135] Uri Resolver enhancements: create a Geonetwork + + + [Task #3135] Uri Resolver enhancements: create a Geonetwork Resolver - [Feature #4000] URI Resolver - must support HEAD request + [Feature #4000] URI Resolver - must support HEAD request - - - [Feature #2008] Updated the method to resolve gCube Storage ID + + + [Feature #2008] Updated the method to resolve gCube Storage ID - [Feature #1925] Added class UriResolverRewriteFilter to filter + [Feature #1925] Added class UriResolverRewriteFilter to filter the different public link types, see: #1959 - [gCube - Support #2695] Uri Resolver: patch to fix old bug in + [gCube - Support #2695] Uri Resolver: patch to fix old bug in HL renaming files - - - [Feature #416] Added code to read fileName and content-type + + + [Feature #416] Added code to read fileName and content-type (mime type) from Storage - - - Fixed bug on encoding - Added new resolver: Storage ID Resolver - - - Integrated Gis-Resolver - - - Added fileName and contentType parameters to SMP URI resolver + + + Fixed bug on encoding + Added new resolver: Storage ID Resolver + + + Integrated Gis-Resolver + + + Added fileName and contentType parameters to SMP URI resolver - - - first release - + + + first release + \ No newline at end of file diff --git a/pom.xml b/pom.xml index d5bc4f3..96d4125 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ org.gcube.data.transfer uri-resolver - 2.3.1 + 2.3.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. From 96771103501471393b64c1dedb306ddea3791822 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 7 Apr 2020 16:31:24 +0200 Subject: [PATCH 3/3] commented junit test --- src/test/java/CatalogueNameExtractor.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/java/CatalogueNameExtractor.java b/src/test/java/CatalogueNameExtractor.java index a38ab90..e4460ee 100644 --- a/src/test/java/CatalogueNameExtractor.java +++ b/src/test/java/CatalogueNameExtractor.java @@ -7,9 +7,10 @@ public class CatalogueNameExtractor { "https://ckan-grsf-admin2.d4science.org", "https://ckan.pre.d4science.org/", "https://ckan-aginfra.d4science.org", + "https://catalogue.d4science.org/", "https://catalogue-imarine.d4science.org/" }; - @Test + //@Test public void extraCatalogueName() { CatalogueStaticConfigurations staticConf = new CatalogueStaticConfigurations();