87 lines
2.2 KiB
Java
87 lines
2.2 KiB
Java
/**
|
|
*
|
|
*/
|
|
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.util.UriResolverMapReader;
|
|
|
|
/**
|
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
|
* @Oct 14, 2014
|
|
*
|
|
*/
|
|
public class UriResolverManager {
|
|
|
|
|
|
private UriResolverMapReader uriResolverMapReader;
|
|
private Map<String, String> applicationTypes;
|
|
private String userScope;
|
|
private String userApplicationType;
|
|
|
|
/**
|
|
*
|
|
* @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.userApplicationType = applicationType;
|
|
this.userScope = scope;
|
|
|
|
}
|
|
|
|
public String getLink(Map<String, String> parameters) throws IllegalArgumentException{
|
|
|
|
// if(applicationTypeReader.)
|
|
return "";
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @return the Application Types availables
|
|
*/
|
|
public Set<String> getApplicationTypes(){
|
|
return this.applicationTypes.keySet();
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @return a map Application Type - Resource Name
|
|
*/
|
|
public Map<String, String> getCapabilities(){
|
|
return this.applicationTypes;
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
|
|
try {
|
|
UriResolverManager resolver = new UriResolverManager("/gcube", "NA");
|
|
} catch (UriResolverMapException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
} catch (IllegalArgumentException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
}
|