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 8265ee9..d6b74f0 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/catalogue/ItemCatalogueURLs.java +++ b/src/main/java/org/gcube/datatransfer/resolver/catalogue/ItemCatalogueURLs.java @@ -24,6 +24,7 @@ public class ItemCatalogueURLs { private String itemName; private boolean isPublicItem; private String privateVRECataloguePortletURL; - private String publicGatewayCataloguePortletURL; private String publicVRECataloguePortletURL; + private String publicGatewayCataloguePortletURL; + } 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 e72f33d..424ec14 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 @@ -50,8 +50,7 @@ public class CkanCatalogueConfigurationsReader { public final static String APPLICATION_PROFILE_NAME = "CkanPortlet"; private static final String DATACATALOGUECONFIGURATION_PROPERTIES = "datacatalogueconfiguration.properties"; - - + /** * Load catalogue end points. * @@ -64,23 +63,27 @@ public class CkanCatalogueConfigurationsReader { DataCatalogueImpl catalogueImpl = CatalogueServiceEndpointReader.getDataCatalogueImpl(); - //String privatePortletURL = catalogueImpl.getPortletUrl(); - Map accessLevelMap = catalogueImpl.getMapAccessURLToCatalogue(); + links.setMapAccessURLToCatalogue(accessLevelMap); 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); - - //Building public URL from private portlet URL + String publicGatewayPortletURL = accessLevelMap.get(ACCESS_LEVEL_TO_CATALOGUE_PORTLET.PUBLIC_GATEWAY); + links.setPublicGatewayPortletURL(publicGatewayPortletURL); + try{ - 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); + + if(publicGatewayPortletURL==null || publicGatewayPortletURL.isEmpty()) { + //Building the gateway catalogue public URL from private VRE Portlet URL + 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); + } }catch(Exception e){ logger.warn("Erron on generating public catalogue URL from private URL: "+privatePortletURL, e); } 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 994b7a7..6d64c53 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 @@ -12,6 +12,7 @@ import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; +import lombok.ToString; /** @@ -27,6 +28,7 @@ import lombok.Setter; @NoArgsConstructor @Getter @Setter +@ToString public class GatewayCKANCatalogueReference implements Serializable{ /** @@ -43,5 +45,5 @@ public class GatewayCKANCatalogueReference implements Serializable{ private String ckanURL; public Map mapAccessURLToCatalogue; - + } 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 7c5a051..ec86f80 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/CatalogueResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/CatalogueResolver.java @@ -226,7 +226,7 @@ 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 publicVREPortletURL = String.format("%s?path=/%s/%s",ckanCatalogueReference.getPublicVREPortletURL(),entityContextValue, entityName); - return new ItemCatalogueURLs(entityName, isPublicItem, privateVREPortletURL, publicGatewayPorltetURL, publicVREPortletURL); + return new ItemCatalogueURLs(entityName, isPublicItem, privateVREPortletURL, publicVREPortletURL, publicGatewayPorltetURL); }catch (Exception e) { logger.error("Error when resolving CatalogueURL:", e); throw e;