From fa9a707c87654330dfb5788a6029b8199c6cdf17 Mon Sep 17 00:00:00 2001 From: "Boslet, Cory" Date: Thu, 16 Apr 2020 10:43:38 -0400 Subject: move network adapter to an external client task Began impelenting new network external task. Made the vnfAdapterTask subflow an openstack subflow, refactored infra flows and BB to call it for network functions. Fixed bugs discovered through a robot dry run, added unit test, added support for rollback network request Updated junit test files for comparison due to not polling for response Removed the no longer used network adapter rest task from bpmn tasks Removed the unused network adapter async and its beans Removed network async client package from open pojo scan Issue-ID: SO-2813 Signed-off-by: Benjamin, Max (mb388a) Change-Id: I4c25892012cc86659ab122448ed1aca5cab91671 --- .../org/onap/so/openstack/utils/MsoHeatUtils.java | 22 + .../so/adapters/network/MsoNetworkAdapter.java | 7 +- .../adapters/network/MsoNetworkAdapterAsync.java | 104 - .../network/MsoNetworkAdapterAsyncImpl.java | 605 ------ .../so/adapters/network/MsoNetworkAdapterImpl.java | 38 +- .../so/adapters/network/NetworkAdapterRest.java | 660 ------ .../async/client/CreateNetworkNotification.java | 394 ---- .../client/CreateNetworkNotificationResponse.java | 53 - .../async/client/DeleteNetworkNotification.java | 162 -- .../client/DeleteNetworkNotificationResponse.java | 53 - .../network/async/client/MsoExceptionCategory.java | 61 - .../adapters/network/async/client/MsoRequest.java | 97 - .../network/async/client/NetworkAdapterNotify.java | 170 -- .../async/client/NetworkAdapterNotify_Service.java | 110 - .../network/async/client/NetworkRollback.java | 325 --- .../network/async/client/NetworkStatus.java | 63 - .../network/async/client/ObjectFactory.java | 311 --- .../async/client/QueryNetworkNotification.java | 447 ---- .../client/QueryNetworkNotificationResponse.java | 53 - .../async/client/RollbackNetworkNotification.java | 139 -- .../RollbackNetworkNotificationResponse.java | 53 - .../async/client/UpdateNetworkNotification.java | 350 ---- .../client/UpdateNetworkNotificationResponse.java | 53 - .../network/async/client/package-info.java | 21 - .../so/adapters/openstack/CXFConfiguration.java | 19 +- .../adapters/tasks/orchestration/PollService.java | 36 +- .../tasks/orchestration/RollbackService.java | 16 +- .../adapters/tasks/orchestration/StackService.java | 189 +- .../src/test/java/org/onap/so/BeansTest.java | 1 - .../network/MsoNetworkAdapterAsyncImplTest.java | 269 --- .../adapters/network/NetworkAdapterRestTest.java | 364 ---- .../tasks/orchestration/PollServiceTest.java | 4 +- .../tasks/orchestration/RollbackServiceTest.java | 2 +- .../tasks/orchestration/StackServiceTest.java | 2 +- .../onap/so/client/exception/ExceptionBuilder.java | 2 +- .../resources/subprocess/OpenstackAdapterTask.bpmn | 336 +++ .../main/resources/subprocess/VnfAdapterTask.bpmn | 336 --- .../subprocess/BuildingBlock/CreateNetworkBB.bpmn | 102 +- .../subprocess/BuildingBlock/CreateVfModuleBB.bpmn | 94 +- .../subprocess/BuildingBlock/DeleteNetworkBB.bpmn | 22 +- .../subprocess/BuildingBlock/NetworkAdapter.bpmn | 69 + .../subprocess/BuildingBlock/UpdateNetworkBB.bpmn | 59 +- .../subprocess/BuildingBlock/VnfAdapter.bpmn | 36 +- .../bpmn/subprocess/VnfAdapterTest.java | 6 +- .../scripts/DoCreateNetworkInstance.groovy | 2200 ++++++++++---------- .../scripts/DoCreateNetworkInstanceRollback.groovy | 611 +++--- .../scripts/DoDeleteNetworkInstance.groovy | 1672 +++++++-------- .../scripts/DoDeleteNetworkInstanceRollback.groovy | 338 --- .../scripts/DoUpdateNetworkInstance.groovy | 1784 ++++++++-------- .../scripts/DoUpdateNetworkInstanceRollback.groovy | 312 --- .../DoDeleteNetworkInstanceRollbackTest.groovy | 343 --- .../DoUpdateNetworkInstanceRollbackTest.groovy | 329 --- .../process/DeleteVfModuleVolumeInfraV1.bpmn | 286 +-- .../process/UpdateVfModuleVolumeInfraV1.bpmn | 178 +- .../subprocess/DoCreateNetworkInstance.bpmn | 651 +++--- .../DoCreateNetworkInstanceRollback.bpmn | 267 +-- .../resources/subprocess/DoCreateVfModule.bpmn | 890 ++++---- .../subprocess/DoCreateVfModuleRollback.bpmn | 584 +++--- .../subprocess/DoCreateVfModuleVolumeRollback.bpmn | 116 +- .../subprocess/DoCreateVfModuleVolumeV2.bpmn | 182 +- .../subprocess/DoDeleteNetworkInstance.bpmn | 549 +++-- .../DoDeleteNetworkInstanceRollback.bpmn | 547 ----- .../resources/subprocess/DoDeleteVfModule.bpmn | 228 +- .../subprocess/DoDeleteVfModuleFromVnf.bpmn | 202 +- .../subprocess/DoDeleteVfModuleVolumeV2.bpmn | 62 +- .../subprocess/DoUpdateNetworkInstance.bpmn | 497 ++--- .../DoUpdateNetworkInstanceRollback.bpmn | 374 ---- .../resources/subprocess/DoUpdateVfModule.bpmn | 330 +-- .../network/tasks/NetworkAdapterCreateTasks.java | 5 +- .../network/tasks/NetworkAdapterDeleteTasks.java | 2 +- .../adapter/network/tasks/NetworkAdapterImpl.java | 103 + .../network/tasks/NetworkAdapterRestV1.java | 166 -- .../network/tasks/NetworkAdapterUpdateTasks.java | 2 +- .../tasks/NetworkAdapterCreateTasksTest.java | 2 +- .../network/tasks/NetworkAdapterImplTest.java | 30 + .../network/tasks/NetworkAdapterRestV1Test.java | 303 --- .../tasks/NetworkAdapterUpdateTasksTest.java | 2 +- 77 files changed, 6461 insertions(+), 14001 deletions(-) delete mode 100644 adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsync.java delete mode 100644 adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java delete mode 100644 adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java delete mode 100644 adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/CreateNetworkNotification.java delete mode 100644 adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/CreateNetworkNotificationResponse.java delete mode 100644 adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/DeleteNetworkNotification.java delete mode 100644 adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/DeleteNetworkNotificationResponse.java delete mode 100644 adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/MsoExceptionCategory.java delete mode 100644 adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/MsoRequest.java delete mode 100644 adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/NetworkAdapterNotify.java delete mode 100644 adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/NetworkAdapterNotify_Service.java delete mode 100644 adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/NetworkRollback.java delete mode 100644 adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/NetworkStatus.java delete mode 100644 adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/ObjectFactory.java delete mode 100644 adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/QueryNetworkNotification.java delete mode 100644 adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/QueryNetworkNotificationResponse.java delete mode 100644 adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/RollbackNetworkNotification.java delete mode 100644 adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/RollbackNetworkNotificationResponse.java delete mode 100644 adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/UpdateNetworkNotification.java delete mode 100644 adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/UpdateNetworkNotificationResponse.java delete mode 100644 adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/package-info.java delete mode 100644 adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java delete mode 100644 adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java create mode 100644 bpmn/MSOCommonBPMN/src/main/resources/subprocess/OpenstackAdapterTask.bpmn delete mode 100644 bpmn/MSOCommonBPMN/src/main/resources/subprocess/VnfAdapterTask.bpmn create mode 100644 bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/NetworkAdapter.bpmn delete mode 100644 bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollback.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollback.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollbackTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollbackTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteNetworkInstanceRollback.bpmn delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateNetworkInstanceRollback.bpmn create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterImpl.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1.java create mode 100644 bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterImplTest.java delete mode 100644 bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java index 62d9f068f9..c33160d255 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java @@ -184,6 +184,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin { if (CREATE_COMPLETE.equals(currentStack.getStackStatus())) { new StackInfoMapper(currentStack).map(); } else if (CREATE_IN_PROGRESS.equals(currentStack.getStackStatus())) { + // TODO should check poll for completion right here currentStack = processCreateStack(cloudSiteId, tenantId, timeoutMinutes, backout, currentStack, createStack, true); } else if (CREATE_FAILED.equals(currentStack.getStackStatus()) @@ -322,6 +323,27 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin { } } + public Stack postProcessStackUpdate(Stack updateStack) throws MsoOpenstackException { + if (!"UPDATE_COMPLETE".equals(updateStack.getStackStatus())) { + logger.error("{} Stack status: {} Stack status reason: {} {} Update Stack error", + MessageEnum.RA_UPDATE_STACK_ERR, updateStack.getStackStatus(), updateStack.getStackStatusReason(), + ErrorCode.DataError.getValue()); + + MsoOpenstackException me = null; + if ("UPDATE_IN_PROGRESS".equals(updateStack.getStackStatus())) { + me = new MsoOpenstackException(0, "", "Stack Update Timeout"); + } else { + String error = + "Stack error (" + updateStack.getStackStatus() + "): " + updateStack.getStackStatusReason(); + me = new MsoOpenstackException(0, "", error); + } + me.addContext("UpdateStack"); + throw me; + } else { + return updateStack; + } + } + public Stack pollStackForStatus(int timeoutMinutes, Stack stack, String stackStatus, String cloudSiteId, String tenantId, boolean notFoundIsSuccess) throws MsoException { int pollingFrequency = diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapter.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapter.java index 302a6d302b..010d91fec9 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapter.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapter.java @@ -191,13 +191,16 @@ public interface MsoNetworkAdapter { @WebParam(name = "modelCustomizationUuid") String modelCustomizationUuid, @WebParam(name = "networkId") @XmlElement(required = true) String networkId, @WebParam(name = "request") MsoRequest msoRequest, - @WebParam(name = "networkDeleted", mode = Mode.OUT) Holder networkDeleted) throws NetworkException; + @WebParam(name = "networkDeleted", mode = Mode.OUT) Holder networkDeleted, + @WebParam(name = "pollForCompletion") @XmlElement(required = false) Boolean pollForCompletion) + throws NetworkException; /** * This is the "Rollback Network" Web Service endpoint definition. */ @WebMethod - public void rollbackNetwork(@WebParam(name = "rollback") @XmlElement(required = true) NetworkRollback rollback) + public void rollbackNetwork(@WebParam(name = "rollback") @XmlElement(required = true) NetworkRollback rollback, + @WebParam(name = "pollForCompletion") @XmlElement(required = false) Boolean pollForCompletion) throws NetworkException; @WebMethod diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsync.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsync.java deleted file mode 100644 index 5b7340e24f..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsync.java +++ /dev/null @@ -1,104 +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.adapters.network; - - -import java.util.List; -import java.util.Map; -import javax.jws.Oneway; -import javax.jws.WebMethod; -import javax.jws.WebParam; -import javax.jws.WebService; -import javax.xml.bind.annotation.XmlElement; -import org.onap.so.entity.MsoRequest; -import org.onap.so.openstack.beans.NetworkRollback; -import org.onap.so.openstack.beans.Subnet; - -/** - * This webservice defines the Asynchronous versions of NETWORK adapter calls. The notification messages for final - * responses are documented elsewhere (by the client service WSDL). - * - */ -@WebService(name = "NetworkAdapterAsync", targetNamespace = "http://org.onap.so/networkA") -public interface MsoNetworkAdapterAsync { - /** - * This is the "Create NETWORK" Web Service Endpoint definition. - */ - @WebMethod - @Oneway - public void createNetworkA(@WebParam(name = "cloudSiteId") @XmlElement(required = true) String cloudSiteId, - @WebParam(name = "tenantId") @XmlElement(required = true) String tenantId, - @WebParam(name = "networkType") @XmlElement(required = true) String networkType, - @WebParam(name = "modelCustomizationUuid") String modelCustomizationUuid, - @WebParam(name = "networkName") @XmlElement(required = true) String networkName, - @WebParam(name = "physicalNetworkName") String physicalNetworkName, - @WebParam(name = "vlans") List vlans, @WebParam(name = "failIfExists") Boolean failIfExists, - @WebParam(name = "backout") Boolean backout, @WebParam(name = "subnets") List subnets, - @WebParam(name = "networkParams") Map networkParams, - @WebParam(name = "messageId") @XmlElement(required = true) String messageId, - @WebParam(name = "request") MsoRequest msoRequest, - @WebParam(name = "notificationUrl") @XmlElement(required = true) String notificationUrl); - - @WebMethod - @Oneway - public void updateNetworkA(@WebParam(name = "cloudSiteId") @XmlElement(required = true) String cloudSiteId, - @WebParam(name = "tenantId") @XmlElement(required = true) String tenantId, - @WebParam(name = "networkType") @XmlElement(required = true) String networkType, - @WebParam(name = "modelCustomizationUuid") String modelCustomizationUuid, - @WebParam(name = "networkId") @XmlElement(required = true) String networkId, - @WebParam(name = "networkName") @XmlElement(required = true) String networkName, - @WebParam(name = "physicalNetworkName") @XmlElement(required = true) String physicalNetworkName, - @WebParam(name = "vlans") @XmlElement(required = true) List vlans, - @WebParam(name = "subnets") List subnets, - @WebParam(name = "networkParams") Map networkParams, - @WebParam(name = "messageId") @XmlElement(required = true) String messageId, - @WebParam(name = "request") MsoRequest msoRequest, - @WebParam(name = "notificationUrl") @XmlElement(required = true) String notificationUrl); - - @WebMethod - @Oneway - public void queryNetworkA(@WebParam(name = "cloudSiteId") @XmlElement(required = true) String cloudSiteId, - @WebParam(name = "tenantId") @XmlElement(required = true) String tenantId, - @WebParam(name = "networkNameOrId") @XmlElement(required = true) String networkNameOrId, - @WebParam(name = "messageId") @XmlElement(required = true) String messageId, - @WebParam(name = "request") MsoRequest msoRequest, - @WebParam(name = "notificationUrl") @XmlElement(required = true) String notificationUrl); - - @WebMethod - @Oneway - public void deleteNetworkA(@WebParam(name = "cloudSiteId") @XmlElement(required = true) String cloudSiteId, - @WebParam(name = "tenantId") @XmlElement(required = true) String tenantId, - @WebParam(name = "networkType") @XmlElement(required = true) String networkType, - @WebParam(name = "modelCustomizationUuid") String modelCustomizationUuid, - @WebParam(name = "networkId") @XmlElement(required = true) String networkId, - @WebParam(name = "messageId") @XmlElement(required = true) String messageId, - @WebParam(name = "request") MsoRequest msoRequest, - @WebParam(name = "notificationUrl") @XmlElement(required = true) String notificationUrl); - - @WebMethod - @Oneway - public void rollbackNetworkA(@WebParam(name = "rollback") @XmlElement(required = true) NetworkRollback rollback, - @WebParam(name = "messageId") @XmlElement(required = true) String messageId, - @WebParam(name = "notificationUrl") @XmlElement(required = true) String notificationUrl); - - @WebMethod - public void healthCheckA(); -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java deleted file mode 100644 index 8d75212f4e..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java +++ /dev/null @@ -1,605 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Modifications Copyright (C) 2018 IBM. - * 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.adapters.network; - - -import java.net.MalformedURLException; -import java.net.URL; -import java.security.GeneralSecurityException; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import javax.jws.WebService; -import javax.xml.bind.DatatypeConverter; -import javax.xml.namespace.QName; -import javax.xml.ws.BindingProvider; -import javax.xml.ws.Holder; -import javax.xml.ws.handler.MessageContext; -import org.onap.so.adapters.network.async.client.CreateNetworkNotification; -import org.onap.so.adapters.network.async.client.MsoExceptionCategory; -import org.onap.so.adapters.network.async.client.NetworkAdapterNotify; -import org.onap.so.adapters.network.async.client.NetworkAdapterNotify_Service; -import org.onap.so.adapters.network.async.client.QueryNetworkNotification; -import org.onap.so.adapters.network.async.client.UpdateNetworkNotification; -import org.onap.so.adapters.network.exceptions.NetworkException; -import org.onap.so.entity.MsoRequest; -import org.onap.logging.filter.base.ErrorCode; -import org.onap.so.logger.LoggingAnchor; -import org.onap.so.logger.MessageEnum; -import org.onap.so.openstack.beans.NetworkRollback; -import org.onap.so.openstack.beans.NetworkStatus; -import org.onap.so.openstack.beans.Subnet; -import org.onap.so.utils.CryptoUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Component; - -@Component -@WebService(serviceName = "NetworkAdapterAsync", - endpointInterface = "org.onap.so.adapters.network.MsoNetworkAdapterAsync", - targetNamespace = "http://org.onap.so/networkA") -public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { - - private static final Logger logger = LoggerFactory.getLogger(MsoNetworkAdapterAsyncImpl.class); - - private static final String BPEL_AUTH_PROP = "org.onap.so.adapters.network.bpelauth"; - private static final String ENCRYPTION_KEY_PROP = "mso.msoKey"; - private static final String NETWORK_EXCEPTION_MSG = "Got a NetworkException on createNetwork: "; - private static final String CREATE_NETWORK_ERROR_LOGMSG = "{} {} Error sending createNetwork notification {} "; - private static final String FAULT_INFO_ERROR_LOGMSG = "{} {} Exception - fault info "; - private static final String SHARED = "shared"; - private static final String EXTERNAL = "external"; - - @Autowired - private Environment environment; - - @Autowired - private MsoNetworkAdapter networkAdapter; - - /** - * Health Check web method. Does nothing but return to show the adapter is deployed. - */ - @Override - public void healthCheckA() { - logger.debug("Health check call in Network Adapter"); - } - - /** - * This is the "Create Network" web service implementation. It will create a new Network of the requested type in - * the specified cloud and tenant. The tenant must exist at the time this service is called. - * - * If a network with the same name already exists, this can be considered a success or failure, depending on the - * value of the 'failIfExists' parameter. - * - * There will be a pre-defined set of network types defined in the MSO Catalog. All such networks will have a - * similar configuration, based on the allowable Openstack networking definitions. This includes basic networks, - * provider networks (with a single VLAN), and multi-provider networks (one or more VLANs) - * - * Initially, all provider networks must be "vlan" type, and multiple segments in a multi-provider network must be - * multiple VLANs on the same physical network. - * - * This service supports two modes of Network creation/update: - via Heat Templates - via Neutron API The network - * orchestration mode for each network type is declared in its catalog definition. All Heat-based templates must - * support some subset of the same input parameters: network_name, physical_network, vlan(s). - * - * The method returns the network ID and a NetworkRollback object. This latter object can be passed as-is to the - * rollbackNetwork operation to undo everything that was created. This is useful if a network is successfully - * created but the orchestration fails on a subsequent operation. - */ - @Override - public void createNetworkA(String cloudSiteId, String tenantId, String networkType, String modelCustomizationUuid, - String networkName, String physicalNetworkName, List vlans, Boolean failIfExists, Boolean backout, - List subnets, Map networkParams, String messageId, MsoRequest msoRequest, - String notificationUrl) { - - logger.debug("Async Create Network: {} of type {} in {}/{}", networkName, networkType, cloudSiteId, tenantId); - - // Use the synchronous method to perform the actual Create - - - // Synchronous Web Service Outputs - Holder networkId = new Holder<>(); - Holder neutronNetworkId = new Holder<>(); - Holder networkRollback = new Holder<>(); - Holder> subnetIdMap = new Holder<>(); - - HashMap params = (HashMap) networkParams; - if (params == null) - params = new HashMap<>(); - String shared = null; - String external = null; - if (params.containsKey(SHARED)) - shared = params.get(SHARED); - if (params.containsKey(EXTERNAL)) - external = params.get(EXTERNAL); - - try { - networkAdapter.createNetwork(cloudSiteId, tenantId, networkType, modelCustomizationUuid, networkName, - physicalNetworkName, vlans, shared, external, failIfExists, backout, subnets, params, msoRequest, - networkId, neutronNetworkId, subnetIdMap, networkRollback); - } catch (NetworkException e) { - logger.debug(NETWORK_EXCEPTION_MSG, e); - MsoExceptionCategory exCat = null; - String eMsg = null; - try { - eMsg = e.getFaultInfo().getMessage(); - exCat = MsoExceptionCategory.fromValue(e.getFaultInfo().getCategory().name()); - } catch (Exception e1) { - logger.error(FAULT_INFO_ERROR_LOGMSG, MessageEnum.RA_FAULT_INFO_EXC, ErrorCode.DataError.getValue(), - e1); - } - // Build and send Asynchronous error response - try { - NetworkAdapterNotify notifyPort = getNotifyEP(notificationUrl); - notifyPort.createNetworkNotification(messageId, false, exCat, eMsg, null, null, null, null); - } catch (Exception e1) { - logger.error(CREATE_NETWORK_ERROR_LOGMSG, MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, - ErrorCode.DataError.getValue(), e1.getMessage(), e1); - - } - return; - } - logger.debug("Async Create Network:Name {} physicalNetworkName:{}", networkName, physicalNetworkName); - // Build and send Asynchronous response - try { - NetworkAdapterNotify notifyPort = getNotifyEP(notificationUrl); - notifyPort.createNetworkNotification(messageId, true, null, null, networkId.value, neutronNetworkId.value, - copyCreateSubnetIdMap(subnetIdMap), copyNrb(networkRollback)); - } catch (Exception e) { - logger.error(CREATE_NETWORK_ERROR_LOGMSG, MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, - ErrorCode.DataError.getValue(), e.getMessage(), e); - - } - return; - } - - /** - * This is the "Update Network" web service implementation. It will update an existing Network of the requested type - * in the specified cloud and tenant. The typical use will be to replace the VLANs with the supplied list (to add or - * remove a VLAN), but other properties may be updated as well. - * - * There will be a pre-defined set of network types defined in the MSO Catalog. All such networks will have a - * similar configuration, based on the allowable Openstack networking definitions. This includes basic networks, - * provider networks (with a single VLAN), and multi-provider networks (one or more VLANs). - * - * Initially, all provider networks must currently be "vlan" type, and multi-provider networks must be multiple - * VLANs on the same physical network. - * - * This service supports two modes of Network update: - via Heat Templates - via Neutron API The network - * orchestration mode for each network type is declared in its catalog definition. All Heat-based templates must - * support some subset of the same input parameters: network_name, physical_network, vlan, segments. - * - * The method returns a NetworkRollback object. This object can be passed as-is to the rollbackNetwork operation to - * undo everything that was updated. This is useful if a network is successfully updated but orchestration fails on - * a subsequent operation. - */ - @Override - public void updateNetworkA(String cloudSiteId, String tenantId, String networkType, String modelCustomizationUuid, - String networkId, String networkName, String physicalNetworkName, List vlans, List subnets, - Map networkParams, String messageId, MsoRequest msoRequest, String notificationUrl) { - - logger.debug("Async Update Network: {} of type {} in {}/{}", networkId, networkType, cloudSiteId, tenantId); - - // Use the synchronous method to perform the actual Create - - - // Synchronous Web Service Outputs - Holder networkRollback = new Holder<>(); - Holder> subnetIdMap = new Holder<>(); - - HashMap params = (HashMap) networkParams; - if (params == null) - params = new HashMap<>(); - String shared = null; - String external = null; - if (params.containsKey(SHARED)) - shared = params.get(SHARED); - if (params.containsKey(EXTERNAL)) - external = params.get(EXTERNAL); - - try { - networkAdapter.updateNetwork(cloudSiteId, tenantId, networkType, modelCustomizationUuid, networkId, - networkName, physicalNetworkName, vlans, shared, external, subnets, params, msoRequest, subnetIdMap, - networkRollback); - } catch (NetworkException e) { - logger.debug("Got a NetworkException on updateNetwork: ", e); - MsoExceptionCategory exCat = null; - String eMsg = null; - try { - eMsg = e.getFaultInfo().getMessage(); - exCat = MsoExceptionCategory.fromValue(e.getFaultInfo().getCategory().name()); - } catch (Exception e1) { - logger.error(FAULT_INFO_ERROR_LOGMSG, MessageEnum.RA_FAULT_INFO_EXC, ErrorCode.DataError.getValue(), - e1); - } - // Build and send Asynchronous error response - try { - NetworkAdapterNotify notifyPort = getNotifyEP(notificationUrl); - notifyPort.updateNetworkNotification(messageId, false, exCat, eMsg, null, copyNrb(networkRollback)); - } catch (Exception e1) { - logger.error("{} {} Error sending updateNetwork notification {} ", - MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, ErrorCode.DataError.getValue(), e1.getMessage(), e1); - - } - return; - } - logger.debug("Async Update Network:Name {} NetworkId:{}", networkName, networkId); - // Build and send Asynchronous response - try { - NetworkAdapterNotify notifyPort = getNotifyEP(notificationUrl); - notifyPort.updateNetworkNotification(messageId, true, null, null, copyUpdateSubnetIdMap(subnetIdMap), - copyNrb(networkRollback)); - } catch (Exception e) { - logger.error("{} {} Error sending updateNotification request {} ", MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, - ErrorCode.DataError.getValue(), e.getMessage(), e); - } - return; - } - - /** - * This is the queryNetwork method. It returns the existence and status of the specified network, along with its - * Neutron UUID and list of VLANs. This method attempts to find the network using both Heat and Neutron. Heat stacks - * are first searched based on the provided network name/id. If none is found, the Neutron is directly queried. - */ - @Override - public void queryNetworkA(String cloudSiteId, String tenantId, String networkNameOrId, String messageId, - MsoRequest msoRequest, String notificationUrl) { - - logger.debug("Async Query Network {} in {}/{}", networkNameOrId, cloudSiteId, tenantId); - String errorCreateNetworkMessage = CREATE_NETWORK_ERROR_LOGMSG; - - // Use the synchronous method to perform the actual Create - - - // Synchronous Web Service Outputs - Holder networkExists = new Holder<>(); - Holder networkId = new Holder<>(); - Holder neutronNetworkId = new Holder<>(); - Holder status = new Holder<>(); - Holder> vlans = new Holder<>(); - Holder> subnetIdMap = new Holder<>(); - - try { - networkAdapter.queryNetwork(cloudSiteId, tenantId, networkNameOrId, msoRequest, networkExists, networkId, - neutronNetworkId, status, vlans, subnetIdMap); - } catch (NetworkException e) { - logger.debug(NETWORK_EXCEPTION_MSG, e); - MsoExceptionCategory exCat = null; - String eMsg = null; - try { - eMsg = e.getFaultInfo().getMessage(); - exCat = MsoExceptionCategory.fromValue(e.getFaultInfo().getCategory().name()); - } catch (Exception e1) { - logger.error(FAULT_INFO_ERROR_LOGMSG, MessageEnum.RA_FAULT_INFO_EXC, ErrorCode.DataError.getValue(), - e1); - } - // Build and send Asynchronous error response - try { - NetworkAdapterNotify notifyPort = getNotifyEP(notificationUrl); - notifyPort.queryNetworkNotification(messageId, false, exCat, eMsg, null, null, null, null, null, null); - } catch (Exception e1) { - logger.error(errorCreateNetworkMessage, MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, - ErrorCode.DataError.getValue(), e1.getMessage(), e1); - } - return; - } - logger.debug("Async Query Network:NameOrId {} tenantId:{}", networkNameOrId, tenantId); - // Build and send Asynchronous response - try { - NetworkAdapterNotify notifyPort = getNotifyEP(notificationUrl); - org.onap.so.adapters.network.async.client.NetworkStatus networkS = - org.onap.so.adapters.network.async.client.NetworkStatus.fromValue(status.value.name()); - notifyPort.queryNetworkNotification(messageId, true, null, null, networkExists.value, networkId.value, - neutronNetworkId.value, networkS, vlans.value, copyQuerySubnetIdMap(subnetIdMap)); - } catch (Exception e) { - logger.error(errorCreateNetworkMessage, MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, - ErrorCode.DataError.getValue(), e.getMessage(), e); - } - return; - } - - /** - * This is the "Delete Network" web service implementation. It will delete a Network in the specified cloud and - * tenant. - * - * If the network is not found, it is treated as a success. - * - * This service supports two modes of Network creation/update/delete: - via Heat Templates - via Neutron API The - * network orchestration mode for each network type is declared in its catalog definition. - * - * For Heat-based orchestration, the networkId should be the stack ID. For Neutron-based orchestration, the - * networkId should be the Neutron network UUID. - * - * The method returns nothing on success. Rollback is not possible for delete commands, so any failure on delete - * will require manual fallout in the client. - */ - @Override - public void deleteNetworkA(String cloudSiteId, String tenantId, String networkType, String modelCustomizationUuid, - String networkId, String messageId, MsoRequest msoRequest, String notificationUrl) { - - String serviceName = "DeleteNetworkA"; - logger.debug("Async Delete Network {} in {}/{}", networkId, cloudSiteId, tenantId); - - // Use the synchronous method to perform the actual Create - - - // Synchronous Web Service Outputs - Holder networkDeleted = new Holder<>(); - - try { - networkAdapter.deleteNetwork(cloudSiteId, tenantId, networkType, modelCustomizationUuid, networkId, - msoRequest, networkDeleted); - } catch (NetworkException e) { - logger.debug(NETWORK_EXCEPTION_MSG, e); - MsoExceptionCategory exCat = null; - String eMsg = null; - try { - eMsg = e.getFaultInfo().getMessage(); - exCat = MsoExceptionCategory.fromValue(e.getFaultInfo().getCategory().name()); - } catch (Exception e1) { - logger.error(FAULT_INFO_ERROR_LOGMSG, MessageEnum.RA_FAULT_INFO_EXC, ErrorCode.DataError.getValue(), - e1); - } - // Build and send Asynchronous error response - try { - NetworkAdapterNotify notifyPort = getNotifyEP(notificationUrl); - notifyPort.deleteNetworkNotification(messageId, false, exCat, eMsg, null); - } catch (Exception e1) { - logger.error(CREATE_NETWORK_ERROR_LOGMSG, MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, - ErrorCode.DataError.getValue(), e1.getMessage(), e1); - - } - return; - } - logger.debug("Async Delete NetworkId: {} tenantId:{}", networkId, tenantId); - // Build and send Asynchronous response - try { - NetworkAdapterNotify notifyPort = getNotifyEP(notificationUrl); - notifyPort.deleteNetworkNotification(messageId, true, null, null, networkDeleted.value); - } catch (Exception e) { - logger.error("{} {} Error sending deleteNetwork notification {} ", MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, - ErrorCode.DataError.getValue(), e.getMessage(), e); - - } - return; - } - - /** - * This web service endpoint will rollback a previous Create VNF operation. A rollback object is returned to the - * client in a successful creation response. The client can pass that object as-is back to the rollbackNetwork - * operation to undo the creation. - * - * The rollback includes removing the VNF and deleting the tenant if the tenant did not exist prior to the VNF - * creation. - */ - @Override - public void rollbackNetworkA(NetworkRollback rollback, String messageId, String notificationUrl) { - // rollback may be null (e.g. if network already existed when Create was called) - if (rollback == null) { - logger.warn("{} {} Rollback is null", MessageEnum.RA_ROLLBACK_NULL, ErrorCode.SchemaError.getValue()); - return; - } - - logger.info(LoggingAnchor.TWO, MessageEnum.RA_ASYNC_ROLLBACK, rollback.getNetworkStackId()); - // Use the synchronous method to perform the actual Create - - - try { - networkAdapter.rollbackNetwork(rollback); - } catch (NetworkException e) { - logger.debug("Got a NetworkException on rollbackNetwork: ", e); - // Build and send Asynchronous error response - MsoExceptionCategory exCat = null; - String eMsg = null; - try { - eMsg = e.getFaultInfo().getMessage(); - exCat = MsoExceptionCategory.fromValue(e.getFaultInfo().getCategory().name()); - } catch (Exception e1) { - logger.error("{} {} Exception in get fault info ", MessageEnum.RA_FAULT_INFO_EXC, - ErrorCode.DataError.getValue(), e1); - } - // Build and send Asynchronous error response - try { - NetworkAdapterNotify notifyPort = getNotifyEP(notificationUrl); - notifyPort.rollbackNetworkNotification(rollback.getMsoRequest().getRequestId(), false, exCat, eMsg); - } catch (Exception e1) { - logger.error(CREATE_NETWORK_ERROR_LOGMSG, MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, - ErrorCode.DataError.getValue(), e1.getMessage(), e1); - - } - return; - } - logger.debug("Async Rollback NetworkId: {} tenantId:{}", rollback.getNetworkStackId(), rollback.getTenantId()); - // Build and send Asynchronous response - try { - NetworkAdapterNotify notifyPort = getNotifyEP(notificationUrl); - notifyPort.rollbackNetworkNotification(rollback.getMsoRequest().getRequestId(), true, null, null); - } catch (Exception e) { - logger.error("{} {} Error sending rollbackNetwork notification {} ", - MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, ErrorCode.DataError.getValue(), e.getMessage(), e); - - } - return; - } - - private org.onap.so.adapters.network.async.client.NetworkRollback copyNrb(Holder hNrb) { - org.onap.so.adapters.network.async.client.NetworkRollback cnrb = - new org.onap.so.adapters.network.async.client.NetworkRollback(); - - if (hNrb != null && hNrb.value != null) { - org.onap.so.adapters.network.async.client.MsoRequest cmr = - new org.onap.so.adapters.network.async.client.MsoRequest(); - - cnrb.setCloudId(hNrb.value.getCloudId()); - cmr.setRequestId(hNrb.value.getMsoRequest().getRequestId()); - cmr.setServiceInstanceId(hNrb.value.getMsoRequest().getServiceInstanceId()); - cnrb.setMsoRequest(cmr); - cnrb.setNetworkId(hNrb.value.getNetworkId()); - cnrb.setNetworkStackId(hNrb.value.getNetworkStackId()); - cnrb.setNeutronNetworkId(hNrb.value.getNeutronNetworkId()); - cnrb.setTenantId(hNrb.value.getTenantId()); - cnrb.setNetworkType(hNrb.value.getNetworkType()); - cnrb.setNetworkCreated(hNrb.value.getNetworkCreated()); - cnrb.setNetworkName(hNrb.value.getNetworkName()); - cnrb.setPhysicalNetwork(hNrb.value.getPhysicalNetwork()); - List vlansc = cnrb.getVlans(); - List vlansh = hNrb.value.getVlans(); - if (vlansh != null) { - vlansc.addAll(vlansh); - } - } - return cnrb; - } - - private NetworkAdapterNotify getNotifyEP(String notificationUrl) { - - URL warWsdlLoc = null; - try { - warWsdlLoc = Thread.currentThread().getContextClassLoader().getResource("NetworkAdapterNotify.wsdl"); - } catch (Exception e) { - logger.error("{} {} Exception - WSDL not found ", MessageEnum.RA_WSDL_NOT_FOUND, - ErrorCode.DataError.getValue(), e); - } - if (warWsdlLoc == null) { - logger.error("{} {} WSDL not found", MessageEnum.RA_WSDL_NOT_FOUND, ErrorCode.DataError.getValue()); - } else { - try { - logger.debug("NetworkAdpaterNotify.wsdl location: {}", warWsdlLoc.toURI().toString()); - } catch (Exception e) { - logger.error("{} {} Exception - WSDL URL convention ", MessageEnum.RA_WSDL_URL_CONVENTION_EXC, - ErrorCode.SchemaError.getValue(), e); - } - } - - NetworkAdapterNotify_Service notifySvc = new NetworkAdapterNotify_Service(warWsdlLoc, - new QName("http://org.onap.so/networkNotify", "networkAdapterNotify")); - - NetworkAdapterNotify notifyPort = notifySvc.getMsoNetworkAdapterAsyncImplPort(); - - BindingProvider bp = (BindingProvider) notifyPort; - - URL epUrl = null; - try { - epUrl = new URL(notificationUrl); - } catch (MalformedURLException e1) { - logger.error("{} {} Exception - init notification ", MessageEnum.RA_INIT_NOTIF_EXC, - ErrorCode.DataError.getValue(), e1); - } - - if (null != epUrl) { - logger.debug("Notification Endpoint URL: {}", epUrl.toExternalForm()); - bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, epUrl.toExternalForm()); - } else { - logger.debug("Notification Endpoint URL is NULL: "); - } - - // authentication - try { - Map reqCtx = bp.getRequestContext(); - Map> headers = new HashMap<>(); - - String userCredentials = this.getEncryptedProperty(BPEL_AUTH_PROP, "", ENCRYPTION_KEY_PROP); - - String basicAuth = "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes()); - reqCtx.put(MessageContext.HTTP_REQUEST_HEADERS, headers); - headers.put("Authorization", Collections.singletonList(basicAuth)); - } catch (Exception e) { - logger.error("{} {} Unable to set authorization in callback request {} ", - MessageEnum.RA_SET_CALLBACK_AUTH_EXC, ErrorCode.DataError.getValue(), e.getMessage(), e); - } - - return notifyPort; - } - - public String getEncryptedProperty(String key, String defaultValue, String encryptionKey) { - try { - return CryptoUtils.decrypt(this.environment.getProperty(key), this.environment.getProperty(encryptionKey)); - } catch (GeneralSecurityException e) { - logger.debug("Exception while decrypting property: {} ", this.environment.getProperty(key), e); - } - return defaultValue; - - } - - private CreateNetworkNotification.SubnetIdMap copyCreateSubnetIdMap(Holder> hMap) { - - CreateNetworkNotification.SubnetIdMap subnetIdMap = new CreateNetworkNotification.SubnetIdMap(); - - if (hMap != null && hMap.value != null) { - Map sMap = hMap.value; - CreateNetworkNotification.SubnetIdMap.Entry entry = new CreateNetworkNotification.SubnetIdMap.Entry(); - - for (Map.Entry mapEntry : sMap.entrySet()) { - String key = mapEntry.getKey(); - String value = mapEntry.getValue(); - entry.setKey(key); - entry.setValue(value); - subnetIdMap.getEntry().add(entry); - } - } - return subnetIdMap; - } - - private UpdateNetworkNotification.SubnetIdMap copyUpdateSubnetIdMap(Holder> hMap) { - - UpdateNetworkNotification.SubnetIdMap subnetIdMap = new UpdateNetworkNotification.SubnetIdMap(); - - if (hMap != null && hMap.value != null) { - Map sMap = hMap.value; - UpdateNetworkNotification.SubnetIdMap.Entry entry = new UpdateNetworkNotification.SubnetIdMap.Entry(); - - for (Map.Entry mapEntry : sMap.entrySet()) { - String key = mapEntry.getKey(); - String value = mapEntry.getValue(); - entry.setKey(key); - entry.setValue(value); - subnetIdMap.getEntry().add(entry); - } - } - return subnetIdMap; - } - - private QueryNetworkNotification.SubnetIdMap copyQuerySubnetIdMap(Holder> hMap) { - - QueryNetworkNotification.SubnetIdMap subnetIdMap = new QueryNetworkNotification.SubnetIdMap(); - - if (hMap != null && hMap.value != null) { - Map sMap = hMap.value; - QueryNetworkNotification.SubnetIdMap.Entry entry = new QueryNetworkNotification.SubnetIdMap.Entry(); - - for (Map.Entry mapEntry : sMap.entrySet()) { - String key = mapEntry.getKey(); - String value = mapEntry.getValue(); - entry.setKey(key); - entry.setValue(value); - subnetIdMap.getEntry().add(entry); - } - } - return subnetIdMap; - } -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java index 860c747f15..489585c04b 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java @@ -140,6 +140,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { * @see MsoNetworkAdapterImpl#MsoNetworkAdapterImpl(MsoPropertiesFactory) */ + @Deprecated @Override public void createNetwork(String cloudSiteId, String tenantId, String networkType, String modelCustomizationUuid, String networkName, String physicalNetworkName, List vlans, String shared, String external, @@ -149,9 +150,10 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { Holder networkFqdn = new Holder<>(); createNetwork(cloudSiteId, tenantId, networkType, modelCustomizationUuid, networkName, physicalNetworkName, vlans, null, shared, external, failIfExists, backout, subnets, null, null, msoRequest, networkId, - neutronNetworkId, networkFqdn, subnetIdMap, rollback); + neutronNetworkId, networkFqdn, subnetIdMap, rollback, true); } + @Deprecated @Override public void createNetworkContrail(String cloudSiteId, String tenantId, String networkType, String modelCustomizationUuid, String networkName, List routeTargets, String shared, @@ -162,7 +164,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { throws NetworkException { createNetwork(cloudSiteId, tenantId, networkType, modelCustomizationUuid, networkName, null, null, routeTargets, shared, external, failIfExists, backout, subnets, policyFqdns, routeTableFqdns, msoRequest, networkId, - neutronNetworkId, networkFqdn, subnetIdMap, rollback); + neutronNetworkId, networkFqdn, subnetIdMap, rollback, true); } /** @@ -188,12 +190,12 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { * created but the orchestration fails on a subsequent operation. */ - private void createNetwork(String cloudSiteId, String tenantId, String networkType, String modelCustomizationUuid, + public void createNetwork(String cloudSiteId, String tenantId, String networkType, String modelCustomizationUuid, String networkName, String physicalNetworkName, List vlans, List routeTargets, String shared, String external, Boolean failIfExists, Boolean backout, List subnets, List policyFqdns, List routeTableFqdns, MsoRequest msoRequest, Holder networkId, Holder neutronNetworkId, Holder networkFqdn, Holder> subnetIdMap, - Holder rollback) throws NetworkException { + Holder rollback, Boolean pollForCompletion) throws NetworkException { logger.debug("*** CREATE Network: {} of type {} in {}/{}", networkName, networkType, cloudSiteId, tenantId); // Will capture execution time for metrics @@ -365,7 +367,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { if (backout == null) backout = true; heatStack = heat.createStack(cloudSiteId, CLOUD_OWNER, tenantId, networkName, null, template, stackParams, - true, heatTemplate.getTimeoutMinutes(), null, null, null, backout.booleanValue(), failIfExists); + pollForCompletion, heatTemplate.getTimeoutMinutes(), null, null, null, backout.booleanValue(), + failIfExists); } catch (MsoException me) { me.addContext(CREATE_NETWORK_CONTEXT); logger.error("{} {} Exception creating network type {} in {}/{} ", MessageEnum.RA_CREATE_NETWORK_EXC, @@ -423,6 +426,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { return; } + @Deprecated @Override public void updateNetwork(String cloudSiteId, String tenantId, String networkType, String modelCustomizationUuid, String networkId, String networkName, String physicalNetworkName, List vlans, String shared, @@ -434,6 +438,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } + @Deprecated @Override public void updateNetworkContrail(String cloudSiteId, String tenantId, String networkType, String modelCustomizationUuid, String networkId, String networkName, List routeTargets, @@ -465,7 +470,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { * undo everything that was updated. This is useful if a network is successfully updated but orchestration fails on * a subsequent operation. */ - private void updateNetwork(String cloudSiteId, String tenantId, String networkType, String modelCustomizationUuid, + public void updateNetwork(String cloudSiteId, String tenantId, String networkType, String modelCustomizationUuid, String networkId, String networkName, String physicalNetworkName, List vlans, List routeTargets, String shared, String external, List subnets, List policyFqdns, List routeTableFqdns, MsoRequest msoRequest, @@ -524,7 +529,6 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { // Does not exist. Throw an exception (can't update a non-existent network) throw new NetworkException(error, MsoExceptionCategory.USERDATA); } - long updateNetworkStarttime = System.currentTimeMillis(); try { netInfo = neutron.updateNetwork(cloudSiteId, tenantId, networkId, neutronNetworkType, physicalNetworkName, vlans); @@ -671,7 +675,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { // Ignore MsoStackNotFound exception because we already checked. try { heatStack = heatWithUpdate.updateStack(cloudSiteId, CLOUD_OWNER, tenantId, networkId, template, - stackParams, true, heatTemplate.getTimeoutMinutes()); + stackParams, false, heatTemplate.getTimeoutMinutes()); } catch (MsoException me) { me.addContext(UPDATE_NETWORK_CONTEXT); logger.error("{} {} Exception - update network {} in {}/{} ", MessageEnum.RA_UPDATE_NETWORK_ERR, @@ -944,7 +948,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { */ @Override public void deleteNetwork(String cloudSiteId, String tenantId, String networkType, String modelCustomizationUuid, - String networkId, MsoRequest msoRequest, Holder networkDeleted) throws NetworkException { + String networkId, MsoRequest msoRequest, Holder networkDeleted, Boolean pollForCompletion) + throws NetworkException { logger.debug("*** DELETE Network adapter with Network: {} in {}/{}", networkId, cloudSiteId, tenantId); if (commonUtils.isNullOrEmpty(cloudSiteId) || commonUtils.isNullOrEmpty(tenantId) || commonUtils.isNullOrEmpty(networkId)) { @@ -953,6 +958,10 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { throw new NetworkException(error, MsoExceptionCategory.USERDATA); } + if (pollForCompletion == null) { + pollForCompletion = true; + } + // Retrieve the Network Resource definition NetworkResource networkResource = null; if (commonUtils.isNullOrEmpty(modelCustomizationUuid)) { @@ -980,7 +989,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } try { - StackInfo stack = heat.deleteStack(tenantId, CLOUD_OWNER, cloudSiteId, networkId, true, timeoutMinutes); + StackInfo stack = + heat.deleteStack(tenantId, CLOUD_OWNER, cloudSiteId, networkId, pollForCompletion, timeoutMinutes); networkDeleted.value = stack.isOperationPerformed(); } catch (MsoException me) { me.addContext("DeleteNetwork"); @@ -1006,12 +1016,16 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { * creation. */ @Override - public void rollbackNetwork(NetworkRollback rollback) throws NetworkException { + public void rollbackNetwork(NetworkRollback rollback, Boolean pollForCompletion) throws NetworkException { if (rollback == null) { logger.error("{} {} rollback is null", MessageEnum.RA_ROLLBACK_NULL, ErrorCode.DataError.getValue()); return; } + if (pollForCompletion == null) { + pollForCompletion = true; + } + // Get the elements of the VnfRollback object for easier access String cloudSiteId = rollback.getCloudId(); String tenantId = rollback.getTenantId(); @@ -1021,7 +1035,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { if (rollback.getNetworkCreated()) { try { - heat.deleteStack(tenantId, CLOUD_OWNER, cloudSiteId, networkId, true, 120); + heat.deleteStack(tenantId, CLOUD_OWNER, cloudSiteId, networkId, pollForCompletion, 120); } catch (MsoException me) { me.addContext("RollbackNetwork"); logger.error("{} {} Exception - Rollback Network (heat): {} in {}/{} ", diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java deleted file mode 100644 index 09356d02c8..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java +++ /dev/null @@ -1,660 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.adapters.network; - - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import javax.inject.Provider; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.GenericEntity; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.xml.ws.Holder; -import org.apache.http.HttpStatus; -import org.onap.logging.ref.slf4j.ONAPLogConstants; -import org.onap.so.adapters.network.exceptions.NetworkException; -import org.onap.so.adapters.nwrest.ContrailNetwork; -import org.onap.so.adapters.nwrest.CreateNetworkError; -import org.onap.so.adapters.nwrest.CreateNetworkRequest; -import org.onap.so.adapters.nwrest.CreateNetworkResponse; -import org.onap.so.adapters.nwrest.DeleteNetworkError; -import org.onap.so.adapters.nwrest.DeleteNetworkRequest; -import org.onap.so.adapters.nwrest.DeleteNetworkResponse; -import org.onap.so.adapters.nwrest.ProviderVlanNetwork; -import org.onap.so.adapters.nwrest.QueryNetworkError; -import org.onap.so.adapters.nwrest.QueryNetworkResponse; -import org.onap.so.adapters.nwrest.RollbackNetworkError; -import org.onap.so.adapters.nwrest.RollbackNetworkRequest; -import org.onap.so.adapters.nwrest.RollbackNetworkResponse; -import org.onap.so.adapters.nwrest.UpdateNetworkError; -import org.onap.so.adapters.nwrest.UpdateNetworkRequest; -import org.onap.so.adapters.nwrest.UpdateNetworkResponse; -import org.onap.so.adapters.vnf.BpelRestClient; -import org.onap.so.entity.MsoRequest; -import org.onap.logging.filter.base.ErrorCode; -import org.onap.so.logger.MessageEnum; -import org.onap.so.openstack.beans.NetworkRollback; -import org.onap.so.openstack.beans.NetworkStatus; -import org.onap.so.openstack.beans.RouteTarget; -import org.onap.so.openstack.exceptions.MsoExceptionCategory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.MDC; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; - -@Path("/v1/networks") -@Api(value = "/v1/networks", description = "root of network adapters restful web service") -@Component -@Transactional -public class NetworkAdapterRest { - - private static final Logger logger = LoggerFactory.getLogger(NetworkAdapterRest.class); - private static final String TESTING_KEYWORD = "___TESTING___"; - private String exceptionMsg = "Exception:"; - private static final String SHARED = "shared"; - private static final String EXTERNAL = "external"; - - @Autowired - private MsoNetworkAdapterImpl adapter; - - @Autowired - private Provider bpelRestClientProvider; - - - @POST - @Path("") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @ApiOperation(value = "CreateNetwork", response = Response.class, - notes = "Creates a new network, CreateNetworkRquest JSON is required") - @ApiResponses({@ApiResponse(code = 200, message = "network has been successfully created"), - @ApiResponse(code = 202, message = "create network request has been accepted (async only)"), - @ApiResponse(code = 500, message = "create network failed, examine entity object for details")}) - public Response createNetwork( - @ApiParam(value = "details of network being created", required = true) CreateNetworkRequest req) { - logger.debug("createNetwork enter: {}", req.toJsonString()); - CreateNetworkTask task = new CreateNetworkTask(req); - if (req.isSynchronous()) { - // This is a synchronous request - task.run(); - return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build(); - } else { - // This is an asynchronous request - try { - Thread t1 = new Thread(task); - t1.start(); - } catch (Exception e) { - // problem handling create, send generic failure as sync resp to caller - logger.error("{} {} Exception while create network ", MessageEnum.RA_CREATE_NETWORK_EXC, - ErrorCode.BusinessProcessError.getValue(), e); - return Response.serverError().build(); - } - // send sync response (ACK) to caller - logger.debug("createNetwork exit"); - return Response.status(HttpStatus.SC_ACCEPTED).build(); - } - } - - public class CreateNetworkTask implements Runnable { - private final CreateNetworkRequest req; - private CreateNetworkResponse response = null; - private CreateNetworkError eresp = null; - private boolean sendxml; - - public CreateNetworkTask(CreateNetworkRequest req) { - this.req = req; - this.sendxml = true; // can be set with a field or header later - } - - public int getStatusCode() { - return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST; - } - - public Object getGenericEntityResponse() { - return (response != null) ? new GenericEntity(response) {} - : new GenericEntity(eresp) {}; - } - - private String getResponse() { - if (response != null) { - return sendxml ? response.toXmlString() : response.toJsonString(); - } else { - return sendxml ? eresp.toXmlString() : eresp.toJsonString(); - } - } - - @Override - public void run() { - try { - MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId()); - } catch (Exception e) { - logger.error("Error adding RequestId to MDC", e); - } - logger.debug("CreateNetworkTask start"); - try { - // Synchronous Web Service Outputs - Holder networkId = new Holder<>(); - Holder neutronNetworkId = new Holder<>(); - Holder networkFqdn = new Holder<>(); - Holder> subnetIdMap = new Holder<>(); - Holder rollback = new Holder<>(); - - HashMap params = (HashMap) req.getNetworkParams(); - if (params == null) { - params = new HashMap<>(); - } - String shared = null; - String external = null; - - String cloudsite = req.getCloudSiteId(); - if (cloudsite != null && cloudsite.equals(TESTING_KEYWORD)) { - String tenant = req.getTenantId(); - if (tenant != null && tenant.equals(TESTING_KEYWORD)) { - throw new NetworkException("testing."); - } - networkId.value = "479D3D8B-6360-47BC-AB75-21CC91981484"; - neutronNetworkId.value = "55e55884-28fa-11e6-8971-0017f20fe1b8"; - networkFqdn.value = "086f70b6-28fb-11e6-8260-0017f20fe1b8"; - subnetIdMap.value = testMap(); - rollback.value = new NetworkRollback(); - } else if (req.isContrailRequest()) { - ContrailNetwork ctn = req.getContrailNetwork(); - if (ctn == null) { - ctn = new ContrailNetwork(); - req.setContrailNetwork(ctn); - } - if (params.containsKey(SHARED)) { - shared = params.get(SHARED); - } else { - if (ctn.getShared() != null) { - shared = ctn.getShared(); - } - } - if (params.containsKey(EXTERNAL)) { - external = params.get(EXTERNAL); - } else { - if (ctn.getExternal() != null) { - external = ctn.getExternal(); - } - } - adapter.createNetworkContrail(req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(), - req.getModelCustomizationUuid(), req.getNetworkName(), - req.getContrailNetwork().getRouteTargets(), shared, external, req.getFailIfExists(), - req.getBackout(), req.getSubnets(), params, req.getContrailNetwork().getPolicyFqdns(), - req.getContrailNetwork().getRouteTableFqdns(), req.getMsoRequest(), networkId, - neutronNetworkId, networkFqdn, subnetIdMap, rollback); - } else { - ProviderVlanNetwork pvn = req.getProviderVlanNetwork(); - if (pvn == null) { - pvn = new ProviderVlanNetwork(); - req.setProviderVlanNetwork(pvn); - } - if (params.containsKey(SHARED)) - shared = params.get(SHARED); - if (params.containsKey(EXTERNAL)) - external = params.get(EXTERNAL); - adapter.createNetwork(req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(), - req.getModelCustomizationUuid(), req.getNetworkName(), - req.getProviderVlanNetwork().getPhysicalNetworkName(), - req.getProviderVlanNetwork().getVlans(), shared, external, req.getFailIfExists(), - req.getBackout(), req.getSubnets(), params, req.getMsoRequest(), networkId, - neutronNetworkId, subnetIdMap, rollback); - } - response = new CreateNetworkResponse(req.getNetworkId(), neutronNetworkId.value, - rollback.value.getNetworkStackId(), networkFqdn.value, rollback.value.getNetworkCreated(), - subnetIdMap.value, rollback.value, req.getMessageId()); - } catch (NetworkException e) { - logger.debug(exceptionMsg, e); - eresp = new CreateNetworkError(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); - } - if (!req.isSynchronous()) { - // This is asynch, so POST response back to caller - BpelRestClient bpelClient = bpelRestClientProvider.get(); - bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); - } - logger.debug("CreateNetworkTask exit: code={}, resp={}", getStatusCode(), getResponse()); - } - } - - @DELETE - @Path("{aaiNetworkId}") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @ApiOperation(value = "DeleteNetwork", response = Response.class, - notes = "Deletes an existing network, aaiNetworkId and DeleteNetworkRequest JSON are required") - @ApiResponses({@ApiResponse(code = 200, message = "network has been successfully deleted"), - @ApiResponse(code = 202, message = "request to delete network has been accepted (async only)"), - @ApiResponse(code = 500, message = "delete network failed, examine entity object for details")}) - public Response deleteNetwork( - @ApiParam(value = "aaiNetworkId to be deleted ", - required = true) @PathParam("aaiNetworkId") String aaiNetworkId, - @ApiParam(value = "details of network being deleted", required = true) DeleteNetworkRequest req) { - logger.debug("deleteNetwork enter: {}", req.toJsonString()); - if (aaiNetworkId == null || !aaiNetworkId.equals(req.getNetworkId())) { - return Response.status(HttpStatus.SC_BAD_REQUEST).type(MediaType.TEXT_PLAIN).entity( - "A&AI NetworkId in URL (" + aaiNetworkId + ") does not match content (" + req.getNetworkId() + ")") - .build(); - } - DeleteNetworkTask task = new DeleteNetworkTask(req); - if (req.isSynchronous()) { - // This is a synchronous request - task.run(); - return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build(); - } else { - // This is an asynchronous request - try { - Thread t1 = new Thread(task); - t1.start(); - } catch (Exception e) { - // problem handling create, send generic failure as sync resp to caller - logger.error("{} {} Exception while delete network ", MessageEnum.RA_DELETE_NETWORK_EXC, - ErrorCode.BusinessProcessError.getValue(), e); - return Response.serverError().build(); - } - // send sync response (ACK) to caller - logger.debug("deleteNetwork exit"); - return Response.status(HttpStatus.SC_ACCEPTED).build(); - } - } - - public class DeleteNetworkTask implements Runnable { - private final DeleteNetworkRequest req; - private DeleteNetworkResponse response = null; - private DeleteNetworkError eresp = null; - private boolean sendxml; - - public DeleteNetworkTask(DeleteNetworkRequest req) { - this.req = req; - this.sendxml = true; // can be set with a field or header later - } - - public int getStatusCode() { - return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST; - } - - public Object getGenericEntityResponse() { - return (response != null) ? new GenericEntity(response) {} - : new GenericEntity(eresp) {}; - } - - private String getResponse() { - if (response != null) { - return sendxml ? response.toXmlString() : response.toJsonString(); - } else { - return sendxml ? eresp.toXmlString() : eresp.toJsonString(); - } - } - - @Override - public void run() { - try { - MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId()); - } catch (Exception e) { - logger.error("Error adding RequestId to MDC", e); - } - logger.debug("DeleteNetworkTask start"); - try { - Holder networkDeleted = new Holder<>(); - if (req.getCloudSiteId().equals(TESTING_KEYWORD)) { - networkDeleted.value = true; - } else { - adapter.deleteNetwork(req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(), - req.getModelCustomizationUuid(), req.getNetworkStackId(), req.getMsoRequest(), - networkDeleted); - } - response = new DeleteNetworkResponse(req.getNetworkId(), networkDeleted.value, req.getMessageId()); - } catch (NetworkException e) { - logger.debug(exceptionMsg, e); - eresp = new DeleteNetworkError(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); - } - if (!req.isSynchronous()) { - // This is asynch, so POST response back to caller - BpelRestClient bpelClient = bpelRestClientProvider.get(); - bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); - } - logger.debug("DeleteNetworkTask exit: code={}, resp={}", getStatusCode(), getResponse()); - } - } - - @GET - @Path("{aaiNetworkId}") - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @ApiOperation(value = "QueryNetwork", response = Response.class, notes = "Queries an existing network") - @ApiResponses({@ApiResponse(code = 200, message = "Query network successful"), - @ApiResponse(code = 500, message = "Query network failed, examine entity object for details")}) - public Response queryNetwork( - @ApiParam(value = "cloudSiteId", required = false) @QueryParam("cloudSiteId") String cloudSiteId, - @ApiParam(value = "tenantId", required = false) @QueryParam("tenantId") String tenantId, - @ApiParam(value = "networkStackId", required = false) @QueryParam("networkStackId") String networkStackId, - @ApiParam(value = "skipAAI", required = false) @QueryParam("skipAAI") String skipAAI, - @ApiParam(value = "msoRequest.requestId", - required = false) @QueryParam("msoRequest.requestId") String requestId, - @ApiParam(value = "msoRequest.serviceInstanceId", - required = false) @QueryParam("msoRequest.serviceInstanceId") String serviceInstanceId, - @ApiParam(value = "aaiNetworkId", required = false) @PathParam("aaiNetworkId") String aaiNetworkId) { - // This request responds synchronously only - logger.debug("Query network enter:{}" + aaiNetworkId); - MsoRequest msoRequest = new MsoRequest(requestId, serviceInstanceId); - - try { - int respStatus = HttpStatus.SC_OK; - QueryNetworkResponse resp = new QueryNetworkResponse(networkStackId, null, networkStackId, null, null); - Holder networkExists = new Holder<>(); - Holder networkId = new Holder<>(); - Holder neutronNetworkId = new Holder<>(); - Holder status = new Holder<>(); - Holder> routeTargets = new Holder<>(); - Holder> subnetIdMap = new Holder<>(); - - adapter.queryNetworkContrail(cloudSiteId, tenantId, aaiNetworkId, msoRequest, networkExists, networkId, - neutronNetworkId, status, routeTargets, subnetIdMap); - - if (!networkExists.value) { - logger.debug("network not found"); - respStatus = HttpStatus.SC_NOT_FOUND; - } else { - logger.debug("network found {}, status={}", networkId.value, status.value); - resp.setNetworkExists(networkExists.value); - resp.setNetworkId(networkId.value); - resp.setNeutronNetworkId(neutronNetworkId.value); - resp.setNetworkStatus(status.value); - resp.setRouteTargets(routeTargets.value); - resp.setSubnetIdMap(subnetIdMap.value); - } - logger.debug("Query network exit"); - return Response.status(respStatus).entity(new GenericEntity(resp) {}).build(); - } catch (NetworkException e) { - logger.error("{} {} Exception when query VNF ", MessageEnum.RA_QUERY_VNF_ERR, - ErrorCode.BusinessProcessError.getValue(), e); - QueryNetworkError err = new QueryNetworkError(); - err.setMessage(e.getMessage()); - err.setCategory(MsoExceptionCategory.INTERNAL); - return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR) - .entity(new GenericEntity(err) {}).build(); - } - } - - @DELETE - @Path("{aaiNetworkId}/rollback") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @ApiOperation(value = "RollbackNetwork", response = Response.class, notes = "Rollback an existing network") - @ApiResponses({@ApiResponse(code = 200, message = "Rollback network successful"), - @ApiResponse(code = 202, message = "Rollback network request has been accepted (async only)"), - @ApiResponse(code = 500, message = "Rollback network failed, examine entity object for details")}) - public Response rollbackNetwork( - @ApiParam(value = "RollbackNetworkRequest in JSON format", required = true) RollbackNetworkRequest req) { - logger.debug("rollbackNetwork enter: {}", req.toJsonString()); - RollbackNetworkTask task = new RollbackNetworkTask(req); - if (req.isSynchronous()) { - // This is a synchronous request - task.run(); - return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build(); - } else { - // This is an asynchronous request - try { - Thread t1 = new Thread(task); - t1.start(); - } catch (Exception e) { - // problem handling create, send generic failure as sync resp to caller - logger.error("{} {} Exception in rollbackNetwork ", MessageEnum.RA_ROLLBACK_NULL, - ErrorCode.BusinessProcessError.getValue(), e); - return Response.serverError().build(); - } - // send sync response (ACK) to caller - logger.debug("rollbackNetwork exit"); - return Response.status(HttpStatus.SC_ACCEPTED).build(); - } - } - - public class RollbackNetworkTask implements Runnable { - private final RollbackNetworkRequest req; - private RollbackNetworkResponse response = null; - private RollbackNetworkError eresp = null; - private boolean sendxml; - - public RollbackNetworkTask(RollbackNetworkRequest req) { - this.req = req; - this.sendxml = true; // can be set with a field or header later - } - - public int getStatusCode() { - return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST; - } - - public Object getGenericEntityResponse() { - return (response != null) ? new GenericEntity(response) {} - : new GenericEntity(eresp) {}; - } - - private String getResponse() { - if (response != null) { - return sendxml ? response.toXmlString() : response.toJsonString(); - } else { - return sendxml ? eresp.toXmlString() : eresp.toJsonString(); - } - } - - @Override - public void run() { - try { - MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getNetworkRollback().getMsoRequest().getRequestId()); - } catch (Exception e) { - logger.error("Error adding RequestId to MDC", e); - } - logger.debug("RollbackNetworkTask start"); - try { - NetworkRollback nwr = req.getNetworkRollback(); - adapter.rollbackNetwork(nwr); - response = new RollbackNetworkResponse(true, req.getMessageId()); - } catch (NetworkException e) { - logger.debug(exceptionMsg, e); - eresp = new RollbackNetworkError(e.getMessage(), MsoExceptionCategory.INTERNAL, true, - req.getMessageId()); - } - if (!req.isSynchronous()) { - // This is asynch, so POST response back to caller - BpelRestClient bpelClient = bpelRestClientProvider.get(); - bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); - } - logger.debug("RollbackNetworkTask exit: code={}, resp={}", getStatusCode(), getResponse()); - } - } - - @PUT - @Path("{aaiNetworkId}") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @ApiOperation(value = "UpdateNetwork", response = Response.class, notes = "Update an existing network") - @ApiResponses({@ApiResponse(code = 200, message = "Update network successful"), - @ApiResponse(code = 202, message = "Update network request has been accepted (async only)"), - @ApiResponse(code = 500, message = "Update network failed, examine entity object for details")}) - public Response updateNetwork( - @ApiParam(value = "aaiNetworkId", required = true) @PathParam("aaiNetworkId") String aaiNetworkId, - @ApiParam(value = "UpdateNetworkRequest in JSON format", required = true) UpdateNetworkRequest req) { - logger.debug("updateNetwork enter: {}", req.toJsonString()); - if (aaiNetworkId == null || !aaiNetworkId.equals(req.getNetworkId())) { - return Response.status(HttpStatus.SC_BAD_REQUEST).type(MediaType.TEXT_PLAIN).entity( - "A&AI NetworkId in URL (" + aaiNetworkId + ") does not match content (" + req.getNetworkId() + ")") - .build(); - } - UpdateNetworkTask task = new UpdateNetworkTask(req); - if (req.isSynchronous()) { - // This is a synchronous request - task.run(); - return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build(); - } else { - // This is an asynchronous request - try { - Thread t1 = new Thread(task); - t1.start(); - } catch (Exception e) { - // problem handling create, send generic failure as sync resp to caller - logger.error("{} {} Exception in updateNetwork ", MessageEnum.RA_UPDATE_NETWORK_ERR, - ErrorCode.BusinessProcessError.getValue(), e); - return Response.serverError().build(); - } - // send sync response (ACK) to caller - logger.debug("updateNetwork exit"); - return Response.status(HttpStatus.SC_ACCEPTED).build(); - } - } - - public class UpdateNetworkTask implements Runnable { - private final UpdateNetworkRequest req; - private UpdateNetworkResponse response = null; - private UpdateNetworkError eresp = null; - private boolean sendxml; - - public UpdateNetworkTask(UpdateNetworkRequest req) { - this.req = req; - this.sendxml = true; // can be set with a field or header later - } - - public int getStatusCode() { - return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST; - } - - public Object getGenericEntityResponse() { - return (response != null) ? new GenericEntity(response) {} - : new GenericEntity(eresp) {}; - } - - private String getResponse() { - if (response != null) { - return sendxml ? response.toXmlString() : response.toJsonString(); - } else { - return sendxml ? eresp.toXmlString() : eresp.toJsonString(); - } - } - - @Override - public void run() { - try { - MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId()); - } catch (Exception e) { - logger.error("Error adding RequestId to MDC", e); - } - logger.debug("UpdateNetworkTask start"); - try { - Holder> subnetIdMap = new Holder<>(); - Holder rollback = new Holder<>(); - HashMap params = (HashMap) req.getNetworkParams(); - if (params == null) { - params = new HashMap(); - } - String shared = null; - String external = null; - - if (req.getCloudSiteId().equals(TESTING_KEYWORD)) { - subnetIdMap.value = testMap(); - NetworkRollback rb = new NetworkRollback(); - rb.setCloudId(req.getCloudSiteId()); - rb.setTenantId(req.getTenantId()); - rb.setMsoRequest(req.getMsoRequest()); - rollback.value = rb; - } else if (req.isContrailRequest()) { - ContrailNetwork ctn = req.getContrailNetwork(); - if (ctn == null) { - ctn = new ContrailNetwork(); - req.setContrailNetwork(ctn); - } - if (params.containsKey(SHARED)) { - shared = params.get(SHARED); - } else { - if (ctn.getShared() != null) { - shared = ctn.getShared(); - } - } - if (params.containsKey(EXTERNAL)) { - external = params.get(EXTERNAL); - } else { - if (ctn.getExternal() != null) { - external = ctn.getExternal(); - } - } - adapter.updateNetworkContrail(req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(), - req.getModelCustomizationUuid(), req.getNetworkStackId(), req.getNetworkName(), - req.getContrailNetwork().getRouteTargets(), shared, external, req.getSubnets(), params, - req.getContrailNetwork().getPolicyFqdns(), req.getContrailNetwork().getRouteTableFqdns(), - req.getMsoRequest(), subnetIdMap, rollback); - } else { - ProviderVlanNetwork pvn = req.getProviderVlanNetwork(); - if (pvn == null) { - pvn = new ProviderVlanNetwork(); - req.setProviderVlanNetwork(pvn); - } - if (params.containsKey(SHARED)) { - shared = params.get(SHARED); - } - if (params.containsKey(EXTERNAL)) { - external = params.get(EXTERNAL); - } - adapter.updateNetwork(req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(), - req.getModelCustomizationUuid(), req.getNetworkStackId(), req.getNetworkName(), - req.getProviderVlanNetwork().getPhysicalNetworkName(), - req.getProviderVlanNetwork().getVlans(), shared, external, req.getSubnets(), params, - req.getMsoRequest(), subnetIdMap, rollback); - } - response = new UpdateNetworkResponse(req.getNetworkId(), null, // NeutronNetworkId is not available from - // an update - subnetIdMap.value, req.getMessageId()); - } catch (NetworkException e) { - logger.debug(exceptionMsg, e); - eresp = new UpdateNetworkError(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); - } - if (!req.isSynchronous()) { - // This is asynch, so POST response back to caller - BpelRestClient bpelClient = bpelRestClientProvider.get(); - bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); - } - logger.debug("UpdateNetworkTask exit: code={}, resp={}", getStatusCode(), getResponse()); - } - } - - public static Map testMap() { - Map m = new HashMap<>(); - m.put("mickey", "7"); - m.put("clyde", "10"); - m.put("wayne", "99"); - return m; - } -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/CreateNetworkNotification.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/CreateNetworkNotification.java deleted file mode 100644 index f30ccf2214..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/CreateNetworkNotification.java +++ /dev/null @@ -1,394 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (C) 2018 IBM. - * ================================================================================ - * 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.adapters.network.async.client; - -import java.util.ArrayList; -import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

- * Java class for createNetworkNotification complex type. - * - *

- * The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="createNetworkNotification">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="completed" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
- *         <element name="exception" type="{http://org.onap.so/networkNotify}msoExceptionCategory" minOccurs="0"/>
- *         <element name="errorMessage" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="networkId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="neutronNetworkId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="subnetIdMap" minOccurs="0">
- *           <complexType>
- *             <complexContent>
- *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *                 <sequence>
- *                   <element name="entry" maxOccurs="unbounded" minOccurs="0">
- *                     <complexType>
- *                       <complexContent>
- *                         <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *                           <sequence>
- *                             <element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *                             <element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *                           </sequence>
- *                         </restriction>
- *                       </complexContent>
- *                     </complexType>
- *                   </element>
- *                 </sequence>
- *               </restriction>
- *             </complexContent>
- *           </complexType>
- *         </element>
- *         <element name="rollback" type="{http://org.onap.so/networkNotify}networkRollback" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "createNetworkNotification", propOrder = {"messageId", "completed", "exception", "errorMessage", - "networkId", "neutronNetworkId", "subnetIdMap", "rollback"}) -public class CreateNetworkNotification { - - @XmlElement(required = true) - protected String messageId; - protected boolean completed; - protected MsoExceptionCategory exception; - protected String errorMessage; - protected String networkId; - protected String neutronNetworkId; - protected CreateNetworkNotification.SubnetIdMap subnetIdMap; - protected NetworkRollback rollback; - - /** - * Gets the value of the messageId property. - * - * @return possible object is {@link String } - * - */ - public String getMessageId() { - return messageId; - } - - /** - * Sets the value of the messageId property. - * - * @param value allowed object is {@link String } - * - */ - public void setMessageId(String value) { - this.messageId = value; - } - - /** - * Gets the value of the completed property. - * - */ - public boolean isCompleted() { - return completed; - } - - /** - * Sets the value of the completed property. - * - */ - public void setCompleted(boolean value) { - this.completed = value; - } - - /** - * Gets the value of the exception property. - * - * @return possible object is {@link MsoExceptionCategory } - * - */ - public MsoExceptionCategory getException() { - return exception; - } - - /** - * Sets the value of the exception property. - * - * @param value allowed object is {@link MsoExceptionCategory } - * - */ - public void setException(MsoExceptionCategory value) { - this.exception = value; - } - - /** - * Gets the value of the errorMessage property. - * - * @return possible object is {@link String } - * - */ - public String getErrorMessage() { - return errorMessage; - } - - /** - * Sets the value of the errorMessage property. - * - * @param value allowed object is {@link String } - * - */ - public void setErrorMessage(String value) { - this.errorMessage = value; - } - - /** - * Gets the value of the networkId property. - * - * @return possible object is {@link String } - * - */ - public String getNetworkId() { - return networkId; - } - - /** - * Sets the value of the networkId property. - * - * @param value allowed object is {@link String } - * - */ - public void setNetworkId(String value) { - this.networkId = value; - } - - /** - * Gets the value of the neutronNetworkId property. - * - * @return possible object is {@link String } - * - */ - public String getNeutronNetworkId() { - return neutronNetworkId; - } - - /** - * Sets the value of the neutronNetworkId property. - * - * @param value allowed object is {@link String } - * - */ - public void setNeutronNetworkId(String value) { - this.neutronNetworkId = value; - } - - /** - * Gets the value of the subnetIdMap property. - * - * @return possible object is {@link CreateNetworkNotification.SubnetIdMap } - * - */ - public CreateNetworkNotification.SubnetIdMap getSubnetIdMap() { - return subnetIdMap; - } - - /** - * Sets the value of the subnetIdMap property. - * - * @param value allowed object is {@link CreateNetworkNotification.SubnetIdMap } - * - */ - public void setSubnetIdMap(CreateNetworkNotification.SubnetIdMap value) { - this.subnetIdMap = value; - } - - /** - * Gets the value of the rollback property. - * - * @return possible object is {@link NetworkRollback } - * - */ - public NetworkRollback getRollback() { - return rollback; - } - - /** - * Sets the value of the rollback property. - * - * @param value allowed object is {@link NetworkRollback } - * - */ - public void setRollback(NetworkRollback value) { - this.rollback = value; - } - - - /** - *

- * Java class for anonymous complex type. - * - *

- * The following schema fragment specifies the expected content contained within this class. - * - *

-     * <complexType>
-     *   <complexContent>
-     *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
-     *       <sequence>
-     *         <element name="entry" maxOccurs="unbounded" minOccurs="0">
-     *           <complexType>
-     *             <complexContent>
-     *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
-     *                 <sequence>
-     *                   <element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
-     *                   <element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
-     *                 </sequence>
-     *               </restriction>
-     *             </complexContent>
-     *           </complexType>
-     *         </element>
-     *       </sequence>
-     *     </restriction>
-     *   </complexContent>
-     * </complexType>
-     * 
- * - * - */ - @XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "", propOrder = {"entry"}) - public static class SubnetIdMap { - - protected List entry; - - /** - * Gets the value of the entry property. - * - *

- * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you - * make to the returned list will be present inside the JAXB object. This is why there is not a set - * method for the entry property. - * - *

- * For example, to add a new item, do as follows: - * - *

-         * getEntry().add(newItem);
-         * 
- * - * - *

- * Objects of the following type(s) are allowed in the list {@link CreateNetworkNotification.SubnetIdMap.Entry } - * - * - */ - public List getEntry() { - if (entry == null) { - entry = new ArrayList<>(); - } - return this.entry; - } - - - /** - *

- * Java class for anonymous complex type. - * - *

- * The following schema fragment specifies the expected content contained within this class. - * - *

-         * <complexType>
-         *   <complexContent>
-         *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
-         *       <sequence>
-         *         <element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
-         *         <element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
-         *       </sequence>
-         *     </restriction>
-         *   </complexContent>
-         * </complexType>
-         * 
- * - * - */ - @XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "", propOrder = {"key", "value"}) - public static class Entry { - - protected String key; - protected String value; - - /** - * Gets the value of the key property. - * - * @return possible object is {@link String } - * - */ - public String getKey() { - return key; - } - - /** - * Sets the value of the key property. - * - * @param value allowed object is {@link String } - * - */ - public void setKey(String value) { - this.key = value; - } - - /** - * Gets the value of the value property. - * - * @return possible object is {@link String } - * - */ - public String getValue() { - return value; - } - - /** - * Sets the value of the value property. - * - * @param value allowed object is {@link String } - * - */ - public void setValue(String value) { - this.value = value; - } - - } - - } - -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/CreateNetworkNotificationResponse.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/CreateNetworkNotificationResponse.java deleted file mode 100644 index 4ade875193..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/CreateNetworkNotificationResponse.java +++ /dev/null @@ -1,53 +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.adapters.network.async.client; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlType; - - -/** - *

- * Java class for createNetworkNotificationResponse complex type. - * - *

- * The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="createNetworkNotificationResponse">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "createNetworkNotificationResponse") -public class CreateNetworkNotificationResponse { - - -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/DeleteNetworkNotification.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/DeleteNetworkNotification.java deleted file mode 100644 index ff94be9156..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/DeleteNetworkNotification.java +++ /dev/null @@ -1,162 +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.adapters.network.async.client; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

- * Java class for deleteNetworkNotification complex type. - * - *

- * The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="deleteNetworkNotification">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="completed" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
- *         <element name="exception" type="{http://org.onap.so/networkNotify}msoExceptionCategory" minOccurs="0"/>
- *         <element name="errorMessage" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="networkDeleted" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "deleteNetworkNotification", - propOrder = {"messageId", "completed", "exception", "errorMessage", "networkDeleted"}) -public class DeleteNetworkNotification { - - @XmlElement(required = true) - protected String messageId; - protected boolean completed; - protected MsoExceptionCategory exception; - protected String errorMessage; - protected Boolean networkDeleted; - - /** - * Gets the value of the messageId property. - * - * @return possible object is {@link String } - * - */ - public String getMessageId() { - return messageId; - } - - /** - * Sets the value of the messageId property. - * - * @param value allowed object is {@link String } - * - */ - public void setMessageId(String value) { - this.messageId = value; - } - - /** - * Gets the value of the completed property. - * - */ - public boolean isCompleted() { - return completed; - } - - /** - * Sets the value of the completed property. - * - */ - public void setCompleted(boolean value) { - this.completed = value; - } - - /** - * Gets the value of the exception property. - * - * @return possible object is {@link MsoExceptionCategory } - * - */ - public MsoExceptionCategory getException() { - return exception; - } - - /** - * Sets the value of the exception property. - * - * @param value allowed object is {@link MsoExceptionCategory } - * - */ - public void setException(MsoExceptionCategory value) { - this.exception = value; - } - - /** - * Gets the value of the errorMessage property. - * - * @return possible object is {@link String } - * - */ - public String getErrorMessage() { - return errorMessage; - } - - /** - * Sets the value of the errorMessage property. - * - * @param value allowed object is {@link String } - * - */ - public void setErrorMessage(String value) { - this.errorMessage = value; - } - - /** - * Gets the value of the networkDeleted property. - * - * @return possible object is {@link Boolean } - * - */ - public Boolean isNetworkDeleted() { - return networkDeleted; - } - - /** - * Sets the value of the networkDeleted property. - * - * @param value allowed object is {@link Boolean } - * - */ - public void setNetworkDeleted(Boolean value) { - this.networkDeleted = value; - } - -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/DeleteNetworkNotificationResponse.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/DeleteNetworkNotificationResponse.java deleted file mode 100644 index 7f7d0ae569..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/DeleteNetworkNotificationResponse.java +++ /dev/null @@ -1,53 +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.adapters.network.async.client; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlType; - - -/** - *

- * Java class for deleteNetworkNotificationResponse complex type. - * - *

- * The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="deleteNetworkNotificationResponse">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "deleteNetworkNotificationResponse") -public class DeleteNetworkNotificationResponse { - - -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/MsoExceptionCategory.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/MsoExceptionCategory.java deleted file mode 100644 index ad3c541730..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/MsoExceptionCategory.java +++ /dev/null @@ -1,61 +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.adapters.network.async.client; - -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlType; - - -/** - *

- * Java class for msoExceptionCategory. - * - *

- * The following schema fragment specifies the expected content contained within this class. - *

- * - *

- * <simpleType name="msoExceptionCategory">
- *   <restriction base="{http://www.w3.org/2001/XMLSchema}string">
- *     <enumeration value="OPENSTACK"/>
- *     <enumeration value="IO"/>
- *     <enumeration value="INTERNAL"/>
- *     <enumeration value="USERDATA"/>
- *   </restriction>
- * </simpleType>
- * 
- * - */ -@XmlType(name = "msoExceptionCategory") -@XmlEnum -public enum MsoExceptionCategory { - - OPENSTACK, IO, INTERNAL, USERDATA; - - public String value() { - return name(); - } - - public static MsoExceptionCategory fromValue(String v) { - return valueOf(v); - } - -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/MsoRequest.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/MsoRequest.java deleted file mode 100644 index 90ae448660..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/MsoRequest.java +++ /dev/null @@ -1,97 +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.adapters.network.async.client; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlType; - - -/** - *

- * Java class for msoRequest complex type. - * - *

- * The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="msoRequest">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="requestId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="serviceInstanceId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "msoRequest", propOrder = {"requestId", "serviceInstanceId"}) -public class MsoRequest { - - protected String requestId; - protected String serviceInstanceId; - - /** - * Gets the value of the requestId property. - * - * @return possible object is {@link String } - * - */ - public String getRequestId() { - return requestId; - } - - /** - * Sets the value of the requestId property. - * - * @param value allowed object is {@link String } - * - */ - public void setRequestId(String value) { - this.requestId = value; - } - - /** - * Gets the value of the serviceInstanceId property. - * - * @return possible object is {@link String } - * - */ - public String getServiceInstanceId() { - return serviceInstanceId; - } - - /** - * Sets the value of the serviceInstanceId property. - * - * @param value allowed object is {@link String } - * - */ - public void setServiceInstanceId(String value) { - this.serviceInstanceId = value; - } - -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/NetworkAdapterNotify.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/NetworkAdapterNotify.java deleted file mode 100644 index 8fb62cc32e..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/NetworkAdapterNotify.java +++ /dev/null @@ -1,170 +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.adapters.network.async.client; - -import java.util.List; -import javax.jws.WebMethod; -import javax.jws.WebParam; -import javax.jws.WebService; -import javax.xml.bind.annotation.XmlSeeAlso; -import javax.xml.ws.Action; -import javax.xml.ws.RequestWrapper; -import javax.xml.ws.ResponseWrapper; - - -/** - * This class was generated by the JAX-WS RI. JAX-WS RI 2.2.9-b14002 Generated source version: 2.2 - * - */ -@WebService(name = "networkAdapterNotify", targetNamespace = "http://org.onap.so/networkNotify") -@XmlSeeAlso({ObjectFactory.class}) -public interface NetworkAdapterNotify { - - - /** - * - * @param exception - * @param errorMessage - * @param messageId - * @param completed - */ - @WebMethod - @RequestWrapper(localName = "rollbackNetworkNotification", targetNamespace = "http://org.onap.so/networkNotify", - className = "org.onap.so.adapters.network.async.client.RollbackNetworkNotification") - @ResponseWrapper(localName = "rollbackNetworkNotificationResponse", - targetNamespace = "http://org.onap.so/networkNotify", - className = "org.onap.so.adapters.network.async.client.RollbackNetworkNotificationResponse") - @Action(input = "http://org.onap.so/notify/adapterNotify/rollbackNetworkNotificationRequest", - output = "http://org.onap.so/notify/adapterNotify/rollbackNetworkNotificationResponse") - public void rollbackNetworkNotification(@WebParam(name = "messageId", targetNamespace = "") String messageId, - @WebParam(name = "completed", targetNamespace = "") boolean completed, - @WebParam(name = "exception", targetNamespace = "") MsoExceptionCategory exception, - @WebParam(name = "errorMessage", targetNamespace = "") String errorMessage); - - /** - * - * @param exception - * @param vlans - * @param networkExists - * @param errorMessage - * @param messageId - * @param networkId - * @param completed - * @param neutronNetworkId - * @param status - * @param subnetIdMap - */ - @WebMethod - @RequestWrapper(localName = "queryNetworkNotification", targetNamespace = "http://org.onap.so/networkNotify", - className = "org.onap.so.adapters.network.async.client.QueryNetworkNotification") - @ResponseWrapper(localName = "queryNetworkNotificationResponse", - targetNamespace = "http://org.onap.so/networkNotify", - className = "org.onap.so.adapters.network.async.client.QueryNetworkNotificationResponse") - @Action(input = "http://org.onap.so/notify/adapterNotify/queryNetworkNotificationRequest", - output = "http://org.onap.so/notify/adapterNotify/queryNetworkNotificationResponse") - public void queryNetworkNotification(@WebParam(name = "messageId", targetNamespace = "") String messageId, - @WebParam(name = "completed", targetNamespace = "") boolean completed, - @WebParam(name = "exception", targetNamespace = "") MsoExceptionCategory exception, - @WebParam(name = "errorMessage", targetNamespace = "") String errorMessage, - @WebParam(name = "networkExists", targetNamespace = "") Boolean networkExists, - @WebParam(name = "networkId", targetNamespace = "") String networkId, - @WebParam(name = "neutronNetworkId", targetNamespace = "") String neutronNetworkId, - @WebParam(name = "status", targetNamespace = "") NetworkStatus status, - @WebParam(name = "vlans", targetNamespace = "") List vlans, @WebParam(name = "subnetIdMap", - targetNamespace = "") org.onap.so.adapters.network.async.client.QueryNetworkNotification.SubnetIdMap subnetIdMap); - - /** - * - * @param exception - * @param rollback - * @param errorMessage - * @param messageId - * @param networkId - * @param completed - * @param neutronNetworkId - * @param subnetIdMap - */ - @WebMethod - @RequestWrapper(localName = "createNetworkNotification", targetNamespace = "http://org.onap.so/networkNotify", - className = "org.onap.so.adapters.network.async.client.CreateNetworkNotification") - @ResponseWrapper(localName = "createNetworkNotificationResponse", - targetNamespace = "http://org.onap.so/networkNotify", - className = "org.onap.so.adapters.network.async.client.CreateNetworkNotificationResponse") - @Action(input = "http://org.onap.so/notify/adapterNotify/createNetworkNotificationRequest", - output = "http://org.onap.so/notify/adapterNotify/createNetworkNotificationResponse") - public void createNetworkNotification(@WebParam(name = "messageId", targetNamespace = "") String messageId, - @WebParam(name = "completed", targetNamespace = "") boolean completed, - @WebParam(name = "exception", targetNamespace = "") MsoExceptionCategory exception, - @WebParam(name = "errorMessage", targetNamespace = "") String errorMessage, - @WebParam(name = "networkId", targetNamespace = "") String networkId, - @WebParam(name = "neutronNetworkId", targetNamespace = "") String neutronNetworkId, - @WebParam(name = "subnetIdMap", - targetNamespace = "") org.onap.so.adapters.network.async.client.CreateNetworkNotification.SubnetIdMap subnetIdMap, - @WebParam(name = "rollback", targetNamespace = "") NetworkRollback rollback); - - /** - * - * @param exception - * @param networkDeleted - * @param errorMessage - * @param messageId - * @param completed - */ - @WebMethod - @RequestWrapper(localName = "deleteNetworkNotification", targetNamespace = "http://org.onap.so/networkNotify", - className = "org.onap.so.adapters.network.async.client.DeleteNetworkNotification") - @ResponseWrapper(localName = "deleteNetworkNotificationResponse", - targetNamespace = "http://org.onap.so/networkNotify", - className = "org.onap.so.adapters.network.async.client.DeleteNetworkNotificationResponse") - @Action(input = "http://org.onap.so/notify/adapterNotify/deleteNetworkNotificationRequest", - output = "http://org.onap.so/notify/adapterNotify/deleteNetworkNotificationResponse") - public void deleteNetworkNotification(@WebParam(name = "messageId", targetNamespace = "") String messageId, - @WebParam(name = "completed", targetNamespace = "") boolean completed, - @WebParam(name = "exception", targetNamespace = "") MsoExceptionCategory exception, - @WebParam(name = "errorMessage", targetNamespace = "") String errorMessage, - @WebParam(name = "networkDeleted", targetNamespace = "") Boolean networkDeleted); - - /** - * - * @param exception - * @param rollback - * @param errorMessage - * @param messageId - * @param completed - * @param subnetIdMap - */ - @WebMethod - @RequestWrapper(localName = "updateNetworkNotification", targetNamespace = "http://org.onap.so/networkNotify", - className = "org.onap.so.adapters.network.async.client.UpdateNetworkNotification") - @ResponseWrapper(localName = "updateNetworkNotificationResponse", - targetNamespace = "http://org.onap.so/networkNotify", - className = "org.onap.so.adapters.network.async.client.UpdateNetworkNotificationResponse") - @Action(input = "http://org.onap.so/notify/adapterNotify/updateNetworkNotificationRequest", - output = "http://org.onap.so/notify/adapterNotify/updateNetworkNotificationResponse") - public void updateNetworkNotification(@WebParam(name = "messageId", targetNamespace = "") String messageId, - @WebParam(name = "completed", targetNamespace = "") boolean completed, - @WebParam(name = "exception", targetNamespace = "") MsoExceptionCategory exception, - @WebParam(name = "errorMessage", targetNamespace = "") String errorMessage, - @WebParam(name = "subnetIdMap", - targetNamespace = "") org.onap.so.adapters.network.async.client.UpdateNetworkNotification.SubnetIdMap subnetIdMap, - @WebParam(name = "rollback", targetNamespace = "") NetworkRollback rollback); - -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/NetworkAdapterNotify_Service.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/NetworkAdapterNotify_Service.java deleted file mode 100644 index 68142e6cc9..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/NetworkAdapterNotify_Service.java +++ /dev/null @@ -1,110 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (C) 2018 IBM. - * ================================================================================ - * 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.adapters.network.async.client; - -import java.net.URL; -import javax.xml.namespace.QName; -import javax.xml.ws.Service; -import javax.xml.ws.WebEndpoint; -import javax.xml.ws.WebServiceClient; -import javax.xml.ws.WebServiceException; -import javax.xml.ws.WebServiceFeature; - - -/** - * This class was generated by the JAX-WS RI. JAX-WS RI 2.2.9-b14002 Generated source version: 2.2 - * - */ -@WebServiceClient(name = "networkAdapterNotify", targetNamespace = "http://org.onap.so/networkNotify", - wsdlLocation = "/NetworkAdapterNotify.wsdl") -public class NetworkAdapterNotify_Service extends Service { - - private static final URL NETWORKADAPTERNOTIFY_WSDL_LOCATION; - private static final WebServiceException NETWORKADAPTERNOTIFY_EXCEPTION; - private static final String URL = "http://org.onap.so/networkNotify"; - private static final QName NETWORKADAPTERNOTIFY_QNAME = new QName(URL, "networkAdapterNotify"); - - static { - NETWORKADAPTERNOTIFY_WSDL_LOCATION = - org.onap.so.adapters.network.async.client.NetworkAdapterNotify_Service.class - .getResource("/NetworkAdapterNotify.wsdl"); - WebServiceException e = null; - if (NETWORKADAPTERNOTIFY_WSDL_LOCATION == null) { - e = new WebServiceException( - "Cannot find '/NetworkAdapterNotify.wsdl' wsdl. Place the resource correctly in the classpath."); - } - NETWORKADAPTERNOTIFY_EXCEPTION = e; - } - - public NetworkAdapterNotify_Service() { - super(getWsdlLocation(), NETWORKADAPTERNOTIFY_QNAME); - } - - public NetworkAdapterNotify_Service(WebServiceFeature... features) { - super(getWsdlLocation(), NETWORKADAPTERNOTIFY_QNAME, features); - } - - public NetworkAdapterNotify_Service(URL wsdlLocation) { - super(wsdlLocation, NETWORKADAPTERNOTIFY_QNAME); - } - - public NetworkAdapterNotify_Service(URL wsdlLocation, WebServiceFeature... features) { - super(wsdlLocation, NETWORKADAPTERNOTIFY_QNAME, features); - } - - public NetworkAdapterNotify_Service(URL wsdlLocation, QName serviceName) { - super(wsdlLocation, serviceName); - } - - public NetworkAdapterNotify_Service(URL wsdlLocation, QName serviceName, WebServiceFeature... features) { - super(wsdlLocation, serviceName, features); - } - - /** - * - * @return returns NetworkAdapterNotify - */ - @WebEndpoint(name = "MsoNetworkAdapterAsyncImplPort") - public NetworkAdapterNotify getMsoNetworkAdapterAsyncImplPort() { - return super.getPort(new QName(URL, "MsoNetworkAdapterAsyncImplPort"), NetworkAdapterNotify.class); - } - - /** - * - * @param features A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features - * not in the features parameter will have their default values. - * @return returns NetworkAdapterNotify - */ - @WebEndpoint(name = "MsoNetworkAdapterAsyncImplPort") - public NetworkAdapterNotify getMsoNetworkAdapterAsyncImplPort(WebServiceFeature... features) { - return super.getPort(new QName(URL, "MsoNetworkAdapterAsyncImplPort"), NetworkAdapterNotify.class, features); - } - - private static URL getWsdlLocation() { - if (NETWORKADAPTERNOTIFY_EXCEPTION != null) { - throw NETWORKADAPTERNOTIFY_EXCEPTION; - } - return NETWORKADAPTERNOTIFY_WSDL_LOCATION; - } - -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/NetworkRollback.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/NetworkRollback.java deleted file mode 100644 index c51a21d5f0..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/NetworkRollback.java +++ /dev/null @@ -1,325 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (C) 2018 IBM. - * ================================================================================ - * 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.adapters.network.async.client; - -import java.util.ArrayList; -import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

- * Java class for networkRollback complex type. - * - *

- * The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="networkRollback">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="cloudId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="msoRequest" type="{http://org.onap.so/networkNotify}msoRequest" minOccurs="0"/>
- *         <element name="networkCreated" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
- *         <element name="networkId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="networkStackId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="networkName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="networkType" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="networkUpdated" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
- *         <element name="neutronNetworkId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="physicalNetwork" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="tenantId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="vlans" type="{http://www.w3.org/2001/XMLSchema}int" maxOccurs="unbounded" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "networkRollback", - propOrder = {"cloudId", "msoRequest", "networkCreated", "networkId", "networkStackId", "networkName", - "networkType", "networkUpdated", "neutronNetworkId", "physicalNetwork", "tenantId", "vlans"}) -public class NetworkRollback { - - protected String cloudId; - protected MsoRequest msoRequest; - protected boolean networkCreated; - protected String networkId; - protected String networkStackId; - protected String networkName; - protected String networkType; - protected boolean networkUpdated; - protected String neutronNetworkId; - protected String physicalNetwork; - protected String tenantId; - @XmlElement(nillable = true) - protected List vlans; - - /** - * Gets the value of the cloudId property. - * - * @return possible object is {@link String } - * - */ - public String getCloudId() { - return cloudId; - } - - /** - * Sets the value of the cloudId property. - * - * @param value allowed object is {@link String } - * - */ - public void setCloudId(String value) { - this.cloudId = value; - } - - /** - * Gets the value of the msoRequest property. - * - * @return possible object is {@link MsoRequest } - * - */ - public MsoRequest getMsoRequest() { - return msoRequest; - } - - /** - * Sets the value of the msoRequest property. - * - * @param value allowed object is {@link MsoRequest } - * - */ - public void setMsoRequest(MsoRequest value) { - this.msoRequest = value; - } - - /** - * Gets the value of the networkCreated property. - * - */ - public boolean isNetworkCreated() { - return networkCreated; - } - - /** - * Sets the value of the networkCreated property. - * - */ - public void setNetworkCreated(boolean value) { - this.networkCreated = value; - } - - /** - * Gets the value of the networkId property. - * - * @return possible object is {@link String } - * - */ - public String getNetworkId() { - return networkId; - } - - /** - * Sets the value of the networkId property. - * - * @param value allowed object is {@link String } - * - */ - public void setNetworkId(String value) { - this.networkId = value; - } - - /** - * Gets the value of the networkStackId property. - * - * @return possible object is {@link String } - * - */ - public String getNetworkStackId() { - return networkStackId; - } - - /** - * Sets the value of the networkStackId property. - * - * @param value allowed object is {@link String } - * - */ - public void setNetworkStackId(String value) { - this.networkStackId = value; - } - - /** - * Gets the value of the networkName property. - * - * @return possible object is {@link String } - * - */ - public String getNetworkName() { - return networkName; - } - - /** - * Sets the value of the networkName property. - * - * @param value allowed object is {@link String } - * - */ - public void setNetworkName(String value) { - this.networkName = value; - } - - /** - * Gets the value of the networkType property. - * - * @return possible object is {@link String } - * - */ - public String getNetworkType() { - return networkType; - } - - /** - * Sets the value of the networkType property. - * - * @param value allowed object is {@link String } - * - */ - public void setNetworkType(String value) { - this.networkType = value; - } - - /** - * Gets the value of the networkUpdated property. - * - */ - public boolean isNetworkUpdated() { - return networkUpdated; - } - - /** - * Sets the value of the networkUpdated property. - * - */ - public void setNetworkUpdated(boolean value) { - this.networkUpdated = value; - } - - /** - * Gets the value of the neutronNetworkId property. - * - * @return possible object is {@link String } - * - */ - public String getNeutronNetworkId() { - return neutronNetworkId; - } - - /** - * Sets the value of the neutronNetworkId property. - * - * @param value allowed object is {@link String } - * - */ - public void setNeutronNetworkId(String value) { - this.neutronNetworkId = value; - } - - /** - * Gets the value of the physicalNetwork property. - * - * @return possible object is {@link String } - * - */ - public String getPhysicalNetwork() { - return physicalNetwork; - } - - /** - * Sets the value of the physicalNetwork property. - * - * @param value allowed object is {@link String } - * - */ - public void setPhysicalNetwork(String value) { - this.physicalNetwork = value; - } - - /** - * Gets the value of the tenantId property. - * - * @return possible object is {@link String } - * - */ - public String getTenantId() { - return tenantId; - } - - /** - * Sets the value of the tenantId property. - * - * @param value allowed object is {@link String } - * - */ - public void setTenantId(String value) { - this.tenantId = value; - } - - /** - * Gets the value of the vlans property. - * - *

- * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to - * the returned list will be present inside the JAXB object. This is why there is not a set method for - * the vlans property. - * - *

- * For example, to add a new item, do as follows: - * - *

-     * getVlans().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list {@link Integer } - * - * - */ - public List getVlans() { - if (vlans == null) { - vlans = new ArrayList<>(); - } - return this.vlans; - } - -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/NetworkStatus.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/NetworkStatus.java deleted file mode 100644 index 36641477c0..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/NetworkStatus.java +++ /dev/null @@ -1,63 +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.adapters.network.async.client; - -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlType; - - -/** - *

- * Java class for networkStatus. - * - *

- * The following schema fragment specifies the expected content contained within this class. - *

- * - *

- * <simpleType name="networkStatus">
- *   <restriction base="{http://www.w3.org/2001/XMLSchema}string">
- *     <enumeration value="NOTFOUND"/>
- *     <enumeration value="ACTIVE"/>
- *     <enumeration value="DOWN"/>
- *     <enumeration value="BUILD"/>
- *     <enumeration value="ERROR"/>
- *     <enumeration value="UNKNOWN"/>
- *   </restriction>
- * </simpleType>
- * 
- * - */ -@XmlType(name = "networkStatus") -@XmlEnum -public enum NetworkStatus { - - NOTFOUND, ACTIVE, DOWN, BUILD, ERROR, UNKNOWN; - - public String value() { - return name(); - } - - public static NetworkStatus fromValue(String v) { - return valueOf(v); - } - -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/ObjectFactory.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/ObjectFactory.java deleted file mode 100644 index a7a2974660..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/ObjectFactory.java +++ /dev/null @@ -1,311 +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.adapters.network.async.client; - -import javax.xml.bind.JAXBElement; -import javax.xml.bind.annotation.XmlElementDecl; -import javax.xml.bind.annotation.XmlRegistry; -import javax.xml.namespace.QName; - - -/** - * This object contains factory methods for each Java content interface and Java element interface generated in the - * org.onap.so.adapters.network.async.client package. - *

- * An ObjectFactory allows you to programatically construct new instances of the Java representation for XML content. - * The Java representation of XML content can consist of schema derived interfaces and classes representing the binding - * of schema type definitions, element declarations and model groups. Factory methods for each of these are provided in - * this class. - * - */ -@XmlRegistry -public class ObjectFactory { - - private static final String URL = "http://org.onap.so/networkNotify"; - private static final QName _RollbackNetworkNotification_QNAME = new QName(URL, "rollbackNetworkNotification"); - private static final QName _UpdateNetworkNotification_QNAME = new QName(URL, "updateNetworkNotification"); - private static final QName _QueryNetworkNotificationResponse_QNAME = - new QName(URL, "queryNetworkNotificationResponse"); - private static final QName _UpdateNetworkNotificationResponse_QNAME = - new QName(URL, "updateNetworkNotificationResponse"); - private static final QName _CreateNetworkNotificationResponse_QNAME = - new QName(URL, "createNetworkNotificationResponse"); - private static final QName _DeleteNetworkNotification_QNAME = new QName(URL, "deleteNetworkNotification"); - private static final QName _DeleteNetworkNotificationResponse_QNAME = - new QName(URL, "deleteNetworkNotificationResponse"); - private static final QName _CreateNetworkNotification_QNAME = new QName(URL, "createNetworkNotification"); - private static final QName _QueryNetworkNotification_QNAME = new QName(URL, "queryNetworkNotification"); - private static final QName _RollbackNetworkNotificationResponse_QNAME = - new QName(URL, "rollbackNetworkNotificationResponse"); - - /** - * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: - * org.onap.so.adapters.network.async.client - * - */ - public ObjectFactory() {} - - /** - * Create an instance of {@link QueryNetworkNotification } - * - */ - public QueryNetworkNotification createQueryNetworkNotification() { - return new QueryNetworkNotification(); - } - - /** - * Create an instance of {@link QueryNetworkNotification.SubnetIdMap } - * - */ - public QueryNetworkNotification.SubnetIdMap createQueryNetworkNotificationSubnetIdMap() { - return new QueryNetworkNotification.SubnetIdMap(); - } - - /** - * Create an instance of {@link CreateNetworkNotification } - * - */ - public CreateNetworkNotification createCreateNetworkNotification() { - return new CreateNetworkNotification(); - } - - /** - * Create an instance of {@link CreateNetworkNotification.SubnetIdMap } - * - */ - public CreateNetworkNotification.SubnetIdMap createCreateNetworkNotificationSubnetIdMap() { - return new CreateNetworkNotification.SubnetIdMap(); - } - - /** - * Create an instance of {@link UpdateNetworkNotification } - * - */ - public UpdateNetworkNotification createUpdateNetworkNotification() { - return new UpdateNetworkNotification(); - } - - /** - * Create an instance of {@link UpdateNetworkNotification.SubnetIdMap } - * - */ - public UpdateNetworkNotification.SubnetIdMap createUpdateNetworkNotificationSubnetIdMap() { - return new UpdateNetworkNotification.SubnetIdMap(); - } - - /** - * Create an instance of {@link UpdateNetworkNotificationResponse } - * - */ - public UpdateNetworkNotificationResponse createUpdateNetworkNotificationResponse() { - return new UpdateNetworkNotificationResponse(); - } - - /** - * Create an instance of {@link CreateNetworkNotificationResponse } - * - */ - public CreateNetworkNotificationResponse createCreateNetworkNotificationResponse() { - return new CreateNetworkNotificationResponse(); - } - - /** - * Create an instance of {@link RollbackNetworkNotification } - * - */ - public RollbackNetworkNotification createRollbackNetworkNotification() { - return new RollbackNetworkNotification(); - } - - /** - * Create an instance of {@link QueryNetworkNotificationResponse } - * - */ - public QueryNetworkNotificationResponse createQueryNetworkNotificationResponse() { - return new QueryNetworkNotificationResponse(); - } - - /** - * Create an instance of {@link RollbackNetworkNotificationResponse } - * - */ - public RollbackNetworkNotificationResponse createRollbackNetworkNotificationResponse() { - return new RollbackNetworkNotificationResponse(); - } - - /** - * Create an instance of {@link DeleteNetworkNotification } - * - */ - public DeleteNetworkNotification createDeleteNetworkNotification() { - return new DeleteNetworkNotification(); - } - - /** - * Create an instance of {@link DeleteNetworkNotificationResponse } - * - */ - public DeleteNetworkNotificationResponse createDeleteNetworkNotificationResponse() { - return new DeleteNetworkNotificationResponse(); - } - - /** - * Create an instance of {@link NetworkRollback } - * - */ - public NetworkRollback createNetworkRollback() { - return new NetworkRollback(); - } - - /** - * Create an instance of {@link MsoRequest } - * - */ - public MsoRequest createMsoRequest() { - return new MsoRequest(); - } - - /** - * Create an instance of {@link QueryNetworkNotification.SubnetIdMap.Entry } - * - */ - public QueryNetworkNotification.SubnetIdMap.Entry createQueryNetworkNotificationSubnetIdMapEntry() { - return new QueryNetworkNotification.SubnetIdMap.Entry(); - } - - /** - * Create an instance of {@link CreateNetworkNotification.SubnetIdMap.Entry } - * - */ - public CreateNetworkNotification.SubnetIdMap.Entry createCreateNetworkNotificationSubnetIdMapEntry() { - return new CreateNetworkNotification.SubnetIdMap.Entry(); - } - - /** - * Create an instance of {@link UpdateNetworkNotification.SubnetIdMap.Entry } - * - */ - public UpdateNetworkNotification.SubnetIdMap.Entry createUpdateNetworkNotificationSubnetIdMapEntry() { - return new UpdateNetworkNotification.SubnetIdMap.Entry(); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link RollbackNetworkNotification }{@code >}} - * - */ - @XmlElementDecl(namespace = URL, name = "rollbackNetworkNotification") - public JAXBElement createRollbackNetworkNotification( - RollbackNetworkNotification value) { - return new JAXBElement<>(_RollbackNetworkNotification_QNAME, RollbackNetworkNotification.class, null, value); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link UpdateNetworkNotification }{@code >}} - * - */ - @XmlElementDecl(namespace = URL, name = "updateNetworkNotification") - public JAXBElement createUpdateNetworkNotification(UpdateNetworkNotification value) { - return new JAXBElement<>(_UpdateNetworkNotification_QNAME, UpdateNetworkNotification.class, null, value); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link QueryNetworkNotificationResponse }{@code >}} - * - */ - @XmlElementDecl(namespace = URL, name = "queryNetworkNotificationResponse") - public JAXBElement createQueryNetworkNotificationResponse( - QueryNetworkNotificationResponse value) { - return new JAXBElement<>(_QueryNetworkNotificationResponse_QNAME, QueryNetworkNotificationResponse.class, null, - value); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link UpdateNetworkNotificationResponse }{@code >}} - * - */ - @XmlElementDecl(namespace = URL, name = "updateNetworkNotificationResponse") - public JAXBElement createUpdateNetworkNotificationResponse( - UpdateNetworkNotificationResponse value) { - return new JAXBElement<>(_UpdateNetworkNotificationResponse_QNAME, UpdateNetworkNotificationResponse.class, - null, value); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link CreateNetworkNotificationResponse }{@code >}} - * - */ - @XmlElementDecl(namespace = URL, name = "createNetworkNotificationResponse") - public JAXBElement createCreateNetworkNotificationResponse( - CreateNetworkNotificationResponse value) { - return new JAXBElement<>(_CreateNetworkNotificationResponse_QNAME, CreateNetworkNotificationResponse.class, - null, value); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link DeleteNetworkNotification }{@code >}} - * - */ - @XmlElementDecl(namespace = URL, name = "deleteNetworkNotification") - public JAXBElement createDeleteNetworkNotification(DeleteNetworkNotification value) { - return new JAXBElement<>(_DeleteNetworkNotification_QNAME, DeleteNetworkNotification.class, null, value); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link DeleteNetworkNotificationResponse }{@code >}} - * - */ - @XmlElementDecl(namespace = URL, name = "deleteNetworkNotificationResponse") - public JAXBElement createDeleteNetworkNotificationResponse( - DeleteNetworkNotificationResponse value) { - return new JAXBElement<>(_DeleteNetworkNotificationResponse_QNAME, DeleteNetworkNotificationResponse.class, - null, value); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link CreateNetworkNotification }{@code >}} - * - */ - @XmlElementDecl(namespace = URL, name = "createNetworkNotification") - public JAXBElement createCreateNetworkNotification(CreateNetworkNotification value) { - return new JAXBElement<>(_CreateNetworkNotification_QNAME, CreateNetworkNotification.class, null, value); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link QueryNetworkNotification }{@code >}} - * - */ - @XmlElementDecl(namespace = URL, name = "queryNetworkNotification") - public JAXBElement createQueryNetworkNotification(QueryNetworkNotification value) { - return new JAXBElement<>(_QueryNetworkNotification_QNAME, QueryNetworkNotification.class, null, value); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link RollbackNetworkNotificationResponse }{@code >}} - * - */ - @XmlElementDecl(namespace = URL, name = "rollbackNetworkNotificationResponse") - public JAXBElement createRollbackNetworkNotificationResponse( - RollbackNetworkNotificationResponse value) { - return new JAXBElement<>(_RollbackNetworkNotificationResponse_QNAME, RollbackNetworkNotificationResponse.class, - null, value); - } - -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/QueryNetworkNotification.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/QueryNetworkNotification.java deleted file mode 100644 index d9adbf2ad2..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/QueryNetworkNotification.java +++ /dev/null @@ -1,447 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (C) 2018 IBM. - * ================================================================================ - * 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.adapters.network.async.client; - -import java.util.ArrayList; -import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

- * Java class for queryNetworkNotification complex type. - * - *

- * The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="queryNetworkNotification">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="completed" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
- *         <element name="exception" type="{http://org.onap.so/networkNotify}msoExceptionCategory" minOccurs="0"/>
- *         <element name="errorMessage" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="networkExists" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
- *         <element name="networkId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="neutronNetworkId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="status" type="{http://org.onap.so/networkNotify}networkStatus" minOccurs="0"/>
- *         <element name="vlans" type="{http://www.w3.org/2001/XMLSchema}int" maxOccurs="unbounded" minOccurs="0"/>
- *         <element name="subnetIdMap" minOccurs="0">
- *           <complexType>
- *             <complexContent>
- *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *                 <sequence>
- *                   <element name="entry" maxOccurs="unbounded" minOccurs="0">
- *                     <complexType>
- *                       <complexContent>
- *                         <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *                           <sequence>
- *                             <element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *                             <element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *                           </sequence>
- *                         </restriction>
- *                       </complexContent>
- *                     </complexType>
- *                   </element>
- *                 </sequence>
- *               </restriction>
- *             </complexContent>
- *           </complexType>
- *         </element>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "queryNetworkNotification", propOrder = {"messageId", "completed", "exception", "errorMessage", - "networkExists", "networkId", "neutronNetworkId", "status", "vlans", "subnetIdMap"}) -public class QueryNetworkNotification { - - @XmlElement(required = true) - protected String messageId; - protected boolean completed; - protected MsoExceptionCategory exception; - protected String errorMessage; - protected Boolean networkExists; - protected String networkId; - protected String neutronNetworkId; - protected NetworkStatus status; - @XmlElement(type = Integer.class) - protected List vlans; - protected QueryNetworkNotification.SubnetIdMap subnetIdMap; - - /** - * Gets the value of the messageId property. - * - * @return possible object is {@link String } - * - */ - public String getMessageId() { - return messageId; - } - - /** - * Sets the value of the messageId property. - * - * @param value allowed object is {@link String } - * - */ - public void setMessageId(String value) { - this.messageId = value; - } - - /** - * Gets the value of the completed property. - * - */ - public boolean isCompleted() { - return completed; - } - - /** - * Sets the value of the completed property. - * - */ - public void setCompleted(boolean value) { - this.completed = value; - } - - /** - * Gets the value of the exception property. - * - * @return possible object is {@link MsoExceptionCategory } - * - */ - public MsoExceptionCategory getException() { - return exception; - } - - /** - * Sets the value of the exception property. - * - * @param value allowed object is {@link MsoExceptionCategory } - * - */ - public void setException(MsoExceptionCategory value) { - this.exception = value; - } - - /** - * Gets the value of the errorMessage property. - * - * @return possible object is {@link String } - * - */ - public String getErrorMessage() { - return errorMessage; - } - - /** - * Sets the value of the errorMessage property. - * - * @param value allowed object is {@link String } - * - */ - public void setErrorMessage(String value) { - this.errorMessage = value; - } - - /** - * Gets the value of the networkExists property. - * - * @return possible object is {@link Boolean } - * - */ - public Boolean isNetworkExists() { - return networkExists; - } - - /** - * Sets the value of the networkExists property. - * - * @param value allowed object is {@link Boolean } - * - */ - public void setNetworkExists(Boolean value) { - this.networkExists = value; - } - - /** - * Gets the value of the networkId property. - * - * @return possible object is {@link String } - * - */ - public String getNetworkId() { - return networkId; - } - - /** - * Sets the value of the networkId property. - * - * @param value allowed object is {@link String } - * - */ - public void setNetworkId(String value) { - this.networkId = value; - } - - /** - * Gets the value of the neutronNetworkId property. - * - * @return possible object is {@link String } - * - */ - public String getNeutronNetworkId() { - return neutronNetworkId; - } - - /** - * Sets the value of the neutronNetworkId property. - * - * @param value allowed object is {@link String } - * - */ - public void setNeutronNetworkId(String value) { - this.neutronNetworkId = value; - } - - /** - * Gets the value of the status property. - * - * @return possible object is {@link NetworkStatus } - * - */ - public NetworkStatus getStatus() { - return status; - } - - /** - * Sets the value of the status property. - * - * @param value allowed object is {@link NetworkStatus } - * - */ - public void setStatus(NetworkStatus value) { - this.status = value; - } - - /** - * Gets the value of the vlans property. - * - *

- * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to - * the returned list will be present inside the JAXB object. This is why there is not a set method for - * the vlans property. - * - *

- * For example, to add a new item, do as follows: - * - *

-     * getVlans().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list {@link Integer } - * - * - */ - public List getVlans() { - if (vlans == null) { - vlans = new ArrayList<>(); - } - return this.vlans; - } - - /** - * Gets the value of the subnetIdMap property. - * - * @return possible object is {@link QueryNetworkNotification.SubnetIdMap } - * - */ - public QueryNetworkNotification.SubnetIdMap getSubnetIdMap() { - return subnetIdMap; - } - - /** - * Sets the value of the subnetIdMap property. - * - * @param value allowed object is {@link QueryNetworkNotification.SubnetIdMap } - * - */ - public void setSubnetIdMap(QueryNetworkNotification.SubnetIdMap value) { - this.subnetIdMap = value; - } - - - /** - *

- * Java class for anonymous complex type. - * - *

- * The following schema fragment specifies the expected content contained within this class. - * - *

-     * <complexType>
-     *   <complexContent>
-     *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
-     *       <sequence>
-     *         <element name="entry" maxOccurs="unbounded" minOccurs="0">
-     *           <complexType>
-     *             <complexContent>
-     *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
-     *                 <sequence>
-     *                   <element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
-     *                   <element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
-     *                 </sequence>
-     *               </restriction>
-     *             </complexContent>
-     *           </complexType>
-     *         </element>
-     *       </sequence>
-     *     </restriction>
-     *   </complexContent>
-     * </complexType>
-     * 
- * - * - */ - @XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "", propOrder = {"entry"}) - public static class SubnetIdMap { - - protected List entry; - - /** - * Gets the value of the entry property. - * - *

- * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you - * make to the returned list will be present inside the JAXB object. This is why there is not a set - * method for the entry property. - * - *

- * For example, to add a new item, do as follows: - * - *

-         * getEntry().add(newItem);
-         * 
- * - * - *

- * Objects of the following type(s) are allowed in the list {@link QueryNetworkNotification.SubnetIdMap.Entry } - * - * - */ - public List getEntry() { - if (entry == null) { - entry = new ArrayList<>(); - } - return this.entry; - } - - - /** - *

- * Java class for anonymous complex type. - * - *

- * The following schema fragment specifies the expected content contained within this class. - * - *

-         * <complexType>
-         *   <complexContent>
-         *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
-         *       <sequence>
-         *         <element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
-         *         <element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
-         *       </sequence>
-         *     </restriction>
-         *   </complexContent>
-         * </complexType>
-         * 
- * - * - */ - @XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "", propOrder = {"key", "value"}) - public static class Entry { - - protected String key; - protected String value; - - /** - * Gets the value of the key property. - * - * @return possible object is {@link String } - * - */ - public String getKey() { - return key; - } - - /** - * Sets the value of the key property. - * - * @param value allowed object is {@link String } - * - */ - public void setKey(String value) { - this.key = value; - } - - /** - * Gets the value of the value property. - * - * @return possible object is {@link String } - * - */ - public String getValue() { - return value; - } - - /** - * Sets the value of the value property. - * - * @param value allowed object is {@link String } - * - */ - public void setValue(String value) { - this.value = value; - } - - } - - } - -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/QueryNetworkNotificationResponse.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/QueryNetworkNotificationResponse.java deleted file mode 100644 index 2e18e05860..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/QueryNetworkNotificationResponse.java +++ /dev/null @@ -1,53 +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.adapters.network.async.client; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlType; - - -/** - *

- * Java class for queryNetworkNotificationResponse complex type. - * - *

- * The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="queryNetworkNotificationResponse">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "queryNetworkNotificationResponse") -public class QueryNetworkNotificationResponse { - - -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/RollbackNetworkNotification.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/RollbackNetworkNotification.java deleted file mode 100644 index 7b5d0f0f2a..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/RollbackNetworkNotification.java +++ /dev/null @@ -1,139 +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.adapters.network.async.client; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

- * Java class for rollbackNetworkNotification complex type. - * - *

- * The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="rollbackNetworkNotification">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="completed" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
- *         <element name="exception" type="{http://org.onap.so/networkNotify}msoExceptionCategory" minOccurs="0"/>
- *         <element name="errorMessage" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "rollbackNetworkNotification", propOrder = {"messageId", "completed", "exception", "errorMessage"}) -public class RollbackNetworkNotification { - - @XmlElement(required = true) - protected String messageId; - protected boolean completed; - protected MsoExceptionCategory exception; - protected String errorMessage; - - /** - * Gets the value of the messageId property. - * - * @return possible object is {@link String } - * - */ - public String getMessageId() { - return messageId; - } - - /** - * Sets the value of the messageId property. - * - * @param value allowed object is {@link String } - * - */ - public void setMessageId(String value) { - this.messageId = value; - } - - /** - * Gets the value of the completed property. - * - */ - public boolean isCompleted() { - return completed; - } - - /** - * Sets the value of the completed property. - * - */ - public void setCompleted(boolean value) { - this.completed = value; - } - - /** - * Gets the value of the exception property. - * - * @return possible object is {@link MsoExceptionCategory } - * - */ - public MsoExceptionCategory getException() { - return exception; - } - - /** - * Sets the value of the exception property. - * - * @param value allowed object is {@link MsoExceptionCategory } - * - */ - public void setException(MsoExceptionCategory value) { - this.exception = value; - } - - /** - * Gets the value of the errorMessage property. - * - * @return possible object is {@link String } - * - */ - public String getErrorMessage() { - return errorMessage; - } - - /** - * Sets the value of the errorMessage property. - * - * @param value allowed object is {@link String } - * - */ - public void setErrorMessage(String value) { - this.errorMessage = value; - } - -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/RollbackNetworkNotificationResponse.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/RollbackNetworkNotificationResponse.java deleted file mode 100644 index 7ddc8d75de..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/RollbackNetworkNotificationResponse.java +++ /dev/null @@ -1,53 +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.adapters.network.async.client; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlType; - - -/** - *

- * Java class for rollbackNetworkNotificationResponse complex type. - * - *

- * The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="rollbackNetworkNotificationResponse">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "rollbackNetworkNotificationResponse") -public class RollbackNetworkNotificationResponse { - - -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/UpdateNetworkNotification.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/UpdateNetworkNotification.java deleted file mode 100644 index 1a464d3250..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/UpdateNetworkNotification.java +++ /dev/null @@ -1,350 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (C) 2018 IBM. - * ================================================================================ - * 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.adapters.network.async.client; - -import java.util.ArrayList; -import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

- * Java class for updateNetworkNotification complex type. - * - *

- * The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="updateNetworkNotification">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="completed" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
- *         <element name="exception" type="{http://org.onap.so/networkNotify}msoExceptionCategory" minOccurs="0"/>
- *         <element name="errorMessage" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="subnetIdMap" minOccurs="0">
- *           <complexType>
- *             <complexContent>
- *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *                 <sequence>
- *                   <element name="entry" maxOccurs="unbounded" minOccurs="0">
- *                     <complexType>
- *                       <complexContent>
- *                         <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *                           <sequence>
- *                             <element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *                             <element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *                           </sequence>
- *                         </restriction>
- *                       </complexContent>
- *                     </complexType>
- *                   </element>
- *                 </sequence>
- *               </restriction>
- *             </complexContent>
- *           </complexType>
- *         </element>
- *         <element name="rollback" type="{http://org.onap.so/networkNotify}networkRollback" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "updateNetworkNotification", - propOrder = {"messageId", "completed", "exception", "errorMessage", "subnetIdMap", "rollback"}) -public class UpdateNetworkNotification { - - @XmlElement(required = true) - protected String messageId; - protected boolean completed; - protected MsoExceptionCategory exception; - protected String errorMessage; - protected UpdateNetworkNotification.SubnetIdMap subnetIdMap; - protected NetworkRollback rollback; - - /** - * Gets the value of the messageId property. - * - * @return possible object is {@link String } - * - */ - public String getMessageId() { - return messageId; - } - - /** - * Sets the value of the messageId property. - * - * @param value allowed object is {@link String } - * - */ - public void setMessageId(String value) { - this.messageId = value; - } - - /** - * Gets the value of the completed property. - * - */ - public boolean isCompleted() { - return completed; - } - - /** - * Sets the value of the completed property. - * - */ - public void setCompleted(boolean value) { - this.completed = value; - } - - /** - * Gets the value of the exception property. - * - * @return possible object is {@link MsoExceptionCategory } - * - */ - public MsoExceptionCategory getException() { - return exception; - } - - /** - * Sets the value of the exception property. - * - * @param value allowed object is {@link MsoExceptionCategory } - * - */ - public void setException(MsoExceptionCategory value) { - this.exception = value; - } - - /** - * Gets the value of the errorMessage property. - * - * @return possible object is {@link String } - * - */ - public String getErrorMessage() { - return errorMessage; - } - - /** - * Sets the value of the errorMessage property. - * - * @param value allowed object is {@link String } - * - */ - public void setErrorMessage(String value) { - this.errorMessage = value; - } - - /** - * Gets the value of the subnetIdMap property. - * - * @return possible object is {@link UpdateNetworkNotification.SubnetIdMap } - * - */ - public UpdateNetworkNotification.SubnetIdMap getSubnetIdMap() { - return subnetIdMap; - } - - /** - * Sets the value of the subnetIdMap property. - * - * @param value allowed object is {@link UpdateNetworkNotification.SubnetIdMap } - * - */ - public void setSubnetIdMap(UpdateNetworkNotification.SubnetIdMap value) { - this.subnetIdMap = value; - } - - /** - * Gets the value of the rollback property. - * - * @return possible object is {@link NetworkRollback } - * - */ - public NetworkRollback getRollback() { - return rollback; - } - - /** - * Sets the value of the rollback property. - * - * @param value allowed object is {@link NetworkRollback } - * - */ - public void setRollback(NetworkRollback value) { - this.rollback = value; - } - - - /** - *

- * Java class for anonymous complex type. - * - *

- * The following schema fragment specifies the expected content contained within this class. - * - *

-     * <complexType>
-     *   <complexContent>
-     *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
-     *       <sequence>
-     *         <element name="entry" maxOccurs="unbounded" minOccurs="0">
-     *           <complexType>
-     *             <complexContent>
-     *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
-     *                 <sequence>
-     *                   <element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
-     *                   <element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
-     *                 </sequence>
-     *               </restriction>
-     *             </complexContent>
-     *           </complexType>
-     *         </element>
-     *       </sequence>
-     *     </restriction>
-     *   </complexContent>
-     * </complexType>
-     * 
- * - * - */ - @XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "", propOrder = {"entry"}) - public static class SubnetIdMap { - - protected List entry; - - /** - * Gets the value of the entry property. - * - *

- * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you - * make to the returned list will be present inside the JAXB object. This is why there is not a set - * method for the entry property. - * - *

- * For example, to add a new item, do as follows: - * - *

-         * getEntry().add(newItem);
-         * 
- * - * - *

- * Objects of the following type(s) are allowed in the list {@link UpdateNetworkNotification.SubnetIdMap.Entry } - * - * - */ - public List getEntry() { - if (entry == null) { - entry = new ArrayList<>(); - } - return this.entry; - } - - - /** - *

- * Java class for anonymous complex type. - * - *

- * The following schema fragment specifies the expected content contained within this class. - * - *

-         * <complexType>
-         *   <complexContent>
-         *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
-         *       <sequence>
-         *         <element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
-         *         <element name="value" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
-         *       </sequence>
-         *     </restriction>
-         *   </complexContent>
-         * </complexType>
-         * 
- * - * - */ - @XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "", propOrder = {"key", "value"}) - public static class Entry { - - protected String key; - protected String value; - - /** - * Gets the value of the key property. - * - * @return possible object is {@link String } - * - */ - public String getKey() { - return key; - } - - /** - * Sets the value of the key property. - * - * @param value allowed object is {@link String } - * - */ - public void setKey(String value) { - this.key = value; - } - - /** - * Gets the value of the value property. - * - * @return possible object is {@link String } - * - */ - public String getValue() { - return value; - } - - /** - * Sets the value of the value property. - * - * @param value allowed object is {@link String } - * - */ - public void setValue(String value) { - this.value = value; - } - - } - - } - -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/UpdateNetworkNotificationResponse.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/UpdateNetworkNotificationResponse.java deleted file mode 100644 index 0ffcb5e9e6..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/UpdateNetworkNotificationResponse.java +++ /dev/null @@ -1,53 +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.adapters.network.async.client; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlType; - - -/** - *

- * Java class for updateNetworkNotificationResponse complex type. - * - *

- * The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="updateNetworkNotificationResponse">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "updateNetworkNotificationResponse") -public class UpdateNetworkNotificationResponse { - - -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/package-info.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/package-info.java deleted file mode 100644 index fdd8711170..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/package-info.java +++ /dev/null @@ -1,21 +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========================================================= - */ -@javax.xml.bind.annotation.XmlSchema(namespace = "http://org.onap.so/networkNotify") -package org.onap.so.adapters.network.async.client; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/CXFConfiguration.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/CXFConfiguration.java index 8f815f1827..a7bca73fdd 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/CXFConfiguration.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/CXFConfiguration.java @@ -33,9 +33,7 @@ import org.apache.cxf.jaxrs.swagger.Swagger2Feature; import org.apache.cxf.jaxws.EndpointImpl; import org.apache.cxf.transport.servlet.CXFServlet; import org.onap.so.adapters.cloudregion.CloudRegionRestV1; -import org.onap.so.adapters.network.MsoNetworkAdapterAsyncImpl; import org.onap.so.adapters.network.MsoNetworkAdapterImpl; -import org.onap.so.adapters.network.NetworkAdapterRest; import org.onap.so.adapters.tenant.MsoTenantAdapterImpl; import org.onap.so.adapters.tenant.TenantAdapterRest; import org.onap.so.adapters.vnf.MsoVnfAdapterAsyncImpl; @@ -54,15 +52,11 @@ import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; @Configuration public class CXFConfiguration { - @Autowired - private NetworkAdapterRest networkAdapterRest; @Autowired private TenantAdapterRest tenantAdapterRest; @Autowired private MsoNetworkAdapterImpl networkAdapterImpl; @Autowired - private MsoNetworkAdapterAsyncImpl networkAdapterAsyncImpl; - @Autowired private MsoTenantAdapterImpl tenantAdapterImpl; @Autowired private MsoVnfAdapterImpl vnfAdapterImpl; @@ -104,17 +98,6 @@ public class CXFConfiguration { return endpoint; } - @Bean - public Endpoint networkAdapterAsyncEndpoint() { - EndpointImpl endpoint = new EndpointImpl(springBus(), networkAdapterAsyncImpl); - endpoint.publish("/NetworkAdapterAsync"); - endpoint.setWsdlLocation("NetworkAdapterAsync.wsdl"); - endpoint.getInInterceptors().add(new SOAPLoggingInInterceptor()); - endpoint.getOutInterceptors().add(new SOAPLoggingOutInterceptor()); - endpoint.getOutFaultInterceptors().add(new SOAPLoggingOutInterceptor()); - return endpoint; - } - /* * tenant adapter endpoint */ @@ -159,7 +142,7 @@ public class CXFConfiguration { public Server rsServer() { JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean(); endpoint.setBus(springBus()); - endpoint.setServiceBeans(Arrays.asList(networkAdapterRest, tenantAdapterRest)); + endpoint.setServiceBeans(Arrays.asList(tenantAdapterRest)); endpoint.setAddress("/rest"); endpoint.setFeatures(Arrays.asList(createSwaggerFeature(), new LoggingFeature())); endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(jettisonStyleObjectMapper.getMapper()), diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/PollService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/PollService.java index 6e181c4696..9ff50e8644 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/PollService.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/PollService.java @@ -33,10 +33,13 @@ import javax.xml.parsers.DocumentBuilderFactory; import org.apache.commons.lang3.mutable.MutableBoolean; import org.camunda.bpm.client.task.ExternalTask; import org.camunda.bpm.client.task.ExternalTaskService; +import org.onap.so.adapters.nwrest.CreateNetworkRequest; import org.onap.so.adapters.vnfrest.CreateVfModuleRequest; import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest; import org.onap.so.adapters.vnfrest.DeleteVfModuleRequest; import org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest; +import org.onap.so.adapters.nwrest.DeleteNetworkRequest; +import org.onap.so.adapters.nwrest.UpdateNetworkRequest; import org.onap.so.logging.tasks.AuditMDCSetup; import org.onap.so.openstack.exceptions.MsoException; import org.onap.so.openstack.utils.MsoHeatUtils; @@ -70,7 +73,7 @@ public class PollService extends ExternalTaskUtils { MutableBoolean success = new MutableBoolean(); String errorMessage = null; try { - String xmlRequest = externalTask.getVariable("vnfAdapterTaskRequest"); + String xmlRequest = externalTask.getVariable("openstackAdapterTaskRequest"); if (xmlRequest != null) { Optional requestType = findRequestType(xmlRequest); if ("createVolumeGroupRequest".equals(requestType.get())) { @@ -87,6 +90,15 @@ public class PollService extends ExternalTaskUtils { DeleteVolumeGroupRequest req = JAXB.unmarshal(new StringReader(xmlRequest), DeleteVolumeGroupRequest.class); pollDeleteResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success); + } else if ("createNetworkRequest".equals(requestType.get())) { + determineCreateNetworkStatus(xmlRequest, externalTask, success); + } else if ("deleteNetworkRequest".equals(requestType.get())) { + logger.debug("Executing External Task Poll Service for Delete Network"); + DeleteNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), DeleteNetworkRequest.class); + pollDeleteResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success); + } else if ("updateNetworkRequest".equals(requestType.get())) { + UpdateNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), UpdateNetworkRequest.class); + pollUpdateResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success); } } } catch (Exception e) { @@ -143,6 +155,19 @@ public class PollService extends ExternalTaskUtils { } } + private void determineCreateNetworkStatus(String xmlRequest, ExternalTask externalTask, MutableBoolean success) + throws MsoException { + CreateNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), CreateNetworkRequest.class); + boolean pollRollbackStatus = externalTask.getVariable("PollRollbackStatus"); + if (pollRollbackStatus) { + logger.debug("Executing External Task Poll Service for Rollback Create Network"); + pollDeleteResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success); + } else { + logger.debug("Executing External Task Poll Service for Create Network"); + pollCreateResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success); + } + } + private void pollCreateResource(String cloudSiteId, String tenantId, ExternalTask externalTask, MutableBoolean success) throws MsoException { Stack currentStack = createCurrentStack(externalTask.getVariable("stackId")); @@ -163,6 +188,15 @@ public class PollService extends ExternalTaskUtils { success.setTrue(); } + private void pollUpdateResource(String cloudSiteId, String tenantId, ExternalTask externalTask, + MutableBoolean success) throws MsoException { + Stack currentStack = createCurrentStack(externalTask.getVariable("stackId")); + Stack stack = + msoHeatUtils.pollStackForStatus(1, currentStack, "UPDATE_IN_PROGRESS", cloudSiteId, tenantId, false); + msoHeatUtils.postProcessStackUpdate(stack); + success.setTrue(); + } + protected Optional findRequestType(String xmlString) { try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/RollbackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/RollbackService.java index c302293169..15e6ff581d 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/RollbackService.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/RollbackService.java @@ -11,6 +11,8 @@ import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.ws.Holder; import org.camunda.bpm.client.task.ExternalTask; import org.camunda.bpm.client.task.ExternalTaskService; +import org.onap.so.adapters.network.MsoNetworkAdapterImpl; +import org.onap.so.adapters.nwrest.CreateNetworkRequest; import org.onap.so.adapters.vnf.MsoVnfAdapterImpl; import org.onap.so.adapters.vnfrest.CreateVfModuleRequest; import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest; @@ -29,6 +31,9 @@ public class RollbackService extends ExternalTaskUtils { @Autowired private MsoVnfAdapterImpl vnfAdapterImpl; + @Autowired + private MsoNetworkAdapterImpl networkAdapterImpl; + @Autowired private AuditMDCSetup mdcSetup; @@ -39,7 +44,7 @@ public class RollbackService extends ExternalTaskUtils { boolean success = false; boolean pollRollbackStatus = false; try { - String xmlRequest = externalTask.getVariable("vnfAdapterTaskRequest"); + String xmlRequest = externalTask.getVariable("openstackAdapterTaskRequest"); if (xmlRequest != null) { Optional requestType = findRequestType(xmlRequest); if ("createVolumeGroupRequest".equals(requestType.get())) { @@ -59,6 +64,15 @@ public class RollbackService extends ExternalTaskUtils { req.getMsoRequest(), new Holder<>()); pollRollbackStatus = true; success = true; + } else if ("createNetworkRequest".equals(requestType.get())) { + logger.debug("Executing External Task Rollback Service for Create Network"); + Holder networkDeleted = new Holder<>(); + CreateNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), CreateNetworkRequest.class); + networkAdapterImpl.deleteNetwork(req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(), + req.getModelCustomizationUuid(), req.getNetworkName(), req.getMsoRequest(), networkDeleted, + false); + pollRollbackStatus = true; + success = true; } } } catch (Exception e) { diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/StackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/StackService.java index 34952a056b..6b7ceedbb8 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/StackService.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/StackService.java @@ -25,6 +25,7 @@ package org.onap.so.adapters.tasks.orchestration; import java.io.ByteArrayInputStream; import java.io.StringReader; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Optional; import javax.xml.bind.JAXB; @@ -34,6 +35,18 @@ import javax.xml.ws.Holder; import org.apache.commons.lang3.mutable.MutableBoolean; import org.camunda.bpm.client.task.ExternalTask; import org.camunda.bpm.client.task.ExternalTaskService; +import org.onap.so.adapters.network.MsoNetworkAdapterImpl; +import org.onap.so.adapters.network.exceptions.NetworkException; +import org.onap.so.adapters.nwrest.ContrailNetwork; +import org.onap.so.adapters.nwrest.CreateNetworkRequest; +import org.onap.so.adapters.nwrest.CreateNetworkResponse; +import org.onap.so.adapters.nwrest.DeleteNetworkRequest; +import org.onap.so.adapters.nwrest.DeleteNetworkResponse; +import org.onap.so.adapters.nwrest.ProviderVlanNetwork; +import org.onap.so.adapters.nwrest.RollbackNetworkRequest; +import org.onap.so.adapters.nwrest.RollbackNetworkResponse; +import org.onap.so.adapters.nwrest.UpdateNetworkRequest; +import org.onap.so.adapters.nwrest.UpdateNetworkResponse; import org.onap.so.adapters.vnf.MsoVnfAdapterImpl; import org.onap.so.adapters.vnf.exceptions.VnfException; import org.onap.so.adapters.vnfrest.CreateVfModuleRequest; @@ -47,6 +60,8 @@ import org.onap.so.adapters.vnfrest.DeleteVolumeGroupResponse; import org.onap.so.adapters.vnfrest.VfModuleRollback; import org.onap.so.adapters.vnfrest.VolumeGroupRollback; import org.onap.so.logging.tasks.AuditMDCSetup; +import org.onap.so.openstack.beans.NetworkRollback; +import org.onap.so.openstack.beans.RouteTarget; import org.onap.so.openstack.beans.VnfRollback; import org.onap.so.utils.ExternalTaskUtils; import org.slf4j.Logger; @@ -62,13 +77,20 @@ public class StackService extends ExternalTaskUtils { @Autowired private MsoVnfAdapterImpl vnfAdapterImpl; + @Autowired + private MsoNetworkAdapterImpl networkAdapterImpl; + @Autowired private AuditMDCSetup mdcSetup; + private static final String SHARED = "shared"; + private static final String EXTERNAL = "external"; + + // TODO set backout earlier in case of exception?? public void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) { Map variables = new HashMap<>(); mdcSetup.setupMDC(externalTask); - String xmlRequest = externalTask.getVariable("vnfAdapterTaskRequest"); + String xmlRequest = externalTask.getVariable("openstackAdapterTaskRequest"); logger.debug("Executing External Task Stack Service. {}", xmlRequest); MutableBoolean success = new MutableBoolean(); MutableBoolean backout = new MutableBoolean(); @@ -80,6 +102,11 @@ public class StackService extends ExternalTaskUtils { Holder> outputs = new Holder<>(); Holder vnfRollback = new Holder<>(); Optional requestType = findRequestType(xmlRequest); + Holder networkId = new Holder<>(); + Holder neutronNetworkId = new Holder<>(); + Holder networkFqdn = new Holder<>(); + Holder> subnetIdMap = new Holder<>(); + Holder networkRollback = new Holder<>(); if ("createVolumeGroupRequest".equals(requestType.get())) { logger.debug("Executing External Task Stack Service For Create Volume Group"); response = createVolumeGroup(xmlRequest, outputs, vnfRollback, canonicalStackId, backout, success); @@ -92,6 +119,16 @@ public class StackService extends ExternalTaskUtils { } else if ("deleteVolumeGroupRequest".equals(requestType.get())) { logger.debug("Executing External Task Stack Service For Delete Volume Group"); response = deleteVolumeGroup(xmlRequest, outputs, vnfRollback, canonicalStackId, backout, success); + } else if ("createNetworkRequest".equals(requestType.get())) { + response = createNetwork(xmlRequest, networkId, neutronNetworkId, networkFqdn, subnetIdMap, + networkRollback, canonicalStackId, backout, success); + } else if ("deleteNetworkRequest".equals(requestType.get())) { + response = deleteNetwork(xmlRequest, canonicalStackId, backout, success); + } else if ("updateNetworkRequest".equals(requestType.get())) { + response = + updateNetwork(xmlRequest, subnetIdMap, networkRollback, canonicalStackId, backout, success); + } else if ("rollbackNetworkRequest".equals(requestType.get())) { + response = rollbackNetwork(xmlRequest, canonicalStackId, backout, success); } } } catch (Exception e) { @@ -192,6 +229,156 @@ public class StackService extends ExternalTaskUtils { return deleteResponse.toXmlString(); } + private String createNetwork(String xmlRequest, Holder networkId, Holder neutronNetworkId, + Holder networkFqdn, Holder> subnetIdMap, + Holder networkRollback, Holder canonicalStackId, MutableBoolean backout, + MutableBoolean success) throws NetworkException { + CreateNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), CreateNetworkRequest.class); + HashMap params = (HashMap) req.getNetworkParams(); + if (params == null) { + params = new HashMap<>(); + } + String shared = null; + String external = null; + String physicalNetworkName = null; + List vlans = null; + List routeTargets = null; + List fqdns = null; + List routeTable = null; + if (params.containsKey(SHARED)) + shared = params.get(SHARED); + if (params.containsKey(EXTERNAL)) + external = params.get(EXTERNAL); + if (req.isContrailRequest()) { + ContrailNetwork ctn = req.getContrailNetwork(); + if (ctn == null) { + ctn = new ContrailNetwork(); + req.setContrailNetwork(ctn); + } + if (shared == null && ctn.getShared() != null) { + shared = ctn.getShared(); + } + if (shared == null && ctn.getExternal() != null) { + external = ctn.getExternal(); + } + routeTargets = req.getContrailNetwork().getRouteTargets(); + fqdns = req.getContrailNetwork().getPolicyFqdns(); + routeTable = req.getContrailNetwork().getRouteTableFqdns(); + } else { + ProviderVlanNetwork pvn = req.getProviderVlanNetwork(); + if (pvn == null) { + pvn = new ProviderVlanNetwork(); + req.setProviderVlanNetwork(pvn); + } + physicalNetworkName = req.getProviderVlanNetwork().getPhysicalNetworkName(); + vlans = req.getProviderVlanNetwork().getVlans(); + } + networkAdapterImpl.createNetwork(req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(), + req.getModelCustomizationUuid(), req.getNetworkName(), physicalNetworkName, vlans, routeTargets, shared, + external, req.getFailIfExists(), false, req.getSubnets(), fqdns, routeTable, req.getMsoRequest(), + networkId, neutronNetworkId, networkFqdn, subnetIdMap, networkRollback, false); + success.setTrue(); + backout.setValue(req.getBackout()); + canonicalStackId.value = networkRollback.value.getNetworkStackId(); + + CreateNetworkResponse response = new CreateNetworkResponse(req.getNetworkId(), neutronNetworkId.value, + networkRollback.value.getNetworkStackId(), networkFqdn.value, networkRollback.value.getNetworkCreated(), + subnetIdMap.value, networkRollback.value, req.getMessageId()); + return response.toXmlString(); + } + + private String deleteNetwork(String xmlRequest, Holder canonicalStackId, MutableBoolean backout, + MutableBoolean success) throws NetworkException { + backout.setFalse(); + DeleteNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), DeleteNetworkRequest.class); + Holder networkDeleted = new Holder<>(); + + networkAdapterImpl.deleteNetwork(req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(), + req.getModelCustomizationUuid(), req.getNetworkStackId(), req.getMsoRequest(), networkDeleted, false); + + canonicalStackId.value = req.getNetworkStackId(); + success.setTrue(); + + DeleteNetworkResponse response = + new DeleteNetworkResponse(req.getNetworkId(), networkDeleted.value, req.getMessageId()); + return response.toXmlString(); + } + + private String rollbackNetwork(String xmlRequest, Holder canonicalStackId, MutableBoolean backout, + MutableBoolean success) throws NetworkException { + backout.setFalse(); + RollbackNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), RollbackNetworkRequest.class); + + NetworkRollback rollback = req.getNetworkRollback(); + networkAdapterImpl.rollbackNetwork(rollback, false); + + canonicalStackId.value = rollback.getNetworkStackId(); + success.setTrue(); + + RollbackNetworkResponse response = new RollbackNetworkResponse(true, req.getMessageId()); + return response.toXmlString(); + } + + private String updateNetwork(String xmlRequest, Holder> subnetIdMap, + Holder networkRollback, Holder canonicalStackId, MutableBoolean backout, + MutableBoolean success) throws NetworkException { + backout.setFalse(); + UpdateNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), UpdateNetworkRequest.class); + HashMap params = (HashMap) req.getNetworkParams(); + if (params == null) { + params = new HashMap<>(); + } + String shared = null; + String external = null; + String physicalNetworkName = null; + List vlans = null; + List routeTargets = null; + List fqdns = null; + List routeTable = null; + if (params.containsKey(SHARED)) + shared = params.get(SHARED); + if (params.containsKey(EXTERNAL)) + external = params.get(EXTERNAL); + if (req.isContrailRequest()) { + ContrailNetwork ctn = req.getContrailNetwork(); + if (ctn == null) { + ctn = new ContrailNetwork(); + req.setContrailNetwork(ctn); + } + if (shared == null && ctn.getShared() != null) { + shared = ctn.getShared(); + } + if (shared == null && ctn.getExternal() != null) { + external = ctn.getExternal(); + } + routeTargets = req.getContrailNetwork().getRouteTargets(); + fqdns = req.getContrailNetwork().getPolicyFqdns(); + routeTable = req.getContrailNetwork().getRouteTableFqdns(); + } else { + ProviderVlanNetwork pvn = req.getProviderVlanNetwork(); + if (pvn == null) { + pvn = new ProviderVlanNetwork(); + req.setProviderVlanNetwork(pvn); + } + physicalNetworkName = req.getProviderVlanNetwork().getPhysicalNetworkName(); + vlans = req.getProviderVlanNetwork().getVlans(); + } + + networkAdapterImpl.updateNetwork(req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(), + req.getModelCustomizationUuid(), req.getNetworkStackId(), req.getNetworkName(), physicalNetworkName, + vlans, routeTargets, shared, external, req.getSubnets(), fqdns, routeTable, req.getMsoRequest(), + subnetIdMap, networkRollback); + + success.setTrue(); + canonicalStackId.value = req.getNetworkStackId(); + + UpdateNetworkResponse response = + new UpdateNetworkResponse(req.getNetworkId(), null, subnetIdMap.value, req.getMessageId()); + return response.toXmlString(); + } + + + protected Optional findRequestType(String xmlString) { try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/BeansTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/BeansTest.java index 5bafe2b1d6..d8e1e2a9a9 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/BeansTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/BeansTest.java @@ -49,7 +49,6 @@ public class BeansTest { @Test public void pojoStructure() { - test("org.onap.so.adapters.network.async.client"); test("org.onap.so.adapters.vnf.async.client"); test("org.onap.so.adapters.network"); test("org.onap.so.adapters.vnf"); diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java deleted file mode 100644 index 00961a16b9..0000000000 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java +++ /dev/null @@ -1,269 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.adapters.network; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.containing; -import static com.github.tomakehurst.wiremock.client.WireMock.patch; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static org.onap.so.bpmn.mock.StubOpenStack.getBodyFromFile; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackCreatedVUSP_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackCreated_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackDeleteOrUpdateComplete_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPostStacks_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPutPublicUrlStackByNameAndID_NETWORK2_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccessQueryNetwork; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import org.apache.http.HttpStatus; -import org.junit.Test; -import org.onap.so.adapters.vnf.BaseRestTestUtils; -import org.onap.so.entity.MsoRequest; -import org.onap.so.openstack.beans.NetworkRollback; -import org.onap.so.openstack.beans.Subnet; -import org.springframework.beans.factory.annotation.Autowired; -import com.github.tomakehurst.wiremock.WireMockServer; - -public class MsoNetworkAdapterAsyncImplTest extends BaseRestTestUtils { - @Autowired - MsoNetworkAdapterAsyncImpl impl; - - @Test - public void healthCheckATest() { - MsoNetworkAdapterAsyncImpl mNAAimpl = new MsoNetworkAdapterAsyncImpl(); - mNAAimpl.healthCheckA(); - } - - @Test - public void rollbackNetworkATest() throws IOException { - wireMockServer.stubFor(post(urlPathEqualTo("/v2.0/tokens")).withRequestBody(containing("tenantId")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody(getBodyFromFile("OpenstackResponse_Access.json", wireMockPort, "/mockPublicUrl")) - .withStatus(HttpStatus.SC_OK))); - wireMockServer.stubFor(post(urlPathEqualTo("/notificationUrl")) - .withRequestBody(containing("true")) - .willReturn(aResponse().withBody( - "\n" - + " \n" + " \n" - + " \n" - + " \n" + " \n" - + "") - .withStatus(HttpStatus.SC_OK))); - NetworkRollback nrb = getNetworkRollback("mtn13"); - impl.rollbackNetworkA(nrb, "messageId", "http://localhost:" + wireMockPort + "/notificationUrl"); - } - - @Test - public void rollbackNetworkATest_NotifyException() throws IOException { - wireMockServer.stubFor(post(urlPathEqualTo("/v2.0/tokens")).withRequestBody(containing("tenantId")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody(getBodyFromFile("OpenstackResponse_Access.json", wireMockPort, "/mockPublicUrl")) - .withStatus(HttpStatus.SC_OK))); - wireMockServer.stubFor( - post(urlPathEqualTo("/notificationUrl")).withRequestBody(containing("true")) - .willReturn(aResponse().withStatus(HttpStatus.SC_NOT_FOUND))); - NetworkRollback nrb = getNetworkRollback("mtn13"); - impl.rollbackNetworkA(nrb, "messageId", "http://localhost:" + wireMockPort + "/notificationUrl"); - } - - private NetworkRollback getNetworkRollback(String cloudId) { - NetworkRollback nrb = new NetworkRollback(); - nrb.setCloudId(cloudId); - nrb.setMsoRequest(new MsoRequest()); - nrb.setModelCustomizationUuid("3bdbb104-476c-483e-9f8b-c095b3d3068c"); - nrb.setNetworkCreated(true); - nrb.setNetworkId("networkId"); - nrb.setNetworkName("networkName"); - nrb.setNetworkStackId("networkStackId"); - nrb.setNetworkType("networkType"); - nrb.setNeutronNetworkId("neutronNetworkId"); - nrb.setPhysicalNetwork("physicalNetwork"); - nrb.setTenantId("tenantId"); - nrb.setVlans(new ArrayList<>()); - return nrb; - } - - @Test - public void rollbackNetworkATestNetworkException() { - NetworkRollback nrb = getNetworkRollback("cloudId"); - - impl.rollbackNetworkA(nrb, "messageId", "http://localhost"); - } - - @Test - public void noRollbackNetworkATest() { - impl.rollbackNetworkA(null, "messageId", "http://localhost"); - } - - - @Test - public void deleteNetworkATest() throws IOException { - wireMockServer.stubFor(post(urlPathEqualTo("/v2.0/tokens")).withRequestBody(containing("tenantId")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody(getBodyFromFile("OpenstackResponse_Access.json", wireMockPort, "/mockPublicUrl")) - .withStatus(HttpStatus.SC_OK))); - wireMockServer.stubFor(post(urlPathEqualTo("/notificationUrl")) - .withRequestBody(containing("true")) - .willReturn(aResponse().withBody( - "\n" - + " \n" + " \n" - + " \n" - + " \n" + " \n" - + "") - .withStatus(HttpStatus.SC_OK))); - impl.deleteNetworkA("mtn13", "tenantId", "networkType", "modelCustomizationUuid", "networkId", "messageId", - new MsoRequest(), "http://localhost:" + wireMockPort + "/notificationUrl"); - } - - @Test - public void deleteNetworkATest_NotifyException() throws IOException { - wireMockServer.stubFor(post(urlPathEqualTo("/v2.0/tokens")).withRequestBody(containing("tenantId")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody(getBodyFromFile("OpenstackResponse_Access.json", wireMockPort, "/mockPublicUrl")) - .withStatus(HttpStatus.SC_OK))); - wireMockServer.stubFor( - post(urlPathEqualTo("/notificationUrl")).withRequestBody(containing("true")) - .willReturn(aResponse().withStatus(HttpStatus.SC_NOT_FOUND))); - impl.deleteNetworkA("mtn13", "tenantId", "networkType", "modelCustomizationUuid", "networkId", "messageId", - new MsoRequest(), "http://localhost:" + wireMockPort + "/notificationUrl"); - } - - @Test - public void deleteNetworkATest_NetworkException() { - impl.deleteNetworkA("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkId", - "messageId", new MsoRequest(), "http://localhost:" + wireMockPort + "/notificationUrl"); - } - - @Test - public void updateNetworkATest() throws IOException { - wireMockServer.stubFor(post(urlPathEqualTo("/v2.0/tokens")).withRequestBody(containing("tenantId")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody(getBodyFromFile("OpenstackResponse_Access.json", wireMockPort, "/mockPublicUrl")) - .withStatus(HttpStatus.SC_OK))); - mockOpenStackGetStackCreated_200(wireMockServer, "OpenstackResponse_Stack_Created.json", - "dvspg-VCE_VPE-mtjnj40avbc"); - mockOpenStackGetStackDeleteOrUpdateComplete_200(wireMockServer, "OpenstackResponse_Stack_UpdateComplete.json"); - mockOpenStackPutPublicUrlStackByNameAndID_NETWORK2_200(wireMockServer); - wireMockServer.stubFor(post(urlPathEqualTo("/notificationUrl")) - .withRequestBody(containing("updateNetworkNotification")) - .willReturn(aResponse().withBody( - "\n" - + " \n" + " \n" - + " \n" - + " \n" + " \n" - + "") - .withStatus(HttpStatus.SC_OK))); - HashMap networkParams = new HashMap(); - networkParams.put("shared", "true"); - networkParams.put("external", "false"); - impl.updateNetworkA("mtn13", "tenantId", "networkType", "3bdbb104-476c-483e-9f8b-c095b3d3068c", - "dvspg-VCE_VPE-mtjnj40avbc", "dvspg-VCE_VPE-mtjnj40avbc", "physicalNetworkName", new ArrayList<>(), - new ArrayList(), networkParams, "messageId", new MsoRequest(), - "http://localhost:" + wireMockPort + "/notificationUrl"); - } - - @Test - public void updateNetworkATest_NotifyExcpetion() throws IOException { - wireMockServer.stubFor(post(urlPathEqualTo("/v2.0/tokens")).withRequestBody(containing("tenantId")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody(getBodyFromFile("OpenstackResponse_Access.json", wireMockPort, "/mockPublicUrl")) - .withStatus(HttpStatus.SC_OK))); - mockOpenStackGetStackCreated_200(wireMockServer, "OpenstackResponse_Stack_Created.json", - "dvspg-VCE_VPE-mtjnj40avbc"); - mockOpenStackGetStackDeleteOrUpdateComplete_200(wireMockServer, "OpenstackResponse_Stack_UpdateComplete.json"); - mockOpenStackPutPublicUrlStackByNameAndID_NETWORK2_200(wireMockServer); - HashMap networkParams = new HashMap(); - networkParams.put("shared", "true"); - networkParams.put("external", "false"); - impl.updateNetworkA("mtn13", "tenantId", "networkType", "3bdbb104-476c-483e-9f8b-c095b3d3068c", - "dvspg-VCE_VPE-mtjnj40avbc", "dvspg-VCE_VPE-mtjnj40avbc", "physicalNetworkName", new ArrayList<>(), - new ArrayList<>(), networkParams, "messageId", new MsoRequest(), - "http://localhost:" + wireMockPort + "/notificationUrl"); - } - - @Test - public void updateNetworkATest_NetworkException() { - impl.updateNetworkA("cloudSiteId", "tenantId", "networkType", "3bdbb104-476c-483e-9f8b-c095b3d3068c", - "networkId", "dvspg-VCE_VPE-mtjnj40avbc", "physicalNetworkName", new ArrayList<>(), new ArrayList<>(), - new HashMap(), "messageId", new MsoRequest(), - "http://localhost:" + wireMockPort + "/notificationUrl"); - } - - @Test - public void queryNetworkATest() throws IOException { - mockOpenStackResponseAccessQueryNetwork(wireMockServer, wireMockPort); - impl.queryNetworkA("mtn13", "tenantId", "networkId", "messageId", new MsoRequest(), - "http://localhost:" + wireMockPort + "/notificationUrl"); - } - - @Test - public void createNetworkATest() throws IOException { - wireMockServer.stubFor(post(urlPathEqualTo("/v2.0/tokens")).withRequestBody(containing("tenantId")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody(getBodyFromFile("OpenstackResponse_Access.json", wireMockPort, "/mockPublicUrl")) - .withStatus(HttpStatus.SC_OK))); - wireMockServer.stubFor(post(urlPathEqualTo("/notificationUrl")) - .withRequestBody(containing("createNetworkNotification")) - .willReturn(aResponse().withBody( - "\n" - + " \n" + " \n" - + " \n" - + " \n" + " \n" - + "") - .withStatus(HttpStatus.SC_OK))); - mockOpenStackGetStackCreatedVUSP_200(wireMockServer); - mockOpenStackPostStacks_200(wireMockServer); - mockOpenStackPostStacks_200(wireMockServer); - HashMap networkParams = new HashMap(); - impl.createNetworkA("mtn13", "tenantId", "networkType", "3bdbb104-476c-483e-9f8b-c095b3d3068c", - "vUSP-23804-T-01-dpa2b_EVUSP-CORE-VIF-TSIG0_net_0", "physicalNetworkName", new ArrayList<>(), false, - false, new ArrayList<>(), networkParams, "messageId", new MsoRequest(), - "http://localhost:" + wireMockPort + "/notificationUrl"); - } - - @Test - public void createNetworkATest_NotifyException() throws IOException { - wireMockServer.stubFor(post(urlPathEqualTo("/v2.0/tokens")).withRequestBody(containing("tenantId")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody(getBodyFromFile("OpenstackResponse_Access.json", wireMockPort, "/mockPublicUrl")) - .withStatus(HttpStatus.SC_OK))); - mockOpenStackGetStackCreatedVUSP_200(wireMockServer); - mockOpenStackPostStacks_200(wireMockServer); - HashMap networkParams = new HashMap(); - networkParams.put("shared", "true"); - networkParams.put("external", "false"); - impl.createNetworkA("mtn13", "tenantId", "networkType", "3bdbb104-476c-483e-9f8b-c095b3d3068c", - "vUSP-23804-T-01-dpa2b_EVUSP-CORE-VIF-TSIG0_net_0", "physicalNetworkName", new ArrayList<>(), false, - false, new ArrayList<>(), networkParams, "messageId", new MsoRequest(), - "http://localhost:" + wireMockPort + "/notificationUrl"); - } - - @Test - public void createNetworkATest_NetworkException() { - impl.createNetworkA("mtn13", "tenantId", "networkType", "3bdbb104-476c-483e-9f8b-c095b3d3068c", - "vUSP-23804-T-01-dpa2b_EVUSP-CORE-VIF-TSIG0_net_0", "physicalNetworkName", new ArrayList<>(), false, - false, new ArrayList<>(), new HashMap(), "messageId", new MsoRequest(), - "http://localhost:" + wireMockPort + "/notificationUrl"); - } - -} diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java deleted file mode 100644 index 412abeab3b..0000000000 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java +++ /dev/null @@ -1,364 +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.adapters.network; - -import static com.shazam.shazamcrest.MatcherAssert.assertThat; -import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; -import static org.junit.Assert.assertEquals; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackDeletePublicUrlStackByNameAndID_204; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetPublicUrlStackByNameAndID_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetPublicUrlStackByNameAndID_204; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackAppC_404; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackCreatedAppC_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackCreatedVUSP_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVUSP_404; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPostPublicUrlWithBodyFile_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPublicUrlStackByID_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPublicUrlStackByName_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPutPublicUrlStackByNameAndID_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccess; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import org.json.JSONException; -import org.junit.Test; -import org.onap.so.adapters.nwrest.CreateNetworkRequest; -import org.onap.so.adapters.nwrest.CreateNetworkResponse; -import org.onap.so.adapters.nwrest.DeleteNetworkRequest; -import org.onap.so.adapters.nwrest.DeleteNetworkResponse; -import org.onap.so.adapters.nwrest.QueryNetworkError; -import org.onap.so.adapters.nwrest.QueryNetworkResponse; -import org.onap.so.adapters.nwrest.RollbackNetworkRequest; -import org.onap.so.adapters.nwrest.RollbackNetworkResponse; -import org.onap.so.adapters.nwrest.UpdateNetworkRequest; -import org.onap.so.adapters.nwrest.UpdateNetworkResponse; -import org.onap.so.adapters.vnf.BaseRestTestUtils; -import org.onap.so.client.policy.JettisonStyleMapperProvider; -import org.onap.so.entity.MsoRequest; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; - -public class NetworkAdapterRestTest extends BaseRestTestUtils { - - @Autowired - private JettisonStyleMapperProvider jettisonTypeObjectMapper; - private static final String CLOUDSITE_ID = "mtn13"; - private static final String TENANT_ID = "ba38bc24a2ef4fb2ad2810c894f1938f"; - private static final String NETWORK_ID = "da886914-efb2-4917-b335-c8381528d90b"; - private static final String NETWORK_TYPE = "CONTRAIL30_BASIC"; - private static final String MODEL_CUSTOMIZATION_UUID = "3bdbb104-476c-483e-9f8b-c095b3d308ac"; - private static final String MSO_SERVICE_INSTANCE_ID = "05869d5f-47df-4b45-bbfc-4f03ce0a50bf"; - private static final String MSO_REQUEST_ID = "requestId"; - private static final String NETWORK_NAME = "vUSP-23804-T-01-dpa2b_EVUSP-CORE-VIF-TSIG0_net_0"; - - @Test - public void testCreateNetwork() throws JSONException, JsonParseException, JsonMappingException, IOException { - - CreateNetworkRequest request = new CreateNetworkRequest(); - request.setBackout(true); - request.setSkipAAI(true); - request.setFailIfExists(false); - MsoRequest msoReq = new MsoRequest(); - String networkTechnology = "CONTRAIL"; - - msoReq.setRequestId(MSO_REQUEST_ID); - msoReq.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID); - request.setMsoRequest(msoReq); - request.setCloudSiteId(CLOUDSITE_ID); - request.setTenantId(TENANT_ID); - request.setNetworkId(NETWORK_ID); - request.setNetworkName(NETWORK_NAME); - request.setNetworkType(NETWORK_TYPE); - request.setModelCustomizationUuid(MODEL_CUSTOMIZATION_UUID); - request.setNetworkTechnology(networkTechnology); - - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - - mockOpenStackPostPublicUrlWithBodyFile_200(wireMockServer); - - mockOpenStackGetStackCreatedVUSP_200(wireMockServer); - - mockOpenStackGetStackVUSP_404(wireMockServer); - - headers.add("Accept", MediaType.APPLICATION_JSON); - HttpEntity entity = new HttpEntity(request, headers); - ResponseEntity response = restTemplate.exchange( - createURLWithPort("/services/rest/v1/networks"), HttpMethod.POST, entity, CreateNetworkResponse.class); - - CreateNetworkResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue( - new File("src/test/resources/__files/CreateNetworkResponse.json"), CreateNetworkResponse.class); - - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - assertThat(response.getBody(), sameBeanAs(expectedResponse)); - } - - @Test - public void testCreateNetwork_JSON() throws JSONException, JsonParseException, JsonMappingException, IOException { - - - - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - - mockOpenStackPostPublicUrlWithBodyFile_200(wireMockServer); - - mockOpenStackGetStackCreatedAppC_200(wireMockServer); - - mockOpenStackGetStackAppC_404(wireMockServer); - - headers.add("Content-Type", MediaType.APPLICATION_JSON); - headers.add("Accept", MediaType.APPLICATION_JSON); - - String request = readJsonFileAsString("src/test/resources/CreateNetwork.json"); - HttpEntity entity = new HttpEntity(request, headers); - - ResponseEntity response = restTemplate.exchange( - createURLWithPort("/services/rest/v1/networks"), HttpMethod.POST, entity, CreateNetworkResponse.class); - - CreateNetworkResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue( - new File("src/test/resources/__files/CreateNetworkResponse2.json"), CreateNetworkResponse.class); - - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - assertThat(response.getBody(), sameBeanAs(expectedResponse)); - } - - - - @Test - public void testDeleteNetwork() throws IOException { - - DeleteNetworkRequest request = new DeleteNetworkRequest(); - - MsoRequest msoReq = new MsoRequest(); - - msoReq.setRequestId(MSO_REQUEST_ID); - msoReq.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID); - request.setMsoRequest(msoReq); - request.setCloudSiteId(CLOUDSITE_ID); - request.setTenantId(TENANT_ID); - request.setNetworkId(NETWORK_ID); - request.setNetworkType(NETWORK_TYPE); - request.setModelCustomizationUuid(MODEL_CUSTOMIZATION_UUID); - request.setNetworkStackId(NETWORK_ID); - - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - - mockOpenStackPublicUrlStackByID_200(wireMockServer, wireMockPort); - - mockOpenStackGetPublicUrlStackByNameAndID_204(wireMockServer, wireMockPort); - - mockOpenStackDeletePublicUrlStackByNameAndID_204(wireMockServer); - - headers.add("Accept", MediaType.APPLICATION_JSON); - - HttpEntity entity = new HttpEntity(request, headers); - - ResponseEntity response = restTemplate.exchange( - createURLWithPort("/services/rest/v1/networks/da886914-efb2-4917-b335-c8381528d90b"), HttpMethod.DELETE, - entity, DeleteNetworkResponse.class); - - DeleteNetworkResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue( - new File("src/test/resources/__files/DeleteNetworkResponse.json"), DeleteNetworkResponse.class); - - assertThat(response.getBody(), sameBeanAs(expectedResponse)); - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - - } - - @Test - public void testRollbackNetwork() throws IOException { - - RollbackNetworkRequest request = new RollbackNetworkRequest(); - MsoRequest msoReq = new MsoRequest(); - msoReq.setRequestId(MSO_REQUEST_ID); - msoReq.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID); - - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - - mockOpenStackPublicUrlStackByID_200(wireMockServer, wireMockPort); - - mockOpenStackGetPublicUrlStackByNameAndID_204(wireMockServer, wireMockPort); - - mockOpenStackDeletePublicUrlStackByNameAndID_204(wireMockServer); - - headers.add("Accept", MediaType.APPLICATION_JSON); - - HttpEntity entity = new HttpEntity<>(request, headers); - - ResponseEntity response = restTemplate.exchange( - createURLWithPort("/services/rest/v1/networks/da886914-efb2-4917-b335-c8381528d90b/rollback"), - HttpMethod.DELETE, entity, RollbackNetworkResponse.class); - - RollbackNetworkResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue( - new File("src/test/resources/__files/RollbackNetworkResponse.json"), RollbackNetworkResponse.class); - - assertThat(response.getBody(), sameBeanAs(expectedResponse)); - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - - } - - @Test - public void testQueryNetwork_Exception() throws IOException { - MsoRequest msoReq = new MsoRequest(); - msoReq.setRequestId(MSO_REQUEST_ID); - msoReq.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID); - headers.add("Accept", MediaType.APPLICATION_JSON); - - HttpEntity entity = new HttpEntity(headers); - - ResponseEntity response = restTemplate.exchange( - createURLWithPort("/services/rest/v1/networks/da886914-efb2-4917-b335-c8381528d90b"), HttpMethod.GET, - entity, QueryNetworkError.class); - - assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); - - } - - @Test - public void testQueryNetwork() throws IOException { - - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - mockOpenStackGetStackVfModule_200(wireMockServer); - - headers.add("Accept", MediaType.APPLICATION_JSON); - HttpEntity entity = new HttpEntity(headers); - - ResponseEntity response = restTemplate.exchange( - createURLWithPort("/services/rest/v1/networks/da886914-efb2-4917-b335-c8381528d90b" + "?cloudSiteId=" - + CLOUDSITE_ID + "&tenantId=" + TENANT_ID + "&aaiNetworkId=aaiNetworkId"), - HttpMethod.GET, entity, QueryNetworkResponse.class); - - assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value()); - - } - - @Test - public void testUpdateNetwork() throws IOException { - - UpdateNetworkRequest request = new UpdateNetworkRequest(); - - MsoRequest msoReq = new MsoRequest(); - - msoReq.setRequestId(MSO_REQUEST_ID); - msoReq.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID); - request.setMsoRequest(msoReq); - request.setCloudSiteId(CLOUDSITE_ID); - request.setTenantId(TENANT_ID); - request.setNetworkId(NETWORK_ID); - request.setNetworkName(NETWORK_NAME); - request.setNetworkType(NETWORK_TYPE); - request.setModelCustomizationUuid(MODEL_CUSTOMIZATION_UUID); - request.setNetworkStackId(NETWORK_ID); - - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - - mockOpenStackPublicUrlStackByName_200(wireMockServer, wireMockPort); - - mockOpenStackPublicUrlStackByID_200(wireMockServer, wireMockPort); - - mockOpenStackGetPublicUrlStackByNameAndID_200(wireMockServer, wireMockPort); - - mockOpenStackPutPublicUrlStackByNameAndID_200(wireMockServer); - - headers.add("Accept", MediaType.APPLICATION_JSON); - - HttpEntity entity = new HttpEntity(request, headers); - - ResponseEntity response = restTemplate.exchange( - createURLWithPort("/services/rest/v1/networks/da886914-efb2-4917-b335-c8381528d90b"), HttpMethod.PUT, - entity, UpdateNetworkResponse.class); - - UpdateNetworkResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue( - new File("src/test/resources/__files/UpdateNetworkResponse.json"), UpdateNetworkResponse.class); - - assertThat(response.getBody(), sameBeanAs(expectedResponse)); - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - } - - @Test - public void testCreateNetworkCNRC_JSON() - throws JSONException, JsonParseException, JsonMappingException, IOException { - - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - - mockOpenStackPostPublicUrlWithBodyFile_200(wireMockServer); - - mockOpenStackGetStackCreatedAppC_200(wireMockServer); - - mockOpenStackGetStackAppC_404(wireMockServer); - - headers.add("Content-Type", MediaType.APPLICATION_JSON); - headers.add("Accept", MediaType.APPLICATION_JSON); - - String request = readJsonFileAsString("src/test/resources/CreateNetwork3.json"); - HttpEntity entity = new HttpEntity(request, headers); - - ResponseEntity response = restTemplate.exchange( - createURLWithPort("/services/rest/v1/networks"), HttpMethod.POST, entity, CreateNetworkResponse.class); - - CreateNetworkResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue( - new File("src/test/resources/__files/CreateNetworkResponse3.json"), CreateNetworkResponse.class); - - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - assertThat(response.getBody(), sameBeanAs(expectedResponse)); - } - - @Test - public void testCreateNetworkNC_Shared_JSON() - throws JSONException, JsonParseException, JsonMappingException, IOException { - - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - - mockOpenStackPostPublicUrlWithBodyFile_200(wireMockServer); - - mockOpenStackGetStackCreatedAppC_200(wireMockServer); - - mockOpenStackGetStackAppC_404(wireMockServer); - - headers.add("Content-Type", MediaType.APPLICATION_JSON); - headers.add("Accept", MediaType.APPLICATION_JSON); - - String request = readJsonFileAsString("src/test/resources/CreateNetwork4.json"); - HttpEntity entity = new HttpEntity(request, headers); - - ResponseEntity response = restTemplate.exchange( - createURLWithPort("/services/rest/v1/networks"), HttpMethod.POST, entity, CreateNetworkResponse.class); - - CreateNetworkResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue( - new File("src/test/resources/__files/CreateNetworkResponse4.json"), CreateNetworkResponse.class); - - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - assertThat(response.getBody(), sameBeanAs(expectedResponse)); - } - - @Override - protected String readJsonFileAsString(String fileLocation) - throws JsonParseException, JsonMappingException, IOException { - return new String(Files.readAllBytes(Paths.get(fileLocation))); - } -} diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/PollServiceTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/PollServiceTest.java index b5b0f5a8ef..8d5ab8234e 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/PollServiceTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/PollServiceTest.java @@ -44,7 +44,7 @@ public class PollServiceTest { String xmlString = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "/vnfAdapterTaskRequestCreate.xml"))); - Mockito.when(mockExternalTask.getVariable("vnfAdapterTaskRequest")).thenReturn(xmlString); + Mockito.when(mockExternalTask.getVariable("openstackAdapterTaskRequest")).thenReturn(xmlString); Mockito.when(mockExternalTask.getVariable("PollRollbackStatus")).thenReturn(false); Mockito.when(mockExternalTask.getVariable("stackId")).thenReturn("stackId/stack123"); Mockito.when(msoHeatUtils.pollStackForStatus(eq(1), any(Stack.class), eq("CREATE_IN_PROGRESS"), eq("regionOne"), @@ -64,7 +64,7 @@ public class PollServiceTest { String xmlString = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "/vnfAdapterTaskRequestCreate.xml"))); - Mockito.when(mockExternalTask.getVariable("vnfAdapterTaskRequest")).thenReturn(xmlString); + Mockito.when(mockExternalTask.getVariable("openstackAdapterTaskRequest")).thenReturn(xmlString); Mockito.when(mockExternalTask.getVariable("PollRollbackStatus")).thenReturn(true); Mockito.when(mockExternalTask.getVariable("stackId")).thenReturn("stackId/stack123"); Mockito.when(msoHeatUtils.pollStackForStatus(eq(1), any(), eq("DELETE_IN_PROGRESS"), eq("regionOne"), diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/RollbackServiceTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/RollbackServiceTest.java index f7613909ec..1f68106f78 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/RollbackServiceTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/RollbackServiceTest.java @@ -65,7 +65,7 @@ public class RollbackServiceTest { Stack stack = new Stack(); stack.setId("heatId"); - Mockito.when(mockExternalTask.getVariable("vnfAdapterTaskRequest")).thenReturn(payload); + Mockito.when(mockExternalTask.getVariable("openstackAdapterTaskRequest")).thenReturn(payload); Mockito.doNothing().when(vnfAdapterImpl).deleteVfModule(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()); Mockito.doNothing().when(mockExternalTaskService).complete(Mockito.any(), Mockito.any()); diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/StackServiceTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/StackServiceTest.java index 2f583b30a2..cc2dfa213e 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/StackServiceTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/StackServiceTest.java @@ -64,7 +64,7 @@ public class StackServiceTest { Stack stack = new Stack(); stack.setId("heatId"); - Mockito.when(mockExternalTask.getVariable("vnfAdapterTaskRequest")).thenReturn(payload); + Mockito.when(mockExternalTask.getVariable("openstackAdapterTaskRequest")).thenReturn(payload); Mockito.doNothing().when(vnfAdapterImpl).createVfModule(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java index 30fd2c8770..4455c9fe9d 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java @@ -329,7 +329,7 @@ public class ExceptionBuilder { } } - public void processVnfAdapterException(DelegateExecution execution) { + public void processOpenstackAdapterException(DelegateExecution execution) { StringBuilder workflowExceptionMessage = new StringBuilder(); logger.debug("Processing Vnf Adapter Exception"); try { diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/OpenstackAdapterTask.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/OpenstackAdapterTask.bpmn new file mode 100644 index 0000000000..e437f13d7b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/OpenstackAdapterTask.bpmn @@ -0,0 +1,336 @@ + + + + + SequenceFlow_13uy51h + + + SequenceFlow_9 + + + + SequenceFlow_9 + SequenceFlow_1ff2y8j + + + + SequenceFlow_1p39f4r + SequenceFlow_0ecut35 + + + + SequenceFlow_0ecut35 + SequenceFlow_13uy51h + SequenceFlow_0o8wnkx + + + #{execution.getVariable("OpenstackPollSuccess") == true } + + + #{execution.getVariable("OpenstackPollSuccess") == false } + + + SequenceFlow_1ff2y8j + SequenceFlow_1p39f4r + SequenceFlow_007m32h + + + #{execution.getVariable("OpenstackInvokeSuccess") == true } + + + #{execution.getVariable("OpenstackInvokeSuccess") == false } + + + + SequenceFlow_02rhau9 + + + + SequenceFlow_0y1by9x + SequenceFlow_006myq9 + + + + SequenceFlow_006myq9 + SequenceFlow_1ubla93 + SequenceFlow_1piwh1c + + + + + SequenceFlow_1ubla93 + SequenceFlow_1nku4uk + + + SequenceFlow_1piwh1c + SequenceFlow_1nku4uk + SequenceFlow_1yx80cq + + + SequenceFlow_1yx80cq + SequenceFlow_1az3a2q + SequenceFlow_0bnzfqb + + + #{execution.getVariable("PollRollbackStatus") == true} + + + + + + + SequenceFlow_0bnzfqb + + + + SequenceFlow_02rhau9 + SequenceFlow_0y1by9x + SequenceFlow_1az3a2q + + + #{execution.getVariable("backout") == true } + + + + + + + + + SequenceFlow_007m32h + + + + SequenceFlow_0o8wnkx + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/VnfAdapterTask.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/VnfAdapterTask.bpmn deleted file mode 100644 index 69b68e534e..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/VnfAdapterTask.bpmn +++ /dev/null @@ -1,336 +0,0 @@ - - - - - SequenceFlow_13uy51h - - - SequenceFlow_9 - - - - SequenceFlow_9 - SequenceFlow_1ff2y8j - - - - SequenceFlow_1p39f4r - SequenceFlow_0ecut35 - - - - SequenceFlow_0ecut35 - SequenceFlow_13uy51h - SequenceFlow_0o8wnkx - - - - - - - - - SequenceFlow_1ff2y8j - SequenceFlow_1p39f4r - SequenceFlow_007m32h - - - - - - - - - - SequenceFlow_02rhau9 - - - - SequenceFlow_0y1by9x - SequenceFlow_006myq9 - - - - SequenceFlow_006myq9 - SequenceFlow_1ubla93 - SequenceFlow_1piwh1c - - - - - SequenceFlow_1ubla93 - SequenceFlow_1nku4uk - - - SequenceFlow_1piwh1c - SequenceFlow_1nku4uk - SequenceFlow_1yx80cq - - - SequenceFlow_1yx80cq - SequenceFlow_1az3a2q - SequenceFlow_0bnzfqb - - - - - - - - - - SequenceFlow_0bnzfqb - - - - SequenceFlow_02rhau9 - SequenceFlow_0y1by9x - SequenceFlow_1az3a2q - - - - - - - - - - - - SequenceFlow_007m32h - - - - SequenceFlow_0o8wnkx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateNetworkBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateNetworkBB.bpmn index 1ea311549c..12b038e738 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateNetworkBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateNetworkBB.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_1maepy7 @@ -11,7 +11,7 @@ SequenceFlow_1oc7wcr SequenceFlow_0n42zi5 - + SequenceFlow_1eqfh23 SequenceFlow_1fm99t6 @@ -31,19 +31,19 @@ - + SequenceFlow_03ebe6c - + SequenceFlow_1oc7wcr - + SequenceFlow_1eqfh23 - + SequenceFlow_0y0w60u @@ -55,12 +55,12 @@ SequenceFlow_03ebe6c - + - + SequenceFlow_1fm99t6 SequenceFlow_0qpu80i @@ -83,148 +83,148 @@ - + - + - + - + - + - + - + - - + + - - + + - - + + - - + + - + - + - + - + - + - + - + - + - - + + - - + + - - + + - + - - + + - + - + - - + + - - + + - - + + - + - - + + diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn index 97fad57e7d..d77e141364 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_1xr6chl @@ -12,7 +12,7 @@ SequenceFlow_1vbwdaw - + SequenceFlow_15hn8si SequenceFlow_16g4dz0 @@ -83,148 +83,148 @@ - + - + - - + + - + - + - - + + - - + + - + - - + + - - - - - - + + + + + + - + - + - + - + - + - + - - + + - - + + - - - - + + + + - + - - + + - + - - + + - + - - + + - + - - + + diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteNetworkBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteNetworkBB.bpmn index 7a05163b0f..37459cdc7e 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteNetworkBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteNetworkBB.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_1mc3d3f @@ -17,12 +17,12 @@ SequenceFlow_0nhd7b7 - + - + SequenceFlow_16ti327 SequenceFlow_0gnafn2 @@ -52,8 +52,8 @@ - - + + @@ -68,8 +68,8 @@ - - + + @@ -78,15 +78,15 @@ - - + + - - + + diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/NetworkAdapter.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/NetworkAdapter.bpmn new file mode 100644 index 0000000000..fe071a25ba --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/NetworkAdapter.bpmn @@ -0,0 +1,69 @@ + + + + + Flow_1te2q0o + + + + + + Flow_0dcm3bq + + + + Flow_1te2q0o + Flow_16y1hyp + + + Flow_03mucze + Flow_0dcm3bq + + + + + + + + + + Flow_16y1hyp + Flow_03mucze + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UpdateNetworkBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UpdateNetworkBB.bpmn index 1235469b42..f4ffa18267 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UpdateNetworkBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UpdateNetworkBB.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_074w2et @@ -48,11 +48,12 @@ SequenceFlow_06ei0em - + + SequenceFlow_07hq1eg SequenceFlow_183ph5i @@ -61,7 +62,7 @@ SequenceFlow_183ph5i SequenceFlow_001ursg - + SequenceFlow_0qrtpcy SequenceFlow_07hq1eg @@ -98,8 +99,8 @@ - - + + @@ -117,8 +118,8 @@ - - + + @@ -130,15 +131,15 @@ - - + + - - + + @@ -153,8 +154,8 @@ - - + + @@ -184,38 +185,38 @@ - - - - + + + + - - + + - - + + - - + + - - + + @@ -224,15 +225,15 @@ - - + + - - + + diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/VnfAdapter.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/VnfAdapter.bpmn index e139e94660..3448e8d577 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/VnfAdapter.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/VnfAdapter.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_1xr6chl @@ -27,10 +27,10 @@ SequenceFlow_1ivhukd - + - + @@ -38,8 +38,8 @@ SequenceFlow_0qaaf5k SequenceFlow_0j1zvis - - + + @@ -53,8 +53,8 @@ - - + + @@ -72,10 +72,10 @@ - - - - + + + + @@ -93,25 +93,25 @@ - - + + - + - - + + - - + + diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VnfAdapterTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VnfAdapterTest.java index 4dbf4d46ff..51384c6a87 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VnfAdapterTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VnfAdapterTest.java @@ -32,12 +32,12 @@ import org.onap.so.bpmn.common.BuildingBlockExecution; public class VnfAdapterTest extends BaseBPMNTest { @Test public void vnfAdapterCreatedTest() { - mockSubprocess("vnfAdapterTask", "Mocked vnfAdapterTask", "GenericStub"); + mockSubprocess("openstackAdapterTask", "Mocked openstackAdapterTask", "GenericStub"); ProcessInstance pi = runtimeService.startProcessInstanceByKey("VnfAdapter", variables); assertThat(pi).isNotNull(); - assertThat(pi).isStarted().hasPassedInOrder("VnfAdapter_Start", "PreProcessRequest", "Call_vnfAdapterTask", - "PostProcessResponse", "VnfAdapter_End"); + assertThat(pi).isStarted().hasPassedInOrder("VnfAdapter_Start", "PreProcessRequest", + "Call_openstackAdapterTask", "PostProcessResponse", "VnfAdapter_End"); assertThat(pi).isEnded(); } 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..4d1807b796 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 @@ -78,1355 +78,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 DoCreateNetworkInstance.bpmn 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 DoCreateNetworkInstance.bpmn 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 = - """ + 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 DoCreateNetworkInstance.bpmn 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 DoCreateNetworkInstance.bpmn 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 = + """ ${MsoUtils.xmlEscape(networkId)} ${MsoUtils.xmlEscape(networkName)} """ - 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 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 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) - } - } + }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 " - 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 " + 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 = - """ + String netName = network.getNetworkName() + String networkOutputs = + """ ${MsoUtils.xmlEscape(netId)} ${MsoUtils.xmlEscape(netName)} """ - 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 = client.get(uri, NotFoundException.class).getRelationships() - if(relationships.isPresent()){ - List uris = relationships.get().getRelatedAAIUris(AAIObjectType.VPN_BINDING) + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, execution.getVariable(Prefix + "networkId")) + Optional relationships = client.get(uri, NotFoundException.class).getRelationships() + if(relationships.isPresent()){ + List 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 binding = wrapper.asBean(VpnBinding.class) + AAIResultWrapper wrapper = client.get(u.depth(Depth.TWO), NotFoundException.class) + Optional binding = wrapper.asBean(VpnBinding.class) - String routeTarget = "" - String routeRole = "" - if(binding.get().getRouteTargets() != null) { - List targets = binding.get().getRouteTargets().getRouteTarget() - for(RouteTarget target : targets) { - routeTarget = target.getGlobalRouteTarget() - routeRole = target.getRouteTargetRole() - routeTargets += "" + '\n' + - " " + routeTarget + "" + '\n' + - " " + routeRole + "" + '\n' + - "" + '\n' - } - } + String routeTarget = "" + String routeRole = "" + if(binding.get().getRouteTargets() != null) { + List targets = binding.get().getRouteTargets().getRouteTarget() + for(RouteTarget target : targets) { + routeTarget = target.getGlobalRouteTarget() + routeRole = target.getRouteTargetRole() + routeTargets += "" + '\n' + + " " + routeTarget + "" + '\n' + + " " + routeRole + "" + '\n' + + "" + '\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 = - """ + } else { + // reset return code to success + execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") + AaiUtil aaiUriUtil = new AaiUtil(this) + String schemaVersion = aaiUriUtil.getNamespace() + String aaiStubResponse = + """ """ - String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) - execution.setVariable(Prefix + "queryVpnBindingAAIResponse", aaiStubResponseAsXml) - execution.setVariable(Prefix + "routeCollection", "") - 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", "") + 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 = client.get(uri, NotFoundException.class).getRelationships() - if(relationships.isPresent()){ - List 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 = client.get(uri, NotFoundException.class).getRelationships() + if(relationships.isPresent()){ + List 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 += "" + networkPolicy + "" + '\n' + String networkPolicy = p.getNetworkPolicyFqdn() + networkPolicies += "" + networkPolicy + "" + '\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 = - """ + } else { + // reset return code to success + execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200") + AaiUtil aaiUriUtil = new AaiUtil(this) + String schemaVersion = aaiUriUtil.getNamespace() + String aaiStubResponse = + """ """ - String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) - execution.setVariable(Prefix + "queryNetworkPolicyAAIResponse", aaiStubResponseAsXml) - execution.setVariable(Prefix + "networkCollection", "") - 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", "") + 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 = client.get(uri, NotFoundException.class).getRelationships() - if(relationships.isPresent()){ - List 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 = client.get(uri, NotFoundException.class).getRelationships() + if(relationships.isPresent()){ + List 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 += "" + networkTableRef + "" + '\n' + String networkTableRef = rt.getRouteTableReferenceFqdn() + networkTableRefs += "" + networkTableRef + "" + '\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 = - """ + } else { + // reset return code to success + execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "200") + AaiUtil aaiUriUtil = new AaiUtil(this) + String schemaVersion = aaiUriUtil.getNamespace() + String aaiStubResponse = + """ """ - String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) - execution.setVariable(Prefix + "queryNetworkTableRefAAIResponse", aaiStubResponseAsXml) - execution.setVariable(Prefix + "tableRefCollection", "") - 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", "") + 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) { + public void prepareSDNCRequest (DelegateExecution execution) { - execution.setVariable("prefix",Prefix) + execution.setVariable("prefix",Prefix) - logger.trace("Inside prepareSDNCRequest() of DoCreateNetworkInstance") + logger.trace("Inside prepareSDNCRequest() 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") + 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 networkId = execution.getVariable(Prefix + "networkId") + String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") - // 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) - // 1. prepare assign topology via SDNC Adapter SUBFLOW call - String sndcTopologyCreateRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, createNetworkInput, serviceInstanceId, sdncCallback, "assign", "NetworkActivateRequest", cloudRegionId, networkId, null, null) + // 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) + 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) { + public void prepareRpcSDNCRequest (DelegateExecution execution) { - execution.setVariable("prefix",Prefix) + execution.setVariable("prefix",Prefix) - logger.trace("Inside prepareRpcSDNCRequest() of DoCreateNetworkInstance") + logger.trace("Inside prepareRpcSDNCRequest() of DoCreateNetworkInstance") - try { - // get variables + 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 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 networkId = execution.getVariable(Prefix + "networkId") + String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") - // 1. prepare assign topology via SDNC Adapter SUBFLOW call - String sndcTopologyCreateRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, createNetworkInput, serviceInstanceId, sdncCallback, "assign", "CreateNetworkInstance", cloudRegionId, networkId, null) + // 1. prepare assign topology via SDNC Adapter SUBFLOW call + String sndcTopologyCreateRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, createNetworkInput, serviceInstanceId, sdncCallback, "assign", "CreateNetworkInstance", cloudRegionId, networkId, null) - String sndcTopologyCreateRequesAsString = utils.formatXml(sndcTopologyCreateRequest) - execution.setVariable(Prefix + "assignSDNCRequest", sndcTopologyCreateRequesAsString) - logger.debug(Prefix + "assignSDNCRequest - " + "\n" + sndcTopologyCreateRequesAsString) + 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) + } 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) { + public void prepareRpcSDNCActivateRequest (DelegateExecution execution) { - execution.setVariable("prefix",Prefix) + execution.setVariable("prefix",Prefix) - logger.trace("Inside prepareRpcSDNCActivateRequest() of DoCreateNetworkInstance") + logger.trace("Inside prepareRpcSDNCActivateRequest() 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 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") + String networkId = execution.getVariable(Prefix + "networkId") + String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") - // 1. prepare assign topology via SDNC Adapter SUBFLOW call - String sndcTopologyCreateRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, createNetworkInput, serviceInstanceId, sdncCallback, "activate", "CreateNetworkInstance", cloudRegionId, networkId, null) + // 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) + 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 - // ************************************************** + // ************************************************** + // Post or Validate Response Section + // ************************************************** - public void validateCreateNetworkResponse (DelegateExecution execution) { + public void validateCreateNetworkResponse (DelegateExecution execution) { - execution.setVariable("prefix",Prefix) + execution.setVariable("prefix",Prefix) - logger.trace("Inside validateNetworkResponse() of DoCreateNetworkInstance") + logger.trace("Inside validateNetworkResponse() of DoCreateNetworkInstance") - try { - String returnCode = execution.getVariable(Prefix + "networkReturnCode") - String networkResponse = execution.getVariable(Prefix + "createNetworkResponse") - if (networkResponse==null) { - networkResponse="" // reset - } + try { + String networkResponse = execution.getVariable(Prefix + "createNetworkResponse") + if (networkResponse==null) { + networkResponse="" // reset + } - logger.debug(" Network Adapter create responseCode: " + returnCode) + execution.setVariable(Prefix + "isNetworkRollbackNeeded", true) + execution.setVariable(Prefix + "createNetworkResponse", networkResponse) + logger.debug(" Network Adapter create Success Response - " + "\n" + networkResponse) - String errorMessage = "" - if (returnCode == "200") { - 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 = - """ + // prepare rollback data + String rollbackData = utils.getNodeXml(networkResponse, "rollback", false).replace("tag0:","").replace(":tag0","") + rollbackData = rollbackData.replace("rollback>", "networkRollback>") + String rollbackNetwork = + """ ${rollbackData} """ - 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('', '') - 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('', "") - 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('', "") + 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('', "") - 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('', "") + 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 rollbackData = new HashMap(); - 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 rollbackData = new HashMap(); + 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 rollbackData = new HashMap(); - 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 rollbackData = new HashMap(); + 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 DoCreateNetworkInstanceRollback.bpmn 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 DoCreateNetworkInstanceRollback.bpmn 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 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('', "") - 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('', "") - 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 DoCreateNetworkInstanceRollback.bpmn 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 DoCreateNetworkInstanceRollback.bpmn 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 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('', "") + 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('', "") + 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/DoDeleteNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy index 89c5be8d6e..0d49d91910 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 @@ -59,346 +59,346 @@ 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 = getAAIClient().get(L3Network.class,uri); - AAIResultWrapper wrapper = getAAIClient().get(uri); - Optional 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 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 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) - String deleteNetworkRequest = """ + } + + } + + + 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 = getAAIClient().get(L3Network.class,uri); + AAIResultWrapper wrapper = getAAIClient().get(uri); + Optional 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 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 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 deleteNetworkRequest = """ ${MsoUtils.xmlEscape(cloudSiteId)} ${MsoUtils.xmlEscape(tenantId)} @@ -416,645 +416,567 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { """.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) { - - 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) - - } - - } - - public void prepareRpcSDNCRequest (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) + 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) - 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 = - """ - ${rollbackData} - """ - 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('', '') - 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('', "") + 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('', "") - 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('', "") + 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('', "") - 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 rollbackData = new HashMap(); + 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 rollbackData = new HashMap(); - 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 rollbackData = new HashMap(); - 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 rollbackData = new HashMap(); + 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 DoCreateNetworkInstanceRollback.bpmn 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 DoDeleteNetworkInstanceRollback.bpmn 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 DoDeleteNetworkInstanceRollback.bpmn 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 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('', "") - 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('', "") - 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/DoUpdateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy index 6162780b27..87e56791fc 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 @@ -73,1107 +73,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 DoUpdateNetworkInstance.bpmn 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 DoUpdateNetworkInstance.bpmn 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 = - """ + 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 DoUpdateNetworkInstance.bpmn 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 DoUpdateNetworkInstance.bpmn 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 = + """ ${MsoUtils.xmlEscape(networkId)} ${MsoUtils.xmlEscape(networkName)} """ - 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 DoUpdateNetworkInstance, PreProcessRequest() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } 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 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 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) + } + } - 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 = - """ + L3Network net = network.asBean(L3Network.class).get() + String netId = net.getNetworkId() + String netName = net.getNetworkName() + String networkOutputs = + """ ${MsoUtils.xmlEscape(netId)} ${MsoUtils.xmlEscape(netName)} """ - 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 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 binding = wrapper.asBean(VpnBinding.class) - - String routeTarget = "" - String routeRole = "" - if(binding.get().getRouteTargets() != null) { - List targets = binding.get().getRouteTargets().getRouteTarget() - for(RouteTarget target : targets) { - routeTarget = target.getGlobalRouteTarget() - routeRole = target.getRouteTargetRole() - routeTargets += "" + '\n' + - " " + routeTarget + "" + '\n' + - " " + routeRole + "" + '\n' + - "" + '\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 = - """ - - - - """ - String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) - execution.setVariable(Prefix + "queryVpnBindingAAIResponse", aaiStubResponseAsXml) - execution.setVariable(Prefix + "routeCollection", "") - logger.debug(" No vpnBinding, using this stub as response - " + '\n' + aaiStubResponseAsXml) - - } - } + 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) - } 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) - - } - - } + } - 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 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 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 binding = wrapper.asBean(VpnBinding.class) - String networkPolicy = p.getNetworkPolicyFqdn() - networkPolicies += "" + networkPolicy + "" + '\n' + String routeTarget = "" + String routeRole = "" + if(binding.get().getRouteTargets() != null) { + List targets = binding.get().getRouteTargets().getRouteTarget() + for(RouteTarget target : targets) { + routeTarget = target.getGlobalRouteTarget() + routeRole = target.getRouteTargetRole() + routeTargets += "" + '\n' + + " " + routeTarget + "" + '\n' + + " " + routeRole + "" + '\n' + + "" + '\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 = - """ - - - + } else { + // reset return code to success + execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") + AaiUtil aaiUriUtil = new AaiUtil(this) + String schemaVersion = aaiUriUtil.getNamespace() + String aaiStubResponse = + """ + + + """ - String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) - execution.setVariable(Prefix + "queryNetworkPolicyAAIResponse", aaiStubResponseAsXml) - execution.setVariable(Prefix + "networkCollection", "") - 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", "") + 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 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 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 += "" + networkPolicy + "" + '\n' - AAIResourcesClient client = new AAIResourcesClient() - RouteTableReference rt = client.get(u, NotFoundException.class).asBean(RouteTableReference.class).get() + } // end loop - String networkTableRef = rt.getRouteTableReferenceFqdn() - networkTableRefs += "" + networkTableRef + "" + '\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 = + """ + + + + """ + String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) + execution.setVariable(Prefix + "queryNetworkPolicyAAIResponse", aaiStubResponseAsXml) + execution.setVariable(Prefix + "networkCollection", "") + 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 = - """ - - - - """ - String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) - execution.setVariable(Prefix + "queryNetworkTableRefAAIResponse", aaiStubResponseAsXml) - execution.setVariable(Prefix + "tableRefCollection", "") - 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 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 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 += "" + networkTableRef + "" + '\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 = + """ + + + + """ + String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) + execution.setVariable(Prefix + "queryNetworkTableRefAAIResponse", aaiStubResponseAsXml) + execution.setVariable(Prefix + "tableRefCollection", "") + 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 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) { - // ************************************************** - // Post or Validate Response Section - // ************************************************** + execution.setVariable("prefix", Prefix) - public void validateUpdateNetworkResponse (DelegateExecution execution) { + logger.trace("Inside prepareUpdateNetworkRequest of DoUpdateNetworkInstance ") - execution.setVariable("prefix", Prefix) + try { - logger.trace("Inside validateUpdateNetworkResponse of DoUpdateNetworkInstance ") + // get variables + String requestId = execution.getVariable(Prefix + "requestId") + String messageId = execution.getVariable(Prefix + "messageId") + String source = execution.getVariable(Prefix + "source") - try { - String returnCode = execution.getVariable(Prefix + "networkReturnCode") - String networkResponse = execution.getVariable(Prefix + "updateNetworkResponse") - if (networkResponse==null) { - networkResponse="" // reset - } + 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) + + } - 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 = - """ - ${rollbackData} - """ - 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('', '') - 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('', "") - 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('', "") + 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 rollbackData = new HashMap(); + 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 rollbackData = new HashMap(); - 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 rollbackData = new HashMap(); + 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 rollbackData = new HashMap(); - 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 DoCreateNetworkInstance.bpmn 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 DoUpdateNetworkInstanceRollback.bpmn 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 DoUpdateNetworkInstanceRollback.bpmn 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 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('', "") - 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/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 = - """ - - MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 - c4f4e878-cde0-4b15-ae9a-bda857759cea - - CONTRAIL_EXTERNAL - true - 7dd5365547234ee8937416c65507d266 - RDM2WAGPLCP - - 1ef47428-cade-45bd-a103-0751e8b2deb0 - - - -""" - - String rollbackDeActivateSDNCRequest = - """ - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - activate - network-topology-operation - sdncCallback - generic-resource - - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - CreateNetworkInstance - VID - - - - - - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - MSO-dev-service-type - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - MSO_1610_dev - - - 8abc633a-810b-4ca5-8b3a-09511d13a2ce - CONTRAIL_EXTERNAL - - invariant-uuid - customization-uuid - uuid - version - CONTRAIL_EXTERNAL - - - - 8abc633a-810b-4ca5-8b3a-09511d13a2ce - CONTRAIL_EXTERNAL - MNS-25180-L-01-dmz_direct_net_1 - 7dd5365547234ee8937416c65507d266 - RDM2WAGPLCP - - -""" - - String rollbackSDNCRequest = - """ - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - rollback - network-topology-operation - sdncCallback - - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - CreateNetworkInstance - VID - - - - - - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - MSO-dev-service-type - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - MSO_1610_dev - - - 8abc633a-810b-4ca5-8b3a-09511d13a2ce - CONTRAIL_EXTERNAL - - invariant-uuid - customization-uuid - uuid - version - CONTRAIL_EXTERNAL - - - - 8abc633a-810b-4ca5-8b3a-09511d13a2ce - CONTRAIL_EXTERNAL - MNS-25180-L-01-dmz_direct_net_1 - 7dd5365547234ee8937416c65507d266 - RDM2WAGPLCP - - -""" - -// - - - - - - - - - - - @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 rollbackData = new HashMap(); - 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 rollbackData = new HashMap(); - 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/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 = - """ - - MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 - c4f4e878-cde0-4b15-ae9a-bda857759cea - - CONTRAIL_EXTERNAL - true - 7dd5365547234ee8937416c65507d266 - RDM2WAGPLCP - - 1ef47428-cade-45bd-a103-0751e8b2deb0 - - - -""" - - String rollbackActivateSDNCRequest = - """ - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - rollback - network-topology-operation - sdncCallback - generic-resource - - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - CreateNetworkInstance - VID - - - - - - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - MSO-dev-service-type - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - MSO_1610_dev - - - 8abc633a-810b-4ca5-8b3a-09511d13a2ce - CONTRAIL_EXTERNAL - - invariant-uuid - customization-uuid - uuid - version - CONTRAIL_EXTERNAL - - - - 8abc633a-810b-4ca5-8b3a-09511d13a2ce - CONTRAIL_EXTERNAL - MNS-25180-L-01-dmz_direct_net_1 - 7dd5365547234ee8937416c65507d266 - RDM2WAGPLCP - - -""" - - String rollbackSDNCRequest = - """ - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - rollback - network-topology-operation - sdncCallback - generic-resource - - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - CreateNetworkInstance - VID - - - - - - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - MSO-dev-service-type - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - MSO_1610_dev - - - 8abc633a-810b-4ca5-8b3a-09511d13a2ce - CONTRAIL_EXTERNAL - - invariant-uuid - customization-uuid - uuid - version - CONTRAIL_EXTERNAL - - - - 8abc633a-810b-4ca5-8b3a-09511d13a2ce - CONTRAIL_EXTERNAL - MNS-25180-L-01-dmz_direct_net_1 - 7dd5365547234ee8937416c65507d266 - RDM2WAGPLCP - - -""" - -// - - - - - - - - - - - @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 rollbackData = new HashMap(); - 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 rollbackData = new HashMap(); - 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-flows/src/main/resources/process/DeleteVfModuleVolumeInfraV1.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteVfModuleVolumeInfraV1.bpmn index 2e5d2e30b1..65a11e24be 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteVfModuleVolumeInfraV1.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteVfModuleVolumeInfraV1.bpmn @@ -1,14 +1,14 @@ - + SequenceFlow_1 SequenceFlow_7 - import org.onap.so.bpmn.infrastructure.scripts.* def deleteVfMod = new DeleteVfModuleVolumeInfraV1() deleteVfMod.executeMethod('preProcessRequest', execution, isDebugLogEnabled) -]]> + @@ -18,24 +18,24 @@ deleteVfMod.executeMethod('preProcessRequest', execution, isDebugLogEnabled) SequenceFlow_7 SequenceFlow_12 - import org.onap.so.bpmn.infrastructure.scripts.* def deleteVfMod = new DeleteVfModuleVolumeInfraV1() -deleteVfMod.executeMethod('sendSyncResponse', execution, isDebugLogEnabled)]]> +deleteVfMod.executeMethod('sendSyncResponse', execution, isDebugLogEnabled) SequenceFlow_12 SequenceFlow_6 - import org.onap.so.bpmn.infrastructure.scripts.* def delVfModuleVol = new DeleteVfModuleVolumeInfraV1() -delVfModuleVol.executeMethod('callRESTQueryAAICloudRegion', execution, isDebugLogEnabled)]]> +delVfModuleVol.executeMethod('callRESTQueryAAICloudRegion', execution, isDebugLogEnabled) SequenceFlow_15 SequenceFlow_2 - import org.onap.so.bpmn.infrastructure.scripts.* def deleteVfMod = new DeleteVfModuleVolumeInfraV1() -deleteVfMod.executeMethod('prepareVnfAdapterDeleteRequest', execution, isDebugLogEnabled)]]> +deleteVfMod.executeMethod('prepareVnfAdapterDeleteRequest', execution, isDebugLogEnabled) @@ -48,12 +48,12 @@ deleteVfMod.executeMethod('prepareVnfAdapterDeleteRequest', execution, isDebugLo SequenceFlow_21 - + #{execution.getVariable("DELVfModVol_tenantId") == execution.getVariable("DELVfModVol_volumeGroupTenantId")} - + - + @@ -67,18 +67,18 @@ deleteVfMod.executeMethod('prepareVnfAdapterDeleteRequest', execution, isDebugLo SequenceFlow_8 SequenceFlow_13 - import org.onap.so.bpmn.infrastructure.scripts.* def deleteVfMod = new DeleteVfModuleVolumeInfraV1() deleteVfMod.executeMethod('queryAAIForVolumeGroup', execution, isDebugLogEnabled) -]]> + SequenceFlow_21 SequenceFlow_22 - import org.onap.so.bpmn.infrastructure.scripts.* def deleteVfMod = new DeleteVfModuleVolumeInfraV1() -deleteVfMod.executeMethod('handleTenantIdMismatch', execution, isDebugLogEnabled)]]> +deleteVfMod.executeMethod('handleTenantIdMismatch', execution, isDebugLogEnabled) @@ -89,7 +89,7 @@ deleteVfMod.executeMethod('handleTenantIdMismatch', execution, isDebugLogEnabled - + #{execution.getVariable("DELVfModVol_isCloudRegionGood") == true} SequenceFlow_4 @@ -109,9 +109,9 @@ deleteVfMod.executeMethod('handleTenantIdMismatch', execution, isDebugLogEnabled SequenceFlow_responseNotSent SequenceFlow_14 - import org.onap.so.bpmn.infrastructure.scripts.* def deleteVfMod = new DeleteVfModuleVolumeInfraV1() -deleteVfMod.executeMethod('sendSyncError', execution, isDebugLogEnabled)]]> +deleteVfMod.executeMethod('sendSyncError', execution, isDebugLogEnabled) @@ -121,10 +121,10 @@ deleteVfMod.executeMethod('sendSyncError', execution, isDebugLogEnabled)]]>SequenceFlow_responseSent SequenceFlow_14 SequenceFlow_25 - import org.onap.so.bpmn.infrastructure.scripts.* def deleteVfMod = new DeleteVfModuleVolumeInfraV1() deleteVfMod.executeMethod('prepareFalloutHandler', execution, isDebugLogEnabled) -]]> + @@ -151,27 +151,27 @@ deleteVfMod.executeMethod('prepareFalloutHandler', execution, isDebugLogEnabled) SequenceFlow_35 SequenceFlow_37 - import org.onap.so.bpmn.infrastructure.scripts.* def deleteVfMod = new DeleteVfModuleVolumeInfraV1() deleteVfMod.executeMethod('prepareDBRequest', execution, isDebugLogEnabled) -]]> + SequenceFlow_27 SequenceFlow_29 - import org.onap.so.bpmn.infrastructure.scripts.* def deleteVfMod = new DeleteVfModuleVolumeInfraV1() deleteVfMod.executeMethod('prepareCompletionHandlerRequest', execution, isDebugLogEnabled) -]]> + SequenceFlow_10 SequenceFlow_24 - + // The following variable is checked by the unit test +execution.setVariable("DELVfModVol_TransactionSuccessIndicator", true) @@ -197,7 +197,7 @@ execution.setVariable("DELVfModVol_TransactionSuccessIndicator", true)]]> - + ${UrnPropertiesReader.getVariable("mso.adapters.openecomp.db.endpoint", execution)} ${DELVfModVol_updateInfraRequest} @@ -219,9 +219,9 @@ execution.setVariable("DELVfModVol_TransactionSuccessIndicator", true)]]> SequenceFlow_vnfAdapterCallOK SequenceFlow_35 - import org.onap.so.bpmn.infrastructure.scripts.* def deleteVfMod = new DeleteVfModuleVolumeInfraV1() -deleteVfMod.executeMethod('deleteVolGrpId', execution, isDebugLogEnabled)]]> +deleteVfMod.executeMethod('deleteVolGrpId', execution, isDebugLogEnabled) @@ -243,321 +243,321 @@ deleteVfMod.executeMethod('deleteVolGrpId', execution, isDebugLogEnabled)]]> - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - - + + - + - - - - + + + + - - + + - - + + - - + + - + - - + + - - + + - + - + - - + + - - - - + + + + - + - - + + - + - + - - + + - + - - - - + + + + - - + + - + - + - + - - + + - - - - + + + + - + - - - - + + + + - + - - + + - + - + - + - + - - - - + + + + - - - - + + + + - - - - + + + + - + - + - - + + - + - - - - + + + + - + - + - - - - + + + + - + - - + + - + - - - - - - + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVfModuleVolumeInfraV1.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVfModuleVolumeInfraV1.bpmn index ce346e13b3..4826d88d8a 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVfModuleVolumeInfraV1.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVfModuleVolumeInfraV1.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_1 @@ -21,7 +21,7 @@ - + ${UrnPropertiesReader.getVariable("mso.adapters.openecomp.db.endpoint", execution)} ${UPDVfModVol_updateInfraRequest} @@ -43,26 +43,26 @@ SequenceFlow_22 SequenceFlow_21 - import org.onap.so.bpmn.infrastructure.scripts.* def uvmv = new UpdateVfModuleVolumeInfraV1() -uvmv.executeMethod('prepVnfAdapterRest', execution, isDebugLogEnabled)]]> +uvmv.executeMethod('prepVnfAdapterRest', execution, isDebugLogEnabled) SequenceFlow_12 SequenceFlow_13 - import org.onap.so.bpmn.infrastructure.scripts.* def uvmv = new UpdateVfModuleVolumeInfraV1() -uvmv.executeMethod('prepCompletionHandlerRequest', execution, UPDVfModVol_requestId, 'UPDATE', UPDVfModVol_source, isDebugLogEnabled)]]> +uvmv.executeMethod('prepCompletionHandlerRequest', execution, UPDVfModVol_requestId, 'UPDATE', UPDVfModVol_source, isDebugLogEnabled) - + - + SequenceFlow_21 SequenceFlow_19 @@ -71,16 +71,16 @@ uvmv.executeMethod('prepCompletionHandlerRequest', execution, UPDVfModVol_reques SequenceFlow_19 SequenceFlow_11 - import org.onap.so.bpmn.infrastructure.scripts.* def uvmv = new UpdateVfModuleVolumeInfraV1() -uvmv.executeMethod('prepDbInfraDbRequest', execution, isDebugLogEnabled)]]> +uvmv.executeMethod('prepDbInfraDbRequest', execution, isDebugLogEnabled) SequenceFlow_14 SequenceFlow_1 - + // The following variable is checked by the unit test +execution.setVariable("UpdateVfModuleVolumeSuccessIndicator", true) @@ -101,9 +101,9 @@ execution.setVariable("UpdateVfModuleVolumeSuccessIndicator", true)]]> SequenceFlow_7 SequenceFlow_4 - import org.onap.so.bpmn.infrastructure.scripts.* def uvmv = new UpdateVfModuleVolumeInfraV1() -uvmv.executeMethod('prepFalloutHandler', execution, isDebugLogEnabled)]]> +uvmv.executeMethod('prepFalloutHandler', execution, isDebugLogEnabled) @@ -134,17 +134,17 @@ uvmv.executeMethod('prepFalloutHandler', execution, isDebugLogEnabled)]]> SequenceFlow_YesVfModuleRelation SequenceFlow_8 - import org.onap.so.bpmn.infrastructure.scripts.* def uvmv = new UpdateVfModuleVolumeInfraV1() -uvmv.executeMethod('queryAAIForVfModule', execution, isDebugLogEnabled)]]> +uvmv.executeMethod('queryAAIForVfModule', execution, isDebugLogEnabled) SequenceFlow_personaModelidMatchNo SequenceFlow_18 - import org.onap.so.bpmn.infrastructure.scripts.* def uvmv = new UpdateVfModuleVolumeInfraV1() -uvmv.executeMethod('handlePersonaModelIdMismatch', execution, isDebugLogEnabled)]]> +uvmv.executeMethod('handlePersonaModelIdMismatch', execution, isDebugLogEnabled) @@ -154,9 +154,9 @@ uvmv.executeMethod('handlePersonaModelIdMismatch', execution, isDebugLogEnabled) SequenceFlow_3 SequenceFlow_2 - import org.onap.so.bpmn.infrastructure.scripts.* def uvmv = new UpdateVfModuleVolumeInfraV1() -uvmv.executeMethod('preProcessRequest', execution, isDebugLogEnabled)]]> +uvmv.executeMethod('preProcessRequest', execution, isDebugLogEnabled) @@ -166,9 +166,9 @@ uvmv.executeMethod('preProcessRequest', execution, isDebugLogEnabled)]]> SequenceFlow_2 SequenceFlow_20 - import org.onap.so.bpmn.infrastructure.scripts.* def uvmv = new UpdateVfModuleVolumeInfraV1() -uvmv.executeMethod('sendSynchResponse', execution, isDebugLogEnabled)]]> +uvmv.executeMethod('sendSynchResponse', execution, isDebugLogEnabled) @@ -177,7 +177,7 @@ uvmv.executeMethod('sendSynchResponse', execution, isDebugLogEnabled)]]>SequenceFlow_noVfModuleRelation - + #{UPDVfModVol_relatedVfModuleLink != ''} @@ -192,9 +192,9 @@ uvmv.executeMethod('sendSynchResponse', execution, isDebugLogEnabled)]]> SequenceFlow_NoTenantMatch SequenceFlow_17 - import org.onap.so.bpmn.infrastructure.scripts.* def uvmv = new UpdateVfModuleVolumeInfraV1() -uvmv.executeMethod('handleTenantIdMismatch', execution, isDebugLogEnabled)]]> +uvmv.executeMethod('handleTenantIdMismatch', execution, isDebugLogEnabled) @@ -204,17 +204,17 @@ uvmv.executeMethod('handleTenantIdMismatch', execution, isDebugLogEnabled)]]> SequenceFlow_5 SequenceFlow_15 - import org.onap.so.bpmn.infrastructure.scripts.* def uvmv = new UpdateVfModuleVolumeInfraV1() -uvmv.executeMethod('queryAAIForVolumeGroup', execution, isDebugLogEnabled)]]> +uvmv.executeMethod('queryAAIForVolumeGroup', execution, isDebugLogEnabled) SequenceFlow_20 SequenceFlow_5 - import org.onap.so.bpmn.infrastructure.scripts.* def uvmv = new UpdateVfModuleVolumeInfraV1() -uvmv.executeMethod('queryAAIForGenericVnf', execution, isDebugLogEnabled)]]> +uvmv.executeMethod('queryAAIForGenericVnf', execution, isDebugLogEnabled) @@ -228,10 +228,10 @@ uvmv.executeMethod('queryAAIForGenericVnf', execution, isDebugLogEnabled)]]> - - - - + + + + @@ -249,8 +249,8 @@ uvmv.executeMethod('queryAAIForGenericVnf', execution, isDebugLogEnabled)]]> - - + + @@ -262,15 +262,15 @@ uvmv.executeMethod('queryAAIForGenericVnf', execution, isDebugLogEnabled)]]> - - + + - - + + @@ -282,15 +282,15 @@ uvmv.executeMethod('queryAAIForGenericVnf', execution, isDebugLogEnabled)]]> - - + + - - + + @@ -308,15 +308,15 @@ uvmv.executeMethod('queryAAIForGenericVnf', execution, isDebugLogEnabled)]]> - - + + - - + + @@ -328,31 +328,31 @@ uvmv.executeMethod('queryAAIForGenericVnf', execution, isDebugLogEnabled)]]> - - + + - - + + - - + + - - - - + + + + @@ -361,8 +361,8 @@ uvmv.executeMethod('queryAAIForGenericVnf', execution, isDebugLogEnabled)]]> - - + + @@ -383,8 +383,8 @@ uvmv.executeMethod('queryAAIForGenericVnf', execution, isDebugLogEnabled)]]> - - + + @@ -396,8 +396,8 @@ uvmv.executeMethod('queryAAIForGenericVnf', execution, isDebugLogEnabled)]]> - - + + @@ -409,15 +409,15 @@ uvmv.executeMethod('queryAAIForGenericVnf', execution, isDebugLogEnabled)]]> - - + + - - + + @@ -429,10 +429,10 @@ uvmv.executeMethod('queryAAIForGenericVnf', execution, isDebugLogEnabled)]]> - - - - + + + + @@ -447,16 +447,16 @@ uvmv.executeMethod('queryAAIForGenericVnf', execution, isDebugLogEnabled)]]> - - - + + + - - + + @@ -468,18 +468,18 @@ uvmv.executeMethod('queryAAIForGenericVnf', execution, isDebugLogEnabled)]]> - - - - + + + + - - - + + + @@ -494,22 +494,22 @@ uvmv.executeMethod('queryAAIForGenericVnf', execution, isDebugLogEnabled)]]> - - + + - - + + - - + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateNetworkInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateNetworkInstance.bpmn index c049eaafa0..76e6199fa6 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateNetworkInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateNetworkInstance.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_1n61wit @@ -24,8 +24,7 @@ DoCreateNetworkInstance.callRESTQueryAAICloudRegion(execution) SequenceFlow_11 import org.onap.so.bpmn.infrastructure.scripts.* def DoCreateNetworkInstance = new DoCreateNetworkInstance() -DoCreateNetworkInstance.prepareSDNCRequest(execution) - +DoCreateNetworkInstance.prepareSDNCRequest(execution) @@ -78,13 +77,6 @@ DoCreateNetworkInstance.callRESTQueryAAINetworkId(execution) SequenceFlow_12 - - SequenceFlow_59 - SequenceFlow_13 - import org.onap.so.bpmn.infrastructure.scripts.* -def DoCreateNetworkInstance = new DoCreateNetworkInstance() -DoCreateNetworkInstance.validateCreateNetworkResponse(execution) - isAAIQueryNameYes_SequenceFlow isNetworkActiveYes_SequenceFlow @@ -149,7 +141,7 @@ DoCreateNetworkInstance.prepareSDNCRollbackRequest(execution) isSdncRpc4No_SequenceFlow4 - #{execution.getVariable("sdncVersion") != '1610'} + #{execution.getVariable("sdncVersion") != '1610'} @@ -163,7 +155,7 @@ DoCreateNetworkInstance.prepareRpcSDNCRollbackRequest(execution) SequenceFlow_1qwubew - SequenceFlow_15sffxc + Flow_15l1pk2 SequenceFlow_096tad6 import org.onap.so.bpmn.infrastructure.scripts.* def DoCreateNetworkInstance = new DoCreateNetworkInstance() @@ -223,7 +215,7 @@ DoCreateNetworkInstance.postProcessResponse(execution) SequenceFlow_0bwpkkb SequenceFlow_15sffxc - + SequenceFlow_0b8j5rw SequenceFlow_12tlymf @@ -241,19 +233,24 @@ DoCreateNetworkInstance.postProcessResponse(execution) SequenceFlow_10ttvwn import org.onap.so.bpmn.infrastructure.scripts.* def DoCreateNetworkInstance = new DoCreateNetworkInstance() -DoCreateNetworkInstance.setExceptionFlag(execution) - +DoCreateNetworkInstance.setExceptionFlag(execution) + + SequenceFlow_15sffxc + Flow_15l1pk2 + import org.onap.so.bpmn.infrastructure.scripts.* +def DoCreateNetworkInstance = new DoCreateNetworkInstance() +DoCreateNetworkInstance.validateCreateNetworkResponse(execution) + + -    -Include ONLY inputs/varrables:   + Include ONLY inputs/varrables:   rollbackData, as Map -rollbackSDNCRequest -rollbackActivateSDNCRequest -rollbackNetworkRequest -WorkflowException -  +WorkflowException @@ -261,31 +258,7 @@ WorkflowException - - - - - ${CRENWKI_createNetworkRequest} - ${UrnPropertiesReader.getVariable("mso.adapters.network.rest.endpoint", execution)} - - - - #{BasicAuthHeaderValuePO} - application/xml - - - POST - ${statusCode} - ${response} - - http-connector - - - SequenceFlow_61 - SequenceFlow_59 - - - + SequenceFlow_13 SequenceFlow_35 @@ -349,10 +322,9 @@ DoCreateNetworkInstance.callRESTQueryAAINetworkPolicy(execution) SequenceFlow_61 import org.onap.so.bpmn.infrastructure.scripts.* def DoCreateNetworkInstance = new DoCreateNetworkInstance() -DoCreateNetworkInstance.prepareCreateNetworkRequest(execution) - +DoCreateNetworkInstance.prepareCreateNetworkRequest(execution) - + SequenceFlow_38 SequenceFlow_20 @@ -435,7 +407,7 @@ DoCreateNetworkInstance.validateRpcSDNCActivateResponse(execution) - #{execution.getVariable("sdncVersion") != '1610'} + #{execution.getVariable("sdncVersion") != '1610'} @@ -458,7 +430,7 @@ DoCreateNetworkInstance.validateRpcSDNCActivateResponse(execution)isSdncRpc2No_SequenceFlow2 - #{execution.getVariable("sdncVersion") != '1610'} + #{execution.getVariable("sdncVersion") != '1610'} @@ -466,8 +438,7 @@ DoCreateNetworkInstance.validateRpcSDNCActivateResponse(execution)SequenceFlow_0j8bxnb import org.onap.so.bpmn.infrastructure.scripts.* def DoCreateNetworkInstance = new DoCreateNetworkInstance() -DoCreateNetworkInstance.prepareRpcSDNCRequest(execution) - +DoCreateNetworkInstance.prepareRpcSDNCRequest(execution) SequenceFlow_1s8b1m1 @@ -500,781 +471,773 @@ DoCreateNetworkInstance.postProcessResponse(execution) def DoCreateNetworkInstance = new DoCreateNetworkInstance() DoCreateNetworkInstance.getServiceInstance(execution) - - if '200', Prepare PO Network Rollback - - + + + + + + + + SequenceFlow_61 + SequenceFlow_13 + - + - + - + - + - + - - + + - + - - - + + + - + - - - - + + + + - + - - - - + - + - + - + - + - + - - + + - + - - + + - + - + - + - + - - + + - - + + - - + + - + - - - - + + + + - + - + - - + + - + - - + + - + - - + + - + - + - + - + - - + + - + - - - - + + + + - - - - + + + + - - - - - - - - - - + - - - - - + + + - + - - + + - + - + - - - + + + - + - - + + - + - + - + - - - - + + + + - + - - - + + + - + - + - - - + + + - + - - + + - + - - - + + + - + - + - + - + - - + + - - + + - - - + + + - + - - - - + + + + - - - - + + + + - + - - - - + + + + - + - + - - - - + + + + - + - - + + - + - + - + - + - + - - + + - - + + - - + + - - + + - + - - + + - + - + - + - - - + + + - + - + - + - + - - + + - + - - - + + + - + - + - + - - - + + + - + - - + + - + - + - - + + - - + + - + - + - - + + - + - - - + + + - + - + - + - - + + - + - - - + + + - + - + - + - + - + - + - + - - - - + + + + - + - + - - + + - + - - - - + + + + - + - - + + - - + + - - - + + + - - + + - + - - + + - + - - + + - + - + - - + + - + - - + + - + - + - - + + - + - - + + - + - - + + - + - - - + + + - - - - - - - - + - - + + - + - - + + - + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateNetworkInstanceRollback.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateNetworkInstanceRollback.bpmn index 6a4861b9a4..5103fa9d0a 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateNetworkInstanceRollback.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateNetworkInstanceRollback.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_1krl2dg @@ -7,9 +7,9 @@ SequenceFlow_1krl2dg SequenceFlow_0u41iz2 - import org.onap.so.bpmn.infrastructure.scripts.* def DoCreateNetworkInstanceRollback = new DoCreateNetworkInstanceRollback() -DoCreateNetworkInstanceRollback.preProcessRequest(execution)]]> +DoCreateNetworkInstanceRollback.preProcessRequest(execution) @@ -72,9 +72,9 @@ DoCreateNetworkInstanceRollback.preProcessRequest(execution)]]> SequenceFlow_0qc4v9t SequenceFlow_0el8yzs SequenceFlow_0yto4gz - import org.onap.so.bpmn.infrastructure.scripts.* def DoCreateNetworkInstanceRollback = new DoCreateNetworkInstanceRollback() -DoCreateNetworkInstanceRollback.validateRollbackResponses(execution)]]> +DoCreateNetworkInstanceRollback.validateRollbackResponses(execution) SequenceFlow_1lteduj @@ -84,20 +84,20 @@ DoCreateNetworkInstanceRollback.validateRollbackResponses(execution)]]> - + #{execution.getVariable("CRENWKIR_rollbackActivateSDNCRequest") != null} - - + + #{execution.getVariable("CRENWKIR_rollbackNetworkRequest") != null} - + #{execution.getVariable("CRENWKIR_rollbackSDNCRequest") != null} - + #{execution.getVariable("sdncVersion") != '1610'} SequenceFlow_0yto4gz @@ -109,9 +109,9 @@ DoCreateNetworkInstanceRollback.validateRollbackResponses(execution)]]> SequenceFlow_0xktw7v SequenceFlow_0soe5t3 - import org.onap.so.bpmn.infrastructure.scripts.* def DoCreateNetworkInstanceRollback = new DoCreateNetworkInstanceRollback() -DoCreateNetworkInstanceRollback.processJavaException(execution)]]> +DoCreateNetworkInstanceRollback.processJavaException(execution) SequenceFlow_0xktw7v @@ -137,9 +137,9 @@ DoCreateNetworkInstanceRollback.processJavaException(execution)]]> SequenceFlow_0q0te67 SequenceFlow_0lomcvn - import org.onap.so.bpmn.infrastructure.scripts.* execution.setVariable("workflowException", execution.getVariable("WorkflowException") -]]> + @@ -172,29 +172,41 @@ execution.setVariable("workflowException", execution.getVariable("WorkflowExcept - - SequenceFlow_0e1uixp + + Flow_0t2n952 SequenceFlow_17o4w67 - import org.onap.so.bpmn.infrastructure.scripts.* def DoCreateNetworkInstanceRollback = new DoCreateNetworkInstanceRollback() -DoCreateNetworkInstanceRollback.callPONetworkAdapter(execution)]]> +DoCreateNetworkInstanceRollback.setNetworkAdapterResponseCode(execution) - + + + + + + SequenceFlow_0e1uixp + Flow_0t2n952 + + + + Include ONLY inputs/varrables:   rollbackData, as Map -rollbackSDNCRequest -rollbackActivateSDNCRequest -rollbackNetworkRequest WorkflowException   -]]> - + + - + set value for: WorkflowException rolledBack wasDeleted -]]> - + + @@ -202,316 +214,321 @@ wasDeleted - + - + - - + + - - - + + + - + - + - + - + - + - + - + - - + + - + - + - + - + - + - + - + - - + + - - + + - + - - + + - + - - - - + + - + - - - - + + + + - - + + - + - - + + - + - - - - + + + + - - - + + + - + - - + + - + - + - - + + - + - - - + + + - - + + - + - + - + - + - - + + - - + + - + - - + + - - - + + + - + - + - + - - + + - - + + - + - - + + - + - + - + - + - + - - + + - - + + - + + + + + + + + - \ No newline at end of file + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModule.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModule.bpmn index 0d1b970c62..74e0600f4f 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModule.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModule.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_1 @@ -37,7 +37,7 @@ SequenceFlow_21 - + #{execution.getVariable("DCVFM_volumeGroupName") != null && execution.getVariable("DCVFM_volumeGroupName") != "" } @@ -76,19 +76,19 @@ SequenceFlow_20 SequenceFlow_1nh92s8 - import org.onap.so.bpmn.infrastructure.scripts.* String response = execution.getVariable("DCVFM_assignSDNCAdapterResponse") def doCreateVfModule = new DoCreateVfModule() -doCreateVfModule.validateSDNCResponse(execution, response, "assign")]]> +doCreateVfModule.validateSDNCResponse(execution, response, "assign") SequenceFlow_8 SequenceFlow_18 - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModule = new DoCreateVfModule() -doCreateVfModule.preProcessSDNCAssignRequest(execution)]]> +doCreateVfModule.preProcessSDNCAssignRequest(execution) @@ -96,9 +96,9 @@ doCreateVfModule.preProcessSDNCAssignRequest(execution)]]> SequenceFlow_0p61zug SequenceFlow_0aegg0r SequenceFlow_23 - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModule = new DoCreateVfModule() -doCreateVfModule.preProcessSDNCGetRequest(execution, "vfmodule")]]> +doCreateVfModule.preProcessSDNCGetRequest(execution, "vfmodule") @@ -118,12 +118,12 @@ doCreateVfModule.preProcessSDNCGetRequest(execution, "vfmodule")]]> SequenceFlow_24 SequenceFlow_31 - import org.onap.so.bpmn.infrastructure.scripts.* String response = execution.getVariable("DCVFM_getSDNCAdapterResponse") def doCreateVfModule = new DoCreateVfModule() -doCreateVfModule.validateSDNCResponse(execution, response, "get")]]> +doCreateVfModule.validateSDNCResponse(execution, response, "get") @@ -138,16 +138,16 @@ doCreateVfModule.validateSDNCResponse(execution, response, "get")]]> SequenceFlow_1avfxsz SequenceFlow_5 - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModule = new DoCreateVfModule() -doCreateVfModule.preProcessUpdateAAIVfModuleRequestOrch(execution)]]> +doCreateVfModule.preProcessUpdateAAIVfModuleRequestOrch(execution) SequenceFlow_10 SequenceFlow_12 - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModule = new DoCreateVfModule() -doCreateVfModule.preProcessSDNCActivateRequest(execution)]]> +doCreateVfModule.preProcessSDNCActivateRequest(execution) @@ -165,12 +165,12 @@ doCreateVfModule.preProcessSDNCActivateRequest(execution)]]> SequenceFlow_13 SequenceFlow_14 - import org.onap.so.bpmn.infrastructure.scripts.* String response = execution.getVariable("DCVFM_activateSDNCAdapterResponse") def doCreateVfModule = new DoCreateVfModule() -doCreateVfModule.validateSDNCResponse(execution, response, "activate")]]> +doCreateVfModule.validateSDNCResponse(execution, response, "activate") SequenceFlow_14 @@ -195,9 +195,9 @@ doCreateVfModule.validateSDNCResponse(execution, response, "activate")]]> SequenceFlow_28 SequenceFlow_3 - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModule = new DoCreateVfModule() -doCreateVfModule.prepareCreateAAIVfModuleVolumeGroupRequest(execution)]]> +doCreateVfModule.prepareCreateAAIVfModuleVolumeGroupRequest(execution) @@ -220,13 +220,13 @@ doCreateVfModule.prepareCreateAAIVfModuleVolumeGroupRequest(execution)]]> SequenceFlow_31 SequenceFlow_32 - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModule = new DoCreateVfModule() -doCreateVfModule.preProcessVNFAdapterRequest(execution)]]> +doCreateVfModule.preProcessVNFAdapterRequest(execution) - + - + @@ -239,9 +239,9 @@ doCreateVfModule.preProcessVNFAdapterRequest(execution)]]> SequenceFlow_33 SequenceFlow_1ushk1d - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModule = new DoCreateVfModule() -doCreateVfModule.postProcessVNFAdapterRequest(execution)]]> +doCreateVfModule.postProcessVNFAdapterRequest(execution) SequenceFlow_0xfanpi @@ -265,9 +265,9 @@ doCreateVfModule.postProcessVNFAdapterRequest(execution)]]> SequenceFlow_25 SequenceFlow_27 - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModule = new DoCreateVfModule() -doCreateVfModule.postProcessCreateAAIVfModule(execution)]]> +doCreateVfModule.postProcessCreateAAIVfModule(execution) @@ -277,22 +277,22 @@ doCreateVfModule.postProcessCreateAAIVfModule(execution)]]> - + execution.getVariable("DCVFM_isBaseVfModule") == "true" SequenceFlow_36 SequenceFlow_37 - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModule = new DoCreateVfModule() -doCreateVfModule.queryAAIVfModule(execution)]]> +doCreateVfModule.queryAAIVfModule(execution) SequenceFlow_16 SequenceFlow_7 - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModule = new DoCreateVfModule() -doCreateVfModule.setSuccessIndicator(execution, true)]]> +doCreateVfModule.setSuccessIndicator(execution, true) @@ -302,20 +302,20 @@ doCreateVfModule.setSuccessIndicator(execution, true)]]> SequenceFlow_40 SequenceFlow_43 - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModule = new DoCreateVfModule() -return doCreateVfModule.queryCloudRegion(execution)]]> +return doCreateVfModule.queryCloudRegion(execution) - + #{execution.getVariable("DCVFM_volumeGroupId") != null && execution.getVariable("DCVFM_volumeGroupId") != "" } SequenceFlow_1 SequenceFlow_4 - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModule = new DoCreateVfModule() -doCreateVfModule.preProcessRequest(execution)]]> +doCreateVfModule.preProcessRequest(execution) @@ -352,16 +352,16 @@ doCreateVfModule.preProcessRequest(execution)]]> - + execution.getVariable("DCVFM_contrailNetworkPolicyFqdnList") != null && !execution.getVariable("DCVFM_contrailNetworkPolicyFqdnList").isEmpty() SequenceFlow_0ery1pk SequenceFlow_0abffyj - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModule = new DoCreateVfModule() -doCreateVfModule.createNetworkPoliciesInAAI(execution)]]> +doCreateVfModule.createNetworkPoliciesInAAI(execution) SequenceFlow_0363dz7 @@ -374,7 +374,7 @@ doCreateVfModule.createNetworkPoliciesInAAI(execution)]]> SequenceFlow_1avfxsz - + !execution.getVariable("DCVFM_oamManagementV4Address").isEmpty() || !execution.getVariable("DCVFM_oamManagementV6Address").isEmpty() @@ -384,9 +384,9 @@ doCreateVfModule.createNetworkPoliciesInAAI(execution)]]> SequenceFlow_0bi38s7 SequenceFlow_1qm81ym - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModule = new DoCreateVfModule() -doCreateVfModule.prepUpdateAAIGenericVnf(execution)]]> +doCreateVfModule.prepUpdateAAIGenericVnf(execution) @@ -401,16 +401,16 @@ doCreateVfModule.prepUpdateAAIGenericVnf(execution)]]> - + #{execution.getVariable("DCVFM_sdncVersion" ) == '1707'} SequenceFlow_0m382su SequenceFlow_0g270u0 - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModule = new DoCreateVfModule() -doCreateVfModule.preProcessSDNCGetRequest(execution, 'vnf')]]> +doCreateVfModule.preProcessSDNCGetRequest(execution, 'vnf') @@ -428,12 +428,12 @@ doCreateVfModule.preProcessSDNCGetRequest(execution, 'vnf')]]> SequenceFlow_1yrlvgb SequenceFlow_170kw7h - import org.onap.so.bpmn.infrastructure.scripts.* String response = execution.getVariable("DCVFM_getVnfSDNCAdapterResponse") def doCreateVfModule = new DoCreateVfModule() -doCreateVfModule.validateSDNCResponse(execution, response, "get")]]> +doCreateVfModule.validateSDNCResponse(execution, response, "get") @@ -445,7 +445,7 @@ doCreateVfModule.validateSDNCResponse(execution, response, "get")]]> - + #{execution.getVariable("DCVFM_vfModuleName") == null} @@ -486,16 +486,16 @@ doCreateVfModule.validateSDNCResponse(execution, response, "get")]]> SequenceFlow_04bd5in SequenceFlow_1i1q78e - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModule = new DoCreateVfModule() -doCreateVfModule.preProcessRollback(execution)]]> +doCreateVfModule.preProcessRollback(execution) SequenceFlow_0112l2c SequenceFlow_0z2rczk - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModule = new DoCreateVfModule() -doCreateVfModule.postProcessRollback(execution)]]> +doCreateVfModule.postProcessRollback(execution) @@ -508,14 +508,14 @@ doCreateVfModule.postProcessRollback(execution)]]> - + #{execution.getVariable("disableRollback" ) == true} SequenceFlow_1nh7m8d SequenceFlow_1pgo10r - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModule = new DoCreateVfModule() -doCreateVfModule.processBPMNException(execution)]]> +doCreateVfModule.processBPMNException(execution) @@ -525,7 +525,7 @@ doCreateVfModule.processBPMNException(execution)]]> SequenceFlow_006rnym - + #{execution.getVariable("DCVFM_volumeGroupId") != null && execution.getVariable("DCVFM_volumeGroupId") != "" } SequenceFlow_4 @@ -540,18 +540,18 @@ doCreateVfModule.processBPMNException(execution)]]> - + execution.getVariable("DCVFM_aLaCarte") == true - + execution.getVariable("DCVFM_twoPhaseDesign") == true SequenceFlow_00bh7m7 - + execution.getVariable("DCVFM_orchestrationStatus") == "PendingActivation" || execution.getVariable("DCVFM_orchestrationStatus") == "Assigned" SequenceFlow_1nh92s8 @@ -559,7 +559,7 @@ doCreateVfModule.processBPMNException(execution)]]> SequenceFlow_1iyt5i4 - + execution.getVariable("DCVFM_aLaCarte") == true @@ -581,30 +581,30 @@ doCreateVfModule.processBPMNException(execution)]]> SequenceFlow_17cp3tn SequenceFlow_0ynd0iy - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModule = new DoCreateVfModule() -doCreateVfModule.preProcessUpdateAAIVfModuleRequestStatus(execution, 'PendingActivation')]]> +doCreateVfModule.preProcessUpdateAAIVfModuleRequestStatus(execution, 'PendingActivation') SequenceFlow_16mgvsd SequenceFlow_0cc17yk - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModule = new DoCreateVfModule() -doCreateVfModule.queryCatalogDB(execution)]]> +doCreateVfModule.queryCatalogDB(execution) SequenceFlow_1y8q87e SequenceFlow_1sf1091 - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModule = new DoCreateVfModule() -doCreateVfModule.queryAAIVfModuleForStatus(execution)]]> +doCreateVfModule.queryAAIVfModuleForStatus(execution) SequenceFlow_1mnipp8 SequenceFlow_00bh7m7 - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModule = new DoCreateVfModule() -doCreateVfModule.setSuccessIndicator(execution, true)]]> +doCreateVfModule.setSuccessIndicator(execution, true) SequenceFlow_15i583d @@ -613,7 +613,7 @@ doCreateVfModule.setSuccessIndicator(execution, true)]]> - + #{execution.getVariable("DCVFM_volumeGroupId") != null && execution.getVariable("DCVFM_volumeGroupId") != "" } SequenceFlow_0tfrcnc @@ -629,7 +629,7 @@ doCreateVfModule.setSuccessIndicator(execution, true)]]> SequenceFlow_0p3cspl - + execution.getVariable("DCVFM_isBaseVfModule") == "true" @@ -642,9 +642,9 @@ doCreateVfModule.setSuccessIndicator(execution, true)]]> SequenceFlow_0oadvvx SequenceFlow_03batve - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModule = new DoCreateVfModule() -return doCreateVfModule.queryCloudRegion(execution)]]> +return doCreateVfModule.queryCloudRegion(execution) @@ -663,17 +663,17 @@ return doCreateVfModule.queryCloudRegion(execution)]]> SequenceFlow_0p3cspl SequenceFlow_1k7xbcu - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModule = new DoCreateVfModule() -doCreateVfModule.queryAAIVfModule(execution)]]> +doCreateVfModule.queryAAIVfModule(execution) SequenceFlow_006rnym SequenceFlow_1iyt5i4 SequenceFlow_0thm33s - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModule = new DoCreateVfModule() -doCreateVfModule.preProcessUpdateAAIVfModuleRequestStatus(execution, 'Assigned')]]> +doCreateVfModule.preProcessUpdateAAIVfModuleRequestStatus(execution, 'Assigned') @@ -693,983 +693,983 @@ doCreateVfModule.preProcessUpdateAAIVfModuleRequestStatus(execution, 'Assigned') - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - - - - + + + + - - - + + + - + - - - - + + + + - + - + - - + + - + - - + + - + - - - + + + - + - - - + + + - - - + + + - - - - + + + + - + - + - + - + - + - + - - - - + + + + - - - - + + + + - - - - + + + + - + - + - - - - + + + + - - - - + + + + - + - + - + - - + + - - + + - - - - + + + + - - + + - - - - + + + + - + - - + + - + - + - + - + - + - - + + - + - + - - - - + + + + - - + + - - + + - + - + - + - + - + - - - + + + - + - - + + - + - + - - - - + + + + - - - - + + + + - + - - + + - + - - - - + + + + - + - - - - - + + + + + - + - - + + - + - + - - + + - - - + + + - + - - + + - + - - - + + + - + - + - + - + - - - + + + - + - - - - + + + + - - - + + + - - + + - + - - - - + + + + - - + + - + - + - - + + - + - - - + + + - + - - + + - - + + - + - + - + - - - - + + + + - - - + + + - + - + - - + + - + - - - + + + - + - + - + - + - + - + - + - + - - + + - - - - + + + + - - + + - - + + - + - + - - + + - + - - - + + + - + - + - - - + + + - + - + - - + + - + - + - + - - + + - + - + - + - - - + + + - + - - + + - + - - + + - - + + - + - + - - + + - + - + - + - - + + - + - - + + - - + + - - - - - + + + + + - + - - - - + + + + - + - - + + - - + + - - + + - + - + - + - + - + - + - + - - + + - + - - - + + + - + - + - - + + - - + + - - - + + + - + - + - - + + - + - - - + + + - + - + - - - - - - + + + + + + - - - + + + - + - + - + - + - + - - + + - - - - - + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModuleRollback.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModuleRollback.bpmn index e9675b89f8..699ee5bcd1 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModuleRollback.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModuleRollback.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_1 @@ -21,7 +21,7 @@ SequenceFlow_8 - + execution.getVariable("DCVFMR_rollbackPrepareUpdateVfModule") == "true" && !(execution.getVariable('aLaCarte') == true && execution.getVariable("DCVFMR_rollbackSDNCRequestAssign") == "true") @@ -34,15 +34,15 @@ SequenceFlow_1p0v6yk SequenceFlow_16 - import org.onap.so.bpmn.infrastructure.scripts.* def dcvfmr = new DoCreateVfModuleRollback() -dcvfmr.prepVNFAdapterRequest(execution)]]> +dcvfmr.prepVNFAdapterRequest(execution) - + - + @@ -51,15 +51,15 @@ dcvfmr.prepVNFAdapterRequest(execution)]]> SequenceFlow_08aruzz - + #{execution.getVariable("DCVFMR_rollbackSDNCRequestActivate") == "true" && execution.getVariable("sdncVersion") == "1707"} SequenceFlow_13 SequenceFlow_14 - import org.onap.so.bpmn.infrastructure.scripts.* def dcvfmr = new DoCreateVfModuleRollback() -dcvfmr.prepUpdateAAIVfModule(execution)]]> +dcvfmr.prepUpdateAAIVfModule(execution) @@ -78,7 +78,7 @@ dcvfmr.prepUpdateAAIVfModule(execution)]]> SequenceFlow_17 - + #{execution.getVariable("DCVFMR_rollbackUpdateAAIVfModule") == "true"} @@ -88,15 +88,15 @@ dcvfmr.prepUpdateAAIVfModule(execution)]]> SequenceFlow_20 - + #{execution.getVariable("DCVFMR_rollbackSDNCRequestAssign") == "true" || execution.getVariable("DCVFMR_rollbackSDNCRequestActivate") == "true"} SequenceFlow_1rpg6ac SequenceFlow_32 - import org.onap.so.bpmn.infrastructure.scripts.* def dcvfmr = new DoCreateVfModuleRollback() -dcvfmr.prepSDNCAdapterRequest(execution)]]> +dcvfmr.prepSDNCAdapterRequest(execution) @@ -121,7 +121,7 @@ dcvfmr.prepSDNCAdapterRequest(execution)]]> - + #{execution.getVariable("DCVFMR_rollbackCreateAAIVfModule") == "true"} @@ -141,18 +141,18 @@ dcvfmr.prepSDNCAdapterRequest(execution)]]> SequenceFlow_24 SequenceFlow_34 - import org.onap.so.bpmn.infrastructure.scripts.* def dcvfmr = new DoCreateVfModuleRollback() -dcvfmr.prepDeleteAAIVfModule(execution)]]> +dcvfmr.prepDeleteAAIVfModule(execution) SequenceFlow_2 SequenceFlow_4 - import org.onap.so.bpmn.infrastructure.scripts.* def dcvfmr = new DoCreateVfModuleRollback() -dcvfmr.sdncValidateResponse(execution, DCVFMR_DoCreateVfModuleRollbackResponse)]]> +dcvfmr.sdncValidateResponse(execution, DCVFMR_DoCreateVfModuleRollbackResponse) @@ -168,18 +168,18 @@ dcvfmr.sdncValidateResponse(execution, DCVFMR_DoCreateVfModuleRollbackResponse)] SequenceFlow_02fx6z6 SequenceFlow_22 - import org.onap.so.bpmn.infrastructure.scripts.* def dcvfmr = new DoCreateVfModuleRollback() dcvfmr.logWorkflowException(execution, 'DoCreateVfModuleRollback caught an event') -dcvfmr.saveWorkflowException(execution, 'DCVFMR_CaughtWorkflowException1')]]> +dcvfmr.saveWorkflowException(execution, 'DCVFMR_CaughtWorkflowException1') SequenceFlow_12 SequenceFlow_02fx6z6 - import org.onap.so.bpmn.infrastructure.scripts.* def dcvfmr = new DoCreateVfModuleRollback() -dcvfmr.setFailedRollbackStatus(execution)]]> +dcvfmr.setFailedRollbackStatus(execution) @@ -193,9 +193,9 @@ dcvfmr.setFailedRollbackStatus(execution)]]> SequenceFlow_1 SequenceFlow_5 - import org.onap.so.bpmn.infrastructure.scripts.* def dcvfmr = new DoCreateVfModuleRollback() -dcvfmr.preProcessRequest(execution)]]> +dcvfmr.preProcessRequest(execution) @@ -207,16 +207,16 @@ dcvfmr.preProcessRequest(execution)]]> SequenceFlow_0unumxv SequenceFlow_0djpj3r - import org.onap.so.bpmn.infrastructure.scripts.* def dcvfmr = new DoCreateVfModuleRollback() -dcvfmr.deleteNetworkPoliciesFromAAI(execution)]]> +dcvfmr.deleteNetworkPoliciesFromAAI(execution) SequenceFlow_111l1he SequenceFlow_0ca4brn - import org.onap.so.bpmn.infrastructure.scripts.* def dcvfmr = new DoCreateVfModuleRollback() -dcvfmr.preProcessUpdateAAIGenericVnf(execution)]]> +dcvfmr.preProcessUpdateAAIGenericVnf(execution) @@ -238,12 +238,12 @@ dcvfmr.preProcessUpdateAAIGenericVnf(execution)]]> - + #{execution.getVariable("DCVFMR_rollbackUpdateVnfAAI") == "true"} - + #{execution.getVariable("DCVFMR_rollbackVnfAdapterCreate") == "true"} @@ -253,7 +253,7 @@ dcvfmr.preProcessUpdateAAIGenericVnf(execution)]]> - + #{execution.getVariable("skipRollback" ) == true} SequenceFlow_06rm0hg @@ -264,9 +264,9 @@ dcvfmr.preProcessUpdateAAIGenericVnf(execution)]]> SequenceFlow_10 SequenceFlow_0ugalf8 - import org.onap.so.bpmn.infrastructure.scripts.* def dcvfmr = new DoCreateVfModuleRollback() -dcvfmr.preProcessSDNCDeactivateRequest(execution)]]> +dcvfmr.preProcessSDNCDeactivateRequest(execution) @@ -284,26 +284,26 @@ dcvfmr.preProcessSDNCDeactivateRequest(execution)]]> SequenceFlow_0n78x37 SequenceFlow_06rm0hg - import org.onap.so.bpmn.infrastructure.scripts.* def dcvfmr = new DoCreateVfModuleRollback() String response = execution.getVariable("DCVFMR_deactivateSDNCAdapterResponse") -dcvfmr.sdncValidateResponse(execution, response)]]> +dcvfmr.sdncValidateResponse(execution, response) - + #{execution.getVariable("DCVFMR_rollbackCreateNetworkPoliciesAAI") == "true"} SequenceFlow_16ghmax SequenceFlow_1iufuuu - import org.onap.so.bpmn.infrastructure.scripts.* def dcvfmr = new DoCreateVfModuleRollback() -dcvfmr.preProcessSDNCUnassignRequest(execution)]]> +dcvfmr.preProcessSDNCUnassignRequest(execution) @@ -321,10 +321,10 @@ dcvfmr.preProcessSDNCUnassignRequest(execution)]]> SequenceFlow_1l4n37b SequenceFlow_12otwa4 - import org.onap.so.bpmn.infrastructure.scripts.* def dcvfmr = new DoCreateVfModuleRollback() String response = execution.getVariable("DCVFMR_unassignSDNCAdapterResponse") -dcvfmr.sdncValidateResponse(execution, response)]]> +dcvfmr.sdncValidateResponse(execution, response) SequenceFlow_19 @@ -333,7 +333,7 @@ dcvfmr.sdncValidateResponse(execution, response)]]> - + #{execution.getVariable("DCVFMR_rollbackSDNCRequestAssign") == "true" && execution.getVariable("sdncVersion") == "1707"} @@ -342,9 +342,9 @@ dcvfmr.sdncValidateResponse(execution, response)]]> SequenceFlow_35 SequenceFlow_17it51d SequenceFlow_1h8ve60 - import org.onap.so.bpmn.infrastructure.scripts.* def dcvfmr = new DoCreateVfModuleRollback() -dcvfmr.setSuccessfulRollbackStatus(execution)]]> +dcvfmr.setSuccessfulRollbackStatus(execution) SequenceFlow_03i4czf @@ -354,7 +354,7 @@ dcvfmr.setSuccessfulRollbackStatus(execution)]]> - + execution.getVariable('aLaCarte') == true && execution.getVariable("DCVFMR_rollbackSDNCRequestAssign") == "true" @@ -370,9 +370,9 @@ dcvfmr.setSuccessfulRollbackStatus(execution)]]> SequenceFlow_17ne2iz SequenceFlow_0fvuowt - import org.onap.so.bpmn.infrastructure.scripts.* def dcvfmr = new DoCreateVfModuleRollback() -dcvfmr.prepUpdateAAIVfModuleToAssigned(execution)]]> +dcvfmr.prepUpdateAAIVfModuleToAssigned(execution) @@ -381,593 +381,593 @@ dcvfmr.prepUpdateAAIVfModuleToAssigned(execution)]]> - + - + - - + + - + - + - + - - + + - + - + - + - + - + - + - - + + - - + + - + - - - - + + + + - + - + - - - + + + - + - + - - - + + + - + - - - - + + + + - - + + - + - - - - - - + + + + + + - + - + - + - - - - + + + + - + - - + + - + - + - - - - - - - + + + + + + + - + - - + + - + - - - + + + - - - - - - + + + + + + - + - + - + - - - - - - - + + + + + + + - + - - - + + + - + - - - - - + + + + + - + - + - - + + - - - + + + - + - + - + - + - + - + - + - - - - + + + + - + - + - + - + - + - - - + + + - + - + - - - - + + + + - + - - - - + + + + - + - - - - + + + + - - - + + + - - - - - + + + + + - + - - - - - - + + + + + + - + - + - + - - + + - + - - - - + + + + - + - - + + - - - + + + - + - + - + - + - + - - + + - - + + - - - + + + - - - - - - + + + + + + - + - - - - - + + + + + - + - - + + - - + + - + - + - + - + - + - - - + + + - + - - - + + + - + - - - - + + + + - - + + - + - - + + - + - + - + - - + + - + - - - - - + + + + + - + - - - + + + - - + + - + - + - - - + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModuleVolumeRollback.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModuleVolumeRollback.bpmn index 6f3dceda84..b5cb1bf255 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModuleVolumeRollback.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModuleVolumeRollback.bpmn @@ -1,13 +1,13 @@ - + SequenceFlow_0xktw7v SequenceFlow_0soe5t3 - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModuleVolumeRollback = new DoCreateVfModuleVolumeRollback() -doCreateVfModuleVolumeRollback.processJavaException(execution)]]> +doCreateVfModuleVolumeRollback.processJavaException(execution) SequenceFlow_0xktw7v @@ -33,9 +33,9 @@ doCreateVfModuleVolumeRollback.processJavaException(execution)]]> SequenceFlow_0h7k68j SequenceFlow_10dawse - + - + @@ -44,15 +44,15 @@ doCreateVfModuleVolumeRollback.processJavaException(execution)]]> SequenceFlow_0bv04qn - + #{execution.getVariable("DCVFMODVOLRBK_isCreateVnfRollbackNeeded") == "true"} SequenceFlow_0bv04qn SequenceFlow_17k6oyz SequenceFlow_13nb3n0 - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModuleVolumeRollback = new DoCreateVfModuleVolumeRollback() -doCreateVfModuleVolumeRollback.executeMethod('callRESTDeleteAAIVolumeGroup', execution, isDebugLogEnabled)]]> +doCreateVfModuleVolumeRollback.executeMethod('callRESTDeleteAAIVolumeGroup', execution, isDebugLogEnabled) @@ -63,7 +63,7 @@ doCreateVfModuleVolumeRollback.executeMethod('callRESTDeleteAAIVolumeGroup', exe SequenceFlow_1do0853 - + #{execution.getVariable("DCVFMODVOLRBK_isAAIRollbackNeeded" ) == "true"} @@ -74,14 +74,14 @@ doCreateVfModuleVolumeRollback.executeMethod('callRESTDeleteAAIVolumeGroup', exe SequenceFlow_13nb3n0 - + #{execution.getVariable("DCVFMODVOLRBK_backoutOnFailure") != "false"} SequenceFlow_0qreiaa SequenceFlow_1xah9es - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModuleVolumeRollback = new DoCreateVfModuleVolumeRollback() -doCreateVfModuleVolumeRollback.preProcessRequest(execution)]]> +doCreateVfModuleVolumeRollback.preProcessRequest(execution) @@ -90,153 +90,153 @@ doCreateVfModuleVolumeRollback.preProcessRequest(execution)]]> - + - + - + - + - - + + - - + + - + - + - + - + - + - + - + - - + + - + - - - - + + + + - - - + + + - - + + - + - + - - - + + + - - + + - + - + - - + + - + - - - + + + - - + + - - + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModuleVolumeV2.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModuleVolumeV2.bpmn index 58ea0c4951..5dc9878561 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModuleVolumeV2.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModuleVolumeV2.bpmn @@ -1,27 +1,27 @@ - + SequenceFlow_1 SequenceFlow_1wi1cf9 - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModuleVolumeV2 = new DoCreateVfModuleVolumeV2() -doCreateVfModuleVolumeV2.executeMethod('preProcessRequest', execution, isDebugLogEnabled)]]> +doCreateVfModuleVolumeV2.executeMethod('preProcessRequest', execution, isDebugLogEnabled) SequenceFlow_1dpt7ul SequenceFlow_23 - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModuleVolumeV2 = new DoCreateVfModuleVolumeV2() -doCreateVfModuleVolumeV2.executeMethod('callRESTQueryAAICloudRegion', execution, isDebugLogEnabled)]]> +doCreateVfModuleVolumeV2.executeMethod('callRESTQueryAAICloudRegion', execution, isDebugLogEnabled) SequenceFlow_volGrpName404No SequenceFlow_7 - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModuleVolumeV2 = new DoCreateVfModuleVolumeV2() -doCreateVfModuleVolumeV2.executeMethod('buildWorkflowException', execution, 2500, "Volume group name already exists in the system.", isDebugLogEnabled)]]> +doCreateVfModuleVolumeV2.executeMethod('buildWorkflowException', execution, 2500, "Volume group name already exists in the system.", isDebugLogEnabled) @@ -31,15 +31,15 @@ doCreateVfModuleVolumeV2.executeMethod('buildWorkflowException', execution, 2500 SequenceFlow_volGrpName404No - + #{DCVFMODVOLV2_AaiReturnCode == '404'} SequenceFlow_23 SequenceFlow_14 - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModuleVolumeV2 = new DoCreateVfModuleVolumeV2() -doCreateVfModuleVolumeV2.executeMethod('callRESTQueryAAIGenericVnf', execution, isDebugLogEnabled)]]> +doCreateVfModuleVolumeV2.executeMethod('callRESTQueryAAIGenericVnf', execution, isDebugLogEnabled) @@ -50,22 +50,22 @@ doCreateVfModuleVolumeV2.executeMethod('callRESTQueryAAIGenericVnf', execution, SequenceFlow_14 SequenceFlow_6 - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModuleVolumeV2 = new DoCreateVfModuleVolumeV2() -doCreateVfModuleVolumeV2.executeMethod('callRESTQueryAAIVolGrpName', execution, isDebugLogEnabled)]]> +doCreateVfModuleVolumeV2.executeMethod('callRESTQueryAAIVolGrpName', execution, isDebugLogEnabled) SequenceFlow_volGrpName404Yes SequenceFlow_9 - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModuleVolumeV2 = new DoCreateVfModuleVolumeV2() -doCreateVfModuleVolumeV2.executeMethod('callRESTCreateAAIVolGrpName', execution, isDebugLogEnabled)]]> +doCreateVfModuleVolumeV2.executeMethod('callRESTCreateAAIVolGrpName', execution, isDebugLogEnabled) - + - + @@ -79,25 +79,25 @@ doCreateVfModuleVolumeV2.executeMethod('callRESTCreateAAIVolGrpName', execution, SequenceFlow_1gbt2n5 SequenceFlow_28 - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModuleVolumeV2 = new DoCreateVfModuleVolumeV2() -doCreateVfModuleVolumeV2.executeMethod('callRESTQueryAAIVolGrpName', execution, isDebugLogEnabled)]]> +doCreateVfModuleVolumeV2.executeMethod('callRESTQueryAAIVolGrpName', execution, isDebugLogEnabled) SequenceFlow_5 SequenceFlow_8 - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModuleVolumeV2 = new DoCreateVfModuleVolumeV2() -doCreateVfModuleVolumeV2.executeMethod('setSuccessIndicator', execution, true)]]> +doCreateVfModuleVolumeV2.executeMethod('setSuccessIndicator', execution, true) SequenceFlow_28 SequenceFlow_5 - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModuleVolumeV2 = new DoCreateVfModuleVolumeV2() -doCreateVfModuleVolumeV2.executeMethod('callRESTUpdateCreatedVolGrpName', execution, isDebugLogEnabled)]]> +doCreateVfModuleVolumeV2.executeMethod('callRESTUpdateCreatedVolGrpName', execution, isDebugLogEnabled) @@ -106,9 +106,9 @@ doCreateVfModuleVolumeV2.executeMethod('callRESTUpdateCreatedVolGrpName', execut SequenceFlow_9 SequenceFlow_10 - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModuleVolumeV2 = new DoCreateVfModuleVolumeV2() -doCreateVfModuleVolumeV2.executeMethod('prepareVnfAdapterCreateRequest', execution, isDebugLogEnabled)]]> +doCreateVfModuleVolumeV2.executeMethod('prepareVnfAdapterCreateRequest', execution, isDebugLogEnabled) @@ -121,18 +121,18 @@ doCreateVfModuleVolumeV2.executeMethod('prepareVnfAdapterCreateRequest', executi SequenceFlow_1qwurc5 SequenceFlow_1gbt2n5 - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModuleVolumeV2 = new DoCreateVfModuleVolumeV2() -doCreateVfModuleVolumeV2.executeMethod('validateVnfResponse', execution, isDebugLogEnabled)]]> +doCreateVfModuleVolumeV2.executeMethod('validateVnfResponse', execution, isDebugLogEnabled) SequenceFlow_1wi1cf9 SequenceFlow_1dpt7ul - import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModuleVolumeV2 = new DoCreateVfModuleVolumeV2() -doCreateVfModuleVolumeV2.executeMethod('getServiceInstance', execution, isDebugLogEnabled)]]> +doCreateVfModuleVolumeV2.executeMethod('getServiceInstance', execution, isDebugLogEnabled) @@ -142,194 +142,194 @@ doCreateVfModuleVolumeV2.executeMethod('getServiceInstance', execution, isDebugL - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - - - - - + + + + + - + - - + + - - + + - - + + - + - - + + - - - - + + + + - - + + - + - - + + - - + + - - + + - + - - + + - + - - + + - + - + - + - - + + - - + + - + - - + + - - + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteNetworkInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteNetworkInstance.bpmn index d6069d714e..5edbf3cd55 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteNetworkInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteNetworkInstance.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_1 @@ -8,9 +8,9 @@ SequenceFlow_0msqfwu SequenceFlow_6 - import org.onap.so.bpmn.infrastructure.scripts.* def callRESTDeleteAAI = new DoDeleteNetworkInstance() -callRESTDeleteAAI.callRESTQueryAAI(execution)]]> +callRESTDeleteAAI.callRESTQueryAAI(execution) @@ -31,10 +31,9 @@ callRESTDeleteAAI.callRESTQueryAAI(execution)]]> SequenceFlow_12 SequenceFlow_1jnva78 SequenceFlow_5 - import org.onap.so.bpmn.infrastructure.scripts.* def validateSDNCResponse = new DoDeleteNetworkInstance() -validateSDNCResponse.validateSDNCResponse(execution) -]]> +validateSDNCResponse.validateSDNCResponse(execution) @@ -54,7 +53,7 @@ validateSDNCResponse.validateSDNCResponse(execution) - + #{execution.getVariable("DELNWKI_sdncResponseSuccess" ) == true} @@ -67,18 +66,17 @@ validateSDNCResponse.validateSDNCResponse(execution) SequenceFlow_1nl99y6 SequenceFlow_1yvnovn - import org.onap.so.bpmn.infrastructure.scripts.* def DoDeleteNetworkInstance = new DoDeleteNetworkInstance() -DoDeleteNetworkInstance.postProcessResponse(execution) -]]> +DoDeleteNetworkInstance.postProcessResponse(execution) SequenceFlow_1wif0e5 - import org.onap.so.bpmn.infrastructure.scripts.* def DoDeleteNetworkInstance = new DoDeleteNetworkInstance() -DoDeleteNetworkInstance.prepareRpcSDNCDeactivateRollback(execution)]]> +DoDeleteNetworkInstance.prepareRpcSDNCDeactivateRollback(execution) SequenceFlow_021b0sz @@ -86,33 +84,16 @@ DoDeleteNetworkInstance.prepareRpcSDNCDeactivateRollback(execution)]]>SequenceFlow_1suj1nc - + #{execution.getVariable("DELNWKI_rollbackEnabled") == true} - - - - - - - - - - - - - - - - SequenceFlow_147vc14 - SequenceFlow_0tiz0kk SequenceFlow_0jb7rws SequenceFlow_1raa09h - + #{execution.getVariable("DELNWKI_isSdncDeactivateRollbackNeeded") == true} SequenceFlow_1suj1nc @@ -124,24 +105,19 @@ DoDeleteNetworkInstance.prepareRpcSDNCDeactivateRollback(execution)]]> SequenceFlow_1wif0e5 - SequenceFlow_147vc14 - import org.onap.so.bpmn.infrastructure.scripts.* def DoDeleteNetworkInstance = new DoDeleteNetworkInstance() -DoDeleteNetworkInstance.prepareRollbackData(execution)]]> +DoDeleteNetworkInstance.prepareRollbackData(execution) - SequenceFlow_1a51h25 SequenceFlow_021b0sz - import org.onap.so.bpmn.infrastructure.scripts.* def DoDeleteNetworkInstance = new DoDeleteNetworkInstance() -DoDeleteNetworkInstance.setExceptionFlag(execution)]]> +DoDeleteNetworkInstance.setExceptionFlag(execution) - Rollback Not Needed for Delete. - - isRelationshipExistNo_SequenceFlow @@ -149,7 +125,7 @@ DoDeleteNetworkInstance.setExceptionFlag(execution)]]> querySuccessNo_SequenceFlow - + #{execution.getVariable("DELNWKI_isAAIGood") == true} @@ -159,7 +135,7 @@ DoDeleteNetworkInstance.setExceptionFlag(execution)]]> - + #{execution.getVariable("DELNWKI_aaiReturnCode" ) == "404"} isReturnCode404_No_SequenceFlow @@ -172,7 +148,7 @@ DoDeleteNetworkInstance.setExceptionFlag(execution)]]> - + #{execution.getVariable("DELNWKI_isSilentSuccess") == true} isReturnCode404_Yes_SequenceFlow @@ -186,9 +162,9 @@ DoDeleteNetworkInstance.setExceptionFlag(execution)]]> isResponseEmptyNo_SequenceFlow SequenceFlow_30 - import org.onap.so.bpmn.infrastructure.scripts.* def deleteNetMod = new DoDeleteNetworkInstance() -deleteNetMod.callRESTQueryAAICloudRegion(execution)]]> +deleteNetMod.callRESTQueryAAICloudRegion(execution) @@ -198,7 +174,7 @@ deleteNetMod.callRESTQueryAAICloudRegion(execution)]]> - + #{execution.getVariable("DELNWKI_isVfRelationshipExist") == true} isRelationshipExistYes_SequenceFlow @@ -210,36 +186,18 @@ deleteNetMod.callRESTQueryAAICloudRegion(execution)]]> SequenceFlow_0r3pvf8 SequenceFlow_1pdp4d2 - import org.onap.so.bpmn.infrastructure.scripts.* def prepareSDNCRequest = new DoDeleteNetworkInstance() -prepareSDNCRequest.prepareSDNCRequest(execution) -]]> +prepareSDNCRequest.prepareSDNCRequest(execution) - - SequenceFlow_2 - SequenceFlow_20 - - - SequenceFlow_30 SequenceFlow_15 - - - - - SequenceFlow_15 - SequenceFlow_2 - import org.onap.so.bpmn.infrastructure.scripts.* def prepareNetworkRequest = new DoDeleteNetworkInstance() -prepareNetworkRequest.sendRequestToVnfAdapter(execution)]]> +prepareNetworkRequest.prepareNetworkRequest(execution) - + SequenceFlow_13 @@ -251,9 +209,9 @@ prepareNetworkRequest.sendRequestToVnfAdapter(execution)]]> SequenceFlow_13 SequenceFlow_17 - import org.onap.so.bpmn.infrastructure.scripts.* def deleteNetMod = new DoDeleteNetworkInstance() -deleteNetMod.processJavaException(execution)]]> +deleteNetMod.processJavaException(execution) @@ -261,15 +219,14 @@ deleteNetMod.processJavaException(execution)]]> sdncTopoDeleteYes_SequenceFlow SequenceFlow_1pbgnr2 - import org.onap.so.bpmn.infrastructure.scripts.* def DoDeleteNetworkInstance = new DoDeleteNetworkInstance() -DoDeleteNetworkInstance.postProcessResponse(execution) -]]> +DoDeleteNetworkInstance.postProcessResponse(execution) - SequenceFlow_20 + Flow_10caop8 SequenceFlow_0r3pvf8 SequenceFlow_0kqnddy @@ -277,10 +234,9 @@ DoDeleteNetworkInstance.postProcessResponse(execution) SequenceFlow_0f13b17 SequenceFlow_0zlbzad - import org.onap.so.bpmn.infrastructure.scripts.* def prepareSDNCRequest = new DoDeleteNetworkInstance() -prepareSDNCRequest.prepareRpcSDNCRequest(execution) -]]> +prepareSDNCRequest.prepareRpcSDNCRequest(execution) @@ -298,23 +254,22 @@ prepareSDNCRequest.prepareRpcSDNCRequest(execution) - + #{execution.getVariable("sdncVersion") != '1610'} SequenceFlow_1 SequenceFlow_0msqfwu - import org.onap.so.bpmn.infrastructure.scripts.* def DoDeleteNetworkInstance = new DoDeleteNetworkInstance() -DoDeleteNetworkInstance.preProcessRequest(execution)]]> +DoDeleteNetworkInstance.preProcessRequest(execution) silentSuccess_SequenceFlow SequenceFlow_0f25bme - import org.onap.so.bpmn.infrastructure.scripts.* def DoDeleteNetworkInstance = new DoDeleteNetworkInstance() -DoDeleteNetworkInstance.postProcessResponse(execution) -]]> +DoDeleteNetworkInstance.postProcessResponse(execution) @@ -333,9 +288,9 @@ DoDeleteNetworkInstance.postProcessResponse(execution) SequenceFlow_0kqnddy SequenceFlow_1o088sy - import org.onap.so.bpmn.infrastructure.scripts.* def DoDeleteNetworkInstance = new DoDeleteNetworkInstance() -DoDeleteNetworkInstance.prepareRpcSDNCDeactivate(execution)]]> +DoDeleteNetworkInstance.prepareRpcSDNCDeactivate(execution) @@ -346,9 +301,9 @@ DoDeleteNetworkInstance.prepareRpcSDNCDeactivate(execution)]]> SequenceFlow_1i3193l SequenceFlow_0n8sf23 - import org.onap.so.bpmn.infrastructure.scripts.* def DoDeleteNetworkInstance = new DoDeleteNetworkInstance() -DoDeleteNetworkInstance.validateRpcSDNCDeactivateResponse(execution)]]> +DoDeleteNetworkInstance.validateRpcSDNCDeactivateResponse(execution) SequenceFlow_08hus4u @@ -359,575 +314,555 @@ DoDeleteNetworkInstance.validateRpcSDNCDeactivateResponse(execution)]]> - + #{execution.getVariable("DELNWKI_sdncResponseSuccess" ) == true} SequenceFlow_08hus4u SequenceFlow_1qyo7ot + + + + + + + SequenceFlow_15 + Flow_10caop8 + + - + - + - - + + - + - + - + - - + + - - - - - + + - + - - + + - + - + - + - - - - + + + + - + - - + + - + - + - + - - + + - + - - + + - + - + - + - + - - - + + + - + - - - - - - - - + - + - + - + - + - - - - + + + + - + - - + + - + - + - + - + - - + + - - - - - - - - + - + - - + + - + - + - - + + - - - - + - + - + - + - - - - + + + + - + - - + + - + - + - - + + - + - + - + - - - - + + + + - + - + - + - + - + - - + + - - + + - + - - + + - - + + - + - - + + - - + + - + - + - - - + + + - + - + - + - - + + - - + + - - + + - + - + - - + + - + - - + + - + - + - - - - + + + + - + - + - + - - + + - - + + - - + + - - + + - + - - - + + + - + - + - + - + - + - - - - + + + + - + - - - + + + - + - - - - + - + - - - - + + + + - + - + - - + + - - - + + + - + - - + + - - - - - - - - - + + - + - - + + - - - + + + - \ No newline at end of file + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteNetworkInstanceRollback.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteNetworkInstanceRollback.bpmn deleted file mode 100644 index 7ec02addfa..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteNetworkInstanceRollback.bpmn +++ /dev/null @@ -1,547 +0,0 @@ - - - - - SequenceFlow_1krl2dg - - - SequenceFlow_1krl2dg - SequenceFlow_0u41iz2 - - - - - - - - - - - - - - - SequenceFlow_1mxbdps - SequenceFlow_07s5r14 - - - SequenceFlow_0u41iz2 - SequenceFlow_1bb7zpp - SequenceFlow_1mxbdps - - - SequenceFlow_1xokvq6 - SequenceFlow_1xs882r - SequenceFlow_1ucaagl - - - - - - - - - SequenceFlow_1ucaagl - - - - - SequenceFlow_0xktw7v - SequenceFlow_0soe5t3 - - - - SequenceFlow_0xktw7v - - - - SequenceFlow_0soe5t3 - - - - - - SequenceFlow_1hcmrh9 - SequenceFlow_1pi168e - SequenceFlow_1xs882r - - - - SequenceFlow_1bb7zpp - SequenceFlow_07s5r14 - SequenceFlow_1yj3542 - SequenceFlow_18e00sw - - - - - - - ${DELNWKIR_rollbackNetworkRequest} - - - - #{BasicAuthHeaderValuePO} - application/xml - - - POST - ${response} - ${statusCode} - - http-connector - - - SequenceFlow_18e00sw - SequenceFlow_1eyt8z2 - - - - - - SequenceFlow_1yj3542 - SequenceFlow_1eyt8z2 - SequenceFlow_1xokvq6 - SequenceFlow_172safw - - - SequenceFlow_172safw - SequenceFlow_1wy1aba - SequenceFlow_1yltkyg - - - - - - - - - - - - - - - - - - - - - - SequenceFlow_1yltkyg - SequenceFlow_1hcmrh9 - - - - - - - - - - - - SequenceFlow_1wy1aba - SequenceFlow_1pi168e - - - - - SequenceFlow_1s5yjuu - - - SequenceFlow_01hh1wq - SequenceFlow_1s5yjuu - - - - SequenceFlow_01hh1wq - - - - - - - SequenceFlow_0b0m3o7 - - - - SequenceFlow_141226w - - - - - - SequenceFlow_141226w - SequenceFlow_0b0m3o7 - - - - SequenceFlow_1lr1613 - - - - SequenceFlow_0np0b8p - - - - SequenceFlow_1lr1613 - SequenceFlow_0np0b8p - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVfModule.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVfModule.bpmn index 6026fc84b3..e08ffbde2f 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVfModule.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVfModule.bpmn @@ -1,12 +1,12 @@ - + SequenceFlow_0fp1wqz SequenceFlow_28 - import org.onap.so.bpmn.infrastructure.scripts.* def dvm = new DoDeleteVfModule() -dvm.prepUpdateAAIVfModule(execution)]]> +dvm.prepUpdateAAIVfModule(execution) @@ -30,7 +30,7 @@ dvm.prepUpdateAAIVfModule(execution)]]> SequenceFlow_029ioyr SequenceFlow_14xn858 - + @@ -48,22 +48,22 @@ dvm.prepUpdateAAIVfModule(execution)]]> SequenceFlow_14xn858 SequenceFlow_4 - import org.onap.so.bpmn.infrastructure.scripts.* def dvm = new DoDeleteVfModule() -dvm.prepVNFAdapterRequest(execution)]]> +dvm.prepVNFAdapterRequest(execution) SequenceFlow_31 SequenceFlow_32 - import org.onap.so.bpmn.infrastructure.scripts.* def dvm = new DoDeleteVfModule() -dvm.prepSDNCAdapterRequest(execution, "delete")]]> +dvm.prepSDNCAdapterRequest(execution, "delete") - + - + @@ -88,33 +88,33 @@ dvm.prepSDNCAdapterRequest(execution, "delete")]]> SequenceFlow_2 SequenceFlow_34 - import org.onap.so.bpmn.infrastructure.scripts.* def dvm = new DoDeleteVfModule() -dvm.prepDeleteAAIVfModule(execution)]]> +dvm.prepDeleteAAIVfModule(execution) SequenceFlow_33 SequenceFlow_2 - import org.onap.so.bpmn.infrastructure.scripts.* def dvm = new DoDeleteVfModule() -dvm.sdncValidateResponse(execution, DoDVfMod_doDeleteVfModuleResponse)]]> +dvm.sdncValidateResponse(execution, DoDVfMod_doDeleteVfModuleResponse) SequenceFlow_1 SequenceFlow_12 - import org.onap.so.bpmn.infrastructure.scripts.* def dvm = new DoDeleteVfModule() -dvm.preProcessRequest(execution)]]> +dvm.preProcessRequest(execution) SequenceFlow_12 SequenceFlow_42 - import org.onap.so.bpmn.infrastructure.scripts.* def dvm = new DoDeleteVfModule() -dvm.preProcessRequest(execution)]]> +dvm.preProcessRequest(execution) @@ -125,16 +125,16 @@ dvm.preProcessRequest(execution)]]> SequenceFlow_0coa90m SequenceFlow_08g02ch - import org.onap.so.bpmn.infrastructure.scripts.* def dvm = new DoDeleteVfModule() -dvm.deleteNetworkPoliciesFromAAI(execution)]]> +dvm.deleteNetworkPoliciesFromAAI(execution) SequenceFlow_1xruki1 SequenceFlow_0coa90m - import org.onap.so.bpmn.infrastructure.scripts.* def dvm = new DoDeleteVfModule() -dvm.postProcessVNFAdapterRequest(execution)]]> +dvm.postProcessVNFAdapterRequest(execution) @@ -144,7 +144,7 @@ dvm.postProcessVNFAdapterRequest(execution)]]> - + execution.getVariable("DoDVfMod_oamManagementV4Address") != null || execution.getVariable("DoDVfMod_oamManagementV6Address") != null @@ -158,9 +158,9 @@ dvm.postProcessVNFAdapterRequest(execution)]]> SequenceFlow_1yehsyc SequenceFlow_1a7lzhz - import org.onap.so.bpmn.infrastructure.scripts.* def doDeleteVfModule = new DoDeleteVfModule() -doDeleteVfModule.prepUpdateAAIGenericVnf(execution)]]> +doDeleteVfModule.prepUpdateAAIGenericVnf(execution) @@ -177,11 +177,11 @@ doDeleteVfModule.prepUpdateAAIGenericVnf(execution)]]> SequenceFlow_42 SequenceFlow_029ioyr - import org.onap.so.bpmn.infrastructure.scripts.* def dvm = new DoDeleteVfModule() -dvm.queryAAIVfModuleForStatus(execution)]]> +dvm.queryAAIVfModuleForStatus(execution) - + @@ -189,240 +189,240 @@ dvm.queryAAIVfModuleForStatus(execution)]]> - + - + - - + + - + - + - - + + - + - - + + - + - + - - + + - + - + - + - + - - - - - + + + + + - - - - + + + + - - + + - - + + - + - - + + - - - + + + - - - + + + - + - - + + - + - + - - - - - - + + + + + + - + - + - - + + - - - + + + - + - - - - + + + + - + - - + + - + - - - + + + - - + + - + - + - - + + - + - - + + - - - - - - + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVfModuleFromVnf.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVfModuleFromVnf.bpmn index 918964f8f8..2dcf79ec8b 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVfModuleFromVnf.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVfModuleFromVnf.bpmn @@ -1,5 +1,5 @@ - + @@ -19,22 +19,22 @@ SequenceFlow_0kx9e3s SequenceFlow_4 - import org.onap.so.bpmn.infrastructure.scripts.* def ddvmfv = new DoDeleteVfModuleFromVnf() -ddvmfv.prepVNFAdapterRequest(execution)]]> +ddvmfv.prepVNFAdapterRequest(execution) SequenceFlow_0ltm4jt SequenceFlow_32 - import org.onap.so.bpmn.infrastructure.scripts.* def ddvmfv = new DoDeleteVfModuleFromVnf() -ddvmfv.preProcessSDNCUnassignRequest(execution)]]> +ddvmfv.preProcessSDNCUnassignRequest(execution) - + - + @@ -48,33 +48,33 @@ ddvmfv.preProcessSDNCUnassignRequest(execution)]]> SequenceFlow_33 SequenceFlow_2 - import org.onap.so.bpmn.infrastructure.scripts.* def ddvmfv = new DoDeleteVfModuleFromVnf() String response = execution.getVariable("DDVMFV_deactivateSDNCAdapterResponse") -ddvmfv.validateSDNCResponse(execution, response, "unassign")]]> +ddvmfv.validateSDNCResponse(execution, response, "unassign") SequenceFlow_1 SequenceFlow_0qbjihn - import org.onap.so.bpmn.infrastructure.scripts.* def ddvmfv = new DoDeleteVfModuleFromVnf() -ddvmfv.preProcessRequest(execution)]]> +ddvmfv.preProcessRequest(execution) SequenceFlow_0coa90m SequenceFlow_0ltm4jt - import org.onap.so.bpmn.infrastructure.scripts.* def ddvmfv = new DoDeleteVfModuleFromVnf() -ddvmfv.deleteNetworkPoliciesFromAAI(execution)]]> +ddvmfv.deleteNetworkPoliciesFromAAI(execution) SequenceFlow_0hia88a SequenceFlow_0coa90m - import org.onap.so.bpmn.infrastructure.scripts.* def ddvmfv = new DoDeleteVfModuleFromVnf() -ddvmfv.postProcessVNFAdapterRequest(execution)]]> +ddvmfv.postProcessVNFAdapterRequest(execution) @@ -88,9 +88,9 @@ ddvmfv.postProcessVNFAdapterRequest(execution)]]> SequenceFlow_1igsfgk SequenceFlow_0y4td40 - import org.onap.so.bpmn.infrastructure.scripts.* def ddvmfv = new DoDeleteVfModuleFromVnf() -ddvmfv.preProcessSDNCDeactivateRequest(execution)]]> +ddvmfv.preProcessSDNCDeactivateRequest(execution) @@ -108,27 +108,27 @@ ddvmfv.preProcessSDNCDeactivateRequest(execution)]]> SequenceFlow_12q2r4i SequenceFlow_0kx9e3s - import org.onap.so.bpmn.infrastructure.scripts.* def ddvmfv = new DoDeleteVfModuleFromVnf() String response = execution.getVariable("DDVMFV_deactivateSDNCAdapterResponse") -ddvmfv.validateSDNCResponse(execution, response, "deactivate")]]> +ddvmfv.validateSDNCResponse(execution, response, "deactivate") SequenceFlow_0qbjihn SequenceFlow_1c2lvlc - import org.onap.so.bpmn.infrastructure.scripts.* def ddvmfv = new DoDeleteVfModuleFromVnf() -ddvmfv.queryAAIForVfModule(execution)]]> +ddvmfv.queryAAIForVfModule(execution) SequenceFlow_1c2lvlc SequenceFlow_1igsfgk - import org.onap.so.bpmn.infrastructure.scripts.* def ddvmfv = new DoDeleteVfModuleFromVnf() -ddvmfv.validateVfModule(execution)]]> +ddvmfv.validateVfModule(execution) @@ -141,9 +141,9 @@ ddvmfv.validateVfModule(execution)]]> SequenceFlow_095634c SequenceFlow_0yvjvhu - import org.onap.so.bpmn.common.scripts.* ExceptionUtil ex = new ExceptionUtil() -ex.processJavaException(execution)]]> +ex.processJavaException(execution) @@ -161,9 +161,9 @@ ex.processJavaException(execution)]]> SequenceFlow_2 SequenceFlow_092kvy3 - import org.onap.so.bpmn.infrastructure.scripts.* def ddvmfv = new DoDeleteVfModuleFromVnf() -ddvmfv.prepDeleteAAIVfModule(execution)]]> +ddvmfv.prepDeleteAAIVfModule(execution) @@ -174,218 +174,218 @@ ddvmfv.prepDeleteAAIVfModule(execution)]]> - + - - + + - + - + - + - + - - + + - - + + - + - - - + + + - + - - - - + + + + - + - + - - + + - + - - - - + + + + - - + + - - + + - - - - - - + + + + + + - - - - - - + + + + + + - + - + - + - - + + - - + + - + - - - - - - + + + + + + - + - + - + - + - + - - + + - - + + - + - + - - + + - - + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVfModuleVolumeV2.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVfModuleVolumeV2.bpmn index e7706c20e6..6a44a117c1 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVfModuleVolumeV2.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVfModuleVolumeV2.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_1gvfdp4 @@ -7,27 +7,27 @@ SequenceFlow_1vy2ojp SequenceFlow_1dlcqmc - import org.onap.so.bpmn.infrastructure.scripts.* def delVfModuleVol = new DoDeleteVfModuleVolumeV2() -delVfModuleVol.executeMethod('callRESTQueryAAICloudRegion', execution, isDebugLogEnabled)]]> +delVfModuleVol.executeMethod('callRESTQueryAAICloudRegion', execution, isDebugLogEnabled) SequenceFlow_1dlcqmc SequenceFlow_1kjccf1 - import org.onap.so.bpmn.infrastructure.scripts.* def deleteVfMod = new DoDeleteVfModuleVolumeV2() -deleteVfMod.executeMethod('callRESTQueryAAIForVolumeGroup', execution, isDebugLogEnabled)]]> +deleteVfMod.executeMethod('callRESTQueryAAIForVolumeGroup', execution, isDebugLogEnabled) SequenceFlow_1kjccf1 SequenceFlow_1tgngf7 - import org.onap.so.bpmn.infrastructure.scripts.* def deleteVfMod = new DoDeleteVfModuleVolumeV2() -deleteVfMod.executeMethod('prepareVnfAdapterDeleteRequest', execution, isDebugLogEnabled)]]> +deleteVfMod.executeMethod('prepareVnfAdapterDeleteRequest', execution, isDebugLogEnabled) - + - + @@ -40,9 +40,9 @@ deleteVfMod.executeMethod('prepareVnfAdapterDeleteRequest', execution, isDebugLo SequenceFlow_04zsr0f SequenceFlow_13c3cv2 - import org.onap.so.bpmn.infrastructure.scripts.* def deleteVfMod = new DoDeleteVfModuleVolumeV2() -deleteVfMod.executeMethod('callRESTDeleteAAIVolumeGroup', execution, isDebugLogEnabled)]]> +deleteVfMod.executeMethod('callRESTDeleteAAIVolumeGroup', execution, isDebugLogEnabled) SequenceFlow_1sgtwr2 @@ -53,19 +53,19 @@ deleteVfMod.executeMethod('callRESTDeleteAAIVolumeGroup', execution, isDebugLogE SequenceFlow_1gvfdp4 SequenceFlow_1vy2ojp - import org.onap.so.bpmn.infrastructure.scripts.* def deleteVfMod = new DoDeleteVfModuleVolumeV2() deleteVfMod.executeMethod('preProcessRequest', execution, isDebugLogEnabled) -]]> + SequenceFlow_13c3cv2 SequenceFlow_1sgtwr2 - import org.onap.so.bpmn.infrastructure.scripts.* def deleteVfMod = new DoDeleteVfModuleVolumeV2() -deleteVfMod.executeMethod('postProcess', execution, isDebugLogEnabled)]]> +deleteVfMod.executeMethod('postProcess', execution, isDebugLogEnabled) @@ -102,22 +102,22 @@ deleteVfMod.executeMethod('postProcess', execution, isDebugLogEnabled)]]> - - + + - - + + - - + + @@ -126,15 +126,15 @@ deleteVfMod.executeMethod('postProcess', execution, isDebugLogEnabled)]]> - - + + - - + + @@ -143,22 +143,22 @@ deleteVfMod.executeMethod('postProcess', execution, isDebugLogEnabled)]]> - - + + - - + + - - + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateNetworkInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateNetworkInstance.bpmn index b82b1da951..ede63eafac 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateNetworkInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateNetworkInstance.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_1 @@ -8,18 +8,18 @@ SequenceFlow_32 SequenceFlow_11 - import org.onap.so.bpmn.infrastructure.scripts.* def DoUpdateNetworkInstance = new DoUpdateNetworkInstance() DoUpdateNetworkInstance.prepareSDNCRequest(execution) -]]> + SequenceFlow_12 SequenceFlow_5 - import org.onap.so.bpmn.infrastructure.scripts.* def DoUpdateNetworkInstance = new DoUpdateNetworkInstance() -DoUpdateNetworkInstance.validateSDNCResponse(execution)]]> +DoUpdateNetworkInstance.validateSDNCResponse(execution) SequenceFlow_5 @@ -28,7 +28,7 @@ DoUpdateNetworkInstance.validateSDNCResponse(execution)]]> - + #{execution.getVariable("UPDNETI_sdncResponseSuccess" ) == true} @@ -59,9 +59,9 @@ DoUpdateNetworkInstance.validateSDNCResponse(execution)]]> SequenceFlow_46 SequenceFlow_29 - import org.onap.so.bpmn.infrastructure.scripts.* def DoUpdateNetworkInstance = new DoUpdateNetworkInstance() -DoUpdateNetworkInstance.postProcessResponse(execution)]]> +DoUpdateNetworkInstance.postProcessResponse(execution) @@ -71,7 +71,7 @@ DoUpdateNetworkInstance.postProcessResponse(execution)]]> isRollbackOn_NoNetwork_SequenceFlow - + #{execution.getVariable("UPDNETI_rollbackEnabled") == true} @@ -85,7 +85,7 @@ DoUpdateNetworkInstance.postProcessResponse(execution)]]> isPONR_No_SequenceFlow - + #{execution.getVariable("UPDNETI_isPONR") == true} @@ -94,15 +94,15 @@ DoUpdateNetworkInstance.postProcessResponse(execution)]]> sdncOk_No_ExclusiveGateway - + #{execution.getVariable("UPDNETI_isSdncRollbackNeeded" ) == true} sdncOk_Yeso_ExclusiveGateway SequenceFlow_53 - import org.onap.so.bpmn.infrastructure.scripts.* def DoUpdateNetworkInstance = new DoUpdateNetworkInstance() -DoUpdateNetworkInstance.prepareSDNCRollbackRequest(execution)]]> +DoUpdateNetworkInstance.prepareSDNCRollbackRequest(execution) @@ -117,37 +117,17 @@ DoUpdateNetworkInstance.prepareSDNCRollbackRequest(execution)]]> SequenceFlow_47 - SequenceFlow_0qr4es6 - import org.onap.so.bpmn.infrastructure.scripts.* def DoUpdateNetworkInstance = new DoUpdateNetworkInstance() -DoUpdateNetworkInstance.prepareRollbackData(execution)]]> +DoUpdateNetworkInstance.prepareRollbackData(execution) - - - - - - - - - - - - - - - - - SequenceFlow_0qr4es6 - SequenceFlow_0ze5k6c SequenceFlow_04rdjfi - import org.onap.so.bpmn.infrastructure.scripts.* def DoUpdateNetworkInstance = new DoUpdateNetworkInstance() -DoUpdateNetworkInstance.postProcessResponse(execution)]]> +DoUpdateNetworkInstance.postProcessResponse(execution) - SequenceFlow_0nrc66n @@ -155,14 +135,14 @@ DoUpdateNetworkInstance.postProcessResponse(execution)]]> - + #{execution.getVariable("sdncVersion") != '1610'} SequenceFlow_23 SequenceFlow_053re4q - import org.onap.so.bpmn.infrastructure.scripts.* def DoUpdateNetworkInstance = new DoUpdateNetworkInstance() -DoUpdateNetworkInstance.setExceptionFlag(execution)]]> +DoUpdateNetworkInstance.setExceptionFlag(execution) @@ -172,24 +152,21 @@ DoUpdateNetworkInstance.setExceptionFlag(execution)]]> SequenceFlow_0ze5k6c - Note: Rollback is not needed for UpdateNetwork, - - - SequenceFlow_13 + Flow_1eutzkj SequenceFlow_35 - import org.onap.so.bpmn.infrastructure.scripts.* def DoUpdateNetworkInstance = new DoUpdateNetworkInstance() -DoUpdateNetworkInstance.callRESTReQueryAAINetworkId(execution)]]> +DoUpdateNetworkInstance.callRESTReQueryAAINetworkId(execution) SequenceFlow_35 SequenceFlow_46 - import org.onap.so.bpmn.infrastructure.scripts.* def DoUpdateNetworkInstance = new DoUpdateNetworkInstance() -DoUpdateNetworkInstance.callRESTUpdateContrailAAINetwork(execution)]]> +DoUpdateNetworkInstance.callRESTUpdateContrailAAINetwork(execution) @@ -199,9 +176,9 @@ DoUpdateNetworkInstance.callRESTUpdateContrailAAINetwork(execution)]]> SequenceFlow_10 SequenceFlow_14 - import org.onap.so.bpmn.infrastructure.scripts.* def DoUpdateNetworkInstance = new DoUpdateNetworkInstance() -DoUpdateNetworkInstance.processJavaException(execution)]]> +DoUpdateNetworkInstance.processJavaException(execution) @@ -216,570 +193,518 @@ DoUpdateNetworkInstance.processJavaException(execution)]]> SequenceFlow_1 SequenceFlow_7 - import org.onap.so.bpmn.infrastructure.scripts.* def DoUpdateNetworkInstance = new DoUpdateNetworkInstance() DoUpdateNetworkInstance.preProcessRequest(execution) -]]> + SequenceFlow_24 SequenceFlow_32 - import org.onap.so.bpmn.infrastructure.scripts.* def DoUpdateNetworkInstance = new DoUpdateNetworkInstance() -DoUpdateNetworkInstance.callRESTQueryAAICloudRegion(execution)]]> +DoUpdateNetworkInstance.callRESTQueryAAICloudRegion(execution) SequenceFlow_3 SequenceFlow_24 - import org.onap.so.bpmn.infrastructure.scripts.* def DoUpdateNetworkInstance = new DoUpdateNetworkInstance() -DoUpdateNetworkInstance.callRESTQueryAAINetworkId(execution)]]> +DoUpdateNetworkInstance.callRESTQueryAAINetworkId(execution) - - SequenceFlow_59 - SequenceFlow_13 - - - - - - - - ${UPDNETI_updateNetworkRequest} - - - - #{BasicAuthHeaderValuePO} - application/xml - - - PUT - ${statusCode} - ${response} - - http-connector - - - SequenceFlow_61 - SequenceFlow_59 - - SequenceFlow_2 SequenceFlow_61 - import org.onap.so.bpmn.infrastructure.scripts.* def DoUpdateNetworkInstance = new DoUpdateNetworkInstance() DoUpdateNetworkInstance.prepareUpdateNetworkRequest(execution) -]]> + - + SequenceFlow_38 SequenceFlow_2 - import org.onap.so.bpmn.infrastructure.scripts.* def DoUpdateNetworkInstance = new DoUpdateNetworkInstance() -DoUpdateNetworkInstance.callRESTQueryAAINetworkTableRef(execution)]]> +DoUpdateNetworkInstance.callRESTQueryAAINetworkTableRef(execution) sdncTopoYes_SequenceFlow SequenceFlow_6 - import org.onap.so.bpmn.infrastructure.scripts.* def DoUpdateNetworkInstance = new DoUpdateNetworkInstance() -DoUpdateNetworkInstance.callRESTReQueryAAINetworkId(execution)]]> +DoUpdateNetworkInstance.callRESTReQueryAAINetworkId(execution) SequenceFlow_6 SequenceFlow_15 - import org.onap.so.bpmn.infrastructure.scripts.* def DoUpdateNetworkInstance = new DoUpdateNetworkInstance() -DoUpdateNetworkInstance.callRESTQueryAAINetworkVpnBinding(execution)]]> +DoUpdateNetworkInstance.callRESTQueryAAINetworkVpnBinding(execution) SequenceFlow_15 SequenceFlow_38 - import org.onap.so.bpmn.infrastructure.scripts.* def DoUpdateNetworkInstance = new DoUpdateNetworkInstance() -DoUpdateNetworkInstance.callRESTQueryAAINetworkPolicy(execution)]]> +DoUpdateNetworkInstance.callRESTQueryAAINetworkPolicy(execution) SequenceFlow_7 SequenceFlow_3 - import org.onap.so.bpmn.infrastructure.scripts.* def DoUpdateNetworkInstance = new DoUpdateNetworkInstance() -DoUpdateNetworkInstance.getServiceInstance(execution)]]> +DoUpdateNetworkInstance.getServiceInstance(execution) + + + + + + + SequenceFlow_61 + Flow_1eutzkj + + - + - + - + - - + + - - - - - - - + - + - + - + - + - + - - + + - + - - - + + + - + - + - + - + - + - - + + - - + + - - + + - - - - + + + + - + - - + + - - + + - + - + - + - - + + - - + + - + - + - - + + - - - - - - - - + - - - + + + - + - + - - + + - + - - - + + + - + - + - - + + - + - + - + - - - - + + + + - + - - - - + + + + - + - + - + - - + + - + - - - + + + - + - + - + - + - - + + - + - - - + + + - + - - + + - - + + - - - - - - - - - - + - + - + - + - - + + - - + + - - - - - - - + + + + + + + - - + + - + - - + + - + - - - - + + + + - - - - + - + - - - - - - - - - + + + + - + - + - - + + - + - - - + + + - + - + - - + + - + - - - + + - - - - - - - - + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateNetworkInstanceRollback.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateNetworkInstanceRollback.bpmn deleted file mode 100644 index 9d37d8084e..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateNetworkInstanceRollback.bpmn +++ /dev/null @@ -1,374 +0,0 @@ - - - - - SequenceFlow_1krl2dg - - - SequenceFlow_1krl2dg - SequenceFlow_0u41iz2 - - - - - - - - - ${UPDNETIR_rollbackNetworkRequest} - - - - #{BasicAuthHeaderValuePO} - application/xml - - - PUT - ${statusCode} - ${response} - - http-connector - - - SequenceFlow_0e1uixp - SequenceFlow_17o4w67 - - - SequenceFlow_0u41iz2 - SequenceFlow_0e1uixp - SequenceFlow_1lteduj - - - - - - - - - - - - SequenceFlow_101y57s - SequenceFlow_0790olb - - - SequenceFlow_0virkpu - SequenceFlow_101y57s - SequenceFlow_0mw0dgd - - - SequenceFlow_0qc4v9t - SequenceFlow_0el8yzs - SequenceFlow_0yto4gz - - - - SequenceFlow_1lteduj - SequenceFlow_17o4w67 - SequenceFlow_0virkpu - SequenceFlow_0qc4v9t - - - - - - - - - - - - - - - SequenceFlow_0yto4gz - - - - - - SequenceFlow_0xktw7v - SequenceFlow_0soe5t3 - - - - SequenceFlow_0xktw7v - - - - SequenceFlow_0soe5t3 - - - - - - SequenceFlow_0790olb - SequenceFlow_0mw0dgd - SequenceFlow_0el8yzs - - - - - - SequenceFlow_07kf49j - SequenceFlow_01syg1x - - - - SequenceFlow_07kf49j - - - - SequenceFlow_01syg1x - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateVfModule.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateVfModule.bpmn index cfda2ad73c..d423ae5cba 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateVfModule.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateVfModule.bpmn @@ -1,13 +1,13 @@ - + - + This flow expects its incoming request to be in the variable 'DoUpdateVfModuleRequest'. This flow produces no output. SequenceFlow_38 SequenceFlow_2 - import org.onap.so.bpmn.infrastructure.scripts.* def duvm = new DoUpdateVfModule() -duvm.prepPrepareUpdateAAIVfModule(execution)]]> +duvm.prepPrepareUpdateAAIVfModule(execution) @@ -26,18 +26,18 @@ duvm.prepPrepareUpdateAAIVfModule(execution)]]> SequenceFlow_1 SequenceFlow_38 - import org.onap.so.bpmn.infrastructure.scripts.* def duvm = new DoUpdateVfModule() -duvm.preProcessRequest(execution)]]> +duvm.preProcessRequest(execution) SequenceFlow_6 SequenceFlow_35 - import org.onap.so.bpmn.infrastructure.scripts.* def duvm = new DoUpdateVfModule() -duvm.handleWorkflowException(execution)]]> +duvm.handleWorkflowException(execution) SequenceFlow_35 @@ -63,9 +63,9 @@ duvm.handleWorkflowException(execution)]]> SequenceFlow_9 SequenceFlow_18 SequenceFlow_25 - import org.onap.so.bpmn.infrastructure.scripts.* def duvm = new DoUpdateVfModule() -duvm.prepUpdateAAIVfModule(execution)]]> +duvm.prepUpdateAAIVfModule(execution) @@ -83,9 +83,9 @@ duvm.prepUpdateAAIVfModule(execution)]]> SequenceFlow_26 SequenceFlow_27 - import org.onap.so.bpmn.infrastructure.scripts.* def duvm = new DoUpdateVfModule() -duvm.prepSDNCTopologyAct(execution)]]> +duvm.prepSDNCTopologyAct(execution) @@ -104,9 +104,9 @@ duvm.prepSDNCTopologyAct(execution)]]> SequenceFlow_24 SequenceFlow_13 - import org.onap.so.bpmn.infrastructure.scripts.* def duvm = new DoUpdateVfModule() -duvm.prepUpdateAAIGenericVnf(execution)]]> +duvm.prepUpdateAAIGenericVnf(execution) @@ -128,7 +128,7 @@ duvm.prepUpdateAAIGenericVnf(execution)]]> - + ${execution.getVariable('DOUPVfMod_skipUpdateGenericVnf')} == true SequenceFlow_1 @@ -138,9 +138,9 @@ duvm.prepUpdateAAIGenericVnf(execution)]]> SequenceFlow_16 SequenceFlow_17 SequenceFlow_12 - import org.onap.so.bpmn.infrastructure.scripts.* def duvm = new DoUpdateVfModule() -duvm.prepSDNCTopologyChg(execution)]]> +duvm.prepSDNCTopologyChg(execution) @@ -156,9 +156,9 @@ duvm.prepSDNCTopologyChg(execution)]]> SequenceFlow_12 SequenceFlow_3 - + - + @@ -171,18 +171,18 @@ duvm.prepSDNCTopologyChg(execution)]]> SequenceFlow_23 SequenceFlow_21 - import org.onap.so.bpmn.infrastructure.scripts.* def duvm = new DoUpdateVfModule() -duvm.prepVnfAdapterRest(execution)]]> +duvm.prepVnfAdapterRest(execution) SequenceFlow_22 SequenceFlow_23 - import org.onap.so.bpmn.infrastructure.scripts.* String response = execution.getVariable("DOUPVfMod_sdncTopologyResponse") def duvm = new DoUpdateVfModule() -duvm.validateSDNCResponse(execution, response, "query")]]> +duvm.validateSDNCResponse(execution, response, "query") @@ -200,19 +200,19 @@ duvm.validateSDNCResponse(execution, response, "query")]]> SequenceFlow_3 SequenceFlow_5 - import org.onap.so.bpmn.infrastructure.scripts.* String response = execution.getVariable("DOUPVfMod_sdncChangeAssignResponse") def duvm = new DoUpdateVfModule() -duvm.validateSDNCResponse(execution, response, "changeassign")]]> +duvm.validateSDNCResponse(execution, response, "changeassign") SequenceFlow_5 SequenceFlow_19 - import org.onap.so.bpmn.infrastructure.scripts.* def duvm = new DoUpdateVfModule() -duvm.prepSDNCTopologyQuery(execution)]]> +duvm.prepSDNCTopologyQuery(execution) @@ -241,9 +241,9 @@ duvm.prepSDNCTopologyQuery(execution)]]> SequenceFlow_10 SequenceFlow_11 - import org.onap.so.bpmn.infrastructure.scripts.* def duvm = new DoUpdateVfModule() -duvm.prepConfirmVolumeGroupTenant(execution)]]> +duvm.prepConfirmVolumeGroupTenant(execution) @@ -252,18 +252,18 @@ duvm.prepConfirmVolumeGroupTenant(execution)]]> SequenceFlow_16 - + ${execution.getVariable('DOUPVfMod_volumeGroupId').isEmpty()} == false - + execution.getVariable("DOUPVfMod_isBaseVfModule") == "true" SequenceFlow_30 SequenceFlow_34 - import org.onap.so.bpmn.infrastructure.scripts.* def doUpdateVfModule = new DoUpdateVfModule() -doUpdateVfModule.queryAAIVfModule(execution)]]> +doUpdateVfModule.queryAAIVfModule(execution) @@ -277,16 +277,16 @@ doUpdateVfModule.queryAAIVfModule(execution)]]> SequenceFlow_7 SequenceFlow_20 - import org.onap.so.bpmn.infrastructure.scripts.* String response = execution.getVariable("DOUPVfMod_sdncActivateResponse") def duvm = new DoUpdateVfModule() -duvm.validateSDNCResponse(execution, response, "activate")]]> +duvm.validateSDNCResponse(execution, response, "activate") SequenceFlow_20 SequenceFlow_4 - + // This variable is checked by the unit test +execution.setVariable('DoUpdateVfModuleSuccessIndicator', true) @@ -299,369 +299,369 @@ execution.setVariable('DoUpdateVfModuleSuccessIndicator', true)]]> - + - + - + - - + + - + - - + + - + - - + + - + - + - + - - - - + + + + - + - + - - + + - + - + - + - - + + - - - - + + + + - + - - - - - + + + + + - + - - + + - + - + - - + + - + - + - - - - + + + + - - + + - + - + - - + + - - + + - + - + - + - + - + - - + + - + - + - - + + - + - - + + - + - - + + - + - + - - + + - - - - + + + + - + - + - - + + - + - - - + + + - + - + - + - - + + - - + + - - + + - - + + - + - + - + - + - - - - + + + + - - + + - + - - + + - - - + + + - + - - - - + + + + - + - - + + - - + + diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasks.java index 0ec28d901c..fb5c81a52e 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasks.java @@ -63,7 +63,7 @@ public class NetworkAdapterCreateTasks { gBBInput.getRequestContext(), gBBInput.getCloudRegion(), gBBInput.getOrchContext(), serviceInstance, l3Network, userInput, cloudRegionPo, gBBInput.getCustomer()); - execution.setVariable("networkAdapterRequest", createNetworkRequest); + execution.setVariable("networkAdapterRequest", createNetworkRequest.toXmlString()); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -81,13 +81,14 @@ public class NetworkAdapterCreateTasks { execution.setVariable("networkAdapterCreateRollback", true); } } else { - throw new Exception("No response was sent back from NetworkAdapterRestV1 subflow."); + throw new Exception("No response was sent back from NetworkAdapter subflow."); } } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + // TODO is this even used anywhere? public void rollbackCreateNetwork(BuildingBlockExecution execution) { try { GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasks.java index 7a7d681762..df5e7d2b34 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasks.java @@ -53,7 +53,7 @@ public class NetworkAdapterDeleteTasks { DeleteNetworkRequest deleteNetworkRequest = networkAdapterObjectMapper.deleteNetworkRequestMapper( gBBInput.getRequestContext(), gBBInput.getCloudRegion(), serviceInstance, l3Network); - execution.setVariable("networkAdapterRequest", deleteNetworkRequest); + execution.setVariable("networkAdapterRequest", deleteNetworkRequest.toXmlString()); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterImpl.java new file mode 100644 index 0000000000..5a84910a29 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterImpl.java @@ -0,0 +1,103 @@ +package org.onap.so.bpmn.infrastructure.adapter.network.tasks; + +import java.io.ByteArrayInputStream; +import java.io.StringReader; +import java.util.Optional; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.adapters.nwrest.CreateNetworkError; +import org.onap.so.adapters.nwrest.CreateNetworkRequest; +import org.onap.so.adapters.nwrest.CreateNetworkResponse; +import org.onap.so.adapters.nwrest.DeleteNetworkError; +import org.onap.so.adapters.nwrest.DeleteNetworkRequest; +import org.onap.so.adapters.nwrest.DeleteNetworkResponse; +import org.onap.so.adapters.nwrest.UpdateNetworkError; +import org.onap.so.adapters.nwrest.UpdateNetworkRequest; +import org.onap.so.adapters.nwrest.UpdateNetworkResponse; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.utils.Components; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class NetworkAdapterImpl { + + private static final Logger logger = LoggerFactory.getLogger(NetworkAdapterImpl.class); + + @Autowired + private ExtractPojosForBB extractPojosForBB; + + @Autowired + private ExceptionBuilder exceptionUtil; + + public void preProcessNetworkAdapter(BuildingBlockExecution execution) { + try { + GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); + ServiceInstance serviceInstance = + extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); + execution.setVariable("mso-request-id", gBBInput.getRequestContext().getMsoRequestId()); + execution.setVariable("mso-service-instance-id", serviceInstance.getServiceInstanceId()); + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + + public void postProcessNetworkAdapter(BuildingBlockExecution execution) { + try { + String workflowResponse = (String) execution.getVariable("WorkflowResponse"); + if (workflowResponse != null) { + Optional responseType = findResponseType(workflowResponse); + if ("createNetworkResponse".equals(responseType.get())) { + CreateNetworkResponse createNetworkResponse = + (CreateNetworkResponse) unmarshalXml(workflowResponse, CreateNetworkResponse.class); + execution.setVariable("createNetworkResponse", createNetworkResponse); + } else if ("deleteNetworkResponse".equals(responseType.get())) { + DeleteNetworkResponse deleteNetworkResponse = + (DeleteNetworkResponse) unmarshalXml(workflowResponse, DeleteNetworkResponse.class); + execution.setVariable("deleteNetworkResponse", deleteNetworkResponse); + } else if ("updateNetworkResponse".equals(responseType.get())) { + UpdateNetworkResponse updateNetworkResponse = + (UpdateNetworkResponse) unmarshalXml(workflowResponse, UpdateNetworkResponse.class); + execution.setVariable("updateNetworkResponse", updateNetworkResponse); + } else { + logger.warn("Unable to determine network response type"); + } + } + } catch (Exception e) { + logger.error("Error Network Adapter post process", e); + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e.getMessage(), Components.OPENSTACK); + } + } + + protected Object unmarshalXml(String xmlString, Class resultClass) throws JAXBException { + StringReader reader = new StringReader(xmlString); + JAXBContext context = JAXBContext.newInstance(resultClass); + Unmarshaller unmarshaller = context.createUnmarshaller(); + return unmarshaller.unmarshal(reader); + } + + protected Optional findResponseType(String xmlString) { + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + org.w3c.dom.Document doc; + doc = builder.parse(new ByteArrayInputStream(xmlString.getBytes("UTF-8"))); + return Optional.of(doc.getDocumentElement().getNodeName()); + } catch (Exception e) { + logger.error("Error Finding Response Type", e); + return Optional.empty(); + } + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1.java deleted file mode 100644 index 2705d00d6b..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1.java +++ /dev/null @@ -1,166 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2019 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.adapter.network.tasks; - -import java.io.StringReader; -import java.util.Optional; -import javax.ws.rs.core.Response; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.onap.so.adapters.nwrest.CreateNetworkError; -import org.onap.so.adapters.nwrest.CreateNetworkRequest; -import org.onap.so.adapters.nwrest.CreateNetworkResponse; -import org.onap.so.adapters.nwrest.DeleteNetworkError; -import org.onap.so.adapters.nwrest.DeleteNetworkRequest; -import org.onap.so.adapters.nwrest.DeleteNetworkResponse; -import org.onap.so.adapters.nwrest.UpdateNetworkError; -import org.onap.so.adapters.nwrest.UpdateNetworkRequest; -import org.onap.so.adapters.nwrest.UpdateNetworkResponse; -import org.onap.so.client.exception.ExceptionBuilder; -import org.onap.so.client.orchestration.NetworkAdapterResources; -import org.onap.logging.filter.base.ONAPComponents; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.onap.so.utils.Components; - -@Component -public class NetworkAdapterRestV1 { - - private static final Logger logger = LoggerFactory.getLogger(NetworkAdapterRestV1.class); - - private static final String NETWORK_REQUEST = "networkAdapterRequest"; - private static final String NETWORK_MESSAGE = "NetworkAResponse_MESSAGE"; - private static final String NETWORK_SYNC_CODE = "NETWORKREST_networkAdapterStatusCode"; - private static final String NETWORK_SYNC_RESPONSE = "NETWORKREST_networkAdapterResponse"; - private static final String NETWORK_CORRELATOR = "NetworkAResponse_CORRELATOR"; - - @Autowired - private ExceptionBuilder exceptionBuilder; - - @Autowired - private NetworkAdapterResources networkAdapterResources; - - public void callNetworkAdapter(DelegateExecution execution) { - try { - Object networkAdapterRequest = execution.getVariable(NETWORK_REQUEST); - if (networkAdapterRequest != null) { - Optional response = Optional.empty(); - if (networkAdapterRequest instanceof CreateNetworkRequest) { - CreateNetworkRequest createNetworkRequest = (CreateNetworkRequest) networkAdapterRequest; - execution.setVariable(NETWORK_CORRELATOR, createNetworkRequest.getMessageId()); - response = networkAdapterResources.createNetworkAsync(createNetworkRequest); - } else if (networkAdapterRequest instanceof DeleteNetworkRequest) { - DeleteNetworkRequest deleteNetworkRequest = (DeleteNetworkRequest) networkAdapterRequest; - execution.setVariable(NETWORK_CORRELATOR, deleteNetworkRequest.getMessageId()); - response = networkAdapterResources.deleteNetworkAsync(deleteNetworkRequest); - } else if (networkAdapterRequest instanceof UpdateNetworkRequest) { - UpdateNetworkRequest updateNetworkRequest = (UpdateNetworkRequest) networkAdapterRequest; - execution.setVariable(NETWORK_CORRELATOR, updateNetworkRequest.getMessageId()); - response = networkAdapterResources.updateNetworkAsync(updateNetworkRequest); - } - if (response.isPresent()) { - String statusCode = Integer.toString(response.get().getStatus()); - String responseString = ""; - if (response.get().getEntity() != null) { - responseString = (String) response.get().getEntity(); - } - execution.setVariable(NETWORK_SYNC_CODE, statusCode); - execution.setVariable(NETWORK_SYNC_RESPONSE, responseString); - } else { - throw new Exception("No Ack response from Openstack Adapter"); - } - } else { - throw new Exception("No Network Request was created. networkAdapterRequest was null."); - } - } catch (Exception ex) { - exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, ex, ONAPComponents.SO); - } - } - - public void processCallback(DelegateExecution execution) { - try { - Object networkAdapterRequest = execution.getVariable(NETWORK_REQUEST); - String callback = (String) execution.getVariable(NETWORK_MESSAGE); - String logCallbackMessage = "Callback from OpenstackAdapter: " + callback; - logger.debug(logCallbackMessage); - if (networkAdapterRequest != null) { - if (networkAdapterRequest instanceof CreateNetworkRequest) { - if (callback.contains("createNetworkError")) { - CreateNetworkError createNetworkError = - (CreateNetworkError) unmarshalXml(callback, CreateNetworkError.class); - throw new Exception(createNetworkError.getMessage()); - } else { - CreateNetworkResponse createNetworkResponse = - (CreateNetworkResponse) unmarshalXml(callback, CreateNetworkResponse.class); - execution.setVariable("createNetworkResponse", createNetworkResponse); - } - } else if (networkAdapterRequest instanceof DeleteNetworkRequest) { - if (callback.contains("deleteNetworkError")) { - DeleteNetworkError deleteNetworkError = - (DeleteNetworkError) unmarshalXml(callback, DeleteNetworkError.class); - throw new Exception(deleteNetworkError.getMessage()); - } else { - DeleteNetworkResponse deleteNetworkResponse = - (DeleteNetworkResponse) unmarshalXml(callback, DeleteNetworkResponse.class); - execution.setVariable("deleteNetworkResponse", deleteNetworkResponse); - } - } else if (networkAdapterRequest instanceof UpdateNetworkRequest) { - if (callback.contains("updateNetworkError")) { - UpdateNetworkError updateNetworkError = - (UpdateNetworkError) unmarshalXml(callback, UpdateNetworkError.class); - throw new Exception(updateNetworkError.getMessage()); - } else { - UpdateNetworkResponse updateNetworkResponse = - (UpdateNetworkResponse) unmarshalXml(callback, UpdateNetworkResponse.class); - execution.setVariable("updateNetworkResponse", updateNetworkResponse); - } - } - } - } catch (Exception e) { - logger.error("Error in Openstack Adapter callback", e); - exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e.getMessage(), Components.OPENSTACK); - } - } - - protected Object unmarshalXml(String xmlString, Class resultClass) throws JAXBException { - StringReader reader = new StringReader(xmlString); - JAXBContext context = JAXBContext.newInstance(resultClass); - Unmarshaller unmarshaller = context.createUnmarshaller(); - return unmarshaller.unmarshal(reader); - } - - public void handleTimeOutException(DelegateExecution execution) { - exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, - "Error timed out waiting on Openstack Async-Response", ONAPComponents.SO); - } - - public void handleSyncError(DelegateExecution execution) { - String statusCode = (String) execution.getVariable(NETWORK_SYNC_CODE); - String responseString = (String) execution.getVariable(NETWORK_SYNC_RESPONSE); - String errorMessage = "Error with Openstack Adapter Sync Request: StatusCode = " + statusCode + " Response = " - + responseString; - exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, errorMessage, Components.OPENSTACK); - } -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasks.java index e238a4fdd3..c64491f71a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasks.java @@ -55,7 +55,7 @@ public class NetworkAdapterUpdateTasks { UpdateNetworkRequest updateNetworkRequest = networkAdapterObjectMapper.createNetworkUpdateRequestMapper( gBBInput.getRequestContext(), gBBInput.getCloudRegion(), gBBInput.getOrchContext(), serviceInstance, l3Network, gBBInput.getUserInput(), gBBInput.getCustomer()); - execution.setVariable("networkAdapterRequest", updateNetworkRequest); + execution.setVariable("networkAdapterRequest", updateNetworkRequest.toXmlString()); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasksTest.java index 00dfd4e236..60bed17447 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasksTest.java @@ -89,7 +89,7 @@ public class NetworkAdapterCreateTasksTest extends BaseTaskTest { networkAdapterCreateTasks.createNetwork(execution); verify(networkAdapterObjectMapper, times(1)).createNetworkRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer); - assertEquals(createNetworkRequest, execution.getVariable("networkAdapterRequest")); + assertEquals(createNetworkRequest.toXmlString(), execution.getVariable("networkAdapterRequest")); } @Test diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterImplTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterImplTest.java new file mode 100644 index 0000000000..10cc09cdcc --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterImplTest.java @@ -0,0 +1,30 @@ +package org.onap.so.bpmn.infrastructure.adapter.network.tasks; + +import static com.shazam.shazamcrest.MatcherAssert.assertThat; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.junit.Assert.assertNotNull; +import javax.xml.bind.JAXBException; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.onap.so.FileUtil; +import org.onap.so.adapters.nwrest.CreateNetworkResponse; +import org.onap.so.bpmn.BaseTaskTest; + +public class NetworkAdapterImplTest extends BaseTaskTest { + + @InjectMocks + private NetworkAdapterImpl networkAdapterImpl = new NetworkAdapterImpl(); + + private static final String RESPONSE = + FileUtil.readResourceFile("__files/BuildingBlocks/Network/createNetworkResponse.xml"); + + @Test + public void postProcessNetworkAdapter() throws JAXBException { + execution.setVariable("WorkflowResponse", RESPONSE); + networkAdapterImpl.postProcessNetworkAdapter(execution); + assertNotNull(execution.getVariable("createNetworkResponse")); + assertThat(networkAdapterImpl.unmarshalXml(RESPONSE, CreateNetworkResponse.class), + sameBeanAs(execution.getVariable("createNetworkResponse"))); + } + +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java deleted file mode 100644 index 67ce6bfbe9..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java +++ /dev/null @@ -1,303 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2018 Nokia. - * ================================================================================ - * 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.adapter.network.tasks; - -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; -import javax.xml.bind.JAXBException; -import org.camunda.bpm.engine.delegate.BpmnError; -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; -import org.glassfish.jersey.message.internal.OutboundJaxrsResponse; -import org.glassfish.jersey.message.internal.OutboundMessageContext; -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.onap.so.adapters.nwrest.CreateNetworkRequest; -import org.onap.so.adapters.nwrest.CreateNetworkResponse; -import org.onap.so.adapters.nwrest.DeleteNetworkRequest; -import org.onap.so.adapters.nwrest.DeleteNetworkResponse; -import org.onap.so.adapters.nwrest.NetworkRequestCommon; -import org.onap.so.adapters.nwrest.UpdateNetworkError; -import org.onap.so.adapters.nwrest.UpdateNetworkRequest; -import org.onap.so.adapters.nwrest.UpdateNetworkResponse; -import org.onap.so.client.exception.ExceptionBuilder; -import org.onap.so.client.orchestration.NetworkAdapterResources; -import org.onap.so.utils.Components; -import org.onap.logging.filter.base.ONAPComponents; -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.ArgumentMatchers.eq; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; -import static org.mockito.Mockito.when; -import static org.mockito.MockitoAnnotations.initMocks; - -public class NetworkAdapterRestV1Test { - - @Mock - private ExceptionBuilder exceptionBuilder; - @Mock - private NetworkAdapterResources networkAdapterResources; - @InjectMocks - private NetworkAdapterRestV1 networkAdapterRestV1Tasks; - - private DelegateExecution delegateExecution; - - private static final String CREATE_NETWORK_RESPONSE = "createNetworkResponse"; - private static final String DELETE_NETWORK_RESPONSE = "deleteNetworkResponse"; - private static final String CREATE_NETWORK_ERROR = "createNetworkError"; - private static final String DELETE_NETWORK_ERROR = "deleteNetworkError"; - private static final String NET_ID_FOR_CREATE_NETWORK_RESPONSE = "netIdForCreateNetworkResponse"; - private static final String NET_ID_FOR_DELETE_NETWORK_RESPONSE = "netIdForDeleteNetworkResponse"; - private static final String CREATE_NETWORK_ERROR_MESSAGE = "createNetErrorMessage"; - private static final String DELETE_NETWORK_ERROR_MESSAGE = "deleteNetErrorMessage"; - - @Before - public void setup() { - initMocks(this); - delegateExecution = new DelegateExecutionFake(); - } - - @Test - public void testUnmarshalXml() throws JAXBException { - String xml = - "ec37c121-e3ec-4697-8adf-2d7dca7044fctruesomeNetworkFqdn991ec7bf-c9c4-4ac1-bb9c-4b61645bddb3someStackId9c47521a-2916-4018-b2bc-71ab767497e3someCloudIdb7171cdd-8b05-459b-80ef-2093150e898390b32315-176e-4dab-bcf1-80eb97a1c4f471e7db22-7907-4d78-8fcc-8d89d28e90betruesomeStackIdSomeNetworkType9c47521a-2916-4018-b2bc-71ab767497e3b60da4f71c1d4b35b8113d4eca6deaa16b381fa9-48ce-4e16-9978-d75309565bb6bc1d5537-860b-4894-8eba-6faff41e648c"; - CreateNetworkResponse response = - (CreateNetworkResponse) new NetworkAdapterRestV1().unmarshalXml(xml, CreateNetworkResponse.class); - String returnedXml = response.toXmlString(); - System.out.println(returnedXml); - } - - @Test - public void testUnmarshalXmlUpdate() throws JAXBException { - UpdateNetworkResponse expectedResponse = new UpdateNetworkResponse(); - expectedResponse.setMessageId("ec100bcc-2659-4aa4-b4d8-3255715c2a51"); - expectedResponse.setNetworkId("80de31e3-cc78-4111-a9d3-5b92bf0a39eb"); - Map subnetMap = new HashMap<>(); - subnetMap.put("95cd8437-25f1-4238-8720-cbfe7fa81476", "d8d16606-5d01-4822-b160-9a0d257303e0"); - expectedResponse.setSubnetMap(subnetMap); - String xml = - "ec100bcc-2659-4aa4-b4d8-3255715c2a5180de31e3-cc78-4111-a9d3-5b92bf0a39eb95cd8437-25f1-4238-8720-cbfe7fa81476d8d16606-5d01-4822-b160-9a0d257303e0"; - UpdateNetworkResponse response = - (UpdateNetworkResponse) new NetworkAdapterRestV1().unmarshalXml(xml, UpdateNetworkResponse.class); - assertThat(expectedResponse, sameBeanAs(response)); - } - - @Test - public void processCallbackTest() { - UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest(); - UpdateNetworkResponse updateNetworkResponse = new UpdateNetworkResponse(); - updateNetworkResponse.setMessageId("messageId"); - updateNetworkResponse.setNetworkId("networkId"); - delegateExecution.setVariable("networkAdapterRequest", updateNetworkRequest); - delegateExecution.setVariable("NetworkAResponse_MESSAGE", updateNetworkResponse.toXmlString()); - - networkAdapterRestV1Tasks.processCallback(delegateExecution); - - assertThat(updateNetworkResponse, sameBeanAs(delegateExecution.getVariable("updateNetworkResponse"))); - } - - @Test - public void processCallbackErrorTest() { - UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest(); - UpdateNetworkError updateNetworkResponse = new UpdateNetworkError(); - updateNetworkResponse.setMessageId("messageId"); - updateNetworkResponse.setMessage("test error message"); - delegateExecution.setVariable("networkAdapterRequest", updateNetworkRequest); - delegateExecution.setVariable("NetworkAResponse_MESSAGE", updateNetworkResponse.toXmlString()); - - doThrow(new BpmnError("MSOWorkflowException")).when(exceptionBuilder).buildAndThrowWorkflowException( - any(DelegateExecution.class), anyInt(), any(String.class), any(ONAPComponents.class)); - - try { - networkAdapterRestV1Tasks.processCallback(delegateExecution); - } catch (BpmnError be) { - assertEquals("MSOWorkflowException", be.getErrorCode()); - } - assertNull(delegateExecution.getVariable("updateNetworkResponse")); - verify(exceptionBuilder, times(1)).buildAndThrowWorkflowException(any(DelegateExecution.class), eq(7000), - eq("test error message"), eq(Components.OPENSTACK)); - } - - @Test - public void processCallback_createNetworkResponse() { - delegateExecution.setVariable("networkAdapterRequest", new CreateNetworkRequest()); - delegateExecution.setVariable("NetworkAResponse_MESSAGE", - createNetworkResponse(CREATE_NETWORK_RESPONSE, NET_ID_FOR_CREATE_NETWORK_RESPONSE)); - networkAdapterRestV1Tasks.processCallback(delegateExecution); - - Object result = delegateExecution.getVariable("createNetworkResponse"); - assertTrue(result instanceof CreateNetworkResponse); - CreateNetworkResponse createNetworkResponse = (CreateNetworkResponse) result; - assertEquals(createNetworkResponse.getNetworkId(), NET_ID_FOR_CREATE_NETWORK_RESPONSE); - } - - @Test - public void processCallback_deleteNetworkResponse() { - delegateExecution.setVariable("networkAdapterRequest", new DeleteNetworkRequest()); - delegateExecution.setVariable("NetworkAResponse_MESSAGE", - createNetworkResponse(DELETE_NETWORK_RESPONSE, NET_ID_FOR_DELETE_NETWORK_RESPONSE)); - networkAdapterRestV1Tasks.processCallback(delegateExecution); - - Object result = delegateExecution.getVariable("deleteNetworkResponse"); - assertTrue(result instanceof DeleteNetworkResponse); - DeleteNetworkResponse deleteNetworkResponse = (DeleteNetworkResponse) result; - assertEquals(deleteNetworkResponse.getNetworkId(), NET_ID_FOR_DELETE_NETWORK_RESPONSE); - } - - @Test - public void processCallback_createNetworkError() { - try { - delegateExecution.setVariable("networkAdapterRequest", new CreateNetworkRequest()); - delegateExecution.setVariable("NetworkAResponse_MESSAGE", - createNetworkError(CREATE_NETWORK_ERROR, CREATE_NETWORK_ERROR_MESSAGE)); - networkAdapterRestV1Tasks.processCallback(delegateExecution); - } catch (Exception e) { - assertEquals(e.getMessage(), CREATE_NETWORK_ERROR_MESSAGE); - } - } - - @Test - public void processCallback_deleteNetworkError() { - try { - delegateExecution.setVariable("networkAdapterRequest", new DeleteNetworkRequest()); - delegateExecution.setVariable("NetworkAResponse_MESSAGE", - createNetworkError(DELETE_NETWORK_ERROR, DELETE_NETWORK_ERROR_MESSAGE)); - networkAdapterRestV1Tasks.processCallback(delegateExecution); - } catch (Exception e) { - assertEquals(e.getMessage(), DELETE_NETWORK_ERROR_MESSAGE); - } - } - - @Test - public void callNetworkAdapter_CreateNetworkRequestSuccess() throws Exception { - // given - String messageId = "createNetReqMessageId"; - CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest(); - createNetworkRequest.setMessageId(messageId); - delegateExecution.setVariable("networkAdapterRequest", createNetworkRequest); - Status status = Status.OK; - String responseEntity = "createNetworkResponse"; - Optional response = Optional.of(createResponse(status, responseEntity)); - when(networkAdapterResources.createNetworkAsync(createNetworkRequest)).thenReturn(response); - // when - networkAdapterRestV1Tasks.callNetworkAdapter(delegateExecution); - // then - verifyExecutionContent(status, responseEntity, messageId); - } - - @Test - public void callNetworkAdapter_DeleteNetworkRequestSuccess() throws Exception { - // given - String messageId = "DeleteNetReqMessageId"; - DeleteNetworkRequest deleteNetworkRequest = new DeleteNetworkRequest(); - deleteNetworkRequest.setMessageId(messageId); - delegateExecution.setVariable("networkAdapterRequest", deleteNetworkRequest); - Status status = Status.OK; - String responseEntity = "deleteNetworkResponse"; - Optional response = Optional.of(createResponse(status, responseEntity)); - when(networkAdapterResources.deleteNetworkAsync(deleteNetworkRequest)).thenReturn(response); - // when - networkAdapterRestV1Tasks.callNetworkAdapter(delegateExecution); - // then - verifyExecutionContent(status, responseEntity, messageId); - } - - @Test - public void callNetworkAdapter_UpdateNetworkRequestSuccess() throws Exception { - // given - String messageId = "UpdateNetReqMessageId"; - UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest(); - updateNetworkRequest.setMessageId(messageId); - delegateExecution.setVariable("networkAdapterRequest", updateNetworkRequest); - Status status = Status.OK; - String responseEntity = "updateNetworkResponse"; - Optional response = Optional.of(createResponse(status, responseEntity)); - when(networkAdapterResources.updateNetworkAsync(updateNetworkRequest)).thenReturn(response); - // when - networkAdapterRestV1Tasks.callNetworkAdapter(delegateExecution); - // then - verifyExecutionContent(status, responseEntity, messageId); - } - - @Test - public void callNetworkAdapterError_networkAdapterRequestIsNull() { - // when - networkAdapterRestV1Tasks.callNetworkAdapter(delegateExecution); - // then - verify(exceptionBuilder, times(1)).buildAndThrowWorkflowException(any(DelegateExecution.class), eq(7000), - any(Exception.class), eq(ONAPComponents.SO)); - } - - @Test - public void callNetworkAdapterError_noResponse() throws Exception { - // given - String messageId = "UpdateNetReqMessageId"; - UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest(); - updateNetworkRequest.setMessageId(messageId); - delegateExecution.setVariable("networkAdapterRequest", updateNetworkRequest); - when(networkAdapterResources.updateNetworkAsync(updateNetworkRequest)).thenReturn(Optional.empty()); - // when - networkAdapterRestV1Tasks.callNetworkAdapter(delegateExecution); - // then - verify(exceptionBuilder, times(1)).buildAndThrowWorkflowException(any(DelegateExecution.class), eq(7000), - any(Exception.class), eq(ONAPComponents.SO)); - } - - private void verifyExecutionContent(Status status, String responseEntity, String messageId) { - assertEquals(delegateExecution.getVariable("NETWORKREST_networkAdapterStatusCode"), - Integer.toString(status.getStatusCode())); - assertEquals(delegateExecution.getVariable("NETWORKREST_networkAdapterResponse"), responseEntity); - assertEquals(delegateExecution.getVariable("NetworkAResponse_CORRELATOR"), messageId); - } - - private Response createResponse(Status status, String responseEntity) { - OutboundMessageContext outboundMessageContext = new OutboundMessageContext(); - outboundMessageContext.setEntity(responseEntity); - return new OutboundJaxrsResponse(status, outboundMessageContext); - } - - private String createNetworkResponse(String networkResponseType, String networkId) { - - return "<" + networkResponseType + ">" - + networkId + ""; - } - - private String createNetworkError(String networkErrorType, String message) { - - return "<" + networkErrorType + ">" - + message + ""; - } - -} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasksTest.java index af97c3d038..64a315ad4d 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasksTest.java @@ -95,7 +95,7 @@ public class NetworkAdapterUpdateTasksTest extends BaseTaskTest { networkAdapterUpdateTasks.updateNetwork(execution); verify(networkAdapterObjectMapper, times(1)).createNetworkUpdateRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, network, userInput, customer); - assertEquals(updateNetworkRequest, execution.getVariable("networkAdapterRequest")); + assertEquals(updateNetworkRequest.toXmlString(), execution.getVariable("networkAdapterRequest")); } -- cgit 1.2.3-korg