Merge "Update parameter parsing of SDNC LCM client"
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilder.java
index 0f17c54..333bf80 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilder.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilder.java
@@ -48,8 +48,6 @@
         try {
             String path = sdncLcmProperties.getPath() + operation;
             pathUri = new URI(path);
-            logger.debug("SDNC host: " + sdncLcmProperties.getHost());
-            logger.debug("SDNC API path: " + pathUri.getPath());
         } catch (Exception e) {
             String msg = "Error API path syntax: ";
             logger.error(msg, e);
@@ -57,9 +55,7 @@
         }
 
         try {
-            SDNCLcmRestClient sdncLcmRestClient = new SDNCLcmRestClient(sdncLcmProperties, pathUri);
-            logger.debug("Create SDNCLcmRestClient success");
-            return sdncLcmRestClient;
+            return new SDNCLcmRestClient(sdncLcmProperties, pathUri);
         } catch (Exception e) {
             String msg = "Create SDNCLcmRestClient failure: ";
             logger.error(msg, e);
@@ -69,9 +65,7 @@
 
     public SDNCLcmDmaapClient newSDNCLcmDmaapClient() throws SDNCLcmClientBuilderException {
         try {
-            SDNCLcmDmaapClient sdncLcmDmaapClient = new SDNCLcmDmaapClient(sdncLcmProperties);
-            logger.debug("Create SDNCLcmDmaapClient success");
-            return sdncLcmDmaapClient;
+            return new SDNCLcmDmaapClient(sdncLcmProperties);
         } catch (Exception e) {
             String msg = "Create SDNCLcmDmaapClient failure: ";
             logger.error(msg, e);
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmMessageBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmMessageBuilder.java
index bf1229a..4ea6850 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmMessageBuilder.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmMessageBuilder.java
@@ -26,7 +26,7 @@
 
 public class SDNCLcmMessageBuilder {
 
-    public static LcmFlags getSDNCFlags() {
+    public static LcmFlags buildLcmFlags() {
         LcmFlags lcmFlags = new LcmFlags();
 
         lcmFlags.setMode(SDNCConstants.LCM_FLAGS_MODE_NORMAL);
@@ -43,7 +43,7 @@
         lcmCommonHeader.setOriginatorId(SDNCConstants.SYSTEM_NAME);
         lcmCommonHeader.setRequestId(requestId);
         lcmCommonHeader.setSubRequestId(subRequestId);
-        lcmCommonHeader.setFlags(getSDNCFlags());
+        lcmCommonHeader.setFlags(buildLcmFlags());
         lcmCommonHeader.setTimestamp(Instant.now().toString());
 
         return lcmCommonHeader;
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmFlags.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmFlags.java
index 36527ec..55e0ea3 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmFlags.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmFlags.java
@@ -35,7 +35,7 @@
     private String force;
 
     @JsonProperty("ttl")
-    private int ttl;
+    private Integer ttl;
 
     public String getMode() {
         return mode;
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmStatus.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmStatus.java
index 8a2a142..3bbafca 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmStatus.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/LcmStatus.java
@@ -29,16 +29,16 @@
 public class LcmStatus {
 
     @JsonProperty(value = "code", required = true)
-    private int code;
+    private Integer code;
 
     @JsonProperty(value = "message", required = true)
     private String message;
 
-    public int getCode() {
+    public Integer getCode() {
         return code;
     }
 
-    public void setCode(int value) {
+    public void setCode(Integer value) {
         this.code = value;
     }
 
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/SwToBeDownloadedElement.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/SwToBeDownloadedElement.java
index 1a3529d..05de9b1 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/SwToBeDownloadedElement.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/SwToBeDownloadedElement.java
@@ -32,7 +32,7 @@
     private String swLocation;
 
     @JsonProperty(value = "swFileSize")
-    private long swFileSize;
+    private Long swFileSize;
 
     @JsonProperty(value = "swFileCompression")
     private String swFileCompression;
@@ -48,11 +48,11 @@
         this.swLocation = value;
     }
 
-    public long getSwFileSize() {
+    public Long getSwFileSize() {
         return swFileSize;
     }
 
-    public void setSwFileSize(long value) {
+    public void setSwFileSize(Long value) {
         this.swFileSize = value;
     }
 
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayloadTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayloadTest.java
index f9fa679..b99d45a 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayloadTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayloadTest.java
@@ -37,7 +37,7 @@
         SwToBeDownloadedElement swToBeDownloadedElement = new SwToBeDownloadedElement();
 
         swToBeDownloadedElement.setSwLocation("http://192.168.1.20/test.zip");
-        swToBeDownloadedElement.setSwFileSize(123456);
+        swToBeDownloadedElement.setSwFileSize(123456L);
         swToBeDownloadedElement.setSwFileCompression("ZIP");
         swToBeDownloadedElement.setSwFileFormat("binary");
 
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDE.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDE.java
index ed865e0..8499b6f 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDE.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDE.java
@@ -26,7 +26,6 @@
 import com.fasterxml.jackson.databind.ObjectMapper;
 import org.springframework.stereotype.Component;
 import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.onap.so.bpmn.core.json.JsonUtils;
 import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
 import org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.common.SoPropertyConstants;
 import org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.LcmControllerDE;
@@ -102,13 +101,14 @@
     }
 
     private LcmOutput selectLcmOutputFromDmaapResponses(List<LcmDmaapResponse> lcmDmaapResponses, LcmInput lcmInput) {
-        String expectedCorrelationId =
-                lcmInput.getCommonHeader().getRequestId() + "-" + lcmInput.getCommonHeader().getSubRequestId();
+        String requestId = lcmInput.getCommonHeader().getRequestId();
+        String subRequestId = lcmInput.getCommonHeader().getSubRequestId();
 
         for (LcmDmaapResponse lcmDmaapResponse : lcmDmaapResponses) {
-            String correlationId = lcmDmaapResponse.getCorrelationId();
-            if (expectedCorrelationId.equals(correlationId)) {
-                return lcmDmaapResponse.getBody().getOutput();
+            LcmOutput lcmOutput = lcmDmaapResponse.getBody().getOutput();
+            if (requestId.equals(lcmOutput.getCommonHeader().getRequestId())
+                    && subRequestId.equals(lcmOutput.getCommonHeader().getSubRequestId())) {
+                return lcmOutput;
             }
         }
 
@@ -204,15 +204,13 @@
                 return null;
         }
 
-        logger.debug("SDNC LCM payload for {}: {}", lcmAction, lcmPayload);
-
         String subRequestId = UUID.randomUUID().toString();
         LcmInput lcmInput =
                 SDNCLcmMessageBuilder.buildLcmInputForPnf(requestId, subRequestId, pnfName, lcmAction, lcmPayload);
 
         ObjectMapper mapper = new ObjectMapper();
         String lcmInputMsg = mapper.writeValueAsString(lcmInput);
-        logger.debug("SDNC input message:\n" + lcmInputMsg);
+        logger.debug("SDNC input message for {}: {}", lcmAction, lcmInputMsg);
 
         return lcmInput;
     }
@@ -224,27 +222,16 @@
         }
 
         LcmStatus lcmStatus = lcmOutput.getStatus();
+        String outputPayload = lcmOutput.getPayload();
+        logger.debug("SDNC LCM output payload of action {}: {}", lcmAction, outputPayload);
 
         if (lcmStatus.getCode() == SDNCConstants.LCM_OUTPUT_SUCCESS_CODE) {
-            logger.debug("Call SDNC LCM API success: " + lcmStatus.getMessage());
+            logger.debug("Call SDNC LCM API for {} success, message: {}", lcmAction, lcmStatus.getMessage());
+            return true;
         } else {
-            logger.error("Call SDNC LCM API failure: " + lcmStatus.getMessage());
+            logger.error("Call SDNC LCM API for {} failure, message: {}", lcmAction, lcmStatus.getMessage());
+            return false;
         }
-
-        String outputPayload = lcmOutput.getPayload();
-        logger.debug("SDNC LCM action: {}, result: {}", lcmAction, outputPayload);
-        if (outputPayload != null) {
-            String result = JsonUtils.getJsonValue(outputPayload, "result");
-            if ("Success".equals(result)) {
-                logger.debug("Run SDNC LCM action {} success", lcmAction);
-                return true;
-            } else {
-                String reason = JsonUtils.getJsonValue(outputPayload, "reason");
-                logger.error("Run SDNC LCM action {} failure, reason: {}", lcmAction, reason);
-            }
-        }
-
-        return false;
     }
 
     private boolean sendLcmRequest(DelegateExecution execution, LcmInput lcmInput) {