m2 sonar fix 05/109605/2
authorTaka Cho <takamune.cho@att.com>
Fri, 26 Jun 2020 15:35:12 +0000 (11:35 -0400)
committerTaka Cho <takamune.cho@att.com>
Fri, 26 Jun 2020 18:01:51 +0000 (14:01 -0400)
- "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 <takamune.cho@att.com>
controlloop/m2/appclcm/src/main/java/org/onap/policy/m2/appclcm/AppcLcmOperation.java

index 24f8ed5..cbd7413 100644 (file)
@@ -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<String, String> setCommonPayload(Map<String, String> aai) throws ControlLoopException {
         Map<String, String> payload = new HashMap<>();
-
         for (Map.Entry<String, String> 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