diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 21f61b8..cfa6374 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -4,9 +4,6 @@ - - uses - 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 a970d93..a5ab4a0 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/CatalogueResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/CatalogueResolver.java @@ -188,7 +188,7 @@ public class CatalogueResolver { if(scopeBean.is(Type.VO)) { logger.info("It is a {} scope", Type.VO); logger.warn("The Catalogue can't work at {} level, I'm overriding the scope to {} level", Type.VO, Type.INFRASTRUCTURE); - fullScope = fullScope.substring(0, fullScope.indexOf("/")); + fullScope = fullScope.substring(1, fullScope.indexOf("/")); //skypping the first slash logger.info("Overriden the input scope {} with {} type: {}", fullScope, Type.INFRASTRUCTURE, fullScope); } diff --git a/src/test/java/GetAllInfrastructureScopesFromIS.java b/src/test/java/GetAllInfrastructureScopesFromIS.java index 5e83ab8..b8010a3 100644 --- a/src/test/java/GetAllInfrastructureScopesFromIS.java +++ b/src/test/java/GetAllInfrastructureScopesFromIS.java @@ -28,15 +28,11 @@ import org.xml.sax.InputSource; /** - * The Class GetAllInfrastructureVREs. + * The Class GetAllInfrastructureScopesFromIS. * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * Nov 8, 2018 - */ -/** - * - * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it - * Nov 8, 2018 + * + * May 16, 2019 */ public class GetAllInfrastructureScopesFromIS { @@ -52,76 +48,77 @@ public class GetAllInfrastructureScopesFromIS { public static void main(String[] args) { try { - - -// //TODO TOKEN TO ROOT SCOPE -// String rootScope = "/gcube"; -// //String rootScope = "/d4science.research-infrastructures.eu"; -// ScopeProvider.instance.set(rootScope); -// -// String secondaryType = "INFRASTRUCTURE"; -// List listVOScopes = getListOfVOScopes("INFRASTRUCTURE"); -// -// System.out.println("Searching for secondaryType="+secondaryType +" scope/s found is/are: " +listVOScopes); -// -// Map vreNameFullScope = new HashMap(); -// -// secondaryType = "VRE"; -// int noVOTypeCount = 0; -// for (String voScope : listVOScopes) { -// int count = voScope.length() - voScope.replace("/", "").length(); -// //IS A VO -// if(count==2){ -// logger.info(voScope +" is a VO..."); -// ScopeProvider.instance.set(voScope); -// List listVREs = getListOfResourcesForSecondaryType(secondaryType); -// System.out.println("VREs found for VO "+voScope+ " is/are "+listVREs.size()+ ": "+listVREs); -// for (String vreName : listVREs) { -// String vreScope = String.format("%s/%s", voScope,vreName); -// vreNameFullScope.put(vreName, vreScope); -// } -// -// }else{ -// noVOTypeCount++; -// System.out.println(voScope +" is not a VO, skipping it"); -// } -// } -// -// -// System.out.println("Total VO is: "+(listVOScopes.size()+noVOTypeCount)); -// for (String vreName : vreNameFullScope.keySet()) { -// System.out.println("VRE Name: "+vreName + " has scope: "+vreNameFullScope.get(vreName)); -// } -// -// System.out.println("Total VRE is: "+vreNameFullScope.size()); - - - String rootScope = "/gcube"; - //String rootScope = "/d4science.research-infrastructures.eu"; - ScopeProvider.instance.set(rootScope); - UriResolverSmartGearManagerInit.setRootContextScope(rootScope); - LoadingMapOfScopeCache cache = new LoadingMapOfScopeCache(); - - int i = 0; - for (String string : cache.getCache().asMap().keySet()) { - try { - System.out.println(++i+") Scope Name: "+string + " to full scope: "+LoadingMapOfScopeCache.get(string)); - } catch (ExecutionException e) { - e.printStackTrace(); + + String rootScope = "/gcube"; + //String rootScope = "/d4science.research-infrastructures.eu"; + ScopeProvider.instance.set(rootScope); + UriResolverSmartGearManagerInit.setRootContextScope(rootScope); + LoadingMapOfScopeCache cache = new LoadingMapOfScopeCache(); + + int i = 0; + for (String string : cache.getCache().asMap().keySet()) { + try { + System.out.println(++i+") Scope Name: "+string + " to full scope: "+LoadingMapOfScopeCache.get(string)); + } catch (ExecutionException e) { + e.printStackTrace(); + } } - } - - String scopeName = "devsec"; - ScopeBean scopeBean = LoadingMapOfScopeCache.get(scopeName); - String fullScope = scopeBean.toString(); - logger.info("Read fullScope: "+fullScope + " for SCOPE name: "+scopeName +" from cache created by: "+GetAllInfrastructureScopes.class.getSimpleName()); - - if(scopeBean.is(Type.VO)) { - logger.info("It is a {} scope", Type.VO); - logger.warn("The Catalogue can't work at {} level, I'm overriding the scope to {} level", Type.VO, Type.INFRASTRUCTURE); - fullScope = fullScope.substring(0, fullScope.indexOf("/")); - logger.info("Overriden the input scope {} with {} type: {}", fullScope, Type.INFRASTRUCTURE, fullScope); - } + + String scopeName = "devsec"; + ScopeBean scopeBean = LoadingMapOfScopeCache.get(scopeName); + String fullScope = scopeBean.toString(); + logger.info("Read fullScope: "+fullScope + " for SCOPE name: "+scopeName +" from cache created by: "+GetAllInfrastructureScopes.class.getSimpleName()); + + if(scopeBean.is(Type.VO)) { + logger.info("It is a {} scope", Type.VO); + logger.warn("The Catalogue can't work at {} level, I'm overriding the scope to {} level", Type.VO, Type.INFRASTRUCTURE); + fullScope = fullScope.substring(0, fullScope.indexOf("/")); + logger.info("Overriden the input scope {} with {} type: {}", fullScope, Type.INFRASTRUCTURE, fullScope); + } + + +// //TODO TOKEN TO ROOT SCOPE +// String rootScope = "/gcube"; +// //String rootScope = "/d4science.research-infrastructures.eu"; +// ScopeProvider.instance.set(rootScope); + // +// String secondaryType = "INFRASTRUCTURE"; +// List listVOScopes = getListOfVOScopes("INFRASTRUCTURE"); + // +// System.out.println("Searching for secondaryType="+secondaryType +" scope/s found is/are: " +listVOScopes); + // +// Map vreNameFullScope = new HashMap(); + // +// secondaryType = "VRE"; +// int noVOTypeCount = 0; +// for (String voScope : listVOScopes) { +// int count = voScope.length() - voScope.replace("/", "").length(); +// //IS A VO +// if(count==2){ +// logger.info(voScope +" is a VO..."); +// ScopeProvider.instance.set(voScope); +// List listVREs = getListOfResourcesForSecondaryType(secondaryType); +// System.out.println("VREs found for VO "+voScope+ " is/are "+listVREs.size()+ ": "+listVREs); +// for (String vreName : listVREs) { +// String vreScope = String.format("%s/%s", voScope,vreName); +// vreNameFullScope.put(vreName, vreScope); +// } + // +// }else{ +// noVOTypeCount++; +// System.out.println(voScope +" is not a VO, skipping it"); +// } +// } + // + // +// System.out.println("Total VO is: "+(listVOScopes.size()+noVOTypeCount)); +// for (String vreName : vreNameFullScope.keySet()) { +// System.out.println("VRE Name: "+vreName + " has scope: "+vreNameFullScope.get(vreName)); +// } + // +// System.out.println("Total VRE is: "+vreNameFullScope.size()); + + }catch (Exception e) { e.printStackTrace();