Merge "fixed sonar issues in PrintYangToProp.java"
diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java
index 047fa29..85acd27 100755
--- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java
+++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java
@@ -83,6 +83,7 @@
     protected final long expectedCompletionTime;
     protected final long unprocessedFailoverThreshold;
     private static final String LOGGER_ALARM_MSG="Generated alarm: DBResourceManager.getData - No active DB connection pools are available.";
+    private static final String EXCEPTION_MSG= "No active DB connection pools are available in RequestDataNoRecovery call.";
 
     public DBResourceManager(final DBLIBResourceProvider configuration) {
         this(configuration.getProperties());
@@ -461,7 +462,7 @@
     private CachedRowSet requestDataNoRecovery(String statement, ArrayList<Object> arguments, String preferredDS) throws SQLException {
         if(dsQueue.isEmpty()){
             LOGGER.error(LOGGER_ALARM_MSG);
-            throw new DBLibException("No active DB connection pools are available in RequestDataNoRecovery call.");
+            throw new DBLibException(EXCEPTION_MSG);
         }
         CachedDataSource active = this.dsQueue.first();
         long time = System.currentTimeMillis();
@@ -475,8 +476,7 @@
                 }
             }
             return active.getData(statement, arguments);
-//        } catch(SQLDataException exc){
-//            throw exc;
+
         } catch(Throwable exc){
             String message = exc.getMessage();
             if(message == null)
@@ -537,7 +537,7 @@
     private boolean writeDataNoRecovery(String statement, ArrayList<Object> arguments, String preferredDS) throws SQLException {
         if(dsQueue.isEmpty()){
             LOGGER.error(LOGGER_ALARM_MSG);
-            throw new DBLibException("No active DB connection pools are available in RequestDataNoRecovery call.");
+            throw new DBLibException(EXCEPTION_MSG);
         }
 
         boolean initialRequest = true;
@@ -665,7 +665,7 @@
             SQLException exception = new DBLibException(lastException.getMessage());
             exception.setStackTrace(lastException.getStackTrace());
             if(lastException.getCause() instanceof SQLException) {
-//                exception.setNextException((SQLException)lastException.getCause());
+
                 throw (SQLException)lastException.getCause();
             }
             throw exception;
diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/DbConfigPool.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/DbConfigPool.java
index fb94ea0..6cb1d9c 100644
--- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/DbConfigPool.java
+++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/DbConfigPool.java
@@ -28,19 +28,18 @@
 import org.slf4j.LoggerFactory;
 
 public class DbConfigPool {
-	private static Logger LOGGER = LoggerFactory.getLogger(DbConfigPool.class);
-
+	private static Logger log = LoggerFactory.getLogger(DbConfigPool.class);
 	private final String type;
-
+	private static final int timeOut=0;
 	private ArrayList<BaseDBConfiguration> configurations = new ArrayList<>();
 
 	public DbConfigPool(Properties properties) {
-		LOGGER.debug("Initializing DbConfigType");
+		log.debug("Initializing DbConfigType");
 		type = properties.getProperty(BaseDBConfiguration.DATABASE_TYPE, "JDBC").toUpperCase();
 	}
 
 	public int getTimeout() {
-		return 0;
+		return timeOut;
 	}
 
 	public String getType() {
diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java
index 905944b..454af02 100644
--- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java
+++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/PollingWorker.java
@@ -62,7 +62,7 @@
 		interval = Long.parseLong((ctxprops == null || ctxprops.getProperty("org.onap.ccsdk.dblib.pm.interval") == null)
 				? "60" : (String) ctxprops.getProperty("org.onap.ccsdk.dblib.pm.interval"));
 		// '0' bucket is to count exceptions
-		String sampling[] = ((ctxprops == null || ctxprops.getProperty("org.onap.ccsdk.dblib.pm.sampling") == null)
+		String[] sampling = ((ctxprops == null || ctxprops.getProperty("org.onap.ccsdk.dblib.pm.sampling") == null)
 				? "0,2,5,10,20,50,100" : (String) ctxprops.getProperty("org.onap.ccsdk.dblib.pm.sampling")).split(",");
 
 		if (enabled) {
diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ConfigureNodeExecutor.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ConfigureNodeExecutor.java
index 7ffdfca..5d6a083 100644
--- a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ConfigureNodeExecutor.java
+++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/provider/base/ConfigureNodeExecutor.java
@@ -40,6 +40,8 @@
 	private static final Logger LOG = LoggerFactory
 			.getLogger(ConfigureNodeExecutor.class);
 	private static final String CAUGHT_EXCEPTION_MSG="Caught exception from ";
+	private static final String ALREADY_ACTIVE= "already-active";
+	private static final String NOT_FOUND= "not-found";
 
 	public SvcLogicNode execute(SvcLogicServiceBase svc, SvcLogicNode node,
 			SvcLogicContext ctx) throws SvcLogicException {
@@ -108,10 +110,10 @@
 							case SUCCESS:
 								break;
 							case ALREADY_ACTIVE:
-								outValue = "already-active";
+								outValue = ALREADY_ACTIVE;
 								break;
 							case NOT_FOUND:
-								outValue = "not-found";
+								outValue = NOT_FOUND;
 								break;
 							case NOT_READY:
 								outValue = "not-ready";
@@ -134,10 +136,10 @@
 							case SUCCESS:
 								break;
 							case ALREADY_ACTIVE:
-								outValue = "already-active";
+								outValue = ALREADY_ACTIVE;
 								break;
 							case NOT_FOUND:
-								outValue = "not-found";
+								outValue = NOT_FOUND;
 								break;
 							case NOT_READY:
 								outValue = "not-ready";
@@ -150,10 +152,10 @@
 					}
 					break;
 				case ALREADY_ACTIVE:
-					outValue = "already-active";
+					outValue = ALREADY_ACTIVE;
 					break;
 				case NOT_FOUND:
-					outValue = "not-found";
+					outValue = NOT_FOUND;
 					break;
 				case NOT_READY:
 					outValue = "not-ready";
@@ -177,10 +179,10 @@
 							outValue = "success";
 							break;
 						case ALREADY_ACTIVE:
-							outValue = "already-active";
+							outValue = ALREADY_ACTIVE;
 							break;
 						case NOT_FOUND:
-							outValue = "not-found";
+							outValue = NOT_FOUND;
 							break;
 						case NOT_READY:
 							outValue = "not-ready";
@@ -203,10 +205,10 @@
 							outValue = "success";
 							break;
 						case ALREADY_ACTIVE:
-							outValue = "already-active";
+							outValue = ALREADY_ACTIVE;
 							break;
 						case NOT_FOUND:
-							outValue = "not-found";
+							outValue = NOT_FOUND;
 							break;
 						case NOT_READY:
 							outValue = "not-ready";
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java
index eeea80b..eb4e15e 100755
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java
+++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java
@@ -56,7 +56,9 @@
     private static final String IPV6_ADDRESS="Ipv6Address";
     
     private static final String IP_PREFIX="IpPrefix";
-
+    private static final String SETTING_PROPERTY="Setting property ";
+    private static final String BUILDER="-builder";
+    
     @Deprecated
     public static void setProperties(Properties input) {
         setYangMappingProperties(input);
@@ -146,7 +148,7 @@
                     } else if ("PortNumber".equals(simpleTypeName)) {
                         propVal = String.valueOf((Integer) retValue);
                     }
-                    LOG.debug("Setting property " + pfx + " to " + propVal);
+                    LOG.debug(SETTING_PROPERTY + pfx + " to " + propVal);
                     props.setProperty(pfx, propVal);
                 }
             } catch (Exception e) {
@@ -182,8 +184,8 @@
                     propNamePfx = toLowerHyphen(fromClass.getSimpleName());
                 }
 
-                if (propNamePfx.endsWith("-builder")) {
-                    propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length());
+                if (propNamePfx.endsWith(BUILDER)) {
+                    propNamePfx = propNamePfx.substring(0, propNamePfx.length() - BUILDER.length());
                 }
 
                 if (propNamePfx.endsWith("-impl")) {
@@ -332,7 +334,7 @@
                                 } else {
                                     propVal = propValObj.toString();
                                 }
-                                LOG.debug("Setting property " + propName + " to " + propVal);
+                                LOG.debug(SETTING_PROPERTY + propName + " to " + propVal);
                                 props.setProperty(propName, propVal);
 
                             }
@@ -379,7 +381,7 @@
             } else {
                 fromVal = fromObj.toString();
             }
-            LOG.debug("Setting property " + pfx + " to " + fromVal);
+            LOG.debug(SETTING_PROPERTY + pfx + " to " + fromVal);
             props.setProperty(pfx, fromVal);
         }
 
@@ -559,8 +561,8 @@
                     propNamePfx = toLowerHyphen(toClass.getSimpleName());
                 }
 
