Merge branch 'Bug/18951'
This commit is contained in:
commit
4042ca34d8
|
@ -8,15 +8,15 @@
|
|||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="test" value="true"/>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
|
@ -29,5 +29,6 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="var" path="GCUBE_DEV_KEYS"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -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
|
||||
|
|
212
changelog.xml
212
changelog.xml
|
@ -1,135 +1,185 @@
|
|||
<ReleaseNotes>
|
||||
<Changeset component="org.gcube.data-transfer.uri-resolver.2-2-0" date="2019-11-12">
|
||||
<Change>[Feature #18038] Catalogue Resolver: resolve a public ITEM URL to the public VRE Catalogue (if available)
|
||||
<Changeset
|
||||
component="org.gcube.data-transfer.uri-resolver.2-3-1"
|
||||
date="2020-04-06">
|
||||
<Change>[Bug #18951] URI-Resolver: redirect to catalogue public item
|
||||
must manage the case 'catalogue-'
|
||||
</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.data-transfer.uri-resolver.2-2-0" date="2019-10-04">
|
||||
<Change>[Feature #17630] Support parametric Content-Disposition
|
||||
</Changeset>
|
||||
<Changeset
|
||||
component="org.gcube.data-transfer.uri-resolver.2-2-0"
|
||||
date="2019-11-12">
|
||||
<Change>[Feature #18038] Catalogue Resolver: resolve a public ITEM URL
|
||||
to the public VRE Catalogue (if available)
|
||||
</Change>
|
||||
<Change>[Bug #17650] Bug #17650: URI-Resolver: HEAD request to
|
||||
</Changeset>
|
||||
<Changeset
|
||||
component="org.gcube.data-transfer.uri-resolver.2-2-0"
|
||||
date="2019-10-04">
|
||||
<Change>[Feature #17630] Support parametric Content-Disposition
|
||||
</Change>
|
||||
<Change>[Bug #17650] Bug #17650: URI-Resolver: HEAD request to
|
||||
StorageID link does not return the "content-disposition
|
||||
</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.data-transfer.uri-resolver.2-1-1" date="2019-07-16">
|
||||
<Change>[Incident #17180] Bug fixes
|
||||
</Changeset>
|
||||
<Changeset
|
||||
component="org.gcube.data-transfer.uri-resolver.2-1-1"
|
||||
date="2019-07-16">
|
||||
<Change>[Incident #17180] Bug fixes
|
||||
</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.data-transfer.uri-resolver.2-1-0" date="2019-03-14">
|
||||
<Change>[Feature #16263] Added new dataminer-invocation-model
|
||||
</Changeset>
|
||||
<Changeset
|
||||
component="org.gcube.data-transfer.uri-resolver.2-1-0"
|
||||
date="2019-03-14">
|
||||
<Change>[Feature #16263] Added new dataminer-invocation-model
|
||||
</Change>
|
||||
<Change>[Task #16296] Bug fixes
|
||||
<Change>[Task #16296] Bug fixes
|
||||
</Change>
|
||||
<Change>[Task #16471] Tested Catalogue Resolver backward compatibility
|
||||
<Change>[Task #16471] Tested Catalogue Resolver backward compatibility
|
||||
</Change>
|
||||
<Change>[Incident #16671] Fixing Catalogue Resolver in case of working
|
||||
<Change>[Incident #16671] Fixing Catalogue Resolver in case of working
|
||||
with INFRASTRUCTURE and VO scope
|
||||
</Change>
|
||||
<Change>[Incident #16713] GN harvesting from CKAN does not work
|
||||
<Change>[Incident #16713] GN harvesting from CKAN does not work
|
||||
properly
|
||||
</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.data-transfer.uri-resolver.2-0-0" date="2018-10-23">
|
||||
<Change>[Task #12740] Developed as web-service by using jersey
|
||||
</Changeset>
|
||||
<Changeset
|
||||
component="org.gcube.data-transfer.uri-resolver.2-0-0"
|
||||
date="2018-10-23">
|
||||
<Change>[Task #12740] Developed as web-service by using jersey
|
||||
framework
|
||||
</Change>
|
||||
<Change>[Task #12294] Created the resolver 'parthenosregistry'
|
||||
<Change>[Task #12294] Created the resolver 'parthenosregistry'
|
||||
</Change>
|
||||
<Change>[Task #13006] Fixing issue on resolving public Catalogues
|
||||
<Change>[Task #13006] Fixing issue on resolving public Catalogues
|
||||
</Change>
|
||||
<Change>[Task #12969] Create the new resolvers: "Analitycs" and
|
||||
<Change>[Task #12969] Create the new resolvers: "Analitycs" and
|
||||
"Knime"
|
||||
</Change>
|
||||
<Change>
|
||||
<Change>
|
||||
[Feature #13072] Provide Metadata of a public link
|
||||
</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.data-transfer.uri-resolver.1-15-0" date="2018-07-20">
|
||||
<Change>[Task #10070] Catalogue Resolver enhancement: resolve
|
||||
</Changeset>
|
||||
<Changeset
|
||||
component="org.gcube.data-transfer.uri-resolver.1-15-0"
|
||||
date="2018-07-20">
|
||||
<Change>[Task #10070] Catalogue Resolver enhancement: resolve
|
||||
public/private items to public/private catalogue
|
||||
</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.data-transfer.uri-resolver.1-14-0" date="2017-09-06">
|
||||
<Change>[Task #9538] Geonetwork-Uri Resolver enhancement: provide new
|
||||
</Changeset>
|
||||
<Changeset
|
||||
component="org.gcube.data-transfer.uri-resolver.1-14-0"
|
||||
date="2017-09-06">
|
||||
<Change>[Task #9538] Geonetwork-Uri Resolver enhancement: provide new
|
||||
filters and improve current ones
|
||||
</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.data-transfer.uri-resolver.1-13-0" date="2017-07-03">
|
||||
<Change>[Feature #9108] Edit the GenericResource
|
||||
</Changeset>
|
||||
<Changeset
|
||||
component="org.gcube.data-transfer.uri-resolver.1-13-0"
|
||||
date="2017-07-03">
|
||||
<Change>[Feature #9108] Edit the GenericResource
|
||||
(ApplicationProfile-Gis Viewer Application)
|
||||
</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.data-transfer.uri-resolver.1-12-0" date="2017-05-15">
|
||||
<Change>[Feature #8494] Remove GeoServices query from URI-Resolver
|
||||
</Changeset>
|
||||
<Changeset
|
||||
component="org.gcube.data-transfer.uri-resolver.1-12-0"
|
||||
date="2017-05-15">
|
||||
<Change>[Feature #8494] Remove GeoServices query from URI-Resolver
|
||||
</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.data-transfer.uri-resolver.1-11-0" date="2017-03-22">
|
||||
<Change>[Feature #7350] GeoExplorer Resolver: resolve a GeoExplorer
|
||||
</Changeset>
|
||||
<Changeset
|
||||
component="org.gcube.data-transfer.uri-resolver.1-11-0"
|
||||
date="2017-03-22">
|
||||
<Change>[Feature #7350] GeoExplorer Resolver: resolve a GeoExplorer
|
||||
Link
|
||||
</Change>
|
||||
<Change>[Task #7626] Fix issue on set/reset scope
|
||||
<Change>[Task #7626] Fix issue on set/reset scope
|
||||
</Change>
|
||||
<Change>[Task #7807] Provide a check for HAProxy</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.data-transfer.uri-resolver.1-10-0" date="2017-02-28">
|
||||
<Change>[Task #6492] Catalogue Resolver: "improve"/"build better"
|
||||
<Change>[Task #7807] Provide a check for HAProxy</Change>
|
||||
</Changeset>
|
||||
<Changeset
|
||||
component="org.gcube.data-transfer.uri-resolver.1-10-0"
|
||||
date="2017-02-28">
|
||||
<Change>[Task #6492] Catalogue Resolver: "improve"/"build better"
|
||||
public URLs to products
|
||||
</Change>
|
||||
<Change>[Task #6952] Catalogue Resolver: update on the fly the
|
||||
<Change>[Task #6952] Catalogue Resolver: update on the fly the
|
||||
Application Profile for VRE's used to resolve Product URL
|
||||
</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.data-transfer.uri-resolver.1-9-0" date="2016-12-20">
|
||||
<Change>[Task #6119] Provide CatalogueResolver: get/resolve a link to
|
||||
</Changeset>
|
||||
<Changeset
|
||||
component="org.gcube.data-transfer.uri-resolver.1-9-0"
|
||||
date="2016-12-20">
|
||||
<Change>[Task #6119] Provide CatalogueResolver: get/resolve a link to
|
||||
a CKAN Entity
|
||||
</Change>
|
||||
<Change>[Task #6262] Catalogue Resolver: get/resolve a direct link
|
||||
<Change>[Task #6262] Catalogue Resolver: get/resolve a direct link
|
||||
</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.data-transfer.uri-resolver.1-8-0" date="2016-10-26">
|
||||
<Change>Removed scope provider from several resolver</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.data-transfer.uri-resolver.1-7-0" date="2016-06-09">
|
||||
<Change>[Feature #4207] Uri Resolver upgrade: it must support new
|
||||
</Changeset>
|
||||
<Changeset
|
||||
component="org.gcube.data-transfer.uri-resolver.1-8-0"
|
||||
date="2016-10-26">
|
||||
<Change>Removed scope provider from several resolver</Change>
|
||||
</Changeset>
|
||||
<Changeset
|
||||
component="org.gcube.data-transfer.uri-resolver.1-7-0"
|
||||
date="2016-06-09">
|
||||
<Change>[Feature #4207] Uri Resolver upgrade: it must support new
|
||||
Geonetwork Manager
|
||||
</Change>
|
||||
<Change>[Task #4250] Geonetwork Resolver upgrade: it must return only
|
||||
<Change>[Task #4250] Geonetwork Resolver upgrade: it must return only
|
||||
"private" Metadata Ids for CKAN harversting
|
||||
</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.data-transfer.uri-resolver.1-6-0" date="2016-05-16">
|
||||
<Change>[Task #3135] Uri Resolver enhancements: create a Geonetwork
|
||||
</Changeset>
|
||||
<Changeset
|
||||
component="org.gcube.data-transfer.uri-resolver.1-6-0"
|
||||
date="2016-05-16">
|
||||
<Change>[Task #3135] Uri Resolver enhancements: create a Geonetwork
|
||||
Resolver
|
||||
</Change>
|
||||
<Change>[Feature #4000] URI Resolver - must support HEAD request
|
||||
<Change>[Feature #4000] URI Resolver - must support HEAD request
|
||||
</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.data-transfer.uri-resolver.1-5-0" date="2016-03-17">
|
||||
<Change>[Feature #2008] Updated the method to resolve gCube Storage ID
|
||||
</Changeset>
|
||||
<Changeset
|
||||
component="org.gcube.data-transfer.uri-resolver.1-5-0"
|
||||
date="2016-03-17">
|
||||
<Change>[Feature #2008] Updated the method to resolve gCube Storage ID
|
||||
</Change>
|
||||
<Change>[Feature #1925] Added class UriResolverRewriteFilter to filter
|
||||
<Change>[Feature #1925] Added class UriResolverRewriteFilter to filter
|
||||
the different public link types, see: #1959
|
||||
</Change>
|
||||
<Change>[gCube - Support #2695] Uri Resolver: patch to fix old bug in
|
||||
<Change>[gCube - Support #2695] Uri Resolver: patch to fix old bug in
|
||||
HL renaming files
|
||||
</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.data-transfer.uri-resolver.1-4-0" date="2015-09-21">
|
||||
<Change>[Feature #416] Added code to read fileName and content-type
|
||||
</Changeset>
|
||||
<Changeset
|
||||
component="org.gcube.data-transfer.uri-resolver.1-4-0"
|
||||
date="2015-09-21">
|
||||
<Change>[Feature #416] Added code to read fileName and content-type
|
||||
(mime type) from Storage
|
||||
</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.data-transfer.uri-resolver.1-3-0" date="2015-04-28">
|
||||
<Change>Fixed bug on encoding</Change>
|
||||
<Change>Added new resolver: Storage ID Resolver</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.data-transfer.uri-resolver.1-2-0" date="2014-10-20">
|
||||
<Change>Integrated Gis-Resolver</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.data-transfer.uri-resolver.1-1-0" date="2013-07-09">
|
||||
<Change>Added fileName and contentType parameters to SMP URI resolver
|
||||
</Changeset>
|
||||
<Changeset
|
||||
component="org.gcube.data-transfer.uri-resolver.1-3-0"
|
||||
date="2015-04-28">
|
||||
<Change>Fixed bug on encoding</Change>
|
||||
<Change>Added new resolver: Storage ID Resolver</Change>
|
||||
</Changeset>
|
||||
<Changeset
|
||||
component="org.gcube.data-transfer.uri-resolver.1-2-0"
|
||||
date="2014-10-20">
|
||||
<Change>Integrated Gis-Resolver</Change>
|
||||
</Changeset>
|
||||
<Changeset
|
||||
component="org.gcube.data-transfer.uri-resolver.1-1-0"
|
||||
date="2013-07-09">
|
||||
<Change>Added fileName and contentType parameters to SMP URI resolver
|
||||
</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.data-transfer.uri-resolver.1-0-0" date="2013-04-19">
|
||||
<Change>first release</Change>
|
||||
</Changeset>
|
||||
</Changeset>
|
||||
<Changeset
|
||||
component="org.gcube.data-transfer.uri-resolver.1-0-0"
|
||||
date="2013-04-19">
|
||||
<Change>first release</Change>
|
||||
</Changeset>
|
||||
</ReleaseNotes>
|
2
pom.xml
2
pom.xml
|
@ -9,7 +9,7 @@
|
|||
</parent>
|
||||
<groupId>org.gcube.data.transfer</groupId>
|
||||
<artifactId>uri-resolver</artifactId>
|
||||
<version>2.3.1</version>
|
||||
<version>2.3.1-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
<description>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.</description>
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ public class ItemCatalogueURLs {
|
|||
|
||||
private String itemName;
|
||||
private boolean isPublicItem;
|
||||
|
||||
private String privateVRECataloguePortletURL;
|
||||
private String publicVRECataloguePortletURL;
|
||||
private String publicGatewayCataloguePortletURL;
|
||||
|
|
|
@ -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<String> 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<String> 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;
|
||||
}
|
||||
}
|
|
@ -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<ACCESS_LEVEL_TO_CATALOGUE_PORTLET, String> 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();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -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<ACCESS_LEVEL_TO_CATALOGUE_PORTLET, String> mapAccessURLToCatalogue;
|
||||
/** The map access URL to catalogue. */
|
||||
private Map<ACCESS_LEVEL_TO_CATALOGUE_PORTLET, String> 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<ACCESS_LEVEL_TO_CATALOGUE_PORTLET, String>();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
|
@ -1,7 +0,0 @@
|
|||
# Property files
|
||||
#
|
||||
# author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
# created 11/2017
|
||||
#
|
||||
|
||||
PORTAL_RELATIVE_URL_TO_CATALOGUE = catalogue
|
|
@ -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) {
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
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.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");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue