Fixed bug to parse json userParams array 13/20413/1
authorShailendra Borale <sb8915@att.com>
Tue, 24 Oct 2017 18:41:30 +0000 (14:41 -0400)
committerShailendra Borale <sb8915@att.com>
Tue, 24 Oct 2017 18:41:30 +0000 (14:41 -0400)
BPMN request - userParams is an array of maps, rather than a map.
Each map has name and value elements.
Changed code to parse the array correctly.

Change-Id: Ie06ba22b03fa5c5ceb103c42daa3bbf7e6e252db
Issue-Id: SO-262
Signed-off-by: Shailendra Borale <sb8915@att.com>
bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy
bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/request.json
bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/requestNoSIName.json
bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/requestNoSINameNoRollback.json
bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/request.json

index 87cf6fb..fc6293c 100644 (file)
@@ -156,29 +156,33 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor {
                        execution.setVariable("subscriberInfo", subscriberInfo)\r
                        utils.log("DEBUG", "Incoming subscriberInfo is: " + subscriberInfo, isDebugEnabled)\r
 \r
-                 /*
-                 * Extracting User Parameters from incoming Request and converting into a Map
-                 */
-                 def jsonSlurper = new JsonSlurper()
-                 def jsonOutput = new JsonOutput()
+                 /*\r
+                 * Extracting User Parameters from incoming Request and converting into a Map\r
+                 */\r
+                 def jsonSlurper = new JsonSlurper()\r
+                 def jsonOutput = new JsonOutput()\r
+\r
+                 Map reqMap = jsonSlurper.parseText(createVcpeServiceRequest)\r
+\r  
+                 //InputParams\r
+                 def userParams = reqMap.requestDetails?.requestParameters?.userParams\r
   
-                 Map reqMap = jsonSlurper.parseText(createVcpeServiceRequest)
-  
-                 //InputParams
-                 def userParams = reqMap.requestDetails?.requestParameters?.userParams
-  
-                 Map<String, String> inputMap = [:]
-                 if (userParams) {
-                         userParams.each {
-                                 name, value -> inputMap.put(name, value)
-                                       if (name.equals("BRG_WAN_MAC_Address"))
-                                                       execution.setVariable("brgWanMacAddress", value)\r
-                         }
-                 }
-
-                 utils.log("DEBUG", "User Input Parameters map: " + userParams.toString(), isDebugEnabled)
-                 execution.setVariable("serviceInputParams", inputMap)
-
+                 Map<String, String> inputMap = [:]\r
+\r
+\r
+                 if (userParams) {\r
+                               userParams.each {\r
+                                                               userParam ->\r
+                                                               if("BRG_WAN_MAC_Address".equals(userParam?.name)) {\r
+                                                                                               execution.setVariable("brgWanMacAddress", userParam.value)\r
+                                                                                               inputMap.put("BRG_WAN_MAC_Address", userParam.value)\r
+                                       }\r
+                               }\r
+                 }\r
+\r
+                 utils.log("DEBUG", "User Input Parameters map: " + userParams.toString(), isDebugEnabled)\r
+                 execution.setVariable("serviceInputParams", inputMap)\r
+\r
                        utils.log("DEBUG", "Incoming brgWanMacAddress is: " + execution.getVariable('brgWanMacAddress'), isDebugEnabled)\r
 \r
                        //For Completion Handler & Fallout Handler\r
index dc4669e..a0168bd 100644 (file)
                                        "subscriptionServiceType":"123456789",
                                        "aLaCarte":"false",
                                        "userParams":
-                                               {
-                                                       "BRG_WAN_MAC_Address" : "brgmac"
-                                               }
+                                          [
+                                               {
+                                                       "name":"BRG_WAN_MAC_Address",
+                                                       "value":"brgmac"
+                                               }
+                                          ]
                                }
                                
                }
index dc9ac49..17c6d15 100644 (file)
                                {
                                        "subscriptionServiceType":"123456789",
                                        "aLaCarte":"false",
-                                       "userParams":
-                                               {
-                                                       "BRG_WAN_MAC_Address" : "brgmac"
-                                               }
+                    "userParams":
+                       [
+                            {
+                                "name":"BRG_WAN_MAC_Address",
+                                "value":"brgmac"
+                            }
+                       ]
                                }
                                
                }
index d5b0713..8583e66 100644 (file)
                                {
                                        "subscriptionServiceType":"123456789",
                                        "aLaCarte":"false",
-                                       "userParams":
-                                               {
-                                                       "BRG_WAN_MAC_Address" : "brgmac"
-                                               }
+                    "userParams":
+                       [
+                            {
+                                "name":"BRG_WAN_MAC_Address",
+                                "value":"brgmac"
+                            }
+                       ]
                                }
                                
                }
index dc4669e..99941c9 100644 (file)
                                {
                                        "subscriptionServiceType":"123456789",
                                        "aLaCarte":"false",
-                                       "userParams":
-                                               {
-                                                       "BRG_WAN_MAC_Address" : "brgmac"
-                                               }
+                    "userParams":
+                       [
+                            {
+                                "name":"BRG_WAN_MAC_Address",
+                                "value":"brgmac"
+                            }
+                       ]
                                }
                                
                }