merged (again) with #18967

This commit is contained in:
Francesco Mangiacrapa 2020-06-18 15:48:47 +02:00
parent 257682bed8
commit 29e1949301
15 changed files with 403 additions and 43 deletions

View File

@ -4,6 +4,13 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v2-4-0] [r4-24-0]- 2020-06-18
**New Features**
[#18967] Extend the URIResolver behaviour to deal with Catalogue items belonging to Dismissed VREs
## [v2-3-2] [r4-23-0]- 2020-05-18 ## [v2-3-2] [r4-23-0]- 2020-05-18
[#19288] Release the URI-Resolver to integrate the patched Uri-Resolver-Manager [#19288] Release the URI-Resolver to integrate the patched Uri-Resolver-Manager

View File

@ -9,7 +9,7 @@
</parent> </parent>
<groupId>org.gcube.data.transfer</groupId> <groupId>org.gcube.data.transfer</groupId>
<artifactId>uri-resolver</artifactId> <artifactId>uri-resolver</artifactId>
<version>2.3.2</version> <version>2.4.0-SNAPSHOT</version>
<packaging>war</packaging> <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> <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>
@ -85,6 +85,12 @@
<version>[0.0.1,1.0.0-SNAPSHOT)</version> <version>[0.0.1,1.0.0-SNAPSHOT)</version>
</dependency> </dependency>
<dependency>
<groupId>org.gcube.infrastructure.detachedres</groupId>
<artifactId>detachedres-library</artifactId>
<version>[1.0.0,2.0.0-SNAPSHOT)</version>
</dependency>
<!-- TODO REMOVE THIS IMPORT --> <!-- TODO REMOVE THIS IMPORT -->
<dependency> <dependency>
<groupId>org.gcube.common</groupId> <groupId>org.gcube.common</groupId>

View File

@ -53,7 +53,7 @@ public class LoadingGNPublicLayerIDsInstanceCache {
RemovalListener<String, List<String>> removalListener = new RemovalListener<String, List<String>>() { RemovalListener<String, List<String>> removalListener = new RemovalListener<String, List<String>>() {
public void onRemoval(RemovalNotification<String, List<String>> removal) { public void onRemoval(RemovalNotification<String, List<String>> removal) {
logger.info("cache expired"); logger.debug("cache expired");
} }
}; };

View File

@ -46,7 +46,7 @@ public class LoadingGeoExplorerApplicationURLCache {
RemovalListener<String, String> removalListener = new RemovalListener<String, String>() { RemovalListener<String, String> removalListener = new RemovalListener<String, String>() {
public void onRemoval(RemovalNotification<String, String> removal) { public void onRemoval(RemovalNotification<String, String> removal) {
logger.info("cache expired"); logger.debug("cache expired");
} }
}; };

View File

@ -48,7 +48,7 @@ public class LoadingGeonetworkInstanceCache {
RemovalListener<String, GeonetworkInstance> removalListener = new RemovalListener<String, GeonetworkInstance>() { RemovalListener<String, GeonetworkInstance> removalListener = new RemovalListener<String, GeonetworkInstance>() {
public void onRemoval(RemovalNotification<String, GeonetworkInstance> removal) { public void onRemoval(RemovalNotification<String, GeonetworkInstance> removal) {
logger.info("cache expired"); logger.debug("cache expired");
} }
}; };

View File

@ -46,7 +46,7 @@ public class LoadingGisViewerApplicationURLCache {
RemovalListener<String, String> removalListener = new RemovalListener<String, String>() { RemovalListener<String, String> removalListener = new RemovalListener<String, String>() {
public void onRemoval(RemovalNotification<String, String> removal) { public void onRemoval(RemovalNotification<String, String> removal) {
logger.info("cache expired"); logger.debug("cache expired");
} }
}; };

View File

@ -0,0 +1,208 @@
/**
*
*/
package org.gcube.datatransfer.resolver.caches;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.datatransfer.resolver.init.UriResolverSmartGearManagerInit;
import org.gcube.infrastructure.detachedres.detachedreslibrary.server.DetachedREsClient;
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.DetachedREs;
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.Gateway;
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.VO;
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.VRE;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.cache.RemovalListener;
import com.google.common.cache.RemovalNotification;
/**
* The Class LoadingMapOfDetachedVRE.
*
* @author Francesco Mangiacrapa at ISTI-CNR Pisa (Italy)
* Jun 10, 2020
*/
public class LoadingMapOfDetachedVRE {
private static Logger LOG = LoggerFactory.getLogger(LoadingMapOfDetachedVRE.class);
private static LoadingCache<String, VRE> vreNameToVRE;
static{
CacheLoader<String, VRE> loader = new CacheLoader<String, VRE>(){
@Override
public VRE load(String vreName)
throws Exception {
LOG.info("Loading the cache for VRE name: {}",vreName);
VRE theVRE = loadVREObjForVREName(vreName);
if(theVRE!=null)
LOG.info("Returning {} with scope {} for the VRE name: {}", VRE.class.getSimpleName(), theVRE.getScope(), vreName);
else {
LOG.info("No VRE obj for VRE name {}",vreName);
}
return theVRE;
}
};
RemovalListener<String, VRE> removalListener = new RemovalListener<String, VRE>() {
@Override
public void onRemoval(RemovalNotification<String, VRE> arg0) {
LOG.debug("cache expired");
}
};
vreNameToVRE = CacheBuilder.newBuilder().maximumSize(300).expireAfterWrite(
12, TimeUnit.HOURS).removalListener(removalListener).
build(loader);
//Populating the cache at init stage
populateTheCache();
LOG.info("Pre-Loaded detached VRE Name to VRE Obj cache with: "+vreNameToVRE.asMap().size()+" item/s");
}
/**
* Populate the cache.
*/
private static void populateTheCache(){
String authorizationToken = null;
try{
//Populating the cache by using the detachedres-library
LOG.info("Trying to pre-populate the detached VREs cache with mapping (VRE Name, VRE Obj)");
ScopeProvider.instance.set(UriResolverSmartGearManagerInit.getRootContextScope());
authorizationToken = SecurityTokenProvider.instance.get();
if(authorizationToken==null) {
LOG.info("No token found into {} to instance the {}, so reading it from SG configurations",
SecurityTokenProvider.class.getSimpleName(), DetachedREsClient.class.getSimpleName());
authorizationToken = UriResolverSmartGearManagerInit.getRootTokenFromSGConfiguration();
if(authorizationToken!=null)
SecurityTokenProvider.instance.set(authorizationToken);
}
DetachedREsClient detachedREsClient = new DetachedREsClient();
DetachedREs detachedREs = detachedREsClient.getDetachedREs();
int totalVREDimissed = 0;
for (Gateway gateway : detachedREs.getGateways().values()) {
LOG.trace("Gateway: " + gateway.getName());
int vreDismissedPerGatew = 0;
for (VO vo : gateway.getVos().values()) {
LOG.trace("VO: " + vo.getName());
for (VRE vre : vo.getVres().values()) {
if(LOG.isTraceEnabled()) {
LOG.trace("VRE name: " + vre.getName() +
" scope: "+vre.getScope() +
" VRE catalogue url: " + vre.getCatalogUrl() +
" VRE catalog Portlet URL: "+vre.getCatalogPortletURL());
}
try {
if(vre.getScope()!=null && !vre.getScope().isEmpty()) {
String vreName = vre.getScope().split("/")[3];
vreNameToVRE.asMap().put(vreName, vre);
vreDismissedPerGatew++;
}
}catch (Exception e) {
LOG.warn("Error on parsing the scope: "+vre.getScope()+ " skipping it");
}
}
}
LOG.debug("VREs dismissed loaded and cached per " + gateway.getName() + " are: "+vreDismissedPerGatew);
totalVREDimissed+=vreDismissedPerGatew;
}
LOG.debug("Total detached VREs are: "+totalVREDimissed);
LOG.info("Cache populated with: ");
Map<String, VRE> mapOfVreNames = vreNameToVRE.asMap();
for (String key : mapOfVreNames.keySet()) {
VRE theDetachedVRE = mapOfVreNames.get(key);
LOG.info("VRE name {}, VRE obj with scope {}, catalogueURL {}, cataloguePortletURL {}",
key,
theDetachedVRE.getScope(),
theDetachedVRE.getCatalogUrl(),
theDetachedVRE.getCatalogPortletURL());
}
}catch(Exception e){
//SILENT
}finally{
if(authorizationToken!=null) {
LOG.info("resetting security token provider");
SecurityTokenProvider.instance.reset();
}
}
}
/**
* Gets the VRE obj for input VRE name.
*
* @param vreName the vre name
* @return the vre
* @throws ExecutionException the execution exception
*/
public static VRE get(String vreName) throws ExecutionException{
try {
return vreNameToVRE.get(vreName);
}catch (Exception e) {
LOG.info("Error on getting VRE obj for vreName {}. Is the key {} not found in the cache?", vreName, vreName);
throw e;
}
}
/**
* Load VRE obj for VRE name.
*
* @param vreName the vre name
* @return the vre
*/
protected static VRE loadVREObjForVREName(String vreName){
VRE theVRE = vreNameToVRE.getIfPresent(vreName);
//THIS CHECK SHOULD NOT BE NEEDED
if(theVRE==null){
populateTheCache();
theVRE = vreNameToVRE.getIfPresent(vreName);
}
return theVRE;
}
/**
* Gets the cache.
*
* @return the cache
*/
public LoadingCache<String, VRE> getCache(){
return vreNameToVRE;
}
}

View File

@ -54,7 +54,7 @@ public class LoadingMapOfScopeCache {
@Override @Override
public void onRemoval(RemovalNotification<String, ScopeBean> arg0) { public void onRemoval(RemovalNotification<String, ScopeBean> arg0) {
logger.info("cache expired"); logger.debug("cache expired");
//prePopulateCache(); //prePopulateCache();
} }
@ -86,13 +86,6 @@ public class LoadingMapOfScopeCache {
} }
logger.info("Cache populated with: "+scopeNamesToFullScopes.asMap().toString()); logger.info("Cache populated with: "+scopeNamesToFullScopes.asMap().toString());
//logger.info("Pre-Loaded CatalogueApplicationProfiles cache is: "+catalogueApplicationProfiles.asMap().toString());
// if(UriResolverSmartGearManagerInit.getRootContextScope().compareTo("/gcube")==0){
// logger.warn("HARD-CABLING PARTHENOS_Registry scope to resolve PARTHENOS_REGISTRY Links in dev environment");
// scopeNamesToFullScopes.asMap().put("PARTHENOS_Registry", "/d4science.research-infrastructures.eu/ParthenosVO/PARTHENOS_Registry");
// }
}catch(Exception e){ }catch(Exception e){
//SILENT //SILENT
@ -123,9 +116,9 @@ public class LoadingMapOfScopeCache {
*/ */
protected static ScopeBean loadFullScopeforScopeName(String scopeName){ protected static ScopeBean loadFullScopeforScopeName(String scopeName){
//THIS CHECK SHOULD BE NOT NEEDED
ScopeBean fullScope = scopeNamesToFullScopes.getIfPresent(scopeName); ScopeBean fullScope = scopeNamesToFullScopes.getIfPresent(scopeName);
//THIS CHECK SHOULD NOT BE NEEDED
if(fullScope==null){ if(fullScope==null){
populateTheCache(); populateTheCache();
fullScope = scopeNamesToFullScopes.getIfPresent(scopeName); fullScope = scopeNamesToFullScopes.getIfPresent(scopeName);

View File

@ -8,6 +8,7 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.util.Properties; import java.util.Properties;
import java.util.Set;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
import javax.servlet.ServletException; import javax.servlet.ServletException;
@ -17,10 +18,13 @@ import org.gcube.common.scope.impl.ScopeBean;
import org.gcube.common.scope.impl.ScopeBean.Type; import org.gcube.common.scope.impl.ScopeBean.Type;
import org.gcube.datatransfer.resolver.caches.LoadingGeonetworkInstanceCache; import org.gcube.datatransfer.resolver.caches.LoadingGeonetworkInstanceCache;
import org.gcube.datatransfer.resolver.caches.LoadingGisViewerApplicationURLCache; import org.gcube.datatransfer.resolver.caches.LoadingGisViewerApplicationURLCache;
import org.gcube.datatransfer.resolver.caches.LoadingMapOfDetachedVRE;
import org.gcube.datatransfer.resolver.caches.LoadingMapOfScopeCache; import org.gcube.datatransfer.resolver.caches.LoadingMapOfScopeCache;
import org.gcube.datatransfer.resolver.gis.property.ApplicationProfilePropertyReader; import org.gcube.datatransfer.resolver.gis.property.ApplicationProfilePropertyReader;
import org.gcube.datatransfer.resolver.gis.property.PropertyFileNotFoundException; import org.gcube.datatransfer.resolver.gis.property.PropertyFileNotFoundException;
import org.gcube.smartgears.ApplicationManager; import org.gcube.smartgears.ApplicationManager;
import org.gcube.smartgears.ContextProvider;
import org.gcube.smartgears.context.application.ApplicationContext;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -89,11 +93,12 @@ public class UriResolverSmartGearManagerInit implements ApplicationManager {
//JUST ONCE AND TO BE SURE WITH THE ROOT SCOPE INITIALIZED //JUST ONCE AND TO BE SURE WITH THE ROOT SCOPE INITIALIZED
if(initRootContextPerformed && gisViewerProfile!=null && geoExplorerProfile!=null){ if(initRootContextPerformed && gisViewerProfile!=null && geoExplorerProfile!=null){
log.info("Pre-Loading caches... using rootContextScope: "+rootContextScope); log.info("Pre-Loading caches... using rootContextScope: "+rootContextScope);
//init the caches //init the caches
new LoadingGeonetworkInstanceCache(); new LoadingGeonetworkInstanceCache();
new LoadingGisViewerApplicationURLCache(); new LoadingGisViewerApplicationURLCache();
new LoadingMapOfScopeCache(); new LoadingMapOfScopeCache();
new LoadingMapOfDetachedVRE();
} }
} }
catch (Exception e) { catch (Exception e) {
@ -229,4 +234,30 @@ public class UriResolverSmartGearManagerInit implements ApplicationManager {
public static void setRootContextScope(String rootContextScope) { public static void setRootContextScope(String rootContextScope) {
UriResolverSmartGearManagerInit.rootContextScope = rootContextScope; UriResolverSmartGearManagerInit.rootContextScope = rootContextScope;
} }
/**
* Gets the root token from SG configurations.
*
* @return the root token from SG configurations
*/
public static String getRootTokenFromSGConfiguration() {
try {
ApplicationContext ctx = ContextProvider.get();
Set<String> tokens = ctx.configuration().startTokens();
for (String token : tokens) {
//I'm using the first token,
//it should be a token of root because of URI-Resolver works at root level
log.info("Token read from SG configuration is {}-MASKED-TOKEN",token.substring(0,10));
return token;
}
log.warn("Token not found by reading the SG configurations!!! Returning null");
return null;
} catch (Exception e) {
log.error("Error on reading the start tokens from SG configuration",e);
return null;
}
}
} }

View File

@ -1,6 +1,9 @@
package org.gcube.datatransfer.resolver.services; package org.gcube.datatransfer.resolver.services;
import java.net.URI;
import java.net.URL; import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@ -20,15 +23,18 @@ import org.gcube.common.scope.impl.ScopeBean;
import org.gcube.common.scope.impl.ScopeBean.Type; import org.gcube.common.scope.impl.ScopeBean.Type;
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogueRunningCluster.ACCESS_LEVEL_TO_CATALOGUE_PORTLET; import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogueRunningCluster.ACCESS_LEVEL_TO_CATALOGUE_PORTLET;
import org.gcube.datatransfer.resolver.ConstantsResolver; import org.gcube.datatransfer.resolver.ConstantsResolver;
import org.gcube.datatransfer.resolver.caches.LoadingMapOfDetachedVRE;
import org.gcube.datatransfer.resolver.caches.LoadingMapOfScopeCache; import org.gcube.datatransfer.resolver.caches.LoadingMapOfScopeCache;
import org.gcube.datatransfer.resolver.catalogue.CatalogueRequest; import org.gcube.datatransfer.resolver.catalogue.CatalogueRequest;
import org.gcube.datatransfer.resolver.catalogue.ItemCatalogueURLs; import org.gcube.datatransfer.resolver.catalogue.ItemCatalogueURLs;
import org.gcube.datatransfer.resolver.catalogue.ResourceCatalogueCodes; import org.gcube.datatransfer.resolver.catalogue.ResourceCatalogueCodes;
import org.gcube.datatransfer.resolver.catalogue.resource.CatalogueStaticConfigurations;
import org.gcube.datatransfer.resolver.catalogue.resource.CkanCatalogueConfigurationsReader; import org.gcube.datatransfer.resolver.catalogue.resource.CkanCatalogueConfigurationsReader;
import org.gcube.datatransfer.resolver.catalogue.resource.GatewayCKANCatalogueReference; import org.gcube.datatransfer.resolver.catalogue.resource.GatewayCKANCatalogueReference;
import org.gcube.datatransfer.resolver.catalogue.resource.GetAllInfrastructureScopes; import org.gcube.datatransfer.resolver.catalogue.resource.GetAllInfrastructureScopes;
import org.gcube.datatransfer.resolver.services.error.ExceptionManager; import org.gcube.datatransfer.resolver.services.error.ExceptionManager;
import org.gcube.datatransfer.resolver.util.Util; import org.gcube.datatransfer.resolver.util.Util;
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.VRE;
import org.gcube.smartgears.utils.InnerMethodName; import org.gcube.smartgears.utils.InnerMethodName;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -49,6 +55,7 @@ public class CatalogueResolver {
private static Logger logger = LoggerFactory.getLogger(CatalogueResolver.class); private static Logger logger = LoggerFactory.getLogger(CatalogueResolver.class);
private static String helpURI = "https://wiki.gcube-system.org/gcube/URI_Resolver#CATALOGUE_Resolver"; private static String helpURI = "https://wiki.gcube-system.org/gcube/URI_Resolver#CATALOGUE_Resolver";
private static enum SCOPE_STATUS {ACTIVE, DETACHED}
/** /**
* Resolve catalogue. * Resolve catalogue.
@ -184,11 +191,29 @@ public class CatalogueResolver {
try { try {
String entityContextValue = ResourceCatalogueCodes.valueOfCodeId(entityContext).getValue(); String entityContextValue = ResourceCatalogueCodes.valueOfCodeId(entityContext).getValue();
ScopeBean scopeBean = null; ScopeBean scopeBean = null;
SCOPE_STATUS scopeStatus = SCOPE_STATUS.ACTIVE;
VRE vreDetached = null;
try{ try{
scopeBean = LoadingMapOfScopeCache.get(scopeName); scopeBean = LoadingMapOfScopeCache.get(scopeName);
}catch(ExecutionException | InvalidCacheLoadException e){ }catch(ExecutionException | InvalidCacheLoadException e){
logger.error("Error on getting the fullscope from cache for scopeName "+scopeName, e); logger.error("Error on getting the fullscope from cache for scopeName {}. Tryng to load it from DetachedRE",scopeName);
throw ExceptionManager.wrongParameterException(req, "Error on getting full scope for the scope name '"+scopeName+"'. Is it registered as a valid Scope in the D4Science Infrastructure System?", CatalogueResolver.class, helpURI);
boolean isScopeDetached = false;
try {
vreDetached = LoadingMapOfDetachedVRE.get(scopeName);
scopeBean = new ScopeBean(vreDetached.getScope());
scopeStatus = SCOPE_STATUS.DETACHED;
logger.info("I loaded a valid VRE obj for scope name {}", scopeName);
isScopeDetached = true;
}catch (Exception e1) {
logger.warn("I was not able to load a detached VRE for vreName {}. Going to error for wrong scope",scopeName);
}
//If is not a cas of scope detached, going to error for wrong scope
if(!isScopeDetached) {
logger.error("Error on getting the fullscope from cache for scopeName "+scopeName, e);
throw ExceptionManager.wrongParameterException(req, "Error on getting full scope for the scope name '"+scopeName+"'. Is it registered as a valid Scope in the D4Science Infrastructure System?", CatalogueResolver.class, helpURI);
}
} }
String fullScope = scopeBean.toString(); String fullScope = scopeBean.toString();
@ -203,8 +228,37 @@ public class CatalogueResolver {
} }
ScopeProvider.instance.set(fullScope); ScopeProvider.instance.set(fullScope);
GatewayCKANCatalogueReference ckanCatalogueReference = CkanCatalogueConfigurationsReader.loadCatalogueEndPoints(); GatewayCKANCatalogueReference ckanCatalogueReference = null;
logger.info("Managing scope status: {}",scopeStatus);
switch (scopeStatus) {
case DETACHED:
String privatePortletURL = vreDetached.getCatalogPortletURL();
//The private portlet URL
Map<ACCESS_LEVEL_TO_CATALOGUE_PORTLET, String> mapAccessURLToCatalogue = new HashMap<ACCESS_LEVEL_TO_CATALOGUE_PORTLET, String>(3);
mapAccessURLToCatalogue.put(ACCESS_LEVEL_TO_CATALOGUE_PORTLET.PRIVATE_VRE,privatePortletURL);
//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"
CatalogueStaticConfigurations staticConf = new CatalogueStaticConfigurations();
//Replacing for example "ckan-bb" with "[PREFIXES-TO-CATALOGUE-URL]-bb" (e.g catalogue-bb)
String relativeURLWithCatalogueName = staticConf.buildRelativeURLToPublicCatalogueGateway(vreDetached.getCatalogUrl());
String toGatewayPortletURL = String.format("%s/%s", publicURL, relativeURLWithCatalogueName);
mapAccessURLToCatalogue.put(ACCESS_LEVEL_TO_CATALOGUE_PORTLET.PUBLIC_GATEWAY,toGatewayPortletURL);
ckanCatalogueReference = new GatewayCKANCatalogueReference(fullScope, vreDetached.getCatalogUrl(), mapAccessURLToCatalogue);
break;
case ACTIVE:
default:
ckanCatalogueReference = CkanCatalogueConfigurationsReader.loadCatalogueEndPoints();
break;
}
logger.info("For scope "+fullScope+" loaded end points: "+ckanCatalogueReference); logger.info("For scope "+fullScope+" loaded end points: "+ckanCatalogueReference);
//IS THE PRODUCT PLUBLIC OR PRIVATE? //IS THE PRODUCT PLUBLIC OR PRIVATE?

View File

@ -1,5 +1,4 @@
import org.gcube.datatransfer.resolver.catalogue.resource.CatalogueStaticConfigurations; import org.gcube.datatransfer.resolver.catalogue.resource.CatalogueStaticConfigurations;
import org.junit.Test;
public class CatalogueNameExtractor { public class CatalogueNameExtractor {

View File

@ -1,6 +1,8 @@
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.datatransfer.resolver.catalogue.resource.CkanCatalogueConfigurationsReader; import org.gcube.datatransfer.resolver.catalogue.resource.CkanCatalogueConfigurationsReader;
import org.gcube.datatransfer.resolver.catalogue.resource.GatewayCKANCatalogueReference; import org.gcube.datatransfer.resolver.catalogue.resource.GatewayCKANCatalogueReference;
import org.gcube.datatransfer.resolver.init.UriResolverSmartGearManagerInit;
import org.gcube.datatransfer.resolver.services.CatalogueResolver;
/** /**
@ -12,18 +14,33 @@ import org.gcube.datatransfer.resolver.catalogue.resource.GatewayCKANCatalogueRe
*/ */
public class CatalogueResolverTest { public class CatalogueResolverTest {
private static String entityName = "using_e-infrastructures_for_biodiversity_conservation";
private static String entityContext = "ctlg";
private static String vreName = "BlueBridgeProject";
private String rootContextScope = "/gcube";
private String authorizationToken = "";
//@Before
public void init() {
/** UriResolverSmartGearManagerInit.setRootContextScope(rootContextScope);
* The main method. }
*
* @param args
* the arguments //@Test
*/ public void testCatalogueResolver() {
public static void main(String[] args) { SecurityTokenProvider.instance.set(authorizationToken);
CatalogueResolver catalogRes = new CatalogueResolver();
catalogRes.resolveCatalogue(null, entityName, vreName, entityContext);
}
//@Test
public void testCatalogueLoadEndPoints() {
try { try {
ScopeProvider.instance.set("/d4science.research-infrastructures.eu/gCubeApps/BiodiversityLab");
//ScopeProvider.instance.set("/d4science.research-infrastructures.eu"); //ScopeProvider.instance.set("/d4science.research-infrastructures.eu");
GatewayCKANCatalogueReference ckanCatalogueReference = CkanCatalogueConfigurationsReader.loadCatalogueEndPoints(); GatewayCKANCatalogueReference ckanCatalogueReference = CkanCatalogueConfigurationsReader.loadCatalogueEndPoints();
System.out.println(ckanCatalogueReference.toString()); System.out.println(ckanCatalogueReference.toString());

View File

@ -0,0 +1,46 @@
import java.util.concurrent.ExecutionException;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.datatransfer.resolver.caches.LoadingMapOfDetachedVRE;
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.VRE;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class DetachedVREsTest {
public static Logger LOG = LoggerFactory.getLogger(DetachedVREsTest.class);
public static String TOKEN = "";
public static String detachedVREName = "BlueBridgeProject";
public static String rootScope = "/gcube";
//@Before
public void initCache() {
}
/**
* Storage hub test.
*
* @throws Exception the exception
*/
//@Test
public void testCacheOfDetachedVREs() throws Exception{
try {
ScopeProvider.instance.set(rootScope);
SecurityTokenProvider.instance.set(TOKEN);
//LoadingMapOfDetachedVRE cache = new LoadingMapOfDetachedVRE();
VRE theDetachedVRE = LoadingMapOfDetachedVRE.get(detachedVREName);
LOG.info("Detached VRE found {}", theDetachedVRE);
}catch (ExecutionException e) {
LOG.info("The Detached VRE for name {} not found",detachedVREName);
}catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -3,7 +3,6 @@ import static org.gcube.resources.discovery.icclient.ICFactory.client;
import java.io.StringReader; import java.io.StringReader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.ExecutionException;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
@ -18,6 +17,7 @@ import org.gcube.datatransfer.resolver.init.UriResolverSmartGearManagerInit;
import org.gcube.resources.discovery.client.api.DiscoveryClient; import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.Query; import org.gcube.resources.discovery.client.queries.api.Query;
import org.gcube.resources.discovery.client.queries.impl.QueryBox; import org.gcube.resources.discovery.client.queries.impl.QueryBox;
import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.w3c.dom.Document; import org.w3c.dom.Document;
@ -38,12 +38,12 @@ public class GetAllInfrastructureScopesFromIS {
protected static final String RESOURCE_PROFILE_NAME_TEXT = "/Resource/Profile/Name/text()"; protected static final String RESOURCE_PROFILE_NAME_TEXT = "/Resource/Profile/Name/text()";
/** /**
* The main method. * Test loading map of scope.
*
* @param args the arguments
*/ */
public static void main(String[] args) { @Test
public void testLoadingMapOfScope() {
try { try {
@ -53,16 +53,16 @@ public class GetAllInfrastructureScopesFromIS {
UriResolverSmartGearManagerInit.setRootContextScope(rootScope); UriResolverSmartGearManagerInit.setRootContextScope(rootScope);
LoadingMapOfScopeCache cache = new LoadingMapOfScopeCache(); LoadingMapOfScopeCache cache = new LoadingMapOfScopeCache();
int i = 0; // int i = 0;
for (String string : cache.getCache().asMap().keySet()) { // for (String string : cache.getCache().asMap().keySet()) {
try { // try {
System.out.println(++i+") Scope Name: "+string + " to full scope: "+LoadingMapOfScopeCache.get(string)); // System.out.println(++i+") Scope Name: "+string + " to full scope: "+LoadingMapOfScopeCache.get(string));
} catch (ExecutionException e) { // } catch (ExecutionException e) {
e.printStackTrace(); // e.printStackTrace();
} // }
} // }
String scopeName = "devsec"; String scopeName = "abc";
ScopeBean scopeBean = LoadingMapOfScopeCache.get(scopeName); ScopeBean scopeBean = LoadingMapOfScopeCache.get(scopeName);
String fullScope = scopeBean.toString(); String fullScope = scopeBean.toString();
logger.info("Read fullScope: "+fullScope + " for SCOPE name: "+scopeName +" from cache created by: "+GetAllInfrastructureScopes.class.getSimpleName()); logger.info("Read fullScope: "+fullScope + " for SCOPE name: "+scopeName +" from cache created by: "+GetAllInfrastructureScopes.class.getSimpleName());

View File

@ -1,6 +1,5 @@
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.datatransfer.resolver.gis.entity.GisLayerItem; import org.gcube.datatransfer.resolver.gis.entity.GisLayerItem;
import org.gcube.datatransfer.resolver.gis.entity.ServerParameters;
import org.gcube.datatransfer.resolver.services.GisResolver; import org.gcube.datatransfer.resolver.services.GisResolver;
/** /**