aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYulian Han <elaine.hanyulian@huawei.com>2018-04-09 15:40:45 +0800
committerSeshu Kumar M <seshu.kumar.m@huawei.com>2018-04-10 05:30:08 +0000
commit34318cf179ed6aa372f21a327d5a730a008708d6 (patch)
treeda8a4832f98dd44eb6fb8bf19df4f992304f8b42
parent955768f7bf4520fb8b9120121251f9537b260db6 (diff)
Modify in params pre-processing in groovy
Change-Id: Idaa55084f5ecb0dd3636c232cebc14fa5f064600 Issue-ID: SO-565 Signed-off-by: Yulian Han <elaine.hanyulian@huawei.com>
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CompareModelofE2EServiceInstance.groovy69
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCompareModelVersions.groovy4
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy10
3 files changed, 50 insertions, 33 deletions
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CompareModelofE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CompareModelofE2EServiceInstance.groovy
index c70c971bc7..3652d56303 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CompareModelofE2EServiceInstance.groovy
+++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CompareModelofE2EServiceInstance.groovy
@@ -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)
}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCompareModelVersions.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCompareModelVersions.groovy
index a49a0664e8..77b0657514 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCompareModelVersions.groovy
+++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCompareModelVersions.groovy
@@ -149,7 +149,7 @@ public class DoCompareModelVersions extends AbstractServiceTaskProcessor {
"modelUuid":"${modelUuid}",
"modelVersion":""
}"""
- execution.setVariable("serviceModelInfo", serviceModelInfo)
+
execution.setVariable("serviceModelInfo_Target", serviceModelInfo)
utils.log("DEBUG", " ***** Completed prepareDecomposeService_Target of update generic e2e service ***** ", isDebugEnabled)
@@ -187,7 +187,7 @@ public class DoCompareModelVersions extends AbstractServiceTaskProcessor {
"modelUuid":"${modelUuid}",
"modelVersion":""
}"""
- execution.setVariable("serviceModelInfo", serviceModelInfo)
+
execution.setVariable("serviceModelInfo_Original", serviceModelInfo)
utils.log("DEBUG", " ***** Completed prepareDecomposeService_Original of update generic e2e service ***** ", isDebugEnabled)
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy
index 30db8c53eb..0172402185 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy
+++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy
@@ -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()