* Copyright (C) 2017 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
+ * Modifications Copyright (C) 2018 IBM.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
+/**
+ * @author Rich Tabedzki
+ *
+ */
package org.onap.ccsdk.sli.adaptors.aai;
import java.io.IOException;
import java.net.URL;
import java.net.URLDecoder;
import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.TreeSet;
import org.apache.commons.lang.StringUtils;
-import org.openecomp.aai.inventory.v11.GenericVnf;
+import org.onap.aai.inventory.v21.GenericVnf;
import org.onap.ccsdk.sli.adaptors.aai.data.AAIDatum;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
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;
- }
+ Class<? extends AAIDatum> clazz = getClassFromResource(resoource) ;
if(clazz == null) {
return null;
}
if(nameValues.containsKey("selflink")){
- Class<? extends AAIDatum> clazz = null;
- try {
- clazz = getClassFromResource(resoource) ;
- } catch (ClassNotFoundException e) {
- LOG.warn("AAIRequest does not support class: " + e.getMessage());
- return null;
- }
+ Class<? extends AAIDatum> clazz = getClassFromResource(resoource) ;
if(clazz != null)
return new SelfLinkRequest(clazz);
switch(resoource){
case "generic-query":
return new GenericQueryRequest();
- case "named-query":
- return new NamedQueryRequest();
case "nodes-query":
return new NodesQueryRequest();
case "custom-query":
}
InputStream in = url.openStream();
- Reader reader = new InputStreamReader(in, "UTF-8");
+ Reader reader = new InputStreamReader(in, StandardCharsets.UTF_8);
Properties properties = new Properties();
properties.load(reader);
bs.set(bitIndex);
}
String path = properties.getProperty(key);
- LOG.info(String.format("bitset %s\t\t%s", bs.toString(), path));
+ LOG.trace(String.format("bitset %s\t\t%s", bs.toString(), path));
bitsetPaths.put(bs, path);
}
LOG.info("loaded " + resourceNames.toString());
function = clazz.getMethod("processPathData", request_url.getClass(), requestProperties.getClass());
request_url = (String) function.invoke(null, request_url, requestProperties);
} catch (Exception e) {
- e.printStackTrace();
+ LOG.error("Caught exception", e);
}
}
}
// for group search add itself, but remove singular version of itself
if(!uniqueResources.contains(resource)) {
boolean replaced = false;
- Set<String> tmpUniqueResources = new HashSet<String>();
+ Set<String> tmpUniqueResources = new HashSet<>();
tmpUniqueResources.addAll(uniqueResources);
for(String item : tmpUniqueResources){
String plural = item +"s";
return AAIService.getObjectMapper();
}
- public static Class<? extends AAIDatum> getClassFromResource(String resoourceName) throws ClassNotFoundException {
+ public static Class<? extends AAIDatum> getClassFromResource(String resoourceName) {
String className = GenericVnf.class.getName();
String[] split = resoourceName.split("-");
for(int i = 0; i < split.length; i++) {
String caps = StringUtils.join(split);
className = className.replace("GenericVnf", caps);
- Class<? extends AAIDatum> clazz = null;
try {
- clazz = (Class<? extends AAIDatum>)Class.forName(className);
+ return (Class<? extends AAIDatum>)Class.forName(className);
} catch (ClassNotFoundException e) {
LOG.warn("AAIRequest does not support class: " + e.getMessage());
return null;
}
-
- return clazz;
}
protected static AAIRequest getRequestFromResource(String resoourceName) {
- Class<? extends AAIDatum> clazz = null;
- try {
- clazz = getClassFromResource(resoourceName);
- } catch (ClassNotFoundException e) {
- LOG.warn("AAIRequest does not support class: " + e.getMessage());
- return null;
- }
+ Class<? extends AAIDatum> clazz = getClassFromResource(resoourceName);
+
if(clazz == null) {
return null;
}
- GenericRequest request = new GenericRequest(clazz);
- return request;
+ return new GenericRequest(clazz);
}
public static Map<String, String> splitQuery(String query) throws UnsupportedEncodingException {
public String getTargetUri() {
return targetUri;
}
+
+ public static final String getSupportedAAIVersion() {
+ return configProperties.getProperty(AAIDeclarations.AAI_VERSION, "/v21/");
+ }
}