improved handling of indexed data
[ccsdk/sli/adaptors.git] / aai-service / provider / src / main / java / org / onap / ccsdk / sli / adaptors / aai / AAIRequest.java
index 36615d9..04312fd 100755 (executable)
@@ -5,6 +5,8 @@
  * 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;
@@ -32,6 +37,7 @@ import java.net.URISyntaxException;
 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;
@@ -45,7 +51,7 @@ import java.util.Set;
 import java.util.TreeSet;
 
 import org.apache.commons.lang.StringUtils;
-import org.openecomp.aai.inventory.v13.GenericVnf;
+import org.onap.aai.inventory.v14.GenericVnf;
 import org.onap.ccsdk.sli.adaptors.aai.data.AAIDatum;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -173,7 +179,7 @@ public abstract class AAIRequest {
             }
 
             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);
@@ -265,7 +271,7 @@ public abstract class AAIRequest {
                     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);
                 }
             }
         }
@@ -291,7 +297,7 @@ public abstract class AAIRequest {
             // 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";
@@ -430,8 +436,7 @@ public abstract class AAIRequest {
         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 {
@@ -468,4 +473,8 @@ public abstract class AAIRequest {
     public String getTargetUri() {
         return targetUri;
     }
+    public static final String getSupportedAAIVersion() {
+        return configProperties.getProperty(AAIDeclarations.AAI_VERSION, "/v14/");
+    }
 }