-                if (propNamePfx.endsWith("-builder")) {
-                    propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length());
+                if (propNamePfx.endsWith(BUILDER)) {
+                    propNamePfx = propNamePfx.substring(0, propNamePfx.length() - BUILDER.length());
                 }
 
                 if (propNamePfx.endsWith("-impl")) {
@@ -1035,8 +1037,8 @@
                     propNamePfx = toLowerHyphen(toClass.getSimpleName());
                 }
 
-                if (propNamePfx.endsWith("-builder")) {
-                    propNamePfx = propNamePfx.substring(0, propNamePfx.length() - "-builder".length());
+                if (propNamePfx.endsWith(BUILDER)) {
+                    propNamePfx = propNamePfx.substring(0, propNamePfx.length() - BUILDER.length());
                 }
 
                 if (propNamePfx.endsWith("-impl")) {
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java
index b4059ed..d5c7f3b 100755
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java
+++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java
@@ -3,7 +3,7 @@
  * ONAP : CCSDK
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * 						reserved.
+ *                         reserved.
  * ================================================================================
  *  Modifications Copyright (C) 2018 IBM.
  * ================================================================================
@@ -27,7 +27,6 @@
 
 import org.onap.ccsdk.sli.core.dblib.DbLibService;
 import org.onap.ccsdk.sli.core.sli.ConfigurationException;
-import org.onap.ccsdk.sli.core.sli.MetricLogger;
 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
 import org.onap.ccsdk.sli.core.sli.SvcLogicDblibStore;
 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
@@ -44,7 +43,7 @@
 import org.slf4j.LoggerFactory;
 import org.slf4j.MDC;
 
-public class SvcLogicServiceImpl extends SvcLogicServiceImplBase implements SvcLogicService  {
+public class SvcLogicServiceImpl extends SvcLogicServiceImplBase implements SvcLogicService {
 
     private static final Logger LOG = LoggerFactory.getLogger(SvcLogicServiceImpl.class);
     protected BundleContext bctx = null;
@@ -113,7 +112,7 @@
         execute(graph, ctx);
         return (ctx.toProperties());
     }
-    
+
     @Override
     public SvcLogicStore getStore() throws SvcLogicException {
         // Create and initialize SvcLogicStore object - used to access
diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java
index ebfe817..fd3364c 100644
--- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java
+++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java
@@ -65,6 +65,7 @@
 	private static final Logger LOG = LoggerFactory.getLogger(SliPluginUtils.class);
 	private static final String LOG_MSG="extracting list from context memory";
 	private static final String LOG_MSG1="removing elements from list";
+	private static final String LENGTH="_length";
 
 
 	// ========== CONSTRUCTORS ==========
@@ -216,7 +217,7 @@
 			i++;
 		}
 		// Reset list length (removed by ctxBulkErase above)
-		ctx.setAttribute(ctx_list_str+"_length", Integer.toString(listSz));
+		ctx.setAttribute(ctx_list_str+LENGTH, Integer.toString(listSz));
 	}
 
     /**
@@ -492,7 +493,7 @@
 	 * @since 1.0
 	 */
 	public static final int getArrayLength( SvcLogicContext ctx, String key, Logger log, LogLevel logLevel, String log_message ) {
-		String ctxKey = key.endsWith("_length") ? key : key + "_length";
+		String ctxKey = key.endsWith(LENGTH) ? key : key + LENGTH;
 		try {
 			return Integer.parseInt(ctx.getAttribute(ctxKey));
 		}
@@ -829,7 +830,7 @@
                 writeJsonObject(entry.getValue().getAsJsonObject(), ctx, root + entry.getKey() + ".");
             } else if (entry.getValue().isJsonArray()) {
                 JsonArray array = entry.getValue().getAsJsonArray();
-                ctx.setAttribute(root + entry.getKey() + "_length", String.valueOf(array.size()));
+                ctx.setAttribute(root + entry.getKey() + LENGTH, String.valueOf(array.size()));
                 Integer arrayIdx = 0;
                 for (JsonElement element : array) {
                     if (element.isJsonObject()) {
@@ -873,7 +874,7 @@
 
 		try {
 			String ctxList = parameters.get("list");
-			ctxList = (ctxList.endsWith("_length")) ? ctxList : ctxList + "_length";
+			ctxList = (ctxList.endsWith(LENGTH)) ? ctxList : ctxList + LENGTH;
 			int listLength = getArrayLength(ctx, ctxList);
 
 			if (listLength == 0) {
@@ -1063,9 +1064,9 @@
 		setParametersToCtxList(parameters, ctx, prefixKeyWithIndex, valuePrefixKey);
 
 		// set length of list
-		String ListLengthKeyName = prefixKey + "_length";
+		String ListLengthKeyName = prefixKey + LENGTH;
 
-		ctxSetAttribute(ctx, prefixKey + "_length", listLength + 1);
+		ctxSetAttribute(ctx, prefixKey + LENGTH, listLength + 1);
 		LOG.debug("Updated _length: " + prefixKey + "_length is now " + ctx.getAttribute(ListLengthKeyName));
 	}
 
diff --git a/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java b/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java
index 667bae9..4817a95 100644
--- a/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java
+++ b/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java
@@ -566,7 +566,7 @@
 			YangInstanceIdentifier testResultId = YangInstanceIdentifier.builder().node(TEST_RESULTS_QNAME).node(TEST_RESULT_QNAME).build();
 
 			// Construct results list
-			LinkedList<LeafSetEntryNode<Object>> entryList = new LinkedList<LeafSetEntryNode<Object>>();
+			LinkedList<LeafSetEntryNode<Object>> entryList = new LinkedList<>();
 			for (String result : testResult.getResults()) {
 				LeafSetEntryNode<Object> leafSetEntryNode = ImmutableLeafSetEntryNodeBuilder.create()
 																				.withNodeIdentifier(new NodeWithValue(RESULTS_QNAME, result))