From da366370647e6b72df4d8433bb52ec22a443d0ca Mon Sep 17 00:00:00 2001 From: "Boslet, Cory" Date: Tue, 7 Jul 2020 11:46:43 -0400 Subject: move sdn clients to own package Began moving the sdn clients into one central isolated location Added test files, removed unused methods, fixed poms Fixed the client so that is doesnt have to import bpmn and can be built at top level Fixed bad merge that hapeened due to conflicts Added missing test files for sdno unit test Added maria db driver java client for spring test and jersey depend Issue-ID: SO-3034 Signed-off-by: Benjamin, Max (mb388a) Change-Id: I4c0a6288623194c517dbc8fa6120d577b400ee01 --- .../mapper/GCTopologyOperationRequestMapper.java | 107 +++++++++ .../sdnc/mapper/GeneralTopologyObjectMapper.java | 267 +++++++++++++++++++++ .../NetworkTopologyOperationRequestMapper.java | 114 +++++++++ .../mapper/ServiceTopologyOperationMapper.java | 89 +++++++ .../VfModuleTopologyOperationRequestMapper.java | 202 ++++++++++++++++ .../mapper/VnfTopologyOperationRequestMapper.java | 164 +++++++++++++ .../orchestration/SDNCConfigurationResources.java | 2 +- .../client/orchestration/SDNCNetworkResources.java | 2 +- .../SDNCServiceInstanceResources.java | 2 +- .../orchestration/SDNCVfModuleResources.java | 2 +- .../so/client/orchestration/SDNCVnfResources.java | 2 +- .../java/org/onap/so/client/sdnc/SDNCClient.java | 97 -------- .../org/onap/so/client/sdnc/SdnCommonTasks.java | 168 ------------- .../onap/so/client/sdnc/beans/SDNCProperties.java | 57 ----- .../org/onap/so/client/sdnc/beans/SDNCRequest.java | 97 -------- .../onap/so/client/sdnc/beans/SDNCSvcAction.java | 55 ----- .../so/client/sdnc/beans/SDNCSvcOperation.java | 44 ---- .../onap/so/client/sdnc/endpoint/SDNCTopology.java | 44 ---- .../mapper/GCTopologyOperationRequestMapper.java | 107 --------- .../sdnc/mapper/GeneralTopologyObjectMapper.java | 267 --------------------- .../NetworkTopologyOperationRequestMapper.java | 114 --------- .../mapper/ServiceTopologyOperationMapper.java | 89 ------- .../VfModuleTopologyOperationRequestMapper.java | 202 ---------------- .../mapper/VnfTopologyOperationRequestMapper.java | 164 ------------- .../onap/so/client/sdno/SDNOHealthCheckClient.java | 167 ------------- .../org/onap/so/client/sdno/SDNOValidator.java | 55 ----- .../org/onap/so/client/sdno/SDNOValidatorImpl.java | 128 ---------- .../onap/so/client/sdno/beans/AAIParamList.java | 83 ------- .../java/org/onap/so/client/sdno/beans/Body.java | 77 ------ .../java/org/onap/so/client/sdno/beans/Input.java | 90 ------- .../onap/so/client/sdno/beans/RequestHdCustom.java | 183 -------------- .../client/sdno/beans/RequestHealthDiagnostic.java | 197 --------------- .../org/onap/so/client/sdno/beans/ResultInfo.java | 112 --------- .../java/org/onap/so/client/sdno/beans/SDNO.java | 128 ---------- 34 files changed, 948 insertions(+), 2730 deletions(-) create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GCTopologyOperationRequestMapper.java create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GeneralTopologyObjectMapper.java create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/NetworkTopologyOperationRequestMapper.java create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/ServiceTopologyOperationMapper.java create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VnfTopologyOperationRequestMapper.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCProperties.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcAction.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcOperation.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/endpoint/SDNCTopology.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOHealthCheckClient.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOValidator.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/AAIParamList.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/Body.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/Input.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/RequestHdCustom.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/RequestHealthDiagnostic.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/ResultInfo.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/SDNO.java (limited to 'bpmn/so-bpmn-tasks/src/main/java') diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GCTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GCTopologyOperationRequestMapper.java new file mode 100644 index 0000000000..5b6043f303 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GCTopologyOperationRequestMapper.java @@ -0,0 +1,107 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.sdnc.mapper; + +import java.net.URI; +import java.util.UUID; +import org.onap.sdnc.northbound.client.model.GenericResourceApiConfigurationinformationConfigurationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiGcTopologyOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiGcrequestinputGcRequestInput; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.client.sdnc.beans.SDNCSvcAction; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component(value = "sdncGCTopologyOperationRequestMapper") +public class GCTopologyOperationRequestMapper { + + @Autowired + private GeneralTopologyObjectMapper generalTopologyObjectMapper; + + public GenericResourceApiGcTopologyOperationInformation assignOrActivateVnrReqMapper(SDNCSvcAction svcAction, + GenericResourceApiRequestActionEnumeration reqAction, ServiceInstance serviceInstance, + RequestContext requestContext, Customer customer, Configuration vnrConfiguration, GenericVnf voiceVnf, + String sdncReqId, URI callbackUri) { + + String msoRequestId = UUID.randomUUID().toString(); + if (requestContext != null && requestContext.getMsoRequestId() != null) { + msoRequestId = requestContext.getMsoRequestId(); + } + GenericResourceApiGcTopologyOperationInformation req = new GenericResourceApiGcTopologyOperationInformation(); + GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = + generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId, callbackUri.toString()); + GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper + .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, reqAction); + GenericResourceApiServiceinformationServiceInformation serviceInformation = + generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, false); + GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation = + generalTopologyObjectMapper.buildConfigurationInformation(vnrConfiguration, true); + GenericResourceApiGcrequestinputGcRequestInput gcRequestInput = + generalTopologyObjectMapper.buildGcRequestInformation(voiceVnf, null); + req.setRequestInformation(requestInformation); + req.setSdncRequestHeader(sdncRequestHeader); + req.setServiceInformation(serviceInformation); + req.setConfigurationInformation(configurationInformation); + req.setGcRequestInput(gcRequestInput); + + return req; + + } + + + public GenericResourceApiGcTopologyOperationInformation deactivateOrUnassignVnrReqMapper(SDNCSvcAction svcAction, + ServiceInstance serviceInstance, RequestContext requestContext, Configuration vnrConfiguration, + String sdncReqId, URI callbackUri) { + + String msoRequestId = null; + if (requestContext != null) { + msoRequestId = requestContext.getMsoRequestId(); + } + GenericResourceApiGcTopologyOperationInformation req = new GenericResourceApiGcTopologyOperationInformation(); + GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = + generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId, callbackUri.toString()); + GenericResourceApiRequestinformationRequestInformation requestInformation = + generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, + GenericResourceApiRequestActionEnumeration.DELETEGENERICCONFIGURATIONINSTANCE); + GenericResourceApiServiceinformationServiceInformation serviceInformation = + new GenericResourceApiServiceinformationServiceInformation(); + serviceInformation.setServiceInstanceId(serviceInstance.getServiceInstanceId()); + GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation = + new GenericResourceApiConfigurationinformationConfigurationInformation(); + configurationInformation.setConfigurationId(vnrConfiguration.getConfigurationId()); + configurationInformation.setConfigurationType(vnrConfiguration.getConfigurationType()); + req.setRequestInformation(requestInformation); + req.setSdncRequestHeader(sdncRequestHeader); + req.setServiceInformation(serviceInformation); + req.setConfigurationInformation(configurationInformation); + return req; + + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GeneralTopologyObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GeneralTopologyObjectMapper.java new file mode 100644 index 0000000000..48a384c48a --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GeneralTopologyObjectMapper.java @@ -0,0 +1,267 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.sdnc.mapper; + +import java.util.List; +import java.util.Map; +import java.util.Set; +import org.onap.sdnc.northbound.client.model.GenericResourceApiConfigurationinformationConfigurationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiGcrequestinputGcRequestInput; +import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkinformationNetworkInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiOnapmodelinformationOnapModelInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduleinformationVfModuleInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; +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.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +@Component +public class GeneralTopologyObjectMapper { + + private static final Logger logger = LoggerFactory.getLogger(GeneralTopologyObjectMapper.class); + private ObjectMapper mapper = new ObjectMapper(); + + /* + * Build GenericResourceApiRequestinformationRequestInformation + */ + public GenericResourceApiRequestinformationRequestInformation buildGenericResourceApiRequestinformationRequestInformation( + String msoReqId, GenericResourceApiRequestActionEnumeration requestAction) { + + GenericResourceApiRequestinformationRequestInformation requestInformation = + new GenericResourceApiRequestinformationRequestInformation(); + requestInformation.setRequestId(msoReqId); + requestInformation.setRequestAction(requestAction); + requestInformation.setSource("MSO"); + return requestInformation; + } + + /* + * Build GenericResourceApiServiceinformationServiceInformation + */ + public GenericResourceApiServiceinformationServiceInformation buildServiceInformation( + ServiceInstance serviceInstance, RequestContext requestContext, Customer customer, + boolean includeModelInformation) { + GenericResourceApiServiceinformationServiceInformation serviceInformation = + new GenericResourceApiServiceinformationServiceInformation(); + serviceInformation.serviceId(serviceInstance.getServiceInstanceId()); + if (requestContext != null) { + serviceInformation.setSubscriptionServiceType(requestContext.getProductFamilyId()); + } + if (includeModelInformation) { + GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = + new GenericResourceApiOnapmodelinformationOnapModelInformation(); + onapModelInformation + .setModelInvariantUuid(serviceInstance.getModelInfoServiceInstance().getModelInvariantUuid()); + onapModelInformation.setModelVersion(serviceInstance.getModelInfoServiceInstance().getModelVersion()); + onapModelInformation.setModelName(serviceInstance.getModelInfoServiceInstance().getModelName()); + onapModelInformation.setModelUuid(serviceInstance.getModelInfoServiceInstance().getModelUuid()); + serviceInformation.setOnapModelInformation(onapModelInformation); + } + serviceInformation.setServiceInstanceId(serviceInstance.getServiceInstanceId()); + + if (customer != null) { + serviceInformation.setGlobalCustomerId(customer.getGlobalCustomerId()); + if (customer.getServiceSubscription() != null) { + serviceInformation.setSubscriptionServiceType(customer.getServiceSubscription().getServiceType()); + } + + } + return serviceInformation; + } + + /* + * Build GenericResourceApiNetworkinformationNetworkInformation + */ + public GenericResourceApiNetworkinformationNetworkInformation buildNetworkInformation(L3Network network) { + GenericResourceApiNetworkinformationNetworkInformation networkInformation = + new GenericResourceApiNetworkinformationNetworkInformation(); + GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = + new GenericResourceApiOnapmodelinformationOnapModelInformation(); + if (network.getModelInfoNetwork() != null) { + onapModelInformation.setModelInvariantUuid(network.getModelInfoNetwork().getModelInvariantUUID()); + onapModelInformation.setModelName(network.getModelInfoNetwork().getModelName()); + onapModelInformation.setModelVersion(network.getModelInfoNetwork().getModelVersion()); + onapModelInformation.setModelUuid(network.getModelInfoNetwork().getModelUUID()); + onapModelInformation.setModelCustomizationUuid(network.getModelInfoNetwork().getModelCustomizationUUID()); + networkInformation.setOnapModelInformation(onapModelInformation); + } + + networkInformation.setFromPreload(null); + networkInformation.setNetworkId(network.getNetworkId()); + networkInformation.setNetworkType(network.getNetworkType()); + networkInformation.setNetworkTechnology(network.getNetworkTechnology()); + return networkInformation; + } + + /* + * Build GenericResourceApiVnfinformationVnfInformation + */ + public GenericResourceApiVnfinformationVnfInformation buildVnfInformation(GenericVnf vnf, + ServiceInstance serviceInstance, boolean includeModelInformation) { + GenericResourceApiVnfinformationVnfInformation vnfInformation = + new GenericResourceApiVnfinformationVnfInformation(); + if (includeModelInformation && vnf.getModelInfoGenericVnf() != null) { + GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = + new GenericResourceApiOnapmodelinformationOnapModelInformation(); + onapModelInformation.setModelInvariantUuid(vnf.getModelInfoGenericVnf().getModelInvariantUuid()); + onapModelInformation.setModelName(vnf.getModelInfoGenericVnf().getModelName()); + onapModelInformation.setModelVersion(vnf.getModelInfoGenericVnf().getModelVersion()); + onapModelInformation.setModelUuid(vnf.getModelInfoGenericVnf().getModelUuid()); + onapModelInformation.setModelCustomizationUuid(vnf.getModelInfoGenericVnf().getModelCustomizationUuid()); + vnfInformation.setOnapModelInformation(onapModelInformation); + } + vnfInformation.setVnfId(vnf.getVnfId()); + vnfInformation.setVnfType(vnf.getVnfType()); + vnfInformation.setVnfName(vnf.getVnfName()); + return vnfInformation; + } + + /* + * Build GenericResourceApiVfModuleinformationVfModuleInformation + */ + public GenericResourceApiVfmoduleinformationVfModuleInformation buildVfModuleInformation(VfModule vfModule, + GenericVnf vnf, ServiceInstance serviceInstance, RequestContext requestContext, + boolean includeModelInformation) throws MapperException { + GenericResourceApiVfmoduleinformationVfModuleInformation vfModuleInformation = + new GenericResourceApiVfmoduleinformationVfModuleInformation(); + if (includeModelInformation) { + if (vfModule.getModelInfoVfModule() == null) { + throw new MapperException("VF Module model info is null for " + vfModule.getVfModuleId()); + } else { + GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = + new GenericResourceApiOnapmodelinformationOnapModelInformation(); + onapModelInformation.setModelInvariantUuid(vfModule.getModelInfoVfModule().getModelInvariantUUID()); + onapModelInformation.setModelName(vfModule.getModelInfoVfModule().getModelName()); + onapModelInformation.setModelVersion(vfModule.getModelInfoVfModule().getModelVersion()); + onapModelInformation.setModelUuid(vfModule.getModelInfoVfModule().getModelUUID()); + onapModelInformation + .setModelCustomizationUuid(vfModule.getModelInfoVfModule().getModelCustomizationUUID()); + vfModuleInformation.setOnapModelInformation(onapModelInformation); + } + } + if (vfModule.getModelInfoVfModule() != null) { + vfModuleInformation.setVfModuleType(vfModule.getModelInfoVfModule().getModelName()); + } + vfModuleInformation.setVfModuleId(vfModule.getVfModuleId()); + if (requestContext != null && requestContext.getRequestParameters() != null) { + vfModuleInformation.setFromPreload(requestContext.getRequestParameters().getUsePreload()); + } else { + vfModuleInformation.setFromPreload(true); + } + + return vfModuleInformation; + } + + + public GenericResourceApiSdncrequestheaderSdncRequestHeader buildSdncRequestHeader(SDNCSvcAction svcAction, + String sdncReqId) { + return buildSdncRequestHeader(svcAction, sdncReqId, null); + } + + public GenericResourceApiSdncrequestheaderSdncRequestHeader buildSdncRequestHeader(SDNCSvcAction svcAction, + String sdncReqId, String callbackUrl) { + GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = + new GenericResourceApiSdncrequestheaderSdncRequestHeader(); + sdncRequestHeader.setSvcAction(svcAction.getSdncApiAction()); + sdncRequestHeader.setSvcRequestId(sdncReqId); + sdncRequestHeader.setSvcNotificationUrl(callbackUrl); + return sdncRequestHeader; + } + + /** + * Build ConfigurationInformation + * + * @param configuration + * @param includeModelInformation + * @return + */ + public GenericResourceApiConfigurationinformationConfigurationInformation buildConfigurationInformation( + Configuration configuration, boolean includeModelInformation) { + GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation = + new GenericResourceApiConfigurationinformationConfigurationInformation(); + configurationInformation.setConfigurationId(configuration.getConfigurationId()); + configurationInformation.setConfigurationName(configuration.getConfigurationName()); + configurationInformation.setConfigurationType(configuration.getConfigurationType()); + if (includeModelInformation) { + GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = + new GenericResourceApiOnapmodelinformationOnapModelInformation(); + onapModelInformation.setModelInvariantUuid(configuration.getModelInfoConfiguration().getModelInvariantId()); + onapModelInformation.setModelUuid(configuration.getModelInfoConfiguration().getModelVersionId()); + onapModelInformation + .setModelCustomizationUuid(configuration.getModelInfoConfiguration().getModelCustomizationId()); + configurationInformation.setOnapModelInformation(onapModelInformation); + } + return configurationInformation; + } + + + /** + * Build GcRequestInformation + * + * @param vnf + * @param genericResourceApiParam + * @return + */ + public GenericResourceApiGcrequestinputGcRequestInput buildGcRequestInformation(GenericVnf vnf, + GenericResourceApiParam genericResourceApiParam) { + GenericResourceApiGcrequestinputGcRequestInput gcRequestInput = + new GenericResourceApiGcrequestinputGcRequestInput(); + gcRequestInput.setVnfId(vnf.getVnfId()); + if (genericResourceApiParam != null) { + gcRequestInput.setInputParameters(genericResourceApiParam); + } + return gcRequestInput; + } + + + public String mapUserParamValue(Object value) { + if (value == null) { + return null; + } else { + if (value instanceof Map || value instanceof Set || value instanceof List) { + try { + return mapper.writeValueAsString(value); + } catch (JsonProcessingException e) { + logger.error("could not map value to string", e); + throw new IllegalArgumentException(e); + } + } else { + return value.toString(); + } + } + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/NetworkTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/NetworkTopologyOperationRequestMapper.java new file mode 100644 index 0000000000..593c15d6cc --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/NetworkTopologyOperationRequestMapper.java @@ -0,0 +1,114 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.sdnc.mapper; + +import java.util.Map; +import java.util.UUID; +import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkinformationNetworkInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkrequestinputNetworkRequestInput; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; +import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.client.sdnc.beans.SDNCSvcAction; +import org.onap.so.client.sdnc.beans.SDNCSvcOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * Mapper creating SDNC request + * + */ +@Component +public class NetworkTopologyOperationRequestMapper { + + @Autowired + private GeneralTopologyObjectMapper generalTopologyObjectMapper; + + public GenericResourceApiNetworkOperationInformation reqMapper(SDNCSvcOperation svcOperation, + SDNCSvcAction svcAction, GenericResourceApiRequestActionEnumeration reqAction, L3Network network, + ServiceInstance serviceInstance, Customer customer, RequestContext requestContext, + CloudRegion cloudRegion) { + GenericResourceApiNetworkOperationInformation req = new GenericResourceApiNetworkOperationInformation(); + String sdncReqId = UUID.randomUUID().toString(); + String msoRequestId = UUID.randomUUID().toString(); + if (requestContext != null && requestContext.getMsoRequestId() != null) { + msoRequestId = requestContext.getMsoRequestId(); + } + GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = + generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId); + GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper + .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, reqAction); + GenericResourceApiServiceinformationServiceInformation serviceInformation = + generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, true); + GenericResourceApiNetworkinformationNetworkInformation networkInformation = + generalTopologyObjectMapper.buildNetworkInformation(network); + GenericResourceApiNetworkrequestinputNetworkRequestInput networkRequestInput = + buildNetworkRequestInput(network, serviceInstance, cloudRegion); + + req.setRequestInformation(requestInformation); + req.setSdncRequestHeader(sdncRequestHeader); + req.setServiceInformation(serviceInformation); + req.setNetworkInformation(networkInformation); + + if (requestContext != null && requestContext.getUserParams() != null) { + for (Map.Entry entry : requestContext.getUserParams().entrySet()) { + GenericResourceApiParam networkInputParameters = new GenericResourceApiParam(); + GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); + paramItem.setName(entry.getKey()); + paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue())); + networkInputParameters.addParamItem(paramItem); + networkRequestInput.setNetworkInputParameters(networkInputParameters); + } + } + + req.setNetworkRequestInput(networkRequestInput); + return req; + } + + /* + * Private helper to build GenericResourceApiNetworkrequestinputNetworkRequestInput + */ + private GenericResourceApiNetworkrequestinputNetworkRequestInput buildNetworkRequestInput(L3Network network, + ServiceInstance serviceInstance, CloudRegion cloudRegion) { + GenericResourceApiNetworkrequestinputNetworkRequestInput networkRequestInput = + new GenericResourceApiNetworkrequestinputNetworkRequestInput(); + networkRequestInput.setTenant(cloudRegion.getTenantId()); + networkRequestInput.setCloudOwner(cloudRegion.getCloudOwner()); + networkRequestInput.setAicCloudRegion(cloudRegion.getLcpCloudRegionId()); + if (network.getNetworkName() != null && !network.getNetworkName().equals("")) { + networkRequestInput.setNetworkName(network.getNetworkName()); + } + if (serviceInstance.getCollection() != null && serviceInstance.getCollection().getInstanceGroup() != null) { + // set only for network created as part of the collection/instance since 1806 + networkRequestInput.setNetworkInstanceGroupId(serviceInstance.getCollection().getInstanceGroup().getId()); + } + return networkRequestInput; + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/ServiceTopologyOperationMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/ServiceTopologyOperationMapper.java new file mode 100644 index 0000000000..69606393c3 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/ServiceTopologyOperationMapper.java @@ -0,0 +1,89 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.sdnc.mapper; + +import java.util.Map; +import java.util.UUID; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServicerequestinputServiceRequestInput; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.client.sdnc.beans.SDNCSvcAction; +import org.onap.so.client.sdnc.beans.SDNCSvcOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class ServiceTopologyOperationMapper { + + @Autowired + public GeneralTopologyObjectMapper generalTopologyObjectMapper; + + public GenericResourceApiServiceOperationInformation reqMapper(SDNCSvcOperation svcOperation, + SDNCSvcAction svcAction, GenericResourceApiRequestActionEnumeration resourceAction, + ServiceInstance serviceInstance, Customer customer, RequestContext requestContext) { + + String sdncReqId = UUID.randomUUID().toString(); + String msoRequestId = UUID.randomUUID().toString(); + if (requestContext != null && requestContext.getMsoRequestId() != null) { + msoRequestId = requestContext.getMsoRequestId(); + } + GenericResourceApiServiceOperationInformation servOpInput = new GenericResourceApiServiceOperationInformation(); + GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = + generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId); + GenericResourceApiRequestinformationRequestInformation reqInfo = generalTopologyObjectMapper + .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, resourceAction); + GenericResourceApiServiceinformationServiceInformation servInfo = + generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, true); + GenericResourceApiServicerequestinputServiceRequestInput servReqInfo = + new GenericResourceApiServicerequestinputServiceRequestInput(); + + servReqInfo.setServiceInstanceName(serviceInstance.getServiceInstanceName()); + + servOpInput.setSdncRequestHeader(sdncRequestHeader); + servOpInput.setRequestInformation(reqInfo); + servOpInput.setServiceInformation(servInfo); + servOpInput.setServiceRequestInput(servReqInfo); + + if (requestContext != null && requestContext.getUserParams() != null) { + for (Map.Entry entry : requestContext.getUserParams().entrySet()) { + GenericResourceApiServicerequestinputServiceRequestInput serviceRequestInput = + new GenericResourceApiServicerequestinputServiceRequestInput(); + serviceRequestInput.setServiceInstanceName(serviceInstance.getServiceInstanceName()); + GenericResourceApiParam serviceInputParameters = new GenericResourceApiParam(); + GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); + paramItem.setName(entry.getKey()); + paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue())); + serviceInputParameters.addParamItem(paramItem); + serviceRequestInput.serviceInputParameters(serviceInputParameters); + servOpInput.setServiceRequestInput(serviceRequestInput); + } + } + return servOpInput; + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java new file mode 100644 index 0000000000..901187e231 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java @@ -0,0 +1,202 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.sdnc.mapper; + +import java.net.URI; +import java.util.Map; +import java.util.UUID; +import org.onap.so.logger.LoggingAnchor; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiSvcActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleResponseInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduleinformationVfModuleInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmodulerequestinputVfModuleRequestInput; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; +import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; +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.logging.filter.base.ErrorCode; +import org.onap.so.logger.MessageEnum; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import com.fasterxml.jackson.databind.ObjectMapper; + +@Component +public class VfModuleTopologyOperationRequestMapper { + private static final Logger logger = LoggerFactory.getLogger(VfModuleTopologyOperationRequestMapper.class); + + @Autowired + private GeneralTopologyObjectMapper generalTopologyObjectMapper; + + public GenericResourceApiVfModuleOperationInformation reqMapper(SDNCSvcOperation svcOperation, + SDNCSvcAction svcAction, VfModule vfModule, VolumeGroup volumeGroup, GenericVnf vnf, + ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion, RequestContext requestContext, + String sdncAssignResponse, URI callbackURL) throws MapperException { + GenericResourceApiVfModuleOperationInformation req = new GenericResourceApiVfModuleOperationInformation(); + + boolean includeModelInformation = false; + + GenericResourceApiRequestActionEnumeration requestAction = + GenericResourceApiRequestActionEnumeration.CREATEVFMODULEINSTANCE; + GenericResourceApiSvcActionEnumeration genericResourceApiSvcAction = + GenericResourceApiSvcActionEnumeration.ASSIGN; + + if (svcAction.equals(SDNCSvcAction.ACTIVATE)) { + genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.ACTIVATE; + requestAction = GenericResourceApiRequestActionEnumeration.CREATEVFMODULEINSTANCE; + includeModelInformation = true; + } else if (svcAction.equals(SDNCSvcAction.ASSIGN)) { + genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.ASSIGN; + requestAction = GenericResourceApiRequestActionEnumeration.CREATEVFMODULEINSTANCE; + includeModelInformation = true; + } else if (svcAction.equals(SDNCSvcAction.DEACTIVATE)) { + genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.DEACTIVATE; + requestAction = GenericResourceApiRequestActionEnumeration.DELETEVFMODULEINSTANCE; + includeModelInformation = false; + } else if (svcAction.equals(SDNCSvcAction.DELETE)) { + genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.DELETE; + requestAction = GenericResourceApiRequestActionEnumeration.DELETEVFMODULEINSTANCE; + includeModelInformation = false; + } else if (svcAction.equals(SDNCSvcAction.UNASSIGN)) { + genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.UNASSIGN; + requestAction = GenericResourceApiRequestActionEnumeration.DELETEVFMODULEINSTANCE; + includeModelInformation = false; + } else if (svcAction.equals(SDNCSvcAction.CHANGE_ASSIGN)) { + genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.CHANGEASSIGN; + requestAction = GenericResourceApiRequestActionEnumeration.CREATEVFMODULEINSTANCE; + includeModelInformation = true; + } + + String sdncReqId = UUID.randomUUID().toString(); + String msoRequestId = UUID.randomUUID().toString(); + if (requestContext != null && requestContext.getMsoRequestId() != null) { + msoRequestId = requestContext.getMsoRequestId(); + } + + GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper + .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, requestAction); + GenericResourceApiServiceinformationServiceInformation serviceInformation = generalTopologyObjectMapper + .buildServiceInformation(serviceInstance, requestContext, customer, includeModelInformation); + GenericResourceApiVnfinformationVnfInformation vnfInformation = + generalTopologyObjectMapper.buildVnfInformation(vnf, serviceInstance, includeModelInformation); + GenericResourceApiVfmoduleinformationVfModuleInformation vfModuleInformation = generalTopologyObjectMapper + .buildVfModuleInformation(vfModule, vnf, serviceInstance, requestContext, includeModelInformation); + GenericResourceApiVfmodulerequestinputVfModuleRequestInput vfModuleRequestInput = + buildVfModuleRequestInput(vfModule, volumeGroup, cloudRegion, requestContext); + GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = + buildVfModuleSdncRequestHeader(sdncReqId, genericResourceApiSvcAction, callbackURL); + + req.setRequestInformation(requestInformation); + req.setSdncRequestHeader(sdncRequestHeader); + req.setServiceInformation(serviceInformation); + req.setVnfInformation(vnfInformation); + req.setVfModuleInformation(vfModuleInformation); + req.setVfModuleRequestInput(vfModuleRequestInput); + + return req; + } + + private GenericResourceApiVfmodulerequestinputVfModuleRequestInput buildVfModuleRequestInput(VfModule vfModule, + VolumeGroup volumeGroup, CloudRegion cloudRegion, RequestContext requestContext) { + GenericResourceApiVfmodulerequestinputVfModuleRequestInput vfModuleRequestInput = + new GenericResourceApiVfmodulerequestinputVfModuleRequestInput(); + if (cloudRegion != null) { + vfModuleRequestInput.setTenant(cloudRegion.getTenantId()); + vfModuleRequestInput.setAicCloudRegion(cloudRegion.getLcpCloudRegionId()); + vfModuleRequestInput.setCloudOwner(cloudRegion.getCloudOwner()); + } + if (vfModule.getVfModuleName() != null && !vfModule.getVfModuleName().equals("")) { + vfModuleRequestInput.setVfModuleName(vfModule.getVfModuleName()); + } + GenericResourceApiParam vfModuleInputParameters = new GenericResourceApiParam(); + + if (requestContext != null && requestContext.getUserParams() != null) { + for (Map.Entry entry : requestContext.getUserParams().entrySet()) { + GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); + paramItem.setName(entry.getKey()); + paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue())); + vfModuleInputParameters.addParamItem(paramItem); + } + } + + if (vfModule.getCloudParams() != null) { + for (Map.Entry entry : vfModule.getCloudParams().entrySet()) { + GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); + paramItem.setName(entry.getKey()); + paramItem.setValue(entry.getValue()); + vfModuleInputParameters.addParamItem(paramItem); + } + } + + if (volumeGroup != null) { + GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); + paramItem.setName("volume-group-id"); + paramItem.setValue(volumeGroup.getVolumeGroupId()); + vfModuleInputParameters.addParamItem(paramItem); + } + vfModuleRequestInput.setVfModuleInputParameters(vfModuleInputParameters); + + return vfModuleRequestInput; + } + + private GenericResourceApiSdncrequestheaderSdncRequestHeader buildVfModuleSdncRequestHeader(String sdncReqId, + GenericResourceApiSvcActionEnumeration svcAction, URI callbackUrl) { + GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = + new GenericResourceApiSdncrequestheaderSdncRequestHeader(); + sdncRequestHeader.setSvcRequestId(sdncReqId); + sdncRequestHeader.setSvcAction(svcAction); + sdncRequestHeader.setSvcNotificationUrl(callbackUrl.toString()); + return sdncRequestHeader; + } + + public String buildObjectPath(String sdncAssignResponse) { + String objectPath = null; + if (sdncAssignResponse != null) { + ObjectMapper mapper = new ObjectMapper(); + try { + GenericResourceApiVfModuleResponseInformation assignResponseInfo = + mapper.readValue(sdncAssignResponse, GenericResourceApiVfModuleResponseInformation.class); + objectPath = assignResponseInfo.getVfModuleResponseInformation().getObjectPath(); + } catch (Exception e) { + logger.error(LoggingAnchor.FIVE, MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), e.getMessage(), "BPMN", + ErrorCode.UnknownError.getValue(), e.getMessage()); + } + } + return objectPath; + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VnfTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VnfTopologyOperationRequestMapper.java new file mode 100644 index 0000000000..c2dcb8f290 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VnfTopologyOperationRequestMapper.java @@ -0,0 +1,164 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.sdnc.mapper; + +import java.net.URI; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import org.apache.commons.lang.StringUtils; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfrequestinputVnfRequestInput; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds; +import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.generalobjects.License; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup; +import org.onap.so.client.sdnc.beans.SDNCSvcAction; +import org.onap.so.client.sdnc.beans.SDNCSvcOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class VnfTopologyOperationRequestMapper { + + @Autowired + private GeneralTopologyObjectMapper generalTopologyObjectMapper; + + /** + * This method is used for creating the vnf request. + * + * By these parameter it will get he detailas and prepare the request. + * + * @param svcOperation + * @param svcAction + * @param requestAction + * @param vnf + * @param serviceInstance + * @param customer + * @param cloudRegion + * @param requestContext + * @param homing + * @return request + */ + public GenericResourceApiVnfOperationInformation reqMapper(SDNCSvcOperation svcOperation, SDNCSvcAction svcAction, + GenericResourceApiRequestActionEnumeration requestAction, GenericVnf vnf, ServiceInstance serviceInstance, + Customer customer, CloudRegion cloudRegion, RequestContext requestContext, boolean homing, + URI callbackUrl) { + String sdncReqId = UUID.randomUUID().toString(); + String msoRequestId = UUID.randomUUID().toString(); + if (requestContext != null && requestContext.getMsoRequestId() != null) { + msoRequestId = requestContext.getMsoRequestId(); + } + GenericResourceApiVnfOperationInformation req = new GenericResourceApiVnfOperationInformation(); + GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = + generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId, callbackUrl.toString()); + GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper + .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, requestAction); + GenericResourceApiServiceinformationServiceInformation serviceInformation = + generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, true); + GenericResourceApiVnfinformationVnfInformation vnfInformation = + generalTopologyObjectMapper.buildVnfInformation(vnf, serviceInstance, true); + GenericResourceApiVnfrequestinputVnfRequestInput vnfRequestInput = + new GenericResourceApiVnfrequestinputVnfRequestInput(); + + vnfRequestInput.setTenant(cloudRegion.getTenantId()); + vnfRequestInput.setAicCloudRegion(cloudRegion.getLcpCloudRegionId()); + vnfRequestInput.setCloudOwner(cloudRegion.getCloudOwner()); + + if (StringUtils.isNotBlank(vnf.getVnfName())) { + vnfRequestInput.setVnfName(vnf.getVnfName()); + } + + req.setRequestInformation(requestInformation); + req.setSdncRequestHeader(sdncRequestHeader); + req.setServiceInformation(serviceInformation); + req.setVnfInformation(vnfInformation); + + GenericResourceApiParam vnfInputParameters = new GenericResourceApiParam(); + if (requestContext != null && requestContext.getUserParams() != null) { + for (Map.Entry entry : requestContext.getUserParams().entrySet()) { + GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); + paramItem.setName(entry.getKey()); + paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue())); + vnfInputParameters.addParamItem(paramItem); + vnfRequestInput.setVnfInputParameters(vnfInputParameters); + } + } + if (vnf.getCloudParams() != null) { + for (Map.Entry entry : vnf.getCloudParams().entrySet()) { + GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); + paramItem.setName(entry.getKey()); + paramItem.setValue(entry.getValue()); + vnfInputParameters.addParamItem(paramItem); + } + } + if (homing) { + License license = vnf.getLicense(); + if (license != null) { + if (license.getEntitlementPoolUuids() != null && !license.getEntitlementPoolUuids().isEmpty()) { + String entitlementPoolUuid = license.getEntitlementPoolUuids().get(0); + GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); + paramItem.setName("entitlement_assignment_group_uuid"); + paramItem.setValue(entitlementPoolUuid); + vnfInputParameters.addParamItem(paramItem); + } + if (license.getLicenseKeyGroupUuids() != null && !license.getLicenseKeyGroupUuids().isEmpty()) { + String licenseKeyGroupUuid = license.getLicenseKeyGroupUuids().get(0); + GenericResourceApiParamParam paramItem2 = new GenericResourceApiParamParam(); + paramItem2.setName("license_assignment_group_uuid"); + paramItem2.setValue(licenseKeyGroupUuid); + vnfInputParameters.addParamItem(paramItem2); + } + } + } + List instanceGroups = vnf.getInstanceGroups(); + List networkInstanceGroupIdList = + new ArrayList<>(); + + for (InstanceGroup instanceGroup : instanceGroups) { + if (ModelInfoInstanceGroup.TYPE_L3_NETWORK + .equalsIgnoreCase(instanceGroup.getModelInfoInstanceGroup().getType())) { + GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds instanceGroupId = + new GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds(); + instanceGroupId.setVnfNetworkInstanceGroupId(instanceGroup.getId()); + networkInstanceGroupIdList.add(instanceGroupId); + } + } + + vnfRequestInput.setVnfNetworkInstanceGroupIds(networkInstanceGroupIdList); + vnfRequestInput.setVnfInputParameters(vnfInputParameters); + req.setVnfRequestInput(vnfRequestInput); + return req; + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCConfigurationResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCConfigurationResources.java index 4aa6a1026a..da675bb498 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCConfigurationResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCConfigurationResources.java @@ -21,6 +21,7 @@ package org.onap.so.client.orchestration; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GCTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; @@ -29,7 +30,6 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.onap.so.client.sdnc.mapper.GCTopologyOperationRequestMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.net.URI; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCNetworkResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCNetworkResources.java index 0123eb67be..dc59969492 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCNetworkResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCNetworkResources.java @@ -24,6 +24,7 @@ package org.onap.so.client.orchestration; import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.NetworkTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; @@ -31,7 +32,6 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.mapper.NetworkTopologyOperationRequestMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCServiceInstanceResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCServiceInstanceResources.java index 960efea2f0..54efd23bf9 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCServiceInstanceResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCServiceInstanceResources.java @@ -22,6 +22,7 @@ package org.onap.so.client.orchestration; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.ServiceTopologyOperationMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; @@ -29,7 +30,6 @@ import org.onap.so.client.exception.BadResponseException; 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.client.sdnc.mapper.ServiceTopologyOperationMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVfModuleResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVfModuleResources.java index 01511eaccc..c500374dc1 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVfModuleResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVfModuleResources.java @@ -24,6 +24,7 @@ package org.onap.so.client.orchestration; import java.net.URI; import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.VfModuleTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; @@ -36,7 +37,6 @@ import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.SDNCClient; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.mapper.VfModuleTopologyOperationRequestMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java index 27edeed02a..d198756b1e 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java @@ -25,6 +25,7 @@ package org.onap.so.client.orchestration; import java.net.URI; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.VnfTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; @@ -35,7 +36,6 @@ import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.SDNCClient; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.mapper.VnfTopologyOperationRequestMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java deleted file mode 100644 index 7d2fc10d0b..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java +++ /dev/null @@ -1,97 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.sdnc; - -import java.util.LinkedHashMap; -import javax.ws.rs.core.UriBuilder; -import org.onap.so.client.BaseClient; -import org.onap.so.client.exception.BadResponseException; -import org.onap.so.client.exception.MapperException; -import org.onap.so.client.sdnc.beans.SDNCProperties; -import org.onap.so.client.sdnc.endpoint.SDNCTopology; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.ParameterizedTypeReference; -import org.springframework.http.HttpHeaders; -import org.springframework.stereotype.Component; - -@Component -public class SDNCClient { - - @Autowired - private SDNCProperties properties; - @Autowired - private SdnCommonTasks sdnCommonTasks; - - /** - * - * @param request - takes in a generated object from sdnc client - creates a json request string and sends it to - * sdnc - receives and validates the linkedhashmap sent back from sdnc - * @throws MapperException - * @throws BadResponseException - */ - public String post(Object request, SDNCTopology topology) throws MapperException, BadResponseException { - String jsonRequest = sdnCommonTasks.buildJsonRequest(request); - String targetUrl = properties.getHost() + properties.getPath() + ":" + topology.toString() + "/"; - BaseClient> STOClient = new BaseClient<>(); - - STOClient.setTargetUrl(targetUrl); - HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth(), true); - STOClient.setHttpHeader(httpHeader); - LinkedHashMap output = - STOClient.post(jsonRequest, new ParameterizedTypeReference>() {}); - return sdnCommonTasks.validateSDNResponse(output); - } - - - public String post(Object request, String url) throws MapperException, BadResponseException { - String jsonRequest = sdnCommonTasks.buildJsonRequest(request); - BaseClient> STOClient = new BaseClient<>(); - STOClient.setTargetUrl(url); - HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth(), true); - STOClient.setHttpHeader(httpHeader); - LinkedHashMap output = - STOClient.post(jsonRequest, new ParameterizedTypeReference>() {}); - return sdnCommonTasks.validateSDNResponse(output); - } - - /** - * - * @param queryLink - takes in a link to topology that needs to be queried - creates a json request string and sends - * it to sdnc - receives and validates the linkedhashmap sent back from sdnc * - * @throws MapperException - * @throws BadResponseException - */ - public String get(String queryLink) throws MapperException, BadResponseException { - String request = ""; - String jsonRequest = sdnCommonTasks.buildJsonRequest(request); - String targetUrl = UriBuilder.fromUri(properties.getHost()).path(queryLink).build().toString(); - BaseClient> STOClient = new BaseClient<>(); - STOClient.setTargetUrl(targetUrl); - HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth(), false); - STOClient.setHttpHeader(httpHeader); - LinkedHashMap output = - STOClient.get(jsonRequest, new ParameterizedTypeReference>() {}); - return sdnCommonTasks.validateSDNGetResponse(output); - } - -} 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 deleted file mode 100644 index 01ac675d83..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java +++ /dev/null @@ -1,168 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.sdnc; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import org.onap.so.logger.LoggingAnchor; -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.logging.filter.base.ErrorCode; -import org.onap.so.logger.MessageEnum; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -@Component -public class SdnCommonTasks { - - private static final Logger logger = LoggerFactory.getLogger(SDNCClient.class); - private static final String RESPONSE_CODE = "response-code"; - private static final String RESPONSE_MESSAGE = "response-message"; - private static final String NO_RESPONSE_FROM_SDNC = "Error did not receive a response from SDNC."; - private static final String BAD_RESPONSE_FROM_SDNC = "Error received a bad response from SDNC."; - private static final String SDNC_CODE_NOT_0_OR_IN_200_299 = "Error from SDNC: %s"; - private static final String COULD_NOT_CONVERT_SDNC_POJO_TO_JSON = - "ERROR: Could not convert SDNC pojo to json string."; - private static final String BRACKETS = LoggingAnchor.FIVE; - - /*** - * - * @param request - * @return - * @throws MapperException - */ - public String buildJsonRequest(Object request) throws MapperException { - String jsonRequest; - ObjectMapper objMapper = new ObjectMapper(); - objMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - try { - jsonRequest = objMapper.writerWithDefaultPrettyPrinter().writeValueAsString(request); - } catch (JsonProcessingException e) { - logger.error(BRACKETS, MessageEnum.JAXB_EXCEPTION.toString(), COULD_NOT_CONVERT_SDNC_POJO_TO_JSON, "BPMN", - ErrorCode.DataError.getValue(), e.getMessage()); - throw new MapperException(COULD_NOT_CONVERT_SDNC_POJO_TO_JSON); - } - jsonRequest = "{\"input\":" + jsonRequest + "}"; - logger.info(jsonRequest); - return jsonRequest; - } - - /*** - * - * @param auth - * @return - */ - public HttpHeaders getHttpHeaders(String auth, boolean includeContentType) { - HttpHeaders httpHeader = new HttpHeaders(); - httpHeader.set("Authorization", auth); - if (includeContentType) { - httpHeader.setContentType(MediaType.APPLICATION_JSON); - } - List acceptMediaTypes = new ArrayList<>(); - acceptMediaTypes.add(MediaType.APPLICATION_JSON); - httpHeader.setAccept(acceptMediaTypes); - return httpHeader; - } - - /*** - * - * @param output - * @return - * @throws BadResponseException - */ - public String validateSDNResponse(LinkedHashMap output) throws BadResponseException { - if (CollectionUtils.isEmpty(output)) { - logger.error(BRACKETS, MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), NO_RESPONSE_FROM_SDNC, "BPMN", - ErrorCode.UnknownError.getValue(), NO_RESPONSE_FROM_SDNC); - throw new BadResponseException(NO_RESPONSE_FROM_SDNC); - } - LinkedHashMap embeddedResponse = (LinkedHashMap) output.get("output"); - String responseCode = ""; - String responseMessage = ""; - if (embeddedResponse != null) { - responseCode = (String) embeddedResponse.get(RESPONSE_CODE); - responseMessage = (String) embeddedResponse.get(RESPONSE_MESSAGE); - } - ObjectMapper objMapper = new ObjectMapper(); - String jsonResponse; - try { - jsonResponse = objMapper.writeValueAsString(output); - logger.debug(jsonResponse); - } catch (JsonProcessingException e) { - logger.warn("Could not convert SDNC Response to String", e); - jsonResponse = ""; - } - logger.info("ResponseCode: {} ResponseMessage: {}", responseCode, responseMessage); - int code = StringUtils.isNotEmpty(responseCode) ? Integer.parseInt(responseCode) : 0; - if (isHttpCodeSuccess(code)) { - logger.info("Successful Response from SDNC"); - return jsonResponse; - } else { - String errorMessage = String.format(SDNC_CODE_NOT_0_OR_IN_200_299, responseMessage); - logger.error(BRACKETS, MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), errorMessage, "BPMN", - ErrorCode.DataError.getValue(), errorMessage); - throw new BadResponseException(errorMessage); - } - } - - /*** - * - * @param output - * @return - * @throws BadResponseException - */ - public String validateSDNGetResponse(LinkedHashMap output) throws BadResponseException { - if (CollectionUtils.isEmpty(output)) { - logger.error(BRACKETS, MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), NO_RESPONSE_FROM_SDNC, "BPMN", - ErrorCode.UnknownError.getValue(), NO_RESPONSE_FROM_SDNC); - throw new BadResponseException(NO_RESPONSE_FROM_SDNC); - } - ObjectMapper objMapper = new ObjectMapper(); - logger.debug("Using object mapper"); - String stringOutput = ""; - try { - stringOutput = objMapper.writeValueAsString(output); - } catch (Exception e) { - logger.error(BRACKETS, MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), BAD_RESPONSE_FROM_SDNC, "BPMN", - ErrorCode.UnknownError.getValue(), BAD_RESPONSE_FROM_SDNC); - throw new BadResponseException(BAD_RESPONSE_FROM_SDNC); - } - logger.debug("Received from GET request: {}", stringOutput); - return stringOutput; - } - - - private boolean isHttpCodeSuccess(int code) { - return code >= HttpStatus.SC_OK && code < HttpStatus.SC_MULTIPLE_CHOICES || code == 0; - } -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCProperties.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCProperties.java deleted file mode 100644 index 15076fa45a..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCProperties.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.sdnc.beans; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -@Configuration -@ConfigurationProperties(prefix = "sdnc") -public class SDNCProperties { - - private String host; - private String path; - private String auth; - - public String getHost() { - return host; - } - - public void setHost(String host) { - this.host = host; - } - - public String getPath() { - return path; - } - - public void setPath(String path) { - this.path = path; - } - - public String getAuth() { - return auth; - } - - public void setAuth(String auth) { - this.auth = auth; - } -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java deleted file mode 100644 index 2c8bdd931c..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java +++ /dev/null @@ -1,97 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2018 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.client.sdnc.beans; - -import java.io.Serializable; -import java.util.UUID; -import org.onap.so.client.sdnc.endpoint.SDNCTopology; -import org.apache.commons.lang3.builder.HashCodeBuilder; -import org.apache.commons.lang3.builder.EqualsBuilder; - -public class SDNCRequest implements Serializable { - - /** - * - */ - private static final long serialVersionUID = 4679678988657593282L; - private String timeOut = "PT1H"; - private SDNCTopology topology; - private String correlationValue = UUID.randomUUID().toString(); - private String correlationName = "SDNCCallback"; - private transient Object sdncPayload; - - - public String getTimeOut() { - return timeOut; - } - - public void setTimeOut(String timeOut) { - this.timeOut = timeOut; - } - - public SDNCTopology getTopology() { - return topology; - } - - public void setTopology(SDNCTopology topology) { - this.topology = topology; - } - - public String getCorrelationValue() { - return correlationValue; - } - - public void setCorrelationValue(String correlationValue) { - this.correlationValue = correlationValue; - } - - public String getCorrelationName() { - return correlationName; - } - - public void setCorrelationName(String correlationName) { - this.correlationName = correlationName; - } - - public Object getSDNCPayload() { - return sdncPayload; - } - - public void setSDNCPayload(Object sDNCPayload) { - this.sdncPayload = sDNCPayload; - } - - @Override - public boolean equals(final Object other) { - if (!(other instanceof SDNCRequest)) { - return false; - } - SDNCRequest castOther = (SDNCRequest) other; - return new EqualsBuilder().append(correlationValue, castOther.correlationValue) - .append(correlationName, castOther.correlationName).isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder().append(correlationValue).append(correlationName).toHashCode(); - } - -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcAction.java deleted file mode 100644 index d6216c509d..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcAction.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.sdnc.beans; - -import org.onap.sdnc.northbound.client.model.GenericResourceApiSvcActionEnumeration; - -public enum SDNCSvcAction { - ACTIVATE("activate", GenericResourceApiSvcActionEnumeration.ACTIVATE), - DELETE("delete", GenericResourceApiSvcActionEnumeration.DELETE), - ASSIGN("assign", GenericResourceApiSvcActionEnumeration.ASSIGN), - ROLLBACK("rollback", GenericResourceApiSvcActionEnumeration.ROLLBACK), - UNASSIGN("unassign", GenericResourceApiSvcActionEnumeration.UNASSIGN), - DEACTIVATE("deactivate", GenericResourceApiSvcActionEnumeration.DEACTIVATE), - CHANGE_DELETE("changedelete", GenericResourceApiSvcActionEnumeration.CHANGEDELETE), - CHANGE_ASSIGN("changeassign", GenericResourceApiSvcActionEnumeration.CHANGEASSIGN), - CREATE("create", GenericResourceApiSvcActionEnumeration.CREATE), - ENABLE("enable", GenericResourceApiSvcActionEnumeration.ENABLE), - DISABLE("disable", GenericResourceApiSvcActionEnumeration.DISABLE); - - private final String name; - - private GenericResourceApiSvcActionEnumeration sdncApiAction; - - private SDNCSvcAction(String name, GenericResourceApiSvcActionEnumeration sdncApiAction) { - this.name = name; - this.sdncApiAction = sdncApiAction; - } - - public GenericResourceApiSvcActionEnumeration getSdncApiAction() { - return this.sdncApiAction; - } - - @Override - public String toString() { - return name; - } -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcOperation.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcOperation.java deleted file mode 100644 index 4edbf37bad..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcOperation.java +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.sdnc.beans; - -public enum SDNCSvcOperation { - - VF_MODULE_TOPOLOGY_OPERATION("vf-module-topology-operation"), - NETWORK_TOPOLOGY_OPERATION("network-topology-operation"), - VNF_TOPOLOGY_OPERATION("vnf-topology-operation"), - CONTRAIL_ROUTE_TOPOLOGY_OPERATION("contrail-route-topology-operation"), - SECURITY_ZONE_TOPOLOGY_OPERATION("security-zone-topology-operation"), - PORT_MIRROR_TOPOLOGY_OPERATION("port-mirror-topology-operation"), - SERVICE_TOPOLOGY_OPERATION("service-topology-operation"), - GENERIC_CONFIGURATION_TOPOLOGY_OPERATION("generic-configuration-topology-operation"); - - private final String name; - - private SDNCSvcOperation(String name) { - this.name = name; - } - - @Override - public String toString() { - return name; - } -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/endpoint/SDNCTopology.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/endpoint/SDNCTopology.java deleted file mode 100644 index ae9fe6ad70..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/endpoint/SDNCTopology.java +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.sdnc.endpoint; - -public enum SDNCTopology { - - SERVICE("service-topology-operation"), - VNF("vnf-topology-operation"), - VFMODULE("vf-module-topology-operation"), - CONTRAILROUTE("contrail-route-topology-operation"), - PORTMIRROR("port-mirror-topology-operation"), - NETWORK("network-topology-operation"), - SECURITYZONE("security-zone-topology-operation"), - CONFIGURATION("generic-configuration-topology-operation"); - - private final String topology; - - private SDNCTopology(String topology) { - this.topology = topology; - } - - @Override - public String toString() { - return this.topology; - } -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java deleted file mode 100644 index 6af8c2f9c5..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java +++ /dev/null @@ -1,107 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2018 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.client.sdnc.mapper; - -import java.net.URI; -import java.util.UUID; -import org.onap.sdnc.northbound.client.model.GenericResourceApiConfigurationinformationConfigurationInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiGcTopologyOperationInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiGcrequestinputGcRequestInput; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; -import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; -import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; -import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; -import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component(value = "sdncGCTopologyOperationRequestMapper") -public class GCTopologyOperationRequestMapper { - - @Autowired - private GeneralTopologyObjectMapper generalTopologyObjectMapper; - - public GenericResourceApiGcTopologyOperationInformation assignOrActivateVnrReqMapper(SDNCSvcAction svcAction, - GenericResourceApiRequestActionEnumeration reqAction, ServiceInstance serviceInstance, - RequestContext requestContext, Customer customer, Configuration vnrConfiguration, GenericVnf voiceVnf, - String sdncReqId, URI callbackUri) { - - String msoRequestId = UUID.randomUUID().toString(); - if (requestContext != null && requestContext.getMsoRequestId() != null) { - msoRequestId = requestContext.getMsoRequestId(); - } - GenericResourceApiGcTopologyOperationInformation req = new GenericResourceApiGcTopologyOperationInformation(); - GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = - generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId, callbackUri.toString()); - GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper - .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, reqAction); - GenericResourceApiServiceinformationServiceInformation serviceInformation = - generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, false); - GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation = - generalTopologyObjectMapper.buildConfigurationInformation(vnrConfiguration, true); - GenericResourceApiGcrequestinputGcRequestInput gcRequestInput = - generalTopologyObjectMapper.buildGcRequestInformation(voiceVnf, null); - req.setRequestInformation(requestInformation); - req.setSdncRequestHeader(sdncRequestHeader); - req.setServiceInformation(serviceInformation); - req.setConfigurationInformation(configurationInformation); - req.setGcRequestInput(gcRequestInput); - - return req; - - } - - - public GenericResourceApiGcTopologyOperationInformation deactivateOrUnassignVnrReqMapper(SDNCSvcAction svcAction, - ServiceInstance serviceInstance, RequestContext requestContext, Configuration vnrConfiguration, - String sdncReqId, URI callbackUri) { - - String msoRequestId = null; - if (requestContext != null) { - msoRequestId = requestContext.getMsoRequestId(); - } - GenericResourceApiGcTopologyOperationInformation req = new GenericResourceApiGcTopologyOperationInformation(); - GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = - generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId, callbackUri.toString()); - GenericResourceApiRequestinformationRequestInformation requestInformation = - generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, - GenericResourceApiRequestActionEnumeration.DELETEGENERICCONFIGURATIONINSTANCE); - GenericResourceApiServiceinformationServiceInformation serviceInformation = - new GenericResourceApiServiceinformationServiceInformation(); - serviceInformation.setServiceInstanceId(serviceInstance.getServiceInstanceId()); - GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation = - new GenericResourceApiConfigurationinformationConfigurationInformation(); - configurationInformation.setConfigurationId(vnrConfiguration.getConfigurationId()); - configurationInformation.setConfigurationType(vnrConfiguration.getConfigurationType()); - req.setRequestInformation(requestInformation); - req.setSdncRequestHeader(sdncRequestHeader); - req.setServiceInformation(serviceInformation); - req.setConfigurationInformation(configurationInformation); - return req; - - } - -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java deleted file mode 100644 index a9611cbde5..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java +++ /dev/null @@ -1,267 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.sdnc.mapper; - -import java.util.List; -import java.util.Map; -import java.util.Set; -import org.onap.sdnc.northbound.client.model.GenericResourceApiConfigurationinformationConfigurationInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiGcrequestinputGcRequestInput; -import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkinformationNetworkInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiOnapmodelinformationOnapModelInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; -import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduleinformationVfModuleInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; -import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; -import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; -import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; -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.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -@Component -public class GeneralTopologyObjectMapper { - - private static final Logger logger = LoggerFactory.getLogger(GeneralTopologyObjectMapper.class); - private ObjectMapper mapper = new ObjectMapper(); - - /* - * Build GenericResourceApiRequestinformationRequestInformation - */ - public GenericResourceApiRequestinformationRequestInformation buildGenericResourceApiRequestinformationRequestInformation( - String msoReqId, GenericResourceApiRequestActionEnumeration requestAction) { - - GenericResourceApiRequestinformationRequestInformation requestInformation = - new GenericResourceApiRequestinformationRequestInformation(); - requestInformation.setRequestId(msoReqId); - requestInformation.setRequestAction(requestAction); - requestInformation.setSource("MSO"); - return requestInformation; - } - - /* - * Build GenericResourceApiServiceinformationServiceInformation - */ - public GenericResourceApiServiceinformationServiceInformation buildServiceInformation( - ServiceInstance serviceInstance, RequestContext requestContext, Customer customer, - boolean includeModelInformation) { - GenericResourceApiServiceinformationServiceInformation serviceInformation = - new GenericResourceApiServiceinformationServiceInformation(); - serviceInformation.serviceId(serviceInstance.getServiceInstanceId()); - if (requestContext != null) { - serviceInformation.setSubscriptionServiceType(requestContext.getProductFamilyId()); - } - if (includeModelInformation) { - GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = - new GenericResourceApiOnapmodelinformationOnapModelInformation(); - onapModelInformation - .setModelInvariantUuid(serviceInstance.getModelInfoServiceInstance().getModelInvariantUuid()); - onapModelInformation.setModelVersion(serviceInstance.getModelInfoServiceInstance().getModelVersion()); - onapModelInformation.setModelName(serviceInstance.getModelInfoServiceInstance().getModelName()); - onapModelInformation.setModelUuid(serviceInstance.getModelInfoServiceInstance().getModelUuid()); - serviceInformation.setOnapModelInformation(onapModelInformation); - } - serviceInformation.setServiceInstanceId(serviceInstance.getServiceInstanceId()); - - if (customer != null) { - serviceInformation.setGlobalCustomerId(customer.getGlobalCustomerId()); - if (customer.getServiceSubscription() != null) { - serviceInformation.setSubscriptionServiceType(customer.getServiceSubscription().getServiceType()); - } - - } - return serviceInformation; - } - - /* - * Build GenericResourceApiNetworkinformationNetworkInformation - */ - public GenericResourceApiNetworkinformationNetworkInformation buildNetworkInformation(L3Network network) { - GenericResourceApiNetworkinformationNetworkInformation networkInformation = - new GenericResourceApiNetworkinformationNetworkInformation(); - GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = - new GenericResourceApiOnapmodelinformationOnapModelInformation(); - if (network.getModelInfoNetwork() != null) { - onapModelInformation.setModelInvariantUuid(network.getModelInfoNetwork().getModelInvariantUUID()); - onapModelInformation.setModelName(network.getModelInfoNetwork().getModelName()); - onapModelInformation.setModelVersion(network.getModelInfoNetwork().getModelVersion()); - onapModelInformation.setModelUuid(network.getModelInfoNetwork().getModelUUID()); - onapModelInformation.setModelCustomizationUuid(network.getModelInfoNetwork().getModelCustomizationUUID()); - networkInformation.setOnapModelInformation(onapModelInformation); - } - - networkInformation.setFromPreload(null); - networkInformation.setNetworkId(network.getNetworkId()); - networkInformation.setNetworkType(network.getNetworkType()); - networkInformation.setNetworkTechnology(network.getNetworkTechnology()); - return networkInformation; - } - - /* - * Build GenericResourceApiVnfinformationVnfInformation - */ - public GenericResourceApiVnfinformationVnfInformation buildVnfInformation(GenericVnf vnf, - ServiceInstance serviceInstance, boolean includeModelInformation) { - GenericResourceApiVnfinformationVnfInformation vnfInformation = - new GenericResourceApiVnfinformationVnfInformation(); - if (includeModelInformation && vnf.getModelInfoGenericVnf() != null) { - GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = - new GenericResourceApiOnapmodelinformationOnapModelInformation(); - onapModelInformation.setModelInvariantUuid(vnf.getModelInfoGenericVnf().getModelInvariantUuid()); - onapModelInformation.setModelName(vnf.getModelInfoGenericVnf().getModelName()); - onapModelInformation.setModelVersion(vnf.getModelInfoGenericVnf().getModelVersion()); - onapModelInformation.setModelUuid(vnf.getModelInfoGenericVnf().getModelUuid()); - onapModelInformation.setModelCustomizationUuid(vnf.getModelInfoGenericVnf().getModelCustomizationUuid()); - vnfInformation.setOnapModelInformation(onapModelInformation); - } - vnfInformation.setVnfId(vnf.getVnfId()); - vnfInformation.setVnfType(vnf.getVnfType()); - vnfInformation.setVnfName(vnf.getVnfName()); - return vnfInformation; - } - - /* - * Build GenericResourceApiVfModuleinformationVfModuleInformation - */ - public GenericResourceApiVfmoduleinformationVfModuleInformation buildVfModuleInformation(VfModule vfModule, - GenericVnf vnf, ServiceInstance serviceInstance, RequestContext requestContext, - boolean includeModelInformation) throws MapperException { - GenericResourceApiVfmoduleinformationVfModuleInformation vfModuleInformation = - new GenericResourceApiVfmoduleinformationVfModuleInformation(); - if (includeModelInformation) { - if (vfModule.getModelInfoVfModule() == null) { - throw new MapperException("VF Module model info is null for " + vfModule.getVfModuleId()); - } else { - GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = - new GenericResourceApiOnapmodelinformationOnapModelInformation(); - onapModelInformation.setModelInvariantUuid(vfModule.getModelInfoVfModule().getModelInvariantUUID()); - onapModelInformation.setModelName(vfModule.getModelInfoVfModule().getModelName()); - onapModelInformation.setModelVersion(vfModule.getModelInfoVfModule().getModelVersion()); - onapModelInformation.setModelUuid(vfModule.getModelInfoVfModule().getModelUUID()); - onapModelInformation - .setModelCustomizationUuid(vfModule.getModelInfoVfModule().getModelCustomizationUUID()); - vfModuleInformation.setOnapModelInformation(onapModelInformation); - } - } - if (vfModule.getModelInfoVfModule() != null) { - vfModuleInformation.setVfModuleType(vfModule.getModelInfoVfModule().getModelName()); - } - vfModuleInformation.setVfModuleId(vfModule.getVfModuleId()); - if (requestContext != null && requestContext.getRequestParameters() != null) { - vfModuleInformation.setFromPreload(requestContext.getRequestParameters().getUsePreload()); - } else { - vfModuleInformation.setFromPreload(true); - } - - return vfModuleInformation; - } - - - public GenericResourceApiSdncrequestheaderSdncRequestHeader buildSdncRequestHeader(SDNCSvcAction svcAction, - String sdncReqId) { - return buildSdncRequestHeader(svcAction, sdncReqId, null); - } - - public GenericResourceApiSdncrequestheaderSdncRequestHeader buildSdncRequestHeader(SDNCSvcAction svcAction, - String sdncReqId, String callbackUrl) { - GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = - new GenericResourceApiSdncrequestheaderSdncRequestHeader(); - sdncRequestHeader.setSvcAction(svcAction.getSdncApiAction()); - sdncRequestHeader.setSvcRequestId(sdncReqId); - sdncRequestHeader.setSvcNotificationUrl(callbackUrl); - return sdncRequestHeader; - } - - /** - * Build ConfigurationInformation - * - * @param configuration - * @param includeModelInformation - * @return - */ - public GenericResourceApiConfigurationinformationConfigurationInformation buildConfigurationInformation( - Configuration configuration, boolean includeModelInformation) { - GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation = - new GenericResourceApiConfigurationinformationConfigurationInformation(); - configurationInformation.setConfigurationId(configuration.getConfigurationId()); - configurationInformation.setConfigurationName(configuration.getConfigurationName()); - configurationInformation.setConfigurationType(configuration.getConfigurationType()); - if (includeModelInformation) { - GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = - new GenericResourceApiOnapmodelinformationOnapModelInformation(); - onapModelInformation.setModelInvariantUuid(configuration.getModelInfoConfiguration().getModelInvariantId()); - onapModelInformation.setModelUuid(configuration.getModelInfoConfiguration().getModelVersionId()); - onapModelInformation - .setModelCustomizationUuid(configuration.getModelInfoConfiguration().getModelCustomizationId()); - configurationInformation.setOnapModelInformation(onapModelInformation); - } - return configurationInformation; - } - - - /** - * Build GcRequestInformation - * - * @param vnf - * @param genericResourceApiParam - * @return - */ - public GenericResourceApiGcrequestinputGcRequestInput buildGcRequestInformation(GenericVnf vnf, - GenericResourceApiParam genericResourceApiParam) { - GenericResourceApiGcrequestinputGcRequestInput gcRequestInput = - new GenericResourceApiGcrequestinputGcRequestInput(); - gcRequestInput.setVnfId(vnf.getVnfId()); - if (genericResourceApiParam != null) { - gcRequestInput.setInputParameters(genericResourceApiParam); - } - return gcRequestInput; - } - - - public String mapUserParamValue(Object value) { - if (value == null) { - return null; - } else { - if (value instanceof Map || value instanceof Set || value instanceof List) { - try { - return mapper.writeValueAsString(value); - } catch (JsonProcessingException e) { - logger.error("could not map value to string", e); - throw new IllegalArgumentException(e); - } - } else { - return value.toString(); - } - } - } -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java deleted file mode 100644 index b1c95154c6..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java +++ /dev/null @@ -1,114 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.sdnc.mapper; - -import java.util.Map; -import java.util.UUID; -import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkinformationNetworkInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkrequestinputNetworkRequestInput; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; -import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; -import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; -import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; -import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; -import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -/** - * Mapper creating SDNC request - * - */ -@Component -public class NetworkTopologyOperationRequestMapper { - - @Autowired - private GeneralTopologyObjectMapper generalTopologyObjectMapper; - - public GenericResourceApiNetworkOperationInformation reqMapper(SDNCSvcOperation svcOperation, - SDNCSvcAction svcAction, GenericResourceApiRequestActionEnumeration reqAction, L3Network network, - ServiceInstance serviceInstance, Customer customer, RequestContext requestContext, - CloudRegion cloudRegion) { - GenericResourceApiNetworkOperationInformation req = new GenericResourceApiNetworkOperationInformation(); - String sdncReqId = UUID.randomUUID().toString(); - String msoRequestId = UUID.randomUUID().toString(); - if (requestContext != null && requestContext.getMsoRequestId() != null) { - msoRequestId = requestContext.getMsoRequestId(); - } - GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = - generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId); - GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper - .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, reqAction); - GenericResourceApiServiceinformationServiceInformation serviceInformation = - generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, true); - GenericResourceApiNetworkinformationNetworkInformation networkInformation = - generalTopologyObjectMapper.buildNetworkInformation(network); - GenericResourceApiNetworkrequestinputNetworkRequestInput networkRequestInput = - buildNetworkRequestInput(network, serviceInstance, cloudRegion); - - req.setRequestInformation(requestInformation); - req.setSdncRequestHeader(sdncRequestHeader); - req.setServiceInformation(serviceInformation); - req.setNetworkInformation(networkInformation); - - if (requestContext != null && requestContext.getUserParams() != null) { - for (Map.Entry entry : requestContext.getUserParams().entrySet()) { - GenericResourceApiParam networkInputParameters = new GenericResourceApiParam(); - GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); - paramItem.setName(entry.getKey()); - paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue())); - networkInputParameters.addParamItem(paramItem); - networkRequestInput.setNetworkInputParameters(networkInputParameters); - } - } - - req.setNetworkRequestInput(networkRequestInput); - return req; - } - - /* - * Private helper to build GenericResourceApiNetworkrequestinputNetworkRequestInput - */ - private GenericResourceApiNetworkrequestinputNetworkRequestInput buildNetworkRequestInput(L3Network network, - ServiceInstance serviceInstance, CloudRegion cloudRegion) { - GenericResourceApiNetworkrequestinputNetworkRequestInput networkRequestInput = - new GenericResourceApiNetworkrequestinputNetworkRequestInput(); - networkRequestInput.setTenant(cloudRegion.getTenantId()); - networkRequestInput.setCloudOwner(cloudRegion.getCloudOwner()); - networkRequestInput.setAicCloudRegion(cloudRegion.getLcpCloudRegionId()); - if (network.getNetworkName() != null && !network.getNetworkName().equals("")) { - networkRequestInput.setNetworkName(network.getNetworkName()); - } - if (serviceInstance.getCollection() != null && serviceInstance.getCollection().getInstanceGroup() != null) { - // set only for network created as part of the collection/instance since 1806 - networkRequestInput.setNetworkInstanceGroupId(serviceInstance.getCollection().getInstanceGroup().getId()); - } - return networkRequestInput; - } -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java deleted file mode 100644 index b5957b3009..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java +++ /dev/null @@ -1,89 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.sdnc.mapper; - -import java.util.Map; -import java.util.UUID; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; -import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiServicerequestinputServiceRequestInput; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; -import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; -import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class ServiceTopologyOperationMapper { - - @Autowired - public GeneralTopologyObjectMapper generalTopologyObjectMapper; - - public GenericResourceApiServiceOperationInformation reqMapper(SDNCSvcOperation svcOperation, - SDNCSvcAction svcAction, GenericResourceApiRequestActionEnumeration resourceAction, - ServiceInstance serviceInstance, Customer customer, RequestContext requestContext) { - - String sdncReqId = UUID.randomUUID().toString(); - String msoRequestId = UUID.randomUUID().toString(); - if (requestContext != null && requestContext.getMsoRequestId() != null) { - msoRequestId = requestContext.getMsoRequestId(); - } - GenericResourceApiServiceOperationInformation servOpInput = new GenericResourceApiServiceOperationInformation(); - GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = - generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId); - GenericResourceApiRequestinformationRequestInformation reqInfo = generalTopologyObjectMapper - .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, resourceAction); - GenericResourceApiServiceinformationServiceInformation servInfo = - generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, true); - GenericResourceApiServicerequestinputServiceRequestInput servReqInfo = - new GenericResourceApiServicerequestinputServiceRequestInput(); - - servReqInfo.setServiceInstanceName(serviceInstance.getServiceInstanceName()); - - servOpInput.setSdncRequestHeader(sdncRequestHeader); - servOpInput.setRequestInformation(reqInfo); - servOpInput.setServiceInformation(servInfo); - servOpInput.setServiceRequestInput(servReqInfo); - - if (requestContext != null && requestContext.getUserParams() != null) { - for (Map.Entry entry : requestContext.getUserParams().entrySet()) { - GenericResourceApiServicerequestinputServiceRequestInput serviceRequestInput = - new GenericResourceApiServicerequestinputServiceRequestInput(); - serviceRequestInput.setServiceInstanceName(serviceInstance.getServiceInstanceName()); - GenericResourceApiParam serviceInputParameters = new GenericResourceApiParam(); - GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); - paramItem.setName(entry.getKey()); - paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue())); - serviceInputParameters.addParamItem(paramItem); - serviceRequestInput.serviceInputParameters(serviceInputParameters); - servOpInput.setServiceRequestInput(serviceRequestInput); - } - } - return servOpInput; - } -} 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 deleted file mode 100644 index f6642ab76a..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java +++ /dev/null @@ -1,202 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.sdnc.mapper; - -import java.net.URI; -import java.util.Map; -import java.util.UUID; -import org.onap.so.logger.LoggingAnchor; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; -import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiSvcActionEnumeration; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleResponseInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduleinformationVfModuleInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmodulerequestinputVfModuleRequestInput; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; -import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; -import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; -import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; -import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; -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.logging.filter.base.ErrorCode; -import org.onap.so.logger.MessageEnum; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import com.fasterxml.jackson.databind.ObjectMapper; - -@Component -public class VfModuleTopologyOperationRequestMapper { - private static final Logger logger = LoggerFactory.getLogger(VfModuleTopologyOperationRequestMapper.class); - - @Autowired - private GeneralTopologyObjectMapper generalTopologyObjectMapper; - - public GenericResourceApiVfModuleOperationInformation reqMapper(SDNCSvcOperation svcOperation, - SDNCSvcAction svcAction, VfModule vfModule, VolumeGroup volumeGroup, GenericVnf vnf, - ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion, RequestContext requestContext, - String sdncAssignResponse, URI callbackURL) throws MapperException { - GenericResourceApiVfModuleOperationInformation req = new GenericResourceApiVfModuleOperationInformation(); - - boolean includeModelInformation = false; - - GenericResourceApiRequestActionEnumeration requestAction = - GenericResourceApiRequestActionEnumeration.CREATEVFMODULEINSTANCE; - GenericResourceApiSvcActionEnumeration genericResourceApiSvcAction = - GenericResourceApiSvcActionEnumeration.ASSIGN; - - if (svcAction.equals(SDNCSvcAction.ACTIVATE)) { - genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.ACTIVATE; - requestAction = GenericResourceApiRequestActionEnumeration.CREATEVFMODULEINSTANCE; - includeModelInformation = true; - } else if (svcAction.equals(SDNCSvcAction.ASSIGN)) { - genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.ASSIGN; - requestAction = GenericResourceApiRequestActionEnumeration.CREATEVFMODULEINSTANCE; - includeModelInformation = true; - } else if (svcAction.equals(SDNCSvcAction.DEACTIVATE)) { - genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.DEACTIVATE; - requestAction = GenericResourceApiRequestActionEnumeration.DELETEVFMODULEINSTANCE; - includeModelInformation = false; - } else if (svcAction.equals(SDNCSvcAction.DELETE)) { - genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.DELETE; - requestAction = GenericResourceApiRequestActionEnumeration.DELETEVFMODULEINSTANCE; - includeModelInformation = false; - } else if (svcAction.equals(SDNCSvcAction.UNASSIGN)) { - genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.UNASSIGN; - requestAction = GenericResourceApiRequestActionEnumeration.DELETEVFMODULEINSTANCE; - includeModelInformation = false; - } else if (svcAction.equals(SDNCSvcAction.CHANGE_ASSIGN)) { - genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.CHANGEASSIGN; - requestAction = GenericResourceApiRequestActionEnumeration.CREATEVFMODULEINSTANCE; - includeModelInformation = true; - } - - String sdncReqId = UUID.randomUUID().toString(); - String msoRequestId = UUID.randomUUID().toString(); - if (requestContext != null && requestContext.getMsoRequestId() != null) { - msoRequestId = requestContext.getMsoRequestId(); - } - - GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper - .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, requestAction); - GenericResourceApiServiceinformationServiceInformation serviceInformation = generalTopologyObjectMapper - .buildServiceInformation(serviceInstance, requestContext, customer, includeModelInformation); - GenericResourceApiVnfinformationVnfInformation vnfInformation = - generalTopologyObjectMapper.buildVnfInformation(vnf, serviceInstance, includeModelInformation); - GenericResourceApiVfmoduleinformationVfModuleInformation vfModuleInformation = generalTopologyObjectMapper - .buildVfModuleInformation(vfModule, vnf, serviceInstance, requestContext, includeModelInformation); - GenericResourceApiVfmodulerequestinputVfModuleRequestInput vfModuleRequestInput = - buildVfModuleRequestInput(vfModule, volumeGroup, cloudRegion, requestContext); - GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = - buildVfModuleSdncRequestHeader(sdncReqId, genericResourceApiSvcAction, callbackURL); - - req.setRequestInformation(requestInformation); - req.setSdncRequestHeader(sdncRequestHeader); - req.setServiceInformation(serviceInformation); - req.setVnfInformation(vnfInformation); - req.setVfModuleInformation(vfModuleInformation); - req.setVfModuleRequestInput(vfModuleRequestInput); - - return req; - } - - private GenericResourceApiVfmodulerequestinputVfModuleRequestInput buildVfModuleRequestInput(VfModule vfModule, - VolumeGroup volumeGroup, CloudRegion cloudRegion, RequestContext requestContext) { - GenericResourceApiVfmodulerequestinputVfModuleRequestInput vfModuleRequestInput = - new GenericResourceApiVfmodulerequestinputVfModuleRequestInput(); - if (cloudRegion != null) { - vfModuleRequestInput.setTenant(cloudRegion.getTenantId()); - vfModuleRequestInput.setAicCloudRegion(cloudRegion.getLcpCloudRegionId()); - vfModuleRequestInput.setCloudOwner(cloudRegion.getCloudOwner()); - } - if (vfModule.getVfModuleName() != null && !vfModule.getVfModuleName().equals("")) { - vfModuleRequestInput.setVfModuleName(vfModule.getVfModuleName()); - } - GenericResourceApiParam vfModuleInputParameters = new GenericResourceApiParam(); - - if (requestContext != null && requestContext.getUserParams() != null) { - for (Map.Entry entry : requestContext.getUserParams().entrySet()) { - GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); - paramItem.setName(entry.getKey()); - paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue())); - vfModuleInputParameters.addParamItem(paramItem); - } - } - - if (vfModule.getCloudParams() != null) { - for (Map.Entry entry : vfModule.getCloudParams().entrySet()) { - GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); - paramItem.setName(entry.getKey()); - paramItem.setValue(entry.getValue()); - vfModuleInputParameters.addParamItem(paramItem); - } - } - - if (volumeGroup != null) { - GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); - paramItem.setName("volume-group-id"); - paramItem.setValue(volumeGroup.getVolumeGroupId()); - vfModuleInputParameters.addParamItem(paramItem); - } - vfModuleRequestInput.setVfModuleInputParameters(vfModuleInputParameters); - - return vfModuleRequestInput; - } - - private GenericResourceApiSdncrequestheaderSdncRequestHeader buildVfModuleSdncRequestHeader(String sdncReqId, - GenericResourceApiSvcActionEnumeration svcAction, URI callbackUrl) { - GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = - new GenericResourceApiSdncrequestheaderSdncRequestHeader(); - sdncRequestHeader.setSvcRequestId(sdncReqId); - sdncRequestHeader.setSvcAction(svcAction); - sdncRequestHeader.setSvcNotificationUrl(callbackUrl.toString()); - return sdncRequestHeader; - } - - public String buildObjectPath(String sdncAssignResponse) { - String objectPath = null; - if (sdncAssignResponse != null) { - ObjectMapper mapper = new ObjectMapper(); - try { - GenericResourceApiVfModuleResponseInformation assignResponseInfo = - mapper.readValue(sdncAssignResponse, GenericResourceApiVfModuleResponseInformation.class); - objectPath = assignResponseInfo.getVfModuleResponseInformation().getObjectPath(); - } catch (Exception e) { - logger.error(LoggingAnchor.FIVE, MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), e.getMessage(), "BPMN", - ErrorCode.UnknownError.getValue(), e.getMessage()); - } - } - return objectPath; - } -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java deleted file mode 100644 index fd0af3a4dd..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java +++ /dev/null @@ -1,164 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.sdnc.mapper; - -import java.net.URI; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import org.apache.commons.lang.StringUtils; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; -import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfrequestinputVnfRequestInput; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds; -import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; -import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; -import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; -import org.onap.so.bpmn.servicedecomposition.generalobjects.License; -import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; -import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup; -import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class VnfTopologyOperationRequestMapper { - - @Autowired - private GeneralTopologyObjectMapper generalTopologyObjectMapper; - - /** - * This method is used for creating the vnf request. - * - * By these parameter it will get he detailas and prepare the request. - * - * @param svcOperation - * @param svcAction - * @param requestAction - * @param vnf - * @param serviceInstance - * @param customer - * @param cloudRegion - * @param requestContext - * @param homing - * @return request - */ - public GenericResourceApiVnfOperationInformation reqMapper(SDNCSvcOperation svcOperation, SDNCSvcAction svcAction, - GenericResourceApiRequestActionEnumeration requestAction, GenericVnf vnf, ServiceInstance serviceInstance, - Customer customer, CloudRegion cloudRegion, RequestContext requestContext, boolean homing, - URI callbackUrl) { - String sdncReqId = UUID.randomUUID().toString(); - String msoRequestId = UUID.randomUUID().toString(); - if (requestContext != null && requestContext.getMsoRequestId() != null) { - msoRequestId = requestContext.getMsoRequestId(); - } - GenericResourceApiVnfOperationInformation req = new GenericResourceApiVnfOperationInformation(); - GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = - generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId, callbackUrl.toString()); - GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper - .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, requestAction); - GenericResourceApiServiceinformationServiceInformation serviceInformation = - generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, true); - GenericResourceApiVnfinformationVnfInformation vnfInformation = - generalTopologyObjectMapper.buildVnfInformation(vnf, serviceInstance, true); - GenericResourceApiVnfrequestinputVnfRequestInput vnfRequestInput = - new GenericResourceApiVnfrequestinputVnfRequestInput(); - - vnfRequestInput.setTenant(cloudRegion.getTenantId()); - vnfRequestInput.setAicCloudRegion(cloudRegion.getLcpCloudRegionId()); - vnfRequestInput.setCloudOwner(cloudRegion.getCloudOwner()); - - if (StringUtils.isNotBlank(vnf.getVnfName())) { - vnfRequestInput.setVnfName(vnf.getVnfName()); - } - - req.setRequestInformation(requestInformation); - req.setSdncRequestHeader(sdncRequestHeader); - req.setServiceInformation(serviceInformation); - req.setVnfInformation(vnfInformation); - - GenericResourceApiParam vnfInputParameters = new GenericResourceApiParam(); - if (requestContext != null && requestContext.getUserParams() != null) { - for (Map.Entry entry : requestContext.getUserParams().entrySet()) { - GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); - paramItem.setName(entry.getKey()); - paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue())); - vnfInputParameters.addParamItem(paramItem); - vnfRequestInput.setVnfInputParameters(vnfInputParameters); - } - } - if (vnf.getCloudParams() != null) { - for (Map.Entry entry : vnf.getCloudParams().entrySet()) { - GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); - paramItem.setName(entry.getKey()); - paramItem.setValue(entry.getValue()); - vnfInputParameters.addParamItem(paramItem); - } - } - if (homing) { - License license = vnf.getLicense(); - if (license != null) { - if (license.getEntitlementPoolUuids() != null && !license.getEntitlementPoolUuids().isEmpty()) { - String entitlementPoolUuid = license.getEntitlementPoolUuids().get(0); - GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); - paramItem.setName("entitlement_assignment_group_uuid"); - paramItem.setValue(entitlementPoolUuid); - vnfInputParameters.addParamItem(paramItem); - } - if (license.getLicenseKeyGroupUuids() != null && !license.getLicenseKeyGroupUuids().isEmpty()) { - String licenseKeyGroupUuid = license.getLicenseKeyGroupUuids().get(0); - GenericResourceApiParamParam paramItem2 = new GenericResourceApiParamParam(); - paramItem2.setName("license_assignment_group_uuid"); - paramItem2.setValue(licenseKeyGroupUuid); - vnfInputParameters.addParamItem(paramItem2); - } - } - } - List instanceGroups = vnf.getInstanceGroups(); - List networkInstanceGroupIdList = - new ArrayList<>(); - - for (InstanceGroup instanceGroup : instanceGroups) { - if (ModelInfoInstanceGroup.TYPE_L3_NETWORK - .equalsIgnoreCase(instanceGroup.getModelInfoInstanceGroup().getType())) { - GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds instanceGroupId = - new GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds(); - instanceGroupId.setVnfNetworkInstanceGroupId(instanceGroup.getId()); - networkInstanceGroupIdList.add(instanceGroupId); - } - } - - vnfRequestInput.setVnfNetworkInstanceGroupIds(networkInstanceGroupIdList); - vnfRequestInput.setVnfInputParameters(vnfInputParameters); - req.setVnfRequestInput(vnfRequestInput); - return req; - } -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOHealthCheckClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOHealthCheckClient.java deleted file mode 100644 index 9b857dc08c..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOHealthCheckClient.java +++ /dev/null @@ -1,167 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.sdno; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import org.onap.so.client.dmaap.DmaapConsumer; -import org.onap.so.client.dmaap.DmaapPublisher; -import org.onap.so.client.sdno.beans.AAIParamList; -import org.onap.so.client.sdno.beans.Body; -import org.onap.so.client.sdno.beans.Input; -import org.onap.so.client.sdno.beans.RequestHdCustom; -import org.onap.so.client.sdno.beans.SDNO; -import org.onap.so.client.sdno.dmaap.SDNOHealthCheckDmaapConsumer; -import org.onap.so.client.sdno.dmaap.SDNOHealthCheckDmaapPublisher; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class SDNOHealthCheckClient { - - private static final String NODE_TYPE = "VROUTER"; - private static final String API_OPERATION_TYPE = "health-diagnostic-custom"; - private static final String MIRRORING_CHECK = "mirroring_check"; - private static final String CLIENT_NAME = "MSO"; - private static final String PRE_CHECK_CODE = "VROUTER000003"; - private static final String POST_CHECK_CODE = "VROUTER000004"; - private static final String LPORT_MIRRORING_CHECK = "lport_mirroring_check"; - private static final String CONFIGURATION_ID = "configuration-id"; - - - public boolean lPortMirrorHealthPreCheck(String userId, String requestId, Optional clliCode, - String configurationId, String interfaceId) throws Exception { - String request = buildLPortMirrorCheckPreRequest(userId, requestId, clliCode, configurationId, interfaceId); - return this.execute(requestId, request); - } - - public boolean lPortMirrorHealthPostCheck(String userId, String requestId, Optional clliCode, - String configurationId, String interfaceId) throws Exception { - String request = buildLPortMirrorCheckPostRequest(userId, requestId, clliCode, configurationId, interfaceId); - return this.execute(requestId, request); - } - - public boolean portMirrorHealthPreCheck(String userId, String requestId, Optional clliCode, - String configurationId) throws Exception { - final String request = this.buildPortMirrorPreCheckRequest(userId, requestId, clliCode, configurationId); - return this.execute(requestId, request); - } - - public boolean portMirrorHealthPostCheck(String userId, String requestId, Optional clliCode, - String configurationId) throws Exception { - final String request = this.buildPortMirrorPostCheckRequest(userId, requestId, clliCode, configurationId); - return this.execute(requestId, request); - } - - protected String buildLPortMirrorCheckPreRequest(String userId, String requestId, Optional clliCode, - String configurationId, String interfaceId) throws JsonProcessingException { - return this.buildLPortMirrorCheckRequest(userId, requestId, clliCode, configurationId, interfaceId, - PRE_CHECK_CODE); - } - - protected String buildLPortMirrorCheckPostRequest(String userId, String requestId, Optional clliCode, - String configurationId, String interfaceId) throws JsonProcessingException { - return this.buildLPortMirrorCheckRequest(userId, requestId, clliCode, configurationId, interfaceId, - POST_CHECK_CODE); - } - - protected String buildPortMirrorPreCheckRequest(String userId, String requestId, Optional clliCode, - String configurationId) throws JsonProcessingException { - return this.buildPortMirrorCheckRequest(userId, requestId, clliCode, configurationId, PRE_CHECK_CODE); - } - - protected String buildPortMirrorPostCheckRequest(String userId, String requestId, Optional clliCode, - String configurationId) throws JsonProcessingException { - return this.buildPortMirrorCheckRequest(userId, requestId, clliCode, configurationId, POST_CHECK_CODE); - } - - protected String buildPortMirrorCheckRequest(String userId, String requestId, Optional clliCode, - String configurationId, String diagnosticCode) throws JsonProcessingException { - final AAIParamList list = new AAIParamList(); - list.setKey(CONFIGURATION_ID); - list.setValue(configurationId); - - return this.buildRequest(userId, requestId, clliCode, diagnosticCode, MIRRORING_CHECK, - Collections.singletonList(list)); - } - - protected String buildLPortMirrorCheckRequest(String userId, String requestId, Optional clliCode, - String configurationId, String interfaceId, String diagnosticCode) throws JsonProcessingException { - - final AAIParamList configurationIdParam = new AAIParamList(); - configurationIdParam.setKey(CONFIGURATION_ID); - configurationIdParam.setValue(configurationId); - final AAIParamList interfaceIdParam = new AAIParamList(); - interfaceIdParam.setKey("interface-id"); - interfaceIdParam.setValue(interfaceId); - final List list = new ArrayList<>(); - list.add(configurationIdParam); - list.add(interfaceIdParam); - return this.buildRequest(userId, requestId, clliCode, diagnosticCode, LPORT_MIRRORING_CHECK, list); - } - - - protected String buildRequest(String userId, String requestId, Optional clliCode, String diagnosticCode, - String operationType, List paramList) throws JsonProcessingException { - - final RequestHdCustom hdCustom = new RequestHdCustom(); - hdCustom.withRequestUserId(userId).withRequestId(requestId).withRequestClientName(CLIENT_NAME) - .withHealthDiagnosticCode(diagnosticCode).withOperationType(operationType).withAaiParamList(paramList); - - final Input input = new Input(); - input.setRequestHdCustom(hdCustom); - final Body body = new Body(); - body.setInput(input); - final SDNO request = new SDNO(); - request.withBody(body).withOperation(API_OPERATION_TYPE).withNodeType(NODE_TYPE); - if (clliCode.isPresent()) { - request.setNodeLoc(clliCode.get()); - } - return this.getJson(request); - - } - - protected String getJson(SDNO obj) throws JsonProcessingException { - final ObjectMapper mapper = new ObjectMapper(); - return mapper.writeValueAsString(obj); - } - - protected DmaapPublisher getPublisher() throws FileNotFoundException, IOException { - return new SDNOHealthCheckDmaapPublisher(); - } - - protected DmaapConsumer getConsumer(String requestId) throws FileNotFoundException, IOException { - return new SDNOHealthCheckDmaapConsumer(requestId); - } - - protected boolean execute(String requestId, String request) throws Exception { - final DmaapPublisher publisher = this.getPublisher(); - publisher.send(request); - - final DmaapConsumer consumer = this.getConsumer(requestId); - - return consumer.consume(); - } - -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOValidator.java deleted file mode 100644 index 83624dec63..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOValidator.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.sdno; - -import java.io.IOException; -import java.util.UUID; -import org.onap.aai.domain.yang.GenericVnf; - -public interface SDNOValidator { - - /** - * Issues a health diagnostic request for a given vnf to SDN-O - * - * @param vnfId - * @param uuid - * @param requestingUserId - * @return diagnostic result - * @throws IOException - * @throws Exception - */ - public boolean healthDiagnostic(String vnfId, UUID uuid, String requestingUserId) throws IOException, Exception; - - - /** - * Issues a health diagnostic request for a given GenericVnf to SDN-O - * - * @param genericVnf - * @param uuid - * @param requestingUserId - * @return diagnostic result - * @throws IOException - * @throws Exception - */ - public boolean healthDiagnostic(GenericVnf genericVnf, UUID uuid, String requestingUserId) - throws IOException, Exception; - -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java deleted file mode 100644 index 9fc95a6f3f..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java +++ /dev/null @@ -1,128 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.sdno; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.Optional; -import java.util.UUID; -import javax.ws.rs.NotFoundException; -import org.onap.aai.domain.yang.GenericVnf; -import org.onap.aaiclient.client.aai.AAIObjectType; -import org.onap.aaiclient.client.aai.AAIResourcesClient; -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; -import org.onap.so.client.dmaap.DmaapConsumer; -import org.onap.so.client.dmaap.DmaapPublisher; -import org.onap.so.client.sdno.beans.Body; -import org.onap.so.client.sdno.beans.Input; -import org.onap.so.client.sdno.beans.RequestHealthDiagnostic; -import org.onap.so.client.sdno.beans.SDNO; -import org.onap.so.client.sdno.dmaap.SDNOHealthCheckDmaapConsumer; -import org.onap.so.client.sdno.dmaap.SDNOHealthCheckDmaapPublisher; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class SDNOValidatorImpl implements SDNOValidator { - - private final static String clientName = "MSO"; - private final static String HEALTH_DIAGNOSTIC_CODE_DEFAULT = "default"; - - @Override - public boolean healthDiagnostic(String vnfId, UUID uuid, String requestingUserId) throws IOException, Exception { - - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); - AAIResourcesClient client = new AAIResourcesClient(); - GenericVnf vnf = client.get(GenericVnf.class, uri) - .orElseThrow(() -> new NotFoundException(vnfId + " not found in A&AI")); - - SDNO requestDiagnostic = buildRequestDiagnostic(vnf, uuid, requestingUserId); - ObjectMapper mapper = new ObjectMapper(); - String json = mapper.writeValueAsString(requestDiagnostic); - this.submitRequest(json); - boolean status = this.pollForResponse(uuid.toString()); - return status; - } - - @Override - public boolean healthDiagnostic(GenericVnf genericVnf, UUID uuid, String requestingUserId) - throws IOException, Exception { - - SDNO requestDiagnostic = buildRequestDiagnostic(genericVnf, uuid, requestingUserId); - ObjectMapper mapper = new ObjectMapper(); - String json = mapper.writeValueAsString(requestDiagnostic); - this.submitRequest(json); - boolean status = this.pollForResponse(uuid.toString()); - return status; - } - - protected SDNO buildRequestDiagnostic(GenericVnf vnf, UUID uuid, String requestingUserId) { - - Optional nfRole; - if (vnf.getNfRole() == null) { - nfRole = Optional.empty(); - } else { - nfRole = Optional.of(vnf.getNfRole()); - } - Input input = new Input(); - SDNO parentRequest = new SDNO(); - Body body = new Body(); - parentRequest.setBody(body); - parentRequest.setNodeType(nfRole.orElse("NONE").toUpperCase()); - parentRequest.setOperation("health-diagnostic"); - - body.setInput(input); - - RequestHealthDiagnostic request = new RequestHealthDiagnostic(); - - request.setRequestClientName(clientName); - request.setRequestNodeName(vnf.getVnfName()); - request.setRequestNodeUuid(vnf.getVnfId()); - request.setRequestNodeType(nfRole.orElse("NONE").toUpperCase()); - request.setRequestNodeIp(vnf.getIpv4OamAddress()); // generic-vnf oam ip - request.setRequestUserId(requestingUserId); // mech id? - request.setRequestId(uuid.toString()); // something to identify this request by for polling - request.setHealthDiagnosticCode(HEALTH_DIAGNOSTIC_CODE_DEFAULT); - - input.setRequestHealthDiagnostic(request); - - return parentRequest; - } - - protected void submitRequest(String json) throws FileNotFoundException, IOException, InterruptedException { - - DmaapPublisher publisher = new SDNOHealthCheckDmaapPublisher(); - publisher.send(json); - } - - protected boolean pollForResponse(String uuid) throws Exception { - DmaapConsumer consumer = this.getConsumer(uuid); - return consumer.consume(); - } - - - - protected DmaapConsumer getConsumer(String uuid) throws FileNotFoundException, IOException { - return new SDNOHealthCheckDmaapConsumer(uuid); - } - - - -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/AAIParamList.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/AAIParamList.java deleted file mode 100644 index 7e98355b4d..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/AAIParamList.java +++ /dev/null @@ -1,83 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.sdno.beans; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"key", "value"}) -public class AAIParamList { - - @JsonProperty("key") - private String key; - @JsonProperty("value") - private String value; - - /** - * No args constructor for use in serialization - * - */ - public AAIParamList() {} - - /** - * - * @param value - * @param key - */ - public AAIParamList(String key, String value) { - super(); - this.key = key; - this.value = value; - } - - @JsonProperty("key") - public String getKey() { - return key; - } - - @JsonProperty("key") - public void setKey(String key) { - this.key = key; - } - - public AAIParamList withKey(String key) { - this.key = key; - return this; - } - - @JsonProperty("value") - public String getValue() { - return value; - } - - @JsonProperty("value") - public void setValue(String value) { - this.value = value; - } - - public AAIParamList withValue(String value) { - this.value = value; - return this; - } - -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/Body.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/Body.java deleted file mode 100644 index 8c40b749a6..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/Body.java +++ /dev/null @@ -1,77 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.sdno.beans; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"input"}) -public class Body implements Serializable { - - @JsonProperty("input") - private Input input; - @JsonIgnore - private Map additionalProperties = new HashMap<>(); - private static final long serialVersionUID = 9101706044452851559L; - - @JsonProperty("input") - public Input getInput() { - return input; - } - - @JsonProperty("input") - public void setInput(Input input) { - this.input = input; - } - - public Body withInput(Input input) { - this.input = input; - return this; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - } - - public void setAdditionalProperties(Map map) { - this.additionalProperties = map; - } - - public Body withAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - return this; - } - -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/Input.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/Input.java deleted file mode 100644 index c8122c06f6..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/Input.java +++ /dev/null @@ -1,90 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.sdno.beans; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"request-healthdiagnostic", "request-hd-custom"}) -public class Input implements Serializable { - - @JsonProperty("request-healthdiagnostic") - private RequestHealthDiagnostic RequestHealthDiagnostic; - @JsonProperty("request-hd-custom") - private RequestHdCustom requestHdCustom; - - @JsonIgnore - private Map additionalProperties = new HashMap<>(); - private final static long serialVersionUID = 7155546785389227528L; - - @JsonProperty("request-healthdiagnostic") - public RequestHealthDiagnostic getRequestHealthDiagnostic() { - return RequestHealthDiagnostic; - } - - @JsonProperty("request-healthdiagnostic") - public void setRequestHealthDiagnostic(RequestHealthDiagnostic RequestHealthDiagnostic) { - this.RequestHealthDiagnostic = RequestHealthDiagnostic; - } - - @JsonProperty("request-hd-custom") - public RequestHdCustom getRequestHdCustom() { - return requestHdCustom; - } - - @JsonProperty("request-hd-custom") - public void setRequestHdCustom(RequestHdCustom requestHdCustom) { - this.requestHdCustom = requestHdCustom; - } - - public Input withRequestHealthDiagnostic(RequestHealthDiagnostic RequestHealthDiagnostic) { - this.RequestHealthDiagnostic = RequestHealthDiagnostic; - return this; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - } - - public void setAdditionalProperties(Map map) { - this.additionalProperties = map; - } - - public Input withAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - return this; - } - -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/RequestHdCustom.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/RequestHdCustom.java deleted file mode 100644 index 485f64673f..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/RequestHdCustom.java +++ /dev/null @@ -1,183 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.sdno.beans; - -import java.io.Serializable; -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({"request-client-name", "request-user-id", "request-id", "health-diagnostic-code", "operation-type", - "send-detailed-cmd-response", "aai-param-list"}) -public class RequestHdCustom implements Serializable { - - /** - * - */ - private static final long serialVersionUID = -206110458275127710L; - @JsonProperty("request-client-name") - private String requestClientName; - @JsonProperty("request-user-id") - private String requestUserId; - @JsonProperty("request-id") - private String requestId; - @JsonProperty("health-diagnostic-code") - private String healthDiagnosticCode; - @JsonProperty("operation-type") - private String operationType; - @JsonProperty("send-detailed-cmd-response") - private String sendDetailedCmdResponse = "false"; - @JsonProperty("aai-param-list") - private List aaiParamList = new ArrayList<>(); - - /** - * No args constructor for use in serialization - * - */ - public RequestHdCustom() {} - - /** - * - * @param requestClientName - * @param operationType - * @param requestId - * @param healthDiagnosticCode - * @param aaiParamList - * @param requestUserId - */ - public RequestHdCustom(String requestClientName, String requestUserId, String requestId, - String healthDiagnosticCode, String operationType, List aaiParamList) { - super(); - this.requestClientName = requestClientName; - this.requestUserId = requestUserId; - this.requestId = requestId; - this.healthDiagnosticCode = healthDiagnosticCode; - this.operationType = operationType; - this.aaiParamList = aaiParamList; - } - - @JsonProperty("request-client-name") - public String getRequestClientName() { - return requestClientName; - } - - @JsonProperty("request-client-name") - public void setRequestClientName(String requestClientName) { - this.requestClientName = requestClientName; - } - - public RequestHdCustom withRequestClientName(String requestClientName) { - this.requestClientName = requestClientName; - return this; - } - - @JsonProperty("request-user-id") - public String getRequestUserId() { - return requestUserId; - } - - @JsonProperty("request-user-id") - public void setRequestUserId(String requestUserId) { - this.requestUserId = requestUserId; - } - - public RequestHdCustom withRequestUserId(String requestUserId) { - this.requestUserId = requestUserId; - return this; - } - - @JsonProperty("request-id") - public String getRequestId() { - return requestId; - } - - @JsonProperty("request-id") - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public RequestHdCustom withRequestId(String requestId) { - this.requestId = requestId; - return this; - } - - @JsonProperty("health-diagnostic-code") - public String getHealthDiagnosticCode() { - return healthDiagnosticCode; - } - - @JsonProperty("health-diagnostic-code") - public void setHealthDiagnosticCode(String healthDiagnosticCode) { - this.healthDiagnosticCode = healthDiagnosticCode; - } - - public RequestHdCustom withHealthDiagnosticCode(String healthDiagnosticCode) { - this.healthDiagnosticCode = healthDiagnosticCode; - return this; - } - - @JsonProperty("operation-type") - public String getOperationType() { - return operationType; - } - - @JsonProperty("operation-type") - public void setOperationType(String operationType) { - this.operationType = operationType; - } - - public RequestHdCustom withOperationType(String operationType) { - this.operationType = operationType; - return this; - } - - public void setSendDetailedCmdResponse(String sendDetailedCmdResponse) { - this.sendDetailedCmdResponse = sendDetailedCmdResponse; - } - - public String getSendDetailedCmdResponse() { - return sendDetailedCmdResponse; - } - - public RequestHdCustom withSendDetailedCmdResponse(String sendDetailedCmdResponse) { - this.sendDetailedCmdResponse = sendDetailedCmdResponse; - return this; - } - - @JsonProperty("aai-param-list") - public List getAaiParamList() { - return aaiParamList; - } - - @JsonProperty("aai-param-list") - public void setAaiParamList(List aaiParamList) { - this.aaiParamList = aaiParamList; - } - - public RequestHdCustom withAaiParamList(List aaiParamList) { - this.aaiParamList = aaiParamList; - return this; - } - -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/RequestHealthDiagnostic.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/RequestHealthDiagnostic.java deleted file mode 100644 index b1b75ab412..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/RequestHealthDiagnostic.java +++ /dev/null @@ -1,197 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.sdno.beans; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"request-client-name", "request-node-name", "request-node-uuid", "request-node-ip", "request-id", - "request-user-id", "request-node-type", "health-diagnostic-code"}) -public class RequestHealthDiagnostic implements Serializable { - - @JsonProperty("request-client-name") - private String requestClientName; - @JsonProperty("request-node-name") - private String requestNodeName; - @JsonProperty("request-node-uuid") - private String requestNodeUuid; - @JsonProperty("request-node-ip") - private String requestNodeIp; - @JsonProperty("request-id") - private String requestId; - @JsonProperty("request-user-id") - private String requestUserId; - @JsonProperty("request-node-type") - private String requestNodeType; - @JsonProperty("health-diagnostic-code") - private String healthDiagnosticCode; - @JsonIgnore - private Map additionalProperties = new HashMap<>(); - private static final long serialVersionUID = 1166788526178388021L; - - @JsonProperty("request-client-name") - public String getRequestClientName() { - return requestClientName; - } - - @JsonProperty("request-client-name") - public void setRequestClientName(String requestClientName) { - this.requestClientName = requestClientName; - } - - public RequestHealthDiagnostic withRequestClientName(String requestClientName) { - this.requestClientName = requestClientName; - return this; - } - - @JsonProperty("request-node-name") - public String getRequestNodeName() { - return requestNodeName; - } - - @JsonProperty("request-node-name") - public void setRequestNodeName(String requestNodeName) { - this.requestNodeName = requestNodeName; - } - - public RequestHealthDiagnostic withRequestNodeName(String requestNodeName) { - this.requestNodeName = requestNodeName; - return this; - } - - @JsonProperty("request-node-uuid") - public String getRequestNodeUuid() { - return requestNodeUuid; - } - - @JsonProperty("request-node-uuid") - public void setRequestNodeUuid(String requestNodeUuid) { - this.requestNodeUuid = requestNodeUuid; - } - - public RequestHealthDiagnostic withRequestNodeUuid(String requestNodeUuid) { - this.requestNodeUuid = requestNodeUuid; - return this; - } - - @JsonProperty("request-node-ip") - public String getRequestNodeIp() { - return requestNodeIp; - } - - @JsonProperty("request-node-ip") - public void setRequestNodeIp(String requestNodeIp) { - this.requestNodeIp = requestNodeIp; - } - - public RequestHealthDiagnostic withRequestNodeIp(String requestNodeIp) { - this.requestNodeIp = requestNodeIp; - return this; - } - - @JsonProperty("request-id") - public String getRequestId() { - return requestId; - } - - @JsonProperty("request-id") - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public RequestHealthDiagnostic withRequestId(String requestId) { - this.requestId = requestId; - return this; - } - - @JsonProperty("request-user-id") - public String getRequestUserId() { - return requestUserId; - } - - @JsonProperty("request-user-id") - public void setRequestUserId(String requestUserId) { - this.requestUserId = requestUserId; - } - - public RequestHealthDiagnostic withRequestUserId(String requestUserId) { - this.requestUserId = requestUserId; - return this; - } - - @JsonProperty("request-node-type") - public String getRequestNodeType() { - return requestNodeType; - } - - @JsonProperty("request-node-type") - public void setRequestNodeType(String requestNodeType) { - this.requestNodeType = requestNodeType; - } - - public RequestHealthDiagnostic withRequestNodeType(String requestNodeType) { - this.requestNodeType = requestNodeType; - return this; - } - - @JsonProperty("health-diagnostic-code") - public String getHealthDiagnosticCode() { - return healthDiagnosticCode; - } - - @JsonProperty("health-diagnostic-code") - public void setHealthDiagnosticCode(String healthDiagnosticCode) { - this.healthDiagnosticCode = healthDiagnosticCode; - } - - public RequestHealthDiagnostic withHealthDiagnosticCode(String healthDiagnosticCode) { - this.healthDiagnosticCode = healthDiagnosticCode; - return this; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - } - - public void setAdditionalProperties(Map map) { - this.additionalProperties = map; - } - - public RequestHealthDiagnostic withAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - return this; - } - -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/ResultInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/ResultInfo.java deleted file mode 100644 index 8b84cf6659..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/ResultInfo.java +++ /dev/null @@ -1,112 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.sdno.beans; - -import java.util.HashMap; -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"client-name", "code", "processing-host", "request-id", "status"}) -public class ResultInfo { - - @JsonProperty("client-name") - private String clientName; - @JsonProperty("code") - private String code; - @JsonProperty("processing-host") - private String processingHost; - @JsonProperty("request-id") - private String requestId; - @JsonProperty("status") - private String status; - @JsonIgnore - private Map additionalProperties = new HashMap<>(); - - @JsonProperty("client-name") - public String getClientName() { - return clientName; - } - - @JsonProperty("client-name") - public void setClientName(String clientName) { - this.clientName = clientName; - } - - @JsonProperty("code") - public String getCode() { - return code; - } - - @JsonProperty("code") - public void setCode(String code) { - this.code = code; - } - - @JsonProperty("processing-host") - public String getProcessingHost() { - return processingHost; - } - - @JsonProperty("processing-host") - public void setProcessingHost(String processingHost) { - this.processingHost = processingHost; - } - - @JsonProperty("request-id") - public String getRequestId() { - return requestId; - } - - @JsonProperty("request-id") - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - @JsonProperty("status") - public String getStatus() { - return status; - } - - @JsonProperty("status") - public void setStatus(String status) { - this.status = status; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - } - - public void setAdditionalProperties(Map map) { - this.additionalProperties = map; - } -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/SDNO.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/SDNO.java deleted file mode 100644 index 46e2c1d1fc..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/SDNO.java +++ /dev/null @@ -1,128 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.sdno.beans; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"operation", "nodeLoc", "nodeType", "body"}) -public class SDNO implements Serializable { - - @JsonProperty("operation") - private String operation; - @JsonProperty("nodeLoc") - private String nodeLoc; - @JsonProperty("nodeType") - private String nodeType; - @JsonProperty("body") - private Body body; - @JsonIgnore - private Map additionalProperties = new HashMap<>(); - private static final long serialVersionUID = -5303297382564282650L; - - @JsonProperty("operation") - public String getOperation() { - return operation; - } - - @JsonProperty("operation") - public void setOperation(String operation) { - this.operation = operation; - } - - @JsonProperty("nodeLoc") - public String getNodeLoc() { - return nodeLoc; - } - - @JsonProperty("nodeLoc") - public void setNodeLoc(String nodeLoc) { - this.nodeLoc = nodeLoc; - } - - public SDNO withNodeLoc(String nodeLoc) { - this.nodeLoc = nodeLoc; - return this; - } - - public SDNO withOperation(String operation) { - this.operation = operation; - return this; - } - - @JsonProperty("nodeType") - public String getNodeType() { - return nodeType; - } - - @JsonProperty("nodeType") - public void setNodeType(String nodeType) { - this.nodeType = nodeType; - } - - public SDNO withNodeType(String nodeType) { - this.nodeType = nodeType; - return this; - } - - @JsonProperty("body") - public Body getBody() { - return body; - } - - @JsonProperty("body") - public void setBody(Body body) { - this.body = body; - } - - public SDNO withBody(Body body) { - this.body = body; - return this; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - } - - public void setAdditionalProperties(Map map) { - this.additionalProperties = map; - } - - public SDNO SDNO(String name, Object value) { - this.additionalProperties.put(name, value); - return this; - } - -} -- cgit 1.2.3-korg