From c80a85fa44b0b02efae3935ec79a81c2f5db8820 Mon Sep 17 00:00:00 2001 From: Jegadeesh Babu Date: Sun, 31 Mar 2019 12:35:47 +0530 Subject: Used constants to avoid dup of literals Sonar fix Issue-ID: APPC-1562 Change-Id: Ic9d14b32f4deac975b46154a2ac8e4664ec11c52 Signed-off-by: Jegadeesh Babu --- .../org/onap/appc/adapter/chef/impl/ChefAdapterImpl.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/ChefAdapterImpl.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/ChefAdapterImpl.java index 717c39914..6a8664acb 100644 --- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/ChefAdapterImpl.java +++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/ChefAdapterImpl.java @@ -168,6 +168,7 @@ public class ChefAdapterImpl implements ChefAdapter { public void vnfcNodeobjects(Map params, SvcLogicContext ctx) throws SvcLogicException { logger.info("update the nodeObjects of VNF-C"); int code; + final String LOG_ERR_METHOD_STR = "vnfcNodeobjects"; try { chefInfo(params, ctx); String nodeListS = params.get(NODE_LIST_STR); @@ -208,12 +209,12 @@ public class ChefAdapterImpl implements ChefAdapter { } } catch (JSONException e) { code = APPC_ERRORCODE; - logger.error(POSTING_REQUEST_JSON_ERROR_STR + "vnfcNodeobjects", e); - doFailure(ctx, code, POSTING_REQUEST_JSON_ERROR_STR + "vnfcNodeobjects" + e.getMessage()); + logger.error(POSTING_REQUEST_JSON_ERROR_STR + LOG_ERR_METHOD_STR, e); + doFailure(ctx, code, POSTING_REQUEST_JSON_ERROR_STR + LOG_ERR_METHOD_STR + e.getMessage()); } catch (Exception e) { code = APPC_ERRORCODE; - logger.error(POSTING_REQUEST_ERROR_STR + "vnfcNodeobjects", e); - doFailure(ctx, code, POSTING_REQUEST_ERROR_STR + "vnfcNodeobjects" + e.getMessage()); + logger.error(POSTING_REQUEST_ERROR_STR + LOG_ERR_METHOD_STR, e); + doFailure(ctx, code, POSTING_REQUEST_ERROR_STR + LOG_ERR_METHOD_STR + e.getMessage()); } } @@ -600,11 +601,12 @@ public class ChefAdapterImpl implements ChefAdapter { try { JSONObject messageJson = new JSONObject(message); JSONObject node = messageJson.getJSONObject("nodes"); + final String failed = "failed"; if (node == null) { logger.debug("Status Complete but node details in the message is null : " + message); return Boolean.TRUE; } - if (node.has("failed") && !(node.isNull("failed")) && (node.getJSONArray("failed").length() != 0)) { + if (node.has(failed) && !(node.isNull(failed)) && (node.getJSONArray(failed).length() != 0)) { logger.debug("Status Complete but one or more Failed nodes ....FAILURE " + message); return Boolean.TRUE; } -- cgit 1.2.3-korg