From 9b0595cc58b9a990909175bfcbcad59337a74b4f Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Thu, 29 Nov 2018 10:51:47 +0530 Subject: Sonar Fix: AnsibleMessageParser.java Fixed sonar issues/code-smells across this file. Issue-ID: APPC-1256 Change-Id: I70480e3867c0ab49325d10e0ec91e76bf6979c50 Signed-off-by: Arundathi Patil --- .../org/onap/appc/adapter/ansible/model/AnsibleMessageParser.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'appc-adapters/appc-ansible-adapter') diff --git a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/model/AnsibleMessageParser.java b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/model/AnsibleMessageParser.java index 6aee75631..5f6259c03 100644 --- a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/model/AnsibleMessageParser.java +++ b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/model/AnsibleMessageParser.java @@ -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)); -- cgit 1.2.3-korg