From cbea6d143050276e024fc710450a028afc7a102f Mon Sep 17 00:00:00 2001 From: Marcus G K Williams Date: Wed, 10 Oct 2018 16:50:52 -0700 Subject: Fix UserInput Exception 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 --- .../CreateGenericALaCarteServiceInstance.groovy | 66 +++++++++++++++++++--- .../vcpe/scripts/CreateVcpeResCustService.groovy | 9 ++- 2 files changed, 64 insertions(+), 11 deletions(-) (limited to 'bpmn') diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateGenericALaCarteServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateGenericALaCarteServiceInstance.groovy index 968612301d..9763960bfd 100755 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateGenericALaCarteServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateGenericALaCarteServiceInstance.groovy @@ -142,12 +142,37 @@ public class CreateGenericALaCarteServiceInstance extends AbstractServiceTaskPro Map 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 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 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 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 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") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy index c5f712cafc..beac679691 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy @@ -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 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) -- cgit 1.2.3-korg