diff options
255 files changed, 3764 insertions, 849 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java index 9042095e84..446c725e48 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java @@ -85,7 +85,7 @@ import org.onap.so.config.beans.PoConfig; import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.db.catalog.beans.CloudifyManager; import org.onap.so.db.catalog.beans.HeatTemplateParam; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.exceptions.MsoAdapterException; import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java index 576784ae3e..0a3c6acd84 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java @@ -37,7 +37,7 @@ import org.onap.so.config.beans.PoConfig; import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.db.catalog.beans.ServerType; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.exceptions.MsoAdapterException; import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; 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 f06d2a2452..8207c7c589 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 @@ -52,7 +52,7 @@ import org.onap.so.db.catalog.beans.HeatTemplateParam; import org.onap.so.db.request.beans.CloudApiRequests; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.CreateStackRequest; import org.onap.so.openstack.beans.HeatStatus; @@ -101,8 +101,6 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin { private static final String CREATE_IN_PROGRESS = "CREATE_IN_PROGRESS"; - private static final String DELETE_STACK = "DeleteStack"; - protected static final String HEAT_ERROR = "HeatError"; protected static final String CREATE_STACK = "CreateStack"; @@ -115,14 +113,14 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin { private Environment environment; @Autowired - RequestsDbClient requestDBClient; - - @Autowired StackStatusHandler statusHandler; @Autowired NovaClientImpl novaClient; + @Autowired + RequestsDbClient requestDBClient; + private static final Logger logger = LoggerFactory.getLogger(MsoHeatUtils.class); // Properties names and variables (with default values) @@ -182,6 +180,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin { CreateStackParam createStack = createStackParam(stackName, heatTemplate, stackInputs, timeoutMinutes, environment, nestedTemplates, heatFiles); Stack currentStack = queryHeatStack(stackName, cloudSiteId, tenantId); + boolean operationPerformed = false; if (currentStack != null) { logger.debug("Existing Stack found with Status: {} ", currentStack.getStackStatus()); if (CREATE_COMPLETE.equals(currentStack.getStackStatus())) { @@ -220,8 +219,11 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin { currentStack = queryHeatStack(currentStack.getStackName() + "/" + currentStack.getId(), cloudSiteId, tenantId); } + operationPerformed = true; } - return new StackInfoMapper(currentStack).map(); + StackInfo stackInfo = new StackInfoMapper(currentStack).map(); + stackInfo.setOperationPerformed(operationPerformed); + return stackInfo; } /** @@ -497,14 +499,17 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin { public StackInfo deleteStack(String tenantId, String cloudOwner, String cloudSiteId, String stackName, boolean pollForCompletion, int timeoutMinutes) throws MsoException { Stack currentStack = queryHeatStack(stackName, cloudSiteId, tenantId); + StackInfo stackInfo = null; if (currentStack == null || DELETE_COMPLETE.equals(currentStack.getStackStatus())) { - return new StackInfo(stackName, HeatStatus.NOTFOUND); + stackInfo = new StackInfo(stackName, HeatStatus.NOTFOUND); + stackInfo.setOperationPerformed(false); } else { currentStack = deleteStack(currentStack, timeoutMinutes, cloudSiteId, tenantId); - StackInfo stackInfo = new StackInfoMapper(currentStack).map(); + stackInfo = new StackInfoMapper(currentStack).map(); stackInfo.setName(stackName); - return stackInfo; + stackInfo.setOperationPerformed(true); } + return stackInfo; } /** @@ -1182,4 +1187,11 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin { } } + public void updateResourceStatus(String requestId, String resourceStatusMessage) { + InfraActiveRequests request = new InfraActiveRequests(); + request.setRequestId(requestId); + request.setResourceStatusMessage(resourceStatusMessage); + requestDBClient.patchInfraActiveRequests(request); + } + } diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java index 684fe98bf3..f001565baf 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java @@ -29,7 +29,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.StackInfo; import org.onap.so.openstack.exceptions.MsoException; diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java index f74a3f5f53..b875c2c8bb 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java @@ -29,7 +29,7 @@ import java.util.Optional; import org.onap.so.cloud.authentication.AuthenticationMethodFactory; import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.db.catalog.beans.CloudSite; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.MsoTenant; import org.onap.so.openstack.exceptions.MsoAdapterException; diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java index ca0180ae4b..1df5fe36ab 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java @@ -43,7 +43,7 @@ import org.onap.so.adapters.vdu.VduStatus; import org.onap.so.client.HttpClient; import org.onap.so.client.HttpClientFactory; import org.onap.so.client.RestClient; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.HeatStatus; import org.onap.so.openstack.beans.StackInfo; @@ -81,7 +81,9 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { private static final ObjectMapper JSON_MAPPER = new ObjectMapper(); private static final Integer DEFAULT_MSB_PORT = 80; private static final String DEFAULT_MSB_IP = "127.0.0.1"; + private static final String DEFAULT_MSB_SCHEME = "http"; private static final String ONAP_IP = "ONAP_IP"; + private static final String MSB_SCHEME = "MSB_SCHEME"; private final HttpClientFactory httpClientFactory = new HttpClientFactory(); @Autowired @@ -795,10 +797,14 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { msbIp = environment.getProperty("mso.msb-ip", DEFAULT_MSB_IP); } Integer msbPort = environment.getProperty("mso.msb-port", Integer.class, DEFAULT_MSB_PORT); + String msbScheme = System.getenv().get(MSB_SCHEME); + if (null == msbScheme || msbScheme.isEmpty()) { + msbScheme = environment.getProperty("mso.msb-scheme", DEFAULT_MSB_SCHEME); + } String path = "/api/multicloud/v1/" + cloudOwner + "/" + cloudSiteId + "/infra_workload"; - String endpoint = UriBuilder.fromPath(path).host(msbIp).port(msbPort).scheme("http").build().toString(); + String endpoint = UriBuilder.fromPath(path).host(msbIp).port(msbPort).scheme(msbScheme).build().toString(); if (workloadId != null) { String middlepart = null; if (isName) { diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java index 44fc620b07..3e28e5c45a 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java @@ -35,7 +35,7 @@ import org.onap.so.cloud.authentication.ServiceEndpointNotFoundException; import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.db.catalog.beans.ServerType; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.NetworkInfo; import org.onap.so.openstack.exceptions.MsoAdapterException; diff --git a/adapters/mso-adapter-utils/src/test/resources/application-test.yaml b/adapters/mso-adapter-utils/src/test/resources/application-test.yaml index 32a4db6b80..117d616cd4 100644 --- a/adapters/mso-adapter-utils/src/test/resources/application-test.yaml +++ b/adapters/mso-adapter-utils/src/test/resources/application-test.yaml @@ -53,6 +53,7 @@ mso: logPath: logs msb-ip: localhost msb-port: ${wiremock.server.port} + msb-scheme: http catalog: db: spring: diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/beans/StackInfo.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/beans/StackInfo.java index 76d3667632..7e2071525d 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/beans/StackInfo.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/beans/StackInfo.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,7 +26,7 @@ import java.util.Map; /* * This Java bean class relays Heat stack status information to ActiveVOS processes. - * + * * This bean is returned by all Heat-specific adapter operations (create, query, delete) */ @@ -36,6 +36,7 @@ public class StackInfo { private String canonicalName = ""; private HeatStatus status = HeatStatus.UNKNOWN; private String statusMessage = ""; + private boolean operationPerformed; private Map<String, Object> outputs = new HashMap<>(); private Map<String, Object> parameters = new HashMap<>(); @@ -106,5 +107,15 @@ public class StackInfo { this.parameters = parameters; } + public boolean isOperationPerformed() { + return operationPerformed; + } + + public void setOperationPerformed(boolean operationPerformed) { + this.operationPerformed = operationPerformed; + } + + + } diff --git a/adapters/mso-nssmf-adapter/pom.xml b/adapters/mso-nssmf-adapter/pom.xml index b6b52ce7c5..3e9c2fe6d7 100644 --- a/adapters/mso-nssmf-adapter/pom.xml +++ b/adapters/mso-nssmf-adapter/pom.xml @@ -28,6 +28,7 @@ <artifactId>adapters</artifactId> <version>1.6.0-SNAPSHOT</version> </parent> + <groupId>org.onap.so.adapters</groupId> <artifactId>mso-nssmf-adapter</artifactId> <packaging>jar</packaging> <name>mso-nssmf-adapter</name> diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/RestUtil.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/RestUtil.java index 3592d4f6a3..dcc6f5ba72 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/RestUtil.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/rest/RestUtil.java @@ -59,7 +59,7 @@ import static org.onap.so.adapters.nssmf.rest.HttpMethod.POST; import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.BAD_REQUEST; import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.unMarshal; -import static org.onap.so.logger.ErrorCode.AvailabilityError; +import static org.onap.logging.filter.base.ErrorCode.AvailabilityError; import static org.onap.so.logger.LoggingAnchor.FOUR; import static org.onap.so.logger.MessageEnum.RA_NS_EXC; diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/NssmfAdapterUtil.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/NssmfAdapterUtil.java index b0b84d822b..3a7c2f19df 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/NssmfAdapterUtil.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/NssmfAdapterUtil.java @@ -25,7 +25,7 @@ import java.io.IOException; import org.onap.so.adapters.nssmf.exceptions.ApplicationException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import static org.onap.so.logger.LoggingAnchor.THREE; import static org.onap.so.logger.MessageEnum.RA_NS_EXC; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/ContrailPolicyRef.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/ContrailPolicyRef.java index 9d7eafbf82..214cebb338 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/ContrailPolicyRef.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/ContrailPolicyRef.java @@ -26,7 +26,7 @@ package org.onap.so.adapters.network; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/ContrailSubnet.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/ContrailSubnet.java index 25667efc71..ba4e93fa93 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/ContrailSubnet.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/ContrailSubnet.java @@ -27,7 +27,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import java.util.ArrayList; import java.util.List; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.HostRoute; import org.onap.so.openstack.beans.Pool; 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 index e95e9a3a83..8d75212f4e 100644 --- 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 @@ -46,7 +46,7 @@ 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.so.logger.ErrorCode; +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; 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 ef04ee9c13..257374fdb2 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 @@ -47,7 +47,7 @@ import org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationReposi import org.onap.so.db.catalog.data.repository.NetworkResourceRepository; import org.onap.so.db.catalog.utils.MavenLikeVersioning; import org.onap.so.entity.MsoRequest; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.HeatStatus; @@ -92,6 +92,13 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { private static final String NEUTRON_MODE = "NEUTRON"; private static final String CLOUD_OWNER = "CloudOwner"; private static final String LOG_DEBUG_MSG = "Got Network definition from Catalog: {}"; + private static final String NETWORK_EXIST_STATUS_MESSAGE = + "The network was found to already exist, thus no new network was created in the cloud via this request"; + private static final String NETWORK_CREATED_STATUS_MESSAGE = + "The new network was successfully created in the cloud"; + private static final String NETWORK_NOT_EXIST_STATUS_MESSAGE = + "The network as not found, thus no network was deleted in the cloud via this request"; + private static final String NETWORK_DELETED_STATUS_MESSAGE = "The network was successfully deleted in the cloud"; private static final Logger logger = LoggerFactory.getLogger(MsoNetworkAdapterImpl.class); @@ -225,7 +232,6 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { // See if the Network already exists (by name) NetworkInfo netInfo = null; - long queryNetworkStarttime = System.currentTimeMillis(); try { netInfo = neutron.queryNetwork(networkName, tenantId, cloudSiteId); } catch (MsoException me) { @@ -254,10 +260,10 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { logger.warn("{} {} Found Existing network, status={} for Neutron mode ", MessageEnum.RA_NETWORK_ALREADY_EXIST, ErrorCode.DataError.getValue(), netInfo.getStatus()); } + heat.updateResourceStatus(msoRequest.getRequestId(), NETWORK_EXIST_STATUS_MESSAGE); return; } - long createNetworkStarttime = System.currentTimeMillis(); try { netInfo = neutron.createNetwork(cloudSiteId, tenantId, neutronNetworkType, networkName, physicalNetworkName, vlans); @@ -360,6 +366,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { MessageEnum.RA_NETWORK_ALREADY_EXIST, ErrorCode.DataError.getValue(), heatStack.getStatus(), networkName, cloudSiteId, tenantId); } + heat.updateResourceStatus(msoRequest.getRequestId(), NETWORK_EXIST_STATUS_MESSAGE); return; } @@ -473,6 +480,12 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { networkRollback.setNetworkCreated(true); networkRollback.setNetworkType(networkType); + try { + heat.updateResourceStatus(msoRequest.getRequestId(), NETWORK_CREATED_STATUS_MESSAGE); + } catch (Exception e) { + logger.warn("Exception while updating infra active request", e); + } + logger.debug("Network {} successfully created via HEAT", networkName); } @@ -1055,8 +1068,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } } else { try { - heat.deleteStack(tenantId, CLOUD_OWNER, cloudSiteId, networkId, true, timeoutMinutes); - networkDeleted.value = true; + StackInfo stack = heat.deleteStack(tenantId, CLOUD_OWNER, cloudSiteId, networkId, true, timeoutMinutes); + networkDeleted.value = stack.isOperationPerformed(); } catch (MsoException me) { me.addContext("DeleteNetwork"); logger.error("{} {} Delete Network (heat): {} in {}/{} ", MessageEnum.RA_DELETE_NETWORK_EXC, @@ -1064,6 +1077,12 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { throw new NetworkException(me); } } + try { + heat.updateResourceStatus(msoRequest.getRequestId(), + networkDeleted.value ? NETWORK_DELETED_STATUS_MESSAGE : NETWORK_NOT_EXIST_STATUS_MESSAGE); + } catch (Exception e) { + logger.warn("Exception while updating infra active request", e); + } } /** 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 index 0c37837880..09356d02c8 100644 --- 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 @@ -62,7 +62,7 @@ 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.so.logger.ErrorCode; +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; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/MsoTenantAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/MsoTenantAdapterImpl.java index 04b90b444f..4b02595074 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/MsoTenantAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/MsoTenantAdapterImpl.java @@ -33,7 +33,7 @@ import org.onap.so.adapters.tenant.exceptions.TenantAlreadyExists; import org.onap.so.adapters.tenant.exceptions.TenantException; import org.onap.so.adapters.tenantrest.TenantRollback; import org.onap.so.entity.MsoRequest; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.MsoTenant; import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/BpelRestClient.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/BpelRestClient.java index 662ce33022..5b0370b25e 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/BpelRestClient.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/BpelRestClient.java @@ -37,7 +37,7 @@ import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.utils.CryptoUtils; import org.slf4j.Logger; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImpl.java index e925e6037c..68d1bebc51 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImpl.java @@ -44,7 +44,7 @@ import org.onap.so.adapters.vnf.async.client.VnfAdapterNotify; import org.onap.so.adapters.vnf.async.client.VnfAdapterNotify_Service; import org.onap.so.adapters.vnf.exceptions.VnfException; import org.onap.so.entity.MsoRequest; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.VnfRollback; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java index 65d5523709..32e88d8cad 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java @@ -53,7 +53,7 @@ import org.onap.so.entity.MsoRequest; import org.onap.so.heatbridge.HeatBridgeApi; import org.onap.so.heatbridge.HeatBridgeException; import org.onap.so.heatbridge.HeatBridgeImpl; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.HeatStatus; @@ -109,6 +109,12 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { private static final String USER_ERROR = "USER ERROR"; private static final String VERSION_MIN = "VersionMin"; private static final String VERSION_MAX = "VersionMax"; + private static final String VF_EXIST_STATUS_MESSAGE = + "The vf module was found to already exist, thus no new vf module was created in the cloud via this request"; + private static final String VF_CREATED_STATUS_MESSAGE = "The new vf module was successfully created in the cloud"; + private static final String VF_NOT_EXIST_STATUS_MESSAGE = + "The vf module was not, thus no vf module was deleted in the cloud via this request"; + private static final String VF_DELETED_STATUS_MESSAGE = "The vf module was successfully deleted in the cloud"; @Autowired private VFModuleCustomizationRepository vfModuleCustomRepo; @@ -1046,6 +1052,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { heatStack = msoHeatUtils.createStack(cloudSiteId, cloudOwner, tenantId, vfModuleName, null, template, goldenInputs, true, heatTemplate.getTimeoutMinutes(), newEnvironmentString, nestedTemplatesChecked, heatFilesObjects, backout.booleanValue(), failIfExists); + + msoHeatUtils.updateResourceStatus(msoRequest.getRequestId(), + heatStack.isOperationPerformed() ? VF_EXIST_STATUS_MESSAGE : VF_CREATED_STATUS_MESSAGE); } else { throw new MsoHeatNotFoundException(); } @@ -1125,7 +1134,10 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } try { - msoHeatUtils.deleteStack(tenantId, cloudOwner, cloudSiteId, vnfName, true, timeoutMinutes); + StackInfo stackInfo = + msoHeatUtils.deleteStack(tenantId, cloudOwner, cloudSiteId, vnfName, true, timeoutMinutes); + msoHeatUtils.updateResourceStatus(msoRequest.getRequestId(), + stackInfo.isOperationPerformed() ? VF_DELETED_STATUS_MESSAGE : VF_NOT_EXIST_STATUS_MESSAGE); } catch (MsoException me) { me.addContext(DELETE_VNF); // Failed to query the Stack due to an openstack exception. diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java index abaf881ba5..ba837a9718 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java @@ -52,7 +52,7 @@ import org.onap.so.db.catalog.beans.VnfResource; import org.onap.so.db.catalog.data.repository.VFModuleCustomizationRepository; import org.onap.so.db.catalog.utils.MavenLikeVersioning; import org.onap.so.entity.MsoRequest; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.MsoTenant; import org.onap.so.openstack.beans.VnfRollback; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java index b1f4055b3b..0ecfd15dde 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java @@ -65,7 +65,7 @@ import org.onap.so.db.catalog.beans.VnfResource; import org.onap.so.db.catalog.data.repository.VFModuleCustomizationRepository; import org.onap.so.db.catalog.utils.MavenLikeVersioning; import org.onap.so.entity.MsoRequest; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.VnfRollback; import org.onap.so.openstack.beans.VnfStatus; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java index 0fb11ebbf3..0836f69ba7 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java @@ -56,7 +56,7 @@ import org.onap.so.adapters.vnfrest.UpdateVfModuleResponse; import org.onap.so.adapters.vnfrest.VfModuleExceptionResponse; import org.onap.so.adapters.vnfrest.VfModuleRollback; import org.onap.so.entity.MsoRequest; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.VnfRollback; import org.onap.so.openstack.beans.VnfStatus; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java index fcb570f3f5..18ed9872a0 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java @@ -55,7 +55,7 @@ import org.onap.so.adapters.vnfrest.UpdateVfModuleResponse; import org.onap.so.adapters.vnfrest.VfModuleExceptionResponse; import org.onap.so.adapters.vnfrest.VfModuleRollback; import org.onap.so.entity.MsoRequest; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.VnfRollback; import org.onap.so.openstack.beans.VnfStatus; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRest.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRest.java index c9e046ca43..7e12735e05 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRest.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRest.java @@ -56,7 +56,7 @@ import org.onap.so.adapters.vnfrest.UpdateVolumeGroupResponse; import org.onap.so.adapters.vnfrest.VolumeGroupExceptionResponse; import org.onap.so.adapters.vnfrest.VolumeGroupRollback; import org.onap.so.entity.MsoRequest; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.VnfRollback; import org.onap.so.openstack.beans.VnfStatus; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java index 2b7234aca6..cfddbba34e 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java @@ -55,7 +55,7 @@ import org.onap.so.adapters.vnfrest.UpdateVolumeGroupResponse; import org.onap.so.adapters.vnfrest.VolumeGroupExceptionResponse; import org.onap.so.adapters.vnfrest.VolumeGroupRollback; import org.onap.so.entity.MsoRequest; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.VnfRollback; import org.onap.so.openstack.beans.VnfStatus; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java index e2022c9a6e..6d3b0ab680 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java @@ -76,7 +76,7 @@ import org.onap.so.heatbridge.helpers.AaiHelper; import org.onap.so.heatbridge.openstack.api.OpenstackClient; import org.onap.so.heatbridge.openstack.factory.OpenstackClientFactoryImpl; import org.onap.so.heatbridge.utils.HeatBridgeUtils; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.openstack4j.model.compute.Server; diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MSONetworkAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MSONetworkAdapterImplTest.java index add1918748..284067a766 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MSONetworkAdapterImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MSONetworkAdapterImplTest.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,6 +20,9 @@ package org.onap.so.adapters.network; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.patch; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static org.junit.Assert.assertEquals; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackDeleteNeutronNetwork; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackDeleteStack_200; @@ -52,6 +55,7 @@ import org.springframework.http.HttpEntity; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.web.util.UriComponentsBuilder; +import com.github.tomakehurst.wiremock.WireMockServer; public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @@ -112,6 +116,8 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void createNetworkByModelNameAlreadyExistNeutronMode() throws IOException { + mockUpdateRequestDb(wireMockServer, "9733c8d1-2668-4e5f-8b51-2cacc9b662c0"); + mockOpenStackResponseAccess(wireMockServer, wireMockPort); mockOpenStackGetAllNeutronNetworks_200(wireMockServer, "OpenstackGetNeutronNetworks.json"); @@ -140,6 +146,8 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void createNetworkByModelNameHeatMode() throws IOException { + mockUpdateRequestDb(wireMockServer, "9733c8d1-2668-4e5f-8b51-2cacc9b662c0"); + mockOpenStackResponseAccess(wireMockServer, wireMockPort); mockOpenStackGetStack_404(wireMockServer, "DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId"); @@ -158,6 +166,8 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void createNetworkByModelNameAlreadyExistHeatMode() throws IOException { + mockUpdateRequestDb(wireMockServer, "9733c8d1-2668-4e5f-8b51-2cacc9b662c0"); + mockOpenStackResponseAccess(wireMockServer, wireMockPort); mockOpenStackPostStack_200(wireMockServer, "OpenstackResponse_Stack.json"); @@ -236,6 +246,8 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void deleteNetworkHeatModeSuccess() throws IOException { + mockUpdateRequestDb(wireMockServer, "5a29d907-b8c7-47bf-85f3-3940c0cce0f7"); + mockOpenStackResponseAccess(wireMockServer, wireMockPort); mockOpenStackGetStackDeleteOrUpdateComplete_200(wireMockServer, "OpenstackResponse_Stack_DeleteComplete.json"); @@ -292,6 +304,8 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { @Test public void deleteNetworkNeureonMode() throws IOException { + mockUpdateRequestDb(wireMockServer, "5a29d907-b8c7-47bf-85f3-3940c0cce0f7"); + mockOpenStackResponseAccess(wireMockServer, wireMockPort); mockOpenStackGetNeutronNetwork(wireMockServer, "GetNeutronNetwork.json", NETWORK_ID, HttpStatus.SC_OK); @@ -506,4 +520,9 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { String input = new String(Files.readAllBytes(Paths.get(JsonInput))); return input; } + + public static void mockUpdateRequestDb(WireMockServer wireMockServer, String requestId) throws IOException { + wireMockServer.stubFor(patch(urlPathEqualTo("/infraActiveRequests/" + requestId)) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK))); + } } 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 index 727f18902a..00961a16b9 100644 --- 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 @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,6 +22,7 @@ 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; @@ -41,6 +42,7 @@ 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 @@ -263,4 +265,5 @@ public class MsoNetworkAdapterAsyncImplTest extends BaseRestTestUtils { false, new ArrayList<>(), new HashMap<String, String>(), "messageId", new MsoRequest(), "http://localhost:" + wireMockPort + "/notificationUrl"); } + } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java index a058378425..9fc2aba948 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java @@ -23,6 +23,7 @@ package org.onap.so.adapters.vnf; import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.patch; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static org.mockito.Mockito.when; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200; @@ -30,6 +31,7 @@ import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_ import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPutStack; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccess; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenstackGetWithResponse; +import java.io.IOException; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -53,6 +55,7 @@ import org.onap.so.openstack.beans.VnfRollback; import org.onap.so.openstack.exceptions.MsoException; import org.onap.so.openstack.utils.MsoHeatUtils; import org.springframework.beans.factory.annotation.Autowired; +import com.github.tomakehurst.wiremock.WireMockServer; import com.github.tomakehurst.wiremock.stubbing.Scenario; @@ -73,6 +76,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { public void createVnfTest() throws Exception { mockOpenStackResponseAccess(wireMockServer, wireMockPort); mockOpenStackGetStackVfModule_200(wireMockServer); + mockUpdateRequestDb(wireMockServer, "12345"); MsoRequest msoRequest = getMsoRequest(); @@ -88,6 +92,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { public void createVnfTest_NullFailIfExists() throws Exception { mockOpenStackResponseAccess(wireMockServer, wireMockPort); mockOpenStackGetStackVfModule_200(wireMockServer); + mockUpdateRequestDb(wireMockServer, "12345"); MsoRequest msoRequest = getMsoRequest(); @@ -117,6 +122,8 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { .inScenario("HeatStatusFailure").whenScenarioStateIs("HeatStackFailed") .willSetStateTo("HeatStackSuccess")); + mockUpdateRequestDb(wireMockServer, "12345"); + MsoRequest msoRequest = getMsoRequest(); Map<String, Object> map = new HashMap<>(); @@ -133,6 +140,8 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { public void createVnfTest_HeatStatusCreated() throws Exception { mockOpenStackResponseAccess(wireMockServer, wireMockPort); mockOpenStackGetStackVfModule_200(wireMockServer); + mockUpdateRequestDb(wireMockServer, "12345"); + MsoRequest msoRequest = getMsoRequest(); Map<String, Object> map = new HashMap<>(); map.put("key1", "value1"); @@ -516,5 +525,10 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { return vfModuleCustomization; } + public static void mockUpdateRequestDb(WireMockServer wireMockServer, String requestId) throws IOException { + wireMockServer.stubFor(patch(urlPathEqualTo("/infraActiveRequests/" + requestId)) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK))); + } + } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java index 5a8524fd73..9655e90e46 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,6 +22,8 @@ package org.onap.so.adapters.vnf; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; +import com.github.tomakehurst.wiremock.WireMockServer; +import org.apache.http.HttpStatus; import org.json.JSONException; import org.junit.Ignore; import org.junit.Test; @@ -49,6 +51,9 @@ import java.io.File; import java.io.IOException; import java.util.HashMap; import java.util.Map; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.patch; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertEquals; @@ -112,6 +117,8 @@ public class VnfAdapterRestTest extends BaseRestTestUtils { mockOpenStackGetStackVfModule_200(wireMockServer); + mockUpdateRequestDb(wireMockServer, "62265093-277d-4388-9ba6-449838ade586"); + headers.add("Accept", MediaType.APPLICATION_JSON); HttpEntity<CreateVfModuleRequest> entity = new HttpEntity<CreateVfModuleRequest>(request, headers); @@ -208,6 +215,8 @@ public class VnfAdapterRestTest extends BaseRestTestUtils { mockOpenStackGetStackVfModule_200(wireMockServer); + mockUpdateRequestDb(wireMockServer, "62265093-277d-4388-9ba6-449838ade586"); + headers.add("Accept", MediaType.APPLICATION_JSON); HttpEntity<CreateVfModuleRequest> entity = new HttpEntity<CreateVfModuleRequest>(request, headers); @@ -342,6 +351,7 @@ public class VnfAdapterRestTest extends BaseRestTestUtils { mockOpenStackDeletePublicUrlStackByNameAndID_204(wireMockServer); + mockUpdateRequestDb(wireMockServer, "62265093-277d-4388-9ba6-449838ade586"); headers.add("Accept", MediaType.APPLICATION_JSON); HttpEntity<DeleteVfModuleRequest> entity = new HttpEntity<DeleteVfModuleRequest>(request, headers); @@ -539,4 +549,9 @@ public class VnfAdapterRestTest extends BaseRestTestUtils { return request; } + + public static void mockUpdateRequestDb(WireMockServer wireMockServer, String requestId) throws IOException { + wireMockServer.stubFor(patch(urlPathEqualTo("/infraActiveRequests/" + requestId)) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK))); + } } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java index 523a6903cc..c2e2b567f1 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,6 +20,7 @@ package org.onap.so.adapters.vnf; +import org.apache.http.HttpStatus; import org.junit.Test; import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest; import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse; @@ -37,6 +38,9 @@ import org.springframework.http.ResponseEntity; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; import java.io.IOException; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.patch; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static org.junit.Assert.assertEquals; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackWithBody_200; @@ -50,6 +54,9 @@ public class VolumeAdapterRestTest extends VolumeGroupAdapterCommon { @Test public void testCreateVNFVolumes() throws IOException { + wireMockServer.stubFor(patch(urlPathEqualTo("/infraActiveRequests/62265093-277d-4388-9ba6-449838ade586")) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK))); + mockOpenStackResponseAccess(wireMockServer, wireMockPort); mockOpenStackPostStacks_200(wireMockServer); mockOpenStackGetStackVfModule_200(wireMockServer); diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java index fb4bec69ed..6fd9f02cfe 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,6 +20,7 @@ package org.onap.so.adapters.vnf; +import org.apache.http.HttpStatus; import org.junit.Test; import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest; import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse; @@ -37,6 +38,9 @@ import org.springframework.http.ResponseEntity; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; import java.io.IOException; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.patch; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static org.junit.Assert.assertEquals; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackWithBody_200; @@ -52,6 +56,9 @@ public class VolumeAdapterRestV2Test extends VolumeGroupAdapterCommon { mockOpenStackResponseAccess(wireMockServer, wireMockPort); mockOpenStackPostStacks_200(wireMockServer); mockOpenStackGetStackVfModule_200(wireMockServer); + wireMockServer.stubFor(patch(urlPathEqualTo("/infraActiveRequests/62265093-277d-4388-9ba6-449838ade586")) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK))); + CreateVolumeGroupRequest request = buildCreateVfModuleRequest(); HttpEntity<CreateVolumeGroupRequest> entity = new HttpEntity<>(request, headers); diff --git a/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml b/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml index 20fd812ab9..42955c35c9 100644 --- a/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml +++ b/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml @@ -61,11 +61,15 @@ ssl-enable: false tomcat: max-threads: 50 mso: + adapters: + requestDb: + endpoint: http://localhost:${wiremock.server.port} audit: lock-time: 240000 logPath: logs msb-ip: localhost msb-port: ${wiremock.server.port} + msb-scheme: http catalog: db: spring: diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java index 24dab2fc5b..9f48144eb8 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java @@ -10,9 +10,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -27,19 +27,15 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; -import org.onap.logging.filter.base.ONAPComponents; -import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.db.request.beans.ArchivedInfraRequests; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.data.repository.ArchivedInfraRequestsRepository; import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository; -import org.onap.so.logger.ErrorCode; -import org.onap.so.logger.LoggingAnchor; -import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.ScheduledTasksMDCSetup; +import org.onap.logging.filter.base.ErrorCode; +import org.onap.logging.filter.base.ScheduledLogging; +import org.onap.logging.filter.base.ScheduledTaskException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.domain.PageRequest; @@ -56,8 +52,6 @@ public class ArchiveInfraRequestsScheduler { private InfraActiveRequestsRepository infraActiveRepo; @Autowired private ArchivedInfraRequestsRepository archivedInfraRepo; - @Autowired - private ScheduledTasksMDCSetup scheduledMDCSetup; @Value("${mso.infra-requests.archived.period}") @@ -65,11 +59,13 @@ public class ArchiveInfraRequestsScheduler { /** * Runs the scheduler nightly [Seconds] [Minutes] [Hours] [Day of month] [Month] [Day of week] [Year] + * + * @throws ScheduledTaskException */ + @ScheduledLogging @Scheduled(cron = "0 0 1 * * ?") @SchedulerLock(name = "archiveInfraRequestsScheduler") - public void infraRequestsScheduledTask() { - scheduledMDCSetup.mdcSetup(ONAPComponents.REQUEST_DB, "infraRequestsScheduledTask"); + public void infraRequestsScheduledTask() throws ScheduledTaskException { logger.debug("Start of archiveInfraRequestsScheduler"); Date currentDate = new Date(); @@ -97,10 +93,9 @@ public class ArchiveInfraRequestsScheduler { } while (!requestsByStartTime.isEmpty()); logger.debug("End of archiveInfraRequestsScheduler"); - scheduledMDCSetup.exitAndClearMDC(); } - protected void archiveInfraRequests(List<InfraActiveRequests> requests) { + protected void archiveInfraRequests(List<InfraActiveRequests> requests) throws ScheduledTaskException { List<ArchivedInfraRequests> newArchivedReqs = new ArrayList<>(); List<InfraActiveRequests> oldInfraReqs = new ArrayList<>(); @@ -147,14 +142,12 @@ public class ArchiveInfraRequestsScheduler { archivedInfra.setVolumeGroupName(iar.getVolumeGroupName()); archivedInfra.setProductFamilyName(iar.getProductFamilyName()); archivedInfra.setTenantName(iar.getTenantName()); + archivedInfra.setResourceStatusMessage(iar.getResourceStatusMessage()); newArchivedReqs.add(archivedInfra); oldInfraReqs.add(iar); } catch (Exception e) { - scheduledMDCSetup.errorMDCSetup(ErrorCode.UnknownError, e.getMessage()); - MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.ERROR.toString()); - logger.error(LoggingAnchor.TWO, MessageEnum.RA_GENERAL_EXCEPTION.toString(), - ErrorCode.UnknownError.getValue(), e); + throw new ScheduledTaskException(ErrorCode.UnknownError, e.getMessage(), e); } } diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java index 052a53bb1f..b262cb21cb 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java @@ -39,7 +39,7 @@ import org.onap.so.db.request.data.repository.OperationStatusRepository; import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository; import org.onap.so.db.request.data.repository.SiteStatusRepository; import org.onap.so.db.request.data.repository.InstanceNfvoMappingRepository; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.requestsdb.RequestsDbConstant; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbException.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbException.java index 27580977b8..e1e629008d 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbException.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbException.java @@ -24,7 +24,7 @@ package org.onap.so.adapters.requestsdb.exceptions; import javax.xml.ws.WebFault; import org.onap.so.exceptions.MSOException; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; /** * This class simply extends Exception (without addition additional functionality) to provide an identifier for diff --git a/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V7.3.1__AddResourceStatusMessageColumn.sql b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V7.3.1__AddResourceStatusMessageColumn.sql new file mode 100644 index 0000000000..f388a185f5 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V7.3.1__AddResourceStatusMessageColumn.sql @@ -0,0 +1,4 @@ +use requestdb; + +ALTER TABLE infra_active_requests ADD COLUMN IF NOT EXISTS RESOURCE_STATUS_MESSAGE longtext; +ALTER TABLE archived_infra_requests ADD COLUMN IF NOT EXISTS RESOURCE_STATUS_MESSAGE longtext;
\ No newline at end of file diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SDNCAdapterService.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SDNCAdapterService.java index b96a564b1a..f8daf69965 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SDNCAdapterService.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SDNCAdapterService.java @@ -31,7 +31,7 @@ import javax.xml.ws.WebEndpoint; import javax.xml.ws.WebServiceClient; import javax.xml.ws.WebServiceFeature; import org.onap.so.logger.LoggingAnchor; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/client/SDNCAdapterCallbackRequest.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/client/SDNCAdapterCallbackRequest.java index 577b550be6..3de95b338b 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/client/SDNCAdapterCallbackRequest.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/client/SDNCAdapterCallbackRequest.java @@ -32,7 +32,7 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import org.onap.so.logger.LoggingAnchor; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/client/SDNCCallbackAdapterService.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/client/SDNCCallbackAdapterService.java index 87620743d7..978cd44b56 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/client/SDNCCallbackAdapterService.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/client/SDNCCallbackAdapterService.java @@ -30,7 +30,7 @@ import javax.xml.ws.WebEndpoint; import javax.xml.ws.WebServiceClient; import javax.xml.ws.WebServiceFeature; import org.onap.so.logger.LoggingAnchor; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Constants.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Constants.java index 294dccdb90..da0fcd3d04 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Constants.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Constants.java @@ -42,6 +42,7 @@ public interface Constants { public static final String REQUEST_TUNABLES = "org.onap.so.adapters.sdnc"; public static final String MSO_ACTION_LCM = "lcm"; + public static final String MSO_ACTION_MDONS = "opticalservice"; public static final String LCM_API_VER = "2.00"; public static final int LCM_FLAGS_TTL = 65000; public static final String LCM_ORIGINATOR_ID = "MSO"; diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/MapRequestTunables.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/MapRequestTunables.java index b15831ff03..0535b3de2d 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/MapRequestTunables.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/MapRequestTunables.java @@ -24,7 +24,7 @@ package org.onap.so.adapters.sdnc.impl; import org.onap.so.logger.LoggingAnchor; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCAdapterPortTypeImpl.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCAdapterPortTypeImpl.java index 2b023f4c15..7c35be02a4 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCAdapterPortTypeImpl.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCAdapterPortTypeImpl.java @@ -29,7 +29,7 @@ import org.onap.so.logger.LoggingAnchor; import org.onap.so.adapters.sdnc.SDNCAdapterPortType; import org.onap.so.adapters.sdnc.SDNCAdapterRequest; import org.onap.so.adapters.sdnc.SDNCAdapterResponse; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java index bcd1db7929..b8977f05d8 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java @@ -46,7 +46,7 @@ import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathFactory; import org.onap.so.logger.LoggingAnchor; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.utils.CryptoUtils; import org.onap.so.adapters.sdnc.SDNCAdapterRequest; import org.onap.so.adapters.sdnc.client.CallbackHeader; @@ -112,6 +112,8 @@ public class SDNCRestClient { Document reqDoc = node.getOwnerDocument(); if (Constants.MSO_ACTION_LCM.equals(msoAction)) { sdncReqBody = Utils.genSdncLcmReq(reqDoc, rt); + } else if (Constants.MSO_ACTION_MDONS.equals(msoAction)) { + sdncReqBody = Utils.genOpticalSdncReq(reqDoc, rt); } else { sdncReqBody = Utils.genSdncReq(reqDoc, rt); } diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Utils.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Utils.java index 56c38f8891..f52ebcab9b 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Utils.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Utils.java @@ -34,7 +34,7 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.onap.so.logger.LoggingAnchor; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,10 +42,13 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import org.json.XML; +import org.json.JSONObject; public class Utils { private static Logger logger = LoggerFactory.getLogger(Utils.class); + private static int MSOJsonIndentFactor = 3; private Utils() {} @@ -230,6 +233,85 @@ public class Utils { return null; } + public static String genOpticalSdncReq(Document reqDoc, RequestTunables rt) { + try { + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db = dbf.newDocumentBuilder(); + + // NewDoc for output + // Root + Document newdoc = db.newDocument(); + Element root = newdoc.createElementNS(rt.getNamespace(), "input"); + newdoc.appendChild(root); + // RequestData + NodeList nodes = reqDoc.getDocumentElement().getChildNodes(); + for (int i = 0; i < nodes.getLength(); i++) { + Node n = nodes.item(i); + Node newNode = newdoc.importNode(n, true); + root.appendChild(newNode); + } + String req = domToStr(newdoc); + String s = xml2json(req, true); + logger.debug("Formatted SdncReq:\n", s); + return s; + + } catch (Exception e) { + logger.error(LoggingAnchor.FOUR, MessageEnum.RA_ERROR_CREATE_SDNC_REQUEST.toString(), "SDNC", + ErrorCode.BusinessProcessError.getValue(), "Exception in genOpticalSdncReq", e); + } + return null; + } + + /** + * Uses the JSONObject static method to convert a XML doc to JSON. + * + * @param xml String containing the XML doc + * @param pretty flag to determine if the output should be formatted + * @return String containing the JSON translation + */ + public static String xml2json(String xml, boolean pretty) { + try { + // name spaces cause problems, so just remove them + JSONObject jsonObj = XML.toJSONObject(removeNamespaces(xml)); + if (!pretty) { + return jsonObj.toString(); + } else { + // add an indent to make it 'pretty' + return jsonObj.toString(MSOJsonIndentFactor); + } + } catch (Exception e) { + logger.debug("xml2json(): unable to parse xml and convert to json. Exception was: {}", e.toString(), e); + return null; + } + } + + /** + * Removes namespaces and namespace declarations from an XML document. + * + * @param xml the XML document + * @return a possibly modified document + */ + public static String removeNamespaces(Object xml) { + if (xml == null) { + logger.debug("removeNamespaces input object is null , returning null"); + return null; + } + + String text = String.valueOf(xml); + + // remove xmlns declaration + text = text.replaceAll("xmlns.*?(\"|\').*?(\"|\')", ""); + // remove opening tag prefix + text = text.replaceAll("(<)(\\w+:)(.*?>)", "$1$3"); + // remove closing tags prefix + text = text.replaceAll("(</)(\\w+:)(.*?>)", "$1$3"); + // remove extra spaces left when xmlns declarations are removed + text = text.replaceAll("\\s+>", ">"); + + return text; + } + + public static String genMsoFailResp(SDNCResponse resp) { try { diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallback.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallback.java index 631be2f9ff..62f45f88b1 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallback.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallback.java @@ -28,7 +28,7 @@ import java.net.URI; import javax.xml.bind.DatatypeConverter; import org.onap.logging.filter.spring.SpringClientPayloadFilter; import org.onap.so.adapters.sdnc.impl.Constants; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter; diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/MapTypedRequestTunablesData.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/MapTypedRequestTunablesData.java index 979238fe2f..776251a20b 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/MapTypedRequestTunablesData.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/MapTypedRequestTunablesData.java @@ -26,7 +26,7 @@ package org.onap.so.adapters.sdnc.sdncrest; import org.onap.so.logger.LoggingAnchor; import org.onap.so.adapters.sdnc.exception.SDNCAdapterException; import org.onap.so.adapters.sdnc.impl.Constants; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCConnector.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCConnector.java index e184bbd110..431e9db87b 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCConnector.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCConnector.java @@ -51,7 +51,7 @@ import org.apache.http.util.EntityUtils; import org.onap.so.adapters.sdnc.impl.Constants; import org.onap.so.adapters.sdncrest.SDNCErrorCommon; import org.onap.so.adapters.sdncrest.SDNCResponseCommon; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestTask.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestTask.java index 50c8a089df..305abe2762 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestTask.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestTask.java @@ -38,7 +38,7 @@ import org.onap.so.adapters.sdncrest.RequestInformation; import org.onap.so.adapters.sdncrest.SDNCResponseCommon; import org.onap.so.adapters.sdncrest.SDNCServiceError; import org.onap.so.adapters.sdncrest.SDNCServiceRequest; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SNIROResponse.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SNIROResponse.java index 5f80c20b97..9f7760a0d8 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SNIROResponse.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SNIROResponse.java @@ -33,7 +33,7 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.onap.so.logger.LoggingAnchor; import org.onap.so.adapters.sdnc.impl.Constants; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/JsonUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/JsonUtil.java index 5b50f776cc..04109bd89d 100644 --- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/JsonUtil.java +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/JsonUtil.java @@ -27,7 +27,7 @@ import java.io.IOException; import org.onap.so.logger.LoggingAnchor; import org.onap.so.adapters.vfc.constant.HttpCode; import org.onap.so.adapters.vfc.exceptions.ApplicationException; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java index 984cdb8016..a708c2641c 100644 --- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java @@ -47,7 +47,7 @@ import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.util.EntityUtils; import org.onap.so.adapters.vfc.model.RestfulResponse; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/src/main/resources/SOL003-VNFPackageManagement-API.json b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/src/main/resources/SOL003-VNFPackageManagement-API.json index 1f4a8ac306..17d81f44c1 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/src/main/resources/SOL003-VNFPackageManagement-API.json +++ b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/src/main/resources/SOL003-VNFPackageManagement-API.json @@ -1187,8 +1187,14 @@ "DISABLED" ] }, - "usageState": { - "description": "- IN_USE: VNF instances instantiated from this VNF package exist. - NOT_IN_USE: No existing VNF instance is instantiated from this VNF package.\n" + "usageState": + { + "description": "- IN_USE: VNF instances instantiated from this VNF package exist. - NOT_IN_USE: No existing VNF instance is instantiated from this VNF package.\n", + "type": "string", + "enum": [ + "IN_USE", + "NOT_IN_USE" + ] }, "userDefinedData": { "description": "This type represents a list of key-value pairs. The order of the pairs in the list is not significant. In JSON, a set of key- value pairs is represented as an object. It shall comply with the provisions defined in clause 4 of IETF RFC 7159.\n", @@ -2024,8 +2030,14 @@ "DISABLED" ] }, - "usageState": { - "description": "- IN_USE: VNF instances instantiated from this VNF package exist. - NOT_IN_USE: No existing VNF instance is instantiated from this VNF package.\n" + "usageState": + { + "description": "- IN_USE: VNF instances instantiated from this VNF package exist. - NOT_IN_USE: No existing VNF instance is instantiated from this VNF package.\n", + "type": "string", + "enum": [ + "IN_USE", + "NOT_IN_USE" + ] }, "userDefinedData": { "description": "This type represents a list of key-value pairs. The order of the pairs in the list is not significant. In JSON, a set of key- value pairs is represented as an object. It shall comply with the provisions defined in clause 4 of IETF RFC 7159.\n", @@ -4572,16 +4584,31 @@ "type": "string" } }, - "operationalState": { + "operationalState": + { "description": "- ENABLED: The VNF package is enabled, i.e. it can be used for instantiation of new VNF instances.\n- DISABLED: The VNF package is disabled, i.e. it cannot be used for further VNF instantiation requests (unless and until the VNF package\n is re-enabled).\n", - "type": "string", - "enum": [ - "ENABLED", - "DISABLED" - ] + "type": "array", + "items": + { + "type": "string", + "enum": [ + "ENABLED", + "DISABLED" + ] + } }, - "usageState": { - "description": "- IN_USE: VNF instances instantiated from this VNF package exist. - NOT_IN_USE: No existing VNF instance is instantiated from this VNF package.\n" + "usageState": + { + "description": "- IN_USE: VNF instances instantiated from this VNF package exist. - NOT_IN_USE: No existing VNF instance is instantiated from this VNF package.\n", + "type": "array", + "items": + { + "type": "string", + "enum": [ + "IN_USE", + "NOT_IN_USE" + ] + } } } }, @@ -4803,18 +4830,32 @@ "type": "string" } }, - "operationalState": { + "operationalState": + { "description": "- ENABLED: The VNF package is enabled, i.e. it can be used for instantiation of new VNF instances.\n- DISABLED: The VNF package is disabled, i.e. it cannot be used for further VNF instantiation requests (unless and until the VNF package\n is re-enabled).\n", - "type": "string", - "enum": [ - "ENABLED", - "DISABLED" - ] + "type": "array", + "items": + { + "type": "string", + "enum": [ + "ENABLED", + "DISABLED" + ] + } }, - "usageState": { - "description": "- IN_USE: VNF instances instantiated from this VNF package exist. - NOT_IN_USE: No existing VNF instance is instantiated from this VNF package.\n" - } - } + "usageState": + { + "description": "- IN_USE: VNF instances instantiated from this VNF package exist. - NOT_IN_USE: No existing VNF instance is instantiated from this VNF package.\n", + "type": "array", + "items": + { + "type": "string", + "enum": [ + "IN_USE", + "NOT_IN_USE" + ] + } + } } }, "callbackUri": { "description": "String formatted according to IETF RFC 3986.\n", diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java index 6d566c07ad..f32a9b0fa9 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java @@ -21,16 +21,16 @@ package org.onap.so.adapters.vnfmadapter.converters.sol003.etsicatalog; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.Version; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfProducts; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfProductsProviders; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter.NotificationTypesEnum; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter.OperationalStateEnum; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter1; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter1.NotificationTypesEnum; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter1.OperationalStateEnum; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter1.UsageStateEnum; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilterVersions; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilterVnfProducts; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilterVnfProductsFromProviders; @@ -62,7 +62,7 @@ public class PkgmSubscriptionRequestConverter implements private org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter getPkgmNotificationsFilter( - final SubscriptionsFilter sol003SubscriptionsFilter) { + final SubscriptionsFilter1 sol003SubscriptionsFilter) { final org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter etsiCatalogManagerFilters = new org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter(); @@ -81,21 +81,40 @@ public class PkgmSubscriptionRequestConverter implements etsiCatalogManagerFilters .setOperationalState(getOperationalState(sol003SubscriptionsFilter.getOperationalState())); - etsiCatalogManagerFilters.setUsageState(null); + etsiCatalogManagerFilters.setUsageState(getUsageState(sol003SubscriptionsFilter.getUsageState())); return etsiCatalogManagerFilters; } - // TODO 'operationalState' in the Sol003 Swagger is type 'OperationalStateEnum'. The ETSI - // Catalog Manager Swagger - // 'operationalState' is type 'List<OperationalStateEnum>'. This method needs to be updated once - // swagger is updated. + + private List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.UsageStateEnum> getUsageState( + final List<UsageStateEnum> usageStates) { + if (usageStates != null) { + final List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.UsageStateEnum> etsiCatalogUsageStates = + new ArrayList<>(); + usageStates.stream().forEach(state -> { + etsiCatalogUsageStates.add( + org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.UsageStateEnum + .fromValue(state.getValue())); + }); + return etsiCatalogUsageStates; + } + return Collections.emptyList(); + } + + private List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.OperationalStateEnum> getOperationalState( - final OperationalStateEnum operationalState) { - if (operationalState != null) { - return Arrays.asList( - org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.OperationalStateEnum - .fromValue(operationalState.getValue())); + final List<OperationalStateEnum> operationalStates) { + if (operationalStates != null) { + final List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.OperationalStateEnum> etsiCatalogOperationalStates = + new ArrayList<>(); + operationalStates.forEach(state -> { + etsiCatalogOperationalStates.add( + org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.OperationalStateEnum + .fromValue(state.getValue())); + }); + + return etsiCatalogOperationalStates; } return Collections.emptyList(); } @@ -165,12 +184,12 @@ public class PkgmSubscriptionRequestConverter implements final List<NotificationTypesEnum> notificationTypes) { if (notificationTypes != null && !notificationTypes.isEmpty()) { - final List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.NotificationTypesEnum> etsiCatalogManagerNotificationTypes = + final List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.NotificationTypesEnum> etsiCatalogNotificationTypes = new ArrayList<>(); - notificationTypes.forEach(type -> etsiCatalogManagerNotificationTypes.add( + notificationTypes.forEach(type -> etsiCatalogNotificationTypes.add( org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.NotificationTypesEnum .fromValue(type.getValue()))); - return etsiCatalogManagerNotificationTypes; + return etsiCatalogNotificationTypes; } return Collections.emptyList(); } diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java index a4c52fd13d..a23eb6c3e3 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java @@ -34,14 +34,14 @@ import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.EtsiCatalogServic import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.BasicAuth; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.NsdmSubscription; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscription; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2002; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse201; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsLinks; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.VnfPackagesLinksSelf; import org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement.cache.PackageManagementCacheServiceProvider; +import org.onap.so.adapters.vnfmadapter.rest.exceptions.ConversionFailedException; import org.onap.so.adapters.vnfmadapter.rest.exceptions.InternalServerErrorException; import org.onap.so.adapters.vnfmadapter.rest.exceptions.SubscriptionNotFoundException; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.ConversionFailedException; import org.onap.so.utils.CryptoUtils; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; @@ -80,7 +80,7 @@ public class SubscriptionManager { this.msoKeyString = msoKeyString; } - public Optional<InlineResponse2002> createSubscription(final PkgmSubscriptionRequest pkgmSubscriptionRequest) + public Optional<InlineResponse201> createSubscription(final PkgmSubscriptionRequest pkgmSubscriptionRequest) throws GeneralSecurityException { final org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest etsiCatalogManagerSubscriptionRequest = @@ -97,14 +97,14 @@ public class SubscriptionManager { packageManagementCacheServiceProvider.addSubscription(subscriptionId, pkgmSubscriptionRequest); - final InlineResponse2002 response2002 = new InlineResponse2002(); - response2002.setId(subscriptionId); - response2002.setFilter(pkgmSubscriptionRequest.getFilter()); - response2002.setCallbackUri(getSubscriptionUri(subscriptionId).toString()); - response2002.setLinks(new SubscriptionsLinks() + final InlineResponse201 response = new InlineResponse201(); + response.setId(subscriptionId); + response.setFilter(pkgmSubscriptionRequest.getFilter()); + response.setCallbackUri(getSubscriptionUri(subscriptionId).toString()); + response.setLinks(new SubscriptionsLinks() .self(new VnfPackagesLinksSelf().href(getSubscriptionUri(subscriptionId).toString()))); - return Optional.of(response2002); + return Optional.of(response); } throw new InternalServerErrorException( "Received empty response from POST to ETSI Catalog Manager Subscription Endpoint."); @@ -114,7 +114,7 @@ public class SubscriptionManager { return packageManagementCacheServiceProvider.getSubscriptionId(pkgmSubscriptionRequest); } - public Optional<InlineResponse2002> getSubscription(final String subscriptionId) { + public Optional<InlineResponse201> getSubscription(final String subscriptionId) { logger.debug("Checking if subscrition with id: {} exists in ETSI Catalog Manager", subscriptionId); final Optional<NsdmSubscription> etsiCatalogSubscriptionOption = @@ -137,12 +137,12 @@ public class SubscriptionManager { return Optional.empty(); } - public List<InlineResponse2002> getSubscriptions() { + public List<InlineResponse201> getSubscriptions() { final Map<String, PkgmSubscriptionRequest> subscriptions = packageManagementCacheServiceProvider.getSubscriptions(); - final List<InlineResponse2002> response = new ArrayList<>(); + final List<InlineResponse201> response = new ArrayList<>(); subscriptions.forEach((key, value) -> { - final Optional<InlineResponse2002> optional = getSubscription(key); + final Optional<InlineResponse201> optional = getSubscription(key); if (optional.isPresent()) { response.add(optional.get()); } @@ -175,8 +175,8 @@ public class SubscriptionManager { return packageManagementCacheServiceProvider.getSubscription(subscriptionId); } - private InlineResponse2002 getInlineResponse2002(final String id, final PkgmSubscriptionRequest subscription) { - return new InlineResponse2002().id(id).filter(subscription.getFilter()) + private InlineResponse201 getInlineResponse2002(final String id, final PkgmSubscriptionRequest subscription) { + return new InlineResponse201().id(id).filter(subscription.getFilter()) .callbackUri(subscription.getCallbackUri()); } diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionController.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionController.java index 6db3797f9b..515e317496 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionController.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionController.java @@ -28,7 +28,7 @@ import java.util.List; import java.util.Optional; import javax.ws.rs.core.MediaType; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.ProblemDetails; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2002; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse201; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest; import org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement.SubscriptionManager; import org.slf4j.Logger; @@ -92,15 +92,15 @@ public class Sol003PackageManagementSubscriptionController { } logger.debug("No duplicate Subscription exists, continuing with POST."); - final Optional<InlineResponse2002> optionalInlineResponse2002 = + final Optional<InlineResponse201> optionalInlineResponse = subscriptionManager.createSubscription(pkgmSubscriptionRequest); - if (optionalInlineResponse2002.isPresent()) { - InlineResponse2002 inlineResponse2002 = optionalInlineResponse2002.get(); - final URI subscriptionUri = subscriptionManager.getSubscriptionUri(inlineResponse2002.getId()); + if (optionalInlineResponse.isPresent()) { + InlineResponse201 inlineResponse = optionalInlineResponse.get(); + final URI subscriptionUri = subscriptionManager.getSubscriptionUri(inlineResponse.getId()); final HttpHeaders headers = createLocationHeader(subscriptionUri); logger.debug("Sending response with uri {} ", subscriptionUri); - return new ResponseEntity<>(inlineResponse2002, headers, HttpStatus.CREATED); + return new ResponseEntity<>(inlineResponse, headers, HttpStatus.CREATED); } final String errorMessage = "A null response was received during the postSubscriptionRequest call."; logger.error(errorMessage); @@ -113,9 +113,9 @@ public class Sol003PackageManagementSubscriptionController { * @return All of the current active subscriptions. Object: List<InlineResponse2002> Response Code: 200 OK */ @GetMapping(value = "/subscriptions") - public ResponseEntity<List<InlineResponse2002>> getSubscriptions() { + public ResponseEntity<List<InlineResponse201>> getSubscriptions() { logger.info(LOG_REQUEST_RECEIVED, " getSubscriptions."); - List<InlineResponse2002> subscriptionsList = subscriptionManager.getSubscriptions(); + List<InlineResponse201> subscriptionsList = subscriptionManager.getSubscriptions(); return new ResponseEntity<>(subscriptionsList, HttpStatus.OK); } @@ -128,7 +128,7 @@ public class Sol003PackageManagementSubscriptionController { @GetMapping(value = "/subscriptions/{subscriptionId}") public ResponseEntity<?> getSubscription(@PathVariable("subscriptionId") final String subscriptionId) { logger.info(LOG_REQUEST_RECEIVED, " Getting Subscription: ", subscriptionId); - final Optional<InlineResponse2002> optional = subscriptionManager.getSubscription(subscriptionId); + final Optional<InlineResponse201> optional = subscriptionManager.getSubscription(subscriptionId); if (optional.isPresent()) { logger.debug("Return subscription with id {} and body {}", subscriptionId, optional); return new ResponseEntity<>(optional.get(), HttpStatus.OK); diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionControllerTest.java index 7466895d97..9016cad528 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionControllerTest.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionControllerTest.java @@ -54,15 +54,16 @@ import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.LinkSelf; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.NsdmSubscription; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscription; +import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.ProblemDetails; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.SubscriptionAuthentication; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.Version; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfProducts; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfProductsProviders; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2002; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse201; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthentication; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter.NotificationTypesEnum; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter1; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilterVnfProductsFromProviders; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsLinks; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.VnfPackagesLinksSelf; @@ -132,8 +133,8 @@ public class Sol003PackageManagementSubscriptionControllerTest { @Test public void testSuccessPostSubscription() throws GeneralSecurityException, URISyntaxException { final PkgmSubscriptionRequest pkgmSubscriptionRequest = postSubscriptionForTest(); - final ResponseEntity<InlineResponse2002> response = - (ResponseEntity<InlineResponse2002>) sol003PackageManagementSubscriptionController + final ResponseEntity<InlineResponse201> response = + (ResponseEntity<InlineResponse201>) sol003PackageManagementSubscriptionController .postSubscriptionRequest(pkgmSubscriptionRequest); final HttpHeaders headers = buildHttpHeaders(Objects.requireNonNull(response.getBody()).getCallbackUri()); @@ -178,22 +179,22 @@ public class Sol003PackageManagementSubscriptionControllerTest { mockRestServiceServer.expect(requestTo(msbEndpoint + "/" + ID)).andExpect(method(HttpMethod.GET)) .andRespond(withSuccess(gson.toJson(new NsdmSubscription().id(ID)), MediaType.APPLICATION_JSON)); - final ResponseEntity<InlineResponse2002> response = - (ResponseEntity<InlineResponse2002>) sol003PackageManagementSubscriptionController + final ResponseEntity<InlineResponse201> response = + (ResponseEntity<InlineResponse201>) sol003PackageManagementSubscriptionController .postSubscriptionRequest(pkgmSubscriptionRequest); final String subscriptionId = response.getBody().getId(); - final ResponseEntity<InlineResponse2002> response2002 = - (ResponseEntity<InlineResponse2002>) sol003PackageManagementSubscriptionController + final ResponseEntity<InlineResponse201> responseEntity = + (ResponseEntity<InlineResponse201>) sol003PackageManagementSubscriptionController .getSubscription(subscriptionId); final HttpHeaders headers = buildHttpHeaders(response.getBody().getCallbackUri()); assertEquals(response.getBody().getFilter(), pkgmSubscriptionRequest.getFilter()); assertEquals(response.getHeaders(), headers); - assertEquals(HttpStatus.OK, response2002.getStatusCode()); + assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); assertEquals(pkgmSubscriptionRequest.getFilter(), response.getBody().getFilter()); // Ensure CallBackUri is set to new URI assertNotEquals(pkgmSubscriptionRequest.getCallbackUri(), response.getBody().getCallbackUri()); @@ -204,10 +205,9 @@ public class Sol003PackageManagementSubscriptionControllerTest { final String invalidId = "invalidSubscriptionId"; mockRestServiceServer.expect(requestTo(msbEndpoint + "/" + invalidId)).andExpect(method(HttpMethod.GET)) .andRespond(withStatus(HttpStatus.NOT_FOUND)); - final ResponseEntity<InlineResponse2002> response = - (ResponseEntity<InlineResponse2002>) sol003PackageManagementSubscriptionController - .getSubscription(invalidId); + final ResponseEntity<?> response = sol003PackageManagementSubscriptionController.getSubscription(invalidId); assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode()); + assertTrue(response.getBody() instanceof ProblemDetails); } @Test @@ -221,14 +221,14 @@ public class Sol003PackageManagementSubscriptionControllerTest { .andRespond(withSuccess(gson.toJson(new NsdmSubscription().id(ID)), MediaType.APPLICATION_JSON)); sol003PackageManagementSubscriptionController.postSubscriptionRequest(pkgmSubscriptionRequest); - final ResponseEntity<List<InlineResponse2002>> response = + final ResponseEntity<List<InlineResponse201>> response = sol003PackageManagementSubscriptionController.getSubscriptions(); - final List<InlineResponse2002> subscriptionsList = response.getBody(); + final List<InlineResponse201> subscriptionsList = response.getBody(); assertEquals(Objects.requireNonNull(response.getBody()).get(0).getFilter(), pkgmSubscriptionRequest.getFilter()); - assert (subscriptionsList != null); + assertNotNull(subscriptionsList != null); assertNotEquals('0', subscriptionsList.size()); assertEquals(HttpStatus.OK, response.getStatusCode()); } @@ -310,13 +310,13 @@ public class Sol003PackageManagementSubscriptionControllerTest { .andRespond(withSuccess(gson.toJson(buildPkgmSubscription()), MediaType.APPLICATION_JSON)); - final ResponseEntity<InlineResponse2002> responseEntity = testRestTemplate.postForEntity( + final ResponseEntity<InlineResponse201> responseEntity = testRestTemplate.postForEntity( LOCALHOST_URL + port + Constants.PACKAGE_MANAGEMENT_BASE_URL + "/subscriptions", request, - InlineResponse2002.class); + InlineResponse201.class); assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode()); assertTrue(responseEntity.hasBody()); - final InlineResponse2002 actual = responseEntity.getBody(); + final InlineResponse201 actual = responseEntity.getBody(); assertEquals(ID, actual.getId()); @@ -340,7 +340,7 @@ public class Sol003PackageManagementSubscriptionControllerTest { private PkgmSubscriptionRequest buildPkgmSubscriptionRequest() { final PkgmSubscriptionRequest pkgmSubscriptionRequest = new PkgmSubscriptionRequest(); - final SubscriptionsFilter sub = buildSubscriptionsFilter(); + final SubscriptionsFilter1 sub = buildSubscriptionsFilter(); final SubscriptionsAuthentication auth = new SubscriptionsAuthentication(); pkgmSubscriptionRequest.setFilter(sub); pkgmSubscriptionRequest.setCallbackUri(msbEndpoint.toString()); @@ -348,11 +348,11 @@ public class Sol003PackageManagementSubscriptionControllerTest { return pkgmSubscriptionRequest; } - private SubscriptionsFilter buildSubscriptionsFilter() { - final SubscriptionsFilter sub = new SubscriptionsFilter(); + private SubscriptionsFilter1 buildSubscriptionsFilter() { + final SubscriptionsFilter1 sub = new SubscriptionsFilter1(); final List<String> vnfdIdList = new ArrayList<>(); final List<String> vnfPkgIdList = new ArrayList<>(); - final List<NotificationTypesEnum> notificationTypes = new ArrayList<>(); + final List<SubscriptionsFilter1.NotificationTypesEnum> notificationTypes = new ArrayList<>(); final SubscriptionsFilterVnfProductsFromProviders subscriptionsFilterVnfProductsFromProviders = new SubscriptionsFilterVnfProductsFromProviders(); final List<SubscriptionsFilterVnfProductsFromProviders> vnfProductsFromProviders = new ArrayList<>(); diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/requests/SubscriptionRequest.json b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/requests/SubscriptionRequest.json index 85ffb99d8d..c38466f8e5 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/requests/SubscriptionRequest.json +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/requests/SubscriptionRequest.json @@ -28,7 +28,7 @@ "vnfPkgId": [ "VNFPKGID" ], - "operationalState": "ENABLED" + "operationalState": ["ENABLED"] }, "callbackUri": "http://so-vnfm-adapter:9093/api/vnfpkgm/v1/subscriptions", "authentication": diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/ASDCControllerSingleton.java b/asdc-controller/src/main/java/org/onap/so/asdc/ASDCControllerSingleton.java index ecffb683ca..fe166f7942 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/ASDCControllerSingleton.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/ASDCControllerSingleton.java @@ -24,15 +24,13 @@ package org.onap.so.asdc; import java.security.SecureRandom; import javax.annotation.PreDestroy; -import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.asdc.client.ASDCController; import org.onap.so.asdc.client.exceptions.ASDCControllerException; -import org.onap.so.logger.ErrorCode; -import org.onap.so.logger.ScheduledTasksMDCSetup; -import org.onap.so.utils.Components; +import org.onap.logging.filter.base.ErrorCode; +import org.onap.logging.filter.base.ScheduledLogging; +import org.onap.logging.filter.base.ScheduledTaskException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Profile; import org.springframework.scheduling.annotation.Scheduled; @@ -47,16 +45,13 @@ public class ASDCControllerSingleton { private final ASDCController asdcController; @Autowired - private ScheduledTasksMDCSetup scheduledMDCSetup; - - @Autowired public ASDCControllerSingleton(final ASDCController asdcController) { this.asdcController = asdcController; } + @ScheduledLogging @Scheduled(fixedRate = 50000) - public void periodicControllerTask() { - scheduledMDCSetup.mdcSetup(Components.ASDC_CONTROLLER, "periodicControllerTask"); + public void periodicControllerTask() throws ScheduledTaskException { try { final int randomNumber = new SecureRandom().nextInt(Integer.MAX_VALUE); asdcController.setControllerName("mso-controller" + randomNumber); @@ -66,11 +61,9 @@ public class ASDCControllerSingleton { asdcController.initASDC(); } } catch (final ASDCControllerException controllerException) { - scheduledMDCSetup.errorMDCSetup(ErrorCode.UnknownError, controllerException.getMessage()); - MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.ERROR.toString()); - logger.error("Exception occurred", controllerException); + throw new ScheduledTaskException(ErrorCode.UnknownError, controllerException.getMessage(), + controllerException); } - scheduledMDCSetup.exitAndClearMDC(); } @PreDestroy diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java index e084cfec18..ad96e1be4b 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java @@ -74,7 +74,7 @@ import org.onap.so.db.request.beans.WatchdogComponentDistributionStatus; import org.onap.so.db.request.beans.WatchdogDistributionStatus; import org.onap.so.db.request.data.repository.WatchdogComponentDistributionStatusRepository; import org.onap.so.db.request.data.repository.WatchdogDistributionStatusRepository; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCStatusCallBack.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCStatusCallBack.java index d0f86c722e..d59984bb52 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCStatusCallBack.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCStatusCallBack.java @@ -6,12 +6,14 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ + * Modifications Copyright (c) 2020 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. @@ -52,21 +54,25 @@ public final class ASDCStatusCallBack implements IStatusCallback { try { - if (iStatus.getStatus() != null) { - if (iStatus.getStatus().equals(DistributionStatusEnum.COMPONENT_DONE_OK) - || iStatus.getStatus().equals(DistributionStatusEnum.COMPONENT_DONE_ERROR)) { - WatchdogDistributionStatus watchdogDistributionStatus = watchdogDistributionStatusRepository - .findById(iStatus.getDistributionID()).orElseGet(() -> null); - if (watchdogDistributionStatus == null) { - watchdogDistributionStatus = new WatchdogDistributionStatus(); - watchdogDistributionStatus.setDistributionId(iStatus.getDistributionID()); - watchdogDistributionStatusRepository.save(watchdogDistributionStatus); - } - logger.debug(event); - toscaInstaller.installTheComponentStatus(iStatus); - - } + if (iStatus.getStatus() == null) { + logger.info("Missing status on Status Object. "); + return; + } + if (!iStatus.getStatus().equals(DistributionStatusEnum.COMPONENT_DONE_OK) + && !iStatus.getStatus().equals(DistributionStatusEnum.COMPONENT_DONE_ERROR)) { + logger.info("Status is not 'Component Done OK' or 'Component Done Error'"); + return; } + WatchdogDistributionStatus watchdogDistributionStatus = + watchdogDistributionStatusRepository.findById(iStatus.getDistributionID()).orElseGet(() -> null); + if (watchdogDistributionStatus == null) { + watchdogDistributionStatus = new WatchdogDistributionStatus(); + watchdogDistributionStatus.setDistributionId(iStatus.getDistributionID()); + watchdogDistributionStatusRepository.save(watchdogDistributionStatus); + } + logger.debug(event); + toscaInstaller.installTheComponentStatus(iStatus); + } catch (ArtifactInstallerException e) { logger.error("Error in ASDCStatusCallback {}", e.getMessage(), e); logger.debug("Error in ASDCStatusCallback {}", e.getMessage()); diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/FinalDistributionStatusMessage.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/FinalDistributionStatusMessage.java index 13cace404e..0a1b1c531e 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/client/FinalDistributionStatusMessage.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/FinalDistributionStatusMessage.java @@ -4,12 +4,14 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2020 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. @@ -37,7 +39,6 @@ public class FinalDistributionStatusMessage implements IFinalDistrStatusMessage public FinalDistributionStatusMessage(String distributionId, final DistributionStatusEnum distributionStatusEnum, final long timestampL, String consumerId) { - // componentName = componentname; consumerID = consumerId; distributionID = distributionId; status = distributionStatusEnum; @@ -68,6 +69,7 @@ public class FinalDistributionStatusMessage implements IFinalDistrStatusMessage this.timestamp = timestamp; } + @Override public String getComponentName() { return componentName; } @@ -76,6 +78,7 @@ public class FinalDistributionStatusMessage implements IFinalDistrStatusMessage this.componentName = componentName; } + @Override public String getConsumerID() { return consumerID; } diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/JsonStatusData.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/JsonStatusData.java index 7bd9c752a4..34f21ab813 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/JsonStatusData.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/JsonStatusData.java @@ -4,12 +4,14 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2020 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. @@ -50,43 +52,37 @@ public class JsonStatusData implements IStatusData { @Override public String getDistributionID() { - // return (String)this.attributesMap.get("distributionID"); return "35120a87-1f82-4276-9735-f6de5a244d65"; } @Override public String getConsumerID() { - // return (String)this.attributesMap.get("consumerID"); return "mso.123456"; } @Override public String getComponentName() { - // return (String)this.attributesMap.get("componentName"); return "SDN-C"; } @Override public Long getTimestamp() { - // return (String)this.attributesMap.get("timestamp"); return null; } @Override public String getArtifactURL() { - // return (String)this.attributesMap.get("artifactURL"); return "/sdc/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml"; } @Override public DistributionStatusEnum getStatus() { - // return (DistributionStatusEnum)this.attributesMap.get(DistributionStatusEnum.DEPLOY_OK); return DistributionStatusEnum.COMPONENT_DONE_OK; } /** * Method instantiate a INotificationData implementation from a JSON file. - * + * * @param notifFilePath The file path in String * @return A JsonNotificationData instance * @throws IOException in case of the file is not readable or not accessible @@ -96,19 +92,6 @@ public class JsonStatusData implements IStatusData { InputStream is = Thread.currentThread().getContextClassLoader() .getResourceAsStream(notifFilePath + "status-structure.json"); - // String fileLocation = System.getProperty("mso.config.path") + "notif-structure.json"; - - // String source = fileLocation; - // InputStream is = IOUtils.toInputStream(source, "UTF-8"); - - // String myString = IOUtils.toString(is, "UTF-8"); - - - // System.out.println(myString); - - if (is == null) { - // throw new FileExistsException("Resource Path does not exist: "+notifFilePath); - } return mapper.readValue(is, JsonStatusData.class); } diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/rest/ASDCRestInterface.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/rest/ASDCRestInterface.java index a9d06d8e82..42778507f0 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/rest/ASDCRestInterface.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/rest/ASDCRestInterface.java @@ -36,7 +36,7 @@ import org.onap.so.asdc.client.test.emulators.DistributionClientEmulator; import org.onap.so.asdc.client.test.emulators.JsonStatusData; import org.onap.so.asdc.client.test.emulators.NotificationDataImpl; import org.onap.so.asdc.installer.heat.ToscaResourceInstaller; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java index dcb49478f4..04d4b0c2dc 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java @@ -50,7 +50,7 @@ import org.onap.so.db.catalog.beans.ToscaCsar; import org.onap.so.db.catalog.beans.VfModule; import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.VnfResourceCustomization; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleStructure.java index 36d6ab96c0..11c1cc33cf 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleStructure.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleStructure.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2020 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 @@ -25,8 +27,6 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; -import org.onap.sdc.api.notification.IVfModuleMetadata; -import org.onap.so.asdc.client.ASDCConfiguration; import org.onap.so.asdc.client.exceptions.ArtifactInstallerException; import org.onap.so.db.catalog.beans.VfModule; @@ -73,23 +73,6 @@ public final class VfModuleStructure { } } - public List<VfModuleArtifact> getOrderedArtifactList() { - - List<VfModuleArtifact> artifactsList = new LinkedList<>(); - - artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT)); - artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_ENV)); - artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_VOL)); - - artifactsList.addAll((artifactsMap.get(ASDCConfiguration.HEAT_NESTED))); - - artifactsList.addAll((artifactsMap.get(ASDCConfiguration.HEAT_ARTIFACT))); - - artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_VOL)); - - return null; - } - public IVfModuleData getVfModuleMetadata() { return vfModuleMetadata; } diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java index f954fe0c5a..f5b0e17cf5 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java @@ -7,6 +7,8 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ + * Modifications Copyright (c) 2020 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 @@ -77,39 +79,38 @@ public class VfResourceStructure extends ResourceStructure { private Service catalogService; - public VfResourceStructure(INotificationData notificationdata, IResourceInstance resourceinstance) { - super(notificationdata, resourceinstance); + public VfResourceStructure(INotificationData notificationData, IResourceInstance resourceInstance) { + super(notificationData, resourceInstance); this.resourceType = ResourceType.VF_RESOURCE; vfModulesStructureList = new LinkedList<>(); vfModulesMetadataList = new ArrayList<>(); } - public void addArtifactToStructure(IDistributionClient distributionClient, IArtifactInfo artifactinfo, + public void addArtifactToStructure(IDistributionClient distributionClient, IArtifactInfo artifactInfo, IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException { - this.addArtifactToStructure(distributionClient, artifactinfo, clientResult, null); + this.addArtifactToStructure(artifactInfo, clientResult, null); } - public void addArtifactToStructure(IDistributionClient distributionClient, IArtifactInfo artifactinfo, - IDistributionClientDownloadResult clientResult, String modifiedHeatTemplate) - throws UnsupportedEncodingException { - VfModuleArtifact vfModuleArtifact = new VfModuleArtifact(artifactinfo, clientResult, modifiedHeatTemplate); - addArtifactByType(artifactinfo, clientResult, vfModuleArtifact); - if (ASDCConfiguration.VF_MODULES_METADATA.equals(artifactinfo.getArtifactType())) { + public void addArtifactToStructure(IArtifactInfo artifactInfo, IDistributionClientDownloadResult clientResult, + String modifiedHeatTemplate) throws UnsupportedEncodingException { + VfModuleArtifact vfModuleArtifact = new VfModuleArtifact(artifactInfo, clientResult, modifiedHeatTemplate); + addArtifactByType(artifactInfo, clientResult, vfModuleArtifact); + if (ASDCConfiguration.VF_MODULES_METADATA.equals(artifactInfo.getArtifactType())) { logger.debug("VF_MODULE_ARTIFACT: " + new String(clientResult.getArtifactPayload(), "UTF-8")); logger.debug(ASDCNotificationLogging.dumpVfModuleMetaDataList(vfModulesMetadataList)); } } - public void addWorkflowArtifactToStructure(IArtifactInfo artifactinfo, + public void addWorkflowArtifactToStructure(IArtifactInfo artifactInfo, IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException { - WorkflowArtifact workflowArtifact = new WorkflowArtifact(artifactinfo, clientResult); - workflowArtifactsMapByUUID.put(artifactinfo.getArtifactUUID(), workflowArtifact); + WorkflowArtifact workflowArtifact = new WorkflowArtifact(artifactInfo, clientResult); + workflowArtifactsMapByUUID.put(artifactInfo.getArtifactUUID(), workflowArtifact); } - protected void addArtifactByType(IArtifactInfo artifactinfo, IDistributionClientDownloadResult clientResult, + protected void addArtifactByType(IArtifactInfo artifactInfo, IDistributionClientDownloadResult clientResult, VfModuleArtifact vfModuleArtifact) { - switch (artifactinfo.getArtifactType()) { + switch (artifactInfo.getArtifactType()) { case ASDCConfiguration.HEAT: case ASDCConfiguration.HEAT_ENV: case ASDCConfiguration.HEAT_VOL: @@ -118,7 +119,7 @@ public class VfResourceStructure extends ResourceStructure { case ASDCConfiguration.HEAT_NET: case ASDCConfiguration.OTHER: case ASDCConfiguration.CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT: - artifactsMapByUUID.put(artifactinfo.getArtifactUUID(), vfModuleArtifact); + artifactsMapByUUID.put(artifactInfo.getArtifactUUID(), vfModuleArtifact); break; case ASDCConfiguration.VF_MODULES_METADATA: vfModulesMetadataList = this.decodeVfModuleArtifact(clientResult.getArtifactPayload()); @@ -196,9 +197,7 @@ public class VfResourceStructure extends ResourceStructure { public List<IVfModuleData> decodeVfModuleArtifact(byte[] arg0) { try { - List<IVfModuleData> listVFModuleMetaData = - new ObjectMapper().readValue(arg0, new TypeReference<List<VfModuleMetaData>>() {}); - return listVFModuleMetaData; + return new ObjectMapper().readValue(arg0, new TypeReference<List<VfModuleMetaData>>() {}); } catch (JsonParseException e) { logger.debug("JsonParseException : ", e); diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java index 195aa7e302..4253521dff 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java @@ -6,6 +6,8 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ + * Modifications Copyright (c) 2020 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 @@ -27,6 +29,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.net.URI; +import java.net.URISyntaxException; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Enumeration; @@ -47,7 +50,7 @@ import org.apache.http.entity.mime.content.ByteArrayBody; import org.apache.http.entity.mime.content.StringBody; import org.apache.http.impl.client.HttpClientBuilder; import org.onap.so.asdc.client.ASDCConfiguration; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; @@ -107,18 +110,15 @@ public class BpmnInstaller { logger.error(LoggingAnchor.FIVE, MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL.toString(), csarFilePath, ex.getMessage(), ErrorCode.DataError.getValue(), "ASDC reading CSAR with workflows failed"); } - return; } public boolean containsWorkflows(String csarFilePath) { - boolean workflowsInCsar = false; try (ZipFile zipFile = new ZipFile(csarFilePath)) { Enumeration<? extends ZipEntry> zipEntries = zipFile.entries(); while (zipEntries.hasMoreElements()) { String fileName = zipEntries.nextElement().getName(); if (fileName.endsWith(BPMN_SUFFIX)) { - workflowsInCsar = true; - break; + return true; } } } catch (Exception e) { @@ -126,10 +126,11 @@ public class BpmnInstaller { logger.error(LoggingAnchor.FIVE, MessageEnum.ASDC_ARTIFACT_CHECK_EXC.toString(), csarFilePath, e.getMessage(), ErrorCode.DataError.getValue(), "ASDC Unable to check CSAR entries"); } - return workflowsInCsar; + return false; } - protected HttpResponse sendDeploymentRequest(String bpmnFileName, String version) throws Exception { + protected HttpResponse sendDeploymentRequest(String bpmnFileName, String version) + throws IOException, URISyntaxException { HttpClient client = HttpClientBuilder.create().build(); URI deploymentUri = new URI(this.env.getProperty(CAMUNDA_URL) + CREATE_DEPLOYMENT_PATH); HttpPost post = new HttpPost(deploymentUri); @@ -141,7 +142,7 @@ public class BpmnInstaller { return client.execute(post); } - protected HttpEntity buildMimeMultipart(String bpmnFileName, String version) throws Exception { + protected HttpEntity buildMimeMultipart(String bpmnFileName, String version) throws IOException { FileInputStream bpmnFileStream = new FileInputStream( Paths.get(getMsoConfigPath(), "ASDC", version, bpmnFileName).normalize().toString()); @@ -182,17 +183,14 @@ public class BpmnInstaller { return requestEntity; } - /* protected void extractBpmnFileFromCsar(ZipInputStream zipIn, String fileName) throws IOException */ protected void extractBpmnFileFromCsar(ZipInputStream zipIn, String fileName) { String filePath = Paths.get(System.getProperty("mso.config.path"), "ASDC", fileName).normalize().toString(); - /* BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(filePath)); */ try (BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(filePath))) { byte[] bytesIn = new byte[4096]; - int read = 0; + int read; while ((read = zipIn.read(bytesIn)) != -1) { outputStream.write(bytesIn, 0, read); } - /* outputStream.close(); */ } catch (IOException e) { logger.error("Unable to open file.", e); } diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/WorkflowResource.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/WorkflowResource.java index ef4dfa24aa..1f111ba7a0 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/WorkflowResource.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/WorkflowResource.java @@ -40,7 +40,7 @@ import org.onap.so.db.catalog.beans.WorkflowActivitySpecSequence; import org.onap.so.db.catalog.data.repository.ActivitySpecRepository; import org.onap.so.db.catalog.data.repository.VnfResourceRepository; import org.onap.so.db.catalog.data.repository.WorkflowRepository; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java index 1c7ebb7d9a..423c1a7ed6 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java @@ -83,7 +83,7 @@ import org.onap.so.db.request.beans.WatchdogServiceModVerIdLookup; import org.onap.so.db.request.data.repository.WatchdogComponentDistributionStatusRepository; import org.onap.so.db.request.data.repository.WatchdogDistributionStatusRepository; import org.onap.so.db.request.data.repository.WatchdogServiceModVerIdLookupRepository; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy index ee70dcc89c..ecd90165c2 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy @@ -24,7 +24,7 @@ package org.onap.so.bpmn.common.scripts import org.onap.so.logger.LoggingAnchor import org.onap.so.client.HttpClientFactory -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import java.util.regex.Matcher import java.util.regex.Pattern diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy index 976ad1466d..e83e7e2ea2 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy @@ -32,6 +32,7 @@ import org.onap.so.bpmn.common.workflow.context.WorkflowCallbackResponse import org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.client.HttpClientFactory import org.onap.so.client.aai.AAIResourcesClient import org.springframework.web.util.UriUtils import org.slf4j.Logger @@ -677,4 +678,8 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess public AAIResourcesClient getAAIClient(){ return new AAIResourcesClient(); } + + HttpClientFactory getHttpClientFactory(){ + return new HttpClientFactory() + } } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy index 4df38edcc3..e5fff9c100 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy @@ -24,7 +24,7 @@ package org.onap.so.bpmn.common.scripts import org.onap.so.logger.LoggingAnchor import org.onap.so.client.aai.entities.AAIResultWrapper -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import static org.apache.commons.lang3.StringUtils.isBlank; diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AppCClient.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AppCClient.groovy index c843cc35fe..6b021834b3 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AppCClient.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AppCClient.groovy @@ -28,7 +28,7 @@ import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.core.json.JsonUtils import org.onap.appc.client.lcm.model.Action import org.onap.so.client.appc.ApplicationControllerAction -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy index 83784e1960..7b49fa06b3 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy @@ -32,7 +32,7 @@ import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.client.HttpClient import org.onap.so.client.HttpClientFactory -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy index 841fe9f50e..48a8e60095 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy @@ -27,7 +27,7 @@ import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.db.request.beans.InfraActiveRequests import org.onap.so.db.request.client.RequestsDbClient -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy index b666c8d19d..9c8d8bfa12 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy @@ -30,7 +30,7 @@ import org.onap.so.client.aai.AAIObjectType import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.constants.Defaults -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy index 569d4b75b9..24375e59cc 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy @@ -32,7 +32,7 @@ import org.onap.so.client.aai.entities.Relationships import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.constants.Defaults -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy index 163e914238..b43a153acb 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy @@ -33,7 +33,7 @@ import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.client.graphinventory.entities.uri.Depth import org.onap.so.db.catalog.beans.OrchestrationStatus -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy index 4d57b1b26f..4b33676955 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy @@ -29,7 +29,7 @@ import org.onap.so.client.aai.AAIObjectType import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.client.graphinventory.entities.uri.Depth -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExceptionUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExceptionUtil.groovy index 195b1fc0d6..38f7bf445f 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExceptionUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExceptionUtil.groovy @@ -23,7 +23,7 @@ package org.onap.so.bpmn.common.scripts import org.onap.so.logger.LoggingAnchor -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import static org.apache.commons.lang3.StringUtils.* diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/FalloutHandler.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/FalloutHandler.groovy index 8306f33592..c294f1b8c3 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/FalloutHandler.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/FalloutHandler.groovy @@ -26,7 +26,7 @@ import org.onap.so.logger.LoggingAnchor import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.db.request.beans.InfraActiveRequests import org.onap.so.db.request.client.RequestsDbClient -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.bpmn.core.UrnPropertiesReader; import java.text.SimpleDateFormat diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy index 6d4b50f690..203ccb97f6 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy @@ -25,7 +25,7 @@ package org.onap.so.bpmn.common.scripts import org.onap.so.logger.LoggingAnchor import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.client.HttpClientFactory -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import java.io.Serializable; diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ManualHandling.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ManualHandling.groovy index 615964b2a9..a1e3576d86 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ManualHandling.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ManualHandling.groovy @@ -23,7 +23,7 @@ package org.onap.so.bpmn.common.scripts import org.onap.so.logger.LoggingAnchor -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import static org.apache.commons.lang3.StringUtils.*; diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy index a2f5dfbffe..eea476a278 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy @@ -23,7 +23,7 @@ package org.onap.so.bpmn.common.scripts import org.onap.so.logger.LoggingAnchor -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import java.text.SimpleDateFormat diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ReceiveWorkflowMessage.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ReceiveWorkflowMessage.groovy index 39e6db4d3f..f012eabe5e 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ReceiveWorkflowMessage.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ReceiveWorkflowMessage.groovy @@ -30,7 +30,7 @@ import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy index ce474fa713..b35042e3c0 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy @@ -49,8 +49,8 @@ class RequestDBUtil { String operationType = operationStatus.getOperation() String result = operationStatus.getResult() String progress = operationStatus.getProgress() - String operationContent = operationStatus.getOperationContent() - String reason = operationStatus.getReason() + String operationContent = operationStatus.getOperationContent()?: "" + String reason = operationStatus.getReason()?: "" String payload = """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapter.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapter.groovy index db39358ccd..f9119dcb1d 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapter.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapter.groovy @@ -24,7 +24,7 @@ package org.onap.so.bpmn.common.scripts import org.onap.so.logger.LoggingAnchor import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import java.text.SimpleDateFormat diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy index 52d6758b2b..ebaf65ff81 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy @@ -24,7 +24,7 @@ package org.onap.so.bpmn.common.scripts import org.onap.so.logger.LoggingAnchor import org.onap.so.client.HttpClientFactory -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import java.text.SimpleDateFormat import javax.ws.rs.core.Response diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy index ba5145d19b..753d4403f3 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy @@ -23,7 +23,7 @@ package org.onap.so.bpmn.common.scripts import org.onap.so.logger.LoggingAnchor -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import java.text.SimpleDateFormat import java.net.URLEncoder diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy index f24eda813d..2455305b4e 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy @@ -28,7 +28,7 @@ import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.L3Network import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.springframework.web.util.UriUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.logger.MessageEnum diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/TrinityExceptionUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/TrinityExceptionUtil.groovy index 30964aa4ec..8075944c8c 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/TrinityExceptionUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/TrinityExceptionUtil.groovy @@ -25,7 +25,7 @@ package org.onap.so.bpmn.common.scripts import org.onap.so.logger.LoggingAnchor import org.camunda.bpm.engine.delegate.DelegateExecution import org.apache.commons.lang3.* -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy index 8f409fa13e..f19933fa8b 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy @@ -31,7 +31,7 @@ import org.onap.so.client.aai.AAIObjectType import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.client.graphinventory.entities.uri.Depth -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy index 20aeb11c5f..cfa384dc50 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy @@ -23,7 +23,7 @@ package org.onap.so.bpmn.common.scripts import org.onap.so.logger.LoggingAnchor -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import javax.xml.parsers.DocumentBuilder import javax.xml.parsers.DocumentBuilderFactory diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy index 803a3f71de..a6aacc7ea5 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy @@ -24,7 +24,7 @@ package org.onap.so.bpmn.common.scripts import org.onap.so.logger.LoggingAnchor import org.onap.so.client.HttpClientFactory -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import javax.ws.rs.core.Response import org.apache.commons.lang3.* diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterUtils.groovy index 6cfa2a1a64..91b29d3867 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterUtils.groovy @@ -26,7 +26,7 @@ import org.onap.so.logger.LoggingAnchor import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/BpmnRestClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/BpmnRestClient.java index d9356306b7..bd31c552d3 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/BpmnRestClient.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/BpmnRestClient.java @@ -34,7 +34,7 @@ import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.HttpClientBuilder; import org.onap.so.bpmn.core.UrnPropertiesReader; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.utils.CryptoUtils; import org.slf4j.Logger; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/workflow/context/WorkflowContextHolder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/workflow/context/WorkflowContextHolder.java index 047b1f3930..204611cb8f 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/workflow/context/WorkflowContextHolder.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/workflow/context/WorkflowContextHolder.java @@ -26,7 +26,7 @@ package org.onap.so.bpmn.common.workflow.context; import java.util.concurrent.DelayQueue; import java.util.concurrent.TimeUnit; import org.onap.so.logger.LoggingAnchor; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java index e7e51bba77..f0954c3695 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java @@ -662,6 +662,7 @@ public class BBInputSetup implements JavaDelegate { } protected void populateVolumeGroup(BBInputSetupParameter parameter) throws Exception { + String replaceVnfModelCustomizationUUID = null; VolumeGroup volumeGroup = null; GenericVnf vnf = null; String vnfModelCustomizationUUID = null; @@ -674,7 +675,11 @@ public class BBInputSetup implements JavaDelegate { for (RelatedInstanceList relatedInstList : parameter.getRelatedInstanceList()) { RelatedInstance relatedInstance = relatedInstList.getRelatedInstance(); if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)) { - vnfModelCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationUuid(); + if (parameter.getIsReplace()) { + replaceVnfModelCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationId(); + } else { + vnfModelCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationId(); + } break; } } @@ -685,8 +690,13 @@ public class BBInputSetup implements JavaDelegate { vnfModelCustomizationUUID = bbInputSetupUtils.getAAIGenericVnf(vnf.getVnfId()).getModelCustomizationId(); ModelInfo vnfModelInfo = new ModelInfo(); - vnfModelInfo.setModelCustomizationUuid(vnfModelCustomizationUUID); - mapCatalogVnf(tempVnf, vnfModelInfo, parameter.getService()); + if (parameter.getIsReplace()) { + vnfModelInfo.setModelCustomizationUuid(replaceVnfModelCustomizationUUID); + mapCatalogVnf(tempVnf, vnfModelInfo, parameter.getServiceModel().getNewService()); + } else { + vnfModelInfo.setModelCustomizationUuid(vnfModelCustomizationUUID); + mapCatalogVnf(tempVnf, vnfModelInfo, parameter.getServiceModel().getCurrentService()); + } break; } } @@ -696,6 +706,22 @@ public class BBInputSetup implements JavaDelegate { && volumeGroupTemp.getVolumeGroupId() .equalsIgnoreCase(parameter.getLookupKeyMap().get(ResourceKey.VOLUME_GROUP_ID))) { volumeGroup = volumeGroupTemp; + if (volumeGroup.getModelInfoVfModule() == null) { + throw new Exception( + "ModelInfoVfModule is null for VolumeGroup: " + volumeGroup.getVolumeGroupId()); + } + String volumeGroupCustId = volumeGroup.getModelInfoVfModule().getModelCustomizationUUID(); + ModelInfo modelInfoVolumeGroup = new ModelInfo(); + modelInfoVolumeGroup.setModelCustomizationId(volumeGroupCustId); + if (parameter.getIsReplace() && parameter.getLookupKeyMap().get(ResourceKey.VOLUME_GROUP_ID) != null + && volumeGroupTemp.getVolumeGroupId() + .equalsIgnoreCase(parameter.getLookupKeyMap().get(ResourceKey.VOLUME_GROUP_ID))) { + mapCatalogVolumeGroup(volumeGroupTemp, modelInfoVolumeGroup, + parameter.getServiceModel().getNewService(), replaceVnfModelCustomizationUUID); + } else { + mapCatalogVolumeGroup(volumeGroupTemp, modelInfoVolumeGroup, + parameter.getServiceModel().getCurrentService(), vnfModelCustomizationUUID); + } break; } } @@ -703,10 +729,13 @@ public class BBInputSetup implements JavaDelegate { volumeGroup = createVolumeGroup(parameter.getLookupKeyMap(), parameter.getResourceId(), parameter.getInstanceName(), generatedVnfType, parameter.getInstanceParams()); vnf.getVolumeGroups().add(volumeGroup); - } - if (volumeGroup != null) { - mapCatalogVolumeGroup(volumeGroup, parameter.getModelInfo(), parameter.getService(), - vnfModelCustomizationUUID); + if (parameter.getIsReplace()) { + mapCatalogVolumeGroup(volumeGroup, parameter.getModelInfo(), + parameter.getServiceModel().getNewService(), replaceVnfModelCustomizationUUID); + } else { + mapCatalogVolumeGroup(volumeGroup, parameter.getModelInfo(), + parameter.getServiceModel().getCurrentService(), vnfModelCustomizationUUID); + } } } else { logger.debug("Related VNF instance Id not found: {}", @@ -1514,6 +1543,9 @@ public class BBInputSetup implements JavaDelegate { parameter.setInstanceName(vfModules.getVolumeGroupInstanceName()); parameter.setVnfType(vnfType); parameter.setInstanceParams(vfModules.getInstanceParams()); + ServiceModel serviceModel = new ServiceModel(); + serviceModel.setCurrentService(service); + parameter.setServiceModel(serviceModel); this.populateVolumeGroup(parameter); } else { parameter.setResourceId(lookupKeyMap.get(ResourceKey.VF_MODULE_ID)); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java index 28ec71b13f..67d073d7b6 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java @@ -186,6 +186,9 @@ public class BBInputSetupMapperLayer { protected VolumeGroup mapAAIVolumeGroup(org.onap.aai.domain.yang.VolumeGroup aaiVolumeGroup) { VolumeGroup volumeGroup = modelMapper.map(aaiVolumeGroup, VolumeGroup.class); + ModelInfoVfModule modelInfo = new ModelInfoVfModule(); + modelInfo.setModelCustomizationUUID(aaiVolumeGroup.getModelCustomizationId()); + volumeGroup.setModelInfoVfModule(modelInfo); volumeGroup.setOrchestrationStatus(this.mapOrchestrationStatusFromAAI(aaiVolumeGroup.getOrchestrationStatus())); return volumeGroup; } 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 0a6ce05a06..2e9d4b0117 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 @@ -40,7 +40,7 @@ import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.onap.so.objects.audit.AAIObjectAudit; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/SDNCLcmPropertiesImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/SDNCLcmPropertiesImpl.java index eb2567d47c..9b46611468 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/SDNCLcmPropertiesImpl.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/SDNCLcmPropertiesImpl.java @@ -31,12 +31,14 @@ public class SDNCLcmPropertiesImpl implements SDNCLcmProperties { public static final String SDNC_HOST = "sdnc.host"; public static final String SDNC_AUTH = "sdnc.auth"; public static final String LCM_PATH = "sdnc.lcm.path"; + public static final String LCM_ACTION_TIMEOUT = "sdnc.lcm.actionTimeout"; public static final String DMAAP_HOST = "sdnc.dmaap.host"; public static final String DMAAP_AUTH = "sdnc.dmaap.auth"; - public static final String DMAAP_PARTITION = "sdnc.dmaap.partition"; public static final String DMAAP_TIMEOUT = "sdnc.dmaap.timeout"; public static final String DMAAP_ENVIRONMENT = "sdnc.dmaap.environment"; + + public static final String LCM_DMAAP_PARTITION = "sdnc.lcm.dmaap.partition"; public static final String LCM_DMAAP_READ_TOPIC = "sdnc.lcm.dmapp.readTopic"; public static final String LCM_DMAAP_WRITE_TOPIC = "sdnc.lcm.dmaap.writeTopic"; @@ -56,6 +58,12 @@ public class SDNCLcmPropertiesImpl implements SDNCLcmProperties { } @Override + public long getActionTimeout() { + String actionTimeout = UrnPropertiesReader.getVariable(LCM_ACTION_TIMEOUT); + return (actionTimeout != null) ? Long.parseLong(actionTimeout) : SDNCConstants.LCM_ACTION_TIMEOUT; + } + + @Override public String getBasicAuth() { return UrnPropertiesReader.getVariable(SDNC_AUTH); } @@ -72,7 +80,7 @@ public class SDNCLcmPropertiesImpl implements SDNCLcmProperties { @Override public String getDmaapPartition() { - String partition = UrnPropertiesReader.getVariable(DMAAP_PARTITION); + String partition = UrnPropertiesReader.getVariable(LCM_DMAAP_PARTITION); return (partition != null) ? partition : SDNCConstants.LCM_DMAAP_PARTITION; } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SDNCConstants.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SDNCConstants.java index fd9412e70e..dcbb120c69 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SDNCConstants.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SDNCConstants.java @@ -45,5 +45,6 @@ public interface SDNCConstants { String LCM_DMAAP_READ_TOPIC = "SDNC-LCM-WRITE"; String LCM_DMAAP_WRITE_TOPIC = "SDNC-LCM-READ"; - int LCM_TIMEOUT = 300; + long LCM_ACTION_TIMEOUT = 300000; // Millisecond + int LCM_OUTPUT_SUCCESS_CODE = 400; } diff --git a/common/src/main/java/org/onap/so/logger/ErrorCode.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmActionConstants.java index a57ed99f2b..8ab40cb08d 100644 --- a/common/src/main/java/org/onap/so/logger/ErrorCode.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmActionConstants.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020 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. @@ -18,23 +18,11 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.logger; +package org.onap.so.client.sdnc.lcm; -public enum ErrorCode { - PermissionError(100), - AvailabilityError(200), - DataError(300), - SchemaError(400), - BusinessProcessError(500), - UnknownError(900); - - private int value; - - ErrorCode(int value) { - this.value = value; - } - - public int getValue() { - return this.value; - } +public interface SDNCLcmActionConstants { + String ACTIVATE_N_E_SW = "ActivateNESw"; + String DOWNLOAD_N_E_SW = "DownloadNESw"; + String UPGRADE_POST_CHECK = "UpgradePostCheck"; + String UPGRADE_PRE_CHECK = "UpgradePreCheck"; } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilder.java index 5616db3577..0f17c547b5 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilder.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilder.java @@ -39,6 +39,10 @@ public class SDNCLcmClientBuilder { sdncLcmProperties = pros; } + public SDNCLcmProperties getSDNCLcmProperties() { + return sdncLcmProperties; + } + public SDNCLcmRestClient newSDNCLcmRestClient(String operation) throws SDNCLcmClientBuilderException { URI pathUri; try { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmProperties.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmProperties.java index df5fb3be0b..a21196e08f 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmProperties.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmProperties.java @@ -27,6 +27,8 @@ public interface SDNCLcmProperties extends RestProperties { String getPath(); + long getActionTimeout(); + String getBasicAuth(); String getDmaapHost(); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/ActivateNESwPayload.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/ActivateNESwPayload.java new file mode 100644 index 0000000000..d86d114a9f --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/ActivateNESwPayload.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.client.sdnc.lcm.beans.payload; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"ipaddressV4Oam", "playbookName", "swVersionToBeActivated"}) +public class ActivateNESwPayload { + + @JsonProperty(value = "ipaddress-v4-oam", required = true) + private String ipaddressV4Oam; + + @JsonProperty(value = "playbook-name") + private String playbookName; + + @JsonProperty(value = "swVersionToBeActivated", required = true) + private String swVersionToBeActivated; + + public String getIpaddressV4Oam() { + return ipaddressV4Oam; + } + + public void setIpaddressV4Oam(String value) { + this.ipaddressV4Oam = value; + } + + public String getPlaybookName() { + return playbookName; + } + + public void setPlaybookName(String value) { + this.playbookName = value; + } + + public String getSwVersionToBeActivated() { + return swVersionToBeActivated; + } + + public void setSwVersionToBeActivated(String value) { + this.swVersionToBeActivated = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayload.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayload.java new file mode 100644 index 0000000000..5dc5cf503d --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayload.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.client.sdnc.lcm.beans.payload; + +import java.util.ArrayList; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"ipaddressV4Oam", "playbookName", "swToBeDownloaded"}) +public class DownloadNESwPayload { + + @JsonProperty(value = "ipaddress-v4-oam", required = true) + private String ipaddressV4Oam; + + @JsonProperty(value = "playbook-name") + private String playbookName; + + @JsonProperty(value = "swToBeDownloaded", required = true) + private List<SwToBeDownloadedElement> swToBeDownloaded = new ArrayList<>(); + + public String getIpaddressV4Oam() { + return ipaddressV4Oam; + } + + public void setIpaddressV4Oam(String value) { + this.ipaddressV4Oam = value; + } + + public String getPlaybookName() { + return playbookName; + } + + public void setPlaybookName(String value) { + this.playbookName = value; + } + + public List<SwToBeDownloadedElement> getSwToBeDownloaded() { + return swToBeDownloaded; + } + + public void setSwToBeDownloaded(List<SwToBeDownloadedElement> value) { + this.swToBeDownloaded = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/SwToBeDownloadedElement.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/SwToBeDownloadedElement.java new file mode 100644 index 0000000000..1a3529d7c4 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/SwToBeDownloadedElement.java @@ -0,0 +1,75 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.client.sdnc.lcm.beans.payload; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"swLocation", "swFileSize", "swFileCompression", "swFileFormat"}) +public class SwToBeDownloadedElement { + + @JsonProperty(value = "swLocation", required = true) + private String swLocation; + + @JsonProperty(value = "swFileSize") + private long swFileSize; + + @JsonProperty(value = "swFileCompression") + private String swFileCompression; + + @JsonProperty(value = "swFileFormat") + private String swFileFormat; + + public String getSwLocation() { + return swLocation; + } + + public void setSwLocation(String value) { + this.swLocation = value; + } + + public long getSwFileSize() { + return swFileSize; + } + + public void setSwFileSize(long value) { + this.swFileSize = value; + } + + public String getSwFileCompression() { + return swFileCompression; + } + + public void setSwFileCompression(String value) { + this.swFileCompression = value; + } + + public String getSwFileFormat() { + return swFileFormat; + } + + public void setSwFileFormat(String value) { + this.swFileFormat = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePostCheckPayload.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePostCheckPayload.java new file mode 100644 index 0000000000..76937d262c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePostCheckPayload.java @@ -0,0 +1,96 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.client.sdnc.lcm.beans.payload; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"ipaddressV4Oam", "playbookName", "oldSwVersion", "targetSwVersion", "ruleName", "additionalData"}) +public class UpgradePostCheckPayload { + + @JsonProperty(value = "ipaddress-v4-oam", required = true) + private String ipaddressV4Oam; + + @JsonProperty(value = "playbook-name") + private String playbookName; + + @JsonProperty(value = "oldSwVersion", required = true) + private String oldSwVersion; + + @JsonProperty(value = "targetSwVersion", required = true) + private String targetSwVersion; + + @JsonProperty(value = "ruleName", required = true) + private String ruleName; + + @JsonProperty(value = "additionalData") + private String additionalData; + + public String getIpaddressV4Oam() { + return ipaddressV4Oam; + } + + public void setIpaddressV4Oam(String value) { + this.ipaddressV4Oam = value; + } + + public String getPlaybookName() { + return playbookName; + } + + public void setPlaybookName(String value) { + this.playbookName = value; + } + + public String getOldSwVersion() { + return oldSwVersion; + } + + public void setOldSwVersion(String value) { + this.oldSwVersion = value; + } + + public String getTargetSwVersion() { + return targetSwVersion; + } + + public void setTargetSwVersion(String value) { + this.targetSwVersion = value; + } + + public String getRuleName() { + return ruleName; + } + + public void setRuleName(String value) { + this.ruleName = value; + } + + public String getAdditionalData() { + return additionalData; + } + + public void setAdditionalData(String value) { + this.additionalData = value; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePreCheckPayload.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePreCheckPayload.java new file mode 100644 index 0000000000..d1a95b8418 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePreCheckPayload.java @@ -0,0 +1,96 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.client.sdnc.lcm.beans.payload; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"ipaddressV4Oam", "playbookName", "oldSwVersion", "targetSwVersion", "ruleName", "additionalData"}) +public class UpgradePreCheckPayload { + + @JsonProperty(value = "ipaddress-v4-oam", required = true) + private String ipaddressV4Oam; + + @JsonProperty(value = "playbook-name") + private String playbookName; + + @JsonProperty(value = "oldSwVersion", required = true) + private String oldSwVersion; + + @JsonProperty(value = "targetSwVersion", required = true) + private String targetSwVersion; + + @JsonProperty(value = "ruleName", required = true) + private String ruleName; + + @JsonProperty(value = "additionalData") + private String additionalData; + + public String getIpaddressV4Oam() { + return ipaddressV4Oam; + } + + public void setIpaddressV4Oam(String value) { + this.ipaddressV4Oam = value; + } + + public String getPlaybookName() { + return playbookName; + } + + public void setPlaybookName(String value) { + this.playbookName = value; + } + + public String getOldSwVersion() { + return oldSwVersion; + } + + public void setOldSwVersion(String value) { + this.oldSwVersion = value; + } + + public String getTargetSwVersion() { + return targetSwVersion; + } + + public void setTargetSwVersion(String value) { + this.targetSwVersion = value; + } + + public String getRuleName() { + return ruleName; + } + + public void setRuleName(String value) { + this.ruleName = value; + } + + public String getAdditionalData() { + return additionalData; + } + + public void setAdditionalData(String value) { + this.additionalData = value; + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtilTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtilTest.groovy new file mode 100644 index 0000000000..6b63bbe56c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtilTest.groovy @@ -0,0 +1,78 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # Licensed under the Apache License, Version 2.0 (the "License") + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.common.scripts + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.onap.so.db.request.beans.OperationStatus + +import static org.junit.Assert.assertNotNull +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.times +import static org.mockito.Mockito.when + +class RequestDBUtilTest extends MsoGroovyTest { + + @Before + void init() throws IOException { + super.init("DoDeleteSliceServiceTest") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void prepareUpdateOperationStatus(){ + when(mockExecution.getVariable("mso.adapters.openecomp.db.endpoint")).thenReturn("http://sdc-wfd-be:8080") + OperationStatus operationStatus = new OperationStatus() + operationStatus.setServiceId("testServiceId") + operationStatus.setOperationId("testOperationId") + operationStatus.setUserId("testUserId") + operationStatus.setOperation("testOpertation") + operationStatus.setResult("testResult") + operationStatus.setProgress("testProgress") + operationStatus.setOperationContent("testOperationContent") + operationStatus.setReason("testReason") + + RequestDBUtil requestDBUtil = new RequestDBUtil() + requestDBUtil.prepareUpdateOperationStatus(mockExecution, operationStatus) + + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus = captor.getAllValues() + assertNotNull(updateOperationStatus) + } + + @Test + void testGetOperationStatus(){ + when(mockExecution.getVariable("mso.adapters.openecomp.db.endpoint")).thenReturn("http://sdc-wfd-be:8080") + + RequestDBUtil requestDBUtil = new RequestDBUtil() + requestDBUtil.getOperationStatus(mockExecution, "testServiceId","testOperationId") + + Mockito.verify(mockExecution,times(1)).setVariable(eq("getOperationStatus"), captor.capture()) + String getOperationStatus = captor.getAllValues() + assertNotNull(getOperationStatus) + + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java index 1acf4edb4a..df7337c0d9 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java @@ -888,7 +888,6 @@ public class BBInputSetupTest { verify(SPY_bbInputSetup, times(1)).populateGenericVnf(parameter); assertEquals("VnfId populated", true, lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID).equalsIgnoreCase(resourceId)); - doReturn(ModelType.volumeGroup).when(modelInfo).getModelType(); resourceId = "volumeGroupId"; parameter.setResourceId(resourceId); @@ -1159,12 +1158,13 @@ public class BBInputSetupTest { ModelInfo mi = new ModelInfo(); mi.setModelType(ModelType.vnf); mi.setModelCustomizationUuid("vnfModelCustomizationUUID"); + mi.setModelCustomizationId("vnfModelCustomizationUUID"); ri.setModelInfo(mi); ril.setRelatedInstance(ri); requestDetails.setRelatedInstanceList(new RelatedInstanceList[] {ril}); ModelInfo modelInfo = new ModelInfo(); - modelInfo.setModelType(ModelType.volumeGroup); + modelInfo.setModelCustomizationId("volumeGroupCustId"); RequestInfo reqInfo = new RequestInfo(); reqInfo.setInstanceName("volumeGroupName"); @@ -1178,6 +1178,8 @@ public class BBInputSetupTest { VolumeGroup vg = new VolumeGroup(); vg.setVolumeGroupName("volumeGroupName"); vg.setVolumeGroupId("volumeGroupId"); + vg.setModelInfoVfModule(new ModelInfoVfModule()); + vg.getModelInfoVfModule().setModelCustomizationUUID("volumeGroupCustId"); vnf.getVolumeGroups().add(vg); serviceInstance.getVnfs().add(vnf); @@ -1186,6 +1188,8 @@ public class BBInputSetupTest { Map<ResourceKey, String> lookupKeyMap = new HashMap<>(); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "genericVnfId"); + ServiceModel serviceModel = new ServiceModel(); + serviceModel.setCurrentService(service); String bbName = AssignFlows.VOLUME_GROUP.toString(); String resourceId = "123"; doNothing().when(SPY_bbInputSetup).mapCatalogVolumeGroup(isA(VolumeGroup.class), eq(modelInfo), eq(service), @@ -1198,9 +1202,10 @@ public class BBInputSetupTest { BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestId(REQUEST_ID) .setModelInfo(modelInfo).setService(service).setBbName(bbName).setServiceInstance(serviceInstance) .setLookupKeyMap(lookupKeyMap).setResourceId(resourceId).setRequestDetails(requestDetails) - .setInstanceName(reqInfo.getInstanceName()).build(); + .setInstanceName(reqInfo.getInstanceName()).setServiceModel(serviceModel).build(); SPY_bbInputSetup.populateVolumeGroup(parameter); - verify(SPY_bbInputSetup, times(1)).mapCatalogVolumeGroup(vg, modelInfo, service, "vnfModelCustomizationUUID"); + verify(SPY_bbInputSetup, times(1)).mapCatalogVolumeGroup(eq(vg), isA(ModelInfo.class), eq(service), + eq("vnfModelCustomizationUUID")); vnf.getVolumeGroups().clear(); SPY_bbInputSetup.populateVolumeGroup(parameter); verify(SPY_bbInputSetup, times(1)).mapCatalogVolumeGroup(vnf.getVolumeGroups().get(0), modelInfo, service, diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClientTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClientTest.java index 5483792a84..3757769769 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClientTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClientTest.java @@ -42,7 +42,7 @@ public class SDNCLcmDmaapClientTest extends BaseTest { protected static final String DMAAP_HOST_PROP = SDNCLcmPropertiesImpl.DMAAP_HOST; protected static final String DMAAP_WRITE_TOPIC_PROP = SDNCLcmPropertiesImpl.LCM_DMAAP_WRITE_TOPIC; protected static final String DMAAP_READ_TOPIC_PROP = SDNCLcmPropertiesImpl.LCM_DMAAP_READ_TOPIC; - protected static final String DMAAP_PARTITION_PROP = SDNCLcmPropertiesImpl.DMAAP_PARTITION; + protected static final String DMAAP_PARTITION_PROP = SDNCLcmPropertiesImpl.LCM_DMAAP_PARTITION; protected String testWriteTopic = "TEST-WRITE-TOPIC"; protected String testReadTopic = "TEST-READ-TOPIC"; diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/ActivateNESwPayloadTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/ActivateNESwPayloadTest.java new file mode 100644 index 0000000000..bee07f2022 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/ActivateNESwPayloadTest.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.client.sdnc.lcm.beans.payload; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +public class ActivateNESwPayloadTest extends LcmBasePayloadTest { + private static String expectedActivateNESwPayload = "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\"," + + "\"playbook-name\":\"test_playbook\"," + "\"swVersionToBeActivated\":\"v2\"" + "}"; + + public ActivateNESwPayload buildActivateNESwPayload() { + ActivateNESwPayload activateNESwPayload = new ActivateNESwPayload(); + + activateNESwPayload.setIpaddressV4Oam(ipaddressV4Oam); + activateNESwPayload.setPlaybookName(playbookName); + activateNESwPayload.setSwVersionToBeActivated("v2"); + + return activateNESwPayload; + } + + @Test + public final void testActivateNESwPayload() { + ActivateNESwPayload activateNESwPayload = buildActivateNESwPayload(); + + try { + String activateNESwPayloadString = convertToSting(activateNESwPayload); + assertEquals(expectedActivateNESwPayload, activateNESwPayloadString); + } catch (Exception e) { + fail("Convert ActivateNESwPayload to String error: " + e.toString()); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayloadTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayloadTest.java new file mode 100644 index 0000000000..f9fa679790 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayloadTest.java @@ -0,0 +1,82 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.client.sdnc.lcm.beans.payload; + +import java.util.Collections; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +public class DownloadNESwPayloadTest extends LcmBasePayloadTest { + private static String expectedSwToBeDownloadedElement = "{" + "\"swLocation\":\"http://192.168.1.20/test.zip\"," + + "\"swFileSize\":123456," + "\"swFileCompression\":\"ZIP\"," + "\"swFileFormat\":\"binary\"" + "}"; + + private static String expectedDownloadNESwPayload = + "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\"," + "\"playbook-name\":\"test_playbook\"," + + "\"swToBeDownloaded\":[" + expectedSwToBeDownloadedElement + "]" + "}"; + + public SwToBeDownloadedElement buildSwToBeDownloadedElement() { + SwToBeDownloadedElement swToBeDownloadedElement = new SwToBeDownloadedElement(); + + swToBeDownloadedElement.setSwLocation("http://192.168.1.20/test.zip"); + swToBeDownloadedElement.setSwFileSize(123456); + swToBeDownloadedElement.setSwFileCompression("ZIP"); + swToBeDownloadedElement.setSwFileFormat("binary"); + + return swToBeDownloadedElement; + } + + public DownloadNESwPayload buildDownloadNESwPayload() { + DownloadNESwPayload downloadNESwPayload = new DownloadNESwPayload(); + + downloadNESwPayload.setIpaddressV4Oam(ipaddressV4Oam); + downloadNESwPayload.setPlaybookName(playbookName); + + SwToBeDownloadedElement swToBeDownloadedElement = buildSwToBeDownloadedElement(); + downloadNESwPayload.setSwToBeDownloaded(Collections.singletonList(swToBeDownloadedElement)); + + return downloadNESwPayload; + } + + @Test + public final void testSwToBeDownloadedElement() { + SwToBeDownloadedElement swToBeDownloadedElement = buildSwToBeDownloadedElement(); + + try { + String swToBeDownloadedElementString = convertToSting(swToBeDownloadedElement); + assertEquals(expectedSwToBeDownloadedElement, swToBeDownloadedElementString); + } catch (Exception e) { + fail("Convert SwToBeDownloadedElement to String error: " + e.toString()); + } + } + + @Test + public final void testDownloadNESwPayload() { + DownloadNESwPayload downloadNESwPayload = buildDownloadNESwPayload(); + + try { + String downloadNESwPayloadString = convertToSting(downloadNESwPayload); + assertEquals(expectedDownloadNESwPayload, downloadNESwPayloadString); + } catch (Exception e) { + fail("Convert DownloadNESwPayload to String error: " + e.toString()); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/LcmBasePayloadTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/LcmBasePayloadTest.java new file mode 100644 index 0000000000..5452166d03 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/LcmBasePayloadTest.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.client.sdnc.lcm.beans.payload; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class LcmBasePayloadTest { + private static Logger logger = LoggerFactory.getLogger(LcmBasePayloadTest.class); + + protected String ipaddressV4Oam = "192.168.1.10"; + protected String playbookName = "test_playbook"; + + public String convertToSting(Object msgObject) throws JsonProcessingException { + ObjectMapper mapper = new ObjectMapper(); + + String msgString = mapper.writeValueAsString(msgObject); + logger.debug(msgObject.getClass().getSimpleName() + "\n" + msgString); + + return msgString; + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePostCheckPayloadTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePostCheckPayloadTest.java new file mode 100644 index 0000000000..acd447e890 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePostCheckPayloadTest.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.client.sdnc.lcm.beans.payload; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +public class UpgradePostCheckPayloadTest extends LcmBasePayloadTest { + private static String expectedUpgradePostCheckPayload = "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\"," + + "\"playbook-name\":\"test_playbook\"," + "\"oldSwVersion\":\"v1\"," + "\"targetSwVersion\":\"v2\"," + + "\"ruleName\":\"r102\"," + "\"additionalData\":\"{}\"" + "}"; + + public UpgradePostCheckPayload buildUpgradePostCheckPayload() { + UpgradePostCheckPayload upgradePostCheckPayload = new UpgradePostCheckPayload(); + + upgradePostCheckPayload.setIpaddressV4Oam(ipaddressV4Oam); + upgradePostCheckPayload.setPlaybookName(playbookName); + upgradePostCheckPayload.setOldSwVersion("v1"); + upgradePostCheckPayload.setTargetSwVersion("v2"); + upgradePostCheckPayload.setRuleName("r102"); + upgradePostCheckPayload.setAdditionalData("{}"); + + return upgradePostCheckPayload; + } + + @Test + public final void testUpgradePostCheckPayload() { + UpgradePostCheckPayload upgradePostCheckPayload = buildUpgradePostCheckPayload(); + + try { + String upgradePostCheckPayloadString = convertToSting(upgradePostCheckPayload); + assertEquals(expectedUpgradePostCheckPayload, upgradePostCheckPayloadString); + } catch (Exception e) { + fail("Convert UpgradePostCheckPayload to String error: " + e.toString()); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePreCheckPayloadTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePreCheckPayloadTest.java new file mode 100644 index 0000000000..8bc0714fff --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePreCheckPayloadTest.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.client.sdnc.lcm.beans.payload; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +public class UpgradePreCheckPayloadTest extends LcmBasePayloadTest { + private static String expectedUpgradePreCheckPayload = "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\"," + + "\"playbook-name\":\"test_playbook\"," + "\"oldSwVersion\":\"v1\"," + "\"targetSwVersion\":\"v2\"," + + "\"ruleName\":\"r101\"," + "\"additionalData\":\"{}\"" + "}"; + + public UpgradePreCheckPayload buildUpgradePreCheckPayload() { + UpgradePreCheckPayload upgradePreCheckPayload = new UpgradePreCheckPayload(); + + upgradePreCheckPayload.setIpaddressV4Oam(ipaddressV4Oam); + upgradePreCheckPayload.setPlaybookName(playbookName); + upgradePreCheckPayload.setOldSwVersion("v1"); + upgradePreCheckPayload.setTargetSwVersion("v2"); + upgradePreCheckPayload.setRuleName("r101"); + upgradePreCheckPayload.setAdditionalData("{}"); + + return upgradePreCheckPayload; + } + + @Test + public final void testUpgradePreCheckPayload() { + UpgradePreCheckPayload upgradePreCheckPayload = buildUpgradePreCheckPayload(); + + try { + String upgradePreCheckPayloadString = convertToSting(upgradePreCheckPayload); + assertEquals(expectedUpgradePreCheckPayload, upgradePreCheckPayloadString); + } catch (Exception e) { + fail("Convert UpgradePreCheckPayload to String error: " + e.toString()); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/VolumeGroup.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/VolumeGroup.json index bcc565dc75..7de6df617b 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/VolumeGroup.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/VolumeGroup.json @@ -4,5 +4,8 @@ "vnf-type":"vnfType", "orchestration-status":"PRECREATED", "cloud-params":{}, - "heat-stack-id":"heatStackId" + "heat-stack-id":"heatStackId", + "model-info-vf-module": { + "modelCustomizationUUID": "modelCustomizationId" + } } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerService.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerService.java index 13ba46a852..4e6396c4be 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerService.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerService.java @@ -33,7 +33,7 @@ import org.camunda.bpm.engine.RuntimeService; import org.camunda.bpm.engine.runtime.Execution; import org.camunda.bpm.engine.runtime.MessageCorrelationResult; import org.onap.so.bpmn.core.UrnPropertiesReader; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowMessageResource.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowMessageResource.java index f76fde9ef1..2eb9d175f2 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowMessageResource.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowMessageResource.java @@ -35,7 +35,7 @@ import javax.ws.rs.core.Response; import org.onap.so.logger.LoggingAnchor; import org.onap.so.bpmn.common.workflow.service.CallbackHandlerService.CallbackError; import org.onap.so.bpmn.common.workflow.service.CallbackHandlerService.CallbackResult; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java index 6debcfbff6..731e9d8703 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java @@ -49,7 +49,7 @@ import org.camunda.bpm.engine.variable.Variables.SerializationDataFormats; import org.camunda.bpm.engine.variable.impl.VariableMapImpl; import org.onap.so.bpmn.common.workflow.context.WorkflowResponse; import org.onap.so.bpmn.core.WorkflowException; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationService.groovy index dc33bc930a..4ed0ea6a44 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationService.groovy @@ -102,6 +102,9 @@ class ActivateCommunicationService extends AbstractServiceTaskProcessor { String operationId = jsonUtil.getJsonValue(siRequest, "operationId") execution.setVariable("operationId", operationId) + String operationType = execution.getVariable("operationType") + execution.setVariable("operationType", operationType.toUpperCase()) + } catch (BpmnError e) { throw e } catch (Exception ex) { @@ -139,14 +142,14 @@ class ActivateCommunicationService extends AbstractServiceTaskProcessor { if(si.isPresent()) { if (si.get().getOrchestrationStatus().toLowerCase() == "activated" && - operationType == "deactivation") { + operationType.equalsIgnoreCase("deactivation")) { logger.info("Service is in active state") execution.setVariable("serviceExpectStatus", "deactivated") execution.setVariable("isContinue", "true") execution.setVariable("requestParam", "deactivate") } else if (si.get().getOrchestrationStatus().toLowerCase() == "deactivated" && - operationType == "activation"){ + operationType.equalsIgnoreCase("activation")){ logger.info("Service is in de-activated state") execution.setVariable("serviceExpectStatus", "activated") execution.setVariable("isContinue", "true") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceService.groovy index 630148e899..a8c3ef189e 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceService.groovy @@ -38,7 +38,7 @@ import org.onap.so.client.aai.entities.AAIResultWrapper import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.db.request.beans.OperationStatus -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger @@ -95,6 +95,7 @@ class ActivateSliceService extends AbstractServiceTaskProcessor { if (isBlank(globalSubscriberId)) { msg = "Input globalSubscriberId' is null" logger.info(msg) + execution.setVariable("globalSubscriberId", "5GCustomer") } else { execution.setVariable("globalSubscriberId", globalSubscriberId) } @@ -104,14 +105,16 @@ class ActivateSliceService extends AbstractServiceTaskProcessor { if (isBlank(subscriptionServiceType)) { msg = "Input subscriptionServiceType is null" logger.debug(msg) - //exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + execution.setVariable("subscriptionServiceType", "5G") } else { execution.setVariable("subscriptionServiceType", subscriptionServiceType) } String operationId = jsonUtil.getJsonValue(siRequest, "operationId") execution.setVariable("operationId", operationId) - execution.getVariable("operationType") + String operationType = execution.getVariable("operationType") + execution.setVariable("operationType", operationType.toUpperCase()) + logger.info("operationType is " + execution.getVariable("operationType") ) } catch (BpmnError e) { throw e @@ -308,7 +311,7 @@ class ActivateSliceService extends AbstractServiceTaskProcessor { String nssiid = nssi.getNssiId() updateStratus(execution, globalCustId, serviceType, nssiid, operationType) } - if (operationType == "activation") { + if (operationType.equalsIgnoreCase("activation")) { //update the s-nssai updateStratus(execution, globalCustId, serviceType, e2eserviceInstanceId, operationType) //update the nsi @@ -345,7 +348,7 @@ class ActivateSliceService extends AbstractServiceTaskProcessor { Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) if (si.isPresent()) { - if (operationType == "activation") { + if (operationType.equalsIgnoreCase("activation")) { if (si.get().getOrchestrationStatus() == "deactivated") { si.get().setOrchestrationStatus("activated") client.update(uri, si.get()) @@ -484,15 +487,14 @@ class ActivateSliceService extends AbstractServiceTaskProcessor { Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) if (si.isPresent()) { if (si.get().getOrchestrationStatus().toLowerCase() == "activated" && - operationType == "deactivation") { + operationType.equalsIgnoreCase("deactivation")) { logger.info("Service is in active state") execution.setVariable("e2eservicestatus", "activated") execution.setVariable("isContinue", "true") String snssai = si.get().getEnvironmentContext() execution.setVariable("snssai", snssai) - } else if ((si.get().getOrchestrationStatus().toLowerCase() == "deactivated" || - si.get().getOrchestrationStatus().toLowerCase() == "created") && - operationType == "activation") { + } else if (si.get().getOrchestrationStatus().toLowerCase() == "deactivated" && + operationType.equalsIgnoreCase("activation")) { logger.info("Service is in de-activated state") execution.setVariable("e2eservicestatus", "deactivated") execution.setVariable("isContinue", "true") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy index e3470cd011..71da2abd05 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy @@ -54,7 +54,7 @@ import static org.apache.commons.lang3.StringUtils.isBlank */ class CreateCommunicationService extends AbstractServiceTaskProcessor { - String Prefix="CRESI_" + String Prefix="CCS_" ExceptionUtil exceptionUtil = new ExceptionUtil() diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy index cae629fdf0..650f79b633 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy @@ -39,7 +39,7 @@ import org.onap.so.client.aai.AAIObjectType import org.onap.so.client.aai.AAIResourcesClient import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy index 3da4161953..8b9726c2b7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy @@ -127,7 +127,11 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { String key = iterator.next() HashMap<String, String> hashMap = new HashMap() hashMap.put("name", key) - hashMap.put("value", jsonObject.get(key)) + if(jsonObject.get(key)==null){ + hashMap.put("value", "") + }else{ + hashMap.put("value", jsonObject.get(key)) + } paramList.add(hashMap) } Map<String, List<Map<String, Object>>> paramMap = new HashMap() @@ -345,6 +349,32 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { switch (modelType) { case "VNF" : + if(modelName.contains("UNI") && "MDONS_OTN".equals(serviceType)){ + source = "SO" + sdncTopologyCreateRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" + xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1" + xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"> + <sdncadapter:RequestHeader> + <sdncadapter:RequestId>${msoUtils.xmlEscape(hdrRequestId)}</sdncadapter:RequestId> + <sdncadapter:SvcInstanceId>${msoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId> + <sdncadapter:SvcAction>${msoUtils.xmlEscape(sdnc_svcAction)}</sdncadapter:SvcAction> + <sdncadapter:SvcOperation>optical-service-create</sdncadapter:SvcOperation> + <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl> + <sdncadapter:MsoAction>opticalservice</sdncadapter:MsoAction> + </sdncadapter:RequestHeader> + <sdncadapterworkflow:SDNCRequestData> + <request-id>${msoUtils.xmlEscape(hdrRequestId)}</request-id> + <global-customer-id>${msoUtils.xmlEscape(globalCustomerId)}</global-customer-id> + <service-type>${msoUtils.xmlEscape(serviceType)}</service-type> + <notification-url>sdncCallback</notification-url> + <source>${msoUtils.xmlEscape(source)}</source> + <service-id>${msoUtils.xmlEscape(serviceInstanceId)}</service-id> + <payload> + $netowrkInputParameters + </payload> + </sdncadapterworkflow:SDNCRequestData> + </aetgt:SDNCAdapterWorkflowRequest>""".trim() + } else{ sdncTopologyCreateRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1" xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"> @@ -399,6 +429,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { </vnf-request-input> </sdncadapterworkflow:SDNCRequestData> </aetgt:SDNCAdapterWorkflowRequest>""".trim() + } break case "GROUP" : String vnfid = resourceInputObj.getVnfId() diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy index c3f36ef545..1efc1c11aa 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy @@ -45,7 +45,7 @@ import org.onap.so.bpmn.common.scripts.OofUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy index c9dadf57cb..fc97c292fb 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy @@ -36,7 +36,7 @@ import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.bpmn.infrastructure.aai.AAICreateResources -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy index 1fba23d3c8..33a607268d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy @@ -32,7 +32,7 @@ import org.onap.so.bpmn.core.WorkflowException import org.onap.so.client.aai.AAIObjectType import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVnfInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVnfInfra.groovy index 3eb15558d2..dc9655e7af 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVnfInfra.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVnfInfra.groovy @@ -24,7 +24,7 @@ package org.onap.so.bpmn.infrastructure.scripts import org.onap.so.logger.LoggingAnchor import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import static org.apache.commons.lang3.StringUtils.*; diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy index 00b0b37b18..b121083954 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy @@ -141,7 +141,7 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { * save e2eslice-service instance id and service name * @param execution */ - private void queryCommunicationSeriveFromAAI(DelegateExecution execution) + void queryCommunicationSeriveFromAAI(DelegateExecution execution) { LOGGER.trace(" ***** begin queryCommunicationSeriveFromAAI *****") String serviceInstanceId = execution.getVariable("serviceInstanceId") @@ -186,12 +186,11 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { String globalSubscriberId = execution.getVariable("globalSubscriberId") String serviceType = execution.getVariable("serviceType") - AAIResourcesClient resourceClient = new AAIResourcesClient() AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(aaiObjectType, globalSubscriberId, serviceType, instanceId) - if (!resourceClient.exists(resourceUri)) { + if (!getAAIClient().exists(resourceUri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMsg) } - AAIResultWrapper wrapper = resourceClient.get(resourceUri, NotFoundException.class) + AAIResultWrapper wrapper = getAAIClient().get(resourceUri, NotFoundException.class) return wrapper } @@ -215,7 +214,7 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { requestBody.replaceAll("\\s+", "") String basicAuthValue = UrnPropertiesReader.getVariable("mso.infra.endpoint.auth", execution) - HttpClient httpClient = new HttpClientFactory().newJsonClient(new URL(url), ONAPComponents.SO) + HttpClient httpClient = getHttpClientFactory().newJsonClient(new URL(url), ONAPComponents.SO) httpClient.addAdditionalHeader("Authorization", basicAuthValue) httpClient.addAdditionalHeader("Accept", "application/json") Response httpResponse = httpClient.delete(requestBody) @@ -233,6 +232,41 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { } /** + * prepare update operation status + * @param execution + */ + private void handleNSSMFWFResponse(Response httpResponse, DelegateExecution execution){ + LOGGER.debug(" ======== STARTED prepareUpdateOperationStatus Process ======== ") + + int nsmfResponseCode = httpResponse.getStatus() + LOGGER.debug("nsmfResponseCode${nsmfResponseCode}") + + if (nsmfResponseCode >= 200 && nsmfResponseCode < 204 && httpResponse.hasEntity()) { + String nsmfResponse = httpResponse.readEntity(String.class) + def e2eOperationId = jsonUtil.getJsonValue(nsmfResponse, "operationId") + execution.setVariable("e2eOperationId", e2eOperationId) + execution.setVariable("progress","20") + execution.setVariable("operationContent","waiting nsmf service delete finished") + + execution.setVariable("currentCycle",0) + execution.setVariable("isNSMFTimeOut", "no") + execution.setVariable("isNSMFWFRspSucceed","yes") + } + else + { + String serviceName = execution.getVariable("serviceInstanceName") + execution.setVariable("progress", "100") + execution.setVariable("result", "error") + execution.setVariable("operationContent", "terminate service failure.") + execution.setVariable("reason","NSMF WF asynchronous response failed, status Code:${nsmfResponseCode}") + execution.setVariable("isNSMFWFRspSucceed","no") + LOGGER.error("nsmf async response error,nsmfResponseCode:${nsmfResponseCode},serivceName:${serviceName}") + } + setOperationStatus(execution) + LOGGER.debug("======== COMPLETED prepareUpdateOperationStatus Process ======== ") + } + + /** * prepare to call sub process * @param execution */ @@ -272,22 +306,20 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { String profileId try { - AAIResourcesClient resourceClient = new AAIResourcesClient() AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.COMMUNICATION_PROFILE_ALL, globalSubscriberId, serviceType, serviceInstanceId) - AAIResultWrapper wrapper = resourceClient.get(resourceUri, NotFoundException.class) + AAIResultWrapper wrapper = getAAIClient().get(resourceUri, NotFoundException.class) Optional<CommunicationServiceProfiles> csProfilesOpt = wrapper.asBean(CommunicationServiceProfiles.class) if(csProfilesOpt.isPresent()){ - CommunicationServiceProfiles csProf - iles = csProfilesOpt.get() + CommunicationServiceProfiles csProfiles = csProfilesOpt.get() CommunicationServiceProfile csProfile = csProfiles.getCommunicationServiceProfile().get(0) profileId = csProfile ? csProfile.getProfileId() : "" } resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.COMMUNICATION_SERVICE_PROFILE, globalSubscriberId, serviceType, serviceInstanceId, profileId) - if (!resourceClient.exists(resourceUri)) { + if (!getAAIClient().exists(resourceUri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "communication service profile was not found in aai") } - - resourceClient.delete(resourceUri) + + getAAIClient().delete(resourceUri) LOGGER.debug("end delete communication service profile from AAI") } catch (any) @@ -308,9 +340,8 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { try { LOGGER.debug("start delete communication service from AAI") - AAIResourcesClient resourceClient = new AAIResourcesClient() AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), execution.getVariable("serviceInstanceId")) - resourceClient.delete(serviceInstanceUri) + getAAIClient().delete(serviceInstanceUri) execution.setVariable("progress", "100") execution.setVariable("result", "finished") @@ -330,12 +361,10 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { LOGGER.debug("Starting sendSyncError") try { - String errorMessage + String errorMessage = "Sending Sync Error." if (execution.getVariable("WorkflowException") instanceof WorkflowException) { WorkflowException wfe = execution.getVariable("WorkflowException") errorMessage = wfe.getErrorMessage() - } else { - errorMessage = "Sending Sync Error." } String buildworkflowException = @@ -397,6 +426,7 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { void prepareFailureStatus(DelegateExecution execution) { + execution.setVariable("result", "finished") execution.setVariable("progress", "100") execution.setVariable("operationContent", "terminate service failure.") setOperationStatus(execution) @@ -426,4 +456,5 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { execution.setVariable(paraName, paramValue) } } + } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy index 5c7127f36e..41a4ab85ec 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy @@ -31,7 +31,7 @@ import org.onap.so.bpmn.common.scripts.NetworkUtils import org.onap.so.bpmn.common.scripts.VidUtils import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy index f0d43cf8d7..d8160a97bc 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy @@ -45,19 +45,19 @@ import static org.apache.commons.lang3.StringUtils.isBlank class DeleteSliceService extends AbstractServiceTaskProcessor { - String Prefix="DELSS_" + private final String PREFIX ="DeleteSliceService" ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() private RequestDBUtil requestDBUtil = new RequestDBUtil() - private static final Logger logger = LoggerFactory.getLogger( DeleteSliceService.class) + private static final Logger LOGGER = LoggerFactory.getLogger( DeleteSliceService.class) @Override void preProcessRequest(DelegateExecution execution) { - execution.setVariable("prefix", Prefix) + execution.setVariable("prefix", PREFIX) String msg = "" - logger.trace("Starting preProcessRequest") + LOGGER.debug("*****${PREFIX} preProcessRequest *****") try { // check for incoming json message/input @@ -71,7 +71,7 @@ class DeleteSliceService extends AbstractServiceTaskProcessor { msg = "e2eslice-service id is null" exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) } - logger.info("Input Request: ${siRequest}, reqId: ${requestId}, e2eslice-service: ${serviceInstanceId}") + LOGGER.info("Input Request: ${siRequest}, reqId: ${requestId}, e2eslice-service: ${serviceInstanceId}") //subscriberInfo checkAndSetRequestParam(siRequest,"globalSubscriberId",false, execution) @@ -82,17 +82,17 @@ class DeleteSliceService extends AbstractServiceTaskProcessor { execution.setVariable("progress", "0") execution.setVariable("result", "processing") execution.setVariable("operationType", "DELETE") - execution.setVariable("operationContent", "Prepare init service") + execution.setVariable("operationContent", "Delete Slice service operation start") updateServiceOperationStatus(execution) } catch (BpmnError e) { throw e } catch (Exception ex) { msg = "Exception in preProcessRequest " + ex.getMessage() - logger.debug(msg) + LOGGER.debug(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - logger.trace("Exit preProcessRequest") + LOGGER.debug("*****${PREFIX} Exit preProcessRequest *****") } /** @@ -100,40 +100,39 @@ class DeleteSliceService extends AbstractServiceTaskProcessor { * @param execution */ void sendAsyncResponse(DelegateExecution execution) { - logger.trace("Staring sendSyncResponse") + LOGGER.trace("${PREFIX} Start sendSyncResponse ") try { String operationId = execution.getVariable("operationId") String syncResponse = """{"operationId":"${operationId}"}""".trim() - logger.info("sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse) + LOGGER.info("sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse) sendWorkflowResponse(execution, 202, syncResponse) } catch (Exception ex) { String msg = "Exception in sendSyncResponse: " + ex.getMessage() exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - logger.trace("Exit sendSyncResponse") + LOGGER.trace("${PREFIX} Exit sendSyncResponse") } /** * Deletes the slice service instance in aai */ void deleteSliceServiceInstance(DelegateExecution execution) { - logger.trace("Entered deleteSliceServiceInstance") + LOGGER.trace("${PREFIX} Start deleteSliceServiceInstance") try { - AAIResourcesClient resourceClient = new AAIResourcesClient() AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), execution.getVariable("serviceInstanceId")) - resourceClient.delete(serviceInstanceUri) + getAAIClient().delete(serviceInstanceUri) execution.setVariable("progress", "100") execution.setVariable("result", "finished") execution.setVariable("operationContent", "NSMF completes slicing service termination.") updateServiceOperationStatus(execution) - logger.trace("Exited deleteSliceServiceInstance") + LOGGER.trace("${PREFIX} Exited deleteSliceServiceInstance") }catch(Exception e){ - logger.debug("Error occured within deleteSliceServiceInstance method: " + e) + LOGGER.debug("Error occured within deleteSliceServiceInstance method: " + e) exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Error occured during deleteSliceServiceInstance from aai") } } @@ -161,7 +160,7 @@ class DeleteSliceService extends AbstractServiceTaskProcessor { * delete service profile from aai * @param execution */ - private void delServiceProfileFromAAI(DelegateExecution execution) + void delServiceProfileFromAAI(DelegateExecution execution) { String globalSubscriberId = execution.getVariable("globalSubscriberId") String serviceType = execution.getVariable("serviceType") @@ -170,9 +169,8 @@ class DeleteSliceService extends AbstractServiceTaskProcessor { try { - AAIResourcesClient resourceClient = new AAIResourcesClient() AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_PROFILE_ALL, globalSubscriberId, serviceType, serviceInstanceId) - AAIResultWrapper wrapper = resourceClient.get(resourceUri, NotFoundException.class) + AAIResultWrapper wrapper = getAAIClient().get(resourceUri, NotFoundException.class) Optional<ServiceProfiles> serviceProfilesOpt =wrapper.asBean(ServiceProfiles.class) if(serviceProfilesOpt.isPresent()){ ServiceProfiles serviceProfiles = serviceProfilesOpt.get() @@ -180,29 +178,27 @@ class DeleteSliceService extends AbstractServiceTaskProcessor { profileId = serviceProfile ? serviceProfile.getProfileId() : "" } resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_PROFILE, globalSubscriberId, serviceType, serviceInstanceId, profileId) - if (!resourceClient.exists(resourceUri)) { + if (!getAAIClient().exists(resourceUri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai") } - resourceClient.delete(resourceUri) + getAAIClient().delete(resourceUri) } catch (any) { String msg = "delete service profile from aai failed! cause-"+any.getCause() - logger.error(any.printStackTrace()) + LOGGER.error(any.printStackTrace()) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg); } } void sendSyncError(DelegateExecution execution) { - logger.info("Starting sendSyncError") + LOGGER.debug("${PREFIX} Start sendSyncError") try { - String errorMessage + String errorMessage = "Sending Sync Error." if (execution.getVariable("WorkflowException") instanceof WorkflowException) { WorkflowException wfe = execution.getVariable("WorkflowException") errorMessage = wfe.getErrorMessage() - } else { - errorMessage = "Sending Sync Error." } String buildworkflowException = @@ -211,17 +207,17 @@ class DeleteSliceService extends AbstractServiceTaskProcessor { <aetgt:ErrorCode>7000</aetgt:ErrorCode> </aetgt:WorkflowException>""" - logger.debug(buildworkflowException) + LOGGER.debug(buildworkflowException) sendWorkflowResponse(execution, 500, buildworkflowException) } catch (Exception ex) { - logger.error("Sending Sync Error Activity Failed. " + "\n" + ex.getMessage()) + LOGGER.error("Sending Sync Error Activity Failed. " + "\n" + ex.getMessage()) } } void prepareEndOperationStatus(DelegateExecution execution){ - logger.debug(" ======== STARTED prepareEndOperationStatus Process ======== ") + LOGGER.debug(" ======== ${PREFIX} STARTED prepareEndOperationStatus Process ======== ") execution.setVariable("progress", "100") execution.setVariable("result", "error") @@ -233,7 +229,7 @@ class DeleteSliceService extends AbstractServiceTaskProcessor { execution.setVariable("reason",errorMessage) updateServiceOperationStatus(execution) - logger.debug("======== COMPLETED prepareEndOperationStatus Process ======== ") + LOGGER.debug("======== ${PREFIX} COMPLETED prepareEndOperationStatus Process ======== ") } /** @@ -250,7 +246,7 @@ class DeleteSliceService extends AbstractServiceTaskProcessor { String paramValue = jsonUtil.getJsonValue(siRequest, paraName) if (isBlank(paramValue)) { msg = "Input ${paraName} is null" - logger.error(msg) + LOGGER.error(msg) if(isErrorException) { exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleInfra.groovy index 79aa745792..fd30722369 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleInfra.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleInfra.groovy @@ -31,7 +31,7 @@ import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.VidUtils; import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy index 9fa488f8a7..eb2ec2bc9d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy @@ -38,7 +38,7 @@ import org.onap.so.client.aai.entities.AAIResultWrapper import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.constants.Defaults -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy index 15b91e5221..6af7cc069e 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy @@ -26,7 +26,7 @@ import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.SerializationFeature import org.onap.so.logger.LoggingAnchor -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import static org.apache.commons.lang3.StringUtils.* diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy index 2def9e2d06..4835c9b84b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy @@ -33,7 +33,7 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.client.HttpClient -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy index dafc4b5470..c12d3553d5 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy @@ -25,7 +25,7 @@ package org.onap.so.bpmn.infrastructure.scripts import org.onap.so.logger.LoggingAnchor import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory import org.onap.so.client.HttpClientFactory -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import javax.ws.rs.core.MediaType import javax.ws.rs.core.Response diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy index 4bab2b390d..573282dafd 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy @@ -38,7 +38,7 @@ import org.onap.so.client.aai.AAIObjectPlurals import org.onap.so.client.aai.AAIObjectType import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy index e9b748b14b..823217c4f7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy @@ -24,7 +24,7 @@ package org.onap.so.bpmn.infrastructure.scripts import org.onap.so.logger.LoggingAnchor import org.onap.so.db.catalog.beans.HomingInstance -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import static org.apache.commons.lang3.StringUtils.* diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy index 180032c8f0..e60fab5766 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy @@ -41,7 +41,7 @@ import org.onap.so.bpmn.core.json.JsonUtils import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.so.bpmn.infrastructure.aai.groovyflows.AAICreateResources -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.slf4j.Logger import org.slf4j.LoggerFactory import org.onap.so.logger.MessageEnum diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy index a6cb5cf4cc..150f55316c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy @@ -23,7 +23,7 @@ package org.onap.so.bpmn.infrastructure.scripts import org.onap.so.logger.LoggingAnchor -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy index a88becad1a..72f71686d9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy @@ -23,7 +23,7 @@ package org.onap.so.bpmn.infrastructure.scripts import org.onap.so.logger.LoggingAnchor -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import static org.apache.commons.lang3.StringUtils.* diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy index 48e4fdf2ff..bc535a348f 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy @@ -24,7 +24,7 @@ package org.onap.so.bpmn.infrastructure.scripts import org.onap.so.logger.LoggingAnchor import org.onap.aai.domain.yang.AllottedResource -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import javax.ws.rs.core.UriBuilder diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy index d8897a2468..8d8e97328d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy @@ -76,7 +76,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor * * @param execution */ - private void prepareDecomposeService(DelegateExecution execution) + void prepareDecomposeService(DelegateExecution execution) { LOGGER.trace(" *****${PREFIX} Start prepareDecomposeService *****") try @@ -103,7 +103,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor * get vendor Info * @param execution */ - private void processDecomposition(DelegateExecution execution) { + void processDecomposition(DelegateExecution execution) { LOGGER.debug("*****${PREFIX} start processDecomposition *****") try { @@ -130,7 +130,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor * send deallocate request to nssmf * @param execution */ - private void sendRequestToNSSMF(DelegateExecution execution) + void sendRequestToNSSMF(DelegateExecution execution) { LOGGER.debug("*****${PREFIX} start sendRequestToNSSMF *****") def currentNSSI = execution.getVariable("currentNSSI") @@ -160,7 +160,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor URL url = new URL(nssmfRequest) LOGGER.info("deallocate nssmfRequest:${nssmfRequest}, reqBody: ${json}") - HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL) + HttpClient httpClient = getHttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL) Response httpResponse = httpClient.post(json) checkNssmfResponse(httpResponse, execution) @@ -176,7 +176,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor * send to nssmf query progress * @param execution */ - private void getJobStatus(DelegateExecution execution) + void getJobStatus(DelegateExecution execution) { def currentNSSI = execution.getVariable("currentNSSI") String jobId = currentNSSI['jobId'] @@ -198,7 +198,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor URL url = new URL(nssmfRequest) LOGGER.info("get deallocate job status, nssmfRequest:${nssmfRequest}, requestBody: ${json}") - HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL) + HttpClient httpClient = getHttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL) Response httpResponse = httpClient.post(json) checkNssmfResponse(httpResponse, execution) @@ -248,7 +248,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor * prepare update requestdb * @param execution */ - private void handleJobStatus(DelegateExecution execution) + void handleJobStatus(DelegateExecution execution) { def currentNSSI = execution.getVariable("currentNSSI") int currentProgress = currentNSSI["jobProgress"] @@ -267,7 +267,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor LOGGER.debug("update operation, currentProgress=${currentProgress}, proportion=${proportion}, progress = ${progress}" ) } - private void timeDelay(DelegateExecution execution) { + void timeDelay(DelegateExecution execution) { try { Thread.sleep(10000); } catch(InterruptedException e) { @@ -279,7 +279,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor * delete slice profile from aai * @param execution */ - private void delSliceProfileFromAAI(DelegateExecution execution) + void delSliceProfileFromAAI(DelegateExecution execution) { LOGGER.debug("*****${PREFIX} start delSliceProfileFromAAI *****") def currentNSSI = execution.getVariable("currentNSSI") @@ -291,12 +291,11 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor try { LOGGER.debug("delete nssiServiceInstanceId:${nssiServiceInstanceId}, profileId:${profileId}") - AAIResourcesClient resourceClient = new AAIResourcesClient() AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, globalSubscriberId, serviceType, nssiServiceInstanceId, profileId) - if (!resourceClient.exists(resourceUri)) { + if (!getAAIClient().exists(resourceUri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai") } - resourceClient.delete(resourceUri) + getAAIClient().delete(resourceUri) } catch (any) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy index 09eb7994a8..89c5be8d6e 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy @@ -45,7 +45,7 @@ import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.client.graphinventory.entities.uri.Depth import org.onap.so.constants.Defaults -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy index 7c2a2be6ac..76086dab49 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy @@ -29,7 +29,6 @@ import org.onap.aai.domain.yang.SliceProfiles import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.client.aai.AAIObjectType -import org.onap.so.client.aai.AAIResourcesClient import org.onap.so.client.aai.entities.AAIResultWrapper import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory @@ -309,12 +308,11 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { String globalSubscriberId = execution.getVariable("globalSubscriberId") String serviceType = execution.getVariable("serviceType") - AAIResourcesClient resourceClient = new AAIResourcesClient() AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(aaiObjectType, globalSubscriberId, serviceType, instanceId) - if (!resourceClient.exists(resourceUri)) { + if (!getAAIClient().exists(resourceUri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMsg) } - AAIResultWrapper wrapper = resourceClient.get(resourceUri, NotFoundException.class) + AAIResultWrapper wrapper = getAAIClient().get(resourceUri, NotFoundException.class) LOGGER.trace(" *****${PREFIX} Exit queryAAI *****") return wrapper } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy index 4c8247a309..511f461844 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy @@ -25,7 +25,7 @@ package org.onap.so.bpmn.infrastructure.scripts import org.onap.so.logger.LoggingAnchor import org.onap.aai.domain.yang.NetworkPolicies import org.onap.aai.domain.yang.NetworkPolicy -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import javax.xml.parsers.DocumentBuilder import javax.xml.parsers.DocumentBuilderFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy index eba43632a7..9c8bd156a9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy @@ -27,7 +27,7 @@ import org.onap.aai.domain.yang.GenericVnf import org.onap.aai.domain.yang.NetworkPolicies import org.onap.aai.domain.yang.NetworkPolicy import org.onap.aai.domain.yang.VfModule -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import static org.apache.commons.lang3.StringUtils.* import org.camunda.bpm.engine.delegate.BpmnError diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy index 20d250d89f..ff58fd567d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy @@ -45,7 +45,7 @@ import org.onap.so.client.graphinventory.entities.uri.Depth import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.client.aai.AAIObjectType -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleE2EServiceInstance.groovy index 231fe6e252..4eba33dc7d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleE2EServiceInstance.groovy @@ -22,7 +22,7 @@ package org.onap.so.bpmn.infrastructure.scripts import org.onap.so.logger.LoggingAnchor -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import static org.apache.commons.lang3.StringUtils.*; diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy index 367975e003..16e1241750 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy @@ -34,7 +34,7 @@ import org.onap.so.bpmn.core.json.JsonUtils import org.camunda.bpm.engine.delegate.BpmnError import com.fasterxml.jackson.databind.ObjectMapper import org.onap.so.client.HttpClientFactory -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import javax.ws.rs.core.Response diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoSendCommandToNSSMF.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoSendCommandToNSSMF.groovy index 63cd3c72f9..5acc016c7b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoSendCommandToNSSMF.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoSendCommandToNSSMF.groovy @@ -36,7 +36,7 @@ import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.client.HttpClient import org.onap.so.client.HttpClientFactory -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy index f7852431e5..854584fea9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy @@ -45,7 +45,7 @@ import org.onap.so.client.aai.entities.uri.AAIUri import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.constants.Defaults -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy index cfdba89db7..7caa63ec72 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy @@ -24,7 +24,7 @@ package org.onap.so.bpmn.infrastructure.scripts import org.onap.so.logger.LoggingAnchor import org.onap.so.client.HttpClientFactory -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import javax.ws.rs.core.Response import org.camunda.bpm.engine.delegate.BpmnError diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy index e36f32578d..275cef0b0c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy @@ -35,7 +35,7 @@ import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.client.aai.* import org.onap.so.client.appc.ApplicationControllerOrchestrator import org.onap.so.client.appc.ApplicationControllerSupport -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/RollbackVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/RollbackVnf.groovy index ed65616d89..d5bdb73b61 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/RollbackVnf.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/RollbackVnf.groovy @@ -22,7 +22,7 @@ package org.onap.so.bpmn.infrastructure.scripts import org.onap.so.logger.LoggingAnchor -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.common.scripts.ExceptionUtil diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ScaleCustomE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ScaleCustomE2EServiceInstance.groovy index b21efdd563..b27ca4a956 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ScaleCustomE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ScaleCustomE2EServiceInstance.groovy @@ -23,7 +23,7 @@ package org.onap.so.bpmn.infrastructure.scripts import org.onap.so.logger.LoggingAnchor -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import static org.apache.commons.lang3.StringUtils.* diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModule.groovy index 6946eebc56..6e5ee01c9a 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModule.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModule.groovy @@ -29,7 +29,7 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfra.groovy index 2404169493..76702eab81 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfra.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfra.groovy @@ -30,7 +30,7 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy index 3e9b934a2e..f1fbafc7de 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy @@ -37,7 +37,7 @@ import org.onap.so.client.aai.entities.Relationships import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.constants.Defaults -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy index 7f2bbebc8d..5449ba6708 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy @@ -42,7 +42,7 @@ import org.onap.so.client.aai.entities.Relationships import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.constants.Defaults -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy index 26a509022c..053e2b36d1 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy @@ -35,7 +35,7 @@ import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.client.aai.AAIRestClientImpl import org.onap.so.client.aai.AAIUpdatorImpl import org.onap.so.client.aai.AAIValidatorImpl -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy index 09e7516f85..e423ecc83c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy @@ -46,7 +46,7 @@ import org.onap.so.client.aai.entities.uri.AAIUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.client.appc.ApplicationControllerClient import org.onap.so.client.appc.ApplicationControllerSupport -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfConfigUpdate.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfConfigUpdate.groovy index 90523a02be..d11f4c19eb 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfConfigUpdate.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfConfigUpdate.groovy @@ -33,7 +33,7 @@ import org.onap.so.client.aai.* import org.onap.so.client.aai.entities.AAIResultWrapper import org.onap.so.client.aai.entities.uri.AAIUri import org.onap.so.client.aai.entities.uri.AAIUriFactory -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy index 3cb40115ba..34215a11aa 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy @@ -39,7 +39,7 @@ import org.onap.so.client.aai.entities.uri.AAIUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.client.appc.ApplicationControllerClient import org.onap.so.client.appc.ApplicationControllerSupport -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy index d57011f61f..6327ea233c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy @@ -22,7 +22,7 @@ package org.onap.so.bpmn.vcpe.scripts import org.onap.so.logger.LoggingAnchor -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import static org.apache.commons.lang3.StringUtils.* diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy index 553ec2397c..5205fa1874 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy @@ -31,7 +31,7 @@ import org.onap.so.bpmn.common.scripts.NetworkUtils import org.onap.so.bpmn.common.scripts.VidUtils import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy index 0681e54bba..68abcea07c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy @@ -35,7 +35,7 @@ import org.onap.so.client.aai.AAIObjectType import org.onap.so.client.aai.AAIResourcesClient import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy index f24bb46981..b5ddc57781 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy @@ -31,7 +31,7 @@ import org.onap.so.bpmn.common.scripts.AllottedResourceUtils import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy index 51d04dd092..fc50d3a3b3 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy @@ -34,7 +34,7 @@ import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.client.aai.AAIObjectType import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy index 1427730187..80e5831fbe 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy @@ -29,7 +29,7 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy index 29ee1a648e..117078992f 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy @@ -32,7 +32,7 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy index 404f19eca9..b029a4686b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy @@ -32,7 +32,7 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java index fab3496559..3ea8b190ad 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java @@ -35,8 +35,10 @@ public class ExecutionVariableNames { public final static String TIMEOUT_FOR_NOTIFICATION = "timeoutForPnfEntryNotification"; public final static String PNF_UUID = "pnfUuid"; public final static String SERVICE_INSTANCE_ID = "serviceInstanceId"; + public final static String REQUEST_ID = "requestId"; public final static String MSO_REQUEST_ID = "msoRequestId"; public final static String MODEL_UUID = "modelUuid"; + public final static String REQUEST_PAYLOAD = "requestPayload"; public final static String SERVICE_MODEL_INFO = "serviceModelInfo"; diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcher.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcher.java index 4482d2a327..6c140061c0 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcher.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcher.java @@ -69,7 +69,7 @@ public class NfSoftwareUpgradeDispatcher implements JavaDelegate { @Override public void execute(DelegateExecution delegateExecution) throws Exception { - logger.debug("Running execute block for activity id:{}, name:{}", delegateExecution.getCurrentActivityId(), + logger.debug("Running execute block for activity id: {}, name: {}", delegateExecution.getCurrentActivityId(), delegateExecution.getCurrentActivityName()); RequestDetails bpmnRequestDetails = requestVerification(delegateExecution); @@ -82,9 +82,10 @@ public class NfSoftwareUpgradeDispatcher implements JavaDelegate { final List<PnfResourceCustomization> pnfCustomizations = getPnfResourceCustomizations(delegateExecution, serviceModelUuid); final PnfResourceCustomization pnfResourceCustomization = pnfCustomizations.get(0); + final String payload = bpmnRequestDetails.getRequestParameters().getPayload(); populateExecution(delegateExecution, bpmnRequestDetails, pnfResourceCustomization, pnf, serviceInstanceName, - pnfName, serviceModelUuid, userParams); + pnfName, serviceModelUuid, userParams, payload); logger.trace("Completed preProcessRequest PnfSoftwareUpgradeServiceRequest Request "); } @@ -104,7 +105,7 @@ public class NfSoftwareUpgradeDispatcher implements JavaDelegate { private void populateExecution(DelegateExecution delegateExecution, RequestDetails bpmnRequestDetails, PnfResourceCustomization pnfResourceCustomization, Pnf pnf, String serviceInstanceName, String pnfName, - String serviceModelUuid, List<Map<String, Object>> userParams) { + String serviceModelUuid, List<Map<String, Object>> userParams, String payload) { delegateExecution.setVariable(SERVICE_MODEL_INFO, bpmnRequestDetails.getModelInfo()); delegateExecution.setVariable(SERVICE_INSTANCE_NAME, serviceInstanceName); @@ -124,6 +125,8 @@ public class NfSoftwareUpgradeDispatcher implements JavaDelegate { delegateExecution.setVariable(param.get("name").toString(), param.get("value").toString()); } } + + delegateExecution.setVariable(REQUEST_PAYLOAD, payload); } private Pnf getPnfByPnfName(DelegateExecution delegateExecution, String pnfName) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java index 7f2cd5c071..109f45e6eb 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java @@ -71,7 +71,7 @@ import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.aai.entities.Relationships; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java index f933277f3c..de8a35de06 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java @@ -45,7 +45,7 @@ import org.onap.msb.sdk.httpclient.msb.MSBServiceClient; import org.onap.so.bpmn.core.UrnPropertiesReader; import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.GenericResourceApi; import org.onap.so.db.request.beans.ResourceOperationStatus; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.requestsdb.RequestsDbConstant; import org.slf4j.Logger; diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationServiceTest.groovy index 7e02779f10..3eefd31e63 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationServiceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationServiceTest.groovy @@ -57,11 +57,11 @@ class ActivateCommunicationServiceTest extends MsoGroovyTest { when(mockExecution.getVariable("bpmnRequest")).thenReturn(req) when(mockExecution.getVariable("mso-request-id")).thenReturn("54321") when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") - + when(mockExecution.getVariable("operationType")).thenReturn("activation") ActivateCommunicationService service = new ActivateCommunicationService() service.preProcessRequest(mockExecution) - Mockito.verify(mockExecution, times(5)).setVariable(captor.capture(), captor.capture()) + Mockito.verify(mockExecution, times(6)).setVariable(captor.capture(), captor.capture()) } @Test diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceServiceTest.groovy new file mode 100644 index 0000000000..f3c61dd628 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceServiceTest.groovy @@ -0,0 +1,118 @@ +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.onap.so.bpmn.common.scripts.MsoGroovyTest + +import static org.junit.Assert.assertEquals +import static org.junit.Assert.assertNotNull +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.times +import static org.mockito.Mockito.when + +class ActivateSliceServiceTest extends MsoGroovyTest { + @Before + void init() throws IOException { + super.init("ActivateSliceService") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void testPreProcessRequest() { + + String req = """ + { + "globalSubscriberId": "5GCustomer", + "serviceType": "5G", + "operationId": "test123" + } + """ + when(mockExecution.getVariable("bpmnRequest")).thenReturn(req) + when(mockExecution.getVariable("mso-request-id")).thenReturn("54321") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("operationType")).thenReturn("activation") + + + ActivateSliceService service = new ActivateSliceService() + service.preProcessRequest(mockExecution) + Mockito.verify(mockExecution, times(7)).setVariable(captor.capture(), captor.capture()) + } + + @Test + void testPrepareInitOperationStatus() { + + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("operationId")).thenReturn("54321") + + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("11111") + + ActivateSliceService service = new ActivateSliceService() + + service.prepareInitServiceOperationStatus(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String res = captor.getValue() + assertNotNull(res) + } + + @Test + void testSendSyncResponse() { + when(mockExecution.getVariable("operationId")).thenReturn("123456") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + ActivateSliceService service = new ActivateSliceService() + service.sendSyncResponse(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("sentSyncResponse"), captor.capture()) + def updateVolumeGroupRequest = captor.getValue() + assertEquals(updateVolumeGroupRequest, true) + } + + private static getExpectPayload = { String type, String result, String progress, String operationContent -> + String expect = + """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:ns="http://org.onap.so/requestsdb"> + <soapenv:Header/> + <soapenv:Body> + <ns:${type} xmlns:ns="http://org.onap.so/requestsdb"> + <serviceId>12345</serviceId> + <operationId>54321</operationId> + <operationType>activate</operationType> + <userId>11111</userId> + <result>${result}</result> + <operationContent>${operationContent}</operationContent> + <progress>${progress}</progress> + <reason></reason> + </ns:${type}> + </soapenv:Body> + </soapenv:Envelope> + """ + return expect + } + + @Test + void testPrepareCompleteStatus() { + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("operationId")).thenReturn("54321") + when(mockExecution.getVariable("operationType")).thenReturn("activate") + when(mockExecution.getVariable("operationContent")) + .thenReturn("slice service activate operation finished") + + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("11111") + when(mockExecution.getVariable("operationStatus")) + .thenReturn("deactivated") + ActivateSliceService service = new ActivateSliceService() + + service.prepareCompletionRequest(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String res = captor.getValue() + + String expect = getExpectPayload("updateServiceOperationStatus", "finished", "100", + "slice service activate operation finished") + + assertEquals(expect.replaceAll("\\s+", ""), res.replaceAll("\\s+", "")) + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationServiceTest.groovy new file mode 100644 index 0000000000..8c08e51efe --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationServiceTest.groovy @@ -0,0 +1,308 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # Licensed under the Apache License, Version 2.0 (the "License") + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.onap.logging.filter.base.ONAPComponents +import org.onap.so.bpmn.common.scripts.MsoGroovyTest +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory + +import javax.ws.rs.NotFoundException +import javax.ws.rs.core.Response + +import static org.junit.Assert.assertEquals +import static org.junit.Assert.assertNotNull +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.* + +class DeleteCommunicationServiceTest extends MsoGroovyTest { + + private HttpClientFactory httpClientFactoryMock + private HttpClient httpClientMock + + @Before + void init() throws IOException { + super.init("DeleteCommunicationServiceTest") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void testPreProcessRequest(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("bpmnRequest")).thenReturn(""" + { + "globalSubscriberId ":"5GCustomer", + "serviceType ":"5G" + }""".replaceAll("\\\\s+", "")) + when(mockExecution.getVariable("mso-request-id")).thenReturn("4c614769-f58a-4556-8ad9-dcd903077c82") + + DeleteCommunicationService delCS = new DeleteCommunicationService() + delCS.preProcessRequest(mockExecution) + Mockito.verify(mockExecution,times(3)).setVariable(captor.capture() as String, captor.capture()) + List<ExecutionEntity> values = captor.getAllValues() + assertNotNull(values) + } + + @Test + void testPreInitUpdateOperationStatus(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceInstanceName")).thenReturn("5G-test") + when(mockExecution.getVariable("result")).thenReturn("processing") + when(mockExecution.getVariable("progress")).thenReturn("0") + when(mockExecution.getVariable("operationContent")).thenReturn("delete communication service operation start") + + DeleteCommunicationService delCS = new DeleteCommunicationService() + delCS.preInitUpdateOperationStatus(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus= captor.getValue() + assertNotNull(updateOperationStatus) + } + + @Test + void testQueryCommunicationSeriveFromAAI(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + DeleteCommunicationService obj = spy(DeleteCommunicationService.class) + + AAIResultWrapper wrapper = new AAIResultWrapper(mockQueryCommunicationServiceReturn()) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(resourceUri)).thenReturn(true) + when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper) + obj.queryCommunicationSeriveFromAAI(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("e2eSliceServiceInstanceId"), captor.capture()) + String e2eSliceServiceInstanceId = captor.getValue() + assertNotNull(e2eSliceServiceInstanceId) + } + + @Test + void testPrepareCallCheckProcessStatus(){ + DeleteCommunicationService dcs = new DeleteCommunicationService() + dcs.prepareCallCheckProcessStatus(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("endProgress"), captor.capture()) + int endProgress = captor.getValue() + assertEquals(90,endProgress) + } + + @Test + void testDelCSProfileFromAAI() + { + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResultWrapper wrapper = new AAIResultWrapper(mockQueryCommunicationServiceProfile()) + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.COMMUNICATION_PROFILE_ALL, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + AAIResourceUri profileUri = AAIUriFactory.createResourceUri(AAIObjectType.COMMUNICATION_SERVICE_PROFILE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be", "5G-111111") + + DeleteCommunicationService obj = spy(DeleteCommunicationService.class) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(resourceUri)).thenReturn(true) + when(client.exists(profileUri)).thenReturn(true) + when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper) + doNothing().when(client).delete(profileUri) + obj.delCSProfileFromAAI(mockExecution) + Mockito.verify(client,times(1)).delete(profileUri) + } + + @Test + void testPrepareFailureStatus(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceInstanceName")).thenReturn("5G-test") + when(mockExecution.getVariable("result")).thenReturn("finished") + when(mockExecution.getVariable("progress")).thenReturn("100") + when(mockExecution.getVariable("operationContent")).thenReturn("terminate service failure.") + + DeleteCommunicationService dcs = new DeleteCommunicationService() + dcs.prepareFailureStatus(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus= captor.getValue() + assertNotNull(updateOperationStatus) + } + + @Test + void testDelCSFromAAI(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + DeleteCommunicationService obj = spy(DeleteCommunicationService.class) + when(obj.getAAIClient()).thenReturn(client) + doNothing().when(client).delete(serviceInstanceUri) + + obj.delCSFromAAI(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus= captor.getValue() + assertNotNull(updateOperationStatus) + } + + @Test + void testPreFailedOperationStatus(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceInstanceName")).thenReturn("5G-test") + when(mockExecution.getVariable("result")).thenReturn("error") + when(mockExecution.getVariable("progress")).thenReturn("100") + when(mockExecution.getVariable("operationContent")).thenReturn("terminate service failure") + + DeleteCommunicationService deleteCommunicationService = new DeleteCommunicationService() + WorkflowException exception = new WorkflowException("11113",7000,"terminate service failure") + when(mockExecution.getVariable("WorkflowException")).thenReturn(exception) + deleteCommunicationService.preFailedOperationStatus(mockExecution) + + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus= captor.getValue() + assertNotNull(updateOperationStatus) + } + + @Test + void testSendRequest2NSMFWF(){ + httpClientMock = mock(HttpClient.class) + httpClientFactoryMock = mock(HttpClientFactory.class) + String url ="http://so.onap:8080/onap/so/infra/e2eServiceInstances/v3/5G-777" + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0") + when(mockExecution.getVariable("progress")).thenReturn("20") + when(mockExecution.getVariable("operationContent")).thenReturn("waiting nsmf service delete finished") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("mso.infra.endpoint.url")).thenReturn("http://so.onap:8080/onap/so/infra") + when(mockExecution.getVariable("e2eSliceServiceInstanceId")).thenReturn("5G-777") + when(mockExecution.getVariable("e2eOperationId")).thenReturn("e151059a-d924-4629-845f-264db19e50b3") + when(httpClientFactoryMock.newJsonClient(new URL(url), ONAPComponents.SO)).thenReturn(httpClientMock) + DeleteCommunicationService obj = spy(DeleteCommunicationService.class) + + Response responseMock = mock(Response.class) + when(responseMock.getStatus()).thenReturn(200) + when(responseMock.hasEntity()).thenReturn(true) + when(responseMock.getEntity()).thenReturn(getNSSMFResponse()) + when(obj.getHttpClientFactory()).thenReturn(httpClientFactoryMock) + when(httpClientMock.delete(anyString())).thenReturn(responseMock) + + obj.sendRequest2NSMFWF(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus= captor.getValue() + assertNotNull(updateOperationStatus) + } + + private String getNSSMFResponse(){ + String response = """{ + "service":{ + "serviceId":"e151059a-d924-4629-845f-264db19e50b4", + "operationId":"e151059a-d924-4629-845f-264db19e50b3" + } + }""" + return response + } + + + + + private String mockQueryCommunicationServiceReturn() + { + String expect = + """{ + "service-instance-id": "5G-666", + "service-instance-name": "eMBB_Slice_Communication_Service_5GCustomer", + "service-type": "eMBB", + "service-role": "communication-service", + "environment-context": "01-010101", + "workload-context": "12", + "created-at": "2019-12-11 19:56:00", + "description": "", + "model-invariant-id": "e75698d9-925a-4cdd-a6c0-edacbe6a0b51", + "model-version-id": "8ee5926d-720b-4bb2-86f9-d20e921c143b", + "service-instance-location-id": "300-01|300-02", + "resource-version": "1582623470778", + "orchestration-status": "created", + "relationship-list": { + "relationship": [ + { + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/5G-777", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "5G-777" + } + ], + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "eMBB_e2e_Slice_Service_5GCustomer" + } + ] + } + ] + } + }""" + return expect + } + + private String mockQueryCommunicationServiceProfile() + { + String expect = + """{ + "communication-service-profile": [ + { + "profile-id": "5G-111111", + "max-number-of-UEs": 50, + "coverage-area-list": "longgang,futian", + "latency": 20, + "exp-data-rate-UL": 300, + "exp-data-rate-DL": 500, + "ue-mobility-level": "stationary", + "resource-sharing-level": "Non-Shared", + "resource-version": "1577454950460" + } + ] + }""" + return expect + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceServiceTest.groovy new file mode 100644 index 0000000000..fb50fcc43b --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceServiceTest.groovy @@ -0,0 +1,171 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # Licensed under the Apache License, Version 2.0 (the "License") + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.onap.so.bpmn.common.scripts.MsoGroovyTest +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory + +import javax.ws.rs.NotFoundException + +import static org.junit.Assert.assertNotNull +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.doNothing +import static org.mockito.Mockito.spy +import static org.mockito.Mockito.times +import static org.mockito.Mockito.when +import static org.mockito.Mockito.when +import static org.mockito.Mockito.when + +class DeleteSliceServiceTest extends MsoGroovyTest { + @Before + void init() throws IOException { + super.init("DeleteSliceServiceTest") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void testPreProcessRequest(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("eb0863e9-a69b-4b17-8a56-f05ad110bef7") + when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceInstanceName")).thenReturn("5G-test") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + when(mockExecution.getVariable("result")).thenReturn("processing") + when(mockExecution.getVariable("progress")).thenReturn("0") + when(mockExecution.getVariable("operationContent")).thenReturn("Delete Slice service operation start") + when(mockExecution.getVariable("bpmnRequest")).thenReturn(""" + { + "globalSubscriberId ":"5GCustomer", + "serviceType ":"5G" + }""".replaceAll("\\\\s+", "")) + when(mockExecution.getVariable("mso-request-id")).thenReturn("4c614769-f58a-4556-8ad9-dcd903077c82") + + DeleteSliceService delSS = new DeleteSliceService() + delSS.preProcessRequest(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus = captor.getValue() + assertNotNull(updateOperationStatus) + } + + @Test + void testDeleteSliceServiceInstance(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + when(mockExecution.getVariable("result")).thenReturn("finished") + when(mockExecution.getVariable("progress")).thenReturn("100") + when(mockExecution.getVariable("operationContent")).thenReturn("NSMF completes slicing service termination.") + + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + DeleteSliceService obj = spy(DeleteSliceService.class) + when(obj.getAAIClient()).thenReturn(client) + doNothing().when(client).delete(serviceInstanceUri) + + obj.deleteSliceServiceInstance(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus= captor.getValue() + assertNotNull(updateOperationStatus) + } + + @Test + void testDelServiceProfileFromAAI(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResultWrapper wrapper = new AAIResultWrapper(mockQuerySliceServiceProfile()) + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_PROFILE_ALL, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + AAIResourceUri profileUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_PROFILE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be", "5G-2222222") + + DeleteSliceService obj = spy(DeleteSliceService.class) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(resourceUri)).thenReturn(true) + when(client.exists(profileUri)).thenReturn(true) + when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper) + doNothing().when(client).delete(profileUri) + obj.delServiceProfileFromAAI(mockExecution) + Mockito.verify(client,times(1)).delete(profileUri) + } + + @Test + void testPrepareEndOperationStatus(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceInstanceName")).thenReturn("5G-test") + when(mockExecution.getVariable("result")).thenReturn("error") + when(mockExecution.getVariable("progress")).thenReturn("100") + when(mockExecution.getVariable("operationContent")).thenReturn("terminate service failure") + + DeleteSliceService deleteSliceService = new DeleteSliceService() + WorkflowException exception = new WorkflowException("11113",7000,"terminate service failure") + when(mockExecution.getVariable("WorkflowException")).thenReturn(exception) + deleteSliceService.prepareEndOperationStatus(mockExecution) + + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus= captor.getValue() + assertNotNull(updateOperationStatus) + + } + + private String mockQuerySliceServiceProfile(){ + String expect = + """{ + "service-profile": [ + { + "profile-id": "5G-2222222", + "latency": 50, + "max-number-of-UEs": 500, + "coverage-area-TA-list": "longgang,futian", + "ue-mobility-level": "stationary", + "resource-sharing-level": "Non-Shared", + "exp-data-rate-UL": 10, + "exp-data-rate-DL": 30, + "area-traffic-cap-UL": 100, + "area-traffic-cap-DL": 100, + "activity-factor": 80, + "jitter": 10, + "survival-time": 30, + "cs-availability": 95.5, + "reliability": 99.9, + "exp-data-rate": 80, + "traffic-density": 100, + "conn-density": 80, + "resource-version": "1577454958647" + } + ] + }""" + return expect + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSITest.groovy new file mode 100644 index 0000000000..493e2c9e1e --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSITest.groovy @@ -0,0 +1,258 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # Licensed under the Apache License, Version 2.0 (the "License") + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.onap.logging.filter.base.ONAPComponents +import org.onap.so.beans.nsmf.JobStatusResponse +import org.onap.so.beans.nsmf.NssiResponse +import org.onap.so.beans.nsmf.ResponseDescriptor +import org.onap.so.bpmn.common.scripts.MsoGroovyTest +import org.onap.so.bpmn.core.domain.ServiceArtifact +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.ServiceInfo +import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory + +import javax.ws.rs.core.Response + +import static org.junit.Assert.assertNotNull +import static org.junit.Assert.assertTrue +import static org.mockito.ArgumentMatchers.anyString +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.doNothing +import static org.mockito.Mockito.mock +import static org.mockito.Mockito.spy +import static org.mockito.Mockito.times +import static org.mockito.Mockito.when + +class DoDeallocateNSSITest extends MsoGroovyTest { + + private HttpClientFactory httpClientFactoryMock + private HttpClient httpClientMock + + @Before + void init() throws IOException { + super.init("DoDeallocateNSSITest") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + + @Test + void testPreProcessRequest(){ + def currentNSSI = [:] + currentNSSI.put("nssiServiceInstanceId","5G-999") + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + + DoDeallocateNSSI ddnssi = new DoDeallocateNSSI() + ddnssi.preProcessRequest(mockExecution) + Mockito.verify(mockExecution,times(1)).getVariable("currentNSSI") + } + + @Test + void testPrepareDecomposeService(){ + def currentNSSI = [:] + currentNSSI.put("modelInvariantId", "21d57d4b-52ad-4d3c-a798-248b5bb9124b") + currentNSSI.put("modelVersionId", "bfba363e-e39c-4bd9-a9d5-1371c28f4d22") + currentNSSI.put("nssiServiceInstanceId","5G-999") + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + + DoDeallocateNSSI ddnssi = new DoDeallocateNSSI() + ddnssi.prepareDecomposeService(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("serviceModelInfo"), captor.capture()) + String serviceModelInfo = captor.getValue() + assertNotNull(serviceModelInfo) + } + + @Test + void testProcessDecomposition(){ + def currentNSSI = [:] + ServiceArtifact artifact = new ServiceArtifact() + artifact.setContent(getArtifactContent()) + ServiceInfo serviceInfo = new ServiceInfo() + List<ServiceArtifact> artifactList = new ArrayList<>() + artifactList.add(artifact) + serviceInfo.setServiceArtifact(artifactList) + ServiceDecomposition decomposition = new ServiceDecomposition() + decomposition.setServiceInfo(serviceInfo) + when(mockExecution.getVariable("serviceDecomposition")).thenReturn(decomposition) + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + + DoDeallocateNSSI ddnssi = new DoDeallocateNSSI() + ddnssi.processDecomposition(mockExecution) + String vendor = currentNSSI.get("vendor") + assertNotNull(vendor) + } + + @Test + void testHandleJobStatus(){ + def currentNSSI = [:] + currentNSSI.put("jobProgress", 10) + currentNSSI.put("proportion", 90) + currentNSSI.put("statusDescription","") + currentNSSI.put("e2eServiceInstanceId","21d57d4b-52ad-4d3c-a798-248b5bb9124b") + currentNSSI.put("operationId","4c614769-f58a-4556-8ad9-dcd903077c82") + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + + DoDeallocateNSSI ddnssi = new DoDeallocateNSSI() + ddnssi.handleJobStatus(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus= captor.getValue() + assertNotNull(updateOperationStatus) + } + + @Test + void testDelSliceProfileFromAAI(){ + def currentNSSI = [:] + currentNSSI.put("nssiServiceInstanceId", "5G-999") + currentNSSI.put("profileId", "ddf57704-fe8d-417b-882d-2f2a12ddb225") + currentNSSI.put("globalSubscriberId","5GCustomer") + currentNSSI.put("serviceType","5G") + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + + AAIResourceUri profileUri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, "5GCustomer", "5G", "5G-999", "ddf57704-fe8d-417b-882d-2f2a12ddb225") + DoDeallocateNSSI obj = spy(DoDeallocateNSSI.class) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(profileUri)).thenReturn(true) + doNothing().when(client).delete(profileUri) + + obj.delSliceProfileFromAAI(mockExecution) + Mockito.verify(client,times(1)).delete(profileUri) + } + + @Test + void testSendRequestToNSSMF(){ + httpClientFactoryMock = mock(HttpClientFactory.class) + httpClientMock = mock(HttpClient.class) + + def currentNSSI = [:] + currentNSSI.put("snssai", "01-010101") + currentNSSI.put("profileId", "ddf57704-fe8d-417b-882d-2f2a12ddb225") + currentNSSI.put("nssiServiceInstanceId","5G-999") + currentNSSI.put("nsiServiceInstanceId","5G-888") + + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + when(mockExecution.getVariable("mso.adapters.nssmf.endpoint")).thenReturn("http://so-nssmf-adapter.onap:8088") + String nssmfRequest = "http://so-nssmf-adapter.onap:8088/api/rest/provMns/v1/NSS/SliceProfiles/ddf57704-fe8d-417b-882d-2f2a12ddb225" + + when(httpClientFactoryMock.newJsonClient(new URL(nssmfRequest), ONAPComponents.EXTERNAL)).thenReturn(httpClientMock) + DoDeallocateNSSI obj = spy(DoDeallocateNSSI.class) + when(obj.getHttpClientFactory()).thenReturn(httpClientFactoryMock) + Response responseMock = mock(Response.class) + NssiResponse response = new NssiResponse() + response.setNssiId("NSSI-C-004-HDBHZ-NSSMF-01-A-HW") + response.setJobId("a5c5913d-448a-bcb1-9b800a944d84") + when(httpClientMock.post(anyString())).thenReturn(responseMock) + when(responseMock.getStatus()).thenReturn(202) + when(responseMock.readEntity(NssiResponse.class)) thenReturn(response) + when(responseMock.hasEntity()).thenReturn(true) + + obj.sendRequestToNSSMF(mockExecution) + String jobId = currentNSSI['jobId'] + assertNotNull(jobId) + } + + @Test + void testGetJobStatus(){ + httpClientFactoryMock = mock(HttpClientFactory.class) + httpClientMock = mock(HttpClient.class) + + def currentNSSI = [:] + currentNSSI.put("jobId", "a5c5913d-448a-bcb1-9b800a944d84") + currentNSSI.put("nssiServiceInstanceId","5G-999") + currentNSSI.put("nsiServiceInstanceId","5G-888") + currentNSSI.put("jobProgress",60) + + when(mockExecution.getVariable("isNSSIDeAllocated")).thenReturn(false) + when(mockExecution.getVariable("isNSSIDeAllocated")).thenReturn(false) + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + when(mockExecution.getVariable("mso.adapters.nssmf.endpoint")).thenReturn("http://so-nssmf-adapter.onap:8088") + String nssmfRequest = "http://so-nssmf-adapter.onap:8088/api/rest/provMns/v1/NSS/jobs/a5c5913d-448a-bcb1-9b800a944d84" + + when(httpClientFactoryMock.newJsonClient(new URL(nssmfRequest), ONAPComponents.EXTERNAL)).thenReturn(httpClientMock) + DoDeallocateNSSI obj = spy(DoDeallocateNSSI.class) + when(obj.getHttpClientFactory()).thenReturn(httpClientFactoryMock) + Response responseMock = mock(Response.class) + ResponseDescriptor descriptor = new ResponseDescriptor() + descriptor.setProgress(100) + descriptor.setStatusDescription("finished deallocate nssi") + JobStatusResponse jobStatusResponse = new JobStatusResponse() + jobStatusResponse.setResponseDescriptor(descriptor) + when(httpClientMock.post(anyString())).thenReturn(responseMock) + when(responseMock.getStatus()).thenReturn(202) + when(responseMock.readEntity(JobStatusResponse.class)) thenReturn(jobStatusResponse) + when(responseMock.hasEntity()).thenReturn(true) + + obj.getJobStatus(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("isNSSIDeAllocated"), captor.capture()) + boolean value = captor.getValue() + assertTrue(value) + } + + + private String getArtifactContent(){ + String content = + """ + { + "metadata":{ + "id":"NSST-C-001-HDBNJ-NSSMF-01-A-HW", + "vendor":"HW", + "version":"1.0", + "name":"eMBB_demo", + "description":"eMBB for demo", + "type":"embb", + "domainType":"cn" + }, + "capabilities":{ + "latency":{ + "type":"integer", + "constrainstsl":"less_or_equal", + "value":"20" + }, + "areaTrafficCapDL":{ + "type":"integer", + "constrainstsl":"less_or_equal", + "value":"300" + }, + "areaTrafficCapUL":{ + "type":"integer", + "constrainstsl":"less_or_equal", + "value":"300" + }, + "maxNumberofUEs":{ + "type":"integer", + "constrainstsl":"less_or_equal", + "value":"300" + } + } + } + """ + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceServiceTest.groovy new file mode 100644 index 0000000000..8a18376819 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceServiceTest.groovy @@ -0,0 +1,460 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # Licensed under the Apache License, Version 2.0 (the "License") + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.so.bpmn.common.scripts.MsoGroovyTest +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory + +import javax.ws.rs.NotFoundException + +import static org.junit.Assert.assertEquals +import static org.junit.Assert.assertNotNull +import static org.junit.Assert.assertTrue +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.doNothing +import static org.mockito.Mockito.spy +import static org.mockito.Mockito.times +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.when + +class DoDeleteSliceServiceTest extends MsoGroovyTest { + @Before + void init() throws IOException { + super.init("DoDeleteSliceServiceTest") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void testPreProcessRequest(){ + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("e2a747a0-2ca6-476d-ac28-de999cf3fbfe") + + DoDeleteSliceService doDeleteSliceService = new DoDeleteSliceService() + doDeleteSliceService.preProcessRequest(mockExecution) + + Mockito.verify(mockExecution,times(1)).setVariable(captor.capture() as String, captor.capture()) + List<ExecutionEntity> values = captor.getAllValues() + assertNotNull(values) + } + + @Test + void testQueryE2ESliceSeriveFromAAI(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + DoDeleteSliceService obj = spy(DoDeleteSliceService.class) + + AAIResultWrapper wrapper = new AAIResultWrapper(mockQuerySliceServiceReturn()) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(resourceUri)).thenReturn(true) + when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper) + obj.queryE2ESliceSeriveFromAAI(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("snssai"), captor.capture()) + String snssai = captor.getValue() + assertNotNull(snssai) + } + + @Test + void testGetAllottedResFromAAI(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE_ALL, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + DoDeleteSliceService obj = spy(DoDeleteSliceService.class) + + AAIResultWrapper wrapper = new AAIResultWrapper(mockQueryAllottedResource()) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(resourceUri)).thenReturn(true) + when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper) + obj.getAllottedResFromAAI(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("nsiId"), captor.capture()) + String nsiId = captor.getValue() + assertNotNull(nsiId) + } + + @Test + void testGetNSIFromAAI(){ + when(mockExecution.getVariable("nsiId")).thenReturn("5G-888") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5G-888") + DoDeleteSliceService obj = spy(DoDeleteSliceService.class) + + AAIResultWrapper wrapper = new AAIResultWrapper(mockNSIReturn()) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(resourceUri)).thenReturn(true) + when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper) + obj.getNSIFromAAI(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("nssiIdList"), captor.capture()) + List<String> nssiIdList = captor.getValue() + assertNotNull(nssiIdList) + } + + @Test + void testGetNSSIListFromAAI(){ + List<String> nssiIdList = [] + nssiIdList.add("5G-999") + + when(mockExecution.getVariable("nssiIdList")).thenReturn(nssiIdList) + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5G-999") + DoDeleteSliceService obj = spy(DoDeleteSliceService.class) + + AAIResultWrapper wrapper = new AAIResultWrapper(mockNSSIReturn()) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(resourceUri)).thenReturn(true) + when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper) + obj.getNSSIListFromAAI(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("nssiInstanceList"), captor.capture()) + List<ServiceInstance> nssiInstanceList = captor.getValue() + assertNotNull(nssiInstanceList) + } + + @Test + void testGetCurrentNSSI(){ + ServiceInstance nssi = new ServiceInstance() + nssi.setServiceInstanceId("5G-999") + nssi.setModelInvariantId("21d57d4b-52ad-4d3c-a798-248b5bb9124a") + nssi.setModelVersionId("bfba363e-e39c-4bd9-a9d5-1371c28f4d22") + List<ServiceInstance> nssiInstanceList = [] + nssiInstanceList.add(nssi) + when(mockExecution.getVariable("currentNSSIIndex")).thenReturn(0) + when(mockExecution.getVariable("nssiInstanceList")).thenReturn(nssiInstanceList) + when(mockExecution.getVariable("snssai")).thenReturn("01-010101") + when(mockExecution.getVariable("nsiId")).thenReturn("5G-888") + when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5G-777") + when(mockExecution.getVariable("msoRequestId")).thenReturn("4c614769-f58a-4556-8ad9-dcd903077c82") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + when(mockExecution.getVariable("proportion")).thenReturn("90") + + DoDeleteSliceService ddss = new DoDeleteSliceService() + ddss.getCurrentNSSI(mockExecution) + verify(mockExecution,times(1)).setVariable(eq("currentNSSI"), captor.capture()) + Map currentNSSI = captor.getValue() + assertTrue(currentNSSI.size()>0) + } + + @Test + void testQuerySliceProfileFromAAI(){ + def currentNSSI = [:] + currentNSSI.put("nssiServiceInstanceId","5G-999") + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResultWrapper wrapper = new AAIResultWrapper(mockSliceProfile()) + AAIResourceUri profileUri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE_ALL, "5GCustomer", "5G", "5G-999") + + DoDeleteSliceService obj = spy(DoDeleteSliceService.class) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(profileUri)).thenReturn(true) + when(client.get(profileUri, NotFoundException.class)).thenReturn(wrapper) + obj.querySliceProfileFromAAI(mockExecution) + verify(mockExecution,times(1)).setVariable(eq("currentNSSI"), captor.capture()) + Map value = captor.getValue() + assertNotNull(currentNSSI.get('profileId')) + } + + @Test + void parseNextNSSI(){ + ServiceInstance nssi = new ServiceInstance() + nssi.setServiceInstanceId("5G-999") + nssi.setModelInvariantId("21d57d4b-52ad-4d3c-a798-248b5bb9124b") + nssi.setModelVersionId("bfba363e-e39c-4bd9-a9d5-1371c28f4d22") + List<ServiceInstance> nssiInstanceList = [] + nssiInstanceList.add(nssi) + when(mockExecution.getVariable("currentNSSIIndex")).thenReturn(0) + when(mockExecution.getVariable("nssiInstanceList")).thenReturn(nssiInstanceList) + + DoDeleteSliceService ddss = new DoDeleteSliceService() + ddss.parseNextNSSI(mockExecution) + verify(mockExecution,times(1)).setVariable(eq("isAllNSSIFinished"), captor.capture()) + boolean isAllNSSIFinished = captor.getValue() + assertTrue(isAllNSSIFinished) + } + + private String mockSliceProfile(){ + String expect = + """{ + "slice-profile": [ + { + "profile-id": "ddf57704-fe8d-417b-882d-2f2a12ddb225", + "latency": 20, + "max-number-of-UEs": 0, + "coverage-area-TA-list": "[{\\"province\\":\\"??\\",\\"city\\":\\"???\\",\\"county\\":\\"???\\",\\"street\\":\\"?????\\"}]", + "ue-mobility-level": "stationary", + "resource-sharing-level": "0", + "exp-data-rate-UL": 100, + "exp-data-rate-DL": 100, + "activity-factor": 0, + "e2e-latency": 0, + "jitter": 0, + "survival-time": 0, + "exp-data-rate": 0, + "payload-size": 0, + "traffic-density": 0, + "conn-density": 0, + "s-nssai": "01003", + "resource-version": "1580800791373" + } + ] + } + """ + return expect + } + + private String mockNSSIReturn(){ + String expect = + """ + { + "service-instance-id": "5G-999", + "service-instance-name": "eMBB_Slice_NSSI_5GCustomer", + "service-type": "eMBB", + "service-role": "nssi", + "environment-context": "cn", + "model-invariant-id": "21d57d4b-52ad-4d3c-a798-248b5bb9124a", + "model-version-id": "bfba363e-e39c-4bd9-a9d5-1371c28f4d22", + "service-instance-location-id": "300-01|300-02", + "resource-version": "1578449638032", + "orchestration-status": "activated", + "relationship-list": { + "relationship": [ + { + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/5G-888", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "5G-888" + } + ], + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "eMBB_e2e_Slice_Service_5GCustomer" + } + ] + } + ] + } + } + """ + return expect + } + + private String mockNSIReturn(){ + String expect = + """ + { + "service-instance-id": "5G-888", + "service-instance-name": "eMBB_e2e_Slice_Service_5GCustomer", + "service-type": "embb", + "service-role": "nsi", + "model-invariant-id": "0e9bcb9a-c832-433b-a0c1-74866768f608", + "model-version-id": "2c5fd79d-0f84-4057-9222-952cb6f27036", + "service-instance-location-id": "300-01|300-02", + "resource-version": "1579691104911", + "orchestration-status": "activated", + "relationship-list": { + "relationship": [ + { + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/5G-999", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "5G-999" + } + ], + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "eMBB_Slice_NSSI_5GCustomer" + } + ] + }, + { + "related-to": "allotted-resource", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/5G-777/allotted-resources/allotted-resource/5G-1234", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "5G-777" + }, + { + "relationship-key": "allotted-resource.id", + "relationship-value": "5G-1234" + } + ], + "related-to-property": [ + { + "property-key": "allotted-resource.description" + }, + { + "property-key": "allotted-resource.allotted-resource-name" + } + ] + } + ] + } + } + """ + return expect + } + + private String mockQueryAllottedResource(){ + String expect = + """{ + "allotted-resource": [ + { + "id": "5G-1234", + "resource-version": "1577454983471", + "relationship-list": { + "relationship": [ + { + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/5G-888", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "5G-888" + } + ], + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "eMBB_e2e_Slice_Service_5GCustomer" + } + ] + } + ] + } + } + ] + } + """ + return expect + } + + String mockQuerySliceServiceReturn(){ + String expect = + """{ + "service-instance-id": "5G-777", + "service-instance-name": "eMBB_e2e_Slice_Service_5GCustomer", + "service-type": "embb", + "service-role": "e2eslice-service", + "environment-context": "01-010101", + "model-invariant-id": "e65d737a-41e0-4ad1-958f-56defdf2e907", + "model-version-id": "f2f5967e-72d3-4c5c-b880-e214e71dba4e", + "service-instance-location-id": "300-01|300-02", + "resource-version": "1578449638436", + "orchestration-status": "activated", + "relationship-list": { + "relationship": [ + { + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/5G-666", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "5G-666" + } + ], + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "eMBB_Slice_Communication_Service_5GCustomer" + } + ] + } + ] + } + } + """ + return expect + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java index dab5102efd..bbdcbf7ae3 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java @@ -66,7 +66,7 @@ import org.onap.so.client.orchestration.AAIVfModuleResources; import org.onap.so.client.orchestration.AAIVnfResources; import org.onap.so.client.orchestration.AAIVolumeGroupResources; import org.onap.so.client.orchestration.AAIVpnBindingResources; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java index 4522f7f2e7..415d4614da 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java @@ -42,7 +42,7 @@ import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; import org.onap.so.client.exception.ExceptionBuilder; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.serviceinstancebeans.RequestDetails; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java index e5f28aa4c3..8b78560521 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java @@ -38,7 +38,7 @@ 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.exceptions.MarshallerException; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java index 00d0fdc01d..332c390c7d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java @@ -50,7 +50,7 @@ import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.AAIVnfResources; import org.onap.so.db.catalog.beans.ControllerSelectionReference; import org.onap.so.db.catalog.client.CatalogDbClient; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/LcmControllerDE.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/LcmControllerDE.java index 95e270a071..40034aa26c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/LcmControllerDE.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/LcmControllerDE.java @@ -24,7 +24,6 @@ import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext; import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerRunnable; import org.onap.so.bpmn.infrastructure.decisionpoint.api.controller.ControllerPreparable; -import org.onap.so.client.appc.ApplicationControllerAction; import org.onap.so.client.exception.ExceptionBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -44,9 +43,6 @@ public abstract class LcmControllerDE implements ControllerRunnable<DelegateExec @Autowired protected List<ControllerPreparable<DelegateExecution>> prepareList; - @Autowired - protected ApplicationControllerAction client; - @Override public void prepare(ControllerContext<DelegateExecution> context) { prepareList.stream().filter(prepare -> prepare.understand(context)) diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/common/SoPropertyConstants.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/common/SoPropertyConstants.java new file mode 100644 index 0000000000..badce18a51 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/common/SoPropertyConstants.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.common; + +public interface SoPropertyConstants { + String TARGET_SOFTWARE_VERSION = "targetSoftwareVersion"; + + String SO_ACTION = "action"; + String SO_ACTION_MODE = "mode"; + + String ACTION_ACTIVATE_N_E_SW = "activateNESw"; + String ACTION_DOWNLOAD_N_E_SW = "downloadNESw"; + String ACTION_POST_CHECK = "postCheck"; + String ACTION_PRE_CHECK = "preCheck"; + + String CONTROLLER_STATUS = "ControllerStatus"; +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilder.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilder.java new file mode 100644 index 0000000000..b29009ff1d --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilder.java @@ -0,0 +1,153 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.sdnc; + +import java.util.Arrays; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.bpmn.core.json.JsonUtils; +import org.onap.so.client.sdnc.lcm.beans.payload.*; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.REQUEST_PAYLOAD; +import org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.common.SoPropertyConstants; + +public class SDNCLcmPayloadBuilder { + + private static Logger logger = LoggerFactory.getLogger(SDNCLcmPayloadBuilder.class); + + public static ActivateNESwPayload buildActivateNESwPayload(DelegateExecution execution) { + String requestPayload = String.valueOf(execution.getVariable(REQUEST_PAYLOAD)); + + ActivateNESwPayload activateNESwPayload = new ActivateNESwPayload(); + + String ipaddressV4Oam = JsonUtils.getJsonValue(requestPayload, "ipaddressV4Oam"); + activateNESwPayload.setIpaddressV4Oam(ipaddressV4Oam); + + String targetSwVersion = String.valueOf(execution.getVariable(SoPropertyConstants.TARGET_SOFTWARE_VERSION)); + if (targetSwVersion == null) { + targetSwVersion = JsonUtils.getJsonValue(requestPayload, "targetSwVersion"); + } + activateNESwPayload.setSwVersionToBeActivated(targetSwVersion); + + String playbookName = JsonUtils.getJsonValue(requestPayload, "activateNESwPlaybook"); + if (playbookName != null) { + activateNESwPayload.setPlaybookName(playbookName); + } + + return activateNESwPayload; + } + + public static DownloadNESwPayload buildDownloadNESwPayload(DelegateExecution execution) { + String requestPayload = String.valueOf(execution.getVariable(REQUEST_PAYLOAD)); + + DownloadNESwPayload downloadNESwPayload = new DownloadNESwPayload(); + + String ipaddressV4Oam = JsonUtils.getJsonValue(requestPayload, "ipaddressV4Oam"); + downloadNESwPayload.setIpaddressV4Oam(ipaddressV4Oam); + + String swToBeDownloadedString = JsonUtils.getJsonValue(requestPayload, "swToBeDownloaded"); + SwToBeDownloadedElement[] swToBeDownloadedArray; + + ObjectMapper mapper = new ObjectMapper(); + try { + swToBeDownloadedArray = mapper.readValue(swToBeDownloadedString, SwToBeDownloadedElement[].class); + downloadNESwPayload.setSwToBeDownloaded(Arrays.asList(swToBeDownloadedArray)); + } catch (Exception e) { + logger.error("Parse SwToBeDownloaded error: ", e); + } + + String playbookName = JsonUtils.getJsonValue(requestPayload, "downloadNESwPlaybook"); + if (playbookName != null) { + downloadNESwPayload.setPlaybookName(playbookName); + } + + return downloadNESwPayload; + } + + public static UpgradePostCheckPayload buildUpgradePostCheckPayload(DelegateExecution execution) { + String requestPayload = String.valueOf(execution.getVariable(REQUEST_PAYLOAD)); + + UpgradePostCheckPayload upgradePostCheckPayload = new UpgradePostCheckPayload(); + + String ipaddressV4Oam = JsonUtils.getJsonValue(requestPayload, "ipaddressV4Oam"); + upgradePostCheckPayload.setIpaddressV4Oam(ipaddressV4Oam); + + String oldSwVersion = JsonUtils.getJsonValue(requestPayload, "oldSwVersion"); + upgradePostCheckPayload.setOldSwVersion(oldSwVersion); + + String targetSwVersion = String.valueOf(execution.getVariable(SoPropertyConstants.TARGET_SOFTWARE_VERSION)); + if (targetSwVersion == null) { + targetSwVersion = JsonUtils.getJsonValue(requestPayload, "targetSwVersion"); + } + upgradePostCheckPayload.setTargetSwVersion(targetSwVersion); + + String ruleName = JsonUtils.getJsonValue(requestPayload, "postCheckRuleName"); + upgradePostCheckPayload.setRuleName(ruleName); + + String additionalData = JsonUtils.getJsonValue(requestPayload, "postCheckAdditionalData"); + upgradePostCheckPayload.setAdditionalData(additionalData); + + String playbookName = JsonUtils.getJsonValue(requestPayload, "postCheckPlaybook"); + if (playbookName != null) { + upgradePostCheckPayload.setPlaybookName(playbookName); + } + + return upgradePostCheckPayload; + } + + public static UpgradePreCheckPayload buildUpgradePreCheckPayload(DelegateExecution execution) { + String requestPayload = String.valueOf(execution.getVariable(REQUEST_PAYLOAD)); + + UpgradePreCheckPayload upgradePreCheckPayload = new UpgradePreCheckPayload(); + + String ipaddressV4Oam = JsonUtils.getJsonValue(requestPayload, "ipaddressV4Oam"); + upgradePreCheckPayload.setIpaddressV4Oam(ipaddressV4Oam); + + String oldSwVersion = JsonUtils.getJsonValue(requestPayload, "oldSwVersion"); + upgradePreCheckPayload.setOldSwVersion(oldSwVersion); + + String targetSwVersion = String.valueOf(execution.getVariable(SoPropertyConstants.TARGET_SOFTWARE_VERSION)); + if (targetSwVersion == null) { + targetSwVersion = JsonUtils.getJsonValue(requestPayload, "targetSwVersion"); + } + upgradePreCheckPayload.setTargetSwVersion(targetSwVersion); + + String ruleName = JsonUtils.getJsonValue(requestPayload, "preCheckRuleName"); + upgradePreCheckPayload.setRuleName(ruleName); + + String additionalData = JsonUtils.getJsonValue(requestPayload, "preCheckAdditionalData"); + upgradePreCheckPayload.setAdditionalData(additionalData); + + String playbookName = JsonUtils.getJsonValue(requestPayload, "preCheckPlaybook"); + if (playbookName != null) { + upgradePreCheckPayload.setPlaybookName(playbookName); + } + + return upgradePreCheckPayload; + } + + public static String convertToSting(Object msgObject) throws JsonProcessingException { + ObjectMapper mapper = new ObjectMapper(); + return mapper.writeValueAsString(msgObject); + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDE.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDE.java index db0d402f6e..ed865e058f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDE.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDE.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019 Nordix + * Modifications Copyright (C) 2020 Huawei * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,16 +20,24 @@ package org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.sdnc; +import java.util.List; +import java.util.UUID; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.stereotype.Component; import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.bpmn.core.json.JsonUtils; import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext; +import org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.common.SoPropertyConstants; import org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.LcmControllerDE; -import org.springframework.stereotype.Component; +import org.onap.so.client.sdnc.common.SDNCConstants; +import org.onap.so.client.sdnc.lcm.*; +import org.onap.so.client.sdnc.lcm.beans.*; +import org.onap.so.client.sdnc.lcm.beans.payload.*; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.REQUEST_ID; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.REQUEST_PAYLOAD; -/** - * This class is created to demonstrate how to support {@link DelegateExecution} API based SDNC controller. - * - * Function wise, it's similar to the Appc Controller, like in the AppcClient groovy code. - */ @Component public class SdncControllerDE extends LcmControllerDE { @@ -44,14 +53,33 @@ public class SdncControllerDE extends LcmControllerDE { return true; } - /** - * This method is left empty intentionally. If you are planning to use the SDNC Controller, please implement here. - * - * You can use the {@ref ApplicationControllerAction}, {@ref ApplicationControllerOrchestrator}, - * {@ref ApplicationControllerClient} or create your own SDNC Client proxy. - */ @Override protected int callLcmClient(ControllerContext<DelegateExecution> context) { + DelegateExecution execution = context.getExecution(); + + logger.debug("Running activity for id: {}, name: {}", execution.getCurrentActivityId(), + execution.getCurrentActivityName()); + + boolean result; + try { + LcmInput lcmInput = buildLcmInput(execution); + if (lcmInput != null) { + result = sendLcmRequest(execution, lcmInput); + } else { + logger.error("Build LCM Input error"); + result = false; + } + } catch (Exception e) { + logger.error("Call SDNC LCM Client failure: ", e); + result = false; + } + + if (result) { + execution.setVariable(SoPropertyConstants.CONTROLLER_STATUS, "Success"); + } else { + execution.setVariable(SoPropertyConstants.CONTROLLER_STATUS, "Failure"); + } + return 0; } @@ -59,4 +87,177 @@ public class SdncControllerDE extends LcmControllerDE { protected int getErrorCode() { return SDNC_DELEGATE_EXECUTION_ERROR_CODE; } + + private LcmOutput sendSyncRequest(String operation, LcmInput lcmInput) { + SDNCLcmClientBuilder sdncLcmClientBuilder = new SDNCLcmClientBuilder(); + SDNCLcmRestClient sdncLcmRestClient; + try { + sdncLcmRestClient = sdncLcmClientBuilder.newSDNCLcmRestClient(operation); + } catch (SDNCLcmClientBuilderException e) { + logger.error("Create SDNCLcmRestClient error: ", e); + return null; + } + + return sdncLcmRestClient.sendRequest(lcmInput); + } + + private LcmOutput selectLcmOutputFromDmaapResponses(List<LcmDmaapResponse> lcmDmaapResponses, LcmInput lcmInput) { + String expectedCorrelationId = + lcmInput.getCommonHeader().getRequestId() + "-" + lcmInput.getCommonHeader().getSubRequestId(); + + for (LcmDmaapResponse lcmDmaapResponse : lcmDmaapResponses) { + String correlationId = lcmDmaapResponse.getCorrelationId(); + if (expectedCorrelationId.equals(correlationId)) { + return lcmDmaapResponse.getBody().getOutput(); + } + } + + return null; + } + + private LcmOutput sendAsyncRequest(String operation, LcmInput lcmInput) { + SDNCLcmClientBuilder sdncLcmClientBuilder = new SDNCLcmClientBuilder(); + SDNCLcmDmaapClient sdncLcmDmaapClient; + try { + sdncLcmDmaapClient = sdncLcmClientBuilder.newSDNCLcmDmaapClient(); + } catch (SDNCLcmClientBuilderException e) { + logger.error("Create SDNCLcmDmaapClient error: ", e); + return null; + } + + LcmDmaapRequest lcmDmaapRequest = SDNCLcmMessageBuilder.buildLcmDmaapRequest(operation, lcmInput); + try { + sdncLcmDmaapClient.sendRequest(lcmDmaapRequest); + } catch (Exception e) { + logger.error("SDNCLcmDmaapClient sends request error: ", e); + return null; + } + + long timeout = sdncLcmClientBuilder.getSDNCLcmProperties().getActionTimeout(); + long startTime = System.currentTimeMillis(); + while (true) { + List<LcmDmaapResponse> lcmDmaapResponses = sdncLcmDmaapClient.getResponse(); + if (lcmDmaapResponses.size() > 0) { + LcmOutput lcmOutput = selectLcmOutputFromDmaapResponses(lcmDmaapResponses, lcmInput); + if (lcmOutput != null) { + return lcmOutput; + } + } + + long stopTime = System.currentTimeMillis(); + if ((stopTime - startTime) > timeout) { + logger.error("Timeout for SDNC LCM action {}", lcmInput.getAction()); + return null; + } + } + } + + public static String toLowerHyphen(String lcmAction) { + String regex = "([a-z0-9A-Z])(?=[A-Z])"; + String replacement = "$1-"; + return lcmAction.replaceAll(regex, replacement).toLowerCase(); + } + + private LcmInput buildLcmInput(DelegateExecution execution) throws JsonProcessingException { + String requestId = String.valueOf(execution.getVariable(REQUEST_ID)); + String requestAction = String.valueOf(execution.getVariable(SoPropertyConstants.SO_ACTION)); + String pnfName = String.valueOf(execution.getVariable(PNF_CORRELATION_ID)); + logger.debug(String.format("requestId: %s, action: %s, pnfName: %s", requestId, requestAction, pnfName)); + + String requestPayload = String.valueOf(execution.getVariable(REQUEST_PAYLOAD)); + logger.debug("SO request payload: " + requestPayload); + + String lcmAction; + String lcmPayload; + + switch (requestAction) { + case SoPropertyConstants.ACTION_PRE_CHECK: + lcmAction = SDNCLcmActionConstants.UPGRADE_PRE_CHECK; + + UpgradePreCheckPayload upgradePreCheckPayload; + upgradePreCheckPayload = SDNCLcmPayloadBuilder.buildUpgradePreCheckPayload(execution); + lcmPayload = SDNCLcmPayloadBuilder.convertToSting(upgradePreCheckPayload); + break; + case SoPropertyConstants.ACTION_DOWNLOAD_N_E_SW: + lcmAction = SDNCLcmActionConstants.DOWNLOAD_N_E_SW; + + DownloadNESwPayload downloadNESwPayload; + downloadNESwPayload = SDNCLcmPayloadBuilder.buildDownloadNESwPayload(execution); + lcmPayload = SDNCLcmPayloadBuilder.convertToSting(downloadNESwPayload); + break; + case SoPropertyConstants.ACTION_ACTIVATE_N_E_SW: + lcmAction = SDNCLcmActionConstants.ACTIVATE_N_E_SW; + + ActivateNESwPayload activateNESwPayload; + activateNESwPayload = SDNCLcmPayloadBuilder.buildActivateNESwPayload(execution); + lcmPayload = SDNCLcmPayloadBuilder.convertToSting(activateNESwPayload); + break; + case SoPropertyConstants.ACTION_POST_CHECK: + lcmAction = SDNCLcmActionConstants.UPGRADE_POST_CHECK; + + UpgradePostCheckPayload upgradePostCheckPayload; + upgradePostCheckPayload = SDNCLcmPayloadBuilder.buildUpgradePostCheckPayload(execution); + lcmPayload = SDNCLcmPayloadBuilder.convertToSting(upgradePostCheckPayload); + break; + default: + logger.error("Unsupported SO Action: " + requestAction); + return null; + } + + logger.debug("SDNC LCM payload for {}: {}", lcmAction, lcmPayload); + + String subRequestId = UUID.randomUUID().toString(); + LcmInput lcmInput = + SDNCLcmMessageBuilder.buildLcmInputForPnf(requestId, subRequestId, pnfName, lcmAction, lcmPayload); + + ObjectMapper mapper = new ObjectMapper(); + String lcmInputMsg = mapper.writeValueAsString(lcmInput); + logger.debug("SDNC input message:\n" + lcmInputMsg); + + return lcmInput; + } + + private boolean parseLcmOutput(LcmOutput lcmOutput, String lcmAction) { + if (lcmOutput == null) { + logger.error("Call SDNC LCM API failure"); + return false; + } + + LcmStatus lcmStatus = lcmOutput.getStatus(); + + if (lcmStatus.getCode() == SDNCConstants.LCM_OUTPUT_SUCCESS_CODE) { + logger.debug("Call SDNC LCM API success: " + lcmStatus.getMessage()); + } else { + logger.error("Call SDNC LCM API failure: " + lcmStatus.getMessage()); + } + + String outputPayload = lcmOutput.getPayload(); + logger.debug("SDNC LCM action: {}, result: {}", lcmAction, outputPayload); + if (outputPayload != null) { + String result = JsonUtils.getJsonValue(outputPayload, "result"); + if ("Success".equals(result)) { + logger.debug("Run SDNC LCM action {} success", lcmAction); + return true; + } else { + String reason = JsonUtils.getJsonValue(outputPayload, "reason"); + logger.error("Run SDNC LCM action {} failure, reason: {}", lcmAction, reason); + } + } + + return false; + } + + private boolean sendLcmRequest(DelegateExecution execution, LcmInput lcmInput) { + String actionMode = String.valueOf(execution.getVariable(SoPropertyConstants.SO_ACTION_MODE)); + String lcmOperation = toLowerHyphen(lcmInput.getAction()); + + LcmOutput lcmOutput; + if ("async".equals(actionMode)) { + lcmOutput = sendAsyncRequest(lcmOperation, lcmInput); + } else { + lcmOutput = sendSyncRequest(lcmOperation, lcmInput); + } + + return parseLcmOutput(lcmOutput, lcmInput.getAction()); + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java index ff9d7376de..7930a33a2a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java @@ -39,7 +39,7 @@ import org.onap.so.client.appc.ApplicationControllerAction; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.db.catalog.beans.ControllerSelectionReference; import org.onap.so.db.catalog.client.CatalogDbClient; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java index 1a7d22c0dd..2d39cc185e 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java @@ -35,7 +35,7 @@ import org.onap.so.client.appc.ApplicationControllerAction; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.catalog.beans.ControllerSelectionReference; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ExternalTicketTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ExternalTicketTasks.java index 6bfe618460..7bfcd56c42 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ExternalTicketTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ExternalTicketTasks.java @@ -24,7 +24,7 @@ import org.onap.so.logger.LoggingAnchor; import org.camunda.bpm.engine.delegate.BpmnError; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.client.ticket.ExternalTicket; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java index cf56964af3..9de8e184f2 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java @@ -282,6 +282,7 @@ public class AAIObjectMapper { map().setConfigurationType(source.getModelInfoConfiguration().getConfigurationType()); map().setConfigurationSubType(source.getModelInfoConfiguration().getConfigurationRole()); map().setConfigPolicyName(source.getModelInfoConfiguration().getPolicyName()); + skip().setConfigurationRole(null); } }); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java index 088ce1ac38..dd9ecbead4 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java @@ -31,7 +31,7 @@ import org.onap.namingservice.model.NameGenResponse; import org.onap.namingservice.model.NameGenResponseError; import org.onap.namingservice.model.Respelement; import org.onap.so.client.exception.BadResponseException; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java index e7e4e25af2..01ac675d83 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java @@ -30,7 +30,7 @@ import org.apache.commons.lang.StringUtils; import org.apache.http.HttpStatus; import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.MapperException; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java index a41c79b171..f6642ab76a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java @@ -48,7 +48,7 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/bpmn/so-bpmn-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 index 5bd4df74bb..9adae88a5a 100644 --- 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 @@ -24,10 +24,15 @@ 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; @@ -39,8 +44,8 @@ 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.BaseTaskTest; 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; @@ -54,13 +59,19 @@ 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 extends BaseTaskTest { +public class NetworkAdapterRestV1Test { - @InjectMocks - NetworkAdapterRestV1 networkAdapterRestV1Tasks = new NetworkAdapterRestV1(); @Mock - ExceptionBuilder exceptionBuilder = new ExceptionBuilder(); + 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"; @@ -73,6 +84,7 @@ public class NetworkAdapterRestV1Test extends BaseTaskTest { @Before public void setup() { + initMocks(this); delegateExecution = new DelegateExecutionFake(); } @@ -187,6 +199,53 @@ public class NetworkAdapterRestV1Test extends BaseTaskTest { } } + @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> 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 = "createNetworkResponse"; + Optional<Response> response = Optional.of(createResponse(status, responseEntity)); + when(networkAdapterResources.deleteNetworkAsync(deleteNetworkRequest)).thenReturn(response); + // when + networkAdapterRestV1Tasks.callNetworkAdapter(delegateExecution); + // then + verifyExecutionContent(status, responseEntity, messageId); + } + + 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 "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><" + networkResponseType + "><networkId>" diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilderTest.java new file mode 100644 index 0000000000..61f2ee3432 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilderTest.java @@ -0,0 +1,135 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.sdnc; + +import com.fasterxml.jackson.core.JsonProcessingException; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.junit.Before; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.junit.runner.RunWith; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.when; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.REQUEST_PAYLOAD; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.common.SoPropertyConstants; +import org.onap.so.client.sdnc.lcm.beans.payload.*; + +@RunWith(SpringJUnit4ClassRunner.class) +public class SDNCLcmPayloadBuilderTest { + private static Logger logger = LoggerFactory.getLogger(SDNCLcmPayloadBuilderTest.class); + + protected static String payload = "{" + "\"ipaddressV4Oam\": \"192.168.1.10\"," + "\"oldSwVersion\": \"v1\"," + + "\"preCheckRuleName\": \"r101\"," + "\"preCheckAdditionalData\": \"{}\"," + + "\"preCheckPlaybook\": \"precheck_playbook\"," + "\"swToBeDownloaded\": \"[{" + + "\\\"swLocation\\\": \\\"http://192.168.1.20/test.zip\\\"," + "\\\"swFileSize\\\": 123456," + + "\\\"swFileCompression\\\": \\\"ZIP\\\"," + "\\\"swFileFormat\\\": \\\"binary\\\"}]\"," + + "\"downloadNESwPlaybook\": \"downloadnesw_playbook\"," + + "\"activateNESwPlaybook\": \"activatenesw_playbook\"," + "\"postCheckRuleName\": \"r102\"," + + "\"postCheckAdditionalData\": \"{}\"," + "\"postCheckPlaybook\": \"postcheck_playbook\"" + "}"; + protected String targetSoftwareVersion = "v2"; + + @MockBean + private DelegateExecution execution; + + public static String getRequestPayload() { + return payload; + } + + @Before + public void setUp() { + when(execution.getVariable(REQUEST_PAYLOAD)).thenReturn(payload); + when(execution.getVariable(SoPropertyConstants.TARGET_SOFTWARE_VERSION)).thenReturn(targetSoftwareVersion); + } + + + @Test + public final void testBuildActivateNESwPayload() { + String expectedPayload = "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\"," + + "\"playbook-name\":\"activatenesw_playbook\"," + "\"swVersionToBeActivated\":\"v2\"" + "}"; + + ActivateNESwPayload activateNESwPayload = SDNCLcmPayloadBuilder.buildActivateNESwPayload(execution); + try { + String payload = SDNCLcmPayloadBuilder.convertToSting(activateNESwPayload); + logger.debug("ActivateNESwPayload:\n" + payload); + + assertEquals(expectedPayload, payload); + } catch (JsonProcessingException e) { + fail("Convert ActivateNESwPayload to String error: " + e.toString()); + } + } + + @Test + public final void testBuildDownloadNESwPayload() { + String expectedSwToBeDownloadedElement = "{" + "\"swLocation\":\"http://192.168.1.20/test.zip\"," + + "\"swFileSize\":123456," + "\"swFileCompression\":\"ZIP\"," + "\"swFileFormat\":\"binary\"" + "}"; + String expectedPayload = + "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\"," + "\"playbook-name\":\"downloadnesw_playbook\"," + + "\"swToBeDownloaded\":[" + expectedSwToBeDownloadedElement + "]" + "}"; + + DownloadNESwPayload downloadNESwPayload = SDNCLcmPayloadBuilder.buildDownloadNESwPayload(execution); + try { + String payload = SDNCLcmPayloadBuilder.convertToSting(downloadNESwPayload); + logger.debug("DownloadNESwPayload:\n" + payload); + + assertEquals(expectedPayload, payload); + } catch (JsonProcessingException e) { + fail("Convert DownloadNESwPayload to String error: " + e.toString()); + } + } + + @Test + public final void testBuildUpgradePostCheckPayload() { + String expectedPayload = "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\"," + + "\"playbook-name\":\"postcheck_playbook\"," + "\"oldSwVersion\":\"v1\"," + + "\"targetSwVersion\":\"v2\"," + "\"ruleName\":\"r102\"," + "\"additionalData\":\"{}\"" + "}"; + + UpgradePostCheckPayload upgradePostCheckPayload = SDNCLcmPayloadBuilder.buildUpgradePostCheckPayload(execution); + try { + String payload = SDNCLcmPayloadBuilder.convertToSting(upgradePostCheckPayload); + logger.debug("UpgradePostCheckPayload:\n" + payload); + + assertEquals(expectedPayload, payload); + } catch (JsonProcessingException e) { + fail("Convert UpgradePostCheckPayload to String error: " + e.toString()); + } + } + + @Test + public final void testBuildUpgradePreCheckPayload() { + String expectedPayload = "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\"," + + "\"playbook-name\":\"precheck_playbook\"," + "\"oldSwVersion\":\"v1\"," + + "\"targetSwVersion\":\"v2\"," + "\"ruleName\":\"r101\"," + "\"additionalData\":\"{}\"" + "}"; + + UpgradePreCheckPayload upgradePreCheckPayload = SDNCLcmPayloadBuilder.buildUpgradePreCheckPayload(execution); + try { + String payload = SDNCLcmPayloadBuilder.convertToSting(upgradePreCheckPayload); + logger.debug("UpgradePreCheckPayload:\n" + payload); + + assertEquals(expectedPayload, payload); + } catch (JsonProcessingException e) { + fail("Convert UpgradePreCheckPayload to String error: " + e.toString()); + } + } +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDETest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDETest.java index 674167624e..02c7dca9ae 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDETest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDETest.java @@ -28,7 +28,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext; import org.onap.so.bpmn.infrastructure.decisionpoint.api.controller.ControllerPreparable; -import org.onap.so.client.appc.ApplicationControllerAction; import org.onap.so.client.exception.ExceptionBuilder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.mock.mockito.MockBean; @@ -48,9 +47,6 @@ public class SdncControllerDETest { @MockBean private ControllerPreparable<DelegateExecution> preparable; - @MockBean - protected ApplicationControllerAction client; - @Before public void setUp() { when(controllerContext.getControllerActor()).thenReturn("sdnc"); diff --git a/common/src/main/java/org/onap/so/db/connections/ScheduledDnsLookup.java b/common/src/main/java/org/onap/so/db/connections/ScheduledDnsLookup.java index 40acac57aa..725da97d5b 100644 --- a/common/src/main/java/org/onap/so/db/connections/ScheduledDnsLookup.java +++ b/common/src/main/java/org/onap/so/db/connections/ScheduledDnsLookup.java @@ -8,11 +8,9 @@ import javax.management.JMX; import javax.management.MBeanServer; import javax.management.ObjectInstance; import javax.management.ObjectName; -import org.jboss.logging.MDC; -import org.onap.logging.filter.base.ONAPComponents; -import org.onap.logging.ref.slf4j.ONAPLogConstants; -import org.onap.so.logger.ErrorCode; -import org.onap.so.logger.ScheduledTasksMDCSetup; +import org.onap.logging.filter.base.ErrorCode; +import org.onap.logging.filter.base.ScheduledLogging; +import org.onap.logging.filter.base.ScheduledTaskException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -32,23 +30,16 @@ public class ScheduledDnsLookup { @Autowired private DbDnsIpAddress dnsIpAddress; - @Autowired - private ScheduledTasksMDCSetup scheduledMDCSetup; - private static Logger logger = LoggerFactory.getLogger(ScheduledDnsLookup.class); + @ScheduledLogging @Scheduled(fixedRate = 15000) - public void performDnsLookup() { - scheduledMDCSetup.mdcSetup(ONAPComponents.SO, "performDnsLookup"); + public void performDnsLookup() throws ScheduledTaskException { String dnsUrl = System.getenv(DB_HOST); - try { if (dnsUrl == null) { - scheduledMDCSetup.errorMDCSetup(ErrorCode.DataError, "Database DNS is not provided."); - logger.error("Database DNS is not provided. Please verify the configuration"); - MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.ERROR.toString()); - scheduledMDCSetup.exitAndClearMDC(); - return; + throw new ScheduledTaskException(ErrorCode.DataError, + "Database DNS is not provided. Please verify the configuration"); } InetAddress inetAddress = java.net.InetAddress.getByName(dnsUrl); @@ -57,7 +48,6 @@ public class ScheduledDnsLookup { /* This is in initial state */ if (currentIpAddress == null) { dnsIpAddress.setIpAddress(ipAddress); - scheduledMDCSetup.exitAndClearMDC(); return; } @@ -69,7 +59,6 @@ public class ScheduledDnsLookup { } catch (UnknownHostException e) { logger.warn("Database DNS %s is not resolvable to an IP Address", dnsUrl); } - scheduledMDCSetup.exitAndClearMDC(); } private void softEvictConnectionPool() { diff --git a/common/src/main/java/org/onap/so/logger/ScheduledTasksMDCSetup.java b/common/src/main/java/org/onap/so/logger/ScheduledTasksMDCSetup.java deleted file mode 100644 index 41c4b4bfae..0000000000 --- a/common/src/main/java/org/onap/so/logger/ScheduledTasksMDCSetup.java +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 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.logger; - -import java.util.UUID; -import org.onap.logging.filter.base.Constants; -import org.onap.logging.filter.base.MDCSetup; -import org.onap.logging.filter.base.ONAPComponentsList; -import org.onap.logging.ref.slf4j.ONAPLogConstants; -import org.slf4j.MDC; -import org.springframework.stereotype.Component; - -@Component -public class ScheduledTasksMDCSetup extends MDCSetup { - - public void mdcSetup(ONAPComponentsList targetEntity, String serviceName) { - try { - setEntryTimeStamp(); - setServerFQDN(); - MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.INPROGRESS.toString()); - MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, UUID.randomUUID().toString()); - MDC.put(ONAPLogConstants.MDCs.TARGET_ENTITY, targetEntity.toString()); - MDC.put(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME, Constants.DefaultValues.UNKNOWN); - MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, serviceName); - setLogTimestamp(); - setElapsedTime(); - MDC.put(ONAPLogConstants.MDCs.PARTNER_NAME, getProperty(Constants.Property.PARTNER_NAME)); - logger.info(ONAPLogConstants.Markers.ENTRY, "Entering"); - } catch (Exception e) { - logger.warn("Error in ScheduledTasksMDCSetup mdcSetup: {}", e.getMessage()); - } - } - - public void errorMDCSetup(ErrorCode errorCode, String errorDescription) { - MDC.put(ONAPLogConstants.MDCs.ERROR_CODE, String.valueOf(errorCode.getValue())); - MDC.put(ONAPLogConstants.MDCs.ERROR_DESC, errorDescription); - } - - public void exitAndClearMDC() { - try { - setStatusCode(); - setLogTimestamp(); - setElapsedTime(); - logger.info(ONAPLogConstants.Markers.EXIT, "Exiting."); - } catch (Exception e) { - logger.warn("Error in ScheduledTasksMDCSetup clear MDC: {}", e.getMessage()); - } - MDC.clear(); - } - - public void setStatusCode() { - String currentStatusCode = MDC.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE); - if (currentStatusCode == null || !currentStatusCode.equals(ONAPLogConstants.ResponseStatus.ERROR.toString())) { - MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.COMPLETE.toString()); - } - } -} diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestStatus.java b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestStatus.java index 3ada984b58..f39aa3656a 100644 --- a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestStatus.java +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestStatus.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -32,6 +32,8 @@ public class RequestStatus { protected String requestState; @JsonProperty("statusMessage") protected String statusMessage; + @JsonProperty("resourceStatusMessage") + protected String resourceStatusMessage; @JsonProperty("percentProgress") protected Integer percentProgress; @JsonProperty("timestamp") @@ -95,6 +97,14 @@ public class RequestStatus { this.statusMessage = statusMessage; } + public String getResourceStatusMessage() { + return resourceStatusMessage; + } + + public void setResourceStatusMessage(String resourceStatusMessage) { + this.resourceStatusMessage = resourceStatusMessage; + } + public Integer getPercentProgress() { return percentProgress; } @@ -122,8 +132,8 @@ public class RequestStatus { @Override public String toString() { return new ToStringBuilder(this).append("requestState", requestState).append("statusMessage", statusMessage) - .append("percentProgress", percentProgress).append("timestamp", timeStamp) - .append("extSystemErrorSource", extSystemErrorSource) + .append("resourceStatusMessage", resourceStatusMessage).append("percentProgress", percentProgress) + .append("timestamp", timeStamp).append("extSystemErrorSource", extSystemErrorSource) .append("rollbackExtSystemErrorSource", rollbackExtSystemErrorSource).append("flowStatus", flowStatus) .append("retryStatusMessage", retryStatusMessage).append("rollbackStatusMessage", rollbackStatusMessage) .toString(); diff --git a/common/src/main/java/org/onap/so/utils/CryptoUtils.java b/common/src/main/java/org/onap/so/utils/CryptoUtils.java index 1c38dfb774..eecee4c83f 100644 --- a/common/src/main/java/org/onap/so/utils/CryptoUtils.java +++ b/common/src/main/java/org/onap/so/utils/CryptoUtils.java @@ -24,7 +24,7 @@ package org.onap.so.utils; import org.onap.so.logger.LoggingAnchor; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java b/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java index 4f13cec8f4..035ad1dc81 100644 --- a/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java +++ b/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java @@ -6,6 +6,7 @@ import java.util.concurrent.ConcurrentHashMap; import org.camunda.bpm.client.ExternalTaskClient; import org.camunda.bpm.client.interceptor.ClientRequestInterceptor; import org.camunda.bpm.client.interceptor.auth.BasicAuthProvider; +import org.onap.logging.filter.base.ScheduledLogging; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -53,6 +54,7 @@ public class ExternalTaskServiceUtils { return Integer.parseInt(env.getProperty("workflow.topics.maxClients", "3")); } + @ScheduledLogging @Scheduled(fixedDelay = 30000) public void checkAllClientsActive() { getClients().stream().filter(client -> !client.isActive()).forEach(ExternalTaskClient::start); diff --git a/common/src/main/java/org/onap/so/utils/XmlMarshaller.java b/common/src/main/java/org/onap/so/utils/XmlMarshaller.java index 0ff3ccfa9c..3ae644be6b 100644 --- a/common/src/main/java/org/onap/so/utils/XmlMarshaller.java +++ b/common/src/main/java/org/onap/so/utils/XmlMarshaller.java @@ -34,7 +34,7 @@ import javax.xml.parsers.SAXParserFactory; import javax.xml.transform.sax.SAXSource; import org.onap.so.logger.LoggingAnchor; import org.onap.so.exceptions.MarshallerException; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/common/src/test/java/org/onap/so/logger/ScheduledTasksMDCSetupTest.java b/common/src/test/java/org/onap/so/logger/ScheduledTasksMDCSetupTest.java deleted file mode 100644 index f232781871..0000000000 --- a/common/src/test/java/org/onap/so/logger/ScheduledTasksMDCSetupTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 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.logger; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import org.junit.After; -import org.junit.Test; -import org.onap.logging.filter.base.Constants; -import org.onap.logging.ref.slf4j.ONAPLogConstants; -import org.onap.so.utils.Components; -import org.onap.so.utils.UUIDChecker; -import org.slf4j.MDC; - -public class ScheduledTasksMDCSetupTest { - private ScheduledTasksMDCSetup tasksMDCSetup = new ScheduledTasksMDCSetup(); - - @After - public void tearDown() { - MDC.clear(); - System.clearProperty("partnerName"); - } - - @Test - public void mdcSetupTest() { - System.setProperty("partnerName", Components.APIH.toString()); - tasksMDCSetup.mdcSetup(Components.APIH, "mdcSetupTest"); - - assertTrue(UUIDChecker.isValidUUID(MDC.get(ONAPLogConstants.MDCs.REQUEST_ID))); - assertEquals(Components.APIH.toString(), MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY)); - assertEquals(Components.APIH.toString(), MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME)); - assertEquals("mdcSetupTest", MDC.get(ONAPLogConstants.MDCs.SERVICE_NAME)); - assertEquals(Constants.DefaultValues.UNKNOWN, MDC.get(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME)); - assertNotNull(MDC.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP)); - assertNotNull(MDC.get(ONAPLogConstants.MDCs.ELAPSED_TIME)); - assertNotNull(MDC.get(ONAPLogConstants.MDCs.LOG_TIMESTAMP)); - assertNotNull(MDC.get(ONAPLogConstants.MDCs.SERVER_FQDN)); - } - - @Test - public void errorMDCSetupTest() { - tasksMDCSetup.errorMDCSetup(ErrorCode.UnknownError, "Error"); - - assertEquals("900", MDC.get(ONAPLogConstants.MDCs.ERROR_CODE)); - assertEquals("Error", MDC.get(ONAPLogConstants.MDCs.ERROR_DESC)); - } - - @Test - public void setStatusCodeTest() { - tasksMDCSetup.setStatusCode(); - - assertEquals(ONAPLogConstants.ResponseStatus.COMPLETE.toString(), - MDC.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE)); - } - - @Test - public void setStatusCodeErrorTest() { - MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.ERROR.toString()); - tasksMDCSetup.setStatusCode(); - - assertEquals(ONAPLogConstants.ResponseStatus.ERROR.toString(), - MDC.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE)); - } -} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/ResponseHandler.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/ResponseHandler.java index bedce185c5..806646022c 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/ResponseHandler.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/ResponseHandler.java @@ -34,7 +34,7 @@ import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.BPMNFailureException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import com.fasterxml.jackson.databind.ObjectMapper; import org.slf4j.Logger; diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/logging/ErrorLoggerInfo.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/logging/ErrorLoggerInfo.java index a896078d44..dd51032300 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/logging/ErrorLoggerInfo.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/logging/ErrorLoggerInfo.java @@ -22,7 +22,7 @@ package org.onap.so.apihandlerinfra.logging; import java.io.Serializable; import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionTest.java index 2cdf4f1a3f..7bd371c974 100644 --- a/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionTest.java +++ b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionTest.java @@ -27,7 +27,7 @@ import org.junit.rules.ExpectedException; import org.onap.so.apihandler.common.ErrorNumbers; import org.onap.so.apihandlerinfra.exceptions.*; import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import java.io.IOException; import java.util.LinkedList; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java index 94e03f1452..d4bc4fd165 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java @@ -64,7 +64,7 @@ import org.onap.so.db.catalog.beans.ServiceRecipe; import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.request.beans.OperationStatus; import org.onap.so.db.request.client.RequestsDbClient; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.serviceinstancebeans.ModelInfo; import org.onap.so.serviceinstancebeans.ModelType; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java index 88028d32a1..3007ddd7c9 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java @@ -39,7 +39,7 @@ import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.exceptions.ValidationException; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.serviceinstancebeans.ModelType; import org.onap.so.serviceinstancebeans.RequestReferences; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java index 34eca2f266..0ec61785fd 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java @@ -50,7 +50,7 @@ import org.onap.so.apihandlerinfra.tasksbeans.TasksRequest; import org.onap.so.apihandlerinfra.tasksbeans.Value; import org.onap.so.apihandlerinfra.tasksbeans.Variables; import org.onap.so.exceptions.ValidationException; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java index b7d3d633d6..33c2ac80be 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java @@ -57,7 +57,7 @@ import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.beans.RequestProcessingData; import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.exceptions.ValidationException; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.serviceinstancebeans.CloudRequestData; import org.onap.so.serviceinstancebeans.GetOrchestrationListResponse; @@ -106,7 +106,7 @@ public class OrchestrationRequests { private CamundaRequestHandler camundaRequestHandler; @GET - @Path("/{version:[vV][4-7]}/{requestId}") + @Path("/{version:[vV][4-8]}/{requestId}") @Operation(description = "Find Orchestrated Requests for a given requestId", responses = @ApiResponse( content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class))))) @Produces(MediaType.APPLICATION_JSON) @@ -115,7 +115,6 @@ public class OrchestrationRequests { @PathParam("version") String version, @QueryParam("includeCloudRequest") boolean includeCloudRequest, @QueryParam(value = "format") String format) throws ApiException { - String apiVersion = version.substring(1); GetOrchestrationResponse orchestrationResponse = new GetOrchestrationResponse(); InfraActiveRequests infraActiveRequest = null; @@ -152,7 +151,7 @@ public class OrchestrationRequests { } } - Request request = mapInfraActiveRequestToRequest(infraActiveRequest, includeCloudRequest, format); + Request request = mapInfraActiveRequestToRequest(infraActiveRequest, includeCloudRequest, format, version); if (null != requestProcessingData && !requestProcessingData.isEmpty()) { request.setRequestProcessingData(mapRequestProcessingData(requestProcessingData)); @@ -161,11 +160,11 @@ public class OrchestrationRequests { orchestrationResponse.setRequest(request); return builder.buildResponse(HttpStatus.SC_OK, MDC.get(ONAPLogConstants.MDCs.REQUEST_ID), orchestrationResponse, - apiVersion); + version); } @GET - @Path("/{version:[vV][4-7]}") + @Path("/{version:[vV][4-8]}") @Operation(description = "Find Orchestrated Requests for a URI Information", responses = @ApiResponse( content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class))))) @Produces(MediaType.APPLICATION_JSON) @@ -206,7 +205,7 @@ public class OrchestrationRequests { for (InfraActiveRequests infraActive : activeRequests) { RequestList requestList = new RequestList(); - Request request = mapInfraActiveRequestToRequest(infraActive, includeCloudRequest, format); + Request request = mapInfraActiveRequestToRequest(infraActive, includeCloudRequest, format, version); if (isRequestProcessingDataRequired(format)) { List<RequestProcessingData> requestProcessingData = @@ -292,7 +291,7 @@ public class OrchestrationRequests { } protected Request mapInfraActiveRequestToRequest(InfraActiveRequests iar, boolean includeCloudRequest, - String format) throws ApiException { + String format, String version) throws ApiException { String requestBody = iar.getRequestBody(); Request request = new Request(); @@ -328,8 +327,6 @@ public class OrchestrationRequests { ir.setVolumeGroupInstanceId(iar.getVolumeGroupId()); if (iar.getVolumeGroupName() != null) ir.setVolumeGroupInstanceName(iar.getVolumeGroupName()); - if (iar.getRequestorId() != null) - ir.setRequestorId(iar.getRequestorId()); if (iar.getInstanceGroupId() != null) ir.setInstanceGroupId(iar.getInstanceGroupId()); if (iar.getInstanceGroupName() != null) @@ -404,7 +401,7 @@ public class OrchestrationRequests { }); } - mapRequestStatusAndExtSysErrSrcToRequest(iar, status, format); + mapRequestStatusAndExtSysErrSrcToRequest(iar, status, format, version); request.setRequestStatus(status); return request; @@ -433,7 +430,7 @@ public class OrchestrationRequests { } protected void mapRequestStatusAndExtSysErrSrcToRequest(InfraActiveRequests iar, RequestStatus status, - String format) { + String format, String version) { String rollbackStatusMessage = iar.getRollbackStatusMessage(); String flowStatusMessage = iar.getFlowStatus(); String retryStatusMessage = iar.getRetryStatusMessage(); @@ -469,6 +466,12 @@ public class OrchestrationRequests { if (rollbackStatusMessage != null) { status.setRollbackStatusMessage(rollbackStatusMessage); } + if (version.matches("v[8-9]|v[1-9][0-9]")) { + if (iar.getResourceStatusMessage() != null) { + status.setResourceStatusMessage(iar.getResourceStatusMessage()); + } + } + status.setExtSystemErrorSource(iar.getExtSystemErrorSource()); status.setRollbackExtSystemErrorSource(iar.getRollbackExtSystemErrorSource()); } else { @@ -494,6 +497,13 @@ public class OrchestrationRequests { statusMessages = "ROLLBACK STATUS: " + rollbackStatusMessage; } } + if (iar.getResourceStatusMessage() != null) { + if (statusMessages != null) { + statusMessages = statusMessages + " " + "RESOURCE STATUS: " + iar.getResourceStatusMessage(); + } else { + statusMessages = "RESOURCE STATUS: " + iar.getResourceStatusMessage(); + } + } } if (statusMessages != null) { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationTasks.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationTasks.java index 90cf50262b..836f08adb5 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationTasks.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationTasks.java @@ -35,7 +35,7 @@ import org.onap.so.apihandler.common.ResponseBuilder; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.db.request.beans.OrchestrationTask; import org.onap.so.db.request.client.RequestsDbClient; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java index 38fb1596d0..9b37043b2d 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java @@ -76,7 +76,7 @@ import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.exceptions.ValidationException; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.LogConstants; import org.onap.so.logger.MessageEnum; import org.onap.so.serviceinstancebeans.CloudConfiguration; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequest.java index a15d9cfd48..6132815cf6 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequest.java @@ -43,7 +43,7 @@ import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; import org.onap.so.constants.Status; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.HttpHeadersConstants; import org.onap.so.logger.LogConstants; import org.onap.so.logger.MdcConstants; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java index 33eae43e44..f1e8e711c4 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java @@ -56,7 +56,7 @@ import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.exceptions.ValidationException; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.serviceinstancebeans.CloudConfiguration; import org.onap.so.serviceinstancebeans.ModelInfo; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TasksHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TasksHandler.java index edc287ce0a..418c702768 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TasksHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TasksHandler.java @@ -50,7 +50,7 @@ import org.onap.so.apihandlerinfra.tasksbeans.TaskList; import org.onap.so.apihandlerinfra.tasksbeans.TaskVariableValue; import org.onap.so.apihandlerinfra.tasksbeans.TaskVariables; import org.onap.so.apihandlerinfra.tasksbeans.TasksGetResponse; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java index d9955352c6..357497591d 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java @@ -41,7 +41,7 @@ import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; import org.onap.so.apihandlerinfra.workflowspecificationbeans.*; import org.onap.so.db.catalog.beans.*; import org.onap.so.db.catalog.client.CatalogDbClient; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandler.java index 20e27a5265..3fd672bf42 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandler.java @@ -45,7 +45,7 @@ import org.onap.so.constants.Status; import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.LogConstants; import org.onap.so.logger.MessageEnum; import org.onap.so.serviceinstancebeans.ModelType; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java index 877376cc79..bb2b89ca82 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java @@ -54,7 +54,7 @@ import org.onap.so.constants.Status; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.exceptions.ValidationException; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java index 43f957174c..59c0694ea2 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java @@ -55,7 +55,7 @@ import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestStatus; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.exceptions.ValidationException; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequest.java index 2f922220c9..e11635370c 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequest.java @@ -44,7 +44,7 @@ import org.onap.so.apihandlerinfra.tenantisolationbeans.Action; import org.onap.so.apihandlerinfra.tenantisolationbeans.Distribution; import org.onap.so.apihandlerinfra.tenantisolationbeans.Status; import org.onap.so.exceptions.ValidationException; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.serviceinstancebeans.RequestError; import org.onap.so.serviceinstancebeans.ServiceException; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java index b2596f9013..398e168800 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java @@ -34,7 +34,7 @@ import org.onap.so.apihandlerinfra.tenantisolation.process.CreateVnfOperationalE import org.onap.so.apihandlerinfra.tenantisolation.process.DeactivateVnfOperationalEnvironment; import org.onap.so.apihandlerinfra.tenantisolationbeans.Action; import org.onap.so.apihandlerinfra.tenantisolationbeans.OperationalEnvironment; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.requestsdb.RequestsDBHelper; import org.slf4j.Logger; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/DmaapOperationalEnvClient.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/DmaapOperationalEnvClient.java index e9ce0bf99a..2df0a1ff21 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/DmaapOperationalEnvClient.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/DmaapOperationalEnvClient.java @@ -27,7 +27,7 @@ import org.onap.so.apihandler.common.ErrorNumbers; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java index 65d3109445..f0943393ed 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java @@ -35,7 +35,7 @@ import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; import org.onap.so.client.HttpClient; import org.onap.so.client.HttpClientFactory; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.utils.CryptoUtils; import org.onap.logging.filter.base.ONAPComponents; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java index 0005d26016..9b24a14f68 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java @@ -42,7 +42,7 @@ import org.onap.so.client.aai.entities.Relationships; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.db.request.beans.OperationalEnvDistributionStatus; import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.requestsdb.RequestsDBHelper; import org.slf4j.Logger; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java index 624a7f6945..77579817ff 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java @@ -43,7 +43,7 @@ import org.onap.so.apihandlerinfra.tenantisolationbeans.DistributionStatus; import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.db.request.beans.OperationalEnvDistributionStatus; import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.requestsdb.RequestsDBHelper; import org.slf4j.Logger; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java index 3812aa9edf..e78823593e 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java @@ -31,7 +31,7 @@ import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest; import org.onap.so.apihandlerinfra.tenantisolation.dmaap.DmaapOperationalEnvClient; import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientHelper; import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientObjectBuilder; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.requestsdb.RequestsDBHelper; import org.slf4j.Logger; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java index 5eb4a67fa6..d6969a9851 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java @@ -45,7 +45,7 @@ import org.onap.so.client.grm.beans.ServiceEndPoint; import org.onap.so.client.grm.beans.ServiceEndPointList; import org.onap.so.client.grm.beans.ServiceEndPointRequest; import org.onap.so.client.grm.beans.Version; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.requestsdb.RequestsDBHelper; import org.slf4j.Logger; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java index e8ea153a6a..59f7621b90 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java @@ -33,7 +33,7 @@ import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest; import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientHelper; import org.onap.so.client.aai.entities.AAIResultWrapper; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.requestsdb.RequestsDBHelper; import org.slf4j.Logger; diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionTest.java index bc867503f2..3d80ec230e 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionTest.java @@ -27,7 +27,7 @@ import org.junit.rules.ExpectedException; import org.onap.so.apihandler.common.ErrorNumbers; import org.onap.so.apihandlerinfra.exceptions.*; import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import java.io.IOException; import java.util.LinkedList; diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java index 46fd2f9025..9b892af869 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java @@ -32,6 +32,7 @@ import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import java.io.File; import java.io.IOException; import java.nio.file.Files; @@ -155,6 +156,7 @@ public class OrchestrationRequestsTest extends BaseTest { assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); assertThat(response.getBody(), sameBeanAs(testResponse).ignoring("request.startTime") .ignoring("request.finishTime").ignoring("request.requestStatus.timeStamp")); + assertNull(response.getBody().getRequest().getInstanceReferences().getRequestorId()); assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0)); assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0)); assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0)); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java index 22c82bf75c..4631b53bc0 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,9 +25,9 @@ import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertFalse; import static org.mockito.Mockito.doReturn; import javax.ws.rs.core.Response; import org.apache.commons.lang.StringUtils; @@ -92,6 +92,7 @@ public class OrchestrationRequestsUnitTest { iar.setFlowStatus(FLOW_STATUS); iar.setRollbackStatusMessage(ROLLBACK_STATUS_MESSAGE); iar.setRetryStatusMessage(RETRY_STATUS_MESSAGE); + iar.setResourceStatusMessage("The vf module already exist"); } @Test @@ -101,8 +102,10 @@ public class OrchestrationRequestsUnitTest { instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID); RequestStatus requestStatus = new RequestStatus(); requestStatus.setRequestState(iar.getRequestStatus()); - requestStatus.setStatusMessage(String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s", - FLOW_STATUS + TASK_INFORMATION, RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE)); + requestStatus.setStatusMessage( + String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s RESOURCE STATUS: %s", + FLOW_STATUS + TASK_INFORMATION, RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE, + "The vf module already exist")); Request expected = new Request(); expected.setRequestId(REQUEST_ID); @@ -114,7 +117,7 @@ public class OrchestrationRequestsUnitTest { iar.setOriginalRequestId(ORIGINAL_REQUEST_ID); Request result = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, - OrchestrationRequestFormat.DETAIL.toString()); + OrchestrationRequestFormat.DETAIL.toString(), "v7"); assertThat(result, sameBeanAs(expected)); } @@ -125,8 +128,11 @@ public class OrchestrationRequestsUnitTest { instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID); RequestStatus requestStatus = new RequestStatus(); requestStatus.setRequestState(iar.getRequestStatus()); - requestStatus.setStatusMessage(String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s", - FLOW_STATUS + TASK_INFORMATION, RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE)); + requestStatus.setStatusMessage( + String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s RESOURCE STATUS: %s", + FLOW_STATUS + TASK_INFORMATION, RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE, + "The vf module already exist")); + Request expected = new Request(); expected.setRequestId(REQUEST_ID); expected.setInstanceReferences(instanceReferences); @@ -134,7 +140,7 @@ public class OrchestrationRequestsUnitTest { expected.setRequestScope(SERVICE); Request result = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, - OrchestrationRequestFormat.DETAIL.toString()); + OrchestrationRequestFormat.DETAIL.toString(), "v7"); assertThat(result, sameBeanAs(expected)); } @@ -145,8 +151,10 @@ public class OrchestrationRequestsUnitTest { instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID); RequestStatus requestStatus = new RequestStatus(); requestStatus.setRequestState(iar.getRequestStatus()); - requestStatus.setStatusMessage(String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s", - FLOW_STATUS + TASK_INFORMATION, RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE)); + requestStatus.setStatusMessage( + String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s RESOURCE STATUS: %s", + FLOW_STATUS + TASK_INFORMATION, RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE, + "The vf module already exist")); Request expected = new Request(); expected.setRequestId(REQUEST_ID); @@ -157,7 +165,7 @@ public class OrchestrationRequestsUnitTest { includeCloudRequest = false; Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, - OrchestrationRequestFormat.DETAIL.toString()); + OrchestrationRequestFormat.DETAIL.toString(), "v7"); assertThat(actual, sameBeanAs(expected)); } @@ -183,7 +191,34 @@ public class OrchestrationRequestsUnitTest { includeCloudRequest = false; Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, - OrchestrationRequestFormat.STATUSDETAIL.toString()); + OrchestrationRequestFormat.STATUSDETAIL.toString(), "v7"); + assertThat(actual, sameBeanAs(expected)); + } + + @Test + public void mapRequestStatusAndExtSysErrSrcToRequestStatusDetailV8Test() throws ApiException { + doReturn(null).when(camundaRequestHandler).getTaskName(REQUEST_ID); + InstanceReferences instanceReferences = new InstanceReferences(); + instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID); + RequestStatus requestStatus = new RequestStatus(); + requestStatus.setExtSystemErrorSource(EXT_SYSTEM_ERROR_SOURCE); + requestStatus.setRollbackExtSystemErrorSource(ROLLBACK_EXT_SYSTEM_ERROR_SOURCE); + requestStatus.setRequestState(iar.getRequestStatus()); + requestStatus.setFlowStatus(FLOW_STATUS); + requestStatus.setRollbackStatusMessage(ROLLBACK_STATUS_MESSAGE); + requestStatus.setRetryStatusMessage(RETRY_STATUS_MESSAGE); + requestStatus.setResourceStatusMessage("The vf module already exist"); + + Request expected = new Request(); + expected.setRequestId(REQUEST_ID); + expected.setInstanceReferences(instanceReferences); + expected.setRequestStatus(requestStatus); + expected.setRequestScope(SERVICE); + + includeCloudRequest = false; + + Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, + OrchestrationRequestFormat.STATUSDETAIL.toString(), "v8"); assertThat(actual, sameBeanAs(expected)); } @@ -194,7 +229,7 @@ public class OrchestrationRequestsUnitTest { RequestStatus requestStatus = new RequestStatus(); requestStatus.setRequestState(iar.getRequestStatus()); requestStatus.setStatusMessage( - "FLOW STATUS: FlowStatus RETRY STATUS: RetryStatusMessage ROLLBACK STATUS: RollbackStatusMessage"); + "FLOW STATUS: FlowStatus RETRY STATUS: RetryStatusMessage ROLLBACK STATUS: RollbackStatusMessage RESOURCE STATUS: The vf module already exist"); Request expected = new Request(); expected.setRequestId(REQUEST_ID); @@ -205,7 +240,7 @@ public class OrchestrationRequestsUnitTest { includeCloudRequest = false; Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, - OrchestrationRequestFormat.SIMPLENOTASKINFO.toString()); + OrchestrationRequestFormat.SIMPLENOTASKINFO.toString(), "v7"); assertThat(expected, sameBeanAs(actual)); } @@ -217,7 +252,7 @@ public class OrchestrationRequestsUnitTest { RequestStatus requestStatus = new RequestStatus(); requestStatus.setRequestState(iar.getRequestStatus()); requestStatus.setStatusMessage( - "FLOW STATUS: FlowStatus TASK INFORMATION: TaskName RETRY STATUS: RetryStatusMessage ROLLBACK STATUS: RollbackStatusMessage"); + "FLOW STATUS: FlowStatus TASK INFORMATION: TaskName RETRY STATUS: RetryStatusMessage ROLLBACK STATUS: RollbackStatusMessage RESOURCE STATUS: The vf module already exist"); Request expected = new Request(); expected.setRequestId(REQUEST_ID); @@ -227,7 +262,7 @@ public class OrchestrationRequestsUnitTest { includeCloudRequest = false; - Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, null); + Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, null, "v7"); assertThat(expected, sameBeanAs(actual)); } @@ -238,8 +273,10 @@ public class OrchestrationRequestsUnitTest { instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID); RequestStatus requestStatus = new RequestStatus(); requestStatus.setRequestState(iar.getRequestStatus()); - requestStatus.setStatusMessage(String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s", - FLOW_STATUS + TASK_INFORMATION, RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE)); + requestStatus.setStatusMessage( + String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s RESOURCE STATUS: %s", + FLOW_STATUS + TASK_INFORMATION, RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE, + "The vf module already exist")); Request expected = new Request(); expected.setRequestId(REQUEST_ID); @@ -250,7 +287,7 @@ public class OrchestrationRequestsUnitTest { includeCloudRequest = false; Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, - OrchestrationRequestFormat.DETAIL.toString()); + OrchestrationRequestFormat.DETAIL.toString(), "v7"); assertThat(actual, sameBeanAs(expected)); } @@ -272,9 +309,10 @@ public class OrchestrationRequestsUnitTest { includeCloudRequest = false; iar.setFlowStatus(null); + iar.setResourceStatusMessage(null); Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, - OrchestrationRequestFormat.DETAIL.toString()); + OrchestrationRequestFormat.DETAIL.toString(), "v7"); assertThat(actual, sameBeanAs(expected)); } @@ -288,7 +326,7 @@ public class OrchestrationRequestsUnitTest { iar.setStatusMessage("Error retrieving cloud region from AAI"); Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, - OrchestrationRequestFormat.DETAIL.toString()); + OrchestrationRequestFormat.DETAIL.toString(), "v7"); assertTrue(actual.getRequestStatus().getStatusMessage() .contains("Error Source: " + ROLLBACK_EXT_SYSTEM_ERROR_SOURCE)); @@ -300,8 +338,10 @@ public class OrchestrationRequestsUnitTest { instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID); RequestStatus requestStatus = new RequestStatus(); requestStatus.setRequestState(iar.getRequestStatus()); - requestStatus.setStatusMessage(String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s", - "Successfully completed all Building Blocks", RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE)); + requestStatus.setStatusMessage( + String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s RESOURCE STATUS: %s", + "Successfully completed all Building Blocks", RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE, + "The vf module already exist")); Request expected = new Request(); expected.setRequestId(REQUEST_ID); @@ -313,7 +353,7 @@ public class OrchestrationRequestsUnitTest { iar.setFlowStatus("Successfully completed all Building Blocks"); Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, - OrchestrationRequestFormat.DETAIL.toString()); + OrchestrationRequestFormat.DETAIL.toString(), "v7"); assertThat(actual, sameBeanAs(expected)); } @@ -324,8 +364,10 @@ public class OrchestrationRequestsUnitTest { instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID); RequestStatus requestStatus = new RequestStatus(); requestStatus.setRequestState(iar.getRequestStatus()); - requestStatus.setStatusMessage(String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s", - "All Rollback flows have completed successfully", RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE)); + requestStatus.setStatusMessage( + String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s RESOURCE STATUS: %s", + "All Rollback flows have completed successfully", RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE, + "The vf module already exist")); Request expected = new Request(); expected.setRequestId(REQUEST_ID); @@ -337,7 +379,7 @@ public class OrchestrationRequestsUnitTest { iar.setFlowStatus("All Rollback flows have completed successfully"); Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, - OrchestrationRequestFormat.DETAIL.toString()); + OrchestrationRequestFormat.DETAIL.toString(), "v7"); assertThat(actual, sameBeanAs(expected)); } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java index 8d8f4969d7..0f096ee374 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java @@ -46,7 +46,7 @@ import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestInfo; import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestParameters; import org.onap.so.client.aai.AAIVersion; import org.onap.so.db.request.beans.InfraActiveRequests; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.springframework.beans.factory.annotation.Autowired; import com.fasterxml.jackson.core.JsonProcessingException; diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getOrchestrationRequest.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getOrchestrationRequest.json index 8953dfdfe0..e50aed7a33 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getOrchestrationRequest.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getOrchestrationRequest.json @@ -37,7 +37,7 @@ "networkId": null, "networkName": null, "networkType": null, - "requestorId": null, + "requestorId": "xxxxxx", "configurationId": null, "configurationName": null, "operationalEnvId": null, diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql index 85a17dd369..19855bc85e 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql @@ -1299,6 +1299,7 @@ CREATE TABLE `infra_active_requests` ( `ROLLBACK_EXT_SYSTEM_ERROR_SOURCE` varchar(80) DEFAULT NULL, `TENANT_NAME` varchar(200) DEFAULT NULL, `PRODUCT_FAMILY_NAME` varchar(200) DEFAULT NULL, + `RESOURCE_STATUS_MESSAGE` longtext, PRIMARY KEY (`REQUEST_ID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; @@ -1342,6 +1343,7 @@ CREATE TABLE `archived_infra_requests` ( `OPERATIONAL_ENV_ID` varchar(45) DEFAULT NULL, `OPERATIONAL_ENV_NAME` varchar(200) DEFAULT NULL, `REQUEST_URL` varchar(500) DEFAULT NULL, + `RESOURCE_STATUS_MESSAGE` longtext, PRIMARY KEY (`REQUEST_ID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; diff --git a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java index da8f30ab1e..b669b7d837 100644 --- a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java +++ b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java @@ -277,17 +277,22 @@ public class InfraActiveRequestsRepositoryImpl implements InfraActiveRequestsRep mapKey = "startTime"; } + final String operator = entry.getValue().get(0); final String propertyValue = entry.getValue().get(1); if ("startTime".equals(mapKey)) { final SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy"); try { final Date thisDate = format.parse(propertyValue); final Timestamp minTime = new Timestamp(thisDate.getTime()); - final Timestamp maxTime = new Timestamp(thisDate.getTime() + TimeUnit.DAYS.toMillis(1)); + Timestamp maxTime = new Timestamp(thisDate.getTime() + TimeUnit.DAYS.toMillis(1)); - if ("DOES_NOT_EQUAL".equalsIgnoreCase(entry.getValue().get(0))) { + if ("DOES_NOT_EQUAL".equalsIgnoreCase(operator)) { predicates.add(cb.or(cb.lessThan(tableRoot.get(mapKey), minTime), cb.greaterThanOrEqualTo(tableRoot.get(mapKey), maxTime))); + } else if ("BETWEEN_DATES".equalsIgnoreCase(operator)) { + Date endDate = format.parse(entry.getValue().get(2)); + maxTime = new Timestamp(endDate.getTime()); + predicates.add(cb.between(tableRoot.get(mapKey), minTime, maxTime)); } else { predicates.add(cb.between(tableRoot.get(mapKey), minTime, maxTime)); } @@ -295,7 +300,7 @@ public class InfraActiveRequestsRepositoryImpl implements InfraActiveRequestsRep logger.debug("Exception in getOrchestrationFiltersFromInfraActive(): {}", e.getMessage(), e); return null; } - } else if ("DOES_NOT_EQUAL".equalsIgnoreCase(entry.getValue().get(0))) { + } else if ("DOES_NOT_EQUAL".equalsIgnoreCase(operator)) { predicates.add(cb.notEqual(tableRoot.get(mapKey), propertyValue)); } else { predicates.add(cb.equal(tableRoot.get(mapKey), propertyValue)); diff --git a/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImplTest.java b/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImplTest.java index 3df30c0f49..070457d9f1 100644 --- a/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImplTest.java +++ b/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImplTest.java @@ -19,26 +19,6 @@ */ package org.onap.so.db.request.data.repository; -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.CoreMatchers.not; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.onap.so.db.request.data.repository.InfraActiveRequestsRepositoryImpl.REQUEST_ID; -import static org.onap.so.db.request.data.repository.InfraActiveRequestsRepositoryImpl.SERVICE_INSTANCE_ID; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.Predicate; -import javax.persistence.criteria.Root; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.TestApplication; @@ -47,6 +27,22 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.onap.so.db.request.data.repository.InfraActiveRequestsRepositoryImpl.REQUEST_ID; +import static org.onap.so.db.request.data.repository.InfraActiveRequestsRepositoryImpl.SERVICE_INSTANCE_ID; @RunWith(SpringRunner.class) @SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @@ -171,4 +167,13 @@ public class InfraActiveRequestsRepositoryImplTest { actualRequests.stream().map(item -> item.getServiceInstanceName()).collect(Collectors.joining(","))); } + @Test + public void test_getOrchestrationFiltersFromInfraActive_between_dates() { + Map<String, List<String>> orchestrationMap = new HashMap<>(); + orchestrationMap.put("startTime", Arrays.asList("BETWEEN_DATES", "12-01-2018", "12-31-2018")); + List<InfraActiveRequests> result = objUnderTest.getOrchestrationFiltersFromInfraActive(orchestrationMap); + + assertEquals(1, result.size()); + } + } diff --git a/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql b/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql index c6d22f5402..4c376c7af8 100644 --- a/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql +++ b/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql @@ -102,7 +102,8 @@ CREATE TABLE IF NOT EXISTS PUBLIC.INFRA_ACTIVE_REQUESTS( EXT_SYSTEM_ERROR_SOURCE VARCHAR SELECTIVITY 1, ROLLBACK_EXT_SYSTEM_ERROR_SOURCE VARCHAR SELECTIVITY 1, TENANT_NAME VARCHAR SELECTIVITY 1, - PRODUCT_FAMILY_NAME VARCHAR SELECTIVITY 1 + PRODUCT_FAMILY_NAME VARCHAR SELECTIVITY 1, + RESOURCE_STATUS_MESSAGE VARCHAR SELECTIVITY 36 ); @@ -118,6 +119,7 @@ INSERT INTO PUBLIC.INFRA_ACTIVE_REQUESTS(REQUEST_ID, REQUEST_STATUS, STATUS_MESS ('0017f68c-eb2d-45bb-b7c7-ec31b37dc349', 'UNLOCKED', null, '20', '2017-09-26 16:09:29', null, 'VID', null, null, null, null, null, null, null, '{"modelInfo":{"modelCustomizationName":null,"modelInvariantId":"1587cf0e-f12f-478d-8530-5c55ac578c39","modelType":"configuration","modelNameVersionId":null,"modelName":null,"modelVersion":null,"modelCustomizationUuid":null,"modelVersionId":"36a3a8ea-49a6-4ac8-b06c-89a545444455","modelCustomizationId":"68dc9a92-214c-11e7-93ae-92361f002671","modelUuid":null,"modelInvariantUuid":null,"modelInstanceName":null},"requestInfo":{"billingAccountNumber":null,"callbackUrl":null,"correlator":null,"orderNumber":null,"productFamilyId":null,"orderVersion":null,"source":"VID","instanceName":null,"suppressRollback":false,"requestorId":"xxxxxx"},"relatedInstanceList":[{"relatedInstance":{"instanceName":null,"instanceId":"9e15a443-af65-4f05-9000-47ae495e937d","modelInfo":{"modelCustomizationName":null,"modelInvariantId":"de19ae10-9a25-11e7-abc4-cec278b6b50a","modelType":"service","modelNameVersionId":null,"modelName":"MSOTADevInfra_Configuration_Service","modelVersion":"1.0","modelCustomizationUuid":null,"modelVersionId":"ee938612-9a25-11e7-abc4-cec278b6b50a","modelCustomizationId":null,"modelUuid":null,"modelInvariantUuid":null,"modelInstanceName":null},"instanceDirection":null}}],"subscriberInfo":null,"cloudConfiguration":{"aicNodeClli":null,"tenantId":null,"lcpCloudRegionId":"mtn6"},"requestParameters":{"subscriptionServiceType":null,"userParams":[],"aLaCarte":false,"autoBuildVfModules":false,"cascadeDelete":false,"usePreload":true,"alaCarte":false},"project":null,"owningEntity":null,"platform":null,"lineOfBusiness":null}', null, 'APIH', '2017-09-26 16:09:29', null, null, null, null, null, 'mtn6', null, null, null, null, null, 'configuration', 'activateInstance', '9e15a443-af65-4f05-9000-47ae495e937d', null, 'xxxxxx', '26ef7f15-57bb-48df-8170-e59edc26234c', null, null, null, 'http://localhost:8080/onap/so/infra/serviceInstantiation/v7/serviceInstances'); INSERT INTO PUBLIC.INFRA_ACTIVE_REQUESTS(REQUEST_ID, REQUEST_STATUS, START_TIME, END_TIME, SERVICE_INSTANCE_ID, SERVICE_INSTANCE_NAME ) VALUES +('abc506af-7d09-41e2-9aa8-42b326414510', 'FAILED', '2018-12-24 13:37:00', null, '842be4e5-419d-4b51-a077-895dd16d6653', 'ShouldReturnInDatesQuery'), ('a5294d37-21db-4e3a-ae04-57412adcb4ac', 'COMPLETE', '2019-01-01 12:45:00', '2019-01-01 12:50:00', 'f7712652-b516-4925-a243-64550d26fd84', 'ShouldReturnInSearchQuery_1'), ('9383dc81-7a6c-4673-8082-650d50a82a1a', 'IN_PROGRESS', '2019-01-01 12:55:00', null, 'f7712652-b516-4925-a243-64550d26fd84', 'ShouldReturnInSearchQuery_2'), ('a1abeab2-f8ef-43ab-b76c-9c3c2cb9980f', 'FAILED', '2019-01-01 13:00:00', '2019-01-01 14:00:00', 'f7712652-b516-4925-a243-64550d26fd84', 'ShouldReturnInSearchQuery_3'), @@ -174,7 +176,8 @@ CREATE CACHED TABLE PUBLIC.ARCHIVED_INFRA_REQUESTS( INSTANCE_GROUP_NAME VARCHAR SELECTIVITY 1, REQUEST_URL VARCHAR SELECTIVITY 1, TENANT_NAME VARCHAR SELECTIVITY 1, - PRODUCT_FAMILY_NAME VARCHAR SELECTIVITY 1 + PRODUCT_FAMILY_NAME VARCHAR SELECTIVITY 1, + RESOURCE_STATUS_MESSAGE VARCHAR SELECTIVITY 36 ); CREATE TABLE IF NOT EXISTS cloud_api_requests( diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java index 66768ea349..a6d6af8a07 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -55,6 +55,8 @@ public abstract class InfraRequests implements java.io.Serializable { private String requestId; @Column(name = "REQUEST_STATUS", length = 20) private String requestStatus; + @Column(name = "RESOURCE_STATUS_MESSAGE", length = 2000) + private String resourceStatusMessage; @Column(name = "STATUS_MESSAGE", length = 2000) private String statusMessage; @Column(name = "ROLLBACK_STATUS_MESSAGE", length = 2000) @@ -179,6 +181,14 @@ public abstract class InfraRequests implements java.io.Serializable { this.requestStatus = requestStatus; } + public String getResourceStatusMessage() { + return resourceStatusMessage; + } + + public void setResourceStatusMessage(String resourceStatusMessage) { + this.resourceStatusMessage = resourceStatusMessage; + } + public String getStatusMessage() { return this.statusMessage; } @@ -608,11 +618,12 @@ public abstract class InfraRequests implements java.io.Serializable { @Override public String toString() { return new ToStringBuilder(this).append("requestId", getRequestId()).append("requestStatus", getRequestStatus()) - .append("statusMessage", getStatusMessage()).append("rollbackStatusMessage", getRollbackStatusMessage()) - .append("flowStatus", getFlowStatus()).append("retryStatusMessage", getRetryStatusMessage()) - .append("progress", getProgress()).append("startTime", getStartTime()).append("endTime", getEndTime()) - .append("source", getSource()).append("vnfId", getVnfId()).append("vnfName", getVnfName()) - .append("pnfName", getPnfName()).append("vnfType", getVnfType()).append("serviceType", getServiceType()) + .append("resourceStatusMessage", getResourceStatusMessage()).append("statusMessage", getStatusMessage()) + .append("rollbackStatusMessage", getRollbackStatusMessage()).append("flowStatus", getFlowStatus()) + .append("retryStatusMessage", getRetryStatusMessage()).append("progress", getProgress()) + .append("startTime", getStartTime()).append("endTime", getEndTime()).append("source", getSource()) + .append("vnfId", getVnfId()).append("vnfName", getVnfName()).append("pnfName", getPnfName()) + .append("vnfType", getVnfType()).append("serviceType", getServiceType()) .append("tenantId", getTenantId()).append("vnfParams", getVnfParams()) .append("vnfOutputs", getVnfOutputs()).append("requestBody", getRequestBody()) .append("responseBody", getResponseBody()).append("lastModifiedBy", getLastModifiedBy()) diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java index 7b642ab831..6aa00caeed 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java @@ -360,6 +360,7 @@ public class RequestsDbClient { restTemplate.postForLocation(uri, entity); } + // TODO really this should be called save as its doing a put public void updateInfraActiveRequests(InfraActiveRequests request) { HttpHeaders headers = getHttpHeaders(); URI uri = getUri(infraActiveRequestURI + request.getRequestId()); @@ -371,8 +372,7 @@ public class RequestsDbClient { HttpHeaders headers = getHttpHeaders(); URI uri = getUri(infraActiveRequestURI + request.getRequestId()); HttpEntity<InfraActiveRequests> entity = new HttpEntity<>(request, headers); - restTemplate.exchange(uri, HttpMethod.PATCH, new HttpEntity<InfraActiveRequests>(request, headers), - String.class); + restTemplate.exchange(uri, HttpMethod.PATCH, entity, String.class); } public InfraActiveRequests getInfraActiveRequests(String requestId, String basicAuth, String host) { diff --git a/packages/docker/pom.xml b/packages/docker/pom.xml index 8d95d063da..b231dedf91 100644 --- a/packages/docker/pom.xml +++ b/packages/docker/pom.xml @@ -77,16 +77,14 @@ <name>${docker.image.prefix}/base-image:1.0</name> <build> <cleanup>try</cleanup> - <dockerFileDir>docker-files</dockerFileDir> - <dockerFile>Dockerfile.so-base-image</dockerFile> + <dockerFile>docker-files/Dockerfile.so-base-image</dockerFile> </build> </image> <image> <name>${docker.image.prefix}/vnfm-adapter</name> <build> <cleanup>try</cleanup> - <dockerFileDir>docker-files</dockerFileDir> - <dockerFile>Dockerfile.so-app</dockerFile> + <dockerFile>docker-files/Dockerfile.so-app</dockerFile> <tags> <tag>${project.version}</tag> <tag>${project.version}-${maven.build.timestamp}</tag> @@ -110,8 +108,7 @@ <name>${docker.image.prefix}/ve-vnfm-adapter</name> <build> <cleanup>try</cleanup> - <dockerFileDir>docker-files</dockerFileDir> - <dockerFile>Dockerfile.so-app</dockerFile> + <dockerFile>docker-files/Dockerfile.so-app</dockerFile> <tags> <tag>${project.version}</tag> <tag>${project.version}-${maven.build.timestamp}</tag> @@ -135,8 +132,7 @@ <name>${docker.image.prefix}/catalog-db-adapter</name> <build> <cleanup>try</cleanup> - <dockerFileDir>docker-files</dockerFileDir> - <dockerFile>Dockerfile.so-app</dockerFile> + <dockerFile>docker-files/Dockerfile.so-app</dockerFile> <tags> <tag>${project.version}</tag> <tag>${project.version}-${maven.build.timestamp}</tag> @@ -160,8 +156,7 @@ <name>${docker.image.prefix}/request-db-adapter</name> <build> <cleanup>try</cleanup> - <dockerFileDir>docker-files</dockerFileDir> - <dockerFile>Dockerfile.so-app</dockerFile> + <dockerFile>docker-files/Dockerfile.so-app</dockerFile> <tags> <tag>${project.version}</tag> <tag>${project.version}-${maven.build.timestamp}</tag> @@ -185,8 +180,7 @@ <name>${docker.image.prefix}/sdnc-adapter</name> <build> <cleanup>try</cleanup> - <dockerFileDir>docker-files</dockerFileDir> - <dockerFile>Dockerfile.so-app</dockerFile> + <dockerFile>docker-files/Dockerfile.so-app</dockerFile> <tags> <tag>${project.version}</tag> <tag>${project.version}-${maven.build.timestamp}</tag> @@ -210,8 +204,7 @@ <name>${docker.image.prefix}/openstack-adapter</name> <build> <cleanup>try</cleanup> - <dockerFileDir>docker-files</dockerFileDir> - <dockerFile>Dockerfile.so-app</dockerFile> + <dockerFile>docker-files/Dockerfile.so-app</dockerFile> <tags> <tag>${project.version}</tag> <tag>${project.version}-${maven.build.timestamp}</tag> @@ -235,8 +228,7 @@ <name>${docker.image.prefix}/vfc-adapter</name> <build> <cleanup>try</cleanup> - <dockerFileDir>docker-files</dockerFileDir> - <dockerFile>Dockerfile.so-app</dockerFile> + <dockerFile>docker-files/Dockerfile.so-app</dockerFile> <tags> <tag>${project.version}</tag> <tag>${project.version}-${maven.build.timestamp}</tag> @@ -260,8 +252,7 @@ <name>${docker.image.prefix}/nssmf-adapter</name> <build> <cleanup>try</cleanup> - <dockerFileDir>docker-files</dockerFileDir> - <dockerFile>Dockerfile.so-app</dockerFile> + <dockerFile>docker-files/Dockerfile.so-app</dockerFile> <tags> <tag>${project.version}</tag> <tag>${project.version}-${maven.build.timestamp}</tag> @@ -285,8 +276,7 @@ <name>${docker.image.prefix}/so-appc-orchestrator</name> <build> <cleanup>try</cleanup> - <dockerFileDir>docker-files</dockerFileDir> - <dockerFile>Dockerfile.so-app</dockerFile> + <dockerFile>docker-files/Dockerfile.so-app</dockerFile> <tags> <tag>${project.version}</tag> <tag>${project.version}-${maven.build.timestamp}</tag> @@ -310,8 +300,7 @@ <name>${docker.image.prefix}/sdc-controller</name> <build> <cleanup>try</cleanup> - <dockerFileDir>docker-files</dockerFileDir> - <dockerFile>Dockerfile.so-app</dockerFile> + <dockerFile>docker-files/Dockerfile.so-app</dockerFile> <tags> <tag>${project.version}</tag> <tag>${project.version}-${maven.build.timestamp}</tag> @@ -335,8 +324,7 @@ <name>${docker.image.prefix}/bpmn-infra</name> <build> <cleanup>try</cleanup> - <dockerFileDir>docker-files</dockerFileDir> - <dockerFile>Dockerfile.so-app</dockerFile> + <dockerFile>docker-files/Dockerfile.so-app</dockerFile> <tags> <tag>${project.version}</tag> <tag>${project.version}-${maven.build.timestamp}</tag> @@ -360,8 +348,7 @@ <name>${docker.image.prefix}/api-handler-infra</name> <build> <cleanup>try</cleanup> - <dockerFileDir>docker-files</dockerFileDir> - <dockerFile>Dockerfile.so-app</dockerFile> + <dockerFile>docker-files/Dockerfile.so-app</dockerFile> <tags> <tag>${project.version}</tag> <tag>${project.version}-${maven.build.timestamp}</tag> @@ -385,8 +372,7 @@ <name>${docker.image.prefix}/so-monitoring</name> <build> <cleanup>try</cleanup> - <dockerFileDir>docker-files</dockerFileDir> - <dockerFile>Dockerfile.so-app</dockerFile> + <dockerFile>docker-files/Dockerfile.so-app</dockerFile> <tags> <tag>${project.version}</tag> <tag>${project.version}-${maven.build.timestamp}</tag> @@ -410,8 +396,7 @@ <name>${docker.image.prefix}/so-simulator</name> <build> <cleanup>try</cleanup> - <dockerFileDir>docker-files</dockerFileDir> - <dockerFile>Dockerfile.so-app</dockerFile> + <dockerFile>docker-files/Dockerfile.so-app</dockerFile> <tags> <tag>${project.version}</tag> <tag>${project.version}-${maven.build.timestamp}</tag> diff --git a/packages/docker/src/main/docker/docker-files/Dockerfile.so-app b/packages/docker/src/main/docker/docker-files/Dockerfile.so-app index e8f02f12c6..dc86ff8290 100644 --- a/packages/docker/src/main/docker/docker-files/Dockerfile.so-app +++ b/packages/docker/src/main/docker/docker-files/Dockerfile.so-app @@ -7,23 +7,20 @@ ARG https_proxy ENV HTTPS_PROXY=$https_proxy ENV https_proxy=$HTTPS_PROXY -RUN mkdir /app && mkdir /app/config && mkdir /app/certificates && mkdir /app/logs && mkdir /app/ca-certificates +USER root +RUN mkdir -p /app/config +RUN mkdir -p /app/certificates +RUN mkdir -p /app/logs +RUN mkdir -p /app/ca-certificates COPY maven/app.jar /app COPY configs/logging/logback-spring.xml /app COPY scripts/start-app.sh /app COPY scripts/wait-for.sh /app COPY ca-certificates/onap-ca.crt /app/ca-certificates/onap-ca.crt +RUN chown -R so:so /app -RUN chown -R so:so /app && chmod 700 /app/*.sh - -## TODO for Casablanca: install this in the openstack-adapter container -## Install heatbridge -#RUN apt-get install -y python && apt-get install -y python-pip && echo 'PIP Installed, doing upgrade' && pip install --upgrade pip -#RUN mkdir /opt/mso/heatbridge -#COPY heatbridge/heatbridge-0.3.0.dev0-py2-none-any.whl /opt/mso/heatbridge -#RUN pip install /opt/mso/heatbridge/heatbridge-0.3.0.dev0-py2-none-any.whl - +USER so # Springboot configuration (required) VOLUME /app/config @@ -31,4 +28,4 @@ VOLUME /app/config VOLUME /app/ca-certificates WORKDIR /app -CMD ["/app/start-app.sh"] +ENTRYPOINT ["/app/start-app.sh"] diff --git a/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image b/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image index c0b298e778..031142f216 100644 --- a/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image +++ b/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image @@ -7,11 +7,8 @@ ENV HTTPS_PROXY=$https_proxy ENV http_proxy=$HTTP_PROXY ENV https_proxy=$HTTPS_PROXY -# Update the package list and upgrade installed packages -RUN apk update && apk upgrade - # Install commonly needed tools -RUN apk --no-cache add curl netcat-openbsd sudo nss +RUN apk --no-cache add curl netcat-openbsd nss # Create 'so' user RUN addgroup -g 1000 so && adduser -S -u 1000 -G so -s /bin/sh so diff --git a/packages/docker/src/main/docker/docker-files/scripts/.gitattributes b/packages/docker/src/main/docker/docker-files/scripts/.gitattributes new file mode 100644 index 0000000000..b905d1de69 --- /dev/null +++ b/packages/docker/src/main/docker/docker-files/scripts/.gitattributes @@ -0,0 +1,5 @@ +# Default behavior +* text=auto + +# Files to have unix style line endings on checkout +*.sh text eol=lf
\ No newline at end of file diff --git a/packages/docker/src/main/docker/docker-files/scripts/start-app.sh b/packages/docker/src/main/docker/docker-files/scripts/start-app.sh index 75d64fefa0..74d17fc9b7 100644..100755 --- a/packages/docker/src/main/docker/docker-files/scripts/start-app.sh +++ b/packages/docker/src/main/docker/docker-files/scripts/start-app.sh @@ -16,7 +16,7 @@ then update-ca-certificates --fresh fi - # Re-exec this script as the 'so' user. + # Re-exec this script as the 'onap' user. this=`readlink -f $0` exec su so -c "$this" fi @@ -46,7 +46,7 @@ fi if [ ${APP} = "bpmn-infra" ]; then ln -s ${LOG_PATH} BPMN -fi +fi if [ ${APP} = "so-monitoring" ]; then ln -s ${LOG_PATH} MONITORING @@ -670,17 +670,17 @@ <dependency> <groupId>org.onap.logging-analytics</groupId> <artifactId>logging-slf4j</artifactId> - <version>1.6.4</version> + <version>1.6.6-SNAPSHOT</version> </dependency> <dependency> <groupId>org.onap.logging-analytics</groupId> <artifactId>logging-filter-base</artifactId> - <version>1.6.4</version> + <version>1.6.6-SNAPSHOT</version> </dependency> <dependency> <groupId>org.onap.logging-analytics</groupId> <artifactId>logging-filter-spring</artifactId> - <version>1.6.4</version> + <version>1.6.6-SNAPSHOT</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> |