From 6483327fdeec9870a63936c943cb896315ade27f Mon Sep 17 00:00:00 2001 From: Francesco Mangiacrapa Date: Tue, 19 May 2015 16:34:31 +0000 Subject: [PATCH] 94: Uri-Resolver: must resolve (eventually) several access points for entryname Task-Url: https://support.d4science.org/issues/94 update UriResolverManager git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/uri-resolver-manager@114803 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../UriResolverManager.java | 58 +++++++++++-------- src/test/java/UriResolverManagerTest.java | 22 ++++++- 2 files changed, 55 insertions(+), 25 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/uriresolvermanager/UriResolverManager.java b/src/main/java/org/gcube/portlets/user/uriresolvermanager/UriResolverManager.java index c87e2b3..2325a2d 100644 --- a/src/main/java/org/gcube/portlets/user/uriresolvermanager/UriResolverManager.java +++ b/src/main/java/org/gcube/portlets/user/uriresolvermanager/UriResolverManager.java @@ -31,17 +31,16 @@ import org.slf4j.LoggerFactory; * May 4, 2015 */ public class UriResolverManager { - + + /** + * Time to reload Runtime Resource Configuration + */ + public static int RESET_DELAY = 15*60*1000; //15 MINUTES /** * Time to reload Runtime Resource Configuration */ - public static int RESET_DELAY = 10*60*1000; //10 MINUTES - - /** - * Time to reload Runtime Resource Configuration - */ - public static int RESET_TIME = RESET_DELAY; //10 MINUTES + public static int RESET_TIME = RESET_DELAY; //15 MINUTES private UriResolverMapReader uriResolverMapReader; private Map applicationTypes; @@ -103,11 +102,27 @@ public class UriResolverManager { this.uriResolverMapReader = new UriResolverMapReader(this.scope); this.applicationTypes = uriResolverMapReader.getApplicationTypes(); this.setTimerUriResolverReader(RESET_DELAY, RESET_TIME); + } catch (UriResolverMapException e){ + logger.error("UriResolverMapException: ",e); + throw e; } catch (Exception e) { + logger.error("UriResolverManager: ",e); throw new UriResolverMapException("Map Application Type - Resources not found in IS"); } } + /** + * @param applicationType the applicationType to set + * @throws IllegalArgumentException + */ + public void setApplicationType(String applicationType) throws IllegalArgumentException { + if(!this.applicationTypes.containsKey(applicationType)){ + throw new IllegalArgumentException("Application type '"+applicationType +"' not found in Application Types: "+getApplicationTypes()); + + } + this.applicationType = applicationType; + } + /** * Instance a UriResolverManager * Precondition: set the scope provider {@link ScopeProvider.instance.get()} @@ -119,11 +134,7 @@ public class UriResolverManager { */ public UriResolverManager(String applicationType) throws UriResolverMapException, IllegalArgumentException{ this(); - - if(!this.applicationTypes.containsKey(applicationType)){ - throw new IllegalArgumentException("Application type '"+applicationType +"' not found in Application Types: "+getApplicationTypes()); - } - this.applicationType = applicationType; + setApplicationType(applicationType); } @@ -331,15 +342,16 @@ public class UriResolverManager { public void invalidUriResolverReader(){ reader = null; } - -// public static void main(String[] args) { -// try { -// String scope ="/gcube"; -// UriResolverMapReader resolver = new UriResolverMapReader(scope); -// System.out.println(resolver); -// } catch (Exception e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } + + /* + public static void main(String[] args) { + try { + UriResolverManager manager = new UriResolverManager(); + System.out.println(manager.getCapabilities()); + System.out.println(manager.getApplicationTypes()); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }*/ } diff --git a/src/test/java/UriResolverManagerTest.java b/src/test/java/UriResolverManagerTest.java index 3395f00..c338ec6 100644 --- a/src/test/java/UriResolverManagerTest.java +++ b/src/test/java/UriResolverManagerTest.java @@ -18,7 +18,25 @@ import org.junit.Test; */ public class UriResolverManagerTest { -// @Test + @Test + public void testUriResolverManger(){ + UriResolverManager manager; + try { + ScopeProvider.instance.set("/gcube/devsec/devVRE"); + manager = new UriResolverManager(); + System.out.println(manager.getCapabilities()); + System.out.println(manager.getApplicationTypes()); + } catch (UriResolverMapException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalArgumentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + @Test public void testGIS() { try { @@ -63,7 +81,7 @@ public class UriResolverManagerTest { /** * Thread safe */ -// @Test + @Test public void testSMPID(){ try {