Fixed major sonar issue in AAIService.java 80/75480/3
authorezhil <ezhrajam@in.ibm.com>
Tue, 8 Jan 2019 16:47:46 +0000 (22:17 +0530)
committerEzhilarasi R <ezhrajam@in.ibm.com>
Wed, 9 Jan 2019 06:43:10 +0000 (06:43 +0000)
Change-Id: Ice32a830fa2d9885b64f7ce7a0d0fb47c268cb67
Issue-ID: CCSDK-914
Signed-off-by: ezhil <ezhrajam@in.ibm.com>
aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIService.java

index 78b0f0e..4303894 100755 (executable)
@@ -5,6 +5,8 @@
  * Copyright (C) 2017 AT&T Intellectual Property. All rights
  *             reserved.
  * ================================================================================
+ * Modifications Copyright (C) 2019 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
@@ -21,7 +23,6 @@
 
 package org.onap.ccsdk.sli.adaptors.aai;
 
-
 import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
 import java.io.File;
@@ -113,7 +114,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
     private final String targetUri;
     private final String networkVserverPath;
 
-    private final String svc_inst_qry_path;
+    private final String svc_inst_query_path;
 
     private final String ubb_notify_path;
     private final String selflinkAvpn;
@@ -147,16 +148,6 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
         this(getProperties(url));
     }
 
-    private static Properties getProperties(URL url) {
-        Properties properties = new Properties();
-        try {
-            properties.load(url.openStream());
-        } catch (IOException exc) {
-            LOG.error("getProperties", exc);
-        }
-        return properties;
-    }
-
     public AAIService(Properties props) {
         LOG.info("Entered AAIService.ctor");
 
@@ -222,7 +213,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
         networkVserverPath =props.getProperty(NETWORK_VSERVER_PATH);
 
         props.getProperty(SVC_INSTANCE_PATH);
-        svc_inst_qry_path    = props.getProperty(SVC_INST_QRY_PATH);
+        svc_inst_query_path    = props.getProperty(SVC_INST_QRY_PATH);
         props.getProperty(PARAM_SERVICE_TYPE, "service-type");
 
         props.getProperty(P_INTERFACE_PATH);
@@ -324,11 +315,21 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
             methodsField.set(null, methods);
 
         } catch (SecurityException | IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) {
-         e.printStackTrace();
+            LOG.error("Exception occured", e);
         }
 
     }
 
+    private static Properties getProperties(URL url) {
+        Properties properties = new Properties();
+        try {
+            properties.load(url.openStream());
+        } catch (IOException exc) {
+            LOG.error("getProperties", exc);
+        }
+        return properties;
+    }
+
     public void setExecutor(AAIExecutorInterface executor) {
         this.executor = executor;
     }
@@ -426,7 +427,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
         InputStream inputStream = null;
 
         try {
-            String path = svc_inst_qry_path;
+            String path = svc_inst_query_path;
             path = path.replace("{svc-instance-id}", encodeQuery(svc_instance_id));
 
             String request_url = targetUri+path;
@@ -474,6 +475,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
                 try {
                     inputStream.close();
                 } catch(Exception exc) {
+                    LOG.warn("Error closing Inputstream", exc);
                 }
             }
         }
@@ -729,7 +731,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
                 try {
                     inputStream.close();
                 } catch(Exception exc) {
-
+                    LOG.warn("Error closing InputStream", exc);
                 }
             }
         }
@@ -846,7 +848,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
                 if(inputStream != null)
                 inputStream.close();
             } catch (Exception exc) {
-
+                LOG.warn("Error closing Input stream", exc);
             }
         }
     }
@@ -906,7 +908,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
                 try {
                     inputStream.close();
                 } catch(Exception exc) {
-
+                    LOG.warn("Error closing Input stream", exc);
                 }
             }
         }
@@ -976,7 +978,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
                 try {
                     inputStream.close();
                 } catch(Exception exc) {
-
+                    LOG.warn("Error closing Input stream", exc);
                 }
             }
         }
@@ -1208,12 +1210,14 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
             try {
                 u = new URL(url);
             } catch (MalformedURLException e) {
+                LOG.warn("MalformedURLException", e);
                 return false;
             }
 
             try {
                 u.toURI();
             } catch (URISyntaxException e) {
+                LOG.warn("URISyntaxException", e);
                 return false;
             }
 
@@ -1228,6 +1232,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe
         try {
             u = new URI(url);
         } catch (URISyntaxException e) {
+            LOG.warn("URISyntaxException", e);
             return false;
         }