From 9ad0d913dc0e3188d3af153c606d47faf834d11e Mon Sep 17 00:00:00 2001 From: Mamtha Date: Sat, 18 Apr 2020 01:11:43 +0530 Subject: Reduce code smells Issue-ID: APPC-1858 Change-Id: Id6dde417125b0c51426284dbcfa27cb7b8802822 Signed-off-by: Mamtha --- .../adapter/ansible/model/AnsibleMessageParser.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (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 fc38b550a..1ecb37501 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 @@ -257,15 +257,12 @@ public class AnsibleMessageParser { if (subCode != 200 || !(("SUCCESS").equals(message))) { finalCode = AnsibleResultCodes.REQ_FAILURE.getValue(); } - if ((hostResponse.optJSONObject("Output")) != null) { - if ((hostResponse.optJSONObject("Output").optJSONObject("info")) != null) { - if ((hostResponse.optJSONObject("Output").optJSONObject("info") - .optJSONObject("configData")) != null) { - config = hostResponse.optJSONObject("Output").optJSONObject("info") - .optJSONObject("configData"); - - ansibleResult.setconfigData(config.toString()); - } + if ((hostResponse.optJSONObject(OUTPUT_OPT_KEY)) != null) { + JSONObject hostResponseObjectInfo = hostResponse.optJSONObject(OUTPUT_OPT_KEY).optJSONObject("info"); + JSONObject hostResponseConfigData = hostResponseObjectInfo.optJSONObject("configData"); + if ((hostResponseObjectInfo != null) && hostResponseConfigData != null) { + config = hostResponseConfigData; + ansibleResult.setconfigData(config.toString()); } } } catch (JSONException e) { @@ -387,14 +384,14 @@ public class AnsibleMessageParser { } - private boolean varObjContainsNoData(Object obj) { + /*private boolean varObjContainsNoData(Object obj) { if (obj instanceof String) { if (StringUtils.startsWith(obj.toString(), "$") || StringUtils.isEmpty(obj.toString())) return true; } return false; - } + }*/ private boolean dataIsVariable(String payload) { if (StringUtils.startsWith(payload, "$") || StringUtils.isEmpty(payload)) -- cgit 1.2.3-korg