From 331e512b29fa7bf5de5c20e5c913677f11979e4d Mon Sep 17 00:00:00 2001 From: surya-huawei Date: Thu, 14 Sep 2017 15:56:03 +0530 Subject: Fix Sonar Issues few major issues in sli/adaptors module Issue-Id: CCSDK-87 Change-Id: I43865634fa7d5f5d1b84c7efff691047cfcd5feb Signed-off-by: surya-huawei --- .../onap/ccsdk/sli/adaptors/aai/AAIDeclarations.java | 7 ++++--- .../org/onap/ccsdk/sli/adaptors/aai/AAIRequest.java | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIDeclarations.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIDeclarations.java index 413d85a5..61df1708 100644 --- a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIDeclarations.java +++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIDeclarations.java @@ -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 entry : relParams.entrySet()) { + rlRequest.addRequestProperty(entry.getKey(), entry.getValue()); } String path = rlRequest.updatePathDataValues(null); relationship.setRelatedLink(path); diff --git a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIRequest.java b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIRequest.java index c6145f8a..03121ac0 100644 --- a/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIRequest.java +++ b/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIRequest.java @@ -140,11 +140,11 @@ public abstract class AAIRequest { /** * Map containing resource tag to its bit position in bitset mapping */ - private static Map tagValues = new LinkedHashMap(); + private static Map tagValues = new LinkedHashMap<>(); /** * Map containing bitset value of the path to its path mapping */ - private static Map bitsetPaths = new LinkedHashMap(); + private static Map bitsetPaths = new LinkedHashMap<>(); public static Set getResourceNames() { @@ -180,7 +180,7 @@ public abstract class AAIRequest { Set keys = properties.stringPropertyNames(); int index = 0; - Set resourceNames = new TreeSet(); + Set resourceNames = new TreeSet<>(); for(String key : keys) { String[] tags = key.split("\\|"); @@ -325,8 +325,8 @@ public abstract class AAIRequest { } protected static Set extractUniqueResourceSetFromKeys(Set keySet) { - Set uniqueResources = new TreeSet(); - List keys = new ArrayList(keySet); + Set uniqueResources = new TreeSet<>(); + List 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 nameValues) { Set uniqueResources = extractUniqueResourceSetFromKeys(nameValues.keySet()); - Set tokens = new TreeSet(); + Set tokens = new TreeSet<>(); tokens.add(DEPTH); tokens.addAll(Arrays.asList(this.getArgsList())); @@ -409,12 +409,12 @@ public abstract class AAIRequest { } public static Map splitQuery(String query) throws UnsupportedEncodingException { - Map query_pairs = new LinkedHashMap(); + Map 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 splitPath(String path) throws UnsupportedEncodingException { - Map query_pairs = new LinkedHashMap(); + Map 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")); } } -- cgit 1.2.3-korg