Sonar Fix: AnsibleMessageParser.java 79/73879/3
authorArundathi Patil <arundpil@in.ibm.com>
Thu, 29 Nov 2018 05:21:47 +0000 (10:51 +0530)
committerTakamune Cho <takamune.cho@att.com>
Sat, 1 Dec 2018 00:42:52 +0000 (00:42 +0000)
Fixed sonar issues/code-smells across this file.

Issue-ID: APPC-1256
Change-Id: I70480e3867c0ab49325d10e0ec91e76bf6979c50
Signed-off-by: Arundathi Patil <arundpil@in.ibm.com>
appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/model/AnsibleMessageParser.java

index 6aee756..5f6259c 100644 (file)
@@ -150,6 +150,7 @@ public class AnsibleMessageParser {
             ansibleResult = new AnsibleResult(code, msg);
 
         } catch (JSONException e) {
+            LOGGER.error("JSONException: Error parsing response", e);
             ansibleResult = new AnsibleResult(600, "Error parsing response = " + input + ". Error = " + e.getMessage());
         }
         return ansibleResult;
@@ -167,6 +168,7 @@ public class AnsibleMessageParser {
             JSONObject postResponse = new JSONObject(input);
             ansibleResult = parseGetResponseNested(ansibleResult, postResponse);
         } catch (JSONException e) {
+            LOGGER.error("JSONException: Error parsing response", e);
             ansibleResult = new AnsibleResult(AnsibleResultCodes.INVALID_PAYLOAD.getValue(),
                     "Error parsing response = " + input + ". Error = " + e.getMessage(), "");
         }
@@ -213,10 +215,11 @@ public class AnsibleMessageParser {
 
                     LOGGER.info("Code = {}, Message = {}", subCode, message);
 
-                    if (subCode != 200 || !message.equals("SUCCESS")) {
+                    if (subCode != 200 || !(("SUCCESS").equals(message))) {
                         finalCode = AnsibleResultCodes.REQ_FAILURE.getValue();
                     }
                 } catch (JSONException e) {
+                    LOGGER.error("JSONException: Error parsing response", e);
                     ansibleResult.setStatusCode(AnsibleResultCodes.INVALID_RESPONSE.getValue());
                     ansibleResult.setStatusMessage(String.format(
                             "Error processing response message = %s from host %s", results.getString(host), host));