Update the policyName send to Policy
[clamp.git] / src / main / java / org / onap / clamp / clds / client / DcaeDispatcherServices.java
index 3d8d5d5..f285dc2 100644 (file)
@@ -25,6 +25,7 @@ package org.onap.clamp.clds.client;
 \r
 import com.att.eelf.configuration.EELFLogger;\r
 import com.att.eelf.configuration.EELFManager;\r
+import com.fasterxml.jackson.databind.node.ObjectNode;\r
 \r
 import java.io.BufferedReader;\r
 import java.io.DataOutputStream;\r
@@ -96,18 +97,16 @@ public class DcaeDispatcherServices {
             if (inStream != null) {\r
                 BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inStream));\r
                 String inputLine = null;\r
-                StringBuffer response = new StringBuffer();\r
+                StringBuilder response = new StringBuilder();\r
                 while ((inputLine = bufferedReader.readLine()) != null) {\r
                     response.append(inputLine);\r
                 }\r
                 responseStr = response.toString();\r
             }\r
 \r
-            if (responseStr != null) {\r
-                if (requestFailed) {\r
-                    logger.error("requestFailed - responseStr=" + responseStr);\r
-                    throw new BadRequestException(responseStr);\r
-                }\r
+            if (responseStr != null && requestFailed) {\r
+                logger.error("requestFailed - responseStr=" + responseStr);\r
+                throw new BadRequestException(responseStr);\r
             }\r
 \r
             logger.debug("response code " + responseCode);\r
@@ -237,7 +236,10 @@ public class DcaeDispatcherServices {
         Date startTime = new Date();\r
         LoggingUtils.setTargetContext("DCAE", "createNewDeployment");\r
         try {\r
-            String apiBodyString = "{\"serviceTypeId\": \"" + serviceTypeId + "\"}";\r
+            ObjectNode rootNode = (ObjectNode) refProp.getJsonTemplate("dcae.deployment.template");\r
+            ((ObjectNode) rootNode).put("serviceTypeId", serviceTypeId);\r
+            String apiBodyString = rootNode.toString();\r
+\r
             logger.info("Dcae api Body String - " + apiBodyString);\r
             String url = refProp.getStringValue("DCAE_DISPATCHER_URL") + "/dcae-deployments/" + deploymentId;\r
             logger.info("Dcae Dispatcher Service url - " + url);\r
@@ -270,7 +272,7 @@ public class DcaeDispatcherServices {
 \r
                 String inputLine = null;\r
 \r
-                StringBuffer response = new StringBuffer();\r
+                StringBuilder response = new StringBuilder();\r
 \r
                 while ((inputLine = in.readLine()) != null) {\r
                     response.append(inputLine);\r
@@ -279,11 +281,9 @@ public class DcaeDispatcherServices {
                 responseStr = response.toString();\r
             }\r
 \r
-            if (responseStr != null) {\r
-                if (requestFailed) {\r
-                    logger.error("requestFailed - responseStr=" + responseStr);\r
-                    throw new BadRequestException(responseStr);\r
-                }\r
+            if (responseStr != null && requestFailed) {\r
+                logger.error("requestFailed - responseStr=" + responseStr);\r
+                throw new BadRequestException(responseStr);\r
             }\r
 \r
             logger.debug("response code " + responseCode);\r