From 4f250eadf1bb2b7bfe736aa6511bb3df1ffe3eec Mon Sep 17 00:00:00 2001 From: Taka Cho Date: Fri, 26 Jun 2020 11:35:12 -0400 Subject: m2 sonar fix - "get" returns a string already - to avoid sonar issue for duplicated strings - formating Issue-ID: POLICY-2616 Change-Id: I1fac65bba5ecb402c784dd585ebcd7992cf31545 Signed-off-by: Taka Cho --- .../org/onap/policy/m2/appclcm/AppcLcmOperation.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'controlloop') diff --git a/controlloop/m2/appclcm/src/main/java/org/onap/policy/m2/appclcm/AppcLcmOperation.java b/controlloop/m2/appclcm/src/main/java/org/onap/policy/m2/appclcm/AppcLcmOperation.java index 24f8ed5ab..cbd7413f9 100644 --- a/controlloop/m2/appclcm/src/main/java/org/onap/policy/m2/appclcm/AppcLcmOperation.java +++ b/controlloop/m2/appclcm/src/main/java/org/onap/policy/m2/appclcm/AppcLcmOperation.java @@ -71,6 +71,8 @@ public class AppcLcmOperation implements Operation, LockAdjunct.Requestor, Seria private static final long serialVersionUID = 5062964240000304989L; + private static final String DCAE_ONSET_MISSING = "dcae onset is missing "; + // state when waiting for a lock public static final String LCM_WAIT_FOR_LOCK = "LCM.WAIT_FOR_LOCK"; @@ -171,7 +173,7 @@ public class AppcLcmOperation implements Operation, LockAdjunct.Requestor, Seria // attempt to get a lock for the VM -- if we get it immediately, // we can go to the 'LCM_GUARD_PENDING' or 'LCM_BEGIN' state - target = this.onset.getAai().get(onset.getTarget()).toString(); + target = this.onset.getAai().get(onset.getTarget()); String key = onset.getTargetType() + ":" + target; if (transaction.getAdjunct(LockAdjunct.class).getLock(this, key, transaction.getRequestId().toString(), false)) { @@ -336,28 +338,27 @@ public class AppcLcmOperation implements Operation, LockAdjunct.Requestor, Seria */ private Map setCommonPayload(Map aai) throws ControlLoopException { Map payload = new HashMap<>(); - for (Map.Entry entry : aai.entrySet()) { switch (entry.getKey()) { case DCAE_VSERVER_SELF_LINK_FIELD: if (entry.getValue() != null) { payload.put(APPC_LCM_VM_ID_FIELD, entry.getValue()); } else { - setErrorStatus("dcae onset is missing " + DCAE_VSERVER_SELF_LINK_FIELD); + setErrorStatus(DCAE_ONSET_MISSING + DCAE_VSERVER_SELF_LINK_FIELD); } break; case DCAE_IDENTITY_FIELD: if (entry.getValue() != null) { payload.put(APPC_LCM_IDENTITY_URL_FIELD, entry.getValue()); } else { - setErrorStatus("dcae onset is missing " + DCAE_IDENTITY_FIELD); + setErrorStatus(DCAE_ONSET_MISSING + DCAE_IDENTITY_FIELD); } break; case DCAE_TENANT_ID_FIELD: if (entry.getValue() != null) { payload.put(APPC_LCM_TENANT_ID_FIELD, entry.getValue()); } else { - setErrorStatus("dcae onset is missing " + DCAE_TENANT_ID_FIELD); + setErrorStatus(DCAE_ONSET_MISSING + DCAE_TENANT_ID_FIELD); } break; default: @@ -646,11 +647,8 @@ public class AppcLcmOperation implements Operation, LockAdjunct.Requestor, Seria * @param result the value to store in the 'result' field */ void completeOperation(int attempt, String message, PolicyResult result) { - logger.debug("LCM: completeOperation(" - + "this.attempt=" + this.attempt - + ", attempt=" + attempt - + ", result=" + result - + ", message=" + message); + logger.debug("LCM: completeOperation(this.attempt={}, attempt={}, result={}, message ={})", + this.attempt, attempt, result, message); if (this.attempt == attempt) { // we need to verify that the attempt matches in order to reduce the // chances that we are reacting to a prior 'Response' message that -- cgit 1.2.3-korg