/** * */ package org.gcube.portlets.user.uriresolvermanager; import java.util.Map; import java.util.Set; import org.gcube.portlets.user.uriresolvermanager.exception.IllegalArgumentException; import org.gcube.portlets.user.uriresolvermanager.exception.UriResolverMapException; import org.gcube.portlets.user.uriresolvermanager.readers.RuntimeResourceReader; import org.gcube.portlets.user.uriresolvermanager.readers.UriResolverMapReader; /** * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @Oct 14, 2014 * */ public class UriResolverManager { private UriResolverMapReader uriResolverMapReader; private Map applicationTypes; private String scope; private String applicationType; /** * * @param scope * @param applicationType a key Application Type * @throws Exception */ public UriResolverManager(String scope, String applicationType) throws UriResolverMapException, IllegalArgumentException{ try { this.uriResolverMapReader = new UriResolverMapReader(scope); this.applicationTypes = uriResolverMapReader.getApplicationTypes(); } catch (Exception e) { throw new UriResolverMapException("Map Application Type - Resources not found in IS"); } if(!this.applicationTypes.containsKey(applicationType)){ throw new IllegalArgumentException("Application type '"+applicationType +"' not found in Application Types: "+getApplicationTypes()); } this.applicationType = applicationType; this.scope = scope; } public String getLink(Map parameters) throws IllegalArgumentException{ String resourceName = this.applicationTypes.get(applicationType); try { RuntimeResourceReader reader = new RuntimeResourceReader(scope, resourceName); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return ""; } /** * * @return the Application Types availables */ public Set getApplicationTypes(){ return this.applicationTypes.keySet(); } /** * * @return a map Application Type - Resource Name */ public Map getCapabilities(){ return this.applicationTypes; } public static void main(String[] args) { try { UriResolverManager resolver = new UriResolverManager("/gcube", "GIS"); resolver.getLink(null); } catch (UriResolverMapException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }