summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-common/src
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src')
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/HandleOrchestrationTask.groovy127
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationService.groovy438
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceService.groovy587
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CheckServiceProcessStatus.groovy333
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy678
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy109
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy513
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVnfInfra.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy460
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy259
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleInfra.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy338
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy771
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateCommunicationService.groovy210
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy3
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy4
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy230
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy524
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy22
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy5
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy3
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy824
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy308
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy320
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy5
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy5
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleE2EServiceInstance.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoSendCommandToNSSMF.groovy463
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy11
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/RollbackVnf.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ScaleCustomE2EServiceInstance.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModule.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfra.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy9
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfConfigUpdate.groovy12
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy14
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy16
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcher.java168
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/UpdatePnfEntryInAai.java65
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagement.java2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java5
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java14
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationServiceTest.groovy224
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceServiceTest.groovy118
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CheckServiceProcessStatusTest.groovy344
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationServiceTest.groovy456
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceServiceTest.groovy162
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationServiceTest.groovy308
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceServiceTest.groovy171
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateCommunicationServiceTest.groovy196
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollbackTest.groovy7
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollbackTest.groovy3
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2Test.groovy5
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSITest.groovy258
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceServiceTest.groovy460
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy5
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleTest.groovy5
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResourcesTest.java2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcherTest.java182
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java5
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementThrowingException.java5
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/UpdatePnfEntryInAaiTest.java91
91 files changed, 10359 insertions, 575 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/HandleOrchestrationTask.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/HandleOrchestrationTask.groovy
new file mode 100644
index 0000000000..89490ff620
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/HandleOrchestrationTask.groovy
@@ -0,0 +1,127 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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 com.fasterxml.jackson.databind.ObjectMapper
+import org.onap.so.db.request.beans.OrchestrationTask
+
+import static org.apache.commons.lang3.StringUtils.*
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.onap.so.bpmn.common.scripts.ExceptionUtil
+import org.onap.so.bpmn.core.UrnPropertiesReader
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+
+class HandleOrchestrationTask extends AbstractServiceTaskProcessor {
+ private static final Logger logger = LoggerFactory.getLogger(HandleOrchestrationTask.class)
+
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+ def supportedMethod = ["GET", "POST", "PUT"]
+ def validStatus = [200, 201]
+
+ @Override
+ public void preProcessRequest(DelegateExecution execution) {
+ logger.debug("Start preProcessRequest")
+ String method = execution.getVariable("method")
+ if (!supportedMethod.contains(method)) {
+ String msg = "Method: " + method + " is not supported"
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+
+ String taskId = execution.getVariable("taskId")
+ if (isBlank(taskId)) {
+ String msg = "taskId is empty"
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+
+ def dbAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.requestDb.endpoint",execution)
+ def orchestrationTaskEndpoint = dbAdapterEndpoint + "/orchestrationTask/"
+ if (!"POST".equals(method)) {
+ orchestrationTaskEndpoint = orchestrationTaskEndpoint + taskId
+ }
+ execution.setVariable("url", orchestrationTaskEndpoint)
+ logger.debug("DB Adapter Endpoint is: " + orchestrationTaskEndpoint)
+ def dbAdapterAuth = UrnPropertiesReader.getVariable("mso.adapters.requestDb.auth")
+ Map<String, String> headerMap = [:]
+ headerMap.put("content-type", "application/json")
+ headerMap.put("Authorization", dbAdapterAuth)
+ execution.setVariable("headerMap", headerMap)
+ logger.debug("DB Adapter Header is: " + headerMap)
+
+ String requestId = execution.getVariable("requestId")
+ if (("POST".equals(method) || "PUT".equals(method)) && isBlank(requestId)) {
+ String msg = "requestId is empty"
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ String taskName = execution.getVariable("taskName")
+ if (("POST".equals(method) || "PUT".equals(method)) && isBlank(taskName)) {
+ String msg = "task name is empty"
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ String taskStatus = execution.getVariable("taskStatus")
+ if (("POST".equals(method) || "PUT".equals(method)) && isBlank(taskStatus)) {
+ String msg = "task status is empty"
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ String isManual = execution.getVariable("isManual")
+ if (("POST".equals(method) || "PUT".equals(method)) && isBlank(isManual)) {
+ String msg = "isManual is empty"
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ String paramJson = execution.getVariable("paramJson")
+
+ String payload = ""
+ if ("POST".equals(method) || "PUT".equals(method)) {
+ OrchestrationTask task = new OrchestrationTask()
+ task.setTaskId(taskId)
+ task.setRequestId(requestId)
+ task.setName(taskName)
+ task.setStatus(taskStatus)
+ task.setIsManual(isManual)
+ task.setParams(paramJson)
+ ObjectMapper objectMapper = new ObjectMapper()
+ payload = objectMapper.writeValueAsString(task)
+ logger.debug("Outgoing payload is \n" + payload)
+ }
+ execution.setVariable("payload", payload)
+ logger.debug("End preProcessRequest")
+ }
+
+ public void postProcess(DelegateExecution execution) {
+ Integer statusCode = execution.getVariable("statusCode")
+ logger.debug("statusCode: " + statusCode)
+ String response = execution.getVariable("response")
+ logger.debug("response: " + response)
+ if (!validStatus.contains(statusCode)) {
+ String msg = "Error in sending orchestrationTask request. \nstatusCode: " + statusCode + "\nresponse: " + response
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ }
+}
+
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationService.groovy
new file mode 100644
index 0000000000..4ed0ea6a44
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationService.groovy
@@ -0,0 +1,438 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2019, CMCC Technologies Co., Ltd.
+ #
+ # 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.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.Relationship
+import org.onap.aai.domain.yang.RelationshipData
+import org.onap.aai.domain.yang.RelationshipList
+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.common.scripts.MsoUtils
+import org.onap.so.bpmn.common.scripts.RequestDBUtil
+import org.onap.so.bpmn.core.UrnPropertiesReader
+import org.onap.so.bpmn.core.WorkflowException
+import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.AAIResourcesClient
+import org.onap.so.client.aai.entities.AAIResultWrapper
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+import org.onap.so.db.request.beans.OperationStatus
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+
+import javax.ws.rs.NotFoundException
+
+import static org.apache.commons.lang3.StringUtils.isBlank
+
+class ActivateCommunicationService extends AbstractServiceTaskProcessor {
+
+ String Prefix="ACS_"
+
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+
+ RequestDBUtil requestDBUtil = new RequestDBUtil()
+
+ JsonUtils jsonUtil = new JsonUtils()
+
+ AAIResourcesClient client = getAAIClient()
+
+ private static final Logger logger = LoggerFactory.getLogger(ActivateCommunicationService.class)
+
+ @Override
+ void preProcessRequest(DelegateExecution execution) {
+ logger.debug(Prefix + "preProcessRequest Start")
+ execution.setVariable("prefix", Prefix)
+ String msg
+
+ try {
+ // check for incoming json message/input
+ String siRequest = execution.getVariable("bpmnRequest")
+ logger.debug(siRequest)
+
+ String requestId = execution.getVariable("mso-request-id")
+ execution.setVariable("msoRequestId", requestId)
+ logger.info("Input Request:" + siRequest + " reqId:" + requestId)
+
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ if (isBlank(serviceInstanceId)) {
+ msg = "Input serviceInstanceId' is null"
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ }
+
+ String globalSubscriberId = jsonUtil.getJsonValue(siRequest, "globalSubscriberId")
+ if (isBlank(globalSubscriberId)) {
+ msg = "Input globalSubscriberId' is null"
+ logger.info(msg)
+ execution.setVariable("globalSubscriberId", "5GCustomer")
+ } else {
+ execution.setVariable("globalSubscriberId", globalSubscriberId)
+ }
+
+ String subscriptionServiceType = jsonUtil.getJsonValue(siRequest, "serviceType")
+ if (isBlank(subscriptionServiceType)) {
+ msg = "Input subscriptionServiceType is null"
+ logger.debug(msg)
+ execution.setVariable("subscriptionServiceType", "5G")
+ } else {
+ execution.setVariable("subscriptionServiceType", subscriptionServiceType)
+ }
+
+ String operationId = jsonUtil.getJsonValue(siRequest, "operationId")
+ execution.setVariable("operationId", operationId)
+
+ String operationType = execution.getVariable("operationType")
+ execution.setVariable("operationType", operationType.toUpperCase())
+
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ msg = "Exception in preProcessRequest " + ex.getMessage()
+ logger.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug(Prefix + "preProcessRequest Exit")
+ }
+
+
+ def checkAAIOrchStatus = { DelegateExecution execution ->
+
+ logger.debug(Prefix + "checkAAIOrchStatus Start")
+
+ String msg
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+ String operationType = execution.getVariable("operationType")
+
+ logger.debug("serviceInstanceId: " + serviceInstanceId)
+
+ //check the cms status
+ try {
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
+ globalSubscriberId, subscriptionServiceType, serviceInstanceId)
+
+ if (!client.exists(uri)) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai")
+ }
+
+ AAIResultWrapper wrapper = client.get(uri, NotFoundException.class)
+ Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class)
+ if(si.isPresent()) {
+
+ if (si.get().getOrchestrationStatus().toLowerCase() == "activated" &&
+ operationType.equalsIgnoreCase("deactivation")) {
+ logger.info("Service is in active state")
+ execution.setVariable("serviceExpectStatus", "deactivated")
+ execution.setVariable("isContinue", "true")
+ execution.setVariable("requestParam", "deactivate")
+
+ } else if (si.get().getOrchestrationStatus().toLowerCase() == "deactivated" &&
+ operationType.equalsIgnoreCase("activation")){
+ logger.info("Service is in de-activated state")
+ execution.setVariable("serviceExpectStatus", "activated")
+ execution.setVariable("isContinue", "true")
+ execution.setVariable("requestParam", "activate")
+
+ } else {
+ execution.setVariable("isContinue", "false")
+ }
+
+ RelationshipList relationshipList = si.get().getRelationshipList()
+ List<Relationship> relationship
+ if (relationshipList != null && (relationship = relationshipList.getRelationship()) != null
+ && relationship.size() > 0) {
+ List<RelationshipData> relationshipDatas = relationship.get(0).getRelationshipData()
+
+ for (RelationshipData relationshipData : relationshipDatas) {
+ execution.setVariable("e2e_" + relationshipData.getRelationshipKey(),
+ relationshipData.getRelationshipValue())
+ }
+ } else {
+ msg = "the communication service has no e2e service"
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ }
+ }
+
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ msg = "Exception in " + Prefix + "checkAAIOrchStatus: " + ex.getMessage()
+ logger.info( msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+
+ logger.debug(Prefix + "checkAAIOrchStatus Exit")
+ }
+
+
+ def prepareInitOperationStatus = { DelegateExecution execution ->
+ logger.debug(Prefix + "prepareInitOperationStatus Start")
+
+ String serviceId = execution.getVariable("serviceInstanceId")
+
+ // 生成 operationId
+ String operationId = execution.getVariable("operationId")
+
+ String operationType = execution.getVariable("operationType")
+
+ OperationStatus initStatus = new OperationStatus()
+ initStatus.setServiceId(serviceId)
+ initStatus.setOperationId(operationId)
+ initStatus.setOperation(operationType)
+ initStatus.setUserId(execution.getVariable("globalSubscriberId") as String)
+ initStatus.setResult("processing")
+ initStatus.setProgress("0")
+ initStatus.setReason("")
+ initStatus.setOperationContent("communication service active operation start")
+
+ requestDBUtil.prepareUpdateOperationStatus(execution, initStatus)
+
+ logger.debug(Prefix + "prepareInitOperationStatus Exit")
+ }
+
+
+ def sendSyncResponse = { DelegateExecution execution ->
+ logger.debug(Prefix + "sendSyncResponse Start")
+ try {
+ String operationId = execution.getVariable("operationId")
+
+ String restRequest = """{"operationId":"${operationId}"}""".trim()
+ logger.debug(" sendSyncResponse to APIH:" + "\n" + restRequest)
+
+ sendWorkflowResponse(execution, 202, restRequest)
+ execution.setVariable("sentSyncResponse", true)
+ } catch (Exception ex) {
+ String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage()
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug(Prefix + "sendSyncResponse Exit")
+ }
+
+
+ def preRequestSend2NSMF = { DelegateExecution execution ->
+ logger.debug(Prefix + "preRequestSend2NSMF Start")
+ try {
+
+ String e2eServiceInstanceId = execution.getVariable("e2e_service-instance.service-instance-id")
+ execution.setVariable("e2eServiceInstanceId", e2eServiceInstanceId)
+
+ String requestParam = execution.getVariable("requestParam")
+ //String NSMF_endpoint = "/onap/so/infra/e2eServiceInstances/v3"
+ def NSMF_endpoint = UrnPropertiesReader.getVariable("mso.infra.endpoint.url", execution)
+ def url = NSMF_endpoint + "/e2eServiceInstances/v3/${e2eServiceInstanceId}/${requestParam}"
+ execution.setVariable("NSMF_endpoint", url)
+
+ //get from model catalog inputs
+ String payload = """
+ {
+ "globalSubscriberId": "${execution.getVariable("globalSubscriberId")}",
+ "serviceType": "${execution.getVariable("subscriptionServiceType")}"
+ }
+ """
+ execution.setVariable("CSMF_NSMFRequest", payload.replaceAll("\\s+", ""))
+
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ String msg = "Exception in " + Prefix + "preRequestSend2NSMF. " + ex.getMessage()
+ logger.error(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+
+ logger.debug(Prefix + "preRequestSend2NSMF Exit")
+ }
+
+
+ def processNSMFResponse = { DelegateExecution execution ->
+ logger.debug(Prefix + "processNSMFResponse Start")
+ //oof
+ try {
+ def CSMF_NSMFResponseCode = execution.getVariable("CSMF_NSMFResponseCode") as Integer
+ if (CSMF_NSMFResponseCode >= 200 && CSMF_NSMFResponseCode < 400) {
+ def CSMF_NSMFResponse = execution.getVariable("CSMF_NSMFResponse") as String
+ def e2eOperationId = jsonUtil.getJsonValue(CSMF_NSMFResponse, "operationId")
+
+ execution.setVariable("e2eOperationId", e2eOperationId)
+ execution.setVariable("ProcessNsmfSuccess", "OK")
+ } else {
+ execution.setVariable("ProcessNsmfSuccess", "ERROR")
+ execution.setVariable("operationStatus", "error")
+ execution.setVariable("operationContent",
+ "communication service " + execution.getVariable("operationType")
+ + " operation error: nsmf response fail")
+ execution.setVariable("orchestrationStatus", "error")
+ }
+
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ String msg = "Exception in " + Prefix + "processOOFResponse. " + ex.getMessage()
+ logger.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug(Prefix + "processNSMFResponse Exit")
+ }
+
+
+ def prepareUpdateOperationStatus = { DelegateExecution execution ->
+ logger.debug(Prefix + "prepareUpdateOperationStatus Start")
+ // update status creating
+ OperationStatus status = new OperationStatus()
+ status.setServiceId(execution.getVariable("serviceInstanceId") as String)
+ status.setOperationId(execution.getVariable("operationId") as String)
+ status.setOperation(execution.getVariable("operationType") as String)
+ status.setResult("processing")
+ status.setProgress("20")
+ status.setOperationContent("communication service "+ execution.getVariable("operationType")
+ + " operation processing: waiting nsmf service create finished")
+ status.setUserId(execution.getVariable("globalSubscriberId") as String)
+
+ requestDBUtil.prepareUpdateOperationStatus(execution, status)
+ logger.debug(Prefix + "prepareUpdateOperationStatus Exit")
+ }
+
+
+ //todo
+ def prepareCallCheckProcessStatus = { DelegateExecution execution ->
+ logger.debug(Prefix + "prepareCallCheckProcessStatus Start")
+
+ def successConditions = new ArrayList<>()
+ successConditions.add("finished")
+ execution.setVariable("successConditions", successConditions)
+
+ def errorConditions = new ArrayList<>()
+ errorConditions.add("error")
+ execution.setVariable("errorConditions", errorConditions)
+
+ execution.setVariable("processServiceType", "communication service")
+
+ execution.setVariable("timeOut", 3 * 60 * 60 * 1000)
+
+ def successParamMap = new HashMap<String, Object>()
+ successParamMap.put("orchestrationStatus", execution.getVariable("serviceExpectStatus"))
+
+ execution.setVariable("successParamMap", successParamMap)
+
+ def errorParamMap = new HashMap<String, Object>()
+ errorParamMap.put("orchestrationStatus", "error")
+
+ execution.setVariable("errorParamMap", errorParamMap)
+
+ def timeOutParamMap = new HashMap<String, Object>()
+ timeOutParamMap.put("orchestrationStatus", "error")
+
+ execution.setVariable("timeOutParamMap", timeOutParamMap)
+
+ execution.setVariable("initProgress", 20)
+ execution.setVariable("endProgress", 90)
+
+ logger.debug(Prefix + "prepareCallCheckProcessStatus Exit")
+ }
+
+
+ /**
+ * prepare update operation status to complete after NSMF process success
+ * @param execution
+ */
+ def prepareCompleteStatus = { DelegateExecution execution ->
+
+ logger.debug(Prefix + "prepareCompleteStatus Start")
+ String operationType = execution.getVariable("operationType")
+ OperationStatus status = new OperationStatus()
+ status.setServiceId(execution.getVariable("serviceInstanceId") as String)
+ status.setOperationId(execution.getVariable("operationId") as String)
+ status.setOperation(operationType)
+ status.setResult(execution.getVariable("operationStatus") as String)
+ status.setProgress("100")
+ status.setOperationContent(execution.getVariable("operationContent") as String)
+ status.setUserId(execution.getVariable("globalSubscriberId") as String)
+
+ requestDBUtil.prepareUpdateOperationStatus(execution, status)
+ logger.debug("prepareCompleteStatus end, serviceInstanceId: " + execution.getVariable("serviceInstanceId")
+ + ", operationId: " + execution.getVariable("operationId"))
+
+ logger.debug(Prefix + "prepareCompleteStatus Exit")
+ }
+
+
+ /**
+ * update NSMF complete status to AAI when the NSMF process finished
+ * @param execution
+ */
+ def updateFinishStatusInAAI = { DelegateExecution execution ->
+ logger.debug(Prefix + "updateFinishStatusInAAI Start")
+ String msg
+ try {
+
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String orchestrationStatus = execution.getVariable("orchestrationStatus")
+ // create service
+ ServiceInstance csi = new ServiceInstance()
+ csi.setOrchestrationStatus(orchestrationStatus)
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
+ globalSubscriberId, subscriptionServiceType, serviceInstanceId)
+ client.update(uri, csi)
+
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ msg = "Exception in complete communication service " + ex.getMessage()
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug(Prefix + "updateFinishStatusInAAI Exit")
+ }
+
+
+ public sendSyncError = { DelegateExecution execution ->
+ logger.debug("sendSyncError Start")
+ try {
+ String errorMessage
+ if (execution.getVariable("WorkflowException") instanceof WorkflowException) {
+ WorkflowException wfe = execution.getVariable("WorkflowException") as WorkflowException
+ errorMessage = wfe.getErrorMessage()
+ } else {
+ errorMessage = "Sending Sync Error."
+ }
+
+ String buildWorkflowException =
+ """<aetgt:WorkflowException xmlns:aetgt="http://org.onap/so/workflow/schema/v1">
+ <aetgt:ErrorMessage>${MsoUtils.xmlEscape(errorMessage)}</aetgt:ErrorMessage>
+ <aetgt:ErrorCode>7000</aetgt:ErrorCode>
+ </aetgt:WorkflowException>"""
+
+ logger.debug(buildWorkflowException)
+ sendWorkflowResponse(execution, 500, buildWorkflowException)
+
+ } catch (Exception ex) {
+ logger.debug("Sending Sync Error Activity Failed. " + "\n" + ex.getMessage())
+ }
+ logger.debug(Prefix + "sendSyncError Exit")
+ }
+
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceService.groovy
new file mode 100644
index 0000000000..a8c3ef189e
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceService.groovy
@@ -0,0 +1,587 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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 com.google.gson.Gson
+import com.google.gson.reflect.TypeToken
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.*
+import org.onap.so.beans.nsmf.NSSI
+import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.onap.so.bpmn.common.scripts.ExceptionUtil
+import org.onap.so.bpmn.common.scripts.MsoUtils
+import org.onap.so.bpmn.common.scripts.RequestDBUtil
+import org.onap.so.bpmn.core.WorkflowException
+import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.AAIResourcesClient
+import org.onap.so.client.aai.entities.AAIResultWrapper
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+import org.onap.so.db.request.beans.OperationStatus
+import org.onap.logging.filter.base.ErrorCode
+import org.onap.so.logger.LoggingAnchor
+import org.onap.so.logger.MessageEnum
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+
+import javax.ws.rs.NotFoundException
+import java.lang.reflect.Type
+
+import static org.apache.commons.lang3.StringUtils.isBlank
+
+/**
+ * This groovy class supports the <class>ActivateSliceService.bpmn</class> process.
+ * AlaCarte flow for 1702 slice service activate
+ *
+ */
+
+class ActivateSliceService extends AbstractServiceTaskProcessor {
+
+
+ String Prefix = "ACTSS_"
+
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+
+ JsonUtils jsonUtil = new JsonUtils()
+
+ RequestDBUtil requestDBUtil = new RequestDBUtil()
+
+ private static final Logger logger = LoggerFactory.getLogger(ActivateSliceService.class)
+
+ void preProcessRequest(DelegateExecution execution) {
+ logger.debug(Prefix + "preProcessRequest Start")
+ execution.setVariable("prefix", Prefix)
+ String msg
+
+ try {
+ // check for incoming json message/input
+ String siRequest = execution.getVariable("bpmnRequest")
+ logger.debug(siRequest)
+
+ String requestId = execution.getVariable("mso-request-id")
+ execution.setVariable("msoRequestId", requestId)
+ logger.info("Input Request:" + siRequest + " reqId:" + requestId)
+
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ if (isBlank(serviceInstanceId)) {
+ msg = "Input serviceInstanceId' is null"
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ }
+ String source = jsonUtil.getJsonValue(siRequest, "source")
+ execution.setVariable("source", source)
+
+ //subscriberInfo
+ String globalSubscriberId = jsonUtil.getJsonValue(siRequest, "globalSubscriberId")
+ if (isBlank(globalSubscriberId)) {
+ msg = "Input globalSubscriberId' is null"
+ logger.info(msg)
+ execution.setVariable("globalSubscriberId", "5GCustomer")
+ } else {
+ execution.setVariable("globalSubscriberId", globalSubscriberId)
+ }
+
+ //requestParameters
+ String subscriptionServiceType = jsonUtil.getJsonValue(siRequest, "serviceType")
+ if (isBlank(subscriptionServiceType)) {
+ msg = "Input subscriptionServiceType is null"
+ logger.debug(msg)
+ execution.setVariable("subscriptionServiceType", "5G")
+ } else {
+ execution.setVariable("subscriptionServiceType", subscriptionServiceType)
+ }
+ String operationId = jsonUtil.getJsonValue(siRequest, "operationId")
+ execution.setVariable("operationId", operationId)
+
+ String operationType = execution.getVariable("operationType")
+ execution.setVariable("operationType", operationType.toUpperCase())
+
+ logger.info("operationType is " + execution.getVariable("operationType") )
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ msg = "Exception in preProcessRequest " + ex.getMessage()
+ logger.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug(Prefix + "preProcessRequest Exit")
+ }
+
+
+ def sendSyncResponse = { DelegateExecution execution ->
+ logger.debug(Prefix + "sendSyncResponse Start")
+ try {
+ String operationId = execution.getVariable("operationId")
+ // RESTResponse for API Handler (APIH) Reply Task
+ String Activate5GsliceServiceRestRequest = """{"operationId":"${operationId}"}""".trim()
+ logger.debug(" sendSyncResponse to APIH:" + "\n" + Activate5GsliceServiceRestRequest)
+ sendWorkflowResponse(execution, 202, Activate5GsliceServiceRestRequest)
+ execution.setVariable("sentSyncResponse", true)
+ } catch (Exception ex) {
+ String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage()
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug(Prefix + "sendSyncResponse Exit")
+ }
+
+
+ public sendSyncError = { DelegateExecution execution ->
+ logger.debug("sendSyncError Start")
+ try {
+ String errorMessage
+ if (execution.getVariable("WorkflowException") instanceof WorkflowException) {
+ WorkflowException wfe = execution.getVariable("WorkflowException") as WorkflowException
+ errorMessage = wfe.getErrorMessage()
+ } else {
+ errorMessage = "Sending Sync Error."
+ }
+
+ String buildWorkflowException =
+ """<aetgt:WorkflowException xmlns:aetgt="http://org.onap/so/workflow/schema/v1">
+ <aetgt:ErrorMessage>${MsoUtils.xmlEscape(errorMessage)}</aetgt:ErrorMessage>
+ <aetgt:ErrorCode>7000</aetgt:ErrorCode>
+ </aetgt:WorkflowException>"""
+
+ logger.debug(buildWorkflowException)
+ sendWorkflowResponse(execution, 500, buildWorkflowException)
+
+ } catch (Exception ex) {
+ logger.debug("Sending Sync Error Activity Failed. " + "\n" + ex.getMessage())
+ }
+ logger.debug(Prefix + "sendSyncError Exit")
+ }
+
+
+ def prepareCompletionRequest = { DelegateExecution execution ->
+ logger.debug(Prefix + "prepareCompletionRequest Start")
+ String serviceId = execution.getVariable("serviceInstanceId")
+ String operationId = execution.getVariable("operationId")
+ String userId = execution.getVariable("globalSubscriberId")
+ //String result = execution.getVariable("result")
+ String result = "finished"
+ String progress = "100"
+ String reason = ""
+ String operationContent = execution.getVariable("operationContent")
+ String operationType = execution.getVariable("operationType")
+
+ OperationStatus initStatus = new OperationStatus()
+ initStatus.setServiceId(serviceId)
+ initStatus.setOperationId(operationId)
+ initStatus.setOperation(operationType)
+ initStatus.setUserId(userId)
+ initStatus.setResult(result)
+ initStatus.setProgress(progress)
+ initStatus.setReason(reason)
+ initStatus.setOperationContent(operationContent)
+
+ requestDBUtil.prepareUpdateOperationStatus(execution, initStatus)
+
+ logger.debug(Prefix + "prepareCompletionRequest Exit")
+ }
+
+
+ /**
+ * Init the service Operation Status
+ */
+ def prepareInitServiceOperationStatus = { DelegateExecution execution ->
+ logger.debug(Prefix + "prepareActivateServiceOperationStatus Start")
+ try {
+ String serviceId = execution.getVariable("serviceInstanceId")
+ String operationId = execution.getVariable("operationId")
+ String operationType = execution.getVariable("operationType")
+ String userId = execution.getVariable("globalSubscriberId")
+ String result = "processing"
+ String progress = "0"
+ String reason = ""
+ String operationContent = "Prepare service activation"
+
+ execution.setVariable("e2eserviceInstanceId", serviceId)
+ execution.setVariable("operationType", operationType)
+
+ OperationStatus initStatus = new OperationStatus()
+ initStatus.setServiceId(serviceId)
+ initStatus.setOperationId(operationId)
+ initStatus.setOperation(operationType)
+ initStatus.setUserId(userId)
+ initStatus.setResult(result)
+ initStatus.setProgress(progress)
+ initStatus.setReason(reason)
+ initStatus.setOperationContent(operationContent)
+
+ requestDBUtil.prepareUpdateOperationStatus(execution, initStatus)
+
+ } catch (Exception e) {
+ logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ "Exception Occured Processing prepareInitServiceOperationStatus.", "BPMN",
+ ErrorCode.UnknownError.getValue(), "Exception is:\n" + e)
+ execution.setVariable("CVFMI_ErrorResponse",
+ "Error Occurred during prepareInitServiceOperationStatus Method:\n" + e.getMessage())
+ }
+ logger.debug(Prefix + "prepareInitServiceOperationStatus Exit")
+ }
+
+
+ private getSNSSIStatusByNsi = { DelegateExecution execution, String NSIServiceId ->
+
+ logger.debug(Prefix + "getSNSSIStatusByNsi Start")
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
+ globalSubscriberId, subscriptionServiceType, NSIServiceId)
+ if (!client.exists(uri)) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai")
+ }
+ AAIResultWrapper wrapper = client.get(uri, NotFoundException.class)
+ Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class)
+ if (si.isPresent()) {
+
+ List<Relationship> relatedList = si.get().getRelationshipList().getRelationship()
+ for (Relationship relationship : relatedList) {
+ String relatedTo = relationship.getRelatedTo()
+ if (relatedTo.toLowerCase() == "allotted-resource") {
+ //get snssi from allotted resource in list by nsi
+ List<String> SNSSIList = new ArrayList<>()
+ List<RelationshipData> relationshipDataList = relationship.getRelationshipData()
+ for (RelationshipData relationshipData : relationshipDataList) {
+ if (relationshipData.getRelationshipKey() == "service-instance.service-instance-id") {
+ SNSSIList.add(relationshipData.getRelationshipValue())
+ }
+ }
+ for (String snssi : SNSSIList) {
+ AAIResourcesClient client01 = new AAIResourcesClient()
+ AAIResourceUri uri01 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
+ globalSubscriberId, subscriptionServiceType, snssi)
+ if (!client.exists(uri01)) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500,
+ "Service Instance was not found in aai")
+ }
+ AAIResultWrapper wrapper01 = client01.get(uri01, NotFoundException.class)
+ Optional<ServiceInstance> nssiSi = wrapper01.asBean(ServiceInstance.class)
+ if (nssiSi.isPresent()) {
+ return nssiSi.get().getOrchestrationStatus() == "deactivated"
+ }
+ }
+
+ }
+ }
+
+ }
+ logger.debug(Prefix + "getSNSSIStatusByNsi Exit")
+ }
+
+
+ def updateStatusSNSSAIandNSIandNSSI = { DelegateExecution execution ->
+ logger.debug(Prefix + "updateStatusSNSSAIandNSIandNSSI Start")
+ logger.debug(" ***** update SNSSAI NSI NSSI slicing ***** ")
+ String e2eserviceInstanceId = execution.getVariable("e2eserviceInstanceId")
+ String NSIserviceInstanceId = execution.getVariable("NSIserviceid")
+
+ String globalCustId = execution.getVariable("globalSubscriberId")
+ String serviceType = execution.getVariable("serviceType")
+ String operationType = execution.getVariable("operationType")
+
+ String nssiMap = execution.getVariable("nssiMap")
+ Type type = new TypeToken<HashMap<String, NSSI>>() {}.getType()
+ Map<String, NSSI> activateNssiMap = new Gson().fromJson(nssiMap, type)
+ //update tn/cn/an nssi
+ for (Map.Entry<String, NSSI> entry : activateNssiMap.entrySet()) {
+ NSSI nssi = entry.getValue()
+ String nssiid = nssi.getNssiId()
+ updateStratus(execution, globalCustId, serviceType, nssiid, operationType)
+ }
+ if (operationType.equalsIgnoreCase("activation")) {
+ //update the s-nssai
+ updateStratus(execution, globalCustId, serviceType, e2eserviceInstanceId, operationType)
+ //update the nsi
+ updateStratus(execution, globalCustId, serviceType, NSIserviceInstanceId, operationType)
+ } else {
+ //update the s-nssai
+ updateStratus(execution, globalCustId, serviceType, e2eserviceInstanceId, operationType)
+ boolean flag = getSNSSIStatusByNsi(execution, NSIserviceInstanceId)
+ if (flag) {
+ //update the nsi
+ updateStratus(execution, globalCustId, serviceType, NSIserviceInstanceId, operationType)
+ } else {
+ logger.error("Service's status update failed")
+ String msg = "Service's status update failed"
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ }
+ logger.debug(Prefix + "updateStatusSNSSAIandNSIandNSSI Exit")
+ }
+
+
+ def updateStratus = { DelegateExecution execution, String globalCustId,
+ String serviceType, String serviceId, String operationType ->
+ logger.debug(Prefix + "updateStratus Start")
+
+ try {
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
+ globalCustId, serviceType, serviceId)
+ if (!client.exists(uri)) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai")
+ }
+ AAIResultWrapper wrapper = client.get(uri, NotFoundException.class)
+ Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class)
+
+ if (si.isPresent()) {
+ if (operationType.equalsIgnoreCase("activation")) {
+ if (si.get().getOrchestrationStatus() == "deactivated") {
+ si.get().setOrchestrationStatus("activated")
+ client.update(uri, si.get())
+ }
+ } else {
+ if (si.get().getOrchestrationStatus() == "activated") {
+ si.get().setOrchestrationStatus("deactivated")
+ client.update(uri, si.get())
+ }
+ }
+
+ }
+ } catch (Exception e) {
+ logger.info("Service is already in active state")
+ String msg = "Service is already in active state, " + e.getMessage()
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+
+ logger.debug(Prefix + "updateStratus Exit")
+ }
+
+
+ def prepareActivation = { DelegateExecution execution ->
+ logger.debug(Prefix + "prepareActivation Start")
+
+ logger.debug(" ***** prepare active NSI/AN/CN/TN slice ***** ")
+ String NSIserviceInstanceId = execution.getVariable("NSIserviceid")
+
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+
+ Map<String, NSSI> nssiMap = new HashMap<>()
+
+ List<String> activationSequence = new ArrayList<>(Arrays.asList("an", "tn", "cn"))
+
+ def activationCount = activationSequence.size()
+
+ execution.setVariable("activationIndex", "0")
+
+ execution.setVariable("activationCount", activationCount)
+ try {
+ //get the TN NSSI id by NSI id, active NSSI TN slicing
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
+ globalSubscriberId, subscriptionServiceType, NSIserviceInstanceId)
+ if (!client.exists(uri)) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai")
+ }
+ AAIResultWrapper wrapper = client.get(uri, NotFoundException.class)
+ Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class)
+ if (si.isPresent()) {
+
+ List<Relationship> relatedList = si.get().getRelationshipList().getRelationship()
+ for (Relationship relationship : relatedList) {
+ String relatedTo = relationship.getRelatedTo()
+ if (relatedTo.toLowerCase() == "service-instance") {
+ String relatioshipurl = relationship.getRelatedLink()
+ String nssiserviceid =
+ relatioshipurl.substring(relatioshipurl.lastIndexOf("/") + 1, relatioshipurl.length())
+
+ AAIResourcesClient client01 = new AAIResourcesClient()
+ AAIResourceUri uri01 = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
+ globalSubscriberId, subscriptionServiceType, nssiserviceid)
+ if (!client.exists(uri01)) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500,
+ "Service Instance was not found in aai")
+ }
+ AAIResultWrapper wrapper01 = client01.get(uri01, NotFoundException.class)
+ Optional<ServiceInstance> nssiSi = wrapper01.asBean(ServiceInstance.class)
+ if (nssiSi.isPresent()) {
+ if (nssiSi.get().getEnvironmentContext().toLowerCase().contains("an")
+ || nssiSi.get().getEnvironmentContext().toLowerCase().contains("cn")
+ || nssiSi.get().getEnvironmentContext().toLowerCase().contains("tn")) {
+ nssiMap.put(nssiSi.get().getEnvironmentContext(),
+ new NSSI(nssiSi.get().getServiceInstanceId(),
+ nssiSi.get().getModelInvariantId(), nssiSi.get().getModelVersionId()))
+ }
+ }
+ }
+ }
+
+
+ }
+ } catch (Exception e) {
+ String msg = "Requested service does not exist:" + e.getMessage()
+ logger.info("Service doesnt exist")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+
+ if (nssiMap.size() > 0) {
+ execution.setVariable("isNSSIActivate", "true")
+ String nssiMap01 = mapToJsonStr(nssiMap)
+ execution.setVariable("nssiMap", nssiMap01)
+ execution.setVariable("operation_type", "activate")
+ execution.setVariable("activationCount", nssiMap.size())
+ logger.info("the nssiMap01 is :" + nssiMap01)
+ } else {
+ execution.setVariable("isNSSIActivate", "false")
+ }
+
+ logger.debug(Prefix + "prepareActivation Exit")
+ }
+
+
+ private mapToJsonStr = { HashMap<String, NSSI> stringNSSIHashMap ->
+ HashMap<String, NSSI> map = new HashMap<String, NSSI>()
+ for (Map.Entry<String, NSSI> child : stringNSSIHashMap.entrySet()) {
+ map.put(child.getKey(), child.getValue())
+ }
+ return new Gson().toJson(map)
+ }
+
+
+ def checkAAIOrchStatusofslice = { DelegateExecution execution ->
+ logger.debug(Prefix + "CheckAAIOrchStatus Start")
+
+ String msg = ""
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+ String operationType = execution.getVariable("operationType")
+
+ logger.debug("serviceInstanceId: " + serviceInstanceId)
+
+ //check the e2e slice status
+ try {
+ try {
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
+ globalSubscriberId, subscriptionServiceType, serviceInstanceId)
+ if (!client.exists(uri)) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500,
+ "Service Instance was not found in aai")
+ }
+ AAIResultWrapper wrapper = client.get(uri, NotFoundException.class)
+ Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class)
+ if (si.isPresent()) {
+ if (si.get().getOrchestrationStatus().toLowerCase() == "activated" &&
+ operationType.equalsIgnoreCase("deactivation")) {
+ logger.info("Service is in active state")
+ execution.setVariable("e2eservicestatus", "activated")
+ execution.setVariable("isContinue", "true")
+ String snssai = si.get().getEnvironmentContext()
+ execution.setVariable("snssai", snssai)
+ } else if (si.get().getOrchestrationStatus().toLowerCase() == "deactivated" &&
+ operationType.equalsIgnoreCase("activation")) {
+ logger.info("Service is in de-activated state")
+ execution.setVariable("e2eservicestatus", "deactivated")
+ execution.setVariable("isContinue", "true")
+ String snssai = si.get().getEnvironmentContext()
+ execution.setVariable("snssai", snssai)
+ } else {
+ execution.setVariable("isContinue", "false")
+ }
+ }
+ } catch (Exception e) {
+ msg = "Requested e2eservice does not exist"
+ logger.info("e2eservice doesnt exist")
+ execution.setVariable("isContinue", "false")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+
+ //check the NSI is exist or the status of NSI is active or de-active
+ try {
+
+ //get the allotted-resources by e2e slice id
+ AAIResourcesClient client_allotted = new AAIResourcesClient()
+ AAIResourceUri uri_allotted = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE_ALL,
+ globalSubscriberId, subscriptionServiceType, serviceInstanceId)
+ if (!client_allotted.exists(uri_allotted)) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai")
+ }
+ AAIResultWrapper wrapper_allotted = client_allotted.get(uri_allotted, NotFoundException.class)
+ Optional<AllottedResources> all_allotted = wrapper_allotted.asBean(AllottedResources.class)
+
+ if (all_allotted.isPresent() && all_allotted.get().getAllottedResource()) {
+ List<AllottedResource> AllottedResourceList = all_allotted.get().getAllottedResource()
+ AllottedResource ar = AllottedResourceList.first()
+ String relatedLink = ar.getRelationshipList().getRelationship().first().getRelatedLink()
+ String nsiserviceid = relatedLink.substring(relatedLink.lastIndexOf("/") + 1, relatedLink.length())
+ execution.setVariable("NSIserviceid", nsiserviceid)
+ logger.info("the NSI ID is:" + nsiserviceid)
+
+ //Query nsi by nsi id
+ try {
+ //get the NSI id by e2e slice id
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
+ globalSubscriberId, subscriptionServiceType, nsiserviceid)
+ if (!client.exists(uri)) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500,
+ "Service Instance was not found in aai")
+ }
+ AAIResultWrapper wrapper = client.get(uri, NotFoundException.class)
+ Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class)
+
+ if (si.isPresent()) {
+ if (si.get().getServiceRole().toLowerCase() == "nsi") {
+ if (si.get().getOrchestrationStatus() == "activated") {
+ logger.info("NSI services is in activated state")
+ execution.setVariable("NSIservicestatus", "activated")
+ } else {
+ logger.info("NSI services is in deactivated state")
+ execution.setVariable("NSIservicestatus", "deactivated")
+ }
+ } else {
+ logger.info("the service id" + si.get().getServiceInstanceId() + "is " +
+ si.get().getServiceRole())
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ }
+ } catch (Exception e) {
+ msg = "Requested NSI service does not exist:" + e.getMessage()
+ logger.info("NSI service doesnt exist")
+ execution.setVariable("isContinue", "false")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ }
+ } catch (Exception e) {
+ msg = "Requested service does not exist: " + e.getMessage()
+ logger.info("NSI Service doesnt exist")
+ execution.setVariable("isActivate", "false")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ msg = "Exception in org.onap.so.bpmn.common.scripts.CompleteMsoProcess.CheckAAIOrchStatus " + ex.getMessage()
+ logger.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+
+ logger.debug(Prefix + "CheckAAIOrchStatus Exit")
+ }
+
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CheckServiceProcessStatus.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CheckServiceProcessStatus.groovy
new file mode 100644
index 0000000000..3233bfff61
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CheckServiceProcessStatus.groovy
@@ -0,0 +1,333 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2019, CMCC Technologies Co., Ltd.
+ #
+ # 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.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.onap.so.bpmn.common.scripts.ExceptionUtil
+import org.onap.so.bpmn.common.scripts.RequestDBUtil
+import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.client.aai.AAIResourcesClient
+import org.onap.so.db.request.beans.OperationStatus
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+
+import java.util.concurrent.TimeUnit
+
+import static org.apache.commons.lang3.StringUtils.isBlank
+
+class CheckServiceProcessStatus extends AbstractServiceTaskProcessor {
+
+
+ String Prefix="CSPS_"
+
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+
+ RequestDBUtil requestDBUtil = new RequestDBUtil()
+
+ JsonUtils jsonUtil = new JsonUtils()
+
+ AAIResourcesClient client = getAAIClient()
+
+ private static final Logger logger = LoggerFactory.getLogger(CheckServiceProcessStatus.class)
+
+ @Override
+ void preProcessRequest(DelegateExecution execution) {
+ logger.debug(Prefix + "CheckServiceProcessStatus preProcessRequest Start")
+ execution.setVariable("prefix", Prefix)
+
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ String operationId = execution.getVariable("operationId")
+ String parentServiceInstanceId = execution.getVariable("parentServiceInstanceId")
+ String parentOperationId = execution.getVariable("parentOperationId")
+
+ if (isBlank(serviceInstanceId) || isBlank(operationId)) {
+ String msg = "Exception in" + Prefix + "preProcessRequest: Input serviceInstanceId or operationId is null"
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ }
+
+ if (isBlank(parentServiceInstanceId) || isBlank(parentOperationId)) {
+ execution.setVariable("isNeedUpdateParentStatus", false)
+ }
+
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ if (isBlank(globalSubscriberId)) {
+ execution.setVariable("globalSubscriberId", "5GCustomer")
+ }
+
+ // serviceType: type of service
+ String serviceType = execution.getVariable("processServiceType")
+ if (isBlank(serviceType)) {
+ execution.setVariable("processServiceType", "service")
+ }
+
+ // operationType: type of service
+ String operationType = execution.getVariable("operationType")
+ if (isBlank(operationType)) {
+ execution.setVariable("operationType", "CREATE")
+ }
+
+ //successConditions: processing end success conditions
+ List<String> successConditions = execution.getVariable("successConditions") as List
+
+ //errorConditions: processing end error conditions
+ List<String> errorConditions = execution.getVariable("errorConditions") as List
+
+ if ((successConditions == null || successConditions.size() < 1)
+ && (errorConditions == null || errorConditions.size() < 1)) {
+ String msg = "Exception in" + Prefix + "preProcessRequest: conditions is null"
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else {
+ for (int i = 0; i < successConditions.size(); i++) {
+ String condition = successConditions.get(i)
+ successConditions.set(i, condition.toLowerCase())
+ }
+ for (int i = 0; i < errorConditions.size(); i++) {
+ String condition = errorConditions.get(i)
+ errorConditions.set(i, condition.toLowerCase())
+ }
+ }
+
+ execution.setVariable("startTime", System.currentTimeMillis())
+
+ String initProgress = execution.getVariable("initProgress")
+
+ if (isBlank(initProgress)) {
+ execution.setVariable("initProgress", 0)
+ }
+
+ String endProgress = execution.getVariable("endProgress")
+
+ if (isBlank(endProgress)) {
+ execution.setVariable("endProgress", 100)
+ }
+
+ execution.setVariable("progress", 0)
+ logger.debug(Prefix + "preProcessRequest Exit")
+ }
+
+
+ /**
+ * check service status through request operation id, update operation status
+ */
+ def preCheckServiceStatusReq = { DelegateExecution execution ->
+ logger.trace(Prefix + "preCheckServiceStatusReq Start")
+ String serviceInstanceId = execution.getVariable("serviceInstanceId") as String
+ String operationId = execution.getVariable("operationId") as String
+ requestDBUtil.getOperationStatus(execution, serviceInstanceId, operationId)
+ logger.trace(Prefix + "preCheckServiceStatusReq Exit")
+ }
+
+
+ /**
+ * handle service status, if service status is finished or error, set the service status
+ * @param execution
+ */
+ def handlerServiceStatusResp = { DelegateExecution execution ->
+ logger.trace(Prefix + "handlerServiceStatusResp Start")
+ String msg
+ try {
+ def dbResponseCode = execution.getVariable("dbResponseCode") as Integer
+ if (dbResponseCode >= 200 && dbResponseCode < 400) {
+ String dbResponse = execution.getVariable("dbResponse")
+ def dbResponseJson = jsonUtil.xml2json(dbResponse) as String
+
+ String result = jsonUtil.getJsonValue(dbResponseJson,
+ "Envelope.Body.getServiceOperationStatusResponse.return.result")
+
+ if (isSuccessCompleted(execution, result)) {
+
+ handlerSuccess(execution, result)
+ execution.setVariable("isAllFinished", "true")
+
+ logger.debug(Prefix + "handlerServiceStatusResp: service success finished, dbResponse_result: "
+ + result)
+
+ } else if (isErrorCompleted(execution, result)) {
+
+ handlerError(execution, result)
+ execution.setVariable("isAllFinished", "true")
+
+ logger.debug(Prefix + "handlerServiceStatusResp: service error finished, dbResponse_result: "
+ + result)
+
+ } else {
+ String progress = jsonUtil.getJsonValue(dbResponseJson,
+ "Envelope.Body.getServiceOperationStatusResponse.return.progress")
+
+ String oldProgress = execution.getVariable("progress")
+
+ if (progress == oldProgress) {
+ execution.setVariable("isNeedUpdateDB", false)
+ } else {
+ execution.setVariable("progress", progress)
+ execution.setVariable("isNeedUpdateDB", true)
+ }
+ execution.setVariable("isAllFinished", "false")
+ TimeUnit.SECONDS.sleep(10)
+ }
+ } else {
+ execution.setVariable("isAllFinished", "false")
+ //todo: retry
+ TimeUnit.MILLISECONDS.sleep(10)
+ }
+
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ msg = "Exception in " + Prefix + "handlerServiceStatusResp: " + ex.getMessage()
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+
+ logger.trace(Prefix + "handlerServiceStatusResp Exit")
+ }
+
+
+ def timeWaitDelay = { DelegateExecution execution ->
+
+ Long startTime = execution.getVariable("startTime") as Long
+ Long timeOut = execution.getVariable("timeOut") as Long
+
+ timeOut = timeOut == null ? 3 * 60 * 60 * 1000 : timeOut
+
+ if (System.currentTimeMillis() - startTime > timeOut) {
+
+ handlerTimeOut(execution)
+ execution.setVariable("isTimeOut", "YES")
+
+ } else {
+ execution.setVariable("isTimeOut", "NO")
+ }
+ }
+
+
+ private handlerTimeOut = { DelegateExecution execution ->
+
+ Map<String, Object> paramMap = execution.getVariable("timeOutParamMap") as Map
+
+ handlerProcess(execution, "error", paramMap, "error", "with timeout")
+ }
+
+
+ private handlerSuccess = { DelegateExecution execution, String result ->
+
+ Map<String, Object> paramMap = execution.getVariable("successParamMap") as Map
+
+ handlerProcess(execution, result, paramMap, "deactivated", "success")
+ }
+
+
+ private handlerError = { DelegateExecution execution, String result ->
+
+ Map<String, Object> paramMap = execution.getVariable("errorParamMap") as Map
+
+ handlerProcess(execution, result, paramMap, "error", "with error")
+ }
+
+
+ private handlerProcess = { DelegateExecution execution, String result, def paramMap, def status, def msg ->
+
+ if (paramMap != null) {
+ for (Map.Entry<String, Object> entry : paramMap.entrySet()) {
+ execution.setVariable(entry.getKey(), entry.getValue())
+ }
+ }
+
+
+ if (isBlank(execution.getVariable("operationStatus") as String)) {
+ execution.setVariable("operationStatus", result)
+ }
+
+
+ if (isBlank(execution.getVariable("operationContent") as String)) {
+ String operationContent = execution.getVariable("processServiceType") + " " +
+ execution.getVariable("operationType") + " operation finished " + msg
+ execution.setVariable("operationContent", operationContent)
+ }
+
+ if (isBlank(execution.getVariable("orchestrationStatus") as String)) {
+ execution.setVariable("orchestrationStatus", status)
+ }
+
+ }
+
+
+ /**
+ * judge if the service processing success finished
+ */
+ private isSuccessCompleted = { DelegateExecution execution, String result ->
+
+ //successConditions: processing end success conditions
+ List<String> successConditions = execution.getVariable("successConditions") as List
+
+ result = result.toLowerCase()
+ if (successConditions.contains(result)) {
+ return true
+ }
+ return false
+ }
+
+
+ /**
+ * judge if the service processing error finished
+ */
+ private isErrorCompleted = { DelegateExecution execution, String result ->
+
+ //errorConditions: processing end error conditions
+ List<String> errorConditions = execution.getVariable("errorConditions") as List
+
+ result = result.toLowerCase()
+ if (errorConditions.contains(result)) {
+ return true
+ }
+ return false
+ }
+
+
+ def preUpdateOperationProgress = { DelegateExecution execution ->
+ logger.trace(Prefix + "prepareUpdateOperationStatus Start")
+
+ def progress = execution.getVariable("progress") as Integer
+ def initProgress = execution.getVariable("initProgress") as Integer
+ def endProgress = execution.getVariable("endProgress") as Integer
+
+ def resProgress = (initProgress + (endProgress - initProgress) / 100 * progress) as Integer
+
+ def operationType = execution.getVariable("operationType")
+ def operationContent = execution.getVariable("processServiceType") + " " +
+ operationType + " operation processing " + resProgress
+
+ // update status creating
+ OperationStatus status = new OperationStatus()
+ status.setServiceId(execution.getVariable("parentServiceInstanceId") as String)
+ status.setOperationId(execution.getVariable("parentOperationId") as String)
+ status.setOperation(operationType as String)
+ status.setResult("processing")
+ status.setProgress(resProgress as String)
+ status.setOperationContent(operationContent as String)
+ status.setUserId(execution.getVariable("globalSubscriberId") as String)
+
+ requestDBUtil.prepareUpdateOperationStatus(execution, status)
+ logger.trace(Prefix + "prepareUpdateOperationStatus Exit")
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy
new file mode 100644
index 0000000000..71da2abd05
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy
@@ -0,0 +1,678 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2019, CMCC Technologies Co., Ltd.
+ #
+ # 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 groovy.json.JsonSlurper
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.json.JSONObject
+import org.onap.aai.domain.yang.Relationship
+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.common.scripts.MsoUtils
+import org.onap.so.bpmn.common.scripts.RequestDBUtil
+import org.onap.so.bpmn.core.UrnPropertiesReader
+import org.onap.so.bpmn.core.WorkflowException
+import org.onap.so.bpmn.core.domain.ServiceDecomposition
+import org.onap.so.bpmn.core.domain.ServiceInfo
+import org.onap.so.bpmn.core.domain.ServiceProxy
+import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.AAIResourcesClient
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+import org.onap.so.db.request.beans.OperationStatus
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+import org.springframework.web.util.UriUtils
+
+import static org.apache.commons.lang3.StringUtils.isBlank
+
+/**
+ * This groovy class supports the <class>DoCreateCommunicationService.bpmn</class> process.
+ * AlaCarte flow for 1702 ServiceInstance Create
+ *
+ */
+class CreateCommunicationService extends AbstractServiceTaskProcessor {
+
+ String Prefix="CCS_"
+
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+
+ RequestDBUtil requestDBUtil = new RequestDBUtil()
+
+ JsonUtils jsonUtil = new JsonUtils()
+
+ AAIResourcesClient client = getAAIClient()
+
+ private static final Logger logger = LoggerFactory.getLogger(CreateCommunicationService.class)
+
+ @Override
+ void preProcessRequest(DelegateExecution execution) {
+ logger.debug(Prefix + "preProcessRequest Start")
+ execution.setVariable("prefix", Prefix)
+ execution.setVariable("startTime", System.currentTimeMillis())
+ def msg
+ //execution.setVariable("bpmnRequest", InputString)
+ try {
+ // get request input
+ String siRequest = execution.getVariable("bpmnRequest")
+ logger.debug(siRequest)
+
+ //String requestId = execution.getVariable("mso-request-id")
+ String requestId = execution.getVariable("mso-request-id")
+ execution.setVariable("msoRequestId", requestId)
+ logger.debug("Input Request:" + siRequest + " reqId:" + requestId)
+
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ if (isBlank(serviceInstanceId)) {
+ serviceInstanceId = UUID.randomUUID().toString()
+ }
+ logger.debug("Generated new Service Instance:" + serviceInstanceId)
+ serviceInstanceId = UriUtils.encode(serviceInstanceId,"UTF-8")
+ execution.setVariable("serviceInstanceId", serviceInstanceId)
+
+ //subscriberInfo
+ String globalSubscriberId = jsonUtil.getJsonValue(siRequest, "requestDetails.subscriberInfo.globalSubscriberId")
+ if (isBlank(globalSubscriberId)) {
+ msg = "Input globalSubscriberId' is null"
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else {
+ execution.setVariable("globalSubscriberId", globalSubscriberId)
+ }
+
+ //requestInfo
+ execution.setVariable("source", jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.source"))
+ execution.setVariable("serviceInstanceName", jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.instanceName"))
+ execution.setVariable("disableRollback", jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.suppressRollback"))
+ String productFamilyId = jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.productFamilyId")
+ if (isBlank(productFamilyId))
+ {
+ msg = "Input productFamilyId is null"
+ logger.debug(msg)
+ //exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else {
+ execution.setVariable("productFamilyId", productFamilyId)
+ }
+
+ //modelInfo
+ String serviceModelInfo = jsonUtil.getJsonValue(siRequest, "requestDetails.modelInfo")
+ if (isBlank(serviceModelInfo)) {
+ msg = "Input serviceModelInfo is null"
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else
+ {
+ execution.setVariable("csServiceModelInfo", serviceModelInfo)
+ }
+
+ logger.debug("modelInfo: " + serviceModelInfo)
+
+ //requestParameters, subscriptionServiceType is 5G
+ String subscriptionServiceType = jsonUtil.getJsonValue(siRequest, "requestDetails.requestParameters.subscriptionServiceType")
+ if (isBlank(subscriptionServiceType)) {
+ msg = "Input subscriptionServiceType is null"
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else {
+ // todo: in create e2e interface, this value is write "MOG", so write it as "5G"
+ execution.setVariable("subscriptionServiceType", "5G")
+ }
+
+
+ /*
+ * Extracting User Parameters from incoming Request and converting into a Map
+ */
+ def jsonSlurper = new JsonSlurper()
+
+ Map reqMap = jsonSlurper.parseText(siRequest) as Map
+
+ //InputParams
+ def userParamsList = reqMap.requestDetails?.requestParameters?.userParams
+
+ Map<String, String> inputMap = [:]
+ if (userParamsList) {
+ for (def i=0; i<userParamsList.size(); i++) {
+ def userParams1 = userParamsList.get(i)
+ userParams1.each { param -> inputMap.put(param.key, param.value)}
+ }
+ }
+
+ logger.debug("User Input Parameters map: " + inputMap.toString())
+ execution.setVariable("serviceInputParams", inputMap)
+ execution.setVariable("uuiRequest", inputMap.get("UUIRequest"))
+ execution.setVariable("isAllNSMFFinished", "false")
+ String operationId = UUID.randomUUID().toString()
+ execution.setVariable("operationId", operationId)
+
+ } catch(BpmnError e) {
+ throw e
+ } catch(Exception ex) {
+ msg = "Exception in CreateCommunicationService.preProcessRequest " + ex.getMessage()
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug(Prefix + "preProcessRequest Exit")
+ }
+
+
+ /**
+ * create operation status in request db
+ *
+ * Init the Operation Status
+ */
+ def prepareInitOperationStatus = { DelegateExecution execution ->
+ logger.debug(Prefix + "prepareInitOperationStatus Start")
+
+ String serviceId = execution.getVariable("serviceInstanceId")
+ // 生成 operationId
+ String operationId = execution.getVariable("operationId")
+ logger.debug("Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId)
+
+ OperationStatus initStatus = new OperationStatus()
+ initStatus.setServiceId(serviceId)
+ initStatus.setOperationId(operationId)
+ initStatus.setOperation("CREATE")
+ initStatus.setUserId(execution.getVariable("globalSubscriberId") as String)
+ initStatus.setResult("processing")
+ initStatus.setProgress("0")
+ initStatus.setReason("")
+ initStatus.setOperationContent("communication service create operation start")
+
+ requestDBUtil.prepareUpdateOperationStatus(execution, initStatus)
+
+ logger.debug(Prefix + "prepareInitOperationStatus Exit")
+ }
+
+
+ /**
+ * return sync response
+ */
+ def sendSyncResponse = { DelegateExecution execution ->
+ logger.debug(Prefix + "sendSyncResponse Start")
+ try {
+ String operationId = execution.getVariable("operationId")
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ String createServiceRestRequest = """
+ {
+ "service": {
+ "serviceId":"${serviceInstanceId}",
+ "operationId":"${operationId}"
+ }
+ }
+ """.trim().replaceAll(" ", "")
+
+ logger.debug("sendSyncResponse to APIH:" + "\n" + createServiceRestRequest)
+ sendWorkflowResponse(execution, 202, createServiceRestRequest)
+
+ execution.setVariable("sentSyncResponse", true)
+ } catch (Exception ex) {
+ String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage()
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug(Prefix + "sendSyncResponse Exit")
+ }
+
+
+ /**
+ * query e2e service
+ * @param execution
+ */
+ def prepareDoComposeE2E = { DelegateExecution execution ->
+ logger.debug(Prefix + "prepareDoComposeE2E Start")
+ try {
+ ServiceDecomposition serviceDecomposition = execution.getVariable(
+ "csServiceDecomposition") as ServiceDecomposition
+
+ logger.debug("serviceDecomposition is:" + serviceDecomposition.toJsonString())
+
+ List<ServiceProxy> serviceProxies = serviceDecomposition.getServiceProxy()
+ String sourceModelUuid = serviceProxies.get(0).getSourceModelUuid()
+
+ JSONObject queryJson = new JSONObject()
+ queryJson.put("modelUuid", sourceModelUuid)
+
+ execution.setVariable("e2eServiceModelInfo", queryJson.toString())
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ String msg = "Exception in CreateCommunicationService.prepareDoComposeE2E. " + ex.getMessage()
+ logger.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+
+ logger.debug(Prefix + "prepareDoComposeE2E Exit")
+ }
+
+
+ /**
+ * parse communication service params from request
+ * @param execution
+ */
+ def parseCSParamsFromReq = { DelegateExecution execution ->
+ logger.debug(Prefix + "parseCSParamsFromReq Start")
+ try {
+ //1. CMS info
+
+ String modelInfo = execution.getVariable("csServiceModelInfo")
+ String modelInvariantUuid = jsonUtil.getJsonValue(modelInfo, "modelInvariantUuid")
+ String modelUuid = jsonUtil.getJsonValue(modelInfo, "modelUuid")
+
+ //String modelInvariantUuid = execution.getVariable("modelInvariantId")
+ //String modelUuid = execution.getVariable("modelUuid")
+ String uuiRequest = execution.getVariable("uuiRequest")
+ String useInterval = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.useInterval")
+ String csServiceName = jsonUtil.getJsonValue(uuiRequest, "service.name")
+ String csServiceDescription = jsonUtil.getJsonValue(uuiRequest, "service.description")
+
+ execution.setVariable("modelInvariantUuid", modelInvariantUuid)
+ execution.setVariable("modelUuid", modelUuid)
+ execution.setVariable("useInterval", useInterval)
+ execution.setVariable("csServiceName", csServiceName)
+ execution.setVariable("csServiceDescription", csServiceDescription)
+
+
+ //2. profile info
+ Integer expDataRateDL = jsonUtil.getJsonIntValue(uuiRequest, "service.parameters.requestInputs.expDataRateDL")
+ Integer expDataRateUL = jsonUtil.getJsonIntValue(uuiRequest, "service.parameters.requestInputs.expDataRateUL")
+ Integer latency = jsonUtil.getJsonIntValue(uuiRequest, "service.parameters.requestInputs.latency")
+ Integer maxNumberOfUEs = jsonUtil.getJsonIntValue(uuiRequest, "service.parameters.requestInputs.maxNumberofUEs")
+ String uEMobilityLevel = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.uemobilityLevel")
+ String resourceSharingLevel = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.resourceSharingLevel")
+ String coverageArea = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.coverageAreaList")
+
+ // from template construct input map
+ //String cstTemplate = execution.getVariable("cstTemplate")
+ ServiceDecomposition csServiceDecomposition = execution.getVariable(
+ "csServiceDecomposition") as ServiceDecomposition
+ //String csServiceType = jsonUtil.getJsonValue(cstTemplate, "serviceResources.serviceType")
+ String csServiceType = csServiceDecomposition.getServiceType()
+ execution.setVariable("csServiceType", csServiceType)
+
+ //String cstTemplateInfo = jsonUtil.getJsonValue(cstTemplate, "serviceResources.serviceInfo.serviceInput")
+ ServiceInfo csServiceInfo = csServiceDecomposition.getServiceInfo()
+ String cstTemplateInfo = csServiceInfo.getServiceProperties()
+
+ List<String> csInputs = jsonUtil.StringArrayToList(cstTemplateInfo)
+
+ Map<String, ?> csInputMap = new HashMap<>()
+ for (String csInput : csInputs) {
+ def value
+ if (jsonUtil.getJsonValue(csInput, "type") == "integer") {
+ value = jsonUtil.getJsonValue(csInput, "default")
+ csInputMap.put(jsonUtil.getJsonValue(csInput, "name"), isBlank(value) ? 0 : (value as Integer))
+ } else if (jsonUtil.getJsonValue(csInput, "type") == "string") {
+ csInputMap.put(jsonUtil.getJsonValue(csInput, "name"),
+ jsonUtil.getJsonValue(csInput, "default"))
+ }
+ }
+ csInputMap.put("expDataRateDL", expDataRateDL)
+ csInputMap.put("expDataRateUL", expDataRateUL)
+ csInputMap.put("latency", latency)
+ csInputMap.put("maxNumberofUEs", maxNumberOfUEs)
+ csInputMap.put("uEMobilityLevel", uEMobilityLevel)
+ csInputMap.put("resourceSharingLevel", resourceSharingLevel)
+ csInputMap.put("coverageAreaTAList", coverageArea)
+ csInputMap.put("useInterval", useInterval)
+
+ execution.setVariable("csInputMap", csInputMap)
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ String msg = "Exception in CreateCommunicationService.parseCSParamsFromReq. " + ex.getMessage()
+ logger.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug(Prefix + "parseCSParamsFromReq Exit")
+ }
+
+
+ /**
+ * get E2EST id through CST id and change communication profile to E2E service profile
+ * 1. get E2EST id from cst
+ * 1.1 查source service id
+ * 1.2 source service
+ * 1.3 source service input, init e2e profile
+ */
+ def generateE2EServiceProfile = { DelegateExecution execution ->
+ logger.debug(Prefix + "generateE2EServiceProfile Start")
+ try {
+ ServiceDecomposition e2eServiceDecomposition = execution.getVariable(
+ "e2eServiceDecomposition") as ServiceDecomposition
+ String e2estTemplateInfo = e2eServiceDecomposition.getServiceInfo().getServiceProperties()
+
+ List<String> e2eInputs = jsonUtil.StringArrayToList(e2estTemplateInfo)
+
+ Map<String, ?> csInputMap = execution.getVariable("csInputMap") as Map
+ Map<String, ?> e2eInputMap = new HashMap<>()
+ String key
+ def value
+
+
+ for (String e2eInput in e2eInputs) {
+ if (jsonUtil.getJsonValue(e2eInput, "type") == "integer") {
+ def temp
+ key = jsonUtil.getJsonValue(e2eInput, "name")
+ value = csInputMap.containsKey(key) ? csInputMap.getOrDefault(key, 0) : (isBlank(temp = jsonUtil.getJsonValue(e2eInput, "default")) ? 0 : temp)
+
+ e2eInputMap.put(key, value as Integer)
+ } else {
+ e2eInputMap.put(key = jsonUtil.getJsonValue(e2eInput, "name"), csInputMap.containsKey(key)
+ ? csInputMap.getOrDefault(key, null) : (jsonUtil.getJsonValue(e2eInput, "default")))
+ }
+ }
+
+ e2eInputMap.put("sNSSAI", execution.getVariable("sNSSAI_id"))
+ e2eInputMap.put("areaTrafficCapDL", 100)
+ e2eInputMap.put("areaTrafficCapUL", 100)
+ e2eInputMap.put("sST", execution.getVariable("csServiceType"))
+
+ execution.setVariable("e2eInputMap", e2eInputMap)
+ execution.setVariable("e2eServiceType", e2eServiceDecomposition.getServiceType())
+ execution.setVariable("e2eModelInvariantUuid", e2eServiceDecomposition.getModelInfo().getModelInvariantUuid())
+ execution.setVariable("e2eModelUuid", e2eServiceDecomposition.getModelInfo().getModelUuid())
+
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ String msg = "Exception in DoCreateE2EServiceInstance.createRelationShipInAAI. " + ex.getMessage()
+ logger.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+
+ logger.debug(Prefix + "generateE2EServiceProfile Exit")
+ }
+
+
+ /**
+ * call createE2EService get operation id,
+ * created/processing
+ */
+ def preRequestSend2NSMF(DelegateExecution execution) {
+ logger.debug(Prefix + "preRequestSend2NSMF Start")
+ try {
+
+ //String NSMF_endpoint = "/onap/so/infra/e2eServiceInstances/v3"
+ def NSMF_endpoint = UrnPropertiesReader.getVariable("mso.infra.endpoint.url", execution)
+ def url = NSMF_endpoint + "/e2eServiceInstances/v3"
+ execution.setVariable("NSMF_endpoint", url)
+ //get from model catalog inputs
+ String payload = """
+ {
+ "service":{
+ "name": "${execution.getVariable("csServiceName")}",
+ "description": "e2eService of ${execution.getVariable("modelUuid")}",
+ "serviceInvariantUuid": "${execution.getVariable("e2eModelInvariantUuid")}",
+ "serviceUuid": "${execution.getVariable("e2eModelUuid")}",
+ "globalSubscriberId": "${execution.getVariable("globalSubscriberId")}",
+ "serviceType": "${execution.getVariable("subscriptionServiceType")}",
+ "parameters":{
+ "requestInputs": ${execution.getVariable("e2eInputMap") as JSONObject}
+ }
+ }
+ }
+ """
+ execution.setVariable("CSMF_NSMFRequest", payload.replaceAll("\\s+", ""))
+
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ String msg = "Exception in CreateCommunicationService.preRequestSend2NSMF. " + ex.getMessage()
+ logger.error(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+
+ logger.debug(Prefix + "preRequestSend2NSMF Exit")
+ }
+
+
+ def processNSMFResponse = { DelegateExecution execution ->
+ logger.debug(Prefix + "processNSMFResponse Start")
+ //oof
+ try {
+ def CSMF_NSMFResponseCode = execution.getVariable("CSMF_NSMFResponseCode") as Integer
+ if (CSMF_NSMFResponseCode >= 200 && CSMF_NSMFResponseCode < 400) {
+ def CSMF_NSMFResponse = execution.getVariable("CSMF_NSMFResponse") as String
+ def e2eServiceInstanceId = jsonUtil.getJsonValue(CSMF_NSMFResponse, "service.serviceId")
+ def e2eOperationId = jsonUtil.getJsonValue(CSMF_NSMFResponse, "service.operationId")
+
+ execution.setVariable("e2eServiceInstanceId", e2eServiceInstanceId)
+ execution.setVariable("e2eOperationId", e2eOperationId)
+ execution.setVariable("ProcessNsmfSuccess", "OK")
+ } else {
+ execution.setVariable("ProcessNsmfSuccess", "ERROR")
+ execution.setVariable("operationStatus", "error")
+ execution.setVariable("operationContent",
+ "communication service create operation error: nsmf response fail")
+ execution.setVariable("orchestrationStatus", "error")
+ }
+
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ String msg = "Exception in " + Prefix + "processOOFResponse. " + ex.getMessage()
+ logger.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug(Prefix + "processNSMFResponse Exit")
+ }
+
+
+ /**
+ * create communication service and e2e service relationship
+ *
+ */
+ def createCSAndSSRelationship = { DelegateExecution execution ->
+ logger.debug(Prefix + "createCSAndSSRelationship Start")
+ String msg = ""
+ try {
+ def e2eServiceInstanceId = execution.getVariable("e2eServiceInstanceId")
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+
+ Relationship relationship = new Relationship()
+ String relatedLink = "aai/v16/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${subscriptionServiceType}/service-instances/service-instance/${e2eServiceInstanceId}"
+ relationship.setRelatedLink(relatedLink)
+
+ // create CS and SS relationship in AAI
+ createRelationShipInAAI(execution, relationship)
+
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+
+ msg = "Exception in DoCreateE2EServiceInstance.createCustomRelationship. " + ex.getMessage()
+ logger.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug(Prefix + "createCSAndSSRelationship Exit")
+ }
+
+
+ /**
+ * prepare update operation status to 50% after create relationship in aai
+ * @param execution
+ */
+ def prepareUpdateOperationStatus = { DelegateExecution execution ->
+ logger.debug(Prefix + "prepareUpdateOperationStatus Start")
+ // update status creating
+ OperationStatus status = new OperationStatus()
+ status.setServiceId(execution.getVariable("serviceInstanceId") as String)
+ status.setOperationId(execution.getVariable("operationId") as String)
+ status.setOperation("CREATE")
+ status.setResult("processing")
+ status.setProgress("20")
+ status.setOperationContent("communication service create operation processing: waiting nsmf service create finished")
+ status.setUserId(execution.getVariable("globalSubscriberId") as String)
+
+ requestDBUtil.prepareUpdateOperationStatus(execution, status)
+ logger.debug(Prefix + "prepareUpdateOperationStatus Exit")
+ }
+
+
+ /**
+ * create relationship in AAI
+ */
+ private createRelationShipInAAI = { DelegateExecution execution, final Relationship relationship ->
+ logger.debug(Prefix + "createRelationShipInAAI Start")
+ String msg
+ try {
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
+ execution.getVariable("globalSubscriberId"),
+ execution.getVariable("subscriptionServiceType"),
+ serviceInstanceId).relationshipAPI()
+ client.create(uri, relationship)
+
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ msg = "Exception in CreateCommunicationService.createRelationShipInAAI. " + ex.getMessage()
+ logger.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug(Prefix + "createRelationShipInAAI Exit")
+
+ }
+
+
+ def prepareCallCheckProcessStatus = { DelegateExecution execution ->
+ logger.debug(Prefix + "prepareCallCheckProcessStatus Start")
+
+ def successConditions = new ArrayList<>()
+ successConditions.add("finished")
+ execution.setVariable("successConditions", successConditions)
+
+ def errorConditions = new ArrayList<>()
+ errorConditions.add("error")
+ execution.setVariable("errorConditions", errorConditions)
+
+ execution.setVariable("processServiceType", "communication service")
+
+ execution.setVariable("subOperationType", "CREATE")
+
+ execution.setVariable("timeOut", 3 * 60 * 60 * 1000)
+
+ def successParamMap = new HashMap<String, Object>()
+ successParamMap.put("orchestrationStatus", "deactivated")
+
+ execution.setVariable("successParamMap", successParamMap)
+
+ def errorParamMap = new HashMap<String, Object>()
+ errorParamMap.put("orchestrationStatus", "error")
+
+ execution.setVariable("errorParamMap", errorParamMap)
+
+ def timeOutParamMap = new HashMap<String, Object>()
+ timeOutParamMap.put("orchestrationStatus", "error")
+
+ execution.setVariable("timeOutParamMap", timeOutParamMap)
+
+ execution.setVariable("initProgress", 20)
+ execution.setVariable("endProgress", 90)
+
+ logger.debug(Prefix + "prepareCallCheckProcessStatus Exit")
+ }
+
+
+ /**
+ * prepare update operation status to complete after NSMF process success
+ * @param execution
+ */
+ def prepareCompleteStatus = { DelegateExecution execution ->
+ logger.debug(Prefix + "prepareCompleteStatus Start")
+ OperationStatus status = new OperationStatus()
+ status.setServiceId(execution.getVariable("serviceInstanceId") as String)
+ status.setOperationId(execution.getVariable("operationId") as String)
+ status.setOperation("CREATE")
+ status.setResult(execution.getVariable("operationStatus") as String)
+ status.setProgress("100")
+ status.setOperationContent(execution.getVariable("operationContent") as String)
+ status.setUserId(execution.getVariable("globalSubscriberId") as String)
+
+ requestDBUtil.prepareUpdateOperationStatus(execution, status)
+ logger.debug("prepareCompleteStatus end, serviceInstanceId: " + execution.getVariable("serviceInstanceId")
+ + ", operationId: " + execution.getVariable("operationId"))
+ logger.debug(Prefix + "prepareCompleteStatus Exit")
+ }
+
+
+ /**
+ * update NSMF complete status to AAI when the NSMF process finished
+ * @param execution
+ */
+ def updateFinishStatusInAAI = { DelegateExecution execution ->
+ logger.debug(Prefix + "updateFinishStatusInAAI Start")
+ String msg
+ try {
+
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String orchestrationStatus = execution.getVariable("orchestrationStatus")
+ // create service
+ ServiceInstance csi = new ServiceInstance()
+ csi.setOrchestrationStatus(orchestrationStatus)
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
+ globalSubscriberId, subscriptionServiceType, serviceInstanceId)
+ client.update(uri, csi)
+ logger.debug(Prefix + "updateFinishStatusInAAI update communication service status to deactivated")
+
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ msg = "Exception in complete communication service " + ex.getMessage()
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug(Prefix + "updateFinishStatusInAAI Exit")
+ }
+
+
+ public sendSyncError = { DelegateExecution execution ->
+ logger.debug("sendSyncError Start")
+ try {
+ String errorMessage
+ if (execution.getVariable("WorkflowException") instanceof WorkflowException) {
+ WorkflowException wfe = execution.getVariable("WorkflowException") as WorkflowException
+ errorMessage = wfe.getErrorMessage()
+ } else {
+ errorMessage = "Sending Sync Error."
+ }
+
+ String buildWorkflowException =
+ """<aetgt:WorkflowException xmlns:aetgt="http://org.onap/so/workflow/schema/v1">
+ <aetgt:ErrorMessage>${MsoUtils.xmlEscape(errorMessage)}</aetgt:ErrorMessage>
+ <aetgt:ErrorCode>7000</aetgt:ErrorCode>
+ </aetgt:WorkflowException>"""
+
+ logger.debug(buildWorkflowException)
+ sendWorkflowResponse(execution, 500, buildWorkflowException)
+
+ } catch (Exception ex) {
+ logger.debug("Sending Sync Error Activity Failed. " + "\n" + ex.getMessage())
+ }
+ logger.debug(Prefix + "sendSyncError Exit")
+ }
+
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy
index cae629fdf0..650f79b633 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy
@@ -39,7 +39,7 @@ import org.onap.so.client.aai.AAIObjectType
import org.onap.so.client.aai.AAIResourcesClient
import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import org.onap.so.logger.LoggingAnchor
import org.onap.so.logger.MessageEnum
import org.slf4j.Logger
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy
index 4b3c1aa7b4..8b9726c2b7 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy
@@ -127,7 +127,11 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor {
String key = iterator.next()
HashMap<String, String> hashMap = new HashMap()
hashMap.put("name", key)
- hashMap.put("value", jsonObject.get(key))
+ if(jsonObject.get(key)==null){
+ hashMap.put("value", "")
+ }else{
+ hashMap.put("value", jsonObject.get(key))
+ }
paramList.add(hashMap)
}
Map<String, List<Map<String, Object>>> paramMap = new HashMap()
@@ -163,36 +167,20 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor {
String serInput = jsonUtil.getJsonValue(resourceInputTmp, "requestsInputs")
switch (modelName) {
- case ~/[\w\s\W]*OLT[\w\s\W]*/ :
+ case ~/[\w\s\W]*OLT[\w\s\W]*/ : // for backward compatibilty only, this case will be deprecated
+ case ~/[\w\s\W]*AccessConnectivity[\w\s\W]*/ :
// get the required properties and update in resource input
def resourceInput = resourceInputObj.getResourceParameters()
String incomingRequest = resourceInputObj.getRequestsInputs()
String serviceParameters = JsonUtils.getJsonValue(incomingRequest, "service.parameters")
String requestInputs = JsonUtils.getJsonValue(serviceParameters, "requestInputs")
- String cvlan
- String svlan
- String remoteId
-
- List<Metadatum> metadatum = getMetaDatum(resourceInputObj.getGlobalSubscriberId(),
- resourceInputObj.getServiceType(),
- resourceInputObj.getServiceInstanceId())
- for(Metadatum datum: metadatum) {
- if (datum.getMetaname().equalsIgnoreCase("cvlan")) {
- cvlan = datum.getMetaval()
- }
-
- if (datum.getMetaname().equalsIgnoreCase("svlan")) {
- svlan = datum.getMetaval()
- }
-
- if (datum.getMetaname().equalsIgnoreCase("remoteId")) {
- remoteId = datum.getMetaval()
- }
- }
-
- logger.debug("cvlan: "+cvlan+" | svlan: "+svlan+" | remoteId: "+remoteId)
-
+ String cvlan = jsonUtil.getJsonValue(serInput,
+ "service.parameters.requestInputs.cvlan")
+ String svlan = jsonUtil.getJsonValue(serInput,
+ "service.parameters.requestInputs.svlan")
+ String remoteId = jsonUtil.getJsonValue(serInput,
+ "service.parameters.requestInputs.edgeinternetprofile_ip_remote_id")
String manufacturer = jsonUtil.getJsonValue(serInput,
"service.parameters.requestInputs.ont_ont_manufacturer")
String ontsn = jsonUtil.getJsonValue(serInput,
@@ -209,7 +197,8 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor {
logger.debug("new resource Input :" + resourceInputObj.toString())
break
- case ~/[\w\s\W]*EdgeInternetProfile[\w\s\W]*/ :
+ case ~/[\w\s\W]*EdgeInternetProfile[\w\s\W]*/ : // for backward compatibilty only, this case will be deprecated
+ case ~/[\w\s\W]*InternetProfile[\w\s\W]*/ :
// get the required properties and update in resource input
def resourceInput = resourceInputObj.getResourceParameters()
String incomingRequest = resourceInputObj.getRequestsInputs()
@@ -217,37 +206,34 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor {
String requestInputs = JsonUtils.getJsonValue(serviceParameters, "requestInputs")
JSONObject inputParameters = new JSONObject(requestInputs)
- String cvlan
- String svlan
- String remoteId
+ String cvlan = jsonUtil.getJsonValue(serInput,
+ "service.parameters.requestInputs.cvlan")
+ String svlan = jsonUtil.getJsonValue(serInput,
+ "service.parameters.requestInputs.svlan")
String manufacturer = jsonUtil.getJsonValue(serInput,
"service.parameters.requestInputs.ont_ont_manufacturer")
-
+ String remoteId = jsonUtil.getJsonValue(serInput,
+ "service.parameters.requestInputs.edgeinternetprofile_ip_remote_id")
String ontsn = jsonUtil.getJsonValue(serInput,
"service.parameters.requestInputs.ont_ont_serial_num")
-
- List<Metadatum> metadatum = getMetaDatum(resourceInputObj.getGlobalSubscriberId(),
- resourceInputObj.getServiceType(),
- resourceInputObj.getServiceInstanceId())
- for(Metadatum datum: metadatum) {
- if (datum.getMetaname().equalsIgnoreCase("cvlan")) {
- cvlan = datum.getMetaval()
- }
-
- if (datum.getMetaname().equalsIgnoreCase("svlan")) {
- svlan = datum.getMetaval()
- }
-
- if (datum.getMetaname().equalsIgnoreCase("remoteId")) {
- remoteId = datum.getMetaval()
- }
- }
+ String serviceType = jsonUtil.getJsonValue(serInput,
+ "service.parameters.requestInputs.edgeinternetprofile_ip_service_type")
+ String macAddr = jsonUtil.getJsonValue(serInput,
+ "service.parameters.requestInputs.edgeinternetprofile_ip_rg_mac_addr")
+ String upStream = jsonUtil.getJsonValue(serInput,
+ "service.parameters.requestInputs.edgeinternetprofile_ip_upstream_speed")
+ String downStream = jsonUtil.getJsonValue(serInput,
+ "service.parameters.requestInputs.edgeinternetprofile_ip_downstream_speed")
String uResourceInput = jsonUtil.addJsonValue(resourceInput, "requestInputs.c_vlan", cvlan)
uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.s_vlan", svlan)
uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.manufacturer", manufacturer)
- uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.ip_access_id", remoteId)
+ uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.ip_remote_id", remoteId)
uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.ont_sn", ontsn)
+ uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.ip_service_type", serviceType)
+ uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.ip_rg_mac_addr", macAddr)
+ uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.ip_upstream_speed", upStream)
+ uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.ip_downstream_speed", downStream)
logger.debug("old resource input:" + resourceInputObj.toString())
resourceInputObj.setResourceParameters(uResourceInput)
execution.setVariable(Prefix + "resourceInput", resourceInputObj.toString())
@@ -363,6 +349,32 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor {
switch (modelType) {
case "VNF" :
+ if(modelName.contains("UNI") && "MDONS_OTN".equals(serviceType)){
+ source = "SO"
+ sdncTopologyCreateRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1"
+ xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1"
+ xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1">
+ <sdncadapter:RequestHeader>
+ <sdncadapter:RequestId>${msoUtils.xmlEscape(hdrRequestId)}</sdncadapter:RequestId>
+ <sdncadapter:SvcInstanceId>${msoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
+ <sdncadapter:SvcAction>${msoUtils.xmlEscape(sdnc_svcAction)}</sdncadapter:SvcAction>
+ <sdncadapter:SvcOperation>optical-service-create</sdncadapter:SvcOperation>
+ <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl>
+ <sdncadapter:MsoAction>opticalservice</sdncadapter:MsoAction>
+ </sdncadapter:RequestHeader>
+ <sdncadapterworkflow:SDNCRequestData>
+ <request-id>${msoUtils.xmlEscape(hdrRequestId)}</request-id>
+ <global-customer-id>${msoUtils.xmlEscape(globalCustomerId)}</global-customer-id>
+ <service-type>${msoUtils.xmlEscape(serviceType)}</service-type>
+ <notification-url>sdncCallback</notification-url>
+ <source>${msoUtils.xmlEscape(source)}</source>
+ <service-id>${msoUtils.xmlEscape(serviceInstanceId)}</service-id>
+ <payload>
+ $netowrkInputParameters
+ </payload>
+ </sdncadapterworkflow:SDNCRequestData>
+ </aetgt:SDNCAdapterWorkflowRequest>""".trim()
+ } else{
sdncTopologyCreateRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1"
xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1"
xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1">
@@ -417,6 +429,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor {
</vnf-request-input>
</sdncadapterworkflow:SDNCRequestData>
</aetgt:SDNCAdapterWorkflowRequest>""".trim()
+ }
break
case "GROUP" :
String vnfid = resourceInputObj.getVnfId()
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy
new file mode 100644
index 0000000000..1efc1c11aa
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy
@@ -0,0 +1,513 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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 com.fasterxml.jackson.databind.ObjectMapper
+import org.onap.aai.domain.yang.ServiceInstance
+import org.onap.so.client.HttpClient
+import org.onap.so.client.HttpClientFactory
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.AAIResourcesClient
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+
+import javax.ws.rs.core.Response
+
+import static org.apache.commons.lang3.StringUtils.*
+import org.springframework.web.util.UriUtils
+import groovy.json.JsonSlurper
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.logging.filter.base.ONAPComponents
+import org.onap.so.beans.nsmf.SliceTaskParams
+import org.onap.so.db.request.beans.OrchestrationTask
+import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.onap.so.bpmn.common.scripts.ExceptionUtil
+import org.onap.so.bpmn.common.scripts.OofUtils
+import org.onap.so.bpmn.core.UrnPropertiesReader
+import org.onap.so.bpmn.common.scripts.MsoUtils
+import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.logging.filter.base.ErrorCode
+import org.onap.so.logger.LoggingAnchor
+import org.onap.so.logger.MessageEnum
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+
+public class CreateSliceService extends AbstractServiceTaskProcessor {
+ String Prefix = "CRESS_"
+
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+ JsonUtils jsonUtil = new JsonUtils()
+ JsonSlurper jsonSlurper = new JsonSlurper()
+ ObjectMapper objectMapper = new ObjectMapper()
+ OofUtils oofUtils = new OofUtils()
+ private static final Logger logger = LoggerFactory.getLogger(CreateSliceService.class)
+
+
+ public void preProcessRequest(DelegateExecution execution) {
+ logger.debug("Start preProcessRequest")
+ execution.setVariable("prefix", Prefix)
+ String msg = ""
+
+ try {
+ String ssRequest = execution.getVariable("bpmnRequest")
+ logger.debug(ssRequest)
+
+ String requestId = execution.getVariable("mso-request-id")
+ execution.setVariable("msoRequestId", requestId)
+ logger.debug("Input Request:" + ssRequest + " reqId:" + requestId)
+
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ if (isBlank(serviceInstanceId)) {
+ serviceInstanceId = UUID.randomUUID().toString()
+ }
+
+ String operationId = UUID.randomUUID().toString()
+ execution.setVariable("operationId", operationId)
+
+ logger.debug("Generated new Service Instance:" + serviceInstanceId)
+ serviceInstanceId = UriUtils.encode(serviceInstanceId, "UTF-8")
+ execution.setVariable("serviceInstanceId", serviceInstanceId)
+
+ //subscriberInfo
+ String globalSubscriberId = jsonUtil.getJsonValue(ssRequest, "requestDetails.subscriberInfo.globalSubscriberId")
+ if (isBlank(globalSubscriberId)) {
+ msg = "Input globalSubscriberId' is null"
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else {
+ execution.setVariable("globalSubscriberId", globalSubscriberId)
+ }
+
+ //requestInfo
+ execution.setVariable("source", jsonUtil.getJsonValue(ssRequest, "requestDetails.requestInfo.source"))
+ execution.setVariable("serviceInstanceName", jsonUtil.getJsonValue(ssRequest, "requestDetails.requestInfo.instanceName"))
+ execution.setVariable("disableRollback", jsonUtil.getJsonValue(ssRequest, "requestDetails.requestInfo.suppressRollback"))
+ String productFamilyId = jsonUtil.getJsonValue(ssRequest, "requestDetails.requestInfo.productFamilyId")
+ if (isBlank(productFamilyId)) {
+ msg = "Input productFamilyId is null"
+ logger.debug(msg)
+ //exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else {
+ execution.setVariable("productFamilyId", productFamilyId)
+ }
+
+ //modelInfo
+ String serviceModelInfo = jsonUtil.getJsonValue(ssRequest, "requestDetails.modelInfo")
+ if (isBlank(serviceModelInfo)) {
+ msg = "Input serviceModelInfo is null"
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else {
+ execution.setVariable("serviceModelInfo", serviceModelInfo)
+ }
+
+ logger.debug("modelInfo: " + serviceModelInfo)
+
+ //requestParameters
+ String subscriptionServiceType = jsonUtil.getJsonValue(ssRequest, "requestDetails.requestParameters.subscriptionServiceType")
+ if (isBlank(subscriptionServiceType)) {
+ msg = "Input subscriptionServiceType is null"
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else {
+ execution.setVariable("subscriptionServiceType", subscriptionServiceType)
+ }
+ logger.debug("subscriptionServiceType: " + subscriptionServiceType)
+
+ /*
+ * Extracting User Parameters from incoming Request and converting into a Map
+ */
+ Map reqMap = jsonSlurper.parseText(ssRequest)
+
+ //InputParams
+ def userParamsList = reqMap.requestDetails?.requestParameters?.userParams
+
+ Map<String, String> inputMap = [:]
+ if (userParamsList) {
+ for (def i = 0; i < userParamsList.size(); i++) {
+ def userParams1 = userParamsList.get(i)
+ userParams1.each { param -> inputMap.put(param.key, param.value) }
+ }
+ }
+
+ logger.debug("User Input Parameters map: " + inputMap.toString())
+ String uuiRequest = inputMap.get("UUIRequest")
+ Map uuiReqMap = jsonSlurper.parseText(uuiRequest)
+ Map<String, Object> serviceObject = (Map<String, Object>) uuiReqMap.get("service")
+ Map<String, Object> parameterObject = (Map<String, Object>) serviceObject.get("parameters")
+ Map<String, Object> requestInputs = (Map<String, Object>) parameterObject.get("requestInputs")
+
+ execution.setVariable("serviceInputParams", inputMap)
+ execution.setVariable("uuiRequest", uuiRequest)
+ execution.setVariable("serviceProfile", requestInputs)
+
+ //TODO
+ //execution.setVariable("serviceInputParams", jsonUtil.getJsonValue(siRequest, "requestDetails.requestParameters.userParams"))
+ //execution.setVariable("failExists", true)
+
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ msg = "Exception in preProcessRequest " + ex.getMessage()
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug("Finish preProcessRequest")
+ }
+
+ public void getNSTSelection(DelegateExecution execution) {
+ logger.debug("Start getNSTSelection")
+ String requestId = execution.getVariable("msoRequestId")
+ Map<String, Object> serviceProfile = execution.getVariable("serviceProfile")
+ String oofUrl = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
+
+ def authHeader = ""
+ String basicAuth = UrnPropertiesReader.getVariable("mso.oof.auth", execution)
+ String msokey = UrnPropertiesReader.getVariable("mso.msoKey", execution)
+
+ String basicAuthValue = utils.encrypt(basicAuth, msokey)
+ if (basicAuthValue != null) {
+ logger.debug( "Obtained BasicAuth username and password for OOF: " + basicAuthValue)
+ try {
+ authHeader = utils.getBasicAuth(basicAuthValue, msokey)
+ execution.setVariable("BasicAuthHeaderValue", authHeader)
+ } catch (Exception ex) {
+ logger.debug( "Unable to encode username and password string: " + ex)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - Unable to " +
+ "encode username and password string")
+ }
+ } else {
+ logger.debug( "Unable to obtain BasicAuth - BasicAuth value null")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth " +
+ "value null")
+ }
+
+ URL requestUrl = new URL(oofUrl + "/api/oof/v1/selection/nst")
+ String oofRequest = oofUtils.buildSelectNSTRequest(requestId, serviceProfile)
+ HttpClient httpClient = new HttpClientFactory().newJsonClient(requestUrl, ONAPComponents.OOF)
+ httpClient.addAdditionalHeader("Authorization", authHeader)
+ Response httpResponse = httpClient.post(oofRequest)
+
+ int responseCode = httpResponse.getStatus()
+ logger.debug("OOF sync response code is: " + responseCode)
+
+ if(responseCode != 200){
+ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.")
+ }
+
+ Map<String, Object> nstSolution
+ try {
+ Map<String, Object> resMap = httpResponse.readEntity(Map.class)
+ List<Map<String, Object>> nstSolutions = (List<Map<String, Object>>) resMap.get("solutions")
+ nstSolution = nstSolutions.get(0)
+ execution.setVariable("nstSolution", nstSolution)
+ } catch (Exception ex) {
+ logger.debug( "Failed to get NST solution suggested by OOF.")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Failed to get NST solution suggested by OOF.")
+ }
+
+ logger.debug("Finish getNSTSelection")
+
+ }
+
+ public void prepareDecomposeService(DelegateExecution execution) {
+ logger.debug("Start prepareDecomposeService")
+ String uuiRequest = execution.getVariable("uuiRequest")
+ String ssModelInvariantUuid = jsonUtil.getJsonValue(uuiRequest, "service.serviceInvariantUuid")
+ String ssModelUuid = jsonUtil.getJsonValue(uuiRequest, "service.serviceUuid")
+ String ssServiceModelInfo = """{
+ "modelInvariantUuid":"${ssModelInvariantUuid}",
+ "modelUuid":"${ssModelUuid}",
+ "modelVersion":""
+ }"""
+ execution.setVariable("ssServiceModelInfo", ssServiceModelInfo)
+
+ logger.debug("Finish prepareDecomposeService")
+ }
+
+ public void processDecomposition(DelegateExecution execution) {
+ logger.debug("Start processDecomposition")
+ String uuiRequest = execution.getVariable("uuiRequest")
+ Map<String, Object> serviceProfile = execution.getVariable("serviceProfile")
+ Map<String, Object> nstSolution = execution.getVariable("nstSolution")
+
+ Map uuiReqMap = jsonSlurper.parseText(uuiRequest)
+ Map<String, Object> serviceObject = (Map<String, Object>) uuiReqMap.get("service")
+ String subscriptionServiceType = serviceObject.get("serviceType")
+
+ String serviceType = (String) serviceProfile.get("sST")
+ String resourceSharingLevel = (String) serviceProfile.get("resourceSharingLevel")
+ String nstModelUuid = (String) nstSolution.get("UUID")
+ String nstModelInvariantUuid = (String) nstSolution.get("invariantUUID")
+
+ execution.setVariable("subscriptionServiceType", subscriptionServiceType)
+ execution.setVariable("serviceType", serviceType)
+ execution.setVariable("resourceSharingLevel", resourceSharingLevel)
+ execution.setVariable("nstModelUuid", nstModelUuid)
+ execution.setVariable("nstModelInvariantUuid", nstModelInvariantUuid)
+
+ logger.debug("Finish processDecomposition")
+ }
+
+ public void prepareCreateOrchestrationTask(DelegateExecution execution) {
+ logger.debug("Start createOrchestrationTask")
+ String taskId = execution.getBusinessKey()
+ execution.setVariable("orchestrationTaskId", taskId)
+ logger.debug("BusinessKey: " + taskId)
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ String serviceInstanceName = execution.getVariable("serviceInstanceName")
+ String taskName = "SliceServiceTask"
+ String taskStatus = "Planning"
+ String isManual = "false"
+ String requestMethod = "POST"
+ execution.setVariable("CSSOT_taskId", taskId)
+ execution.setVariable("CSSOT_name", taskName)
+ execution.setVariable("CSSOT_status", taskStatus)
+ execution.setVariable("CSSOT_isManual", isManual)
+ execution.setVariable("CSSOT_requestMethod", requestMethod)
+
+ Map<String, Object> serviceProfile = execution.getVariable("serviceProfile")
+
+ SliceTaskParams sliceTaskParams = new SliceTaskParams()
+ sliceTaskParams.setServiceId(serviceInstanceId)
+ sliceTaskParams.setServiceName(serviceInstanceName)
+ sliceTaskParams.setServiceProfile(serviceProfile)
+ execution.setVariable("sliceTaskParams", sliceTaskParams)
+
+ String paramJson = sliceTaskParams.convertToJson()
+ execution.setVariable("CSSOT_paramJson", paramJson)
+ logger.debug("CSSOT_paramJson: " + paramJson)
+
+ logger.debug("Finish createOrchestrationTask")
+ }
+
+ public void prepareUpdateOrchestrationTask(DelegateExecution execution) {
+ logger.debug("Start prepareUpdateOrchestrationTask")
+ String requestMethod = "PUT"
+ String taskStatus = execution.getVariable("taskStatus")
+ SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
+ String paramJson = sliceTaskParams.convertToJson()
+ execution.setVariable("CSSOT_status", taskStatus)
+ execution.setVariable("CSSOT_paramJson", paramJson)
+ execution.setVariable("CSSOT_requestMethod", requestMethod)
+ logger.debug("Finish prepareUpdateOrchestrationTask")
+ }
+
+ public void prepareGetUserOptions(DelegateExecution execution) {
+ logger.debug("Start prepareGetUserOptions")
+ String requestMethod = "GET"
+ execution.setVariable("taskAction", "commit")
+ String taskAction = execution.getVariable("taskAction")
+ logger.debug("task action is: " + taskAction)
+ if (!"commit".equals(taskAction) && !"abort".equals(taskAction)) {
+ String msg = "Unknown task action: " + taskAction
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ }
+ execution.setVariable("CSSOT_requestMethod", requestMethod)
+ logger.debug("Finish prepareGetUserOptions")
+ }
+
+ public void processUserOptions(DelegateExecution execution) {
+ logger.debug("Start processUserOptions")
+ String response = execution.getVariable("CSSOT_dbResponse")
+ OrchestrationTask orchestrationTask = objectMapper.readValue(response, OrchestrationTask.class)
+ String paramJson = orchestrationTask.getParams()
+ logger.debug("paramJson: " + paramJson)
+ SliceTaskParams sliceTaskParams = new SliceTaskParams()
+ sliceTaskParams.convertFromJson(paramJson)
+ execution.setVariable("sliceTaskParams", sliceTaskParams)
+ logger.debug("Finish processUserOptions")
+ }
+
+ public void updateAAIOrchStatus(DelegateExecution execution) {
+ logger.debug("Start updateAAIOrchStatus")
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ String orchStatus = execution.getVariable("orchestrationStatus")
+
+ try {
+ ServiceInstance si = execution.getVariable("serviceInstanceData")
+ si.setOrchestrationStatus(orchStatus)
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId)
+ client.update(uri, si)
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ String msg = "Exception in CreateSliceService.updateAAIOrchStatus " + ex.getMessage()
+ logger.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+
+ logger.debug("Finish updateAAIOrchStatus")
+ }
+
+ public void prepareInitServiceOperationStatus(DelegateExecution execution) {
+ logger.debug("Start prepareInitServiceOperationStatus")
+ try{
+ String serviceId = execution.getVariable("serviceInstanceId")
+ String operationId = execution.getVariable("operationId")
+ String operationType = "CREATE"
+ String userId = execution.getVariable("globalSubscriberId")
+ String result = "processing"
+ String progress = "0"
+ String reason = ""
+ String operationContent = "Prepare service creation"
+ logger.debug("Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId)
+ serviceId = UriUtils.encode(serviceId,"UTF-8")
+ execution.setVariable("serviceInstanceId", serviceId)
+ execution.setVariable("operationType", operationType)
+
+ def dbAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.openecomp.db.endpoint",execution)
+ execution.setVariable("CSSOS_dbAdapterEndpoint", dbAdapterEndpoint)
+ logger.debug("DB Adapter Endpoint is: " + dbAdapterEndpoint)
+ def dbAdapterAuth = UrnPropertiesReader.getVariable("mso.requestDb.auth")
+ Map<String, String> CSSOS_headerMap = [:]
+ CSSOS_headerMap.put("content-type", "application/soap+xml")
+ CSSOS_headerMap.put("Authorization", dbAdapterAuth)
+ execution.setVariable("CSSOS_headerMap", CSSOS_headerMap)
+ logger.debug("DB Adapter Header is: " + CSSOS_headerMap)
+
+ String payload =
+ """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:ns="http://org.onap.so/requestsdb">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <ns:initServiceOperationStatus xmlns:ns="http://org.onap.so/requestsdb">
+ <serviceId>${MsoUtils.xmlEscape(serviceId)}</serviceId>
+ <operationId>${MsoUtils.xmlEscape(operationId)}</operationId>
+ <operationType>${MsoUtils.xmlEscape(operationType)}</operationType>
+ <userId>${MsoUtils.xmlEscape(userId)}</userId>
+ <result>${MsoUtils.xmlEscape(result)}</result>
+ <operationContent>${MsoUtils.xmlEscape(operationContent)}</operationContent>
+ <progress>${MsoUtils.xmlEscape(progress)}</progress>
+ <reason>${MsoUtils.xmlEscape(reason)}</reason>
+ </ns:initServiceOperationStatus>
+ </soapenv:Body>
+ </soapenv:Envelope>"""
+
+ payload = utils.formatXml(payload)
+ execution.setVariable("CSSOS_updateServiceOperStatusRequest", payload)
+ logger.debug("Outgoing updateServiceOperStatusRequest: \n" + payload)
+ }catch(Exception e){
+ logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ "Exception Occured Processing prepareInitServiceOperationStatus.", "BPMN",
+ ErrorCode.UnknownError.getValue(), "Exception is:\n" + e)
+ }
+ logger.debug("Finish prepareInitServiceOperationStatus")
+ }
+
+ public void prepareUpdateServiceOperationStatus(DelegateExecution execution) {
+ logger.debug("Start preUpdateServiceOperationStatus")
+ try{
+ String serviceId = execution.getVariable("serviceInstanceId")
+ String operationId = execution.getVariable("operationId")
+ String operationType = execution.getVariable("operationType")
+ String userId = execution.getVariable("globalSubscriberId")
+ String result = execution.getVariable("operationResult")
+ String progress = execution.getVariable("operationProgress")
+ String reason = execution.getVariable("operationReason")
+ String operationContent = "service: " + result + " progress: " + progress
+
+ String payload =
+ """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:ns="http://org.onap.so/requestsdb">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <ns:initServiceOperationStatus xmlns:ns="http://org.onap.so/requestsdb">
+ <serviceId>${MsoUtils.xmlEscape(serviceId)}</serviceId>
+ <operationId>${MsoUtils.xmlEscape(operationId)}</operationId>
+ <operationType>${MsoUtils.xmlEscape(operationType)}</operationType>
+ <userId>${MsoUtils.xmlEscape(userId)}</userId>
+ <result>${MsoUtils.xmlEscape(result)}</result>
+ <operationContent>${MsoUtils.xmlEscape(operationContent)}</operationContent>
+ <progress>${MsoUtils.xmlEscape(progress)}</progress>
+ <reason>${MsoUtils.xmlEscape(reason)}</reason>
+ </ns:initServiceOperationStatus>
+ </soapenv:Body>
+ </soapenv:Envelope>"""
+
+ payload = utils.formatXml(payload)
+ execution.setVariable("CSSOS_updateServiceOperStatusRequest", payload)
+ logger.debug("Outgoing updateServiceOperStatusRequest: \n" + payload)
+
+ }catch(Exception e){
+ logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ "Exception Occured Processing preUpdateServiceOperationStatus.", "BPMN",
+ ErrorCode.UnknownError.getValue(), "Exception is:\n" + e.getMessage())
+ }
+ logger.debug("Finish preUpdateServiceOperationStatus")
+ }
+
+ public void sendSyncResponse(DelegateExecution execution) {
+ logger.debug("Start sendSyncResponse")
+ try {
+ String operationId = execution.getVariable("operationId")
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ // RESTResponse for API Handler (APIH) Reply Task
+ String createServiceRestRequest = """{"service":{"serviceId":"${serviceInstanceId}","operationId":"${operationId}"}}""".trim()
+ logger.debug("sendSyncResponse to APIH:" + "\n" + createServiceRestRequest)
+ sendWorkflowResponse(execution, 202, createServiceRestRequest)
+ execution.setVariable("sentSyncResponse", true)
+ } catch (Exception e) {
+ String msg = "Exceptuion in sendSyncResponse:" + e.getMessage()
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug("Finish sendSyncResponse")
+ }
+
+ public void prepareCompletionRequest (DelegateExecution execution) {
+ logger.trace("Start prepareCompletionRequest")
+ try {
+ String requestId = execution.getVariable("msoRequestId")
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ String source = execution.getVariable("source")
+
+ String msoCompletionRequest =
+ """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1"
+ xmlns:ns="http://org.onap/so/request/types/v1">
+ <request-info xmlns="http://org.onap/so/infra/vnf-request/v1">
+ <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
+ <action>CREATE</action>
+ <source>${MsoUtils.xmlEscape(source)}</source>
+ </request-info>
+ <status-message>Service Instance was created successfully.</status-message>
+ <serviceInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</serviceInstanceId>
+ <mso-bpel-name>CreateGenericALaCarteServiceInstance</mso-bpel-name>
+ </aetgt:MsoCompletionRequest>"""
+
+ // Format Response
+ String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest)
+
+ execution.setVariable("completionRequest", xmlMsoCompletionRequest)
+ logger.debug("Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest)
+
+ } catch (Exception ex) {
+ String msg = " Exception in prepareCompletion:" + ex.getMessage()
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.trace("Finish prepareCompletionRequest")
+ }
+
+}
+
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy
index c9dadf57cb..fc97c292fb 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy
@@ -36,7 +36,7 @@ import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.bpmn.infrastructure.aai.AAICreateResources
-import org.onap.so.logger.ErrorCode;
+import org.onap.logging.filter.base.ErrorCode;
import org.onap.so.logger.MessageEnum
import org.slf4j.Logger
import org.slf4j.LoggerFactory
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy
index 1fba23d3c8..33a607268d 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy
@@ -32,7 +32,7 @@ import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.client.aai.AAIObjectType
import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import org.onap.so.logger.MessageEnum
import org.slf4j.Logger
import org.slf4j.LoggerFactory
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVnfInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVnfInfra.groovy
index 3eb15558d2..dc9655e7af 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVnfInfra.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVnfInfra.groovy
@@ -24,7 +24,7 @@ package org.onap.so.bpmn.infrastructure.scripts
import org.onap.so.logger.LoggingAnchor
import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import static org.apache.commons.lang3.StringUtils.*;
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy
new file mode 100644
index 0000000000..b121083954
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy
@@ -0,0 +1,460 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2019, CMCC Technologies Co., Ltd.
+ #
+ # 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.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.Relationship
+import org.onap.aai.domain.yang.ServiceInstance
+import org.onap.aai.domain.yang.CommunicationServiceProfile
+import org.onap.aai.domain.yang.CommunicationServiceProfiles
+import org.onap.logging.filter.base.ONAPComponents
+import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.onap.so.bpmn.common.scripts.ExceptionUtil
+import org.onap.so.bpmn.common.scripts.MsoUtils
+import org.onap.so.bpmn.common.scripts.RequestDBUtil
+import org.onap.so.bpmn.core.UrnPropertiesReader
+import org.onap.so.bpmn.core.WorkflowException
+import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.client.HttpClient
+import org.onap.so.client.HttpClientFactory
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.AAIResourcesClient
+import org.onap.so.client.aai.entities.AAIResultWrapper
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+import org.onap.so.db.request.beans.OperationStatus
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+
+import javax.ws.rs.NotFoundException
+import javax.ws.rs.core.Response
+
+import static org.apache.commons.lang3.StringUtils.isBlank
+
+class DeleteCommunicationService extends AbstractServiceTaskProcessor {
+ private final String PREFIX ="DeleteCommunicationService"
+ private final Long TIMEOUT = 60 * 60 * 1000
+
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+ JsonUtils jsonUtil = new JsonUtils()
+ private RequestDBUtil requestDBUtil = new RequestDBUtil()
+ private static final Logger LOGGER = LoggerFactory.getLogger(DeleteCommunicationService.class)
+
+ @Override
+ void preProcessRequest(DelegateExecution execution) {
+ execution.setVariable("prefix",PREFIX)
+ String msg = ""
+
+ LOGGER.trace("Starting preProcessRequest")
+
+ try {
+ // check for incoming json message/input
+ String siRequest = execution.getVariable("bpmnRequest")
+ String requestId = execution.getVariable("mso-request-id")
+ execution.setVariable("msoRequestId", requestId)
+ execution.setVariable("operationType", "DELETE")
+
+ //communication service id
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ if (isBlank(serviceInstanceId)) {
+ msg = "communication-service id is null"
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ }
+
+ LOGGER.info("Input Request: ${siRequest}, reqId: ${requestId}, serviceInstanceId: ${serviceInstanceId}")
+
+ //requestParameters
+ checkAndSetRequestParam(siRequest,"globalSubscriberId",false,execution)
+ checkAndSetRequestParam(siRequest,"serviceType",false,execution)
+ checkAndSetRequestParam(siRequest,"operationId",false,execution)
+
+ } catch (BpmnError e) {
+ throw e
+ } catch (any) {
+ msg = "Exception in preProcessRequest " + any.getCause()
+ LOGGER.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ LOGGER.trace("Exit preProcessRequest")
+ }
+
+
+ /**
+ * prepare update operation status
+ * @param execution
+ */
+ void preInitUpdateOperationStatus(DelegateExecution execution){
+ LOGGER.trace(" ======== STARTED initUpdateOperationStatus Process ======== ")
+ try{
+ execution.setVariable("result","processing")
+ execution.setVariable("progress","0")
+ execution.setVariable("operationContent","delete communication service operation start")
+ setOperationStatus(execution)
+
+ }catch(Exception e){
+ LOGGER.error("Exception Occured Processing initUpdateOperationStatus. Exception is:\n" + e)
+ execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during initUpdateOperationStatus Method:\n" + e.getMessage())
+ }
+ LOGGER.trace("======== COMPLETED initUpdateOperationStatus Process ======== ")
+ }
+
+ /**
+ * send sync response
+ * @param execution
+ */
+ void sendSyncResponse(DelegateExecution execution) {
+ LOGGER.debug("Begin sendSyncResponse")
+
+ try {
+ String operationId = execution.getVariable("operationId")
+ String syncResponse = """{"operationId":"${operationId}"}""".trim()
+ sendWorkflowResponse(execution, 202, syncResponse)
+
+ } catch (Exception ex) {
+ String msg = "Exception in sendSyncResponse: " + ex.getMessage()
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ LOGGER.debug("Exit sendSyncResponse")
+ }
+
+ /**
+ * query CommunicationSerive from AAI
+ * save e2eslice-service instance id and service name
+ * @param execution
+ */
+ void queryCommunicationSeriveFromAAI(DelegateExecution execution)
+ {
+ LOGGER.trace(" ***** begin queryCommunicationSeriveFromAAI *****")
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+
+ String errorMsg = "query communication service from aai failed"
+ AAIResultWrapper wrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, serviceInstanceId, errorMsg)
+ Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class)
+ if(si.isPresent())
+ {
+ String serviceInstName = si.get()?.getServiceInstanceName()
+ String e2eSliceServiceInstId
+ if(si.isPresent())
+ {
+ List<Relationship> relationshipList = si.get().getRelationshipList()?.getRelationship()
+ for (Relationship relationship : relationshipList)
+ {
+ String relatedTo = relationship.getRelatedTo()
+ if (relatedTo == "service-instance")
+ {
+ String relatedLink = relationship.getRelatedLink()?:""
+ e2eSliceServiceInstId = relatedLink ? relatedLink.substring(relatedLink.lastIndexOf("/") + 1,relatedLink.length()) : ""
+ break
+ }
+ }
+ }
+ execution.setVariable("e2eSliceServiceInstanceId", e2eSliceServiceInstId)
+ execution.setVariable("serviceInstanceName", serviceInstName ?: "")
+ LOGGER.info("communication-service Id: ${serviceInstanceId}, e2eslice-service Id: ${e2eSliceServiceInstId}, serviceName: ${serviceInstName}")
+ }
+ LOGGER.debug(" ***** Exit queryCommunicationSeriveFromAAI *****")
+ }
+
+ /**
+ * query AAI
+ * @param execution
+ * @param aaiObjectType
+ * @param instanceId
+ * @return AAIResultWrapper
+ */
+ private AAIResultWrapper queryAAI(DelegateExecution execution, AAIObjectType aaiObjectType, String instanceId, String errorMsg)
+ {
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String serviceType = execution.getVariable("serviceType")
+
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(aaiObjectType, globalSubscriberId, serviceType, instanceId)
+ if (!getAAIClient().exists(resourceUri)) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMsg)
+ }
+ AAIResultWrapper wrapper = getAAIClient().get(resourceUri, NotFoundException.class)
+ return wrapper
+ }
+
+
+ /**
+ * 再次调用deleteE2EServiceInstance接口,然后获取到operationid,
+ */
+ void sendRequest2NSMFWF(DelegateExecution execution) {
+ LOGGER.trace("begin preRequestSend2NSMF")
+ try {
+ //url:/onap/so/infra/e2eServiceInstances/v3/{serviceInstanceId}"
+ def NSMF_endpoint = UrnPropertiesReader.getVariable("mso.infra.endpoint.url", execution)
+ String url = "${NSMF_endpoint}/e2eServiceInstances/v3/${execution.getVariable("e2eSliceServiceInstanceId")}"
+
+ String requestBody = """
+ {
+ "globalSubscriberId": "${execution.getVariable("globalSubscriberId")}",
+ "serviceType": "${execution.getVariable("serviceType")}"
+ }
+ """
+ requestBody.replaceAll("\\s+", "")
+
+ String basicAuthValue = UrnPropertiesReader.getVariable("mso.infra.endpoint.auth", execution)
+ HttpClient httpClient = getHttpClientFactory().newJsonClient(new URL(url), ONAPComponents.SO)
+ httpClient.addAdditionalHeader("Authorization", basicAuthValue)
+ httpClient.addAdditionalHeader("Accept", "application/json")
+ Response httpResponse = httpClient.delete(requestBody)
+ handleNSSMFWFResponse(httpResponse, execution)
+
+ } catch (BpmnError e) {
+ throw e
+ } catch (any) {
+ String msg = "Exception in DeleteCommunicationService.preRequestSend2NSMF. " + any.getCause()
+ LOGGER.error(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+
+ LOGGER.trace("exit preRequestSend2NSMF")
+ }
+
+ /**
+ * prepare update operation status
+ * @param execution
+ */
+ private void handleNSSMFWFResponse(Response httpResponse, DelegateExecution execution){
+ LOGGER.debug(" ======== STARTED prepareUpdateOperationStatus Process ======== ")
+
+ int nsmfResponseCode = httpResponse.getStatus()
+ LOGGER.debug("nsmfResponseCode${nsmfResponseCode}")
+
+ if (nsmfResponseCode >= 200 && nsmfResponseCode < 204 && httpResponse.hasEntity()) {
+ String nsmfResponse = httpResponse.readEntity(String.class)
+ def e2eOperationId = jsonUtil.getJsonValue(nsmfResponse, "operationId")
+ execution.setVariable("e2eOperationId", e2eOperationId)
+ execution.setVariable("progress","20")
+ execution.setVariable("operationContent","waiting nsmf service delete finished")
+
+ execution.setVariable("currentCycle",0)
+ execution.setVariable("isNSMFTimeOut", "no")
+ execution.setVariable("isNSMFWFRspSucceed","yes")
+ }
+ else
+ {
+ String serviceName = execution.getVariable("serviceInstanceName")
+ execution.setVariable("progress", "100")
+ execution.setVariable("result", "error")
+ execution.setVariable("operationContent", "terminate service failure.")
+ execution.setVariable("reason","NSMF WF asynchronous response failed, status Code:${nsmfResponseCode}")
+ execution.setVariable("isNSMFWFRspSucceed","no")
+ LOGGER.error("nsmf async response error,nsmfResponseCode:${nsmfResponseCode},serivceName:${serviceName}")
+ }
+ setOperationStatus(execution)
+ LOGGER.debug("======== COMPLETED prepareUpdateOperationStatus Process ======== ")
+ }
+
+ /**
+ * prepare to call sub process
+ * @param execution
+ */
+ void prepareCallCheckProcessStatus(DelegateExecution execution)
+ {
+ LOGGER.debug(PREFIX + "prepareCallCheckProcessStatus Start")
+
+ def successConditions = new ArrayList<>()
+ successConditions.add("finished")
+ execution.setVariable("successConditions", successConditions)
+
+ def errorConditions = new ArrayList<>()
+ errorConditions.add("error")
+ execution.setVariable("errorConditions", errorConditions)
+
+ execution.setVariable("processServiceType", "communication service")
+ execution.setVariable("subOperationType", "DELETE")
+ execution.setVariable("initProgress", 20)
+ execution.setVariable("endProgress",90)
+
+ execution.setVariable("timeOut", TIMEOUT)
+
+ LOGGER.debug(PREFIX + "prepareCallCheckProcessStatus Exit")
+ }
+
+ /**
+ * delete communication profile from AAI
+ * @param execution
+ */
+ void delCSProfileFromAAI(DelegateExecution execution)
+ {
+ LOGGER.debug("start delete communication service profile from AAI")
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String serviceType = execution.getVariable("serviceType")
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+
+ String profileId
+ try
+ {
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.COMMUNICATION_PROFILE_ALL, globalSubscriberId, serviceType, serviceInstanceId)
+ AAIResultWrapper wrapper = getAAIClient().get(resourceUri, NotFoundException.class)
+ Optional<CommunicationServiceProfiles> csProfilesOpt = wrapper.asBean(CommunicationServiceProfiles.class)
+ if(csProfilesOpt.isPresent()){
+ CommunicationServiceProfiles csProfiles = csProfilesOpt.get()
+ CommunicationServiceProfile csProfile = csProfiles.getCommunicationServiceProfile().get(0)
+ profileId = csProfile ? csProfile.getProfileId() : ""
+ }
+ resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.COMMUNICATION_SERVICE_PROFILE, globalSubscriberId, serviceType, serviceInstanceId, profileId)
+ if (!getAAIClient().exists(resourceUri)) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "communication service profile was not found in aai")
+ }
+
+ getAAIClient().delete(resourceUri)
+ LOGGER.debug("end delete communication service profile from AAI")
+ }
+ catch (any)
+ {
+ String msg = "delete communication service profile from aai failed! cause-"+any.getCause()
+ LOGGER.error(any.printStackTrace())
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg);
+ }
+
+ }
+
+ /**
+ * delete communication service from AAI
+ * @param execution
+ */
+ void delCSFromAAI(DelegateExecution execution)
+ {
+ try
+ {
+ LOGGER.debug("start delete communication service from AAI")
+ AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), execution.getVariable("serviceInstanceId"))
+ getAAIClient().delete(serviceInstanceUri)
+
+ execution.setVariable("progress", "100")
+ execution.setVariable("result", "finished")
+ execution.setVariable("operationContent", "CSMF completes service terminated.")
+ setOperationStatus(execution)
+ LOGGER.debug("end delete communication service from AAI")
+ }
+ catch (any)
+ {
+ LOGGER.error("Error occured within delCSFromAAI method, cause: ${any.getCause()} ")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Error occured during delete communication service from aai")
+ }
+ }
+
+ void sendSyncError(DelegateExecution execution)
+ {
+ LOGGER.debug("Starting sendSyncError")
+
+ try {
+ String errorMessage = "Sending Sync Error."
+ if (execution.getVariable("WorkflowException") instanceof WorkflowException) {
+ WorkflowException wfe = execution.getVariable("WorkflowException")
+ errorMessage = wfe.getErrorMessage()
+ }
+
+ String buildworkflowException =
+ """<aetgt:WorkflowException xmlns:aetgt="http://org.onap/so/workflow/schema/v1">
+ <aetgt:ErrorMessage>${MsoUtils.xmlEscape(errorMessage)}</aetgt:ErrorMessage>
+ <aetgt:ErrorCode>7000</aetgt:ErrorCode>
+ </aetgt:WorkflowException>"""
+
+ LOGGER.debug(buildworkflowException)
+ sendWorkflowResponse(execution, 500, buildworkflowException)
+
+ } catch (Exception ex) {
+ LOGGER.error("Sending Sync Error Activity Failed. " + "\n" + ex.getMessage())
+ }
+ }
+
+ /**
+ * prepare update operation status
+ * @param execution
+ */
+ void preFailedOperationStatus(DelegateExecution execution)
+ {
+ LOGGER.debug(" ======== STARTED preFailedOperationStatus Process ======== ")
+
+ execution.setVariable("progress", "100")
+ execution.setVariable("result", "error")
+ execution.setVariable("operationContent", "terminate service failure")
+
+ WorkflowException wfex = execution.getVariable("WorkflowException") as WorkflowException
+ String errorMessage = wfex.getErrorMessage()
+ errorMessage = errorMessage.length() > 200 ? errorMessage.substring(0,200) + "......" : errorMessage
+ execution.setVariable("reason", errorMessage)
+ setOperationStatus(execution)
+
+ LOGGER.debug("======== COMPLETED prepareEndOperationStatus Process ======== ")
+ }
+
+ /**
+ * prepare Operation status
+ * @param execution
+ * @param operationType
+ */
+ private void setOperationStatus(DelegateExecution execution)
+ {
+ OperationStatus operationStatus = new OperationStatus()
+ operationStatus.setServiceId(execution.getVariable("serviceInstanceId"))
+ operationStatus.setOperationId(execution.getVariable("operationId"))
+ operationStatus.setUserId(execution.getVariable("globalSubscriberId"))
+ //interface not support update
+ operationStatus.setServiceName(execution.getVariable("serviceInstanceName"))
+ operationStatus.setResult(execution.getVariable("result"))
+ operationStatus.setProgress(execution.getVariable("progress"))
+ operationStatus.setOperationContent(execution.getVariable("operationContent"))
+ operationStatus.setReason(execution.getVariable("reason")?:"")
+ operationStatus.setOperation("DELETE")
+
+ requestDBUtil.prepareUpdateOperationStatus(execution, operationStatus)
+ }
+
+ void prepareFailureStatus(DelegateExecution execution)
+ {
+ execution.setVariable("result", "finished")
+ execution.setVariable("progress", "100")
+ execution.setVariable("operationContent", "terminate service failure.")
+ setOperationStatus(execution)
+ LOGGER.debug("${PREFIX}-prepareFailureStatus,result:${execution.getVariable("result")}, reason: ${execution.getVariable("reason")}")
+ }
+
+ /**
+ * check request json and save parameter to execution
+ * @param siRequest
+ * @param paraName
+ * @param isErrorException
+ * @param execution
+ */
+ private void checkAndSetRequestParam(String siRequest, String paraName, boolean isErrorException, DelegateExecution execution)
+ {
+ String msg = ""
+ String paramValue = jsonUtil.getJsonValue(siRequest, paraName)
+ if (isBlank(paramValue)) {
+ msg = "Input ${paraName} is null"
+ LOGGER.error(msg)
+ if(isErrorException)
+ {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ }
+
+ } else {
+ execution.setVariable(paraName, paramValue)
+ }
+ }
+
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy
index 5c7127f36e..41a4ab85ec 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy
@@ -31,7 +31,7 @@ import org.onap.so.bpmn.common.scripts.NetworkUtils
import org.onap.so.bpmn.common.scripts.VidUtils
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.core.json.JsonUtils
-import org.onap.so.logger.ErrorCode;
+import org.onap.logging.filter.base.ErrorCode;
import org.onap.so.logger.MessageEnum
import org.slf4j.Logger
import org.slf4j.LoggerFactory
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy
new file mode 100644
index 0000000000..d8160a97bc
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy
@@ -0,0 +1,259 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (c) 2019, CMCC Technologies Co., Ltd.
+ * ================================================================================
+ * 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.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.ServiceProfile
+import org.onap.aai.domain.yang.ServiceProfiles
+import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.onap.so.bpmn.common.scripts.ExceptionUtil
+import org.onap.so.bpmn.common.scripts.MsoUtils
+import org.onap.so.bpmn.common.scripts.RequestDBUtil
+import org.onap.so.bpmn.core.WorkflowException
+import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.AAIResourcesClient
+import org.onap.so.client.aai.entities.AAIResultWrapper
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+import org.onap.so.db.request.beans.OperationStatus
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+
+import javax.ws.rs.NotFoundException
+
+import static org.apache.commons.lang3.StringUtils.isBlank
+
+class DeleteSliceService extends AbstractServiceTaskProcessor {
+
+ private final String PREFIX ="DeleteSliceService"
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+ JsonUtils jsonUtil = new JsonUtils()
+ private RequestDBUtil requestDBUtil = new RequestDBUtil()
+
+ private static final Logger LOGGER = LoggerFactory.getLogger( DeleteSliceService.class)
+
+ @Override
+ void preProcessRequest(DelegateExecution execution) {
+ execution.setVariable("prefix", PREFIX)
+ String msg = ""
+
+ LOGGER.debug("*****${PREFIX} preProcessRequest *****")
+
+ try {
+ // check for incoming json message/input
+ String siRequest = execution.getVariable("bpmnRequest")
+ String requestId = execution.getVariable("mso-request-id")
+ execution.setVariable("msoRequestId", requestId)
+
+ //e2eslice-service instance id
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ if (isBlank(serviceInstanceId)) {
+ msg = "e2eslice-service id is null"
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ }
+ LOGGER.info("Input Request: ${siRequest}, reqId: ${requestId}, e2eslice-service: ${serviceInstanceId}")
+
+ //subscriberInfo
+ checkAndSetRequestParam(siRequest,"globalSubscriberId",false, execution)
+ checkAndSetRequestParam(siRequest,"serviceType",false, execution)
+ checkAndSetRequestParam(siRequest,"operationId",false, execution)
+
+ //prepare init operation status
+ execution.setVariable("progress", "0")
+ execution.setVariable("result", "processing")
+ execution.setVariable("operationType", "DELETE")
+ execution.setVariable("operationContent", "Delete Slice service operation start")
+ updateServiceOperationStatus(execution)
+
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ msg = "Exception in preProcessRequest " + ex.getMessage()
+ LOGGER.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ LOGGER.debug("*****${PREFIX} Exit preProcessRequest *****")
+ }
+
+ /**
+ * send asynchronous response
+ * @param execution
+ */
+ void sendAsyncResponse(DelegateExecution execution) {
+ LOGGER.trace("${PREFIX} Start sendSyncResponse ")
+
+ try {
+ String operationId = execution.getVariable("operationId")
+ String syncResponse = """{"operationId":"${operationId}"}""".trim()
+ LOGGER.info("sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse)
+ sendWorkflowResponse(execution, 202, syncResponse)
+
+ } catch (Exception ex) {
+ String msg = "Exception in sendSyncResponse: " + ex.getMessage()
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ LOGGER.trace("${PREFIX} Exit sendSyncResponse")
+ }
+
+ /**
+ * Deletes the slice service instance in aai
+ */
+ void deleteSliceServiceInstance(DelegateExecution execution) {
+ LOGGER.trace("${PREFIX} Start deleteSliceServiceInstance")
+ try {
+
+ AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), execution.getVariable("serviceInstanceId"))
+ getAAIClient().delete(serviceInstanceUri)
+
+ execution.setVariable("progress", "100")
+ execution.setVariable("result", "finished")
+ execution.setVariable("operationContent", "NSMF completes slicing service termination.")
+ updateServiceOperationStatus(execution)
+
+ LOGGER.trace("${PREFIX} Exited deleteSliceServiceInstance")
+ }catch(Exception e){
+ LOGGER.debug("Error occured within deleteSliceServiceInstance method: " + e)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Error occured during deleteSliceServiceInstance from aai")
+ }
+ }
+
+ /**
+ * update operation status
+ * @param execution
+ */
+ private void updateServiceOperationStatus(DelegateExecution execution){
+
+ OperationStatus operationStatus = new OperationStatus()
+ operationStatus.setServiceId(execution.getVariable("serviceInstanceId"))
+ operationStatus.setOperationId(execution.getVariable("operationId"))
+ operationStatus.setUserId(execution.getVariable("globalSubscriberId"))
+ operationStatus.setResult(execution.getVariable("result"))
+ operationStatus.setProgress(execution.getVariable("progress"))
+ operationStatus.setOperationContent(execution.getVariable("operationContent"))
+ operationStatus.setReason(execution.getVariable("reason"))
+ operationStatus.setOperation(execution.getVariable("operationType"))
+
+ requestDBUtil.prepareUpdateOperationStatus(execution, operationStatus)
+ }
+
+ /**
+ * delete service profile from aai
+ * @param execution
+ */
+ void delServiceProfileFromAAI(DelegateExecution execution)
+ {
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String serviceType = execution.getVariable("serviceType")
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ String profileId = ""
+
+ try
+ {
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_PROFILE_ALL, globalSubscriberId, serviceType, serviceInstanceId)
+ AAIResultWrapper wrapper = getAAIClient().get(resourceUri, NotFoundException.class)
+ Optional<ServiceProfiles> serviceProfilesOpt =wrapper.asBean(ServiceProfiles.class)
+ if(serviceProfilesOpt.isPresent()){
+ ServiceProfiles serviceProfiles = serviceProfilesOpt.get()
+ ServiceProfile serviceProfile = serviceProfiles.getServiceProfile().get(0)
+ profileId = serviceProfile ? serviceProfile.getProfileId() : ""
+ }
+ resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_PROFILE, globalSubscriberId, serviceType, serviceInstanceId, profileId)
+ if (!getAAIClient().exists(resourceUri)) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai")
+ }
+ getAAIClient().delete(resourceUri)
+ }
+ catch (any)
+ {
+ String msg = "delete service profile from aai failed! cause-"+any.getCause()
+ LOGGER.error(any.printStackTrace())
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg);
+ }
+ }
+
+ void sendSyncError(DelegateExecution execution) {
+ LOGGER.debug("${PREFIX} Start sendSyncError")
+
+ try {
+ String errorMessage = "Sending Sync Error."
+ if (execution.getVariable("WorkflowException") instanceof WorkflowException) {
+ WorkflowException wfe = execution.getVariable("WorkflowException")
+ errorMessage = wfe.getErrorMessage()
+ }
+
+ String buildworkflowException =
+ """<aetgt:WorkflowException xmlns:aetgt="http://org.onap/so/workflow/schema/v1">
+ <aetgt:ErrorMessage>${MsoUtils.xmlEscape(errorMessage)}</aetgt:ErrorMessage>
+ <aetgt:ErrorCode>7000</aetgt:ErrorCode>
+ </aetgt:WorkflowException>"""
+
+ LOGGER.debug(buildworkflowException)
+ sendWorkflowResponse(execution, 500, buildworkflowException)
+
+ } catch (Exception ex) {
+ LOGGER.error("Sending Sync Error Activity Failed. " + "\n" + ex.getMessage())
+ }
+
+ }
+
+ void prepareEndOperationStatus(DelegateExecution execution){
+ LOGGER.debug(" ======== ${PREFIX} STARTED prepareEndOperationStatus Process ======== ")
+
+ execution.setVariable("progress", "100")
+ execution.setVariable("result", "error")
+ execution.setVariable("operationContent", "NSSMF Terminate service failure")
+
+ WorkflowException wfex = execution.getVariable("WorkflowException") as WorkflowException
+ String errorMessage = wfex.getErrorMessage()
+ errorMessage = errorMessage.length() > 200 ? errorMessage.substring(0,200) + "......" : errorMessage
+ execution.setVariable("reason",errorMessage)
+ updateServiceOperationStatus(execution)
+
+ LOGGER.debug("======== ${PREFIX} COMPLETED prepareEndOperationStatus Process ======== ")
+ }
+
+ /**
+ * check parameters from request body
+ * set to execution
+ * @param siRequest
+ * @param paraName
+ * @param isErrorException
+ * @param execution
+ */
+ private void checkAndSetRequestParam(String siRequest, String paraName, boolean isErrorException, DelegateExecution execution)
+ {
+ String msg = ""
+ String paramValue = jsonUtil.getJsonValue(siRequest, paraName)
+ if (isBlank(paramValue)) {
+ msg = "Input ${paraName} is null"
+ LOGGER.error(msg)
+ if(isErrorException)
+ {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ }
+
+ } else {
+ execution.setVariable(paraName, paramValue)
+ }
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleInfra.groovy
index 79aa745792..fd30722369 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleInfra.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleInfra.groovy
@@ -31,7 +31,7 @@ import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.common.scripts.VidUtils;
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.core.json.JsonUtils
-import org.onap.so.logger.ErrorCode;
+import org.onap.logging.filter.base.ErrorCode;
import org.onap.so.logger.MessageEnum
import org.slf4j.Logger
import org.slf4j.LoggerFactory
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy
index 9fa488f8a7..eb2ec2bc9d 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy
@@ -38,7 +38,7 @@ import org.onap.so.client.aai.entities.AAIResultWrapper
import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.constants.Defaults
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import org.onap.so.logger.MessageEnum
import org.slf4j.Logger
import org.slf4j.LoggerFactory
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy
new file mode 100644
index 0000000000..d5b554d841
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy
@@ -0,0 +1,338 @@
+package org.onap.so.bpmn.infrastructure.scripts
+
+import com.google.common.reflect.TypeToken
+import com.google.gson.Gson
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.AllottedResource
+import org.onap.aai.domain.yang.Relationship
+import org.onap.aai.domain.yang.RelationshipList
+import org.onap.aai.domain.yang.ServiceInstance
+import org.onap.so.beans.nsmf.SliceTaskParams
+import org.onap.so.bpmn.common.scripts.ExceptionUtil
+import org.onap.so.bpmn.core.domain.ServiceDecomposition
+import org.onap.so.bpmn.core.domain.ServiceProxy
+import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.AAIResourcesClient
+import org.onap.so.client.aai.entities.AAIEdgeLabel
+import org.onap.so.client.aai.entities.AAIResultWrapper
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+import org.onap.so.db.request.client.RequestsDbClient
+import org.onap.so.db.request.beans.OrchestrationTask
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+
+import javax.ws.rs.NotFoundException
+import javax.ws.rs.core.UriBuilder
+
+import static org.apache.commons.lang3.StringUtils.isBlank
+
+class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor{
+
+ private static final Logger logger = LoggerFactory.getLogger( DoAllocateNSIandNSSI.class);
+
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+
+ JsonUtils jsonUtil = new JsonUtils()
+ RequestsDbClient requestsDbClient = new RequestsDbClient()
+
+ /**
+ * Pre Process the BPMN Flow Request
+ * Inclouds:
+ * generate the nsOperationKey
+ * generate the nsParameters
+ */
+
+ void preProcessRequest (DelegateExecution execution) {
+ String msg = ""
+ logger.trace("Enter preProcessRequest()")
+ Map<String, Object> nssiMap = new HashMap<>()
+ execution.setVariable("nssiMap", nssiMap)
+ boolean isMoreNSSTtoProcess = true
+ execution.setVariable("isMoreNSSTtoProcess", isMoreNSSTtoProcess)
+ List<String> nsstSequence = new ArrayList<>(Arrays.asList("cn"))
+ execution.setVariable("nsstSequence", nsstSequence)
+ logger.trace("Exit preProcessRequest")
+ }
+
+ void retriveSliceOption(DelegateExecution execution) {
+ logger.trace("Enter retriveSliceOption() of DoAllocateNSIandNSSI")
+ String uuiRequest = execution.getVariable("uuiRequest")
+ boolean isNSIOptionAvailable = false
+ List<String> nssiAssociated = new ArrayList<>()
+ SliceTaskParams sliceParams = execution.getVariable("sliceTaskParams")
+ try
+ {
+ String modelUuid = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.nstar0_allottedresource0_providing_service_uuid")
+ String modelInvariantUuid = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.nstar0_allottedresource0_providing_service_invariant_uuid")
+ String serviceModelInfo = """{
+ "modelInvariantUuid":"${modelInvariantUuid}",
+ "modelUuid":"${modelUuid}",
+ "modelVersion":""
+ }"""
+ execution.setVariable("serviceModelInfo", serviceModelInfo)
+ //Params sliceParams = new Gson().fromJson(params, new TypeToken<Params>() {}.getType());
+ execution.setVariable("sliceParams", sliceParams)
+ }catch (Exception ex) {
+ logger.debug( "Unable to get the task information from request DB: " + ex)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Unable to get task information from request DB.")
+ }
+
+ if(isBlank(sliceParams.getSuggestNsiId()))
+ {
+ isNSIOptionAvailable=false
+ }
+ else
+ {
+ isNSIOptionAvailable=true
+ execution.setVariable('nsiServiceInstanceId',sliceParams.getSuggestNsiId())
+ execution.setVariable('nsiServiceInstanceName',sliceParams.getSuggestNsiName())
+ }
+ execution.setVariable("isNSIOptionAvailable",isNSIOptionAvailable)
+ logger.trace("Exit retriveSliceOption() of DoAllocateNSIandNSSI")
+ }
+
+ void updateRelationship(DelegateExecution execution) {
+ logger.trace("Enter update relationship in DoAllocateNSIandNSSI()")
+ String nsiServiceInstanceId = execution.getVariable("nsiServiceInstanceId")
+ String allottedResourceId = execution.getVariable("allottedResourceId")
+ //Need to check whether nsi exist : Begin
+ org.onap.aai.domain.yang.ServiceInstance nsiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance()
+ SliceTaskParams sliceParams = execution.getVariable("sliceParams")
+
+ String nsiServiceInstanceID = sliceParams.getSuggestNsiId()
+
+ AAIResourcesClient resourceClient = new AAIResourcesClient()
+ AAIResourceUri nsiServiceuri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), nsiServiceInstanceID)
+ //AAIResourceUri nsiServiceuri = AAIUriFactory.createResourceUri(AAIObjectType.QUERY_ALLOTTED_RESOURCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), nsiServiceInstanceID)
+
+ try {
+ AAIResultWrapper wrapper = resourceClient.get(nsiServiceuri, NotFoundException.class)
+ Optional<org.onap.aai.domain.yang.ServiceInstance> si = wrapper.asBean(org.onap.aai.domain.yang.ServiceInstance.class)
+ nsiServiceInstance = si.get()
+ //allottedResourceId=nsiServiceInstance.getAllottedResources().getAllottedResource().get(0).getId()
+
+// if(resourceClient.exists(nsiServiceuri)){
+// execution.setVariable("nsi_resourceLink", nsiServiceuri.build().toString())
+// }else{
+// exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai to " +
+// "associate for service :"+serviceInstanceId)
+// }
+ }catch(BpmnError e) {
+ throw e;
+ }catch (Exception ex){
+ String msg = "NSI suggested in the option doesn't exist. " + nsiServiceInstanceID
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), nsiServiceInstanceId, allottedResourceId)
+ getAAIClient().connect(allottedResourceUri,nsiServiceuri)
+
+ List<String> nssiAssociated = new ArrayList<>()
+ RelationshipList relationshipList = nsiServiceInstance.getRelationshipList()
+ List<Relationship> relationships = relationshipList.getRelationship()
+ for(Relationship relationship in relationships)
+ {
+ if(relationship.getRelatedTo().equalsIgnoreCase("service-instance"))
+ {
+ String NSSIassociated = relationship.getRelatedLink().substring(relationship.getRelatedLink().lastIndexOf("/") + 1);
+ if(!NSSIassociated.equals(nsiServiceInstanceID))
+ nssiAssociated.add(NSSIassociated)
+ }
+ }
+ execution.setVariable("nssiAssociated",nssiAssociated)
+ execution.setVariable("nsiServiceInstanceName",nsiServiceInstance.getServiceInstanceName())
+ logger.trace("Exit update relationship in DoAllocateNSIandNSSI()")
+ }
+
+ void prepareNssiModelInfo(DelegateExecution execution){
+ logger.trace("Enter prepareNssiModelInfo in DoAllocateNSIandNSSI()")
+ List<String> nssiAssociated = new ArrayList<>()
+ Map<String, Object> nssiMap = new HashMap<>()
+ nssiAssociated=execution.getVariable("nssiAssociated")
+ for(String nssiID in nssiAssociated)
+ {
+ try {
+ AAIResourcesClient resourceClient = new AAIResourcesClient()
+ AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), nssiID)
+ AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class)
+ Optional<org.onap.aai.domain.yang.ServiceInstance> si = wrapper.asBean(org.onap.aai.domain.yang.ServiceInstance.class)
+ org.onap.aai.domain.yang.ServiceInstance nssi = si.get()
+ nssiMap.put(nssi.getEnvironmentContext(),"""{
+ "serviceInstanceId":"${nssi.getServiceInstanceId()}",
+ "modelUuid":"${nssi.getModelVersionId()}"
+ }""")
+
+ }catch(NotFoundException e)
+ {
+ logger.debug("NSSI Service Instance not found in AAI: " + nssiID)
+ }catch(Exception e)
+ {
+ logger.debug("NSSI Service Instance not found in AAI: " + nssiID)
+ }
+ execution.setVariable("nssiMap",nssiMap)
+
+ }
+ logger.trace("Exit prepareNssiModelInfo in DoAllocateNSIandNSSI()")
+ }
+
+ void createNSIinAAI(DelegateExecution execution) {
+ logger.trace("Enter CreateNSIinAAI in DoAllocateNSIandNSSI()")
+ ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
+ org.onap.aai.domain.yang.ServiceInstance nsi = new ServiceInstance();
+ String sliceInstanceId = UUID.randomUUID().toString()
+ execution.setVariable("sliceInstanceId",sliceInstanceId)
+ nsi.setServiceInstanceId(sliceInstanceId)
+ String sliceInstanceName = "nsi_"+execution.getVariable("serviceInstanceName")
+ nsi.setServiceInstanceName(sliceInstanceName)
+ String serviceType = execution.getVariable("serviceType")
+ nsi.setServiceType(serviceType)
+ String serviceStatus = "deactivated"
+ nsi.setOrchestrationStatus(serviceStatus)
+ String modelInvariantUuid = serviceDecomposition.getModelInfo().getModelInvariantUuid()
+ String modelUuid = serviceDecomposition.getModelInfo().getModelUuid()
+ nsi.setModelInvariantId(modelInvariantUuid)
+ nsi.setModelVersionId(modelUuid)
+ String uuiRequest = execution.getVariable("uuiRequest")
+ String serviceInstanceLocationid = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.plmnIdList")
+ nsi.setServiceInstanceLocationId(serviceInstanceLocationid)
+ //String snssai = jsonUtil.getJsonValue(uuiRequest, "service.requestInputs.snssai")
+ //nsi.setEnvironmentContext(snssai)
+ String serviceRole = "nsi"
+ nsi.setServiceRole(serviceRole)
+ try {
+
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), sliceInstanceId)
+ client.create(uri, nsi)
+
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ msg = "Exception in DoCreateSliceServiceInstance.instantiateSliceService. " + ex.getMessage()
+ logger.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ Map<String, Object> nssiMap = new HashMap<>()
+ List<ServiceProxy> serviceProxyList = serviceDecomposition.getServiceProxy()
+ List<String> nsstModelInfoList = new ArrayList<>()
+ for(ServiceProxy serviceProxy : serviceProxyList)
+ {
+ //String nsstModelUuid = serviceProxy.getModelInfo().getModelUuid()
+ String nsstModelUuid = serviceProxy.getSourceModelUuid()
+ //String nsstModelInvariantUuid = serviceProxy.getModelInfo().getModelInvariantUuid()
+ String nsstServiceModelInfo = """{
+ "modelInvariantUuid":"",
+ "modelUuid":"${nsstModelUuid}",
+ "modelVersion":""
+ }"""
+ nsstModelInfoList.add(nsstServiceModelInfo)
+ }
+ int currentIndex=0
+ int maxIndex=nsstModelInfoList.size()
+ if(maxIndex < 1)
+ {
+ msg = "Exception in DoAllocateNSIandNSSI. There is no NSST associated with NST "
+ logger.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ execution.setVariable("nsstModelInfoList",nsstModelInfoList)
+ execution.setVariable("currentIndex",currentIndex)
+ execution.setVariable("maxIndex",maxIndex)
+ execution.setVariable('nsiServiceInstanceId',sliceInstanceId)
+ execution.setVariable("nsiServiceInstanceName",sliceInstanceName)
+ logger.trace("Exit CreateNSIinAAI in DoAllocateNSIandNSSI()")
+ }
+
+ void getOneNsstInfo(DelegateExecution execution){
+ List<String> nsstModelInfoList = new ArrayList<>()
+ nsstModelInfoList = execution.getVariable("nsstModelInfoList")
+ int currentIndex = execution.getVariable("currentIndex")
+ int maxIndex = execution.getVariable("maxIndex")
+ boolean isMoreNSSTtoProcess = true
+ String nsstServiceModelInfo = nsstModelInfoList.get(currentIndex)
+ execution.setVariable("serviceModelInfo", nsstServiceModelInfo)
+ execution.setVariable("currentIndex", currentIndex)
+ currentIndex = currentIndex+1
+ if(currentIndex <= maxIndex )
+ isMoreNSSTtoProcess = false
+ execution.setVariable("isMoreNSSTtoProcess", isMoreNSSTtoProcess)
+ }
+
+ void createNSSTMap(DelegateExecution execution){
+ ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
+ String modelUuid= serviceDecomposition.getModelInfo().getModelUuid()
+ String content = serviceDecomposition.getServiceInfo().getServiceArtifact().get(0).getContent()
+ //String nsstID = jsonUtil.getJsonValue(content, "metadata.id")
+ //String vendor = jsonUtil.getJsonValue(content, "metadata.vendor")
+ //String type = jsonUtil.getJsonValue(content, "metadata.type")
+ String domain = jsonUtil.getJsonValue(content, "metadata.domainType")
+
+ Map<String, Object> nssiMap = execution.getVariable("nssiMap")
+ String servicename = execution.getVariable("serviceInstanceName")
+ String nsiname = "nsi_"+servicename
+ nssiMap.put(domain,"""{
+ "serviceInstanceId":"",
+ "modelUuid":"${modelUuid}"
+ }""")
+ execution.setVariable("nssiMap",nssiMap)
+ }
+
+ void prepareNSSIList(DelegateExecution execution){
+ logger.trace("Enter prepareNSSIList in DoAllocateNSIandNSSI()")
+ Map<String, Object> nssiMap = new HashMap<>()
+ Boolean isMoreNSSI = false
+ nssiMap = execution.getVariable("nssiMap")
+ List<String> keys=new ArrayList<String>(nssiMap.values())
+ List<String> nsstSequence = execution.getVariable("nsstSequence")
+ Integer currentIndex=0;
+ execution.setVariable("currentNssiIndex",currentIndex)
+ Integer maxIndex=keys.size()
+ execution.setVariable("maxIndex",maxIndex)
+ if(maxIndex>0)
+ isMoreNSSI=true
+ execution.setVariable("isMoreNSSI",isMoreNSSI)
+ logger.trace("Exit prepareNSSIList in DoAllocateNSIandNSSI()")
+ }
+
+
+ void getOneNSSIInfo(DelegateExecution execution){
+ logger.trace("Enter getOneNSSIInfo in DoAllocateNSIandNSSI()")
+
+ //ServiceDecomposition serviceDecompositionObj = execution.getVariable("serviceDecompositionObj")
+ Map<String, Object> nssiMap=execution.getVariable("nssiMap")
+ List<String> nsstSequence = execution.getVariable("nsstSequence")
+ String currentNSST= nsstSequence.get(execution.getVariable("currentNssiIndex"))
+ boolean isNSSIOptionAvailable = false
+ String nsstInput=nssiMap.get(currentNSST)
+ execution.setVariable("nsstInput",nsstInput)
+ String modelUuid = jsonUtil.getJsonValue(nsstInput, "modelUuid")
+ String nssiInstanceId = jsonUtil.getJsonValue(nsstInput, "serviceInstanceId")
+ String nssiserviceModelInfo = """{
+ "modelInvariantUuid":"",
+ "modelUuid":"${modelUuid}",
+ "modelVersion":""
+ }"""
+ Integer currentIndex = execution.getVariable("currentNssiIndex")
+ currentIndex=currentIndex+1;
+ execution.setVariable("currentNssiIndex",currentIndex)
+ execution.setVariable("nssiserviceModelInfo",nssiserviceModelInfo)
+ execution.setVariable("nssiInstanceId",nssiInstanceId)
+ logger.trace("Exit getOneNSSIInfo in DoAllocateNSIandNSSI()")
+ }
+
+ void updateCurrentIndex(DelegateExecution execution){
+
+ logger.trace("Enter updateCurrentIndex in DoAllocateNSIandNSSI()")
+ Integer currentIndex = execution.getVariable("currentNssiIndex")
+ Integer maxIndex = execution.getVariable("maxIndex")
+ if(currentIndex>=maxIndex)
+ {
+ Boolean isMoreNSSI=false
+ execution.setVariable("isMoreNSSI",isMoreNSSI)
+ }
+ logger.trace("Exit updateCurrentIndex in DoAllocateNSIandNSSI()")
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy
new file mode 100644
index 0000000000..d786cb0ba1
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy
@@ -0,0 +1,771 @@
+package org.onap.so.bpmn.infrastructure.scripts
+
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.ServiceInstance
+import org.onap.aai.domain.yang.SliceProfile
+import org.onap.logging.filter.base.ONAPComponents
+import org.onap.so.beans.nsmf.AllocateAnNssi
+import org.onap.so.beans.nsmf.AllocateCnNssi
+import org.onap.so.beans.nsmf.AllocateTnNssi
+import org.onap.so.beans.nsmf.AnSliceProfile
+import org.onap.so.beans.nsmf.CnSliceProfile
+import org.onap.so.beans.nsmf.EsrInfo
+import org.onap.so.beans.nsmf.JobStatusRequest
+import org.onap.so.beans.nsmf.NetworkType
+import org.onap.so.beans.nsmf.NsiInfo
+import org.onap.so.beans.nsmf.NssiAllocateRequest
+import org.onap.so.beans.nsmf.PerfReq
+import org.onap.so.beans.nsmf.PerfReqEmbbList
+import org.onap.so.beans.nsmf.PerfReqUrllcList
+import org.onap.so.beans.nsmf.ResourceSharingLevel
+import org.onap.so.beans.nsmf.ServiceProfile
+import org.onap.so.beans.nsmf.SliceTaskParams
+import org.onap.so.beans.nsmf.TnSliceProfile
+import org.onap.so.beans.nsmf.UeMobilityLevel
+import org.onap.so.bpmn.common.scripts.ExceptionUtil
+import org.onap.so.bpmn.core.RollbackData
+import org.onap.so.bpmn.core.UrnPropertiesReader
+import org.onap.so.bpmn.core.domain.ModelInfo
+import org.onap.so.bpmn.core.domain.ServiceDecomposition
+import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.client.HttpClient
+import org.onap.so.client.HttpClientFactory
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.AAIResourcesClient
+import org.onap.so.client.aai.entities.AAIEdgeLabel
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+import com.fasterxml.jackson.databind.ObjectMapper;
+import javax.ws.rs.core.Response
+
+import static org.apache.commons.lang3.StringUtils.isBlank
+
+
+class DoAllocateNSSI extends org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor{
+
+ private static final Logger logger = LoggerFactory.getLogger( DoAllocateNSSI.class);
+ private static final ObjectMapper MAPPER = new ObjectMapper();
+
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+
+ JsonUtils jsonUtil = new JsonUtils()
+
+ /**
+ * Pre Process the BPMN Flow Request
+ * Inclouds:
+ * generate the nsOperationKey
+ * generate the nsParameters
+ */
+ void preProcessRequest (DelegateExecution execution) {
+ logger.trace("Enter preProcessRequest()")
+ String msg = ""
+ String nssmfOperation = ""
+ String msoRequestId = execution.getVariable("msoRequestId")
+ String nsstInput = execution.getVariable("nsstInput")
+ String modelUuid = jsonUtil.getJsonValue(nsstInput, "modelUuid")
+ //modelUuid="2763777c-27bd-4df7-93b8-c690e23f4d3f"
+ String nssiInstanceId = jsonUtil.getJsonValue(nsstInput, "serviceInstanceId")
+ String serviceModelInfo = """{
+ "modelInvariantUuid":"",
+ "modelUuid":"${modelUuid}",
+ "modelVersion":""
+ }"""
+ execution.setVariable("serviceModelInfo",serviceModelInfo)
+ execution.setVariable("nssiInstanceId",nssiInstanceId)
+ String nssiProfileID = UUID.randomUUID().toString()
+ execution.setVariable("nssiProfileID",nssiProfileID)
+ if(isBlank(nssiInstanceId))
+ {
+ nssmfOperation="create"
+ nssiInstanceId = UUID.randomUUID().toString()
+ }else {
+ nssmfOperation = "update"
+ }
+ execution.setVariable("nssmfOperation",nssmfOperation)
+ execution.setVariable("nssiInstanceId",nssiInstanceId)
+
+ def isDebugLogEnabled ="false"
+ def isNSSICreated = false
+ execution.setVariable("isNSSICreated",isNSSICreated)
+
+ int currentCycle = 0
+ execution.setVariable("currentCycle", currentCycle)
+
+ logger.trace("Exit preProcessRequest")
+ }
+
+
+ void getNSSTInfo(DelegateExecution execution){
+ logger.trace("Enter getNSSTInfo in DoAllocateNSSI()")
+ ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition")
+ ModelInfo modelInfo = serviceDecomposition.getModelInfo()
+ String serviceRole = "nssi"
+ String nssiServiceInvariantUuid = serviceDecomposition.modelInfo.getModelInvariantUuid()
+ String nssiServiceUuid = serviceDecomposition.modelInfo.getModelUuid()
+ String nssiServiceType = serviceDecomposition.getServiceType()
+ String uuiRequest = execution.getVariable("uuiRequest")
+ String nssiServiceName = "nssi_"+jsonUtil.getJsonValue(uuiRequest, "service.name")
+ execution.setVariable("nssiServiceName",nssiServiceName)
+ execution.setVariable("nssiServiceType",nssiServiceType)
+ execution.setVariable("nssiServiceInvariantUuid",nssiServiceInvariantUuid)
+ execution.setVariable("nssiServiceUuid",nssiServiceUuid)
+ execution.setVariable("serviceRole",serviceRole)
+
+ String content = serviceDecomposition.getServiceInfo().getServiceArtifact().get(0).getContent()
+ String nsstID = jsonUtil.getJsonValue(content, "metadata.id")
+ String nsstVendor = jsonUtil.getJsonValue(content, "metadata.vendor")
+ String nsstDomain = jsonUtil.getJsonValue(content, "metadata.domainType")
+ String nsstType = jsonUtil.getJsonValue(content, "metadata.type")
+
+ execution.setVariable("nsstID",nsstID)
+ execution.setVariable("nsstVendor",nsstVendor)
+ execution.setVariable("nsstDomain",nsstDomain)
+ execution.setVariable("nssiServiceUuid",nssiServiceUuid)
+ execution.setVariable("nsstType",nsstType)
+
+ String nsstContentInfo = """{
+ "NsstID":"${nsstID}",
+ "Vendor":"${nsstVendor}",
+ "type":"${nsstType}"
+ }"""
+
+ logger.trace("Exit getNSSTInfo in DoAllocateNSSI()")
+ }
+
+ void timeDelay(DelegateExecution execution) {
+ logger.trace("Enter timeDelay in DoAllocateNSSI()")
+ try {
+ Thread.sleep(60000);
+ int currentCycle = execution.getVariable("currentCycle")
+ currentCycle=currentCycle+1
+ if(currentCycle>60)
+ {
+ logger.trace("Completed all the retry times... but still nssmf havent completed the creation process...")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "NSSMF creation didnt complete by time...")
+ }
+ execution.setVariable("currentCycle",currentCycle)
+ } catch(InterruptedException e) {
+ logger.info("Time Delay exception" + e)
+ }
+ logger.trace("Exit timeDelay in DoAllocateNSSI()")
+ }
+
+
+ void sendUpdateRequestNSSMF(DelegateExecution execution) {
+ logger.trace("Enter sendUpdateRequestNSSMF in DoAllocateNSSI()")
+ String urlString = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution)
+ logger.debug( "get NSSMF: " + urlString)
+
+ //Prepare auth for NSSMF - Begin
+ def authHeader = ""
+ String basicAuth = UrnPropertiesReader.getVariable("mso.nssmf.auth", execution)
+ String domain = execution.getVariable("nsstDomain")
+ String nssmfRequest = buildUpdateNSSMFRequest(execution, domain.toUpperCase())
+
+ //send request to update NSSI option - Begin
+ URL url = new URL(urlString+"/api/rest/provMns/v1/NSS/SliceProfiles")
+ HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL)
+ Response httpResponse = httpClient.post(nssmfRequest)
+
+ int responseCode = httpResponse.getStatus()
+ logger.debug("NSSMF sync response code is: " + responseCode)
+
+ if(responseCode < 199 && responseCode > 299){
+ String nssmfResponse ="NSSMF response have nobody"
+ if(httpResponse.hasEntity())
+ nssmfResponse = httpResponse.readEntity(String.class)
+ logger.trace("received error message from NSSMF : "+nssmfResponse)
+ logger.trace("Exit sendCreateRequestNSSMF in DoAllocateNSSI()")
+ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.")
+ }
+
+ if(httpResponse.hasEntity()){
+ String nssmfResponse = httpResponse.readEntity(String.class)
+ execution.setVariable("nssmfResponse", nssmfResponse)
+ String nssiId = jsonUtil.getJsonValue(nssmfResponse, "nssiId")
+ String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId")
+ execution.setVariable("nssiId",nssiId)
+ execution.setVariable("jobId",jobId)
+ }else{
+ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.")
+ }
+ logger.trace("Exit sendUpdateRequestNSSMF in DoAllocateNSSI()")
+ }
+
+ void sendCreateRequestNSSMF(DelegateExecution execution) {
+ logger.trace("Enter sendCreateRequestNSSMF in DoAllocateNSSI()")
+ String urlString = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution)
+ logger.debug( "get NSSMF: " + urlString)
+
+ //Prepare auth for NSSMF - Begin
+ String domain = execution.getVariable("nsstDomain")
+ String nssmfRequest = buildCreateNSSMFRequest(execution, domain.toUpperCase())
+
+ //send request to get NSI option - Begin
+ URL url = new URL(urlString+"/api/rest/provMns/v1/NSS/SliceProfiles")
+ HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL)
+ Response httpResponse = httpClient.post(nssmfRequest)
+
+ int responseCode = httpResponse.getStatus()
+ logger.debug("NSSMF sync response code is: " + responseCode)
+
+ if(responseCode < 199 || responseCode > 299 ){
+ String nssmfResponse ="NSSMF response have nobody"
+ if(httpResponse.hasEntity())
+ nssmfResponse = httpResponse.readEntity(String.class)
+ logger.trace("received error message from NSSMF : "+nssmfResponse)
+ logger.trace("Exit sendCreateRequestNSSMF in DoAllocateNSSI()")
+ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.")
+ }
+
+ if(httpResponse.hasEntity()){
+ String nssmfResponse = httpResponse.readEntity(String.class)
+ execution.setVariable("nssmfResponse", nssmfResponse)
+ String nssiId = jsonUtil.getJsonValue(nssmfResponse, "nssiId")
+ String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId")
+ execution.setVariable("nssiId",nssiId)
+ execution.setVariable("jobId",jobId)
+ }else{
+ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.")
+ }
+ logger.trace("Exit sendCreateRequestNSSMF in DoAllocateNSSI()")
+
+ }
+
+ void getNSSMFProgresss(DelegateExecution execution) {
+ logger.trace("Enter getNSSMFProgresss in DoAllocateNSSI()")
+
+ String endpoint = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution)
+ logger.debug( "get NSSMF: " + endpoint)
+
+ //Prepare auth for NSSMF - Begin
+ def authHeader = ""
+ String basicAuth = UrnPropertiesReader.getVariable("mso.nssmf.auth", execution)
+
+ String nssmfRequest = buildNSSMFProgressRequest(execution)
+ String strUrl="/api/rest/provMns/v1/NSS/jobs/"+execution.getVariable("jobId")
+ //send request to update NSSI option - Begin
+ URL url = new URL(endpoint+strUrl)
+ HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL)
+ Response httpResponse = httpClient.post(nssmfRequest)
+
+ int responseCode = httpResponse.getStatus()
+ logger.debug("NSSMF sync response code is: " + responseCode)
+
+ if(responseCode < 199 || responseCode > 299){
+ String nssmfResponse ="NSSMF response have nobody"
+ if(httpResponse.hasEntity())
+ nssmfResponse = httpResponse.readEntity(String.class)
+ logger.trace("received error message from NSSMF : "+nssmfResponse)
+ logger.trace("Exit sendCreateRequestNSSMF in DoAllocateNSSI()")
+ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.")
+ }
+
+ if(httpResponse.hasEntity()){
+ String nssmfResponse = httpResponse.readEntity(String.class)
+ Boolean isNSSICreated = false
+ execution.setVariable("nssmfResponse", nssmfResponse)
+ Integer progress = java.lang.Integer.parseInt(jsonUtil.getJsonValue(nssmfResponse, "responseDescriptor.progress"))
+ String status = jsonUtil.getJsonValue(nssmfResponse, "responseDescriptor.status")
+ String statusDescription = jsonUtil.getJsonValue(nssmfResponse, "responseDescriptor.statusDescription")
+ execution.setVariable("nssmfProgress",progress)
+ execution.setVariable("nssmfStatus",status)
+ execution.setVariable("nddmfStatusDescription",statusDescription)
+ if(progress>99)
+ isNSSICreated = true
+ execution.setVariable("isNSSICreated",isNSSICreated)
+
+ }else{
+ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.")
+ }
+ logger.trace("Exit getNSSMFProgresss in DoAllocateNSSI()")
+
+ }
+
+ void updateRelationship(DelegateExecution execution) {
+ logger.trace("Enter updateRelationship in DoAllocateNSSI()")
+ String nssiInstanceId = execution.getVariable("nssiInstanceId")
+ String nsiInstanceId = execution.getVariable("nsiServiceInstanceId")
+ try{
+ AAIResourceUri nsiServiceuri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nsiInstanceId);
+ AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiInstanceId)
+ getAAIClient().connect(nsiServiceuri, nssiServiceUri, AAIEdgeLabel.COMPOSED_OF);
+ }catch(Exception ex) {
+ String msg = "Exception in DoAllocateNSSI InstantiateNSSI service while creating relationship " + ex.getMessage()
+ logger.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.trace("Exit updateRelationship in DoAllocateNSSI()")
+ }
+
+
+ void instantiateNSSIService(DelegateExecution execution) {
+ logger.trace("Enter instantiateNSSIService in DoAllocateNSSI()")
+ //String nssiInstanceId = execution.getVariable("nssiInstanceId")
+ String nssiInstanceId = execution.getVariable("nssiId")
+ execution.setVariable("nssiInstanceId",nssiInstanceId)
+ String sliceInstanceId = execution.getVariable("nsiServiceInstanceId")
+ try {
+ org.onap.aai.domain.yang.ServiceInstance nssi = new ServiceInstance();
+ Map<String, Object> serviceProfileMap = execution.getVariable("serviceProfile")
+
+ nssi.setServiceInstanceId(nssiInstanceId)
+ nssi.setServiceInstanceName(execution.getVariable("nssiServiceName"))
+ //nssi.setServiceType(execution.getVariable("nssiServiceType"))
+ nssi.setServiceType(serviceProfileMap.get("sST").toString())
+ String serviceStatus = "deactivated"
+ nssi.setOrchestrationStatus(serviceStatus)
+ String modelInvariantUuid = execution.getVariable("nssiServiceInvariantUuid")
+ String modelUuid = execution.getVariable("nssiServiceUuid")
+ nssi.setModelInvariantId(modelInvariantUuid)
+ nssi.setModelVersionId(modelUuid)
+ String uuiRequest = execution.getVariable("uuiRequest")
+ String serviceInstanceLocationid = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.plmnIdList")
+ nssi.setServiceInstanceLocationId(serviceInstanceLocationid)
+ //String snssai = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.sNSSAI")
+ String envContext=execution.getVariable("nsstDomain")
+ nssi.setEnvironmentContext(envContext)
+ nssi.setServiceRole(execution.getVariable("serviceRole"))
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), nssiInstanceId)
+ client.create(uri, nssi)
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ String msg = "Exception in DoCreateSliceServiceInstance.instantiateSliceService. " + ex.getMessage()
+ logger.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ try{
+ AAIResourceUri nsiServiceuri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, sliceInstanceId);
+ AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiInstanceId)
+ getAAIClient().connect(nsiServiceuri, nssiServiceUri, AAIEdgeLabel.COMPOSED_OF);
+ }catch(Exception ex) {
+ String msg = "Exception in DoAllocateNSSI InstantiateNSSI service while creating relationship " + ex.getMessage()
+ logger.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+
+
+
+ def rollbackData = execution.getVariable("RollbackData")
+ if (rollbackData == null) {
+ rollbackData = new RollbackData();
+ }
+ //rollbackData.put("SERVICEINSTANCE", "disableRollback", idisableRollback.toStrng())
+ rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true")
+ rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", nssiInstanceId)
+ rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
+ rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId"))
+ execution.setVariable("rollbackData", rollbackData)
+ execution.setVariable("RollbackData", rollbackData)
+ logger.debug("RollbackData:" + rollbackData)
+ logger.trace("Exit instantiateNSSIService in DoAllocateNSSI()")
+ }
+
+
+ void createSliceProfile(DelegateExecution execution) {
+ logger.trace("Enter createSliceProfile in DoAllocateNSSI()")
+ String sliceserviceInstanceId = execution.getVariable("nssiInstanceId")
+ String nssiProfileID = execution.getVariable("nssiProfileID")
+ Map<String, Object> sliceProfileMap = execution.getVariable("sliceProfileCn")
+ Map<String, Object> serviceProfileMap = execution.getVariable("serviceProfile")
+ SliceProfile sliceProfile = new SliceProfile()
+ sliceProfile.setServiceAreaDimension("")
+ sliceProfile.setPayloadSize(0)
+ sliceProfile.setJitter(0)
+ sliceProfile.setSurvivalTime(0)
+ //sliceProfile.setCsAvailability()
+ //sliceProfile.setReliability()
+ sliceProfile.setExpDataRate(0)
+ sliceProfile.setTrafficDensity(0)
+ sliceProfile.setConnDensity(0)
+ sliceProfile.setExpDataRateUL(Integer.parseInt(sliceProfileMap.get("expDataRateUL").toString()))
+ sliceProfile.setExpDataRateDL(Integer.parseInt(sliceProfileMap.get("expDataRateDL").toString()))
+ sliceProfile.setActivityFactor(Integer.parseInt(sliceProfileMap.get("activityFactor").toString()))
+ sliceProfile.setResourceSharingLevel(sliceProfileMap.get("activityFactor").toString())
+ sliceProfile.setUeMobilityLevel(serviceProfileMap.get("uEMobilityLevel").toString())
+ sliceProfile.setCoverageAreaTAList(serviceProfileMap.get("coverageAreaTAList").toString())
+ sliceProfile.setMaxNumberOfUEs(Integer.parseInt(sliceProfileMap.get("activityFactor").toString()))
+ sliceProfile.setLatency(Integer.parseInt(sliceProfileMap.get("latency").toString()))
+ sliceProfile.setProfileId(nssiProfileID)
+ sliceProfile.setE2ELatency(0)
+
+ try {
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE,
+ execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), sliceserviceInstanceId, nssiProfileID)
+ client.create(uri, sliceProfile)
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ String msg = "Exception in DoCreateSliceServiceInstance.instantiateSliceService. " + ex.getMessage()
+ logger.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+
+ def rollbackData = execution.getVariable("RollbackData")
+ if (rollbackData == null) {
+ rollbackData = new RollbackData();
+ }
+ //rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString())
+ rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true")
+ rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", sliceserviceInstanceId)
+ rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("serviceType"))
+ rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId"))
+ execution.setVariable("rollbackData", rollbackData)
+ execution.setVariable("RollbackData", rollbackData)
+ logger.debug("RollbackData:" + rollbackData)
+ logger.trace("Exit createSliceProfile in DoAllocateNSSI()")
+ }
+
+
+ String buildCreateNSSMFRequest(DelegateExecution execution, String domain) {
+
+ NssiAllocateRequest request = new NssiAllocateRequest()
+ String strRequest = ""
+ //String uuiRequest = execution.getVariable("uuiRequest")
+ SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
+
+ switch (domain) {
+ case "AN":
+ EsrInfo esrInfo = new EsrInfo()
+ esrInfo.setNetworkType(execution.getVariable("networkType"))
+ esrInfo.setVendor(execution.getVariable("nsstVendor"))
+
+ NsiInfo nsiInfo = new NsiInfo()
+ nsiInfo.setNsiId(execution.getVariable("nsiInstanceID"))
+ nsiInfo.setNsiName(execution.getVariable("nsiInstanceName"))
+
+ AnSliceProfile anSliceProfile = new AnSliceProfile()
+ anSliceProfile.setLatency(execution.getVariable("latency"))
+ anSliceProfile.setCoverageAreaTAList(execution.getVariable("coverageAreaList"))
+ anSliceProfile.setQi(execution.getVariable("qi"))
+
+ AllocateAnNssi allocateAnNssi = new AllocateAnNssi()
+ allocateAnNssi.setNsstId(execution.getVariable("nsstId"))
+ allocateAnNssi.setNssiName(execution.getVariable("nssiName"))
+ allocateAnNssi.setNsiInfo(nsiInfo)
+ allocateAnNssi.setSliceProfile(anSliceProfile)
+ String anScriptName = sliceTaskParams.getAnScriptName()
+ allocateAnNssi.setScriptName(anScriptName)
+
+ request.setAllocateAnNssi(allocateAnNssi)
+ request.setEsrInfo(esrInfo)
+ break;
+ case "CN":
+ Map<String, Object> sliceProfileCn =execution.getVariable("sliceProfileCn")
+ Map<String, Object> serviceProfile = execution.getVariable("serviceProfile")
+ NsiInfo nsiInfo = new NsiInfo()
+ nsiInfo.setNsiId(execution.getVariable("nsiServiceInstanceId"))
+ nsiInfo.setNsiName(execution.getVariable("nsiServiceInstanceName"))
+
+ EsrInfo esrInfo = new EsrInfo()
+ esrInfo.setNetworkType(NetworkType.fromString(domain))
+ esrInfo.setVendor(execution.getVariable("nsstVendor"))
+ execution.setVariable("esrInfo",esrInfo)
+
+
+ PerfReqEmbbList perfReqEmbb = new PerfReqEmbbList()
+ perfReqEmbb.setActivityFactor(sliceProfileCn.get("activityFactor"))
+ perfReqEmbb.setAreaTrafficCapDL(sliceProfileCn.get("areaTrafficCapDL"))
+ perfReqEmbb.setAreaTrafficCapUL(sliceProfileCn.get("areaTrafficCapUL"))
+ perfReqEmbb.setExpDataRateDL(sliceProfileCn.get("expDataRateDL"))
+ perfReqEmbb.setExpDataRateUL(sliceProfileCn.get("expDataRateUL"))
+
+ List<PerfReqEmbbList> listPerfReqEmbbList = new ArrayList<>()
+ listPerfReqEmbbList.add(perfReqEmbb)
+
+ PerfReq perfReq = new PerfReq()
+ perfReq.setPerfReqEmbbList(listPerfReqEmbbList)
+
+ PerfReqUrllcList perfReqUrllc = new PerfReqUrllcList()
+ perfReqUrllc.setConnDensity(0)
+ perfReqUrllc.setTrafficDensity(0)
+ perfReqUrllc.setExpDataRate(0)
+ perfReqUrllc.setReliability(0)
+ perfReqUrllc.setCsAvailability(0)
+ perfReqUrllc.setSurvivalTime(0)
+ perfReqUrllc.setJitter(0)
+ perfReqUrllc.setE2eLatency(0)
+ perfReqUrllc.setPayloadSize("0")
+ perfReqUrllc.setServiceAreaDimension("")
+
+ List<PerfReqUrllcList> perfReqUrllcList = new ArrayList<>()
+ perfReqUrllcList.add(perfReqUrllc)
+ perfReq.setPerfReqUrllcList(perfReqUrllcList)
+
+ CnSliceProfile cnSliceProfile = new CnSliceProfile()
+ cnSliceProfile.setSliceProfileId(execution.getVariable("nssiProfileID"))
+ String plmnStr = serviceProfile.get("plmnIdList")
+ List<String> plmnIdList=Arrays.asList(plmnStr.split("\\|"))
+ cnSliceProfile.setPlmnIdList(plmnIdList)
+
+ String resourceSharingLevel = serviceProfile.get("resourceSharingLevel").toString()
+ cnSliceProfile.setResourceSharingLevel(ResourceSharingLevel.fromString(resourceSharingLevel))
+
+ String coverageArea = serviceProfile.get("coverageAreaTAList")
+ List<String> coverageAreaList=Arrays.asList(coverageArea.split("\\|"))
+ cnSliceProfile.setCoverageAreaTAList(coverageAreaList)
+
+ String ueMobilityLevel = serviceProfile.get("uEMobilityLevel").toString()
+ cnSliceProfile.setUeMobilityLevel(UeMobilityLevel.fromString(ueMobilityLevel))
+
+ int latency = serviceProfile.get("latency")
+ cnSliceProfile.setLatency(latency)
+
+ int maxUE = serviceProfile.get("maxNumberofUEs")
+ cnSliceProfile.setMaxNumberofUEs(maxUE)
+
+ String snssai = serviceProfile.get("sNSSAI")
+ List<String> snssaiList = Arrays.asList(snssai.split("\\|"))
+ cnSliceProfile.setSnssaiList(snssaiList)
+
+ cnSliceProfile.setPerfReq(perfReq)
+
+ AllocateCnNssi allocateCnNssi = new AllocateCnNssi()
+ allocateCnNssi.setNsstId(execution.getVariable("nsstid"))
+ allocateCnNssi.setNssiName(execution.getVariable("nssiName"))
+ allocateCnNssi.setSliceProfile(cnSliceProfile)
+ allocateCnNssi.setNsiInfo(nsiInfo)
+ String cnScriptName = sliceTaskParams.getCnScriptName()
+ allocateCnNssi.setScriptName(cnScriptName)
+ request.setAllocateCnNssi(allocateCnNssi)
+ request.setEsrInfo(esrInfo)
+ break;
+ case "TN":
+ EsrInfo esrInfo = new EsrInfo()
+ esrInfo.setNetworkType(execution.getVariable("networkType"))
+ esrInfo.setVendor(execution.getVariable("vendor"))
+
+ TnSliceProfile tnSliceProfile = new TnSliceProfile()
+ tnSliceProfile.setLatency(execution.getVariable("latency"))
+ tnSliceProfile.setBandwidth(execution.getVariable("bandWidth"))
+
+ NsiInfo nsiInfo = new NsiInfo()
+ nsiInfo.setNsiId(execution.getVariable("nsiInstanceID"))
+ nsiInfo.setNsiName(execution.getVariable("nsiInstanceName"))
+
+ AllocateTnNssi allocateTnNssi = new AllocateTnNssi()
+ allocateTnNssi.setSliceProfile(tnSliceProfile)
+ allocateTnNssi.setNsiInfo(nsiInfo)
+ allocateTnNssi.setNsstId(execution.getVariable("nsstid"))
+ String tnScriptName = sliceTaskParams.getTnScriptName()
+ allocateTnNssi.setScriptName(tnScriptName)
+
+ request.setAllocateTnNssi(allocateTnNssi)
+ request.setEsrInfo(esrInfo)
+ break;
+ default:
+ break;
+ }
+ try {
+ strRequest = MAPPER.writeValueAsString(request);
+ } catch (IOException e) {
+ logger.error("Invalid get progress request bean to convert as string");
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Invalid get progress request bean to convert as string")
+ }
+ return strRequest
+ }
+
+
+ String buildUpdateNSSMFRequest(DelegateExecution execution, String domain) {
+ NssiAllocateRequest request = new NssiAllocateRequest()
+ String nsstInput = execution.getVariable("nsstInput")
+ String nssiId = jsonUtil.getJsonValue(nsstInput, "serviceInstanceId")
+ String strRequest = ""
+ SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
+ switch (domain) {
+ case "AN":
+ EsrInfo esrInfo = new EsrInfo()
+ esrInfo.setNetworkType(execution.getVariable("nsstType"))
+ esrInfo.setVendor(execution.getVariable("vendor"))
+
+ NsiInfo nsiInfo = new NsiInfo()
+ nsiInfo.setNsiId(execution.getVariable("nsiInstanceID"))
+ nsiInfo.setNsiName(execution.getVariable("nsiInstanceName"))
+
+ AnSliceProfile anSliceProfile = new AnSliceProfile()
+ anSliceProfile.setLatency(execution.getVariable("latency"))
+ anSliceProfile.setCoverageAreaTAList(execution.getVariable("coverageAreaList"))
+ anSliceProfile.setQi(execution.getVariable("qi"))
+
+ AllocateAnNssi allocateAnNssi = new AllocateAnNssi()
+ allocateAnNssi.setNsstId(execution.getVariable("nsstId"))
+ allocateAnNssi.setNssiName(execution.getVariable("nssiName"))
+ allocateAnNssi.setNsiInfo(nsiInfo)
+ allocateAnNssi.setSliceProfile(anSliceProfile)
+ String anScriptName = sliceTaskParams.getAnScriptName()
+ allocateAnNssi.setScriptName(anScriptName)
+ request.setAllocateAnNssi(allocateAnNssi)
+ request.setEsrInfo(esrInfo)
+ break;
+ case "CN":
+ Map<String, Object> sliceProfileCn =execution.getVariable("sliceProfileCn")
+ Map<String, Object> serviceProfile = execution.getVariable("serviceProfile")
+ NsiInfo nsiInfo = new NsiInfo()
+ nsiInfo.setNsiId(execution.getVariable("nsiServiceInstanceId"))
+ nsiInfo.setNsiName(execution.getVariable("nsiServiceInstanceName"))
+
+ EsrInfo esrInfo = new EsrInfo()
+ esrInfo.setNetworkType(NetworkType.fromString(domain))
+ esrInfo.setVendor(execution.getVariable("nsstVendor"))
+ execution.setVariable("esrInfo",esrInfo)
+
+
+ PerfReqEmbbList perfReqEmbb = new PerfReqEmbbList()
+ perfReqEmbb.setActivityFactor(sliceProfileCn.get("activityFactor"))
+ perfReqEmbb.setAreaTrafficCapDL(sliceProfileCn.get("areaTrafficCapDL"))
+ perfReqEmbb.setAreaTrafficCapUL(sliceProfileCn.get("areaTrafficCapUL"))
+ perfReqEmbb.setExpDataRateDL(sliceProfileCn.get("expDataRateDL"))
+ perfReqEmbb.setExpDataRateUL(sliceProfileCn.get("expDataRateUL"))
+
+ List<PerfReqEmbbList> listPerfReqEmbbList = new ArrayList<>()
+ listPerfReqEmbbList.add(perfReqEmbb)
+
+ PerfReq perfReq = new PerfReq()
+ perfReq.setPerfReqEmbbList(listPerfReqEmbbList)
+
+ PerfReqUrllcList perfReqUrllc = new PerfReqUrllcList()
+ perfReqUrllc.setConnDensity(0)
+ perfReqUrllc.setTrafficDensity(0)
+ perfReqUrllc.setExpDataRate(0)
+ perfReqUrllc.setReliability(0)
+ perfReqUrllc.setCsAvailability(0)
+ perfReqUrllc.setSurvivalTime(0)
+ perfReqUrllc.setJitter(0)
+ perfReqUrllc.setE2eLatency(0)
+ perfReqUrllc.setPayloadSize("0")
+ perfReqUrllc.setServiceAreaDimension("")
+
+ List<PerfReqUrllcList> perfReqUrllcList = new ArrayList<>()
+ perfReqUrllcList.add(perfReqUrllc)
+ perfReq.setPerfReqUrllcList(perfReqUrllcList)
+
+ CnSliceProfile cnSliceProfile = new CnSliceProfile()
+ cnSliceProfile.setSliceProfileId(execution.getVariable("nssiProfileID"))
+ String plmnStr = serviceProfile.get("plmnIdList")
+ List<String> plmnIdList=Arrays.asList(plmnStr.split("\\|"))
+ cnSliceProfile.setPlmnIdList(plmnIdList)
+
+ String resourceSharingLevel = serviceProfile.get("resourceSharingLevel").toString()
+ cnSliceProfile.setResourceSharingLevel(ResourceSharingLevel.fromString(resourceSharingLevel))
+
+ String coverageArea = serviceProfile.get("coverageAreaTAList")
+ List<String> coverageAreaList=Arrays.asList(coverageArea.split("\\|"))
+ cnSliceProfile.setCoverageAreaTAList(coverageAreaList)
+
+ String ueMobilityLevel = serviceProfile.get("uEMobilityLevel").toString()
+ cnSliceProfile.setUeMobilityLevel(UeMobilityLevel.fromString(ueMobilityLevel))
+
+ int latency = serviceProfile.get("latency")
+ cnSliceProfile.setLatency(latency)
+
+ int maxUE = serviceProfile.get("maxNumberofUEs")
+ cnSliceProfile.setMaxNumberofUEs(maxUE)
+
+ String snssai = serviceProfile.get("sNSSAI")
+ List<String> snssaiList = Arrays.asList(snssai.split("\\|"))
+ cnSliceProfile.setSnssaiList(snssaiList)
+
+ cnSliceProfile.setPerfReq(perfReq)
+
+ AllocateCnNssi allocateCnNssi = new AllocateCnNssi()
+ allocateCnNssi.setNsstId(execution.getVariable("nsstid"))
+ allocateCnNssi.setNssiName(execution.getVariable("nssiName"))
+ allocateCnNssi.setSliceProfile(cnSliceProfile)
+ allocateCnNssi.setNsiInfo(nsiInfo)
+ allocateCnNssi.setNssiId(nssiId) // need to check this
+ String cnScriptName = sliceTaskParams.getCnScriptName()
+ allocateCnNssi.setScriptName(cnScriptName)
+ request.setAllocateCnNssi(allocateCnNssi)
+ request.setEsrInfo(esrInfo)
+ break;
+ case "TN":
+ EsrInfo esrInfo = new EsrInfo()
+ esrInfo.setNetworkType(execution.getVariable("networkType"))
+ esrInfo.setVendor(execution.getVariable("vendor"))
+
+ TnSliceProfile tnSliceProfile = new TnSliceProfile()
+ tnSliceProfile.setLatency(execution.getVariable("latency"))
+ tnSliceProfile.setBandwidth(execution.getVariable("bandWidth"))
+
+ NsiInfo nsiInfo = new NsiInfo()
+ nsiInfo.setNsiId(execution.getVariable("nsiInstanceID"))
+ nsiInfo.setNsiName(execution.getVariable("nsiInstanceName"))
+
+ AllocateTnNssi allocateTnNssi = new AllocateTnNssi()
+ allocateTnNssi.setSliceProfile(tnSliceProfile)
+ allocateTnNssi.setNsiInfo(nsiInfo)
+ allocateTnNssi.setNsstId(execution.getVariable("nsstid"))
+ String tnScriptName = sliceTaskParams.getTnScriptName()
+ allocateTnNssi.setScriptName(tnScriptName)
+ request.setAllocateTnNssi(allocateTnNssi)
+ request.setEsrInfo(esrInfo)
+ break;
+ default:
+ break;
+ }
+ try {
+ strRequest = MAPPER.writeValueAsString(request);
+ } catch (IOException e) {
+ logger.error("Invalid get progress request bean to convert as string");
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Invalid get progress request bean to convert as string")
+ }
+ return strRequest
+ }
+
+ String buildNSSMFProgressRequest(DelegateExecution execution){
+ JobStatusRequest request = new JobStatusRequest()
+ String strRequest = ""
+ EsrInfo esrInfo = execution.getVariable("esrInfo")
+ request.setNsiId(execution.getVariable("nsiServiceInstanceId"))
+ request.setNssiId(execution.getVariable("nssiId"))
+ request.setEsrInfo(esrInfo)
+
+ try {
+ strRequest = MAPPER.writeValueAsString(request);
+ } catch (IOException e) {
+ logger.error("Invalid get progress request bean to convert as string");
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Invalid get progress request bean to convert as string")
+ }
+ return strRequest
+ }
+
+ public void prepareUpdateOrchestrationTask(DelegateExecution execution) {
+ logger.debug("Start prepareUpdateOrchestrationTask progress")
+ String requestMethod = "PUT"
+ String progress = execution.getVariable("nssmfProgress")
+ String status = execution.getVariable("nssmfStatus")
+ String statusDescription=execution.getVariable("nddmfStatusDescription")
+ SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
+ String domain = execution.getVariable("nsstDomain")
+ switch (domain.toUpperCase()) {
+ case "AN":
+ sliceTaskParams.setAnProgress(progress)
+ sliceTaskParams.setAnStatus(status)
+ sliceTaskParams.setAnStatusDescription(statusDescription)
+ break;
+ case "CN":
+ sliceTaskParams.setCnProgress(progress)
+ sliceTaskParams.setCnStatus(status)
+ sliceTaskParams.setCnStatusDescription(statusDescription)
+ break;
+ case "TN":
+ sliceTaskParams.setTnProgress(progress)
+ sliceTaskParams.setTnStatus(status)
+ sliceTaskParams.setTnStatusDescription(statusDescription)
+ break;
+ default:
+ break;
+ }
+ String paramJson = sliceTaskParams.convertToJson()
+ execution.setVariable("CSSOT_paramJson", paramJson)
+ execution.setVariable("CSSOT_requestMethod", requestMethod)
+ logger.debug("Finish prepareUpdateOrchestrationTask progress")
+ }
+
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateCommunicationService.groovy
new file mode 100644
index 0000000000..fb4bd158b7
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateCommunicationService.groovy
@@ -0,0 +1,210 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2019, CMCC Technologies Co., Ltd.
+ #
+ # 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.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.CommunicationServiceProfile
+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.json.JsonUtils
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.AAIResourcesClient
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+
+import static org.apache.commons.lang3.StringUtils.isBlank
+
+/**
+ * This groovy class supports the <class>DoCreateCommunicationService.bpmn</class> process.
+ * AlaCarte flow for 1702 ServiceInstance Create
+ *
+ */
+class DoCreateCommunicationService extends AbstractServiceTaskProcessor{
+ String Prefix="DCCS_"
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+ JsonUtils jsonUtil = new JsonUtils()
+ AAIResourcesClient client = new AAIResourcesClient()
+
+ private static final Logger logger = LoggerFactory.getLogger( DoCreateCommunicationService.class)
+
+ @Override
+ void preProcessRequest(DelegateExecution execution) {
+ logger.trace("start preProcessRequest")
+ execution.setVariable("prefix", Prefix)
+ String msg = ""
+ try {
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ if (isBlank(serviceInstanceId)) {
+ msg = "Input serviceInstanceId' is null"
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ }
+
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ if (isBlank(globalSubscriberId)) {
+ msg = "Input globalSubscriberId' is null"
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ }
+
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+ if (isBlank(subscriptionServiceType)) {
+ msg = "Input subscriptionServiceType' is null"
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ }
+
+
+ } catch(BpmnError e) {
+ throw e
+ } catch(Exception ex) {
+ msg = "Exception in preProcessRequest " + ex.getMessage()
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.trace("Exit preProcessRequest")
+ }
+
+ /**
+ * create communication service, generate S-NSSAI Id and communication service profile
+ * 1.create communication service profile
+ *
+ */
+ def createCommunicationServiceProfile = { DelegateExecution execution ->
+ logger.trace("createCSandServiceProfile")
+ String msg = ""
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+ try {
+ // String sNSSAI_id = execution.getVariable("sNSSAI_id")
+ // create communication service profile
+ String profileId = UUID.randomUUID().toString()
+ execution.setVariable("communicationProfileId", profileId)
+
+ def csInputMap = execution.getVariable("csInputMap") as Map<String, ?>
+ Integer latency = csInputMap.get("latency") as Integer
+ Integer maxNumberOfUEs = csInputMap.get("maxNumberofUEs") as Integer
+ Integer expDataRateDL = csInputMap.get("expDataRateDL") as Integer
+ Integer expDataRateUL = csInputMap.get("expDataRateUL") as Integer
+ String coverageArea = csInputMap.get("coverageAreaTAList")
+ String uEMobilityLevel = csInputMap.get("uEMobilityLevel")
+ String resourceSharingLevel = csInputMap.get("resourceSharingLevel")
+
+ CommunicationServiceProfile csp = new CommunicationServiceProfile()
+ csp.setProfileId(profileId)
+
+ csp.setLatency(latency)
+ csp.setMaxNumberOfUEs(maxNumberOfUEs)
+ csp.setUeMobilityLevel(uEMobilityLevel)
+ csp.setResourceSharingLevel(resourceSharingLevel)
+ csp.setExpDataRateDL(expDataRateDL)
+ csp.setExpDataRateUL(expDataRateUL)
+ csp.setCoverageAreaList(coverageArea)
+
+ execution.setVariable("communicationServiceInstanceProfile", csp)
+
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.COMMUNICATION_SERVICE_PROFILE,
+ globalSubscriberId,
+ subscriptionServiceType,
+ serviceInstanceId,
+ profileId
+ )
+ client.create(uri, csp)
+
+
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ msg = "Exception in createCSandServiceProfile " + ex.getMessage()
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.trace("exit createCSandServiceProfile")
+ }
+
+
+ /**
+ * create communication service, generate S-NSSAI Id
+ * 1.generate S-NSSAI Id
+ * 2.create communication service
+ *
+ */
+ def createCommunicationService = { DelegateExecution execution ->
+ logger.trace("create communication service")
+ String msg
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ try {
+ //generate S-NSSAI Id and communication service profile
+ String sNSSAI_id = generateNSSAI(serviceInstanceId)
+
+ execution.setVariable("sNSSAI_id", sNSSAI_id)
+ // 创建service
+ String serviceInstanceName = execution.getVariable("serviceInstanceName")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+ String csServiceType = execution.getVariable("csServiceType")
+ String aaiServiceRole = "communication-service" //待确定
+
+ String oStatus = "processing"
+ String uuiRequest = execution.getVariable("uuiRequest")
+ String modelInvariantUuid = execution.getVariable("modelInvariantUuid")
+ String modelUuid = execution.getVariable("modelUuid")
+ String useInterval = execution.getVariable("useInterval")
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+
+ // create service
+ ServiceInstance csi = new ServiceInstance()
+ csi.setServiceInstanceName(serviceInstanceName)
+ csi.setServiceType(csServiceType)
+ csi.setServiceRole(aaiServiceRole)
+ csi.setOrchestrationStatus(oStatus)
+ csi.setModelInvariantId(modelInvariantUuid)
+ csi.setModelVersionId(modelUuid)
+ csi.setInputParameters(uuiRequest)
+ csi.setWorkloadContext(useInterval)
+ csi.setEnvironmentContext(sNSSAI_id)
+
+ //timestamp format YYYY-MM-DD hh:mm:ss
+ csi.setCreatedAt(new Date(System.currentTimeMillis()).format("yyyy-MM-dd HH:mm:ss", TimeZone.getDefault()))
+
+ execution.setVariable("communicationServiceInstance", csi)
+
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, subscriptionServiceType, serviceInstanceId)
+ client.create(uri, csi)
+
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ msg = "Exception in communication service " + ex.getMessage()
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.trace("exit communication service")
+ }
+
+ private static generateNSSAI = { final String instanceId ->
+ int h, res
+ res = (instanceId == null) ? 0 : (h = instanceId.hashCode()) ^ (h >>> 16)
+ res = res >>> 1
+ return "01-" + Integer.toHexString(res).toUpperCase()
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy
index 15b91e5221..6af7cc069e 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy
@@ -26,7 +26,7 @@ import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.SerializationFeature
import org.onap.so.logger.LoggingAnchor
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import static org.apache.commons.lang3.StringUtils.*
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy
index 22c8a11fae..5c8ece88fe 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy
@@ -41,6 +41,7 @@ import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.client.aai.AAIObjectPlurals
import org.onap.so.client.aai.AAIObjectType
import org.onap.so.client.aai.AAIResourcesClient
+import org.onap.so.client.aai.entities.uri.AAIPluralResourceUri
import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.client.aai.entities.AAIResultWrapper
@@ -379,7 +380,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor {
String networkName = utils.getNodeText(networkInputs, "network-name")
AAIResourcesClient client = new AAIResourcesClient()
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.L3_NETWORK).queryParam("network-name", networkName)
+ AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.L3_NETWORK).queryParam("network-name", networkName)
L3Networks networks = client.get(uri, NotFoundException.class).asBean(L3Networks.class).get()
L3Network network = networks.getL3Network().get(0)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy
index 64d9827c7c..78b8e2d8a7 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy
@@ -23,7 +23,6 @@
package org.onap.so.bpmn.infrastructure.scripts;
import static org.apache.commons.lang3.StringUtils.*;
-
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.aai.domain.yang.OwningEntity
@@ -44,7 +43,6 @@ import org.onap.so.bpmn.infrastructure.aai.groovyflows.AAICreateResources
import org.onap.so.client.aai.AAIObjectType
import org.onap.so.client.aai.AAIResourcesClient
import org.onap.so.client.aai.entities.uri.AAIResourceUri
-import org.onap.so.client.aai.entities.uri.AAIUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.slf4j.Logger
import org.slf4j.LoggerFactory
@@ -293,7 +291,7 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor {
String globalCustomerId = execution.getVariable("globalSubscriberId") //VID to AAI name map
logger.debug(" ***** getAAICustomerById ***** globalCustomerId:" + globalCustomerId)
- AAIUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CUSTOMER, globalCustomerId)
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CUSTOMER, globalCustomerId)
if(!getAAIClient().exists(uri)){
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "GlobalCustomerId:" + globalCustomerId + " not found (404) in AAI")
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy
new file mode 100644
index 0000000000..5a955e65f5
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy
@@ -0,0 +1,230 @@
+package org.onap.so.bpmn.infrastructure.scripts
+
+
+import org.onap.aai.domain.yang.AllottedResource
+
+import static org.apache.commons.lang3.StringUtils.*;
+
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.OwningEntity
+import org.onap.aai.domain.yang.ServiceProfile;
+import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.onap.so.bpmn.common.scripts.CatalogDbUtils
+import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory
+import org.onap.so.bpmn.common.scripts.ExceptionUtil
+import org.onap.so.bpmn.common.scripts.MsoUtils
+import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
+import org.onap.so.bpmn.core.RollbackData
+import org.onap.so.bpmn.core.UrnPropertiesReader
+import org.onap.so.bpmn.core.WorkflowException
+import org.onap.so.bpmn.core.domain.ModelInfo
+import org.onap.so.bpmn.core.domain.ServiceDecomposition
+import org.onap.so.bpmn.core.domain.ServiceInstance
+import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.bpmn.infrastructure.aai.groovyflows.AAICreateResources
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.AAIResourcesClient
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+
+
+
+class DoCreateSliceServiceInstance extends AbstractServiceTaskProcessor{
+
+ private static final Logger logger = LoggerFactory.getLogger( DoCreateSliceServiceInstance.class);
+ JsonUtils jsonUtil = new JsonUtils()
+
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+
+ CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create()
+
+ /**
+ * Pre Process the BPMN Flow Request
+ * Inclouds:
+ * generate the nsOperationKey
+ * generate the nsParameters
+ */
+ void preProcessRequest (DelegateExecution execution) {
+ String msg = ""
+ logger.trace("Enter preProcessRequest()")
+ //Need update
+ //1. Prepare service parameter.
+ //2. Prepare slice profile parameters.
+
+ String sliceserviceInstanceId = execution.getVariable("serviceInstanceId")
+ String allottedResourceId = UUID.randomUUID().toString()
+ execution.setVariable("sliceserviceInstanceId", sliceserviceInstanceId)
+ execution.setVariable("allottedResourceId", allottedResourceId)
+
+ String uuiRequest = execution.getVariable("uuiRequest")
+ String modelInvariantUuid = jsonUtil.getJsonValue(uuiRequest, "service.serviceInvariantUuid")
+ String modelUuid = jsonUtil.getJsonValue(uuiRequest, "service.serviceUuid")
+ //here modelVersion is not set, we use modelUuid to decompose the service.
+ def isDebugLogEnabled = true
+ execution.setVariable("serviceInstanceId",sliceserviceInstanceId)
+ execution.setVariable("isDebugLogEnabled",isDebugLogEnabled)
+ String serviceModelInfo = """{
+ "modelInvariantUuid":"${modelInvariantUuid}",
+ "modelUuid":"${modelUuid}",
+ "modelVersion":""
+ }"""
+ execution.setVariable("serviceModelInfo", serviceModelInfo)
+
+ logger.trace("Exit preProcessRequest")
+ }
+
+
+ void createServiceProfile(DelegateExecution execution) {
+
+ String sliceserviceInstanceId = execution.getVariable("sliceserviceInstanceId")
+ Map<String, Object> serviceProfileMap = execution.getVariable("serviceProfile")
+ String serviceProfileID = UUID.randomUUID().toString()
+ ServiceProfile serviceProfile = new ServiceProfile();
+ serviceProfile.setProfileId(serviceProfileID)
+ serviceProfile.setLatency(Integer.parseInt(serviceProfileMap.get("latency").toString()))
+ serviceProfile.setMaxNumberOfUEs(Integer.parseInt(serviceProfileMap.get("maxNumberofUEs").toString()))
+ serviceProfile.setCoverageAreaTAList(serviceProfileMap.get("coverageAreaTAList").toString())
+ serviceProfile.setUeMobilityLevel(serviceProfileMap.get("uEMobilityLevel").toString())
+ serviceProfile.setResourceSharingLevel(serviceProfileMap.get("resourceSharingLevel").toString())
+ serviceProfile.setExpDataRateUL(Integer.parseInt(serviceProfileMap.get("expDataRateUL").toString()))
+ serviceProfile.setExpDataRateDL(Integer.parseInt(serviceProfileMap.get("expDataRateDL").toString()))
+ serviceProfile.setAreaTrafficCapUL(Integer.parseInt(serviceProfileMap.get("areaTrafficCapUL").toString()))
+ serviceProfile.setAreaTrafficCapDL(Integer.parseInt(serviceProfileMap.get("areaTrafficCapDL").toString()))
+ serviceProfile.setActivityFactor(Integer.parseInt(serviceProfileMap.get("activityFactor").toString()))
+
+ serviceProfile.setJitter(0)
+ serviceProfile.setSurvivalTime(0)
+ serviceProfile.setCsAvailability(new Object())
+ serviceProfile.setReliability(new Object())
+ serviceProfile.setExpDataRate(0)
+ serviceProfile.setTrafficDensity(0)
+ serviceProfile.setConnDensity(0)
+ try {
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_PROFILE, execution.getVariable("globalSubscriberId"),
+ execution.getVariable("subscriptionServiceType"), sliceserviceInstanceId, serviceProfileID)
+ client.create(uri, serviceProfile)
+
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ String msg = "Exception in DoCreateSliceServiceInstance.instantiateSliceService. " + ex.getMessage()
+ logger.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ }
+
+ void instantiateSliceService(DelegateExecution execution) {
+
+ ServiceDecomposition serviceDecomposition= execution.getVariable("sliceServiceDecomposition")
+ String uuiRequest = execution.getVariable("uuiRequest")
+ ModelInfo modelInfo = serviceDecomposition.getModelInfo()
+ String serviceRole = "e2eslice-service"
+ String serviceType = execution.getVariable("serviceType")
+ Map<String, Object> serviceProfile = execution.getVariable("serviceProfile")
+ String ssInstanceId = execution.getVariable("serviceInstanceId")
+ try {
+ org.onap.aai.domain.yang.ServiceInstance ss = new org.onap.aai.domain.yang.ServiceInstance()
+ ss.setServiceInstanceId(ssInstanceId)
+ String sliceInstanceName = execution.getVariable("serviceInstanceName")
+ ss.setServiceInstanceName(sliceInstanceName)
+ ss.setServiceType(serviceType)
+ String serviceStatus = "deactivated"
+ ss.setOrchestrationStatus(serviceStatus)
+ String modelInvariantUuid = modelInfo.getModelInvariantUuid()
+ String modelUuid = modelInfo.getModelUuid()
+ ss.setModelInvariantId(modelInvariantUuid)
+ ss.setModelVersionId(modelUuid)
+ String serviceInstanceLocationid = serviceProfile.get("plmnIdList")
+ ss.setServiceInstanceLocationId(serviceInstanceLocationid)
+ String snssai = serviceProfile.get("sNSSAI")
+ ss.setEnvironmentContext(snssai)
+ ss.setServiceRole(serviceRole)
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), ssInstanceId)
+ client.create(uri, ss)
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ String msg = "Exception in DoCreateSliceServiceInstance.instantiateSliceService. " + ex.getMessage()
+ logger.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+
+
+ def rollbackData = execution.getVariable("RollbackData")
+ if (rollbackData == null) {
+ rollbackData = new RollbackData();
+ }
+ //rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString())
+ rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true")
+ rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", ssInstanceId)
+ rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
+ rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId"))
+ execution.setVariable("rollbackData", rollbackData)
+ execution.setVariable("RollbackData", rollbackData)
+ logger.debug("RollbackData:" + rollbackData)
+
+ }
+
+
+ void createAllottedResource(DelegateExecution execution) {
+ String serviceInstanceId = execution.getVariable('sliceserviceInstanceId')
+
+ AAIResourcesClient resourceClient = new AAIResourcesClient()
+ AAIResourceUri ssServiceuri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId)
+
+// try {
+//
+// if(resourceClient.exists(ssServiceuri)){
+// execution.setVariable("ssi_resourceLink", uri.build().toString())
+// }else{
+// exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai to " +
+// "associate allotted resource for service :"+serviceInstanceId)
+// }
+// }catch(BpmnError e) {
+// throw e;
+// }catch (Exception ex){
+// String msg = "Exception in getServiceInstance. " + ex.getMessage()
+// logger.debug(msg)
+// exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+// }
+
+ try {
+ String allottedResourceId = execution.getVariable("allottedResourceId")
+ ServiceDecomposition serviceDecomposition = execution.getVariable("sliceServiceDecomposition")
+ List<org.onap.so.bpmn.core.domain.AllottedResource> allottedResourceList = serviceDecomposition.getAllottedResources()
+ for(org.onap.so.bpmn.core.domain.AllottedResource allottedResource : allottedResourceList)
+ {
+ //AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceFromParentURI(ssServiceuri, AAIObjectType.ALLOTTED_RESOURCE, allottedResourceId)
+ AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE,
+ execution.getVariable("globalSubscriberId"),execution.getVariable("subscriptionServiceType"),
+ execution.getVariable("sliceserviceInstanceId"), allottedResourceId)
+ execution.setVariable("allottedResourceUri", allottedResourceUri)
+ String arType = allottedResource.getAllottedResourceType()
+ String arRole = allottedResource.getAllottedResourceRole()
+ String modelInvariantId = allottedResource.getModelInfo().getModelInvariantUuid()
+ String modelVersionId = allottedResource.getModelInfo().getModelUuid()
+
+ org.onap.aai.domain.yang.AllottedResource resource = new org.onap.aai.domain.yang.AllottedResource()
+ resource.setId(allottedResourceId)
+ resource.setType(arType)
+ resource.setAllottedResourceName("Allotted_"+ execution.getVariable("serviceInstanceName"))
+ resource.setRole(arRole)
+ resource.setModelInvariantId(modelInvariantId)
+ resource.setModelVersionId(modelVersionId)
+ getAAIClient().create(allottedResourceUri, resource)
+ //AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.SERVICE_INSTANCE, UriBuilder.fromPath(ssServiceuri).build())
+ //getAAIClient().connect(allottedResourceUri,ssServiceuri)
+ }
+ //execution.setVariable("aaiARPath", allottedResourceUri.build().toString());
+
+ }catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception in createAaiAR " + ex.getMessage())
+ }
+ }
+
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy
new file mode 100644
index 0000000000..c66a89b9c6
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy
@@ -0,0 +1,524 @@
+package org.onap.so.bpmn.infrastructure.scripts
+
+import com.fasterxml.jackson.core.type.TypeReference
+import groovy.json.JsonBuilder
+import groovy.json.JsonSlurper
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.Relationship
+import org.onap.aai.domain.yang.RelationshipList
+import org.onap.aai.domain.yang.ServiceInstance
+import org.onap.logging.filter.base.ONAPComponents
+import org.onap.so.beans.nsmf.SliceTaskParams
+import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.onap.so.bpmn.common.scripts.ExceptionUtil
+import org.onap.so.bpmn.common.scripts.OofUtils
+import org.onap.so.bpmn.core.UrnPropertiesReader
+import org.onap.so.bpmn.core.domain.ServiceDecomposition
+import org.onap.so.bpmn.core.domain.ServiceProxy
+import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.client.HttpClient
+import org.onap.so.client.HttpClientFactory
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.AAIResourcesClient
+import org.onap.so.client.aai.entities.AAIResultWrapper
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+import org.onap.so.db.request.client.RequestsDbClient
+import org.onap.so.db.request.beans.OrchestrationTask
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+import javax.ws.rs.NotFoundException
+import javax.ws.rs.core.Response
+
+import static org.apache.commons.lang3.StringUtils.isBlank
+
+public class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
+
+ private static final Logger logger = LoggerFactory.getLogger( DoCreateSliceServiceOption.class)
+
+
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+
+ JsonUtils jsonUtil = new JsonUtils()
+
+ RequestsDbClient requestsDbClient = new RequestsDbClient()
+
+ OofUtils oofUtils = new OofUtils()
+
+ /**
+ * Pre Process the BPMN Flow Request
+ * Inclouds:
+ * generate the nsOperationKey
+ * generate the nsParameters
+ */
+ void preProcessRequest (DelegateExecution execution) {
+ String msg = ""
+ logger.trace("Enter preProcessRequest()")
+ String taskID = execution.getVariable("taskID")
+ Boolean isSharable = true
+ String resourceSharingLevel = execution.getVariable("resourceSharingLevel")
+ if (resourceSharingLevel.equals("shared"))
+ isSharable = true
+ execution.setVariable("isSharable",isSharable)
+ logger.trace("Exit preProcessRequest")
+
+ }
+
+
+ void getNSIOptionfromOOF(DelegateExecution execution) {
+
+ String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
+ logger.debug( "get NSI option OOF Url: " + urlString)
+ boolean isNSISuggested = true
+ execution.setVariable("isNSISuggested",isNSISuggested)
+ String nsiInstanceId = ""
+ String nsiName = ""
+ SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
+ //Prepare auth for OOF - Begin
+ def authHeader = ""
+ String basicAuth = UrnPropertiesReader.getVariable("mso.oof.auth", execution)
+ String msokey = UrnPropertiesReader.getVariable("mso.msoKey", execution)
+
+ String basicAuthValue = utils.encrypt(basicAuth, msokey)
+ if (basicAuthValue != null) {
+ logger.debug( "Obtained BasicAuth username and password for OOF: " + basicAuthValue)
+ try {
+ authHeader = utils.getBasicAuth(basicAuthValue, msokey)
+ execution.setVariable("BasicAuthHeaderValue", authHeader)
+ } catch (Exception ex) {
+ logger.debug( "Unable to encode username and password string: " + ex)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - Unable to " +
+ "encode username and password string")
+ }
+ } else {
+ logger.debug( "Unable to obtain BasicAuth - BasicAuth value null")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth " +
+ "value null")
+ }
+ //Prepare auth for OOF - End
+
+ String requestId = execution.getVariable("msoRequestId")
+ Map<String, Object> profileInfo = execution.getVariable("serviceProfile")
+ String nstModelUuid = execution.getVariable("nstModelUuid")
+ String nstModelInvariantUuid = execution.getVariable("nstModelInvariantUuid")
+ String nstInfo = """"NSTInfo" : {
+ "invariantUUID":"${nstModelInvariantUuid}",
+ "UUID":"${nstModelUuid}"
+ }"""
+
+ String oofRequest = oofUtils.buildSelectNSIRequest(execution, requestId, nstInfo, profileInfo)
+
+ //send request to get NSI option - Begin
+ URL url = new URL(urlString+"/api/oof/v1/selectnsi")
+ HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.OOF)
+ httpClient.addAdditionalHeader("Authorization", authHeader)
+ Response httpResponse = httpClient.post(oofRequest)
+
+ int responseCode = httpResponse.getStatus()
+ logger.debug("OOF sync response code is: " + responseCode)
+
+ if(responseCode != 200){
+ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.")
+ logger.debug("Info: No NSI suggested by OOF" )
+ }
+
+ if(httpResponse.hasEntity()){
+ String OOFResponse = httpResponse.readEntity(String.class)
+ execution.setVariable("OOFResponse", OOFResponse)
+ int index = 0 //This needs to be changed to derive a value when we add policy to decide the solution options.
+ Map OOFResponseObject = new JsonSlurper().parseText(OOFResponse)
+ if(execution.getVariable("isSharable" ) == true && OOFResponseObject.get("solutions").containsKey("sharedNSIsolutions")) {
+ nsiInstanceId = OOFResponseObject.get("solutions").get("sharedNSIsolutions").get(0).get("NSISolution").NSIId
+ nsiName = OOFResponseObject.get("solutions").get("sharedNSIsolutions").get(0).get("NSISolution").NSIName
+ sliceTaskParams.setNstId(nsiInstanceId)
+ sliceTaskParams.setSuggestNsiName(nsiName)
+ execution.setVariable("nsiInstanceId",nsiInstanceId)
+ execution.setVariable("nsiName",nsiName)
+ }else {
+ if(OOFResponseObject.get("solutions").containsKey("newNSISolutions")) {
+ List NSSImap = OOFResponseObject.get("solutions").get("newNSISolutions").get(index).get("NSSISolutions")
+ for(Map nssi : NSSImap) {
+ String nssiName = nssi.get("NSSISolution").NSSIName
+ String nssiId = nssi.get("NSSISolution").NSSIId
+ String domain = nssi.get("NSSISolution").domain.toUpperCase()
+ switch (domain) {
+ case "AN":
+ sliceTaskParams.setAnSuggestNssiId(nssiId)
+ sliceTaskParams.setAnSuggestNssiName(nssiName)
+ break;
+ case "CN":
+ sliceTaskParams.setCnSuggestNssiId(nssiId)
+ sliceTaskParams.setCnSuggestNssiName(nssiName)
+ break;
+ case "TN":
+ sliceTaskParams.setTnSuggestNssiId(nssiId)
+ sliceTaskParams.setTnSuggestNssiName(nssiName)
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ }
+ execution.setVariable("sliceTaskParams", sliceTaskParams)
+ logger.debug("Info: No NSI suggested by OOF" )
+ }
+ //send request to get NSI option - Begin
+
+
+ //send request to get NSI service Info - Begin
+
+ /***
+ * Need to check whether its needed.
+ */
+// logger.debug("Begin to query OOF suggetsed NSI from AAI ")
+// if(isBlank(nsiInstanceId)){
+// isNSISuggested = false
+// execution.setVariable("isNSISuggested",isNSISuggested)
+// }else
+// {
+// try {
+// String globalSubscriberId = execution.getVariable('globalSubscriberId')
+// String serviceType = execution.getVariable('subscriptionServiceType')
+// AAIResourcesClient resourceClient = new AAIResourcesClient()
+// AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, nsiInstanceId)
+// AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class)
+// Optional<org.onap.aai.domain.yang.ServiceInstance> si = wrapper.asBean(org.onap.aai.domain.yang.ServiceInstance.class)
+// org.onap.aai.domain.yang.ServiceInstance nsiServiceInstance = si.get()
+// execution.setVariable("nsiServiceInstance",nsiServiceInstance)
+// isNSISuggested = true
+// execution.setVariable("isNSISuggested",isNSISuggested)
+// SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
+// sliceTaskParams.setSuggestNsiId(nsiInstanceId)
+// sliceTaskParams.setSuggestNsiName(si.get().getServiceInstanceName())
+// execution.setVariable("sliceTaskParams", sliceTaskParams)
+// logger.debug("Info: NSI suggested by OOF exist in AAI ")
+// }catch(BpmnError e) {
+// throw e
+// }catch(Exception ex) {
+// String msg = "Internal Error in getServiceInstance: " + ex.getMessage()
+// //exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+// logger.debug("Info: NSI suggested by OOF doesnt exist in AAI " + nsiInstanceId)
+// }
+// }
+ //send request to get NSI service Info - End
+ //${OrchestrationTaskHandler.createOrchestrationTask(execution.getVariable("OrchestrationTask"))}
+ logger.debug( "*** Completed options Call to OOF ***")
+
+ }
+
+
+ public void parseServiceProfile(DelegateExecution execution) {
+ logger.debug("Start parseServiceProfile")
+ String serviceType = execution.getVariable("serviceType")
+ Map<String, Object> serviceProfile = execution.getVariable("serviceProfile")
+
+ // set sliceProfile for three domains
+ Map<String, Object> sliceProfileTn = getSliceProfile(serviceType, "TN", serviceProfile)
+ Map<String, Object> sliceProfileCn = getSliceProfile(serviceType, "CN", serviceProfile)
+ Map<String, Object> sliceProfileAn = getSliceProfile(serviceType, "AN", serviceProfile)
+
+ execution.setVariable("sliceProfileTn", sliceProfileTn)
+ execution.setVariable("sliceProfileCn", sliceProfileCn)
+ execution.setVariable("sliceProfileAn", sliceProfileAn)
+ logger.debug("sliceProfileTn: " + sliceProfileTn)
+ logger.debug("sliceProfileCn: " + sliceProfileCn)
+ logger.debug("sliceProfileAn: " + sliceProfileAn)
+
+ logger.debug("Finish parseServiceProfile")
+ }
+
+ public Map getSliceProfile(String serviceType, String domain, Map<String, Object> serviceProfile) {
+ String variablePath = "nsmf." + serviceType + ".profileMap" + domain
+ String profileMapStr = UrnPropertiesReader.getVariable(variablePath)
+ logger.debug("Profile map for " + domain + " : " + profileMapStr)
+ Map<String, String> profileMaps = objectMapper.readValue(profileMapStr, new TypeReference<Map<String, String>>(){})
+ Map<String, Object> sliceProfileTn = [:]
+ for (Map.Entry<String, String> profileMap : profileMaps) {
+ sliceProfileTn.put(profileMap.key, serviceProfile.get(profileMap.value))
+ }
+
+ return sliceProfileTn
+ }
+
+
+ void prepareNSSIList(DelegateExecution execution)
+ {
+ ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition")
+ List<String> nssiAssociated = new ArrayList<>()
+ Map<String, String> nssimap = new HashMap<>()
+ String nsiInstanceId=execution.getVariable("nsiInstanceId")
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String serviceType = execution.getVariable("subscriptionServiceType")
+
+ try {
+
+ ServiceInstance si = execution.getVariable("nsiServiceInstance")
+ //List<Relationship> relationships = si.getRelationshipList().getRelationship().stream().filter(relation ->
+ // relation.getRelatedTo().equalsIgnoreCase("service-instance"))
+ RelationshipList relationshipList = si.getRelationshipList()
+ List<Relationship> relationships = relationshipList.getRelationship()
+ for(Relationship relationship in relationships)
+ {
+ if(relationship.getRelatedTo().equalsIgnoreCase("service-instance"))
+ {
+ String NSSIassociated = relationship.getRelatedLink().substring(relationship.getRelatedLink().lastIndexOf("/") + 1);
+ if(!NSSIassociated.equals(nsiInstanceId))
+ nssiAssociated.add(NSSIassociated)
+ }
+ }
+ }catch(BpmnError e) {
+ throw e
+ }catch(Exception ex) {
+ String msg = "Internal Error in getServiceInstance: " + ex.getMessage()
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ Map<String, Object> params = execution.getVariable("params")
+ SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
+ for(String nssiID in nssiAssociated)
+ {
+ try {
+ AAIResourcesClient resourceClient = new AAIResourcesClient()
+ AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, nssiID)
+ AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class)
+ Optional<org.onap.aai.domain.yang.ServiceInstance> si = wrapper.asBean(org.onap.aai.domain.yang.ServiceInstance.class)
+ org.onap.aai.domain.yang.ServiceInstance nssi = si.get()
+
+ String domain = nssi.getEnvironmentContext().toString().toUpperCase()
+ switch (domain) {
+ case "AN":
+ sliceTaskParams.setAnSuggestNssiId(nssi.getServiceInstanceId())
+ sliceTaskParams.setAnSuggestNssiName(nssi.getServiceInstanceName())
+ break;
+ case "CN":
+ sliceTaskParams.setCnSuggestNssiId(nssi.getServiceInstanceId())
+ sliceTaskParams.setCnSuggestNssiName(nssi.getServiceInstanceName())
+ break;
+ case "TN":
+ sliceTaskParams.setTnSuggestNssiId(nssi.getServiceInstanceId())
+ sliceTaskParams.setTnSuggestNssiName(nssi.getServiceInstanceName())
+ break;
+ default:
+ break;
+ }
+ }catch(NotFoundException e)
+ {
+ logger.debug("NSSI Service Instance not found in AAI: " + nssiID)
+ }catch(Exception e)
+ {
+ logger.debug("NSSI Service Instance not found in AAI: " + nssiID)
+ }
+
+ }
+ String nstName = serviceDecomposition.getModelInfo().getModelName()
+ sliceTaskParams.setNstName(nstName)
+ String nstId = serviceDecomposition.getModelInfo().getModelUuid()
+ sliceTaskParams.setNstId(nstId)
+ execution.setVariable("sliceTaskParams",sliceTaskParams)
+
+ }
+
+
+ void updateOptionsInDB(DelegateExecution execution) {
+ logger.debug("Updating options with default value since not sharable : Begin ")
+ String taskID = execution.getVariable("taskID")
+ String params = execution.getVariable("params")
+ logger.debug("Updating options with default value since not sharable : End ")
+
+ }
+
+ void prepareNSTDecompose(DelegateExecution execution) {
+
+ String modelUuid = execution.getVariable("nstModelUuid")
+ String modelInvariantUuid = execution.getVariable("nstModelInvariantUuid")
+
+ String serviceModelInfo = """{
+ "modelInvariantUuid":"${modelInvariantUuid}",
+ "modelUuid":"${modelUuid}",
+ "modelVersion":""
+ }"""
+ execution.setVariable("serviceModelInfo", serviceModelInfo)
+ }
+
+ void prepareNSSTDecompose(DelegateExecution execution) {
+ Boolean isMoreNSSTtoProcess = false
+ Integer maxNSST = execution.getVariable("maxNSST")
+ Integer currentNSST=execution.getVariable("currentNSST")
+ List<String> nsstModelUUIDList = new ArrayList<>()
+ nsstModelUUIDList = execution.getVariable("nsstModelUUIDList")
+ String modelUuid = nsstModelUUIDList.get(currentNSST)
+ String serviceModelInfo = """{
+ "modelInvariantUuid":"",
+ "modelUuid":"${modelUuid}",
+ "modelVersion":""
+ }"""
+ execution.setVariable("serviceModelInfo", serviceModelInfo)
+ currentNSST=currentNSST+1
+ if(currentNSST<maxNSST)
+ isMoreNSSTtoProcess=true
+ execution.setVariable("isMoreNSSTtoProcess",isMoreNSSTtoProcess)
+ execution.setVariable("maxNSST",maxNSST)
+ execution.setVariable("currentNSST",currentNSST)
+ }
+
+
+ void updateStatusInDB(DelegateExecution execution) {
+
+ String taskID = execution.getVariable("taskID")
+ //OrchestrationTask orchestrationTask = requestsDbClient.getNetworkSliceOption(taskID);
+ //orchestrationTask.setTaskStage("wait to confirm")
+ //requestsDbClient.updateNetworkSliceOption(orchestrationTask)
+ }
+
+ void prepareNSSTlistfromNST(DelegateExecution execution) {
+ //Need to update this part from decomposition.
+ logger.trace("Enter prepareNSSTlistfromNST()")
+ Boolean isMoreNSSTtoProcess = false
+ ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition")
+ SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
+ String nstName = serviceDecomposition.getModelInfo().getModelName()
+ sliceTaskParams.setNstName(nstName)
+ String nstId = serviceDecomposition.getModelInfo().getModelUuid()
+ sliceTaskParams.setNstId(nstId)
+ execution.setVariable("sliceTaskParams",sliceTaskParams)
+
+ List<ServiceProxy> proxyList = serviceDecomposition.getServiceProxy()
+ List<String> nsstModelUUIDList = new ArrayList<>()
+ for(ServiceProxy serviceProxy:proxyList)
+ nsstModelUUIDList.add(serviceProxy.getSourceModelUuid())
+ execution.setVariable("nsstModelUUIDList",nsstModelUUIDList)
+ Integer maxNSST = nsstModelUUIDList.size()
+ Integer currentNSST=0
+ execution.setVariable("maxNSST",maxNSST)
+ execution.setVariable("currentNSST",currentNSST)
+ if(currentNSST<maxNSST)
+ isMoreNSSTtoProcess=true
+ execution.setVariable("isMoreNSSTtoProcess",isMoreNSSTtoProcess)
+ logger.trace("Exit prepareNSSTlistfromNST()")
+
+ }
+
+
+ void getNSSTOption(DelegateExecution execution) {
+ ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition")
+ String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String serviceType = execution.getVariable("subscriptionServiceType")
+ String nssiInstanceId =""
+ String nssiName =""
+ SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
+ logger.debug( "get NSI option OOF Url: " + urlString)
+ boolean isNSISuggested = false
+ execution.setVariable("isNSISuggested",isNSISuggested)
+
+ //Prepare auth for OOF - Begin
+ def authHeader = ""
+ String basicAuth = UrnPropertiesReader.getVariable("mso.oof.auth", execution)
+ String msokey = UrnPropertiesReader.getVariable("mso.msoKey", execution)
+
+ String basicAuthValue = utils.encrypt(basicAuth, msokey)
+ if (basicAuthValue != null) {
+ logger.debug( "Obtained BasicAuth username and password for OOF: " + basicAuthValue)
+ try {
+ authHeader = utils.getBasicAuth(basicAuthValue, msokey)
+ execution.setVariable("BasicAuthHeaderValue", authHeader)
+ } catch (Exception ex) {
+ logger.debug( "Unable to encode username and password string: " + ex)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - Unable to " +
+ "encode username and password string")
+ }
+ } else {
+ logger.debug( "Unable to obtain BasicAuth - BasicAuth value null")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth " +
+ "value null")
+ }
+ //Prepare auth for OOF - End
+ //Prepare send request to OOF - Begin
+ String requestId = execution.getVariable("msoRequestId")
+ Map<String, Object> profileInfo = execution.getVariable("serviceProfile")
+ String nsstModelInvariantUuid = serviceDecomposition.getModelInfo().getModelInvariantUuid()
+ String nsstModelUuid = serviceDecomposition.getModelInfo().getModelUuid()
+ String nsstInfo = """"NSSTInfo": {
+ "invariantUUID":"${nsstModelInvariantUuid}",
+ "UUID":"${nsstModelUuid}"
+ }"""
+ String oofRequest = oofUtils.buildSelectNSSIRequest(execution, requestId, nsstInfo ,profileInfo)
+
+
+ URL url = new URL(urlString+"/api/oof/v1/selectnssi")
+ HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.OOF)
+ httpClient.addAdditionalHeader("Authorization", authHeader)
+ Response httpResponse = httpClient.post(oofRequest)
+
+ int responseCode = httpResponse.getStatus()
+ logger.debug("OOF sync response code is: " + responseCode)
+
+ if(responseCode != 200){
+ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.")
+ }
+
+ if(httpResponse.hasEntity()){
+ String OOFResponse = httpResponse.readEntity(String.class)
+ execution.setVariable("OOFResponse", OOFResponse)
+ nssiInstanceId = jsonUtil.getJsonValue(OOFResponse, "NSSIIInfo.NSSIID")
+ nssiName = jsonUtil.getJsonValue(OOFResponse, "NSSIInfo.NSSIName")
+ execution.setVariable("nssiInstanceId",nssiInstanceId)
+ execution.setVariable("nssiName",nssiName)
+ }
+ if(isBlank(nssiInstanceId)){
+ logger.debug( "There is no valid NSST suggested by OOF.")
+ }else
+ {
+ try {
+ AAIResourcesClient resourceClient = new AAIResourcesClient()
+ AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, nssiInstanceId)
+ AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class)
+ Optional<org.onap.aai.domain.yang.ServiceInstance> si = wrapper.asBean(org.onap.aai.domain.yang.ServiceInstance.class)
+ org.onap.aai.domain.yang.ServiceInstance nssi = si.get()
+
+ String domain = nssi.getEnvironmentContext().toString().toUpperCase()
+ switch (domain) {
+ case "AN":
+ sliceTaskParams.setAnSuggestNssiId(nssi.getServiceInstanceId())
+ sliceTaskParams.setAnSuggestNssiName(nssi.getServiceInstanceName())
+ break;
+ case "CN":
+ sliceTaskParams.setCnSuggestNssiId(nssi.getServiceInstanceId())
+ sliceTaskParams.setCnSuggestNssiName(nssi.getServiceInstanceName())
+ break;
+ case "TN":
+ sliceTaskParams.setTnSuggestNssiId(nssi.getServiceInstanceId())
+ sliceTaskParams.setTnSuggestNssiName(nssi.getServiceInstanceName())
+ break;
+ default:
+ break;
+ }
+ }catch(NotFoundException e)
+ {
+ logger.debug("NSSI Service Instance not found in AAI: " + nssiInstanceId)
+ }catch(Exception e)
+ {
+ logger.debug("NSSI Service Instance not found in AAI: " + nssiInstanceId)
+ }
+ }
+
+
+ //Prepare send request to OOF - End
+
+// String content = serviceDecomposition.getServiceInfo().getServiceArtifact().get(0).getContent()
+// String nsstID = jsonUtil.getJsonValue(content, "metadata.id")
+// String vendor = jsonUtil.getJsonValue(content, "metadata.vendor")
+// String domain = jsonUtil.getJsonValue(content, "metadata.domainType")
+// String type = jsonUtil.getJsonValue(content, "metadata.type")
+// String nsstContentInfo = """{
+// "NsstID":"${nsstID}",
+// "Vendor":"${vendor}",
+// "type":"${type}"
+// }"""
+
+ logger.debug("Prepare NSSI option completed ")
+ }
+}
+
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy
index 2def9e2d06..4835c9b84b 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy
@@ -33,7 +33,7 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.client.HttpClient
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import org.onap.so.logger.MessageEnum
import org.slf4j.Logger
import org.slf4j.LoggerFactory
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy
index dafc4b5470..1a3df6ff4e 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy
@@ -22,24 +22,21 @@
package org.onap.so.bpmn.infrastructure.scripts
-import org.onap.so.logger.LoggingAnchor
-import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory
-import org.onap.so.client.HttpClientFactory
-import org.onap.so.logger.ErrorCode
-
import javax.ws.rs.core.MediaType
import javax.ws.rs.core.Response
import javax.xml.parsers.DocumentBuilder
import javax.xml.parsers.DocumentBuilderFactory
-
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.json.JSONArray
import org.json.JSONObject
import org.onap.aai.domain.yang.GenericVnf
import org.onap.aai.domain.yang.NetworkPolicy
+import org.onap.logging.filter.base.ErrorCode
+import org.onap.logging.filter.base.ONAPComponents;
import org.onap.so.bpmn.common.scripts.AaiUtil
import org.onap.so.bpmn.common.scripts.CatalogDbUtils
+import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.common.scripts.NetworkUtils
@@ -53,28 +50,27 @@ import org.onap.so.bpmn.core.domain.VnfResource
import org.onap.so.bpmn.core.json.DecomposeJsonUtil
import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.client.HttpClient
+import org.onap.so.client.HttpClientFactory
import org.onap.so.client.aai.AAIObjectPlurals
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.AAIResourcesClient
import org.onap.so.client.aai.entities.AAIResultWrapper
+import org.onap.so.client.aai.entities.uri.AAIPluralResourceUri
import org.onap.so.client.aai.entities.uri.AAIResourceUri
-import org.onap.so.client.aai.entities.uri.AAIUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.graphinventory.entities.uri.Depth
import org.onap.so.constants.Defaults
import org.onap.so.db.catalog.beans.HomingInstance
+import org.onap.so.logger.LoggingAnchor
import org.onap.so.logger.MessageEnum
import org.slf4j.Logger
import org.slf4j.LoggerFactory
-
-import org.onap.logging.filter.base.ONAPComponents;
import org.w3c.dom.Document
import org.w3c.dom.Element
import org.w3c.dom.NamedNodeMap
import org.w3c.dom.Node
import org.w3c.dom.NodeList
import org.xml.sax.InputSource
-
import com.fasterxml.jackson.databind.ObjectMapper
@@ -307,7 +303,7 @@ public class DoCreateVfModule extends VfModuleBase {
}
try{
- AAIUri serviceInstanceURI = AAIUriFactory.create(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId,serviceType,serviceInstanceId)
+ AAIResourceUri serviceInstanceURI = AAIUriFactory.create(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId,serviceType,serviceInstanceId)
AAIResourcesClient aaiRC = new AAIResourcesClient()
AAIResultWrapper aaiRW = aaiRC.get(serviceInstanceURI)
Map<String, Object> aaiJson = aaiRW.asMap()
@@ -778,7 +774,7 @@ public class DoCreateVfModule extends VfModuleBase {
def vfModuleName = execution.getVariable('DCVFM_vfModuleName')
AaiUtil aaiUriUtil = new AaiUtil(this)
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VF_MODULE, vnfId).queryParam("vf-module-name",vfModuleName)
+ AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VF_MODULE, vnfId).queryParam("vf-module-name",vfModuleName)
String endPoint = aaiUriUtil.createAaiUri(uri)
HttpClient client = httpClientFactory.newXmlClient(new URL(endPoint), ONAPComponents.AAI)
@@ -1927,7 +1923,7 @@ public class DoCreateVfModule extends VfModuleBase {
String fqdn = fqdnList[i]
// Query AAI for this network policy FQDN
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
+ AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
uri.queryParam("network-policy-fqdn", fqdn)
AAIResourcesClient resourceClient = new AAIResourcesClient()
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy
index 4bab2b390d..a77f6f0628 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy
@@ -36,9 +36,10 @@ import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.client.aai.AAIObjectPlurals
import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.uri.AAIPluralResourceUri
import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import org.onap.so.logger.MessageEnum
import org.slf4j.Logger
import org.slf4j.LoggerFactory
@@ -507,7 +508,7 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{
try {
// Query AAI for this network policy FQDN
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
+ AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
uri.queryParam("network-policy-fqdn", fqdn)
Optional<NetworkPolicies> networkPolicies = getAAIClient().get(NetworkPolicies.class, uri)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy
index a233a0a02e..7f2a3e4245 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy
@@ -32,6 +32,7 @@ import org.onap.so.bpmn.core.RollbackData
import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.client.aai.AAIObjectPlurals
import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.uri.AAIPluralResourceUri
import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.constants.Defaults
@@ -132,7 +133,7 @@ public class DoCreateVfModuleVolumeRollback extends AbstractServiceTaskProcessor
volumeGroupName = testVolumeGroupName
}
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion).queryParam("volume-group-name", volumeGroupName)
+ AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion).queryParam("volume-group-name", volumeGroupName)
try {
Optional<VolumeGroups> volumeGroups = getAAIClient().get(VolumeGroups.class, uri)
if (volumeGroups.isPresent()) {
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy
index b2006c45d7..fafe97b0eb 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy
@@ -22,6 +22,7 @@
package org.onap.so.bpmn.infrastructure.scripts
+import javax.ws.rs.NotFoundException
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.aai.domain.yang.GenericVnf
@@ -45,14 +46,12 @@ import org.onap.so.db.catalog.beans.OrchestrationStatus
import org.slf4j.Logger
import org.slf4j.LoggerFactory
-import javax.ws.rs.NotFoundException
-
class DoCreateVfModuleVolumeV2 extends VfModuleBase {
private static final Logger logger = LoggerFactory.getLogger( DoCreateVfModuleVolumeV2.class);
- String prefix='DCVFMODVOLV2_'
- JsonUtils jsonUtil = new JsonUtils()
- private ExceptionUtil exceptionUtil = new ExceptionUtil()
+ String prefix='DCVFMODVOLV2_'
+ JsonUtils jsonUtil = new JsonUtils()
+ private ExceptionUtil exceptionUtil = new ExceptionUtil()
/**
@@ -66,330 +65,327 @@ class DoCreateVfModuleVolumeV2 extends VfModuleBase {
public void preProcessRequest(DelegateExecution execution, isDebugLogEnabled) {
- execution.setVariable("prefix",prefix)
- execution.setVariable(prefix+'SuccessIndicator', false)
- execution.setVariable(prefix+'isPONR', false)
-
- displayInput(execution, isDebugLogEnabled)
- setRollbackData(execution, isDebugLogEnabled)
- setRollbackEnabled(execution, isDebugLogEnabled)
-
-
- def tenantId = execution.getVariable("tenantId")
- if (tenantId == null) {
- String cloudConfiguration = execution.getVariable("cloudConfiguration")
- tenantId = jsonUtil.getJsonValue(cloudConfiguration, "cloudConfiguration.tenantId")
- execution.setVariable("tenantId", tenantId)
- }
-
- def cloudSiteId = execution.getVariable("lcpCloudRegionId")
- if (cloudSiteId == null) {
- String cloudConfiguration = execution.getVariable("cloudConfiguration")
- cloudSiteId = jsonUtil.getJsonValue(cloudConfiguration, "cloudConfiguration.lcpCloudRegionId")
- def cloudOwner = jsonUtil.getJsonValue(cloudConfiguration, "cloudConfiguration.cloudOwner")
- execution.setVariable("lcpCloudRegionId", cloudSiteId)
- execution.setVariable("cloudOwner", cloudOwner)
- }
-
- // Extract attributes from modelInfo
- String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo")
-
- //modelCustomizationUuid
- def modelCustomizationUuid = jsonUtil.getJsonValue(vfModuleModelInfo, "modelCustomizationUuid")
- execution.setVariable("modelCustomizationId", modelCustomizationUuid)
- logger.debug("modelCustomizationId: " + modelCustomizationUuid)
-
- //modelName
- def modelName = jsonUtil.getJsonValue(vfModuleModelInfo, "modelName")
- execution.setVariable("modelName", modelName)
- logger.debug("modelName: " + modelName)
-
- // The following is used on the get Generic Service Instance call
- execution.setVariable('GENGS_type', 'service-instance')
- }
-
-
- /**
- * Display input variables
- * @param execution
- * @param isDebugLogEnabled
- */
- public void displayInput(DelegateExecution execution, isDebugLogEnabled) {
- def input = ['mso-request-id', 'msoRequestId', 'isDebugLogEnabled', 'disableRollback', 'failIfExists', 'serviceInstanceId',
- 'vnfId', 'vnfName', 'tenantId', 'volumeGroupId', 'volumeGroupName', 'lcpCloudRegionId', 'vnfType', 'vfModuleModelInfo', 'asdcServiceModelVersion',
- 'test-volume-group-name', 'test-volume-group-id', 'vfModuleInputParams']
-
- logger.debug('Begin input: ')
- input.each {
- logger.debug(it + ': ' + execution.getVariable(it))
- }
- logger.debug('End input.')
- }
-
-
- /**
- * Define and set rollbackdata object
- * @param execution
- * @param isDebugEnabled
- */
- public void setRollbackData(DelegateExecution execution, isDebugEnabled) {
- def rollbackData = execution.getVariable("rollbackData")
- if (rollbackData == null) {
- rollbackData = new RollbackData()
- }
- def volumeGroupName = execution.getVariable('volumeGroupName')
- rollbackData.put("DCVFMODULEVOL", "volumeGroupName", volumeGroupName)
- execution.setVariable("rollbackData", rollbackData)
- }
-
-
- /**
- * Gets the service instance uri from aai
- */
- public void getServiceInstance(DelegateExecution execution) {
- try {
- String serviceInstanceId = execution.getVariable('serviceInstanceId')
-
- AAIResourcesClient resourceClient = new AAIResourcesClient()
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId)
-
- if(!resourceClient.exists(uri)){
- (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai")
- }
-
- }catch(BpmnError e) {
- throw e
- }catch (Exception ex){
- String msg = "Exception in getServiceInstance. " + ex.getMessage()
- logger.debug(msg)
- (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, msg)
- }
- }
-
- /**
- * Get cloud region
- * @param execution
- * @param isDebugEnabled
- */
- public void callRESTQueryAAICloudRegion (DelegateExecution execution, isDebugEnabled) {
-
- def cloudRegion = execution.getVariable("lcpCloudRegionId")
- logger.debug('Request cloud region is: ' + cloudRegion)
-
- AaiUtil aaiUtil = new AaiUtil(this)
-
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion)
- def queryCloudRegionRequest = aaiUtil.createAaiUri(uri)
-
- cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion)
-
- def aaiCloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "AAI", cloudRegion)
- if ((aaiCloudRegion != "ERROR")) {
- execution.setVariable("lcpCloudRegionId", aaiCloudRegion)
- logger.debug("AIC Cloud Region for AAI: " + aaiCloudRegion)
- } else {
- String errorMessage = "AAI Query Cloud Region Unsuccessful. Return Code: " + execution.getVariable(prefix+"queryCloudRegionReturnCode")
- logger.debug(errorMessage)
- (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, errorMessage)
- }
-
- def poCloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion)
- if ((poCloudRegion != "ERROR")) {
- execution.setVariable("poLcpCloudRegionId", poCloudRegion)
- logger.debug("AIC Cloud Region for PO: " + poCloudRegion)
- } else {
- String errorMessage = "AAI Query Cloud Region Unsuccessful. Return Code: " + execution.getVariable(prefix+"queryCloudRegionReturnCode")
- logger.debug(errorMessage)
- (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, errorMessage)
- }
-
- def rollbackData = execution.getVariable("rollbackData")
- rollbackData.put("DCVFMODULEVOL", "aiccloudregion", cloudRegion)
- }
-
-
- /**
- * Query AAI volume group by name
- * @param execution
- * @param isDebugEnabled
- */
- public void callRESTQueryAAIVolGrpName(DelegateExecution execution, isDebugEnabled) {
-
- def volumeGroupName = execution.getVariable('volumeGroupName')
- def cloudRegion = execution.getVariable('lcpCloudRegionId')
-
- try {
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion).queryParam("volume-group-name", volumeGroupName)
- Optional<VolumeGroups> volumeGroups = getAAIClient().get(VolumeGroups.class,uri)
- if(volumeGroups.isPresent()){
- VolumeGroup volumeGroup = volumeGroups.get().getVolumeGroup().get(0);
- execution.setVariable(prefix+'AaiReturnCode', 200)
- execution.setVariable("queriedVolumeGroupId",volumeGroup.getVolumeGroupId())
- logger.debug("Volume Group Name $volumeGroupName exists in AAI.")
- }else{
- execution.setVariable(prefix+'AaiReturnCode', 404)
- exceptionUtil.buildAndThrowWorkflowException(execution,25000, "Volume Group Name $volumeGroupName does not exist in AAI.")
- }
- }catch(BpmnError error){
- throw error
- }catch(Exception e){
- execution.setVariable(prefix+'AaiReturnCode', 500)
- exceptionUtil.buildAndThrowWorkflowException(execution,25000, "Exception in get volume group by name: " + e.getMessage())
- }
- }
-
-
- /**
- * Create a WorkflowException
- * @param execution
- * @param isDebugEnabled
- */
- public void buildWorkflowException(DelegateExecution execution, int errorCode, errorMessage) {
- logger.debug(errorMessage)
- (new ExceptionUtil()).buildWorkflowException(execution, 2500, errorMessage)
- }
-
-
- /**
- * Create a WorkflowException
- * @param execution
- * @param isDebugEnabled
- */
- public void handleError(DelegateExecution execution, isDebugEnabled) {
- WorkflowException we = execution.getVariable('WorkflowException')
- if (we == null) {
- (new ExceptionUtil()).buildWorkflowException(execution, 2500, "Enexpected error encountered!")
- }
- throw new BpmnError("MSOWorkflowException")
- }
-
-
- /**
- * Create volume group in AAI
- * @param execution
- * @param isDebugEnabled
- */
- public void callRESTCreateAAIVolGrpName(DelegateExecution execution, isDebugEnabled) {
-
- def vnfId = execution.getVariable('vnfId')
- def volumeGroupId = execution.getVariable('volumeGroupId')
- def volumeName = execution.getVariable("volumeGroupName")
- def modelCustomizationId = execution.getVariable("modelCustomizationId")
- def vnfType = execution.getVariable("vnfType")
- def tenantId = execution.getVariable("tenantId")
- def cloudRegion = execution.getVariable('lcpCloudRegionId')
- def cloudOwner = execution.getVariable('cloudOwner')
-
- def testGroupId = execution.getVariable('test-volume-group-id')
- if (testGroupId != null && testGroupId.trim() != '') {
- logger.debug("test volumeGroupId is present: " + testGroupId)
- volumeGroupId = testGroupId
- execution.setVariable("test-volume-group-name", "MSOTESTVOL101a-vSAMP12_base_vol_module-0")
- }
-
- VolumeGroup volumeGroup = new VolumeGroup()
- volumeGroup.setVolumeGroupId(volumeGroupId)
- volumeGroup.setVolumeGroupName(volumeName)
- volumeGroup.setVnfType(vnfType)
- volumeGroup.setOrchestrationStatus(OrchestrationStatus.PENDING.toString())
- volumeGroup.setModelCustomizationId(modelCustomizationId)
-
- logger.debug("volumeGroupId to be used: " + volumeGroupId)
-
- AAIResourceUri volumeGroupUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, cloudOwner, cloudRegion, volumeGroupId)
- AAIResourceUri tenantUri = AAIUriFactory.createResourceUri(AAIObjectType.TENANT, cloudOwner, cloudRegion, tenantId)
- AAIResourceUri vnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
- try {
- getAAIClient().create(volumeGroupUri, volumeGroup)
- getAAIClient().connect(volumeGroupUri, vnfUri)
- getAAIClient().connect(volumeGroupUri, tenantUri)
- execution.setVariable("queriedVolumeGroupId", volumeGroupId)
- RollbackData rollbackData = execution.getVariable("rollbackData")
- rollbackData.put("DCVFMODULEVOL", "isAAIRollbackNeeded", "true")
- } catch (NotFoundException ignored) {
- execution.setVariable(prefix + "isErrorMessageException", true)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Unable to create volume group in AAI. Response code: 404")
- } catch (Exception ex) {
- execution.setVariable(prefix + "isErrorMessageException", true)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, ex.getMessage())
- }
- }
-
- /**
- * Prepare VNF adapter create request XML
- * @param execution
- */
- public void prepareVnfAdapterCreateRequest(DelegateExecution execution, isDebugEnabled) {
-
- GenericVnf aaiGenericVnfResponse = execution.getVariable(prefix+'AAIQueryGenericVfnResponse')
- def vnfId = aaiGenericVnfResponse.getVnfId()
- def vnfName = aaiGenericVnfResponse.getVnfName()
- def vnfType = aaiGenericVnfResponse.getVnfType()
-
- def requestId = execution.getVariable('msoRequestId')
- def serviceId = execution.getVariable('serviceInstanceId')
- def cloudSiteId = execution.getVariable('poLcpCloudRegionId')
- def tenantId = execution.getVariable('tenantId')
- def volumeGroupId = execution.getVariable('volumeGroupId')
- def volumeGroupnName = execution.getVariable('volumeGroupName')
-
- def vnfVersion = execution.getVariable("asdcServiceModelVersion")
- def vnfModuleType = execution.getVariable("modelName")
-
- def modelCustomizationId = execution.getVariable("modelCustomizationId")
-
- // for testing
- logger.debug("volumeGroupId: " + volumeGroupId)
- def testGroupId = execution.getVariable('test-volume-group-id')
- if (testGroupId != null && testGroupId.trim() != '') {
- logger.debug("test volumeGroupId is present: " + testGroupId)
- volumeGroupId = testGroupId
- execution.setVariable("test-volume-group-name", "MSOTESTVOL101a-vSAMP12_base_vol_module-0")
- }
- logger.debug("volumeGroupId to be used: " + volumeGroupId)
-
- // volume group parameters
-
- String volumeGroupParams = ''
- StringBuilder sbParams = new StringBuilder()
- Map<String, String> paramsMap = execution.getVariable("vfModuleInputParams")
- for (Map.Entry<String, String> entry : paramsMap.entrySet()) {
- String paramsXml
- String paramName = entry.getKey()
- String paramValue = entry.getValue()
- paramsXml =
- """ <entry>
+ execution.setVariable("prefix",prefix)
+ execution.setVariable(prefix+'SuccessIndicator', false)
+ execution.setVariable(prefix+'isPONR', false)
+
+ displayInput(execution, isDebugLogEnabled)
+ setRollbackData(execution, isDebugLogEnabled)
+ setRollbackEnabled(execution, isDebugLogEnabled)
+
+
+ def tenantId = execution.getVariable("tenantId")
+ if (tenantId == null) {
+ String cloudConfiguration = execution.getVariable("cloudConfiguration")
+ tenantId = jsonUtil.getJsonValue(cloudConfiguration, "cloudConfiguration.tenantId")
+ execution.setVariable("tenantId", tenantId)
+ }
+
+ def cloudSiteId = execution.getVariable("lcpCloudRegionId")
+ if (cloudSiteId == null) {
+ String cloudConfiguration = execution.getVariable("cloudConfiguration")
+ cloudSiteId = jsonUtil.getJsonValue(cloudConfiguration, "cloudConfiguration.lcpCloudRegionId")
+ def cloudOwner = jsonUtil.getJsonValue(cloudConfiguration, "cloudConfiguration.cloudOwner")
+ execution.setVariable("lcpCloudRegionId", cloudSiteId)
+ execution.setVariable("cloudOwner", cloudOwner)
+ }
+
+ // Extract attributes from modelInfo
+ String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo")
+
+ //modelCustomizationUuid
+ def modelCustomizationUuid = jsonUtil.getJsonValue(vfModuleModelInfo, "modelCustomizationUuid")
+ execution.setVariable("modelCustomizationId", modelCustomizationUuid)
+ logger.debug("modelCustomizationId: " + modelCustomizationUuid)
+
+ //modelName
+ def modelName = jsonUtil.getJsonValue(vfModuleModelInfo, "modelName")
+ execution.setVariable("modelName", modelName)
+ logger.debug("modelName: " + modelName)
+
+ // The following is used on the get Generic Service Instance call
+ execution.setVariable('GENGS_type', 'service-instance')
+ }
+
+
+ /**
+ * Display input variables
+ * @param execution
+ * @param isDebugLogEnabled
+ */
+ public void displayInput(DelegateExecution execution, isDebugLogEnabled) {
+ def input = ['mso-request-id', 'msoRequestId', 'isDebugLogEnabled', 'disableRollback', 'failIfExists', 'serviceInstanceId', 'vnfId', 'vnfName', 'tenantId', 'volumeGroupId', 'volumeGroupName', 'lcpCloudRegionId', 'vnfType', 'vfModuleModelInfo', 'asdcServiceModelVersion', 'test-volume-group-name', 'test-volume-group-id', 'vfModuleInputParams']
+
+ logger.debug('Begin input: ')
+ input.each {
+ logger.debug(it + ': ' + execution.getVariable(it))
+ }
+ logger.debug('End input.')
+ }
+
+
+ /**
+ * Define and set rollbackdata object
+ * @param execution
+ * @param isDebugEnabled
+ */
+ public void setRollbackData(DelegateExecution execution, isDebugEnabled) {
+ def rollbackData = execution.getVariable("rollbackData")
+ if (rollbackData == null) {
+ rollbackData = new RollbackData()
+ }
+ def volumeGroupName = execution.getVariable('volumeGroupName')
+ rollbackData.put("DCVFMODULEVOL", "volumeGroupName", volumeGroupName)
+ execution.setVariable("rollbackData", rollbackData)
+ }
+
+
+ /**
+ * Gets the service instance uri from aai
+ */
+ public void getServiceInstance(DelegateExecution execution) {
+ try {
+ String serviceInstanceId = execution.getVariable('serviceInstanceId')
+
+ AAIResourcesClient resourceClient = new AAIResourcesClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId)
+
+ if(!resourceClient.exists(uri)){
+ (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai")
+ }
+ }catch(BpmnError e) {
+ throw e
+ }catch (Exception ex){
+ String msg = "Exception in getServiceInstance. " + ex.getMessage()
+ logger.debug(msg)
+ (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, msg)
+ }
+ }
+
+ /**
+ * Get cloud region
+ * @param execution
+ * @param isDebugEnabled
+ */
+ public void callRESTQueryAAICloudRegion (DelegateExecution execution, isDebugEnabled) {
+
+ def cloudRegion = execution.getVariable("lcpCloudRegionId")
+ logger.debug('Request cloud region is: ' + cloudRegion)
+
+ AaiUtil aaiUtil = new AaiUtil(this)
+
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion)
+ def queryCloudRegionRequest = aaiUtil.createAaiUri(uri)
+
+ cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion)
+
+ def aaiCloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "AAI", cloudRegion)
+ if ((aaiCloudRegion != "ERROR")) {
+ execution.setVariable("lcpCloudRegionId", aaiCloudRegion)
+ logger.debug("AIC Cloud Region for AAI: " + aaiCloudRegion)
+ } else {
+ String errorMessage = "AAI Query Cloud Region Unsuccessful. Return Code: " + execution.getVariable(prefix+"queryCloudRegionReturnCode")
+ logger.debug(errorMessage)
+ (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, errorMessage)
+ }
+
+ def poCloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion)
+ if ((poCloudRegion != "ERROR")) {
+ execution.setVariable("poLcpCloudRegionId", poCloudRegion)
+ logger.debug("AIC Cloud Region for PO: " + poCloudRegion)
+ } else {
+ String errorMessage = "AAI Query Cloud Region Unsuccessful. Return Code: " + execution.getVariable(prefix+"queryCloudRegionReturnCode")
+ logger.debug(errorMessage)
+ (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, errorMessage)
+ }
+
+ def rollbackData = execution.getVariable("rollbackData")
+ rollbackData.put("DCVFMODULEVOL", "aiccloudregion", cloudRegion)
+ }
+
+
+ /**
+ * Query AAI volume group by name
+ * @param execution
+ * @param isDebugEnabled
+ */
+ public void callRESTQueryAAIVolGrpName(DelegateExecution execution, isDebugEnabled) {
+
+ def volumeGroupName = execution.getVariable('volumeGroupName')
+ def cloudRegion = execution.getVariable('lcpCloudRegionId')
+
+ try {
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion).queryParam("volume-group-name", volumeGroupName)
+ Optional<VolumeGroups> volumeGroups = getAAIClient().get(VolumeGroups.class,uri)
+ if(volumeGroups.isPresent()){
+ VolumeGroup volumeGroup = volumeGroups.get().getVolumeGroup().get(0);
+ execution.setVariable(prefix+'AaiReturnCode', 200)
+ execution.setVariable("queriedVolumeGroupId",volumeGroup.getVolumeGroupId())
+ logger.debug("Volume Group Name $volumeGroupName exists in AAI.")
+ }else{
+ execution.setVariable(prefix+'AaiReturnCode', 404)
+ exceptionUtil.buildAndThrowWorkflowException(execution,25000, "Volume Group Name $volumeGroupName does not exist in AAI.")
+ }
+ }catch(BpmnError error){
+ throw error
+ }catch(Exception e){
+ execution.setVariable(prefix+'AaiReturnCode', 500)
+ exceptionUtil.buildAndThrowWorkflowException(execution,25000, "Exception in get volume group by name: " + e.getMessage())
+ }
+ }
+
+
+ /**
+ * Create a WorkflowException
+ * @param execution
+ * @param isDebugEnabled
+ */
+ public void buildWorkflowException(DelegateExecution execution, int errorCode, errorMessage) {
+ logger.debug(errorMessage)
+ (new ExceptionUtil()).buildWorkflowException(execution, 2500, errorMessage)
+ }
+
+
+ /**
+ * Create a WorkflowException
+ * @param execution
+ * @param isDebugEnabled
+ */
+ public void handleError(DelegateExecution execution, isDebugEnabled) {
+ WorkflowException we = execution.getVariable('WorkflowException')
+ if (we == null) {
+ (new ExceptionUtil()).buildWorkflowException(execution, 2500, "Enexpected error encountered!")
+ }
+ throw new BpmnError("MSOWorkflowException")
+ }
+
+
+ /**
+ * Create volume group in AAI
+ * @param execution
+ * @param isDebugEnabled
+ */
+ public void callRESTCreateAAIVolGrpName(DelegateExecution execution, isDebugEnabled) {
+
+ def vnfId = execution.getVariable('vnfId')
+ def volumeGroupId = execution.getVariable('volumeGroupId')
+ def volumeName = execution.getVariable("volumeGroupName")
+ def modelCustomizationId = execution.getVariable("modelCustomizationId")
+ def vnfType = execution.getVariable("vnfType")
+ def tenantId = execution.getVariable("tenantId")
+ def cloudRegion = execution.getVariable('lcpCloudRegionId')
+ def cloudOwner = execution.getVariable('cloudOwner')
+
+ def testGroupId = execution.getVariable('test-volume-group-id')
+ if (testGroupId != null && testGroupId.trim() != '') {
+ logger.debug("test volumeGroupId is present: " + testGroupId)
+ volumeGroupId = testGroupId
+ execution.setVariable("test-volume-group-name", "MSOTESTVOL101a-vSAMP12_base_vol_module-0")
+ }
+
+ VolumeGroup volumeGroup = new VolumeGroup()
+ volumeGroup.setVolumeGroupId(volumeGroupId)
+ volumeGroup.setVolumeGroupName(volumeName)
+ volumeGroup.setVnfType(vnfType)
+ volumeGroup.setOrchestrationStatus(OrchestrationStatus.PENDING.toString())
+ volumeGroup.setModelCustomizationId(modelCustomizationId)
+
+ logger.debug("volumeGroupId to be used: " + volumeGroupId)
+
+ AAIResourceUri volumeGroupUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, cloudOwner, cloudRegion, volumeGroupId)
+ AAIResourceUri tenantUri = AAIUriFactory.createResourceUri(AAIObjectType.TENANT, cloudOwner, cloudRegion, tenantId)
+ AAIResourceUri vnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
+ try {
+ getAAIClient().create(volumeGroupUri, volumeGroup)
+ getAAIClient().connect(volumeGroupUri, vnfUri)
+ getAAIClient().connect(volumeGroupUri, tenantUri)
+ execution.setVariable("queriedVolumeGroupId", volumeGroupId)
+ RollbackData rollbackData = execution.getVariable("rollbackData")
+ rollbackData.put("DCVFMODULEVOL", "isAAIRollbackNeeded", "true")
+ } catch (NotFoundException ignored) {
+ execution.setVariable(prefix + "isErrorMessageException", true)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Unable to create volume group in AAI. Response code: 404")
+ } catch (Exception ex) {
+ execution.setVariable(prefix + "isErrorMessageException", true)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, ex.getMessage())
+ }
+ }
+
+ /**
+ * Prepare VNF adapter create request XML
+ * @param execution
+ */
+ public void prepareVnfAdapterCreateRequest(DelegateExecution execution, isDebugEnabled) {
+
+ GenericVnf aaiGenericVnfResponse = execution.getVariable(prefix+'AAIQueryGenericVfnResponse')
+ def vnfId = aaiGenericVnfResponse.getVnfId()
+ def vnfName = aaiGenericVnfResponse.getVnfName()
+ def vnfType = aaiGenericVnfResponse.getVnfType()
+
+ def requestId = execution.getVariable('msoRequestId')
+ def serviceId = execution.getVariable('serviceInstanceId')
+ def cloudSiteId = execution.getVariable('poLcpCloudRegionId')
+ def tenantId = execution.getVariable('tenantId')
+ def volumeGroupId = execution.getVariable('volumeGroupId')
+ def volumeGroupnName = execution.getVariable('volumeGroupName')
+
+ def vnfVersion = execution.getVariable("asdcServiceModelVersion")
+ def vnfModuleType = execution.getVariable("modelName")
+
+ def modelCustomizationId = execution.getVariable("modelCustomizationId")
+
+ // for testing
+ logger.debug("volumeGroupId: " + volumeGroupId)
+ def testGroupId = execution.getVariable('test-volume-group-id')
+ if (testGroupId != null && testGroupId.trim() != '') {
+ logger.debug("test volumeGroupId is present: " + testGroupId)
+ volumeGroupId = testGroupId
+ execution.setVariable("test-volume-group-name", "MSOTESTVOL101a-vSAMP12_base_vol_module-0")
+ }
+ logger.debug("volumeGroupId to be used: " + volumeGroupId)
+
+ // volume group parameters
+
+ String volumeGroupParams = ''
+ StringBuilder sbParams = new StringBuilder()
+ Map<String, String> paramsMap = execution.getVariable("vfModuleInputParams")
+ for (Map.Entry<String, String> entry : paramsMap.entrySet()) {
+ String paramsXml
+ String paramName = entry.getKey()
+ String paramValue = entry.getValue()
+ paramsXml =
+ """ <entry>
<key>${MsoUtils.xmlEscape(paramName)}</key>
<value>${MsoUtils.xmlEscape(paramValue)}</value>
</entry>
"""
- sbParams.append(paramsXml)
- }
+ sbParams.append(paramsXml)
+ }
- volumeGroupParams = sbParams.toString()
- logger.debug("volumeGroupParams: "+ volumeGroupParams)
+ volumeGroupParams = sbParams.toString()
+ logger.debug("volumeGroupParams: "+ volumeGroupParams)
- def backoutOnFailure = execution.getVariable(prefix+"backoutOnFailure")
- logger.debug("backoutOnFailure: "+ backoutOnFailure)
+ def backoutOnFailure = execution.getVariable(prefix+"backoutOnFailure")
+ logger.debug("backoutOnFailure: "+ backoutOnFailure)
- def failIfExists = execution.getVariable("failIfExists")
- if(failIfExists == null) {
- failIfExists = 'true'
- }
+ def failIfExists = execution.getVariable("failIfExists")
+ if(failIfExists == null) {
+ failIfExists = 'true'
+ }
- String messageId = UUID.randomUUID()
- logger.debug("messageId to be used is generated: " + messageId)
+ String messageId = UUID.randomUUID()
+ logger.debug("messageId to be used is generated: " + messageId)
- def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId)
- def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution)
- if ('true'.equals(useQualifiedHostName)) {
- notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl)
- }
- logger.debug("CreateVfModuleVolume - notificationUrl: "+ notificationUrl)
+ def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId)
+ def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution)
+ if ('true'.equals(useQualifiedHostName)) {
+ notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl)
+ }
+ logger.debug("CreateVfModuleVolume - notificationUrl: "+ notificationUrl)
- // build request
- String vnfSubCreateWorkflowRequest =
- """
+ // build request
+ String vnfSubCreateWorkflowRequest =
+ """
<createVolumeGroupRequest>
<cloudSiteId>${MsoUtils.xmlEscape(cloudSiteId)}</cloudSiteId>
<tenantId>${MsoUtils.xmlEscape(tenantId)}</tenantId>
@@ -432,23 +428,23 @@ class DoCreateVfModuleVolumeV2 extends VfModuleBase {
</createVolumeGroupRequest>
"""
- String vnfSubCreateWorkflowRequestAsString = utils.formatXml(vnfSubCreateWorkflowRequest)
- logger.debug(vnfSubCreateWorkflowRequestAsString)
- logger.debug(vnfSubCreateWorkflowRequestAsString)
- execution.setVariable(prefix+"createVnfARequest", vnfSubCreateWorkflowRequestAsString)
+ String vnfSubCreateWorkflowRequestAsString = utils.formatXml(vnfSubCreateWorkflowRequest)
+ logger.debug(vnfSubCreateWorkflowRequestAsString)
+ logger.debug(vnfSubCreateWorkflowRequestAsString)
+ execution.setVariable(prefix+"createVnfARequest", vnfSubCreateWorkflowRequestAsString)
- // build rollback request for use later if needed
- String vnfSubRollbackWorkflowRequest = buildRollbackVolumeGroupRequestXml(volumeGroupId, cloudSiteId, tenantId, requestId, serviceId, messageId, notificationUrl)
+ // build rollback request for use later if needed
+ String vnfSubRollbackWorkflowRequest = buildRollbackVolumeGroupRequestXml(volumeGroupId, cloudSiteId, tenantId, requestId, serviceId, messageId, notificationUrl)
- logger.debug("Sub Vnf flow rollback request: vnfSubRollbackWorkflowRequest " + "\n" + vnfSubRollbackWorkflowRequest)
+ logger.debug("Sub Vnf flow rollback request: vnfSubRollbackWorkflowRequest " + "\n" + vnfSubRollbackWorkflowRequest)
- String vnfSubRollbackWorkflowRequestAsString = utils.formatXml(vnfSubRollbackWorkflowRequest)
- execution.setVariable(prefix+"rollbackVnfARequest", vnfSubRollbackWorkflowRequestAsString)
- }
+ String vnfSubRollbackWorkflowRequestAsString = utils.formatXml(vnfSubRollbackWorkflowRequest)
+ execution.setVariable(prefix+"rollbackVnfARequest", vnfSubRollbackWorkflowRequestAsString)
+ }
- public String buildRollbackVolumeGroupRequestXml(volumeGroupId, cloudSiteId, tenantId, requestId, serviceId, messageId, notificationUrl) {
+ public String buildRollbackVolumeGroupRequestXml(volumeGroupId, cloudSiteId, tenantId, requestId, serviceId, messageId, notificationUrl) {
- String request = """
+ String request = """
<rollbackVolumeGroupRequest>
<volumeGroupRollback>
<volumeGroupId>${MsoUtils.xmlEscape(volumeGroupId)}</volumeGroupId>
@@ -467,88 +463,88 @@ class DoCreateVfModuleVolumeV2 extends VfModuleBase {
</rollbackVolumeGroupRequest>
"""
- return request
- }
-
- public String updateRollbackVolumeGroupRequestXml(String rollabackRequest, String heatStackId) {
- String newRequest = rollabackRequest.replace("{{VOLUMEGROUPSTACKID}}", heatStackId)
- return newRequest
- }
-
- /**
- * Validate VNF adapter response
- * @param execution
- */
- public void validateVnfResponse(DelegateExecution execution, isDebugEnabled) {
- def vnfSuccess = execution.getVariable('VNFREST_SuccessIndicator')
- logger.debug("vnfAdapterSuccessIndicator: "+ vnfSuccess)
- if(vnfSuccess==true) {
- String createVnfAResponse = execution.getVariable(prefix+"createVnfAResponse")
- String heatStackID = utils.getNodeText(createVnfAResponse, "volumeGroupStackId")
- String vnfRollbackRequest = execution.getVariable(prefix+"rollbackVnfARequest")
- String updatedVnfRollbackRequest = updateRollbackVolumeGroupRequestXml(vnfRollbackRequest, heatStackID)
- logger.debug("vnfAdapter rollback request: "+ updatedVnfRollbackRequest)
- RollbackData rollbackData = execution.getVariable("rollbackData")
- rollbackData.put("DCVFMODULEVOL", "rollbackVnfARequest", updatedVnfRollbackRequest)
- rollbackData.put("DCVFMODULEVOL", "isCreateVnfRollbackNeeded", "true")
- }
- }
-
-
- /**
- * Update voulume group in AAI
- * @TODO: Can we re-use the create method??
- * @param execution
- * @param isDebugEnabled
- */
- public void callRESTUpdateCreatedVolGrpName(DelegateExecution execution, isDebugEnabled) {
- String volumeGroupId = execution.getVariable("queriedVolumeGroupId")
- String modelCustomizationId = execution.getVariable("modelCustomizationId")
- String cloudRegion = execution.getVariable("lcpCloudRegionId")
- String cloudOwner = execution.getVariable('cloudOwner')
- String createVnfAResponse = execution.getVariable(prefix+"createVnfAResponse")
- def heatStackID = utils.getNodeText(createVnfAResponse, "volumeGroupStackId")
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, cloudOwner, cloudRegion, volumeGroupId)
-
- execution.setVariable(prefix+"heatStackId", heatStackID)
-
- VolumeGroup volumeGroup = new VolumeGroup()
- volumeGroup.setHeatStackId(heatStackID)
- volumeGroup.setModelCustomizationId(modelCustomizationId)
- try {
- getAAIClient().update(uri, volumeGroup)
- execution.setVariable(prefix+"isPONR", true)
- }catch(NotFoundException ignored){
- execution.setVariable(prefix+"isErrorMessageException", true)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Unable to update volume group in AAI. Response code: 404")
- }catch(BpmnError error){
- throw error
- }catch(Exception e){
- execution.setVariable(prefix+"isErrorMessageException", true)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "AAI Adapter Query Failed. "+ e.getMessage())
- }
- }
-
-
- /**
- * Query AAI Generic VNF
- * @param execution
- * @param isDebugEnabled
- */
- public void callRESTQueryAAIGenericVnf(DelegateExecution execution, isDebugEnabled) {
-
- def vnfId = execution.getVariable('vnfId')
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
- try {
- Optional<GenericVnf> genericVnf = getAAIClient().get(GenericVnf.class, uri)
- if (genericVnf.isPresent()) {
- execution.setVariable(prefix + 'AAIQueryGenericVfnResponse', genericVnf.get())
- } else {
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, 'Generic vnf ' + vnfId + ' was not found in AAI. Return code: 404.')
- }
- }catch(Exception e){
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Exception in get generic VNF: " + e.getMessage())
- }
- }
+ return request
+ }
+
+ public String updateRollbackVolumeGroupRequestXml(String rollabackRequest, String heatStackId) {
+ String newRequest = rollabackRequest.replace("{{VOLUMEGROUPSTACKID}}", heatStackId)
+ return newRequest
+ }
+
+ /**
+ * Validate VNF adapter response
+ * @param execution
+ */
+ public void validateVnfResponse(DelegateExecution execution, isDebugEnabled) {
+ def vnfSuccess = execution.getVariable('VNFREST_SuccessIndicator')
+ logger.debug("vnfAdapterSuccessIndicator: "+ vnfSuccess)
+ if(vnfSuccess==true) {
+ String createVnfAResponse = execution.getVariable(prefix+"createVnfAResponse")
+ String heatStackID = utils.getNodeText(createVnfAResponse, "volumeGroupStackId")
+ String vnfRollbackRequest = execution.getVariable(prefix+"rollbackVnfARequest")
+ String updatedVnfRollbackRequest = updateRollbackVolumeGroupRequestXml(vnfRollbackRequest, heatStackID)
+ logger.debug("vnfAdapter rollback request: "+ updatedVnfRollbackRequest)
+ RollbackData rollbackData = execution.getVariable("rollbackData")
+ rollbackData.put("DCVFMODULEVOL", "rollbackVnfARequest", updatedVnfRollbackRequest)
+ rollbackData.put("DCVFMODULEVOL", "isCreateVnfRollbackNeeded", "true")
+ }
+ }
+
+
+ /**
+ * Update voulume group in AAI
+ * @TODO: Can we re-use the create method??
+ * @param execution
+ * @param isDebugEnabled
+ */
+ public void callRESTUpdateCreatedVolGrpName(DelegateExecution execution, isDebugEnabled) {
+ String volumeGroupId = execution.getVariable("queriedVolumeGroupId")
+ String modelCustomizationId = execution.getVariable("modelCustomizationId")
+ String cloudRegion = execution.getVariable("lcpCloudRegionId")
+ String cloudOwner = execution.getVariable('cloudOwner')
+ String createVnfAResponse = execution.getVariable(prefix+"createVnfAResponse")
+ def heatStackID = utils.getNodeText(createVnfAResponse, "volumeGroupStackId")
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, cloudOwner, cloudRegion, volumeGroupId)
+
+ execution.setVariable(prefix+"heatStackId", heatStackID)
+
+ VolumeGroup volumeGroup = new VolumeGroup()
+ volumeGroup.setHeatStackId(heatStackID)
+ volumeGroup.setModelCustomizationId(modelCustomizationId)
+ try {
+ getAAIClient().update(uri, volumeGroup)
+ execution.setVariable(prefix+"isPONR", true)
+ }catch(NotFoundException ignored){
+ execution.setVariable(prefix+"isErrorMessageException", true)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Unable to update volume group in AAI. Response code: 404")
+ }catch(BpmnError error){
+ throw error
+ }catch(Exception e){
+ execution.setVariable(prefix+"isErrorMessageException", true)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "AAI Adapter Query Failed. "+ e.getMessage())
+ }
+ }
+
+
+ /**
+ * Query AAI Generic VNF
+ * @param execution
+ * @param isDebugEnabled
+ */
+ public void callRESTQueryAAIGenericVnf(DelegateExecution execution, isDebugEnabled) {
+
+ def vnfId = execution.getVariable('vnfId')
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
+ try {
+ Optional<GenericVnf> genericVnf = getAAIClient().get(GenericVnf.class, uri)
+ if (genericVnf.isPresent()) {
+ execution.setVariable(prefix + 'AAIQueryGenericVfnResponse', genericVnf.get())
+ } else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, 'Generic vnf ' + vnfId + ' was not found in AAI. Return code: 404.')
+ }
+ }catch(Exception e){
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Exception in get generic VNF: " + e.getMessage())
+ }
+ }
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy
index e9b748b14b..823217c4f7 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy
@@ -24,7 +24,7 @@ package org.onap.so.bpmn.infrastructure.scripts
import org.onap.so.logger.LoggingAnchor
import org.onap.so.db.catalog.beans.HomingInstance
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import static org.apache.commons.lang3.StringUtils.*
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy
index 180032c8f0..e60fab5766 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy
@@ -41,7 +41,7 @@ import org.onap.so.bpmn.core.json.JsonUtils
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.onap.so.bpmn.infrastructure.aai.groovyflows.AAICreateResources
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.onap.so.logger.MessageEnum
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy
index a6cb5cf4cc..150f55316c 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy
@@ -23,7 +23,7 @@
package org.onap.so.bpmn.infrastructure.scripts
import org.onap.so.logger.LoggingAnchor
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy
index a88becad1a..72f71686d9 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy
@@ -23,7 +23,7 @@
package org.onap.so.bpmn.infrastructure.scripts
import org.onap.so.logger.LoggingAnchor
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import static org.apache.commons.lang3.StringUtils.*
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy
index 48e4fdf2ff..bc535a348f 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy
@@ -24,7 +24,7 @@ package org.onap.so.bpmn.infrastructure.scripts
import org.onap.so.logger.LoggingAnchor
import org.onap.aai.domain.yang.AllottedResource
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import javax.ws.rs.core.UriBuilder
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy
new file mode 100644
index 0000000000..8d8e97328d
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy
@@ -0,0 +1,308 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2019, CMCC Technologies Co., Ltd.
+ #
+ # 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 com.fasterxml.jackson.databind.ObjectMapper
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.logging.filter.base.ONAPComponents
+import org.onap.so.beans.nsmf.DeAllocateNssi
+import org.onap.so.beans.nsmf.EsrInfo
+import org.onap.so.beans.nsmf.JobStatusRequest
+import org.onap.so.beans.nsmf.JobStatusResponse
+import org.onap.so.beans.nsmf.NetworkType
+import org.onap.so.beans.nsmf.NssiDeAllocateRequest
+import org.onap.so.beans.nsmf.NssiResponse
+import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.onap.so.bpmn.common.scripts.ExceptionUtil
+import org.onap.so.bpmn.common.scripts.RequestDBUtil
+import org.onap.so.bpmn.core.UrnPropertiesReader
+import org.onap.so.bpmn.core.domain.ServiceArtifact
+import org.onap.so.bpmn.core.domain.ServiceDecomposition
+import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.client.HttpClient
+import org.onap.so.client.HttpClientFactory
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.AAIResourcesClient
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+import org.onap.so.db.request.beans.OperationStatus
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+
+import javax.ws.rs.core.Response
+
+
+class DoDeallocateNSSI extends AbstractServiceTaskProcessor
+{
+ private final String PREFIX ="DoDeallocateNSSI"
+
+ private ExceptionUtil exceptionUtil = new ExceptionUtil()
+ private JsonUtils jsonUtil = new JsonUtils()
+ private RequestDBUtil requestDBUtil = new RequestDBUtil()
+ private static final Logger LOGGER = LoggerFactory.getLogger( DoDeallocateNSSI.class)
+
+ @Override
+ void preProcessRequest(DelegateExecution execution) {
+ LOGGER.trace(" ***** ${PREFIX} Start preProcessRequest *****")
+
+ def currentNSSI = execution.getVariable("currentNSSI")
+ if (!currentNSSI) {
+ String msg = "currentNSSI is null"
+ LOGGER.error(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ }
+
+ LOGGER.trace("***** ${PREFIX} Exit preProcessRequest *****")
+ }
+
+ /**
+ *
+ * @param execution
+ */
+ void prepareDecomposeService(DelegateExecution execution)
+ {
+ LOGGER.trace(" *****${PREFIX} Start prepareDecomposeService *****")
+ try
+ {
+ def currentNSSI = execution.getVariable("currentNSSI")
+ String modelInvariantUuid = currentNSSI['modelInvariantId']
+ String modelVersionId = currentNSSI['modelVersionId']
+ String serviceModelInfo = """{
+ "modelInvariantUuid":"${modelInvariantUuid}",
+ "modelUuid":"${modelVersionId}",
+ "modelVersion":""
+ }"""
+ execution.setVariable("serviceModelInfo", serviceModelInfo)
+ }
+ catch (any)
+ {
+ String exceptionMessage = "Bpmn error encountered in deallocate nssi. Unexpected Error from method prepareDecomposeService() - " + any.getMessage()
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
+ }
+ LOGGER.debug(" ***** ${PREFIX} Exit prepareDecomposeService *****")
+ }
+
+ /**
+ * get vendor Info
+ * @param execution
+ */
+ void processDecomposition(DelegateExecution execution) {
+ LOGGER.debug("*****${PREFIX} start processDecomposition *****")
+
+ try {
+ ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") as ServiceDecomposition
+ ServiceArtifact serviceArtifact = serviceDecomposition ?.getServiceInfo()?.getServiceArtifact()?.get(0)
+ String content = serviceArtifact.getContent()
+ String vendor = jsonUtil.getJsonValue(content, "metadata.vendor")
+ String domainType = jsonUtil.getJsonValue(content, "metadata.domainType")
+
+ def currentNSSI = execution.getVariable("currentNSSI")
+ currentNSSI['vendor'] = vendor
+ currentNSSI['domainType'] = domainType
+ LOGGER.info("processDecomposition, current vendor-domainType:" +String.join("-", vendor, domainType))
+
+ } catch (any) {
+ String exceptionMessage = "Bpmn error encountered in deallocate nssi. processDecomposition() - " + any.getMessage()
+ LOGGER.debug(exceptionMessage)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
+ }
+ LOGGER.debug("*****${PREFIX} Exit processDecomposition *****")
+ }
+
+ /**
+ * send deallocate request to nssmf
+ * @param execution
+ */
+ void sendRequestToNSSMF(DelegateExecution execution)
+ {
+ LOGGER.debug("*****${PREFIX} start sendRequestToNSSMF *****")
+ def currentNSSI = execution.getVariable("currentNSSI")
+ String snssai= currentNSSI['snssai']
+ String profileId = currentNSSI['profileId']
+ String nssiId = currentNSSI['nssiServiceInstanceId']
+ String nsiId = currentNSSI['nsiServiceInstanceId']
+
+ DeAllocateNssi deAllocateNssi = new DeAllocateNssi()
+ deAllocateNssi.setNsiId(nsiId)
+ deAllocateNssi.setNssiId(nssiId)
+ deAllocateNssi.setTerminateNssiOption(0)
+ deAllocateNssi.setSnssaiList(Arrays.asList(snssai))
+
+ NssiDeAllocateRequest deAllocateRequest = new NssiDeAllocateRequest()
+ deAllocateRequest.setDeAllocateNssi(deAllocateNssi)
+ deAllocateRequest.setEsrInfo(getEsrInfo(currentNSSI))
+
+ ObjectMapper mapper = new ObjectMapper()
+ String json = mapper.writeValueAsString(deAllocateRequest)
+
+ //Prepare auth for NSSMF - Begin
+ String nssmfRequest = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution)
+ nssmfRequest = nssmfRequest + String.format("/api/rest/provMns/v1/NSS/SliceProfiles/%s",profileId)
+ //nssmfRequest = nssmfRequest + String.format(NssmfAdapterUtil.NSSMI_DEALLOCATE_URL,profileId)
+ //send request to active NSSI TN option
+ URL url = new URL(nssmfRequest)
+ LOGGER.info("deallocate nssmfRequest:${nssmfRequest}, reqBody: ${json}")
+
+ HttpClient httpClient = getHttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL)
+ Response httpResponse = httpClient.post(json)
+ checkNssmfResponse(httpResponse, execution)
+
+ NssiResponse nssmfResponse = httpResponse.readEntity(NssiResponse.class)
+ currentNSSI['jobId']= nssmfResponse.getJobId() ?: ""
+ currentNSSI['jobProgress'] = 0
+ execution.setVariable("currentNSSI", currentNSSI)
+
+ LOGGER.debug("*****${PREFIX} Exit sendRequestToNSSMF *****")
+ }
+
+ /**
+ * send to nssmf query progress
+ * @param execution
+ */
+ void getJobStatus(DelegateExecution execution)
+ {
+ def currentNSSI = execution.getVariable("currentNSSI")
+ String jobId = currentNSSI['jobId']
+ String nssiId = currentNSSI['nssiServiceInstanceId']
+ String nsiId = currentNSSI['nsiServiceInstanceId']
+
+ JobStatusRequest jobStatusRequest = new JobStatusRequest()
+ jobStatusRequest.setNssiId(nssiId)
+ jobStatusRequest.setNsiId(nsiId)
+ jobStatusRequest.setEsrInfo(getEsrInfo(currentNSSI))
+
+ ObjectMapper mapper = new ObjectMapper()
+ String json = mapper.writeValueAsString(jobStatusRequest)
+
+ //Prepare auth for NSSMF - Begin
+ String nssmfRequest = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution)
+ nssmfRequest = nssmfRequest + String.format("/api/rest/provMns/v1/NSS/jobs/%s",jobId)
+ //send request to active NSSI TN option
+ URL url = new URL(nssmfRequest)
+ LOGGER.info("get deallocate job status, nssmfRequest:${nssmfRequest}, requestBody: ${json}")
+
+ HttpClient httpClient = getHttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL)
+ Response httpResponse = httpClient.post(json)
+ checkNssmfResponse(httpResponse, execution)
+
+ JobStatusResponse jobStatusResponse = httpResponse.readEntity(JobStatusResponse.class)
+ def progress = jobStatusResponse?.getResponseDescriptor()?.getProgress()
+ if(!progress)
+ {
+ LOGGER.error("job progress is null or empty!")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a Bad Job progress from NSSMF.")
+ }
+ int oldProgress = currentNSSI['jobProgress']
+ int currentProgress = progress
+
+ execution.setVariable("isNSSIDeAllocated", (currentProgress == 100))
+ execution.setVariable("isNeedUpdateDB", (oldProgress != currentProgress))
+ currentNSSI['jobProgress'] = currentProgress
+
+ def statusDescription = jobStatusResponse?.getResponseDescriptor()?.getStatusDescription()
+ currentNSSI['statusDescription'] = statusDescription
+
+ LOGGER.debug("job status result: nsiId = ${nsiId}, nssiId=${nssiId}, oldProgress=${oldProgress}, progress = ${currentProgress}" )
+ }
+
+ private void checkNssmfResponse(Response httpResponse, DelegateExecution execution) {
+ int responseCode = httpResponse.getStatus()
+ LOGGER.debug("NSSMF response code is: " + responseCode)
+
+ if ( responseCode < 200 || responseCode > 204 || !httpResponse.hasEntity()) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Response from NSSMF.")
+ }
+ }
+
+
+ private EsrInfo getEsrInfo(def currentNSSI)
+ {
+ String domaintype = currentNSSI['domainType']
+ String vendor = currentNSSI['vendor']
+
+ EsrInfo info = new EsrInfo()
+ info.setNetworkType(NetworkType.fromString(domaintype))
+ info.setVendor(vendor)
+ return info
+ }
+
+ /**
+ * handle job status
+ * prepare update requestdb
+ * @param execution
+ */
+ void handleJobStatus(DelegateExecution execution)
+ {
+ def currentNSSI = execution.getVariable("currentNSSI")
+ int currentProgress = currentNSSI["jobProgress"]
+ def proportion = currentNSSI['proportion']
+ def statusDes = currentNSSI["statusDescription"]
+ int progress = (currentProgress as int) == 0 ? 0 : (currentProgress as int) / 100 * (proportion as int)
+
+ OperationStatus operationStatus = new OperationStatus()
+ operationStatus.setServiceId(currentNSSI['e2eServiceInstanceId'] as String)
+ operationStatus.setOperationId(currentNSSI['operationId'] as String)
+ operationStatus.setOperation("DELETE")
+ operationStatus.setResult("processing")
+ operationStatus.setProgress(progress as String)
+ operationStatus.setOperationContent(statusDes as String)
+ requestDBUtil.prepareUpdateOperationStatus(execution, operationStatus)
+ LOGGER.debug("update operation, currentProgress=${currentProgress}, proportion=${proportion}, progress = ${progress}" )
+ }
+
+ void timeDelay(DelegateExecution execution) {
+ try {
+ Thread.sleep(10000);
+ } catch(InterruptedException e) {
+ LOGGER.error("Time Delay exception" + e)
+ }
+ }
+
+ /**
+ * delete slice profile from aai
+ * @param execution
+ */
+ void delSliceProfileFromAAI(DelegateExecution execution)
+ {
+ LOGGER.debug("*****${PREFIX} start delSliceProfileFromAAI *****")
+ def currentNSSI = execution.getVariable("currentNSSI")
+ String nssiServiceInstanceId = currentNSSI['nssiServiceInstanceId']
+ String profileId = currentNSSI['profileId']
+ String globalSubscriberId = currentNSSI["globalSubscriberId"]
+ String serviceType = currentNSSI["serviceType"]
+
+ try
+ {
+ LOGGER.debug("delete nssiServiceInstanceId:${nssiServiceInstanceId}, profileId:${profileId}")
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, globalSubscriberId, serviceType, nssiServiceInstanceId, profileId)
+ if (!getAAIClient().exists(resourceUri)) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai")
+ }
+ getAAIClient().delete(resourceUri)
+ }
+ catch (any)
+ {
+ String msg = "delete slice profile from aai failed! cause-"+any.getCause()
+ LOGGER.error(any.printStackTrace())
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ LOGGER.debug("*****${PREFIX} Exist delSliceProfileFromAAI *****")
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy
index 09eb7994a8..89c5be8d6e 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy
@@ -45,7 +45,7 @@ import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.client.graphinventory.entities.uri.Depth
import org.onap.so.constants.Defaults
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import org.onap.so.logger.MessageEnum
import org.slf4j.Logger
import org.slf4j.LoggerFactory
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy
new file mode 100644
index 0000000000..76086dab49
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy
@@ -0,0 +1,320 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2019, CMCC Technologies Co., Ltd.
+ #
+ # 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.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.AllottedResource
+import org.onap.aai.domain.yang.AllottedResources
+import org.onap.aai.domain.yang.Relationship
+import org.onap.aai.domain.yang.ServiceInstance
+import org.onap.aai.domain.yang.SliceProfiles
+import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.onap.so.bpmn.common.scripts.ExceptionUtil
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.AAIResultWrapper
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+
+import javax.ws.rs.NotFoundException
+
+import static org.apache.commons.lang3.StringUtils.isBlank
+
+/**
+ * This groovy class supports the <class>DoDeleteSliceService.bpmn</class> process.
+ *
+ * Inputs:
+ * @param - msoRequestId
+ * @param - globalSubscriberId - O
+ * @param - subscriptionServiceType - O
+ * @param - serviceInstanceId
+ *
+ */
+class DoDeleteSliceService extends AbstractServiceTaskProcessor {
+ private final String PREFIX ="DoDeleteSliceService"
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+ private static final Logger LOGGER = LoggerFactory.getLogger( DoDeleteSliceService.class)
+
+ @Override
+ void preProcessRequest(DelegateExecution execution) {
+ LOGGER.debug(" *****${PREFIX} preProcessRequest *****")
+ String msg = ""
+
+ try {
+ //String requestId = execution.getVariable("msoRequestId")
+ execution.setVariable("prefix",PREFIX)
+
+ //Inputs
+ //requestDetails.subscriberInfo. for AAI GET & PUT
+ execution.getVariable("globalSubscriberId") ?: execution.setVariable("globalSubscriberId", "")
+
+ //requestDetails.requestParameters. for AAI PUT
+ execution.getVariable("serviceType") ?: execution.setVariable("serviceType", "")
+
+ //Generated in parent for AAI PUT
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ if (isBlank(serviceInstanceId)){
+ msg = "Input serviceInstanceId is null"
+ LOGGER.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ }
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex){
+ msg = "Exception in preProcessRequest " + ex.getMessage()
+ LOGGER.error(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ LOGGER.debug("*****${PREFIX} Exit preProcessRequest *****")
+ }
+
+ /**
+ * query E2ESliceService from AAI
+ * save snssai
+ * @param execution
+ */
+ void queryE2ESliceSeriveFromAAI(DelegateExecution execution)
+ {
+ LOGGER.trace(" *****${PREFIX} Start queryE2ESliceSeriveFromAAI *****")
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+
+ String errorMsg = "query e2e slice service from aai failed"
+ AAIResultWrapper wrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, serviceInstanceId, errorMsg)
+ Optional<ServiceInstance> si =wrapper.asBean(ServiceInstance.class)
+ if(si.isPresent())
+ {
+ String snssai = si.get()?.getEnvironmentContext()
+ execution.setVariable("snssai", snssai ?: "")
+ LOGGER.info("serviceInstanceId: ${serviceInstanceId}, snssai: ${snssai}")
+ }
+ LOGGER.trace(" *****${PREFIX} Exit queryE2ESliceSeriveFromAAI *****")
+ }
+
+ /**
+ * get allotted resource from AAI
+ * save nsi id
+ * @param execution
+ */
+ void getAllottedResFromAAI(DelegateExecution execution)
+ {
+ LOGGER.trace(" *****${PREFIX} Start getAllottedResFromAAI *****")
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ try
+ {
+ String errorMsg = "query allotted resource from aai failed."
+ AAIResultWrapper wrapper = queryAAI(execution, AAIObjectType.ALLOTTED_RESOURCE_ALL, serviceInstanceId, errorMsg)
+ Optional<AllottedResources> ars = wrapper?.asBean(AllottedResources.class)
+ if(ars.isPresent() && ars.get().getAllottedResource())
+ {
+ List<AllottedResource> allottedResourceList = ars.get().getAllottedResource()
+ AllottedResource ar = allottedResourceList.first()
+ String relatedLink = ar?.getRelationshipList()?.getRelationship()?.first()?.getRelatedLink()
+ String nsiId = relatedLink ? relatedLink.substring(relatedLink.lastIndexOf("/") + 1,relatedLink.length()) : ""
+ execution.setVariable("nsiId", nsiId)
+ LOGGER.info("serviceInstanceId: ${serviceInstanceId}, nsiId:${nsiId}")
+ }
+ }
+ catch(BpmnError e){
+ throw e
+ }
+ catch (Exception ex){
+ String msg = "Exception in getAllottedResFromAAI " + ex.getMessage()
+ LOGGER.error(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ LOGGER.trace(" *****${PREFIX} Exit getAllottedResFromAAI *****")
+ }
+
+ /**
+ * get nsi service instance from aai
+ * save nssi id
+ * @param execution
+ */
+ void getNSIFromAAI(DelegateExecution execution)
+ {
+ LOGGER.trace(" *****${PREFIX} Start getNSIFromAAI *****")
+ String nsiId = execution.getVariable("nsiId")
+ try
+ {
+ String errorMsg = "query nsi from aai failed."
+ AAIResultWrapper wrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, nsiId, errorMsg)
+ Optional<ServiceInstance> si =wrapper.asBean(ServiceInstance.class)
+ List<String> nssiIdList = []
+ String msg = "nsiId:${nsiId},nssiIdList:"
+ if(si.isPresent())
+ {
+ List<Relationship> relationshipList = si.get().getRelationshipList()?.getRelationship()
+ for (Relationship relationship : relationshipList)
+ {
+ String relatedTo = relationship.getRelatedTo()
+ if (relatedTo == "service-instance")
+ {
+ String relatedLink = relationship.getRelatedLink()?:""
+ String nssiId = relatedLink ? relatedLink.substring(relatedLink.lastIndexOf("/") + 1,relatedLink.length()) : ""
+ nssiIdList.add(nssiId)
+ msg+="${nssiId}, "
+ }
+ }
+ }
+ LOGGER.info(msg)
+ execution.setVariable("nssiIdList", nssiIdList)
+ }
+ catch(BpmnError e){
+ throw e
+ }
+ catch (Exception ex){
+ String msg = "Exception in getNSIFromAAI " + ex.getMessage()
+ LOGGER.error(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ LOGGER.trace(" *****${PREFIX} Exit getNSIFromAAI *****")
+ }
+
+ /**
+ * get nssi service from AAI
+ * prepare list
+ * @param execution
+ */
+ void getNSSIListFromAAI(DelegateExecution execution)
+ {
+ LOGGER.trace("*****${PREFIX} Start getNSSIListFromAAI *****")
+ List<String> nssiIdList = execution.getVariable("nssiIdList")
+ List<ServiceInstance> nssiInstanceList = []
+ String errorMsg = "query nssi list from aai failed"
+ for(String nssiId : nssiIdList)
+ {
+ AAIResultWrapper wrapper = queryAAI(execution, AAIObjectType.SERVICE_INSTANCE, nssiId, errorMsg)
+ Optional<ServiceInstance> si =wrapper.asBean(ServiceInstance.class)
+ if(si.isPresent())
+ {
+ nssiInstanceList.add(si.get())
+ }
+ }
+ int size = nssiInstanceList.size()
+ int proportion = size >0 ?((90/size) as int) : 90
+ execution.setVariable("nssiInstanceList", nssiInstanceList)
+ execution.setVariable("currentNSSIIndex", 0)
+ execution.setVariable("proportion", proportion)
+ String msg ="nssiInstanceList size: ${nssiInstanceList.size()}, proportion:${proportion}"
+ LOGGER.info(msg)
+ LOGGER.trace(" *****${PREFIX} Exit getNSSIListFromAAI *****")
+ }
+
+ /**
+ * get current NSSI
+ * @param execution
+ */
+ void getCurrentNSSI(DelegateExecution execution)
+ {
+ LOGGER.trace(" *****${PREFIX} Start getCurrentNSSI *****")
+ List<ServiceInstance> nssiInstanceList = execution.getVariable("nssiInstanceList")
+ int currentIndex = execution.getVariable("currentNSSIIndex") as int
+ ServiceInstance nssi = nssiInstanceList?.get(currentIndex)
+ def currentNSSI = [:]
+ currentNSSI['nssiServiceInstanceId'] = nssi?.getServiceInstanceId()
+ currentNSSI['modelInvariantId'] = nssi?.getModelInvariantId()
+ currentNSSI['modelVersionId'] = nssi?.getModelVersionId()
+ currentNSSI['snssai'] = execution.getVariable("snssai") ?: ""
+ currentNSSI['nsiServiceInstanceId'] = execution.getVariable("nsiId") ?: ""
+ currentNSSI['operationId'] = execution.getVariable("operationId") ?: ""
+ currentNSSI['e2eServiceInstanceId'] = execution.getVariable("serviceInstanceId") ?: ""
+ currentNSSI['msoRequestId'] = execution.getVariable("msoRequestId") ?: ""
+ currentNSSI['globalSubscriberId'] = execution.getVariable("globalSubscriberId") ?: ""
+ currentNSSI['serviceType'] = execution.getVariable("serviceType") ?: ""
+ currentNSSI['serviceModelInfo'] = execution.getVariable("serviceModelInfo") ?: ""
+ currentNSSI['proportion'] = (execution.getVariable("proportion") as int)*(currentIndex+1)
+ execution.setVariable("currentNSSI", currentNSSI)
+ String msg = "Now we deal with nssiServiceInstanceId: ${currentNSSI['nssiServiceInstanceId']}, current Index: ${currentIndex}, current proportion:${currentNSSI['proportion']}"
+ LOGGER.info(msg)
+ LOGGER.trace(" *****${PREFIX} Exit getCurrentNSSI *****")
+ }
+
+ /**
+ * parse next nssi
+ * @param execution
+ */
+ void parseNextNSSI(DelegateExecution execution)
+ {
+ LOGGER.trace(" *****${PREFIX} Start parseNextNSSI *****")
+ if(execution.getVariable("WorkflowException") != null){
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "current job failure!")
+ }
+ def currentIndex = execution.getVariable("currentNSSIIndex")
+ List<ServiceInstance> nssiInstanceList = execution.getVariable("nssiInstanceList")
+ def nextIndex = ++currentIndex
+ LOGGER.info("nextIndex: ${nextIndex}")
+ if(nextIndex >= nssiInstanceList.size()){
+ execution.setVariable("isAllNSSIFinished", "true")
+ }else{
+ execution.setVariable("isAllNSSIFinished", "false")
+ execution.setVariable("currentNSSIIndex", nextIndex)
+ }
+ LOGGER.trace(" *****${PREFIX} Exit parseNextNSSI *****")
+ }
+
+
+ /**
+ * query sliceProfile from AAI
+ * save profileId
+ * @param execution
+ */
+ void querySliceProfileFromAAI(DelegateExecution execution)
+ {
+ LOGGER.trace(" *****${PREFIX} Start querySliceProfileFromAAI *****")
+ def currentNSSI = execution.getVariable("currentNSSI")
+ String nssiId = currentNSSI['nssiServiceInstanceId']
+ String errorMsg = "query slice profile failed"
+ AAIResultWrapper wrapper = queryAAI(execution, AAIObjectType.SLICE_PROFILE_ALL, nssiId, errorMsg)
+ Optional<SliceProfiles> sliceProfiles =wrapper.asBean(SliceProfiles.class)
+ if(sliceProfiles.isPresent())
+ {
+ String profileId = sliceProfiles.get().getSliceProfile()?.get(0)?.getProfileId()
+ currentNSSI['profileId'] = profileId ?: ""
+ LOGGER.info("nssiId: ${nssiId}, profileId: ${profileId}")
+ }
+ execution.setVariable("currentNSSI", currentNSSI)
+ LOGGER.trace(" *****${PREFIX} Exit querySliceProfileFromAAI *****")
+ }
+
+ /**
+ * query AAI
+ * @param execution
+ * @param aaiObjectType
+ * @param instanceId
+ * @return AAIResultWrapper
+ */
+ private AAIResultWrapper queryAAI(DelegateExecution execution, AAIObjectType aaiObjectType, String instanceId, String errorMsg)
+ {
+ LOGGER.trace(" *****${PREFIX} Start queryAAI *****")
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String serviceType = execution.getVariable("serviceType")
+
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(aaiObjectType, globalSubscriberId, serviceType, instanceId)
+ if (!getAAIClient().exists(resourceUri)) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMsg)
+ }
+ AAIResultWrapper wrapper = getAAIClient().get(resourceUri, NotFoundException.class)
+ LOGGER.trace(" *****${PREFIX} Exit queryAAI *****")
+ return wrapper
+ }
+
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy
index 4c8247a309..002e283790 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy
@@ -25,7 +25,7 @@ package org.onap.so.bpmn.infrastructure.scripts
import org.onap.so.logger.LoggingAnchor
import org.onap.aai.domain.yang.NetworkPolicies
import org.onap.aai.domain.yang.NetworkPolicy
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import javax.xml.parsers.DocumentBuilder
import javax.xml.parsers.DocumentBuilderFactory
@@ -41,6 +41,7 @@ import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.client.aai.AAIObjectPlurals
import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.uri.AAIPluralResourceUri
import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.logger.MessageEnum
@@ -489,7 +490,7 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{
for (i in 0..fqdnCount-1) {
String fqdn = fqdnList[i]
// Query AAI for this network policy FQDN
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
+ AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
uri.queryParam("network-policy-fqdn", fqdn)
try {
Optional<NetworkPolicies> networkPolicies = getAAIClient().get(NetworkPolicies.class, uri)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy
index eba43632a7..34a210364a 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy
@@ -27,7 +27,7 @@ import org.onap.aai.domain.yang.GenericVnf
import org.onap.aai.domain.yang.NetworkPolicies
import org.onap.aai.domain.yang.NetworkPolicy
import org.onap.aai.domain.yang.VfModule
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import static org.apache.commons.lang3.StringUtils.*
import org.camunda.bpm.engine.delegate.BpmnError
@@ -43,6 +43,7 @@ import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.client.graphinventory.entities.uri.Depth
import org.onap.so.client.aai.AAIObjectPlurals
import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.uri.AAIPluralResourceUri
import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.logger.MessageEnum
@@ -513,7 +514,7 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase {
// Query AAI for this network policy FQDN
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
+ AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
uri.queryParam("network-policy-fqdn", fqdn)
try {
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy
index 20d250d89f..ff58fd567d 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy
@@ -45,7 +45,7 @@ import org.onap.so.client.graphinventory.entities.uri.Depth
import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.client.aai.AAIObjectType
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import org.onap.so.logger.MessageEnum
import org.slf4j.Logger
import org.slf4j.LoggerFactory
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleE2EServiceInstance.groovy
index 231fe6e252..4eba33dc7d 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleE2EServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleE2EServiceInstance.groovy
@@ -22,7 +22,7 @@
package org.onap.so.bpmn.infrastructure.scripts
import org.onap.so.logger.LoggingAnchor
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import static org.apache.commons.lang3.StringUtils.*;
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy
index 367975e003..16e1241750 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy
@@ -34,7 +34,7 @@ import org.onap.so.bpmn.core.json.JsonUtils
import org.camunda.bpm.engine.delegate.BpmnError
import com.fasterxml.jackson.databind.ObjectMapper
import org.onap.so.client.HttpClientFactory
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import javax.ws.rs.core.Response
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoSendCommandToNSSMF.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoSendCommandToNSSMF.groovy
new file mode 100644
index 0000000000..5acc016c7b
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoSendCommandToNSSMF.groovy
@@ -0,0 +1,463 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2019, CMCC Technologies Co., Ltd.
+ #
+ # 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 com.fasterxml.jackson.databind.ObjectMapper
+import com.google.gson.Gson
+import com.google.gson.reflect.TypeToken
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.logging.filter.base.ONAPComponents
+import org.onap.so.beans.nsmf.*
+import org.onap.so.bpmn.common.scripts.*
+import org.onap.so.bpmn.common.util.OofInfraUtils
+import org.onap.so.bpmn.core.UrnPropertiesReader
+import org.onap.so.bpmn.core.WorkflowException
+import org.onap.so.bpmn.core.domain.ServiceArtifact
+import org.onap.so.bpmn.core.domain.ServiceDecomposition
+import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.client.HttpClient
+import org.onap.so.client.HttpClientFactory
+import org.onap.logging.filter.base.ErrorCode
+import org.onap.so.logger.LoggingAnchor
+import org.onap.so.logger.MessageEnum
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+import org.springframework.web.util.UriUtils
+
+import javax.ws.rs.core.Response
+import java.lang.reflect.Type
+
+/**
+ * This class supports the DoCreateVnf building block subflow
+ * with the creation of a generic vnf for
+ * infrastructure.
+ *
+ */
+class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor {
+
+ private static final Logger logger = LoggerFactory.getLogger( DoSendCommandToNSSMF.class);
+ String Prefix="DoCNSSMF_"
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+ JsonUtils jsonUtil = new JsonUtils()
+ VidUtils vidUtils = new VidUtils(this)
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
+ OofInfraUtils oofInfraUtils = new OofInfraUtils()
+
+ /**
+ * This method gets and validates the incoming
+ * request.
+ *
+ * @param - execution
+ *
+ */
+ public void preProcessRequest(DelegateExecution execution) {
+
+ execution.setVariable("prefix",Prefix)
+ logger.debug("STARTED Do sendcommandtoNssmf PreProcessRequest Process")
+
+ /*******************/
+ try{
+ // Get Variables
+ String e2eserviceInstanceId = execution.getVariable("e2eserviceInstanceId")
+ String serviceInstanceId = execution.getVariable("e2eserviceInstanceId")
+ execution.setVariable("e2eserviceInstanceId", e2eserviceInstanceId)
+ execution.setVariable("serviceInstanceId", serviceInstanceId)
+ logger.debug("Incoming e2eserviceInstanceId is: " + e2eserviceInstanceId)
+
+ String NSIserviceid = execution.getVariable("NSIserviceid")
+ execution.setVariable("NSIserviceid", NSIserviceid)
+ logger.debug("Incoming NSI id is: " + NSIserviceid)
+
+
+ String nssiMap = execution.getVariable("nssiMap")
+ Type type = new TypeToken<HashMap<String, NSSI>>(){}.getType()
+ Map<String, NSSI> DonssiMap = new Gson().fromJson(nssiMap,type)
+ String strDonssiMap = mapToJsonStr(DonssiMap)
+ execution.setVariable("DonssiMap",strDonssiMap)
+ logger.debug("Incoming DonssiMap is: " + strDonssiMap)
+
+ String requestId = execution.getVariable("msoRequestId")
+ execution.setVariable("msoRequestId", requestId)
+
+ String operationType = execution.getVariable("operationType")
+ execution.setVariable("operationType", operationType)
+ logger.debug("Incoming operationType is: " + operationType)
+
+ if (operationType == "activation") {
+ execution.setVariable("activationSequence","an,tn,cn")
+ }else {
+ execution.setVariable("activationSequence","cn,tn,an")
+ }
+ execution.setVariable("activationIndex",0)
+ execution.setVariable("miniute", "0")
+ execution.setVariable("activateNumberSlice",0)
+
+ logger.info("the end !!")
+ }catch(BpmnError b){
+ logger.debug("Rethrowing MSOWorkflowException")
+ throw b
+ }catch(Exception e){
+ logger.info("the end of catch !!")
+ logger.debug(" Error Occured in DoSendCommandToNSSMF PreProcessRequest method!" + e.getMessage())
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoSendCommandToNSSMF PreProcessRequest")
+
+ }
+ logger.trace("COMPLETED DoSendCommandToNSSMF PreProcessRequest Process")
+ }
+ private String mapToJsonStr(Map<String, NSSI> stringNSSIHashMap) {
+ HashMap<String, NSSI> map = new HashMap<String, NSSI>()
+ for(Map.Entry<String, NSSI> child:stringNSSIHashMap.entrySet())
+ {
+ map.put(child.getKey(), child.getValue())
+ }
+ return new Gson().toJson(map)
+ }
+ public void getNSSIformlist(DelegateExecution execution) {
+
+ String nssiMap = execution.getVariable("DonssiMap")
+ Type type = new TypeToken<HashMap<String, NSSI>>(){}.getType()
+ Map<String, NSSI> DonssiMap = new Gson().fromJson(nssiMap,type)
+ String isNSSIActivate = execution.getVariable("isNSSIActivate")
+
+ String activationSequence01 = execution.getVariable("activationSequence")
+ String[] strlist = activationSequence01.split(",")
+
+ int activationIndex = execution.getVariable("activationIndex")
+ int indexcurrent = 0
+ if (isNSSIActivate == "true")
+ {
+ execution.setVariable("isGetSuccessfull", "false")
+ }else{for (int index = activationIndex; index < 3;index++) {
+ String domaintype01 = strlist[index]
+ if (DonssiMap.containsKey(domaintype01)) {
+ NSSI nssiobject = DonssiMap.get(domaintype01)
+ execution.setVariable("domainType", domaintype01)
+ execution.setVariable("nssiId", nssiobject.getNssiId())
+ execution.setVariable("modelInvariantUuid", nssiobject.getModelInvariantId())
+ execution.setVariable("modelUuid", nssiobject.getModelVersionId())
+ execution.setVariable("isGetSuccessfull", "true")
+ String modelInvariantUuid = execution.getVariable("modelInvariantUuid")
+ String modelUuid = execution.getVariable("modelUuid")
+ //here modelVersion is not set, we use modelUuid to decompose the service.
+ String serviceModelInfo = """{
+ "modelInvariantUuid":"${modelInvariantUuid}",
+ "modelUuid":"${modelUuid}",
+ "modelVersion":""
+ }"""
+ execution.setVariable("serviceModelInfo", serviceModelInfo)
+ indexcurrent = index
+ execution.setVariable("activationIndex", indexcurrent)
+ break
+ }else
+ {
+ indexcurrent = index + 1
+
+ }
+ }
+ if ( activationIndex > 2) {
+ execution.setVariable("isGetSuccessfull", "false")
+ }
+ execution.setVariable("activationIndex", indexcurrent)}
+
+ }
+ /**
+ * get vendor Info
+ * @param execution
+ */
+ private void processDecomposition(DelegateExecution execution) {
+ logger.debug("***** processDecomposition *****")
+
+ try {
+ ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") as ServiceDecomposition
+ ServiceArtifact serviceArtifact = serviceDecomposition.getServiceInfo().getServiceArtifact().get(0)
+ String content = serviceArtifact.getContent()
+ String vendor = jsonUtil.getJsonValue(content, "metadata.vendor")
+ //String domainType = jsonUtil.getJsonValue(content, "metadata.domainType")
+
+ execution.setVariable("vendor", vendor)
+ // currentNSSI['domainType'] = domainType
+ logger.info("processDecomposition, current vendor-domainType:" + vendor)
+
+ } catch (any) {
+ String exceptionMessage = "Bpmn error encountered in deallocate nssi. processDecomposition() - " + any.getMessage()
+ logger.debug(exceptionMessage)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
+ }
+ logger.debug("***** Exit processDecomposition *****")
+ }
+ public void UpdateIndex(DelegateExecution execution) {
+ def activationIndex = execution.getVariable("activationIndex")
+ int activateNumberSlice = execution.getVariable("activateNumberSlice") as Integer
+ def activationCount= execution.getVariable("activationCount")
+ //DecimalFormat df1 = new DecimalFormat("##%")
+ int rate = (activateNumberSlice / activationCount) * 100
+ if (rate == 100)
+ {
+ execution.setVariable("isNSSIActivate","true")
+ }
+ else{
+ execution.setVariable("isNSSIActivate","false")
+ }
+ activationIndex = activationIndex + 1
+ execution.setVariable("activationIndex",activationIndex)
+ logger.trace("the Progress of activation is " + rate.toString() + "%" )
+ try{
+ String serviceId = execution.getVariable("serviceInstanceId")
+ String operationId = UUID.randomUUID().toString()
+ String operationType = execution.getVariable("operationType")
+ String userId = ""
+ String result = (operationType.equals("activation"))? "ACTIVATING": "DEACTIVATING"
+ int progress = rate
+ String reason = ""
+ String operationContent = "Service activation in progress"
+ logger.debug("Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId)
+ serviceId = UriUtils.encode(serviceId,"UTF-8")
+ execution.setVariable("e2eserviceInstanceId", serviceId)
+ execution.setVariable("operationId", operationId)
+ execution.setVariable("operationType", operationType)
+
+ def dbAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.openecomp.db.endpoint",execution)
+ execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
+ logger.debug("DB Adapter Endpoint is: " + dbAdapterEndpoint)
+
+ String payload =
+ """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:ns="http://org.onap.so/requestsdb">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <ns:initServiceOperationStatus xmlns:ns="http://org.onap.so/requestsdb">
+ <serviceId>${MsoUtils.xmlEscape(serviceId)}</serviceId>
+ <operationId>${MsoUtils.xmlEscape(operationId)}</operationId>
+ <operationType>${MsoUtils.xmlEscape(operationType)}</operationType>
+ <userId>${MsoUtils.xmlEscape(userId)}</userId>
+ <result>${MsoUtils.xmlEscape(result)}</result>
+ <operationContent>${MsoUtils.xmlEscape(operationContent)}</operationContent>
+ <progress>${MsoUtils.xmlEscape(progress)}</progress>
+ <reason>${MsoUtils.xmlEscape(reason)}</reason>
+ </ns:initServiceOperationStatus>
+ </soapenv:Body>
+ </soapenv:Envelope>"""
+
+ payload = utils.formatXml(payload)
+ execution.setVariable("CVFMI_updateServiceOperStatusRequest", payload)
+ logger.debug("Outgoing CVFMI_updateServiceOperStatusRequest: \n" + payload)
+
+ }catch(Exception e){
+ logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ "Exception Occured Processing Activate Slice .", "BPMN",
+ ErrorCode.UnknownError.getValue(), "Exception is:\n" + e)
+ execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during Activate Slice Method:\n" + e.getMessage())
+ }
+ logger.trace("finished Activate Slice")
+ }
+ public void WaitForReturn(DelegateExecution execution) {
+ //logger.debug("Query : "+ Jobid)
+ def miniute=execution.getVariable("miniute")
+ Thread.sleep(10000)
+ int miniute01 = Integer.parseInt(miniute) + 1
+ logger.debug("waiting for : "+ miniute + "miniutes")
+ execution.setVariable("miniute", String.valueOf(miniute01))
+ }
+ public void GetTheStatusOfActivation(DelegateExecution execution) {
+
+ String snssai= execution.getVariable("snssai")
+ String domaintype = execution.getVariable("domainType")
+ String NSIserviceid=execution.getVariable("NSIserviceid")
+ String nssiId = execution.getVariable("nssiId")
+ String Jobid=execution.getVariable("JobId")
+ def miniute=execution.getVariable("miniute")
+ String vendor = execution.getVariable("vendor")
+ String jobstatus ="error"
+
+
+ logger.debug("Query the jobid activation of SNSSAI: "+ Jobid)
+ logger.debug("the domain is : "+ domaintype)
+ logger.debug("the NSSID is : "+nssiId)
+ logger.debug("the NSIserviceid is : "+NSIserviceid)
+
+ JobStatusRequest jobStatusRequest = new JobStatusRequest()
+
+ EsrInfo info = new EsrInfo()
+ info.setNetworkType(NetworkType.fromString(domaintype))
+ info.setVendor(vendor)
+
+ jobStatusRequest.setNsiId(NSIserviceid)
+ jobStatusRequest.setNssiId(nssiId)
+ jobStatusRequest.setEsrInfo(info)
+
+
+ ObjectMapper mapper = new ObjectMapper()
+ String Reqjson = mapper.writeValueAsString(jobStatusRequest)
+ String isActivateSuccessfull=false
+
+ String urlString = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution)
+ String nssmfRequest = urlString + "/api/rest/provMns/v1/NSS/jobs/" +Jobid
+
+ //send request to active NSSI TN option
+ URL url = new URL(nssmfRequest)
+
+ HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL)
+ Response httpResponse = httpClient.post(Reqjson)
+
+ int responseCode = httpResponse.getStatus()
+ logger.debug("NSSMF activation response code is: " + responseCode)
+
+ if (responseCode == 404) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad job status Response from NSSMF.")
+ isActivateSuccessfull = false
+ execution.setVariable("isActivateSuccessfull", isActivateSuccessfull)
+ jobstatus="error"
+ }else if(responseCode == 200) {
+ if (httpResponse.hasEntity()) {
+ JobStatusResponse jobStatusResponse = httpResponse.readEntity(JobStatusResponse.class)
+ execution.setVariable("statusDescription", jobStatusResponse.getResponseDescriptor().getStatusDescription())
+ jobstatus = jobStatusResponse.getResponseDescriptor().getStatus()
+ switch(jobstatus) {
+ case "started":
+ case "processing":
+ isActivateSuccessfull = "waitting"
+ execution.setVariable("isActivateSuccessfull", isActivateSuccessfull)
+ break
+ case "finished":
+ isActivateSuccessfull = "true"
+ execution.setVariable("isActivateSuccessfull", isActivateSuccessfull)
+ execution.setVariable("activateNumberSlice",execution.getVariable("activateNumberSlice")+ 1)
+ break
+ case "error":
+ default:
+ isActivateSuccessfull = "false"
+ execution.setVariable("isActivateSuccessfull", isActivateSuccessfull)
+
+ }
+ if(Integer.parseInt(miniute) > 6 )
+ {
+ isActivateSuccessfull = "false"
+ execution.setVariable("isActivateSuccessfull", isActivateSuccessfull)
+ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a timeout job status Response from NSSMF.")
+ }
+ }else
+ {
+ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad job status Response from NSSMF.")
+ isActivateSuccessfull = false
+ execution.setVariable("isActivateSuccessfull", isActivateSuccessfull)
+ }
+ } else {
+ isActivateSuccessfull = false
+ execution.setVariable("isActivateSuccessfull", isActivateSuccessfull)
+ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad job status Response from NSSMF.")
+ }
+ }
+ public void SendCommandToNssmf(DelegateExecution execution) {
+
+ String snssai= execution.getVariable("snssai")
+ String domaintype = execution.getVariable("domainType")
+ String NSIserviceid=execution.getVariable("NSIserviceid")
+ String nssiId = execution.getVariable("nssiId")
+ String vendor = execution.getVariable("vendor")
+
+
+ logger.debug("the domain is : "+domaintype)
+ logger.debug("SNSSAI: "+snssai +" will be activated")
+ logger.debug("the NSSID is : "+nssiId)
+ logger.debug("the NSIserviceid is : "+NSIserviceid)
+
+ EsrInfo esr = new EsrInfo();
+ esr.setNetworkType(NetworkType.fromString(domaintype))
+ esr.setVendor(vendor)
+
+ ActDeActNssi actNssi = new ActDeActNssi();
+ actNssi.setNsiId(NSIserviceid);
+ actNssi.setNssiId(nssiId);
+ NssiActDeActRequest actRequest = new NssiActDeActRequest();
+ actRequest.setActDeActNssi(actNssi);
+ actRequest.setEsrInfo(esr)
+
+ ObjectMapper mapper = new ObjectMapper();
+ String json = mapper.writeValueAsString(actRequest);
+
+
+ String urlString = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution)
+
+ //Prepare auth for NSSMF - Begin
+ def authHeader = ""
+ String basicAuth = UrnPropertiesReader.getVariable("mso.nssmf.auth", execution)
+ String operationType = execution.getVariable("operationType")
+
+ String nssmfRequest = urlString + "/api/rest/provMns/v1/NSS/" + snssai + "/" + operationType
+
+ //send request to active NSSI TN option
+ URL url = new URL(nssmfRequest)
+
+ HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL)
+ Response httpResponse = httpClient.post(json)
+
+ int responseCode = httpResponse.getStatus()
+ logger.debug("NSSMF activate response code is: " + responseCode)
+ checkNssmfResponse(httpResponse, execution)
+
+ NssiResponse nssmfResponse = httpResponse.readEntity(NssiResponse.class)
+ String jobId = nssmfResponse.getJobId() ?: ""
+ execution.setVariable("JobId", jobId)
+
+ }
+ private void checkNssmfResponse(Response httpResponse, DelegateExecution execution) {
+ int responseCode = httpResponse.getStatus()
+ logger.debug("NSSMF response code is: " + responseCode)
+
+ if ( responseCode < 200 || responseCode > 202 || !httpResponse.hasEntity()) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Response from NSSMF.")
+ String isNSSIActivated = "false"
+ execution.setVariable("isNSSIActivated", isNSSIActivated)
+ execution.setVariable("isNSSIActivate","false")
+ }else{
+ String isNSSIActivated = "true"
+ execution.setVariable("isNSSIActivated", isNSSIActivated)
+ }
+ }
+
+
+ void sendSyncError (DelegateExecution execution) {
+ logger.trace("start sendSyncError")
+ try {
+ String errorMessage = ""
+ if (execution.getVariable("WorkflowException") instanceof WorkflowException) {
+ WorkflowException wfe = execution.getVariable("WorkflowException")
+ errorMessage = wfe.getErrorMessage()
+ } else {
+ errorMessage = "Sending Sync Error."
+ }
+
+ String buildworkflowException =
+ """<aetgt:WorkflowException xmlns:aetgt="http://org.onap/so/workflow/schema/v1">
+ <aetgt:ErrorMessage>${MsoUtils.xmlEscape(errorMessage)}</aetgt:ErrorMessage>
+ <aetgt:ErrorCode>7000</aetgt:ErrorCode>
+ </aetgt:WorkflowException>"""
+
+ logger.debug(buildworkflowException)
+ sendWorkflowResponse(execution, 500, buildworkflowException)
+
+ } catch (Exception ex) {
+ logger.debug("Sending Sync Error Activity Failed. " + "\n" + ex.getMessage())
+ }
+ logger.trace("finished sendSyncError")
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy
index f7852431e5..ff63bc945b 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy
@@ -22,10 +22,10 @@
package org.onap.so.bpmn.infrastructure.scripts
-import org.onap.so.logger.LoggingAnchor
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.aai.domain.yang.GenericVnf
+import org.onap.logging.filter.base.ErrorCode
import org.onap.so.bpmn.common.scripts.AaiUtil
import org.onap.so.bpmn.common.scripts.CatalogDbUtils
import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory
@@ -37,15 +37,14 @@ import org.onap.so.bpmn.common.scripts.VfModuleBase
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.core.json.JsonUtils;
-import org.onap.so.client.graphinventory.entities.uri.Depth
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.AAIResourcesClient
import org.onap.so.client.aai.entities.AAIResultWrapper
-import org.onap.so.client.aai.entities.uri.AAIUri
-import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+import org.onap.so.client.graphinventory.entities.uri.Depth
import org.onap.so.constants.Defaults
-import org.onap.so.logger.ErrorCode
+import org.onap.so.logger.LoggingAnchor
import org.onap.so.logger.MessageEnum
import org.slf4j.Logger
import org.slf4j.LoggerFactory
@@ -274,7 +273,7 @@ public class DoUpdateVfModule extends VfModuleBase {
}
try{
- AAIUri serviceInstanceURI = AAIUriFactory.create(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId,serviceType,serviceInstanceId)
+ AAIResourceUri serviceInstanceURI = AAIUriFactory.create(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId,serviceType,serviceInstanceId)
AAIResourcesClient aaiRC = new AAIResourcesClient()
AAIResultWrapper aaiRW = aaiRC.get(serviceInstanceURI)
Map<String, Object> aaiJson = aaiRW.asMap()
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy
index cfdba89db7..7caa63ec72 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy
@@ -24,7 +24,7 @@ package org.onap.so.bpmn.infrastructure.scripts
import org.onap.so.logger.LoggingAnchor
import org.onap.so.client.HttpClientFactory
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import javax.ws.rs.core.Response
import org.camunda.bpm.engine.delegate.BpmnError
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy
index e36f32578d..275cef0b0c 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy
@@ -35,7 +35,7 @@ import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.client.aai.*
import org.onap.so.client.appc.ApplicationControllerOrchestrator
import org.onap.so.client.appc.ApplicationControllerSupport
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import org.onap.so.logger.MessageEnum
import org.slf4j.Logger
import org.slf4j.LoggerFactory
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/RollbackVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/RollbackVnf.groovy
index ed65616d89..d5bdb73b61 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/RollbackVnf.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/RollbackVnf.groovy
@@ -22,7 +22,7 @@
package org.onap.so.bpmn.infrastructure.scripts
import org.onap.so.logger.LoggingAnchor
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.so.bpmn.common.scripts.ExceptionUtil
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ScaleCustomE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ScaleCustomE2EServiceInstance.groovy
index b21efdd563..b27ca4a956 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ScaleCustomE2EServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ScaleCustomE2EServiceInstance.groovy
@@ -23,7 +23,7 @@
package org.onap.so.bpmn.infrastructure.scripts
import org.onap.so.logger.LoggingAnchor
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import static org.apache.commons.lang3.StringUtils.*
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModule.groovy
index 6946eebc56..6e5ee01c9a 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModule.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModule.groovy
@@ -29,7 +29,7 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.core.WorkflowException
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import org.onap.so.logger.MessageEnum
import org.slf4j.Logger
import org.slf4j.LoggerFactory
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfra.groovy
index 2404169493..76702eab81 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfra.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfra.groovy
@@ -30,7 +30,7 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.core.WorkflowException
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import org.onap.so.logger.MessageEnum
import org.slf4j.Logger
import org.slf4j.LoggerFactory
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy
index 3e9b934a2e..f1fbafc7de 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy
@@ -37,7 +37,7 @@ import org.onap.so.client.aai.entities.Relationships
import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.constants.Defaults
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import org.onap.so.logger.MessageEnum
import org.slf4j.Logger
import org.slf4j.LoggerFactory
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy
index 7f2bbebc8d..5449ba6708 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy
@@ -42,7 +42,7 @@ import org.onap.so.client.aai.entities.Relationships
import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.constants.Defaults
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import org.onap.so.logger.MessageEnum
import org.slf4j.Logger
import org.slf4j.LoggerFactory
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy
index 26a509022c..053e2b36d1 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy
@@ -35,7 +35,7 @@ import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.client.aai.AAIRestClientImpl
import org.onap.so.client.aai.AAIUpdatorImpl
import org.onap.so.client.aai.AAIValidatorImpl
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import org.onap.so.logger.MessageEnum
import org.slf4j.Logger
import org.slf4j.LoggerFactory
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy
index 09e7516f85..980128c848 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy
@@ -30,6 +30,7 @@ import org.onap.appc.client.lcm.model.Action
import org.onap.appc.client.lcm.model.ActionIdentifiers
import org.onap.appc.client.lcm.model.Flags
import org.onap.appc.client.lcm.model.Status
+import org.onap.logging.filter.base.ErrorCode
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.MsoUtils
@@ -42,11 +43,9 @@ import org.onap.so.client.aai.*
import org.onap.so.client.aai.entities.AAIResultWrapper
import org.onap.so.client.aai.entities.Relationships
import org.onap.so.client.aai.entities.uri.AAIResourceUri
-import org.onap.so.client.aai.entities.uri.AAIUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.client.appc.ApplicationControllerClient
import org.onap.so.client.appc.ApplicationControllerSupport
-import org.onap.so.logger.ErrorCode
import org.onap.so.logger.MessageEnum
import org.slf4j.Logger
import org.slf4j.LoggerFactory
@@ -218,7 +217,7 @@ public abstract class VnfCmBase extends AbstractServiceTaskProcessor {
logger.debug("cloudRegionId is: {}", cloudRegionId)
AAIResourcesClient client = new AAIResourcesClient()
- AAIUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
+ AAIResourceUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
// Check if this VNF exists
if (!client.exists(genericVnfUri)) {
logger.debug("VNF with vnfId {} does not exist in A&AI", vnfId)
@@ -436,7 +435,7 @@ public abstract class VnfCmBase extends AbstractServiceTaskProcessor {
def vnfId = execution.getVariable("vnfId")
logger.debug("vnfId is: {}", vnfId)
AAIResourcesClient client = new AAIResourcesClient()
- AAIUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
+ AAIResourceUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
AAIResultWrapper aaiRW = client.get(genericVnfUri)
Map<String, Object> result = aaiRW.asMap()
boolean isClosedLoopDisabled = result.getOrDefault("is-closed-loop-disabled", false)
@@ -488,7 +487,7 @@ public abstract class VnfCmBase extends AbstractServiceTaskProcessor {
def transactionLoggingUuid = UUID.randomUUID().toString()
def vnfId = execution.getVariable("vnfId")
AAIResourcesClient client = new AAIResourcesClient()
- AAIUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
+ AAIResourceUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
Map<String, Boolean> request = new HashMap<>()
request.put("is-closed-loop-disabled", setDisabled)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfConfigUpdate.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfConfigUpdate.groovy
index 90523a02be..70b7ec102b 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfConfigUpdate.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfConfigUpdate.groovy
@@ -21,22 +21,22 @@
package org.onap.so.bpmn.infrastructure.scripts
-import groovy.json.JsonOutput
-import groovy.json.JsonSlurper
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.appc.client.lcm.model.Action
+import org.onap.logging.filter.base.ErrorCode
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.client.aai.*
import org.onap.so.client.aai.entities.AAIResultWrapper
-import org.onap.so.client.aai.entities.uri.AAIUri
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
-import org.onap.so.logger.ErrorCode
import org.onap.so.logger.MessageEnum
import org.slf4j.Logger
import org.slf4j.LoggerFactory
+import groovy.json.JsonOutput
+import groovy.json.JsonSlurper
public class VnfConfigUpdate extends VnfCmBase {
private static final Logger logger = LoggerFactory.getLogger( VnfConfigUpdate.class)
@@ -360,7 +360,7 @@ public class VnfConfigUpdate extends VnfCmBase {
def vnfId = execution.getVariable("vnfId")
logger.debug("vnfId is: {}", vnfId)
AAIResourcesClient client = new AAIResourcesClient()
- AAIUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
+ AAIResourceUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
AAIResultWrapper aaiRW = client.get(genericVnfUri)
Map<String, Object> result = aaiRW.asMap()
boolean isClosedLoopDisabled = result.getOrDefault("is-closed-loop-disabled", false)
@@ -412,7 +412,7 @@ public class VnfConfigUpdate extends VnfCmBase {
def transactionLoggingUuid = UUID.randomUUID().toString()
def vnfId = execution.getVariable("vnfId")
AAIResourcesClient client = new AAIResourcesClient()
- AAIUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
+ AAIResourceUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
Map<String, Boolean> request = new HashMap<>()
request.put("is-closed-loop-disabled", setDisabled)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy
index 3cb40115ba..c5f117b35f 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy
@@ -21,28 +21,28 @@
package org.onap.so.bpmn.infrastructure.scripts
-import org.onap.so.logger.LoggingAnchor
-import groovy.json.JsonOutput
-import groovy.json.JsonSlurper
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.appc.client.lcm.model.Action
import org.onap.appc.client.lcm.model.ActionIdentifiers
import org.onap.appc.client.lcm.model.Flags
import org.onap.appc.client.lcm.model.Status
+import org.onap.logging.filter.base.ErrorCode
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.client.aai.*
import org.onap.so.client.aai.entities.AAIResultWrapper
-import org.onap.so.client.aai.entities.uri.AAIUri
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.client.appc.ApplicationControllerClient
import org.onap.so.client.appc.ApplicationControllerSupport
-import org.onap.so.logger.ErrorCode
+import org.onap.so.logger.LoggingAnchor
import org.onap.so.logger.MessageEnum
import org.slf4j.Logger
import org.slf4j.LoggerFactory
+import groovy.json.JsonOutput
+import groovy.json.JsonSlurper
public class VnfInPlaceUpdate extends VnfCmBase {
private static final Logger logger = LoggerFactory.getLogger(VnfInPlaceUpdate.class)
@@ -380,7 +380,7 @@ public class VnfInPlaceUpdate extends VnfCmBase {
def vnfId = execution.getVariable("vnfId")
logger.debug("vnfId is: " + vnfId)
AAIResourcesClient client = new AAIResourcesClient()
- AAIUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
+ AAIResourceUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
AAIResultWrapper aaiRW = client.get(genericVnfUri)
Map<String, Object> result = aaiRW.asMap()
boolean isClosedLoopDisabled = result.getOrDefault("is-closed-loop-disabled", false)
@@ -431,7 +431,7 @@ public class VnfInPlaceUpdate extends VnfCmBase {
def transactionLoggingUuid = UUID.randomUUID().toString()
def vnfId = execution.getVariable("vnfId")
AAIResourcesClient client = new AAIResourcesClient()
- AAIUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
+ AAIResourceUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
Map<String, Boolean> request = new HashMap<>()
request.put("is-closed-loop-disabled", setDisabled)
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 d57011f61f..6327ea233c 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
@@ -22,7 +22,7 @@
package org.onap.so.bpmn.vcpe.scripts
import org.onap.so.logger.LoggingAnchor
-import org.onap.so.logger.ErrorCode;
+import org.onap.logging.filter.base.ErrorCode;
import static org.apache.commons.lang3.StringUtils.*
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy
index 553ec2397c..5205fa1874 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy
@@ -31,7 +31,7 @@ import org.onap.so.bpmn.common.scripts.NetworkUtils
import org.onap.so.bpmn.common.scripts.VidUtils
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.core.json.JsonUtils
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import org.onap.so.logger.MessageEnum
import org.slf4j.Logger
import org.slf4j.LoggerFactory
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy
index 0681e54bba..a4f7766c15 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy
@@ -22,7 +22,8 @@
package org.onap.so.bpmn.vcpe.scripts
-import org.onap.so.logger.LoggingAnchor
+import static org.apache.commons.lang3.StringUtils.isBlank
+import javax.ws.rs.core.UriBuilder
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.aai.domain.yang.AllottedResource
@@ -35,16 +36,12 @@ import org.onap.so.client.aai.AAIObjectType
import org.onap.so.client.aai.AAIResourcesClient
import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
+import org.onap.so.logger.LoggingAnchor
import org.onap.so.logger.MessageEnum
import org.slf4j.Logger
import org.slf4j.LoggerFactory
-import javax.ws.rs.NotFoundException
-import javax.ws.rs.core.UriBuilder
-
-import static org.apache.commons.lang3.StringUtils.isBlank
-
/**
* This groovy class supports the <class>DoCreateAllottedResourceBRG.bpmn</class> process.
*
@@ -235,11 +232,10 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{
AAIResourcesClient resourceClient = new AAIResourcesClient()
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId)
- try {
//just to make sure the serviceInstance exists
- uri.build()
+ if (resourceClient.exists(uri)) {
execution.setVariable("PSI_resourceLink", uri)
- } catch (NotFoundException e) {
+ } else {
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai")
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy
index f24bb46981..b5ddc57781 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy
@@ -31,7 +31,7 @@ import org.onap.so.bpmn.common.scripts.AllottedResourceUtils
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
import org.onap.so.bpmn.core.WorkflowException
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import org.onap.so.logger.MessageEnum
import org.slf4j.Logger
import org.slf4j.LoggerFactory
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy
index 51d04dd092..fc50d3a3b3 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy
@@ -34,7 +34,7 @@ import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.client.aai.AAIObjectType
import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import org.onap.so.logger.MessageEnum
import org.slf4j.Logger
import org.slf4j.LoggerFactory
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy
index 1427730187..80e5831fbe 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy
@@ -29,7 +29,7 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy
index 29ee1a648e..117078992f 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy
@@ -32,7 +32,7 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.WorkflowException
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import org.onap.so.logger.MessageEnum
import org.slf4j.Logger
import org.slf4j.LoggerFactory
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy
index 404f19eca9..b029a4686b 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy
@@ -32,7 +32,7 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.WorkflowException
-import org.onap.so.logger.ErrorCode
+import org.onap.logging.filter.base.ErrorCode
import org.onap.so.logger.MessageEnum
import org.slf4j.Logger
import org.slf4j.LoggerFactory
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java
index fab3496559..3ea8b190ad 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java
@@ -35,8 +35,10 @@ public class ExecutionVariableNames {
public final static String TIMEOUT_FOR_NOTIFICATION = "timeoutForPnfEntryNotification";
public final static String PNF_UUID = "pnfUuid";
public final static String SERVICE_INSTANCE_ID = "serviceInstanceId";
+ public final static String REQUEST_ID = "requestId";
public final static String MSO_REQUEST_ID = "msoRequestId";
public final static String MODEL_UUID = "modelUuid";
+ public final static String REQUEST_PAYLOAD = "requestPayload";
public final static String SERVICE_MODEL_INFO = "serviceModelInfo";
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcher.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcher.java
new file mode 100644
index 0000000000..6c140061c0
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcher.java
@@ -0,0 +1,168 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.pnf.delegate;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.engine.delegate.JavaDelegate;
+import org.onap.aai.domain.yang.Pnf;
+import org.onap.so.bpmn.core.json.JsonUtils;
+import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.db.catalog.beans.PnfResourceCustomization;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.*;
+
+/**
+ * This implementation of {@link JavaDelegate} is used to populate the execution object for pnf software upgrade
+ */
+@Component
+public class NfSoftwareUpgradeDispatcher implements JavaDelegate {
+
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+ private static final String SERVICE_INSTANCE_NAME = "serviceInstanceName";
+ private static final String BPMN_REQUEST = "bpmnRequest";
+ private static final String RESOURCE_CUSTOMIZATION_UUID_PARAM = "resource_customization_uuid";
+ private static final String PNF_NAME = "pnfName";
+
+ // ERROR CODE for variable not found in the delegation Context
+ private static final int ERROR_CODE = 601;
+
+ @Autowired
+ private PnfManagement pnfManagement;
+
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+
+ @Autowired
+ private CatalogDbClient catalogDbClient;
+
+ @Autowired
+ private ObjectMapper mapper;
+
+ @Override
+ public void execute(DelegateExecution delegateExecution) throws Exception {
+ logger.debug("Running execute block for activity id: {}, name: {}", delegateExecution.getCurrentActivityId(),
+ delegateExecution.getCurrentActivityName());
+
+ RequestDetails bpmnRequestDetails = requestVerification(delegateExecution);
+
+ final String serviceInstanceName = bpmnRequestDetails.getRequestInfo().getInstanceName();
+ final String pnfName = bpmnRequestDetails.getRequestParameters().getUserParamValue(PNF_NAME);
+ final String serviceModelUuid = bpmnRequestDetails.getModelInfo().getModelUuid();
+ final List<Map<String, Object>> userParams = bpmnRequestDetails.getRequestParameters().getUserParams();
+ final Pnf pnf = getPnfByPnfName(delegateExecution, pnfName);
+ final List<PnfResourceCustomization> pnfCustomizations =
+ getPnfResourceCustomizations(delegateExecution, serviceModelUuid);
+ final PnfResourceCustomization pnfResourceCustomization = pnfCustomizations.get(0);
+ final String payload = bpmnRequestDetails.getRequestParameters().getPayload();
+
+ populateExecution(delegateExecution, bpmnRequestDetails, pnfResourceCustomization, pnf, serviceInstanceName,
+ pnfName, serviceModelUuid, userParams, payload);
+
+ logger.trace("Completed preProcessRequest PnfSoftwareUpgradeServiceRequest Request ");
+ }
+
+ private RequestDetails requestVerification(DelegateExecution delegateExecution) throws IOException {
+ RequestDetails bpmnRequestDetails = mapper.readValue(
+ JsonUtils.getJsonValue(String.valueOf(delegateExecution.getVariable(BPMN_REQUEST)), "requestDetails"),
+ RequestDetails.class);
+
+ throwIfNull(delegateExecution, bpmnRequestDetails.getModelInfo(), SERVICE_MODEL_INFO);
+ throwIfNull(delegateExecution, bpmnRequestDetails.getRequestInfo(), "RequestInfo");
+ throwIfNull(delegateExecution, bpmnRequestDetails.getRequestParameters(), "RequestParameters");
+ throwIfNull(delegateExecution, bpmnRequestDetails.getRequestParameters().getUserParams(), "UserParams");
+
+ return bpmnRequestDetails;
+ }
+
+ private void populateExecution(DelegateExecution delegateExecution, RequestDetails bpmnRequestDetails,
+ PnfResourceCustomization pnfResourceCustomization, Pnf pnf, String serviceInstanceName, String pnfName,
+ String serviceModelUuid, List<Map<String, Object>> userParams, String payload) {
+
+ delegateExecution.setVariable(SERVICE_MODEL_INFO, bpmnRequestDetails.getModelInfo());
+ delegateExecution.setVariable(SERVICE_INSTANCE_NAME, serviceInstanceName);
+ delegateExecution.setVariable(PNF_CORRELATION_ID, pnfName);
+ delegateExecution.setVariable(MODEL_UUID, serviceModelUuid);
+ delegateExecution.setVariable(PNF_UUID, pnf.getPnfId());
+ delegateExecution.setVariable(PRC_BLUEPRINT_NAME, pnfResourceCustomization.getBlueprintName());
+ delegateExecution.setVariable(PRC_BLUEPRINT_VERSION, pnfResourceCustomization.getBlueprintVersion());
+ delegateExecution.setVariable(PRC_CUSTOMIZATION_UUID, pnfResourceCustomization.getModelCustomizationUUID());
+ delegateExecution.setVariable(RESOURCE_CUSTOMIZATION_UUID_PARAM,
+ pnfResourceCustomization.getModelCustomizationUUID());
+ delegateExecution.setVariable(PRC_INSTANCE_NAME, pnfResourceCustomization.getModelInstanceName());
+ delegateExecution.setVariable(PRC_CONTROLLER_ACTOR, pnfResourceCustomization.getControllerActor());
+
+ for (Map<String, Object> param : userParams) {
+ if (param.containsKey("name") && param.containsKey("value")) {
+ delegateExecution.setVariable(param.get("name").toString(), param.get("value").toString());
+ }
+ }
+
+ delegateExecution.setVariable(REQUEST_PAYLOAD, payload);
+ }
+
+ private Pnf getPnfByPnfName(DelegateExecution delegateExecution, String pnfName) {
+ Optional<Pnf> pnfOptional = null;
+ try {
+ pnfOptional = pnfManagement.getEntryFor(pnfName);
+ } catch (IOException e) {
+ logger.warn(e.getMessage(), e);
+ exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ERROR_CODE,
+ "Unable to fetch from AAI" + e.getMessage());
+ }
+ if (pnfOptional == null || !pnfOptional.isPresent()) {
+ exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ERROR_CODE,
+ "AAI entry for PNF: " + pnfName + " does not exist");
+ }
+ return pnfOptional.get();
+ }
+
+ private List<PnfResourceCustomization> getPnfResourceCustomizations(DelegateExecution delegateExecution,
+ String serviceModelUuid) {
+ List<PnfResourceCustomization> pnfCustomizations =
+ catalogDbClient.getPnfResourceCustomizationByModelUuid(serviceModelUuid);
+
+ if (pnfCustomizations == null || pnfCustomizations.isEmpty()) {
+ logger.warn("Unable to find the PNF resource customizations of model service UUID: {}", serviceModelUuid);
+ exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ERROR_CODE,
+ "Unable to find the PNF resource customizations of model service UUID: " + serviceModelUuid);
+ }
+ return pnfCustomizations;
+ }
+
+ private void throwIfNull(DelegateExecution delegateExecution, Object obj, String param) {
+ if (obj == null) {
+ logger.warn("Unable to find the parameter: {} in the execution context", param);
+ exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ERROR_CODE,
+ "Unable to find parameter " + param);
+ }
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/UpdatePnfEntryInAai.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/UpdatePnfEntryInAai.java
new file mode 100644
index 0000000000..f85be8aab7
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/UpdatePnfEntryInAai.java
@@ -0,0 +1,65 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.bpmn.infrastructure.pnf.delegate;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.engine.delegate.JavaDelegate;
+import org.onap.aai.domain.yang.Pnf;
+import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import java.util.Optional;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID;
+import static org.onap.so.client.cds.PayloadConstants.PRC_TARGET_SOFTWARE_VERSION;
+
+
+@Component
+public class UpdatePnfEntryInAai implements JavaDelegate {
+
+ private final Logger logger = LoggerFactory.getLogger(UpdatePnfEntryInAai.class);
+
+ @Autowired
+ private PnfManagement pnfManagement;
+
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+
+ @Override
+ public void execute(DelegateExecution execution) throws Exception {
+ String pnfCorrelationId = String.valueOf(execution.getVariable(PNF_CORRELATION_ID));
+ Optional<Pnf> pnfAaiEntry = pnfManagement.getEntryFor(pnfCorrelationId);
+
+ if (!pnfAaiEntry.isPresent()) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 404,
+ "AAI entry for PNF: " + PNF_CORRELATION_ID + " does not exist");
+ }
+
+ Pnf pnf = pnfAaiEntry.get();
+ String pnfSoftwareVersion = String.valueOf(execution.getVariable(PRC_TARGET_SOFTWARE_VERSION));
+ pnf.setSwVersion(pnfSoftwareVersion);
+
+ pnfManagement.updateEntry(pnfCorrelationId, pnf);
+ logger.debug("AAI entry is updated for pnf correlation id: {}, pnf uuid: {} with swVersion: {}",
+ pnf.getPnfName(), pnfCorrelationId, pnfSoftwareVersion);
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagement.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagement.java
index 9e720fe0a4..46937d0d8c 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagement.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagement.java
@@ -30,5 +30,7 @@ public interface PnfManagement {
void createEntry(String pnfCorrelationId, Pnf entry) throws IOException;
+ void updateEntry(String pnfCorrelationId, Pnf entry) throws IOException;
+
void createRelation(String serviceInstanceId, String pnfName) throws IOException;
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java
index b1af8b1e0b..e6df8070a3 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java
@@ -44,6 +44,11 @@ public class PnfManagementImpl implements PnfManagement {
restClient.createPnf(pnfCorrelationId, entry);
}
+ public void updateEntry(String pnfCorrelationId, Pnf entry) {
+ AAIRestClientImpl restClient = new AAIRestClientImpl();
+ restClient.updatePnf(pnfCorrelationId, entry);
+ }
+
@Override
public void createRelation(String serviceInstanceId, String pnfName) {
AAIResourceUri serviceInstanceURI =
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java
index 7f2cd5c071..c63edc93c7 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java
@@ -22,12 +22,8 @@
package org.onap.so.bpmn.infrastructure.workflow.service;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
import java.io.IOException;
import java.io.InputStream;
-import java.net.SocketTimeoutException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -40,14 +36,12 @@ import java.util.Properties;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.ParseException;
-import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
@@ -69,13 +63,17 @@ import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.AAIResourcesClient;
import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.onap.so.client.aai.entities.Relationships;
+import org.onap.so.client.aai.entities.uri.AAIPluralResourceUri;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
-import org.onap.so.logger.ErrorCode;
+import org.onap.logging.filter.base.ErrorCode;
import org.onap.so.logger.MessageEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.util.UriUtils;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
public class ServicePluginFactory {
@@ -451,7 +449,7 @@ public class ServicePluginFactory {
public Map getTPsfromAAI(String serviceName) {
Map<String, Object> tpInfo = new HashMap<>();
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.LOGICAL_LINK);
+ AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.LOGICAL_LINK);
AAIResourcesClient client = new AAIResourcesClient();
Optional<LogicalLinks> result = client.get(LogicalLinks.class, uri);
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java
index f933277f3c..de8a35de06 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java
@@ -45,7 +45,7 @@ import org.onap.msb.sdk.httpclient.msb.MSBServiceClient;
import org.onap.so.bpmn.core.UrnPropertiesReader;
import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.GenericResourceApi;
import org.onap.so.db.request.beans.ResourceOperationStatus;
-import org.onap.so.logger.ErrorCode;
+import org.onap.logging.filter.base.ErrorCode;
import org.onap.so.logger.MessageEnum;
import org.onap.so.requestsdb.RequestsDbConstant;
import org.slf4j.Logger;
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationServiceTest.groovy
new file mode 100644
index 0000000000..3eefd31e63
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationServiceTest.groovy
@@ -0,0 +1,224 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2019, CMCC Technologies Co., Ltd.
+ #
+ # 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.impl.persistence.entity.ExecutionEntity
+import org.junit.Before
+import org.junit.Test
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
+import org.mockito.Mockito
+import org.onap.so.bpmn.common.scripts.MsoGroovyTest
+
+import static org.junit.Assert.assertEquals
+import static org.junit.Assert.assertNotNull
+import static org.mockito.ArgumentMatchers.eq
+import static org.mockito.Mockito.times
+import static org.mockito.Mockito.when
+
+class ActivateCommunicationServiceTest extends MsoGroovyTest {
+
+ @Before
+ void init() throws IOException {
+ super.init("ActivateCommunicationService")
+ }
+
+ @Captor
+ static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
+
+ @Test
+ void testPreProcessRequest() {
+
+ String req = """
+ {
+ "globalSubscriberId": "5GCustomer",
+ "serviceType": "5G",
+ "operationId": "test123"
+ }
+ """
+ when(mockExecution.getVariable("bpmnRequest")).thenReturn(req)
+ when(mockExecution.getVariable("mso-request-id")).thenReturn("54321")
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345")
+ when(mockExecution.getVariable("operationType")).thenReturn("activation")
+
+ ActivateCommunicationService service = new ActivateCommunicationService()
+ service.preProcessRequest(mockExecution)
+ Mockito.verify(mockExecution, times(6)).setVariable(captor.capture(), captor.capture())
+ }
+
+ @Test
+ void testPrepareInitOperationStatus() {
+
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345")
+ when(mockExecution.getVariable("operationId")).thenReturn("54321")
+
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("11111")
+
+ ActivateCommunicationService service = new ActivateCommunicationService()
+
+ service.prepareInitOperationStatus(mockExecution)
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("updateOperationStatus"), captor.capture())
+ String res = captor.getValue()
+ assertNotNull(res)
+ }
+
+
+ @Test
+ void testSendSyncResponse() {
+ when(mockExecution.getVariable("operationId")).thenReturn("123456")
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345")
+ ActivateCommunicationService service = new ActivateCommunicationService()
+ service.sendSyncResponse(mockExecution)
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("sentSyncResponse"), captor.capture())
+ def updateVolumeGroupRequest = captor.getValue()
+ assertEquals(updateVolumeGroupRequest, true)
+ }
+
+ @Test
+ void testPreRequestSend2NSMF() {
+ when(mockExecution.getVariable("e2e_service-instance.service-instance-id")).thenReturn("12333")
+ when(mockExecution.getVariable("requestParam")).thenReturn("activate")
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("test111")
+ when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("5GConsumer")
+ ActivateCommunicationService service = new ActivateCommunicationService()
+ service.preRequestSend2NSMF(mockExecution)
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("CSMF_NSMFRequest"), captor.capture())
+ String resultSuccess = captor.getValue()
+
+ String expect = """
+ {
+ "globalSubscriberId":"test111",
+ "serviceType":"5GConsumer"
+ }
+ """
+ assertEquals(expect.replaceAll("\\s+", ""), resultSuccess.replaceAll("\\s+", ""))
+ }
+
+ @Test
+ void testProcessNSMFResponseSuccess() {
+ when(mockExecution.getVariable("CSMF_NSMFResponseCode")).thenReturn(202)
+ when(mockExecution.getVariable("CSMF_NSMFResponse")).thenReturn("""
+ {
+ "operationId": "e3819a23-3777-4172-a834-35ee78acf3f4"
+ }
+ """)
+
+ ActivateCommunicationService service = new ActivateCommunicationService()
+ service.processNSMFResponse(mockExecution)
+ Mockito.verify(mockExecution, times(2)).setVariable(captor.capture(), captor.capture())
+ def resultSuccess = captor.getAllValues()
+
+ def expect = new ArrayList<>()
+ expect.add("e2eOperationId")
+ expect.add("e3819a23-3777-4172-a834-35ee78acf3f4")
+ expect.add("ProcessNsmfSuccess")
+ expect.add("OK")
+ assertEquals(expect, resultSuccess)
+ }
+
+ @Test
+ void testProcessNSMFResponseError() {
+ when(mockExecution.getVariable("CSMF_NSMFResponseCode")).thenReturn(500)
+ ActivateCommunicationService service = new ActivateCommunicationService()
+ service.processNSMFResponse(mockExecution)
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("ProcessNsmfSuccess"), captor.capture())
+ String resultSuccess = captor.getValue()
+ assertEquals("ERROR", resultSuccess)
+ }
+
+ @Test
+ void testPrepareUpdateOperationStatus() {
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345")
+ when(mockExecution.getVariable("operationId")).thenReturn("54321")
+ when(mockExecution.getVariable("operationType")).thenReturn("activate")
+
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("11111")
+ when(mockExecution.getVariable("mso.adapters.openecomp.db.endpoint"))
+ .thenReturn("http://localhost:28090/dbadapters/RequestsDbAdapter")
+ ActivateCommunicationService service = new ActivateCommunicationService()
+
+ service.prepareUpdateOperationStatus(mockExecution)
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("updateOperationStatus"), captor.capture())
+ String res = captor.getValue()
+
+ String expect = getExpectPayload("updateServiceOperationStatus", "processing", "20",
+ "communication service activate operation processing: waiting nsmf service create finished")
+
+ assertEquals(expect.replaceAll("\\s+", ""), res.replaceAll("\\s+", ""))
+ }
+
+ private static getExpectPayload = { String type, String result, String progress, String operationContent ->
+ String expect =
+ """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:ns="http://org.onap.so/requestsdb">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <ns:${type} xmlns:ns="http://org.onap.so/requestsdb">
+ <serviceId>12345</serviceId>
+ <operationId>54321</operationId>
+ <operationType>activate</operationType>
+ <userId>11111</userId>
+ <result>${result}</result>
+ <operationContent>${operationContent}</operationContent>
+ <progress>${progress}</progress>
+ <reason></reason>
+ </ns:${type}>
+ </soapenv:Body>
+ </soapenv:Envelope>
+ """
+ return expect
+ }
+
+ @Test
+ void testPrepareCallCheckProcessStatus() {
+ ActivateCommunicationService service = new ActivateCommunicationService()
+ service.prepareCallCheckProcessStatus(mockExecution)
+ Mockito.verify(mockExecution, times(9)).setVariable(captor.capture(), captor.capture())
+ def resultSuccess = captor.getAllValues()
+ assertNotNull(resultSuccess)
+ }
+
+ @Test
+ void testPrepareCompleteStatus() {
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345")
+ when(mockExecution.getVariable("operationId")).thenReturn("54321")
+ when(mockExecution.getVariable("operationType")).thenReturn("activate")
+ when(mockExecution.getVariable("operationContent"))
+ .thenReturn("communication service activate operation finished")
+
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("11111")
+ when(mockExecution.getVariable("operationStatus"))
+ .thenReturn("deactivated")
+ ActivateCommunicationService service = new ActivateCommunicationService()
+
+ service.prepareCompleteStatus(mockExecution)
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("updateOperationStatus"), captor.capture())
+ String res = captor.getValue()
+
+ String expect = getExpectPayload("updateServiceOperationStatus", "deactivated", "100",
+ "communication service activate operation finished")
+
+ assertEquals(expect.replaceAll("\\s+", ""), res.replaceAll("\\s+", ""))
+ }
+
+}
+
+
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceServiceTest.groovy
new file mode 100644
index 0000000000..f3c61dd628
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceServiceTest.groovy
@@ -0,0 +1,118 @@
+package org.onap.so.bpmn.infrastructure.scripts
+
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.junit.Before
+import org.junit.Test
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
+import org.mockito.Mockito
+import org.onap.so.bpmn.common.scripts.MsoGroovyTest
+
+import static org.junit.Assert.assertEquals
+import static org.junit.Assert.assertNotNull
+import static org.mockito.ArgumentMatchers.eq
+import static org.mockito.Mockito.times
+import static org.mockito.Mockito.when
+
+class ActivateSliceServiceTest extends MsoGroovyTest {
+ @Before
+ void init() throws IOException {
+ super.init("ActivateSliceService")
+ }
+
+ @Captor
+ static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
+
+ @Test
+ void testPreProcessRequest() {
+
+ String req = """
+ {
+ "globalSubscriberId": "5GCustomer",
+ "serviceType": "5G",
+ "operationId": "test123"
+ }
+ """
+ when(mockExecution.getVariable("bpmnRequest")).thenReturn(req)
+ when(mockExecution.getVariable("mso-request-id")).thenReturn("54321")
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345")
+ when(mockExecution.getVariable("operationType")).thenReturn("activation")
+
+
+ ActivateSliceService service = new ActivateSliceService()
+ service.preProcessRequest(mockExecution)
+ Mockito.verify(mockExecution, times(7)).setVariable(captor.capture(), captor.capture())
+ }
+
+ @Test
+ void testPrepareInitOperationStatus() {
+
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345")
+ when(mockExecution.getVariable("operationId")).thenReturn("54321")
+
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("11111")
+
+ ActivateSliceService service = new ActivateSliceService()
+
+ service.prepareInitServiceOperationStatus(mockExecution)
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("updateOperationStatus"), captor.capture())
+ String res = captor.getValue()
+ assertNotNull(res)
+ }
+
+ @Test
+ void testSendSyncResponse() {
+ when(mockExecution.getVariable("operationId")).thenReturn("123456")
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345")
+ ActivateSliceService service = new ActivateSliceService()
+ service.sendSyncResponse(mockExecution)
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("sentSyncResponse"), captor.capture())
+ def updateVolumeGroupRequest = captor.getValue()
+ assertEquals(updateVolumeGroupRequest, true)
+ }
+
+ private static getExpectPayload = { String type, String result, String progress, String operationContent ->
+ String expect =
+ """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:ns="http://org.onap.so/requestsdb">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <ns:${type} xmlns:ns="http://org.onap.so/requestsdb">
+ <serviceId>12345</serviceId>
+ <operationId>54321</operationId>
+ <operationType>activate</operationType>
+ <userId>11111</userId>
+ <result>${result}</result>
+ <operationContent>${operationContent}</operationContent>
+ <progress>${progress}</progress>
+ <reason></reason>
+ </ns:${type}>
+ </soapenv:Body>
+ </soapenv:Envelope>
+ """
+ return expect
+ }
+
+ @Test
+ void testPrepareCompleteStatus() {
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345")
+ when(mockExecution.getVariable("operationId")).thenReturn("54321")
+ when(mockExecution.getVariable("operationType")).thenReturn("activate")
+ when(mockExecution.getVariable("operationContent"))
+ .thenReturn("slice service activate operation finished")
+
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("11111")
+ when(mockExecution.getVariable("operationStatus"))
+ .thenReturn("deactivated")
+ ActivateSliceService service = new ActivateSliceService()
+
+ service.prepareCompletionRequest(mockExecution)
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("updateOperationStatus"), captor.capture())
+ String res = captor.getValue()
+
+ String expect = getExpectPayload("updateServiceOperationStatus", "finished", "100",
+ "slice service activate operation finished")
+
+ assertEquals(expect.replaceAll("\\s+", ""), res.replaceAll("\\s+", ""))
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CheckServiceProcessStatusTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CheckServiceProcessStatusTest.groovy
new file mode 100644
index 0000000000..f066f9e878
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CheckServiceProcessStatusTest.groovy
@@ -0,0 +1,344 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2019, CMCC Technologies Co., Ltd.
+ #
+ # 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.impl.persistence.entity.ExecutionEntity
+import org.junit.Before
+import org.junit.Test
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
+import org.mockito.Mockito
+import org.onap.so.bpmn.common.scripts.MsoGroovyTest
+
+import static org.junit.Assert.assertEquals
+import static org.mockito.ArgumentMatchers.eq
+import static org.mockito.Mockito.times
+import static org.mockito.Mockito.when
+
+class CheckServiceProcessStatusTest extends MsoGroovyTest {
+ @Before
+ void init() throws IOException {
+ super.init("CheckServiceProcessStatus")
+ }
+
+ @Captor
+ static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
+
+
+ @Test
+ void testPreProcessRequest () {
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345")
+ when(mockExecution.getVariable("operationId")).thenReturn("54321")
+
+ def successConditions = new ArrayList<>()
+ successConditions.add("finished")
+ successConditions.add("completed")
+
+ def errorConditions = new ArrayList<>()
+ errorConditions.add("error")
+ errorConditions.add("failed")
+
+ when(mockExecution.getVariable("successConditions")).thenReturn(successConditions)
+ when(mockExecution.getVariable("errorConditions")).thenReturn(errorConditions)
+
+
+ CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus()
+ serviceProcessStatus.preProcessRequest(mockExecution)
+ Mockito.verify(mockExecution, times(9)).setVariable(captor.capture(), captor.capture())
+ }
+
+
+ @Test
+ void testPreCheckServiceStatusReq() {
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345")
+ when(mockExecution.getVariable("operationId")).thenReturn("54321")
+
+ CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus()
+
+ serviceProcessStatus.preCheckServiceStatusReq(mockExecution)
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("getOperationStatus"), captor.capture())
+ String res = captor.getValue()
+ String expect =
+ """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:ns="http://org.onap.so/requestsdb">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <ns:getServiceOperationStatus xmlns:ns="http://org.onap.so/requestsdb">
+ <serviceId>12345</serviceId>
+ <operationId>54321</operationId>
+ </ns:getServiceOperationStatus>
+ </soapenv:Body>
+ </soapenv:Envelope>
+ """
+ assertEquals(expect.replaceAll("\\s+", ""), res.replaceAll("\\s+", ""))
+ }
+
+
+ @Test
+ void testHandlerServiceStatusRespSuccess() {
+ mockData()
+ when(mockExecution.getVariable("dbResponseCode")).thenReturn(200)
+ when(mockExecution.getVariable("dbResponse")).thenReturn(getDBResponse("finished"))
+ def successConditions = new ArrayList<>()
+ successConditions.add("finished")
+ successConditions.add("completed")
+
+ when(mockExecution.getVariable("successConditions")).thenReturn(successConditions)
+
+ CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus()
+ serviceProcessStatus.handlerServiceStatusResp(mockExecution)
+
+ Mockito.verify(mockExecution, times(4)).setVariable(captor.capture(), captor.capture())
+ def resultSuccess = captor.getAllValues()
+
+ def expect = new ArrayList<>()
+ expect.add("operationStatus")
+ expect.add("finished")
+ expect.add("operationContent")
+ expect.add("communication service create operation finished success")
+ expect.add("orchestrationStatus")
+ expect.add("deactivated")
+ expect.add("isAllFinished")
+ expect.add("true")
+
+ assertEquals(expect, resultSuccess)
+ }
+
+
+ @Test
+ void testHandlerServiceStatusRespError() {
+ mockData()
+ when(mockExecution.getVariable("dbResponseCode")).thenReturn(200)
+ when(mockExecution.getVariable("dbResponse")).thenReturn(getDBResponse("error"))
+
+ def successConditions = new ArrayList<>()
+ successConditions.add("finished")
+ successConditions.add("completed")
+
+ def errorConditions = new ArrayList<>()
+ errorConditions.add("error")
+ errorConditions.add("failed")
+
+ when(mockExecution.getVariable("successConditions")).thenReturn(successConditions)
+ when(mockExecution.getVariable("errorConditions")).thenReturn(errorConditions)
+
+ CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus()
+ serviceProcessStatus.handlerServiceStatusResp(mockExecution)
+
+ Mockito.verify(mockExecution, times(4)).setVariable(captor.capture(), captor.capture())
+ def resultSuccess = captor.getAllValues()
+
+ def expect = new ArrayList<>()
+ expect.add("operationStatus")
+ expect.add("error")
+ expect.add("operationContent")
+ expect.add("communication service create operation finished with error")
+ expect.add("orchestrationStatus")
+ expect.add("error")
+ expect.add("isAllFinished")
+ expect.add("true")
+
+ assertEquals(expect, resultSuccess)
+ }
+
+
+ @Test
+ void testHandlerServiceStatusRespProcessingNo() {
+ mockData()
+ when(mockExecution.getVariable("dbResponseCode")).thenReturn(200)
+ when(mockExecution.getVariable("dbResponse")).thenReturn(getDBResponse("processing"))
+ when(mockExecution.getVariable("progress")).thenReturn(50)
+
+ def successConditions = new ArrayList<>()
+ successConditions.add("finished")
+ successConditions.add("completed")
+
+ def errorConditions = new ArrayList<>()
+ errorConditions.add("error")
+ errorConditions.add("failed")
+
+ when(mockExecution.getVariable("successConditions")).thenReturn(successConditions)
+ when(mockExecution.getVariable("errorConditions")).thenReturn(errorConditions)
+
+ CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus()
+ serviceProcessStatus.handlerServiceStatusResp(mockExecution)
+
+ Mockito.verify(mockExecution, times(2)).setVariable(captor.capture(), captor.capture())
+ def resultSuccess = captor.getAllValues()
+
+ def expect = new ArrayList<>()
+ expect.add("isNeedUpdateDB")
+ expect.add("false")
+ expect.add("isAllFinished")
+ expect.add("false")
+
+ assertEquals(expect as String, resultSuccess as String)
+ }
+
+
+ @Test
+ void testHandlerServiceStatusRespProcessingYes() {
+ mockData()
+ when(mockExecution.getVariable("dbResponseCode")).thenReturn(200)
+ when(mockExecution.getVariable("dbResponse")).thenReturn(getDBResponse("processing"))
+ when(mockExecution.getVariable("progress")).thenReturn(60)
+
+ def successConditions = new ArrayList<>()
+ successConditions.add("finished")
+ successConditions.add("completed")
+
+ def errorConditions = new ArrayList<>()
+ errorConditions.add("error")
+ errorConditions.add("failed")
+
+ when(mockExecution.getVariable("successConditions")).thenReturn(successConditions)
+ when(mockExecution.getVariable("errorConditions")).thenReturn(errorConditions)
+
+ CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus()
+ serviceProcessStatus.handlerServiceStatusResp(mockExecution)
+
+ Mockito.verify(mockExecution, times(3)).setVariable(captor.capture(), captor.capture())
+ def resultSuccess = captor.getAllValues()
+
+ def expect = new ArrayList<>()
+ expect.add("progress")
+ expect.add("50")
+ expect.add("isNeedUpdateDB")
+ expect.add("true")
+ expect.add("isAllFinished")
+ expect.add("false")
+
+ assertEquals(expect as String, resultSuccess as String)
+ }
+
+
+ @Test
+ void testTimeWaitDelayNo() {
+ mockData()
+ when(mockExecution.getVariable("startTime")).thenReturn(System.currentTimeMillis())
+ CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus()
+
+ serviceProcessStatus.timeWaitDelay(mockExecution)
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("isTimeOut"), captor.capture())
+ def res = captor.getValue()
+
+ assertEquals("NO", res)
+ }
+
+
+ @Test
+ void testTimeWaitDelayYes() {
+ mockData()
+ when(mockExecution.getVariable("startTime")).thenReturn(1000000)
+ CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus()
+
+ serviceProcessStatus.timeWaitDelay(mockExecution)
+ Mockito.verify(mockExecution, times(4)).setVariable(captor.capture(), captor.capture())
+ def res = captor.getAllValues()
+ def expect = new ArrayList<>()
+ expect.add("operationStatus")
+ expect.add("error")
+ expect.add("operationContent")
+ expect.add("communication service create operation finished with timeout")
+ expect.add("orchestrationStatus")
+ expect.add("error")
+ expect.add("isTimeOut")
+ expect.add("YES")
+
+ assertEquals(expect, res)
+ }
+
+
+ @Test
+ void testPreUpdateOperationProgress() {
+ mockData()
+ when(mockExecution.getVariable("progress")).thenReturn(50)
+ when(mockExecution.getVariable("initProgress")).thenReturn(20)
+ when(mockExecution.getVariable("endProgress")).thenReturn(90)
+ when(mockExecution.getVariable("operationType")).thenReturn("CREATE")
+ when(mockExecution.getVariable("processServiceType")).thenReturn("communication service")
+ when(mockExecution.getVariable("parentServiceInstanceId")).thenReturn("12345")
+ when(mockExecution.getVariable("parentOperationId")).thenReturn("54321")
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("11111")
+
+ CheckServiceProcessStatus serviceProcessStatus = new CheckServiceProcessStatus()
+ serviceProcessStatus.preUpdateOperationProgress(mockExecution)
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("updateOperationStatus"), captor.capture())
+ String res = captor.getValue()
+
+ String expect = getExpectPayload("55",
+ "communication service CREATE operation processing 55")
+
+ assertEquals(expect.replaceAll("\\s+", ""), res.replaceAll("\\s+", ""))
+
+
+ }
+
+
+ private static String getExpectPayload(String progress, String operationContent) {
+ String expect =
+ """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:ns="http://org.onap.so/requestsdb">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <ns:updateServiceOperationStatus xmlns:ns="http://org.onap.so/requestsdb">
+ <serviceId>12345</serviceId>
+ <operationId>54321</operationId>
+ <operationType>CREATE</operationType>
+ <userId>11111</userId>
+ <result>processing</result>
+ <operationContent>${operationContent}</operationContent>
+ <progress>${progress}</progress>
+ <reason></reason>
+ </ns:updateServiceOperationStatus>
+ </soapenv:Body>
+ </soapenv:Envelope>
+ """
+ return expect
+ }
+
+
+ private static String getDBResponse(String result) {
+ String response =
+ """<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Body>
+ <ns2:getServiceOperationStatusResponse xmlns:ns2="http://org.onap.so/requestsdb">
+ <return><operation>CREATE</operation>
+ <operationContent>Prepare service creation</operationContent>
+ <operationId>077995e3-eb32-44ae-b35d-491fc6983a44</operationId>
+ <progress>50</progress>
+ <reason></reason>
+ <result>${result}</result>
+ <serviceId>3324f117-696d-4518-b8b5-b01fcc127a03</serviceId>
+ <userId>5GCustomer</userId>
+ </return></ns2:getServiceOperationStatusResponse>
+ </soap:Body>
+ </soap:Envelope>
+ """
+ return response
+ }
+
+
+ private mockData() {
+ when(mockExecution.getVariable("processServiceType")).thenReturn("communication service")
+ when(mockExecution.getVariable("operationType")).thenReturn("create")
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationServiceTest.groovy
new file mode 100644
index 0000000000..3622cc0062
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationServiceTest.groovy
@@ -0,0 +1,456 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2019, CMCC Technologies Co., Ltd.
+ #
+ # 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.impl.persistence.entity.ExecutionEntity
+import org.json.JSONObject
+import org.junit.Before
+import org.junit.Test
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
+import org.mockito.Mockito
+import org.onap.so.bpmn.common.scripts.MsoGroovyTest
+import org.onap.so.bpmn.core.domain.ModelInfo
+import org.onap.so.bpmn.core.domain.ServiceDecomposition
+import org.onap.so.bpmn.core.domain.ServiceInfo
+import org.onap.so.bpmn.core.domain.ServiceProxy
+
+import static org.junit.Assert.assertEquals
+import static org.junit.Assert.assertNotNull
+import static org.mockito.ArgumentMatchers.eq
+import static org.mockito.Mockito.times
+import static org.mockito.Mockito.when
+
+class CreateCommunicationServiceTest extends MsoGroovyTest {
+
+ @Before
+ void init() throws IOException {
+ super.init("CreateCommunicationService")
+ }
+
+ @Captor
+ static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
+
+ @Test
+ void testPreProcessRequest() {
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345")
+ when(mockExecution.getVariable("bpmnRequest")).thenReturn("""
+ {
+ "requestDetails": {
+ "modelInfo": {
+ "modelInvariantId": "e75698d9-925a-4cdd-a6c0-edacbe6a0b51",
+ "modelType": "service",
+ "modelNameVersionId": "8ee5926d-720b-4bb2-86f9-d20e921c143b",
+ "modelName": "voLTE",
+ "modelVersion": "1.0",
+ "modelVersionId": "8ee5926d-720b-4bb2-86f9-d20e921c143b",
+ "modelUuid": "8ee5926d-720b-4bb2-86f9-d20e921c143b",
+ "modelInvariantUuid": "e75698d9-925a-4cdd-a6c0-edacbe6a0b51"
+ },
+ "requestInfo": {
+ "source": "UUI",
+ "instanceName": "CSMFService",
+ "suppressRollback": true
+ },
+ "subscriberInfo": {
+ "globalSubscriberId": "5GCustomer"
+ },
+ "requestParameters": {
+ "subscriptionServiceType": "MOG",
+ "userParams": [{
+ "ServiceInstanceName": "CSMFService",
+ "UUIRequest": "{\\r\\n \\
+ "service\\":{\\r\\n \\"name\\":\\"CSMFService\\",\\r\\n
+ \\"description\\":\\"CSMFService\\",\\r\\n
+ \\"serviceInvariantUuid\\":\\"e75698d9-925a-4cdd-a6c0-edacbe6a0b51\\",\\r\\n
+ \\"serviceUuid\\":\\"8ee5926d-720b-4bb2-86f9-d20e921c143b\\",\\r\\n
+ \\"globalSubscriberId\\":\\"5GCustomer\\",\\r\\n
+ \\"serviceType\\":\\"5G\\",\\r\\n
+ \\"parameters\\":{\\r\\n
+ \\"requestInputs\\":{\\r\\n
+ \\"expDataRateDL\\":10,\\r\\n
+ \\"expDataRateUL\\":30,\\r\\n
+ \\"latency\\":20,\\r\\n
+ \\"maxNumberofUEs\\":300,\\r\\n
+ \\"uemobilityLevel\\":\\"stationary\\",\\r\\n
+ \\"resourceSharingLevel\\":\\"shared\\",\\r\\n
+ \\"coverageAreaList\\": \\"01001\\",\\r\\n
+ \\"useInterval\\":\\"3\\"\\r\\n
+ }\\r\\n
+ }\\r\\n }\\r\\n}\\r\\n"
+ }],
+ "aLaCarte": true,
+ "usePreload": true
+ }
+ },
+ "serviceInstanceId": null,
+ "vnfInstanceId": null,
+ "networkInstanceId": null,
+ "volumeGroupInstanceId": null,
+ "vfModuleInstanceId": null,
+ "configurationId": null,
+ "instanceGroupId": null
+ }""".replaceAll("\\s+", ""))
+ when(mockExecution.getVariable("mso-request-id")).thenReturn("edb08d97-e0f9-4c71-840a-72080d7be42e")
+ CreateCommunicationService communicationService = new CreateCommunicationService()
+ communicationService.preProcessRequest(mockExecution)
+ Mockito.verify(mockExecution, times(14)).setVariable(captor.capture() as String, captor.capture())
+ List<ExecutionEntity> values = captor.getAllValues()
+ assertNotNull(values)
+ }
+
+ @Test
+ void testPrepareInitOperationStatus() {
+
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345")
+ when(mockExecution.getVariable("operationId")).thenReturn("54321")
+
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("11111")
+
+ CreateCommunicationService communicationService = new CreateCommunicationService()
+
+ communicationService.prepareInitOperationStatus(mockExecution)
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("updateOperationStatus"), captor.capture())
+ String res = captor.getValue()
+ assertNotNull(res)
+ }
+
+
+ @Test
+ void testSendSyncResponse() {
+ when(mockExecution.getVariable("operationId")).thenReturn("123456")
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345")
+ CreateCommunicationService communicationService = new CreateCommunicationService()
+ communicationService.sendSyncResponse(mockExecution)
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("sentSyncResponse"), captor.capture())
+ def updateVolumeGroupRequest = captor.getValue()
+ assertEquals(updateVolumeGroupRequest, true)
+ }
+
+
+ @Test
+ void testPrepareDoComposeE2E() {
+ ServiceDecomposition serviceDecomposition = new ServiceDecomposition()
+ ServiceProxy serviceProxy = new ServiceProxy()
+ serviceProxy.setSourceModelUuid("f2f5967e-72d3-4c5c-b880-e214e71dba4e")
+ serviceDecomposition.setServiceProxy(Arrays.asList(serviceProxy))
+ when(mockExecution.getVariable("csServiceDecomposition")).thenReturn(serviceDecomposition)
+ CreateCommunicationService communicationService = new CreateCommunicationService()
+ communicationService.prepareDoComposeE2E(mockExecution)
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("e2eServiceModelInfo"), captor.capture())
+ String e2eServiceModelInfo = captor.getValue()
+ assertEquals(e2eServiceModelInfo.trim().replaceAll(" ", ""),
+ """{"modelUuid":"f2f5967e-72d3-4c5c-b880-e214e71dba4e"}""")
+ }
+
+ @Test
+ void testParseCSParamsFromReq() {
+ mockData()
+ when(mockExecution.getVariable("csServiceModelInfo")).thenReturn("""
+ {
+ "modelInvariantUuid":"e75698d9-925a-4cdd-a6c0-edacbe6a0b51",
+ "modelName":"voLTE",
+ "modelNameVersionId":"8ee5926d-720b-4bb2-86f9-d20e921c143b",
+ "modelVersion":"1.0",
+ "modelVersionId":"8ee5926d-720b-4bb2-86f9-d20e921c143b",
+ "modelInvariantId":"e75698d9-925a-4cdd-a6c0-edacbe6a0b51",
+ "modelType":"service",
+ "modelUuid":"8ee5926d-720b-4bb2-86f9-d20e921c143b"
+ }""")
+
+ ServiceDecomposition decomposition = new ServiceDecomposition()
+ decomposition.setServiceType("embb")
+ ServiceInfo serviceInfo = new ServiceInfo()
+ serviceInfo.setServiceProperties("""
+ [{"name":"useInterval","type":"string","required":false},
+ {"default":"39-00","name":"plmnIdList","type":"string","required":false},
+ {"name":"maxNumberofUEs","type":"integer","required":false},
+ {"name":"latency","type":"integer","required":false},
+ {"name":"uEMobilityLevel","type":"string","required":false},
+ {"name":"expDataRateUL","type":"integer","required":false},
+ {"name":"expDataRateDL","type":"integer","required":false},
+ {"name":"coverageAreaList","type":"string","required":false},
+ {"name":"sNSSAI","type":"string","required":false},
+ {"name":"resourceSharingLevel","type":"string","required":false}]
+ """)
+ decomposition.setServiceInfo(serviceInfo)
+
+ when(mockExecution.getVariable("csServiceDecomposition")).thenReturn(decomposition)
+
+ CreateCommunicationService communicationService = new CreateCommunicationService()
+ communicationService.parseCSParamsFromReq(mockExecution)
+
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("csInputMap"), captor.capture())
+ def csInputMap = captor.getValue()
+ assertEquals(getExpectCsInputMap(), csInputMap)
+
+ }
+
+ private static Map<String, Object> getExpectCsInputMap() {
+ Map<String, Object> csInputMap = new HashMap<>()
+ csInputMap.put("expDataRateDL", 10)
+ csInputMap.put("expDataRateUL", 30)
+ csInputMap.put("latency", 20)
+ csInputMap.put("maxNumberofUEs", 300)
+ csInputMap.put("uEMobilityLevel", "stationary")
+ csInputMap.put("resourceSharingLevel", "shared")
+ csInputMap.put("coverageAreaTAList", "01001")
+ csInputMap.put("useInterval", "3")
+ csInputMap.put("coverageAreaList", null)
+ csInputMap.put("plmnIdList", "39-00")
+ csInputMap.put("sNSSAI", null)
+ return csInputMap
+ }
+
+ @Test
+ void testGenerateE2EServiceProfile() {
+ ServiceDecomposition decomposition = new ServiceDecomposition()
+ decomposition.setServiceType("embb")
+ ServiceInfo serviceInfo = new ServiceInfo()
+ serviceInfo.setServiceProperties("""
+ [{"name":"nstar0_allottedresource0_providing_service_uuid","type":"string","required":true},
+ {"name":"areaTrafficCapDL","type":"integer","required":false},
+ {"name":"maxNumberofUEs","type":"integer","required":false},
+ {"name":"latency","type":"integer","required":false},
+ {"name":"expDataRateUL","type":"integer","required":false},
+ {"name":"sNSSAI","type":"string","required":false},
+ {"name":"plmnIdList","type":"string","required":false},
+ {"name":"sST","type":"integer","required":false},
+ {"name":"areaTrafficCapUL","type":"integer","required":false},
+ {"name":"uEMobilityLevel","type":"string","required":false},
+ {"name":"expDataRateDL","type":"integer","required":false},
+ {"name":"nstar0_allottedresource0_providing_service_invariant_uuid","type":"string","required":true},
+ {"name":"coverageAreaTAList","type":"string","required":false},
+ {"name":"activityFactor","type":"integer","required":false},
+ {"name":"resourceSharingLevel","type":"string","required":false}]
+ """)
+ decomposition.setServiceInfo(serviceInfo)
+
+ ModelInfo modelInfo = new ModelInfo()
+ modelInfo.setModelInvariantUuid("e75698d9-925a-4cdd-a6c0-edacbe6a0b51")
+ modelInfo.setModelUuid("8ee5926d-720b-4bb2-86f9-d20e921c143b")
+ decomposition.setModelInfo(modelInfo)
+
+ when(mockExecution.getVariable("e2eServiceDecomposition")).thenReturn(decomposition)
+ when(mockExecution.getVariable("csInputMap")).thenReturn(getExpectCsInputMap())
+
+ CreateCommunicationService communicationService = new CreateCommunicationService()
+ communicationService.generateE2EServiceProfile(mockExecution)
+
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("e2eInputMap"), captor.capture())
+ def csInputMap = captor.getValue()
+ assertEquals(csInputMap, getExpectE2eInputMap())
+ }
+
+ private static Map<String, Object> getExpectE2eInputMap() {
+ Map<String, Object> e2eInputMap = new HashMap<>()
+ e2eInputMap.put("nstar0_allottedresource0_providing_service_uuid", null)
+ e2eInputMap.put("nstar0_allottedresource0_providing_service_invariant_uuid", null)
+ e2eInputMap.put("areaTrafficCapDL", 100)
+ e2eInputMap.put("areaTrafficCapUL", 100)
+ e2eInputMap.put("expDataRateDL", 10)
+ e2eInputMap.put("expDataRateUL", 30)
+ e2eInputMap.put("latency", 20)
+ e2eInputMap.put("maxNumberofUEs", 300)
+ e2eInputMap.put("uEMobilityLevel", "stationary")
+ e2eInputMap.put("resourceSharingLevel", "shared")
+ e2eInputMap.put("coverageAreaTAList", "01001")
+ e2eInputMap.put("sST", null)
+ e2eInputMap.put("activityFactor", 0)
+ e2eInputMap.put("plmnIdList", "39-00")
+ e2eInputMap.put("sNSSAI", null)
+
+ return e2eInputMap
+ }
+
+ @Test
+ void testPreRequestSend2NSMF() {
+ when(mockExecution.getVariable("e2eInputMap")).thenReturn(getExpectE2eInputMap())
+ when(mockExecution.getVariable("csServiceName")).thenReturn("testName")
+ when(mockExecution.getVariable("modelUuid")).thenReturn("12345")
+ when(mockExecution.getVariable("e2eModelInvariantUuid")).thenReturn("54321")
+ when(mockExecution.getVariable("e2eModelUuid")).thenReturn("11111")
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("test111")
+ when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("5GConsumer")
+ CreateCommunicationService communicationService = new CreateCommunicationService()
+ communicationService.preRequestSend2NSMF(mockExecution)
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("CSMF_NSMFRequest"), captor.capture())
+ String resultSuccess = captor.getValue()
+
+ def expectMap = getExpectE2eInputMap()
+ expectMap.put("nstar0_allottedresource0_providing_service_uuid", null)
+ expectMap.put("nstar0_allottedresource0_providing_service_invariant_uuid", null)
+
+ String expect = """
+ {
+ "service":{
+ "name": "testName",
+ "description": "e2eService of 12345",
+ "serviceInvariantUuid": "54321",
+ "serviceUuid": "11111",
+ "globalSubscriberId": "test111",
+ "serviceType": "5GConsumer",
+ "parameters":{
+ "requestInputs": ${expectMap as JSONObject}
+ }
+ }
+ }
+ """
+ assertEquals(expect.replaceAll("\\s+", ""), resultSuccess.replaceAll("\\s+", ""))
+ }
+
+ @Test
+ void testProcessNSMFResponseSuccess() {
+ when(mockExecution.getVariable("CSMF_NSMFResponseCode")).thenReturn(202)
+ when(mockExecution.getVariable("CSMF_NSMFResponse")).thenReturn("""
+ {
+ "service": {
+ "serviceId": "945063ff-1a01-4944-9232-8e7999e0d5e4",
+ "operationId": "e3819a23-3777-4172-a834-35ee78acf3f4"
+ }
+ }
+ """)
+
+ CreateCommunicationService communicationService = new CreateCommunicationService()
+ communicationService.processNSMFResponse(mockExecution)
+ Mockito.verify(mockExecution, times(3)).setVariable(captor.capture(), captor.capture())
+ def resultSuccess = captor.getAllValues()
+
+ def expect = new ArrayList<>()
+ expect.add("e2eServiceInstanceId")
+ expect.add("945063ff-1a01-4944-9232-8e7999e0d5e4")
+ expect.add("e2eOperationId")
+ expect.add("e3819a23-3777-4172-a834-35ee78acf3f4")
+ expect.add("ProcessNsmfSuccess")
+ expect.add("OK")
+ assertEquals(expect, resultSuccess)
+ }
+
+ @Test
+ void testProcessNSMFResponseError() {
+ when(mockExecution.getVariable("CSMF_NSMFResponseCode")).thenReturn(500)
+ CreateCommunicationService communicationService = new CreateCommunicationService()
+ communicationService.processNSMFResponse(mockExecution)
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("ProcessNsmfSuccess"), captor.capture())
+ String resultSuccess = captor.getValue()
+ assertEquals("ERROR", resultSuccess)
+ }
+
+ @Test
+ void testPrepareUpdateOperationStatus() {
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345")
+ when(mockExecution.getVariable("operationId")).thenReturn("54321")
+
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("11111")
+ when(mockExecution.getVariable("mso.adapters.openecomp.db.endpoint"))
+ .thenReturn("http://localhost:28090/dbadapters/RequestsDbAdapter")
+ CreateCommunicationService communicationService = new CreateCommunicationService()
+
+ communicationService.prepareUpdateOperationStatus(mockExecution)
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("updateOperationStatus"), captor.capture())
+ String res = captor.getValue()
+
+ String expect = getExpectPayload("updateServiceOperationStatus", "processing", "20",
+ "communication service create operation processing: waiting nsmf service create finished")
+
+ assertEquals(expect.replaceAll("\\s+", ""), res.replaceAll("\\s+", ""))
+ }
+
+
+ @Test
+ void testPrepareCallCheckProcessStatus() {
+ CreateCommunicationService communicationService = new CreateCommunicationService()
+ communicationService.prepareCallCheckProcessStatus(mockExecution)
+ Mockito.verify(mockExecution, times(10)).setVariable(captor.capture(), captor.capture())
+ def resultSuccess = captor.getAllValues()
+ assertNotNull(resultSuccess)
+ }
+
+
+ @Test
+ void testPrepareCompleteStatus() {
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345")
+ when(mockExecution.getVariable("operationId")).thenReturn("54321")
+ when(mockExecution.getVariable("operationContent"))
+ .thenReturn("communication service create operation finished")
+
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("11111")
+ when(mockExecution.getVariable("operationStatus"))
+ .thenReturn("processing")
+ CreateCommunicationService communicationService = new CreateCommunicationService()
+
+ communicationService.prepareCompleteStatus(mockExecution)
+ Mockito.verify(mockExecution, times(1)).setVariable(eq("updateOperationStatus"), captor.capture())
+ String res = captor.getValue()
+
+ String expect = getExpectPayload("updateServiceOperationStatus", "processing", "100",
+ "communication service create operation finished")
+
+ assertEquals(expect.replaceAll("\\s+", ""), res.replaceAll("\\s+", ""))
+ }
+
+ private static String getExpectPayload(String type, String result, String progress, String operationContent) {
+ String expect =
+ """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:ns="http://org.onap.so/requestsdb">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <ns:${type} xmlns:ns="http://org.onap.so/requestsdb">
+ <serviceId>12345</serviceId>
+ <operationId>54321</operationId>
+ <operationType>CREATE</operationType>
+ <userId>11111</userId>
+ <result>${result}</result>
+ <operationContent>${operationContent}</operationContent>
+ <progress>${progress}</progress>
+ <reason></reason>
+ </ns:${type}>
+ </soapenv:Body>
+ </soapenv:Envelope>
+ """
+ return expect
+ }
+
+ private void mockData() {
+ when(mockExecution.getVariable("uuiRequest")).thenReturn("""{
+ "service":{
+ "name":"CSMFService",
+ "description":"CSMFService",
+ "serviceInvariantUuid":"e75698d9-925a-4cdd-a6c0-edacbe6a0b51",
+ "serviceUuid":"8ee5926d-720b-4bb2-86f9-d20e921c143b",
+ "globalSubscriberId":"5GCustomer",
+ "serviceType":"5G",
+ "parameters":{
+ "requestInputs":{
+ "expDataRateDL":10,
+ "expDataRateUL":30,
+ "latency":20,
+ "maxNumberofUEs":300,
+ "uemobilityLevel":"stationary",
+ "resourceSharingLevel":"shared",
+ "coverageAreaList": "01001",
+ "useInterval":"3"
+ }
+ }
+ }
+ }""")
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceServiceTest.groovy
new file mode 100644
index 0000000000..6b7944cc6e
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceServiceTest.groovy
@@ -0,0 +1,162 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.impl.persistence.entity.ExecutionEntity
+import org.json.JSONObject
+import org.junit.Before
+import org.junit.Test
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
+import org.mockito.Mockito
+import org.onap.so.beans.nsmf.SliceTaskParams
+import org.onap.so.bpmn.common.scripts.MsoGroovyTest
+import org.onap.so.bpmn.core.domain.ModelInfo
+import org.onap.so.bpmn.core.domain.ServiceDecomposition
+import org.onap.so.bpmn.core.domain.ServiceInfo
+import org.onap.so.bpmn.core.domain.ServiceProxy
+
+import static org.junit.Assert.assertEquals
+import static org.junit.Assert.assertNotNull
+import static org.mockito.ArgumentMatchers.eq
+import static org.mockito.Mockito.times
+import static org.mockito.Mockito.when
+
+class CreateSliceServiceTest extends MsoGroovyTest {
+
+ @Before
+ void init() throws IOException {
+ super.init("CreateSliceService")
+ }
+
+ @Captor
+ static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
+
+ final String bpmnRequest = """
+ {
+ "requestDetails": {
+ "modelInfo": {
+ "modelInvariantId": "123456",
+ "modelType": "service",
+ "modelNameVersionId": "123456",
+ "modelName": "Service Profile",
+ "modelVersion": "1.0",
+ "modelVersionId": "123456",
+ "modelUuid": "123456",
+ "modelInvariantUuid": "123456"
+ },
+ "requestInfo": {
+ "source": "UUI",
+ "instanceName": "NSMF",
+ "suppressRollback": true
+ },
+ "subscriberInfo": {
+ "globalSubscriberId": "5GCustomer"
+ },
+ "requestParameters": {
+ "subscriptionServiceType": "MOG",
+ "userParams": [{
+ "ServiceInstanceName": "NSMF",
+ "UUIRequest": {
+ "service":{
+ "name": "NSMF",
+ "description": "CSMFService",
+ "serviceInvariantUuid": "123456",
+ "serviceUuid": "123456",
+ "globalSubscriberId": "5GCustomer",
+ "serviceType": "5G",
+ "parameters": {},
+ "requestInputs": {
+ "sST": "embb",
+ "sNSSAI": "1-10101",
+ "uEMobilityLevel": "stationary",
+ "areaTrafficCapDL": 123,
+ "maxNumberofUEs": 1000,
+ "expDataRateUL": 2000,
+ "plmnIdList": "39-00|39-01",
+ "areaTrafficCapUL": 456,
+ "latency": 300,
+ "expDataRateDL": 400,
+ "coverageAreaTAList": 101001,
+ "activityFactor": 99,
+ "resourceSharingLevel": "shared"
+ }
+ }
+ }
+ }],
+ "aLaCarte": true,
+ "usePreload": true
+ }
+ },
+ "serviceInstanceId": null,
+ "vnfInstanceId": null,
+ "networkInstanceId": null,
+ "volumeGroupInstanceId": null,
+ "vfModuleInstanceId": null,
+ "configurationId": null,
+ "instanceGroupId": null
+ }""".replaceAll("\\s+", "")
+
+ final String uuiRequest = """
+ "service":{
+ "name": "NSMF",
+ "description": "CSMFService",
+ "serviceInvariantUuid": "123456",
+ "serviceUuid": "123456",
+ "globalSubscriberId": "5GCustomer",
+ "serviceType": "5G",
+ "parameters": {},
+ "requestInputs": {
+ "sST": "embb",
+ "sNSSAI": "1-10101",
+ "uEMobilityLevel": "stationary",
+ "areaTrafficCapDL": 123,
+ "maxNumberofUEs": 1000,
+ "expDataRateUL": 2000,
+ "plmnIdList": "39-00|39-01",
+ "areaTrafficCapUL": 456,
+ "latency": 300,
+ "expDataRateDL": 400,
+ "coverageAreaTAList": 101001,
+ "activityFactor": 99,
+ "resourceSharingLevel": "shared"
+ }
+ }""".replaceAll("\\s+", "")
+
+ final def serviceProfile = ["sST": "embb", "sNSSAI": "1-10101", "uEMobilityLevel": "stationary", "areaTrafficCapDL": 123,
+ "maxNumberofUEs": 1000, "expDataRateUL": 2000, "plmnIdList": "39-00|39-01", "areaTrafficCapUL": 456,
+ "latency": 300, "expDataRateDL": 400, "coverageAreaTAList": 101001, "activityFactor": 99,
+ "resourceSharingLevel": "shared"]
+
+ final def nstSolution = ["UUID": "aaaaaa", "NSTName": "test NST", "invariantUUID": "bbbbbb", "matchLevel": "100%"]
+
+ @Test
+ void testPreProcessRequest() {
+ when(mockExecution.getVariable("bpmnRequest")).thenReturn(bpmnRequest)
+ when(mockExecution.getVariable("mso-request-id")).thenReturn("123456")
+ CreateSliceService sliceService = new CreateSliceService()
+ sliceService.preProcessRequest(mockExecution)
+ Mockito.verify(mockExecution, times(14)).setVariable(captor.capture() as String, captor.capture())
+ List<ExecutionEntity> values = captor.getAllValues()
+ assertNotNull(values)
+ }
+
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationServiceTest.groovy
new file mode 100644
index 0000000000..8c08e51efe
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationServiceTest.groovy
@@ -0,0 +1,308 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2019, CMCC Technologies Co., Ltd.
+ #
+ # 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.impl.persistence.entity.ExecutionEntity
+import org.junit.Before
+import org.junit.Test
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
+import org.mockito.Mockito
+import org.onap.logging.filter.base.ONAPComponents
+import org.onap.so.bpmn.common.scripts.MsoGroovyTest
+import org.onap.so.bpmn.core.WorkflowException
+import org.onap.so.client.HttpClient
+import org.onap.so.client.HttpClientFactory
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.AAIResultWrapper
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+
+import javax.ws.rs.NotFoundException
+import javax.ws.rs.core.Response
+
+import static org.junit.Assert.assertEquals
+import static org.junit.Assert.assertNotNull
+import static org.mockito.ArgumentMatchers.eq
+import static org.mockito.Mockito.*
+
+class DeleteCommunicationServiceTest extends MsoGroovyTest {
+
+ private HttpClientFactory httpClientFactoryMock
+ private HttpClient httpClientMock
+
+ @Before
+ void init() throws IOException {
+ super.init("DeleteCommunicationServiceTest")
+ }
+
+ @Captor
+ static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
+
+ @Test
+ void testPreProcessRequest(){
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345")
+ when(mockExecution.getVariable("bpmnRequest")).thenReturn("""
+ {
+ "globalSubscriberId ":"5GCustomer",
+ "serviceType ":"5G"
+ }""".replaceAll("\\\\s+", ""))
+ when(mockExecution.getVariable("mso-request-id")).thenReturn("4c614769-f58a-4556-8ad9-dcd903077c82")
+
+ DeleteCommunicationService delCS = new DeleteCommunicationService()
+ delCS.preProcessRequest(mockExecution)
+ Mockito.verify(mockExecution,times(3)).setVariable(captor.capture() as String, captor.capture())
+ List<ExecutionEntity> values = captor.getAllValues()
+ assertNotNull(values)
+ }
+
+ @Test
+ void testPreInitUpdateOperationStatus(){
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be")
+ when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0")
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer")
+ when(mockExecution.getVariable("serviceInstanceName")).thenReturn("5G-test")
+ when(mockExecution.getVariable("result")).thenReturn("processing")
+ when(mockExecution.getVariable("progress")).thenReturn("0")
+ when(mockExecution.getVariable("operationContent")).thenReturn("delete communication service operation start")
+
+ DeleteCommunicationService delCS = new DeleteCommunicationService()
+ delCS.preInitUpdateOperationStatus(mockExecution)
+ Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture())
+ String updateOperationStatus= captor.getValue()
+ assertNotNull(updateOperationStatus)
+ }
+
+ @Test
+ void testQueryCommunicationSeriveFromAAI(){
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be")
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer")
+ when(mockExecution.getVariable("serviceType")).thenReturn("5G")
+
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be")
+ DeleteCommunicationService obj = spy(DeleteCommunicationService.class)
+
+ AAIResultWrapper wrapper = new AAIResultWrapper(mockQueryCommunicationServiceReturn())
+ when(obj.getAAIClient()).thenReturn(client)
+ when(client.exists(resourceUri)).thenReturn(true)
+ when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper)
+ obj.queryCommunicationSeriveFromAAI(mockExecution)
+ Mockito.verify(mockExecution,times(1)).setVariable(eq("e2eSliceServiceInstanceId"), captor.capture())
+ String e2eSliceServiceInstanceId = captor.getValue()
+ assertNotNull(e2eSliceServiceInstanceId)
+ }
+
+ @Test
+ void testPrepareCallCheckProcessStatus(){
+ DeleteCommunicationService dcs = new DeleteCommunicationService()
+ dcs.prepareCallCheckProcessStatus(mockExecution)
+ Mockito.verify(mockExecution,times(1)).setVariable(eq("endProgress"), captor.capture())
+ int endProgress = captor.getValue()
+ assertEquals(90,endProgress)
+ }
+
+ @Test
+ void testDelCSProfileFromAAI()
+ {
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be")
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer")
+ when(mockExecution.getVariable("serviceType")).thenReturn("5G")
+
+ AAIResultWrapper wrapper = new AAIResultWrapper(mockQueryCommunicationServiceProfile())
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.COMMUNICATION_PROFILE_ALL, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be")
+ AAIResourceUri profileUri = AAIUriFactory.createResourceUri(AAIObjectType.COMMUNICATION_SERVICE_PROFILE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be", "5G-111111")
+
+ DeleteCommunicationService obj = spy(DeleteCommunicationService.class)
+ when(obj.getAAIClient()).thenReturn(client)
+ when(client.exists(resourceUri)).thenReturn(true)
+ when(client.exists(profileUri)).thenReturn(true)
+ when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper)
+ doNothing().when(client).delete(profileUri)
+ obj.delCSProfileFromAAI(mockExecution)
+ Mockito.verify(client,times(1)).delete(profileUri)
+ }
+
+ @Test
+ void testPrepareFailureStatus(){
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be")
+ when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0")
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer")
+ when(mockExecution.getVariable("serviceInstanceName")).thenReturn("5G-test")
+ when(mockExecution.getVariable("result")).thenReturn("finished")
+ when(mockExecution.getVariable("progress")).thenReturn("100")
+ when(mockExecution.getVariable("operationContent")).thenReturn("terminate service failure.")
+
+ DeleteCommunicationService dcs = new DeleteCommunicationService()
+ dcs.prepareFailureStatus(mockExecution)
+ Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture())
+ String updateOperationStatus= captor.getValue()
+ assertNotNull(updateOperationStatus)
+ }
+
+ @Test
+ void testDelCSFromAAI(){
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be")
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer")
+ when(mockExecution.getVariable("serviceType")).thenReturn("5G")
+
+ AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be")
+ DeleteCommunicationService obj = spy(DeleteCommunicationService.class)
+ when(obj.getAAIClient()).thenReturn(client)
+ doNothing().when(client).delete(serviceInstanceUri)
+
+ obj.delCSFromAAI(mockExecution)
+ Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture())
+ String updateOperationStatus= captor.getValue()
+ assertNotNull(updateOperationStatus)
+ }
+
+ @Test
+ void testPreFailedOperationStatus(){
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be")
+ when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0")
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer")
+ when(mockExecution.getVariable("serviceInstanceName")).thenReturn("5G-test")
+ when(mockExecution.getVariable("result")).thenReturn("error")
+ when(mockExecution.getVariable("progress")).thenReturn("100")
+ when(mockExecution.getVariable("operationContent")).thenReturn("terminate service failure")
+
+ DeleteCommunicationService deleteCommunicationService = new DeleteCommunicationService()
+ WorkflowException exception = new WorkflowException("11113",7000,"terminate service failure")
+ when(mockExecution.getVariable("WorkflowException")).thenReturn(exception)
+ deleteCommunicationService.preFailedOperationStatus(mockExecution)
+
+ Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture())
+ String updateOperationStatus= captor.getValue()
+ assertNotNull(updateOperationStatus)
+ }
+
+ @Test
+ void testSendRequest2NSMFWF(){
+ httpClientMock = mock(HttpClient.class)
+ httpClientFactoryMock = mock(HttpClientFactory.class)
+ String url ="http://so.onap:8080/onap/so/infra/e2eServiceInstances/v3/5G-777"
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be")
+ when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0")
+ when(mockExecution.getVariable("progress")).thenReturn("20")
+ when(mockExecution.getVariable("operationContent")).thenReturn("waiting nsmf service delete finished")
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer")
+ when(mockExecution.getVariable("mso.infra.endpoint.url")).thenReturn("http://so.onap:8080/onap/so/infra")
+ when(mockExecution.getVariable("e2eSliceServiceInstanceId")).thenReturn("5G-777")
+ when(mockExecution.getVariable("e2eOperationId")).thenReturn("e151059a-d924-4629-845f-264db19e50b3")
+ when(httpClientFactoryMock.newJsonClient(new URL(url), ONAPComponents.SO)).thenReturn(httpClientMock)
+ DeleteCommunicationService obj = spy(DeleteCommunicationService.class)
+
+ Response responseMock = mock(Response.class)
+ when(responseMock.getStatus()).thenReturn(200)
+ when(responseMock.hasEntity()).thenReturn(true)
+ when(responseMock.getEntity()).thenReturn(getNSSMFResponse())
+ when(obj.getHttpClientFactory()).thenReturn(httpClientFactoryMock)
+ when(httpClientMock.delete(anyString())).thenReturn(responseMock)
+
+ obj.sendRequest2NSMFWF(mockExecution)
+ Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture())
+ String updateOperationStatus= captor.getValue()
+ assertNotNull(updateOperationStatus)
+ }
+
+ private String getNSSMFResponse(){
+ String response = """{
+ "service":{
+ "serviceId":"e151059a-d924-4629-845f-264db19e50b4",
+ "operationId":"e151059a-d924-4629-845f-264db19e50b3"
+ }
+ }"""
+ return response
+ }
+
+
+
+
+ private String mockQueryCommunicationServiceReturn()
+ {
+ String expect =
+ """{
+ "service-instance-id": "5G-666",
+ "service-instance-name": "eMBB_Slice_Communication_Service_5GCustomer",
+ "service-type": "eMBB",
+ "service-role": "communication-service",
+ "environment-context": "01-010101",
+ "workload-context": "12",
+ "created-at": "2019-12-11 19:56:00",
+ "description": "",
+ "model-invariant-id": "e75698d9-925a-4cdd-a6c0-edacbe6a0b51",
+ "model-version-id": "8ee5926d-720b-4bb2-86f9-d20e921c143b",
+ "service-instance-location-id": "300-01|300-02",
+ "resource-version": "1582623470778",
+ "orchestration-status": "created",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "service-instance",
+ "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+ "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/5G-777",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "5GCustomer"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "5G"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "5G-777"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "eMBB_e2e_Slice_Service_5GCustomer"
+ }
+ ]
+ }
+ ]
+ }
+ }"""
+ return expect
+ }
+
+ private String mockQueryCommunicationServiceProfile()
+ {
+ String expect =
+ """{
+ "communication-service-profile": [
+ {
+ "profile-id": "5G-111111",
+ "max-number-of-UEs": 50,
+ "coverage-area-list": "longgang,futian",
+ "latency": 20,
+ "exp-data-rate-UL": 300,
+ "exp-data-rate-DL": 500,
+ "ue-mobility-level": "stationary",
+ "resource-sharing-level": "Non-Shared",
+ "resource-version": "1577454950460"
+ }
+ ]
+ }"""
+ return expect
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceServiceTest.groovy
new file mode 100644
index 0000000000..fb50fcc43b
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceServiceTest.groovy
@@ -0,0 +1,171 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2019, CMCC Technologies Co., Ltd.
+ #
+ # 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.impl.persistence.entity.ExecutionEntity
+import org.junit.Before
+import org.junit.Test
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
+import org.mockito.Mockito
+import org.onap.so.bpmn.common.scripts.MsoGroovyTest
+import org.onap.so.bpmn.core.WorkflowException
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.AAIResultWrapper
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+
+import javax.ws.rs.NotFoundException
+
+import static org.junit.Assert.assertNotNull
+import static org.mockito.ArgumentMatchers.eq
+import static org.mockito.Mockito.doNothing
+import static org.mockito.Mockito.spy
+import static org.mockito.Mockito.times
+import static org.mockito.Mockito.when
+import static org.mockito.Mockito.when
+import static org.mockito.Mockito.when
+
+class DeleteSliceServiceTest extends MsoGroovyTest {
+ @Before
+ void init() throws IOException {
+ super.init("DeleteSliceServiceTest")
+ }
+
+ @Captor
+ static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
+
+ @Test
+ void testPreProcessRequest(){
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("eb0863e9-a69b-4b17-8a56-f05ad110bef7")
+ when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0")
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer")
+ when(mockExecution.getVariable("serviceInstanceName")).thenReturn("5G-test")
+ when(mockExecution.getVariable("serviceType")).thenReturn("5G")
+ when(mockExecution.getVariable("result")).thenReturn("processing")
+ when(mockExecution.getVariable("progress")).thenReturn("0")
+ when(mockExecution.getVariable("operationContent")).thenReturn("Delete Slice service operation start")
+ when(mockExecution.getVariable("bpmnRequest")).thenReturn("""
+ {
+ "globalSubscriberId ":"5GCustomer",
+ "serviceType ":"5G"
+ }""".replaceAll("\\\\s+", ""))
+ when(mockExecution.getVariable("mso-request-id")).thenReturn("4c614769-f58a-4556-8ad9-dcd903077c82")
+
+ DeleteSliceService delSS = new DeleteSliceService()
+ delSS.preProcessRequest(mockExecution)
+ Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture())
+ String updateOperationStatus = captor.getValue()
+ assertNotNull(updateOperationStatus)
+ }
+
+ @Test
+ void testDeleteSliceServiceInstance(){
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be")
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer")
+ when(mockExecution.getVariable("serviceType")).thenReturn("5G")
+
+ when(mockExecution.getVariable("result")).thenReturn("finished")
+ when(mockExecution.getVariable("progress")).thenReturn("100")
+ when(mockExecution.getVariable("operationContent")).thenReturn("NSMF completes slicing service termination.")
+
+ AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be")
+ DeleteSliceService obj = spy(DeleteSliceService.class)
+ when(obj.getAAIClient()).thenReturn(client)
+ doNothing().when(client).delete(serviceInstanceUri)
+
+ obj.deleteSliceServiceInstance(mockExecution)
+ Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture())
+ String updateOperationStatus= captor.getValue()
+ assertNotNull(updateOperationStatus)
+ }
+
+ @Test
+ void testDelServiceProfileFromAAI(){
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be")
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer")
+ when(mockExecution.getVariable("serviceType")).thenReturn("5G")
+
+ AAIResultWrapper wrapper = new AAIResultWrapper(mockQuerySliceServiceProfile())
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_PROFILE_ALL, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be")
+ AAIResourceUri profileUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_PROFILE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be", "5G-2222222")
+
+ DeleteSliceService obj = spy(DeleteSliceService.class)
+ when(obj.getAAIClient()).thenReturn(client)
+ when(client.exists(resourceUri)).thenReturn(true)
+ when(client.exists(profileUri)).thenReturn(true)
+ when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper)
+ doNothing().when(client).delete(profileUri)
+ obj.delServiceProfileFromAAI(mockExecution)
+ Mockito.verify(client,times(1)).delete(profileUri)
+ }
+
+ @Test
+ void testPrepareEndOperationStatus(){
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be")
+ when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0")
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer")
+ when(mockExecution.getVariable("serviceInstanceName")).thenReturn("5G-test")
+ when(mockExecution.getVariable("result")).thenReturn("error")
+ when(mockExecution.getVariable("progress")).thenReturn("100")
+ when(mockExecution.getVariable("operationContent")).thenReturn("terminate service failure")
+
+ DeleteSliceService deleteSliceService = new DeleteSliceService()
+ WorkflowException exception = new WorkflowException("11113",7000,"terminate service failure")
+ when(mockExecution.getVariable("WorkflowException")).thenReturn(exception)
+ deleteSliceService.prepareEndOperationStatus(mockExecution)
+
+ Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture())
+ String updateOperationStatus= captor.getValue()
+ assertNotNull(updateOperationStatus)
+
+ }
+
+ private String mockQuerySliceServiceProfile(){
+ String expect =
+ """{
+ "service-profile": [
+ {
+ "profile-id": "5G-2222222",
+ "latency": 50,
+ "max-number-of-UEs": 500,
+ "coverage-area-TA-list": "longgang,futian",
+ "ue-mobility-level": "stationary",
+ "resource-sharing-level": "Non-Shared",
+ "exp-data-rate-UL": 10,
+ "exp-data-rate-DL": 30,
+ "area-traffic-cap-UL": 100,
+ "area-traffic-cap-DL": 100,
+ "activity-factor": 80,
+ "jitter": 10,
+ "survival-time": 30,
+ "cs-availability": 95.5,
+ "reliability": 99.9,
+ "exp-data-rate": 80,
+ "traffic-density": 100,
+ "conn-density": 80,
+ "resource-version": "1577454958647"
+ }
+ ]
+ }"""
+ return expect
+ }
+
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateCommunicationServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateCommunicationServiceTest.groovy
new file mode 100644
index 0000000000..37207f8022
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateCommunicationServiceTest.groovy
@@ -0,0 +1,196 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2019, CMCC Technologies Co., Ltd.
+ #
+ # 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.BpmnError
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.junit.Before
+import org.junit.Test
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
+import org.mockito.Mockito
+import org.onap.aai.domain.yang.CommunicationServiceProfile
+import org.onap.aai.domain.yang.ServiceInstance
+import org.onap.so.bpmn.common.scripts.MsoGroovyTest
+import org.onap.so.client.aai.AAIResourcesClient
+
+import static com.shazam.shazamcrest.MatcherAssert.assertThat
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs
+import static org.junit.Assert.assertEquals
+import static org.junit.Assert.assertNotNull
+import static org.mockito.ArgumentMatchers.eq
+import static org.mockito.Mockito.*
+
+class DoCreateCommunicationServiceTest extends MsoGroovyTest {
+
+ private DoCreateCommunicationService communicationService = new DoCreateCommunicationService()
+
+ @Before
+ public void setUp() throws Exception {
+ super.init("DoCreateCommunicationService")
+ communicationService.client = spy(AAIResourcesClient.class)
+ }
+
+ @Captor
+ static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
+
+ @Test
+ public void testPreProcessRequest(){
+ mockData()
+ DoCreateCommunicationService communicationService = new DoCreateCommunicationService()
+ communicationService.preProcessRequest(mockExecution)
+ Mockito.verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture())
+ assertNotNull(captor.getAllValues())
+ }
+
+ @Test
+ public void testCreateCommunicationService() {
+ mockData()
+ ServiceInstance expectedServiceInstanceData = getExpectedServiceInstance()
+
+ try {
+ communicationService.createCommunicationService(mockExecution)
+ } catch (Exception e) {
+
+ assertEquals(e.class, BpmnError.class)
+ }
+
+
+ Mockito.verify(mockExecution).setVariable(eq("communicationServiceInstance"), captor.capture())
+ ServiceInstance resData = captor.getValue()
+ resData.setCreatedAt("")
+ resData.setEnvironmentContext("")
+ assertThat(resData, sameBeanAs(expectedServiceInstanceData))
+ }
+
+ @Test
+ public void testCreateCommunicationServiceProfile() {
+ mockData()
+ DoCreateCommunicationService communicationService = new DoCreateCommunicationService()
+
+ CommunicationServiceProfile expectedServiceInstanceData = getExpectedServiceInstanceProfile()
+
+ try {
+ communicationService.createCommunicationServiceProfile(mockExecution)
+ } catch (Exception e) {
+ assertEquals(e.class, BpmnError.class)
+ }
+
+ Mockito.verify(mockExecution).setVariable(eq("communicationServiceInstanceProfile"), captor.capture())
+ CommunicationServiceProfile resData = captor.getValue()
+ resData.setProfileId("")
+ assertThat(resData, sameBeanAs(expectedServiceInstanceData))
+ }
+
+ private static CommunicationServiceProfile getExpectedServiceInstanceProfile() {
+ CommunicationServiceProfile expectedServiceInstanceData = new CommunicationServiceProfile()
+ expectedServiceInstanceData.setProfileId("")
+ expectedServiceInstanceData.setLatency(20)
+ expectedServiceInstanceData.setMaxNumberOfUEs(300)
+ expectedServiceInstanceData.setUeMobilityLevel("stationary")
+ expectedServiceInstanceData.setResourceSharingLevel("shared")
+ expectedServiceInstanceData.setExpDataRateUL(30)
+ expectedServiceInstanceData.setExpDataRateDL(10)
+ expectedServiceInstanceData.setCoverageAreaList("01001")
+ return expectedServiceInstanceData
+ }
+
+ private static ServiceInstance getExpectedServiceInstance() {
+ ServiceInstance expectedServiceInstanceData = new ServiceInstance()
+ expectedServiceInstanceData.setServiceInstanceName("CSMFService")
+ expectedServiceInstanceData.setServiceRole("communication-service")
+ expectedServiceInstanceData.setOrchestrationStatus("processing")
+ expectedServiceInstanceData.setModelInvariantId("e75698d9-925a-4cdd-a6c0-edacbe6a0b51")
+ expectedServiceInstanceData.setModelVersionId("8ee5926d-720b-4bb2-86f9-d20e921c143b")
+ expectedServiceInstanceData.setInputParameters("""{
+ "service":{
+ "name":"CSMFService",
+ "description":"CSMFService",
+ "serviceInvariantUuid":"e75698d9-925a-4cdd-a6c0-edacbe6a0b51",
+ "serviceUuid":"8ee5926d-720b-4bb2-86f9-d20e921c143b",
+ "globalSubscriberId":"5GCustomer",
+ "serviceType":"5G",
+ "parameters":{
+ "requestInputs":{
+ "expDataRateDL":10,
+ "expDataRateUL":30,
+ "latency":20,
+ "maxNumberofUEs":300,
+ "uemobilityLevel":"stationary",
+ "resourceSharingLevel":"shared",
+ "coverageAreaList": "01001",
+ "useInterval":"3"
+ }
+ }
+ }
+ }""")
+ expectedServiceInstanceData.setWorkloadContext("3")
+ expectedServiceInstanceData.setCreatedAt("")
+ expectedServiceInstanceData.setEnvironmentContext("")
+ return expectedServiceInstanceData
+ }
+
+ private void mockData() {
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345")
+ when(mockExecution.getVariable("serviceInstanceName")).thenReturn("CSMFService")
+ when(mockExecution.getVariable("serviceType")).thenReturn("5G")
+ when(mockExecution.getVariable("uuiRequest")).thenReturn("""{
+ "service":{
+ "name":"CSMFService",
+ "description":"CSMFService",
+ "serviceInvariantUuid":"e75698d9-925a-4cdd-a6c0-edacbe6a0b51",
+ "serviceUuid":"8ee5926d-720b-4bb2-86f9-d20e921c143b",
+ "globalSubscriberId":"5GCustomer",
+ "serviceType":"5G",
+ "parameters":{
+ "requestInputs":{
+ "expDataRateDL":10,
+ "expDataRateUL":30,
+ "latency":20,
+ "maxNumberofUEs":300,
+ "uemobilityLevel":"stationary",
+ "resourceSharingLevel":"shared",
+ "coverageAreaList": "01001",
+ "useInterval":"3"
+ }
+ }
+ }
+ }""")
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer")
+ Map<String, Object> csInputMap = new HashMap<>()
+ csInputMap.put("expDataRateDL", 10)
+ csInputMap.put("expDataRateUL", 30)
+ csInputMap.put("latency", 20)
+ csInputMap.put("maxNumberofUEs", 300)
+ csInputMap.put("uEMobilityLevel", "stationary")
+ csInputMap.put("resourceSharingLevel", "shared")
+ csInputMap.put("coverageAreaTAList", "01001")
+ csInputMap.put("useInterval", "3")
+
+ when(mockExecution.getVariable("csInputMap")).thenReturn(csInputMap)
+
+ when(mockExecution.getVariable("modelInvariantUuid")).thenReturn("e75698d9-925a-4cdd-a6c0-edacbe6a0b51")
+ when(mockExecution.getVariable("modelUuid")).thenReturn("8ee5926d-720b-4bb2-86f9-d20e921c143b")
+ when(mockExecution.getVariable("useInterval")).thenReturn("3")
+ when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("5G")
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollbackTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollbackTest.groovy
index dd18049b5f..7107d15602 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollbackTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollbackTest.groovy
@@ -45,6 +45,7 @@ import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.mock.FileUtil
import org.onap.so.client.aai.AAIObjectPlurals
import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.uri.AAIPluralResourceUri
import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.client.graphinventory.exceptions.GraphInventoryUriComputationException
@@ -168,7 +169,7 @@ class DoCreateVfModuleRollbackTest extends MsoGroovyTest{
fqdnList.add("test")
when(mockExecution.getVariable(prefix + "createdNetworkPolicyFqdnList")).thenReturn(fqdnList)
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
+ AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
uri.queryParam("network-policy-fqdn", "test")
NetworkPolicies networkPolicies = new NetworkPolicies();
NetworkPolicy networkPolicy = new NetworkPolicy();
@@ -198,7 +199,7 @@ class DoCreateVfModuleRollbackTest extends MsoGroovyTest{
fqdnList.add("test")
when(mockExecution.getVariable(prefix + "createdNetworkPolicyFqdnList")).thenReturn(fqdnList)
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
+ AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
uri.queryParam("network-policy-fqdn", "test")
NetworkPolicies networkPolicies = new NetworkPolicies();
NetworkPolicy networkPolicy = new NetworkPolicy();
@@ -228,7 +229,7 @@ class DoCreateVfModuleRollbackTest extends MsoGroovyTest{
fqdnList.add("test")
when(mockExecution.getVariable(prefix + "createdNetworkPolicyFqdnList")).thenReturn(fqdnList)
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
+ AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
uri.queryParam("network-policy-fqdn", "test")
NetworkPolicies networkPolicies = new NetworkPolicies();
NetworkPolicy networkPolicy = new NetworkPolicy();
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollbackTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollbackTest.groovy
index 5c68cc7fc1..8941a24ebc 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollbackTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollbackTest.groovy
@@ -27,6 +27,7 @@ import org.onap.aai.domain.yang.VolumeGroup
import org.onap.aai.domain.yang.VolumeGroups;
import org.onap.so.bpmn.common.scripts.MsoGroovyTest
import org.onap.so.client.aai.AAIObjectPlurals
+import org.onap.so.client.aai.entities.uri.AAIPluralResourceUri
import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.constants.Defaults
@@ -50,7 +51,7 @@ public class DoCreateVfModuleVolumeRollbackTest extends MsoGroovyTest {
String cloudRegionId = "cloudRegionId"
when(mockExecution.getVariable("DCVFMODVOLRBK_volumeGroupName")).thenReturn(volumeGroupName)
when(mockExecution.getVariable("DCVFMODVOLRBK_lcpCloudRegionId")).thenReturn(cloudRegionId)
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegionId).queryParam("volume-group-name", volumeGroupName)
+ AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegionId).queryParam("volume-group-name", volumeGroupName)
VolumeGroup volumeGroup = new VolumeGroup();
volumeGroup.setVolumeGroupId("volumeGroupId")
VolumeGroups groups = new VolumeGroups();
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2Test.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2Test.groovy
index ddb1fbade4..22414b770e 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2Test.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2Test.groovy
@@ -40,6 +40,7 @@ import org.onap.so.bpmn.common.scripts.MsoGroovyTest
import org.onap.so.bpmn.core.RollbackData
import org.onap.so.client.aai.AAIObjectPlurals
import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.uri.AAIPluralResourceUri
import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.constants.Defaults
@@ -160,7 +161,7 @@ class DoCreateVfModuleVolumeV2Test extends MsoGroovyTest {
String lcpCloudRegionId = "lcpCloudRegionId"
when(mockExecution.getVariable(volumeGroupName)).thenReturn(volumeGroupName)
when(mockExecution.getVariable(lcpCloudRegionId)).thenReturn(lcpCloudRegionId)
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), lcpCloudRegionId).queryParam("volume-group-name", volumeGroupName)
+ AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), lcpCloudRegionId).queryParam("volume-group-name", volumeGroupName)
VolumeGroups volumeGroups = new VolumeGroups();
VolumeGroup volumeGroup = new VolumeGroup()
volumeGroup.setVolumeGroupId("volumeGroupId")
@@ -176,7 +177,7 @@ class DoCreateVfModuleVolumeV2Test extends MsoGroovyTest {
String lcpCloudRegionId = "lcpCloudRegionId"
when(mockExecution.getVariable(volumeGroupName)).thenReturn(volumeGroupName)
when(mockExecution.getVariable(lcpCloudRegionId)).thenReturn(lcpCloudRegionId)
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), lcpCloudRegionId).queryParam("volume-group-name", volumeGroupName)
+ AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), lcpCloudRegionId).queryParam("volume-group-name", volumeGroupName)
when(client.get(VolumeGroup.class,uri)).thenReturn(Optional.empty())
thrown.expect(BpmnError.class)
doCreateVfModuleVolumeV2.callRESTQueryAAIVolGrpName(mockExecution,null)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSITest.groovy
new file mode 100644
index 0000000000..493e2c9e1e
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSITest.groovy
@@ -0,0 +1,258 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2019, CMCC Technologies Co., Ltd.
+ #
+ # 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.impl.persistence.entity.ExecutionEntity
+import org.junit.Before
+import org.junit.Test
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
+import org.mockito.Mockito
+import org.onap.logging.filter.base.ONAPComponents
+import org.onap.so.beans.nsmf.JobStatusResponse
+import org.onap.so.beans.nsmf.NssiResponse
+import org.onap.so.beans.nsmf.ResponseDescriptor
+import org.onap.so.bpmn.common.scripts.MsoGroovyTest
+import org.onap.so.bpmn.core.domain.ServiceArtifact
+import org.onap.so.bpmn.core.domain.ServiceDecomposition
+import org.onap.so.bpmn.core.domain.ServiceInfo
+import org.onap.so.client.HttpClient
+import org.onap.so.client.HttpClientFactory
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+
+import javax.ws.rs.core.Response
+
+import static org.junit.Assert.assertNotNull
+import static org.junit.Assert.assertTrue
+import static org.mockito.ArgumentMatchers.anyString
+import static org.mockito.ArgumentMatchers.eq
+import static org.mockito.Mockito.doNothing
+import static org.mockito.Mockito.mock
+import static org.mockito.Mockito.spy
+import static org.mockito.Mockito.times
+import static org.mockito.Mockito.when
+
+class DoDeallocateNSSITest extends MsoGroovyTest {
+
+ private HttpClientFactory httpClientFactoryMock
+ private HttpClient httpClientMock
+
+ @Before
+ void init() throws IOException {
+ super.init("DoDeallocateNSSITest")
+ }
+
+ @Captor
+ static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
+
+
+ @Test
+ void testPreProcessRequest(){
+ def currentNSSI = [:]
+ currentNSSI.put("nssiServiceInstanceId","5G-999")
+ when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
+
+ DoDeallocateNSSI ddnssi = new DoDeallocateNSSI()
+ ddnssi.preProcessRequest(mockExecution)
+ Mockito.verify(mockExecution,times(1)).getVariable("currentNSSI")
+ }
+
+ @Test
+ void testPrepareDecomposeService(){
+ def currentNSSI = [:]
+ currentNSSI.put("modelInvariantId", "21d57d4b-52ad-4d3c-a798-248b5bb9124b")
+ currentNSSI.put("modelVersionId", "bfba363e-e39c-4bd9-a9d5-1371c28f4d22")
+ currentNSSI.put("nssiServiceInstanceId","5G-999")
+ when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
+
+ DoDeallocateNSSI ddnssi = new DoDeallocateNSSI()
+ ddnssi.prepareDecomposeService(mockExecution)
+ Mockito.verify(mockExecution,times(1)).setVariable(eq("serviceModelInfo"), captor.capture())
+ String serviceModelInfo = captor.getValue()
+ assertNotNull(serviceModelInfo)
+ }
+
+ @Test
+ void testProcessDecomposition(){
+ def currentNSSI = [:]
+ ServiceArtifact artifact = new ServiceArtifact()
+ artifact.setContent(getArtifactContent())
+ ServiceInfo serviceInfo = new ServiceInfo()
+ List<ServiceArtifact> artifactList = new ArrayList<>()
+ artifactList.add(artifact)
+ serviceInfo.setServiceArtifact(artifactList)
+ ServiceDecomposition decomposition = new ServiceDecomposition()
+ decomposition.setServiceInfo(serviceInfo)
+ when(mockExecution.getVariable("serviceDecomposition")).thenReturn(decomposition)
+ when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
+
+ DoDeallocateNSSI ddnssi = new DoDeallocateNSSI()
+ ddnssi.processDecomposition(mockExecution)
+ String vendor = currentNSSI.get("vendor")
+ assertNotNull(vendor)
+ }
+
+ @Test
+ void testHandleJobStatus(){
+ def currentNSSI = [:]
+ currentNSSI.put("jobProgress", 10)
+ currentNSSI.put("proportion", 90)
+ currentNSSI.put("statusDescription","")
+ currentNSSI.put("e2eServiceInstanceId","21d57d4b-52ad-4d3c-a798-248b5bb9124b")
+ currentNSSI.put("operationId","4c614769-f58a-4556-8ad9-dcd903077c82")
+ when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
+
+ DoDeallocateNSSI ddnssi = new DoDeallocateNSSI()
+ ddnssi.handleJobStatus(mockExecution)
+ Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture())
+ String updateOperationStatus= captor.getValue()
+ assertNotNull(updateOperationStatus)
+ }
+
+ @Test
+ void testDelSliceProfileFromAAI(){
+ def currentNSSI = [:]
+ currentNSSI.put("nssiServiceInstanceId", "5G-999")
+ currentNSSI.put("profileId", "ddf57704-fe8d-417b-882d-2f2a12ddb225")
+ currentNSSI.put("globalSubscriberId","5GCustomer")
+ currentNSSI.put("serviceType","5G")
+ when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
+
+ AAIResourceUri profileUri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, "5GCustomer", "5G", "5G-999", "ddf57704-fe8d-417b-882d-2f2a12ddb225")
+ DoDeallocateNSSI obj = spy(DoDeallocateNSSI.class)
+ when(obj.getAAIClient()).thenReturn(client)
+ when(client.exists(profileUri)).thenReturn(true)
+ doNothing().when(client).delete(profileUri)
+
+ obj.delSliceProfileFromAAI(mockExecution)
+ Mockito.verify(client,times(1)).delete(profileUri)
+ }
+
+ @Test
+ void testSendRequestToNSSMF(){
+ httpClientFactoryMock = mock(HttpClientFactory.class)
+ httpClientMock = mock(HttpClient.class)
+
+ def currentNSSI = [:]
+ currentNSSI.put("snssai", "01-010101")
+ currentNSSI.put("profileId", "ddf57704-fe8d-417b-882d-2f2a12ddb225")
+ currentNSSI.put("nssiServiceInstanceId","5G-999")
+ currentNSSI.put("nsiServiceInstanceId","5G-888")
+
+ when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
+ when(mockExecution.getVariable("mso.adapters.nssmf.endpoint")).thenReturn("http://so-nssmf-adapter.onap:8088")
+ String nssmfRequest = "http://so-nssmf-adapter.onap:8088/api/rest/provMns/v1/NSS/SliceProfiles/ddf57704-fe8d-417b-882d-2f2a12ddb225"
+
+ when(httpClientFactoryMock.newJsonClient(new URL(nssmfRequest), ONAPComponents.EXTERNAL)).thenReturn(httpClientMock)
+ DoDeallocateNSSI obj = spy(DoDeallocateNSSI.class)
+ when(obj.getHttpClientFactory()).thenReturn(httpClientFactoryMock)
+ Response responseMock = mock(Response.class)
+ NssiResponse response = new NssiResponse()
+ response.setNssiId("NSSI-C-004-HDBHZ-NSSMF-01-A-HW")
+ response.setJobId("a5c5913d-448a-bcb1-9b800a944d84")
+ when(httpClientMock.post(anyString())).thenReturn(responseMock)
+ when(responseMock.getStatus()).thenReturn(202)
+ when(responseMock.readEntity(NssiResponse.class)) thenReturn(response)
+ when(responseMock.hasEntity()).thenReturn(true)
+
+ obj.sendRequestToNSSMF(mockExecution)
+ String jobId = currentNSSI['jobId']
+ assertNotNull(jobId)
+ }
+
+ @Test
+ void testGetJobStatus(){
+ httpClientFactoryMock = mock(HttpClientFactory.class)
+ httpClientMock = mock(HttpClient.class)
+
+ def currentNSSI = [:]
+ currentNSSI.put("jobId", "a5c5913d-448a-bcb1-9b800a944d84")
+ currentNSSI.put("nssiServiceInstanceId","5G-999")
+ currentNSSI.put("nsiServiceInstanceId","5G-888")
+ currentNSSI.put("jobProgress",60)
+
+ when(mockExecution.getVariable("isNSSIDeAllocated")).thenReturn(false)
+ when(mockExecution.getVariable("isNSSIDeAllocated")).thenReturn(false)
+ when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
+ when(mockExecution.getVariable("mso.adapters.nssmf.endpoint")).thenReturn("http://so-nssmf-adapter.onap:8088")
+ String nssmfRequest = "http://so-nssmf-adapter.onap:8088/api/rest/provMns/v1/NSS/jobs/a5c5913d-448a-bcb1-9b800a944d84"
+
+ when(httpClientFactoryMock.newJsonClient(new URL(nssmfRequest), ONAPComponents.EXTERNAL)).thenReturn(httpClientMock)
+ DoDeallocateNSSI obj = spy(DoDeallocateNSSI.class)
+ when(obj.getHttpClientFactory()).thenReturn(httpClientFactoryMock)
+ Response responseMock = mock(Response.class)
+ ResponseDescriptor descriptor = new ResponseDescriptor()
+ descriptor.setProgress(100)
+ descriptor.setStatusDescription("finished deallocate nssi")
+ JobStatusResponse jobStatusResponse = new JobStatusResponse()
+ jobStatusResponse.setResponseDescriptor(descriptor)
+ when(httpClientMock.post(anyString())).thenReturn(responseMock)
+ when(responseMock.getStatus()).thenReturn(202)
+ when(responseMock.readEntity(JobStatusResponse.class)) thenReturn(jobStatusResponse)
+ when(responseMock.hasEntity()).thenReturn(true)
+
+ obj.getJobStatus(mockExecution)
+ Mockito.verify(mockExecution,times(1)).setVariable(eq("isNSSIDeAllocated"), captor.capture())
+ boolean value = captor.getValue()
+ assertTrue(value)
+ }
+
+
+ private String getArtifactContent(){
+ String content =
+ """
+ {
+ "metadata":{
+ "id":"NSST-C-001-HDBNJ-NSSMF-01-A-HW",
+ "vendor":"HW",
+ "version":"1.0",
+ "name":"eMBB_demo",
+ "description":"eMBB for demo",
+ "type":"embb",
+ "domainType":"cn"
+ },
+ "capabilities":{
+ "latency":{
+ "type":"integer",
+ "constrainstsl":"less_or_equal",
+ "value":"20"
+ },
+ "areaTrafficCapDL":{
+ "type":"integer",
+ "constrainstsl":"less_or_equal",
+ "value":"300"
+ },
+ "areaTrafficCapUL":{
+ "type":"integer",
+ "constrainstsl":"less_or_equal",
+ "value":"300"
+ },
+ "maxNumberofUEs":{
+ "type":"integer",
+ "constrainstsl":"less_or_equal",
+ "value":"300"
+ }
+ }
+ }
+ """
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceServiceTest.groovy
new file mode 100644
index 0000000000..8a18376819
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceServiceTest.groovy
@@ -0,0 +1,460 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2019, CMCC Technologies Co., Ltd.
+ #
+ # 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.impl.persistence.entity.ExecutionEntity
+import org.junit.Before
+import org.junit.Test
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
+import org.mockito.Mockito
+import org.onap.aai.domain.yang.ServiceInstance
+import org.onap.so.bpmn.common.scripts.MsoGroovyTest
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.AAIResultWrapper
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+
+import javax.ws.rs.NotFoundException
+
+import static org.junit.Assert.assertEquals
+import static org.junit.Assert.assertNotNull
+import static org.junit.Assert.assertTrue
+import static org.mockito.ArgumentMatchers.eq
+import static org.mockito.Mockito.doNothing
+import static org.mockito.Mockito.spy
+import static org.mockito.Mockito.times
+import static org.mockito.Mockito.verify
+import static org.mockito.Mockito.when
+
+class DoDeleteSliceServiceTest extends MsoGroovyTest {
+ @Before
+ void init() throws IOException {
+ super.init("DoDeleteSliceServiceTest")
+ }
+
+ @Captor
+ static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
+
+ @Test
+ void testPreProcessRequest(){
+ when(mockExecution.getVariable("serviceType")).thenReturn("5G")
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer")
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("e2a747a0-2ca6-476d-ac28-de999cf3fbfe")
+
+ DoDeleteSliceService doDeleteSliceService = new DoDeleteSliceService()
+ doDeleteSliceService.preProcessRequest(mockExecution)
+
+ Mockito.verify(mockExecution,times(1)).setVariable(captor.capture() as String, captor.capture())
+ List<ExecutionEntity> values = captor.getAllValues()
+ assertNotNull(values)
+ }
+
+ @Test
+ void testQueryE2ESliceSeriveFromAAI(){
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be")
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer")
+ when(mockExecution.getVariable("serviceType")).thenReturn("5G")
+
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be")
+ DoDeleteSliceService obj = spy(DoDeleteSliceService.class)
+
+ AAIResultWrapper wrapper = new AAIResultWrapper(mockQuerySliceServiceReturn())
+ when(obj.getAAIClient()).thenReturn(client)
+ when(client.exists(resourceUri)).thenReturn(true)
+ when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper)
+ obj.queryE2ESliceSeriveFromAAI(mockExecution)
+ Mockito.verify(mockExecution,times(1)).setVariable(eq("snssai"), captor.capture())
+ String snssai = captor.getValue()
+ assertNotNull(snssai)
+ }
+
+ @Test
+ void testGetAllottedResFromAAI(){
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be")
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer")
+ when(mockExecution.getVariable("serviceType")).thenReturn("5G")
+
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE_ALL, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be")
+ DoDeleteSliceService obj = spy(DoDeleteSliceService.class)
+
+ AAIResultWrapper wrapper = new AAIResultWrapper(mockQueryAllottedResource())
+ when(obj.getAAIClient()).thenReturn(client)
+ when(client.exists(resourceUri)).thenReturn(true)
+ when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper)
+ obj.getAllottedResFromAAI(mockExecution)
+ Mockito.verify(mockExecution,times(1)).setVariable(eq("nsiId"), captor.capture())
+ String nsiId = captor.getValue()
+ assertNotNull(nsiId)
+ }
+
+ @Test
+ void testGetNSIFromAAI(){
+ when(mockExecution.getVariable("nsiId")).thenReturn("5G-888")
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer")
+ when(mockExecution.getVariable("serviceType")).thenReturn("5G")
+
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5G-888")
+ DoDeleteSliceService obj = spy(DoDeleteSliceService.class)
+
+ AAIResultWrapper wrapper = new AAIResultWrapper(mockNSIReturn())
+ when(obj.getAAIClient()).thenReturn(client)
+ when(client.exists(resourceUri)).thenReturn(true)
+ when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper)
+ obj.getNSIFromAAI(mockExecution)
+ Mockito.verify(mockExecution,times(1)).setVariable(eq("nssiIdList"), captor.capture())
+ List<String> nssiIdList = captor.getValue()
+ assertNotNull(nssiIdList)
+ }
+
+ @Test
+ void testGetNSSIListFromAAI(){
+ List<String> nssiIdList = []
+ nssiIdList.add("5G-999")
+
+ when(mockExecution.getVariable("nssiIdList")).thenReturn(nssiIdList)
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer")
+ when(mockExecution.getVariable("serviceType")).thenReturn("5G")
+
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5G-999")
+ DoDeleteSliceService obj = spy(DoDeleteSliceService.class)
+
+ AAIResultWrapper wrapper = new AAIResultWrapper(mockNSSIReturn())
+ when(obj.getAAIClient()).thenReturn(client)
+ when(client.exists(resourceUri)).thenReturn(true)
+ when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper)
+ obj.getNSSIListFromAAI(mockExecution)
+ Mockito.verify(mockExecution,times(1)).setVariable(eq("nssiInstanceList"), captor.capture())
+ List<ServiceInstance> nssiInstanceList = captor.getValue()
+ assertNotNull(nssiInstanceList)
+ }
+
+ @Test
+ void testGetCurrentNSSI(){
+ ServiceInstance nssi = new ServiceInstance()
+ nssi.setServiceInstanceId("5G-999")
+ nssi.setModelInvariantId("21d57d4b-52ad-4d3c-a798-248b5bb9124a")
+ nssi.setModelVersionId("bfba363e-e39c-4bd9-a9d5-1371c28f4d22")
+ List<ServiceInstance> nssiInstanceList = []
+ nssiInstanceList.add(nssi)
+ when(mockExecution.getVariable("currentNSSIIndex")).thenReturn(0)
+ when(mockExecution.getVariable("nssiInstanceList")).thenReturn(nssiInstanceList)
+ when(mockExecution.getVariable("snssai")).thenReturn("01-010101")
+ when(mockExecution.getVariable("nsiId")).thenReturn("5G-888")
+ when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0")
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5G-777")
+ when(mockExecution.getVariable("msoRequestId")).thenReturn("4c614769-f58a-4556-8ad9-dcd903077c82")
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer")
+ when(mockExecution.getVariable("serviceType")).thenReturn("5G")
+ when(mockExecution.getVariable("proportion")).thenReturn("90")
+
+ DoDeleteSliceService ddss = new DoDeleteSliceService()
+ ddss.getCurrentNSSI(mockExecution)
+ verify(mockExecution,times(1)).setVariable(eq("currentNSSI"), captor.capture())
+ Map currentNSSI = captor.getValue()
+ assertTrue(currentNSSI.size()>0)
+ }
+
+ @Test
+ void testQuerySliceProfileFromAAI(){
+ def currentNSSI = [:]
+ currentNSSI.put("nssiServiceInstanceId","5G-999")
+ when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer")
+ when(mockExecution.getVariable("serviceType")).thenReturn("5G")
+
+ AAIResultWrapper wrapper = new AAIResultWrapper(mockSliceProfile())
+ AAIResourceUri profileUri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE_ALL, "5GCustomer", "5G", "5G-999")
+
+ DoDeleteSliceService obj = spy(DoDeleteSliceService.class)
+ when(obj.getAAIClient()).thenReturn(client)
+ when(client.exists(profileUri)).thenReturn(true)
+ when(client.get(profileUri, NotFoundException.class)).thenReturn(wrapper)
+ obj.querySliceProfileFromAAI(mockExecution)
+ verify(mockExecution,times(1)).setVariable(eq("currentNSSI"), captor.capture())
+ Map value = captor.getValue()
+ assertNotNull(currentNSSI.get('profileId'))
+ }
+
+ @Test
+ void parseNextNSSI(){
+ ServiceInstance nssi = new ServiceInstance()
+ nssi.setServiceInstanceId("5G-999")
+ nssi.setModelInvariantId("21d57d4b-52ad-4d3c-a798-248b5bb9124b")
+ nssi.setModelVersionId("bfba363e-e39c-4bd9-a9d5-1371c28f4d22")
+ List<ServiceInstance> nssiInstanceList = []
+ nssiInstanceList.add(nssi)
+ when(mockExecution.getVariable("currentNSSIIndex")).thenReturn(0)
+ when(mockExecution.getVariable("nssiInstanceList")).thenReturn(nssiInstanceList)
+
+ DoDeleteSliceService ddss = new DoDeleteSliceService()
+ ddss.parseNextNSSI(mockExecution)
+ verify(mockExecution,times(1)).setVariable(eq("isAllNSSIFinished"), captor.capture())
+ boolean isAllNSSIFinished = captor.getValue()
+ assertTrue(isAllNSSIFinished)
+ }
+
+ private String mockSliceProfile(){
+ String expect =
+ """{
+ "slice-profile": [
+ {
+ "profile-id": "ddf57704-fe8d-417b-882d-2f2a12ddb225",
+ "latency": 20,
+ "max-number-of-UEs": 0,
+ "coverage-area-TA-list": "[{\\"province\\":\\"??\\",\\"city\\":\\"???\\",\\"county\\":\\"???\\",\\"street\\":\\"?????\\"}]",
+ "ue-mobility-level": "stationary",
+ "resource-sharing-level": "0",
+ "exp-data-rate-UL": 100,
+ "exp-data-rate-DL": 100,
+ "activity-factor": 0,
+ "e2e-latency": 0,
+ "jitter": 0,
+ "survival-time": 0,
+ "exp-data-rate": 0,
+ "payload-size": 0,
+ "traffic-density": 0,
+ "conn-density": 0,
+ "s-nssai": "01003",
+ "resource-version": "1580800791373"
+ }
+ ]
+ }
+ """
+ return expect
+ }
+
+ private String mockNSSIReturn(){
+ String expect =
+ """
+ {
+ "service-instance-id": "5G-999",
+ "service-instance-name": "eMBB_Slice_NSSI_5GCustomer",
+ "service-type": "eMBB",
+ "service-role": "nssi",
+ "environment-context": "cn",
+ "model-invariant-id": "21d57d4b-52ad-4d3c-a798-248b5bb9124a",
+ "model-version-id": "bfba363e-e39c-4bd9-a9d5-1371c28f4d22",
+ "service-instance-location-id": "300-01|300-02",
+ "resource-version": "1578449638032",
+ "orchestration-status": "activated",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "service-instance",
+ "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+ "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/5G-888",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "5GCustomer"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "5G"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "5G-888"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "eMBB_e2e_Slice_Service_5GCustomer"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ """
+ return expect
+ }
+
+ private String mockNSIReturn(){
+ String expect =
+ """
+ {
+ "service-instance-id": "5G-888",
+ "service-instance-name": "eMBB_e2e_Slice_Service_5GCustomer",
+ "service-type": "embb",
+ "service-role": "nsi",
+ "model-invariant-id": "0e9bcb9a-c832-433b-a0c1-74866768f608",
+ "model-version-id": "2c5fd79d-0f84-4057-9222-952cb6f27036",
+ "service-instance-location-id": "300-01|300-02",
+ "resource-version": "1579691104911",
+ "orchestration-status": "activated",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "service-instance",
+ "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+ "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/5G-999",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "5GCustomer"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "5G"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "5G-999"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "eMBB_Slice_NSSI_5GCustomer"
+ }
+ ]
+ },
+ {
+ "related-to": "allotted-resource",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/5G-777/allotted-resources/allotted-resource/5G-1234",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "5GCustomer"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "5G"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "5G-777"
+ },
+ {
+ "relationship-key": "allotted-resource.id",
+ "relationship-value": "5G-1234"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "allotted-resource.description"
+ },
+ {
+ "property-key": "allotted-resource.allotted-resource-name"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ """
+ return expect
+ }
+
+ private String mockQueryAllottedResource(){
+ String expect =
+ """{
+ "allotted-resource": [
+ {
+ "id": "5G-1234",
+ "resource-version": "1577454983471",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "service-instance",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/5G-888",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "5GCustomer"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "5G"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "5G-888"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "eMBB_e2e_Slice_Service_5GCustomer"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ }
+ """
+ return expect
+ }
+
+ String mockQuerySliceServiceReturn(){
+ String expect =
+ """{
+ "service-instance-id": "5G-777",
+ "service-instance-name": "eMBB_e2e_Slice_Service_5GCustomer",
+ "service-type": "embb",
+ "service-role": "e2eslice-service",
+ "environment-context": "01-010101",
+ "model-invariant-id": "e65d737a-41e0-4ad1-958f-56defdf2e907",
+ "model-version-id": "f2f5967e-72d3-4c5c-b880-e214e71dba4e",
+ "service-instance-location-id": "300-01|300-02",
+ "resource-version": "1578449638436",
+ "orchestration-status": "activated",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "service-instance",
+ "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+ "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/5G-666",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "5GCustomer"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "5G"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "5G-666"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "eMBB_Slice_Communication_Service_5GCustomer"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ """
+ return expect
+ }
+
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy
index f356845a1e..a8d07b696c 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy
@@ -44,6 +44,7 @@ import org.onap.so.bpmn.common.scripts.MsoGroovyTest
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.client.aai.AAIObjectPlurals
import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.uri.AAIPluralResourceUri
import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.client.graphinventory.entities.uri.Depth
@@ -105,7 +106,7 @@ class DoDeleteVfModuleFromVnfTest extends MsoGroovyTest {
List fqdnList = new ArrayList()
fqdnList.add("test")
when(mockExecution.getVariable("DDVFMV_contrailNetworkPolicyFqdnList")).thenReturn(fqdnList)
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
+ AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
uri.queryParam("network-policy-fqdn", "test")
NetworkPolicies networkPolicies = new NetworkPolicies();
NetworkPolicy networkPolicy = new NetworkPolicy();
@@ -127,7 +128,7 @@ class DoDeleteVfModuleFromVnfTest extends MsoGroovyTest {
List fqdnList = new ArrayList()
fqdnList.add("test")
when(mockExecution.getVariable("DDVFMV_contrailNetworkPolicyFqdnList")).thenReturn(fqdnList)
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
+ AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
uri.queryParam("network-policy-fqdn", "test")
when(client.get(NetworkPolicies.class, uri)).thenReturn(Optional.empty())
deleteVfModuleFromVnf.deleteNetworkPoliciesFromAAI(mockExecution)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleTest.groovy
index b56e108faf..815b3a389c 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleTest.groovy
@@ -47,6 +47,7 @@ import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.mock.FileUtil
import org.onap.so.client.aai.AAIObjectPlurals
import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.uri.AAIPluralResourceUri
import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
@@ -104,7 +105,7 @@ class DoDeleteVfModuleTest extends MsoGroovyTest{
NetworkPolicy networkPolicy = new NetworkPolicy()
networkPolicy.setNetworkPolicyId("NP1")
networkPolicies.getNetworkPolicy().add(networkPolicy)
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
+ AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
uri.queryParam("network-policy-fqdn", "test")
when(client.get(NetworkPolicies.class, uri)).thenReturn(Optional.of(networkPolicies))
doDeleteVfModule.deleteNetworkPoliciesFromAAI(mockExecution)
@@ -120,7 +121,7 @@ class DoDeleteVfModuleTest extends MsoGroovyTest{
NetworkPolicy networkPolicy = new NetworkPolicy()
networkPolicy.setNetworkPolicyId("NP1")
networkPolicies.getNetworkPolicy().add(networkPolicy)
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
+ AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
uri.queryParam("network-policy-fqdn", "test")
when(client.get(NetworkPolicies.class, uri)).thenReturn(Optional.of(networkPolicies))
AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, "NP1")
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResourcesTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResourcesTest.java
index 289d97108f..05b0db5d25 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResourcesTest.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResourcesTest.java
@@ -33,8 +33,6 @@ import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcherTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcherTest.java
new file mode 100644
index 0000000000..3c568ffc83
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcherTest.java
@@ -0,0 +1,182 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.pnf.delegate;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.onap.aai.domain.yang.Pnf;
+import org.onap.so.bpmn.core.json.JsonUtils;
+import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement;
+import org.onap.so.db.catalog.beans.PnfResourceCustomization;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.onap.so.serviceinstancebeans.RequestInfo;
+import org.onap.so.serviceinstancebeans.RequestParameters;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import java.io.IOException;
+import java.util.*;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
+import static org.mockito.BDDMockito.given;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.when;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.*;
+import static org.onap.so.client.cds.PayloadConstants.PRC_TARGET_SOFTWARE_VERSION;
+
+
+@RunWith(SpringJUnit4ClassRunner.class)
+public class NfSoftwareUpgradeDispatcherTest {
+
+ private static final String TEST_PROCESS_KEY = "processKey1";
+ private static final String PROCESS_KEY = "testProcessKey";
+ private static final String TEST_PNF_RESOURCE_INSTANCE_NAME = "PNF_demo_resource";
+ private static final String TEST_PNF_RESOURCE_BLUEPRINT_NAME = "blueprintOnap";
+ private static final String TEST_PNF_RESOURCE_BLUEPRINT_VERSION = "1.0.1";
+ private static final String TEST_PNF_RESOURCE_CUSTOMIZATION_UUID = "9acb3a83-8a52-412c-9a45-901764938144";
+ private static final String TEST_PNF_CORRELATION_ID = "PNFDemo";
+ private static final String TEST_PNF_UUID = "FakeID";
+ private static final String TEST_PRC_CONTROLLER_ACTOR = "cds";
+ private static final String TEST_TARGET_SOFTWARE_VERSION = "demo-sw-ver2.0.0";
+
+ private static final String TEST_BPMN_REQUEST = "{\"requestDetails\":{" + "\"requestInfo\":{"
+ + "\"source\":\"VID\"," + "\"suppressRollback\":false," + "\"requestorId\":\"demo\","
+ + "\"productFamilyId\":\"SWUPid\"}," + "\"modelInfo\":{"
+ + "\"modelType\":\"service\",\"modelInvariantUuid\":\"439b7a2f-9524-4dbf-9eee-f2e05521df3f\","
+ + "\"modelInvariantId\":\"439b7a2f-9524-4dbf-9eee-f2e05521df3f\","
+ + "\"modelUuid\":\"42daaac6-5017-4e1e-96c8-6a27dfbe1421\",\"modelName\":\"PNF_int_service_2\","
+ + "\"modelVersion\":\"1.0\"},\"requestParameters\":{\"userParams\":[{\"name\":\"aic_zone\","
+ + "\"value\":\"nova\"},{\"name\":\"pnfId\",\"value\":\"PNFDemo\"},{\"name\":\"targetSoftwareVersion\",\"value\":\"demo-sw-ver2.0.0\"}],"
+ + "\"subscriptionServiceType\":\"SWUP\",\"aLaCarte\":false,\"pnfCorrelationId\":\"PNFDemo\"},"
+ + "\"cloudConfiguration\":{\"lcpCloudRegionId\":\"regionOne\",\"tenantId\":\"09a63533072f4a579d5c99c3b8fe94c6\"},"
+ + "\"subscriberInfo\":{\"globalSubscriberId\":\"ADemoCustomerInEric\"},\"project\":{\"projectName\":\"Project-Demonstration\"},"
+ + "\"owningEntity\":{\"owningEntityId\":\"5eae949c-1c50-4780-b8b5-7cbeb08856b4\",\"owningEntityName\":\"OE-Demonstration\"}}}";
+ /**
+ * Testing model UUID, should be the same as specified in the TEST_SERVICE_MODEL_INFO.
+ */
+ private static final String TEST_MODEL_UUID = "42daaac6-5017-4e1e-96c8-6a27dfbe1421";
+
+ @InjectMocks
+ private NfSoftwareUpgradeDispatcher nfSoftwareUpgradeDispatcher;
+
+ @Mock
+ private PnfManagement pnfManagement;
+
+ @Mock
+ private CatalogDbClient catalogDbClient;
+
+ @Mock
+ private ObjectMapper mapper;
+
+ private DelegateExecution execution = new DelegateExecutionFake();
+
+ @Before
+ public void setUp() throws IOException {
+ List<PnfResourceCustomization> pnfResourceCustomizations = new ArrayList<>();
+ pnfResourceCustomizations.add(buildPnfResourceCustomization());
+ given(catalogDbClient.getPnfResourceCustomizationByModelUuid(TEST_MODEL_UUID))
+ .willReturn(pnfResourceCustomizations);
+ execution.setVariable(PROCESS_KEY, TEST_PROCESS_KEY);
+ execution.setVariable("bpmnRequest", TEST_BPMN_REQUEST);
+ mockMapper();
+ mockAai();
+
+ }
+
+
+ @Test
+ public void testExecution_validCatalogDb_skipVariableSet() {
+ try {
+ nfSoftwareUpgradeDispatcher.execute(execution);
+ assertThat(execution.getVariable(MODEL_UUID)).isEqualTo(TEST_MODEL_UUID);
+ assertThat(execution.getVariable(PRC_TARGET_SOFTWARE_VERSION)).isEqualTo(TEST_TARGET_SOFTWARE_VERSION);
+ assertThat(execution.getVariable(PRC_BLUEPRINT_NAME)).isEqualTo(TEST_PNF_RESOURCE_BLUEPRINT_NAME);
+ assertThat(execution.getVariable(PRC_BLUEPRINT_VERSION)).isEqualTo(TEST_PNF_RESOURCE_BLUEPRINT_VERSION);
+ assertThat(execution.getVariable(PRC_CUSTOMIZATION_UUID)).isEqualTo(TEST_PNF_RESOURCE_CUSTOMIZATION_UUID);
+ assertThat(execution.getVariable(PRC_INSTANCE_NAME)).isEqualTo(TEST_PNF_RESOURCE_INSTANCE_NAME);
+ assertThat(execution.getVariable(PNF_CORRELATION_ID)).isEqualTo(TEST_PNF_CORRELATION_ID);
+ assertThat(execution.getVariable(PNF_UUID)).isEqualTo(TEST_PNF_UUID);
+ assertThat(execution.getVariable(PRC_CONTROLLER_ACTOR)).isEqualTo(TEST_PRC_CONTROLLER_ACTOR);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Exception thrown" + e.getMessage());
+ }
+ }
+
+ private void mockAai() throws IOException {
+ Pnf pnf = new Pnf();
+ pnf.setPnfId(TEST_PNF_UUID);
+ when(pnfManagement.getEntryFor(TEST_PNF_CORRELATION_ID)).thenReturn(Optional.of(pnf));
+ }
+
+ private PnfResourceCustomization buildPnfResourceCustomization() {
+ PnfResourceCustomization pnfResourceCustomization = new PnfResourceCustomization();
+ pnfResourceCustomization.setSkipPostInstConf(true);
+ pnfResourceCustomization.setBlueprintName(TEST_PNF_RESOURCE_BLUEPRINT_NAME);
+ pnfResourceCustomization.setBlueprintVersion(TEST_PNF_RESOURCE_BLUEPRINT_VERSION);
+ pnfResourceCustomization.setModelInstanceName(TEST_PNF_RESOURCE_INSTANCE_NAME);
+ pnfResourceCustomization.setModelCustomizationUUID(TEST_PNF_RESOURCE_CUSTOMIZATION_UUID);
+ pnfResourceCustomization.setControllerActor(TEST_PRC_CONTROLLER_ACTOR);
+ return pnfResourceCustomization;
+ }
+
+ private void mockMapper() throws IOException {
+ RequestDetails bpmnRequestDetails = new RequestDetails();
+
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setInstanceName("demo");
+ bpmnRequestDetails.setRequestInfo(requestInfo);
+
+ RequestParameters requestParameters = new RequestParameters();
+ List<Map<String, Object>> userParams = new ArrayList<>();
+ Map<String, Object> map = new HashMap<>();
+ map.put("name", "targetSoftwareVersion");
+ map.put("value", TEST_TARGET_SOFTWARE_VERSION);
+ userParams.add(map);
+ map = new HashMap<>();
+ map.put("name", "pnfName");
+ map.put("value", "PNFDemo");
+ userParams.add(map);
+ requestParameters.setUserParams(userParams);
+
+ bpmnRequestDetails.setRequestParameters(requestParameters);
+
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelInvariantUuid("439b7a2f-9524-4dbf-9eee-f2e05521df3f");
+ modelInfo.setModelInvariantId("439b7a2f-9524-4dbf-9eee-f2e05521df3f");
+ modelInfo.setModelUuid("42daaac6-5017-4e1e-96c8-6a27dfbe1421");
+ modelInfo.setModelName("PNF_int_service_2");
+ modelInfo.setModelVersion("1.0");
+
+ bpmnRequestDetails.setModelInfo(modelInfo);
+
+
+ doReturn(bpmnRequestDetails).when(mapper).readValue(
+ JsonUtils.getJsonValue(String.valueOf(execution.getVariable("bpmnRequest")), "requestDetails"),
+ RequestDetails.class);
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java
index 8577d9555b..b93902d9f7 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java
@@ -50,6 +50,11 @@ public class PnfManagementTestImpl implements PnfManagement {
}
@Override
+ public void updateEntry(String pnfCorrelationId, Pnf entry) throws IOException {
+ created.put(pnfCorrelationId, entry);
+ }
+
+ @Override
public void createRelation(String serviceInstanceId, String pnfName) {}
public Map<String, Pnf> getCreated() {
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementThrowingException.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementThrowingException.java
index f9b467c650..77377db9d9 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementThrowingException.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementThrowingException.java
@@ -38,6 +38,11 @@ public class PnfManagementThrowingException implements PnfManagement {
}
@Override
+ public void updateEntry(String pnfCorrelationId, Pnf entry) throws IOException {
+ throw new IOException();
+ }
+
+ @Override
public void createRelation(String serviceInstanceId, String pnfName) throws IOException {
throw new IOException();
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/UpdatePnfEntryInAaiTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/UpdatePnfEntryInAaiTest.java
new file mode 100644
index 0000000000..bddfe5b180
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/UpdatePnfEntryInAaiTest.java
@@ -0,0 +1,91 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.bpmn.infrastructure.pnf.delegate;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.onap.aai.domain.yang.Pnf;
+import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import static org.junit.Assert.*;
+import java.io.IOException;
+import java.util.Optional;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.BDDMockito.given;
+import static org.mockito.Mockito.*;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID;
+import static org.onap.so.client.cds.PayloadConstants.PRC_TARGET_SOFTWARE_VERSION;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+public class UpdatePnfEntryInAaiTest {
+
+ @InjectMocks
+ private UpdatePnfEntryInAai updatePnfEntryInAai;
+
+ @Mock
+ private PnfManagement pnfManagementTest;
+
+ private DelegateExecution execution;
+
+
+
+ @Test
+ public void shouldSetSwVersion() throws Exception {
+ // given
+ setupPnf();
+ setupExecution();
+
+ // when
+ updatePnfEntryInAai.execute(execution);
+
+ // verify
+ Optional<Pnf> modifiedEntry = pnfManagementTest.getEntryFor("testPnfCorrelationId");
+ assertNotNull(modifiedEntry.get());
+ assertThat(modifiedEntry.get().getPnfId()).isEqualTo("testtest");
+ assertThat(modifiedEntry.get().getPnfName()).isEqualTo("testPnfCorrelationId");
+ assertThat(modifiedEntry.get().getSwVersion()).isEqualTo("demo-1.2");
+ verify(pnfManagementTest, times(2)).getEntryFor(anyString());
+ }
+
+ private void setupPnf() {
+ try {
+ Pnf pnf = new Pnf();
+ pnf.setSwVersion("1");
+ pnf.setPnfId("testtest");
+ pnf.setPnfName("testPnfCorrelationId");
+ doReturn(Optional.of(pnf)).when(pnfManagementTest).getEntryFor(anyString());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void setupExecution() {
+ execution = mock(DelegateExecution.class);
+ given(execution.getVariable(eq(PNF_CORRELATION_ID))).willReturn("testPnfCorrelationId");
+ given(execution.getVariable(eq(PNF_UUID))).willReturn("testtest");
+ given(execution.getVariable(eq(PRC_TARGET_SOFTWARE_VERSION))).willReturn("demo-1.2");
+ }
+}