Fix request parameter building for sdnc resource 47/44047/1
authorsubhash kumar singh <subhash.kumar.singh@huawei.com>
Sat, 21 Apr 2018 12:36:39 +0000 (12:36 +0000)
committersubhash kumar singh <subhash.kumar.singh@huawei.com>
Sat, 21 Apr 2018 12:36:39 +0000 (12:36 +0000)
Fix request parameter building for sdnc resource

Change-Id: Ib87c08e31837ec9f2c10bcfe9ce7caccfb3f461e
Issue-ID: SO-422
Signed-off-by: subhash kumar singh <subhash.kumar.singh@huawei.com>
bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/resource/ResourceRequestBuilder.java
bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy

index d32a06d..7c3ea37 100644 (file)
@@ -123,7 +123,6 @@ public class ResourceRequestBuilder {
             throws SdcToscaParserException {
 
         Map<String, Object> resouceRequest = new HashMap<>();
-        List<Map<String, Object>> param = new ArrayList<>();
         String csarpath = null;
         try {
             csarpath = getCsarFromUuid(serviceUuid);
@@ -147,13 +146,9 @@ public class ResourceRequestBuilder {
                 Property property = resourceProperties.get(key);
 
                 Object value = getValue(property.getValue(), serviceInputs, serInput);
-                HashMap<String, Object> parameter = new HashMap<>();
-                parameter.put("name", key);
-                parameter.put("value", value);
-                param.add(parameter);
+                resouceRequest.put(key, value);
             }
         }
-        resouceRequest.put("param", param);
         return resouceRequest;
     }
 
index 63fab7d..ede76c0 100644 (file)
@@ -120,7 +120,23 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor {
             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)\r
         }\r
     }\r
-    \r
+\r
+    String customizeResourceParam(String netowrkInputParametersJson) {\r
+        List<Map<String, Object>> paramList = new ArrayList();\r
+        JSONObject jsonObject = new JSONObject(netowrkInputParametersJson);\r
+        Iterator iterator = jsonObject.keys();\r
+        while (iterator.hasNext()) {\r
+            String key = iterator.next();\r
+            HashMap<String, String> hashMap = new HashMap();\r
+            hashMap.put("name", key);\r
+            hashMap.put("value", jsonObject.get(key))\r
+            paramList.add(hashMap)\r
+        }\r
+        Map<String, List<Map<String, Object>>> paramMap = new HashMap();\r
+        paramMap.put("param", paramList);\r
+\r
+        return  new JSONObject(paramMap).toString();\r
+    }\r
     \r
     /**\r
      * Pre Process the BPMN Flow Request\r
@@ -158,7 +174,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor {
             String resourceInputPrameters = resourceInputObj.getResourceParameters()\r
             String netowrkInputParametersJson = jsonUtil.getJsonValue(resourceInputPrameters, "requestInputs")\r
             //here convert json string to xml string\r
-            String netowrkInputParameters = XML.toString(new JSONObject(netowrkInputParametersJson))\r
+            String netowrkInputParameters = XML.toString(new JSONObject(customizeResourceParam(netowrkInputParametersJson)))\r
             // 1. prepare assign topology via SDNC Adapter SUBFLOW call\r
             String sndcTopologyCreateRequest =\r
                     """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"\r