From 42e2d3904b8a7f7b98740344b504439852b68c0c Mon Sep 17 00:00:00 2001
From: Zhuoyao Huang <10112215@zte.com.cn>
Date: Tue, 9 Apr 2019 20:46:05 +0800
Subject: Service instance modification
extend update interface for service instance modification on CCVPN use case extension
Issue-ID: SO-1393
Change-Id: Ib21843be32738de0197185906ba38c61f1095f24
Signed-off-by: Zhuoyao Huang <10112215@zte.com.cn>
---
.../scripts/DoCompareServiceInstanceData.groovy | 270 ++++++++++++++++++
.../scripts/UpdateCustomE2EServiceInstance.groovy | 1 +
.../DoCompareServiceInstanceDataTest.groovy | 301 +++++++++++++++++++++
3 files changed, 572 insertions(+)
create mode 100644 bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareServiceInstanceData.groovy
create mode 100644 bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareServiceInstanceDataTest.groovy
(limited to 'bpmn/so-bpmn-infrastructure-common')
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareServiceInstanceData.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareServiceInstanceData.groovy
new file mode 100644
index 0000000000..a1f68f9b06
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareServiceInstanceData.groovy
@@ -0,0 +1,270 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.bpmn.infrastructure.scripts
+
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.ServiceInstance
+import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.onap.so.bpmn.common.scripts.ExceptionUtil
+import org.onap.so.bpmn.core.domain.Resource
+import org.onap.so.bpmn.core.domain.ServiceDecomposition
+import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.bpmn.infrastructure.workflow.service.ServicePluginFactory
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+/**
+ * This groovy class supports the DoCompareServiceInstanceData.bpmn process.
+ *
+ * Inputs:
+ * @param - serviceInstanceData-original
+ * @param - serviceInstanceId
+ * @param - uuiRequest
+ * @param - model-invariant-id-original
+ * @param - model-version-id-original
+ * @param - msoRequestId
+ * @param - isDebugLogEnabled
+ *
+ * Outputs:
+ * @param - addResourceList
+ * @param - delResourceList
+ * @param - uuiRequest-add
+ * @param - uuiRequest-del
+ *
+ */
+public class DoCompareServiceInstanceData extends AbstractServiceTaskProcessor {
+
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+ JsonUtils jsonUtil = new JsonUtils()
+ private static final Logger logger = LoggerFactory.getLogger( DoCompareServiceInstanceData.class);
+
+ public void preProcessRequest (DelegateExecution execution) {
+ def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
+ logger.info("INFO"," ***** preProcessRequest *****", isDebugEnabled)
+ try {
+ checkInput("serviceInstanceData-original", execution, isDebugEnabled)
+ checkInput("serviceInstanceId", execution, isDebugEnabled)
+ checkInput("uuiRequest", execution, isDebugEnabled)
+ checkInput("model-invariant-id-original", execution, isDebugEnabled)
+ checkInput("model-version-id-original", execution, isDebugEnabled)
+ checkInput("msoRequestId", execution, isDebugEnabled)
+ } catch (Exception ex){
+ String msg = "Exception in preProcessRequest " + ex.getMessage()
+ logger.info("INFO", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.info("INFO"," ***** Exit preProcessRequest *****", isDebugEnabled)
+ }
+
+ private void checkInput(String inputName, DelegateExecution execution, isDebugEnabled) {
+ String msg
+ Object inputValue = execution.getVariable(inputName)
+ if (inputValue == null) {
+ msg = "Input" + inputName + "is null"
+ logger.info("INFO", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ }
+ }
+
+
+ public void prepareDecomposeService_Original(DelegateExecution execution) {
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
+
+ try {
+ logger.debug( " ***** Inside prepareDecomposeService_Original of update generic e2e service ***** ")
+ String modelInvariantUuid = execution.getVariable("model-invariant-id-original")
+ String modelUuid = execution.getVariable("model-version-id-original")
+ //here modelVersion is not set, we use modelUuid to decompose the service.
+ String serviceModelInfo = """{
+ "modelInvariantUuid":"${modelInvariantUuid}",
+ "modelUuid":"${modelUuid}",
+ "modelVersion":""
+ }"""
+
+ execution.setVariable("serviceModelInfo_Original", serviceModelInfo)
+
+ logger.debug( " ***** Completed prepareDecomposeService_Original of update generic e2e service ***** ")
+ } catch (Exception ex) {
+ // try error in method block
+ String exceptionMessage = "Bpmn error encountered in update generic e2e service flow. Unexpected Error from method prepareDecomposeService_Original() - " + ex.getMessage()
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
+ }
+ }
+
+ public void processDecomposition_Original(DelegateExecution execution) {
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
+
+ logger.debug( " ***** Inside processDecomposition_Original() of update generic e2e service flow ***** ")
+ try {
+ ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
+ execution.setVariable("serviceDecomposition_Original", serviceDecomposition)
+ } catch (Exception ex) {
+ String exceptionMessage = "Bpmn error encountered in update generic e2e service flow. processDecomposition_Original() - " + ex.getMessage()
+ logger.debug( exceptionMessage)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
+ }
+ }
+
+ public void doCompareUuiRquestInput(DelegateExecution execution) {
+
+ def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
+ logger.info("INFO", "======== Start doCompareUuiRquestInput Process ======== ", isDebugEnabled)
+
+ String uuiRequest_Target = execution.getVariable("uuiRequest")
+ Map serviceParametersObject_Target = getServiceParametersObject(uuiRequest_Target)
+ Map serviceRequestInputs_Target = (Map) serviceParametersObject_Target.get("requestInputs")
+ List