Fix Sonar Issues 09/12409/1
authorsurya-huawei <a.u.surya@huawei.com>
Thu, 14 Sep 2017 10:26:03 +0000 (15:56 +0530)
committersurya-huawei <a.u.surya@huawei.com>
Thu, 14 Sep 2017 10:27:00 +0000 (15:57 +0530)
few major issues in sli/adaptors module

Issue-Id: CCSDK-87
Change-Id: I43865634fa7d5f5d1b84c7efff691047cfcd5feb
Signed-off-by: surya-huawei <a.u.surya@huawei.com>
aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIDeclarations.java
aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIRequest.java

index 413d85a..61df170 100644 (file)
@@ -245,7 +245,8 @@ public abstract class AAIDeclarations implements AAIClient {
                                                        }
                                                        ctx.setAttribute(prefix + ".error.message", exc.getMessage());
                                                        if(errorCode >= 300) {
-                                                               ctx.setAttribute(prefix + ".error.http.response-code", "" + exc.getReturnCode());
+                                                               ctx.setAttribute(prefix + ".error.http.response-code",
+                                                                                                Integer.toString(exc.getReturnCode()));
                                                        }
                                                        return QueryStatus.FAILURE;
                                                }
@@ -1295,8 +1296,8 @@ public abstract class AAIDeclarations implements AAIClient {
                                                j++;
                                        }
                                                AAIRequest rlRequest = AAIRequest.createRequest(relatedTo, relParams);
-                                               for(String key1 : relParams.keySet()) {
-                                                       rlRequest.addRequestProperty(key1, relParams.get(key1));
+                                               for(Map.Entry<String,String> entry : relParams.entrySet()) {
+                                                       rlRequest.addRequestProperty(entry.getKey(), entry.getValue());
                                                }
                                                String path = rlRequest.updatePathDataValues(null);
                                                relationship.setRelatedLink(path);
index c6145f8..03121ac 100644 (file)
@@ -140,11 +140,11 @@ public abstract class AAIRequest {
        /**
         * Map containing resource tag to its bit position in bitset mapping
         */
-       private static Map<String, String> tagValues = new LinkedHashMap<String, String>();
+       private static Map<String, String> tagValues = new LinkedHashMap<>();
        /**
         * Map containing bitset value of the path to its path mapping
         */
-       private static Map<BitSet, String> bitsetPaths = new LinkedHashMap<BitSet, String>();
+       private static Map<BitSet, String> bitsetPaths = new LinkedHashMap<>();
 
 
        public static Set<String> getResourceNames() {
@@ -180,7 +180,7 @@ public abstract class AAIRequest {
                        Set<String> keys = properties.stringPropertyNames();
 
                        int index = 0;
-                       Set<String> resourceNames = new TreeSet<String>();
+                       Set<String> resourceNames = new TreeSet<>();
 
                        for(String key : keys) {
                                String[] tags = key.split("\\|");
@@ -325,8 +325,8 @@ public abstract class AAIRequest {
        }
 
        protected static Set<String> extractUniqueResourceSetFromKeys(Set<String> keySet) {
-               Set<String> uniqueResources = new TreeSet<String>();
-               List<String> keys = new ArrayList<String>(keySet);
+               Set<String> uniqueResources = new TreeSet<>();
+               List<String> keys = new ArrayList<>(keySet);
                for(String resource : keys) {
                        if(resource.contains(".")) {
                                String [] split = resource.split("\\.");
@@ -339,7 +339,7 @@ public abstract class AAIRequest {
        public void processRequestPathValues(Map<String, String> nameValues) {
                Set<String> uniqueResources = extractUniqueResourceSetFromKeys(nameValues.keySet());
 
-               Set<String> tokens = new TreeSet<String>();
+               Set<String> tokens = new TreeSet<>();
                tokens.add(DEPTH);
                tokens.addAll(Arrays.asList(this.getArgsList()));
 
@@ -409,12 +409,12 @@ public abstract class AAIRequest {
        }
 
        public static Map<String, String> splitQuery(String query) throws UnsupportedEncodingException {
-           Map<String, String> query_pairs = new LinkedHashMap<String, String>();
+           Map<String, String> query_pairs = new LinkedHashMap<>();
 
            if(query != null && !query.isEmpty()) {
                String[] pairs = query.split("&");
                for (String pair : pairs) {
-                       int idx = pair.indexOf("=");
+                       int idx = pair.indexOf('=');
                        query_pairs.put(URLDecoder.decode(pair.substring(0, idx), "UTF-8"), URLDecoder.decode(pair.substring(idx + 1), "UTF-8"));
                }
            }
@@ -422,12 +422,12 @@ public abstract class AAIRequest {
        }
 
        public static Map<String, String> splitPath(String path) throws UnsupportedEncodingException {
-           Map<String, String> query_pairs = new LinkedHashMap<String, String>();
+           Map<String, String> query_pairs = new LinkedHashMap<>();
 
            if(path != null && !path.isEmpty()) {
                String[] pairs = path.split("/");
                for (String pair : pairs) {
-                       int idx = pair.indexOf("=");
+                       int idx = pair.indexOf('=');
                        query_pairs.put(URLDecoder.decode(pair.substring(0, idx), "UTF-8"), URLDecoder.decode(pair.substring(idx + 1), "UTF-8"));
                }
            }