Merge "Fix Sonar Issues"
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 1d7fbd1..413d85a 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
@@ -146,7 +146,7 @@
 
 		getLogger().debug("AAIService.query \tresource = "+resource);
 
-		String vnfId = null;
+		String vnfId;
 		String vnfName = null;
 		HashMap<String, String> nameValues = AAIServiceUtils.keyToHashMap(key, ctx);
 		getLogger().debug("key = "+ nameValues.toString());
@@ -164,7 +164,7 @@
 		// process data using new model
 		boolean useNewModelProcessing = true;
 		// process server query by name the old way
-		if(("vserver".equals(resource) || "vserver2".equals(resource))){
+		if("vserver".equals(resource) || "vserver2".equals(resource)){
 			if(nameValues.containsKey("vserver_name") || nameValues.containsKey("vserver-name") || nameValues.containsKey("vserver.vserver_name") || nameValues.containsKey("vserver.vserver-name"))
 				useNewModelProcessing = false;
 		}
@@ -185,7 +185,7 @@
 		}
 
 		ObjectMapper mapper = AAIService.getObjectMapper();
-		Map<String,Object> attributes = new HashMap<String,Object>();
+		Map<String,Object> attributes = new HashMap<>();
 
 		String modifier = null;
 
@@ -349,12 +349,12 @@
 			} else {
 				if (ctx != null) {
 					if (prefix != null) {
-						ArrayList<String> keys = new ArrayList<String>(attributes.keySet());
+						ArrayList<String> keys = new ArrayList<>(attributes.keySet());
 
 						int numCols = keys.size();
 
 						for (int i = 0; i < numCols; i++) {
-							String colValue = null;
+							String colValue;
 							String colName = keys.get(i);
 							Object object = attributes.get(colName);
 
@@ -369,7 +369,7 @@
 									ctx.setAttribute(colValue.replaceAll("_", "-"), colValue);
 								}
 							} else if(object != null && object instanceof Map) {
-								if(colName.equals(modifier) || colName.equals("relationship-list")){
+								if(colName.equals(modifier) || "relationship-list".equals(colName)){
 									String localNodifier = modifier;
 									if(localNodifier == null)
 										localNodifier = "relationship-list";
@@ -382,7 +382,7 @@
 				}
 			}
 			getLogger().debug("Query - returning " + retval);
-			return (retval);
+			return retval;
 
 		} catch (Exception exc) {
 			getLogger().warn("Failed query - returning FAILURE", exc);
@@ -426,7 +426,7 @@
 			}
 		}
 
-		if(list.size() > 0) {
+		if(!list.isEmpty()) {
 			ctx.setAttribute(prefix + "_length", Integer.toString(list.size()));
 			getLogger().debug(prefix + "_length"  + " : " + Integer.toString(list.size()));
 		}
@@ -465,7 +465,7 @@
 
 		boolean useNewModelProcessing = true;
 		// process server query by name the old way
-		if(("vserver".equals(resource) || "vserver2".equals(resource))){
+		if("vserver".equals(resource) || "vserver2".equals(resource)){
 			if(nameValues.containsKey("vserver-name")) {
 				useNewModelProcessing = false;
 			}
@@ -532,7 +532,7 @@
 			}
 		} else {
 			String reSource = resource.toLowerCase().replace("-", "_");
-				String vnfId = null;
+				String vnfId;
 
 			try {
 				switch(reSource) {
@@ -801,7 +801,7 @@
 				return QueryStatus.FAILURE;
 			}
 
-			Map<String, String> params = new HashMap<String, String>();
+			Map<String, String> params = new HashMap<>();
 
 			request.processRequestPathValues(nameValues);
 			if(nameValues.containsKey("prefix")){
@@ -820,7 +820,8 @@
 			int errorCode = aaiexc.getReturnCode();
 			ctx.setAttribute(prefix + ".error.message", aaiexc.getMessage());
 			if(errorCode >= 300) {
-				ctx.setAttribute(prefix + ".error.http.response-code", "" + aaiexc.getReturnCode());
+				ctx.setAttribute(prefix + ".error.http.response-code", "" +
+						Integer.toString(aaiexc.getReturnCode()));
 			}
 
 			if(aaiexc.getReturnCode() == 404)
@@ -838,7 +839,7 @@
 
 	public QueryStatus processResponseData(String rv, String resource, AAIRequest request, String prefix,  SvcLogicContext ctx, HashMap<String, String> nameValues, String modifier) throws JsonParseException, JsonMappingException, IOException, AAIServiceException
 	{
-		Object response = null;
+		Object response;
 
 			if(rv == null) {
 				return QueryStatus.NOT_FOUND;
@@ -910,7 +911,7 @@
 			getLogger().debug("Retrofiting relationship data: " + exc.getMessage());
 		}
 
-			String preFix = null;
+			String preFix;
 			if(prefix == null || prefix.isEmpty()) {
 				preFix = "";
 			} else {
@@ -1001,7 +1002,7 @@
 	public QueryStatus newModelBackupRequest(String resource,  Map<String, String> params,  String prefix,  SvcLogicContext ctx) {
 
 		QueryStatus retval = QueryStatus.SUCCESS;
-		HashMap<String, String> nameValues = new HashMap<String, String>();
+		HashMap<String, String> nameValues = new HashMap<>();
 
 		try {
 			AAIRequest request = AAIRequest.createRequest(resource, nameValues);
@@ -1083,10 +1084,10 @@
 		HashMap<String, String> nameValues = AAIServiceUtils.keyToHashMap(key, ctx);
 
 		try {
-			ArrayList<String> subResources = new ArrayList<String>();
+			ArrayList<String> subResources = new ArrayList<>();
 			Set<String> set = params.keySet();
-			Map<String, Method> setters = new HashMap<String, Method>();
-			Map<String, Method> getters = new HashMap<String, Method>();
+			Map<String, Method> setters = new HashMap<>();
+			Map<String, Method> getters = new HashMap<>();
 
 			// 1. find class
 			AAIRequest request = AAIRequest.createRequest(resource, nameValues);
@@ -1137,11 +1138,11 @@
 										getLogger().warn("Failed process for " + resourceClass.getName(), x);
 									}
 								} else if(type.getName().equals("java.util.List")) {
-									List<String> newValues = new ArrayList<String>();
+									List<String> newValues = new ArrayList<>();
 									String length = id+"_length";
 									if(!params.isEmpty() && params.containsKey(length)) {
 										String tmp = params.get(length).toString();
-										int count = Integer.valueOf(tmp);
+										int count = Integer.parseInt(tmp);
 										for(int i=0; i<count; i++) {
 											String tmpValue = params.get(String.format("%s[%d]", id, i));
 											newValues.add(tmpValue);
@@ -1158,7 +1159,7 @@
 
 							}
 
-							Method getter = null;
+							Method getter;
 							try {
 								getter = resourceClass.getMethod("get"+StringUtils.capitalize(value));
 								if(!type.getName().equals("java.lang.String")) {
@@ -1181,9 +1182,9 @@
 				}
 			}
 
-			Set<String> relationshipKeys = new TreeSet<String>();
-			Set<String> vlansKeys = new TreeSet<String>();
-			Set<String> metadataKeys = new TreeSet<String>();
+			Set<String> relationshipKeys = new TreeSet<>();
+			Set<String> vlansKeys = new TreeSet<>();
+			Set<String> metadataKeys = new TreeSet<>();
 
 			for(String attribute : set) {
 				String value = params.get(attribute);
@@ -1452,7 +1453,8 @@
 			ctx.setAttribute(prefix + ".error.message", exc.getMessage());
 			int returnCode = exc.getReturnCode();
 			if(returnCode >= 300) {
-				ctx.setAttribute(prefix + ".error.http.response-code", "" + exc.getReturnCode());
+				ctx.setAttribute(prefix + ".error.http.response-code", "" +
+						Integer.toString(exc.getReturnCode()));
 			}
 
 			if(returnCode == 400 || returnCode == 412)
@@ -1477,7 +1479,7 @@
 
 		Class resourceClass = instance.getClass();
 
-		Set<String> relationshipKeys = new TreeSet<String>();
+		Set<String> relationshipKeys = new TreeSet<>();
 
 		Set<String> set = params.keySet();
 
@@ -1492,7 +1494,7 @@
 		// 3. Process Relationships
 		// add relationship list
 		if(!relationshipKeys.isEmpty()) {
-			RelationshipList relationshipList = null;
+			RelationshipList relationshipList;
 			Object obj = null;
 			Method getRelationshipListMethod = null;
 			try {
@@ -1553,7 +1555,7 @@
 					if(relatedLink != null) {
 						relationship.setRelatedLink(relatedLink);
 				} else  {
-					Map<String, String> relParams = new HashMap<String, String>();
+					Map<String, String> relParams = new HashMap<>();
 
 				while(true) {
 					String searchRelationshipKey = "relationship-list.relationship[" + i + "].relationship-data[" + j + "].relationship-key";
@@ -1596,7 +1598,7 @@
 		String resource = params.get("resource").toLowerCase();
 		String prefix = params.get("data-key");
 
-		HashMap<String, String> nameValues = new HashMap<String, String>();
+		HashMap<String, String> nameValues = new HashMap<>();
 		if(AAIRequest.createRequest(resource, nameValues) != null) {
 
 			try {
@@ -1617,7 +1619,7 @@
 		String resource = params.get("resource").toLowerCase();
 		String prefix = params.get("data-key");
 
-		HashMap<String, String> nameValues = new HashMap<String, String>();
+		HashMap<String, String> nameValues = new HashMap<>();
 		if(AAIRequest.createRequest(resource, nameValues) != null) {
 
 			try {
@@ -1782,7 +1784,7 @@
 	}
 
 	static final Map<String, String> ctxGetBeginsWith( SvcLogicContext ctx, String prefix ) {
-		Map<String, String> tmpPrefixMap = new HashMap<String, String>();
+		Map<String, String> tmpPrefixMap = new HashMap<>();
 
 		if(prefix == null || prefix.isEmpty()){
 			return tmpPrefixMap;
@@ -1795,7 +1797,7 @@
 			}
 		}
 
-		Map<String, String> prefixMap = new HashMap<String, String>();
+		Map<String, String> prefixMap = new HashMap<>();
 		Pattern p = Pattern.compile(".*\\[\\d\\]");
 
 		SortedSet<String> keys = new TreeSet(tmpPrefixMap.keySet () );
@@ -1807,7 +1809,7 @@
 				String listKey = key.substring(0, key.indexOf("_length"));
 				int max = Integer.parseInt(tmpPrefixMap.get(key));
 
-				ArrayList<String> data = new ArrayList<String>();
+				ArrayList<String> data = new ArrayList<>();
 				for(int x = 0; x < max; x++){
 					String tmpKey = String.format("%s[%d]", listKey, x);
 					String tmpValue = tmpPrefixMap.get(tmpKey);