Modify in params pre-processing in groovy 87/41687/2
authorYulian Han <elaine.hanyulian@huawei.com>
Mon, 9 Apr 2018 07:40:45 +0000 (15:40 +0800)
committerSeshu Kumar M <seshu.kumar.m@huawei.com>
Tue, 10 Apr 2018 05:30:08 +0000 (05:30 +0000)
Change-Id: Idaa55084f5ecb0dd3636c232cebc14fa5f064600
Issue-ID: SO-565
Signed-off-by: Yulian Han <elaine.hanyulian@huawei.com>
bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CompareModelofE2EServiceInstance.groovy
bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCompareModelVersions.groovy
bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy

index c70c971..3652d56 100644 (file)
@@ -101,32 +101,49 @@ public class CompareModelofE2EServiceInstance extends AbstractServiceTaskProcess
                        if (isBlank(serviceInstanceId)) {
                                msg = "Input serviceInstanceId' is null"
                                exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
-                       }       
-
-                       /*
-                        * Extracting User Parameters from incoming Request and converting into a Map
-                        */
-                       def jsonSlurper = new JsonSlurper()
-                       def jsonOutput = new JsonOutput()
-       
-                       Map reqMap = jsonSlurper.parseText(siRequest)
-       
-                       //InputParams
-                       def userParams = reqMap.requestDetails?.requestParameters?.userParams
-       
-                       Map<String, String> inputMap = [:]
-                       if (userParams) {
-                               userParams.each {
-                                       userParam -> inputMap.put(userParam.name, userParam.value.toString())
-                               }
                        }
-                       execution.setVariable("operationType", "CompareModel") 
                        
-                       utils.log("DEBUG", "User Input Parameters map: " + userParams.toString(), isDebugEnabled)
-                       execution.setVariable("serviceInputParams", inputMap)
-       
-               } catch (BpmnError e) {
-                       throw e;
+                       //subscriberInfo
+                       String globalSubscriberId = jsonUtil.getJsonValue(siRequest, "globalSubscriberId")
+                       if (isBlank(globalSubscriberId)) {
+                               msg = "Input globalSubscriberId' is null"
+                               utils.log("INFO", msg, isDebugEnabled)
+                       } else {
+                               execution.setVariable("globalSubscriberId", globalSubscriberId)
+                       }
+                       
+                       //subscriptionServiceType
+                       String subscriptionServiceType = jsonUtil.getJsonValue(siRequest, "serviceType")
+                       if (isBlank(subscriptionServiceType)) {
+                               msg = "Input subscriptionServiceType is null"
+                               utils.log("DEBUG", msg, isDebugEnabled)
+                               exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+                       } else {
+                               execution.setVariable("serviceType", subscriptionServiceType)
+                       }
+                       
+                       //modelInvariantIdTarget
+                       String modelInvariantIdTarget = jsonUtil.getJsonValue(siRequest, "modelInvariantIdTarget")
+                       if (isBlank(modelInvariantIdTarget)) {
+                               msg = "Input modelInvariantIdTarget' is null"
+                               utils.log("INFO", msg, isDebugEnabled)
+                               exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+                       } else {
+                               execution.setVariable("modelInvariantIdTarget", modelInvariantIdTarget)
+                       }
+                       
+                       //modelVersionIdTarget
+                       String modelVersionIdTarget = jsonUtil.getJsonValue(siRequest, "modelVersionIdTarget")
+                       if (isBlank(modelVersionIdTarget)) {
+                               msg = "Input modelVersionIdTarget is null"
+                               utils.log("DEBUG", msg, isDebugEnabled)
+                               exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+                       } else {
+                               execution.setVariable("modelVersionIdTarget", modelVersionIdTarget)
+                       }
+
+                       execution.setVariable("operationType", "CompareModel")  
+
                } catch (Exception ex){
                        msg = "Exception in preProcessRequest " + ex.getMessage()
                        utils.log("INFO", msg, isDebugEnabled)
@@ -143,13 +160,13 @@ public class CompareModelofE2EServiceInstance extends AbstractServiceTaskProcess
                        CompareModelsResult compareModelsResult = execution.getVariable("compareModelsResult")
                        
                        // RESTResponse (for API Handler(APIH) Reply Task)
-                       String syncResponse = compareModelsResult.toString()
+                       String syncResponse = compareModelsResult.toJsonStringNoRootName()
                        utils.log("INFO", " sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse, isDebugEnabled)
                        sendWorkflowResponse(execution, 202, syncResponse)
 
                } catch (Exception ex) {
                        String msg  = "Exception in sendSyncResponse: " + ex.getMessage()
-                       exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
+                       exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
                }
                utils.log("INFO"," ***** Exit sendSyncResopnse *****",  isDebugEnabled)
        }
