import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
+import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLDecoder;
import java.net.URLEncoder;
public static final String DEPTH = "depth";
protected static Properties configProperties;
- protected final String target_uri;
+ protected final String targetUri;
protected static AAIService aaiService;
protected AAIDatum requestDatum;
public static AAIRequest createRequest(String resoourceName, Map<String, String> nameValues){
String resoource = resoourceName;
+ String masterResource = null;
if(resoource == null)
return null;
if(resoource.contains(":")) {
String[] tokens = resoource.split(":");
- if(tokens != null && tokens.length > 0) {
- resoource = tokens[0];
+ if(tokens != null && tokens.length == 2) {
+ resoource = tokens[1];
+ masterResource = tokens[0];
+ //
+ Class<? extends AAIDatum> clazz = null;
+ try {
+ clazz = getClassFromResource(resoource) ;
+ } catch (ClassNotFoundException e) {
+ LOG.warn("AAIRequest does not support class: " + e.getMessage());
+ return null;
+ }
+
+ if(clazz == null) {
+ return null;
+ }
}
}
case "custom-query":
case "formatted-query":
return new CustomQueryRequest();
- case "linterface":
- return new LInterfaceRequest(LInterfaceRequest.TYPE.L2_BRIDGE_SBG);
- case "l2-bridge-sbg":
- return new SubInterfaceRequest(SubInterfaceRequest.TYPE.L2_BRIDGE_SBG);
- case "l2-bridge-bgf":
- return new SubInterfaceRequest(SubInterfaceRequest.TYPE.L2_BRIDGE_BGF);
case "echo":
case "test":
return new EchoRequest();
- default:
+ case "linterface":
+ case "l2-bridge-sbg":
+ case "l2-bridge-bgf":
{
- AAIRequest request = getRequestFromResource(resoource);
- if(request == null) {
- return null;
- }
- return request;
+ resoource = "l-interface";
+ return getRequestFromResource("l-interface");
}
+ case "relationship-list":
+ return new RelationshipListRequest(AAIRequest.createRequest(masterResource, nameValues));
+ case "relationship":
+ return new RelationshipRequest(AAIRequest.createRequest(masterResource, nameValues));
+ default:
+ return getRequestFromResource(resoource);
}
}
try
{
URL url = null;
- Bundle bundle = FrameworkUtil.getBundle(AAIServiceActivator.class);
+ Bundle bundle = FrameworkUtil.getBundle(AAIService.class);
if(bundle != null) {
BundleContext ctx = bundle.getBundleContext();
if(ctx == null)
}
public AAIRequest() {
- target_uri = configProperties.getProperty(TARGET_URI);
+ targetUri = configProperties.getProperty(TARGET_URI);
}
public void addRequestProperty(String key, String value) {
aaiService.getLogger().warn("Could not deserialize object of type " + lInterfaceRequest.getClass().getSimpleName(), exc) ;
}
- public URL getRequestUrl(String method, String resourceVersion) throws UnsupportedEncodingException, MalformedURLException {
+ public URL getRequestUrl(String method, String resourceVersion) throws UnsupportedEncodingException, MalformedURLException, URISyntaxException {
String request_url = null;
- request_url = target_uri + updatePathDataValues(resourceVersion);
+ request_url = targetUri + updatePathDataValues(resourceVersion);
URL http_req_url = new URL(request_url);
}
protected String getRequestPath(String resource) throws MalformedURLException {
+ if(requestProperties.containsKey("resource-path")) {
+ return requestProperties.getProperty("resource-path");
+ }
+
Set<String> uniqueResources = extractUniqueResourceSetFromKeys(requestProperties.stringPropertyNames());
if(resource != null) {
// for group search add itself, but remove singular version of itself
return path;
}
- public abstract URL getRequestQueryUrl(String method) throws UnsupportedEncodingException, MalformedURLException;
+ public abstract URL getRequestQueryUrl(String method) throws UnsupportedEncodingException, MalformedURLException, URISyntaxException;
public abstract String toJSONString();
public String getTargetUri() {
- return target_uri;
+ return targetUri;
}
}