Replaced hardcoded with const variable 89/82589/1
authorJegadeesh Babu <jegabab1@in.ibm.com>
Mon, 18 Mar 2019 13:54:07 +0000 (19:24 +0530)
committerJegadeesh Babu <jegabab1@in.ibm.com>
Mon, 18 Mar 2019 13:55:05 +0000 (19:25 +0530)
Sonar fix

Issue-ID: APPC-1544
Change-Id: I19c7f33d4e7d1070fa84a33e4f997923c9c1f8e1
Signed-off-by: Jegadeesh Babu <jegabab1@in.ibm.com>
appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/impl/AnsibleAdapterImpl.java

index b352dbe..971730e 100644 (file)
@@ -93,6 +93,7 @@ public class AnsibleAdapterImpl implements AnsibleAdapter {
     private static final String APPC_PROPS = "/appc.properties";
     private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR";
     private static final String propDir = System.getenv(SDNC_CONFIG_DIR);
+    private static final String SERVERIP = "ServerIP";
     private Properties props;
     private int defaultTimeout = 600 * 1000;
     private int defaultSocketTimeout = 60 * 1000;
@@ -335,9 +336,9 @@ public class AnsibleAdapterImpl implements AnsibleAdapter {
             ctx.setAttribute(OUTPUT_ATTRIBUTE_NAME, output);
             String serverIp = testResult.getServerIp();
             if (StringUtils.isBlank(serverIp))
-            ctx.setAttribute("ServerIP", serverIp);
+            ctx.setAttribute(SERVERIP, serverIp);
             else
-              ctx.setAttribute("ServerIP", "");
+              ctx.setAttribute(SERVERIP, "");
             // Check status of test request returned by Agent
             if (code == AnsibleResultCodes.PENDING.getValue()) {
               logger.info(String.format("Submission of Test %s successful.", playbookName));
@@ -373,7 +374,7 @@ public class AnsibleAdapterImpl implements AnsibleAdapter {
         String reqUri = StringUtils.EMPTY;
 
         try {
-            String serverIp = ctx.getAttribute("ServerIP");
+            String serverIp = ctx.getAttribute(SERVERIP);
             if (StringUtils.isNotBlank(serverIp))
                 reqUri = messageProcessor.reqUriResultWithIP(params, serverIp);
             else
@@ -515,7 +516,7 @@ public class AnsibleAdapterImpl implements AnsibleAdapter {
         long endTime = System.currentTimeMillis() + timeout;
 
         while (System.currentTimeMillis() < endTime) {
-            String serverIP = ctx.getAttribute("ServerIP");
+            String serverIP = ctx.getAttribute(SERVERIP);
             ConnectionBuilder httpClientLocal = getHttpConn(defaultSocketTimeout, serverIP);
             logger.info("Querying ansible GetResult URL = " + agentUrl);