Fix up request body of multicloud adapter body

Make some of the attributes json instead of json in a string.
Fixed up payload of request.

Change-Id: I7737fd19d44c8075bd7fef19068a72f8c0ec7e6d
Issue-ID: SO-1124
Signed-off-by: Eric Multanen <eric.w.multanen@intel.com>
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
index 051d813..3451b76 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
@@ -31,8 +31,6 @@
 import javax.ws.rs.core.UriBuilderException;
 import javax.ws.rs.core.Response;
 
-import org.onap.so.db.catalog.beans.CloudIdentity;
-import org.onap.so.utils.CryptoUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.onap.so.adapters.vdu.CloudInfo;
@@ -64,6 +62,8 @@
 import org.springframework.http.MediaType;
 import org.springframework.stereotype.Component;
 
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.woorea.openstack.heat.model.CreateStackParam;
 
@@ -173,35 +173,20 @@
         CreateStackParam stack = createStackParam(stackName, heatTemplate, stackInputs, timeoutMinutes, environment, files, heatFiles);
 
         MulticloudRequest multicloudRequest= new MulticloudRequest();
-        HttpEntity<MulticloudRequest> request = null;
 
         try {
             multicloudRequest.setGenericVnfId(genericVnfId);
             multicloudRequest.setVfModuleId(vfModuleId);
-            multicloudRequest.setOofDirectives(oofDirectives);
-            multicloudRequest.setSdncDirectives(sdncDirectives);
+            multicloudRequest.setOofDirectives(JSON_MAPPER.readTree(oofDirectives));
+            multicloudRequest.setSdncDirectives(JSON_MAPPER.readTree(sdncDirectives));
             multicloudRequest.setTemplateType(templateType);
             if (logger.isDebugEnabled()) {
                 logger.debug(String.format("Stack Template Data is: %s", stack.toString().substring(16)));
             }
-            multicloudRequest.setTemplateData(JSON_MAPPER.writeValueAsString(stack));
+            multicloudRequest.setTemplateData(stack);
             if (logger.isDebugEnabled()) {
                 logger.debug(String.format("Multicloud Request is: %s", multicloudRequest.toString()));
             }
-
-            CloudSite cloudSite = cloudConfig.getCloudSite(cloudSiteId).orElseThrow(() ->
-                    new MsoCloudSiteNotFound(cloudSiteId));
-            CloudIdentity cloudIdentity = cloudSite.getIdentityService();
-            HttpHeaders headers = new HttpHeaders();
-            headers.set ("X-Auth-User", cloudIdentity.getMsoId ());
-            headers.set ("X-Auth-Key", CryptoUtils.decryptCloudConfigPassword(cloudIdentity.getMsoPass ()));
-            headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON.toString());
-            headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON.toString());
-
-            if (logger.isDebugEnabled()) {
-                logger.debug(String.format("Multicloud Request Headers: %s", headers.toString()));
-            }
-            request = new HttpEntity<>(multicloudRequest, headers);
         } catch (Exception e) {
             logger.debug("ERROR making multicloud JSON body ", e);
         }
@@ -211,7 +196,7 @@
         }
         RestClient multicloudClient = getMulticloudClient(multicloudEndpoint);
 
-        Response response = multicloudClient.post(request);
+        Response response = multicloudClient.post(multicloudRequest);
 
         StackInfo createInfo = new StackInfo();
         createInfo.setName(stackName);
@@ -609,7 +594,7 @@
     private RestClient getMulticloudClient(String endpoint) {
         RestClient client = null;
         try {
-            client= new HttpClient(UriBuilder.fromUri(endpoint).build().toURL(),
+            client = new HttpClient(UriBuilder.fromUri(endpoint).build().toURL(),
                     MediaType.APPLICATION_JSON.toString(), TargetEntity.MULTICLOUD);
         } catch (MalformedURLException e) {
             logger.debug(String.format("Encountered malformed URL error getting multicloud rest client %s", e.getMessage()));
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java
index fefc095..4204813 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java
@@ -24,6 +24,9 @@
 import com.fasterxml.jackson.annotation.JsonInclude;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.woorea.openstack.heat.model.CreateStackParam;
+
 import org.apache.commons.lang.builder.ToStringBuilder;
 
 @JsonInclude(JsonInclude.Include.NON_NULL)
@@ -43,13 +46,13 @@
     @JsonProperty("vf-module-id")
     private String vfModuleId;
     @JsonProperty("oof_directives")
-    private String oofDirectives;
+    private JsonNode oofDirectives;
     @JsonProperty("sdnc_directives")
-    private String sdncDirectives;
+    private JsonNode sdncDirectives;
     @JsonProperty("template_type")
     private String templateType;
     @JsonProperty("template_data")
-    private String templateData;
+    private CreateStackParam templateData;
 
 
     @JsonProperty("generic-vnf-id")
@@ -73,22 +76,22 @@
     }
 
     @JsonProperty("oof_directives")
-    public String getOofDirectives() {
+    public JsonNode getOofDirectives() {
         return oofDirectives;
     }
 
     @JsonProperty("oof_directives")
-    public void setOofDirectives(String oofDirectives) {
+    public void setOofDirectives(JsonNode oofDirectives) {
         this.oofDirectives = oofDirectives;
     }
 
     @JsonProperty("sdnc_directives")
-    public String getSdncDirectives() {
+    public JsonNode getSdncDirectives() {
         return sdncDirectives;
     }
 
     @JsonProperty("sdnc_directives")
-    public void setSdncDirectives(String sdncDirectives) {
+    public void setSdncDirectives(JsonNode sdncDirectives) {
         this.sdncDirectives = sdncDirectives;
     }
 
@@ -103,12 +106,12 @@
     }
 
     @JsonProperty("template_data")
-    public String getTemplateData() {
+    public CreateStackParam getTemplateData() {
         return templateData;
     }
 
     @JsonProperty("template_data")
-    public void setTemplateData(String templateData) {
+    public void setTemplateData(CreateStackParam templateData) {
         this.templateData = templateData;
     }