diff options
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common')
110 files changed, 4096 insertions, 5703 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/pom.xml b/bpmn/so-bpmn-infrastructure-common/pom.xml index 1a4e9c6ee8..f4e173dc6f 100644 --- a/bpmn/so-bpmn-infrastructure-common/pom.xml +++ b/bpmn/so-bpmn-infrastructure-common/pom.xml @@ -32,11 +32,11 @@ </execution> </executions> </plugin> - <plugin> + <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.0</version> - <configuration> + <configuration> <compilerId>groovy-eclipse-compiler</compilerId> </configuration> @@ -56,6 +56,30 @@ </plugins> <pluginManagement> <plugins> + <plugin> + <groupId>org.eclipse.m2e</groupId> + <artifactId>lifecycle-mapping</artifactId> + <version>1.0.0</version> + <configuration> + <lifecycleMappingMetadata> + <pluginExecutions> + <pluginExecution> + <pluginExecutionFilter> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <versionRange>[1.0.0,)</versionRange> + <goals> + <goal>unpack</goal> + </goals> + </pluginExecutionFilter> + <action> + <execute /> + </action> + </pluginExecution> + </pluginExecutions> + </lifecycleMappingMetadata> + </configuration> + </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> 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 index 4ed0ea6a44..8e3bef69de 100644 --- 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 @@ -33,11 +33,11 @@ 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.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.so.db.request.beans.OperationStatus 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/ActivateSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceService.groovy index a8c3ef189e..334f5b4e4f 100644 --- 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 @@ -32,11 +32,11 @@ 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.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.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 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 index 3233bfff61..ecbe766695 100644 --- 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 @@ -26,7 +26,7 @@ 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.aaiclient.client.aai.AAIResourcesClient import org.onap.so.db.request.beans.OperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -129,7 +129,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { /** * check service status through request operation id, update operation status */ - def preCheckServiceStatusReq = { DelegateExecution execution -> + void preCheckServiceStatusReq(DelegateExecution execution) { logger.trace(Prefix + "preCheckServiceStatusReq Start") String serviceInstanceId = execution.getVariable("serviceInstanceId") as String String operationId = execution.getVariable("operationId") as String @@ -142,7 +142,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { * handle service status, if service status is finished or error, set the service status * @param execution */ - def handlerServiceStatusResp = { DelegateExecution execution -> + void handlerServiceStatusResp(DelegateExecution execution) { logger.trace(Prefix + "handlerServiceStatusResp Start") String msg try { @@ -203,7 +203,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { } - def timeWaitDelay = { DelegateExecution execution -> + void timeWaitDelay(DelegateExecution execution) { Long startTime = execution.getVariable("startTime") as Long Long timeOut = execution.getVariable("timeOut") as Long @@ -221,7 +221,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { } - private handlerTimeOut = { DelegateExecution execution -> + private handlerTimeOut(DelegateExecution execution) { Map<String, Object> paramMap = execution.getVariable("timeOutParamMap") as Map @@ -229,7 +229,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { } - private handlerSuccess = { DelegateExecution execution, String result -> + private handlerSuccess(DelegateExecution execution, String result) { Map<String, Object> paramMap = execution.getVariable("successParamMap") as Map @@ -237,7 +237,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { } - private handlerError = { DelegateExecution execution, String result -> + private handlerError(DelegateExecution execution, String result) { Map<String, Object> paramMap = execution.getVariable("errorParamMap") as Map @@ -245,7 +245,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { } - private handlerProcess = { DelegateExecution execution, String result, def paramMap, def status, def msg -> + private handlerProcess(DelegateExecution execution, String result, def paramMap, def status, def msg) { if (paramMap != null) { for (Map.Entry<String, Object> entry : paramMap.entrySet()) { @@ -260,7 +260,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { if (isBlank(execution.getVariable("operationContent") as String)) { - String operationContent = execution.getVariable("processServiceType") + " " + + String operationContent = execution.getVariable("processServiceType") + " " + execution.getVariable("operationType") + " operation finished " + msg execution.setVariable("operationContent", operationContent) } @@ -275,7 +275,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { /** * judge if the service processing success finished */ - private isSuccessCompleted = { DelegateExecution execution, String result -> + private Boolean isSuccessCompleted(DelegateExecution execution, String result) { //successConditions: processing end success conditions List<String> successConditions = execution.getVariable("successConditions") as List @@ -291,7 +291,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { /** * judge if the service processing error finished */ - private isErrorCompleted = { DelegateExecution execution, String result -> + private Boolean isErrorCompleted(DelegateExecution execution, String result) { //errorConditions: processing end error conditions List<String> errorConditions = execution.getVariable("errorConditions") as List @@ -304,7 +304,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { } - def preUpdateOperationProgress = { DelegateExecution execution -> + void preUpdateOperationProgress(DelegateExecution execution) { logger.trace(Prefix + "prepareUpdateOperationStatus Start") def progress = execution.getVariable("progress") as Integer @@ -314,7 +314,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { def resProgress = (initProgress + (endProgress - initProgress) / 100 * progress) as Integer def operationType = execution.getVariable("operationType") - def operationContent = execution.getVariable("processServiceType") + " " + + def operationContent = execution.getVariable("processServiceType") + " " + operationType + " operation processing " + resProgress // update status creating diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy index ced1b928fc..be5a029062 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy @@ -41,10 +41,10 @@ import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.builder.AbstractBuilder -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.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils import org.onap.so.bpmn.infrastructure.workflow.service.ServicePluginFactory import java.util.Map 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 index 71da2abd05..12cd0dde0b 100644 --- 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 @@ -36,10 +36,10 @@ 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.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.so.db.request.beans.OperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -293,11 +293,11 @@ class CreateCommunicationService extends AbstractServiceTaskProcessor { //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") + Integer expDataRateDL = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.expDataRateDL") as Integer + Integer expDataRateUL = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.expDataRateUL") as Integer + Integer latency = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.latency") as Integer + Integer maxNumberOfUEs = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.maxNumberofUEs") as Integer + 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") @@ -383,10 +383,7 @@ class CreateCommunicationService extends AbstractServiceTaskProcessor { } e2eInputMap.put("sNSSAI", execution.getVariable("sNSSAI_id")) - e2eInputMap.put("areaTrafficCapDL", 100) - e2eInputMap.put("areaTrafficCapUL", 100) - e2eInputMap.put("sST", execution.getVariable("csServiceType")) - + e2eInputMap.put("sST", execution.getVariable("csServiceType")) execution.setVariable("e2eInputMap", e2eInputMap) execution.setVariable("e2eServiceType", e2eServiceDecomposition.getServiceType()) execution.setVariable("e2eModelInvariantUuid", e2eServiceDecomposition.getModelInfo().getModelInvariantUuid()) 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 650f79b633..c9ad18b0be 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 @@ -35,10 +35,10 @@ import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.domain.VnfResource 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.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum 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 7d1bc4c779..2b9e43109c 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 @@ -41,11 +41,11 @@ import org.onap.so.bpmn.core.domain.ModelInfo import org.onap.so.bpmn.core.domain.ResourceType import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.client.aai.AAIObjectPlurals -import org.onap.so.client.aai.AAIResourcesClient -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.aaiclient.client.aai.AAIObjectPlurals +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory 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/CreateSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy index 1efc1c11aa..15a0f34482 100644 --- 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 @@ -24,10 +24,10 @@ 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 org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import javax.ws.rs.core.Response @@ -155,9 +155,14 @@ public class CreateSliceService extends AbstractServiceTaskProcessor { Map<String, Object> parameterObject = (Map<String, Object>) serviceObject.get("parameters") Map<String, Object> requestInputs = (Map<String, Object>) parameterObject.get("requestInputs") + def serviceProfile = [:] + for(entry in requestInputs) { + serviceProfile[entry.key] = entry.value + } + execution.setVariable("serviceInputParams", inputMap) execution.setVariable("uuiRequest", uuiRequest) - execution.setVariable("serviceProfile", requestInputs) + execution.setVariable("serviceProfile", serviceProfile) //TODO //execution.setVariable("serviceInputParams", jsonUtil.getJsonValue(siRequest, "requestDetails.requestParameters.userParams")) @@ -344,7 +349,7 @@ public class CreateSliceService extends AbstractServiceTaskProcessor { String orchStatus = execution.getVariable("orchestrationStatus") try { - ServiceInstance si = execution.getVariable("serviceInstanceData") + ServiceInstance si = ServiceInstance si = new ServiceInstance() si.setOrchestrationStatus(orchStatus) AAIResourcesClient client = new AAIResourcesClient() AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy index 2e664d90da..80b6641bb7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy @@ -23,9 +23,9 @@ package org.onap.so.bpmn.infrastructure.scripts 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 org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory 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/CreateVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy index 33a607268d..1dfe13738e 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 @@ -29,9 +29,9 @@ 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.client.aai.AAIObjectType -import org.onap.so.client.aai.entities.uri.AAIResourceUri -import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.logging.filter.base.ErrorCode 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/Delete3rdONAPE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy index da486bb1c3..057863be28 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy @@ -41,10 +41,10 @@ import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.ExternalAPIUtil import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.bpmn.core.UrnPropertiesReader -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.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory 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/DeleteCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy index b121083954..26936bfd71 100644 --- 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 @@ -36,11 +36,11 @@ 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.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.so.db.request.beans.OperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -199,7 +199,7 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { * 再次调用deleteE2EServiceInstance接口,然后获取到operationid, */ void sendRequest2NSMFWF(DelegateExecution execution) { - LOGGER.trace("begin preRequestSend2NSMF") + LOGGER.debug("begin preRequestSend2NSMF") try { //url:/onap/so/infra/e2eServiceInstances/v3/{serviceInstanceId}" def NSMF_endpoint = UrnPropertiesReader.getVariable("mso.infra.endpoint.url", execution) @@ -213,9 +213,13 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { """ requestBody.replaceAll("\\s+", "") - String basicAuthValue = UrnPropertiesReader.getVariable("mso.infra.endpoint.auth", execution) + String msoKey = UrnPropertiesReader.getVariable("mso.msoKey", execution) + String basicAuth = UrnPropertiesReader.getVariable("mso.infra.endpoint.auth", execution) + String basicAuthValue = utils.encrypt(basicAuth, msoKey) + String encodeString = utils.getBasicAuth(basicAuthValue, msoKey) + HttpClient httpClient = getHttpClientFactory().newJsonClient(new URL(url), ONAPComponents.SO) - httpClient.addAdditionalHeader("Authorization", basicAuthValue) + httpClient.addAdditionalHeader("Authorization", encodeString) httpClient.addAdditionalHeader("Accept", "application/json") Response httpResponse = httpClient.delete(requestBody) handleNSSMFWFResponse(httpResponse, execution) @@ -228,7 +232,7 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - LOGGER.trace("exit preRequestSend2NSMF") + LOGGER.debug("exit preRequestSend2NSMF") } /** diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteDeviceResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteDeviceResource.groovy index 1d3b2757e7..99289b85b1 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteDeviceResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteDeviceResource.groovy @@ -37,10 +37,10 @@ import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.builder.AbstractBuilder import org.onap.so.client.HttpClient -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.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.slf4j.Logger import org.slf4j.LoggerFactory import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy index cdc242dbd8..cc5b8cf1e8 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy @@ -38,11 +38,11 @@ import org.onap.so.bpmn.core.domain.ModelInfo import org.onap.so.bpmn.core.domain.ResourceType import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.bpmn.core.UrnPropertiesReader -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.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory 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 index 45fd049841..d22ee5e82f 100644 --- 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 @@ -30,11 +30,11 @@ 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.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.so.db.request.beans.OperationStatus 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 eb2ec2bc9d..005f0f3c6b 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 @@ -22,10 +22,16 @@ package org.onap.so.bpmn.infrastructure.scripts -import org.onap.so.logger.LoggingAnchor +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.VolumeGroup +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.logging.filter.base.ErrorCode import org.onap.so.bpmn.common.scripts.AaiUtil; import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor; import org.onap.so.bpmn.common.scripts.ExceptionUtil; @@ -33,19 +39,13 @@ import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.VidUtils; import org.onap.so.bpmn.core.UrnPropertiesReader 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 org.onap.so.constants.Defaults -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 groovy.json.JsonSlurper -import javax.ws.rs.NotFoundException - /** * This groovy class supports the <class>DeleteVfModuleVolume.bpmn</class> process. */ @@ -285,7 +285,7 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { if(wrapper.getRelationships().isPresent()) { List<AAIResourceUri> tenantURIList = wrapper.getRelationships().get().getRelatedAAIUris(AAIObjectType.TENANT) if(!tenantURIList.isEmpty()){ - return tenantURIList.get(0).getURIKeys().get("tenant-id") + return tenantURIList.get(0).getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId) } } return null 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 index d5b554d841..4a8469cc8d 100644 --- 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 @@ -1,31 +1,45 @@ +/*- + * ============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.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.common.scripts.NssmfAdapterUtils 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.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory 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 @@ -36,7 +50,8 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() - RequestsDbClient requestsDbClient = new RequestsDbClient() + + private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil) /** * Pre Process the BPMN Flow Request @@ -65,8 +80,9 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi 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") + Map<String, Object> nstSolution = execution.getVariable("nstSolution") as Map + String modelUuid = nstSolution.get("UUID") + String modelInvariantUuid = nstSolution.get("invariantUUID") String serviceModelInfo = """{ "modelInvariantUuid":"${modelInvariantUuid}", "modelUuid":"${modelUuid}", @@ -95,17 +111,15 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi } void updateRelationship(DelegateExecution execution) { - logger.trace("Enter update relationship in DoAllocateNSIandNSSI()") - String nsiServiceInstanceId = execution.getVariable("nsiServiceInstanceId") + logger.debug("Enter update relationship in DoAllocateNSIandNSSI()") 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.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), nsiServiceInstanceID) //AAIResourceUri nsiServiceuri = AAIUriFactory.createResourceUri(AAIObjectType.QUERY_ALLOTTED_RESOURCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), nsiServiceInstanceID) try { @@ -120,14 +134,8 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi // 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) + + AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), execution.getVariable("sliceServiceInstanceId"), allottedResourceId) getAAIClient().connect(allottedResourceUri,nsiServiceuri) List<String> nssiAssociated = new ArrayList<>() @@ -144,7 +152,14 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi } execution.setVariable("nssiAssociated",nssiAssociated) execution.setVariable("nsiServiceInstanceName",nsiServiceInstance.getServiceInstanceName()) - logger.trace("Exit update relationship in DoAllocateNSIandNSSI()") + }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) + } + logger.debug("Exit update relationship in DoAllocateNSIandNSSI()") } void prepareNssiModelInfo(DelegateExecution execution){ @@ -156,7 +171,7 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi { try { AAIResourcesClient resourceClient = new AAIResourcesClient() - AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), nssiID) + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), 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() @@ -179,13 +194,13 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi } void createNSIinAAI(DelegateExecution execution) { - logger.trace("Enter CreateNSIinAAI in DoAllocateNSIandNSSI()") + logger.debug("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") + String sliceInstanceName = "nsi_"+execution.getVariable("sliceServiceInstanceName") nsi.setServiceInstanceName(sliceInstanceName) String serviceType = execution.getVariable("serviceType") nsi.setServiceType(serviceType) @@ -202,11 +217,20 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi //nsi.setEnvironmentContext(snssai) String serviceRole = "nsi" nsi.setServiceRole(serviceRole) + String msg = "" try { AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), sliceInstanceId) - client.create(uri, nsi) + AAIResourceUri nsiServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), sliceInstanceId) + client.create(nsiServiceUri, nsi) + + Relationship relationship = new Relationship() + logger.info("Creating Allotted resource relationship, nsiServiceUri: " + nsiServiceUri.build().toString()) + relationship.setRelatedLink(nsiServiceUri.build().toString()) + AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE, + execution.getVariable("globalSubscriberId"),execution.getVariable("subscriptionServiceType"), + execution.getVariable("sliceServiceInstanceId"), execution.getVariable("allottedResourceId")).relationshipAPI() + client.create(allottedResourceUri, relationship) } catch (BpmnError e) { throw e @@ -243,7 +267,7 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi execution.setVariable("maxIndex",maxIndex) execution.setVariable('nsiServiceInstanceId',sliceInstanceId) execution.setVariable("nsiServiceInstanceName",sliceInstanceName) - logger.trace("Exit CreateNSIinAAI in DoAllocateNSIandNSSI()") + logger.debug("Exit CreateNSIinAAI in DoAllocateNSIandNSSI()") } void getOneNsstInfo(DelegateExecution execution){ @@ -271,7 +295,7 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi String domain = jsonUtil.getJsonValue(content, "metadata.domainType") Map<String, Object> nssiMap = execution.getVariable("nssiMap") - String servicename = execution.getVariable("serviceInstanceName") + String servicename = execution.getVariable("sliceServiceInstanceName") String nsiname = "nsi_"+servicename nssiMap.put(domain,"""{ "serviceInstanceId":"", @@ -335,4 +359,4 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi } logger.trace("Exit updateCurrentIndex in DoAllocateNSIandNSSI()") } -} +}
\ No newline at end of file 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 index d786cb0ba1..081dddab99 100644 --- 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 @@ -4,7 +4,6 @@ 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 @@ -19,27 +18,23 @@ 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.common.scripts.NssmfAdapterUtils 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.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.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 @@ -53,6 +48,8 @@ class DoAllocateNSSI extends org.onap.so.bpmn.common.scripts.AbstractServiceTask JsonUtils jsonUtil = new JsonUtils() + private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil) + /** * Pre Process the BPMN Flow Request * Inclouds: @@ -155,138 +152,82 @@ class DoAllocateNSSI extends org.onap.so.bpmn.common.scripts.AbstractServiceTask 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) + logger.debug("Enter sendUpdateRequestNSSMF in DoAllocateNSSI()") 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.") - } + String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles" + + String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest) - if(httpResponse.hasEntity()){ - String nssmfResponse = httpResponse.readEntity(String.class) + if (nssmfResponse != null) { 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.") + + } else { + logger.error("received error message from NSSMF : "+ nssmfResponse) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"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) - + logger.debug("Enter sendCreateRequestNSSMF in DoAllocateNSSI()") //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.") - } + String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles" + + String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest) - if(httpResponse.hasEntity()){ - String nssmfResponse = httpResponse.readEntity(String.class) + if (nssmfResponse != null) { 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.") + + } else { + logger.error("received error message from NSSMF : "+ nssmfResponse) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.") } - logger.trace("Exit sendCreateRequestNSSMF in DoAllocateNSSI()") + logger.debug("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) + logger.debug("Enter getNSSMFProgresss in DoAllocateNSSI()") 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.") - } + String strUrl="/api/rest/provMns/v1/NSS/jobs/" + execution.getVariable("jobId") + + String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, strUrl, nssmfRequest) - if(httpResponse.hasEntity()){ - String nssmfResponse = httpResponse.readEntity(String.class) + if(nssmfResponse != null){ Boolean isNSSICreated = false execution.setVariable("nssmfResponse", nssmfResponse) - Integer progress = java.lang.Integer.parseInt(jsonUtil.getJsonValue(nssmfResponse, "responseDescriptor.progress")) + Integer progress = 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) + if(progress > 99) isNSSICreated = true execution.setVariable("isNSSICreated",isNSSICreated) - - }else{ - exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.") + } else { + logger.error("received error message from NSSMF : "+ nssmfResponse) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.") } - logger.trace("Exit getNSSMFProgresss in DoAllocateNSSI()") - + logger.debug("Exit getNSSMFProgresss in DoAllocateNSSI()") } void updateRelationship(DelegateExecution execution) { - logger.trace("Enter updateRelationship in DoAllocateNSSI()") + logger.debug("Enter updateRelationship in DoAllocateNSSI()") String nssiInstanceId = execution.getVariable("nssiInstanceId") String nsiInstanceId = execution.getVariable("nsiServiceInstanceId") try{ @@ -298,7 +239,7 @@ class DoAllocateNSSI extends org.onap.so.bpmn.common.scripts.AbstractServiceTask logger.info(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - logger.trace("Exit updateRelationship in DoAllocateNSSI()") + logger.debug("Exit updateRelationship in DoAllocateNSSI()") } @@ -383,6 +324,7 @@ class DoAllocateNSSI extends org.onap.so.bpmn.common.scripts.AbstractServiceTask sliceProfile.setExpDataRate(0) sliceProfile.setTrafficDensity(0) sliceProfile.setConnDensity(0) + sliceProfile.setSNssai(sliceProfileMap.get("sNSSAI").toString()) sliceProfile.setExpDataRateUL(Integer.parseInt(sliceProfileMap.get("expDataRateUL").toString())) sliceProfile.setExpDataRateDL(Integer.parseInt(sliceProfileMap.get("expDataRateDL").toString())) sliceProfile.setActivityFactor(Integer.parseInt(sliceProfileMap.get("activityFactor").toString())) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy index 9f378e567c..8cd9dee011 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy @@ -37,11 +37,11 @@ import org.onap.so.bpmn.core.domain.ModelInfo import org.onap.so.bpmn.core.domain.Resource import org.onap.so.bpmn.core.domain.ResourceModelInfo 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.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory 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/DoCreateCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateCommunicationService.groovy index fb4bd158b7..26dcaa7ac4 100644 --- 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 @@ -27,10 +27,10 @@ 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.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory 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/DoCreateE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy index 6af7cc069e..b90a34ea94 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 @@ -44,12 +44,12 @@ import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.domain.Resource import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.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.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import org.onap.so.bpmn.infrastructure.workflow.service.ServicePluginFactory -import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory 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/DoCreateE2EServiceInstanceRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceRollback.groovy index a12c2f4b85..3638d89faa 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceRollback.groovy @@ -38,10 +38,10 @@ import org.slf4j.Logger import org.slf4j.LoggerFactory import org.onap.so.logger.MessageEnum import org.onap.so.bpmn.common.scripts.ExceptionUtil; -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.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient import java.util.UUID; 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 5c8ece88fe..22e5819068 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 @@ -22,12 +22,27 @@ package org.onap.so.bpmn.infrastructure.scripts; -import javax.ws.rs.core.UriBuilder -import javax.xml.parsers.DocumentBuilder -import javax.xml.parsers.DocumentBuilderFactory +import javax.ws.rs.NotFoundException import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.L3Network +import org.onap.aai.domain.yang.L3Networks +import org.onap.aai.domain.yang.NetworkPolicy +import org.onap.aai.domain.yang.RouteTableReference +import org.onap.aai.domain.yang.RouteTarget +import org.onap.aai.domain.yang.Subnet +import org.onap.aai.domain.yang.VpnBinding +import org.onap.aaiclient.client.aai.AAIObjectPlurals +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.Relationships +import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.aaiclient.client.graphinventory.entities.uri.Depth import org.onap.so.bpmn.common.scripts.AaiUtil import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil @@ -38,38 +53,10 @@ import org.onap.so.bpmn.common.scripts.VidUtils 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.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 -import org.onap.so.client.aai.entities.Relationships -import org.onap.so.client.graphinventory.entities.uri.Depth import org.onap.so.constants.Defaults import org.slf4j.Logger import org.slf4j.LoggerFactory -import org.springframework.web.util.UriUtils -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 org.onap.aai.domain.yang.VpnBinding -import org.onap.aai.domain.yang.L3Network -import org.onap.aai.domain.yang.L3Networks -import org.onap.aai.domain.yang.NetworkPolicy -import org.onap.aai.domain.yang.RouteTableReference -import org.onap.aai.domain.yang.RouteTarget -import org.onap.aai.domain.yang.Subnet -import com.fasterxml.jackson.jaxrs.util.EndpointAsBeanProperty - -import javax.ws.rs.NotFoundException - import groovy.json.* -import groovy.xml.XmlUtil /** * This groovy class supports the <class>DoCreateNetworkInstance.bpmn</class> process. @@ -78,1355 +65,1323 @@ import groovy.xml.XmlUtil public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { private static final Logger logger = LoggerFactory.getLogger( DoCreateNetworkInstance.class); - String Prefix="CRENWKI_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils(this) - NetworkUtils networkUtils = new NetworkUtils() - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - - def className = getClass().getSimpleName() - - /** - * This method is executed during the preProcessRequest task of the <class>DoCreateNetworkInstance.bpmn</class> process. - * @param execution - */ - public InitializeProcessVariables(DelegateExecution execution){ - /* Initialize all the process variables in this block */ - - execution.setVariable(Prefix + "networkRequest", "") - execution.setVariable(Prefix + "rollbackEnabled", null) - execution.setVariable(Prefix + "networkInputs", "") - //execution.setVariable(Prefix + "requestId", "") - execution.setVariable(Prefix + "messageId", "") - execution.setVariable(Prefix + "source", "") - execution.setVariable("BasicAuthHeaderValuePO", "") - execution.setVariable("BasicAuthHeaderValueSDNC", "") - execution.setVariable(Prefix + "serviceInstanceId","") - execution.setVariable("GENGS_type", "") - execution.setVariable(Prefix + "rsrc_endpoint", null) - execution.setVariable(Prefix + "networkOutputs", "") - execution.setVariable(Prefix + "networkId","") - execution.setVariable(Prefix + "networkName","") - - // AAI query Name - execution.setVariable(Prefix + "queryNameAAIRequest","") - execution.setVariable(Prefix + "queryNameAAIResponse", "") - execution.setVariable(Prefix + "aaiNameReturnCode", "") - execution.setVariable(Prefix + "isAAIqueryNameGood", false) - - // AAI query Cloud Region - execution.setVariable(Prefix + "queryCloudRegionRequest","") - execution.setVariable(Prefix + "queryCloudRegionReturnCode","") - execution.setVariable(Prefix + "queryCloudRegionResponse","") - execution.setVariable(Prefix + "cloudRegionPo","") - execution.setVariable(Prefix + "cloudRegionSdnc","") - execution.setVariable(Prefix + "isCloudRegionGood", false) - - // AAI query Id - execution.setVariable(Prefix + "queryIdAAIRequest","") - execution.setVariable(Prefix + "queryIdAAIResponse", "") - execution.setVariable(Prefix + "aaiIdReturnCode", "") - - // AAI query vpn binding - execution.setVariable(Prefix + "queryVpnBindingAAIRequest","") - execution.setVariable(Prefix + "queryVpnBindingAAIResponse", "") - execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "") - execution.setVariable(Prefix + "vpnBindings", null) - execution.setVariable(Prefix + "vpnCount", 0) - execution.setVariable(Prefix + "routeCollection", "") - - // AAI query network policy - execution.setVariable(Prefix + "queryNetworkPolicyAAIRequest","") - execution.setVariable(Prefix + "queryNetworkPolicyAAIResponse", "") - execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "") - execution.setVariable(Prefix + "networkPolicyUriList", null) - execution.setVariable(Prefix + "networkPolicyCount", 0) - execution.setVariable(Prefix + "networkCollection", "") - - // AAI query route table reference - execution.setVariable(Prefix + "queryNetworkTableRefAAIRequest","") - execution.setVariable(Prefix + "queryNetworkTableRefAAIResponse", "") - execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "") - execution.setVariable(Prefix + "networkTableRefUriList", null) - execution.setVariable(Prefix + "networkTableRefCount", 0) - execution.setVariable(Prefix + "tableRefCollection", "") - - // AAI requery Id - execution.setVariable(Prefix + "requeryIdAAIRequest","") - execution.setVariable(Prefix + "requeryIdAAIResponse", "") - execution.setVariable(Prefix + "aaiRequeryIdReturnCode", "") - - // AAI update contrail - execution.setVariable(Prefix + "updateContrailAAIUrlRequest","") - execution.setVariable(Prefix + "updateContrailAAIPayloadRequest","") - execution.setVariable(Prefix + "updateContrailAAIResponse", "") - execution.setVariable(Prefix + "aaiUpdateContrailReturnCode", "") - - execution.setVariable(Prefix + "createNetworkRequest", "") - execution.setVariable(Prefix + "createNetworkResponse", "") - execution.setVariable(Prefix + "rollbackNetworkRequest", "") - //execution.setVariable(Prefix + "rollbackNetworkResponse", "") - execution.setVariable(Prefix + "networkReturnCode", "") - //execution.setVariable(Prefix + "rollbackNetworkReturnCode", "") - execution.setVariable(Prefix + "isNetworkRollbackNeeded", false) - - execution.setVariable(Prefix + "assignSDNCRequest", "") - execution.setVariable(Prefix + "assignSDNCResponse", "") - execution.setVariable(Prefix + "rollbackSDNCRequest", "") - //execution.setVariable(Prefix + "rollbackSDNCResponse", "") - execution.setVariable(Prefix + "sdncReturnCode", "") - //execution.setVariable(Prefix + "rollbackSDNCReturnCode", "") - execution.setVariable(Prefix + "isSdncRollbackNeeded", false) - execution.setVariable(Prefix + "sdncResponseSuccess", false) - - execution.setVariable(Prefix + "activateSDNCRequest", "") - execution.setVariable(Prefix + "activateSDNCResponse", "") - execution.setVariable(Prefix + "rollbackActivateSDNCRequest", "") - //execution.setVariable(Prefix + "rollbackActivateSDNCResponse", "") - execution.setVariable(Prefix + "sdncActivateReturnCode", "") - //execution.setVariable(Prefix + "rollbackActivateSDNCReturnCode", "") - execution.setVariable(Prefix + "isSdncActivateRollbackNeeded", false) - execution.setVariable(Prefix + "sdncActivateResponseSuccess", false) - - execution.setVariable(Prefix + "orchestrationStatus", "") - execution.setVariable(Prefix + "isVnfBindingPresent", false) - execution.setVariable(Prefix + "Success", false) - - execution.setVariable(Prefix + "isException", false) - - } - - // ************************************************** - // Pre or Prepare Request Section - // ************************************************** - /** - * This method is executed during the preProcessRequest task of the <class>DoCreateNetworkInstance.bpmn</class> process. - * @param execution - */ - public void preProcessRequest (DelegateExecution execution) { - - execution.setVariable("prefix",Prefix) - logger.trace("Inside preProcessRequest() of " + className + ".groovy") - - try { - // initialize flow variables - InitializeProcessVariables(execution) - - // GET Incoming request & validate 3 kinds of format. - execution.setVariable("action", "CREATE") - String networkRequest = execution.getVariable("bpmnRequest") - if (networkRequest != null) { - if (networkRequest.contains("requestDetails")) { - // JSON format request is sent, create xml - try { - def prettyJson = JsonOutput.prettyPrint(networkRequest.toString()) - logger.debug(" Incoming message formatted . . . : " + '\n' + prettyJson) - networkRequest = vidUtils.createXmlNetworkRequestInfra(execution, networkRequest) - - } catch (Exception ex) { - String dataErrorMessage = " Invalid json format Request - " + ex.getMessage() - logger.debug(dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - } else { - // XML format request is sent - - } - } else { - // vIPR format request is sent, create xml from individual variables - networkRequest = vidUtils.createXmlNetworkRequestInstance(execution) - } - - networkRequest = utils.formatXml(networkRequest) - execution.setVariable(Prefix + "networkRequest", networkRequest) - logger.debug(Prefix + "networkRequest - " + '\n' + networkRequest) - - // validate 'backout-on-failure' to override 'mso.rollback' - boolean rollbackEnabled = networkUtils.isRollbackEnabled(execution, networkRequest) - execution.setVariable(Prefix + "rollbackEnabled", rollbackEnabled) - logger.debug(Prefix + "rollbackEnabled - " + rollbackEnabled) - - String networkInputs = utils.getNodeXml(networkRequest, "network-inputs", false).replace("tag0:","").replace(":tag0","") - execution.setVariable(Prefix + "networkInputs", networkInputs) - logger.debug(Prefix + "networkInputs - " + '\n' + networkInputs) - - // prepare messageId - String messageId = execution.getVariable("testMessageId") // for testing - if (messageId == null || messageId == "") { - messageId = UUID.randomUUID() - logger.debug(Prefix + "messageId, random generated: " + messageId) - } else { - logger.debug(Prefix + "messageId, pre-assigned: " + messageId) - } - execution.setVariable(Prefix + "messageId", messageId) - - String source = utils.getNodeText(networkRequest, "source") - execution.setVariable(Prefix + "source", source) - logger.debug(Prefix + "source - " + source) - - // validate cloud region - String lcpCloudRegionId = utils.getNodeText(networkRequest, "aic-cloud-region") - if ((lcpCloudRegionId == null) || (lcpCloudRegionId == "") || (lcpCloudRegionId == "null")) { - String dataErrorMessage = "Missing value/element: 'lcpCloudRegionId' or 'cloudConfiguration' or 'aic-cloud-region'." - logger.debug(" Invalid Request - " + dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - - // validate service instance id - String serviceInstanceId = utils.getNodeText(networkRequest, "service-instance-id") - if ((serviceInstanceId == null) || (serviceInstanceId == "") || (serviceInstanceId == "null")) { - String dataErrorMessage = "Missing value/element: 'serviceInstanceId'." - logger.debug(" Invalid Request - " + dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - - // PO Authorization Info / headers Authorization= - String basicAuthValuePO = UrnPropertiesReader.getVariable("mso.adapters.po.auth",execution) - - try { - def encodedString = utils.getBasicAuth(basicAuthValuePO, UrnPropertiesReader.getVariable("mso.msoKey",execution)) - execution.setVariable("BasicAuthHeaderValuePO",encodedString) - execution.setVariable("BasicAuthHeaderValueSDNC", encodedString) - - } catch (IOException ex) { - String exceptionMessage = "Exception Encountered in DoCreateNetworkInstance, PreProcessRequest() - " - String dataErrorMessage = exceptionMessage + " Unable to encode PO/SDNC user/password string - " + ex.getMessage() - logger.debug(dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - - // Set variables for Generic Get Sub Flow use - execution.setVariable(Prefix + "serviceInstanceId", serviceInstanceId) - logger.debug(Prefix + "serviceInstanceId - " + serviceInstanceId) - - execution.setVariable("GENGS_type", "service-instance") - logger.debug("GENGS_type - " + "service-instance") - logger.debug(" Url for SDNC adapter: " + UrnPropertiesReader.getVariable("mso.adapters.sdnc.endpoint",execution)) - - String sdncVersion = execution.getVariable("sdncVersion") - logger.debug("sdncVersion? : " + sdncVersion) - - // build 'networkOutputs' - String networkId = utils.getNodeText(networkRequest, "network-id") - if ((networkId == null) || (networkId == "null")) { - networkId = "" - } - String networkName = utils.getNodeText(networkRequest, "network-name") - if ((networkName == null) || (networkName == "null")) { - networkName = "" - } - String networkOutputs = - """<network-outputs> + String Prefix="CRENWKI_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + VidUtils vidUtils = new VidUtils(this) + NetworkUtils networkUtils = new NetworkUtils() + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() + + def className = getClass().getSimpleName() + + /** + * This method is executed during the preProcessRequest task of the <class>DoCreateNetworkInstance.bpmn</class> process. + * @param execution + */ + public InitializeProcessVariables(DelegateExecution execution){ + /* Initialize all the process variables in this block */ + + execution.setVariable(Prefix + "networkRequest", "") + execution.setVariable(Prefix + "rollbackEnabled", null) + execution.setVariable(Prefix + "networkInputs", "") + //execution.setVariable(Prefix + "requestId", "") + execution.setVariable(Prefix + "messageId", "") + execution.setVariable(Prefix + "source", "") + execution.setVariable("BasicAuthHeaderValuePO", "") + execution.setVariable("BasicAuthHeaderValueSDNC", "") + execution.setVariable(Prefix + "serviceInstanceId","") + execution.setVariable("GENGS_type", "") + execution.setVariable(Prefix + "rsrc_endpoint", null) + execution.setVariable(Prefix + "networkOutputs", "") + execution.setVariable(Prefix + "networkId","") + execution.setVariable(Prefix + "networkName","") + + // AAI query Name + execution.setVariable(Prefix + "queryNameAAIRequest","") + execution.setVariable(Prefix + "queryNameAAIResponse", "") + execution.setVariable(Prefix + "aaiNameReturnCode", "") + execution.setVariable(Prefix + "isAAIqueryNameGood", false) + + // AAI query Cloud Region + execution.setVariable(Prefix + "queryCloudRegionRequest","") + execution.setVariable(Prefix + "queryCloudRegionReturnCode","") + execution.setVariable(Prefix + "queryCloudRegionResponse","") + execution.setVariable(Prefix + "cloudRegionPo","") + execution.setVariable(Prefix + "cloudRegionSdnc","") + execution.setVariable(Prefix + "isCloudRegionGood", false) + + // AAI query Id + execution.setVariable(Prefix + "queryIdAAIRequest","") + execution.setVariable(Prefix + "queryIdAAIResponse", "") + execution.setVariable(Prefix + "aaiIdReturnCode", "") + + // AAI query vpn binding + execution.setVariable(Prefix + "queryVpnBindingAAIRequest","") + execution.setVariable(Prefix + "queryVpnBindingAAIResponse", "") + execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "") + execution.setVariable(Prefix + "vpnBindings", null) + execution.setVariable(Prefix + "vpnCount", 0) + execution.setVariable(Prefix + "routeCollection", "") + + // AAI query network policy + execution.setVariable(Prefix + "queryNetworkPolicyAAIRequest","") + execution.setVariable(Prefix + "queryNetworkPolicyAAIResponse", "") + execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "") + execution.setVariable(Prefix + "networkPolicyUriList", null) + execution.setVariable(Prefix + "networkPolicyCount", 0) + execution.setVariable(Prefix + "networkCollection", "") + + // AAI query route table reference + execution.setVariable(Prefix + "queryNetworkTableRefAAIRequest","") + execution.setVariable(Prefix + "queryNetworkTableRefAAIResponse", "") + execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "") + execution.setVariable(Prefix + "networkTableRefUriList", null) + execution.setVariable(Prefix + "networkTableRefCount", 0) + execution.setVariable(Prefix + "tableRefCollection", "") + + // AAI requery Id + execution.setVariable(Prefix + "requeryIdAAIRequest","") + execution.setVariable(Prefix + "requeryIdAAIResponse", "") + execution.setVariable(Prefix + "aaiRequeryIdReturnCode", "") + + // AAI update contrail + execution.setVariable(Prefix + "updateContrailAAIUrlRequest","") + execution.setVariable(Prefix + "updateContrailAAIPayloadRequest","") + execution.setVariable(Prefix + "updateContrailAAIResponse", "") + execution.setVariable(Prefix + "aaiUpdateContrailReturnCode", "") + + execution.setVariable(Prefix + "createNetworkRequest", "") + execution.setVariable(Prefix + "createNetworkResponse", "") + execution.setVariable(Prefix + "rollbackNetworkRequest", "") + //execution.setVariable(Prefix + "rollbackNetworkResponse", "") + execution.setVariable(Prefix + "networkReturnCode", "") + //execution.setVariable(Prefix + "rollbackNetworkReturnCode", "") + execution.setVariable(Prefix + "isNetworkRollbackNeeded", false) + + execution.setVariable(Prefix + "assignSDNCRequest", "") + execution.setVariable(Prefix + "assignSDNCResponse", "") + execution.setVariable(Prefix + "rollbackSDNCRequest", "") + //execution.setVariable(Prefix + "rollbackSDNCResponse", "") + execution.setVariable(Prefix + "sdncReturnCode", "") + //execution.setVariable(Prefix + "rollbackSDNCReturnCode", "") + execution.setVariable(Prefix + "isSdncRollbackNeeded", false) + execution.setVariable(Prefix + "sdncResponseSuccess", false) + + execution.setVariable(Prefix + "activateSDNCRequest", "") + execution.setVariable(Prefix + "activateSDNCResponse", "") + execution.setVariable(Prefix + "rollbackActivateSDNCRequest", "") + //execution.setVariable(Prefix + "rollbackActivateSDNCResponse", "") + execution.setVariable(Prefix + "sdncActivateReturnCode", "") + //execution.setVariable(Prefix + "rollbackActivateSDNCReturnCode", "") + execution.setVariable(Prefix + "isSdncActivateRollbackNeeded", false) + execution.setVariable(Prefix + "sdncActivateResponseSuccess", false) + + execution.setVariable(Prefix + "orchestrationStatus", "") + execution.setVariable(Prefix + "isVnfBindingPresent", false) + execution.setVariable(Prefix + "Success", false) + + execution.setVariable(Prefix + "isException", false) + + } + + // ************************************************** + // Pre or Prepare Request Section + // ************************************************** + /** + * This method is executed during the preProcessRequest task of the <class>DoCreateNetworkInstance.bpmn</class> process. + * @param execution + */ + public void preProcessRequest (DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + logger.trace("Inside preProcessRequest() of " + className + ".groovy") + + try { + // initialize flow variables + InitializeProcessVariables(execution) + + // GET Incoming request & validate 3 kinds of format. + execution.setVariable("action", "CREATE") + String networkRequest = execution.getVariable("bpmnRequest") + if (networkRequest != null) { + if (networkRequest.contains("requestDetails")) { + // JSON format request is sent, create xml + try { + def prettyJson = JsonOutput.prettyPrint(networkRequest.toString()) + logger.debug(" Incoming message formatted . . . : " + '\n' + prettyJson) + networkRequest = vidUtils.createXmlNetworkRequestInfra(execution, networkRequest) + + } catch (Exception ex) { + String dataErrorMessage = " Invalid json format Request - " + ex.getMessage() + logger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + } else { + // XML format request is sent + + } + } else { + // vIPR format request is sent, create xml from individual variables + networkRequest = vidUtils.createXmlNetworkRequestInstance(execution) + } + + networkRequest = utils.formatXml(networkRequest) + execution.setVariable(Prefix + "networkRequest", networkRequest) + logger.debug(Prefix + "networkRequest - " + '\n' + networkRequest) + + // validate 'backout-on-failure' to override 'mso.rollback' + boolean rollbackEnabled = networkUtils.isRollbackEnabled(execution, networkRequest) + execution.setVariable(Prefix + "rollbackEnabled", rollbackEnabled) + logger.debug(Prefix + "rollbackEnabled - " + rollbackEnabled) + + String networkInputs = utils.getNodeXml(networkRequest, "network-inputs", false).replace("tag0:","").replace(":tag0","") + execution.setVariable(Prefix + "networkInputs", networkInputs) + logger.debug(Prefix + "networkInputs - " + '\n' + networkInputs) + + // prepare messageId + String messageId = execution.getVariable("testMessageId") // for testing + if (messageId == null || messageId == "") { + messageId = UUID.randomUUID() + logger.debug(Prefix + "messageId, random generated: " + messageId) + } else { + logger.debug(Prefix + "messageId, pre-assigned: " + messageId) + } + execution.setVariable(Prefix + "messageId", messageId) + + String source = utils.getNodeText(networkRequest, "source") + execution.setVariable(Prefix + "source", source) + logger.debug(Prefix + "source - " + source) + + // validate cloud region + String lcpCloudRegionId = utils.getNodeText(networkRequest, "aic-cloud-region") + if ((lcpCloudRegionId == null) || (lcpCloudRegionId == "") || (lcpCloudRegionId == "null")) { + String dataErrorMessage = "Missing value/element: 'lcpCloudRegionId' or 'cloudConfiguration' or 'aic-cloud-region'." + logger.debug(" Invalid Request - " + dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + + // validate service instance id + String serviceInstanceId = utils.getNodeText(networkRequest, "service-instance-id") + if ((serviceInstanceId == null) || (serviceInstanceId == "") || (serviceInstanceId == "null")) { + String dataErrorMessage = "Missing value/element: 'serviceInstanceId'." + logger.debug(" Invalid Request - " + dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + + // PO Authorization Info / headers Authorization= + String basicAuthValuePO = UrnPropertiesReader.getVariable("mso.adapters.po.auth",execution) + + try { + def encodedString = utils.getBasicAuth(basicAuthValuePO, UrnPropertiesReader.getVariable("mso.msoKey",execution)) + execution.setVariable("BasicAuthHeaderValuePO",encodedString) + execution.setVariable("BasicAuthHeaderValueSDNC", encodedString) + + } catch (IOException ex) { + String exceptionMessage = "Exception Encountered in DoCreateNetworkInstance, PreProcessRequest() - " + String dataErrorMessage = exceptionMessage + " Unable to encode PO/SDNC user/password string - " + ex.getMessage() + logger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + + // Set variables for Generic Get Sub Flow use + execution.setVariable(Prefix + "serviceInstanceId", serviceInstanceId) + logger.debug(Prefix + "serviceInstanceId - " + serviceInstanceId) + + execution.setVariable("GENGS_type", "service-instance") + logger.debug("GENGS_type - " + "service-instance") + logger.debug(" Url for SDNC adapter: " + UrnPropertiesReader.getVariable("mso.adapters.sdnc.endpoint",execution)) + + String sdncVersion = execution.getVariable("sdncVersion") + logger.debug("sdncVersion? : " + sdncVersion) + + // build 'networkOutputs' + String networkId = utils.getNodeText(networkRequest, "network-id") + if ((networkId == null) || (networkId == "null")) { + networkId = "" + } + String networkName = utils.getNodeText(networkRequest, "network-name") + if ((networkName == null) || (networkName == "null")) { + networkName = "" + } + String networkOutputs = + """<network-outputs> <network-id>${MsoUtils.xmlEscape(networkId)}</network-id> <network-name>${MsoUtils.xmlEscape(networkName)}</network-name> </network-outputs>""" - execution.setVariable(Prefix + "networkOutputs", networkOutputs) - logger.debug(Prefix + "networkOutputs - " + '\n' + networkOutputs) - execution.setVariable(Prefix + "networkId", networkId) - execution.setVariable(Prefix + "networkName", networkName) + execution.setVariable(Prefix + "networkOutputs", networkOutputs) + logger.debug(Prefix + "networkOutputs - " + '\n' + networkOutputs) + execution.setVariable(Prefix + "networkId", networkId) + execution.setVariable(Prefix + "networkName", networkName) - } catch (BpmnError e) { - throw e; + } catch (BpmnError e) { + throw e; - } catch (Exception ex) { - sendSyncError(execution) - // caught exception - String exceptionMessage = "Exception Encountered in PreProcessRequest() of " + className + ".groovy ***** : " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } catch (Exception ex) { + sendSyncError(execution) + // caught exception + String exceptionMessage = "Exception Encountered in PreProcessRequest() of " + className + ".groovy ***** : " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } + } - } + } - /** - * Gets the service instance uri from aai - */ - public void getServiceInstance(DelegateExecution execution) { - try { - String serviceInstanceId = execution.getVariable('CRENWKI_serviceInstanceId') + /** + * Gets the service instance uri from aai + */ + public void getServiceInstance(DelegateExecution execution) { + try { + String serviceInstanceId = execution.getVariable('CRENWKI_serviceInstanceId') - AAIResourcesClient resourceClient = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) + AAIResourcesClient resourceClient = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) - if(!resourceClient.exists(uri)){ - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai") - }else{ - Map<String, String> keys = uri.getURIKeys() - execution.setVariable("serviceType", keys.get("service-type")) - execution.setVariable("subscriberName", keys.get("global-customer-id")) - } + if(!resourceClient.exists(uri)){ + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai") + }else{ + Map<String, String> keys = uri.getURIKeys() + execution.setVariable("serviceType", keys.get(AAIFluentTypeBuilder.Types.SERVICE_SUBSCRIPTION.getUriParams().serviceType)) + execution.setVariable("subscriberName", keys.get(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId)) + } - }catch(BpmnError e) { - throw e; - }catch (Exception ex){ - String msg = "Exception in getServiceInstance. " + ex.getMessage() - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - } + }catch(BpmnError e) { + throw e; + }catch (Exception ex){ + String msg = "Exception in getServiceInstance. " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } - public void callRESTQueryAAINetworkName (DelegateExecution execution) { + public void callRESTQueryAAINetworkName (DelegateExecution execution) { - execution.setVariable("prefix",Prefix) + execution.setVariable("prefix",Prefix) - logger.debug(" ***** Inside callRESTQueryAAINetworkName() of DoCreateNetworkInstance ***** " ) + logger.debug(" ***** Inside callRESTQueryAAINetworkName() of DoCreateNetworkInstance ***** " ) - try{ - // get variables - String networkInputs = execution.getVariable(Prefix + "networkInputs") - String networkName = utils.getNodeText(networkInputs, "network-name") + try{ + // get variables + String networkInputs = execution.getVariable(Prefix + "networkInputs") + String networkName = utils.getNodeText(networkInputs, "network-name") - AAIResourcesClient client = new AAIResourcesClient() - 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) + AAIResourcesClient client = new AAIResourcesClient() + 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) - execution.setVariable(Prefix + "isAAIqueryNameGood", true) - String orchestrationStatus = network.getOrchestrationStatus() - execution.setVariable(Prefix + "orchestrationStatus", orchestrationStatus.toUpperCase()) - logger.debug(Prefix + "orchestrationStatus - " + orchestrationStatus.toUpperCase()) - execution.setVariable("orchestrationStatus", orchestrationStatus) + execution.setVariable(Prefix + "isAAIqueryNameGood", true) + String orchestrationStatus = network.getOrchestrationStatus() + execution.setVariable(Prefix + "orchestrationStatus", orchestrationStatus.toUpperCase()) + logger.debug(Prefix + "orchestrationStatus - " + orchestrationStatus.toUpperCase()) + execution.setVariable("orchestrationStatus", orchestrationStatus) - logger.debug(Prefix + "isAAIqueryNameGood? : " + execution.getVariable(Prefix + "isAAIqueryNameGood")) + logger.debug(Prefix + "isAAIqueryNameGood? : " + execution.getVariable(Prefix + "isAAIqueryNameGood")) - } catch (NotFoundException e) { - logger.debug(" QueryAAINetworkName return code = '404' (Not Found). Proceed with the Create !!! ") + } catch (NotFoundException e) { + logger.debug(" QueryAAINetworkName return code = '404' (Not Found). Proceed with the Create !!! ") - } catch (Exception ex) { - // try error - String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow - callRESTQueryAAINetworkName() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } catch (Exception ex) { + // try error + String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow - callRESTQueryAAINetworkName() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } + } - } + } - public void callRESTQueryAAICloudRegion (DelegateExecution execution) { + public void callRESTQueryAAICloudRegion (DelegateExecution execution) { - execution.setVariable("prefix",Prefix) + execution.setVariable("prefix",Prefix) - logger.debug(" ***** Inside callRESTQueryAAICloudRegion() of DoCreateNetworkInstance ***** " ) + logger.debug(" ***** Inside callRESTQueryAAICloudRegion() of DoCreateNetworkInstance ***** " ) - try { - String networkInputs = execution.getVariable(Prefix + "networkInputs") - String cloudRegion = utils.getNodeText(networkInputs, "aic-cloud-region") + try { + String networkInputs = execution.getVariable(Prefix + "networkInputs") + String cloudRegion = utils.getNodeText(networkInputs, "aic-cloud-region") - // Prepare AA&I url - AaiUtil aaiUtil = new AaiUtil(this) + // Prepare AA&I url + AaiUtil aaiUtil = new AaiUtil(this) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion) - def queryCloudRegionRequest = aaiUtil.createAaiUri(uri) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion) + def queryCloudRegionRequest = aaiUtil.createAaiUri(uri) - execution.setVariable(Prefix + "queryCloudRegionRequest", queryCloudRegionRequest) + execution.setVariable(Prefix + "queryCloudRegionRequest", queryCloudRegionRequest) - String cloudRegionPo = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) - String cloudRegionSdnc = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "SDNC", cloudRegion) + String cloudRegionPo = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) + String cloudRegionSdnc = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "SDNC", cloudRegion) - if ((cloudRegionPo != "ERROR") && (cloudRegionSdnc != "ERROR")) { - execution.setVariable(Prefix + "cloudRegionPo", cloudRegionPo) - execution.setVariable(Prefix + "cloudRegionSdnc", cloudRegionSdnc) - execution.setVariable(Prefix + "isCloudRegionGood", true) + if ((cloudRegionPo != "ERROR") && (cloudRegionSdnc != "ERROR")) { + execution.setVariable(Prefix + "cloudRegionPo", cloudRegionPo) + execution.setVariable(Prefix + "cloudRegionSdnc", cloudRegionSdnc) + execution.setVariable(Prefix + "isCloudRegionGood", true) - } else { - String dataErrorMessage = "QueryAAICloudRegion Unsuccessful. Return Code: " + execution.getVariable(Prefix + "queryCloudRegionReturnCode") - logger.debug(dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } else { + String dataErrorMessage = "QueryAAICloudRegion Unsuccessful. Return Code: " + execution.getVariable(Prefix + "queryCloudRegionReturnCode") + logger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } + } - logger.debug(" is Cloud Region Good: " + execution.getVariable(Prefix + "isCloudRegionGood")) + logger.debug(" is Cloud Region Good: " + execution.getVariable(Prefix + "isCloudRegionGood")) - } catch (BpmnError e) { - throw e; + } catch (BpmnError e) { + throw e; - } catch (Exception ex) { - // try error - String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow - callRESTQueryAAICloudRegion() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } catch (Exception ex) { + // try error + String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow - callRESTQueryAAICloudRegion() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } + } - } + } - public void callRESTQueryAAINetworkId(DelegateExecution execution) { + public void callRESTQueryAAINetworkId(DelegateExecution execution) { - execution.setVariable("prefix",Prefix) + execution.setVariable("prefix",Prefix) - logger.debug(" ***** Inside callRESTQueryAAINetworkId() of DoCreateNetworkInstance ***** " ) + logger.debug(" ***** Inside callRESTQueryAAINetworkId() of DoCreateNetworkInstance ***** " ) - try { - // get variables - String networkId = "" - String assignSDNCResponse = execution.getVariable(Prefix + "assignSDNCResponse") - if (execution.getVariable("sdncVersion") != "1610") { - String networkResponseInformation = "" - try { - networkResponseInformation = utils.getNodeXml(assignSDNCResponse, "network-response-information", false).replace("tag0:","").replace(":tag0","") - networkId = utils.getNodeText(networkResponseInformation, "instance-id") - } catch (Exception ex) { - String dataErrorMessage = " SNDC Response network validation for 'instance-id' (network-id) failed: Empty <network-response-information>" - logger.debug(dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } + try { + // get variables + String networkId = "" + String assignSDNCResponse = execution.getVariable(Prefix + "assignSDNCResponse") + if (execution.getVariable("sdncVersion") != "1610") { + String networkResponseInformation = "" + try { + networkResponseInformation = utils.getNodeXml(assignSDNCResponse, "network-response-information", false).replace("tag0:","").replace(":tag0","") + networkId = utils.getNodeText(networkResponseInformation, "instance-id") + } catch (Exception ex) { + String dataErrorMessage = " SNDC Response network validation for 'instance-id' (network-id) failed: Empty <network-response-information>" + logger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } - } else { - networkId = utils.getNodeText(assignSDNCResponse, "network-id") - } - if (networkId == null || networkId == "null") { - String dataErrorMessage = "SNDC Response did not contains 'instance-id' or 'network-id' element, or the value is null." - logger.debug(dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } else { - logger.debug(" SNDC Response network validation for 'instance-id' (network-id)' is good: " + networkId) - } + } else { + networkId = utils.getNodeText(assignSDNCResponse, "network-id") + } + if (networkId == null || networkId == "null") { + String dataErrorMessage = "SNDC Response did not contains 'instance-id' or 'network-id' element, or the value is null." + logger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } else { + logger.debug(" SNDC Response network validation for 'instance-id' (network-id)' is good: " + networkId) + } - execution.setVariable(Prefix + "networkId", networkId) - String networkName = utils.getNodeText(assignSDNCResponse, "network-name") - execution.setVariable(Prefix + "networkName", networkName) + execution.setVariable(Prefix + "networkId", networkId) + String networkName = utils.getNodeText(assignSDNCResponse, "network-name") + execution.setVariable(Prefix + "networkName", networkName) - AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId).depth(Depth.ONE) - L3Network network = client.get(uri, NotFoundException.class).asBean(L3Network.class).get() + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId).depth(Depth.ONE) + L3Network network = client.get(uri, NotFoundException.class).asBean(L3Network.class).get() - execution.setVariable(Prefix + "queryIdAAIResponse", network) + execution.setVariable(Prefix + "queryIdAAIResponse", network) - String netId = network.getNetworkId() - execution.setVariable(Prefix + "networkId", netId) - String netName = network.getNetworkName() - execution.setVariable(Prefix + "networkName", netName) + String netId = network.getNetworkId() + execution.setVariable(Prefix + "networkId", netId) + String netName = network.getNetworkName() + execution.setVariable(Prefix + "networkName", netName) - } catch (NotFoundException e) { - String dataErrorMessage = "Response Error from QueryAAINetworkId is 404 (Not Found)." - logger.debug(" AAI Query Failed. " + dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } catch (NotFoundException e) { + String dataErrorMessage = "Response Error from QueryAAINetworkId is 404 (Not Found)." + logger.debug(" AAI Query Failed. " + dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTQueryAAINetworkId() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTQueryAAINetworkId() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } + } - } + } - public void callRESTReQueryAAINetworkId(DelegateExecution execution) { + public void callRESTReQueryAAINetworkId(DelegateExecution execution) { - execution.setVariable("prefix",Prefix) + execution.setVariable("prefix",Prefix) - logger.debug(" ***** Inside callRESTReQueryAAINetworkId() of DoCreateNetworkInstance ***** " ) + logger.debug(" ***** Inside callRESTReQueryAAINetworkId() of DoCreateNetworkInstance ***** " ) - try { - // get variables - String networkId = execution.getVariable(Prefix + "networkId") - String netId = networkId + try { + // get variables + String networkId = execution.getVariable(Prefix + "networkId") + String netId = networkId - AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId).depth(Depth.ONE) - L3Network network = client.get(uri, NotFoundException.class).asBean(L3Network.class).get() + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId).depth(Depth.ONE) + L3Network network = client.get(uri, NotFoundException.class).asBean(L3Network.class).get() - execution.setVariable(Prefix + "aaiRequeryIdReturnCode", "200") - execution.setVariable(Prefix + "requeryIdAAIResponse", network) + execution.setVariable(Prefix + "aaiRequeryIdReturnCode", "200") + execution.setVariable(Prefix + "requeryIdAAIResponse", network) - String netName = network.getNetworkName() - String networkOutputs = - """<network-outputs> + String netName = network.getNetworkName() + String networkOutputs = + """<network-outputs> <network-id>${MsoUtils.xmlEscape(netId)}</network-id> <network-name>${MsoUtils.xmlEscape(netName)}</network-name> </network-outputs>""" - execution.setVariable(Prefix + "networkOutputs", networkOutputs) - logger.debug(" networkOutputs - " + '\n' + networkOutputs) + execution.setVariable(Prefix + "networkOutputs", networkOutputs) + logger.debug(" networkOutputs - " + '\n' + networkOutputs) - } catch (NotFoundException e) { - String dataErrorMessage = "Response Error from ReQueryAAINetworkId is 404 (Not Found)." - logger.debug(" AAI ReQuery Failed. - " + dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } catch (NotFoundException e) { + String dataErrorMessage = "Response Error from ReQueryAAINetworkId is 404 (Not Found)." + logger.debug(" AAI ReQuery Failed. - " + dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTReQueryAAINetworkId() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTReQueryAAINetworkId() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } + } - } + } - public void callRESTQueryAAINetworkVpnBinding(DelegateExecution execution) { + public void callRESTQueryAAINetworkVpnBinding(DelegateExecution execution) { - execution.setVariable("prefix",Prefix) + execution.setVariable("prefix",Prefix) - logger.debug(" ***** Inside callRESTQueryAAINetworkVpnBinding() of DoCreateNetworkInstance ***** " ) + logger.debug(" ***** Inside callRESTQueryAAINetworkVpnBinding() of DoCreateNetworkInstance ***** " ) - try { + try { - AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, execution.getVariable(Prefix + "networkId")) - Optional<Relationships> relationships = client.get(uri, NotFoundException.class).getRelationships() - if(relationships.isPresent()){ - List<AAIResourceUri> uris = relationships.get().getRelatedAAIUris(AAIObjectType.VPN_BINDING) + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, execution.getVariable(Prefix + "networkId")) + Optional<Relationships> relationships = client.get(uri, NotFoundException.class).getRelationships() + if(relationships.isPresent()){ + List<AAIResourceUri> uris = relationships.get().getRelatedAAIUris(AAIObjectType.VPN_BINDING) - logger.debug(Prefix + "vpnCount - " + uris.size()) + logger.debug(Prefix + "vpnCount - " + uris.size()) - if (uris.size() > 0) { - String routeTargets = "" - for(AAIResourceUri u : uris) { + if (uris.size() > 0) { + String routeTargets = "" + for(AAIResourceUri u : uris) { - AAIResultWrapper wrapper = client.get(u.depth(Depth.TWO), NotFoundException.class) - Optional<VpnBinding> binding = wrapper.asBean(VpnBinding.class) + AAIResultWrapper wrapper = client.get(u.depth(Depth.TWO), NotFoundException.class) + Optional<VpnBinding> binding = wrapper.asBean(VpnBinding.class) - String routeTarget = "" - String routeRole = "" - if(binding.get().getRouteTargets() != null) { - List<RouteTarget> targets = binding.get().getRouteTargets().getRouteTarget() - for(RouteTarget target : targets) { - routeTarget = target.getGlobalRouteTarget() - routeRole = target.getRouteTargetRole() - routeTargets += "<routeTargets>" + '\n' + - " <routeTarget>" + routeTarget + "</routeTarget>" + '\n' + - " <routeTargetRole>" + routeRole + "</routeTargetRole>" + '\n' + - "</routeTargets>" + '\n' - } - } + String routeTarget = "" + String routeRole = "" + if(binding.get().getRouteTargets() != null) { + List<RouteTarget> targets = binding.get().getRouteTargets().getRouteTarget() + for(RouteTarget target : targets) { + routeTarget = target.getGlobalRouteTarget() + routeRole = target.getRouteTargetRole() + routeTargets += "<routeTargets>" + '\n' + + " <routeTarget>" + routeTarget + "</routeTarget>" + '\n' + + " <routeTargetRole>" + routeRole + "</routeTargetRole>" + '\n' + + "</routeTargets>" + '\n' + } + } - } // end loop + } // end loop - execution.setVariable(Prefix + "routeCollection", routeTargets) - logger.debug(Prefix + "routeCollection - " + '\n' + routeTargets) + execution.setVariable(Prefix + "routeCollection", routeTargets) + logger.debug(Prefix + "routeCollection - " + '\n' + routeTargets) - } else { - // reset return code to success - execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") - AaiUtil aaiUriUtil = new AaiUtil(this) - String schemaVersion = aaiUriUtil.getNamespace() - String aaiStubResponse = - """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"> + } else { + // reset return code to success + execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") + AaiUtil aaiUriUtil = new AaiUtil(this) + String schemaVersion = aaiUriUtil.getNamespace() + String aaiStubResponse = + """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"> <vpn-binding xmlns="${schemaVersion}"> <global-route-target/> </vpn-binding> </rest:payload>""" - String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) - execution.setVariable(Prefix + "queryVpnBindingAAIResponse", aaiStubResponseAsXml) - execution.setVariable(Prefix + "routeCollection", "<routeTargets/>") - logger.debug(" No vpnBinding, using this stub as response - " + '\n' + aaiStubResponseAsXml) + String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) + execution.setVariable(Prefix + "queryVpnBindingAAIResponse", aaiStubResponseAsXml) + execution.setVariable(Prefix + "routeCollection", "<routeTargets/>") + logger.debug(" No vpnBinding, using this stub as response - " + '\n' + aaiStubResponseAsXml) - } - } + } + } - } catch (NotFoundException e) { - logger.debug("Response Error from AAINetworkVpnBinding is 404 (Not Found).") - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Response Error from AAINetworkVpnBinding is 404 (Not Found).") - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTQueryAAINetworkVpnBinding() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } catch (NotFoundException e) { + logger.debug("Response Error from AAINetworkVpnBinding is 404 (Not Found).") + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Response Error from AAINetworkVpnBinding is 404 (Not Found).") + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTQueryAAINetworkVpnBinding() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } + } - } + } - public void callRESTQueryAAINetworkPolicy(DelegateExecution execution) { + public void callRESTQueryAAINetworkPolicy(DelegateExecution execution) { - execution.setVariable("prefix",Prefix) + execution.setVariable("prefix",Prefix) - logger.debug(" ***** Inside callRESTQueryAAINetworkPolicy() of DoCreateNetworkInstance ***** " ) + logger.debug(" ***** Inside callRESTQueryAAINetworkPolicy() of DoCreateNetworkInstance ***** " ) - try { - AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, execution.getVariable(Prefix + "networkId")) - Optional<Relationships> relationships = client.get(uri, NotFoundException.class).getRelationships() - if(relationships.isPresent()){ - List<AAIResourceUri> uris = relationships.get().getRelatedAAIUris(AAIObjectType.NETWORK_POLICY) + try { + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, execution.getVariable(Prefix + "networkId")) + Optional<Relationships> relationships = client.get(uri, NotFoundException.class).getRelationships() + if(relationships.isPresent()){ + List<AAIResourceUri> uris = relationships.get().getRelatedAAIUris(AAIObjectType.NETWORK_POLICY) - execution.setVariable(Prefix + "networkPolicyCount", uris.size()) - logger.debug(Prefix + "networkPolicyCount - " + uris.size()) + execution.setVariable(Prefix + "networkPolicyCount", uris.size()) + logger.debug(Prefix + "networkPolicyCount - " + uris.size()) - if (uris.size() > 0) { + if (uris.size() > 0) { - String networkPolicies = "" - // AII loop call using list vpnBindings - for(AAIResourceUri u : uris) { + String networkPolicies = "" + // AII loop call using list vpnBindings + for(AAIResourceUri u : uris) { - NetworkPolicy p = client.get(u, NotFoundException.class).asBean(NetworkPolicy.class).get() + NetworkPolicy p = client.get(u, NotFoundException.class).asBean(NetworkPolicy.class).get() - execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200") + execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200") - String networkPolicy = p.getNetworkPolicyFqdn() - networkPolicies += "<policyFqdns>" + networkPolicy + "</policyFqdns>" + '\n' + String networkPolicy = p.getNetworkPolicyFqdn() + networkPolicies += "<policyFqdns>" + networkPolicy + "</policyFqdns>" + '\n' - } // end loop + } // end loop - execution.setVariable(Prefix + "networkCollection", networkPolicies) - logger.debug(Prefix + "networkCollection - " + '\n' + networkPolicies) + execution.setVariable(Prefix + "networkCollection", networkPolicies) + logger.debug(Prefix + "networkCollection - " + '\n' + networkPolicies) - } else { - // reset return code to success - execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200") - AaiUtil aaiUriUtil = new AaiUtil(this) - String schemaVersion = aaiUriUtil.getNamespace() - String aaiStubResponse = - """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"> + } else { + // reset return code to success + execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200") + AaiUtil aaiUriUtil = new AaiUtil(this) + String schemaVersion = aaiUriUtil.getNamespace() + String aaiStubResponse = + """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"> <network-policy xmlns="${schemaVersion}"> <network-policy-fqdn/> </network-policy> </rest:payload>""" - String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) - execution.setVariable(Prefix + "queryNetworkPolicyAAIResponse", aaiStubResponseAsXml) - execution.setVariable(Prefix + "networkCollection", "<policyFqdns/>") - logger.debug(" No net policies, using this stub as response - " + '\n' + aaiStubResponseAsXml) + String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) + execution.setVariable(Prefix + "queryNetworkPolicyAAIResponse", aaiStubResponseAsXml) + execution.setVariable(Prefix + "networkCollection", "<policyFqdns/>") + logger.debug(" No net policies, using this stub as response - " + '\n' + aaiStubResponseAsXml) - } - } - } catch (NotFoundException e) { - String dataErrorMessage = "Response Error from QueryAAINetworkPolicy is 404 (Not Found)." - logger.debug(dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + } + } catch (NotFoundException e) { + String dataErrorMessage = "Response Error from QueryAAINetworkPolicy is 404 (Not Found)." + logger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTQueryAAINetworkPolicy() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTQueryAAINetworkPolicy() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } + } - } + } - public void callRESTQueryAAINetworkTableRef(DelegateExecution execution) { + public void callRESTQueryAAINetworkTableRef(DelegateExecution execution) { - execution.setVariable("prefix",Prefix) + execution.setVariable("prefix",Prefix) - logger.debug(" ***** Inside callRESTQueryAAINetworkTableRef() of DoCreateNetworkInstance ***** " ) + logger.debug(" ***** Inside callRESTQueryAAINetworkTableRef() of DoCreateNetworkInstance ***** " ) - try { + try { - AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, execution.getVariable(Prefix + "networkId")) - Optional<Relationships> relationships = client.get(uri, NotFoundException.class).getRelationships() - if(relationships.isPresent()){ - List<AAIResourceUri> uris = relationships.get().getRelatedAAIUris(AAIObjectType.ROUTE_TABLE_REFERENCE) + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, execution.getVariable(Prefix + "networkId")) + Optional<Relationships> relationships = client.get(uri, NotFoundException.class).getRelationships() + if(relationships.isPresent()){ + List<AAIResourceUri> uris = relationships.get().getRelatedAAIUris(AAIObjectType.ROUTE_TABLE_REFERENCE) - execution.setVariable(Prefix + "networkTableRefCount", uris.size()) - logger.debug(Prefix + "networkTableRefCount - " + uris.size()) + execution.setVariable(Prefix + "networkTableRefCount", uris.size()) + logger.debug(Prefix + "networkTableRefCount - " + uris.size()) - if (uris.size() > 0) { + if (uris.size() > 0) { - // AII loop call using list vpnBindings - String networkTableRefs = "" - for(AAIResourceUri u : uris) { + // AII loop call using list vpnBindings + String networkTableRefs = "" + for(AAIResourceUri u : uris) { - RouteTableReference rt = client.get(u, NotFoundException.class).asBean(RouteTableReference.class).get() + RouteTableReference rt = client.get(u, NotFoundException.class).asBean(RouteTableReference.class).get() - String networkTableRef = rt.getRouteTableReferenceFqdn() - networkTableRefs += "<routeTableFqdns>" + networkTableRef + "</routeTableFqdns>" + '\n' + String networkTableRef = rt.getRouteTableReferenceFqdn() + networkTableRefs += "<routeTableFqdns>" + networkTableRef + "</routeTableFqdns>" + '\n' - } // end loop + } // end loop - execution.setVariable(Prefix + "tableRefCollection", networkTableRefs) - logger.debug(Prefix + "tableRefCollection - " + '\n' + networkTableRefs) + execution.setVariable(Prefix + "tableRefCollection", networkTableRefs) + logger.debug(Prefix + "tableRefCollection - " + '\n' + networkTableRefs) - } else { - // reset return code to success - execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "200") - AaiUtil aaiUriUtil = new AaiUtil(this) - String schemaVersion = aaiUriUtil.getNamespace() - String aaiStubResponse = - """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"> + } else { + // reset return code to success + execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "200") + AaiUtil aaiUriUtil = new AaiUtil(this) + String schemaVersion = aaiUriUtil.getNamespace() + String aaiStubResponse = + """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"> <route-table-references xmlns="${schemaVersion}"> <route-table-reference-fqdn/> </route-table-references> </rest:payload>""" - String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) - execution.setVariable(Prefix + "queryNetworkTableRefAAIResponse", aaiStubResponseAsXml) - execution.setVariable(Prefix + "tableRefCollection", "<routeTableFqdns/>") - logger.debug(" No net table references, using this stub as response - " + '\n' + aaiStubResponseAsXml) - - } - } - - } catch (NotFoundException e) { - String dataErrorMessage = "Response Error from QueryAAINetworkTableRef is 404 (Not Found)." - logger.debug(dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTQueryAAINetworkTableRef() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - - public void callRESTUpdateContrailAAINetwork(DelegateExecution execution) { - - execution.setVariable("prefix",Prefix) - - logger.trace(" ***** Inside callRESTUpdateContrailAAINetwork() of DoCreateNetworkInstance ***** " ) - - try { - // get variables - String networkId = execution.getVariable(Prefix + "networkId") - L3Network requeryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse") - String createNetworkResponse = execution.getVariable(Prefix + "createNetworkResponse") - - L3Network l3Network = new L3Network() - if (StringUtils.isBlank(requeryIdAAIResponse.getHeatStackId())) { - if (utils.nodeExists(createNetworkResponse, 'networkStackId')) { - l3Network.setHeatStackId(utils.getNodeText(createNetworkResponse, 'networkStackId')) - } - } - if (StringUtils.isBlank(requeryIdAAIResponse.getNeutronNetworkId())) { - if (utils.nodeExists(createNetworkResponse, 'neutronNetworkId')) { - l3Network.setNeutronNetworkId(utils.getNodeText(createNetworkResponse, 'neutronNetworkId')) - } - } - if (StringUtils.isBlank(requeryIdAAIResponse.getContrailNetworkFqdn())) { - if (utils.nodeExists(createNetworkResponse, 'networkFqdn')) { - l3Network.setContrailNetworkFqdn(utils.getNodeText(createNetworkResponse, 'networkFqdn')) - } - } - - String status = utils.getNodeText(createNetworkResponse, 'orchestration-status') - if(status.equals("pending-create") || status.equals("PendingCreate")){ - l3Network.setOrchestrationStatus("Created") - }else{ - l3Network.setOrchestrationStatus("Active") - } - - logger.debug("Updating l3-network in AAI" ) - - AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId) - client.update(uri, l3Network) - - if(requeryIdAAIResponse.getSubnets() != null){ - for(Subnet s:requeryIdAAIResponse.getSubnets().getSubnet()){ - String subnetOrchStatus = s.getOrchestrationStatus() - String subnetId = s.getSubnetId() - Subnet subnet = new Subnet() - subnet.setNeutronSubnetId(networkUtils.extractNeutSubId(createNetworkResponse, subnetId)) - if(subnetOrchStatus.equals("pending-create") || subnetOrchStatus.equals("PendingCreate") ){ - subnet.setOrchestrationStatus("Created") - }else{ - subnet.setOrchestrationStatus("Active") - } - - logger.debug("Updating subnet in AAI" ) - AAIResourceUri subUri = AAIUriFactory.createResourceUri(AAIObjectType.SUBNET, networkId, subnetId) - client.update(subUri, subnet) - - } - } - - String rollbackEnabled = execution.getVariable(Prefix + "rollbackEnabled") - if (rollbackEnabled == "true") { - execution.setVariable(Prefix + "isPONR", false) - } else { - execution.setVariable(Prefix + "isPONR", true) - } - logger.debug(Prefix + "isPONR" + ": " + execution.getVariable(Prefix + "isPONR")) - - } catch (BpmnError e) { - throw e; - } catch (NotFoundException e) { - String dataErrorMessage = " Response Error from UpdateContrailAAINetwork is 404 (Not Found)." - logger.debug(dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTUpdateContrailAAINetwork() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - public void prepareCreateNetworkRequest (DelegateExecution execution) { - - execution.setVariable("prefix",Prefix) - - logger.trace("Inside prepareCreateNetworkRequest() of DoCreateNetworkInstance") - - try { - - // get variables - String requestId = execution.getVariable("msoRequestId") - if (requestId == null) { - requestId = execution.getVariable("mso-request-id") - } - String messageId = execution.getVariable(Prefix + "messageId") - String source = execution.getVariable(Prefix + "source") - - String requestInput = execution.getVariable(Prefix + "networkRequest") - L3Network queryIdResponse = execution.getVariable(Prefix + "queryIdAAIResponse") - String cloudRegionId = execution.getVariable(Prefix + "cloudRegionPo") - String backoutOnFailure = execution.getVariable(Prefix + "rollbackEnabled") - - // Prepare Network request - String routeCollection = execution.getVariable(Prefix + "routeCollection") - String policyCollection = execution.getVariable(Prefix + "networkCollection") - String tableCollection = execution.getVariable(Prefix + "tableRefCollection") - String createNetworkRequest = networkUtils.CreateNetworkRequestV2(execution, requestId, messageId, requestInput, queryIdResponse, routeCollection, policyCollection, tableCollection, cloudRegionId, backoutOnFailure, source ) - // Format Response - String buildDeleteNetworkRequestAsString = utils.formatXml(createNetworkRequest) - buildDeleteNetworkRequestAsString = buildDeleteNetworkRequestAsString.replace(":w1aac13n0", "").replace("w1aac13n0:", "") - - execution.setVariable(Prefix + "createNetworkRequest", buildDeleteNetworkRequestAsString) - logger.debug(Prefix + "createNetworkRequest - " + "\n" + buildDeleteNetworkRequestAsString) - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareCreateNetworkRequest() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } + String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) + execution.setVariable(Prefix + "queryNetworkTableRefAAIResponse", aaiStubResponseAsXml) + execution.setVariable(Prefix + "tableRefCollection", "<routeTableFqdns/>") + logger.debug(" No net table references, using this stub as response - " + '\n' + aaiStubResponseAsXml) + + } + } + + } catch (NotFoundException e) { + String dataErrorMessage = "Response Error from QueryAAINetworkTableRef is 404 (Not Found)." + logger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTQueryAAINetworkTableRef() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + + public void callRESTUpdateContrailAAINetwork(DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + logger.trace(" ***** Inside callRESTUpdateContrailAAINetwork() of DoCreateNetworkInstance ***** " ) + + try { + // get variables + String networkId = execution.getVariable(Prefix + "networkId") + L3Network requeryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse") + String createNetworkResponse = execution.getVariable(Prefix + "createNetworkResponse") + + L3Network l3Network = new L3Network() + if (StringUtils.isBlank(requeryIdAAIResponse.getHeatStackId())) { + if (utils.nodeExists(createNetworkResponse, 'networkStackId')) { + l3Network.setHeatStackId(utils.getNodeText(createNetworkResponse, 'networkStackId')) + } + } + if (StringUtils.isBlank(requeryIdAAIResponse.getNeutronNetworkId())) { + if (utils.nodeExists(createNetworkResponse, 'neutronNetworkId')) { + l3Network.setNeutronNetworkId(utils.getNodeText(createNetworkResponse, 'neutronNetworkId')) + } + } + if (StringUtils.isBlank(requeryIdAAIResponse.getContrailNetworkFqdn())) { + if (utils.nodeExists(createNetworkResponse, 'networkFqdn')) { + l3Network.setContrailNetworkFqdn(utils.getNodeText(createNetworkResponse, 'networkFqdn')) + } + } + + String status = utils.getNodeText(createNetworkResponse, 'orchestration-status') + if(status.equals("pending-create") || status.equals("PendingCreate")){ + l3Network.setOrchestrationStatus("Created") + }else{ + l3Network.setOrchestrationStatus("Active") + } + + logger.debug("Updating l3-network in AAI" ) + + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId) + client.update(uri, l3Network) + + if(requeryIdAAIResponse.getSubnets() != null){ + for(Subnet s:requeryIdAAIResponse.getSubnets().getSubnet()){ + String subnetOrchStatus = s.getOrchestrationStatus() + String subnetId = s.getSubnetId() + Subnet subnet = new Subnet() + subnet.setNeutronSubnetId(networkUtils.extractNeutSubId(createNetworkResponse, subnetId)) + if(subnetOrchStatus.equals("pending-create") || subnetOrchStatus.equals("PendingCreate") ){ + subnet.setOrchestrationStatus("Created") + }else{ + subnet.setOrchestrationStatus("Active") + } + + logger.debug("Updating subnet in AAI" ) + AAIResourceUri subUri = AAIUriFactory.createResourceUri(AAIObjectType.SUBNET, networkId, subnetId) + client.update(subUri, subnet) + + } + } + + String rollbackEnabled = execution.getVariable(Prefix + "rollbackEnabled") + if (rollbackEnabled == "true") { + execution.setVariable(Prefix + "isPONR", false) + } else { + execution.setVariable(Prefix + "isPONR", true) + } + logger.debug(Prefix + "isPONR" + ": " + execution.getVariable(Prefix + "isPONR")) + + } catch (BpmnError e) { + throw e; + } catch (NotFoundException e) { + String dataErrorMessage = " Response Error from UpdateContrailAAINetwork is 404 (Not Found)." + logger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTUpdateContrailAAINetwork() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void prepareCreateNetworkRequest (DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + logger.trace("Inside prepareCreateNetworkRequest() of DoCreateNetworkInstance") + + try { + + // get variables + String requestId = execution.getVariable("msoRequestId") + if (requestId == null) { + requestId = execution.getVariable("mso-request-id") + } + String messageId = execution.getVariable(Prefix + "messageId") + String source = execution.getVariable(Prefix + "source") + + String requestInput = execution.getVariable(Prefix + "networkRequest") + L3Network queryIdResponse = execution.getVariable(Prefix + "queryIdAAIResponse") + String cloudRegionId = execution.getVariable(Prefix + "cloudRegionPo") + String backoutOnFailure = execution.getVariable(Prefix + "rollbackEnabled") + + // Prepare Network request + String routeCollection = execution.getVariable(Prefix + "routeCollection") + String policyCollection = execution.getVariable(Prefix + "networkCollection") + String tableCollection = execution.getVariable(Prefix + "tableRefCollection") + String createNetworkRequest = networkUtils.CreateNetworkRequestV2(execution, requestId, messageId, requestInput, queryIdResponse, routeCollection, policyCollection, tableCollection, cloudRegionId, backoutOnFailure, source ) + // Format Response + String buildDeleteNetworkRequestAsString = utils.formatXml(createNetworkRequest) + buildDeleteNetworkRequestAsString = buildDeleteNetworkRequestAsString.replace(":w1aac13n0", "").replace("w1aac13n0:", "") + + execution.setVariable(Prefix + "createNetworkRequest", buildDeleteNetworkRequestAsString) + logger.debug(Prefix + "createNetworkRequest - " + "\n" + buildDeleteNetworkRequestAsString) + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareCreateNetworkRequest() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } + } - public void prepareSDNCRequest (DelegateExecution execution) { + } - execution.setVariable("prefix",Prefix) + public void prepareSDNCRequest (DelegateExecution execution) { - logger.trace("Inside prepareSDNCRequest() of DoCreateNetworkInstance") + execution.setVariable("prefix",Prefix) - try { - // get variables - String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) - String createNetworkInput = execution.getVariable(Prefix + "networkRequest") - String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") + logger.trace("Inside prepareSDNCRequest() of DoCreateNetworkInstance") - String networkId = execution.getVariable(Prefix + "networkId") - String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") + try { + // get variables + String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + String createNetworkInput = execution.getVariable(Prefix + "networkRequest") + String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") - // get/set 'msoRequestId' and 'mso-request-id' - String requestId = execution.getVariable("msoRequestId") - if (requestId != null) { - execution.setVariable("mso-request-id", requestId) - } else { - requestId = execution.getVariable("mso-request-id") - } - execution.setVariable(Prefix + "requestId", requestId) + String networkId = execution.getVariable(Prefix + "networkId") + String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") - // 1. prepare assign topology via SDNC Adapter SUBFLOW call - String sndcTopologyCreateRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, createNetworkInput, serviceInstanceId, sdncCallback, "assign", "NetworkActivateRequest", cloudRegionId, networkId, null, null) + // get/set 'msoRequestId' and 'mso-request-id' + String requestId = execution.getVariable("msoRequestId") + if (requestId != null) { + execution.setVariable("mso-request-id", requestId) + } else { + requestId = execution.getVariable("mso-request-id") + } + execution.setVariable(Prefix + "requestId", requestId) - String sndcTopologyCreateRequesAsString = utils.formatXml(sndcTopologyCreateRequest) - execution.setVariable(Prefix + "assignSDNCRequest", sndcTopologyCreateRequesAsString) - logger.debug(Prefix + "assignSDNCRequest - " + "\n" + sndcTopologyCreateRequesAsString) + // 1. prepare assign topology via SDNC Adapter SUBFLOW call + String sndcTopologyCreateRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, createNetworkInput, serviceInstanceId, sdncCallback, "assign", "NetworkActivateRequest", cloudRegionId, networkId, null, null) + String sndcTopologyCreateRequesAsString = utils.formatXml(sndcTopologyCreateRequest) + execution.setVariable(Prefix + "assignSDNCRequest", sndcTopologyCreateRequesAsString) + logger.debug(Prefix + "assignSDNCRequest - " + "\n" + sndcTopologyCreateRequesAsString) - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareSDNCRequest() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareSDNCRequest() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } + } - public void prepareRpcSDNCRequest (DelegateExecution execution) { + } - execution.setVariable("prefix",Prefix) + public void prepareRpcSDNCRequest (DelegateExecution execution) { - logger.trace("Inside prepareRpcSDNCRequest() of DoCreateNetworkInstance") + execution.setVariable("prefix",Prefix) - try { - // get variables + logger.trace("Inside prepareRpcSDNCRequest() of DoCreateNetworkInstance") - String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) - String createNetworkInput = execution.getVariable(Prefix + "networkRequest") - String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") + try { + // get variables - String networkId = execution.getVariable(Prefix + "networkId") - String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") + String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + String createNetworkInput = execution.getVariable(Prefix + "networkRequest") + String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") - // 1. prepare assign topology via SDNC Adapter SUBFLOW call - String sndcTopologyCreateRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, createNetworkInput, serviceInstanceId, sdncCallback, "assign", "CreateNetworkInstance", cloudRegionId, networkId, null) + String networkId = execution.getVariable(Prefix + "networkId") + String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") - String sndcTopologyCreateRequesAsString = utils.formatXml(sndcTopologyCreateRequest) - execution.setVariable(Prefix + "assignSDNCRequest", sndcTopologyCreateRequesAsString) - logger.debug(Prefix + "assignSDNCRequest - " + "\n" + sndcTopologyCreateRequesAsString) + // 1. prepare assign topology via SDNC Adapter SUBFLOW call + String sndcTopologyCreateRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, createNetworkInput, serviceInstanceId, sdncCallback, "assign", "CreateNetworkInstance", cloudRegionId, networkId, null) - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareRpcSDNCRequest() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + String sndcTopologyCreateRequesAsString = utils.formatXml(sndcTopologyCreateRequest) + execution.setVariable(Prefix + "assignSDNCRequest", sndcTopologyCreateRequesAsString) + logger.debug(Prefix + "assignSDNCRequest - " + "\n" + sndcTopologyCreateRequesAsString) - } + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareRpcSDNCRequest() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } + } - public void prepareRpcSDNCActivateRequest (DelegateExecution execution) { + } - execution.setVariable("prefix",Prefix) + public void prepareRpcSDNCActivateRequest (DelegateExecution execution) { - logger.trace("Inside prepareRpcSDNCActivateRequest() of DoCreateNetworkInstance") + execution.setVariable("prefix",Prefix) - try { - // get variables - String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) - String createNetworkInput = execution.getVariable(Prefix + "networkRequest") - String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") - String networkId = execution.getVariable(Prefix + "networkId") - String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") + logger.trace("Inside prepareRpcSDNCActivateRequest() of DoCreateNetworkInstance") - // 1. prepare assign topology via SDNC Adapter SUBFLOW call - String sndcTopologyCreateRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, createNetworkInput, serviceInstanceId, sdncCallback, "activate", "CreateNetworkInstance", cloudRegionId, networkId, null) + try { + // get variables + String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + String createNetworkInput = execution.getVariable(Prefix + "networkRequest") + String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") + String networkId = execution.getVariable(Prefix + "networkId") + String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") - String sndcTopologyCreateRequesAsString = utils.formatXml(sndcTopologyCreateRequest) - execution.setVariable(Prefix + "activateSDNCRequest", sndcTopologyCreateRequesAsString) - logger.debug(Prefix + "activateSDNCRequest - " + "\n" + sndcTopologyCreateRequesAsString) + // 1. prepare assign topology via SDNC Adapter SUBFLOW call + String sndcTopologyCreateRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, createNetworkInput, serviceInstanceId, sdncCallback, "activate", "CreateNetworkInstance", cloudRegionId, networkId, null) + String sndcTopologyCreateRequesAsString = utils.formatXml(sndcTopologyCreateRequest) + execution.setVariable(Prefix + "activateSDNCRequest", sndcTopologyCreateRequesAsString) + logger.debug(Prefix + "activateSDNCRequest - " + "\n" + sndcTopologyCreateRequesAsString) - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareRpcSDNCActivateRequest() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareRpcSDNCActivateRequest() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } + } + } - // ************************************************** - // Post or Validate Response Section - // ************************************************** - public void validateCreateNetworkResponse (DelegateExecution execution) { + // ************************************************** + // Post or Validate Response Section + // ************************************************** - execution.setVariable("prefix",Prefix) + public void validateCreateNetworkResponse (DelegateExecution execution) { - logger.trace("Inside validateNetworkResponse() of DoCreateNetworkInstance") + execution.setVariable("prefix",Prefix) - try { - String returnCode = execution.getVariable(Prefix + "networkReturnCode") - String networkResponse = execution.getVariable(Prefix + "createNetworkResponse") - if (networkResponse==null) { - networkResponse="" // reset - } + logger.trace("Inside validateNetworkResponse() of DoCreateNetworkInstance") - logger.debug(" Network Adapter create responseCode: " + returnCode) + try { + String networkResponse = execution.getVariable(Prefix + "createNetworkResponse") + if (networkResponse==null) { + networkResponse="" // reset + } - String errorMessage = "" - if (returnCode == "200") { - execution.setVariable(Prefix + "isNetworkRollbackNeeded", true) - execution.setVariable(Prefix + "createNetworkResponse", networkResponse) - logger.debug(" Network Adapter create Success Response - " + "\n" + networkResponse) + execution.setVariable(Prefix + "isNetworkRollbackNeeded", true) + execution.setVariable(Prefix + "createNetworkResponse", networkResponse) + logger.debug(" Network Adapter create Success Response - " + "\n" + networkResponse) - // prepare rollback data - String rollbackData = utils.getNodeXml(networkResponse, "rollback", false).replace("tag0:","").replace(":tag0","") - rollbackData = rollbackData.replace("rollback>", "networkRollback>") - String rollbackNetwork = - """<rollbackNetworkRequest> + // prepare rollback data + String rollbackData = utils.getNodeXml(networkResponse, "rollback", false).replace("tag0:","").replace(":tag0","") + rollbackData = rollbackData.replace("rollback>", "networkRollback>") + String rollbackNetwork = + """<rollbackNetworkRequest> ${rollbackData} </rollbackNetworkRequest>""" - String rollbackNetworkXml = utils.formatXml(rollbackNetwork) - execution.setVariable(Prefix + "rollbackNetworkRequest", rollbackNetworkXml) - logger.debug(" Network Adapter rollback data - " + "\n" + rollbackNetworkXml) - - } else { // network error - if (returnCode.toInteger() > 399 && returnCode.toInteger() < 600) { //4xx, 5xx - if (networkResponse.contains("createNetworkError")) { - networkResponse = networkResponse.replace('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>', '') - errorMessage = utils.getNodeText(networkResponse, "message") - errorMessage = "Received error from Network Adapter: " + errorMessage - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) - - } else { // CatchAll exception - if (returnCode == "500") { - errorMessage = "JBWEB000065: HTTP Status 500." - } else { - errorMessage = "Return code is " + returnCode - } - errorMessage = "Received error from Network Adapter: " + errorMessage - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) - - } - - } else { // CatchAll exception - String dataErrorMessage = "Received error from Network Adapter. Return code is: " + returnCode - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - - } + String rollbackNetworkXml = utils.formatXml(rollbackNetwork) + execution.setVariable(Prefix + "rollbackNetworkRequest", rollbackNetworkXml) + logger.debug(" Network Adapter rollback data - " + "\n" + rollbackNetworkXml) - } catch (BpmnError e) { - throw e; + } catch (BpmnError e) { + throw e; - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. validateCreateNetworkResponse() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. validateCreateNetworkResponse() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } + } - } + } - public void validateSDNCResponse (DelegateExecution execution) { + public void validateSDNCResponse (DelegateExecution execution) { - execution.setVariable("prefix",Prefix) + execution.setVariable("prefix",Prefix) - logger.trace("Inside validateSDNCResponse() of DoCreateNetworkInstance") + logger.trace("Inside validateSDNCResponse() of DoCreateNetworkInstance") - String response = execution.getVariable(Prefix + "assignSDNCResponse") - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - WorkflowException workflowException = execution.getVariable("WorkflowException") + String response = execution.getVariable(Prefix + "assignSDNCResponse") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + WorkflowException workflowException = execution.getVariable("WorkflowException") - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - // reset variable - String assignSDNCResponseDecodeXml = execution.getVariable(Prefix + "assignSDNCResponse") - assignSDNCResponseDecodeXml = assignSDNCResponseDecodeXml.replace('<?xml version="1.0" encoding="UTF-8"?>', "") - execution.setVariable(Prefix + "assignSDNCResponse", assignSDNCResponseDecodeXml) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + // reset variable + String assignSDNCResponseDecodeXml = execution.getVariable(Prefix + "assignSDNCResponse") + assignSDNCResponseDecodeXml = assignSDNCResponseDecodeXml.replace('<?xml version="1.0" encoding="UTF-8"?>', "") + execution.setVariable(Prefix + "assignSDNCResponse", assignSDNCResponseDecodeXml) - if (execution.getVariable(Prefix + "sdncResponseSuccess") == true) { // from sdnc util, Prefix+'sdncResponseSuccess' - execution.setVariable(Prefix + "isSdncRollbackNeeded", true) - logger.debug("Successfully Validated SDNC Response") + if (execution.getVariable(Prefix + "sdncResponseSuccess") == true) { // from sdnc util, Prefix+'sdncResponseSuccess' + execution.setVariable(Prefix + "isSdncRollbackNeeded", true) + logger.debug("Successfully Validated SDNC Response") - } else { - logger.debug("Did NOT Successfully Validated SDNC Response") - throw new BpmnError("MSOWorkflowException") - } + } else { + logger.debug("Did NOT Successfully Validated SDNC Response") + throw new BpmnError("MSOWorkflowException") + } - } + } - public void validateRpcSDNCActivateResponse (DelegateExecution execution) { + public void validateRpcSDNCActivateResponse (DelegateExecution execution) { - execution.setVariable("prefix",Prefix) + execution.setVariable("prefix",Prefix) - logger.trace("Inside validateRpcSDNCActivateResponse() of DoCreateNetworkInstance") + logger.trace("Inside validateRpcSDNCActivateResponse() of DoCreateNetworkInstance") - String response = execution.getVariable(Prefix + "activateSDNCResponse") - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - WorkflowException workflowException = execution.getVariable("WorkflowException") + String response = execution.getVariable(Prefix + "activateSDNCResponse") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + WorkflowException workflowException = execution.getVariable("WorkflowException") - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - // reset variable - String assignSDNCResponseDecodeXml = execution.getVariable(Prefix + "activateSDNCResponse") - assignSDNCResponseDecodeXml = assignSDNCResponseDecodeXml.replace('<?xml version="1.0" encoding="UTF-8"?>', "") - execution.setVariable(Prefix + "activateSDNCResponse", assignSDNCResponseDecodeXml) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + // reset variable + String assignSDNCResponseDecodeXml = execution.getVariable(Prefix + "activateSDNCResponse") + assignSDNCResponseDecodeXml = assignSDNCResponseDecodeXml.replace('<?xml version="1.0" encoding="UTF-8"?>', "") + execution.setVariable(Prefix + "activateSDNCResponse", assignSDNCResponseDecodeXml) - if (execution.getVariable(Prefix + "sdncResponseSuccess") == true) { // from sdnc util, Prefix+'sdncResponseSuccess' - execution.setVariable(Prefix + "isSdncActivateRollbackNeeded", true) - logger.debug("Successfully Validated Rpc SDNC Activate Response") + if (execution.getVariable(Prefix + "sdncResponseSuccess") == true) { // from sdnc util, Prefix+'sdncResponseSuccess' + execution.setVariable(Prefix + "isSdncActivateRollbackNeeded", true) + logger.debug("Successfully Validated Rpc SDNC Activate Response") - } else { - logger.debug("Did NOT Successfully Validated Rpc SDNC Activate Response") - throw new BpmnError("MSOWorkflowException") - } + } else { + logger.debug("Did NOT Successfully Validated Rpc SDNC Activate Response") + throw new BpmnError("MSOWorkflowException") + } - } + } - public void prepareSDNCRollbackRequest (DelegateExecution execution) { + public void prepareSDNCRollbackRequest (DelegateExecution execution) { - execution.setVariable("prefix",Prefix) + execution.setVariable("prefix",Prefix) - logger.trace("Inside prepareSDNCRollbackRequest() of DoCreateNetworkInstance") + logger.trace("Inside prepareSDNCRollbackRequest() of DoCreateNetworkInstance") - try { - // get variables - String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) - String createNetworkInput = execution.getVariable(Prefix + "networkRequest") - String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") - String assignSDNCResponse = execution.getVariable(Prefix + "assignSDNCResponse") - String networkId = execution.getVariable(Prefix + "networkId") - if (networkId == 'null') {networkId = ""} - String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") + try { + // get variables + String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + String createNetworkInput = execution.getVariable(Prefix + "networkRequest") + String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") + String assignSDNCResponse = execution.getVariable(Prefix + "assignSDNCResponse") + String networkId = execution.getVariable(Prefix + "networkId") + if (networkId == 'null') {networkId = ""} + String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") - // 2. prepare rollback topology via SDNC Adapter SUBFLOW call - String sndcTopologyRollbackRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, createNetworkInput, serviceInstanceId, sdncCallback, "rollback", "NetworkActivateRequest", cloudRegionId, networkId, null, null) - String sndcTopologyRollbackRequestAsString = utils.formatXml(sndcTopologyRollbackRequest) - execution.setVariable(Prefix + "rollbackSDNCRequest", sndcTopologyRollbackRequestAsString) - logger.debug(" Preparing request for SDNC Topology 'rollback-NetworkActivateRequest' rollback . . . - " + "\n" + sndcTopologyRollbackRequestAsString) + // 2. prepare rollback topology via SDNC Adapter SUBFLOW call + String sndcTopologyRollbackRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, createNetworkInput, serviceInstanceId, sdncCallback, "rollback", "NetworkActivateRequest", cloudRegionId, networkId, null, null) + String sndcTopologyRollbackRequestAsString = utils.formatXml(sndcTopologyRollbackRequest) + execution.setVariable(Prefix + "rollbackSDNCRequest", sndcTopologyRollbackRequestAsString) + logger.debug(" Preparing request for SDNC Topology 'rollback-NetworkActivateRequest' rollback . . . - " + "\n" + sndcTopologyRollbackRequestAsString) - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareSDNCRollbackRequest() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareSDNCRollbackRequest() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - } + } - } + } - public void prepareRpcSDNCRollbackRequest (DelegateExecution execution) { + public void prepareRpcSDNCRollbackRequest (DelegateExecution execution) { - execution.setVariable("prefix",Prefix) + execution.setVariable("prefix",Prefix) - logger.trace("Inside prepareRpcSDNCRollbackRequest() of DoCreateNetworkInstance") + logger.trace("Inside prepareRpcSDNCRollbackRequest() of DoCreateNetworkInstance") - try { - // get variables - String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) - String createNetworkInput = execution.getVariable(Prefix + "networkRequest") - String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") - String assignSDNCResponse = execution.getVariable(Prefix + "assignSDNCResponse") - String networkId = execution.getVariable(Prefix + "networkId") - if (networkId == 'null') {networkId = ""} - String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") + try { + // get variables + String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + String createNetworkInput = execution.getVariable(Prefix + "networkRequest") + String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") + String assignSDNCResponse = execution.getVariable(Prefix + "assignSDNCResponse") + String networkId = execution.getVariable(Prefix + "networkId") + if (networkId == 'null') {networkId = ""} + String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") - // 2. prepare rollback topology via SDNC Adapter SUBFLOW call - String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, createNetworkInput, serviceInstanceId, sdncCallback, "unassign", "DeleteNetworkInstance", cloudRegionId, networkId, null) - String sndcTopologyRollbackRpcRequestAsString = utils.formatXml(sndcTopologyRollbackRpcRequest) - execution.setVariable(Prefix + "rollbackSDNCRequest", sndcTopologyRollbackRpcRequestAsString) - logger.debug(" Preparing request for SDNC Topology 'unassign-DeleteNetworkInstance' rollback . . . - " + "\n" + sndcTopologyRollbackRpcRequestAsString) + // 2. prepare rollback topology via SDNC Adapter SUBFLOW call + String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, createNetworkInput, serviceInstanceId, sdncCallback, "unassign", "DeleteNetworkInstance", cloudRegionId, networkId, null) + String sndcTopologyRollbackRpcRequestAsString = utils.formatXml(sndcTopologyRollbackRpcRequest) + execution.setVariable(Prefix + "rollbackSDNCRequest", sndcTopologyRollbackRpcRequestAsString) + logger.debug(" Preparing request for SDNC Topology 'unassign-DeleteNetworkInstance' rollback . . . - " + "\n" + sndcTopologyRollbackRpcRequestAsString) - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareRpcSDNCRollbackRequest() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareRpcSDNCRollbackRequest() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - } + } - } + } - public void prepareRpcSDNCActivateRollback(DelegateExecution execution) { + public void prepareRpcSDNCActivateRollback(DelegateExecution execution) { - execution.setVariable("prefix",Prefix) + execution.setVariable("prefix",Prefix) - logger.trace("Inside prepareRpcSDNCActivateRollback() of DoCreateNetworkInstance") + logger.trace("Inside prepareRpcSDNCActivateRollback() of DoCreateNetworkInstance") - try { + try { - // get variables - String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) - String createNetworkInput = execution.getVariable(Prefix + "networkRequest") - String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") - String activateSDNCResponse = execution.getVariable(Prefix + "activateSDNCResponse") - String networkId = execution.getVariable(Prefix + "networkId") - if (networkId == 'null') {networkId = ""} - String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") - - // 2. prepare rollback topology via SDNC Adapter SUBFLOW call - String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, createNetworkInput, serviceInstanceId, sdncCallback, "deactivate", "DeleteNetworkInstance", cloudRegionId, networkId, null) - String sndcTopologyRollbackRpcRequestAsString = utils.formatXml(sndcTopologyRollbackRpcRequest) - execution.setVariable(Prefix + "rollbackActivateSDNCRequest", sndcTopologyRollbackRpcRequestAsString) - logger.debug(" Preparing request for RPC SDNC Topology 'deactivate-DeleteNetworkInstance' rollback . . . - " + "\n" + sndcTopologyRollbackRpcRequestAsString) - - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareRpcSDNCActivateRollback() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - - } - - } + // get variables + String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + String createNetworkInput = execution.getVariable(Prefix + "networkRequest") + String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") + String activateSDNCResponse = execution.getVariable(Prefix + "activateSDNCResponse") + String networkId = execution.getVariable(Prefix + "networkId") + if (networkId == 'null') {networkId = ""} + String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") + + // 2. prepare rollback topology via SDNC Adapter SUBFLOW call + String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, createNetworkInput, serviceInstanceId, sdncCallback, "deactivate", "DeleteNetworkInstance", cloudRegionId, networkId, null) + String sndcTopologyRollbackRpcRequestAsString = utils.formatXml(sndcTopologyRollbackRpcRequest) + execution.setVariable(Prefix + "rollbackActivateSDNCRequest", sndcTopologyRollbackRpcRequestAsString) + logger.debug(" Preparing request for RPC SDNC Topology 'deactivate-DeleteNetworkInstance' rollback . . . - " + "\n" + sndcTopologyRollbackRpcRequestAsString) + + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareRpcSDNCActivateRollback() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + + } + + } - public void prepareRollbackData(DelegateExecution execution) { + public void prepareRollbackData(DelegateExecution execution) { - execution.setVariable("prefix",Prefix) - - logger.trace("Inside prepareRollbackData() of DoCreateNetworkInstance") - - try { - - Map<String, String> rollbackData = new HashMap<String, String>(); - String rollbackSDNCRequest = execution.getVariable(Prefix + "rollbackSDNCRequest") - if (rollbackSDNCRequest != null) { - if (rollbackSDNCRequest != "") { - rollbackData.put("rollbackSDNCRequest", execution.getVariable(Prefix + "rollbackSDNCRequest")) - } - } - String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest") - if (rollbackNetworkRequest != null) { - if (rollbackNetworkRequest != "") { - rollbackData.put("rollbackNetworkRequest", execution.getVariable(Prefix + "rollbackNetworkRequest")) - } - } - String rollbackActivateSDNCRequest = execution.getVariable(Prefix + "rollbackActivateSDNCRequest") - if (rollbackActivateSDNCRequest != null) { - if (rollbackActivateSDNCRequest != "") { - rollbackData.put("rollbackActivateSDNCRequest", execution.getVariable(Prefix + "rollbackActivateSDNCRequest")) - } - } - execution.setVariable("rollbackData", rollbackData) - logger.debug("** rollbackData : " + rollbackData) - - execution.setVariable("WorkflowException", execution.getVariable(Prefix + "WorkflowException")) - logger.debug("** WorkflowException : " + execution.getVariable("WorkflowException")) - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareRollbackData() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void postProcessResponse(DelegateExecution execution) { - - execution.setVariable("prefix",Prefix) - - logger.trace("Inside postProcessResponse() of DoCreateNetworkInstance") - - try { - - //Conditions: - // 1. Silent Success: execution.getVariable("CRENWKI_orchestrationStatus") == "ACTIVE" - // 2. Success: execution.getVariable("WorkflowException") == null (NULL) - // 3. WorkflowException: execution.getVariable("WorkflowException") != null (NOT NULL) - - logger.debug(" ***** Is Exception Encountered (isException)? : " + execution.getVariable(Prefix + "isException")) - // successful flow - if (execution.getVariable(Prefix + "isException") == false) { - // set rollback data - execution.setVariable("orchestrationStatus", "") - execution.setVariable("networkId", execution.getVariable(Prefix + "networkId")) - execution.setVariable("networkName", execution.getVariable(Prefix + "networkName")) - prepareSuccessRollbackData(execution) // populate rollbackData - execution.setVariable("WorkflowException", null) - execution.setVariable(Prefix + "Success", true) - logger.debug(" ***** postProcessResponse(), GOOD !!!") - } else { - // inside sub-flow logic - execution.setVariable(Prefix + "Success", false) - execution.setVariable("rollbackData", null) - String exceptionMessage = " Exception encountered in MSO Bpmn. " - if (execution.getVariable("workflowException") != null) { // Output of Rollback flow. - logger.debug(" ***** workflowException: " + execution.getVariable("workflowException")) - WorkflowException wfex = execution.getVariable("workflowException") - exceptionMessage = wfex.getErrorMessage() - } else { - if (execution.getVariable(Prefix + "WorkflowException") != null) { - WorkflowException pwfex = execution.getVariable(Prefix + "WorkflowException") - exceptionMessage = pwfex.getErrorMessage() - } - } - // going to the Main flow: a-la-carte or macro - logger.debug(" ***** postProcessResponse(), BAD !!!") - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - throw new BpmnError("MSOWorkflowException") - } + execution.setVariable("prefix",Prefix) + + logger.trace("Inside prepareRollbackData() of DoCreateNetworkInstance") + + try { + + Map<String, String> rollbackData = new HashMap<String, String>(); + String rollbackSDNCRequest = execution.getVariable(Prefix + "rollbackSDNCRequest") + if (rollbackSDNCRequest != null) { + if (rollbackSDNCRequest != "") { + rollbackData.put("rollbackSDNCRequest", execution.getVariable(Prefix + "rollbackSDNCRequest")) + } + } + String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest") + if (rollbackNetworkRequest != null) { + if (rollbackNetworkRequest != "") { + rollbackData.put("rollbackNetworkRequest", execution.getVariable(Prefix + "rollbackNetworkRequest")) + } + } + String rollbackActivateSDNCRequest = execution.getVariable(Prefix + "rollbackActivateSDNCRequest") + if (rollbackActivateSDNCRequest != null) { + if (rollbackActivateSDNCRequest != "") { + rollbackData.put("rollbackActivateSDNCRequest", execution.getVariable(Prefix + "rollbackActivateSDNCRequest")) + } + } + execution.setVariable("rollbackData", rollbackData) + logger.debug("** rollbackData : " + rollbackData) + + execution.setVariable("WorkflowException", execution.getVariable(Prefix + "WorkflowException")) + logger.debug("** WorkflowException : " + execution.getVariable("WorkflowException")) + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareRollbackData() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void postProcessResponse(DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + logger.trace("Inside postProcessResponse() of DoCreateNetworkInstance") + + try { + + //Conditions: + // 1. Silent Success: execution.getVariable("CRENWKI_orchestrationStatus") == "ACTIVE" + // 2. Success: execution.getVariable("WorkflowException") == null (NULL) + // 3. WorkflowException: execution.getVariable("WorkflowException") != null (NOT NULL) + + logger.debug(" ***** Is Exception Encountered (isException)? : " + execution.getVariable(Prefix + "isException")) + // successful flow + if (execution.getVariable(Prefix + "isException") == false) { + // set rollback data + execution.setVariable("orchestrationStatus", "") + execution.setVariable("networkId", execution.getVariable(Prefix + "networkId")) + execution.setVariable("networkName", execution.getVariable(Prefix + "networkName")) + prepareSuccessRollbackData(execution) // populate rollbackData + execution.setVariable("WorkflowException", null) + execution.setVariable(Prefix + "Success", true) + logger.debug(" ***** postProcessResponse(), GOOD !!!") + } else { + // inside sub-flow logic + execution.setVariable(Prefix + "Success", false) + execution.setVariable("rollbackData", null) + String exceptionMessage = " Exception encountered in MSO Bpmn. " + if (execution.getVariable("workflowException") != null) { // Output of Rollback flow. + logger.debug(" ***** workflowException: " + execution.getVariable("workflowException")) + WorkflowException wfex = execution.getVariable("workflowException") + exceptionMessage = wfex.getErrorMessage() + } else { + if (execution.getVariable(Prefix + "WorkflowException") != null) { + WorkflowException pwfex = execution.getVariable(Prefix + "WorkflowException") + exceptionMessage = pwfex.getErrorMessage() + } + } + // going to the Main flow: a-la-carte or macro + logger.debug(" ***** postProcessResponse(), BAD !!!") + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + throw new BpmnError("MSOWorkflowException") + } - } catch(BpmnError b){ - logger.debug("Rethrowing MSOWorkflowException") - throw b + } catch(BpmnError b){ + logger.debug("Rethrowing MSOWorkflowException") + throw b - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. postProcessResponse() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - throw new BpmnError("MSOWorkflowException") - - } - - - - } - - public void prepareSuccessRollbackData(DelegateExecution execution) { - - execution.setVariable("prefix",Prefix) - - logger.trace("Inside prepareSuccessRollbackData() of DoCreateNetworkInstance") - - try { - - if (execution.getVariable("sdncVersion") != '1610') { - prepareRpcSDNCRollbackRequest(execution) - prepareRpcSDNCActivateRollback(execution) - } else { - prepareSDNCRollbackRequest(execution) - } - - Map<String, String> rollbackData = new HashMap<String, String>(); - String rollbackSDNCRequest = execution.getVariable(Prefix + "rollbackSDNCRequest") - if (rollbackSDNCRequest != null) { - if (rollbackSDNCRequest != "") { - rollbackData.put("rollbackSDNCRequest", rollbackSDNCRequest) - } - } - String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest") - if (rollbackNetworkRequest != null) { - if (rollbackNetworkRequest != "") { - rollbackData.put("rollbackNetworkRequest", rollbackNetworkRequest) - } - } - String rollbackActivateSDNCRequest = execution.getVariable(Prefix + "rollbackActivateSDNCRequest") - if (rollbackActivateSDNCRequest != null) { - if (rollbackActivateSDNCRequest != "") { - rollbackData.put("rollbackActivateSDNCRequest", rollbackActivateSDNCRequest) - } - } - execution.setVariable("rollbackData", rollbackData) - - logger.debug("** 'rollbackData' for Full Rollback : " + rollbackData) - execution.setVariable("WorkflowException", null) - - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareSuccessRollbackData() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void setExceptionFlag(DelegateExecution execution){ - - execution.setVariable("prefix",Prefix) - - logger.trace("Inside setExceptionFlag() of DoCreateNetworkInstance") - - try { - - execution.setVariable(Prefix + "isException", true) - - if (execution.getVariable("SavedWorkflowException1") != null) { - execution.setVariable(Prefix + "WorkflowException", execution.getVariable("SavedWorkflowException1")) - } else { - execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException")) - } - logger.debug(Prefix + "WorkflowException - " +execution.getVariable(Prefix + "WorkflowException")) + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. postProcessResponse() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + throw new BpmnError("MSOWorkflowException") + + } + + + + } + + public void prepareSuccessRollbackData(DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + logger.trace("Inside prepareSuccessRollbackData() of DoCreateNetworkInstance") + + try { + + if (execution.getVariable("sdncVersion") != '1610') { + prepareRpcSDNCRollbackRequest(execution) + prepareRpcSDNCActivateRollback(execution) + } else { + prepareSDNCRollbackRequest(execution) + } + + Map<String, String> rollbackData = new HashMap<String, String>(); + String rollbackSDNCRequest = execution.getVariable(Prefix + "rollbackSDNCRequest") + if (rollbackSDNCRequest != null) { + if (rollbackSDNCRequest != "") { + rollbackData.put("rollbackSDNCRequest", rollbackSDNCRequest) + } + } + String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest") + if (rollbackNetworkRequest != null) { + if (rollbackNetworkRequest != "") { + rollbackData.put("rollbackNetworkRequest", rollbackNetworkRequest) + } + } + String rollbackActivateSDNCRequest = execution.getVariable(Prefix + "rollbackActivateSDNCRequest") + if (rollbackActivateSDNCRequest != null) { + if (rollbackActivateSDNCRequest != "") { + rollbackData.put("rollbackActivateSDNCRequest", rollbackActivateSDNCRequest) + } + } + execution.setVariable("rollbackData", rollbackData) + + logger.debug("** 'rollbackData' for Full Rollback : " + rollbackData) + execution.setVariable("WorkflowException", null) + + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareSuccessRollbackData() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void setExceptionFlag(DelegateExecution execution){ + + execution.setVariable("prefix",Prefix) + + logger.trace("Inside setExceptionFlag() of DoCreateNetworkInstance") + + try { + + execution.setVariable(Prefix + "isException", true) + + if (execution.getVariable("SavedWorkflowException1") != null) { + execution.setVariable(Prefix + "WorkflowException", execution.getVariable("SavedWorkflowException1")) + } else { + execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException")) + } + logger.debug(Prefix + "WorkflowException - " +execution.getVariable(Prefix + "WorkflowException")) - } catch(Exception ex){ - String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. setExceptionFlag(): " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - } + } catch(Exception ex){ + String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. setExceptionFlag(): " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + } - } + } - // ******************************* - // Build Error Section - // ******************************* + // ******************************* + // Build Error Section + // ******************************* - public void processJavaException(DelegateExecution execution){ + public void processJavaException(DelegateExecution execution){ - execution.setVariable("prefix",Prefix) + execution.setVariable("prefix",Prefix) - try{ - logger.debug( "Caught a Java Exception in " + Prefix) - logger.debug("Started processJavaException Method") - logger.debug("Variables List: " + execution.getVariables()) - execution.setVariable("UnexpectedError", "Caught a Java Lang Exception - " + Prefix) // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception") + try{ + logger.debug( "Caught a Java Exception in " + Prefix) + logger.debug("Started processJavaException Method") + logger.debug("Variables List: " + execution.getVariables()) + execution.setVariable("UnexpectedError", "Caught a Java Lang Exception - " + Prefix) // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception") - }catch(Exception e){ - logger.debug("Caught Exception during processJavaException Method: " + e) - execution.setVariable("UnexpectedError", "Exception in processJavaException method - " + Prefix) // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method" + Prefix) - } - logger.debug( "Completed processJavaException Method in " + Prefix) - } + }catch(Exception e){ + logger.debug("Caught Exception during processJavaException Method: " + e) + execution.setVariable("UnexpectedError", "Exception in processJavaException method - " + Prefix) // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method" + Prefix) + } + logger.debug( "Completed processJavaException Method in " + Prefix) + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollback.groovy index e34e505e55..313e2f4cb7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollback.groovy @@ -48,333 +48,312 @@ import org.camunda.bpm.engine.delegate.DelegateExecution public class DoCreateNetworkInstanceRollback extends AbstractServiceTaskProcessor { private static final Logger logger = LoggerFactory.getLogger( DoCreateNetworkInstanceRollback.class); - String Prefix="CRENWKIR_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils(this) - NetworkUtils networkUtils = new NetworkUtils() - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - - def className = getClass().getSimpleName() - - /** - * This method is executed during the preProcessRequest task of the <class>DoCreateNetworkInstanceRollback.bpmn</class> process. - * @param execution - */ - public InitializeProcessVariables(DelegateExecution execution){ - /* Initialize all the process variables in this block */ - - execution.setVariable(Prefix + "rollbackNetworkRequest", null) - execution.setVariable(Prefix + "rollbackSDNCRequest", null) - execution.setVariable(Prefix + "rollbackActivateSDNCRequest", null) - execution.setVariable(Prefix + "WorkflowException", null) - - execution.setVariable(Prefix + "rollbackNetworkRequest", "") - execution.setVariable(Prefix + "rollbackNetworkResponse", "") - execution.setVariable(Prefix + "rollbackNetworkReturnCode", "") - - execution.setVariable(Prefix + "rollbackSDNCRequest", "") - execution.setVariable(Prefix + "rollbackSDNCResponse", "") - execution.setVariable(Prefix + "rollbackSDNCReturnCode", "") - - execution.setVariable(Prefix + "rollbackActivateSDNCRequest", "") - execution.setVariable(Prefix + "rollbackActivateSDNCResponse", "") - execution.setVariable(Prefix + "rollbackActivateSDNCReturnCode", "") - - execution.setVariable(Prefix + "Success", false) - execution.setVariable(Prefix + "fullRollback", false) - execution.setVariable(Prefix + "networkId", "") - execution.setVariable(Prefix + "urlRollbackPoNetwork", "") - - } - - // ************************************************** - // Pre or Prepare Request Section - // ************************************************** - /** - * This method is executed during the preProcessRequest task of the <class>DoCreateNetworkInstanceRollback.bpmn</class> process. - * @param execution - */ - public void preProcessRequest (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - logger.trace("Inside preProcessRequest() of " + className + ".groovy") - - try { - // initialize flow variables - InitializeProcessVariables(execution) - - // GET Incoming request/variables - String rollbackNetworkRequest = null - String rollbackSDNCRequest = null - String rollbackActivateSDNCRequest = null - - // Partial Rollback - Map<String, String> rollbackData = execution.getVariable("rollbackData") - if (rollbackData != null && rollbackData instanceof Map) { - - if(rollbackData.containsKey("rollbackSDNCRequest")) { - rollbackSDNCRequest = rollbackData["rollbackSDNCRequest"] - } - - if(rollbackData.containsKey("rollbackNetworkRequest")) { - rollbackNetworkRequest = rollbackData["rollbackNetworkRequest"] - } - - if(rollbackData.containsKey("rollbackActivateSDNCRequest")) { - rollbackActivateSDNCRequest = rollbackData["rollbackActivateSDNCRequest"] - } - - } - - execution.setVariable(Prefix + "rollbackNetworkRequest", rollbackNetworkRequest) - execution.setVariable(Prefix + "rollbackSDNCRequest", rollbackSDNCRequest) - execution.setVariable(Prefix + "rollbackActivateSDNCRequest", rollbackActivateSDNCRequest) - logger.debug("'rollbackData': " + '\n' + execution.getVariable("rollbackData")) - - String sdncVersion = execution.getVariable("sdncVersion") - logger.debug("sdncVersion? : " + sdncVersion) - - // PO Authorization Info / headers Authorization= - String basicAuthValuePO = UrnPropertiesReader.getVariable("mso.adapters.po.auth",execution) - try { - def encodedString = utils.getBasicAuth(basicAuthValuePO, UrnPropertiesReader.getVariable("mso.msoKey", execution)) - execution.setVariable("BasicAuthHeaderValuePO",encodedString) - execution.setVariable("BasicAuthHeaderValueSDNC", encodedString) - - } catch (IOException ex) { - String exceptionMessage = "Exception Encountered in DoCreateNetworkInstance, PreProcessRequest() - " - String dataErrorMessage = exceptionMessage + " Unable to encode PO/SDNC user/password string - " + ex.getMessage() - logger.debug(dataErrorMessage ) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - - if (execution.getVariable("SavedWorkflowException1") != null) { - execution.setVariable(Prefix + "WorkflowException", execution.getVariable("SavedWorkflowException1")) - } else { - execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException")) - } - logger.debug("*** WorkflowException : " + execution.getVariable(Prefix + "WorkflowException")) - if(execution.getVariable(Prefix + "WorkflowException") != null) { - // called by: DoCreateNetworkInstance, partial rollback - execution.setVariable(Prefix + "fullRollback", false) - - } else { - // called by: Macro - Full Rollback, WorkflowException = null - execution.setVariable(Prefix + "fullRollback", true) - - } - logger.debug("*** fullRollback? : " + execution.getVariable(Prefix + "fullRollback")) - - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - // caught exception - String exceptionMessage = "Exception Encountered in PreProcessRequest() of " + className + ".groovy ***** : " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void callPONetworkAdapter (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - logger.trace("Inside callPONetworkAdapter() of " + className + "") - - try { - String poUrl = UrnPropertiesReader.getVariable("mso.adapters.network.rest.endpoint",execution) - String rollbackSDNCRequest = execution.getVariable(Prefix + "rollbackSDNCRequest") - String networkId = utils.getNodeText(rollbackSDNCRequest, "network-id") - - String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest") - - String urlRollbackPoNetwork = poUrl+ "/" + networkId + "/rollback" - logger.debug("'urlRollbackPoNetwork': " + urlRollbackPoNetwork) - execution.setVariable(Prefix + "urlRollbackPoNetwork", urlRollbackPoNetwork) - - URL url = new URL(urlRollbackPoNetwork) - HttpClient httpClient = new HttpClientFactory().newXmlClient(url, ONAPComponents.OPENSTACK_ADAPTER) - httpClient.addAdditionalHeader("Authorization", execution.getVariable("BasicAuthHeaderValuePO")) - Response response = httpClient.delete(rollbackNetworkRequest) - - execution.setVariable(Prefix + "rollbackNetworkReturnCode", response.getStatus()) - - logger.debug(" Network Adapter rollback responseCode: " + response.getStatus()) - - - } catch (Exception ex) { - String exceptionMessage = "Exception Encountered in callPONetworkAdapter() of DoCreateNetworkInstanceRollback flow - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - - } - - - public void validateRollbackResponses (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - logger.trace("Inside validateRollbackResponses() of DoCreateNetworkInstanceRollback") - - try { - // validate PO network rollback response - String rollbackNetworkErrorMessages = "" - String rollbackNetworkReturnCode = "200" - if (execution.getVariable(Prefix + "rollbackNetworkRequest") != null) { - rollbackNetworkReturnCode = execution.getVariable(Prefix + "rollbackNetworkReturnCode") - logger.debug(" NetworkRollback Code - " + rollbackNetworkReturnCode) - if (rollbackNetworkReturnCode != "200") { - rollbackNetworkErrorMessages = " + PO Network rollback failed. " - } else { - rollbackNetworkErrorMessages = " + PO Network rollback completed." - } - } - - // validate SDNC rollback response - String rollbackSdncErrorMessages = "" - String rollbackSDNCReturnCode = "200" - if (execution.getVariable(Prefix + "rollbackSDNCRequest") != null) { - rollbackSDNCReturnCode = execution.getVariable(Prefix + "rollbackSDNCReturnCode") - String rollbackSDNCResponse = execution.getVariable(Prefix + "rollbackSDNCResponse") - String rollbackSDNCReturnInnerCode = "" - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - rollbackSDNCResponse = rollbackSDNCResponse - rollbackSDNCResponse = rollbackSDNCResponse.replace('$', '').replace('<?xml version="1.0" encoding="UTF-8"?>', "") - if (rollbackSDNCReturnCode == "200") { - if (utils.nodeExists(rollbackSDNCResponse, "response-code")) { - rollbackSDNCReturnInnerCode = utils.getNodeText(rollbackSDNCResponse, "response-code") - if (rollbackSDNCReturnInnerCode == "200" || rollbackSDNCReturnInnerCode == "" || rollbackSDNCReturnInnerCode == "0") { - rollbackSdncErrorMessages = " + SNDC assign rollback completed." - } else { - rollbackSdncErrorMessages = " + SDNC assign rollback failed. " - } - } else { - rollbackSdncErrorMessages = " + SNDC assign rollback completed." - } - } else { - rollbackSdncErrorMessages = " + SDNC assign rollback failed. " - } - logger.debug(" SDNC assign rollback Code - " + rollbackSDNCReturnCode) - logger.debug(" SDNC assign rollback Response - " + rollbackSDNCResponse) - } - - // validate SDNC activate rollback response - String rollbackActivateSdncErrorMessages = "" - String rollbackActivateSDNCReturnCode = "200" - if (execution.getVariable(Prefix + "rollbackActivateSDNCRequest") != null) { - rollbackActivateSDNCReturnCode = execution.getVariable(Prefix + "rollbackActivateSDNCReturnCode") - String rollbackActivateSDNCResponse = execution.getVariable(Prefix + "rollbackActivateSDNCResponse") - String rollbackActivateSDNCReturnInnerCode = "" - rollbackActivateSDNCResponse = rollbackActivateSDNCResponse - rollbackActivateSDNCResponse = rollbackActivateSDNCResponse.replace('$', '').replace('<?xml version="1.0" encoding="UTF-8"?>', "") - if (rollbackActivateSDNCReturnCode == "200") { - if (utils.nodeExists(rollbackActivateSDNCResponse, "response-code")) { - rollbackActivateSDNCReturnInnerCode = utils.getNodeText(rollbackActivateSDNCResponse, "response-code") - if (rollbackActivateSDNCReturnInnerCode == "200" || rollbackActivateSDNCReturnInnerCode == "" || rollbackActivateSDNCReturnInnerCode == "0") { - rollbackActivateSdncErrorMessages = " + SNDC activate rollback completed." - } else { - rollbackActivateSdncErrorMessages = " + SDNC activate rollback failed. " - } - } else { - rollbackActivateSdncErrorMessages = " + SNDC activate rollback completed." - } - } else { - rollbackActivateSdncErrorMessages = " + SDNC activate rollback failed. " - } - logger.debug(" SDNC activate rollback Code - " + rollbackActivateSDNCReturnCode) - logger.debug(" SDNC activate rollback Response - " + rollbackActivateSDNCResponse) - } - - - String statusMessage = "" - int errorCode = 7000 - logger.debug("*** fullRollback? : " + execution.getVariable(Prefix + "fullRollback")) - if (execution.getVariable(Prefix + "fullRollback") == false) { - // original WorkflowException, - WorkflowException wfe = execution.getVariable(Prefix + "WorkflowException") - if (wfe != null) { - // rollback due to failure in DoCreate - Partial rollback - statusMessage = wfe.getErrorMessage() - errorCode = wfe.getErrorCode() - } else { - statusMessage = "See Previous Camunda flows for cause of Error: Undetermined Exception." - errorCode = '7000' - } - - // set if all rolledbacks are successful - if (rollbackNetworkReturnCode == "200" && rollbackSDNCReturnCode == "200" && rollbackActivateSDNCReturnCode == "200") { - execution.setVariable("rolledBack", true) - execution.setVariable("wasDeleted", true) - - } else { - execution.setVariable("rolledBack", false) - execution.setVariable("wasDeleted", true) - } - - statusMessage = statusMessage + rollbackActivateSdncErrorMessages + rollbackNetworkErrorMessages + rollbackSdncErrorMessages - logger.debug("Final DoCreateNetworkInstanceRollback status message: " + statusMessage) - String processKey = getProcessKey(execution); - WorkflowException exception = new WorkflowException(processKey, errorCode, statusMessage); - execution.setVariable("workflowException", exception); - - } else { - // rollback due to failures in Main flow (Macro) - Full rollback - // WorkflowException = null - if (rollbackNetworkReturnCode == "200" && rollbackSDNCReturnCode == "200" && rollbackActivateSDNCReturnCode == "200") { - execution.setVariable("rollbackSuccessful", true) - execution.setVariable("rollbackError", false) - } else { - String exceptionMessage = "Network Create Rollback was not Successful. " + String Prefix="CRENWKIR_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + VidUtils vidUtils = new VidUtils(this) + NetworkUtils networkUtils = new NetworkUtils() + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() + + def className = getClass().getSimpleName() + + /** + * This method is executed during the preProcessRequest task of the <class>DoCreateNetworkInstanceRollback.bpmn</class> process. + * @param execution + */ + public InitializeProcessVariables(DelegateExecution execution){ + /* Initialize all the process variables in this block */ + + execution.setVariable(Prefix + "rollbackNetworkRequest", null) + execution.setVariable(Prefix + "rollbackSDNCRequest", null) + execution.setVariable(Prefix + "rollbackActivateSDNCRequest", null) + execution.setVariable(Prefix + "WorkflowException", null) + + execution.setVariable(Prefix + "rollbackNetworkRequest", "") + execution.setVariable(Prefix + "rollbackNetworkResponse", "") + execution.setVariable(Prefix + "rollbackNetworkReturnCode", "") + + execution.setVariable(Prefix + "rollbackSDNCRequest", "") + execution.setVariable(Prefix + "rollbackSDNCResponse", "") + execution.setVariable(Prefix + "rollbackSDNCReturnCode", "") + + execution.setVariable(Prefix + "rollbackActivateSDNCRequest", "") + execution.setVariable(Prefix + "rollbackActivateSDNCResponse", "") + execution.setVariable(Prefix + "rollbackActivateSDNCReturnCode", "") + + execution.setVariable(Prefix + "Success", false) + execution.setVariable(Prefix + "fullRollback", false) + execution.setVariable(Prefix + "networkId", "") + execution.setVariable(Prefix + "urlRollbackPoNetwork", "") + } + + // ************************************************** + // Pre or Prepare Request Section + // ************************************************** + /** + * This method is executed during the preProcessRequest task of the <class>DoCreateNetworkInstanceRollback.bpmn</class> process. + * @param execution + */ + public void preProcessRequest (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + + logger.trace("Inside preProcessRequest() of " + className + ".groovy") + + try { + // initialize flow variables + InitializeProcessVariables(execution) + + // GET Incoming request/variables + String rollbackNetworkRequest = null + String rollbackSDNCRequest = null + String rollbackActivateSDNCRequest = null + + // Partial Rollback + Map<String, String> rollbackData = execution.getVariable("rollbackData") + if (rollbackData != null && rollbackData instanceof Map) { + + if(rollbackData.containsKey("rollbackSDNCRequest")) { + rollbackSDNCRequest = rollbackData["rollbackSDNCRequest"] + } + + if(rollbackData.containsKey("rollbackNetworkRequest")) { + rollbackNetworkRequest = rollbackData["rollbackNetworkRequest"] + } + + if(rollbackData.containsKey("rollbackActivateSDNCRequest")) { + rollbackActivateSDNCRequest = rollbackData["rollbackActivateSDNCRequest"] + } + + } + + execution.setVariable(Prefix + "rollbackNetworkRequest", rollbackNetworkRequest) + execution.setVariable(Prefix + "rollbackSDNCRequest", rollbackSDNCRequest) + execution.setVariable(Prefix + "rollbackActivateSDNCRequest", rollbackActivateSDNCRequest) + logger.debug("'rollbackData': " + '\n' + execution.getVariable("rollbackData")) + + String sdncVersion = execution.getVariable("sdncVersion") + logger.debug("sdncVersion? : " + sdncVersion) + + // PO Authorization Info / headers Authorization= + String basicAuthValuePO = UrnPropertiesReader.getVariable("mso.adapters.po.auth",execution) + try { + def encodedString = utils.getBasicAuth(basicAuthValuePO, UrnPropertiesReader.getVariable("mso.msoKey", execution)) + execution.setVariable("BasicAuthHeaderValuePO",encodedString) + execution.setVariable("BasicAuthHeaderValueSDNC", encodedString) + + } catch (IOException ex) { + String exceptionMessage = "Exception Encountered in DoCreateNetworkInstance, PreProcessRequest() - " + String dataErrorMessage = exceptionMessage + " Unable to encode PO/SDNC user/password string - " + ex.getMessage() + logger.debug(dataErrorMessage ) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + + if (execution.getVariable("SavedWorkflowException1") != null) { + execution.setVariable(Prefix + "WorkflowException", execution.getVariable("SavedWorkflowException1")) + } else { + execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException")) + } + logger.debug("*** WorkflowException : " + execution.getVariable(Prefix + "WorkflowException")) + if(execution.getVariable(Prefix + "WorkflowException") != null) { + // called by: DoCreateNetworkInstance, partial rollback + execution.setVariable(Prefix + "fullRollback", false) + + } else { + // called by: Macro - Full Rollback, WorkflowException = null + execution.setVariable(Prefix + "fullRollback", true) + + } + logger.debug("*** fullRollback? : " + execution.getVariable(Prefix + "fullRollback")) + + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex) { + // caught exception + String exceptionMessage = "Exception Encountered in PreProcessRequest() of " + className + ".groovy ***** : " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void setNetworkAdapterResponseCode (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + try { + + execution.setVariable(Prefix + "rollbackNetworkReturnCode", "200") + + } catch (Exception ex) { + String exceptionMessage = "Exception Encountered in callPONetworkAdapter() of DoCreateNetworkInstanceRollback flow - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + + } + + + public void validateRollbackResponses (DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + + logger.trace("Inside validateRollbackResponses() of DoCreateNetworkInstanceRollback") + + try { + // validate PO network rollback response + String rollbackNetworkErrorMessages = "" + String rollbackNetworkReturnCode = "200" + if (execution.getVariable(Prefix + "rollbackNetworkRequest") != null) { + rollbackNetworkReturnCode = execution.getVariable(Prefix + "rollbackNetworkReturnCode") + logger.debug(" NetworkRollback Code - " + rollbackNetworkReturnCode) + if (rollbackNetworkReturnCode != "200") { + rollbackNetworkErrorMessages = " + PO Network rollback failed. " + } else { + rollbackNetworkErrorMessages = " + PO Network rollback completed." + } + } + + // validate SDNC rollback response + String rollbackSdncErrorMessages = "" + String rollbackSDNCReturnCode = "200" + if (execution.getVariable(Prefix + "rollbackSDNCRequest") != null) { + rollbackSDNCReturnCode = execution.getVariable(Prefix + "rollbackSDNCReturnCode") + String rollbackSDNCResponse = execution.getVariable(Prefix + "rollbackSDNCResponse") + String rollbackSDNCReturnInnerCode = "" + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() + rollbackSDNCResponse = rollbackSDNCResponse + rollbackSDNCResponse = rollbackSDNCResponse.replace('$', '').replace('<?xml version="1.0" encoding="UTF-8"?>', "") + if (rollbackSDNCReturnCode == "200") { + if (utils.nodeExists(rollbackSDNCResponse, "response-code")) { + rollbackSDNCReturnInnerCode = utils.getNodeText(rollbackSDNCResponse, "response-code") + if (rollbackSDNCReturnInnerCode == "200" || rollbackSDNCReturnInnerCode == "" || rollbackSDNCReturnInnerCode == "0") { + rollbackSdncErrorMessages = " + SNDC assign rollback completed." + } else { + rollbackSdncErrorMessages = " + SDNC assign rollback failed. " + } + } else { + rollbackSdncErrorMessages = " + SNDC assign rollback completed." + } + } else { + rollbackSdncErrorMessages = " + SDNC assign rollback failed. " + } + logger.debug(" SDNC assign rollback Code - " + rollbackSDNCReturnCode) + logger.debug(" SDNC assign rollback Response - " + rollbackSDNCResponse) + } + + // validate SDNC activate rollback response + String rollbackActivateSdncErrorMessages = "" + String rollbackActivateSDNCReturnCode = "200" + if (execution.getVariable(Prefix + "rollbackActivateSDNCRequest") != null) { + rollbackActivateSDNCReturnCode = execution.getVariable(Prefix + "rollbackActivateSDNCReturnCode") + String rollbackActivateSDNCResponse = execution.getVariable(Prefix + "rollbackActivateSDNCResponse") + String rollbackActivateSDNCReturnInnerCode = "" + rollbackActivateSDNCResponse = rollbackActivateSDNCResponse + rollbackActivateSDNCResponse = rollbackActivateSDNCResponse.replace('$', '').replace('<?xml version="1.0" encoding="UTF-8"?>', "") + if (rollbackActivateSDNCReturnCode == "200") { + if (utils.nodeExists(rollbackActivateSDNCResponse, "response-code")) { + rollbackActivateSDNCReturnInnerCode = utils.getNodeText(rollbackActivateSDNCResponse, "response-code") + if (rollbackActivateSDNCReturnInnerCode == "200" || rollbackActivateSDNCReturnInnerCode == "" || rollbackActivateSDNCReturnInnerCode == "0") { + rollbackActivateSdncErrorMessages = " + SNDC activate rollback completed." + } else { + rollbackActivateSdncErrorMessages = " + SDNC activate rollback failed. " + } + } else { + rollbackActivateSdncErrorMessages = " + SNDC activate rollback completed." + } + } else { + rollbackActivateSdncErrorMessages = " + SDNC activate rollback failed. " + } + logger.debug(" SDNC activate rollback Code - " + rollbackActivateSDNCReturnCode) + logger.debug(" SDNC activate rollback Response - " + rollbackActivateSDNCResponse) + } + + + String statusMessage = "" + int errorCode = 7000 + logger.debug("*** fullRollback? : " + execution.getVariable(Prefix + "fullRollback")) + if (execution.getVariable(Prefix + "fullRollback") == false) { + // original WorkflowException, + WorkflowException wfe = execution.getVariable(Prefix + "WorkflowException") + if (wfe != null) { + // rollback due to failure in DoCreate - Partial rollback + statusMessage = wfe.getErrorMessage() + errorCode = wfe.getErrorCode() + } else { + statusMessage = "See Previous Camunda flows for cause of Error: Undetermined Exception." + errorCode = '7000' + } + + // set if all rolledbacks are successful + if (rollbackNetworkReturnCode == "200" && rollbackSDNCReturnCode == "200" && rollbackActivateSDNCReturnCode == "200") { + execution.setVariable("rolledBack", true) + execution.setVariable("wasDeleted", true) + + } else { + execution.setVariable("rolledBack", false) + execution.setVariable("wasDeleted", true) + } + + statusMessage = statusMessage + rollbackActivateSdncErrorMessages + rollbackNetworkErrorMessages + rollbackSdncErrorMessages + logger.debug("Final DoCreateNetworkInstanceRollback status message: " + statusMessage) + String processKey = getProcessKey(execution); + WorkflowException exception = new WorkflowException(processKey, errorCode, statusMessage); + execution.setVariable("workflowException", exception); + + } else { + // rollback due to failures in Main flow (Macro) - Full rollback + // WorkflowException = null + if (rollbackNetworkReturnCode == "200" && rollbackSDNCReturnCode == "200" && rollbackActivateSDNCReturnCode == "200") { + execution.setVariable("rollbackSuccessful", true) + execution.setVariable("rollbackError", false) + } else { + String exceptionMessage = "Network Create Rollback was not Successful. " logger.debug(exceptionMessage) - execution.setVariable("rollbackSuccessful", false) - execution.setVariable("rollbackError", true) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - throw new BpmnError("MSOWorkflowException") - } + execution.setVariable("rollbackSuccessful", false) + execution.setVariable("rollbackError", true) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + throw new BpmnError("MSOWorkflowException") + } - } + } - } catch (Exception ex) { - String errorMessage = "See Previous Camunda flows for cause of Error: Undetermined Exception." - String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstanceRollback flow. validateRollbackResponses() - " + errorMessage + ": " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + } catch (Exception ex) { + String errorMessage = "See Previous Camunda flows for cause of Error: Undetermined Exception." + String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstanceRollback flow. validateRollbackResponses() - " + errorMessage + ": " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - } + } - } + } - // ******************************* - // Build Error Section - // ******************************* + // ******************************* + // Build Error Section + // ******************************* - public void processJavaException(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) + public void processJavaException(DelegateExecution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) - try{ - logger.debug("Caught a Java Exception in " + Prefix) - logger.debug("Started processJavaException Method") - logger.debug("Variables List: " + execution.getVariables()) - execution.setVariable("UnexpectedError", "Caught a Java Lang Exception - " + Prefix) // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception") + try{ + logger.debug("Caught a Java Exception in " + Prefix) + logger.debug("Started processJavaException Method") + logger.debug("Variables List: " + execution.getVariables()) + execution.setVariable("UnexpectedError", "Caught a Java Lang Exception - " + Prefix) // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception") - }catch(Exception e){ - logger.debug("Caught Exception during processJavaException Method: " + e) - execution.setVariable("UnexpectedError", "Exception in processJavaException method - " + Prefix) // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method" + Prefix) - } - logger.debug("Completed processJavaException Method in " + Prefix) - } + }catch(Exception e){ + logger.debug("Caught Exception during processJavaException Method: " + e) + execution.setVariable("UnexpectedError", "Exception in processJavaException method - " + Prefix) // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method" + Prefix) + } + logger.debug("Completed processJavaException Method in " + Prefix) + } } 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 78b8e2d8a7..fce12e56b0 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 @@ -40,10 +40,10 @@ 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.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory 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/DoCreateSliceServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy index 5a955e65f5..b71379449e 100644 --- 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 @@ -23,10 +23,10 @@ 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.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory 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/DoCreateSliceServiceOption.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy index c66a89b9c6..ec9596e7f3 100644 --- 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 @@ -1,13 +1,29 @@ +/*- + * ============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.core.type.TypeReference -import groovy.json.JsonBuilder +import com.fasterxml.jackson.databind.ObjectMapper 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 @@ -19,50 +35,32 @@ 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.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory 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{ +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") + ObjectMapper objectMapper = new ObjectMapper() + void preProcessRequest (DelegateExecution execution) { } @@ -70,11 +68,10 @@ public class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ 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) @@ -100,235 +97,256 @@ public class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ 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}" + Map<String, Object> nstSolution = execution.getVariable("nstSolution") + logger.debug("Get NST selection from OOF: " + nstSolution.toString()) + String nstInfo = """{ + "modelInvariantId":"${nstSolution.invariantUUID}", + "modelVersionId":"${nstSolution.UUID}", + "modelName":"${nstSolution.NSTName}" }""" - String oofRequest = oofUtils.buildSelectNSIRequest(execution, requestId, nstInfo, profileInfo) + String oofRequest = oofUtils.buildSelectNSIRequest(requestId, nstInfo, profileInfo) + logger.debug("Sending request to OOF: " + oofRequest) //send request to get NSI option - Begin - URL url = new URL(urlString+"/api/oof/v1/selectnsi") + URL url = new URL(urlString+"/api/oof/selection/nsi/v1") HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.OOF) httpClient.addAdditionalHeader("Authorization", authHeader) Response httpResponse = httpClient.post(oofRequest) + processOOFResponse(httpResponse, execution) + + //解析sliceProfile + logger.debug("start parseServiceProfile") + parseServiceProfile(execution) + logger.debug("end parseServiceProfile") + } + + private void processOOFResponse(Response httpResponse, DelegateExecution execution) { int responseCode = httpResponse.getStatus() logger.debug("OOF sync response code is: " + responseCode) - if(responseCode != 200){ + if (responseCode != 200) { exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.") - logger.debug("Info: No NSI suggested by OOF" ) + logger.debug("Info: No NSI suggested by OOF") } - if(httpResponse.hasEntity()){ + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") + if (httpResponse.hasEntity()) { String OOFResponse = httpResponse.readEntity(String.class) + logger.debug("NSI OOFResponse is: " + OOFResponse) 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. + //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; - } - } - } + Map solutions = OOFResponseObject.get("solutions") + + String resourceSharingLevel = execution.getVariable("resourceSharingLevel") + Boolean isSharable = resourceSharingLevel.equals("shared") + if (solutions != null) { + if (isSharable && hasSharedNSIsolutions(solutions)) { + //sharedNSISolution + processSharedNSISolutions(solutions, execution) + } + else if(solutions.containsKey("newNSISolutions")) { + processNewNSISolutions(solutions, execution) + } } execution.setVariable("sliceTaskParams", sliceTaskParams) - logger.debug("Info: No NSI suggested by OOF" ) + logger.debug("sliceTaskParams: "+sliceTaskParams.convertToJson()) } - //send request to get NSI option - Begin + logger.debug("*** Completed options Call to OOF ***") + } + private boolean hasSharedNSIsolutions( Map solutions){ + if(solutions.containsKey("sharedNSISolutions")){ + List sharedNSIsolutions = solutions.get("sharedNSISolutions") + if (sharedNSIsolutions != null && !sharedNSIsolutions.isEmpty()) { + return true + } + } + return false + } - //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 ***") + private void processNewNSISolutions(Map solutions, DelegateExecution execution) { + int index = 0 + List<Map> newNSISolutions = solutions.get("newNSISolutions") + List<Map> NSSImap = new ArrayList<>() + if (newNSISolutions != null && newNSISolutions.size() > 0) { + NSSImap = newNSISolutions.get(index).get("NSSISolutions") as List<Map> + for (Map nssi : NSSImap) { + Map oofSliceProfile = nssi.get("sliceProfile") + String domain = oofSliceProfile.getOrDefault("domainType","") + logger.debug("OOF newNSISolutions SliceProfile: " +oofSliceProfile.toString()+",domain:${domain}") + if(null != domain){ + //TODO +// def nssiSolution = nssi.get("NSSISolution") as Map<String, ?> +// String nssiName = nssiSolution.getOrDefault("NSSIName", "") +// String nssiId = nssiSolution.getOrDefault("NSSIId", "") +// saveNSSIId(nssi, sliceTaskParams) + Map<String, Object> sliceProfile = getSliceProfile(domain, execution, oofSliceProfile) + saveSliceProfile(execution, domain, sliceProfile) + } + } + } } + private void processSharedNSISolutions(Map solutions, DelegateExecution execution) { + String nsiName, nsiInstanceId, nssiId, nssiName + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") - public void parseServiceProfile(DelegateExecution execution) { + Map sharedNSIsolution = ((List) solutions.get("sharedNSISolutions"))?.get(0) + nsiInstanceId = sharedNSIsolution.getOrDefault("NSIId", "") + nsiName = sharedNSIsolution.getOrDefault("NSIName", "") + sliceTaskParams.setSuggestNsiId(nsiInstanceId) + sliceTaskParams.setSuggestNsiName(nsiName) + + //Temporary modification + List NSSIs = sharedNSIsolution.get("NSSIs") + for(Map nssi : NSSIs){ + Map oofSliceProfile = ((List)nssi.get("sliceProfile"))?.get(0) + String domain = oofSliceProfile.getOrDefault("domainType","") + nssiId = nssi.getOrDefault("NSSIId","") + nssiName = nssi.getOrDefault("NSSIName","") + saveNSSIId(domain, nssiId, nssiName,execution) + Map<String, Object> sliceProfile = getSliceProfile(domain, execution, oofSliceProfile) + saveSliceProfile(execution, domain, sliceProfile) + logger.debug("OOF sharedNSISolution SliceProfile:"+oofSliceProfile.toString()+",domain:${domain}") + logger.debug("OOF sharedNSISolution nsiInstanceId:${nsiInstanceId}, nsiName:${nsiName}, nssiId:${nssiId}, nssiName:${nssiName}") + } + } + + private void parseServiceProfile(DelegateExecution execution) { logger.debug("Start parseServiceProfile") String serviceType = execution.getVariable("serviceType") Map<String, Object> serviceProfile = execution.getVariable("serviceProfile") - + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") // 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) + if(!sliceTaskParams.getSliceProfileAn()){ + Map<String, Object> sliceProfileAn = getSliceProfile( "AN", execution,null) + saveSliceProfile(execution,"AN",sliceProfileAn) + } + + if(!sliceTaskParams.getSliceProfileTn()){ + Map<String, Object> sliceProfileTn = getSliceProfile( "TN", execution,null) + saveSliceProfile(execution,"TN",sliceProfileTn) + } - execution.setVariable("sliceProfileTn", sliceProfileTn) - execution.setVariable("sliceProfileCn", sliceProfileCn) - execution.setVariable("sliceProfileAn", sliceProfileAn) - logger.debug("sliceProfileTn: " + sliceProfileTn) - logger.debug("sliceProfileCn: " + sliceProfileCn) - logger.debug("sliceProfileAn: " + sliceProfileAn) + if(!sliceTaskParams.getSliceProfileCn()){ + Map<String, Object> sliceProfileCn = getSliceProfile( "CN", execution,null, ) + saveSliceProfile(execution,"CN",sliceProfileCn) + } 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)) + private void saveSliceProfile(DelegateExecution execution, String domain, Map<String, Object> sliceProfile){ + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") + if(domain.equalsIgnoreCase("AN")){ + execution.setVariable("sliceProfileAn", sliceProfile) + sliceTaskParams.setSliceProfileAn(sliceProfile) + logger.debug("sliceProfileAn: " + sliceProfile) + } + else if(domain.equalsIgnoreCase("TN")){ + execution.setVariable("sliceProfileTn", sliceProfile) + sliceTaskParams.setSliceProfileTn(sliceProfile) + logger.debug("sliceProfileTn: " + sliceProfile) + } + else if(domain.equalsIgnoreCase("CN")){ + execution.setVariable("sliceProfileCn", sliceProfile) + sliceTaskParams.setSliceProfileCn(sliceProfile) + logger.debug("sliceProfileCn: " + sliceProfile) } - - return sliceProfileTn } + private void saveNSSIId(String domain, String nssiId, String nssiName, DelegateExecution execution) { + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") + if(domain.equalsIgnoreCase("AN")){ + sliceTaskParams.setAnSuggestNssiId(nssiId) + sliceTaskParams.setAnSuggestNssiName(nssiName) + } + else if(domain.equalsIgnoreCase("CN")){ + sliceTaskParams.setCnSuggestNssiId(nssiId) + sliceTaskParams.setCnSuggestNssiName(nssiName) + } + else if(domain.equalsIgnoreCase("TN")){ + sliceTaskParams.setTnSuggestNssiId(nssiId) + sliceTaskParams.setTnSuggestNssiName(nssiName) + } + } - 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 { + private Map getSliceProfile(String domain, DelegateExecution execution, Map<String, Object> oofSliceProfile) { + String profileMapStr + Map<String, Object> serviceProfile = execution.getVariable("serviceProfile") + Integer domainLatency = (Integer) serviceProfile.get("latency")/3 + + if(domain.equalsIgnoreCase("AN")){ + profileMapStr = """ { + "latency": ${domainLatency}, + "sNSSAI": "sNSSAI", + "uEMobilityLevel": "uEMobilityLevel", + "coverageAreaTAList": "coverageAreaTAList", + "5QI": 100 + }""" + } + else if(domain.equalsIgnoreCase("TN")){ + profileMapStr =""" { + "latency":${domainLatency}, + "sNSSAI":"sNSSAI", + "e2eLatency":"latency", + "bandwidth": 100 + }""" + } + else if(domain.equalsIgnoreCase("CN")){ + profileMapStr = """ { + "areaTrafficCapDL":"areaTrafficCapDL", + "maxNumberofUEs":"maxNumberofUEs", + "latency":${domainLatency}, + "expDataRateUL":"expDataRateUL", + "sNSSAI":"sNSSAI", + "areaTrafficCapUL":"areaTrafficCapUL", + "uEMobilityLevel":"uEMobilityLevel", + "expDataRateDL":"expDataRateDL", + "activityFactor":"activityFactor", + "resourceSharingLevel":"resourceSharingLevel" + }""" + } - 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) - } + logger.debug("Profile map for " + domain + " : " + profileMapStr) + Map<String, Object> profileMaps = objectMapper.readValue(profileMapStr.trim().replaceAll(" ", ""), new TypeReference<Map<String, String>>(){}) + Map<String, Object> sliceProfile = [:] + for (Map.Entry<String, String> profileMap : profileMaps) { + String key = profileMap.key + String value = profileMaps.get(key) + if(null != oofSliceProfile && oofSliceProfile.keySet().contains(key)){ + sliceProfile.put(key, oofSliceProfile.get(key)) + logger.debug("Get from oof, key:${key}, value: ${oofSliceProfile.get(key)}") + } + else if(serviceProfile.keySet().contains(value)){ + sliceProfile.put(key, serviceProfile.get(value)) + } + else{ + sliceProfile.put(key, profileMaps.get(key)) } - }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() + return sliceProfile + } - 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) - } + void processDecomposition(DelegateExecution execution){ + logger.debug("Start processDecomposition") - } + ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition") + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") String nstName = serviceDecomposition.getModelInfo().getModelName() - sliceTaskParams.setNstName(nstName) String nstId = serviceDecomposition.getModelInfo().getModelUuid() + sliceTaskParams.setNstName(nstName) sliceTaskParams.setNstId(nstId) - execution.setVariable("sliceTaskParams",sliceTaskParams) + logger.debug("End processDecomposition") } - 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") @@ -364,14 +382,6 @@ public class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ } - 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()") @@ -400,7 +410,6 @@ public class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ } - void getNSSTOption(DelegateExecution execution) { ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition") String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) @@ -483,17 +492,17 @@ public class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ case "AN": sliceTaskParams.setAnSuggestNssiId(nssi.getServiceInstanceId()) sliceTaskParams.setAnSuggestNssiName(nssi.getServiceInstanceName()) - break; + break case "CN": sliceTaskParams.setCnSuggestNssiId(nssi.getServiceInstanceId()) sliceTaskParams.setCnSuggestNssiName(nssi.getServiceInstanceName()) - break; + break case "TN": sliceTaskParams.setTnSuggestNssiId(nssi.getServiceInstanceId()) sliceTaskParams.setTnSuggestNssiName(nssi.getServiceInstanceName()) - break; + break default: - break; + break } }catch(NotFoundException e) { @@ -503,22 +512,6 @@ public class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ 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 4835c9b84b..d5469c81a2 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 @@ -24,9 +24,9 @@ package org.onap.so.bpmn.infrastructure.scripts import org.onap.so.logger.LoggingAnchor 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 org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; 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/DoCreateVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy index 1a3df6ff4e..366cdfdb09 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 @@ -51,14 +51,14 @@ 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.AAIUriFactory; -import org.onap.so.client.graphinventory.entities.uri.Depth +import org.onap.aaiclient.client.aai.AAIObjectPlurals +import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +import org.onap.aaiclient.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 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 a505aa1a34..b3c4698ab8 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 @@ -34,11 +34,11 @@ import org.onap.so.bpmn.common.scripts.MsoUtils 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.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.aaiclient.client.aai.AAIObjectPlurals +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.logging.filter.base.ErrorCode 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/DoCreateVfModuleVolumeRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy index 7f2a3e4245..80f6e0edb2 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 @@ -30,11 +30,11 @@ import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.VidUtils 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.aaiclient.client.aai.AAIObjectPlurals +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.so.constants.Defaults 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/DoCreateVfModuleVolumeV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy index fafe97b0eb..b1d909b6b4 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 @@ -36,11 +36,11 @@ 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.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.AAIResourceUri -import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.aai.AAIObjectPlurals +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.so.constants.Defaults import org.onap.so.db.catalog.beans.OrchestrationStatus import org.slf4j.Logger 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 823217c4f7..488f2d85ac 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 @@ -22,14 +22,15 @@ package org.onap.so.bpmn.infrastructure.scripts -import org.onap.so.logger.LoggingAnchor -import org.onap.so.db.catalog.beans.HomingInstance -import org.onap.logging.filter.base.ErrorCode - import static org.apache.commons.lang3.StringUtils.* - import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +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 @@ -41,13 +42,11 @@ import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.domain.VnfResource import org.onap.so.bpmn.core.json.JsonUtils +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.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 /** * This class supports the DoCreateVnf building block subflow @@ -286,8 +285,8 @@ class DoCreateVnf extends AbstractServiceTaskProcessor { if(resourceClient.exists(uri)){ Map<String, String> keys = uri.getURIKeys() - execution.setVariable("globalCustomerId", keys.get("global-customer-id")) - execution.setVariable("serviceType", keys.get("service-type")) + execution.setVariable("globalCustomerId", keys.get(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId)) + execution.setVariable("serviceType", keys.get(AAIFluentTypeBuilder.Types.SERVICE_SUBSCRIPTION.getUriParams().serviceType)) execution.setVariable("GENGS_siResourceLink", uri.build().toString()) }else{ 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 72f71686d9..76629dd1ba 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 @@ -50,10 +50,10 @@ import org.w3c.dom.Element import org.w3c.dom.Node import org.w3c.dom.NodeList import org.xml.sax.InputSource -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.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient import groovy.json.* 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 bc535a348f..53a98c2ec6 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 @@ -44,11 +44,11 @@ import org.slf4j.Logger import org.slf4j.LoggerFactory import org.springframework.web.util.UriUtils; -import org.onap.so.client.aai.AAIResourcesClient -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.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.json.JSONObject import javax.ws.rs.NotFoundException import groovy.json.* 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 index 662baf3e51..547cb6cad7 100644 --- 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 @@ -31,17 +31,16 @@ 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.NssmfAdapterUtils 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.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.so.db.request.beans.OperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -56,6 +55,8 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor private ExceptionUtil exceptionUtil = new ExceptionUtil() private JsonUtils jsonUtil = new JsonUtils() private RequestDBUtil requestDBUtil = new RequestDBUtil() + private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil) + private static final Logger LOGGER = LoggerFactory.getLogger( DoDeallocateNSSI.class) @Override @@ -103,7 +104,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor * get vendor Info * @param execution */ - void processDecomposition(DelegateExecution execution) { + void processDecomposition(DelegateExecution execution) { LOGGER.debug("*****${PREFIX} start processDecomposition *****") try { @@ -152,26 +153,21 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor 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 *****") + String nssmfRequest = mapper.writeValueAsString(deAllocateRequest) + + String urlStr = String.format("/api/rest/provMns/v1/NSS/SliceProfiles/%s",profileId) + + NssiResponse nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlStr, nssmfRequest, NssiResponse.class) + if (nssmfResponse != null) { + currentNSSI['jobId']= nssmfResponse.getJobId() ?: "" + currentNSSI['jobProgress'] = 0 + execution.setVariable("currentNSSI", currentNSSI) + + LOGGER.debug("*****${PREFIX} Exit sendRequestToNSSMF *****") + } else { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a Bad Response from NSSMF.") + } + } /** @@ -191,48 +187,36 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor 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 + String nssmfRequest = mapper.writeValueAsString(jobStatusRequest) - execution.setVariable("isNSSIDeAllocated", (currentProgress == 100)) - execution.setVariable("isNeedUpdateDB", (oldProgress != currentProgress)) - currentNSSI['jobProgress'] = currentProgress + String urlStr = String.format("/api/rest/provMns/v1/NSS/jobs/%s", jobId) - def statusDescription = jobStatusResponse?.getResponseDescriptor()?.getStatusDescription() - currentNSSI['statusDescription'] = statusDescription + JobStatusResponse jobStatusResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlStr, nssmfRequest, JobStatusResponse.class) - LOGGER.debug("job status result: nsiId = ${nsiId}, nssiId=${nssiId}, oldProgress=${oldProgress}, progress = ${currentProgress}" ) - } + if (jobStatusResponse != null) { + 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 - private void checkNssmfResponse(Response httpResponse, DelegateExecution execution) { - int responseCode = httpResponse.getStatus() - LOGGER.debug("NSSMF response code is: " + responseCode) + def statusDescription = jobStatusResponse?.getResponseDescriptor()?.getStatusDescription() + currentNSSI['statusDescription'] = statusDescription - if ( responseCode < 200 || responseCode > 204 || !httpResponse.hasEntity()) { - exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Response from NSSMF.") + LOGGER.debug("job status result: nsiId = ${nsiId}, nssiId=${nssiId}, oldProgress=${oldProgress}, progress = ${currentProgress}" ) + + } else { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a Bad Response from NSSMF.") } - } + } private EsrInfo getEsrInfo(def currentNSSI) { @@ -307,4 +291,4 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor } LOGGER.debug("*****${PREFIX} Exist delSliceProfileFromAAI *****") } -} +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy index 35af3d34d6..21fc50c9b6 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy @@ -47,11 +47,11 @@ import org.onap.so.bpmn.core.domain.VnfcResource 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.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.slf4j.Logger import org.slf4j.LoggerFactory import org.onap.logging.filter.base.ONAPComponents; 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 89c5be8d6e..bee9ad260b 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 @@ -22,10 +22,19 @@ package org.onap.so.bpmn.infrastructure.scripts -import org.onap.so.logger.LoggingAnchor +import javax.ws.rs.core.Response import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.L3Network +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.Relationships +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.aaiclient.client.graphinventory.entities.uri.Depth +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.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil @@ -38,367 +47,357 @@ 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.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.AAIUriFactory -import org.onap.so.client.graphinventory.entities.uri.Depth import org.onap.so.constants.Defaults -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 org.onap.logging.filter.base.ONAPComponents; - import groovy.json.JsonOutput -import javax.ws.rs.core.Response public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { private static final Logger logger = LoggerFactory.getLogger( DoDeleteNetworkInstance.class); - String Prefix= "DELNWKI_" - String groovyClassName = "DoDeleteNetworkInstance" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils(this) - NetworkUtils networkUtils = new NetworkUtils() - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - - public InitializeProcessVariables(DelegateExecution execution){ - /* Initialize all the process variables in this block */ - - execution.setVariable(Prefix + "networkRequest", "") - execution.setVariable(Prefix + "isSilentSuccess", false) - execution.setVariable(Prefix + "Success", false) - - execution.setVariable(Prefix + "requestId", "") - execution.setVariable(Prefix + "source", "") - execution.setVariable(Prefix + "lcpCloudRegion", "") - execution.setVariable(Prefix + "networkInputs", "") - execution.setVariable(Prefix + "tenantId", "") - - execution.setVariable(Prefix + "queryAAIResponse", "") - execution.setVariable(Prefix + "aaiReturnCode", "") - execution.setVariable(Prefix + "isAAIGood", false) - execution.setVariable(Prefix + "isVfRelationshipExist", false) - - // AAI query Cloud Region - execution.setVariable(Prefix + "queryCloudRegionRequest","") - execution.setVariable(Prefix + "queryCloudRegionReturnCode","") - execution.setVariable(Prefix + "queryCloudRegionResponse","") - execution.setVariable(Prefix + "cloudRegionPo","") - execution.setVariable(Prefix + "cloudRegionSdnc","") - - execution.setVariable(Prefix + "deleteNetworkRequest", "") - execution.setVariable(Prefix + "deleteNetworkResponse", "") - execution.setVariable(Prefix + "networkReturnCode", "") - execution.setVariable(Prefix + "rollbackNetworkRequest", "") - - execution.setVariable(Prefix + "deleteSDNCRequest", "") - execution.setVariable(Prefix + "deleteSDNCResponse", "") - execution.setVariable(Prefix + "sdncReturnCode", "") - execution.setVariable(Prefix + "sdncResponseSuccess", false) - - execution.setVariable(Prefix + "deactivateSDNCRequest", "") - execution.setVariable(Prefix + "deactivateSDNCResponse", "") - execution.setVariable(Prefix + "deactivateSdncReturnCode", "") - execution.setVariable(Prefix + "isSdncDeactivateRollbackNeeded", "") - - execution.setVariable(Prefix + "rollbackDeactivateSDNCRequest", "") - execution.setVariable(Prefix + "isException", false) - - - } - - // ************************************************** - // Pre or Prepare Request Section - // ************************************************** - - public void preProcessRequest (DelegateExecution execution) { - - execution.setVariable("prefix",Prefix) - - logger.trace("Inside preProcessRequest() of " + groovyClassName + " Request ") - - // initialize flow variables - InitializeProcessVariables(execution) - - try { - // get incoming message/input - execution.setVariable("action", "DELETE") - String deleteNetwork = execution.getVariable("bpmnRequest") - if (deleteNetwork != null) { - if (deleteNetwork.contains("requestDetails")) { - // JSON format request is sent, create xml - try { - def prettyJson = JsonOutput.prettyPrint(deleteNetwork.toString()) - logger.debug(" Incoming message formatted . . . : " + '\n' + prettyJson) - deleteNetwork = vidUtils.createXmlNetworkRequestInfra(execution, deleteNetwork) - - } catch (Exception ex) { - String dataErrorMessage = " Invalid json format Request - " + ex.getMessage() - logger.debug(dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - } else { - // XML format request is sent - - } - } else { - // vIPR format request is sent, create xml from individual variables - deleteNetwork = vidUtils.createXmlNetworkRequestInstance(execution) - } - - deleteNetwork = utils.formatXml(deleteNetwork) - logger.debug(deleteNetwork) - execution.setVariable(Prefix + "networkRequest", deleteNetwork) - logger.debug(Prefix + "networkRequest - " + '\n' + deleteNetwork) - - // validate 'backout-on-failure' to override 'mso.rollback' - boolean rollbackEnabled = networkUtils.isRollbackEnabled(execution, deleteNetwork) - execution.setVariable(Prefix + "rollbackEnabled", rollbackEnabled) - logger.debug(Prefix + "rollbackEnabled - " + rollbackEnabled) - - String networkInputs = utils.getNodeXml(deleteNetwork, "network-inputs", false).replace("tag0:","").replace(":tag0","") - execution.setVariable(Prefix + "networkInputs", networkInputs) - - // prepare messageId - String messageId = execution.getVariable("testMessageId") // for testing - if (messageId == null || messageId == "") { - messageId = UUID.randomUUID() - logger.debug(Prefix + "messageId, random generated: " + messageId) - } else { - logger.debug(Prefix + "messageId, pre-assigned: " + messageId) - } - execution.setVariable(Prefix + "messageId", messageId) - - String source = utils.getNodeText(deleteNetwork, "source") - execution.setVariable(Prefix + "source", source) - logger.debug(Prefix + "source - " + source) - - String networkId = "" - if (utils.nodeExists(networkInputs, "network-id")) { - networkId = utils.getNodeText(networkInputs, "network-id") - if (networkId == null || networkId == "" || networkId == 'null' ) { - sendSyncError(execution) - // missing value of network-id - String dataErrorMessage = "network-request has missing 'network-id' element/value." - logger.debug(" Invalid Request - " + dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - } - - // lcpCloudRegion or tenantId not sent, will be extracted from query AA&I - def lcpCloudRegion = null - if (utils.nodeExists(networkInputs, "aic-cloud-region")) { - lcpCloudRegion = utils.getNodeText(networkInputs, "aic-cloud-region") - if (lcpCloudRegion == 'null') { - lcpCloudRegion = null - } - } - execution.setVariable(Prefix + "lcpCloudRegion", lcpCloudRegion) - logger.debug("lcpCloudRegion : " + lcpCloudRegion) - - String tenantId = null - if (utils.nodeExists(networkInputs, "tenant-id")) { - tenantId = utils.getNodeText(networkInputs, "tenant-id") - if (tenantId == 'null') { - tenantId = null - } - - } - execution.setVariable(Prefix + "tenantId", tenantId) - logger.debug("tenantId : " + tenantId) - - String sdncVersion = execution.getVariable("sdncVersion") - logger.debug("sdncVersion? : " + sdncVersion) - - // PO Authorization Info / headers Authorization= - String basicAuthValuePO = UrnPropertiesReader.getVariable("mso.adapters.po.auth", execution) - - try { - def encodedString = utils.getBasicAuth(basicAuthValuePO, UrnPropertiesReader.getVariable("mso.msoKey", execution)) - execution.setVariable("BasicAuthHeaderValuePO",encodedString) - execution.setVariable("BasicAuthHeaderValueSDNC", encodedString) - - } catch (IOException ex) { - String dataErrorMessage = " Unable to encode PO/SDNC user/password string - " + ex.getMessage() - logger.debug(dataErrorMessage ) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex){ - // caught exception - String exceptionMessage = "Exception Encountered in DoDeleteNetworkInstance, PreProcessRequest() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - - public void callRESTQueryAAI (DelegateExecution execution) { - - execution.setVariable("prefix",Prefix) - - logger.debug(" ***** Inside callRESTQueryAAI() of DoDoDeleteNetworkInstance ***** " ) - - // get variables - String networkInputs = execution.getVariable(Prefix + "networkInputs") - String networkId = utils.getNodeText(networkInputs, "network-id") - networkId = UriUtils.encode(networkId,"UTF-8") - ExceptionUtil exceptionUtil = new ExceptionUtil() - Boolean isVfRelationshipExist = false - try { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId).depth(Depth.ALL) - Optional<L3Network> l3Network = getAAIClient().get(L3Network.class,uri); - AAIResultWrapper wrapper = getAAIClient().get(uri); - Optional<Relationships> relationships = wrapper.getRelationships() - - if (l3Network.isPresent()) { - execution.setVariable(Prefix + "aaiReturnCode", 200) - execution.setVariable(Prefix + "queryAAIResponse", l3Network.get()) - execution.setVariable(Prefix + "isAAIGood", true) - if (relationships.isPresent()){ - if(!relationships.get().getRelatedAAIUris(AAIObjectType.VF_MODULE).isEmpty()){ - execution.setVariable(Prefix + "isVfRelationshipExist", true) - isVfRelationshipExist = true - String relationshipMessage = "AAI Query Success Response but 'vf-module' relationship exist, not allowed to delete: network Id: " + networkId - exceptionUtil.buildWorkflowException(execution, 2500, relationshipMessage) - }else{ - List<AAIResourceUri> tenantURIList = relationships.get().getRelatedAAIUris(AAIObjectType.TENANT) - for(AAIResourceUri tenantURI: tenantURIList){ - if(execution.getVariable(Prefix + "tenantId") == null) { - String tenantId = tenantURI.getURIKeys().get("tenant-id") - execution.setVariable(Prefix + "tenantId", tenantId) - logger.debug(" Get AAI getTenantId() : " + tenantId) - } - } - List<AAIResourceUri> cloudRegionURIList = relationships.get().getRelatedAAIUris(AAIObjectType.CLOUD_REGION) - for(AAIResourceUri tenantURI: cloudRegionURIList){ - if(execution.getVariable(Prefix + "lcpCloudRegion") == null) { - String lcpCloudRegion = tenantURI.getURIKeys().get("cloud-region-id") - execution.setVariable(Prefix + "lcpCloudRegion", lcpCloudRegion) - logger.debug(" Get AAI getCloudRegion() : " + lcpCloudRegion) - } - } - } - } - logger.debug(Prefix + "isVfRelationshipExist - " + isVfRelationshipExist) - } else { - // not found // empty aai response - execution.setVariable(Prefix + "aaiReturnCode", 404) - execution.setVariable(Prefix + "isAAIGood", false) - execution.setVariable(Prefix + "isSilentSuccess", true) - logger.debug(" AAI Query is Silent Success") - } - logger.debug(" AAI Query call, isAAIGood? : " + execution.getVariable(Prefix + "isAAIGood")) - } catch (Exception ex) { - // caught exception - String exceptionMessage = "Exception Encountered in DoDeleteNetworkInstance, callRESTQueryAAI() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void callRESTQueryAAICloudRegion (DelegateExecution execution) { - - execution.setVariable("prefix", Prefix) - - logger.debug(" ***** Inside callRESTQueryAAICloudRegion of DoDeleteNetworkInstance ***** " ) - - try { - String networkInputs = execution.getVariable(Prefix + "networkInputs") - // String cloudRegion = utils.getNodeText(networkInputs, "aic-cloud-region") - String cloudRegion = execution.getVariable(Prefix + "lcpCloudRegion") - // Prepare AA&I url - AaiUtil aaiUtil = new AaiUtil(this) - - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion) - def queryCloudRegionRequest = aaiUtil.createAaiUri(uri) - - execution.setVariable(Prefix + "queryCloudRegionRequest", queryCloudRegionRequest) - - String cloudRegionPo = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) - String cloudRegionSdnc = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "SDNC", cloudRegion) - - if ((cloudRegionPo != "ERROR") && (cloudRegionSdnc != "ERROR")) { - execution.setVariable(Prefix + "cloudRegionPo", cloudRegionPo) - execution.setVariable(Prefix + "cloudRegionSdnc", cloudRegionSdnc) - - } else { - String dataErrorMessage = "QueryAAICloudRegion Unsuccessful. Return Code: " + execution.getVariable(Prefix + "queryCloudRegionReturnCode") - logger.debug(dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - // caught exception - String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, callRESTQueryAAICloudRegion(). Unexpected Response from AAI - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void prepareNetworkRequest (DelegateExecution execution) { - - execution.setVariable("prefix", Prefix) - - logger.trace("Inside prepareNetworkRequest of DoDeleteNetworkInstance ") - ExceptionUtil exceptionUtil = new ExceptionUtil() - try { - // get variables - String networkRequest = execution.getVariable(Prefix + "networkRequest") - String cloudSiteId = execution.getVariable(Prefix + "cloudRegionPo") - String tenantId = execution.getVariable(Prefix + "tenantId") - - L3Network l3Network = execution.getVariable(Prefix + "queryAAIResponse") - String networkType = l3Network.getNetworkType() - String networkId = l3Network.getNetworkId() - - String networkStackId = "" - networkStackId = l3Network.getHeatStackId() - if (networkStackId == 'null' || networkStackId == "" || networkStackId == null) { - networkStackId = "force_delete" - } - - String requestId = execution.getVariable("msoRequestId") - if (requestId != null) { - execution.setVariable("mso-request-id", requestId) - } else { - requestId = execution.getVariable("mso-request-id") - } - String serviceInstanceId = execution.getVariable("serviceInstanceId") - - // Added new Elements - String messageId = execution.getVariable(Prefix + "messageId") - String notificationUrl = "" //TODO - is this coming from URN? What variable/value to use? - //String notificationUrl = execution.getVariable("URN_?????") //TODO - is this coming from URN? What variable/value to use? - - String modelCustomizationUuid = "" - if (utils.nodeExists(networkRequest, "networkModelInfo")) { - String networkModelInfo = utils.getNodeXml(networkRequest, "networkModelInfo", false).replace("tag0:","").replace(":tag0","") - modelCustomizationUuid = utils.getNodeText(networkModelInfo, "modelCustomizationUuid") - } else { - modelCustomizationUuid = utils.getNodeText(networkRequest, "modelCustomizationId") - } + String Prefix= "DELNWKI_" + String groovyClassName = "DoDeleteNetworkInstance" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + VidUtils vidUtils = new VidUtils(this) + NetworkUtils networkUtils = new NetworkUtils() + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() + + public InitializeProcessVariables(DelegateExecution execution){ + /* Initialize all the process variables in this block */ + + execution.setVariable(Prefix + "networkRequest", "") + execution.setVariable(Prefix + "isSilentSuccess", false) + execution.setVariable(Prefix + "Success", false) + + execution.setVariable(Prefix + "requestId", "") + execution.setVariable(Prefix + "source", "") + execution.setVariable(Prefix + "lcpCloudRegion", "") + execution.setVariable(Prefix + "networkInputs", "") + execution.setVariable(Prefix + "tenantId", "") + + execution.setVariable(Prefix + "queryAAIResponse", "") + execution.setVariable(Prefix + "aaiReturnCode", "") + execution.setVariable(Prefix + "isAAIGood", false) + execution.setVariable(Prefix + "isVfRelationshipExist", false) + + // AAI query Cloud Region + execution.setVariable(Prefix + "queryCloudRegionRequest","") + execution.setVariable(Prefix + "queryCloudRegionReturnCode","") + execution.setVariable(Prefix + "queryCloudRegionResponse","") + execution.setVariable(Prefix + "cloudRegionPo","") + execution.setVariable(Prefix + "cloudRegionSdnc","") + + execution.setVariable(Prefix + "deleteNetworkRequest", "") + execution.setVariable(Prefix + "deleteNetworkResponse", "") + execution.setVariable(Prefix + "networkReturnCode", "") + execution.setVariable(Prefix + "rollbackNetworkRequest", "") + + execution.setVariable(Prefix + "deleteSDNCRequest", "") + execution.setVariable(Prefix + "deleteSDNCResponse", "") + execution.setVariable(Prefix + "sdncReturnCode", "") + execution.setVariable(Prefix + "sdncResponseSuccess", false) + + execution.setVariable(Prefix + "deactivateSDNCRequest", "") + execution.setVariable(Prefix + "deactivateSDNCResponse", "") + execution.setVariable(Prefix + "deactivateSdncReturnCode", "") + execution.setVariable(Prefix + "isSdncDeactivateRollbackNeeded", "") + + execution.setVariable(Prefix + "rollbackDeactivateSDNCRequest", "") + execution.setVariable(Prefix + "isException", false) + + + } + + // ************************************************** + // Pre or Prepare Request Section + // ************************************************** + + public void preProcessRequest (DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + logger.trace("Inside preProcessRequest() of " + groovyClassName + " Request ") + + // initialize flow variables + InitializeProcessVariables(execution) + + try { + // get incoming message/input + execution.setVariable("action", "DELETE") + String deleteNetwork = execution.getVariable("bpmnRequest") + if (deleteNetwork != null) { + if (deleteNetwork.contains("requestDetails")) { + // JSON format request is sent, create xml + try { + def prettyJson = JsonOutput.prettyPrint(deleteNetwork.toString()) + logger.debug(" Incoming message formatted . . . : " + '\n' + prettyJson) + deleteNetwork = vidUtils.createXmlNetworkRequestInfra(execution, deleteNetwork) + + } catch (Exception ex) { + String dataErrorMessage = " Invalid json format Request - " + ex.getMessage() + logger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + } else { + // XML format request is sent + + } + } else { + // vIPR format request is sent, create xml from individual variables + deleteNetwork = vidUtils.createXmlNetworkRequestInstance(execution) + } + + deleteNetwork = utils.formatXml(deleteNetwork) + logger.debug(deleteNetwork) + execution.setVariable(Prefix + "networkRequest", deleteNetwork) + logger.debug(Prefix + "networkRequest - " + '\n' + deleteNetwork) + + // validate 'backout-on-failure' to override 'mso.rollback' + boolean rollbackEnabled = networkUtils.isRollbackEnabled(execution, deleteNetwork) + execution.setVariable(Prefix + "rollbackEnabled", rollbackEnabled) + logger.debug(Prefix + "rollbackEnabled - " + rollbackEnabled) + + String networkInputs = utils.getNodeXml(deleteNetwork, "network-inputs", false).replace("tag0:","").replace(":tag0","") + execution.setVariable(Prefix + "networkInputs", networkInputs) + + // prepare messageId + String messageId = execution.getVariable("testMessageId") // for testing + if (messageId == null || messageId == "") { + messageId = UUID.randomUUID() + logger.debug(Prefix + "messageId, random generated: " + messageId) + } else { + logger.debug(Prefix + "messageId, pre-assigned: " + messageId) + } + execution.setVariable(Prefix + "messageId", messageId) + + String source = utils.getNodeText(deleteNetwork, "source") + execution.setVariable(Prefix + "source", source) + logger.debug(Prefix + "source - " + source) + + String networkId = "" + if (utils.nodeExists(networkInputs, "network-id")) { + networkId = utils.getNodeText(networkInputs, "network-id") + if (networkId == null || networkId == "" || networkId == 'null' ) { + sendSyncError(execution) + // missing value of network-id + String dataErrorMessage = "network-request has missing 'network-id' element/value." + logger.debug(" Invalid Request - " + dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + } + + // lcpCloudRegion or tenantId not sent, will be extracted from query AA&I + def lcpCloudRegion = null + if (utils.nodeExists(networkInputs, "aic-cloud-region")) { + lcpCloudRegion = utils.getNodeText(networkInputs, "aic-cloud-region") + if (lcpCloudRegion == 'null') { + lcpCloudRegion = null + } + } + execution.setVariable(Prefix + "lcpCloudRegion", lcpCloudRegion) + logger.debug("lcpCloudRegion : " + lcpCloudRegion) + + String tenantId = null + if (utils.nodeExists(networkInputs, "tenant-id")) { + tenantId = utils.getNodeText(networkInputs, "tenant-id") + if (tenantId == 'null') { + tenantId = null + } + + } + execution.setVariable(Prefix + "tenantId", tenantId) + logger.debug("tenantId : " + tenantId) + + String sdncVersion = execution.getVariable("sdncVersion") + logger.debug("sdncVersion? : " + sdncVersion) + + // PO Authorization Info / headers Authorization= + String basicAuthValuePO = UrnPropertiesReader.getVariable("mso.adapters.po.auth", execution) + + try { + def encodedString = utils.getBasicAuth(basicAuthValuePO, UrnPropertiesReader.getVariable("mso.msoKey", execution)) + execution.setVariable("BasicAuthHeaderValuePO",encodedString) + execution.setVariable("BasicAuthHeaderValueSDNC", encodedString) + + } catch (IOException ex) { + String dataErrorMessage = " Unable to encode PO/SDNC user/password string - " + ex.getMessage() + logger.debug(dataErrorMessage ) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex){ + // caught exception + String exceptionMessage = "Exception Encountered in DoDeleteNetworkInstance, PreProcessRequest() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + + public void callRESTQueryAAI (DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + logger.debug(" ***** Inside callRESTQueryAAI() of DoDoDeleteNetworkInstance ***** " ) + + // get variables + String networkInputs = execution.getVariable(Prefix + "networkInputs") + String networkId = utils.getNodeText(networkInputs, "network-id") + networkId = UriUtils.encode(networkId,"UTF-8") + ExceptionUtil exceptionUtil = new ExceptionUtil() + Boolean isVfRelationshipExist = false + try { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId).depth(Depth.ALL) + Optional<L3Network> l3Network = getAAIClient().get(L3Network.class,uri); + AAIResultWrapper wrapper = getAAIClient().get(uri); + Optional<Relationships> relationships = wrapper.getRelationships() + + if (l3Network.isPresent()) { + execution.setVariable(Prefix + "aaiReturnCode", 200) + execution.setVariable(Prefix + "queryAAIResponse", l3Network.get()) + execution.setVariable(Prefix + "isAAIGood", true) + if (relationships.isPresent()){ + if(!relationships.get().getRelatedAAIUris(AAIObjectType.VF_MODULE).isEmpty()){ + execution.setVariable(Prefix + "isVfRelationshipExist", true) + isVfRelationshipExist = true + String relationshipMessage = "AAI Query Success Response but 'vf-module' relationship exist, not allowed to delete: network Id: " + networkId + exceptionUtil.buildWorkflowException(execution, 2500, relationshipMessage) + }else{ + List<AAIResourceUri> tenantURIList = relationships.get().getRelatedAAIUris(AAIObjectType.TENANT) + for(AAIResourceUri tenantURI: tenantURIList){ + if(execution.getVariable(Prefix + "tenantId") == null) { + String tenantId = tenantURI.getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId) + execution.setVariable(Prefix + "tenantId", tenantId) + logger.debug(" Get AAI getTenantId() : " + tenantId) + } + } + List<AAIResourceUri> cloudRegionURIList = relationships.get().getRelatedAAIUris(AAIObjectType.CLOUD_REGION) + for(AAIResourceUri tenantURI: cloudRegionURIList){ + if(execution.getVariable(Prefix + "lcpCloudRegion") == null) { + String lcpCloudRegion = tenantURI.getURIKeys().get(AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudRegionId) + execution.setVariable(Prefix + "lcpCloudRegion", lcpCloudRegion) + logger.debug(" Get AAI getCloudRegion() : " + lcpCloudRegion) + } + } + } + } + logger.debug(Prefix + "isVfRelationshipExist - " + isVfRelationshipExist) + } else { + // not found // empty aai response + execution.setVariable(Prefix + "aaiReturnCode", 404) + execution.setVariable(Prefix + "isAAIGood", false) + execution.setVariable(Prefix + "isSilentSuccess", true) + logger.debug(" AAI Query is Silent Success") + } + logger.debug(" AAI Query call, isAAIGood? : " + execution.getVariable(Prefix + "isAAIGood")) + } catch (Exception ex) { + // caught exception + String exceptionMessage = "Exception Encountered in DoDeleteNetworkInstance, callRESTQueryAAI() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void callRESTQueryAAICloudRegion (DelegateExecution execution) { + + execution.setVariable("prefix", Prefix) + + logger.debug(" ***** Inside callRESTQueryAAICloudRegion of DoDeleteNetworkInstance ***** " ) + + try { + String networkInputs = execution.getVariable(Prefix + "networkInputs") + // String cloudRegion = utils.getNodeText(networkInputs, "aic-cloud-region") + String cloudRegion = execution.getVariable(Prefix + "lcpCloudRegion") + // Prepare AA&I url + AaiUtil aaiUtil = new AaiUtil(this) + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion) + def queryCloudRegionRequest = aaiUtil.createAaiUri(uri) + + execution.setVariable(Prefix + "queryCloudRegionRequest", queryCloudRegionRequest) + + String cloudRegionPo = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) + String cloudRegionSdnc = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "SDNC", cloudRegion) + + if ((cloudRegionPo != "ERROR") && (cloudRegionSdnc != "ERROR")) { + execution.setVariable(Prefix + "cloudRegionPo", cloudRegionPo) + execution.setVariable(Prefix + "cloudRegionSdnc", cloudRegionSdnc) + + } else { + String dataErrorMessage = "QueryAAICloudRegion Unsuccessful. Return Code: " + execution.getVariable(Prefix + "queryCloudRegionReturnCode") + logger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex) { + // caught exception + String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, callRESTQueryAAICloudRegion(). Unexpected Response from AAI - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } - String deleteNetworkRequest = """ + } + + public void prepareNetworkRequest (DelegateExecution execution) { + + execution.setVariable("prefix", Prefix) + + logger.trace("Inside prepareNetworkRequest of DoDeleteNetworkInstance ") + ExceptionUtil exceptionUtil = new ExceptionUtil() + try { + // get variables + String networkRequest = execution.getVariable(Prefix + "networkRequest") + String cloudSiteId = execution.getVariable(Prefix + "cloudRegionPo") + String tenantId = execution.getVariable(Prefix + "tenantId") + + L3Network l3Network = execution.getVariable(Prefix + "queryAAIResponse") + String networkType = l3Network.getNetworkType() + String networkId = l3Network.getNetworkId() + + String networkStackId = "" + networkStackId = l3Network.getHeatStackId() + if (networkStackId == 'null' || networkStackId == "" || networkStackId == null) { + networkStackId = "force_delete" + } + + String requestId = execution.getVariable("msoRequestId") + if (requestId != null) { + execution.setVariable("mso-request-id", requestId) + } else { + requestId = execution.getVariable("mso-request-id") + } + String serviceInstanceId = execution.getVariable("serviceInstanceId") + + // Added new Elements + String messageId = execution.getVariable(Prefix + "messageId") + String notificationUrl = "" //TODO - is this coming from URN? What variable/value to use? + //String notificationUrl = execution.getVariable("URN_?????") //TODO - is this coming from URN? What variable/value to use? + + String modelCustomizationUuid = "" + if (utils.nodeExists(networkRequest, "networkModelInfo")) { + String networkModelInfo = utils.getNodeXml(networkRequest, "networkModelInfo", false).replace("tag0:","").replace(":tag0","") + modelCustomizationUuid = utils.getNodeText(networkModelInfo, "modelCustomizationUuid") + } else { + modelCustomizationUuid = utils.getNodeText(networkRequest, "modelCustomizationId") + } + + String deleteNetworkRequest = """ <deleteNetworkRequest> <cloudSiteId>${MsoUtils.xmlEscape(cloudSiteId)}</cloudSiteId> <tenantId>${MsoUtils.xmlEscape(tenantId)}</tenantId> @@ -416,645 +415,567 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { </deleteNetworkRequest> """.trim() - logger.debug(Prefix + "deleteNetworkRequest - " + "\n" + deleteNetworkRequest) - // Format Response - String buildDeleteNetworkRequestAsString = utils.formatXml(deleteNetworkRequest) - logger.debug(buildDeleteNetworkRequestAsString) - logger.debug(Prefix + "deleteNetworkRequestAsString - " + "\n" + buildDeleteNetworkRequestAsString) - - String restURL = UrnPropertiesReader.getVariable("mso.adapters.network.rest.endpoint", execution) - execution.setVariable("mso.adapters.network.rest.endpoint", restURL + "/" + networkId) - logger.debug("mso.adapters.network.rest.endpoint - " + "\n" + restURL + "/" + networkId) - - execution.setVariable(Prefix + "deleteNetworkRequest", buildDeleteNetworkRequestAsString) - logger.debug(Prefix + "deleteNetworkRequest - " + "\n" + buildDeleteNetworkRequestAsString) - } - catch (Exception ex) { - // caught exception - String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareNetworkRequest(). Unexpected Response from AAI - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - } - - /** - * This method is used instead of an HTTP Connector task because the - * connector does not allow DELETE with a body. - */ - public void sendRequestToVnfAdapter(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.sendRequestToVnfAdapter(' + - 'execution=' + execution.getId() + - ')' - - logger.trace('Entered ' + method) - - try { - - String vnfAdapterUrl = UrnPropertiesReader.getVariable("mso.adapters.network.rest.endpoint",execution) - String vnfAdapterRequest = execution.getVariable(Prefix + "deleteNetworkRequest") - - URL url = new URL(vnfAdapterUrl) - HttpClient httpClient = new HttpClientFactory().newXmlClient(url, ONAPComponents.OPENSTACK_ADAPTER) - httpClient.accept = "application/xml" - httpClient.addAdditionalHeader("Authorization", execution.getVariable("BasicAuthHeaderValuePO")) - Response response = httpClient.delete(vnfAdapterRequest) - - execution.setVariable(Prefix + "deleteNetworkResponse", response.readEntity(String.class)) - execution.setVariable(Prefix + "networkReturnCode", response.getStatus()) - - } catch (Exception ex) { - // caught exception - String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, sendRequestToVnfAdapter() - " + ex.getMessage() - logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), exceptionMessage, - "BPMN", ErrorCode.UnknownError.getValue(), - "Exception is:\n" + ex); - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - } - - - public void prepareSDNCRequest (DelegateExecution execution) { + logger.debug(Prefix + "deleteNetworkRequest - " + "\n" + deleteNetworkRequest) + // Format Response + String buildDeleteNetworkRequestAsString = utils.formatXml(deleteNetworkRequest) + logger.debug(buildDeleteNetworkRequestAsString) + logger.debug(Prefix + "deleteNetworkRequestAsString - " + "\n" + buildDeleteNetworkRequestAsString) - execution.setVariable("prefix", Prefix) - - logger.trace("Inside prepareSDNCRequest of DoDeleteNetworkInstance ") - - try { - // get variables - String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) - String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") - - String networkId = "" - if (utils.nodeExists(deleteNetworkInput, "network-id")) { - networkId = utils.getNodeText(deleteNetworkInput, "network-id") - } - if (networkId == 'null') {networkId = ""} - - String serviceInstanceId = utils.getNodeText(deleteNetworkInput, "service-instance-id") - - // get/set 'msoRequestId' and 'mso-request-id' - String requestId = execution.getVariable("msoRequestId") - if (requestId != null) { - execution.setVariable("mso-request-id", requestId) - } else { - requestId = execution.getVariable("mso-request-id") - } - execution.setVariable(Prefix + "requestId", requestId) - logger.debug(Prefix + "requestId " + requestId) - L3Network queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse") - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") - // 1. prepare delete topology via SDNC Adapter SUBFLOW call - String sndcTopologyDeleteRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "delete", "DisconnectNetworkRequest", cloudRegionId, networkId, queryAAIResponse, null) - String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyDeleteRequest) - logger.debug(sndcTopologyDeleteRequesAsString) - execution.setVariable(Prefix + "deleteSDNCRequest", sndcTopologyDeleteRequesAsString) - logger.debug(Prefix + "deleteSDNCRequest - " + "\n" + sndcTopologyDeleteRequesAsString) + String restURL = UrnPropertiesReader.getVariable("mso.adapters.network.rest.endpoint", execution) + execution.setVariable("mso.adapters.network.rest.endpoint", restURL + "/" + networkId) + logger.debug("mso.adapters.network.rest.endpoint - " + "\n" + restURL + "/" + networkId) - } catch (Exception ex) { - // caught exception - String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareSDNCRequest() - " + ex.getMessage() - logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), exceptionMessage, - "BPMN", ErrorCode.UnknownError.getValue(), - "Exception is:\n" + ex); - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void prepareRpcSDNCRequest (DelegateExecution execution) { - - execution.setVariable("prefix", Prefix) - - logger.trace("Inside prepareRpcSDNCRequest of DoDeleteNetworkInstance ") - - try { - // get variables - String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) - String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") - - String networkId = "" - if (utils.nodeExists(deleteNetworkInput, "network-id")) { - networkId = utils.getNodeText(deleteNetworkInput, "network-id") - } - if (networkId == 'null') {networkId = ""} - - String serviceInstanceId = utils.getNodeText(deleteNetworkInput, "service-instance-id") - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") - // 1. prepare delete topology via SDNC Adapter SUBFLOW call - String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "unassign", "DeleteNetworkInstance", cloudRegionId, networkId, null) - String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyRollbackRpcRequest) - logger.debug(sndcTopologyDeleteRequesAsString) - execution.setVariable(Prefix + "deleteSDNCRequest", sndcTopologyDeleteRequesAsString) - logger.debug(Prefix + "deleteSDNCRequest - " + "\n" + sndcTopologyDeleteRequesAsString) - - } catch (Exception ex) { - // caught exception - String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareSDNCRequest() - " + ex.getMessage() - logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), exceptionMessage, - "BPMN", ErrorCode.UnknownError.getValue(), - "Exception is:\n" + ex); - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } + execution.setVariable(Prefix + "deleteNetworkRequest", buildDeleteNetworkRequestAsString) + logger.debug(Prefix + "deleteNetworkRequest - " + "\n" + buildDeleteNetworkRequestAsString) + } + catch (Exception ex) { + // caught exception + String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareNetworkRequest(). Unexpected Response from AAI - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + /** + * This method is used instead of an HTTP Connector task because the + * connector does not allow DELETE with a body. + */ + public void sendRequestToVnfAdapter(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.sendRequestToVnfAdapter(' + + 'execution=' + execution.getId() + + ')' + + logger.trace('Entered ' + method) + + try { + + String vnfAdapterUrl = UrnPropertiesReader.getVariable("mso.adapters.network.rest.endpoint",execution) + String vnfAdapterRequest = execution.getVariable(Prefix + "deleteNetworkRequest") + + URL url = new URL(vnfAdapterUrl) + HttpClient httpClient = new HttpClientFactory().newXmlClient(url, ONAPComponents.OPENSTACK_ADAPTER) + httpClient.accept = "application/xml" + httpClient.addAdditionalHeader("Authorization", execution.getVariable("BasicAuthHeaderValuePO")) + Response response = httpClient.delete(vnfAdapterRequest) + + execution.setVariable(Prefix + "deleteNetworkResponse", response.readEntity(String.class)) + execution.setVariable(Prefix + "networkReturnCode", response.getStatus()) + + } catch (Exception ex) { + // caught exception + String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, sendRequestToVnfAdapter() - " + ex.getMessage() + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), exceptionMessage, + "BPMN", ErrorCode.UnknownError.getValue(), + "Exception is:\n" + ex); + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - public void prepareRpcSDNCDeactivate(DelegateExecution execution) { + } + } + + + public void prepareSDNCRequest (DelegateExecution execution) { + + execution.setVariable("prefix", Prefix) + + logger.trace("Inside prepareSDNCRequest of DoDeleteNetworkInstance ") + + try { + // get variables + String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") + + String networkId = "" + if (utils.nodeExists(deleteNetworkInput, "network-id")) { + networkId = utils.getNodeText(deleteNetworkInput, "network-id") + } + if (networkId == 'null') {networkId = ""} + + String serviceInstanceId = utils.getNodeText(deleteNetworkInput, "service-instance-id") + + // get/set 'msoRequestId' and 'mso-request-id' + String requestId = execution.getVariable("msoRequestId") + if (requestId != null) { + execution.setVariable("mso-request-id", requestId) + } else { + requestId = execution.getVariable("mso-request-id") + } + execution.setVariable(Prefix + "requestId", requestId) + logger.debug(Prefix + "requestId " + requestId) + L3Network queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse") + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() + String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") + // 1. prepare delete topology via SDNC Adapter SUBFLOW call + String sndcTopologyDeleteRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "delete", "DisconnectNetworkRequest", cloudRegionId, networkId, queryAAIResponse, null) + String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyDeleteRequest) + logger.debug(sndcTopologyDeleteRequesAsString) + execution.setVariable(Prefix + "deleteSDNCRequest", sndcTopologyDeleteRequesAsString) + logger.debug(Prefix + "deleteSDNCRequest - " + "\n" + sndcTopologyDeleteRequesAsString) + + } catch (Exception ex) { + // caught exception + String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareSDNCRequest() - " + ex.getMessage() + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), exceptionMessage, + "BPMN", ErrorCode.UnknownError.getValue(), + "Exception is:\n" + ex); + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - execution.setVariable("prefix",Prefix) + } - logger.trace("Inside prepareRpcSDNCDeactivate() of DoDeleteNetworkInstance ") - - try { - - // get variables - String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) - String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") - String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") - String networkId = "" - if (utils.nodeExists(deleteNetworkInput, "network-id")) { - networkId = utils.getNodeText(deleteNetworkInput, "network-id") - } - if (networkId == 'null') {networkId = ""} - String serviceInstanceId = utils.getNodeText(deleteNetworkInput, "service-instance-id") + } - String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "deactivate", "DeleteNetworkInstance", cloudRegionId, networkId, null) - String sndcTopologyRollbackRpcRequestAsString = utils.formatXml(sndcTopologyRollbackRpcRequest) - execution.setVariable(Prefix + "deactivateSDNCRequest", sndcTopologyRollbackRpcRequestAsString) - logger.debug(" Preparing request for RPC SDNC Topology deactivate - " + "\n" + sndcTopologyRollbackRpcRequestAsString) + public void prepareRpcSDNCRequest (DelegateExecution execution) { + execution.setVariable("prefix", Prefix) - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRpcSDNCActivateRollback() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + logger.trace("Inside prepareRpcSDNCRequest of DoDeleteNetworkInstance ") - } + try { + // get variables + String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") - } + String networkId = "" + if (utils.nodeExists(deleteNetworkInput, "network-id")) { + networkId = utils.getNodeText(deleteNetworkInput, "network-id") + } + if (networkId == 'null') {networkId = ""} - // ************************************************** - // Post or Validate Response Section - // ************************************************** + String serviceInstanceId = utils.getNodeText(deleteNetworkInput, "service-instance-id") - public void validateNetworkResponse (DelegateExecution execution) { + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() + String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") + // 1. prepare delete topology via SDNC Adapter SUBFLOW call + String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "unassign", "DeleteNetworkInstance", cloudRegionId, networkId, null) + String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyRollbackRpcRequest) + logger.debug(sndcTopologyDeleteRequesAsString) + execution.setVariable(Prefix + "deleteSDNCRequest", sndcTopologyDeleteRequesAsString) + logger.debug(Prefix + "deleteSDNCRequest - " + "\n" + sndcTopologyDeleteRequesAsString) - execution.setVariable("prefix", Prefix) + } catch (Exception ex) { + // caught exception + String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareSDNCRequest() - " + ex.getMessage() + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), exceptionMessage, + "BPMN", ErrorCode.UnknownError.getValue(), + "Exception is:\n" + ex); + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - logger.trace("Inside validateNetworkResponse of DoDeleteNetworkInstance ") + } - try { - String returnCode = execution.getVariable(Prefix + "networkReturnCode") - String networkResponse = execution.getVariable(Prefix + "deleteNetworkResponse") + } - logger.debug(" Network Adapter responseCode: " + returnCode) - logger.debug("Network Adapter Response - " + "\n" + networkResponse) - logger.debug(networkResponse) - String errorMessage = "" - if (returnCode == "200") { - logger.debug(" Network Adapter Response is successful - " + "\n" + networkResponse) + public void prepareRpcSDNCDeactivate(DelegateExecution execution) { - // prepare rollback data - String rollbackData = utils.getNodeXml(networkResponse, "rollback", false).replace("tag0:","").replace(":tag0","") - if ((rollbackData == null) || (rollbackData.isEmpty())) { - logger.debug(" Network Adapter 'rollback' data is not Sent: " + "\n" + networkResponse) - execution.setVariable(Prefix + "rollbackNetworkRequest", "") - } else { - String rollbackNetwork = - """<NetworkAdapter:rollbackNetwork xmlns:NetworkAdapter="http://org.onap.so/network"> - ${rollbackData} - </NetworkAdapter:rollbackNetwork>""" - String rollbackNetworkXml = utils.formatXml(rollbackNetwork) - execution.setVariable(Prefix + "rollbackNetworkRequest", rollbackNetworkXml) - logger.debug(" Network Adapter rollback data - " + "\n" + rollbackNetworkXml) - } + execution.setVariable("prefix",Prefix) + logger.trace("Inside prepareRpcSDNCDeactivate() of DoDeleteNetworkInstance ") - } else { // network error - if (returnCode.toInteger() > 399 && returnCode.toInteger() < 600) { //4xx, 5xx - if (networkResponse.contains("deleteNetworkError") ) { - networkResponse = networkResponse.replace('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>', '') - errorMessage = utils.getNodeText(networkResponse, "message") - errorMessage = "Received error from Network Adapter: " + errorMessage - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) + try { - } else { // CatchAll exception - if (returnCode == "500") { - errorMessage = "JBWEB000065: HTTP Status 500." - } else { - errorMessage = "Return code is " + returnCode - } - errorMessage = "Received error from Network Adapter: " + errorMessage - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) + // get variables + String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") + String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") + String networkId = "" + if (utils.nodeExists(deleteNetworkInput, "network-id")) { + networkId = utils.getNodeText(deleteNetworkInput, "network-id") + } + if (networkId == 'null') {networkId = ""} + String serviceInstanceId = utils.getNodeText(deleteNetworkInput, "service-instance-id") - } + String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "deactivate", "DeleteNetworkInstance", cloudRegionId, networkId, null) + String sndcTopologyRollbackRpcRequestAsString = utils.formatXml(sndcTopologyRollbackRpcRequest) + execution.setVariable(Prefix + "deactivateSDNCRequest", sndcTopologyRollbackRpcRequestAsString) + logger.debug(" Preparing request for RPC SDNC Topology deactivate - " + "\n" + sndcTopologyRollbackRpcRequestAsString) - } else { // CatchAll exception - String dataErrorMessage = "Received error from Network Adapter. Return code is: " + returnCode - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRpcSDNCActivateRollback() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - } + } - } catch (BpmnError e) { - throw e; + } - } catch (Exception ex) { - // caught exception - String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, validateNetworkResponse() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + public void validateSDNCResponse (DelegateExecution execution) { - } + execution.setVariable("prefix", Prefix) - } + logger.trace("Inside validateSDNCResponse of DoDeleteNetworkInstance ") - public void validateSDNCResponse (DelegateExecution execution) { + String response = execution.getVariable(Prefix + "deleteSDNCResponse") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + WorkflowException workflowException = execution.getVariable("WorkflowException") - execution.setVariable("prefix", Prefix) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + // reset variable + String deleteSDNCResponseDecodeXml = execution.getVariable(Prefix + "deleteSDNCResponse") + deleteSDNCResponseDecodeXml = deleteSDNCResponseDecodeXml.replace('<?xml version="1.0" encoding="UTF-8"?>', "") + execution.setVariable(Prefix + "deleteSDNCResponse", deleteSDNCResponseDecodeXml) - logger.trace("Inside validateSDNCResponse of DoDeleteNetworkInstance ") + if (execution.getVariable(Prefix + "sdncResponseSuccess") == true) { // from sdnc util, prefix+'sdncResponseSuccess' + execution.setVariable(Prefix + "isSdncRollbackNeeded", true) // + execution.setVariable(Prefix + "isPONR", true) + logger.debug("Successfully Validated SDNC Response") + } else { + logger.debug("Did NOT Successfully Validated SDNC Response") + throw new BpmnError("MSOWorkflowException") + } - String response = execution.getVariable(Prefix + "deleteSDNCResponse") - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - WorkflowException workflowException = execution.getVariable("WorkflowException") + } - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - // reset variable - String deleteSDNCResponseDecodeXml = execution.getVariable(Prefix + "deleteSDNCResponse") - deleteSDNCResponseDecodeXml = deleteSDNCResponseDecodeXml.replace('<?xml version="1.0" encoding="UTF-8"?>', "") - execution.setVariable(Prefix + "deleteSDNCResponse", deleteSDNCResponseDecodeXml) + public void validateRpcSDNCDeactivateResponse (DelegateExecution execution) { - if (execution.getVariable(Prefix + "sdncResponseSuccess") == true) { // from sdnc util, prefix+'sdncResponseSuccess' - execution.setVariable(Prefix + "isSdncRollbackNeeded", true) // - execution.setVariable(Prefix + "isPONR", true) - logger.debug("Successfully Validated SDNC Response") - } else { - logger.debug("Did NOT Successfully Validated SDNC Response") - throw new BpmnError("MSOWorkflowException") - } + execution.setVariable("prefix",Prefix) - } + logger.trace("Inside validateRpcSDNCDeactivateResponse() of DoDeleteNetworkInstance ") - public void validateRpcSDNCDeactivateResponse (DelegateExecution execution) { + String response = execution.getVariable(Prefix + "deactivateSDNCResponse") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + WorkflowException workflowException = execution.getVariable("WorkflowException") - execution.setVariable("prefix",Prefix) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + // reset variable + String assignSDNCResponseDecodeXml = execution.getVariable(Prefix + "deactivateSDNCResponse") + assignSDNCResponseDecodeXml = assignSDNCResponseDecodeXml.replace('<?xml version="1.0" encoding="UTF-8"?>', "") + execution.setVariable(Prefix + "deactivateSDNCResponse", assignSDNCResponseDecodeXml) - logger.trace("Inside validateRpcSDNCDeactivateResponse() of DoDeleteNetworkInstance ") + if (execution.getVariable(Prefix + "sdncResponseSuccess") == true) { // from sdnc util, Prefix+'sdncResponseSuccess' + execution.setVariable(Prefix + "isSdncDeactivateRollbackNeeded", true) + logger.debug("Successfully Validated Rpc SDNC Activate Response") - String response = execution.getVariable(Prefix + "deactivateSDNCResponse") - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - WorkflowException workflowException = execution.getVariable("WorkflowException") + } else { + logger.debug("Did NOT Successfully Validated Rpc SDNC Deactivate Response") + throw new BpmnError("MSOWorkflowException") + } - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - // reset variable - String assignSDNCResponseDecodeXml = execution.getVariable(Prefix + "deactivateSDNCResponse") - assignSDNCResponseDecodeXml = assignSDNCResponseDecodeXml.replace('<?xml version="1.0" encoding="UTF-8"?>', "") - execution.setVariable(Prefix + "deactivateSDNCResponse", assignSDNCResponseDecodeXml) + } - if (execution.getVariable(Prefix + "sdncResponseSuccess") == true) { // from sdnc util, Prefix+'sdncResponseSuccess' - execution.setVariable(Prefix + "isSdncDeactivateRollbackNeeded", true) - logger.debug("Successfully Validated Rpc SDNC Activate Response") + public void prepareRpcSDNCDeactivateRollback(DelegateExecution execution) { - } else { - logger.debug("Did NOT Successfully Validated Rpc SDNC Deactivate Response") - throw new BpmnError("MSOWorkflowException") - } + execution.setVariable("prefix",Prefix) - } + logger.trace("Inside prepareRpcSDNCDeactivateRollback() of DoDeleteNetworkInstance ") - public void prepareRpcSDNCDeactivateRollback(DelegateExecution execution) { + try { - execution.setVariable("prefix",Prefix) + // get variables + String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") + String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") + String deactivateSDNCResponse = execution.getVariable(Prefix + "deactivateSDNCResponse") + String networkId = utils.getNodeText(deactivateSDNCResponse, "network-id") + if (networkId == 'null') {networkId = ""} + String serviceInstanceId = utils.getNodeText(deleteNetworkInput, "service-instance-id") - logger.trace("Inside prepareRpcSDNCDeactivateRollback() of DoDeleteNetworkInstance ") - - try { + // 2. prepare rollback topology via SDNC Adapter SUBFLOW call + String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "activate", "CreateNetworkInstance", cloudRegionId, networkId, null) + String sndcTopologyRollbackRpcRequestAsString = utils.formatXml(sndcTopologyRollbackRpcRequest) + execution.setVariable(Prefix + "rollbackDeactivateSDNCRequest", sndcTopologyRollbackRpcRequestAsString) + logger.debug(" Preparing request for RPC SDNC Topology 'activate-CreateNetworkInstance' rollback . . . - " + "\n" + sndcTopologyRollbackRpcRequestAsString) - // get variables - String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) - String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") - String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") - String deactivateSDNCResponse = execution.getVariable(Prefix + "deactivateSDNCResponse") - String networkId = utils.getNodeText(deactivateSDNCResponse, "network-id") - if (networkId == 'null') {networkId = ""} - String serviceInstanceId = utils.getNodeText(deleteNetworkInput, "service-instance-id") - // 2. prepare rollback topology via SDNC Adapter SUBFLOW call - String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "activate", "CreateNetworkInstance", cloudRegionId, networkId, null) - String sndcTopologyRollbackRpcRequestAsString = utils.formatXml(sndcTopologyRollbackRpcRequest) - execution.setVariable(Prefix + "rollbackDeactivateSDNCRequest", sndcTopologyRollbackRpcRequestAsString) - logger.debug(" Preparing request for RPC SDNC Topology 'activate-CreateNetworkInstance' rollback . . . - " + "\n" + sndcTopologyRollbackRpcRequestAsString) + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRpcSDNCDeactivateRollback() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + } - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRpcSDNCDeactivateRollback() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + } - } + public void prepareRollbackData(DelegateExecution execution) { - } + execution.setVariable("prefix",Prefix) - public void prepareRollbackData(DelegateExecution execution) { - - execution.setVariable("prefix",Prefix) + logger.trace("Inside prepareRollbackData() of DoDeleteNetworkInstance ") - logger.trace("Inside prepareRollbackData() of DoDeleteNetworkInstance ") + try { - try { + Map<String, String> rollbackData = new HashMap<String, String>(); + String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest") + if (rollbackNetworkRequest != null) { + if (rollbackNetworkRequest != "") { + rollbackData.put("rollbackNetworkRequest", execution.getVariable(Prefix + "rollbackNetworkRequest")) + } + } + String rollbackDeactivateSDNCRequest = execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest") + if (rollbackDeactivateSDNCRequest != null) { + if (rollbackDeactivateSDNCRequest != "") { + rollbackData.put("rollbackDeactivateSDNCRequest", execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest")) + } + } + execution.setVariable("rollbackData", rollbackData) + logger.debug("** rollbackData : " + rollbackData) - Map<String, String> rollbackData = new HashMap<String, String>(); - String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest") - if (rollbackNetworkRequest != null) { - if (rollbackNetworkRequest != "") { - rollbackData.put("rollbackNetworkRequest", execution.getVariable(Prefix + "rollbackNetworkRequest")) - } - } - String rollbackDeactivateSDNCRequest = execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest") - if (rollbackDeactivateSDNCRequest != null) { - if (rollbackDeactivateSDNCRequest != "") { - rollbackData.put("rollbackDeactivateSDNCRequest", execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest")) - } - } - execution.setVariable("rollbackData", rollbackData) - logger.debug("** rollbackData : " + rollbackData) - - execution.setVariable("WorkflowException", execution.getVariable("WorkflowException")) - logger.debug("** WorkflowException : " + execution.getVariable("WorkflowException")) - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRollbackData() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - - } - - } + execution.setVariable("WorkflowException", execution.getVariable("WorkflowException")) + logger.debug("** WorkflowException : " + execution.getVariable("WorkflowException")) - public void postProcessResponse (DelegateExecution execution) { - - execution.setVariable("prefix", Prefix) - - logger.trace("Inside postProcessResponse of DoDeleteNetworkInstance ") - - try { - - logger.debug(" ***** Is Exception Encountered (isException)? : " + execution.getVariable(Prefix + "isException")) - if (execution.getVariable(Prefix + "isException") == false) { - execution.setVariable(Prefix + "Success", true) - execution.setVariable("WorkflowException", null) - if (execution.getVariable(Prefix + "isSilentSuccess") == true) { - execution.setVariable("rolledBack", false) - } else { - execution.setVariable("rolledBack", true) - } - prepareSuccessRollbackData(execution) // populate rollbackData - - } else { - execution.setVariable(Prefix + "Success", false) - execution.setVariable("rollbackData", null) - String exceptionMessage = " Exception encountered in MSO Bpmn. " - if (execution.getVariable("workflowException") != null) { // Output of Rollback flow. - logger.debug(" ***** workflowException: " + execution.getVariable("workflowException")) - WorkflowException wfex = execution.getVariable("workflowException") - exceptionMessage = wfex.getErrorMessage() - } else { - if (execution.getVariable(Prefix + "WorkflowException") != null) { - WorkflowException pwfex = execution.getVariable(Prefix + "WorkflowException") - exceptionMessage = pwfex.getErrorMessage() - } else { - if (execution.getVariable("WorkflowException") != null) { - WorkflowException pwfex = execution.getVariable("WorkflowException") - exceptionMessage = pwfex.getErrorMessage() - } - } - } - - // going to the Main flow: a-la-carte or macro - logger.debug(" ***** postProcessResponse(), BAD !!!") - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - throw new BpmnError("MSOWorkflowException") - - } - - } catch(BpmnError b){ - logger.debug("Rethrowing MSOWorkflowException") - throw b - - } catch (Exception ex) { - // caught exception - String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, postProcessResponse() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - throw new BpmnError("MSOWorkflowException") + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRollbackData() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) } - } - - public void prepareSuccessRollbackData(DelegateExecution execution) { - - execution.setVariable("prefix",Prefix) - - logger.trace("Inside prepareSuccessRollbackData() of DoDeleteNetworkInstance ") - - try { - - if (execution.getVariable("sdncVersion") != '1610') { - prepareRpcSDNCDeactivateRollback(execution) - prepareRpcSDNCUnassignRollback(execution) - } else { - prepareSDNCRollback(execution) - } - - Map<String, String> rollbackData = new HashMap<String, String>(); - String rollbackSDNCRequest = execution.getVariable(Prefix + "rollbackSDNCRequest") - if (rollbackSDNCRequest != null) { - if (rollbackSDNCRequest != "") { - rollbackData.put("rollbackSDNCRequest", execution.getVariable(Prefix + "rollbackSDNCRequest")) - } - } - String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest") - if (rollbackNetworkRequest != null) { - if (rollbackNetworkRequest != "") { - rollbackData.put("rollbackNetworkRequest", execution.getVariable(Prefix + "rollbackNetworkRequest")) - } - } - String rollbackDeactivateSDNCRequest = execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest") - if (rollbackDeactivateSDNCRequest != null) { - if (rollbackDeactivateSDNCRequest != "") { - rollbackData.put("rollbackDeactivateSDNCRequest", execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest")) - } - } - execution.setVariable("rollbackData", rollbackData) - - logger.debug("** rollbackData : " + rollbackData) - execution.setVariable("WorkflowException", null) + } + + public void postProcessResponse (DelegateExecution execution) { + + execution.setVariable("prefix", Prefix) + + logger.trace("Inside postProcessResponse of DoDeleteNetworkInstance ") + + try { + + logger.debug(" ***** Is Exception Encountered (isException)? : " + execution.getVariable(Prefix + "isException")) + if (execution.getVariable(Prefix + "isException") == false) { + execution.setVariable(Prefix + "Success", true) + execution.setVariable("WorkflowException", null) + if (execution.getVariable(Prefix + "isSilentSuccess") == true) { + execution.setVariable("rolledBack", false) + } else { + execution.setVariable("rolledBack", true) + } + prepareSuccessRollbackData(execution) // populate rollbackData + + } else { + execution.setVariable(Prefix + "Success", false) + execution.setVariable("rollbackData", null) + String exceptionMessage = " Exception encountered in MSO Bpmn. " + if (execution.getVariable("workflowException") != null) { // Output of Rollback flow. + logger.debug(" ***** workflowException: " + execution.getVariable("workflowException")) + WorkflowException wfex = execution.getVariable("workflowException") + exceptionMessage = wfex.getErrorMessage() + } else { + if (execution.getVariable(Prefix + "WorkflowException") != null) { + WorkflowException pwfex = execution.getVariable(Prefix + "WorkflowException") + exceptionMessage = pwfex.getErrorMessage() + } else { + if (execution.getVariable("WorkflowException") != null) { + WorkflowException pwfex = execution.getVariable("WorkflowException") + exceptionMessage = pwfex.getErrorMessage() + } + } + } + + // going to the Main flow: a-la-carte or macro + logger.debug(" ***** postProcessResponse(), BAD !!!") + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + throw new BpmnError("MSOWorkflowException") + + } + + } catch(BpmnError b){ + logger.debug("Rethrowing MSOWorkflowException") + throw b + + } catch (Exception ex) { + // caught exception + String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, postProcessResponse() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + throw new BpmnError("MSOWorkflowException") + } - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareSuccessRollbackData() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + } + + public void prepareSuccessRollbackData(DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + logger.trace("Inside prepareSuccessRollbackData() of DoDeleteNetworkInstance ") + + try { + + if (execution.getVariable("sdncVersion") != '1610') { + prepareRpcSDNCDeactivateRollback(execution) + prepareRpcSDNCUnassignRollback(execution) + } else { + prepareSDNCRollback(execution) + } + + Map<String, String> rollbackData = new HashMap<String, String>(); + String rollbackSDNCRequest = execution.getVariable(Prefix + "rollbackSDNCRequest") + if (rollbackSDNCRequest != null) { + if (rollbackSDNCRequest != "") { + rollbackData.put("rollbackSDNCRequest", execution.getVariable(Prefix + "rollbackSDNCRequest")) + } + } + String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest") + if (rollbackNetworkRequest != null) { + if (rollbackNetworkRequest != "") { + rollbackData.put("rollbackNetworkRequest", execution.getVariable(Prefix + "rollbackNetworkRequest")) + } + } + String rollbackDeactivateSDNCRequest = execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest") + if (rollbackDeactivateSDNCRequest != null) { + if (rollbackDeactivateSDNCRequest != "") { + rollbackData.put("rollbackDeactivateSDNCRequest", execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest")) + } + } + execution.setVariable("rollbackData", rollbackData) + + logger.debug("** rollbackData : " + rollbackData) + execution.setVariable("WorkflowException", null) + + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareSuccessRollbackData() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - } + } - } + } - public void prepareRpcSDNCUnassignRollback(DelegateExecution execution) { + public void prepareRpcSDNCUnassignRollback(DelegateExecution execution) { - execution.setVariable("prefix",Prefix) + execution.setVariable("prefix",Prefix) - logger.trace("Inside prepareRpcSDNCUnassignRollbac() of DoDeleteNetworkInstance ") + logger.trace("Inside prepareRpcSDNCUnassignRollbac() of DoDeleteNetworkInstance ") - try { + try { - // get variables - String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) - String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") + // get variables + String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") - String deleteSDNCResponse = execution.getVariable(Prefix + "deleteSDNCResponse") - String networkId = utils.getNodeText(deleteSDNCResponse, "network-id") - if (networkId == 'null') {networkId = ""} - String serviceInstanceId = utils.getNodeText(deleteNetworkInput, "service-instance-id") + String deleteSDNCResponse = execution.getVariable(Prefix + "deleteSDNCResponse") + String networkId = utils.getNodeText(deleteSDNCResponse, "network-id") + if (networkId == 'null') {networkId = ""} + String serviceInstanceId = utils.getNodeText(deleteNetworkInput, "service-instance-id") - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") - // 1. prepare delete topology via SDNC Adapter SUBFLOW call - String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "assign", "CreateNetworkInstance", cloudRegionId, networkId, null) - String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyRollbackRpcRequest) - logger.debug(sndcTopologyDeleteRequesAsString) - execution.setVariable(Prefix + "rollbackSDNCRequest", sndcTopologyDeleteRequesAsString) - logger.debug(Prefix + "rollbackSDNCRequest" + "\n" + sndcTopologyDeleteRequesAsString) - logger.debug(" Preparing request for RPC SDNC Topology 'assign-CreateNetworkInstance' rollback . . . - " + "\n" + sndcTopologyDeleteRequesAsString) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() + String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") + // 1. prepare delete topology via SDNC Adapter SUBFLOW call + String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "assign", "CreateNetworkInstance", cloudRegionId, networkId, null) + String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyRollbackRpcRequest) + logger.debug(sndcTopologyDeleteRequesAsString) + execution.setVariable(Prefix + "rollbackSDNCRequest", sndcTopologyDeleteRequesAsString) + logger.debug(Prefix + "rollbackSDNCRequest" + "\n" + sndcTopologyDeleteRequesAsString) + logger.debug(" Preparing request for RPC SDNC Topology 'assign-CreateNetworkInstance' rollback . . . - " + "\n" + sndcTopologyDeleteRequesAsString) - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRpcSDNCUnassignRollback() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRpcSDNCUnassignRollback() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - } + } - } + } - public void prepareSDNCRollback (DelegateExecution execution) { + public void prepareSDNCRollback (DelegateExecution execution) { - execution.setVariable("prefix", Prefix) + execution.setVariable("prefix", Prefix) - logger.trace("Inside prepareSDNCRollback of DoDeleteNetworkInstance ") + logger.trace("Inside prepareSDNCRollback of DoDeleteNetworkInstance ") - try { + try { - // get variables - String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) - String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") + // get variables + String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") - String networkId = "" - if (utils.nodeExists(deleteNetworkInput, "network-id")) { - networkId = utils.getNodeText(deleteNetworkInput, "network-id") - } - if (networkId == 'null') {networkId = ""} + String networkId = "" + if (utils.nodeExists(deleteNetworkInput, "network-id")) { + networkId = utils.getNodeText(deleteNetworkInput, "network-id") + } + if (networkId == 'null') {networkId = ""} - String serviceInstanceId = utils.getNodeText(deleteNetworkInput, "service-instance-id") + String serviceInstanceId = utils.getNodeText(deleteNetworkInput, "service-instance-id") - // get/set 'msoRequestId' and 'mso-request-id' - String requestId = execution.getVariable("msoRequestId") - if (requestId != null) { - execution.setVariable("mso-request-id", requestId) - } else { - requestId = execution.getVariable("mso-request-id") - } - execution.setVariable(Prefix + "requestId", requestId) + // get/set 'msoRequestId' and 'mso-request-id' + String requestId = execution.getVariable("msoRequestId") + if (requestId != null) { + execution.setVariable("mso-request-id", requestId) + } else { + requestId = execution.getVariable("mso-request-id") + } + execution.setVariable(Prefix + "requestId", requestId) - L3Network queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse") + L3Network queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse") - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") - // 1. prepare delete topology via SDNC Adapter SUBFLOW call - String sndcTopologyDeleteRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "rollback", "DisconnectNetworkRequest", cloudRegionId, networkId, queryAAIResponse, null) - String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyDeleteRequest) - logger.debug(sndcTopologyDeleteRequesAsString) - execution.setVariable(Prefix + "rollbackSDNCRequest", sndcTopologyDeleteRequesAsString) - logger.debug(Prefix + "rollbackSDNCRequest - " + "\n" + sndcTopologyDeleteRequesAsString) - logger.debug(" Preparing request for RPC SDNC Topology 'rollback-DisconnectNetworkRequest' rollback . . . - " + "\n" + sndcTopologyDeleteRequesAsString) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() + String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") + // 1. prepare delete topology via SDNC Adapter SUBFLOW call + String sndcTopologyDeleteRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "rollback", "DisconnectNetworkRequest", cloudRegionId, networkId, queryAAIResponse, null) + String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyDeleteRequest) + logger.debug(sndcTopologyDeleteRequesAsString) + execution.setVariable(Prefix + "rollbackSDNCRequest", sndcTopologyDeleteRequesAsString) + logger.debug(Prefix + "rollbackSDNCRequest - " + "\n" + sndcTopologyDeleteRequesAsString) + logger.debug(" Preparing request for RPC SDNC Topology 'rollback-DisconnectNetworkRequest' rollback . . . - " + "\n" + sndcTopologyDeleteRequesAsString) - } catch (Exception ex) { - // caught exception - String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareSDNCRollback() - " + ex.getMessage() - logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), exceptionMessage, - "BPMN", ErrorCode.UnknownError.getValue(), - "Exception is:\n" + ex); - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } catch (Exception ex) { + // caught exception + String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareSDNCRollback() - " + ex.getMessage() + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), exceptionMessage, + "BPMN", ErrorCode.UnknownError.getValue(), + "Exception is:\n" + ex); + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } + } - } + } - public void setExceptionFlag(DelegateExecution execution){ + public void setExceptionFlag(DelegateExecution execution){ - execution.setVariable("prefix",Prefix) + execution.setVariable("prefix",Prefix) - logger.trace("Inside setExceptionFlag() of DoDeleteNetworkInstance ") + logger.trace("Inside setExceptionFlag() of DoDeleteNetworkInstance ") - try { + try { - execution.setVariable(Prefix + "isException", true) + execution.setVariable(Prefix + "isException", true) - if (execution.getVariable("SavedWorkflowException1") != null) { - execution.setVariable(Prefix + "WorkflowException", execution.getVariable("SavedWorkflowException1")) - } else { - execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException")) - } - logger.debug(Prefix + "WorkflowException - " +execution.getVariable(Prefix + "WorkflowException")) + if (execution.getVariable("SavedWorkflowException1") != null) { + execution.setVariable(Prefix + "WorkflowException", execution.getVariable("SavedWorkflowException1")) + } else { + execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException")) + } + logger.debug(Prefix + "WorkflowException - " +execution.getVariable(Prefix + "WorkflowException")) - } catch(Exception ex){ - String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance flow. setExceptionFlag(): " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - } + } catch(Exception ex){ + String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance flow. setExceptionFlag(): " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + } - } + } - // ******************************* - // Build Error Section - // ******************************* + // ******************************* + // Build Error Section + // ******************************* - public void processJavaException(DelegateExecution execution){ + public void processJavaException(DelegateExecution execution){ - execution.setVariable("prefix",Prefix) - try{ - logger.debug("Caught a Java Exception") - logger.debug("Started processJavaException Method") - logger.debug("Variables List: " + execution.getVariables()) - execution.setVariable("UnexpectedError", "Caught a Java Lang Exception") // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception") + execution.setVariable("prefix",Prefix) + try{ + logger.debug("Caught a Java Exception") + logger.debug("Started processJavaException Method") + logger.debug("Variables List: " + execution.getVariables()) + execution.setVariable("UnexpectedError", "Caught a Java Lang Exception") // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception") - }catch(Exception e){ - logger.debug("Caught Exception during processJavaException Method: " + e) - execution.setVariable("UnexpectedError", "Exception in processJavaException method") // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method") - } - logger.debug("Completed processJavaException Method of " + Prefix) - } + }catch(Exception e){ + logger.debug("Caught Exception during processJavaException Method: " + e) + execution.setVariable("UnexpectedError", "Exception in processJavaException method") // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method") + } + logger.debug("Completed processJavaException Method of " + Prefix) + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollback.groovy deleted file mode 100644 index 36c145b0e0..0000000000 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollback.groovy +++ /dev/null @@ -1,338 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * 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.xml.XmlUtil -import groovy.json.* -import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.onap.so.bpmn.common.scripts.ExceptionUtil -import org.onap.so.bpmn.common.scripts.NetworkUtils -import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils -import org.onap.so.bpmn.common.scripts.VidUtils -import org.onap.so.bpmn.core.WorkflowException - - -import java.util.UUID; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils - -import org.slf4j.Logger -import org.slf4j.LoggerFactory - -/** - * This groovy class supports the <class>DoCreateNetworkInstanceRollback.bpmn</class> process. - * - */ -public class DoDeleteNetworkInstanceRollback extends AbstractServiceTaskProcessor { - private static final Logger logger = LoggerFactory.getLogger( DoDeleteNetworkInstanceRollback.class); - - String Prefix="DELNWKIR_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils(this) - NetworkUtils networkUtils = new NetworkUtils() - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - - def className = getClass().getSimpleName() - - /** - * This method is executed during the preProcessRequest task of the <class>DoDeleteNetworkInstanceRollback.bpmn</class> process. - * @param execution - */ - public InitializeProcessVariables(DelegateExecution execution){ - /* Initialize all the process variables in this block */ - - execution.setVariable(Prefix + "WorkflowException", null) - - execution.setVariable(Prefix + "rollbackDeactivateSDNCRequest", null) - execution.setVariable(Prefix + "rollbackDeactivateSDNCResponse", "") - execution.setVariable(Prefix + "rollbackDeactivateSDNCReturnCode", "") - - execution.setVariable(Prefix + "rollbackSDNCRequest", "") - execution.setVariable(Prefix + "rollbackSDNCResponse", "") - execution.setVariable(Prefix + "rollbackSDNCReturnCode", "") - - execution.setVariable(Prefix + "rollbackNetworkRequest", null) - execution.setVariable(Prefix + "rollbackNetworkResponse", "") - execution.setVariable(Prefix + "rollbackNetworkReturnCode", "") - - execution.setVariable(Prefix + "Success", false) - execution.setVariable(Prefix + "fullRollback", false) - - } - - // ************************************************** - // Pre or Prepare Request Section - // ************************************************** - /** - * This method is executed during the preProcessRequest task of the <class>DoDeleteNetworkInstanceRollback.bpmn</class> process. - * @param execution - */ - public void preProcessRequest (DelegateExecution execution) { - - execution.setVariable("prefix",Prefix) - - logger.trace("Inside preProcessRequest() of " + className + ".groovy ") - - try { - // initialize flow variables - InitializeProcessVariables(execution) - - // GET Incoming request/variables - String rollbackDeactivateSDNCRequest = null - String rollbackSDNCRequest = null - String rollbackNetworkRequest = null - - Map<String, String> rollbackData = execution.getVariable("rollbackData") - if (rollbackData != null && rollbackData instanceof Map) { - - if(rollbackData.containsKey("rollbackDeactivateSDNCRequest")) { - rollbackDeactivateSDNCRequest = rollbackData["rollbackDeactivateSDNCRequest"] - } - - if(rollbackData.containsKey("rollbackSDNCRequest")) { - rollbackSDNCRequest = rollbackData["rollbackSDNCRequest"] - } - - if(rollbackData.containsKey("rollbackNetworkRequest")) { - rollbackNetworkRequest = rollbackData["rollbackNetworkRequest"] - } - } - - execution.setVariable(Prefix + "rollbackNetworkRequest", rollbackNetworkRequest) - execution.setVariable(Prefix + "rollbackSDNCRequest", rollbackSDNCRequest) - execution.setVariable(Prefix + "rollbackDeactivateSDNCRequest", rollbackDeactivateSDNCRequest) - logger.debug("'rollbackData': " + '\n' + execution.getVariable("rollbackData")) - - String sdncVersion = execution.getVariable("sdncVersion") - logger.debug("sdncVersion? : " + sdncVersion) - - // PO Authorization Info / headers Authorization= - String basicAuthValuePO = UrnPropertiesReader.getVariable("mso.adapters.po.auth",execution) - try { - def encodedString = utils.getBasicAuth(basicAuthValuePO, UrnPropertiesReader.getVariable("mso.msoKey", execution)) - execution.setVariable("BasicAuthHeaderValuePO",encodedString) - execution.setVariable("BasicAuthHeaderValueSDNC", encodedString) - - } catch (IOException ex) { - String exceptionMessage = "Exception Encountered in DoCreateNetworkInstance, PreProcessRequest() - " - String dataErrorMessage = exceptionMessage + " Unable to encode PO/SDNC user/password string - " + ex.getMessage() - logger.debug(dataErrorMessage ) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - - if (execution.getVariable("SavedWorkflowException1") != null) { - execution.setVariable(Prefix + "WorkflowException", execution.getVariable("SavedWorkflowException1")) - } else { - execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException")) - } - logger.debug("*** WorkflowException : " + execution.getVariable(Prefix + "WorkflowException")) - if(execution.getVariable(Prefix + "WorkflowException") != null) { - // called by: DoCreateNetworkInstance, partial rollback - execution.setVariable(Prefix + "fullRollback", false) - - } else { - // called by: Macro - Full Rollback, WorkflowException = null - execution.setVariable(Prefix + "fullRollback", true) - - } - - logger.debug("*** fullRollback? : " + execution.getVariable(Prefix + "fullRollback")) - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - sendSyncError(execution) - // caught exception - String exceptionMessage = "Exception Encountered in PreProcessRequest() of " + className + ".groovy ***** : " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void validateRollbackResponses (DelegateExecution execution) { - - execution.setVariable("prefix",Prefix) - - logger.trace("Inside validateRollbackResponses() of DoDeleteNetworkInstanceRollback ") - - try { - - // validate SDNC activate response - String rollbackDeactivateSDNCMessages = "" - String rollbackDeactivateSDNCReturnCode = "200" - if (execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest") != null) { - rollbackDeactivateSDNCReturnCode = execution.getVariable(Prefix + "rollbackDeactivateSDNCReturnCode") - String rollbackDeactivateSDNCResponse = execution.getVariable(Prefix + "rollbackDeactivateSDNCResponse") - String rollbackDeactivateSDNCReturnInnerCode = "" - rollbackDeactivateSDNCResponse = rollbackDeactivateSDNCResponse.replace('$', '').replace('<?xml version="1.0" encoding="UTF-8"?>', "") - if (rollbackDeactivateSDNCReturnCode == "200") { - if (utils.nodeExists(rollbackDeactivateSDNCResponse, "response-code")) { - rollbackDeactivateSDNCReturnInnerCode = utils.getNodeText(rollbackDeactivateSDNCResponse, "response-code") - if (rollbackDeactivateSDNCReturnInnerCode == "200" || rollbackDeactivateSDNCReturnInnerCode == "" || rollbackDeactivateSDNCReturnInnerCode == "0") { - rollbackDeactivateSDNCMessages = " + SNDC deactivate rollback completed." - } else { - rollbackDeactivateSDNCMessages = " + SDNC deactivate rollback failed. " - } - } else { - rollbackDeactivateSDNCMessages = " + SNDC deactivate rollback completed." - } - } else { - rollbackDeactivateSDNCMessages = " + SDNC deactivate rollback failed. " - } - logger.debug(" SDNC deactivate rollback Code - " + rollbackDeactivateSDNCReturnCode) - logger.debug(" SDNC deactivate rollback Response - " + rollbackDeactivateSDNCResponse) - } - - // validate SDNC rollback response - String rollbackSdncErrorMessages = "" - String rollbackSDNCReturnCode = "200" - if (execution.getVariable(Prefix + "rollbackSDNCRequest") != null) { - rollbackSDNCReturnCode = execution.getVariable(Prefix + "rollbackSDNCReturnCode") - String rollbackSDNCResponse = execution.getVariable(Prefix + "rollbackSDNCResponse") - String rollbackSDNCReturnInnerCode = "" - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - rollbackSDNCResponse = rollbackSDNCResponse.replace('$', '').replace('<?xml version="1.0" encoding="UTF-8"?>', "") - if (rollbackSDNCReturnCode == "200") { - if (utils.nodeExists(rollbackSDNCResponse, "response-code")) { - rollbackSDNCReturnInnerCode = utils.getNodeText(rollbackSDNCResponse, "response-code") - if (rollbackSDNCReturnInnerCode == "200" || rollbackSDNCReturnInnerCode == "" || rollbackSDNCReturnInnerCode == "0") { - rollbackSdncErrorMessages = " + SNDC unassign rollback completed." - } else { - rollbackSdncErrorMessages = " + SDNC unassign rollback failed. " - } - } else { - rollbackSdncErrorMessages = " + SNDC unassign rollback completed." - } - } else { - rollbackSdncErrorMessages = " + SDNC unassign rollback failed. " - } - logger.debug(" SDNC assign rollback Code - " + rollbackSDNCReturnCode) - logger.debug(" SDNC assign rollback Response - " + rollbackSDNCResponse) - } - - // validate PO network rollback response - String rollbackNetworkErrorMessages = "" - String rollbackNetworkReturnCode = "200" - if (execution.getVariable(Prefix + "rollbackNetworkRequest") != null) { - rollbackNetworkReturnCode = execution.getVariable(Prefix + "rollbackNetworkReturnCode") - String rollbackNetworkResponse = execution.getVariable(Prefix + "rollbackNetworkResponse") - if (rollbackNetworkReturnCode != "200") { - rollbackNetworkErrorMessages = " + PO Network rollback failed. " - } else { - rollbackNetworkErrorMessages = " + PO Network rollback completed." - } - - logger.debug(" NetworkRollback Code - " + rollbackNetworkReturnCode) - logger.debug(" NetworkRollback Response - " + rollbackNetworkResponse) - } - - String statusMessage = "" - int errorCode = 7000 - logger.debug("*** fullRollback? : " + execution.getVariable(Prefix + "fullRollback")) - if (execution.getVariable(Prefix + "fullRollback") == false) { - WorkflowException wfe = execution.getVariable(Prefix + "WorkflowException") // original WorkflowException - if (wfe != null) { - statusMessage = wfe.getErrorMessage() - errorCode = wfe.getErrorCode() - } else { - statusMessage = "See Previous Camunda flows for cause of Error: Undetermined Exception." - errorCode = '7000' - } - - // set if all rolledbacks are successful - if (rollbackDeactivateSDNCReturnCode == "200" && rollbackNetworkReturnCode == "200" && rollbackSDNCReturnCode == "200") { - execution.setVariable("rolledBack", true) - execution.setVariable("wasDeleted", true) - - } else { - execution.setVariable("rolledBack", false) - execution.setVariable("wasDeleted", true) - } - - statusMessage = statusMessage + rollbackDeactivateSDNCMessages + rollbackNetworkErrorMessages + rollbackSdncErrorMessages - logger.debug("Final DoDeleteNetworkInstanceRollback status message: " + statusMessage) - String processKey = getProcessKey(execution); - WorkflowException exception = new WorkflowException(processKey, errorCode, statusMessage); - execution.setVariable("workflowException", exception); - - } else { - // rollback due to failures in Main flow (Macro or a-ala-carte) - Full rollback - if (rollbackDeactivateSDNCReturnCode == "200" && rollbackNetworkReturnCode == "200" && rollbackSDNCReturnCode == "200") { - execution.setVariable("rollbackSuccessful", true) - execution.setVariable("rollbackError", false) - } else { - String exceptionMessage = "Network Delete Rollback was not Successful. " - logger.debug(exceptionMessage) - execution.setVariable("rollbackSuccessful", false) - execution.setVariable("rollbackError", true) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - throw new BpmnError("MSOWorkflowException") - } - } - - } catch (Exception ex) { - String errorMessage = "See Previous Camunda flows for cause of Error: Undetermined Exception." - String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstanceRollback flow. validateRollbackResponses() - " + errorMessage + ": " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - // ******************************* - // Build Error Section - // ******************************* - - - - public void processJavaException(DelegateExecution execution){ - - execution.setVariable("prefix",Prefix) - - try{ - logger.debug("Caught a Java Exception in " + Prefix) - logger.debug("Started processJavaException Method") - logger.debug("Variables List: " + execution.getVariables()) - execution.setVariable("UnexpectedError", "Caught a Java Lang Exception - " + Prefix) // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception") - - }catch(Exception e){ - logger.debug("Caught Exception during processJavaException Method: " + e) - execution.setVariable("UnexpectedError", "Exception in processJavaException method - " + Prefix) // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method" + Prefix) - } - logger.debug("Completed processJavaException Method in " + Prefix) - } - -} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy index 1acadbdad8..cda7c321ac 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy @@ -23,11 +23,15 @@ package org.onap.so.bpmn.infrastructure.scripts import static org.apache.commons.lang3.StringUtils.*; - -import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.ServiceInstance +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils @@ -35,17 +39,10 @@ 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.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.slf4j.Logger import org.slf4j.LoggerFactory import org.springframework.web.util.UriUtils; -import groovy.json.* - /** * This groovy class supports the <class>DoDeleteServiceInstance.bpmn</class> process. * @@ -294,7 +291,7 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor { execution.setVariable("GENGS_FoundIndicator", true) execution.setVariable("GENGS_siResourceLink", uri.build().toString()) Map<String, String> keys = uri.getURIKeys() - String globalSubscriberId = execution.getVariable("globalSubscriberId") + String globalSubscriberId = execution.getVariable(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId) if(isBlank(globalSubscriberId)){ globalSubscriberId = keys.get("global-customer-id") execution.setVariable("globalSubscriberId", globalSubscriberId) 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 index 76086dab49..5354d52fce 100644 --- 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 @@ -28,10 +28,10 @@ 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.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory 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/DoDeleteVFCNetworkServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy index 28f4460d71..42f4cb7bd7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy @@ -29,9 +29,9 @@ 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.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 org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.slf4j.Logger import org.slf4j.LoggerFactory import org.onap.logging.filter.base.ONAPComponents; 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 e776eaf422..33a1ece091 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 @@ -39,11 +39,11 @@ 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.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.aaiclient.client.aai.AAIObjectPlurals +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory 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/DoDeleteVfModuleFromVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy index 350de4a03d..786cd3d747 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 @@ -40,12 +40,12 @@ 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.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.aaiclient.client.graphinventory.entities.uri.Depth +import org.onap.aaiclient.client.aai.AAIObjectPlurals +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory 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/DoDeleteVfModuleVolumeV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy index c419f0dc7d..355b5f77c0 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy @@ -22,12 +22,16 @@ package org.onap.so.bpmn.infrastructure.scripts -import org.apache.commons.lang3.StringUtils +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.Relationship -import org.onap.aai.domain.yang.RelationshipData import org.onap.aai.domain.yang.VolumeGroup +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.Relationships +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder import org.onap.so.bpmn.common.scripts.AaiUtil import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil @@ -35,15 +39,9 @@ import org.onap.so.bpmn.common.scripts.MsoUtils 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.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.AAIUriFactory import org.onap.so.constants.Defaults import org.slf4j.Logger import org.slf4j.LoggerFactory -import javax.ws.rs.NotFoundException class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ private static final Logger logger = LoggerFactory.getLogger( DoDeleteVfModuleVolumeV2.class); @@ -180,7 +178,7 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume Group ${volumeGroupId} currently in use - found vf-module relationship.") } for(AAIResourceUri aaiResourceUri: relationships.get().getRelatedAAIUris(AAIObjectType.TENANT)){ - volumeGroupTenantId = aaiResourceUri.getURIKeys().get("tenant-id") + volumeGroupTenantId = aaiResourceUri.getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId) } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnf.groovy index 25303473c7..25fbc93c0a 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnf.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnf.groovy @@ -34,12 +34,12 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.VidUtils import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.client.graphinventory.entities.uri.Depth; -import org.onap.so.client.aai.AAIResourcesClient -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.onap.aaiclient.client.graphinventory.entities.uri.Depth; +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.w3c.dom.Document import org.w3c.dom.Element import org.w3c.dom.Node 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 ff58fd567d..2a0cb5e610 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 @@ -41,10 +41,10 @@ import org.onap.so.bpmn.core.domain.ModuleResource import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.domain.VnfResource import org.onap.so.bpmn.core.json.JsonUtils -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.aaiclient.client.graphinventory.entities.uri.Depth +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.aai.AAIObjectType import org.onap.logging.filter.base.ErrorCode 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/DoSendCommandToNSSMF.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoSendCommandToNSSMF.groovy index 5acc016c7b..a85f5d8ab3 100644 --- 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 @@ -25,17 +25,13 @@ 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 @@ -43,7 +39,6 @@ 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 /** @@ -60,7 +55,8 @@ class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor { JsonUtils jsonUtil = new JsonUtils() VidUtils vidUtils = new VidUtils(this) SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - OofInfraUtils oofInfraUtils = new OofInfraUtils() + + private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil) /** * This method gets and validates the incoming @@ -99,7 +95,7 @@ class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor { execution.setVariable("msoRequestId", requestId) String operationType = execution.getVariable("operationType") - execution.setVariable("operationType", operationType) + execution.setVariable("operationType", operationType.toLowerCase()) logger.debug("Incoming operationType is: " + operationType) if (operationType == "activation") { @@ -123,6 +119,7 @@ class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor { } 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()) @@ -131,6 +128,7 @@ class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor { } return new Gson().toJson(map) } + public void getNSSIformlist(DelegateExecution execution) { String nssiMap = execution.getVariable("DonssiMap") @@ -179,6 +177,7 @@ class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor { execution.setVariable("activationIndex", indexcurrent)} } + /** * get vendor Info * @param execution @@ -204,6 +203,7 @@ class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor { } logger.debug("***** Exit processDecomposition *****") } + public void UpdateIndex(DelegateExecution execution) { def activationIndex = execution.getVariable("activationIndex") int activateNumberSlice = execution.getVariable("activateNumberSlice") as Integer @@ -225,7 +225,7 @@ class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor { String operationId = UUID.randomUUID().toString() String operationType = execution.getVariable("operationType") String userId = "" - String result = (operationType.equals("activation"))? "ACTIVATING": "DEACTIVATING" + String result = (operationType.equalsIgnoreCase("activation"))? "ACTIVATING": "DEACTIVATING" int progress = rate String reason = "" String operationContent = "Service activation in progress" @@ -269,24 +269,25 @@ class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor { } logger.trace("finished Activate Slice") } + public void WaitForReturn(DelegateExecution execution) { //logger.debug("Query : "+ Jobid) - def miniute=execution.getVariable("miniute") + String 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 miniute=execution.getVariable("miniute") String vendor = execution.getVariable("vendor") - String jobstatus ="error" + String jobstatus logger.debug("Query the jobid activation of SNSSAI: "+ Jobid) @@ -306,66 +307,46 @@ class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor { 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.") - } + String nssmfRequest = mapper.writeValueAsString(jobStatusRequest) + String isActivateSuccessfull + + String urlString = "/api/rest/provMns/v1/NSS/jobs/" +Jobid + + JobStatusResponse jobStatusResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest, JobStatusResponse.class) + + if (jobStatusResponse != null) { + 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, 7000, "Received a timeout job status Response from NSSMF.") + } + } else { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a Bad job status Response from NSSMF.") + isActivateSuccessfull = false + execution.setVariable("isActivateSuccessfull", isActivateSuccessfull) + } } + public void SendCommandToNssmf(DelegateExecution execution) { String snssai= execution.getVariable("snssai") @@ -391,49 +372,28 @@ class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor { actRequest.setActDeActNssi(actNssi); actRequest.setEsrInfo(esr) - ObjectMapper mapper = new ObjectMapper(); - String json = mapper.writeValueAsString(actRequest); - - - String urlString = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution) + ObjectMapper mapper = new ObjectMapper() + String nssmfRequest = mapper.writeValueAsString(actRequest) - //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) + String urlString = "/api/rest/provMns/v1/NSS/" + snssai + "/" + operationType.toLowerCase() - HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL) - Response httpResponse = httpClient.post(json) + NssiResponse nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest, NssiResponse.class) - 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) + if (nssmfResponse != null) { + String isNSSIActivated = "true" + execution.setVariable("isNSSIActivated", isNSSIActivated) + String jobId = nssmfResponse.getJobId() ?: "" + execution.setVariable("JobId", jobId) + } else { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a Bad Response from NSSMF.") + String isNSSIActivated = "false" + execution.setVariable("isNSSIActivated", isNSSIActivated) + execution.setVariable("isNSSIActivate","false") + } } - 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") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy index 508131279a..6b91fec03e 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy @@ -20,8 +20,8 @@ * ============LICENSE_END========================================================= */ package org.onap.so.bpmn.infrastructure.scripts -import org.onap.so.client.aai.AAIResourcesClient -import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; import static org.apache.commons.lang3.StringUtils.*; @@ -36,11 +36,11 @@ import org.onap.so.bpmn.core.RollbackData import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.domain.Resource 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.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.springframework.web.util.UriUtils; 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/DoUpdateE2EServiceInstanceRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstanceRollback.groovy index 0a635c6bc6..154de6b887 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstanceRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstanceRollback.groovy @@ -32,11 +32,11 @@ 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.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.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.slf4j.Logger import org.slf4j.LoggerFactory 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/DoUpdateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy index 6162780b27..cf7bb22442 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy @@ -22,12 +22,22 @@ package org.onap.so.bpmn.infrastructure.scripts; -import javax.ws.rs.core.UriBuilder -import javax.xml.parsers.DocumentBuilder -import javax.xml.parsers.DocumentBuilderFactory -import org.apache.commons.lang3.* +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.L3Network +import org.onap.aai.domain.yang.NetworkPolicy +import org.onap.aai.domain.yang.RouteTableReference +import org.onap.aai.domain.yang.RouteTarget +import org.onap.aai.domain.yang.Subnet +import org.onap.aai.domain.yang.VpnBinding +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +import org.onap.aaiclient.client.graphinventory.entities.uri.Depth import org.onap.so.bpmn.common.scripts.AaiUtil import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil @@ -38,33 +48,10 @@ import org.onap.so.bpmn.common.scripts.VidUtils 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.uri.AAIResourceUri -import org.onap.so.client.aai.entities.uri.AAIUriFactory -import org.onap.so.client.aai.entities.AAIResultWrapper -import org.onap.so.client.graphinventory.entities.uri.Depth import org.onap.so.constants.Defaults import org.slf4j.Logger import org.slf4j.LoggerFactory - -import org.springframework.web.util.UriUtils -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 org.onap.aai.domain.yang.VpnBinding -import org.onap.aai.domain.yang.L3Network -import org.onap.aai.domain.yang.NetworkPolicy -import org.onap.aai.domain.yang.RouteTableReference -import org.onap.aai.domain.yang.RouteTarget -import org.onap.aai.domain.yang.Subnet -import javax.ws.rs.NotFoundException - import groovy.json.* -import groovy.xml.XmlUtil /** * This groovy class supports the <class>DoUpdateNetworkInstance.bpmn</class> process. @@ -73,1107 +60,1027 @@ import groovy.xml.XmlUtil public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { private static final Logger logger = LoggerFactory.getLogger( DoUpdateNetworkInstance.class); - String Prefix="UPDNETI_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils(this) - NetworkUtils networkUtils = new NetworkUtils() - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - - /** - * This method is executed during the preProcessRequest task of the <class>DoUpdateNetworkInstance.bpmn</class> process. - * @param execution - */ - public InitializeProcessVariables(DelegateExecution execution){ - /* Initialize all the process variables in this block */ - - execution.setVariable(Prefix + "messageId", "") - execution.setVariable("BasicAuthHeaderValuePO", "") - execution.setVariable("BasicAuthHeaderValueSDNC", "") - execution.setVariable(Prefix + "networkRequest", "") - execution.setVariable(Prefix + "networkInputs", "") - execution.setVariable(Prefix + "networkOutputs", "") - execution.setVariable(Prefix + "requestId", "") - execution.setVariable(Prefix + "source", "") - execution.setVariable(Prefix + "networkId", "") - - execution.setVariable(Prefix + "isPONR", false) // Point-of-no-return, means, rollback is not needed - - // AAI query Cloud Region - execution.setVariable(Prefix + "queryCloudRegionRequest","") - execution.setVariable(Prefix + "queryCloudRegionReturnCode","") - execution.setVariable(Prefix + "queryCloudRegionResponse","") - execution.setVariable(Prefix + "cloudRegionPo","") - execution.setVariable(Prefix + "cloudRegionSdnc","") - execution.setVariable(Prefix + "isCloudRegionGood", false) - - // AAI query Id - execution.setVariable(Prefix + "queryIdAAIRequest","") - execution.setVariable(Prefix + "queryIdAAIResponse", "") - execution.setVariable(Prefix + "aaiIdReturnCode", "") - - // AAI query vpn binding - execution.setVariable(Prefix + "queryVpnBindingAAIRequest","") - execution.setVariable(Prefix + "queryVpnBindingAAIResponse", "") - execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "") - execution.setVariable(Prefix + "vpnBindings", null) - execution.setVariable(Prefix + "vpnCount", 0) - execution.setVariable(Prefix + "routeCollection", "") - - // AAI query network policy - execution.setVariable(Prefix + "queryNetworkPolicyAAIRequest","") - execution.setVariable(Prefix + "queryNetworkPolicyAAIResponse", "") - execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "") - execution.setVariable(Prefix + "networkPolicyUriList", null) - execution.setVariable(Prefix + "networkPolicyCount", 0) - execution.setVariable(Prefix + "networkCollection", "") - - // AAI query route table reference - execution.setVariable(Prefix + "queryNetworkTableRefAAIRequest","") - execution.setVariable(Prefix + "queryNetworkTableRefAAIResponse", "") - execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "") - execution.setVariable(Prefix + "networkTableRefUriList", null) - execution.setVariable(Prefix + "networkTableRefCount", 0) - execution.setVariable(Prefix + "tableRefCollection", "") - - // AAI requery Id - execution.setVariable(Prefix + "requeryIdAAIRequest","") - execution.setVariable(Prefix + "requeryIdAAIResponse", "") - execution.setVariable(Prefix + "aaiRequeryIdReturnCode", "") - - // AAI update contrail - execution.setVariable(Prefix + "updateContrailAAIUrlRequest","") - execution.setVariable(Prefix + "updateContrailAAIPayloadRequest","") - execution.setVariable(Prefix + "updateContrailAAIResponse", "") - execution.setVariable(Prefix + "aaiUpdateContrailReturnCode", "") - - execution.setVariable(Prefix + "updateNetworkRequest", "") - execution.setVariable(Prefix + "updateNetworkResponse", "") - execution.setVariable(Prefix + "rollbackNetworkRequest", "") - execution.setVariable(Prefix + "networkReturnCode", "") - execution.setVariable(Prefix + "isNetworkRollbackNeeded", false) - - execution.setVariable(Prefix + "changeAssignSDNCRequest", "") - execution.setVariable(Prefix + "changeAssignSDNCResponse", "") - execution.setVariable(Prefix + "rollbackSDNCRequest", "") - execution.setVariable(Prefix + "sdncReturnCode", "") - execution.setVariable(Prefix + "isSdncRollbackNeeded", false) - execution.setVariable(Prefix + "sdncResponseSuccess", false) - - execution.setVariable(Prefix + "isVnfBindingPresent", false) - execution.setVariable(Prefix + "Success", false) - execution.setVariable(Prefix + "serviceInstanceId", "") - - execution.setVariable(Prefix + "isException", false) - - } - - // ************************************************** - // Pre or Prepare Request Section - // ************************************************** - /** - * This method is executed during the preProcessRequest task of the <class>DoUpdateNetworkInstance.bpmn</class> process. - * @param execution - */ - public void preProcessRequest (DelegateExecution execution) { - - execution.setVariable("prefix",Prefix) - - logger.trace("Inside preProcessRequest DoUpdateNetworkInstance Request ") - - try { - // initialize flow variables - InitializeProcessVariables(execution) - - // GET Incoming request & validate 3 kinds of format. - execution.setVariable("action", "UPDATE") - String networkRequest = execution.getVariable("bpmnRequest") - if (networkRequest != null) { - if (networkRequest.contains("requestDetails")) { - // JSON format request is sent, create xml - try { - def prettyJson = JsonOutput.prettyPrint(networkRequest.toString()) - logger.debug(" Incoming message formatted . . . : " + '\n' + prettyJson) - networkRequest = vidUtils.createXmlNetworkRequestInfra(execution, networkRequest) - - } catch (Exception ex) { - String dataErrorMessage = " Invalid json format Request - " + ex.getMessage() - logger.debug(dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - } else { - // XML format request is sent - - } - } else { - // vIPR format request is sent, create xml from individual variables - networkRequest = vidUtils.createXmlNetworkRequestInstance(execution) - } - - networkRequest = utils.formatXml(networkRequest) - logger.debug(networkRequest) - execution.setVariable(Prefix + "networkRequest", networkRequest) - logger.debug(" network-request - " + '\n' + networkRequest) - - // validate 'disableRollback' (aka, 'suppressRollback') - boolean rollbackEnabled = networkUtils.isRollbackEnabled(execution, networkRequest) - execution.setVariable(Prefix + "rollbackEnabled", rollbackEnabled) - logger.debug(Prefix + "rollbackEnabled - " + rollbackEnabled) - - String networkInputs = utils.getNodeXml(networkRequest, "network-inputs", false).replace("tag0:","").replace(":tag0","") - execution.setVariable(Prefix + "networkInputs", networkInputs) - logger.debug(Prefix + "networkInputs - " + '\n' + networkInputs) - - // prepare messageId - String messageId = execution.getVariable(Prefix + "messageId") // for testing - if (messageId == null || messageId == "") { - messageId = UUID.randomUUID() - logger.debug(" UPDNETI_messageId, random generated: " + messageId) - } else { - logger.debug(" UPDNETI_messageId, pre-assigned: " + messageId) - } - execution.setVariable(Prefix + "messageId", messageId) - - String source = utils.getNodeText(networkRequest, "source") - execution.setVariable(Prefix + "source", source) - logger.debug(Prefix + "source - " + source) - - String networkId = "" - if (utils.nodeExists(networkRequest, "network-id")) { - networkId = utils.getNodeText(networkRequest, "network-id") - if (networkId == 'null' || networkId == "") { - sendSyncError(execution) - // missing value of networkId - String dataErrorMessage = "Variable 'network-id' value/element is missing." - logger.debug(" Invalid Request - " + dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - } - - String lcpCloudRegion = "" - if (utils.nodeExists(networkRequest, "aic-cloud-region")) { - lcpCloudRegion = utils.getNodeText(networkRequest, "aic-cloud-region") - if ((lcpCloudRegion == 'null') || (lcpCloudRegion == "")) { - sendSyncError(execution) - String dataErrorMessage = "requestDetails has missing 'aic-cloud-region' value/element." - logger.debug(" Invalid Request - " + dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - } - - String serviceInstanceId = "" - if (utils.nodeExists(networkRequest, "service-instance-id")) { - serviceInstanceId = utils.getNodeText(networkRequest, "service-instance-id") - if ((serviceInstanceId == 'null') || (lcpCloudRegion == "")) { - sendSyncError(execution) - String dataErrorMessage = "Variable 'serviceInstanceId' value/element is missing." - logger.debug(" Invalid Request - " + dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - } - - // PO Authorization Info / headers Authorization= - String basicAuthValuePO = UrnPropertiesReader.getVariable("mso.adapters.po.auth",execution) - - - try { - def encodedString = utils.getBasicAuth(basicAuthValuePO, UrnPropertiesReader.getVariable("mso.msoKey", execution)) - execution.setVariable("BasicAuthHeaderValuePO",encodedString) - execution.setVariable("BasicAuthHeaderValueSDNC", encodedString) - - } catch (IOException ex) { - String exceptionMessage = "Exception Encountered in DoUpdateNetworkInstance, PreProcessRequest() - " - String dataErrorMessage = exceptionMessage + " Unable to encode PO/SDNC user/password string - " + ex.getMessage() - logger.debug(dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - - // Set variables for Generic Get Sub Flow use - execution.setVariable(Prefix + "serviceInstanceId", serviceInstanceId) - logger.debug(Prefix + "serviceInstanceId - " + serviceInstanceId) - - logger.debug(" Url for SDNC adapter: " + UrnPropertiesReader.getVariable("mso.adapters.sdnc.endpoint",execution)) - - String sdncVersion = execution.getVariable("sdncVersion") - logger.debug("sdncVersion? : " + sdncVersion) - - // build 'networkOutputs' - networkId = utils.getNodeText(networkRequest, "network-id") - if ((networkId == null) || (networkId == "null")) { - networkId = "" - } - String networkName = utils.getNodeText(networkRequest, "network-name") - if ((networkName == null) || (networkName == "null")) { - networkName = "" - } - String networkOutputs = - """<network-outputs> + String Prefix="UPDNETI_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + VidUtils vidUtils = new VidUtils(this) + NetworkUtils networkUtils = new NetworkUtils() + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() + + /** + * This method is executed during the preProcessRequest task of the <class>DoUpdateNetworkInstance.bpmn</class> process. + * @param execution + */ + public InitializeProcessVariables(DelegateExecution execution){ + /* Initialize all the process variables in this block */ + + execution.setVariable(Prefix + "messageId", "") + execution.setVariable("BasicAuthHeaderValuePO", "") + execution.setVariable("BasicAuthHeaderValueSDNC", "") + execution.setVariable(Prefix + "networkRequest", "") + execution.setVariable(Prefix + "networkInputs", "") + execution.setVariable(Prefix + "networkOutputs", "") + execution.setVariable(Prefix + "requestId", "") + execution.setVariable(Prefix + "source", "") + execution.setVariable(Prefix + "networkId", "") + + execution.setVariable(Prefix + "isPONR", false) // Point-of-no-return, means, rollback is not needed + + // AAI query Cloud Region + execution.setVariable(Prefix + "queryCloudRegionRequest","") + execution.setVariable(Prefix + "queryCloudRegionReturnCode","") + execution.setVariable(Prefix + "queryCloudRegionResponse","") + execution.setVariable(Prefix + "cloudRegionPo","") + execution.setVariable(Prefix + "cloudRegionSdnc","") + execution.setVariable(Prefix + "isCloudRegionGood", false) + + // AAI query Id + execution.setVariable(Prefix + "queryIdAAIRequest","") + execution.setVariable(Prefix + "queryIdAAIResponse", "") + execution.setVariable(Prefix + "aaiIdReturnCode", "") + + // AAI query vpn binding + execution.setVariable(Prefix + "queryVpnBindingAAIRequest","") + execution.setVariable(Prefix + "queryVpnBindingAAIResponse", "") + execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "") + execution.setVariable(Prefix + "vpnBindings", null) + execution.setVariable(Prefix + "vpnCount", 0) + execution.setVariable(Prefix + "routeCollection", "") + + // AAI query network policy + execution.setVariable(Prefix + "queryNetworkPolicyAAIRequest","") + execution.setVariable(Prefix + "queryNetworkPolicyAAIResponse", "") + execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "") + execution.setVariable(Prefix + "networkPolicyUriList", null) + execution.setVariable(Prefix + "networkPolicyCount", 0) + execution.setVariable(Prefix + "networkCollection", "") + + // AAI query route table reference + execution.setVariable(Prefix + "queryNetworkTableRefAAIRequest","") + execution.setVariable(Prefix + "queryNetworkTableRefAAIResponse", "") + execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "") + execution.setVariable(Prefix + "networkTableRefUriList", null) + execution.setVariable(Prefix + "networkTableRefCount", 0) + execution.setVariable(Prefix + "tableRefCollection", "") + + // AAI requery Id + execution.setVariable(Prefix + "requeryIdAAIRequest","") + execution.setVariable(Prefix + "requeryIdAAIResponse", "") + execution.setVariable(Prefix + "aaiRequeryIdReturnCode", "") + + // AAI update contrail + execution.setVariable(Prefix + "updateContrailAAIUrlRequest","") + execution.setVariable(Prefix + "updateContrailAAIPayloadRequest","") + execution.setVariable(Prefix + "updateContrailAAIResponse", "") + execution.setVariable(Prefix + "aaiUpdateContrailReturnCode", "") + + execution.setVariable(Prefix + "updateNetworkRequest", "") + execution.setVariable(Prefix + "updateNetworkResponse", "") + execution.setVariable(Prefix + "rollbackNetworkRequest", "") + execution.setVariable(Prefix + "networkReturnCode", "") + execution.setVariable(Prefix + "isNetworkRollbackNeeded", false) + + execution.setVariable(Prefix + "changeAssignSDNCRequest", "") + execution.setVariable(Prefix + "changeAssignSDNCResponse", "") + execution.setVariable(Prefix + "rollbackSDNCRequest", "") + execution.setVariable(Prefix + "sdncReturnCode", "") + execution.setVariable(Prefix + "isSdncRollbackNeeded", false) + execution.setVariable(Prefix + "sdncResponseSuccess", false) + + execution.setVariable(Prefix + "isVnfBindingPresent", false) + execution.setVariable(Prefix + "Success", false) + execution.setVariable(Prefix + "serviceInstanceId", "") + + execution.setVariable(Prefix + "isException", false) + + } + + // ************************************************** + // Pre or Prepare Request Section + // ************************************************** + /** + * This method is executed during the preProcessRequest task of the <class>DoUpdateNetworkInstance.bpmn</class> process. + * @param execution + */ + public void preProcessRequest (DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + + logger.trace("Inside preProcessRequest DoUpdateNetworkInstance Request ") + + try { + // initialize flow variables + InitializeProcessVariables(execution) + + // GET Incoming request & validate 3 kinds of format. + execution.setVariable("action", "UPDATE") + String networkRequest = execution.getVariable("bpmnRequest") + if (networkRequest != null) { + if (networkRequest.contains("requestDetails")) { + // JSON format request is sent, create xml + try { + def prettyJson = JsonOutput.prettyPrint(networkRequest.toString()) + logger.debug(" Incoming message formatted . . . : " + '\n' + prettyJson) + networkRequest = vidUtils.createXmlNetworkRequestInfra(execution, networkRequest) + + } catch (Exception ex) { + String dataErrorMessage = " Invalid json format Request - " + ex.getMessage() + logger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + } else { + // XML format request is sent + + } + } else { + // vIPR format request is sent, create xml from individual variables + networkRequest = vidUtils.createXmlNetworkRequestInstance(execution) + } + + networkRequest = utils.formatXml(networkRequest) + logger.debug(networkRequest) + execution.setVariable(Prefix + "networkRequest", networkRequest) + logger.debug(" network-request - " + '\n' + networkRequest) + + // validate 'disableRollback' (aka, 'suppressRollback') + boolean rollbackEnabled = networkUtils.isRollbackEnabled(execution, networkRequest) + execution.setVariable(Prefix + "rollbackEnabled", rollbackEnabled) + logger.debug(Prefix + "rollbackEnabled - " + rollbackEnabled) + + String networkInputs = utils.getNodeXml(networkRequest, "network-inputs", false).replace("tag0:","").replace(":tag0","") + execution.setVariable(Prefix + "networkInputs", networkInputs) + logger.debug(Prefix + "networkInputs - " + '\n' + networkInputs) + + // prepare messageId + String messageId = execution.getVariable(Prefix + "messageId") // for testing + if (messageId == null || messageId == "") { + messageId = UUID.randomUUID() + logger.debug(" UPDNETI_messageId, random generated: " + messageId) + } else { + logger.debug(" UPDNETI_messageId, pre-assigned: " + messageId) + } + execution.setVariable(Prefix + "messageId", messageId) + + String source = utils.getNodeText(networkRequest, "source") + execution.setVariable(Prefix + "source", source) + logger.debug(Prefix + "source - " + source) + + String networkId = "" + if (utils.nodeExists(networkRequest, "network-id")) { + networkId = utils.getNodeText(networkRequest, "network-id") + if (networkId == 'null' || networkId == "") { + sendSyncError(execution) + // missing value of networkId + String dataErrorMessage = "Variable 'network-id' value/element is missing." + logger.debug(" Invalid Request - " + dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } + } + + String lcpCloudRegion = "" + if (utils.nodeExists(networkRequest, "aic-cloud-region")) { + lcpCloudRegion = utils.getNodeText(networkRequest, "aic-cloud-region") + if ((lcpCloudRegion == 'null') || (lcpCloudRegion == "")) { + sendSyncError(execution) + String dataErrorMessage = "requestDetails has missing 'aic-cloud-region' value/element." + logger.debug(" Invalid Request - " + dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + } + + String serviceInstanceId = "" + if (utils.nodeExists(networkRequest, "service-instance-id")) { + serviceInstanceId = utils.getNodeText(networkRequest, "service-instance-id") + if ((serviceInstanceId == 'null') || (lcpCloudRegion == "")) { + sendSyncError(execution) + String dataErrorMessage = "Variable 'serviceInstanceId' value/element is missing." + logger.debug(" Invalid Request - " + dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + } + + // PO Authorization Info / headers Authorization= + String basicAuthValuePO = UrnPropertiesReader.getVariable("mso.adapters.po.auth",execution) + + + try { + def encodedString = utils.getBasicAuth(basicAuthValuePO, UrnPropertiesReader.getVariable("mso.msoKey", execution)) + execution.setVariable("BasicAuthHeaderValuePO",encodedString) + execution.setVariable("BasicAuthHeaderValueSDNC", encodedString) + + } catch (IOException ex) { + String exceptionMessage = "Exception Encountered in DoUpdateNetworkInstance, PreProcessRequest() - " + String dataErrorMessage = exceptionMessage + " Unable to encode PO/SDNC user/password string - " + ex.getMessage() + logger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + + // Set variables for Generic Get Sub Flow use + execution.setVariable(Prefix + "serviceInstanceId", serviceInstanceId) + logger.debug(Prefix + "serviceInstanceId - " + serviceInstanceId) + + logger.debug(" Url for SDNC adapter: " + UrnPropertiesReader.getVariable("mso.adapters.sdnc.endpoint",execution)) + + String sdncVersion = execution.getVariable("sdncVersion") + logger.debug("sdncVersion? : " + sdncVersion) + + // build 'networkOutputs' + networkId = utils.getNodeText(networkRequest, "network-id") + if ((networkId == null) || (networkId == "null")) { + networkId = "" + } + String networkName = utils.getNodeText(networkRequest, "network-name") + if ((networkName == null) || (networkName == "null")) { + networkName = "" + } + String networkOutputs = + """<network-outputs> <network-id>${MsoUtils.xmlEscape(networkId)}</network-id> <network-name>${MsoUtils.xmlEscape(networkName)}</network-name> </network-outputs>""" - execution.setVariable(Prefix + "networkOutputs", networkOutputs) - logger.debug(Prefix + "networkOutputs - " + '\n' + networkOutputs) - execution.setVariable(Prefix + "networkId", networkId) - execution.setVariable(Prefix + "networkName", networkName) - + execution.setVariable(Prefix + "networkOutputs", networkOutputs) + logger.debug(Prefix + "networkOutputs - " + '\n' + networkOutputs) + execution.setVariable(Prefix + "networkId", networkId) + execution.setVariable(Prefix + "networkName", networkName) - } catch (BpmnError e) { - throw e; - } catch (Exception ex){ - sendSyncError(execution) - // caught exception - String exceptionMessage = "Exception Encountered in DoUpdateNetworkInstance, PreProcessRequest() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } catch (BpmnError e) { + throw e; - } - } + } catch (Exception ex){ + sendSyncError(execution) + // caught exception + String exceptionMessage = "Exception Encountered in DoUpdateNetworkInstance, PreProcessRequest() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - /** - * Gets the service instance uri from aai - * - */ - public void getServiceInstance(DelegateExecution execution) { - logger.trace("getServiceInstance ") - try { - String serviceInstanceId = execution.getVariable('serviceInstanceId') - - AAIResourcesClient resourceClient = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) - - if(!resourceClient.exists(uri)){ - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Service Instance not found in aai") - }else{ - Map<String, String> keys = uri.getURIKeys() - execution.setVariable("serviceType", keys.get("service-type")) - execution.setVariable("subscriberName", keys.get("global-customer-id")) - } - - }catch(BpmnError e) { - throw e; - }catch (Exception ex){ - String msg = "Exception in getServiceInstance. " + ex.getMessage() - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - } + } + } + + /** + * Gets the service instance uri from aai + * + */ + public void getServiceInstance(DelegateExecution execution) { + logger.trace("getServiceInstance ") + try { + String serviceInstanceId = execution.getVariable('serviceInstanceId') + + AAIResourcesClient resourceClient = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) + + if(!resourceClient.exists(uri)){ + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Service Instance not found in aai") + }else{ + Map<String, String> keys = uri.getURIKeys() + execution.setVariable("serviceType", keys.get(AAIFluentTypeBuilder.Types.SERVICE_SUBSCRIPTION.getUriParams().serviceType)) + execution.setVariable("subscriberName", keys.get(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId)) + } + + }catch(BpmnError e) { + throw e; + }catch (Exception ex){ + String msg = "Exception in getServiceInstance. " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } - public void callRESTQueryAAICloudRegion (DelegateExecution execution) { + public void callRESTQueryAAICloudRegion (DelegateExecution execution) { - execution.setVariable("prefix", Prefix) + execution.setVariable("prefix", Prefix) - logger.debug(" ***** Inside callRESTQueryAAICloudRegion of DoUpdateNetworkInstance ***** " ) + logger.debug(" ***** Inside callRESTQueryAAICloudRegion of DoUpdateNetworkInstance ***** " ) - try { - String networkInputs = execution.getVariable(Prefix + "networkInputs") - String cloudRegion = utils.getNodeText(networkInputs, "aic-cloud-region") + try { + String networkInputs = execution.getVariable(Prefix + "networkInputs") + String cloudRegion = utils.getNodeText(networkInputs, "aic-cloud-region") - // Prepare AA&I url - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) - AaiUtil aaiUtil = new AaiUtil(this) + // Prepare AA&I url + String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + AaiUtil aaiUtil = new AaiUtil(this) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion) - def queryCloudRegionRequest = aaiUtil.createAaiUri(uri) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion) + def queryCloudRegionRequest = aaiUtil.createAaiUri(uri) - execution.setVariable(Prefix + "queryCloudRegionRequest", queryCloudRegionRequest) + execution.setVariable(Prefix + "queryCloudRegionRequest", queryCloudRegionRequest) - String cloudRegionPo = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) - String cloudRegionSdnc = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "SDNC", cloudRegion) + String cloudRegionPo = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) + String cloudRegionSdnc = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "SDNC", cloudRegion) - if ((cloudRegionPo != "ERROR") && (cloudRegionSdnc != "ERROR")) { - execution.setVariable(Prefix + "cloudRegionPo", cloudRegionPo) - execution.setVariable(Prefix + "cloudRegionSdnc", cloudRegionSdnc) - execution.setVariable(Prefix + "isCloudRegionGood", true) + if ((cloudRegionPo != "ERROR") && (cloudRegionSdnc != "ERROR")) { + execution.setVariable(Prefix + "cloudRegionPo", cloudRegionPo) + execution.setVariable(Prefix + "cloudRegionSdnc", cloudRegionSdnc) + execution.setVariable(Prefix + "isCloudRegionGood", true) - } else { - String dataErrorMessage = "QueryAAICloudRegion Unsuccessful. Return Code: " + execution.getVariable(Prefix + "queryCloudRegionReturnCode") - logger.debug(dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } else { + String dataErrorMessage = "QueryAAICloudRegion Unsuccessful. Return Code: " + execution.getVariable(Prefix + "queryCloudRegionReturnCode") + logger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } + } - logger.debug(" is Cloud Region Good: " + execution.getVariable(Prefix + "isCloudRegionGood")) + logger.debug(" is Cloud Region Good: " + execution.getVariable(Prefix + "isCloudRegionGood")) - } catch (BpmnError e) { - throw e; + } catch (BpmnError e) { + throw e; - } catch (Exception ex) { - // try error - String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow - callRESTQueryAAICloudRegion() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } catch (Exception ex) { + // try error + String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow - callRESTQueryAAICloudRegion() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } + } - } + } - public void callRESTQueryAAINetworkId(DelegateExecution execution) { + public void callRESTQueryAAINetworkId(DelegateExecution execution) { - execution.setVariable("prefix", Prefix) + execution.setVariable("prefix", Prefix) - logger.debug(" ***** Inside callRESTQueryAAINetworkId of DoUpdateNetworkInstance ***** " ) + logger.debug(" ***** Inside callRESTQueryAAINetworkId of DoUpdateNetworkInstance ***** " ) - try { - // get variables - String networkRequest = execution.getVariable(Prefix + "networkRequest") - String networkId = utils.getNodeText(networkRequest, "network-id") - execution.setVariable(Prefix + "networkId", networkId) + try { + // get variables + String networkRequest = execution.getVariable(Prefix + "networkRequest") + String networkId = utils.getNodeText(networkRequest, "network-id") + execution.setVariable(Prefix + "networkId", networkId) - AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId).depth(Depth.ONE) - AAIResultWrapper network = client.get(uri, NotFoundException.class) + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId).depth(Depth.ONE) + AAIResultWrapper network = client.get(uri, NotFoundException.class) - execution.setVariable(Prefix + "aaiIdReturnCode", "200") + execution.setVariable(Prefix + "aaiIdReturnCode", "200") - execution.setVariable(Prefix + "queryIdAAIResponse", network) + execution.setVariable(Prefix + "queryIdAAIResponse", network) - } catch (NotFoundException e) { - String dataErrorMessage = "Response Error from QueryAAINetworkId is 404 (Not Found)." - logger.debug(" AAI Query Failed. " + dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. callRESTQueryAAINetworkId() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } catch (NotFoundException e) { + String dataErrorMessage = "Response Error from QueryAAINetworkId is 404 (Not Found)." + logger.debug(" AAI Query Failed. " + dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. callRESTQueryAAINetworkId() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } + } - } + } - public void callRESTReQueryAAINetworkId(DelegateExecution execution) { + public void callRESTReQueryAAINetworkId(DelegateExecution execution) { - execution.setVariable("prefix", Prefix) + execution.setVariable("prefix", Prefix) - logger.debug(" ***** Inside callRESTReQueryAAINetworkId of DoUpdateNetworkInstance ***** " ) + logger.debug(" ***** Inside callRESTReQueryAAINetworkId of DoUpdateNetworkInstance ***** " ) - try { - // get variables - String networkRequest = execution.getVariable(Prefix + "networkRequest") - String networkId = utils.getNodeText(networkRequest, "network-id") + try { + // get variables + String networkRequest = execution.getVariable(Prefix + "networkRequest") + String networkId = utils.getNodeText(networkRequest, "network-id") - AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId).depth(Depth.ONE) - AAIResultWrapper network = client.get(uri, NotFoundException.class) + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId).depth(Depth.ONE) + AAIResultWrapper network = client.get(uri, NotFoundException.class) - execution.setVariable(Prefix + "aaiRequeryIdReturnCode", "200") - execution.setVariable(Prefix + "requeryIdAAIResponse", network) + execution.setVariable(Prefix + "aaiRequeryIdReturnCode", "200") + execution.setVariable(Prefix + "requeryIdAAIResponse", network) - L3Network net = network.asBean(L3Network.class).get() - String netId = net.getNetworkId() - String netName = net.getNetworkName() - String networkOutputs = - """<network-outputs> + L3Network net = network.asBean(L3Network.class).get() + String netId = net.getNetworkId() + String netName = net.getNetworkName() + String networkOutputs = + """<network-outputs> <network-id>${MsoUtils.xmlEscape(netId)}</network-id> <network-name>${MsoUtils.xmlEscape(netName)}</network-name> </network-outputs>""" - execution.setVariable(Prefix + "networkOutputs", networkOutputs) - logger.debug(" networkOutputs - " + '\n' + networkOutputs) - - } catch (NotFoundException e) { - String dataErrorMessage = "Response Error from ReQueryAAINetworkId is 404 (Not Found)." - logger.debug(" AAI ReQuery Failed. - " + dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. callRESTReQueryAAINetworkId() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void callRESTQueryAAINetworkVpnBinding(DelegateExecution execution) { - - execution.setVariable("prefix", Prefix) - - logger.debug(" ***** Inside callRESTQueryAAINetworkVpnBinding of DoUpdateNetworkInstance ***** " ) - - try { - - // get variables - AAIResultWrapper queryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse") - if(queryIdAAIResponse.getRelationships().isPresent()){ - List<AAIResourceUri> uris = queryIdAAIResponse.getRelationships().get().getRelatedAAIUris(AAIObjectType.VPN_BINDING) - - logger.debug(Prefix + "vpnCount - " + uris.size()) - - if (uris.size() > 0) { - String routeTargets = "" - for(AAIResourceUri u : uris) { - - AAIResourcesClient client = new AAIResourcesClient() - AAIResultWrapper wrapper = client.get(u.depth(Depth.TWO), NotFoundException.class) - Optional<VpnBinding> binding = wrapper.asBean(VpnBinding.class) - - String routeTarget = "" - String routeRole = "" - if(binding.get().getRouteTargets() != null) { - List<RouteTarget> targets = binding.get().getRouteTargets().getRouteTarget() - for(RouteTarget target : targets) { - routeTarget = target.getGlobalRouteTarget() - routeRole = target.getRouteTargetRole() - routeTargets += "<routeTargets>" + '\n' + - " <routeTarget>" + routeTarget + "</routeTarget>" + '\n' + - " <routeTargetRole>" + routeRole + "</routeTargetRole>" + '\n' + - "</routeTargets>" + '\n' - } - } - - } // end loop - - execution.setVariable(Prefix + "routeCollection", routeTargets) - logger.debug(" UPDNETI_routeCollection - " + '\n' + routeTargets) - - } else { - // reset return code to success - execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") - AaiUtil aaiUriUtil = new AaiUtil(this) - String schemaVersion = aaiUriUtil.getNamespace() - String aaiStubResponse = - """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"> - <vpn-binding xmlns="${schemaVersion}"> - <global-route-target/> - </vpn-binding> - </rest:payload>""" - String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) - execution.setVariable(Prefix + "queryVpnBindingAAIResponse", aaiStubResponseAsXml) - execution.setVariable(Prefix + "routeCollection", "<routeTargets/>") - logger.debug(" No vpnBinding, using this stub as response - " + '\n' + aaiStubResponseAsXml) - - } - } - - } catch (NotFoundException e) { - logger.debug("Response Error from AAINetworkVpnBinding is 404 (Not Found).") - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Response Error from AAINetworkVpnBinding is 404 (Not Found).") - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. callRESTQueryAAINetworkVpnBinding() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + execution.setVariable(Prefix + "networkOutputs", networkOutputs) + logger.debug(" networkOutputs - " + '\n' + networkOutputs) + + } catch (NotFoundException e) { + String dataErrorMessage = "Response Error from ReQueryAAINetworkId is 404 (Not Found)." + logger.debug(" AAI ReQuery Failed. - " + dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. callRESTReQueryAAINetworkId() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - - } + } - public void callRESTQueryAAINetworkPolicy(DelegateExecution execution) { + } - execution.setVariable("prefix", Prefix) + public void callRESTQueryAAINetworkVpnBinding(DelegateExecution execution) { - logger.debug(" ***** Inside callRESTQueryAAINetworkPolicy of DoUpdateNetworkInstance ***** " ) + execution.setVariable("prefix", Prefix) - try { - // get variables - AAIResultWrapper queryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse") - if(queryIdAAIResponse.getRelationships().isPresent()){ - List<AAIResourceUri> uris = queryIdAAIResponse.getRelationships().get().getRelatedAAIUris(AAIObjectType.NETWORK_POLICY) + logger.debug(" ***** Inside callRESTQueryAAINetworkVpnBinding of DoUpdateNetworkInstance ***** " ) - execution.setVariable(Prefix + "networkPolicyCount", uris.size()) - logger.debug(Prefix + "networkPolicyCount - " + uris.size()) + try { - if (uris.size() > 0) { + // get variables + AAIResultWrapper queryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse") + if(queryIdAAIResponse.getRelationships().isPresent()){ + List<AAIResourceUri> uris = queryIdAAIResponse.getRelationships().get().getRelatedAAIUris(AAIObjectType.VPN_BINDING) - String networkPolicies = "" - // AII loop call using list vpnBindings - for(AAIResourceUri u : uris) { + logger.debug(Prefix + "vpnCount - " + uris.size()) - AAIResourcesClient client = new AAIResourcesClient() - NetworkPolicy p = client.get(u, NotFoundException.class).asBean(NetworkPolicy.class).get() + if (uris.size() > 0) { + String routeTargets = "" + for(AAIResourceUri u : uris) { - execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200") + AAIResourcesClient client = new AAIResourcesClient() + AAIResultWrapper wrapper = client.get(u.depth(Depth.TWO), NotFoundException.class) + Optional<VpnBinding> binding = wrapper.asBean(VpnBinding.class) - String networkPolicy = p.getNetworkPolicyFqdn() - networkPolicies += "<policyFqdns>" + networkPolicy + "</policyFqdns>" + '\n' + String routeTarget = "" + String routeRole = "" + if(binding.get().getRouteTargets() != null) { + List<RouteTarget> targets = binding.get().getRouteTargets().getRouteTarget() + for(RouteTarget target : targets) { + routeTarget = target.getGlobalRouteTarget() + routeRole = target.getRouteTargetRole() + routeTargets += "<routeTargets>" + '\n' + + " <routeTarget>" + routeTarget + "</routeTarget>" + '\n' + + " <routeTargetRole>" + routeRole + "</routeTargetRole>" + '\n' + + "</routeTargets>" + '\n' + } + } - } // end loop + } // end loop - execution.setVariable(Prefix + "networkCollection", networkPolicies) - logger.debug(" UPDNETI_networkCollection - " + '\n' + networkPolicies) + execution.setVariable(Prefix + "routeCollection", routeTargets) + logger.debug(" UPDNETI_routeCollection - " + '\n' + routeTargets) - } else { - // reset return code to success - execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200") - AaiUtil aaiUriUtil = new AaiUtil(this) - String schemaVersion = aaiUriUtil.getNamespace() - String aaiStubResponse = - """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"> - <network-policy xmlns="${schemaVersion}"> - <network-policy-fqdn/> - </network-policy> + } else { + // reset return code to success + execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") + AaiUtil aaiUriUtil = new AaiUtil(this) + String schemaVersion = aaiUriUtil.getNamespace() + String aaiStubResponse = + """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"> + <vpn-binding xmlns="${schemaVersion}"> + <global-route-target/> + </vpn-binding> </rest:payload>""" - String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) - execution.setVariable(Prefix + "queryNetworkPolicyAAIResponse", aaiStubResponseAsXml) - execution.setVariable(Prefix + "networkCollection", "<policyFqdns/>") - logger.debug(" No net policies, using this stub as response - " + '\n' + aaiStubResponseAsXml) + String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) + execution.setVariable(Prefix + "queryVpnBindingAAIResponse", aaiStubResponseAsXml) + execution.setVariable(Prefix + "routeCollection", "<routeTargets/>") + logger.debug(" No vpnBinding, using this stub as response - " + '\n' + aaiStubResponseAsXml) + + } + } + + } catch (NotFoundException e) { + logger.debug("Response Error from AAINetworkVpnBinding is 404 (Not Found).") + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Response Error from AAINetworkVpnBinding is 404 (Not Found).") + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. callRESTQueryAAINetworkVpnBinding() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } + } - } catch (NotFoundException e) { - String dataErrorMessage = "Response Error from QueryAAINetworkPolicy is 404 (Not Found)." - logger.debug(dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. callRESTQueryAAINetworkPolicy() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } - } + public void callRESTQueryAAINetworkPolicy(DelegateExecution execution) { - } + execution.setVariable("prefix", Prefix) - public void callRESTQueryAAINetworkTableRef(DelegateExecution execution) { + logger.debug(" ***** Inside callRESTQueryAAINetworkPolicy of DoUpdateNetworkInstance ***** " ) - execution.setVariable("prefix", Prefix) + try { + // get variables + AAIResultWrapper queryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse") + if(queryIdAAIResponse.getRelationships().isPresent()){ + List<AAIResourceUri> uris = queryIdAAIResponse.getRelationships().get().getRelatedAAIUris(AAIObjectType.NETWORK_POLICY) - logger.debug(" ***** Inside callRESTQueryAAINetworkTableRef of DoUpdateNetworkInstance ***** " ) + execution.setVariable(Prefix + "networkPolicyCount", uris.size()) + logger.debug(Prefix + "networkPolicyCount - " + uris.size()) - try { - AAIResultWrapper queryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse") - if(queryIdAAIResponse.getRelationships().isPresent()){ - List<AAIResourceUri> uris = queryIdAAIResponse.getRelationships().get().getRelatedAAIUris(AAIObjectType.ROUTE_TABLE_REFERENCE) + if (uris.size() > 0) { - execution.setVariable(Prefix + "networkTableRefCount", uris.size()) - logger.debug(Prefix + "networkTableRefCount - " + uris.size()) + String networkPolicies = "" + // AII loop call using list vpnBindings + for(AAIResourceUri u : uris) { - logger.debug(" UPDNETI_networkTableRefCount - " + uris.size()) - if (uris.size() > 0) { + AAIResourcesClient client = new AAIResourcesClient() + NetworkPolicy p = client.get(u, NotFoundException.class).asBean(NetworkPolicy.class).get() - execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "200") + execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200") - // AII loop call using list vpnBindings - String networkTableRefs = "" - for(AAIResourceUri u : uris) { + String networkPolicy = p.getNetworkPolicyFqdn() + networkPolicies += "<policyFqdns>" + networkPolicy + "</policyFqdns>" + '\n' - AAIResourcesClient client = new AAIResourcesClient() - RouteTableReference rt = client.get(u, NotFoundException.class).asBean(RouteTableReference.class).get() + } // end loop - String networkTableRef = rt.getRouteTableReferenceFqdn() - networkTableRefs += "<routeTableFqdns>" + networkTableRef + "</routeTableFqdns>" + '\n' + execution.setVariable(Prefix + "networkCollection", networkPolicies) + logger.debug(" UPDNETI_networkCollection - " + '\n' + networkPolicies) - } // end loop + } else { + // reset return code to success + execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200") + AaiUtil aaiUriUtil = new AaiUtil(this) + String schemaVersion = aaiUriUtil.getNamespace() + String aaiStubResponse = + """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"> + <network-policy xmlns="${schemaVersion}"> + <network-policy-fqdn/> + </network-policy> + </rest:payload>""" + String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) + execution.setVariable(Prefix + "queryNetworkPolicyAAIResponse", aaiStubResponseAsXml) + execution.setVariable(Prefix + "networkCollection", "<policyFqdns/>") + logger.debug(" No net policies, using this stub as response - " + '\n' + aaiStubResponseAsXml) + + } + } + + } catch (NotFoundException e) { + String dataErrorMessage = "Response Error from QueryAAINetworkPolicy is 404 (Not Found)." + logger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. callRESTQueryAAINetworkPolicy() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - execution.setVariable(Prefix + "tableRefCollection", networkTableRefs) - logger.debug(" UPDNETI_tableRefCollection - " + '\n' + networkTableRefs) + } - } else { - // reset return code to success - execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "200") - AaiUtil aaiUriUtil = new AaiUtil(this) - String schemaVersion = aaiUriUtil.getNamespace() - String aaiStubResponse = - """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"> - <route-table-references xmlns="${schemaVersion}"> - <route-table-reference-fqdn/> - </route-table-references> - </rest:payload>""" - String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) - execution.setVariable(Prefix + "queryNetworkTableRefAAIResponse", aaiStubResponseAsXml) - execution.setVariable(Prefix + "tableRefCollection", "<routeTableFqdns/>") - logger.debug(" No net table references, using this stub as response - " + '\n' + aaiStubResponseAsXml) - - } - } - - } catch (NotFoundException e) { - String dataErrorMessage = "Response Error from QueryAAINetworkTableRef is 404 (Not Found)." - logger.debug(dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. callRESTQueryAAINetworkTableRef() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void callRESTUpdateContrailAAINetwork(DelegateExecution execution) { - execution.setVariable("prefix", Prefix) - logger.debug(" ***** Inside callRESTUpdateContrailAAINetwork of DoUpdateNetworkInstance ***** " ) - try { - // get variables - String networkRequest = execution.getVariable(Prefix + "networkRequest") - String networkId = utils.getNodeText(networkRequest, "network-id") - AAIResultWrapper requeryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse") - String updateNetworkResponse = execution.getVariable(Prefix + "updateNetworkResponse") - - L3Network oldL3Network = requeryIdAAIResponse.asBean(L3Network.class).get() - L3Network l3Network = new L3Network() - if (oldL3Network.getHeatStackId() != null) { - } else { - if (utils.nodeExists(updateNetworkResponse, 'networkStackId')) { - l3Network.setHeatStackId(utils.getNodeText(updateNetworkResponse, 'networkStackId')) - } - } - if (oldL3Network.getNeutronNetworkId() != null) { - } else { - if (utils.nodeExists(updateNetworkResponse, 'neutronNetworkId')) { - l3Network.setNeutronNetworkId(utils.getNodeText(updateNetworkResponse, 'neutronNetworkId')) - } - } - if (oldL3Network.getContrailNetworkFqdn() != null) { - } else { - if (utils.nodeExists(updateNetworkResponse, 'networkFqdn')) { - l3Network.setContrailNetworkFqdn(utils.getNodeText(updateNetworkResponse, 'networkFqdn')) - } - } - - String status = utils.getNodeText(updateNetworkResponse, 'orchestration-status') - if(status.equals("pending-create") || status.equals("PendingCreate")){ - l3Network.setOrchestrationStatus("Created") - }else{ - l3Network.setOrchestrationStatus("Active") - } - - AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId) - client.update(uri, l3Network) - - List<Subnet> subnets = oldL3Network.getSubnets().getSubnet() - for(Subnet s:subnets){ - String subnetOrchStatus = s.getOrchestrationStatus() - String subnetId = s.getSubnetId() - - Subnet subnet = new Subnet() - String neutronSubnetId = networkUtils.extractNeutSubId(updateNetworkResponse, subnetId) - subnet.setNeutronSubnetId(neutronSubnetId) - if(subnetOrchStatus.equals("pending-create") || subnetOrchStatus.equals("PendingCreate") ){ - subnet.setOrchestrationStatus("Created") - }else{ - subnet.setOrchestrationStatus("Active") - } - - AAIResourceUri subUri = AAIUriFactory.createResourceUri(AAIObjectType.SUBNET, networkId, subnetId) - client.update(subUri, subnet) - } - - execution.setVariable(Prefix + "isPONR", true) - - } catch (BpmnError e) { - throw e; - } catch (NotFoundException e) { - String dataErrorMessage = " Response Error from UpdateContrailAAINetwork is 404 (Not Found)." - logger.debug(dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. callRESTUpdateContrailAAINetwork() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void prepareUpdateNetworkRequest (DelegateExecution execution) { - - execution.setVariable("prefix", Prefix) - - logger.trace("Inside prepareUpdateNetworkRequest of DoUpdateNetworkInstance ") - - try { - - // get variables - String requestId = execution.getVariable(Prefix + "requestId") - String messageId = execution.getVariable(Prefix + "messageId") - String source = execution.getVariable(Prefix + "source") - - String requestInput = execution.getVariable(Prefix + "networkRequest") - L3Network queryIdResponse = execution.getVariable(Prefix + "requeryIdAAIResponse") - String cloudRegionId = execution.getVariable(Prefix + "cloudRegionPo") - String backoutOnFailure = execution.getVariable(Prefix + "rollbackEnabled") + } - // Prepare Network request - String routeCollection = execution.getVariable(Prefix + "routeCollection") - String policyCollection = execution.getVariable(Prefix + "networkCollection") - String tableCollection = execution.getVariable(Prefix + "tableRefCollection") - String updateNetworkRequest = networkUtils.UpdateNetworkRequestV2(execution, requestId, messageId, requestInput, queryIdResponse, routeCollection, policyCollection, tableCollection, cloudRegionId, backoutOnFailure, source ) - // Format Response - String buildUpdateNetworkRequestAsString = utils.formatXml(updateNetworkRequest) - buildUpdateNetworkRequestAsString = buildUpdateNetworkRequestAsString.replace(":w1aac13n0", "").replace("w1aac13n0:", "") - logger.debug(buildUpdateNetworkRequestAsString) + public void callRESTQueryAAINetworkTableRef(DelegateExecution execution) { - execution.setVariable(Prefix + "updateNetworkRequest", buildUpdateNetworkRequestAsString) - logger.debug(" UPDNETI_updateNetworkRequest - " + "\n" + buildUpdateNetworkRequestAsString) + execution.setVariable("prefix", Prefix) - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoUpdateNetworkInstance flow. prepareUpdateNetworkRequest() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + logger.debug(" ***** Inside callRESTQueryAAINetworkTableRef of DoUpdateNetworkInstance ***** " ) - } + try { + AAIResultWrapper queryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse") + if(queryIdAAIResponse.getRelationships().isPresent()){ + List<AAIResourceUri> uris = queryIdAAIResponse.getRelationships().get().getRelatedAAIUris(AAIObjectType.ROUTE_TABLE_REFERENCE) - } + execution.setVariable(Prefix + "networkTableRefCount", uris.size()) + logger.debug(Prefix + "networkTableRefCount - " + uris.size()) - public void prepareSDNCRequest (DelegateExecution execution) { + logger.debug(" UPDNETI_networkTableRefCount - " + uris.size()) + if (uris.size() > 0) { - execution.setVariable("prefix", Prefix) + execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "200") - logger.trace("Inside prepareSDNCRequest of DoUpdateNetworkInstance ") + // AII loop call using list vpnBindings + String networkTableRefs = "" + for(AAIResourceUri u : uris) { - try { - // get variables - String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) - String updateNetworkInput = execution.getVariable(Prefix + "networkRequest") - String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") + AAIResourcesClient client = new AAIResourcesClient() + RouteTableReference rt = client.get(u, NotFoundException.class).asBean(RouteTableReference.class).get() - String networkId = "" - if (utils.nodeExists(updateNetworkInput, "network-id")) { - networkId = utils.getNodeText(updateNetworkInput, "network-id") - } - if (networkId == null) {networkId = ""} + String networkTableRef = rt.getRouteTableReferenceFqdn() + networkTableRefs += "<routeTableFqdns>" + networkTableRef + "</routeTableFqdns>" + '\n' - String serviceInstanceId = utils.getNodeText(updateNetworkInput, "service-instance-id") + } // end loop - AAIResultWrapper wrapper = execution.getVariable(Prefix + "queryIdAAIResponse") - L3Network queryAAIResponse = wrapper.asBean(L3Network.class).get() + execution.setVariable(Prefix + "tableRefCollection", networkTableRefs) + logger.debug(" UPDNETI_tableRefCollection - " + '\n' + networkTableRefs) - // 1. prepare assign topology via SDNC Adapter SUBFLOW call - String sndcTopologyCreateRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, updateNetworkInput, serviceInstanceId, sdncCallback, "changeassign", "NetworkActivateRequest", cloudRegionId, networkId, queryAAIResponse, null) + } else { + // reset return code to success + execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "200") + AaiUtil aaiUriUtil = new AaiUtil(this) + String schemaVersion = aaiUriUtil.getNamespace() + String aaiStubResponse = + """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"> + <route-table-references xmlns="${schemaVersion}"> + <route-table-reference-fqdn/> + </route-table-references> + </rest:payload>""" + String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) + execution.setVariable(Prefix + "queryNetworkTableRefAAIResponse", aaiStubResponseAsXml) + execution.setVariable(Prefix + "tableRefCollection", "<routeTableFqdns/>") + logger.debug(" No net table references, using this stub as response - " + '\n' + aaiStubResponseAsXml) - String sndcTopologyUpdateRequesAsString = utils.formatXml(sndcTopologyCreateRequest) - logger.debug(sndcTopologyUpdateRequesAsString) - execution.setVariable(Prefix + "changeAssignSDNCRequest", sndcTopologyUpdateRequesAsString) - logger.debug(" UPDNETI_changeAssignSDNCRequest - " + "\n" + sndcTopologyUpdateRequesAsString) + } + } + } catch (NotFoundException e) { + String dataErrorMessage = "Response Error from QueryAAINetworkTableRef is 404 (Not Found)." + logger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoUpdateNetworkInstance flow. prepareSDNCRequest() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. callRESTQueryAAINetworkTableRef() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } - } + } + + public void callRESTUpdateContrailAAINetwork(DelegateExecution execution) { + execution.setVariable("prefix", Prefix) + logger.debug(" ***** Inside callRESTUpdateContrailAAINetwork of DoUpdateNetworkInstance ***** " ) + try { + // get variables + String networkRequest = execution.getVariable(Prefix + "networkRequest") + String networkId = utils.getNodeText(networkRequest, "network-id") + AAIResultWrapper requeryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse") + String updateNetworkResponse = execution.getVariable(Prefix + "updateNetworkResponse") + + L3Network oldL3Network = requeryIdAAIResponse.asBean(L3Network.class).get() + L3Network l3Network = new L3Network() + if (oldL3Network.getHeatStackId() != null) { + } else { + if (utils.nodeExists(updateNetworkResponse, 'networkStackId')) { + l3Network.setHeatStackId(utils.getNodeText(updateNetworkResponse, 'networkStackId')) + } + } + if (oldL3Network.getNeutronNetworkId() != null) { + } else { + if (utils.nodeExists(updateNetworkResponse, 'neutronNetworkId')) { + l3Network.setNeutronNetworkId(utils.getNodeText(updateNetworkResponse, 'neutronNetworkId')) + } + } + if (oldL3Network.getContrailNetworkFqdn() != null) { + } else { + if (utils.nodeExists(updateNetworkResponse, 'networkFqdn')) { + l3Network.setContrailNetworkFqdn(utils.getNodeText(updateNetworkResponse, 'networkFqdn')) + } + } + + String status = utils.getNodeText(updateNetworkResponse, 'orchestration-status') + if(status.equals("pending-create") || status.equals("PendingCreate")){ + l3Network.setOrchestrationStatus("Created") + }else{ + l3Network.setOrchestrationStatus("Active") + } + + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId) + client.update(uri, l3Network) + + List<Subnet> subnets = oldL3Network.getSubnets().getSubnet() + for(Subnet s:subnets){ + String subnetOrchStatus = s.getOrchestrationStatus() + String subnetId = s.getSubnetId() + + Subnet subnet = new Subnet() + String neutronSubnetId = networkUtils.extractNeutSubId(updateNetworkResponse, subnetId) + subnet.setNeutronSubnetId(neutronSubnetId) + if(subnetOrchStatus.equals("pending-create") || subnetOrchStatus.equals("PendingCreate") ){ + subnet.setOrchestrationStatus("Created") + }else{ + subnet.setOrchestrationStatus("Active") + } + + AAIResourceUri subUri = AAIUriFactory.createResourceUri(AAIObjectType.SUBNET, networkId, subnetId) + client.update(subUri, subnet) + } + + execution.setVariable(Prefix + "isPONR", true) + + } catch (BpmnError e) { + throw e; + } catch (NotFoundException e) { + String dataErrorMessage = " Response Error from UpdateContrailAAINetwork is 404 (Not Found)." + logger.debug(dataErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. callRESTUpdateContrailAAINetwork() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } + } + } + public void prepareUpdateNetworkRequest (DelegateExecution execution) { + execution.setVariable("prefix", Prefix) - // ************************************************** - // Post or Validate Response Section - // ************************************************** + logger.trace("Inside prepareUpdateNetworkRequest of DoUpdateNetworkInstance ") - public void validateUpdateNetworkResponse (DelegateExecution execution) { + try { - execution.setVariable("prefix", Prefix) + // get variables + String requestId = execution.getVariable(Prefix + "requestId") + String messageId = execution.getVariable(Prefix + "messageId") + String source = execution.getVariable(Prefix + "source") - logger.trace("Inside validateUpdateNetworkResponse of DoUpdateNetworkInstance ") + String requestInput = execution.getVariable(Prefix + "networkRequest") + L3Network queryIdResponse = execution.getVariable(Prefix + "requeryIdAAIResponse") + String cloudRegionId = execution.getVariable(Prefix + "cloudRegionPo") + String backoutOnFailure = execution.getVariable(Prefix + "rollbackEnabled") + + // Prepare Network request + String routeCollection = execution.getVariable(Prefix + "routeCollection") + String policyCollection = execution.getVariable(Prefix + "networkCollection") + String tableCollection = execution.getVariable(Prefix + "tableRefCollection") + String updateNetworkRequest = networkUtils.UpdateNetworkRequestV2(execution, requestId, messageId, requestInput, queryIdResponse, routeCollection, policyCollection, tableCollection, cloudRegionId, backoutOnFailure, source ) + // Format Response + String buildUpdateNetworkRequestAsString = utils.formatXml(updateNetworkRequest) + buildUpdateNetworkRequestAsString = buildUpdateNetworkRequestAsString.replace(":w1aac13n0", "").replace("w1aac13n0:", "") + logger.debug(buildUpdateNetworkRequestAsString) + + execution.setVariable(Prefix + "updateNetworkRequest", buildUpdateNetworkRequestAsString) + logger.debug(" UPDNETI_updateNetworkRequest - " + "\n" + buildUpdateNetworkRequestAsString) + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoUpdateNetworkInstance flow. prepareUpdateNetworkRequest() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - try { - String returnCode = execution.getVariable(Prefix + "networkReturnCode") - String networkResponse = execution.getVariable(Prefix + "updateNetworkResponse") - if (networkResponse==null) { - networkResponse="" // reset - } + } - logger.debug(" Network Adapter update responseCode: " + returnCode) + } - String errorMessage = "" - if (returnCode == "200") { - execution.setVariable(Prefix + "isNetworkRollbackNeeded", true) - logger.debug(networkResponse) - execution.setVariable(Prefix + "updateNetworkResponse", networkResponse) - logger.debug(" Network Adapter update Success Response - " + "\n" + networkResponse) + public void prepareSDNCRequest (DelegateExecution execution) { - // prepare rollback data - String rollbackData = utils.getNodeXml(networkResponse, "rollback", false).replace("tag0:","").replace(":tag0","") - rollbackData = rollbackData.replace("rollback>", "networkRollback>") - String rollbackNetwork = - """<rollbackNetworkRequest> - ${rollbackData} - </rollbackNetworkRequest>""" - String rollbackNetworkXml = utils.formatXml(rollbackNetwork) - execution.setVariable(Prefix + "rollbackNetworkRequest", rollbackNetworkXml) - logger.debug(" Network Adapter rollback data - " + "\n" + rollbackNetworkXml) + execution.setVariable("prefix", Prefix) - } else { // network error - if (returnCode.toInteger() > 399 && returnCode.toInteger() < 600) { //4xx, 5xx - if (networkResponse.contains("updateNetworkError")) { - networkResponse = networkResponse.replace('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>', '') - errorMessage = utils.getNodeText(networkResponse, "message") - errorMessage = "Received error from Network Adapter: " + errorMessage - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) + logger.trace("Inside prepareSDNCRequest of DoUpdateNetworkInstance ") - } else { // CatchAll exception - if (returnCode == "500") { - errorMessage = "JBWEB000065: HTTP Status 500." - } else { - errorMessage = "Return code is " + returnCode - } - errorMessage = "Received error from Network Adapter: " + errorMessage - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) + try { + // get variables + String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + String updateNetworkInput = execution.getVariable(Prefix + "networkRequest") + String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") - } + String networkId = "" + if (utils.nodeExists(updateNetworkInput, "network-id")) { + networkId = utils.getNodeText(updateNetworkInput, "network-id") + } + if (networkId == null) {networkId = ""} - } else { // CatchAll exception - String dataErrorMessage = "Received error from Network Adapter. Return code is: " + returnCode - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + String serviceInstanceId = utils.getNodeText(updateNetworkInput, "service-instance-id") - } + AAIResultWrapper wrapper = execution.getVariable(Prefix + "queryIdAAIResponse") + L3Network queryAAIResponse = wrapper.asBean(L3Network.class).get() - } + // 1. prepare assign topology via SDNC Adapter SUBFLOW call + String sndcTopologyCreateRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, updateNetworkInput, serviceInstanceId, sdncCallback, "changeassign", "NetworkActivateRequest", cloudRegionId, networkId, queryAAIResponse, null) - } catch (BpmnError e) { - throw e; + String sndcTopologyUpdateRequesAsString = utils.formatXml(sndcTopologyCreateRequest) + logger.debug(sndcTopologyUpdateRequesAsString) + execution.setVariable(Prefix + "changeAssignSDNCRequest", sndcTopologyUpdateRequesAsString) + logger.debug(" UPDNETI_changeAssignSDNCRequest - " + "\n" + sndcTopologyUpdateRequesAsString) - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoUpdateNetworkInstance flow. validateUpdateNetworkResponse() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoUpdateNetworkInstance flow. prepareSDNCRequest() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } - } + } - public void validateSDNCResponse (DelegateExecution execution) { + public void validateSDNCResponse (DelegateExecution execution) { - execution.setVariable("prefix", Prefix) + execution.setVariable("prefix", Prefix) - logger.trace("Inside validateSDNCResponse of DoUpdateNetworkInstance ") + logger.trace("Inside validateSDNCResponse of DoUpdateNetworkInstance ") - String response = execution.getVariable(Prefix + "changeAssignSDNCResponse") - WorkflowException workflowException = null - try { - workflowException = execution.getVariable(Prefix + "WorkflowException") - //execution.setVariable("WorkflowException", workflowException) - } catch (Exception ex) { - logger.debug(" Sdnc 'WorkflowException' object is empty or null. ") - } + String response = execution.getVariable(Prefix + "changeAssignSDNCResponse") + WorkflowException workflowException = null + try { + workflowException = execution.getVariable(Prefix + "WorkflowException") + //execution.setVariable("WorkflowException", workflowException) + } catch (Exception ex) { + logger.debug(" Sdnc 'WorkflowException' object is empty or null. ") + } - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - // reset variable - String changeAssignSDNCResponseDecodeXml = execution.getVariable(Prefix + "changeAssignSDNCResponse") - changeAssignSDNCResponseDecodeXml = changeAssignSDNCResponseDecodeXml.replace('<?xml version="1.0" encoding="UTF-8"?>', "") - execution.setVariable(Prefix + "changeAssignSDNCResponse", changeAssignSDNCResponseDecodeXml) - - if (execution.getVariable(Prefix + "sdncResponseSuccess") == true) { // from sdnc util, prefix+'sdncResponseSuccess' - execution.setVariable(Prefix + "isSdncRollbackNeeded", true) - logger.debug("Successfully Validated SDNC Response") - - } else { - logger.debug("Did NOT Successfully Validated SDNC Response") - throw new BpmnError("MSOWorkflowException") - } - - } - - - public void postProcessResponse (DelegateExecution execution) { - - execution.setVariable("prefix", Prefix) - - logger.trace("Inside postProcessResponse of DoUpdateNetworkInstance ") - - try { - logger.debug(" ***** Is Exception Encountered (isException)? : " + execution.getVariable(Prefix + "isException")) - if (execution.getVariable(Prefix + "isException") == false) { - // set rollback data - execution.setVariable("orchestrationStatus", "") - execution.setVariable("networkId", execution.getVariable(Prefix + "networkId")) - execution.setVariable("networkName", execution.getVariable(Prefix + "networkName")) - prepareSuccessRollbackData(execution) // populate rollbackData - execution.setVariable("WorkflowException", null) - execution.setVariable(Prefix + "Success", true) - logger.debug(" ***** postProcessResponse(), GOOD !!!") - } else { - execution.setVariable(Prefix + "Success", false) - execution.setVariable("rollbackData", null) - String exceptionMessage = " Exception encountered in MSO Bpmn. " - if (execution.getVariable("workflowException") != null) { // Output of Rollback flow. - logger.debug(" ***** workflowException: " + execution.getVariable("workflowException")) - WorkflowException wfex = execution.getVariable("workflowException") - exceptionMessage = wfex.getErrorMessage() - } else { - if (execution.getVariable(Prefix + "WorkflowException") != null) { - WorkflowException pwfex = execution.getVariable(Prefix + "WorkflowException") - exceptionMessage = pwfex.getErrorMessage() - } - } - // going to the Main flow: a-la-carte or macro - logger.debug(" ***** postProcessResponse(), BAD !!!") - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - throw new BpmnError("MSOWorkflowException") - } + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + // reset variable + String changeAssignSDNCResponseDecodeXml = execution.getVariable(Prefix + "changeAssignSDNCResponse") + changeAssignSDNCResponseDecodeXml = changeAssignSDNCResponseDecodeXml.replace('<?xml version="1.0" encoding="UTF-8"?>', "") + execution.setVariable(Prefix + "changeAssignSDNCResponse", changeAssignSDNCResponseDecodeXml) - } catch(BpmnError b){ - logger.debug("Rethrowing MSOWorkflowException") - throw b + if (execution.getVariable(Prefix + "sdncResponseSuccess") == true) { // from sdnc util, prefix+'sdncResponseSuccess' + execution.setVariable(Prefix + "isSdncRollbackNeeded", true) + logger.debug("Successfully Validated SDNC Response") + } else { + logger.debug("Did NOT Successfully Validated SDNC Response") + throw new BpmnError("MSOWorkflowException") + } - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoUpdateNetworkInstance flow. postProcessResponse() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + + + public void postProcessResponse (DelegateExecution execution) { + + execution.setVariable("prefix", Prefix) + + logger.trace("Inside postProcessResponse of DoUpdateNetworkInstance ") + + try { + logger.debug(" ***** Is Exception Encountered (isException)? : " + execution.getVariable(Prefix + "isException")) + if (execution.getVariable(Prefix + "isException") == false) { + // set rollback data + execution.setVariable("orchestrationStatus", "") + execution.setVariable("networkId", execution.getVariable(Prefix + "networkId")) + execution.setVariable("networkName", execution.getVariable(Prefix + "networkName")) + prepareSuccessRollbackData(execution) // populate rollbackData + execution.setVariable("WorkflowException", null) + execution.setVariable(Prefix + "Success", true) + logger.debug(" ***** postProcessResponse(), GOOD !!!") + } else { + execution.setVariable(Prefix + "Success", false) + execution.setVariable("rollbackData", null) + String exceptionMessage = " Exception encountered in MSO Bpmn. " + if (execution.getVariable("workflowException") != null) { // Output of Rollback flow. + logger.debug(" ***** workflowException: " + execution.getVariable("workflowException")) + WorkflowException wfex = execution.getVariable("workflowException") + exceptionMessage = wfex.getErrorMessage() + } else { + if (execution.getVariable(Prefix + "WorkflowException") != null) { + WorkflowException pwfex = execution.getVariable(Prefix + "WorkflowException") + exceptionMessage = pwfex.getErrorMessage() + } + } + // going to the Main flow: a-la-carte or macro + logger.debug(" ***** postProcessResponse(), BAD !!!") + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + throw new BpmnError("MSOWorkflowException") + } + + } catch(BpmnError b){ + logger.debug("Rethrowing MSOWorkflowException") + throw b + + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoUpdateNetworkInstance flow. postProcessResponse() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) } - } + } - public void prepareSDNCRollbackRequest (DelegateExecution execution) { + public void prepareSDNCRollbackRequest (DelegateExecution execution) { - execution.setVariable("prefix", Prefix) + execution.setVariable("prefix", Prefix) - logger.trace("Inside prepareSDNCRollbackRequest of DoUpdateNetworkInstance ") + logger.trace("Inside prepareSDNCRollbackRequest of DoUpdateNetworkInstance ") - try { - // for some reason the WorkflowException object is null after the sdnc rollback call task, need to save WorkflowException. - execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException")) - // get variables - String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) - String updateNetworkInput = execution.getVariable(Prefix + "networkRequest") - String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") - String changeAssignSDNCResponse = execution.getVariable(Prefix + "changeAssignSDNCResponse") - String networkId = utils.getNodeText(changeAssignSDNCResponse, "network-id") + try { + // for some reason the WorkflowException object is null after the sdnc rollback call task, need to save WorkflowException. + execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException")) + // get variables + String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + String updateNetworkInput = execution.getVariable(Prefix + "networkRequest") + String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") + String changeAssignSDNCResponse = execution.getVariable(Prefix + "changeAssignSDNCResponse") + String networkId = utils.getNodeText(changeAssignSDNCResponse, "network-id") - String serviceInstanceId = utils.getNodeText(updateNetworkInput, "service-instance-id") + String serviceInstanceId = utils.getNodeText(updateNetworkInput, "service-instance-id") - // 2. prepare rollback topology via SDNC Adapter SUBFLOW call - String sndcTopologyRollbackRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, updateNetworkInput, serviceInstanceId, sdncCallback, "rollback", "NetworkActivateRequest", cloudRegionId, networkId, null, null) - String sndcTopologyRollbackRequestAsString = utils.formatXml(sndcTopologyRollbackRequest) - execution.setVariable(Prefix + "rollbackSDNCRequest", sndcTopologyRollbackRequestAsString) - logger.debug(" Preparing request for SDNC Topology assign's rollback/compensation . . . - " + "\n" + sndcTopologyRollbackRequestAsString) + // 2. prepare rollback topology via SDNC Adapter SUBFLOW call + String sndcTopologyRollbackRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, updateNetworkInput, serviceInstanceId, sdncCallback, "rollback", "NetworkActivateRequest", cloudRegionId, networkId, null, null) + String sndcTopologyRollbackRequestAsString = utils.formatXml(sndcTopologyRollbackRequest) + execution.setVariable(Prefix + "rollbackSDNCRequest", sndcTopologyRollbackRequestAsString) + logger.debug(" Preparing request for SDNC Topology assign's rollback/compensation . . . - " + "\n" + sndcTopologyRollbackRequestAsString) - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoUpdateNetworkInstance flow. prepareSDNCRollbackRequest() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoUpdateNetworkInstance flow. prepareSDNCRollbackRequest() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + + } - } + } - } + public void prepareRollbackData(DelegateExecution execution) { - public void prepareRollbackData(DelegateExecution execution) { + execution.setVariable("prefix",Prefix) - execution.setVariable("prefix",Prefix) + logger.trace("Inside prepareRollbackData() of DoUpdateNetworkInstance ") - logger.trace("Inside prepareRollbackData() of DoUpdateNetworkInstance ") + try { - try { + Map<String, String> rollbackData = new HashMap<String, String>(); + String rollbackSDNCRequest = execution.getVariable(Prefix + "rollbackSDNCRequest") + if (rollbackSDNCRequest != null) { + if (rollbackSDNCRequest != "") { + rollbackData.put("rollbackSDNCRequest", execution.getVariable(Prefix + "rollbackSDNCRequest")) + } + } + String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest") + if (rollbackNetworkRequest != null) { + if (rollbackNetworkRequest != "") { + rollbackData.put("rollbackNetworkRequest", execution.getVariable(Prefix + "rollbackNetworkRequest")) + } + } + execution.setVariable("rollbackData", rollbackData) + logger.debug("** rollbackData : " + rollbackData) - Map<String, String> rollbackData = new HashMap<String, String>(); - String rollbackSDNCRequest = execution.getVariable(Prefix + "rollbackSDNCRequest") - if (rollbackSDNCRequest != null) { - if (rollbackSDNCRequest != "") { - rollbackData.put("rollbackSDNCRequest", execution.getVariable(Prefix + "rollbackSDNCRequest")) - } - } - String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest") - if (rollbackNetworkRequest != null) { - if (rollbackNetworkRequest != "") { - rollbackData.put("rollbackNetworkRequest", execution.getVariable(Prefix + "rollbackNetworkRequest")) - } - } - execution.setVariable("rollbackData", rollbackData) - logger.debug("** rollbackData : " + rollbackData) + execution.setVariable("WorkflowException", execution.getVariable(Prefix + "WorkflowException")) + logger.debug("** WorkflowException : " + execution.getVariable("WorkflowException")) - execution.setVariable("WorkflowException", execution.getVariable(Prefix + "WorkflowException")) - logger.debug("** WorkflowException : " + execution.getVariable("WorkflowException")) + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoUpdateNetworkInstance flow. prepareRollbackData() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoUpdateNetworkInstance flow. prepareRollbackData() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + } - } + } - } + public void prepareSuccessRollbackData(DelegateExecution execution) { - public void prepareSuccessRollbackData(DelegateExecution execution) { + execution.setVariable("prefix",Prefix) - execution.setVariable("prefix",Prefix) + logger.trace("Inside prepareSuccessRollbackData() of DoUpdateNetworkInstance ") - logger.trace("Inside prepareSuccessRollbackData() of DoUpdateNetworkInstance ") + try { - try { + if (execution.getVariable("sdncVersion") != '1610') { + // skip: 1702 for 'changeassign' or equivalent not yet defined in SNDC, so no rollback. + } else { + prepareSDNCRollbackRequest(execution) + } - if (execution.getVariable("sdncVersion") != '1610') { - // skip: 1702 for 'changeassign' or equivalent not yet defined in SNDC, so no rollback. - } else { - prepareSDNCRollbackRequest(execution) - } + Map<String, String> rollbackData = new HashMap<String, String>(); + String rollbackSDNCRequest = execution.getVariable(Prefix + "rollbackSDNCRequest") + if (rollbackSDNCRequest != null) { + if (rollbackSDNCRequest != "") { + rollbackData.put("rollbackSDNCRequest", rollbackSDNCRequest) + } + } + String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest") + if (rollbackNetworkRequest != null) { + if (rollbackNetworkRequest != "") { + rollbackData.put("rollbackNetworkRequest", rollbackNetworkRequest) + } + } + execution.setVariable("rollbackData", rollbackData) - Map<String, String> rollbackData = new HashMap<String, String>(); - String rollbackSDNCRequest = execution.getVariable(Prefix + "rollbackSDNCRequest") - if (rollbackSDNCRequest != null) { - if (rollbackSDNCRequest != "") { - rollbackData.put("rollbackSDNCRequest", rollbackSDNCRequest) - } - } - String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest") - if (rollbackNetworkRequest != null) { - if (rollbackNetworkRequest != "") { - rollbackData.put("rollbackNetworkRequest", rollbackNetworkRequest) - } - } - execution.setVariable("rollbackData", rollbackData) + logger.debug("** 'rollbackData' for Full Rollback : " + rollbackData) + execution.setVariable("WorkflowException", null) - logger.debug("** 'rollbackData' for Full Rollback : " + rollbackData) - execution.setVariable("WorkflowException", null) + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DoUpdateNetworkInstance flow. prepareSuccessRollbackData() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoUpdateNetworkInstance flow. prepareSuccessRollbackData() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + } - } + } - } + public void setExceptionFlag(DelegateExecution execution){ - public void setExceptionFlag(DelegateExecution execution){ + execution.setVariable("prefix",Prefix) - execution.setVariable("prefix",Prefix) + logger.trace("Inside setExceptionFlag() of DoUpdateNetworkInstance ") - logger.trace("Inside setExceptionFlag() of DoUpdateNetworkInstance ") + try { - try { + execution.setVariable(Prefix + "isException", true) - execution.setVariable(Prefix + "isException", true) + if (execution.getVariable("SavedWorkflowException1") != null) { + execution.setVariable(Prefix + "WorkflowException", execution.getVariable("SavedWorkflowException1")) + } else { + execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException")) + } + logger.debug(Prefix + "WorkflowException - " +execution.getVariable(Prefix + "WorkflowException")) - if (execution.getVariable("SavedWorkflowException1") != null) { - execution.setVariable(Prefix + "WorkflowException", execution.getVariable("SavedWorkflowException1")) - } else { - execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException")) - } - logger.debug(Prefix + "WorkflowException - " +execution.getVariable(Prefix + "WorkflowException")) + } catch(Exception ex){ + String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. setExceptionFlag(): " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + } - } catch(Exception ex){ - String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. setExceptionFlag(): " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - } + } - } + // ******************************* + // Build Error Section + // ******************************* - // ******************************* - // Build Error Section - // ******************************* + public void processJavaException(DelegateExecution execution){ - public void processJavaException(DelegateExecution execution){ - - execution.setVariable("prefix",Prefix) - try{ - logger.debug("Caught a Java Exception") - logger.debug("Started processJavaException Method") - logger.debug("Variables List: " + execution.getVariables()) - execution.setVariable("UnexpectedError", "Caught a Java Lang Exception - " + Prefix) // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception") + execution.setVariable("prefix",Prefix) + try{ + logger.debug("Caught a Java Exception") + logger.debug("Started processJavaException Method") + logger.debug("Variables List: " + execution.getVariables()) + execution.setVariable("UnexpectedError", "Caught a Java Lang Exception - " + Prefix) // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception") - }catch(Exception e){ - logger.debug("Caught Exception during processJavaException Method: " + e) - execution.setVariable("UnexpectedError", "Exception in processJavaException method") // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method") - } - logger.debug("Completed processJavaException Method") - } + }catch(Exception e){ + logger.debug("Caught Exception during processJavaException Method: " + e) + execution.setVariable("UnexpectedError", "Exception in processJavaException method") // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method") + } + logger.debug("Completed processJavaException Method") + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollback.groovy deleted file mode 100644 index 371e54ca75..0000000000 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollback.groovy +++ /dev/null @@ -1,312 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * 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.xml.XmlUtil -import groovy.json.* - -import org.onap.so.bpmn.common.scripts.AaiUtil -import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.onap.so.bpmn.common.scripts.ExceptionUtil -import org.onap.so.bpmn.common.scripts.NetworkUtils -import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils -import org.onap.so.bpmn.common.scripts.VidUtils -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.bpmn.core.json.JsonUtils - - -import java.util.UUID; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils - -import org.slf4j.Logger -import org.slf4j.LoggerFactory - -/** - * This groovy class supports the <class>DoCreateNetworkInstance.bpmn</class> process. - * - */ -public class DoUpdateNetworkInstanceRollback extends AbstractServiceTaskProcessor { - private static final Logger logger = LoggerFactory.getLogger( DoUpdateNetworkInstanceRollback.class); - - String Prefix="UPDNETIR_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils(this) - NetworkUtils networkUtils = new NetworkUtils() - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - - def className = getClass().getSimpleName() - - /** - * This method is executed during the preProcessRequest task of the <class>DoUpdateNetworkInstanceRollback.bpmn</class> process. - * @param execution - */ - public InitializeProcessVariables(DelegateExecution execution){ - /* Initialize all the process variables in this block */ - - execution.setVariable(Prefix + "rollbackNetworkRequest", null) - execution.setVariable(Prefix + "rollbackSDNCRequest", null) - execution.setVariable(Prefix + "WorkflowException", null) - - execution.setVariable(Prefix + "rollbackNetworkRequest", "") - execution.setVariable(Prefix + "rollbackNetworkResponse", "") - execution.setVariable(Prefix + "rollbackNetworkReturnCode", "") - - execution.setVariable(Prefix + "rollbackSDNCRequest", "") - execution.setVariable(Prefix + "rollbackSDNCResponse", "") - execution.setVariable(Prefix + "rollbackSDNCReturnCode", "") - - execution.setVariable(Prefix + "Success", false) - execution.setVariable(Prefix + "fullRollback", false) - - } - - // ************************************************** - // Pre or Prepare Request Section - // ************************************************** - /** - * This method is executed during the preProcessRequest task of the <class>DoUpdateNetworkInstanceRollback.bpmn</class> process. - * @param execution - */ - public void preProcessRequest (DelegateExecution execution) { - - execution.setVariable("prefix",Prefix) - - logger.trace("Inside preProcessRequest() of " + className + ".groovy ") - - try { - // initialize flow variables - InitializeProcessVariables(execution) - - // GET Incoming request/variables - String rollbackNetworkRequest = null - String rollbackSDNCRequest = null - - // Partial Rollback - Map<String, String> rollbackData = execution.getVariable("rollbackData") - if (rollbackData != null && rollbackData instanceof Map) { - - if(rollbackData.containsKey("rollbackNetworkRequest")) { - rollbackNetworkRequest = rollbackData["rollbackNetworkRequest"] - } - - if(rollbackData.containsKey("rollbackSDNCRequest")) { - rollbackSDNCRequest = rollbackData["rollbackSDNCRequest"] - } - } - - execution.setVariable(Prefix + "rollbackNetworkRequest", rollbackNetworkRequest) - execution.setVariable(Prefix + "rollbackSDNCRequest", rollbackSDNCRequest) - logger.debug("'rollbackData': " + '\n' + execution.getVariable("rollbackData")) - - String sdncVersion = execution.getVariable("sdncVersion") - logger.debug("sdncVersion? : " + sdncVersion) - - // PO Authorization Info / headers Authorization= - String basicAuthValuePO = UrnPropertiesReader.getVariable("mso.adapters.po.auth",execution) - - try { - def encodedString = utils.getBasicAuth(basicAuthValuePO, UrnPropertiesReader.getVariable("mso.msoKey", execution)) - execution.setVariable("BasicAuthHeaderValuePO",encodedString) - execution.setVariable("BasicAuthHeaderValueSDNC", encodedString) - - } catch (IOException ex) { - String exceptionMessage = "Exception Encountered in DoCreateNetworkInstance, PreProcessRequest() - " - String dataErrorMessage = exceptionMessage + " Unable to encode PO/SDNC user/password string - " + ex.getMessage() - logger.debug(dataErrorMessage ) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - - if (execution.getVariable("SavedWorkflowException1") != null) { - execution.setVariable(Prefix + "WorkflowException", execution.getVariable("SavedWorkflowException1")) - } else { - execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException")) - } - logger.debug("*** WorkflowException : " + execution.getVariable(Prefix + "WorkflowException")) - if(execution.getVariable(Prefix + "WorkflowException") != null) { - // called by: DoCreateNetworkInstance, partial rollback - execution.setVariable(Prefix + "fullRollback", false) - - } else { - // called by: Macro - Full Rollback, WorkflowException = null - execution.setVariable(Prefix + "fullRollback", true) - - } - logger.debug("*** fullRollback? : " + execution.getVariable(Prefix + "fullRollback")) - - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - sendSyncError(execution) - // caught exception - String exceptionMessage = "Exception Encountered in PreProcessRequest() of " + className + ".groovy ***** : " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void validateRollbackResponses (DelegateExecution execution) { - - execution.setVariable("prefix",Prefix) - - logger.trace("Inside validateRollbackResponses() of DoUpdateNetworkInstanceRollback ") - - try { - // validate PO network rollback response - String rollbackNetworkErrorMessages = "" - String rollbackNetworkReturnCode = "200" - if (execution.getVariable(Prefix + "rollbackNetworkRequest") != null) { - rollbackNetworkReturnCode = execution.getVariable(Prefix + "rollbackNetworkReturnCode") - String rollbackNetworkResponse = execution.getVariable(Prefix + "rollbackNetworkResponse") - logger.debug(" NetworkRollback Code - " + rollbackNetworkReturnCode) - logger.debug(" NetworkRollback Response - " + rollbackNetworkResponse) - if (rollbackNetworkReturnCode != "200") { - rollbackNetworkErrorMessages = " + PO Network rollback failed. " - } else { - rollbackNetworkErrorMessages = " + PO Network rollback completed." - } - } - - // validate SDNC rollback response - String rollbackSdncErrorMessages = "" - String rollbackSDNCReturnCode = "200" - if (execution.getVariable(Prefix + "rollbackSDNCRequest") != null) { - rollbackSDNCReturnCode = execution.getVariable(Prefix + "rollbackSDNCReturnCode") - String rollbackSDNCResponse = execution.getVariable(Prefix + "rollbackSDNCResponse") - String rollbackSDNCReturnInnerCode = "" - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - rollbackSDNCResponse = rollbackSDNCResponse.replace('$', '').replace('<?xml version="1.0" encoding="UTF-8"?>', "") - if (rollbackSDNCReturnCode == "200") { - if (utils.nodeExists(rollbackSDNCResponse, "response-code")) { - rollbackSDNCReturnInnerCode = utils.getNodeText(rollbackSDNCResponse, "response-code") - if (rollbackSDNCReturnInnerCode == "200" || rollbackSDNCReturnInnerCode == "" || rollbackSDNCReturnInnerCode == "0") { - rollbackSdncErrorMessages = " + SNDC changeassign rollback completed." - } else { - rollbackSdncErrorMessages = " + SDNC changeassign rollback failed. " - } - } else { - rollbackSdncErrorMessages = " + SNDC changeassign rollback completed." - } - } else { - rollbackSdncErrorMessages = " + SDNC changeassign rollback failed. " - } - logger.debug(" SDNC changeassign rollback Code - " + rollbackSDNCReturnCode) - logger.debug(" SDNC changeassign rollback Response - " + rollbackSDNCResponse) - } - - String statusMessage = "" - int errorCode = 7000 - logger.debug("*** fullRollback? : " + execution.getVariable(Prefix + "fullRollback")) - if (execution.getVariable(Prefix + "fullRollback") == false) { - // original WorkflowException, - WorkflowException wfe = execution.getVariable(Prefix + "WorkflowException") - if (wfe != null) { - // rollback due to failure in DoCreate - Partial rollback - statusMessage = wfe.getErrorMessage() - errorCode = wfe.getErrorCode() - } else { - statusMessage = "See Previous Camunda flows for cause of Error: Undetermined Exception." - errorCode = '7000' - } - - // set if all rolledbacks are successful - if (rollbackNetworkReturnCode == "200" && rollbackSDNCReturnCode == "200") { - execution.setVariable("rolledBack", true) - - } else { - execution.setVariable("rolledBack", false) - - } - - statusMessage = statusMessage + rollbackNetworkErrorMessages + rollbackSdncErrorMessages - logger.debug("Final DoUpdateNetworkInstanceRollback status message: " + statusMessage) - String processKey = getProcessKey(execution); - WorkflowException exception = new WorkflowException(processKey, errorCode, statusMessage); - execution.setVariable("workflowException", exception); - - } else { - // rollback due to failures in Main flow (Macro) - Full rollback - // WorkflowException = null - if (rollbackNetworkReturnCode == "200" && rollbackSDNCReturnCode == "200") { - execution.setVariable("rollbackSuccessful", true) - execution.setVariable("rollbackError", false) - } else { - String exceptionMessage = "Network Update Rollback was not Successful. " - logger.debug(exceptionMessage) - execution.setVariable("rollbackSuccessful", false) - execution.setVariable("rollbackError", true) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - throw new BpmnError("MSOWorkflowException") - } - - } - - - } catch (Exception ex) { - execution.setVariable("WorkflowException", null) - String errorMessage = "See Previous Camunda flows for cause of Error: Undetermined Exception." - String exceptionMessage = " Bpmn error encountered in DoUpdateNetworkInstanceRollback flow. validateRollbackResponses() - " + errorMessage + ": " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - execution.setVariable("WorkflowException", execution.getVariable("WorkflowException")) - - } - - } - - // ******************************* - // Build Error Section - // ******************************* - - - - public void processJavaException(DelegateExecution execution){ - - execution.setVariable("prefix",Prefix) - - try{ - logger.debug("Caught a Java Exception in " + Prefix) - logger.debug("Started processJavaException Method") - logger.debug("Variables List: " + execution.getVariables()) - execution.setVariable("UnexpectedError", "Caught a Java Lang Exception - " + Prefix) // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception") - - }catch(Exception e){ - logger.debug("Caught Exception during processJavaException Method: " + e) - execution.setVariable("UnexpectedError", "Exception in processJavaException method - " + Prefix) // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method" + Prefix) - } - logger.trace("Completed processJavaException Method in " + Prefix) - } - -} 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 ff63bc945b..00cf2a3ff1 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 @@ -37,12 +37,12 @@ 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.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.client.graphinventory.entities.uri.Depth +import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +import org.onap.aaiclient.client.graphinventory.entities.uri.Depth import org.onap.so.constants.Defaults import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum 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 7caa63ec72..7e180ca542 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 @@ -37,11 +37,11 @@ import org.onap.so.bpmn.core.domain.ModelInfo import org.onap.so.bpmn.core.domain.ModuleResource import org.onap.so.bpmn.core.domain.VnfResource import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.client.graphinventory.entities.uri.Depth +import org.onap.aaiclient.client.graphinventory.entities.uri.Depth import org.onap.so.client.HttpClient -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.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; 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/HandleOrchestrationTask.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HandleOrchestrationTask.groovy index 89490ff620..0f15717b3c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HandleOrchestrationTask.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HandleOrchestrationTask.groovy @@ -103,6 +103,7 @@ class HandleOrchestrationTask extends AbstractServiceTaskProcessor { task.setName(taskName) task.setStatus(taskStatus) task.setIsManual(isManual) + task.setCreatedTime(new Date()) task.setParams(paramJson) ObjectMapper objectMapper = new ObjectMapper() payload = objectMapper.writeValueAsString(task) 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 275cef0b0c..841c2a44cd 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 @@ -32,7 +32,7 @@ import org.onap.so.bpmn.core.domain.ModelInfo import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.domain.VnfResource import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.client.aai.* +import org.onap.aaiclient.client.aai.* import org.onap.so.client.appc.ApplicationControllerOrchestrator import org.onap.so.client.appc.ApplicationControllerSupport import org.onap.logging.filter.base.ErrorCode diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy index 8e554e286d..282e9611fd 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy @@ -39,11 +39,11 @@ import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.domain.Resource import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.bpmn.core.UrnPropertiesReader -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.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.springframework.web.util.UriUtils 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/UpdateVfModuleInfraV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfraV2.groovy index 575a8f3f1a..75ee556cfb 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfraV2.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfraV2.groovy @@ -29,7 +29,7 @@ import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.client.aai.AAIValidatorImpl +import org.onap.aaiclient.client.aai.AAIValidatorImpl import org.onap.so.client.appc.ApplicationControllerClient 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 f1fbafc7de..148ab1898f 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 @@ -22,28 +22,28 @@ package org.onap.so.bpmn.infrastructure.scripts +import static org.apache.commons.lang.StringUtils.isEmpty import org.apache.commons.collections.CollectionUtils import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.VolumeGroup +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.Relationships +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +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.common.scripts.VfModuleBase import org.onap.so.bpmn.core.UrnPropertiesReader 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.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.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory -import static org.apache.commons.lang.StringUtils.isEmpty - class UpdateVfModuleVolume extends VfModuleBase { private static final Logger logger = LoggerFactory.getLogger(UpdateVfModuleVolume.class) @@ -196,7 +196,7 @@ class UpdateVfModuleVolume extends VfModuleBase { List<AAIResourceUri> resourceUriList = relationships.get().getRelatedAAIUris(AAIObjectType.TENANT) if(CollectionUtils.isNotEmpty(resourceUriList)){ AAIResourceUri tenantUri = resourceUriList.get(0) - String volumeGroupTenantId = tenantUri.getURIKeys().get("tenant-id") + String volumeGroupTenantId = tenantUri.getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId) if( isEmpty(volumeGroupTenantId)){ exceptionUtil.buildAndThrowWorkflowException(execution,2500,"Could not find Tenant Id element in Volume Group with Volume Group Id" + volumeGroupId + ", AIC Cloud Region" + aicCloudRegion) } 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 5449ba6708..b6873a19fe 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 @@ -22,34 +22,33 @@ package org.onap.so.bpmn.infrastructure.scripts -import org.onap.so.logger.LoggingAnchor -import groovy.json.JsonException -import groovy.json.JsonSlurper +import static org.apache.cxf.common.util.CollectionUtils.isEmpty +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.GenericVnf import org.onap.aai.domain.yang.VfModule import org.onap.aai.domain.yang.VolumeGroup +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.Relationships +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +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.common.scripts.VfModuleBase import org.onap.so.bpmn.common.scripts.VidUtils import org.onap.so.bpmn.core.UrnPropertiesReader 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.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.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.core.UriBuilder - -import static org.apache.cxf.common.util.CollectionUtils.isEmpty +import groovy.json.JsonException +import groovy.json.JsonSlurper class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { private static final Logger logger = LoggerFactory.getLogger(UpdateVfModuleVolumeInfraV1.class) @@ -217,7 +216,7 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { if (relationships.isPresent()) { List<AAIResourceUri> tenantURIList = relationships.get().getRelatedAAIUris(AAIObjectType.TENANT) if (!isEmpty(tenantURIList)) { - String volumeGroupTenantId = tenantURIList.get(0).getURIKeys().get("tenant-id") + String volumeGroupTenantId = tenantURIList.get(0).getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId) execution.setVariable('UPDVfModVol_volumeGroupTenantId', volumeGroupTenantId) logger.debug("Received Tenant Id {} from AAI for Volume Group with Volume Group Id {}, AIC Cloud Region ", volumeGroupTenantId, volumeGroupId, aicCloudRegion) 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 053e2b36d1..8dd014a076 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 @@ -32,9 +32,9 @@ import org.onap.so.bpmn.core.domain.ModelInfo import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.domain.VnfResource 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.aaiclient.client.aai.AAIRestClientImpl +import org.onap.aaiclient.client.aai.AAIUpdatorImpl +import org.onap.aaiclient.client.aai.AAIValidatorImpl import org.onap.logging.filter.base.ErrorCode 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/VnfCmBase.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy index 980128c848..aa3512379a 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 @@ -26,6 +26,12 @@ 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.aaiclient.client.aai.* +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.Relationships +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder import org.onap.appc.client.lcm.model.Action import org.onap.appc.client.lcm.model.ActionIdentifiers import org.onap.appc.client.lcm.model.Flags @@ -39,11 +45,6 @@ import org.onap.so.bpmn.core.domain.ModelInfo import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.domain.VnfResource 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.Relationships -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.MessageEnum @@ -248,7 +249,7 @@ public abstract class VnfCmBase extends AbstractServiceTaskProcessor { for (AAIResourceUri j in vserverUris) { - String vserverId = j.getURIKeys().get('vserver-id') + String vserverId = j.getURIKeys().get(AAIFluentTypeBuilder.Types.VSERVER.getUriParams().vserverId) String vserverJson = client.get(j).getJson() logger.debug("Retrieved vserverJson from AAI: {}", vserverJson) String vserverSelfLink = jsonUtils.getJsonValue(vserverJson, "vserver-selflink") 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 70b7ec102b..ddc80f6a50 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 @@ -28,10 +28,10 @@ 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.AAIResourceUri -import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.aai.* +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory 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/VnfInPlaceUpdate.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy index c5f117b35f..603d5e4dd9 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 @@ -31,10 +31,10 @@ 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.AAIResourceUri -import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.aai.* +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.so.client.appc.ApplicationControllerClient import org.onap.so.client.appc.ApplicationControllerSupport import org.onap.so.logger.LoggingAnchor 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 5205fa1874..dd1dae6edd 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 @@ -21,9 +21,17 @@ */ package org.onap.so.bpmn.vcpe.scripts -import org.onap.so.logger.LoggingAnchor +import javax.ws.rs.NotFoundException import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.Relationships +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder +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 @@ -31,19 +39,11 @@ 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.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.onap.so.client.aai.AAIResourcesClient -import org.onap.so.client.aai.AAIObjectType -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.AAIUriFactory -import javax.ws.rs.NotFoundException - /** * This groovy class supports the <class>DeleteVcpeResCustService.bpmn</class> process. * @@ -220,7 +220,7 @@ public class DeleteVcpeResCustService extends AbstractServiceTaskProcessor { List<AAIResourceUri> vnfUris = relationships.get().getRelatedAAIUris(AAIObjectType.GENERIC_VNF) for(AAIResourceUri u:vnfUris){ Map<String, String> keys = u.getURIKeys() - String vnfId = keys.get("vnf-id") + String vnfId = keys.get(AAIFluentTypeBuilder.Types.GENERIC_VNF.getUriParams().vnfId) relatedVnfIdList.add(vnfId) } List<AAIResourceUri> arUris = relationships.get().getRelatedAAIUris(AAIObjectType.ALLOTTED_RESOURCE) 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 a4f7766c15..683b82e4a7 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 @@ -32,10 +32,10 @@ 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.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.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum 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 fc50d3a3b3..9782440e85 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 @@ -31,9 +31,9 @@ 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.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.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResources.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResources.java index ce53044052..1cc68953f8 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResources.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResources.java @@ -24,10 +24,10 @@ import java.util.HashMap; import java.util.Map; import java.util.Optional; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; -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.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAIDeleteServiceInstance.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAIDeleteServiceInstance.java index c489ef29ce..22166483b1 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAIDeleteServiceInstance.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAIDeleteServiceInstance.java @@ -23,9 +23,9 @@ package org.onap.so.bpmn.infrastructure.aai; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; import org.onap.so.bpmn.common.scripts.ExceptionUtil; -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.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAIResource.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAIResource.java index 1410752f76..a6971318b7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAIResource.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/AAIResource.java @@ -20,7 +20,7 @@ package org.onap.so.bpmn.infrastructure.aai; -import org.onap.so.client.aai.AAIResourcesClient; +import org.onap.aaiclient.client.aai.AAIResourcesClient; import org.springframework.stereotype.Component; @Component diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAICreateResources.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAICreateResources.java index bbca10be0f..c2e2a3c258 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAICreateResources.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAICreateResources.java @@ -27,11 +27,11 @@ import java.util.Map; import java.util.Optional; import org.onap.aai.domain.yang.OwningEntities; import org.onap.aai.domain.yang.OwningEntity; -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.AAIResourceUri; -import org.onap.so.client.aai.entities.uri.AAIUriFactory; +import org.onap.aaiclient.client.aai.AAIObjectPlurals; +import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.AAIResourcesClient; +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIDeleteServiceInstance.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIDeleteServiceInstance.java index 11707c4149..bb7415da93 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIDeleteServiceInstance.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIDeleteServiceInstance.java @@ -23,10 +23,10 @@ package org.onap.so.bpmn.infrastructure.aai.groovyflows; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; import org.onap.so.bpmn.common.scripts.ExceptionUtil; -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.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.AAIResourcesClient; +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/api/ControllerContext.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/api/ControllerContext.java index 0de211bd7d..147b291ed7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/api/ControllerContext.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/api/ControllerContext.java @@ -18,7 +18,6 @@ */ package org.onap.so.bpmn.infrastructure.decisionpoint.api; -import java.util.Map; import org.camunda.bpm.engine.delegate.DelegateExecution; /** diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigAssignDelegate.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigAssignDelegate.java index dd2601f0d0..c390186fb0 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigAssignDelegate.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigAssignDelegate.java @@ -18,7 +18,6 @@ import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableName 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.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_CUSTOMIZATION_UUID; -import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_INSTANCE_NAME; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.SERVICE_INSTANCE_ID; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; 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 e6df8070a3..001e166893 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 @@ -22,11 +22,11 @@ package org.onap.so.bpmn.infrastructure.pnf.management; import java.util.Optional; import org.onap.aai.domain.yang.Pnf; -import org.onap.so.client.aai.AAIObjectType; -import org.onap.so.client.aai.AAIResourcesClient; -import org.onap.so.client.aai.AAIRestClientImpl; -import org.onap.so.client.aai.entities.uri.AAIResourceUri; -import org.onap.so.client.aai.entities.uri.AAIUriFactory; +import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.AAIResourcesClient; +import org.onap.aaiclient.client.aai.AAIRestClientImpl; +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.springframework.stereotype.Component; @Component 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 c63edc93c7..99ed7b1e91 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 @@ -54,19 +54,19 @@ import org.onap.aai.domain.yang.LogicalLinks; import org.onap.aai.domain.yang.PInterface; import org.onap.aai.domain.yang.Pnf; import org.onap.aai.domain.yang.Relationship; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.bpmn.core.UrnPropertiesReader; import org.onap.so.bpmn.core.domain.Resource; import org.onap.so.bpmn.core.domain.ServiceDecomposition; import org.onap.so.bpmn.core.json.JsonUtils; -import org.onap.so.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.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.logging.filter.base.ErrorCode; +import org.onap.aaiclient.client.aai.AAIObjectPlurals; +import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.AAIResourcesClient; +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; +import org.onap.aaiclient.client.aai.entities.Relationships; +import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri; +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -93,7 +93,7 @@ public class ServicePluginFactory { private static final String VS_UNMONITORED = "VS_besteffort"; private static final String TS_MONITORED = "TS1"; private static final String TS_UNMONITORED = "TS2"; - private static final String CUSTOM_TP_LIST[] = + private static final String[] CUSTOM_TP_LIST = new String[] {VS_MONITORED, VS_UNMONITORED, TS_MONITORED, TS_UNMONITORED}; static { @@ -108,10 +108,14 @@ public class ServicePluginFactory { logger.error("Failed to load property file, Either property file is missing or empty!"); } } catch (IOException e) { - logger.error("Failed to load property file!"); + logger.error("Failed to load property file!", e); } } + private ServicePluginFactory() { + + } + public static synchronized ServicePluginFactory getInstance() { if (null == instance) { instance = new ServicePluginFactory(); @@ -119,9 +123,6 @@ public class ServicePluginFactory { return instance; } - private ServicePluginFactory() { - - } private String getInventoryOSSEndPoint() { return UrnPropertiesReader.getVariable("mso.service-plugin.inventory-oss-endpoint", @@ -197,7 +198,7 @@ public class ServicePluginFactory { return false; } - Map<String, Object> accessTPInfo = new HashMap<String, Object>(); + Map<String, Object> accessTPInfo = new HashMap<>(); accessTPInfo.put("access-provider-id", tpInfoMap.get("access-provider-id")); accessTPInfo.put("access-client-id", tpInfoMap.get("access-client-id")); accessTPInfo.put("access-topology-id", tpInfoMap.get("access-topology-id")); @@ -254,7 +255,7 @@ public class ServicePluginFactory { } } - Map<String, Object> tpInfoMap = new HashMap<String, Object>(); + Map<String, Object> tpInfoMap = new HashMap<>(); // Site resource has location param and SOTNAttachment resource has clientSignal param if (location == null || clientSignal == null) { @@ -413,8 +414,6 @@ public class ServicePluginFactory { serviceRequestInputs.put("remote-access-node-id", crossTPs.get("remote-access-node-id")); serviceRequestInputs.put("remote-access-ltp-id", crossTPs.get("remote-access-ltp-id")); } - - return; } private LogicalLink selectLogicalLink(List<LogicalLink> logicalLinks, String svcName) { @@ -430,14 +429,14 @@ public class ServicePluginFactory { if (relationship.getRelatedTo().equals("p-interface") && relationship.getRelatedLink().contains("-ltpId-" + localTp) && link.getOperationalStatus().equalsIgnoreCase("up")) { - logger.info("linkname:" + link.getLinkName() + " is matching with allowed list"); + logger.info("linkname:{} is matching with allowed list", link.getLinkName()); return link; } } } } - logger.error("There is no matching logical link for allowed list :" + Arrays.toString(allowedList)); + logger.error("There is no matching logical link for allowed list :{}", Arrays.toString(allowedList)); return null; } else { logger.info("link customization is not required"); @@ -459,7 +458,7 @@ public class ServicePluginFactory { if (link != null) { boolean isRemoteLink = false; - logger.info("processing link :" + link.getLinkName()); + logger.info("processing link :{}", link.getLinkName()); AAIResultWrapper wrapper = new AAIResultWrapper(link); Optional<Relationships> optRelationships = wrapper.getRelationships(); List<AAIResourceUri> pInterfaces = new ArrayList<>(); @@ -484,70 +483,7 @@ public class ServicePluginFactory { remoteTP = pInterfaces.get(1); } - if (localTP != null && remoteTP != null) { - // give local tp - String tpUrl = localTP.build().toString(); - String localNodeId = tpUrl.split("/")[4]; - tpInfo.put("local-access-node-id", localNodeId); - - logger.info("Get info for local TP :" + localNodeId); - Optional<Pnf> optLocalPnf = client.get(Pnf.class, - AAIUriFactory.createResourceUri(AAIObjectType.PNF, localNodeId)); - - if (optLocalPnf.isPresent()) { - Pnf localPnf = optLocalPnf.get(); - - for (Relationship rel : localPnf.getRelationshipList().getRelationship()) { - if (rel.getRelatedTo().equalsIgnoreCase("network-resource")) { - String[] networkRef = rel.getRelatedLink() - .substring(rel.getRelatedLink().lastIndexOf("/") + 1).split("-"); - if (networkRef.length == 6) { - tpInfo.put("local-access-provider-id", networkRef[1]); - tpInfo.put("local-access-client-id", networkRef[3]); - tpInfo.put("local-access-topology-id", networkRef[5]); - } - } - } - } - String ltpIdStr = tpUrl.substring(tpUrl.lastIndexOf("/") + 1); - if (ltpIdStr.contains("-")) { - tpInfo.put("local-access-ltp-id", ltpIdStr.substring(ltpIdStr.lastIndexOf("-") + 1)); - } - - // give remote tp - tpUrl = remoteTP.build().toString(); - PInterface intfRemote = client.get(PInterface.class, remoteTP).get(); - - String remoteNodeId = tpUrl.split("/")[4]; - tpInfo.put("remote-access-node-id", remoteNodeId); - - logger.info("Get info for remote TP:" + remoteNodeId); - - String[] networkRefRemote = intfRemote.getNetworkRef().split("-"); - Optional<Pnf> optRemotePnf = client.get(Pnf.class, - AAIUriFactory.createResourceUri(AAIObjectType.PNF, remoteNodeId)); - - if (optRemotePnf.isPresent()) { - Pnf remotePnf = optRemotePnf.get(); - - for (Relationship rel : remotePnf.getRelationshipList().getRelationship()) { - if (rel.getRelatedTo().equalsIgnoreCase("network-resource")) { - String[] networkRef = rel.getRelatedLink() - .substring(rel.getRelatedLink().lastIndexOf("/") + 1).split("-"); - if (networkRef.length == 6) { - tpInfo.put("remote-access-provider-id", networkRefRemote[1]); - tpInfo.put("remote-access-client-id", networkRefRemote[3]); - tpInfo.put("remote-access-topology-id", networkRefRemote[5]); - } - } - } - } - - String ltpIdStrR = tpUrl.substring(tpUrl.lastIndexOf("/") + 1); - if (ltpIdStrR.contains("-")) { - tpInfo.put("remote-access-ltp-id", ltpIdStrR.substring(ltpIdStr.lastIndexOf("-") + 1)); - } - } + tpInfo = getTPInfo(client, localTP, remoteTP); } } } @@ -555,6 +491,91 @@ public class ServicePluginFactory { return tpInfo; } + private Map<String, Object> getTPInfo(AAIResourcesClient client, AAIResourceUri localTP, AAIResourceUri remoteTP) { + + Map<String, Object> tpInfo = new HashMap<>(); + + if (localTP != null && remoteTP != null) { + // give local tp + String tpUrl = localTP.build().toString(); + String localNodeId = tpUrl.split("/")[4]; + tpInfo.put("local-access-node-id", localNodeId); + + logger.info("Get info for local TP :{}", localNodeId); + Optional<Pnf> optLocalPnf = + client.get(Pnf.class, AAIUriFactory.createResourceUri(AAIObjectType.PNF, localNodeId)); + + + getTpInfoFromLocalTp(tpInfo, optLocalPnf); + + String ltpIdStr = tpUrl.substring(tpUrl.lastIndexOf("/") + 1); + if (ltpIdStr.contains("-")) { + tpInfo.put("local-access-ltp-id", ltpIdStr.substring(ltpIdStr.lastIndexOf("-") + 1)); + } + + // give remote tp + tpUrl = remoteTP.build().toString(); + PInterface intfRemote = client.get(PInterface.class, remoteTP).get(); + + String remoteNodeId = tpUrl.split("/")[4]; + tpInfo.put("remote-access-node-id", remoteNodeId); + + logger.info("Get info for remote TP:{}", remoteNodeId); + + String[] networkRefRemote = intfRemote.getNetworkRef().split("-"); + Optional<Pnf> optRemotePnf = + client.get(Pnf.class, AAIUriFactory.createResourceUri(AAIObjectType.PNF, remoteNodeId)); + + getTpInfoFromRemoteTp(tpInfo, networkRefRemote, optRemotePnf); + + String ltpIdStrR = tpUrl.substring(tpUrl.lastIndexOf("/") + 1); + if (ltpIdStrR.contains("-")) { + tpInfo.put("remote-access-ltp-id", ltpIdStrR.substring(ltpIdStr.lastIndexOf("-") + 1)); + } + } + + return tpInfo; + } + + + private void getTpInfoFromLocalTp(Map<String, Object> tpInfo, Optional<Pnf> optLocalPnf) { + if (optLocalPnf.isPresent()) { + Pnf localPnf = optLocalPnf.get(); + + for (Relationship rel : localPnf.getRelationshipList().getRelationship()) { + if (rel.getRelatedTo().equalsIgnoreCase("network-resource")) { + String[] networkRef = + rel.getRelatedLink().substring(rel.getRelatedLink().lastIndexOf("/") + 1).split("-"); + if (networkRef.length == 6) { + tpInfo.put("local-access-provider-id", networkRef[1]); + tpInfo.put("local-access-client-id", networkRef[3]); + tpInfo.put("local-access-topology-id", networkRef[5]); + } + } + } + } + } + + private void getTpInfoFromRemoteTp(Map<String, Object> tpInfo, String[] networkRefRemote, + Optional<Pnf> optRemotePnf) { + if (optRemotePnf.isPresent()) { + Pnf remotePnf = optRemotePnf.get(); + + for (Relationship rel : remotePnf.getRelationshipList().getRelationship()) { + if (rel.getRelatedTo().equalsIgnoreCase("network-resource")) { + String[] networkRef = + rel.getRelatedLink().substring(rel.getRelatedLink().lastIndexOf("/") + 1).split("-"); + if (networkRef.length == 6) { + tpInfo.put("remote-access-provider-id", networkRefRemote[1]); + tpInfo.put("remote-access-client-id", networkRefRemote[3]); + tpInfo.put("remote-access-topology-id", networkRefRemote[5]); + } + } + } + } + } + + // this method check if pInterface is remote private boolean isRemotePInterface(AAIResourcesClient client, AAIResourceUri uri) { @@ -899,6 +920,7 @@ public class ServicePluginFactory { return responseContent; } catch (Exception e) { + logger.debug("Exception in sendRequest", e); return null; } finally { 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 de8a35de06..e614ddd28d 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 @@ -109,7 +109,7 @@ public abstract class AbstractSdncOperationTask implements JavaDelegate { objectMapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); postBody = objectMapper.writeValueAsString(inputEntity); } catch (JsonProcessingException e) { - logger.error(Arrays.toString(e.getStackTrace())); + logger.error("JsonProcessingException in getPostbody", e); } return postBody; } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/HeaderUtil.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/HeaderUtil.java index 3da5b0de70..d2a5c36096 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/HeaderUtil.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/HeaderUtil.java @@ -7,9 +7,9 @@ * 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. @@ -21,9 +21,13 @@ package org.onap.so.bpmn.infrastructure.workflow.serviceTask.client; import java.util.Base64; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class HeaderUtil { + private static Logger logger = LoggerFactory.getLogger(HeaderUtil.class); + public static final String USER = "admin"; public static final String PASS = "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U"; public static final String DefaulAuth = getAuthorization(USER, PASS); @@ -38,6 +42,7 @@ public class HeaderUtil { try { base64 = Base64.getEncoder().encodeToString(str.getBytes("utf-8")); } catch (Exception ex) { + logger.error("Exception in base64Encode", ex); } return base64; } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResourceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResourceTest.groovy index d4857503b5..1551533e53 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResourceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResourceTest.groovy @@ -27,9 +27,9 @@ import org.mockito.Mockito import org.mockito.MockitoAnnotations import org.mockito.Spy import org.onap.so.bpmn.common.scripts.MsoGroovyTest -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.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import javax.ws.rs.NotFoundException diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy index 1b92592e37..09b17701a6 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy @@ -34,10 +34,10 @@ import org.mockito.runners.MockitoJUnitRunner import org.onap.aai.domain.yang.ResultData import org.onap.aai.domain.yang.SearchResults 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 org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import static org.junit.Assert.assertEquals import static org.mockito.Mockito.* 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 index 8c08e51efe..39d0334bef 100644 --- 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 @@ -30,10 +30,10 @@ 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 org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import javax.ws.rs.NotFoundException import javax.ws.rs.core.Response 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 index fb50fcc43b..1a9c6bb474 100644 --- 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 @@ -27,10 +27,10 @@ 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 org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import javax.ws.rs.NotFoundException diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy index 50d5506c23..7137799433 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy @@ -35,11 +35,11 @@ import org.onap.aai.domain.yang.VolumeGroup import org.onap.so.bpmn.common.scripts.DeleteAAIVfModule 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 org.onap.so.client.graphinventory.exceptions.GraphInventoryUriComputationException +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryUriComputationException import javax.ws.rs.NotFoundException 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 index 37207f8022..12783ae047 100644 --- 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 @@ -30,7 +30,7 @@ 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 org.onap.aaiclient.client.aai.AAIResourcesClient import static com.shazam.shazamcrest.MatcherAssert.assertThat import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceTest.groovy index e8170ed2cb..2b1e748de5 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceTest.groovy @@ -46,8 +46,8 @@ import org.mockito.runners.MockitoJUnitRunner import org.onap.aai.domain.yang.L3Network import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.client.aai.AAIResourcesClient -import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import com.github.tomakehurst.wiremock.client.WireMock import com.github.tomakehurst.wiremock.junit.WireMockRule import org.apache.commons.lang3.* diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceTest.groovy index 90c7b71a07..158c43c27a 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceTest.groovy @@ -33,7 +33,7 @@ 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.mock.StubResponseAAI -import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import static org.mockito.Mockito.* diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstanceTest.groovy index c359f74d7f..32ebf09531 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstanceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstanceTest.groovy @@ -32,9 +32,9 @@ import org.mockito.Mockito import org.mockito.MockitoAnnotations import org.mockito.Spy import org.onap.so.bpmn.common.scripts.MsoGroovyTest -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.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import javax.ws.rs.NotFoundException import static org.junit.Assert.assertEquals import static org.mockito.ArgumentMatchers.isA 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 7107d15602..b2573f1b51 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 @@ -43,12 +43,12 @@ import org.onap.so.bpmn.common.scripts.utils.XmlComparator import org.onap.so.bpmn.core.RollbackData 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 +import org.onap.aaiclient.client.aai.AAIObjectPlurals +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryUriComputationException import javax.ws.rs.NotFoundException 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 8941a24ebc..cc522544de 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 @@ -26,10 +26,10 @@ import org.onap.aai.domain.yang.VfModule 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.aaiclient.client.aai.AAIObjectPlurals +import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.so.constants.Defaults import static org.mockito.Mockito.spy 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 22414b770e..7aa162cae7 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 @@ -38,11 +38,11 @@ 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.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.aaiclient.client.aai.AAIObjectPlurals +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.so.constants.Defaults import static org.junit.Assert.assertEquals diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2Test.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2Test.groovy index 6b3674d908..a3b2a1c8b9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2Test.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2Test.groovy @@ -27,9 +27,9 @@ import org.mockito.Spy import org.onap.aai.domain.yang.AllottedResource import org.onap.so.bpmn.common.scripts.MsoGroovyTest import org.onap.so.bpmn.mock.FileUtil -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.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import javax.ws.rs.core.UriBuilder import static org.mockito.Mockito.times import static org.mockito.Mockito.when 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 index 493e2c9e1e..88140d83ce 100644 --- 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 @@ -35,9 +35,9 @@ 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 org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import javax.ws.rs.core.Response diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollbackTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollbackTest.groovy deleted file mode 100644 index 5e264c0af4..0000000000 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollbackTest.groovy +++ /dev/null @@ -1,343 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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 static org.mockito.Mockito.* - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.ProcessEngineServices -import org.camunda.bpm.engine.RepositoryService -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl -import org.camunda.bpm.engine.repository.ProcessDefinition -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner -import org.mockito.internal.debugging.MockitoDebuggerImpl -import org.onap.so.bpmn.common.scripts.MsoUtils -import org.onap.so.bpmn.core.WorkflowException -import org.junit.Before -import org.junit.Rule; -import org.junit.Test -import org.junit.Ignore -import org.junit.runner.RunWith - -import static org.junit.Assert.*; - -import com.github.tomakehurst.wiremock.client.WireMock; -import com.github.tomakehurst.wiremock.junit.WireMockRule; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.apache.commons.lang3.* - - -@RunWith(MockitoJUnitRunner.class) -class DoDeleteNetworkInstanceRollbackTest { - - @Rule - public WireMockRule wireMockRule = new WireMockRule(8090); - - def utils = new MsoUtils() - String Prefix="DELNWKIR_" - - - String rollbackNetworkRequest = - """<NetworkAdapter:rollbackNetwork xmlns:NetworkAdapter="http://org.onap.so/network"> - <rollback> - <networkId>MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641</networkId> - <neutronNetworkId>c4f4e878-cde0-4b15-ae9a-bda857759cea</neutronNetworkId> - <networkStackId/> - <networkType>CONTRAIL_EXTERNAL</networkType> - <networkCreated>true</networkCreated> - <tenantId>7dd5365547234ee8937416c65507d266</tenantId> - <cloudSiteId>RDM2WAGPLCP</cloudSiteId> - <msoRequest> - <requestId>1ef47428-cade-45bd-a103-0751e8b2deb0</requestId> - <serviceInstanceId/> - </msoRequest> - </rollback> -</NetworkAdapter:rollbackNetwork>""" - - String rollbackDeActivateSDNCRequest = - """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" - xmlns:ns5="http://org.onap/so/request/types/v1" - xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>88f65519-9a38-4c4b-8445-9eb4a5a5af56</sdncadapter:RequestId> - <sdncadapter:SvcInstanceId>f70e927b-6087-4974-9ef8-c5e4d5847ca4</sdncadapter:SvcInstanceId> - <sdncadapter:SvcAction>activate</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>network-topology-operation</sdncadapter:SvcOperation> - <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl> - <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction> - </sdncadapter:RequestHeader> - <aetgt:SDNCRequestData> - <request-information> - <request-id>88f65519-9a38-4c4b-8445-9eb4a5a5af56</request-id> - <request-action>CreateNetworkInstance</request-action> - <source>VID</source> - <notification-url/> - <order-number/> - <order-version/> - </request-information> - <service-information> - <service-id>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-id> - <service-type>MSO-dev-service-type</service-type> - <service-instance-id>f70e927b-6087-4974-9ef8-c5e4d5847ca4</service-instance-id> - <subscriber-name>MSO_1610_dev</subscriber-name> - </service-information> - <network-information> - <network-id>8abc633a-810b-4ca5-8b3a-09511d13a2ce</network-id> - <network-type>CONTRAIL_EXTERNAL</network-type> - <onap-model-information> - <model-invariant-uuid>invariant-uuid</model-invariant-uuid> - <model-customization-uuid>customization-uuid</model-customization-uuid> - <model-uuid>uuid</model-uuid> - <model-version>version</model-version> - <model-name>CONTRAIL_EXTERNAL</model-name> - </onap-model-information> - </network-information> - <network-request-information> - <network-id>8abc633a-810b-4ca5-8b3a-09511d13a2ce</network-id> - <network-type>CONTRAIL_EXTERNAL</network-type> - <network-name>MNS-25180-L-01-dmz_direct_net_1</network-name> - <tenant>7dd5365547234ee8937416c65507d266</tenant> - <aic-cloud-region>RDM2WAGPLCP</aic-cloud-region> - </network-request-information> - </aetgt:SDNCRequestData> -</aetgt:SDNCAdapterWorkflowRequest>""" - - String rollbackSDNCRequest = - """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" - xmlns:ns5="http://org.onap/so/request/types/v1" - xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>88f65519-9a38-4c4b-8445-9eb4a5a5af56</sdncadapter:RequestId> - <sdncadapter:SvcInstanceId>f70e927b-6087-4974-9ef8-c5e4d5847ca4</sdncadapter:SvcInstanceId> - <sdncadapter:SvcAction>rollback</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>network-topology-operation</sdncadapter:SvcOperation> - <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl> - </sdncadapter:RequestHeader> - <aetgt:SDNCRequestData> - <request-information> - <request-id>88f65519-9a38-4c4b-8445-9eb4a5a5af56</request-id> - <request-action>CreateNetworkInstance</request-action> - <source>VID</source> - <notification-url/> - <order-number/> - <order-version/> - </request-information> - <service-information> - <service-id>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-id> - <service-type>MSO-dev-service-type</service-type> - <service-instance-id>f70e927b-6087-4974-9ef8-c5e4d5847ca4</service-instance-id> - <subscriber-name>MSO_1610_dev</subscriber-name> - </service-information> - <network-information> - <network-id>8abc633a-810b-4ca5-8b3a-09511d13a2ce</network-id> - <network-type>CONTRAIL_EXTERNAL</network-type> - <onap-model-information> - <model-invariant-uuid>invariant-uuid</model-invariant-uuid> - <model-customization-uuid>customization-uuid</model-customization-uuid> - <model-uuid>uuid</model-uuid> - <model-version>version</model-version> - <model-name>CONTRAIL_EXTERNAL</model-name> - </onap-model-information> - </network-information> - <network-request-information> - <network-id>8abc633a-810b-4ca5-8b3a-09511d13a2ce</network-id> - <network-type>CONTRAIL_EXTERNAL</network-type> - <network-name>MNS-25180-L-01-dmz_direct_net_1</network-name> - <tenant>7dd5365547234ee8937416c65507d266</tenant> - <aic-cloud-region>RDM2WAGPLCP</aic-cloud-region> - </network-request-information> - </aetgt:SDNCRequestData> -</aetgt:SDNCAdapterWorkflowRequest>""" - -// - - - - - - - - - - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) - } - - public void initializeVariables (DelegateExecution mockExecution) { - - verify(mockExecution).setVariable(Prefix + "WorkflowException", null) - - verify(mockExecution).setVariable(Prefix + "rollbackDeactivateSDNCRequest", null) - verify(mockExecution).setVariable(Prefix + "rollbackDeactivateSDNCResponse", "") - verify(mockExecution).setVariable(Prefix + "rollbackDeactivateSDNCReturnCode", "") - - verify(mockExecution).setVariable(Prefix + "rollbackNetworkRequest", null) - verify(mockExecution).setVariable(Prefix + "rollbackNetworkResponse", "") - verify(mockExecution).setVariable(Prefix + "rollbackNetworkReturnCode", "") - - verify(mockExecution).setVariable(Prefix + "Success", false) - verify(mockExecution).setVariable(Prefix + "fullRollback", false) - - } - - @Test - //@Ignore - public void preProcessRequest() { - - println "************ preProcessRequest ************* " - - WorkflowException workflowException = new WorkflowException("DoCreateNetworkInstance", 2500, "Received error from Network Adapter: JBWEB000065: HTTP Status 500.") - Map<String, String> rollbackData = new HashMap<String, String>(); - rollbackData.put("rollbackDeactivateSDNCRequest", rollbackDeActivateSDNCRequest) - rollbackData.put("rollbackNetworkRequest", rollbackNetworkRequest) - rollbackData.put("rollbackSDNCRequest", rollbackSDNCRequest) - - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") - when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) - when(mockExecution.getVariable("rollbackData")).thenReturn(rollbackData) - when(mockExecution.getVariable("sdncVersion")).thenReturn("1702") - - when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - when(mockExecution.getVariable("mso.adapters.sdnc.endpoint")).thenReturn("http://localhost:8090/SDNCAdapter") - when(mockExecution.getVariable("mso.adapters.network.rest.endpoint")).thenReturn("http://localhost:8090/networks/NetworkAdapter") - when(mockExecution.getVariable("mso.adapters.sdnc.resource.endpoint")).thenReturn("http://localhost:8090/SDNCAdapterRpc") - - - // preProcessRequest(DelegateExecution execution) - DoDeleteNetworkInstanceRollback DoDeleteNetworkInstanceRollback = new DoDeleteNetworkInstanceRollback() - DoDeleteNetworkInstanceRollback.preProcessRequest(mockExecution) - - //verify variable initialization - initializeVariables(mockExecution) - -// verify(mockExecution).getVariable("isDebugLogEnabled") - verify(mockExecution).setVariable("prefix", Prefix) - - } - - - @Test - //@Ignore - public void validateRollbackResponses_Good() { - - WorkflowException workflowException = new WorkflowException("DoDeleteNetworkInstanceRollback", 2500, "AAI Update Contrail Failed. Error 404.") - WorkflowException expectedWorkflowException = new WorkflowException("DoDeleteNetworkInstanceRollback", 2500, "AAI Update Contrail Failed. Error 404. + SNDC deactivate rollback completed. + PO Network rollback completed. + SNDC unassign rollback completed.") - - println "************ validateRollbackResponses_Good() ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") - - when(mockExecution.getVariable(Prefix + "rollbackDeactivateSDNCRequest")).thenReturn("Good") - when(mockExecution.getVariable(Prefix + "rollbackDeactivateSDNCReturnCode")).thenReturn("200") - when(mockExecution.getVariable(Prefix + "rollbackDeactivateSDNCResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn("Good") - when(mockExecution.getVariable(Prefix + "rollbackNetworkReturnCode")).thenReturn("200") - when(mockExecution.getVariable(Prefix + "rollbackNetworkResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable(Prefix + "rollbackSDNCRequest")).thenReturn("Good") - when(mockExecution.getVariable(Prefix + "rollbackSDNCReturnCode")).thenReturn("200") - when(mockExecution.getVariable(Prefix + "rollbackSDNCResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable(Prefix + "WorkflowException")).thenReturn(workflowException) - when(mockExecution.getVariable(Prefix + "fullRollback")).thenReturn(false) - - DoDeleteNetworkInstanceRollback DoDeleteNetworkInstanceRollback = new DoDeleteNetworkInstanceRollback() - DoDeleteNetworkInstanceRollback.validateRollbackResponses(mockExecution) - - // verify set prefix = Prefix + "" - verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) - verify(mockExecution, atLeast(1)).setVariable("rolledBack", true) - verify(mockExecution, atLeast(1)).setVariable("wasDeleted", true) - verify(mockExecution).setVariable("WorkflowException", refEq(expectedWorkflowException, any(WorkflowException.class))) - //verify(mockExecution).setVariable("WorkflowException", expectedWorkflowException) - } - - @Test - //@Ignore - public void validateRollbackResponses_FullRollback() { - - Map<String, String> rollbackData = new HashMap<String, String>(); - rollbackData.put("rollbackDeactivateSDNCRequest", rollbackDeActivateSDNCRequest) - rollbackData.put("rollbackNetworkRequest", rollbackNetworkRequest) - rollbackData.put("rollbackSDNCRequest", rollbackSDNCRequest) - - println "************ validateRollbackResponses_FullRollback() ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") - - when(mockExecution.getVariable(Prefix + "rollbackDeactivateSDNCRequest")).thenReturn("Good") - when(mockExecution.getVariable(Prefix + "rollbackDeactivateSDNCReturnCode")).thenReturn("200") - when(mockExecution.getVariable(Prefix + "rollbackDeactivateSDNCResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn("Good") - when(mockExecution.getVariable(Prefix + "rollbackNetworkReturnCode")).thenReturn("200") - when(mockExecution.getVariable(Prefix + "rollbackNetworkResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable(Prefix + "rollbackSDNCRequest")).thenReturn("Good") - when(mockExecution.getVariable(Prefix + "rollbackSDNCReturnCode")).thenReturn("200") - when(mockExecution.getVariable(Prefix + "rollbackSDNCResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable(Prefix + "WorkflowException")).thenReturn(null) - when(mockExecution.getVariable(Prefix + "fullRollback")).thenReturn(true) - when(mockExecution.getVariable("rollbackData")).thenReturn(rollbackData) - - DoDeleteNetworkInstanceRollback DoDeleteNetworkInstanceRollback = new DoDeleteNetworkInstanceRollback() - DoDeleteNetworkInstanceRollback.validateRollbackResponses(mockExecution) - - // verify set prefix = Prefix + "" - verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) - verify(mockExecution, atLeast(1)).setVariable("rollbackSuccessful", true) - verify(mockExecution, atLeast(1)).setVariable("rollbackError", false) - - } - - - private ExecutionEntity setupMock() { - - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("DoDeleteNetworkInstanceRollback") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoDeleteNetworkInstanceRollback") - when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") - ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) - when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) - - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - - when(mockExecution.getId()).thenReturn("100") - when(mockExecution.getProcessDefinitionId()).thenReturn("DoDeleteNetworkInstanceRollback") - when(mockExecution.getProcessInstanceId()).thenReturn("DoDeleteNetworkInstanceRollback") - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - - return mockExecution - } - -} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceTest.groovy index a95a01912d..3b172f3015 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceTest.groovy @@ -42,10 +42,10 @@ import org.onap.aai.domain.yang.RelationshipList import org.onap.so.bpmn.common.scripts.MsoGroovyTest import org.onap.so.bpmn.common.scripts.MsoUtils 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.client.graphinventory.entities.uri.Depth +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.graphinventory.entities.uri.Depth import org.onap.so.constants.Defaults import com.github.tomakehurst.wiremock.client.WireMock 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 index 8a18376819..9dbb6a5a56 100644 --- 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 @@ -27,10 +27,10 @@ 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 org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import javax.ws.rs.NotFoundException diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstanceTest.groovy index c2113e2f28..0251eab668 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstanceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstanceTest.groovy @@ -28,10 +28,10 @@ import org.junit.rules.ExpectedException 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.AAIObjectType -import org.onap.so.client.aai.entities.uri.AAIResourceUri -import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.aai.AAIObjectPlurals +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.so.constants.Defaults import static org.mockito.ArgumentMatchers.isA 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 a8d07b696c..daf005eabf 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 @@ -42,12 +42,12 @@ import org.onap.aai.domain.yang.NetworkPolicies import org.onap.aai.domain.yang.NetworkPolicy 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 +import org.onap.aaiclient.client.aai.AAIObjectPlurals +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.graphinventory.entities.uri.Depth import static com.github.tomakehurst.wiremock.client.WireMock.* import static org.mockito.Mockito.* 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 815b3a389c..0e47958249 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 @@ -45,11 +45,11 @@ import org.onap.so.bpmn.common.scripts.MsoGroovyTest import org.onap.so.bpmn.common.scripts.utils.XmlComparator 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.aaiclient.client.aai.AAIObjectPlurals +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import javax.ws.rs.NotFoundException diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2Test.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2Test.groovy index 2885d6919e..dd8601fb43 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2Test.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2Test.groovy @@ -49,11 +49,11 @@ import org.onap.so.bpmn.common.scripts.utils.XmlComparator import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.mock.FileUtil -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.onap.so.client.graphinventory.exceptions.GraphInventoryUriComputationException +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryUriComputationException import org.springframework.core.env.Environment import org.springframework.mock.env.MockEnvironment diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModulesTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModulesTest.groovy index 9e4ab6f757..2da6eca84e 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModulesTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModulesTest.groovy @@ -39,11 +39,11 @@ import org.mockito.runners.MockitoJUnitRunner import org.onap.aai.domain.yang.GenericVnf 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.uri.AAIResourceUri -import org.onap.so.client.aai.entities.uri.AAIUriFactory -import org.onap.so.client.graphinventory.entities.uri.Depth -import org.onap.so.client.graphinventory.exceptions.GraphInventoryUriComputationException +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.graphinventory.entities.uri.Depth +import org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryUriComputationException import static com.github.tomakehurst.wiremock.client.WireMock.* import static org.mockito.Mockito.* diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollbackTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollbackTest.groovy deleted file mode 100644 index 7bc82c1ccc..0000000000 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollbackTest.groovy +++ /dev/null @@ -1,329 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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 static org.mockito.Mockito.* - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.ProcessEngineServices -import org.camunda.bpm.engine.RepositoryService -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.camunda.bpm.engine.repository.ProcessDefinition -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner -import org.onap.so.bpmn.common.scripts.MsoUtils -import org.onap.so.bpmn.core.WorkflowException -import org.junit.Before -import org.junit.Rule; -import org.junit.Test -import org.junit.Ignore -import org.junit.runner.RunWith - -import static org.junit.Assert.*; - -import com.github.tomakehurst.wiremock.client.WireMock; -import com.github.tomakehurst.wiremock.junit.WireMockRule; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; -import org.apache.commons.lang3.* - - -@RunWith(MockitoJUnitRunner.class) -class DoUpdateNetworkInstanceRollbackTest { - - def utils = new MsoUtils() - String Prefix="UPDNETIR_" - - - String rollbackNetworkRequest = - """<NetworkAdapter:rollbackNetwork xmlns:NetworkAdapter="http://org.onap.so/network"> - <rollback> - <networkId>MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641</networkId> - <neutronNetworkId>c4f4e878-cde0-4b15-ae9a-bda857759cea</neutronNetworkId> - <networkStackId/> - <networkType>CONTRAIL_EXTERNAL</networkType> - <networkCreated>true</networkCreated> - <tenantId>7dd5365547234ee8937416c65507d266</tenantId> - <cloudSiteId>RDM2WAGPLCP</cloudSiteId> - <msoRequest> - <requestId>1ef47428-cade-45bd-a103-0751e8b2deb0</requestId> - <serviceInstanceId/> - </msoRequest> - </rollback> -</NetworkAdapter:rollbackNetwork>""" - - String rollbackActivateSDNCRequest = - """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" - xmlns:ns5="http://org.onap/so/request/types/v1" - xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>88f65519-9a38-4c4b-8445-9eb4a5a5af56</sdncadapter:RequestId> - <sdncadapter:SvcInstanceId>f70e927b-6087-4974-9ef8-c5e4d5847ca4</sdncadapter:SvcInstanceId> - <sdncadapter:SvcAction>rollback</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>network-topology-operation</sdncadapter:SvcOperation> - <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl> - <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction> - </sdncadapter:RequestHeader> - <aetgt:SDNCRequestData> - <request-information> - <request-id>88f65519-9a38-4c4b-8445-9eb4a5a5af56</request-id> - <request-action>CreateNetworkInstance</request-action> - <source>VID</source> - <notification-url/> - <order-number/> - <order-version/> - </request-information> - <service-information> - <service-id>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-id> - <service-type>MSO-dev-service-type</service-type> - <service-instance-id>f70e927b-6087-4974-9ef8-c5e4d5847ca4</service-instance-id> - <subscriber-name>MSO_1610_dev</subscriber-name> - </service-information> - <network-information> - <network-id>8abc633a-810b-4ca5-8b3a-09511d13a2ce</network-id> - <network-type>CONTRAIL_EXTERNAL</network-type> - <onap-model-information> - <model-invariant-uuid>invariant-uuid</model-invariant-uuid> - <model-customization-uuid>customization-uuid</model-customization-uuid> - <model-uuid>uuid</model-uuid> - <model-version>version</model-version> - <model-name>CONTRAIL_EXTERNAL</model-name> - </onap-model-information> - </network-information> - <network-request-information> - <network-id>8abc633a-810b-4ca5-8b3a-09511d13a2ce</network-id> - <network-type>CONTRAIL_EXTERNAL</network-type> - <network-name>MNS-25180-L-01-dmz_direct_net_1</network-name> - <tenant>7dd5365547234ee8937416c65507d266</tenant> - <aic-cloud-region>RDM2WAGPLCP</aic-cloud-region> - </network-request-information> - </aetgt:SDNCRequestData> -</aetgt:SDNCAdapterWorkflowRequest>""" - - String rollbackSDNCRequest = - """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" - xmlns:ns5="http://org.onap/so/request/types/v1" - xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>88f65519-9a38-4c4b-8445-9eb4a5a5af56</sdncadapter:RequestId> - <sdncadapter:SvcInstanceId>f70e927b-6087-4974-9ef8-c5e4d5847ca4</sdncadapter:SvcInstanceId> - <sdncadapter:SvcAction>rollback</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>network-topology-operation</sdncadapter:SvcOperation> - <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl> - <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction> - </sdncadapter:RequestHeader> - <aetgt:SDNCRequestData> - <request-information> - <request-id>88f65519-9a38-4c4b-8445-9eb4a5a5af56</request-id> - <request-action>CreateNetworkInstance</request-action> - <source>VID</source> - <notification-url/> - <order-number/> - <order-version/> - </request-information> - <service-information> - <service-id>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-id> - <service-type>MSO-dev-service-type</service-type> - <service-instance-id>f70e927b-6087-4974-9ef8-c5e4d5847ca4</service-instance-id> - <subscriber-name>MSO_1610_dev</subscriber-name> - </service-information> - <network-information> - <network-id>8abc633a-810b-4ca5-8b3a-09511d13a2ce</network-id> - <network-type>CONTRAIL_EXTERNAL</network-type> - <onap-model-information> - <model-invariant-uuid>invariant-uuid</model-invariant-uuid> - <model-customization-uuid>customization-uuid</model-customization-uuid> - <model-uuid>uuid</model-uuid> - <model-version>version</model-version> - <model-name>CONTRAIL_EXTERNAL</model-name> - </onap-model-information> - </network-information> - <network-request-information> - <network-id>8abc633a-810b-4ca5-8b3a-09511d13a2ce</network-id> - <network-type>CONTRAIL_EXTERNAL</network-type> - <network-name>MNS-25180-L-01-dmz_direct_net_1</network-name> - <tenant>7dd5365547234ee8937416c65507d266</tenant> - <aic-cloud-region>RDM2WAGPLCP</aic-cloud-region> - </network-request-information> - </aetgt:SDNCRequestData> -</aetgt:SDNCAdapterWorkflowRequest>""" - -// - - - - - - - - - - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) - } - - public void initializeVariables (DelegateExecution mockExecution) { - - verify(mockExecution).setVariable(Prefix + "rollbackNetworkRequest", null) - verify(mockExecution).setVariable(Prefix + "rollbackSDNCRequest", null) - verify(mockExecution).setVariable(Prefix + "WorkflowException", null) - - verify(mockExecution).setVariable(Prefix + "rollbackNetworkRequest", "") - verify(mockExecution).setVariable(Prefix + "rollbackNetworkResponse", "") - verify(mockExecution).setVariable(Prefix + "rollbackNetworkReturnCode", "") - - verify(mockExecution).setVariable(Prefix + "rollbackSDNCRequest", "") - verify(mockExecution).setVariable(Prefix + "rollbackSDNCResponse", "") - verify(mockExecution).setVariable(Prefix + "rollbackSDNCReturnCode", "") - - verify(mockExecution).setVariable(Prefix + "Success", false) - verify(mockExecution).setVariable(Prefix + "fullRollback", false) - - - } - - @Test - //@Ignore - public void preProcessRequest() { - - println "************ preProcessRequest ************* " - - WorkflowException workflowException = new WorkflowException("DoUpdateNetworkInstanceRollback", 2500, "Received error from Network Adapter: JBWEB000065: HTTP Status 500.") - Map<String, String> rollbackData = new HashMap<String, String>(); - rollbackData.put("rollbackSDNCRequest", rollbackSDNCRequest) - rollbackData.put("rollbackNetworkRequest", rollbackNetworkRequest) - - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") - when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) - when(mockExecution.getVariable("rollbackData")).thenReturn(rollbackData) - when(mockExecution.getVariable("sdncVersion")).thenReturn("1610") - when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - when(mockExecution.getVariable("mso.adapters.sdnc.endpoint")).thenReturn("http://localhost:28090/SDNCAdapter") - when(mockExecution.getVariable("mso.adapters.network.rest.endpoint")).thenReturn("http://localhost:28090/networks/NetworkAdapter") - when(mockExecution.getVariable("mso.adapters.sdnc.resource.endpoint")).thenReturn("http://localhost:28090/SDNCAdapterRpc") - - - // preProcessRequest(DelegateExecution execution) - DoUpdateNetworkInstanceRollback DoUpdateNetworkInstanceRollback = new DoUpdateNetworkInstanceRollback() - DoUpdateNetworkInstanceRollback.preProcessRequest(mockExecution) - -// verify(mockExecution).getVariable("isDebugLogEnabled") - verify(mockExecution).setVariable("prefix", Prefix) - - //verify variable initialization - initializeVariables(mockExecution) - - } - - - @Test - @Ignore - public void validateRollbackResponses_Good() { - - WorkflowException workflowException = new WorkflowException("DoUpdateNetworkInstanceRollback", 2500, "AAI Update Contrail Failed. Error 404.") - WorkflowException expectedWorkflowException = new WorkflowException("DoUpdateNetworkInstanceRollback", 2500, "AAI Update Contrail Failed. Error 404. + SNDC activate rollback completed. + PO Network rollback completed. + SNDC assign rollback completed.") - - println "************ validateRollbackResponses_Good() ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") - when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn("Good") - when(mockExecution.getVariable(Prefix + "rollbackSDNCRequest")).thenReturn("Good") - when(mockExecution.getVariable(Prefix + "rollbackNetworkReturnCode")).thenReturn("200") - when(mockExecution.getVariable(Prefix + "rollbackNetworkResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable(Prefix + "rollbackSDNCReturnCode")).thenReturn("200") - when(mockExecution.getVariable(Prefix + "rollbackSDNCResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable(Prefix + "WorkflowException")).thenReturn(workflowException) - when(mockExecution.getVariable(Prefix + "fullRollback")).thenReturn(false) - - DoUpdateNetworkInstanceRollback DoUpdateNetworkInstanceRollback = new DoUpdateNetworkInstanceRollback() - DoUpdateNetworkInstanceRollback.validateRollbackResponses(mockExecution) - - // verify set prefix = Prefix + "" - verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) - verify(mockExecution, atLeast(1)).setVariable("rolledBack", true) - verify(mockExecution, atLeast(1)).setVariable("wasDeleted", true) - verify(mockExecution).setVariable("WorkflowException", refEq(expectedWorkflowException, any(WorkflowException.class))) - //verify(mockExecution).setVariable("WorkflowException", expectedWorkflowException) - } - - @Test - //@Ignore - public void validateRollbackResponses_FullRollback() { - - Map<String, String> rollbackData = new HashMap<String, String>(); - rollbackData.put("rollbackSDNCRequest", rollbackSDNCRequest) - rollbackData.put("rollbackNetworkRequest", rollbackNetworkRequest) - - println "************ validateRollbackResponses_FullRollback() ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("prefix")).thenReturn(Prefix) - when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn("Good") - when(mockExecution.getVariable(Prefix + "rollbackSDNCRequest")).thenReturn("Good") - when(mockExecution.getVariable(Prefix + "rollbackNetworkReturnCode")).thenReturn("200") - when(mockExecution.getVariable(Prefix + "rollbackNetworkResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable(Prefix + "rollbackSDNCReturnCode")).thenReturn("200") - when(mockExecution.getVariable(Prefix + "rollbackSDNCResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable(Prefix + "WorkflowException")).thenReturn(null) - when(mockExecution.getVariable(Prefix + "fullRollback")).thenReturn(true) - when(mockExecution.getVariable("rollbackData")).thenReturn(rollbackData) - - DoUpdateNetworkInstanceRollback DoUpdateNetworkInstanceRollback = new DoUpdateNetworkInstanceRollback() - DoUpdateNetworkInstanceRollback.validateRollbackResponses(mockExecution) - - // verify set prefix = Prefix + "" - verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) - verify(mockExecution, atLeast(1)).setVariable("rollbackSuccessful", true) - verify(mockExecution, atLeast(1)).setVariable("rollbackError", false) - - } - - - private ExecutionEntity setupMock() { - - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("DoUpdateNetworkInstanceRollback") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoUpdateNetworkInstanceRollback") - when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") - ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) - when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) - - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - - when(mockExecution.getId()).thenReturn("100") - when(mockExecution.getProcessDefinitionId()).thenReturn("DoUpdateNetworkInstanceRollback") - when(mockExecution.getProcessInstanceId()).thenReturn("DoUpdateNetworkInstanceRollback") - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - - return mockExecution - } - -} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceTest.groovy index 19bb7c86b4..a7d6cad990 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceTest.groovy @@ -39,7 +39,7 @@ import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.mock.FileUtil -import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper import org.springframework.mock.env.MockEnvironment import static org.mockito.ArgumentMatchers.eq diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1Test.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1Test.groovy index 80e2c863e8..bf877bd725 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1Test.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1Test.groovy @@ -40,10 +40,10 @@ import org.onap.aai.domain.yang.VfModule import org.onap.aai.domain.yang.VolumeGroup import org.onap.so.bpmn.common.scripts.MsoGroovyTest import org.onap.so.bpmn.mock.FileUtil -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.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.so.constants.Defaults import javax.ws.rs.core.UriBuilder diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeTest.groovy index 6771476955..6a8465e2b6 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeTest.groovy @@ -38,10 +38,10 @@ import org.onap.aai.domain.yang.VfModule import org.onap.aai.domain.yang.VolumeGroup import org.onap.so.bpmn.common.scripts.MsoGroovyTest import org.onap.so.bpmn.mock.FileUtil -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.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import org.onap.so.constants.Defaults import javax.ws.rs.core.UriBuilder diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy index 09244bedc4..d7f7547459 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy @@ -31,9 +31,9 @@ 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.mock.FileUtil -import org.onap.so.client.aai.AAIObjectType -import org.onap.so.client.aai.AAIResourcesClient -import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import javax.ws.rs.core.UriBuilder diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy index 901bdaf7b3..2a6894785e 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy @@ -29,9 +29,9 @@ import org.mockito.MockitoAnnotations import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.mock.FileUtil -import org.onap.so.client.aai.AAIObjectType -import org.onap.so.client.aai.AAIResourcesClient -import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.aaiclient.client.aai.AAIObjectType +import org.onap.aaiclient.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory import javax.ws.rs.core.UriBuilder diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/GroovyTestBase.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/GroovyTestBase.groovy index 1ff098b940..36cb5ac195 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/GroovyTestBase.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/GroovyTestBase.groovy @@ -33,7 +33,7 @@ import org.mockito.junit.MockitoJUnitRunner import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.AllottedResourceUtils import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.client.aai.AAIResourcesClient +import org.onap.aaiclient.client.aai.AAIResourcesClient import static org.mockito.ArgumentMatchers.any import static org.mockito.Mockito.* 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 05b0db5d25..978814be7f 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 @@ -36,11 +36,11 @@ import org.junit.runner.RunWith; import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; -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.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.AAIResourcesClient; +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; @RunWith(MockitoJUnitRunner.class) public class AAICreateResourcesTest { diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAIDeleteServiceInstanceTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAIDeleteServiceInstanceTest.java index 1aca331a17..64d3fca811 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAIDeleteServiceInstanceTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAIDeleteServiceInstanceTest.java @@ -34,8 +34,8 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.onap.so.client.aai.AAIResourcesClient; -import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.aaiclient.client.aai.AAIResourcesClient; +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; public class AAIDeleteServiceInstanceTest { private AAIDeleteServiceInstance aaiDeleteServiceInstance; |