Fix UserInput Exception 11/70211/4
authorMarcus G K Williams <marcus.williams@intel.com>
Wed, 10 Oct 2018 23:50:52 +0000 (16:50 -0700)
committerMarcus Williams <marcus.williams@intel.com>
Thu, 11 Oct 2018 17:27:03 +0000 (17:27 +0000)
This change fixes processing of
UserInput in prepareCreateServiceInstance
which causes an exception if any user-input
is passed into createRequest.

Issue-ID: SO-1121
Change-Id: Iae8b158dfb8771d55607e09bdb18471358a2d9cd
Signed-off-by: Marcus G K Williams <marcus.williams@intel.com>
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateGenericALaCarteServiceInstance.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy
common/pom.xml

index 9686123..9763960 100755 (executable)
@@ -142,12 +142,37 @@ public class CreateGenericALaCarteServiceInstance extends AbstractServiceTaskPro
             Map<String, String> inputMap = [:]
             if (userParams) {
                 userParams.each {
-                    userParam -> inputMap.put(userParam.name, userParam.value.toString())
+                    userParam ->
+                        if ("Customer_Location".equals(userParam?.name)) {
+                            msoLogger.debug("User Input customerLocation: " + userParam.value.toString())
+                            Map<String, String> customerMap = [:]
+                            userParam.value.each {
+                                param ->
+
+                                    inputMap.put(param.key, param.value)
+                                    customerMap.put(param.key, param.value)
+                            }
+                            execution.setVariable("customerLocation", customerMap)
+                        }
+                        if ("Homing_Solution".equals(userParam?.name)) {
+                            msoLogger.debug("User Input Homing_Solution: " + userParam.value.toString())
+                            execution.setVariable("homingService", userParam.value)
+                            execution.setVariable("callHoming", true)
+                            inputMap.put("Homing_Solution", userParam.value)
+                        }
+                        if (!"Homing_Solution".equals(userParam?.name) && !"Customer_Location".equals(userParam?.name))
+                        {
+                            msoLogger.debug("User Input Parameter " + userParam.name + ": " + userParam.value.toString())
+                            inputMap.put(userParam.name, userParam.value)
+                        }
                 }
             }
 
             msoLogger.debug("User Input Parameters map: " + userParams.toString())
-            execution.setVariable("serviceInputParams", inputMap)
+            msoLogger.debug("User Input Map: " + inputMap.toString())
+            if (inputMap.toString() != "[:]") {
+                execution.setVariable("serviceInputParams", inputMap)
+            }
 
             //TODO
             //execution.setVariable("failExists", true)
@@ -231,7 +256,7 @@ public class CreateGenericALaCarteServiceInstance extends AbstractServiceTaskPro
      }
 
     public void processDecomposition(DelegateExecution execution) {
-        def isDebugEnabled = execution.getVariable(DebugFlag)
+        def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
 
         msoLogger.trace("Inside processDecomposition() of CreateGenericALaCarteServiceInstance  ")
 
@@ -241,7 +266,6 @@ public class CreateGenericALaCarteServiceInstance extends AbstractServiceTaskPro
 
             // VNFs
             List<VnfResource> vnfList = serviceDecomposition.getVnfResources()
-            filterVnfs(vnfList)
             serviceDecomposition.setVnfResources(vnfList)
 
             execution.setVariable("vnfList", vnfList)
@@ -290,18 +314,44 @@ public class CreateGenericALaCarteServiceInstance extends AbstractServiceTaskPro
              def jsonOutput = new JsonOutput()
              def siRequest = execution.getVariable("bpmnRequest")
              Map reqMap = jsonSlurper.parseText(siRequest)
+
              //InputParams
              def userParams = reqMap.requestDetails?.requestParameters?.userParams
+
              Map<String, String> inputMap = [:]
-             if (userParams != null) {
+             if (userParams) {
                  userParams.each {
-                     userParam -> inputMap.put(userParam.name, userParam.value)
+                     userParam ->
+                         if ("Customer_Location".equals(userParam?.name)) {
+                             msoLogger.debug("User Input customerLocation: " + userParam.value.toString())
+                             Map<String, String> customerMap = [:]
+                             userParam.value.each {
+                                 param ->
+
+                                     inputMap.put(param.key, param.value)
+                                     customerMap.put(param.key, param.value)
+                             }
+                             execution.setVariable("customerLocation", customerMap)
+                         }
+                         if ("Homing_Solution".equals(userParam?.name)) {
+                             msoLogger.debug("User Input Homing_Solution: " + userParam.value.toString())
+                             execution.setVariable("homingService", userParam.value)
+                             execution.setVariable("callHoming", true)
+                             inputMap.put("Homing_Solution", userParam.value)
+                         }
+                         if (!"Homing_Solution".equals(userParam?.name) && !"Customer_Location".equals(userParam?.name))
+                         {
+                             msoLogger.debug("User Input Parameter " + userParam.name + ": " + userParam.value.toString())
+                             inputMap.put(userParam.name, userParam.value)
+                         }
                  }
              }
 
              msoLogger.debug("User Input Parameters map: " + userParams.toString())
-             execution.setVariable("serviceInputParams", inputMap)
-
+             msoLogger.debug("User Input Map: " + inputMap.toString())
+             if (inputMap.toString() != "[:]") {
+                 execution.setVariable("serviceInputParams", inputMap)
+             }
              ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
 
              String serviceInstanceId = execution.getVariable("serviceInstanceId")
index c5f712c..beac679 100644 (file)
@@ -202,12 +202,15 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor {
                 userParams.each {
                                 userParam ->
                         if ("Customer_Location".equals(userParam?.name)) {
-                                    execution.setVariable("customerLocation", userParam.value)
-                                    userParam.value.each {
+                            Map<String, String> customerMap = [:]
+                            userParam.value.each {
                                 param ->
+
                                     inputMap.put(param.key, param.value)
+                                    customerMap.put(param.key, param.value)
                                     }
-                                }
+                            execution.setVariable("customerLocation", customerMap)
+                        }
                         if ("Homing_Model_Ids".equals(userParam?.name)) {
                             utils.log("DEBUG", "Homing_Model_Ids: " + userParam.value.toString() + "  ---- Type is:" +
                                     userParam.value.getClass() , isDebugEnabled)
index 285cd56..d8e71b0 100644 (file)
@@ -62,7 +62,7 @@
                <dependency>
                        <groupId>org.onap.aai.aai-common</groupId>
                        <artifactId>aai-schema</artifactId>
-                       <version>1.3.0-SNAPSHOT</version>
+                       <version>1.3.0</version>
                </dependency>
                <dependency>
                        <groupId>org.modelmapper</groupId>