index a49a066..77b0657 100644 (file)
@@ -149,7 +149,7 @@ public class DoCompareModelVersions extends AbstractServiceTaskProcessor {
             "modelUuid":"${modelUuid}",\r
             "modelVersion":""\r
              }"""\r
-            execution.setVariable("serviceModelInfo", serviceModelInfo)\r
+            \r
             execution.setVariable("serviceModelInfo_Target", serviceModelInfo)\r
 \r
             utils.log("DEBUG", " ***** Completed prepareDecomposeService_Target of update generic e2e service ***** ", isDebugEnabled)\r
@@ -187,7 +187,7 @@ public class DoCompareModelVersions extends AbstractServiceTaskProcessor {
             "modelUuid":"${modelUuid}",\r
             "modelVersion":""\r
              }"""\r
-            execution.setVariable("serviceModelInfo", serviceModelInfo)\r
+            \r
             execution.setVariable("serviceModelInfo_Original", serviceModelInfo)\r
 \r
             utils.log("DEBUG", " ***** Completed prepareDecomposeService_Original of update generic e2e service ***** ", isDebugEnabled)\r
index 30db8c5..0172402 100644 (file)
@@ -34,6 +34,7 @@ import org.openecomp.mso.bpmn.common.scripts.AaiUtil
 import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
 import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils
+import org.openecomp.mso.bpmn.common.resource.ResourceRequestBuilder
 import org.openecomp.mso.bpmn.core.RollbackData
 import org.openecomp.mso.bpmn.core.WorkflowException
 import org.openecomp.mso.rest.APIResponse;
@@ -84,13 +85,12 @@ public class DoCompareModelofE2EServiceInstance extends AbstractServiceTaskProce
        JsonUtils jsonUtil = new JsonUtils()
 
        public void preProcessRequest (DelegateExecution execution) {
-               execution.setVariable("isDebugLogEnabled","true")
 
                def method = getClass().getSimpleName() + '.preProcessRequest(' +'execution=' + execution.getId() +')'
                def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
                utils.log("INFO","Entered " + method, isDebugEnabled)
                String msg = ""
-               utils.log("INFO"," ***** Enter CompareModelofE2EServiceInstance preProcessRequest *****",  isDebugEnabled)
+               utils.log("INFO"," ***** Enter DoCompareModelofE2EServiceInstance preProcessRequest *****",  isDebugEnabled)
 
                execution.setVariable("prefix", Prefix)
                //Inputs
@@ -121,14 +121,14 @@ public class DoCompareModelofE2EServiceInstance extends AbstractServiceTaskProce
                        exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
                }
 
-               String modelInvariantUuid = execution.getVariable('modelInvariantIdTarget')
+               String modelInvariantUuid = execution.getVariable("modelInvariantIdTarget")
                if (isBlank(modelInvariantUuid)){
                        msg = "Input modelInvariantUuid is null"
                        utils.log("INFO", msg, isDebugEnabled)
                        exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
                }
 
-               String modelUuid = execution.getVariable('modelVersionIdTarget')
+               String modelUuid = execution.getVariable("modelVersionIdTarget")
                if (isBlank(modelUuid)){
                        msg = "Input modelUuid is null"
                        utils.log("INFO", msg, isDebugEnabled)
@@ -238,7 +238,7 @@ public class DoCompareModelofE2EServiceInstance extends AbstractServiceTaskProce
                        requestInputs.addAll(resourceParameters.keySet())                       
                }
                
-               for(Resource rc : deletedResourceList) {
+               for(Resource rc : delResourceList) {
                        mi = rc.getModelInfo()
                        String resourceCustomizationUuid = mi.getModelCustomizationUuid()
                        ResourceModelInfo rmodel = new ResourceModelInfo()