From dc3aac0ffdc29304b793e201988413cce25d6903 Mon Sep 17 00:00:00 2001 From: ezhil Date: Wed, 26 Dec 2018 16:04:52 +0530 Subject: Fixed sonar fix in AnsibleMessageParser.java Fixed sonar issues Issue-ID: CCSDK-874 Change-Id: Ic4cc98be436cc746df06b3b3f01dca40ecc7b888 Signed-off-by: ezhil --- .../ccsdk/sli/adaptors/ansible/model/AnsibleMessageParser.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'ansible-adapter/ansible-adapter-bundle') diff --git a/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/model/AnsibleMessageParser.java b/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/model/AnsibleMessageParser.java index 0f2862579..6e2244ff9 100644 --- a/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/model/AnsibleMessageParser.java +++ b/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/model/AnsibleMessageParser.java @@ -6,6 +6,8 @@ * ================================================================================ * Copyright (C) 2017 Amdocs * ============================================================================= + * Modifications Copyright (C) 2018 IBM. + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -151,6 +153,7 @@ public class AnsibleMessageParser { ansibleResult = new AnsibleResult(code, msg); } catch (JSONException e) { + LOGGER.error("JSON exception", e); ansibleResult = new AnsibleResult(600, "Error parsing response = " + input + ". Error = " + e.getMessage()); } return ansibleResult; @@ -168,6 +171,7 @@ public class AnsibleMessageParser { JSONObject postResponse = new JSONObject(input); ansibleResult = parseGetResponseNested(ansibleResult, postResponse); } catch (JSONException e) { + LOGGER.error("JSON exception", e); ansibleResult = new AnsibleResult(AnsibleResultCodes.INVALID_PAYLOAD.getValue(), "Error parsing response = " + input + ". Error = " + e.getMessage(), ""); } @@ -196,7 +200,7 @@ public class AnsibleMessageParser { // Results are available. process them // Results is a dictionary of the form - // {host :{status:s, group:g, message:m, hostname:h}, ...} + LOGGER.info("Processing results in response"); JSONObject results = postRsp.getJSONObject("Results"); LOGGER.info("Get JSON dictionary from Results .."); @@ -214,10 +218,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("JSON exception", 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