diff options
author | Dan Timoney <dtimoney@att.com> | 2021-04-23 13:02:22 -0400 |
---|---|---|
committer | Dan Timoney <dtimoney@att.com> | 2021-04-23 15:48:50 -0400 |
commit | bf2bea4aaee161d82c8093f8b723f0fd9b57a115 (patch) | |
tree | 0f784c234b444f0479dad7b3eb6fb3c1e502cd6d /ms/generic-resource-api/src/main/java/org/onap | |
parent | 5c4184f9312d00166dea77b5a16ae400c669f473 (diff) |
Refactor GRA to separate docker creation from application code
Refactor GRA so that application jar is created in a separate
maven module from the docker build.
Issue-ID: SDNC-1527
Change-Id: I4a9af7fe4df14faaf683588bc2567fcc3346886e
Signed-off-by: Dan Timoney <dtimoney@att.com>
Diffstat (limited to 'ms/generic-resource-api/src/main/java/org/onap')
32 files changed, 0 insertions, 6660 deletions
diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/FilterConfiguration.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/FilterConfiguration.java deleted file mode 100644 index 6b96541..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/FilterConfiguration.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.onap.sdnc.apps.ms.gra;
-
-import org.onap.aaf.cadi.filter.CadiFilter;
-import org.onap.ccsdk.apps.filters.ContentTypeFilter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.boot.web.servlet.FilterRegistrationBean;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.core.annotation.Order;
-
-@Configuration
-public class FilterConfiguration {
-
- private static final Logger log = LoggerFactory.getLogger(FilterConfiguration.class);
-
- @Bean
- @Order(1)
- public FilterRegistrationBean<CadiFilter> cadiFilter() {
- CadiFilter filter = new CadiFilter();
-
- FilterRegistrationBean<CadiFilter> registrationBean = new FilterRegistrationBean<>();
- registrationBean.setFilter(filter);
- if ("none".equals(System.getProperty("cadi_prop_files", "none"))) {
- log.info("cadi_prop_files undefined, AAF CADI disabled");
- registrationBean.addUrlPatterns("/xxxx/*");
- } else {
- registrationBean.addUrlPatterns("/*");
- registrationBean.addInitParameter("cadi_prop_files", System.getProperty("cadi_prop_files"));
- }
-
- return registrationBean;
- }
-
-}
diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/GenericResourceMsApp.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/GenericResourceMsApp.java deleted file mode 100644 index d436d21..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/GenericResourceMsApp.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SDNC - * ================================================================================ - * Copyright (C) 2020 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.sdnc.apps.ms.gra; - -import org.onap.ccsdk.apps.ms.sliboot.controllers.RestconfApiController; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.context.annotation.Import; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -@SpringBootApplication(scanBasePackages = { "org.onap.sdnc.apps.ms.gra", "org.onap.ccsdk.apps.services" }) -@EnableJpaRepositories(basePackages = { "org.onap.sdnc.apps.ms.gra", "org.onap.ccsdk.apps.ms.sliboot" }) -@EntityScan(basePackages = { "org.onap.sdnc.apps.ms.gra", "org.onap.ccsdk.apps.ms.sliboot" }) -@EnableTransactionManagement -@Import(RestconfApiController.class) -@EnableSwagger2 - -public class GenericResourceMsApp { - - private static final Logger log = LoggerFactory.getLogger(GenericResourceMsApp.class); - - public static void main(String[] args) throws Exception { - SpringApplication.run(GenericResourceMsApp.class, args); - } -} diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiController.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiController.java deleted file mode 100644 index 7508eb8..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiController.java +++ /dev/null @@ -1,1969 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SDNC - * ================================================================================ - * Copyright (C) 2020 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.sdnc.apps.ms.gra.controllers; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Optional; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -import org.onap.ccsdk.apps.services.RestApplicationException; -import org.onap.ccsdk.apps.services.RestException; -import org.onap.ccsdk.apps.services.RestProtocolException; -import org.onap.sdnc.apps.ms.gra.controllers.ServiceDataHelper.ServiceDataTransaction; -import org.onap.sdnc.apps.ms.gra.data.ConfigContrailRouteAllottedResources; -import org.onap.sdnc.apps.ms.gra.data.ConfigContrailRouteAllottedResourcesRepository; -import org.onap.sdnc.apps.ms.gra.data.ConfigNetworksRepository; -import org.onap.sdnc.apps.ms.gra.data.ConfigPortMirrorConfigurations; -import org.onap.sdnc.apps.ms.gra.data.ConfigPortMirrorConfigurationsRepository; -import org.onap.sdnc.apps.ms.gra.data.ConfigPreloadData; -import org.onap.sdnc.apps.ms.gra.data.ConfigPreloadDataRepository; -import org.onap.sdnc.apps.ms.gra.data.ConfigServices; -import org.onap.sdnc.apps.ms.gra.data.ConfigServicesRepository; -import org.onap.sdnc.apps.ms.gra.data.ConfigVfModules; -import org.onap.sdnc.apps.ms.gra.data.ConfigVfModulesRepository; -import org.onap.sdnc.apps.ms.gra.data.ConfigVnfsRepository; -import org.onap.sdnc.apps.ms.gra.swagger.ConfigApi; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiContrailrouteallottedresourcesContrailRouteAllottedResource; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiContrailrouteallottedresourcesContrailrouteallottedresourceAllottedResourceData; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiContrailroutetopologyContrailRouteTopology; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiOnapmodelinformationOnapModelInformation; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiOperStatusData; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiPortmirrorconfigurationsPortMirrorConfiguration; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiPortmirrorconfigurationsPortmirrorconfigurationConfigurationData; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiPortmirrorconfigurationtopologyPortMirrorConfigurationTopology; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiPreloadModelInformation; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiPreloaddataPreloadData; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiPreloadmodelinformationPreloadList; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiPreloadnetworktopologyinformationPreloadNetworkTopologyInformation; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiServiceModelInfrastructure; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiServicedataServiceData; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiServicedataServicedataVnfsVnf; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiServicedataServicedataVnfsVnfVnfData; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiServicedataServicedataVnfsVnfVnfdataVfmodulesVfModule; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiServicemodelinfrastructureService; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiServicestatusServiceStatus; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiServicetopologyServiceTopology; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiVfmoduletopologyVfModuleTopology; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiVnfNetworkData; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiVnfresourceassignmentsVnfResourceAssignments; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiVnfresourceassignmentsVnfresourceassignmentsVnfNetworks; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiVnftopologyVnfTopology; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; - -@Controller -@ComponentScan(basePackages = { "org.onap.sdnc.apps.ms.gra.*" }) -@EntityScan("org.onap.sdnc.apps.ms.gra.springboot.*") -public class ConfigApiController implements ConfigApi { - private static final Logger log = LoggerFactory.getLogger(ConfigApiController.class); - - private final ObjectMapper objectMapper; - - private final HttpServletRequest request; - - @Autowired - private ConfigPreloadDataRepository configPreloadDataRepository; - - @Autowired - private ConfigServicesRepository configServicesRepository; - - @Autowired - private ConfigNetworksRepository configNetworksRepository; - - @Autowired - private ConfigVnfsRepository configVnfsRepository; - - @Autowired - private ConfigVfModulesRepository configVfModulesRepository; - - @Autowired - private ConfigPortMirrorConfigurationsRepository configPortMirrorConfigurationsRepository; - - @Autowired - private ConfigContrailRouteAllottedResourcesRepository configContrailRouteAllottedResourcesRepository; - - @Autowired - private ServiceDataHelper serviceDataHelper; - - @Autowired - public ConfigApiController(ObjectMapper objectMapper, HttpServletRequest request) { - objectMapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); - objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - this.objectMapper = objectMapper; - this.request = request; - } - - @Override - public Optional<ObjectMapper> getObjectMapper() { - return Optional.ofNullable(objectMapper); - } - - @Override - public Optional<HttpServletRequest> getRequest() { - return Optional.ofNullable(request); - } - - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIpreloadInformationDelete() { - configPreloadDataRepository.deleteAll(); - return (new ResponseEntity<>(HttpStatus.NO_CONTENT)); - } - - /** - * Extracts port-mirror configuration data from CONFIG_GRA_PORT_MIRROR_CONFIGURATIONS for a given, configuration-id - * <p> - * Maps to /config/GENERIC-RESOURCE-API:port-mirror-configurations/port-mirror-configuration/{configuration-id}/ - * @param configurationId the configuration ID for a port-mirror - * @return HttpStatus.OK (200) if the data is found. - * @throws RestException if the data does not exist. - */ - public ResponseEntity<GenericResourceApiPortmirrorconfigurationsPortMirrorConfiguration> - configGENERICRESOURCEAPIportMirrorConfigurationsPortMirrorConfigurationConfigurationIdGet( - String configurationId) throws RestApplicationException { - GenericResourceApiPortmirrorconfigurationsPortMirrorConfiguration retval = null; - - List<ConfigPortMirrorConfigurations> pmConfigurations = configPortMirrorConfigurationsRepository.findByConfigurationId(configurationId); - - if (pmConfigurations.isEmpty()) { - log.info("No configuration data found with id [{}]",configurationId); - throw new RestApplicationException("data-missing", - "Request could not be completed because the relevant data model content does not exist", - HttpStatus.NOT_FOUND.value()); - } else { - ConfigPortMirrorConfigurations pmConfiguration = pmConfigurations.get(0); - retval = new GenericResourceApiPortmirrorconfigurationsPortMirrorConfiguration(); - retval.setConfigurationId(configurationId); - retval.setConfigurationStatus(pmConfiguration.getPortMirrorConfigurationStatus()); - try { - retval.setConfigurationData(objectMapper.readValue(pmConfiguration.getPmcData(), GenericResourceApiPortmirrorconfigurationsPortmirrorconfigurationConfigurationData.class)); - } catch (JsonProcessingException e) { - log.error("Could not deserialize service data for service instance id {}", configurationId, e); - throw new RestApplicationException("data-conversion", "Request could not be completed due to internal error", e, HttpStatus.INTERNAL_SERVER_ERROR.value()); - } - } - return new ResponseEntity<>(retval, HttpStatus.OK); - } - - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIportMirrorConfigurationsPortMirrorConfigurationConfigurationIdPut( - String configurationId, @Valid GenericResourceApiPortmirrorconfigurationsPortMirrorConfiguration newConfiguration) - throws RestApplicationException { - - boolean dataExists = false; - - String newConfigurationId = newConfiguration.getConfigurationId(); - - ConfigPortMirrorConfigurations portMirrorConfiguration = null; - List<ConfigPortMirrorConfigurations> existingConfiguration = configPortMirrorConfigurationsRepository.findByConfigurationId(configurationId); - if ((existingConfiguration != null) && !existingConfiguration.isEmpty()) { - dataExists = true; - portMirrorConfiguration = existingConfiguration.get(0); - } else { - portMirrorConfiguration = new ConfigPortMirrorConfigurations(); - portMirrorConfiguration.setConfigureationId(configurationId); - } - - try { - portMirrorConfiguration.setPmcData(objectMapper.writeValueAsString(newConfiguration.getConfigurationData())); - } catch (JsonProcessingException e) { - log.error("Could not serialize porr-mirror configuration data for {}", portMirrorConfiguration.getConfigureationId(), e); - throw new RestApplicationException("data-conversion", "Request could not be completed due to internal error", e, HttpStatus.INTERNAL_SERVER_ERROR.value()); - - } - portMirrorConfiguration.setPortMirrorConfigurationStatus(newConfiguration.getConfigurationStatus()); - configPortMirrorConfigurationsRepository.save(portMirrorConfiguration); - - if (dataExists) { - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } else { - return new ResponseEntity<>(HttpStatus.CREATED); - } - } - - @Override - public ResponseEntity<GenericResourceApiPortmirrorconfigurationtopologyPortMirrorConfigurationTopology> - configGENERICRESOURCEAPIportMirrorConfigurationsPortMirrorConfigurationConfigurationIdConfigurationDataPortMirrorConfigurationTopologyGet( - String configurationId) throws RestApplicationException, RestProtocolException { - @Valid GenericResourceApiPortmirrorconfigurationtopologyPortMirrorConfigurationTopology portMirrorConfigurationTopology = null; - GenericResourceApiPortmirrorconfigurationsPortmirrorconfigurationConfigurationData portMirrorConfigurationData = null; - - List<ConfigPortMirrorConfigurations> configPortMirrorConfigurations = configPortMirrorConfigurationsRepository.findByConfigurationId(configurationId); - if ((configPortMirrorConfigurations == null) || (configPortMirrorConfigurations.isEmpty())) { - log.info("No configuration data found with id [{}]", configurationId); - throw new RestApplicationException("data-missing", - "Request could not be completed because the relevant data model content does not exist", - HttpStatus.NOT_FOUND.value()); - } - - try { - if ( configPortMirrorConfigurations.get(0).getPmcData().isEmpty()) { - throw new RestProtocolException("data-missing", "No configuration-data entry found", HttpStatus.NOT_FOUND.value()); - } else { - portMirrorConfigurationData = objectMapper.readValue(configPortMirrorConfigurations.get(0).getPmcData(), GenericResourceApiPortmirrorconfigurationsPortmirrorconfigurationConfigurationData.class); - portMirrorConfigurationTopology = portMirrorConfigurationData.getPortMirrorConfigurationTopology(); - } - if (portMirrorConfigurationTopology == null) { - throw new RestProtocolException("data-missing", "No service-topology entry found", HttpStatus.NOT_FOUND.value()); - } - return new ResponseEntity<>(portMirrorConfigurationTopology, HttpStatus.OK); - } catch (JsonProcessingException e) { - log.error("Could not parse service data", e); - throw new RestApplicationException("data-conversion", "Request could not be completed due to internal error", e, HttpStatus.INTERNAL_SERVER_ERROR.value()); - } - } - - - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIportMirrorConfigurationsPortMirrorConfigurationConfigurationIdDelete(String configurationId) { - configPortMirrorConfigurationsRepository.deleteByConfigurationId(configurationId); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } - - /** - * Extracts contrail-route-allotted-resource data from CONFIG_GRA_CONTRAIL_ROUTE_ALLOTTED_RESOURCES for a given allottedResourceId - * <p> - * Maps to /config/GENERIC-RESOURCE-API:contrail-route-allotted-resources/contrail-route-allotted-resource/{allotted-resource-id} - * @param allottedResourceId the allotted-resource-id for a contrail-route - * @return HttpStatus.OK (200) if the data is found. - * @throws RestException if the data does not exist. - */ - public ResponseEntity<GenericResourceApiContrailrouteallottedresourcesContrailRouteAllottedResource> - configGENERICRESOURCEAPIcontrailRouteAllottedResourcesContrailRouteAllottedResourceAllottedResourceIdGet( - String allottedResourceId) throws RestApplicationException { - GenericResourceApiContrailrouteallottedresourcesContrailRouteAllottedResource retval = null; - - List<ConfigContrailRouteAllottedResources> allottedResources = configContrailRouteAllottedResourcesRepository.findByAllottedResourceId(allottedResourceId); - - if (allottedResources.isEmpty()) { - log.info("No contrail-route-allotted-resource found with id [{}]", allottedResourceId); - throw new RestApplicationException("data-missing", - "Request could not be completed because the relevant data model content does not exist", - HttpStatus.NOT_FOUND.value()); - } - else { - ConfigContrailRouteAllottedResources allottedResource = allottedResources.get(0); - retval = new GenericResourceApiContrailrouteallottedresourcesContrailRouteAllottedResource(); - retval.setAllottedResourceId(allottedResourceId); - retval.setAllottedResourceStatus(allottedResource.getAllottedResourceStatus()); - try { - retval.setAllottedResourceData(objectMapper.readValue(allottedResource.getArData(), - GenericResourceApiContrailrouteallottedresourcesContrailrouteallottedresourceAllottedResourceData.class)); - } catch (JsonProcessingException e) { - log.error("Could not deserialize service data for service instance id {}", allottedResourceId, e); - throw new RestApplicationException("data-conversion", "Request could not be completed due to internal error", e, HttpStatus.INTERNAL_SERVER_ERROR.value()); - } - } - return new ResponseEntity<>(retval, HttpStatus.OK); - } - - /** - * PUT contrail-route-allotted-resource data from CONFIG_GRA_CONTRAIL_ROUTE_ALLOTTED_RESOURCES for a given allottedResourceId - * <p> - * Maps to /config/GENERIC-RESOURCE-API:contrail-route-allotted-resources/contrail-route-allotted-resource/{allotted-resource-id} - * @param allottedResourceId the allotted-resource-id for a contrail-route - * @return HttpStatus.OK (200) if the data is found. - * @throws RestException if the data does not exist. - */ - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIcontrailRouteAllottedResourcesContrailRouteAllottedResourceAllottedResourceIdPut( - String allottedResourceId, @Valid GenericResourceApiContrailrouteallottedresourcesContrailRouteAllottedResource newAllottedResource) - throws RestApplicationException { - - boolean dataExists = false; - - String newAllottedResourceId = newAllottedResource.getAllottedResourceId(); - - ConfigContrailRouteAllottedResources allottedResource = null; - List<ConfigContrailRouteAllottedResources> existingAllottedResource = - configContrailRouteAllottedResourcesRepository.findByAllottedResourceId(allottedResourceId); - - if ((existingAllottedResource != null) && !existingAllottedResource.isEmpty()) { - dataExists = true; - allottedResource = existingAllottedResource.get(0); - } else { - allottedResource = new ConfigContrailRouteAllottedResources(); - allottedResource.setAllottedResourceId(allottedResourceId); - } - - try { - allottedResource.setArData(objectMapper.writeValueAsString(newAllottedResource.getAllottedResourceData())); - } catch (JsonProcessingException e) { - log.error("Could not serialize porr-mirror configuration data for {}", allottedResource.getAllottedResourceId(), e); - throw new RestApplicationException("data-conversion", "Request could not be completed due to internal error", e, HttpStatus.INTERNAL_SERVER_ERROR.value()); - - } - allottedResource.setAllottedResourceStatus(newAllottedResource.getAllottedResourceStatus()); - configContrailRouteAllottedResourcesRepository.save(allottedResource); - - if (dataExists) { - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } else { - return new ResponseEntity<>(HttpStatus.CREATED); - } - } - - /** - * Extracts contrail-route-topology data from CONFIG_GRA_CONTRAIL_ROUTE_ALLOTTED_RESOURCES for a given allottedResourceId - * <p> - * Maps to /config/GENERIC-RESOURCE-API:contrail-route-allotted-resources/contrail-route-allotted-resource/{allotted-resource-id}/allotted-resource-data/contrail-route-topology/ - * @param allottedResourceId the allotted-resource-id for a contrail-route - * @return HttpStatus.OK (200) if the data is found. - * @throws RestException if the data does not exist. - */ - @Override - public ResponseEntity<GenericResourceApiContrailroutetopologyContrailRouteTopology> - configGENERICRESOURCEAPIcontrailRouteAllottedResourcesContrailRouteAllottedResourceAllottedResourceIdAllottedResourceDataContrailRouteTopologyGet( - String allottedResourceId) throws RestApplicationException, RestProtocolException { - @Valid GenericResourceApiContrailroutetopologyContrailRouteTopology contrailRouteTopology = null; - GenericResourceApiContrailrouteallottedresourcesContrailrouteallottedresourceAllottedResourceData allottedResourceData = null; - - List<ConfigContrailRouteAllottedResources> configContrailRouteAllottedResources = - configContrailRouteAllottedResourcesRepository.findByAllottedResourceId(allottedResourceId); - - if ((configContrailRouteAllottedResources == null) || (configContrailRouteAllottedResources.isEmpty())) { - log.info("No contrail-route-allotted-resoure data found with id [{}]", allottedResourceId); - throw new RestApplicationException("data-missing", - "Request could not be completed because the relevant data model content does not exist", - HttpStatus.NOT_FOUND.value()); - } - - try { - if ( configContrailRouteAllottedResources.get(0).getArData().isEmpty()) { - throw new RestProtocolException("data-missing", "No allotted-resource-data entry found", HttpStatus.NOT_FOUND.value()); - } else { - allottedResourceData = objectMapper.readValue(configContrailRouteAllottedResources.get(0).getArData(), - GenericResourceApiContrailrouteallottedresourcesContrailrouteallottedresourceAllottedResourceData.class); - - contrailRouteTopology = allottedResourceData.getContrailRouteTopology(); - } - if (contrailRouteTopology == null) { - throw new RestProtocolException("data-missing", "No contrail-route-topology entry found", HttpStatus.NOT_FOUND.value()); - } - return new ResponseEntity<>(contrailRouteTopology, HttpStatus.OK); - } catch (JsonProcessingException e) { - log.error("Could not parse port-mirror-configuration data", e); - throw new RestApplicationException("data-conversion", "Request could not be completed due to internal error", e, HttpStatus.INTERNAL_SERVER_ERROR.value()); - } - } - - - /** - * DELETE allotted-resource data from CONFIG_GRA_CONTRAIL_ROUTE_ALLOTTED_RESOURCES for a given allottedResourceId - * <p> - * Maps to /config/GENERIC-RESOURCE-API:contrail-route-allotted-resources/contrail-route-allotted-resource/{allotted-resource-id} - * @param allottedResourceId the allotted-resource-id for a contrail-route - * @return HttpStatus.NO_CONTENT (204) if the data is found. - */ - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIcontrailRouteAllottedResourcesContrailRouteAllottedResourceAllottedResourceIdDelete( - String allottedResourceId) { - configContrailRouteAllottedResourcesRepository.deleteByAllottedResourceId(allottedResourceId); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } - - - @Override - public ResponseEntity<GenericResourceApiPreloadModelInformation> configGENERICRESOURCEAPIpreloadInformationGet() - throws RestApplicationException { - GenericResourceApiPreloadModelInformation genericResourceApiPreloadModelInformation = new GenericResourceApiPreloadModelInformation(); - - if (configPreloadDataRepository.count() == 0) { - throw new RestApplicationException("data-missing", - "Request could not be completed because the relevant data model content does not exist", - HttpStatus.NOT_FOUND.value()); - } - - for (ConfigPreloadData configPreloadData : configPreloadDataRepository.findAll()) { - GenericResourceApiPreloadmodelinformationPreloadList preloadListItem = new GenericResourceApiPreloadmodelinformationPreloadList(); - - preloadListItem.setPreloadId(configPreloadData.getPreloadId()); - preloadListItem.setPreloadType(configPreloadData.getPreloadType()); - try { - preloadListItem.setPreloadData(objectMapper.readValue(configPreloadData.getPreloadData(), - GenericResourceApiPreloaddataPreloadData.class)); - } catch (JsonProcessingException e) { - log.error("Could not convert preload data", e); - throw new RestApplicationException("data-conversion", - "Request could not be completed due to internal error", e, - HttpStatus.INTERNAL_SERVER_ERROR.value()); - } - genericResourceApiPreloadModelInformation.addPreloadListItem(preloadListItem); - } - - return new ResponseEntity<>(genericResourceApiPreloadModelInformation, HttpStatus.OK); - } - - @Override - public ResponseEntity<GenericResourceApiPreloadnetworktopologyinformationPreloadNetworkTopologyInformation> configGENERICRESOURCEAPIpreloadInformationPreloadListPreloadIdPreloadTypePreloadDataPreloadNetworkTopologyInformationGet( - String preloadId, String preloadType) throws RestException { - GenericResourceApiPreloadnetworktopologyinformationPreloadNetworkTopologyInformation netTopoInfo = null; - - if (configPreloadDataRepository.count() == 0) { - throw new RestApplicationException("data-missing", - "Request could not be completed because the relevant data model content does not exist", - HttpStatus.NOT_FOUND.value()); - } - - for (ConfigPreloadData configPreloadData : configPreloadDataRepository.findAll()) { - - try { - GenericResourceApiPreloaddataPreloadData preloadDataItem = objectMapper - .readValue(configPreloadData.getPreloadData(), GenericResourceApiPreloaddataPreloadData.class); - netTopoInfo = preloadDataItem.getPreloadNetworkTopologyInformation(); - } catch (JsonProcessingException e) { - log.error("Could not convert preload data", e); - throw new RestApplicationException("data-conversion", - "Request could not be completed due to internal error", e, - HttpStatus.INTERNAL_SERVER_ERROR.value()); - } - } - - return new ResponseEntity<>(netTopoInfo, HttpStatus.OK); - } - - - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIpreloadInformationPost( - @Valid GenericResourceApiPreloadModelInformation graPreloadModelInfo) - throws RestApplicationException, RestProtocolException { - - List<GenericResourceApiPreloadmodelinformationPreloadList> preloadList = graPreloadModelInfo.getPreloadList(); - List<ConfigPreloadData> newPreloadData = new LinkedList<>(); - - if (preloadList != null) { - // Verification pass - if any items already exist, return an error - for (GenericResourceApiPreloadmodelinformationPreloadList curItem : preloadList) { - - List<ConfigPreloadData> curPreloadData = configPreloadDataRepository - .findByPreloadIdAndPreloadType(curItem.getPreloadId(), curItem.getPreloadType()); - if ((curPreloadData != null) && (!curPreloadData.isEmpty())) { - log.error("Preload data already exists for {}:{}", curItem.getPreloadId(), - curItem.getPreloadType()); - throw new RestProtocolException("data-exists", - "Data already exists for " + curItem.getPreloadId() + ":" + curItem.getPreloadType(), - HttpStatus.CONFLICT.value()); - } else { - try { - newPreloadData.add(new ConfigPreloadData(curItem.getPreloadId(), curItem.getPreloadType(), - objectMapper.writeValueAsString(curItem.getPreloadData()))); - } catch (JsonProcessingException e) { - log.error("Cannot convert preload data"); - throw new RestApplicationException("data-conversion", - "Request could not be completed due to internal error", e, - HttpStatus.INTERNAL_SERVER_ERROR.value()); - - } - } - } - - // Update pass - for (ConfigPreloadData newDataItem : newPreloadData) { - log.info("Adding preload data for {}:{}", newDataItem.getPreloadId(), newDataItem.getPreloadType()); - configPreloadDataRepository.save(newDataItem); - } - } else { - throw new RestProtocolException("data-missing", "No preload-list entries found to add", - HttpStatus.CONFLICT.value()); - } - - return new ResponseEntity<>(HttpStatus.CREATED); - } - - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIpreloadInformationPut( - @Valid GenericResourceApiPreloadModelInformation graPreloadModelInfo) throws RestApplicationException { - - boolean addedNew = false; - List<GenericResourceApiPreloadmodelinformationPreloadList> preloadList = graPreloadModelInfo.getPreloadList(); - - if (preloadList != null) { - Iterator<GenericResourceApiPreloadmodelinformationPreloadList> iter = preloadList.iterator(); - while (iter.hasNext()) { - GenericResourceApiPreloadmodelinformationPreloadList curItem = iter.next(); - List<ConfigPreloadData> curPreloadData = configPreloadDataRepository - .findByPreloadIdAndPreloadType(curItem.getPreloadId(), curItem.getPreloadType()); - if ((curPreloadData == null) || curPreloadData.isEmpty()) { - addedNew = true; - } - - try { - configPreloadDataRepository.save(new ConfigPreloadData(curItem.getPreloadId(), - curItem.getPreloadType(), objectMapper.writeValueAsString(curItem.getPreloadData()))); - } catch (JsonProcessingException e) { - log.error("Cannot convert preload data", e); - throw new RestApplicationException("data-conversion", - "Request could not be completed due to internal error", e, - HttpStatus.INTERNAL_SERVER_ERROR.value()); - - } - } - } - - if (addedNew) { - return new ResponseEntity<>(HttpStatus.CREATED); - } else { - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } - - } - - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIpreloadInformationPreloadListPost( - @Valid GenericResourceApiPreloadmodelinformationPreloadList preloadListItem) throws RestProtocolException { - - throw new RestProtocolException("data-missing", "Missing key for list \"preload-list\"", - HttpStatus.NOT_FOUND.value()); - } - - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIpreloadInformationPreloadListPreloadIdPreloadTypeDelete( - String preloadId, String preloadType) { - configPreloadDataRepository.deleteByPreloadIdAndPreloadType(preloadId, preloadType); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } - - @Override - public ResponseEntity<GenericResourceApiPreloadmodelinformationPreloadList> configGENERICRESOURCEAPIpreloadInformationPreloadListPreloadIdPreloadTypeGet( - String preloadId, String preloadType) throws RestApplicationException { - List<ConfigPreloadData> preloadData = configPreloadDataRepository.findByPreloadIdAndPreloadType(preloadId, - preloadType); - if (preloadData != null) { - if (!preloadData.isEmpty()) { - ConfigPreloadData preloadDataItem = preloadData.get(0); - GenericResourceApiPreloadmodelinformationPreloadList preloadDataList = new GenericResourceApiPreloadmodelinformationPreloadList(); - preloadDataList.setPreloadId(preloadDataItem.getPreloadId()); - preloadDataList.setPreloadType(preloadDataItem.getPreloadType()); - try { - preloadDataList.setPreloadData(objectMapper.readValue(preloadDataItem.getPreloadData(), - GenericResourceApiPreloaddataPreloadData.class)); - } catch (JsonProcessingException e) { - log.error("Cannot convert preload data", e); - throw new RestApplicationException("data-conversion", - "Request could not be completed due to internal error", e, - HttpStatus.INTERNAL_SERVER_ERROR.value()); - } - return new ResponseEntity<>(preloadDataList, HttpStatus.OK); - } - } - return new ResponseEntity<>(HttpStatus.NOT_FOUND); - } - - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIpreloadInformationPreloadListPreloadIdPreloadTypePost( - String preloadId, String preloadType, - @Valid GenericResourceApiPreloadmodelinformationPreloadList preloadListItem) - throws RestApplicationException, RestProtocolException { - List<ConfigPreloadData> preloadDataItems = configPreloadDataRepository.findByPreloadIdAndPreloadType(preloadId, - preloadType); - - if ((preloadDataItems != null) && !preloadDataItems.isEmpty()) { - log.error("Preload data already exists for {}:{}", preloadId, preloadType); - throw new RestProtocolException("data-exists", "Data already exists for " + preloadId + ":" + preloadType, - HttpStatus.CONFLICT.value()); - } - - try { - log.info("Adding preload data for {}:{}", preloadId, preloadType); - configPreloadDataRepository.save(new ConfigPreloadData(preloadId, preloadType, - objectMapper.writeValueAsString(preloadListItem.getPreloadData()))); - } catch (JsonProcessingException e) { - log.error("Cannot convert preload data", e); - throw new RestApplicationException("data-conversion", - "Request could not be completed due to internal error", e, - HttpStatus.INTERNAL_SERVER_ERROR.value()); - - } - return new ResponseEntity<>(HttpStatus.CREATED); - } - - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIpreloadInformationPreloadListPreloadIdPreloadTypePut( - String preloadId, String preloadType, - @Valid GenericResourceApiPreloadmodelinformationPreloadList preloadListItem) - throws RestApplicationException, RestProtocolException { - List<ConfigPreloadData> preloadDataItems = configPreloadDataRepository.findByPreloadIdAndPreloadType(preloadId, - preloadType); - boolean dataExists = false; - if ((preloadDataItems != null) && !preloadDataItems.isEmpty()) { - dataExists = true; - } - - if ((preloadListItem.getPreloadId() == null) || (preloadListItem.getPreloadType() == null) - || (preloadListItem.getPreloadData() == null)) { - log.error("Invalid list item received: {}", preloadListItem); - throw new RestProtocolException("bad-attribute", "Invalid data received", HttpStatus.BAD_REQUEST.value()); - } - - try { - if (dataExists) { - log.info("Updating preload data for {}:{} -> {}", preloadId, preloadType, - objectMapper.writeValueAsString(preloadListItem)); - - } else { - log.info("Adding preload data for {}:{}", preloadId, preloadType); - } - - configPreloadDataRepository.save(new ConfigPreloadData(preloadId, preloadType, - objectMapper.writeValueAsString(preloadListItem.getPreloadData()))); - } catch (JsonProcessingException e) { - log.error("Cannot convert preload data", e); - throw new RestApplicationException("data-conversion", - "Request could not be completed due to internal error", e, - HttpStatus.INTERNAL_SERVER_ERROR.value()); - - } - - if (dataExists) { - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } else { - return new ResponseEntity<>(HttpStatus.CREATED); - } - } - - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIpreloadInformationPreloadListPreloadIdPreloadTypePreloadDataDelete( - String preloadId, String preloadType) throws RestProtocolException { - List<ConfigPreloadData> preloadData = configPreloadDataRepository.findByPreloadIdAndPreloadType(preloadId, - preloadType); - - if ((preloadData == null) || preloadData.isEmpty()) { - throw new RestProtocolException("data-missing", "No preload entry found", HttpStatus.NOT_FOUND.value()); - } - - ConfigPreloadData preloadDataItem = preloadData.get(0); - - if (preloadDataItem.getPreloadData() == null) { - throw new RestProtocolException("data-missing", "No preload-data found", HttpStatus.NOT_FOUND.value()); - } - preloadDataItem.setPreloadData(null); - configPreloadDataRepository.save(preloadDataItem); - - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } - - @Override - public ResponseEntity<GenericResourceApiPreloaddataPreloadData> configGENERICRESOURCEAPIpreloadInformationPreloadListPreloadIdPreloadTypePreloadDataGet( - String preloadId, String preloadType) throws RestApplicationException, RestProtocolException { - List<ConfigPreloadData> preloadData = configPreloadDataRepository.findByPreloadIdAndPreloadType(preloadId, - preloadType); - - if ((preloadData == null) || preloadData.isEmpty()) { - throw new RestProtocolException("data-missing", "No preload entry found", HttpStatus.NOT_FOUND.value()); - } - - ConfigPreloadData preloadDataItem = preloadData.get(0); - - if (preloadDataItem.getPreloadData() == null) { - throw new RestProtocolException("data-missing", "No preload-data found", HttpStatus.NOT_FOUND.value()); - } - try { - return new ResponseEntity<>(objectMapper.readValue(preloadDataItem.getPreloadData(), - GenericResourceApiPreloaddataPreloadData.class), HttpStatus.OK); - } catch (JsonProcessingException e) { - log.error("Cannot convert preload data", e); - throw new RestApplicationException("data-conversion", - "Request could not be completed due to internal error", e, - HttpStatus.INTERNAL_SERVER_ERROR.value()); - } - } - - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIpreloadInformationPreloadListPreloadIdPreloadTypePreloadDataPost( - String preloadId, String preloadType, @Valid GenericResourceApiPreloaddataPreloadData preloadData) - throws RestApplicationException, RestProtocolException { - - - List<ConfigPreloadData> preloadDataItems = configPreloadDataRepository.findByPreloadIdAndPreloadType(preloadId, - preloadType); - if ((preloadDataItems == null) || (preloadDataItems.isEmpty())) { - throw new RestProtocolException("data-missing", "No preload entry found", HttpStatus.NOT_FOUND.value()); - } - - if ((preloadData == null) || (preloadData.getPreloadNetworkTopologyInformation() == null)) { - throw new RestProtocolException("bad-attribute", "Invalid preloadData received", - HttpStatus.BAD_REQUEST.value()); - } - - ConfigPreloadData preloadDataItem = preloadDataItems.get(0); - - if (preloadDataItem.getPreloadData() != null) { - log.error("Preload data already exists for {}:{} ", preloadId, preloadType); - throw new RestProtocolException("data-exists", "Data already exists for " + preloadId + ":" + preloadType, - HttpStatus.CONFLICT.value()); - } - - try { - preloadDataItem.setPreloadData(objectMapper.writeValueAsString(preloadData)); - configPreloadDataRepository.save(preloadDataItem); - } catch (JsonProcessingException e) { - log.error("Cannot convert preload data", e); - throw new RestApplicationException("data-conversion", - "Request could not be completed due to internal error", e, - HttpStatus.INTERNAL_SERVER_ERROR.value()); - } - - return new ResponseEntity<>(HttpStatus.CREATED); - } - - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIpreloadInformationPreloadListPreloadIdPreloadTypePreloadDataPut( - String preloadId, String preloadType, @Valid GenericResourceApiPreloaddataPreloadData preloadData) - throws RestApplicationException, RestProtocolException { - boolean dataExists = false; - List<ConfigPreloadData> preloadDataItems = configPreloadDataRepository.findByPreloadIdAndPreloadType(preloadId, - preloadType); - if ((preloadDataItems == null) || (preloadDataItems.isEmpty())) { - throw new RestProtocolException("data-missing", "No preload entry found", HttpStatus.NOT_FOUND.value()); - } - - if ((preloadData == null) || (preloadData.getPreloadNetworkTopologyInformation() == null)) { - throw new RestProtocolException("bad-attribute", "Invalid preloadData received", - HttpStatus.BAD_REQUEST.value()); - } - - ConfigPreloadData preloadDataItem = preloadDataItems.get(0); - - if (preloadDataItem.getPreloadData() != null) { - dataExists = true; - } - - try { - preloadDataItem.setPreloadData(objectMapper.writeValueAsString(preloadData)); - configPreloadDataRepository.save(preloadDataItem); - } catch (JsonProcessingException e) { - log.error("Cannot convert preload data", e); - throw new RestApplicationException("data-conversion", - "Request could not be completed due to internal error", e, - HttpStatus.INTERNAL_SERVER_ERROR.value()); - } - - if (dataExists) { - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } else { - return new ResponseEntity<>(HttpStatus.CREATED); - } - } - - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIservicesDelete() { - configVfModulesRepository.deleteAll(); - configVnfsRepository.deleteAll(); - configNetworksRepository.deleteAll(); - configServicesRepository.deleteAll(); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } - - @Override - public ResponseEntity<GenericResourceApiServiceModelInfrastructure> configGENERICRESOURCEAPIservicesGet() - throws RestApplicationException { - GenericResourceApiServiceModelInfrastructure modelInfrastructure = new GenericResourceApiServiceModelInfrastructure(); - - if (configServicesRepository.count() == 0) { - throw new RestApplicationException("data-missing", - "Request could not be completed because the relevant data model content does not exist", - HttpStatus.NOT_FOUND.value()); - } - - for (ConfigServices service : configServicesRepository.findAll()) { - GenericResourceApiServicemodelinfrastructureService serviceItem = new GenericResourceApiServicemodelinfrastructureService(); - String svcInstanceId = service.getSvcInstanceId(); - - serviceItem.setServiceInstanceId(svcInstanceId); - serviceItem.setServiceStatus(service.getServiceStatus()); - - // Construct service data from networks/vnfs/vfModules - GenericResourceApiServicedataServiceData serviceItemSvcData; - try { - serviceItemSvcData = serviceDataHelper.getServiceData(service); - } catch (JsonProcessingException e) { - log.error("Could not deserialize service data for {}", service.getSvcInstanceId(), e); - throw new RestApplicationException("data-conversion", - "Request could not be completed due to internal error", e, - HttpStatus.INTERNAL_SERVER_ERROR.value()); - } - - - if (serviceItemSvcData != null) { - serviceItem.setServiceData(serviceItemSvcData); - } - modelInfrastructure.addServiceItem(serviceItem); - } - - return new ResponseEntity<>(modelInfrastructure, HttpStatus.OK); - - } - - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIservicesPost(@Valid GenericResourceApiServiceModelInfrastructure modelInfrastructure) - throws RestApplicationException, RestProtocolException { - - ServiceDataTransaction transaction = serviceDataHelper.createTransaction(); - - for (GenericResourceApiServicemodelinfrastructureService serviceItem : modelInfrastructure.getService()) { - String svcInstanceId = serviceItem.getServiceInstanceId(); - List<ConfigServices> existingService = configServicesRepository.findBySvcInstanceId(svcInstanceId); - if ((existingService != null) && !existingService.isEmpty()) { - log.error("Service data already exists for {}", svcInstanceId); - throw new RestProtocolException("data-exists", - "Data already exists for service-instance-id " + svcInstanceId, HttpStatus.CONFLICT.value()); - } - ConfigServices service = new ConfigServices(); - service.setSvcInstanceId(svcInstanceId); - service.setServiceStatus(serviceItem.getServiceStatus()); - - try { - serviceDataHelper.saveService(service, serviceItem.getServiceData(), transaction); - } catch (JsonProcessingException e) { - log.error("Could not serialize service data for {}", service.getSvcInstanceId(), e); - throw new RestApplicationException("data-conversion", - "Request could not be completed due to internal error", e, - HttpStatus.INTERNAL_SERVER_ERROR.value()); - - } - } - - transaction.commit(); - - return new ResponseEntity<>(HttpStatus.CREATED); - - } - - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIservicesPut( - @Valid GenericResourceApiServiceModelInfrastructure modelInfrastructure) throws RestApplicationException { - - ServiceDataTransaction transaction = serviceDataHelper.createTransaction(); - boolean dataExists = false; - - for (GenericResourceApiServicemodelinfrastructureService serviceItem : modelInfrastructure.getService()) { - String svcInstanceId = serviceItem.getServiceInstanceId(); - List<ConfigServices> existingService = configServicesRepository.findBySvcInstanceId(svcInstanceId); - if ((existingService != null) && !existingService.isEmpty()) { - dataExists = true; - } - ConfigServices service = new ConfigServices(); - service.setSvcInstanceId(svcInstanceId); - service.setServiceStatus(serviceItem.getServiceStatus()); - try { - serviceDataHelper.saveService(service, serviceItem.getServiceData(), transaction); - } catch (JsonProcessingException e) { - log.error("Could not serialize service data for {}", service.getSvcInstanceId(), e); - throw new RestApplicationException("data-conversion", - "Request could not be completed due to internal error", e, - HttpStatus.INTERNAL_SERVER_ERROR.value()); - - } - } - - transaction.commit(); - - if (dataExists) { - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } else { - return new ResponseEntity<>(HttpStatus.CREATED); - } - - } - - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServicePost( - @Valid GenericResourceApiServicemodelinfrastructureService servicesData) throws RestApplicationException { - String svcInstanceId = servicesData.getServiceInstanceId(); - try { - ConfigServices configService = new ConfigServices(svcInstanceId, servicesData.getServiceStatus()); - serviceDataHelper.saveService(configService, servicesData.getServiceData()); - } catch (JsonProcessingException e) { - log.error("Cannot convert service data", e); - throw new RestApplicationException("data-conversion", - "Request could not be completed due to internal error", e, - HttpStatus.INTERNAL_SERVER_ERROR.value()); - - } - return new ResponseEntity<>(HttpStatus.OK); - } - - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdDelete( - String serviceInstanceId) { - serviceDataHelper.deleteService(serviceInstanceId); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } - - @Override - public ResponseEntity<GenericResourceApiServicemodelinfrastructureService> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdGet( - String serviceInstanceId) throws RestApplicationException { - GenericResourceApiServicemodelinfrastructureService retval = null; - - List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId); - - if (services.isEmpty()) { - return new ResponseEntity<>(HttpStatus.NOT_FOUND); - } else { - ConfigServices service = services.get(0); - retval = new GenericResourceApiServicemodelinfrastructureService(); - retval.setServiceInstanceId(serviceInstanceId); - retval.setServiceStatus(service.getServiceStatus()); - try { - retval.setServiceData(serviceDataHelper.getServiceData(service)); - } catch (JsonProcessingException e) { - log.error("Could not deserialize service data for service instance id {}", serviceInstanceId, e); - throw new RestApplicationException("data-conversion", - "Request could not be completed due to internal error", e, - HttpStatus.INTERNAL_SERVER_ERROR.value()); - - } - } - - return new ResponseEntity<>(retval, HttpStatus.OK); - - } - - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdPost(String svcInstanceId, - @Valid GenericResourceApiServicemodelinfrastructureService newService) - throws RestApplicationException, RestProtocolException { - - List<ConfigServices> existingService = configServicesRepository.findBySvcInstanceId(svcInstanceId); - if ((existingService != null) && !existingService.isEmpty()) { - log.error("Service data already exists for {}", svcInstanceId); - throw new RestProtocolException("data-exists", - "Data already exists for service-instance-id " + svcInstanceId, HttpStatus.CONFLICT.value()); - } - ConfigServices service = new ConfigServices(); - service.setSvcInstanceId(svcInstanceId); - service.setServiceStatus(newService.getServiceStatus()); - try { - serviceDataHelper.saveService(service, newService.getServiceData()); - } catch (JsonProcessingException e) { - log.error("Could not serialize service data for {}", service.getSvcInstanceId(), e); - throw new RestApplicationException("data-conversion", - "Request could not be completed due to internal error", e, - HttpStatus.INTERNAL_SERVER_ERROR.value()); - - } - - return new ResponseEntity<>(HttpStatus.CREATED); - } - - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdPut(String serviceInstanceId, - @Valid GenericResourceApiServicemodelinfrastructureService newService) throws RestApplicationException { - - boolean dataExists = false; - - String svcInstanceId = newService.getServiceInstanceId(); - - ConfigServices service = null; - List<ConfigServices> existingService = configServicesRepository.findBySvcInstanceId(svcInstanceId); - if ((existingService != null) && !existingService.isEmpty()) { - dataExists = true; - service = existingService.get(0); - } else { - service = new ConfigServices(); - service.setSvcInstanceId(svcInstanceId); - } - - service.setServiceStatus(newService.getServiceStatus()); - try { - serviceDataHelper.saveService(service, newService.getServiceData()); - } catch (JsonProcessingException e) { - log.error("Could not serialize service data for {}", service.getSvcInstanceId(), e); - throw new RestApplicationException("data-conversion", - "Request could not be completed due to internal error", e, - HttpStatus.INTERNAL_SERVER_ERROR.value()); - - } - - if (dataExists) { - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } else { - return new ResponseEntity<>(HttpStatus.CREATED); - } - } - - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataDelete( - String serviceInstanceId) throws RestProtocolException { - List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId); - - if ((services == null) || (services.isEmpty())) { - throw new RestProtocolException("data-missing", "No service entry found", HttpStatus.NOT_FOUND.value()); - } - - ConfigServices service = services.get(0); - if (!serviceDataHelper.hasServiceData(service)) { - throw new RestProtocolException("data-missing", "No service-data found", HttpStatus.NOT_FOUND.value()); - } - serviceDataHelper.clearServiceData(service); - - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } - - @Override - public ResponseEntity<GenericResourceApiServicedataServiceData> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataGet( - String serviceInstanceId) throws RestApplicationException, RestProtocolException { - GenericResourceApiServicedataServiceData serviceData = null; - - List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId); - if ((services == null) || (services.isEmpty())) { - throw new RestProtocolException("data-missing", "No service entry found", HttpStatus.NOT_FOUND.value()); - } - - try { - serviceData = serviceDataHelper.getServiceData(services.get(0)); - return new ResponseEntity<>(serviceData, HttpStatus.OK); - } catch (JsonProcessingException e) { - log.error("Could not parse service data", e); - throw new RestApplicationException("data-conversion", - "Request could not be completed due to internal error", e, - HttpStatus.INTERNAL_SERVER_ERROR.value()); - } - - } - - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataPost( - String serviceInstanceId, @Valid GenericResourceApiServicedataServiceData serviceData) - throws RestApplicationException, RestProtocolException { - ConfigServices service; - List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId); - if ((services == null) || (services.isEmpty())) { - throw new RestProtocolException("data-missing", "No service entry found", HttpStatus.NOT_FOUND.value()); - } - - if ((serviceData == null) || (serviceData.getServiceInformation() == null)) { - throw new RestProtocolException("bad-attribute", "Invalid service-data received", - HttpStatus.BAD_REQUEST.value()); - - } - service = services.get(0); - - if (serviceDataHelper.hasServiceData(service)) { - log.error("service-data already exists for svcInstanceId {}", serviceInstanceId); - throw new RestProtocolException("data-exists", "Data already exists for " + serviceInstanceId, - HttpStatus.CONFLICT.value()); - } - - try { - serviceDataHelper.saveService(service, serviceData); - } catch (JsonProcessingException e) { - log.error("Could not serialize service data for svc instance id {}", serviceInstanceId, e); - throw new RestApplicationException("data-conversion", - "Request could not be completed due to internal error", e, - HttpStatus.INTERNAL_SERVER_ERROR.value()); - } - - return new ResponseEntity<>(HttpStatus.CREATED); - - } - - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataPut( - String serviceInstanceId, @Valid GenericResourceApiServicedataServiceData serviceData) - throws RestApplicationException, RestProtocolException { - ConfigServices service; - boolean dataExists = false; - - List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId); - if ((services == null) || (services.isEmpty())) { - throw new RestProtocolException("data-missing", "No service entry found", HttpStatus.NOT_FOUND.value()); - } - - if ((serviceData == null) || (serviceData.getServiceInformation() == null)) { - throw new RestProtocolException("bad-attribute", "Invalid service-data received", - HttpStatus.BAD_REQUEST.value()); - - } - service = services.get(0); - - dataExists = serviceDataHelper.hasServiceData(service); - - try { - serviceDataHelper.saveService(service, serviceData); - } catch (JsonProcessingException e) { - log.error("Could not serialize service data for svc instance id {}", serviceInstanceId, e); - throw new RestApplicationException("data-conversion", - "Request could not be completed due to internal error", e, - HttpStatus.INTERNAL_SERVER_ERROR.value()); - } - - if (dataExists) { - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } else { - return new ResponseEntity<>(HttpStatus.CREATED); - } - } - - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceStatusDelete( - String serviceInstanceId) throws RestProtocolException { - List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId); - - if ((services == null) || (services.isEmpty())) { - throw new RestProtocolException("data-missing", "No service entry found", HttpStatus.NOT_FOUND.value()); - } - - ConfigServices service = services.get(0); - if (service.getServiceStatus() == null) { - throw new RestProtocolException("data-missing", "No service-status found", HttpStatus.NOT_FOUND.value()); - } - service.setServiceStatus(null); - configServicesRepository.save(service); - - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - - } - - @Override - public ResponseEntity<GenericResourceApiServicestatusServiceStatus> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceStatusGet( - String serviceInstanceId) throws RestApplicationException, RestProtocolException { - GenericResourceApiServicestatusServiceStatus serviceStatus = null; - - List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId); - if ((services == null) || (services.isEmpty())) { - throw new RestProtocolException("data-missing", "No service entry found", HttpStatus.NOT_FOUND.value()); - } - - serviceStatus = services.get(0).getServiceStatus(); - return new ResponseEntity<>(serviceStatus, HttpStatus.OK); - } - - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceStatusPost( - String serviceInstanceId, @Valid GenericResourceApiServicestatusServiceStatus serviceStatus) - throws RestProtocolException { - ConfigServices service; - List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId); - if ((services == null) || (services.isEmpty())) { - throw new RestProtocolException("data-missing", "No service entry found", HttpStatus.NOT_FOUND.value()); - } - - if ((serviceStatus == null) || (serviceStatus.getAction() == null)) { - throw new RestProtocolException("bad-attribute", "Invalid service-status received", - HttpStatus.BAD_REQUEST.value()); - - } - service = services.get(0); - - if (service.getServiceStatus() != null) { - log.error("service-status already exists for svcInstanceId {}", serviceInstanceId); - throw new RestProtocolException("data-exists", "Data already exists for " + serviceInstanceId, - HttpStatus.CONFLICT.value()); - } - - service.setServiceStatus(serviceStatus); - configServicesRepository.save(service); - - return new ResponseEntity<>(HttpStatus.CREATED); - - } - - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceStatusPut( - String serviceInstanceId, @Valid GenericResourceApiServicestatusServiceStatus serviceStatus) - throws RestProtocolException { - ConfigServices service; - boolean dataExists = false; - - List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId); - if ((services == null) || (services.isEmpty())) { - throw new RestProtocolException("data-missing", "No service entry found", HttpStatus.NOT_FOUND.value()); - } - - if ((serviceStatus == null) || (serviceStatus.getAction() == null)) { - throw new RestProtocolException("bad-attribute", "Invalid service-status received", - HttpStatus.BAD_REQUEST.value()); - - } - service = services.get(0); - - if (service.getServiceStatus() != null) { - dataExists = true; - } - - service.setServiceStatus(serviceStatus); - configServicesRepository.save(service); - - if (dataExists) { - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } else { - return new ResponseEntity<>(HttpStatus.CREATED); - } - } - - /** - * Deletes VNF data from the Config table specified Service Instance. - * <p> - * Maps to - * /config/GENERIC-RESOURCE-API:services/service/{service-instance-id}/service-data/vnfs/vnf/{vnf-id}/ - * - * @param serviceInstanceId the Service Instance ID to perform the delete on - * @param vnfId the VNF ID of the VNF to delete - * @return HttpStatus.NO_CONTENT (204) on successful delete - * <p> - * HttpStatus.BAD_REQUEST (400) if unmarshalling Service Data from the - * database fails, there is no VNF data for {@code vnfId}, or writing - * Service Data back to the database fails. - * <p> - * HttpStatus.NOT_FOUND (404) if {@code serviceInstanceId} does not - * exist. - */ - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataVnfsVnfVnfIdDelete( - String serviceInstanceId, String vnfId) throws RestException { - log.info("DELETE | VNF Data for ({})", vnfId); - - List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId); - ConfigServices data; - if ((services == null) || (services.isEmpty())) { - log.info("Could not find data for ({}).", serviceInstanceId); - // Or throw the data not found error? - throw new RestProtocolException("data-missing", "Service Instance ID not found.", - HttpStatus.NOT_FOUND.value()); - } else { - data = services.get(0); - } - - if (!serviceDataHelper.hasServiceData(data)) { - log.info("Could not find Service Data for ({}).", serviceInstanceId); - throw new RestProtocolException("data-missing", "Service data not found.", HttpStatus.NOT_FOUND.value()); - } - - if (serviceDataHelper.deleteVnf(serviceInstanceId, vnfId) > 0) { - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } else { - // Data was not found - log.error("Did not find VNF ({}) in data.", vnfId); - throw new RestProtocolException("data-missing", "VNF ID not found.", HttpStatus.NOT_FOUND.value()); - } - } - - /** - * Extracts VNF data from the Config table specified Service Instance. - * <p> - * Maps to - * /config/GENERIC-RESOURCE-API:services/service/{service-instance-id}/service-data/vnfs/vnf/{vnf-id}/ - * - * @param serviceInstanceId the Service Instance ID to lookup data for - * @param vnfId the VNF ID of the VNF to return - * @return HttpStatus.OK (200) if the data is found. - * @throws RestException if the data does not exist. - */ - @Override - public ResponseEntity<GenericResourceApiServicedataServicedataVnfsVnf> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataVnfsVnfVnfIdGet( - String serviceInstanceId, String vnfId) throws RestException { - log.info("GET | VNF Data for ({})", vnfId); - - List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId); - if ((services == null) || (services.isEmpty())) { - throw new RestProtocolException("data-missing", "No service entry found", HttpStatus.NOT_FOUND.value()); - } - - GenericResourceApiServicedataServicedataVnfsVnf vnf = null; - try { - vnf = serviceDataHelper.getVnf(serviceInstanceId, vnfId); - } catch (JsonProcessingException e) { - log.error("Could not parse service data", e); - throw new RestApplicationException("data-conversion", - "Request could not be completed due to internal error", e, - HttpStatus.INTERNAL_SERVER_ERROR.value()); - } - - if (vnf != null) { - return new ResponseEntity<>(vnf, HttpStatus.OK); - } else { - log.info("No information found for {}", vnfId); - throw new RestApplicationException("data-missing", - "Request could not be completed because the relevant data model content does not exist", - HttpStatus.NOT_FOUND.value()); - } - } - - /** - * Creates or updates VNF data in the Config table for a specified Service - * Instance. If it is a new Service Instance or a new VNF, creates all necessary - * parent data containers, then performs the updates. - * <p> - * Maps to /config/GENERIC-RESOURCE-API:services/service/{service-instance-id}/service-data/vnfs/vnf/{vnf-id}/ - * @param serviceInstanceId the Service Instance ID to perform the delete on - * @param vnfId the VNF ID of the VNF to delete - * @param genericResourceApiServicedataServicedataVnfsVnfBodyParam the playload - * @return HttpStatus.CREATED (201) on successful create - * <p> - * HttpStatus.NO_CONTENT (204) on successful update - * <p> - * HttpStatus.BAD_REQUEST (400) if {@code vnfId} does not match what is specified in the - * {@code genericResourceApiServicedataServicedataVnfsVnfBodyParam} , or if updating the database fails. - * @throws RestException - */ - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataVnfsVnfVnfIdPut( - String serviceInstanceId, String vnfId, - GenericResourceApiServicedataServicedataVnfsVnf vnf) - throws RestException { - log.info("PUT | VNF Data for ({})", vnfId); - if (!vnfId.equals(vnf.getVnfId())) { - throw new RestProtocolException("bad-attribute", "vnf-id mismatch", HttpStatus.BAD_REQUEST.value()); - } - - List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId); - ConfigServices data; - ServiceDataTransaction transaction = serviceDataHelper.createTransaction(); - if ((services == null) || (services.isEmpty())) { - log.info("Could not find data for ({}). Creating new Service Object.", serviceInstanceId); - data = new ConfigServices(); - data.setSvcInstanceId(serviceInstanceId); - transaction.save(data); - } else { - data = services.get(0); - } - - try { - HttpStatus responseStatus = HttpStatus.NO_CONTENT; - if (serviceDataHelper.getVnf(serviceInstanceId, vnfId) == null) { - responseStatus = HttpStatus.CREATED; - } - serviceDataHelper.saveVnf(serviceInstanceId, vnf, transaction); - transaction.commit(); - return new ResponseEntity<>(responseStatus); - } catch (JsonProcessingException e) { - log.error("Error saving vnf", e); - return new ResponseEntity<>(HttpStatus.BAD_REQUEST); - } - } - - /** - * Extracts VNF Topology data from the Config table specified Service Instance - * and VNF ID. - * <p> - * Maps to - * /config/GENERIC-RESOURCE-API:services/service/{service-instance-id}/service-data/vnfs/vnf/{vnf-id}/vnf-data/vnf-topology/ - * - * @param serviceInstanceId the Service Instance ID to lookup data for - * @param vnfId the VNF ID of the VNF to extract topology data from. - * @return HttpStatus.OK (200) if the data is found. - * @throws RestException if the data does not exist. - */ - @Override - public ResponseEntity<GenericResourceApiVnftopologyVnfTopology> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataVnfsVnfVnfIdVnfDataVnfTopologyGet( - String serviceInstanceId, String vnfId) throws RestException { - log.info("GET | VNF Topology for ({})", vnfId); - - List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId); - if ((services == null) || (services.isEmpty())) { - throw new RestProtocolException("data-missing", "No service entry found", HttpStatus.NOT_FOUND.value()); - } - - GenericResourceApiServicedataServicedataVnfsVnf vnf = null; - - try { - vnf = serviceDataHelper.getVnf(serviceInstanceId, vnfId); - } catch (JsonProcessingException e) { - log.error("Could not parse service data", e); - throw new RestApplicationException("data-conversion", - "Request could not be completed due to internal error", e, - HttpStatus.INTERNAL_SERVER_ERROR.value()); - } - - // Drill down to find the data - if (vnf != null && vnf.getVnfData() != null && vnf.getVnfData().getVnfTopology() != null) { - return new ResponseEntity<>(vnf.getVnfData().getVnfTopology(), HttpStatus.OK); - } else { - log.info("No information found for {}", vnfId); - throw new RestApplicationException("data-missing", - "Request could not be completed because the relevant data model content does not exist", - HttpStatus.NOT_FOUND.value()); - } - } - - /** - * Creates or updates VNF Level Operation Status data in the Config table for a - * specified Service Instance. If it is a new Service Instance or a new VNF, - * creates all necessary parent data containers, then performs the updates. - * <p> - * Maps to - * /config/GENERIC-RESOURCE-API:services/service/{service-instance-id}/service-data/vnfs/vnf/{vnf-id}/vnf-data/vnf-level-oper-status/ - * - * @param serviceInstanceId the Service Instance ID to - * perform the delete on - * @param vnfId the VNF ID of the VNF to - * delete - * @param genericResourceApiOperStatusDataBodyParam the payload - * @return HttpStatus.CREATED (201) on successful create. - * <p> - * HttpStatus.NO_CONTENT (204) on successful update. - * <p> - * HttpStatus.BAD_REQUEST (400) if updating the database fails. - * @throws RestException - */ - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataVnfsVnfVnfIdVnfDataVnfLevelOperStatusPut( - String serviceInstanceId, String vnfId, - GenericResourceApiOperStatusData genericResourceApiOperStatusDataBodyParam) throws RestException { - log.info("PUT | VNF Level Oper Status ({})", vnfId); - ServiceDataTransaction transaction = serviceDataHelper.createTransaction(); - - List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId); - ConfigServices data; - if ((services == null) || (services.isEmpty())) { - log.info("Could not find data for ({}). Creating new Service Object.", serviceInstanceId); - data = new ConfigServices(); - data.setSvcInstanceId(serviceInstanceId); - transaction.save(data); - } else { - data = services.get(0); - } - - HttpStatus responseStatus = HttpStatus.NO_CONTENT; - - try { - GenericResourceApiServicedataServicedataVnfsVnf vnf = serviceDataHelper.getVnf(serviceInstanceId, vnfId); - if (vnf == null) { - responseStatus = HttpStatus.CREATED; - vnf = new GenericResourceApiServicedataServicedataVnfsVnf(); - vnf.setVnfId(vnfId); - } - GenericResourceApiServicedataServicedataVnfsVnfVnfData vnfData = vnf.getVnfData(); - if (vnfData == null) { - vnfData = new GenericResourceApiServicedataServicedataVnfsVnfVnfData(); - } - vnfData.setVnfLevelOperStatus(genericResourceApiOperStatusDataBodyParam); - vnf.setVnfData(vnfData); - serviceDataHelper.saveVnf(serviceInstanceId, vnf, transaction); - transaction.commit(); - return new ResponseEntity<>(responseStatus); - } catch (JsonProcessingException e) { - log.error("Error saving vnf", e); - return new ResponseEntity<>(HttpStatus.BAD_REQUEST); - } - } - - /** - * Creates or updates VNF Onap Model Information data in the Config table for a - * specified Service Instance. If it is a new Service Instance or a new VNF, - * creates all necessary parent data containers, then performs the updates. - * <p> - * Maps to - * /config/GENERIC-RESOURCE-API:services/service/{service-instance-id}/service-data/vnfs/vnf/{vnf-id}/vnf-data/vnf-topology/onap-model-information/ - * - * @param serviceInstanceId the - * Service - * Instance - * ID - * to - * perform - * the - * delete - * on - * @param vnfId the - * VNF - * ID - * of - * the - * VNF - * to - * delete - * @param genericResourceApiOnapmodelinformationOnapModelInformationBodyParam the - * payload - * @return HttpStatus.CREATED (201) on successful create. - * <p> - * HttpStatus.NO_CONTENT (204) on successful update. - * <p> - * HttpStatus.BAD_REQUEST (400) if updating the database fails. - * @throws RestException - */ - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataVnfsVnfVnfIdVnfDataVnfTopologyOnapModelInformationPut( - String serviceInstanceId, String vnfId, - GenericResourceApiOnapmodelinformationOnapModelInformation genericResourceApiOnapmodelinformationOnapModelInformationBodyParam) - throws RestException { - log.info("PUT | VNF Topology Onap Model Information ({})", vnfId); - ServiceDataTransaction transaction = serviceDataHelper.createTransaction(); - - List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId); - ConfigServices data; - if ((services == null) || (services.isEmpty())) { - log.info("Could not find data for ({}). Creating new Service Object.", serviceInstanceId); - data = new ConfigServices(); - data.setSvcInstanceId(serviceInstanceId); - transaction.save(data); - } else { - data = services.get(0); - } - - - GenericResourceApiServicedataServicedataVnfsVnf vnf = null; - HttpStatus responseStatus = HttpStatus.NO_CONTENT; - - try { - vnf = serviceDataHelper.getVnf(serviceInstanceId, vnfId); - } catch(JsonProcessingException e) { - - log.error("Could not parse service data", e); - throw new RestApplicationException("data-conversion", - "Request could not be completed due to internal error", e, - HttpStatus.INTERNAL_SERVER_ERROR.value()); - } - - if (vnf == null) { - responseStatus = HttpStatus.CREATED; - vnf = new GenericResourceApiServicedataServicedataVnfsVnf(); - vnf.setVnfId(vnfId); - vnf.setVnfData(new GenericResourceApiServicedataServicedataVnfsVnfVnfData()); - vnf.getVnfData().setVnfTopology(new GenericResourceApiVnftopologyVnfTopology()); - } - - vnf.getVnfData().getVnfTopology() - .setOnapModelInformation(genericResourceApiOnapmodelinformationOnapModelInformationBodyParam); - - // Save the updated VNF (and service, if new) - try { - serviceDataHelper.saveVnf(serviceInstanceId, vnf, transaction); - transaction.commit(); - return new ResponseEntity<>(responseStatus); - } catch (JsonProcessingException e) { - log.error("Error mapping object to JSON", e); - // Should probably be a 500 INTERNAL_SERVICE_ERROR - return new ResponseEntity<>(HttpStatus.BAD_REQUEST); - } - } - - /** - * Creates or updates VNF Network data in the Config table for a specified - * Service Instance. If it is a new Service Instance or a new VNF, creates all - * necessary parent data containers, then performs the updates. - * <p> - * Maps to /config/GENERIC-RESOURCE-API:services/service/{service-instance-id}/service-data/vnfs/vnf/{vnf-id}/vnf-data/vnf-topology/vnf-resource-assignments/vnf-networks/ - * @param serviceInstanceId the Service Instance ID to perform the delete on - * @param vnfId the VNF ID of the VNF to delete - * @param genericResourceApiVnfresourceassignmentsVnfresourceassignmentsVnfNetworksBodyParam the * payload - * @return HttpStatus.CREATED (201) on successful create. - * <p> - * HttpStatus.NO_CONTENT (204) on successful update. - * <p> - * HttpStatus.BAD_REQUEST (400) if updating the database fails. - * @throws RestException - */ - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataVnfsVnfVnfIdVnfDataVnfTopologyVnfResourceAssignmentsVnfNetworksPut( - String serviceInstanceId, String vnfId, - GenericResourceApiVnfresourceassignmentsVnfresourceassignmentsVnfNetworks genericResourceApiVnfresourceassignmentsVnfresourceassignmentsVnfNetworksBodyParam) - throws RestException { - log.info("PUT | VNF Topology VNF Resource Assignments VNF Networks ({})", vnfId); - - ServiceDataTransaction transaction = serviceDataHelper.createTransaction(); - List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId); - ConfigServices data; - if ((services == null) || (services.isEmpty())) { - log.info("Could not find data for ({}). Creating new Service Object.", serviceInstanceId); - data = new ConfigServices(); - data.setSvcInstanceId(serviceInstanceId); - transaction.save(data); - } else { - data = services.get(0); - } - - HttpStatus responseStatus = HttpStatus.NO_CONTENT; - GenericResourceApiServicedataServicedataVnfsVnf vnf = null; - - try { - vnf = serviceDataHelper.getVnf(serviceInstanceId, vnfId); - } catch(JsonProcessingException e) { - - log.error("Could not parse service data", e); - throw new RestApplicationException("data-conversion", - "Request could not be completed due to internal error", e, - HttpStatus.INTERNAL_SERVER_ERROR.value()); - } - - if (vnf == null) { - log.info("Creating VNF data for ({})", vnfId); - vnf = new GenericResourceApiServicedataServicedataVnfsVnf(); - vnf.setVnfId(vnfId); - responseStatus = HttpStatus.CREATED; - } - GenericResourceApiServicedataServicedataVnfsVnfVnfData vnfData = vnf.getVnfData(); - if (vnfData == null) { - vnfData = new GenericResourceApiServicedataServicedataVnfsVnfVnfData(); - } - - GenericResourceApiVnftopologyVnfTopology vnfTopology = vnfData.getVnfTopology(); - if (vnfTopology == null) { - vnfTopology = new GenericResourceApiVnftopologyVnfTopology(); - } - - GenericResourceApiVnfresourceassignmentsVnfResourceAssignments vnfResourceAssignments = vnfTopology.getVnfResourceAssignments(); - if (vnfResourceAssignments == null) { - vnfResourceAssignments = new GenericResourceApiVnfresourceassignmentsVnfResourceAssignments(); - } - vnfResourceAssignments.setVnfNetworks(genericResourceApiVnfresourceassignmentsVnfresourceassignmentsVnfNetworksBodyParam); - vnfTopology.setVnfResourceAssignments(vnfResourceAssignments); - vnfData.setVnfTopology(vnfTopology); - vnf.setVnfData(vnfData); - - // Map and save the new data - try { - serviceDataHelper.saveVnf(serviceInstanceId, vnf, transaction); - transaction.commit(); - return new ResponseEntity<>(responseStatus); - } catch (JsonProcessingException e) { - log.error("Error mapping object to JSON", e); - // Should probably be a 500 INTERNAL_SERVICE_ERROR - return new ResponseEntity<>(HttpStatus.BAD_REQUEST); - } - } - - /** - * Creates or updates VNF Network Role data in the Config table for a specified - * Service Instance. If it is a new Service Instance or a new VNF, creates all - * necessary parent data containers, then performs the updates. - * <p> - * Maps to - * /config/GENERIC-RESOURCE-API:services/service/{service-instance-id}/service-data/vnfs/vnf/{vnf-id}/vnf-data/vnf-topology/vnf-resource-assignments/vnf-networks/vnf-network/{network-role}/ - * - * @param serviceInstanceId the Service Instance ID to - * perform the delete on - * @param vnfId the VNF ID of the VNF to - * delete - * @param genericResourceApiVnfNetworkDataBodyParam the payload - * @return HttpStatus.CREATED (201) on successful create. - * <p> - * HttpStatus.NO_CONTENT (204) on successful update. - * <p> - * HttpStatus.BAD_REQUEST (400) if updating the database fails. - * @throws RestException - */ - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataVnfsVnfVnfIdVnfDataVnfTopologyVnfResourceAssignmentsVnfNetworksVnfNetworkNetworkRolePut( - String serviceInstanceId, String vnfId, String networkRole, - GenericResourceApiVnfNetworkData genericResourceApiVnfNetworkDataBodyParam) throws RestException { - log.info("PUT | VNF Network Network Role ({})", vnfId); - if (!networkRole.equals(genericResourceApiVnfNetworkDataBodyParam.getNetworkRole())) { - throw new RestProtocolException("bad-attribute", "network-role mismatch", HttpStatus.BAD_REQUEST.value()); - } - - ServiceDataTransaction transaction = serviceDataHelper.createTransaction(); - - List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId); - ConfigServices data; - if ((services == null) || (services.isEmpty())) { - log.info("Could not find data for ({}). Creating new Service Object.", serviceInstanceId); - data = new ConfigServices(); - data.setSvcInstanceId(serviceInstanceId); - transaction.save(data); - } else { - data = services.get(0); - } - - HttpStatus responseStatus = HttpStatus.NO_CONTENT; - GenericResourceApiServicedataServicedataVnfsVnf vnf = null; - - try { - vnf = serviceDataHelper.getVnf(serviceInstanceId, vnfId); - } catch(JsonProcessingException e) { - - log.error("Could not parse service data", e); - throw new RestApplicationException("data-conversion", - "Request could not be completed due to internal error", e, - HttpStatus.INTERNAL_SERVER_ERROR.value()); - } - - if (vnf == null) { - log.info("Creating VNF data for ({})", vnfId); - vnf = new GenericResourceApiServicedataServicedataVnfsVnf(); - vnf.setVnfId(vnfId); - responseStatus = HttpStatus.CREATED; - } - GenericResourceApiServicedataServicedataVnfsVnfVnfData vnfData = vnf.getVnfData(); - if (vnfData == null) { - vnfData = new GenericResourceApiServicedataServicedataVnfsVnfVnfData(); - } - - GenericResourceApiVnftopologyVnfTopology vnfTopology = vnfData.getVnfTopology(); - if (vnfTopology == null) { - vnfTopology = new GenericResourceApiVnftopologyVnfTopology(); - } - - GenericResourceApiVnfresourceassignmentsVnfResourceAssignments vnfResourceAssignments = vnfTopology.getVnfResourceAssignments(); - if (vnfResourceAssignments == null) { - vnfResourceAssignments = new GenericResourceApiVnfresourceassignmentsVnfResourceAssignments(); - } - - GenericResourceApiVnfresourceassignmentsVnfresourceassignmentsVnfNetworks vnfNetworks = vnfResourceAssignments.getVnfNetworks(); - if (vnfNetworks == null) { - vnfNetworks = new GenericResourceApiVnfresourceassignmentsVnfresourceassignmentsVnfNetworks(); - vnfNetworks.setVnfNetwork(new ArrayList<>()); - } - - - if (vnfNetworks.getVnfNetwork().isEmpty()) { - vnfNetworks.addVnfNetworkItem(genericResourceApiVnfNetworkDataBodyParam); - } else { - GenericResourceApiVnfresourceassignmentsVnfresourceassignmentsVnfNetworks vnfNetworksNew = new GenericResourceApiVnfresourceassignmentsVnfresourceassignmentsVnfNetworks(); - vnfNetworksNew.setVnfNetwork(new ArrayList<>()); - vnfNetworks.getVnfNetwork().stream() - .filter(targetNetwork -> !targetNetwork.getNetworkRole().equals(networkRole)).forEach(vnfNetworksNew::addVnfNetworkItem); - - vnfNetworksNew.addVnfNetworkItem(genericResourceApiVnfNetworkDataBodyParam); - vnfNetworks = vnfNetworksNew; - } - - vnfResourceAssignments.setVnfNetworks(vnfNetworks); - vnfTopology.setVnfResourceAssignments(vnfResourceAssignments); - vnfData.setVnfTopology(vnfTopology); - vnf.setVnfData(vnfData); - try { - serviceDataHelper.saveVnf(serviceInstanceId, vnf, transaction); - transaction.commit(); - return new ResponseEntity<>(responseStatus); - } catch (JsonProcessingException e) { - log.error("Error mapping object to JSON", e); - // Should probably be a 500 INTERNAL_SERVICE_ERROR - return new ResponseEntity<>(HttpStatus.BAD_REQUEST); - } - } - - - @Override - public ResponseEntity<GenericResourceApiServicetopologyServiceTopology> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataServiceTopologyGet( - String serviceInstanceId) throws RestApplicationException, RestProtocolException { - GenericResourceApiServicetopologyServiceTopology serviceTopology = null; - GenericResourceApiServicedataServiceData serviceData = null; - - List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId); - if ((services == null) || (services.isEmpty())) { - throw new RestProtocolException("data-missing", "No service entry found", HttpStatus.NOT_FOUND.value()); - } - - ConfigServices service = services.get(0); - - try { - if ( (service.getSvcData() == null) || service.getSvcData().isEmpty()) { - throw new RestProtocolException("data-missing", "No service-data entry found", - HttpStatus.NOT_FOUND.value()); - } else { - serviceData = serviceDataHelper.getServiceData(service); - serviceTopology = serviceData.getServiceTopology(); - } - if (serviceTopology == null) { - throw new RestProtocolException("data-missing", "No service-topology entry found", - HttpStatus.NOT_FOUND.value()); - } - return new ResponseEntity<>(serviceTopology, HttpStatus.OK); - } catch (JsonProcessingException e) { - log.error("Could not parse service data", e); - throw new RestApplicationException("data-conversion", - "Request could not be completed due to internal error", e, - HttpStatus.INTERNAL_SERVER_ERROR.value()); - } - - } - - /** - * Extracts VF MODULE data from CONFIG_GRA_SERVICES for a given, service-instance-id, vnf-id, and vf-module-id - * <p> - * Maps to /config/GENERIC-RESOURCE-API:services/service/{service-instance-id}/service-data/vnfs/vnf/{vnf-id}/vnf-data/vf-modules/vf-module/{vf-module-id}/ - * @param serviceInstanceId the Service Instance ID to lookup data for - * @param vnfId the VNF ID of the VNF to return - * @param vfModuleId the vf-moudle ID of a specific VNF to return - * @return HttpStatus.OK (200) if the data is found. - * @throws RestException if the data does not exist. - */ - @Override - public ResponseEntity<GenericResourceApiServicedataServicedataVnfsVnfVnfdataVfmodulesVfModule> - configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataVnfsVnfVnfIdVnfDataVfModulesVfModuleVfModuleIdGet( - String serviceInstanceId, String vnfId, String vfModuleId) throws RestException { - - log.info("GET | Vf Module Data for ({})", vfModuleId); - - - List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId); - if((services == null) || (services.isEmpty())) { - throw new RestProtocolException("data-missing", "No service entry found", HttpStatus.NOT_FOUND.value()); - } - - GenericResourceApiServicedataServicedataVnfsVnfVnfdataVfmodulesVfModule vfModule; - try { - vfModule = serviceDataHelper.getVfModule(serviceInstanceId, vnfId, vfModuleId); - } catch (JsonProcessingException e) { - log.error("Could not parse service data", e); - throw new RestApplicationException("data-conversion", - "Request could not be completed due to internal error", e, - HttpStatus.INTERNAL_SERVER_ERROR.value()); - } - - if(vfModule != null) { - return new ResponseEntity<>(vfModule, HttpStatus.OK); - } else { - log.info("No vf-module found for [{}]", vfModuleId); - throw new RestApplicationException("data-missing", - "Request could not be completed because the relevant data model content does not exist", - HttpStatus.NOT_FOUND.value()); - } - } - - /** - * PUT VF MODULE data into CONFIG_GRA_SERVICES of a given, service-instance-id, vnf-id - * <p> - * Maps to /config/GENERIC-RESOURCE-API:services/service/{service-instance-id}/service-data/vnfs/vnf/{vnf-id}/vnf-data/vf-modules/vf-module/{vf-module-id}/ - * @param serviceInstanceId the Service Instance ID - * @param vnfId the VNF ID as the parent of the specified vf-module-id and child of the specified service-instance - * @param vfModuleId the vf-moudle ID as a child of the specified VNF - * @return HttpStatus.OK (200) if the data is found. - * @throws RestException if the data does not exist. - */ - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataVnfsVnfVnfIdVnfDataVfModulesVfModuleVfModuleIdPut( - String serviceInstanceId, String vnfId, String vfModuleId, - GenericResourceApiServicedataServicedataVnfsVnfVnfdataVfmodulesVfModule genericResourceApiServicedataServicedataVnfsVnfVnfdataVfmodulesVfModuleBodyParam) - throws RestException { - log.info("PUT | vf-module Data of ({}) for vnf ({}) in service({})", vfModuleId, vnfId, serviceInstanceId); - - if(! vfModuleId.equals(genericResourceApiServicedataServicedataVnfsVnfVnfdataVfmodulesVfModuleBodyParam.getVfModuleId())) { - throw new RestProtocolException("bad-attribute", "vf-module-id mismatch", HttpStatus.BAD_REQUEST.value()); - } - - - HttpStatus responseStatus = HttpStatus.NO_CONTENT; - List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId); - - if((services == null) || (services.isEmpty())) { - log.error("service-instance-id ({}) not found in SDN.", serviceInstanceId); - return new ResponseEntity<>(HttpStatus.BAD_REQUEST); - } - - - GenericResourceApiServicedataServicedataVnfsVnf vnf; - try { - vnf = serviceDataHelper.getVnf(serviceInstanceId, vnfId); - } catch (JsonProcessingException e1) { - log.error("Could not parse service data", e1); - throw new RestApplicationException("data-conversion", - "Request could not be completed due to internal error", e1, - HttpStatus.INTERNAL_SERVER_ERROR.value()); - } - - if(vnf == null) { - log.error("vnf-id ({}) not found in SDN.", vnfId); - return new ResponseEntity<>(HttpStatus.BAD_REQUEST); - } - - // See if this is the first vf module being added - List<ConfigVfModules> configVfModules = configVfModulesRepository.findBySvcInstanceIdAndVnfId(serviceInstanceId, vnfId); - - if ((configVfModules == null) || configVfModules.isEmpty()) { - responseStatus = HttpStatus.CREATED; - } - - // Add vf module - try { - serviceDataHelper.saveVfModule(serviceInstanceId, vnfId, genericResourceApiServicedataServicedataVnfsVnfVnfdataVfmodulesVfModuleBodyParam, null); - return new ResponseEntity<>(responseStatus); - } catch(JsonProcessingException e) { - log.error("Error mapping object to JSON", e); - // Should probably be a 500 INTERNAL_SERVICE_ERROR - return new ResponseEntity<>(HttpStatus.BAD_REQUEST); - } - } - - /** - * Extracts VF MODULE Topology data from the Config table specified Service - * Instance and VNF ID. - * <p> - * Maps to /config/GENERIC-RESOURCE-API:services/service/{service-instance-id}/service-data/vnfs/vnf/{vnf-id}/vnf-data/vf-modules/vf-module/{vf-module-id}/vf-module-data/vf-module-topology/ - * @param serviceInstanceId the Service Instance ID to lookup data for - * @param vnfId the VNF ID of the VNF to extract topology data from. - * @param vfModuleId the vf-module-idof the vf-module to extract topology data from. - * @return HttpStatus.OK (200) if the data is found. - * @throws RestException if the data does not exist. - */ - @Override - public ResponseEntity<GenericResourceApiVfmoduletopologyVfModuleTopology> - configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataVnfsVnfVnfIdVnfDataVfModulesVfModuleVfModuleIdVfModuleDataVfModuleTopologyGet( - String serviceInstanceId, String vnfId, String vfModuleId) throws RestException { - log.info("GET | vf-module-topology for ({})", vfModuleId); - - List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId); - if((services == null) || (services.isEmpty())) { - throw new RestApplicationException("data-missing", - "Request could not be completed because the relevant data model content does not exist", - HttpStatus.NOT_FOUND.value()); - } - - GenericResourceApiServicedataServicedataVnfsVnfVnfdataVfmodulesVfModule vfModule; - try { - vfModule = serviceDataHelper.getVfModule(serviceInstanceId, vnfId, vfModuleId); - } catch (JsonProcessingException e) { - log.error("Could not parse service data", e); - throw new RestApplicationException("data-conversion", - "Request could not be completed due to internal error", e, - HttpStatus.INTERNAL_SERVER_ERROR.value()); - } - if (vfModule != null - && vfModule.getVfModuleData() != null - && vfModule.getVfModuleData().getVfModuleTopology() != null) { - return new ResponseEntity<>(vfModule.getVfModuleData().getVfModuleTopology(), HttpStatus.OK); - } else { - log.info("No information found for {}", vfModuleId); - throw new RestApplicationException("data-missing", - "Request could not be completed because the relevant data model content does not exist", - HttpStatus.NOT_FOUND.value()); - } - } - - @Override - public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataVnfsVnfVnfIdVnfDataVfModulesVfModuleVfModuleIdDelete( - String serviceInstanceId, String vnfId, String vfModuleId) throws RestProtocolException { - - log.info("DELETE | vf-module Data for ({})", vfModuleId); - - - - List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId); - - if((services == null) || (services.isEmpty())) { - log.error("service-instance-id ({}) not found in SDN.", serviceInstanceId); - return new ResponseEntity<>(HttpStatus.BAD_REQUEST); - } - - - - serviceDataHelper.deleteVfModule(serviceInstanceId, vnfId, vfModuleId); - return new ResponseEntity<>(HttpStatus.OK); - - } -} - diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/controllers/OperationalApiController.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/controllers/OperationalApiController.java deleted file mode 100644 index aeecd63..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/controllers/OperationalApiController.java +++ /dev/null @@ -1,213 +0,0 @@ -package org.onap.sdnc.apps.ms.gra.controllers; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.onap.sdnc.apps.ms.gra.data.*; -import org.onap.sdnc.apps.ms.gra.swagger.OperationalApi; -import org.onap.sdnc.apps.ms.gra.swagger.model.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; -import java.util.Iterator; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.atomic.AtomicBoolean; - -@Controller -@ComponentScan(basePackages = {"org.onap.sdnc.apps.ms.gra.*"}) -@EntityScan("org.onap.sdnc.apps.ms.gra.springboot.*") -public class OperationalApiController implements OperationalApi { - private static final Logger log = LoggerFactory.getLogger(ConfigApiController.class); - - private final ObjectMapper objectMapper; - - private final HttpServletRequest request; - - @Autowired - private OperationalPreloadDataRepository operationalPreloadDataRepository; - - @Autowired - private OperationalServicesRepository operationalServicesRepository; - - @Autowired - public OperationalApiController(ObjectMapper objectMapper, HttpServletRequest request) { - objectMapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); - objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - this.objectMapper = objectMapper; - this.request = request; - } - - @Override - public Optional<ObjectMapper> getObjectMapper() { - return Optional.ofNullable(objectMapper); - } - - @Override - public Optional<HttpServletRequest> getRequest() { - return Optional.ofNullable(request); - } - - - @Override - public ResponseEntity<GenericResourceApiPreloadModelInformation> operationalGENERICRESOURCEAPIpreloadInformationGet() { - GenericResourceApiPreloadModelInformation genericResourceApiPreloadModelInformation = new GenericResourceApiPreloadModelInformation(); - - operationalPreloadDataRepository.findAll().forEach(configPreloadData -> { - GenericResourceApiPreloadmodelinformationPreloadList preloadListItem = new GenericResourceApiPreloadmodelinformationPreloadList(); - - preloadListItem.setPreloadId(configPreloadData.getPreloadId()); - preloadListItem.setPreloadType(configPreloadData.getPreloadType()); - try { - preloadListItem.setPreloadData(objectMapper.readValue(configPreloadData.getPreloadData(), GenericResourceApiPreloaddataPreloadData.class)); - } catch (JsonProcessingException e) { - log.error("Could not convert preload data", e); - } - genericResourceApiPreloadModelInformation.addPreloadListItem(preloadListItem); - }); - - - return new ResponseEntity<>(genericResourceApiPreloadModelInformation, HttpStatus.OK); - } - - - @Override - public ResponseEntity<GenericResourceApiPreloadmodelinformationPreloadList> operationalGENERICRESOURCEAPIpreloadInformationPreloadListPreloadIdPreloadTypeGet(String preloadId, String preloadType) { - List<OperationalPreloadData> preloadData = operationalPreloadDataRepository.findByPreloadIdAndPreloadType(preloadId, preloadType); - if (preloadData != null) { - if (!preloadData.isEmpty()) { - OperationalPreloadData preloadDataItem = preloadData.get(0); - GenericResourceApiPreloadmodelinformationPreloadList preloadDataList = new GenericResourceApiPreloadmodelinformationPreloadList(); - preloadDataList.setPreloadId(preloadDataItem.getPreloadId()); - preloadDataList.setPreloadType(preloadDataItem.getPreloadType()); - try { - preloadDataList.setPreloadData(objectMapper.readValue(preloadDataItem.getPreloadData(), GenericResourceApiPreloaddataPreloadData.class)); - } catch (JsonProcessingException e) { - log.error("Cannot convert preload data", e); - } - return new ResponseEntity<>(preloadDataList, HttpStatus.OK); - } - } - return new ResponseEntity<>(HttpStatus.NOT_FOUND); - } - - - @Override - public ResponseEntity<GenericResourceApiPreloaddataPreloadData> operationalGENERICRESOURCEAPIpreloadInformationPreloadListPreloadIdPreloadTypePreloadDataGet(String preloadId, String preloadType) { - List<OperationalPreloadData> preloadData = operationalPreloadDataRepository.findByPreloadIdAndPreloadType(preloadId, preloadType); - if (preloadData != null) { - if (!preloadData.isEmpty()) { - OperationalPreloadData preloadDataItem = preloadData.get(0); - try { - return new ResponseEntity<>(objectMapper.readValue(preloadDataItem.getPreloadData(), GenericResourceApiPreloaddataPreloadData.class), HttpStatus.OK); - } catch (JsonProcessingException e) { - log.error("Cannot convert preload data", e); - } - } - } - return new ResponseEntity<>(HttpStatus.NOT_FOUND); - } - - - @Override - public ResponseEntity<GenericResourceApiServiceModelInfrastructure> operationalGENERICRESOURCEAPIservicesGet() { - GenericResourceApiServiceModelInfrastructure modelInfrastructure = new GenericResourceApiServiceModelInfrastructure(); - - AtomicBoolean caughtError = new AtomicBoolean(false); - operationalServicesRepository.findAll().forEach(service -> - { - GenericResourceApiServicemodelinfrastructureService serviceItem = new GenericResourceApiServicemodelinfrastructureService(); - serviceItem.setServiceInstanceId(service.getSvcInstanceId()); - try { - serviceItem.setServiceData(objectMapper.readValue(service.getSvcData(), GenericResourceApiServicedataServiceData.class)); - } catch (JsonProcessingException e) { - log.error("Could not deserialize service data for {}", service.getSvcInstanceId(), e); - caughtError.set(true); - } - serviceItem.setServiceStatus(service.getServiceStatus()); - modelInfrastructure.addServiceItem(serviceItem); - }); - - if (caughtError.get()) { - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); - } else { - return new ResponseEntity<>(modelInfrastructure, HttpStatus.OK); - } - } - - - - @Override - public ResponseEntity<GenericResourceApiServicemodelinfrastructureService> operationalGENERICRESOURCEAPIservicesServiceServiceInstanceIdGet(String serviceInstanceId) { - GenericResourceApiServicemodelinfrastructureService retval = null; - - List<OperationalServices> services = operationalServicesRepository.findBySvcInstanceId(serviceInstanceId); - - if (services.isEmpty()) { - return new ResponseEntity<> (HttpStatus.NOT_FOUND); - } else { - OperationalServices service = services.get(0); - retval = new GenericResourceApiServicemodelinfrastructureService(); - retval.setServiceInstanceId(serviceInstanceId); - retval.setServiceStatus(service.getServiceStatus()); - try { - retval.setServiceData(objectMapper.readValue(service.getSvcData(), GenericResourceApiServicedataServiceData.class)); - } catch (JsonProcessingException e) { - log.error("Could not deserialize service data for service instance id {}", serviceInstanceId, e); - retval = null; - } - } - - if (retval == null) { - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); - } else { - return new ResponseEntity<>(retval, HttpStatus.OK); - } - } - - - @Override - public ResponseEntity<GenericResourceApiServicedataServiceData> operationalGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataGet(String serviceInstanceId) { - GenericResourceApiServicedataServiceData serviceData = null; - - List<OperationalServices> services = operationalServicesRepository.findBySvcInstanceId(serviceInstanceId); - if (services.isEmpty()) { - return new ResponseEntity<>(HttpStatus.NOT_FOUND); - } else { - try { - serviceData = objectMapper.readValue(services.get(0).getSvcData(), GenericResourceApiServicedataServiceData.class); - return new ResponseEntity<>(serviceData, HttpStatus.OK); - } catch (JsonProcessingException e) { - log.error("Could not parse service data", e); - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - } - - @Override - public ResponseEntity<GenericResourceApiServicestatusServiceStatus> operationalGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceStatusGet(String serviceInstanceId) { - GenericResourceApiServicestatusServiceStatus serviceStatus = null; - List<OperationalServices> services = operationalServicesRepository.findBySvcInstanceId(serviceInstanceId); - - if (!services.isEmpty()) { - OperationalServices service = services.get(0); - serviceStatus = service.getServiceStatus(); - } - - if (serviceStatus == null) { - return new ResponseEntity<>(HttpStatus.NOT_FOUND); - } else { - return new ResponseEntity<>(serviceStatus, HttpStatus.OK); - } - - } - -} diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/controllers/OperationsApiController.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/controllers/OperationsApiController.java deleted file mode 100644 index 6b0a463..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/controllers/OperationsApiController.java +++ /dev/null @@ -1,1858 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SDNC - * ================================================================================ - * Copyright (C) 2020 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.sdnc.apps.ms.gra.controllers; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; -import java.util.Optional; -import java.util.Properties; -import java.util.TimeZone; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -import org.onap.ccsdk.apps.services.RestException; -import org.onap.ccsdk.apps.services.SvcLogicFactory; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicLoader; -import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceBase; -import org.onap.sdnc.apps.ms.gra.data.ConfigContrailRouteAllottedResourcesRepository; -import org.onap.sdnc.apps.ms.gra.data.ConfigNetworksRepository; -import org.onap.sdnc.apps.ms.gra.data.ConfigPortMirrorConfigurations; -import org.onap.sdnc.apps.ms.gra.data.ConfigPortMirrorConfigurationsRepository; -import org.onap.sdnc.apps.ms.gra.data.ConfigPreloadData; -import org.onap.sdnc.apps.ms.gra.data.ConfigPreloadDataRepository; -import org.onap.sdnc.apps.ms.gra.data.ConfigServices; -import org.onap.sdnc.apps.ms.gra.data.ConfigServicesRepository; -import org.onap.sdnc.apps.ms.gra.data.ConfigVfModulesRepository; -import org.onap.sdnc.apps.ms.gra.data.ConfigVnfsRepository; -import org.onap.sdnc.apps.ms.gra.data.OperationalContrailRouteAllottedResourcesRepository; -import org.onap.sdnc.apps.ms.gra.data.OperationalPortMirrorConfigurationsRepository; -import org.onap.sdnc.apps.ms.gra.data.OperationalPreloadData; -import org.onap.sdnc.apps.ms.gra.data.OperationalPreloadDataRepository; -import org.onap.sdnc.apps.ms.gra.data.OperationalServices; -import org.onap.sdnc.apps.ms.gra.data.OperationalServicesRepository; -import org.onap.sdnc.apps.ms.gra.swagger.OperationsApi; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiInstanceReference; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiNetworkOperationInformation; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiNetworkOperationInformationBodyparam; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiNetworkTopologyOperation; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiNetworktopologyoperationOutput; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiPolicyUpdateNotifyOperation; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiPolicyupdatenotifyoperationInput; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiPolicyupdatenotifyoperationInputBodyparam; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiPolicyupdatenotifyoperationOutput; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiPortMirrorTopologyOperation; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiPortMirrorTopologyOperationInformation; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiPortMirrorTopologyOperationInformationBodyparam; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiPortmirrortopologyoperationOutput; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiPreloadNetworkTopologyOperation; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiPreloadTopologyResponseBody; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiPreloadVfModuleTopologyOperation; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiPreloaddataPreloadData; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiPreloadnetworktopologyoperationInputBodyparam; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiPreloadvfmoduletopologyoperationInputBodyparam; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiRequestStatusEnumeration; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiServiceOperationInformation; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiServiceOperationInformationBodyparam; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiServiceTopologyOperation; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiServicetopologyoperationOutput; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiVfModuleOperationInformation; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiVfModuleOperationInformationBodyparam; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiVfModuleTopologyOperation; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiVfmoduletopologyoperationOutput; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiVnfGetResourceRequest; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiVnfOperationInformation; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiVnfOperationInformationBodyparam; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiVnfTopologyOperation; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiVnfgetresourcerequestInput; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiVnfgetresourcerequestInputBodyparam; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiVnfgetresourcerequestOutput; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiVnftopologyoperationOutput; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Import; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; - -@Controller -@ComponentScan(basePackages = { "org.onap.sdnc.apps.ms.gra.*", "org.onap.ccsdk.apps.services" }) -@EntityScan("org.onap.sdnc.apps.ms.gra.*") -@Import(value = SvcLogicFactory.class) -public class OperationsApiController implements OperationsApi { - - private static final String CALLED_STR = "{} called."; - private static final String MODULE_NAME = "GENERIC-RESOURCE-API"; - private static final String SERVICE_OBJECT_PATH_PARAM = "service-object-path"; - private static final String NETWORK_OBJECT_PATH_PARAM = "network-object-path"; - private static final String VNF_OBJECT_PATH_PARAM = "vnf-object-path"; - private static final String PNF_OBJECT_PATH_PARAM = "pnf-object-path"; - private static final String VF_MODULE_OBJECT_PATH_PARAM = "vf-module-object-path"; - private static final String PORT_MIRROR_OBJECT_PATH_PARAM = "port-mirror-object-path"; - private static final String BACKGROUND_THREAD_STARTED_MESSAGE = "Start background thread"; - private static final String BACKGROUND_THREAD_INFO = "Background thread: input conf_id is {}"; - private static final String SKIP_MDSAL_UPDATE_PROP = "skip-mdsal-update"; - private static final String ADDING_INPUT_DATA_LOG = "Adding INPUT data for {} [{}] input: {}"; - private static final String ADDING_OPERATIONAL_DATA_LOG = "Adding OPERATIONAL data for {} [{}] operational-data: {}"; - - private final ObjectMapper objectMapper; - - private final HttpServletRequest request; - - @Autowired - protected SvcLogicServiceBase svc; - - @Autowired - protected SvcLogicLoader svcLogicLoader; - - @Autowired - private ConfigPreloadDataRepository configPreloadDataRepository; - - @Autowired - private OperationalPreloadDataRepository operationalPreloadDataRepository; - - @Autowired - private ConfigServicesRepository configServicesRepository; - - @Autowired - private OperationalServicesRepository operationalServicesRepository; - - @Autowired - private ConfigNetworksRepository configNetworksRepository; - - @Autowired - private ConfigVnfsRepository configVnfsRepository; - - @Autowired - private ConfigVfModulesRepository configVfModulesRepository; - - @Autowired - private ConfigContrailRouteAllottedResourcesRepository configContrailRouteAllottedResourcesRepository; - - @Autowired - private OperationalContrailRouteAllottedResourcesRepository operationalContrailRouteAllottedResourcesRepository; - - @Autowired - private ConfigPortMirrorConfigurationsRepository configPortMirrorConfigurationsRepository; - - @Autowired - private OperationalPortMirrorConfigurationsRepository operationalPortMirrorConfigurationsRepository; - - @Autowired - private ServiceDataHelper serviceDataHelper; - - private static class Iso8601Util { - - private static TimeZone timeZone = TimeZone.getTimeZone("UTC"); - private static DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); - - private Iso8601Util() { - } - - static { - dateFormat.setTimeZone(timeZone); - } - - private static String now() { - return dateFormat.format(new Date()); - } - } - - @org.springframework.beans.factory.annotation.Autowired - public OperationsApiController(ObjectMapper objectMapper, HttpServletRequest request) { - objectMapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); - objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - this.objectMapper = objectMapper; - this.request = request; - } - - @Override - public Optional<ObjectMapper> getObjectMapper() { - return Optional.ofNullable(objectMapper); - } - - @Override - public Optional<HttpServletRequest> getRequest() { - return Optional.ofNullable(request); - } - - @Override - public ResponseEntity<GenericResourceApiPreloadNetworkTopologyOperation> operationsGENERICRESOURCEAPIpreloadNetworkTopologyOperationPost( - @Valid GenericResourceApiPreloadnetworktopologyoperationInputBodyparam graInput) { - final String svcOperation = "preload-network-topology-operation"; - GenericResourceApiPreloadNetworkTopologyOperation retval = new GenericResourceApiPreloadNetworkTopologyOperation(); - GenericResourceApiPreloadTopologyResponseBody resp = new GenericResourceApiPreloadTopologyResponseBody(); - - log.info(CALLED_STR, svcOperation); - if (hasInvalidPreloadNetwork(graInput)) { - log.debug("exiting {} because of null or empty preload-network-topology-information", svcOperation); - - resp.setResponseCode("403"); - resp.setResponseMessage("invalid input, null or empty preload-network-topology-information"); - resp.setAckFinalIndicator("Y"); - - retval.setOutput(resp); - - return new ResponseEntity<>(retval, HttpStatus.FORBIDDEN); - } - - String preloadId = graInput.getInput().getPreloadNetworkTopologyInformation() - .getNetworkTopologyIdentifierStructure().getNetworkId(); - String preloadType = "network"; - - resp.setSvcRequestId(graInput.getInput().getSdncRequestHeader().getSvcRequestId()); - - SvcLogicContext ctxIn = new SvcLogicContext(); - - GenericResourceApiPreloaddataPreloadData preloadData = null; - - // Add input to SvcLogicContext - try { - ctxIn.mergeJson(svcOperation + "-input", objectMapper.writeValueAsString(graInput.getInput())); - } catch (JsonProcessingException e) { - log.error("exiting {} due to parse error on input preload data", svcOperation); - resp.setResponseCode("500"); - resp.setResponseMessage("internal error"); - resp.setAckFinalIndicator("Y"); - retval.setOutput(resp); - return new ResponseEntity<>(retval, HttpStatus.INTERNAL_SERVER_ERROR); - } - - // Add config tree data to SvcLogicContext - try { - preloadData = getConfigPreloadData(preloadId, preloadType); - ctxIn.mergeJson("preload-data", objectMapper.writeValueAsString(preloadData)); - } catch (JsonProcessingException e) { - log.error("exiting {} due to parse error on saved config preload data", svcOperation); - resp.setResponseCode("500"); - resp.setResponseMessage("internal error"); - resp.setAckFinalIndicator("Y"); - retval.setOutput(resp); - return new ResponseEntity<>(retval, HttpStatus.INTERNAL_SERVER_ERROR); - } - - // Add operational tree data to SvcLogicContext - try { - preloadData = getOperationalPreloadData(preloadId, preloadType); - ctxIn.mergeJson("operational-data", objectMapper.writeValueAsString(preloadData)); - } catch (JsonProcessingException e) { - log.error("exiting {} due to parse error on saved operational preload data", svcOperation); - resp.setResponseCode("500"); - resp.setResponseMessage("internal error"); - resp.setAckFinalIndicator("Y"); - retval.setOutput(resp); - return new ResponseEntity<>(retval, HttpStatus.INTERNAL_SERVER_ERROR); - } - - // Call DG - try { - // Any of these can throw a nullpointer exception - // execute should only throw a SvcLogicException - SvcLogicContext ctxOut = svc.execute(MODULE_NAME, svcOperation, null, "sync", ctxIn); - Properties respProps = ctxOut.toProperties(); - - resp.setAckFinalIndicator(respProps.getProperty("ack-final-indicator", "Y")); - resp.setResponseCode(respProps.getProperty("error-code", "200")); - resp.setResponseMessage(respProps.getProperty("error-message", "SUCCESS")); - - if ("200".equals(resp.getResponseCode())) { - // If DG returns success, update database - String ctxJson = ctxOut.toJsonString("preload-data"); - log.info("DG preload-data is {}", ctxJson); - GenericResourceApiPreloaddataPreloadData preloadToLoad = objectMapper.readValue(ctxJson, - GenericResourceApiPreloaddataPreloadData.class); - saveConfigPreloadData(preloadId, preloadType, preloadToLoad); - saveOperationalPreloadData(preloadId, preloadType, preloadToLoad); - } - - } catch (NullPointerException npe) { - log.error("Caught NPE", npe); - resp.setAckFinalIndicator("true"); - resp.setResponseCode("500"); - resp.setResponseMessage("Check that you populated module, rpc and or mode correctly."); - } catch (SvcLogicException e) { - log.error("Caught SvcLogicException", e); - resp.setAckFinalIndicator("true"); - resp.setResponseCode("500"); - resp.setResponseMessage(e.getMessage()); - } catch (JsonMappingException e) { - log.error("Caught JsonMappingException", e); - resp.setAckFinalIndicator("true"); - resp.setResponseCode("500"); - resp.setResponseMessage(e.getMessage()); - } catch (JsonProcessingException e) { - log.error("Caught JsonProcessingException", e); - resp.setAckFinalIndicator("true"); - resp.setResponseCode("500"); - resp.setResponseMessage(e.getMessage()); - } - - retval.setOutput(resp); - return (new ResponseEntity<>(retval, HttpStatus.valueOf(Integer.parseInt(resp.getResponseCode())))); - } - - @Override - public ResponseEntity<GenericResourceApiPreloadVfModuleTopologyOperation> operationsGENERICRESOURCEAPIpreloadVfModuleTopologyOperationPost( - @Valid GenericResourceApiPreloadvfmoduletopologyoperationInputBodyparam graInput) { - final String svcOperation = "preload-vf-module-topology-operation"; - GenericResourceApiPreloadVfModuleTopologyOperation retval = new GenericResourceApiPreloadVfModuleTopologyOperation(); - GenericResourceApiPreloadTopologyResponseBody resp = new GenericResourceApiPreloadTopologyResponseBody(); - - log.info(CALLED_STR, svcOperation); - if (hasInvalidPreloadNetwork(graInput)) { - log.debug("exiting {} because of null or empty preload-network-topology-information", svcOperation); - - resp.setResponseCode("403"); - resp.setResponseMessage("invalid input, null or empty preload-network-topology-information"); - resp.setAckFinalIndicator("Y"); - - retval.setOutput(resp); - - return new ResponseEntity<>(retval, HttpStatus.FORBIDDEN); - } - - String preloadId = graInput.getInput().getPreloadVfModuleTopologyInformation().getVfModuleTopology() - .getVfModuleTopologyIdentifier().getVfModuleName(); - String preloadType = "vf-module"; - - resp.setSvcRequestId(graInput.getInput().getSdncRequestHeader().getSvcRequestId()); - - SvcLogicContext ctxIn = new SvcLogicContext(); - - GenericResourceApiPreloaddataPreloadData preloadData = null; - - // Add input to SvcLogicContext - try { - ctxIn.mergeJson(svcOperation + "-input", objectMapper.writeValueAsString(graInput.getInput())); - } catch (JsonProcessingException e) { - log.error("exiting {} due to parse error on input preload data", svcOperation); - resp.setResponseCode("500"); - resp.setResponseMessage("internal error"); - resp.setAckFinalIndicator("Y"); - retval.setOutput(resp); - return new ResponseEntity<>(retval, HttpStatus.INTERNAL_SERVER_ERROR); - } - - // Add config tree data to SvcLogicContext - try { - preloadData = getConfigPreloadData(preloadId, preloadType); - ctxIn.mergeJson("preload-data", objectMapper.writeValueAsString(preloadData)); - } catch (JsonProcessingException e) { - log.error("exiting {} due to parse error on saved config preload data", svcOperation); - resp.setResponseCode("500"); - resp.setResponseMessage("internal error"); - resp.setAckFinalIndicator("Y"); - retval.setOutput(resp); - return new ResponseEntity<>(retval, HttpStatus.INTERNAL_SERVER_ERROR); - } - - // Add operational tree data to SvcLogicContext - try { - preloadData = getOperationalPreloadData(preloadId, preloadType); - ctxIn.mergeJson("operational-data", objectMapper.writeValueAsString(preloadData)); - } catch (JsonProcessingException e) { - log.error("exiting {} due to parse error on saved operational preload data", svcOperation); - resp.setResponseCode("500"); - resp.setResponseMessage("internal error"); - resp.setAckFinalIndicator("Y"); - retval.setOutput(resp); - return new ResponseEntity<>(retval, HttpStatus.INTERNAL_SERVER_ERROR); - } - - // Call DG - try { - // Any of these can throw a nullpointer exception - // execute should only throw a SvcLogicException - SvcLogicContext ctxOut = svc.execute(MODULE_NAME, svcOperation, null, "sync", ctxIn); - Properties respProps = ctxOut.toProperties(); - - resp.setAckFinalIndicator(respProps.getProperty("ack-final-indicator", "Y")); - resp.setResponseCode(respProps.getProperty("error-code", "200")); - resp.setResponseMessage(respProps.getProperty("error-message", "SUCCESS")); - - if ("200".equals(resp.getResponseCode())) { - // If DG returns success, update database - String ctxJson = ctxOut.toJsonString("preload-data"); - GenericResourceApiPreloaddataPreloadData preloadToLoad = objectMapper.readValue(ctxJson, - GenericResourceApiPreloaddataPreloadData.class); - saveConfigPreloadData(preloadId, preloadType, preloadToLoad); - saveOperationalPreloadData(preloadId, preloadType, preloadToLoad); - } - - } catch (NullPointerException npe) { - resp.setAckFinalIndicator("true"); - resp.setResponseCode("500"); - resp.setResponseMessage("Check that you populated module, rpc and or mode correctly."); - } catch (SvcLogicException e) { - resp.setAckFinalIndicator("true"); - resp.setResponseCode("500"); - resp.setResponseMessage(e.getMessage()); - } catch (JsonMappingException e) { - resp.setAckFinalIndicator("true"); - resp.setResponseCode("500"); - resp.setResponseMessage(e.getMessage()); - } catch (JsonProcessingException e) { - resp.setAckFinalIndicator("true"); - resp.setResponseCode("500"); - resp.setResponseMessage(e.getMessage()); - } - - retval.setOutput(resp); - return (new ResponseEntity<>(retval, HttpStatus.valueOf(Integer.parseInt(resp.getResponseCode())))); - } - - private boolean hasInvalidPreloadNetwork( - GenericResourceApiPreloadnetworktopologyoperationInputBodyparam preloadData) { - return ((preloadData == null) || (preloadData.getInput() == null) - || (preloadData.getInput().getPreloadNetworkTopologyInformation() == null)); - } - - private boolean hasInvalidPreloadNetwork( - GenericResourceApiPreloadvfmoduletopologyoperationInputBodyparam preloadData) { - return ((preloadData == null) || (preloadData.getInput() == null) - || (preloadData.getInput().getPreloadVfModuleTopologyInformation() == null)); - } - - private boolean hasInvalidServiceId(GenericResourceApiServiceOperationInformation input) { - - return input == null || input.getServiceInformation() == null - || input.getServiceInformation().getServiceInstanceId() == null - || input.getServiceInformation().getServiceInstanceId().length() == 0; - } - - private boolean hasInvalidServiceId(GenericResourceApiNetworkOperationInformation input) { - - return input == null || input.getServiceInformation() == null - || input.getServiceInformation().getServiceInstanceId() == null - || input.getServiceInformation().getServiceInstanceId().length() == 0; - } - - private boolean hasInvalidServiceId(GenericResourceApiVnfOperationInformation input) { - - return input == null || input.getServiceInformation() == null - || input.getServiceInformation().getServiceInstanceId() == null - || input.getServiceInformation().getServiceInstanceId().length() == 0; - } - - private boolean hasInvalidServiceId(GenericResourceApiVfModuleOperationInformation input) { - - return input == null || input.getServiceInformation() == null - || input.getServiceInformation().getServiceInstanceId() == null - || input.getServiceInformation().getServiceInstanceId().length() == 0; - } - - private boolean hasInvalidServiceId(GenericResourceApiPortMirrorTopologyOperationInformation input) { - - return input == null || input.getServiceInformation() == null - || input.getServiceInformation().getServiceInstanceId() == null - || input.getServiceInformation().getServiceInstanceId().length() == 0; - } - - private boolean hasInvalidServiceId(GenericResourceApiVnfgetresourcerequestInput input) { - - return input == null || input.getServiceInformation() == null - || input.getServiceInformation().getServiceInstanceId() == null - || input.getServiceInformation().getServiceInstanceId().length() == 0; - } - - private boolean hasInvalidVnfId(GenericResourceApiVfModuleOperationInformation input) { - - return input == null || input.getVnfInformation() == null - || input.getVnfInformation().getVnfId() == null - || input.getVnfInformation().getVnfId().length() == 0; - } - - private boolean hasInvalidConfigurationId(GenericResourceApiPortMirrorTopologyOperationInformation input) { - return input.getConfigurationInformation() == null - || input.getConfigurationInformation().getConfigurationId() == null - || input.getConfigurationInformation().getConfigurationId().length() == 0; - } - - private boolean hasInvalidPolicyUpdateInput(GenericResourceApiPolicyupdatenotifyoperationInput input) { - return (input.getPolicyName() == null) || (input.getUpdateType() == null) || (input.getVersionId() == null); - } - - private GenericResourceApiPreloaddataPreloadData getConfigPreloadData(String preloadId, String preloadType) - throws JsonProcessingException { - - List<ConfigPreloadData> configPreloadData = configPreloadDataRepository.findByPreloadIdAndPreloadType(preloadId, - preloadType); - - if (configPreloadData.isEmpty()) { - return (null); - } else { - return (objectMapper.readValue(configPreloadData.get(0).getPreloadData(), - GenericResourceApiPreloaddataPreloadData.class)); - } - } - - private GenericResourceApiPreloaddataPreloadData getOperationalPreloadData(String preloadId, String preloadType) - throws JsonProcessingException { - - List<OperationalPreloadData> configPreloadData = operationalPreloadDataRepository - .findByPreloadIdAndPreloadType(preloadId, preloadType); - - if (configPreloadData.isEmpty()) { - return (null); - } else { - return (objectMapper.readValue(configPreloadData.get(0).getPreloadData(), - GenericResourceApiPreloaddataPreloadData.class)); - } - } - - private void saveConfigPreloadData(String preloadId, String preloadType, - GenericResourceApiPreloaddataPreloadData preloadData) throws JsonProcessingException { - - configPreloadDataRepository.deleteByPreloadIdAndPreloadType(preloadId, preloadType); - configPreloadDataRepository - .save(new ConfigPreloadData(preloadId, preloadType, objectMapper.writeValueAsString(preloadData))); - - } - - private void saveOperationalPreloadData(String preloadId, String preloadType, - GenericResourceApiPreloaddataPreloadData preloadData) throws JsonProcessingException { - - operationalPreloadDataRepository.deleteByPreloadIdAndPreloadType(preloadId, preloadType); - operationalPreloadDataRepository - .save(new OperationalPreloadData(preloadId, preloadType, objectMapper.writeValueAsString(preloadData))); - - } - - - @Override - public ResponseEntity<GenericResourceApiNetworkTopologyOperation> operationsGENERICRESOURCEAPInetworkTopologyOperationPost( - @Valid GenericResourceApiNetworkOperationInformationBodyparam input) throws RestException { - final String svcOperation = "network-topology-operation"; - GenericResourceApiNetworkTopologyOperation retval = new GenericResourceApiNetworkTopologyOperation(); - GenericResourceApiNetworktopologyoperationOutput resp = new GenericResourceApiNetworktopologyoperationOutput(); - - log.info(CALLED_STR, svcOperation); - // Verify input contains service instance id - if (hasInvalidServiceId(input.getInput())) { - log.debug("exiting {} because of null or empty service-instance-id", svcOperation); - - resp.setResponseCode("404"); - resp.setResponseMessage("null or empty service-instance-id"); - resp.setAckFinalIndicator("Y"); - - retval.setOutput(resp); - - return new ResponseEntity<>(retval, HttpStatus.OK); - } - - String svcInstanceId = input.getInput().getServiceInformation().getServiceInstanceId(); - - SvcLogicContext ctxIn = new SvcLogicContext(); - - // Add input to SvcLogicContext - try { - ctxIn.mergeJson(svcOperation + "-input", objectMapper.writeValueAsString(input.getInput())); - } catch (JsonProcessingException e) { - log.error("exiting {} due to parse error on input data", svcOperation); - resp.setResponseCode("500"); - resp.setResponseMessage("internal error"); - resp.setAckFinalIndicator("Y"); - retval.setOutput(resp); - return new ResponseEntity<>(retval, HttpStatus.INTERNAL_SERVER_ERROR); - } - - // Add config tree data to SvcLogicContext - List<ConfigServices> configServices = configServicesRepository.findBySvcInstanceId(svcInstanceId); - ConfigServices configService = null; - String svcData = null; - if (configServices != null && !configServices.isEmpty()) { - configService = configServices.get(0); - try { - svcData = serviceDataHelper.getServiceDataAsString(svcInstanceId); - } catch (JsonProcessingException e) { - log.error("exiting {} due to parse error on service data", svcOperation); - resp.setResponseCode("500"); - resp.setResponseMessage("internal error"); - resp.setAckFinalIndicator("Y"); - retval.setOutput(resp); - return new ResponseEntity<>(retval, HttpStatus.INTERNAL_SERVER_ERROR); - } - } - if (svcData != null) { - ctxIn.mergeJson("service-data", svcData); - } else { - log.debug("exiting {} because the service-instance does not have any service data in SDN", svcOperation); - - resp.setResponseCode("404"); - resp.setResponseMessage("invalid input: the service-instance does not have any service data in SDNC"); - resp.setAckFinalIndicator("Y"); - - retval.setOutput(resp); - - return new ResponseEntity<>(retval, HttpStatus.OK); - } - - // Add operational tree data to SvcLogicContext - List<OperationalServices> operServices = operationalServicesRepository.findBySvcInstanceId(svcInstanceId); - OperationalServices operService = null; - boolean saveOperationalData = false; - - if (operServices != null && !operServices.isEmpty()) { - operService = operServices.get(0); - ctxIn.mergeJson("operational-data", operService.getSvcData()); - } else { - operService = new OperationalServices(svcInstanceId, null, null); - } - - // Update service status info in config entry from input - configService.setServiceStatusAction(input.getInput().getRequestInformation().getRequestAction().toString()); - configService.setServiceStatusRpcAction(input.getInput().getSdncRequestHeader().getSvcAction().toString()); - configService.setServiceStatusRpcName(svcOperation); - - String ctxSvcDataJson = svcData; - - // Call DG - try { - // Any of these can throw a nullpointer exception - // execute should only throw a SvcLogicException - SvcLogicContext ctxOut = svc.execute(MODULE_NAME, svcOperation, null, "sync", ctxIn); - Properties respProps = ctxOut.toProperties(); - - resp.setAckFinalIndicator(respProps.getProperty("ack-final-indicator", "Y")); - resp.setResponseCode(respProps.getProperty("error-code", "200")); - resp.setResponseMessage(respProps.getProperty("error-message", "SUCCESS")); - - - - configService - .setServiceStatusRequestStatus(GenericResourceApiRequestStatusEnumeration.SYNCCOMPLETE.toString()); - - if ("200".equals(resp.getResponseCode())) { - - GenericResourceApiInstanceReference serviceReference = new GenericResourceApiInstanceReference(); - serviceReference.setInstanceId(svcInstanceId); - serviceReference.setObjectPath(respProps.getProperty(SERVICE_OBJECT_PATH_PARAM)); - resp.setServiceResponseInformation(serviceReference); - - GenericResourceApiInstanceReference networkReference = new GenericResourceApiInstanceReference(); - networkReference.setInstanceId(respProps.getProperty("networkId")); - networkReference.setObjectPath(respProps.getProperty(NETWORK_OBJECT_PATH_PARAM)); - resp.setNetworkResponseInformation(networkReference); - - // If DG returns success, update svcData in config and operational trees - // and remember to save operational data. - ctxSvcDataJson = ctxOut.toJsonString("service-data"); - operService.setSvcData(ctxSvcDataJson); - saveOperationalData = true; - } - - } catch (NullPointerException npe) { - resp.setAckFinalIndicator("true"); - resp.setResponseCode("500"); - resp.setResponseMessage("Check that you populated module, rpc and or mode correctly."); - } catch (SvcLogicException e) { - resp.setAckFinalIndicator("true"); - resp.setResponseCode("500"); - resp.setResponseMessage(e.getMessage()); - } - - // Update status in config services entry - - configService.setServiceStatusFinalIndicator(resp.getAckFinalIndicator()); - configService.setServiceStatusResponseCode(resp.getResponseCode()); - configService.setServiceStatusResponseMessage(resp.getResponseMessage()); - configService.setServiceStatusResponseTimestamp(Iso8601Util.now()); - - - // Save service data - try { - serviceDataHelper.saveService(configService, ctxSvcDataJson); - } catch (JsonProcessingException e) { - log.error("exiting {} due to error saving service data", svcOperation); - resp.setResponseCode("500"); - resp.setResponseMessage("internal error"); - resp.setAckFinalIndicator("Y"); - retval.setOutput(resp); - return new ResponseEntity<>(retval, HttpStatus.INTERNAL_SERVER_ERROR); - } - - // If necessary, sync status to operation service entry and save - if (saveOperationalData) { - operService.setServiceStatus(configService.getServiceStatus()); - operationalServicesRepository.save(operService); - } - retval.setOutput(resp); - - return (new ResponseEntity<>(retval, HttpStatus.OK)); - } - - @Override - public ResponseEntity<GenericResourceApiServiceTopologyOperation> operationsGENERICRESOURCEAPIserviceTopologyOperationPost( - @Valid GenericResourceApiServiceOperationInformationBodyparam input) throws RestException { - final String svcOperation = "service-topology-operation"; - GenericResourceApiServiceTopologyOperation retval = new GenericResourceApiServiceTopologyOperation(); - GenericResourceApiServicetopologyoperationOutput resp = new GenericResourceApiServicetopologyoperationOutput(); - - log.info(CALLED_STR, svcOperation); - - // Verify input contains service instance id - if (hasInvalidServiceId(input.getInput())) { - log.debug("exiting {} because of null or empty service-instance-id", svcOperation); - - resp.setResponseCode("404"); - resp.setResponseMessage("null or empty service-instance-id"); - resp.setAckFinalIndicator("Y"); - - retval.setOutput(resp); - - return new ResponseEntity<>(retval, HttpStatus.OK); - } - - String svcInstanceId = input.getInput().getServiceInformation().getServiceInstanceId(); - - SvcLogicContext ctxIn = new SvcLogicContext(); - - // Add input to SvcLogicContext - try { - ctxIn.mergeJson(svcOperation + "-input", objectMapper.writeValueAsString(input.getInput())); - } catch (JsonProcessingException e) { - log.error("exiting {} due to parse error on input data", svcOperation); - resp.setResponseCode("500"); - resp.setResponseMessage("internal error"); - resp.setAckFinalIndicator("Y"); - retval.setOutput(resp); - return new ResponseEntity<>(retval, HttpStatus.INTERNAL_SERVER_ERROR); - } - - // Add config tree data to SvcLogicContext - List<ConfigServices> configServices = configServicesRepository.findBySvcInstanceId(svcInstanceId); - ConfigServices configService = null; - String svcData = null; - if (configServices != null && !configServices.isEmpty()) { - configService = configServices.get(0); - try { - svcData = serviceDataHelper.getServiceDataAsString(svcInstanceId); - if (svcData != null) { - ctxIn.mergeJson("service-data", svcData); - } - } catch (JsonProcessingException e) { - log.error("exiting {} due to parse error on service data", svcOperation, e); - resp.setResponseCode("500"); - resp.setResponseMessage("internal error"); - resp.setAckFinalIndicator("Y"); - retval.setOutput(resp); - return new ResponseEntity<>(retval, HttpStatus.INTERNAL_SERVER_ERROR); - } - } else { - configService = new ConfigServices(svcInstanceId); - } - - - // Add operational tree data to SvcLogicContext - List<OperationalServices> operServices = operationalServicesRepository.findBySvcInstanceId(svcInstanceId); - OperationalServices operService = null; - boolean saveOperationalData = false; - - if (operServices != null && !operServices.isEmpty()) { - operService = operServices.get(0); - ctxIn.mergeJson("operational-data", operService.getSvcData()); - } else { - operService = new OperationalServices(svcInstanceId, null, null); - } - - // Update service status info in config entry from input - configService.setServiceStatusAction(input.getInput().getRequestInformation().getRequestAction().toString()); - configService.setServiceStatusRpcAction(input.getInput().getSdncRequestHeader().getSvcAction().toString()); - configService.setServiceStatusRpcName(svcOperation); - - String ctxSvcDataJson = svcData; - // Call DG - try { - // Any of these can throw a nullpointer exception - // execute should only throw a SvcLogicException - SvcLogicContext ctxOut = svc.execute(MODULE_NAME, svcOperation, null, "sync", ctxIn); - Properties respProps = ctxOut.toProperties(); - - resp.setAckFinalIndicator(respProps.getProperty("ack-final-indicator", "Y")); - resp.setResponseCode(respProps.getProperty("error-code", "200")); - resp.setResponseMessage(respProps.getProperty("error-message", "SUCCESS")); - - configService - .setServiceStatusRequestStatus(GenericResourceApiRequestStatusEnumeration.SYNCCOMPLETE.toString()); - - if ("200".equals(resp.getResponseCode())) { - GenericResourceApiInstanceReference serviceReference = new GenericResourceApiInstanceReference(); - serviceReference.setInstanceId(svcInstanceId); - serviceReference.setObjectPath(respProps.getProperty(SERVICE_OBJECT_PATH_PARAM)); - resp.setServiceResponseInformation(serviceReference); - - // If DG returns success, update svcData in config and operational trees - // and remember to save operational data. - ctxSvcDataJson= ctxOut.toJsonString("service-data"); - - operService.setSvcData(ctxSvcDataJson); - saveOperationalData = true; - } - - } catch (NullPointerException npe) { - resp.setAckFinalIndicator("true"); - resp.setResponseCode("500"); - resp.setResponseMessage("Check that you populated module, rpc and or mode correctly."); - } catch (SvcLogicException e) { - resp.setAckFinalIndicator("true"); - resp.setResponseCode("500"); - resp.setResponseMessage(e.getMessage()); - } - - // Update status in config services entry - - configService.setServiceStatusFinalIndicator(resp.getAckFinalIndicator()); - configService.setServiceStatusResponseCode(resp.getResponseCode()); - configService.setServiceStatusResponseMessage(resp.getResponseMessage()); - configService.setServiceStatusResponseTimestamp(Iso8601Util.now()); - - // Save service data - try { - serviceDataHelper.saveService(configService, ctxSvcDataJson); - } catch (JsonProcessingException e) { - log.error("exiting {} due to error saving service data", svcOperation, e); - resp.setResponseCode("500"); - resp.setResponseMessage("internal error"); - resp.setAckFinalIndicator("Y"); - retval.setOutput(resp); - return new ResponseEntity<>(retval, HttpStatus.INTERNAL_SERVER_ERROR); - } - - // If necessary, sync status to operation service entry and save - if (saveOperationalData) { - operService.setServiceStatus(configService.getServiceStatus()); - operationalServicesRepository.save(operService); - } - retval.setOutput(resp); - return (new ResponseEntity<>(retval, HttpStatus.OK)); - - } - - @Override - public ResponseEntity<GenericResourceApiVnfTopologyOperation> operationsGENERICRESOURCEAPIvnfTopologyOperationPost( - @Valid GenericResourceApiVnfOperationInformationBodyparam input) - throws RestException { - final String svcOperation = "vnf-topology-operation"; - GenericResourceApiVnfTopologyOperation retval = new GenericResourceApiVnfTopologyOperation(); - GenericResourceApiVnftopologyoperationOutput resp = new GenericResourceApiVnftopologyoperationOutput(); - - log.info(CALLED_STR, svcOperation); - // Verify input contains service instance id - if(hasInvalidServiceId(input.getInput())) { - log.debug("exiting {} because of null or empty service-instance-id", svcOperation); - - resp.setResponseCode("404"); - resp.setResponseMessage("null or empty service-instance-id"); - resp.setAckFinalIndicator("Y"); - - retval.setOutput(resp); - - return new ResponseEntity<>(retval, HttpStatus.OK); - } - - String svcInstanceId = input.getInput().getServiceInformation().getServiceInstanceId(); - String vnfId = null; - - if((input.getInput() != null) && (input.getInput().getVnfInformation() != null)) { - vnfId = input.getInput().getVnfInformation().getVnfId(); - } - - SvcLogicContext ctxIn = new SvcLogicContext(); - - // Add input to SvcLogicContext - try { - ctxIn.mergeJson(svcOperation + "-input", objectMapper.writeValueAsString(input.getInput())); - } - catch(JsonProcessingException e) { - log.error("exiting {} due to parse error on input data", svcOperation); - resp.setResponseCode("500"); - resp.setResponseMessage("internal error"); - resp.setAckFinalIndicator("Y"); - retval.setOutput(resp); - return new ResponseEntity<>(retval, HttpStatus.INTERNAL_SERVER_ERROR); - } - - // Add config tree data to SvcLogicContext - List<ConfigServices> configServices = configServicesRepository.findBySvcInstanceId(svcInstanceId); - ConfigServices configService = null; - String svcData = null; - if (configServices != null && !configServices.isEmpty()) { - configService = configServices.get(0); - try { - svcData = serviceDataHelper.getServiceDataAsString(svcInstanceId); - } catch (JsonProcessingException e) { - log.error("exiting {} due to parse error on service data", svcOperation); - resp.setResponseCode("500"); - resp.setResponseMessage("internal error"); - resp.setAckFinalIndicator("Y"); - retval.setOutput(resp); - return new ResponseEntity<>(retval, HttpStatus.INTERNAL_SERVER_ERROR); - } - } - if (svcData != null) { - ctxIn.mergeJson("service-data", svcData); - } else { - log.debug("exiting {} because the service-instance does not have any service data in SDN", svcOperation); - - resp.setResponseCode("404"); - resp.setResponseMessage("invalid input: the service-instance does not have any service data in SDNC"); - resp.setAckFinalIndicator("Y"); - - retval.setOutput(resp); - - return new ResponseEntity<>(retval, HttpStatus.OK); - } - - // Add operational tree data to SvcLogicContext - List<OperationalServices> operServices = operationalServicesRepository.findBySvcInstanceId(svcInstanceId); - OperationalServices operService = null; - boolean saveOperationalData = false; - - if(operServices != null && !operServices.isEmpty()) { - operService = operServices.get(0); - ctxIn.mergeJson("operational-data", operService.getSvcData()); - } - else { - operService = new OperationalServices(svcInstanceId, null, null); - } - - // Update service status info in config entry from input - configService.setServiceStatusAction(input.getInput().getRequestInformation().getRequestAction().toString()); - configService.setServiceStatusRpcAction(input.getInput().getSdncRequestHeader().getSvcAction().toString()); - configService.setServiceStatusRpcName(svcOperation); - - String ctxSvcDataJson = svcData; - - // Call DG - try { - // Any of these can throw a nullpointer exception - // execute should only throw a SvcLogicException - SvcLogicContext ctxOut = svc.execute(MODULE_NAME, svcOperation, null, "sync", ctxIn); - Properties respProps = ctxOut.toProperties(); - - resp.setAckFinalIndicator(respProps.getProperty("ack-final-indicator", "Y")); - resp.setResponseCode(respProps.getProperty("error-code", "200")); - resp.setResponseMessage(respProps.getProperty("error-message", "SUCCESS")); - - configService - .setServiceStatusRequestStatus(GenericResourceApiRequestStatusEnumeration.SYNCCOMPLETE.toString()); - - if("200".equals(resp.getResponseCode())) { - - GenericResourceApiInstanceReference serviceReference = new GenericResourceApiInstanceReference(); - serviceReference.setInstanceId(svcInstanceId); - serviceReference.setObjectPath(respProps.getProperty(SERVICE_OBJECT_PATH_PARAM)); - resp.setServiceResponseInformation(serviceReference); - - if(vnfId == null) { - vnfId = respProps.getProperty("vnfId"); - } - GenericResourceApiInstanceReference vnfReference = new GenericResourceApiInstanceReference(); - vnfReference.setInstanceId(vnfId); - vnfReference.setObjectPath(respProps.getProperty(VNF_OBJECT_PATH_PARAM)); - resp.setVnfResponseInformation(vnfReference); - - // If DG returns success, update svcData in config and operational trees - // and remember to save operational data. - ctxSvcDataJson = ctxOut.toJsonString("service-data"); - operService.setSvcData(ctxSvcDataJson); - saveOperationalData = true; - } - - } - catch(NullPointerException npe) { - resp.setAckFinalIndicator("Y"); - resp.setResponseCode("500"); - resp.setResponseMessage("Check that you populated module, rpc and or mode correctly."); - } - catch(SvcLogicException e) { - resp.setAckFinalIndicator("Y"); - resp.setResponseCode("500"); - resp.setResponseMessage(e.getMessage()); - } - - // Update status in config services entry - - configService.setServiceStatusFinalIndicator(resp.getAckFinalIndicator()); - configService.setServiceStatusResponseCode(resp.getResponseCode()); - configService.setServiceStatusResponseMessage(resp.getResponseMessage()); - configService.setServiceStatusResponseTimestamp(Iso8601Util.now()); - - // Save service data - try { - serviceDataHelper.saveService(configService, ctxSvcDataJson); - } catch (JsonProcessingException e) { - log.error("exiting {} due to error saving service data", svcOperation); - resp.setResponseCode("500"); - resp.setResponseMessage("internal error"); - resp.setAckFinalIndicator("Y"); - retval.setOutput(resp); - return new ResponseEntity<>(retval, HttpStatus.INTERNAL_SERVER_ERROR); - } - - - // If necessary, sync status to operation service entry and save - if(saveOperationalData) { - operService.setServiceStatus(configService.getServiceStatus()); - operationalServicesRepository.save(operService); - } - - if(resp.getAckFinalIndicator().equals("N")) { - // Spawn background thread to invoke the Async DG - Runnable backgroundThread = () -> { - log.info(BACKGROUND_THREAD_STARTED_MESSAGE); - processAsyncVnfTopologyOperation(svcOperation, input); - }; - new Thread(backgroundThread).start(); - } - - log.info("Returned {} for {} [{}] {}.", resp.getResponseCode(), svcOperation, vnfId, resp.getResponseMessage()); - retval.setOutput(resp); - return (new ResponseEntity<>(retval, HttpStatus.OK)); - } - - public void processAsyncVnfTopologyOperation(String parentOperation, @Valid GenericResourceApiVnfOperationInformationBodyparam input) { - final String svcOperation = "vnf-topology-operation-async"; - GenericResourceApiVnftopologyoperationOutput resp = new GenericResourceApiVnftopologyoperationOutput(); - - log.info(CALLED_STR, svcOperation); - // Verify input contains service instance id - String svcInstanceId = input.getInput().getServiceInformation().getServiceInstanceId(); - String vnfId = input.getInput().getVnfInformation().getVnfId(); - - SvcLogicContext ctxIn = new SvcLogicContext(); - - // Add input to SvcLogicContext - try { - ctxIn.mergeJson(parentOperation + "-input", objectMapper.writeValueAsString(input.getInput())); - } catch (JsonProcessingException e) { - log.error("exiting {} due to parse error on input data", svcOperation); - return; - } - - // Add config tree data to SvcLogicContext - List<ConfigServices> configServices = configServicesRepository.findBySvcInstanceId(svcInstanceId); - ConfigServices configService = null; - String svcData = null; - if (configServices != null && !configServices.isEmpty()) { - configService = configServices.get(0); - try { - svcData = serviceDataHelper.getServiceDataAsString(svcInstanceId); - } catch (JsonProcessingException e) { - log.error("exiting {} due to parse error on service data", svcOperation); - return; - } - } - if (svcData != null) { - ctxIn.mergeJson("service-data", svcData); - } else { - log.error("exiting {} because there is no service data with id [{}] in SDN", svcOperation, svcInstanceId); - return; - } - - - // Add operational tree data to SvcLogicContext - List<OperationalServices> operServices = operationalServicesRepository.findBySvcInstanceId(svcInstanceId); - OperationalServices operService = null; - - if(operServices != null && !operServices.isEmpty()) { - operService = operServices.get(0); - ctxIn.mergeJson("operational-data", operService.getSvcData()); - } - else { - operService = new OperationalServices(svcInstanceId, null, null); - } - - // Update service status info in config entry from input - configService.setServiceStatusAction(input.getInput().getRequestInformation().getRequestAction().toString()); - configService.setServiceStatusRpcAction(input.getInput().getSdncRequestHeader().getSvcAction().toString()); - configService.setServiceStatusRpcName(svcOperation); - - String ctxSvcDataJson = svcData; - - // Call DG - try { - // Any of these can throw a nullpointer exception - // execute should only throw a SvcLogicException - SvcLogicContext ctxOut = svc.execute(MODULE_NAME, svcOperation, null, "sync", ctxIn); - Properties respProps = ctxOut.toProperties(); - - resp.setAckFinalIndicator(respProps.getProperty("ack-final-indicator", "Y")); - resp.setResponseCode(respProps.getProperty("error-code", "200")); - resp.setResponseMessage(respProps.getProperty("error-message", "SUCCESS")); - - configService - .setServiceStatusRequestStatus(GenericResourceApiRequestStatusEnumeration.SYNCCOMPLETE.toString()); - - if("200".equals(resp.getResponseCode())) { - GenericResourceApiInstanceReference serviceReference = new GenericResourceApiInstanceReference(); - serviceReference.setInstanceId(svcInstanceId); - serviceReference.setObjectPath(respProps.getProperty(SERVICE_OBJECT_PATH_PARAM)); - resp.setServiceResponseInformation(serviceReference); - - if(vnfId == null) { - vnfId = respProps.getProperty("vnfId"); - } - GenericResourceApiInstanceReference vnfReference = new GenericResourceApiInstanceReference(); - vnfReference.setInstanceId(vnfId); - vnfReference.setObjectPath(respProps.getProperty(VNF_OBJECT_PATH_PARAM)); - resp.setVnfResponseInformation(vnfReference); - - // If DG returns success, update svcData in config and operational trees - // and remember to save operational data. - ctxSvcDataJson = ctxOut.toJsonString("service-data"); - operService.setSvcData(ctxSvcDataJson); - - // Update status in config services entry - - configService.setServiceStatusFinalIndicator(resp.getAckFinalIndicator()); - configService.setServiceStatusResponseCode(resp.getResponseCode()); - configService.setServiceStatusResponseMessage(resp.getResponseMessage()); - configService.setServiceStatusResponseTimestamp(Iso8601Util.now()); - - // Save service data - try { - serviceDataHelper.saveService(configService, ctxSvcDataJson); - } catch (JsonProcessingException e) { - log.error("exiting {} due to error saving service data", svcOperation); - return; - } - - // Update operational tree - operService.setServiceStatus(configService.getServiceStatus()); - operationalServicesRepository.save(operService); - log.info("Returned SUCCESS for {} [{}]", svcOperation, vnfId); - } - } - catch(Exception e) { - log.error("Caught Exception updating configuration status in SDN for {} [{}] \n", svcOperation, vnfId); - } - } - - @Override - public ResponseEntity<GenericResourceApiVfModuleTopologyOperation> operationsGENERICRESOURCEAPIvfModuleTopologyOperationPost( - @Valid GenericResourceApiVfModuleOperationInformationBodyparam input) - throws RestException { - final String svcOperation = "vf-module-topology-operation"; - GenericResourceApiVfModuleTopologyOperation retval = new GenericResourceApiVfModuleTopologyOperation(); - GenericResourceApiVfmoduletopologyoperationOutput resp = new GenericResourceApiVfmoduletopologyoperationOutput(); - - log.info(CALLED_STR, svcOperation); - - log.info("MYSQL_DATABASE = {}", System.getenv("MYSQL_DATABASE")); - // Verify input contains service instance id - if (hasInvalidServiceId(input.getInput())) { - log.debug("exiting {} because of null or empty service-instance-id", svcOperation); - - resp.setResponseCode("404"); - resp.setResponseMessage("null or empty service-instance-id"); - resp.setAckFinalIndicator("Y"); - retval.setOutput(resp); - return new ResponseEntity<>(retval, HttpStatus.OK); - } - - // Verify input contains vnf-id - if (hasInvalidVnfId(input.getInput())) { - log.debug("exiting {} because of null or empty vnf-id", svcOperation); - - resp.setResponseCode("404"); - resp.setResponseMessage("null or empty vnf-id"); - resp.setAckFinalIndicator("Y"); - retval.setOutput(resp); - return new ResponseEntity<>(retval, HttpStatus.OK); - } - - String svcInstanceId = input.getInput().getServiceInformation().getServiceInstanceId(); - String vnfId = input.getInput().getVnfInformation().getVnfId(); - String vfModuleId = input.getInput().getVfModuleInformation().getVfModuleId(); - - SvcLogicContext ctxIn = new SvcLogicContext(); - - // Add input to SvcLogicContext - try { - ctxIn.mergeJson(svcOperation + "-input", objectMapper.writeValueAsString(input.getInput())); - } catch (JsonProcessingException e) { - log.error("exiting {} due to parse error on input data", svcOperation); - resp.setResponseCode("500"); - resp.setResponseMessage("internal error"); - resp.setAckFinalIndicator("Y"); - retval.setOutput(resp); - return new ResponseEntity<>(retval, HttpStatus.INTERNAL_SERVER_ERROR); - } - - // Add config tree data to SvcLogicContext - List<ConfigServices> configServices = configServicesRepository.findBySvcInstanceId(svcInstanceId); - ConfigServices configService = null; - String svcData = null; - if (configServices != null && !configServices.isEmpty()) { - configService = configServices.get(0); - try { - svcData = serviceDataHelper.getServiceDataAsString(svcInstanceId); - } catch (JsonProcessingException e) { - log.error("exiting {} due to parse error on service data", svcOperation); - resp.setResponseCode("500"); - resp.setResponseMessage("internal error"); - resp.setAckFinalIndicator("Y"); - retval.setOutput(resp); - return new ResponseEntity<>(retval, HttpStatus.INTERNAL_SERVER_ERROR); - } - } - if (svcData != null) { - ctxIn.mergeJson("service-data", svcData); - } else { - log.debug("exiting {} because the service-instance does not have any service data in SDN", svcOperation); - - resp.setResponseCode("404"); - resp.setResponseMessage("invalid input: the service-instance does not have any service data in SDNC"); - resp.setAckFinalIndicator("Y"); - - retval.setOutput(resp); - - return new ResponseEntity<>(retval, HttpStatus.OK); - } - - // Add operational tree data to SvcLogicContext - List<OperationalServices> operServices = operationalServicesRepository.findBySvcInstanceId(svcInstanceId); - OperationalServices operService = null; - - if (operServices != null && !operServices.isEmpty()) { - operService = operServices.get(0); - log.info("Read ({}) data for [{}] operational-data: {}", - "OPERATIONAL_GRA_PORT_MIRROR_CONFIGURATIONS", svcInstanceId, operService.getSvcData().toString()); - //ctxIn.mergeJson("operational-data", operService.getSvcData()); - } else { - log.info("No operational-data found in OPERATIONAL_GRA_PORT_MIRROR_CONFIGURATIONS for [{}]", svcInstanceId); - operService = new OperationalServices(svcInstanceId, null, null); - } - - // Update service status info in config entry from input - configService.setServiceStatusAction(input.getInput().getRequestInformation().getRequestAction().toString()); - configService.setServiceStatusRpcAction(input.getInput().getSdncRequestHeader().getSvcAction().toString()); - configService.setServiceStatusRpcName(svcOperation); - - String ackFinal = "Y"; - String skipMdsalUpdate; - - - // Call DG - try { - // Any of these can throw a nullpointer exception - // execute should only throw a SvcLogicException - SvcLogicContext ctxOut = svc.execute(MODULE_NAME, svcOperation, null, "sync", ctxIn); - Properties respProps = ctxOut.toProperties(); - - ackFinal = respProps.getProperty("ack-final", "Y"); - skipMdsalUpdate = respProps.getProperty("skip-mdsal-update", "N"); - log.info("ackFinal [{}], skipMdsalUpdate [{}]", ackFinal, skipMdsalUpdate); - - resp.setAckFinalIndicator(ackFinal); - resp.setResponseCode(respProps.getProperty("error-code", "200")); - resp.setResponseMessage(respProps.getProperty("error-message", "SUCCESS")); - - // Update status in config services entry - configService.setServiceStatusFinalIndicator(resp.getAckFinalIndicator()); - configService.setServiceStatusResponseCode(resp.getResponseCode()); - configService.setServiceStatusResponseMessage(resp.getResponseMessage()); - configService.setServiceStatusResponseTimestamp(Iso8601Util.now()); - configService - .setServiceStatusRequestStatus(GenericResourceApiRequestStatusEnumeration.SYNCCOMPLETE.toString()); - - if ("200".equals(resp.getResponseCode())) { - - GenericResourceApiInstanceReference serviceReference = new GenericResourceApiInstanceReference(); - serviceReference.setInstanceId(svcInstanceId); - serviceReference.setObjectPath(respProps.getProperty(SERVICE_OBJECT_PATH_PARAM)); - resp.setServiceResponseInformation(serviceReference); - - GenericResourceApiInstanceReference vnfReference = new GenericResourceApiInstanceReference(); - vnfReference.setInstanceId(vnfId); - vnfReference.setObjectPath(respProps.getProperty(VNF_OBJECT_PATH_PARAM)); - resp.setVnfResponseInformation(vnfReference); - - GenericResourceApiInstanceReference vfModuleReference = new GenericResourceApiInstanceReference(); - vnfReference.setInstanceId(vfModuleId); - vnfReference.setObjectPath(respProps.getProperty(VF_MODULE_OBJECT_PATH_PARAM)); - resp.setVnfResponseInformation(vfModuleReference); - - if (skipMdsalUpdate.equals("N")) { - // If DG returns success, - // ONLY update svcData in config and operational trees - // and remember to save operational data when skip-mdsal-update is Y in ctx. - String ctxJson = ctxOut.toJsonString("service-data"); - log.info("Saving service-data in SDN because skipMdsalUpdate is {}", skipMdsalUpdate); - log.info("Service data : {}", ctxJson); - serviceDataHelper.saveService(configService, ctxJson); - - log.info("Copying service-data to operational-data"); - operService.setSvcData(ctxJson); - operService.setServiceStatus(configService.getServiceStatus()); - operationalServicesRepository.save(operService); - } - } - } catch (NullPointerException npe) { - resp.setAckFinalIndicator("Y"); - resp.setResponseCode("500"); - resp.setResponseMessage("Check that you populated module, rpc and or mode correctly."); - } catch (SvcLogicException e) { - resp.setAckFinalIndicator("Y"); - } catch (JsonProcessingException e) { - resp.setAckFinalIndicator("Y"); - resp.setResponseCode("500"); - resp.setResponseMessage("Internal error"); - log.error("exiting {} due to error updating service data", svcOperation, e); - } - - if (ackFinal.equals("N")) { - // Spawn background thread to invoke the Async DG - Runnable backgroundThread = new Runnable() { - public void run() { - log.info(BACKGROUND_THREAD_STARTED_MESSAGE); - processAsyncVfModuleTopologyOperation(svcOperation, input); - } - }; - new Thread(backgroundThread).start(); - } - retval.setOutput(resp); - return (new ResponseEntity<>(retval, HttpStatus.OK)); - } - - public void processAsyncVfModuleTopologyOperation( String parentOperation, - @Valid GenericResourceApiVfModuleOperationInformationBodyparam input) { - log.info(BACKGROUND_THREAD_INFO, input.getInput().getVfModuleInformation().getVfModuleId()); - final String svcOperation = "vf-module-topology-operation-async"; - - log.info(CALLED_STR, svcOperation); - String svcInstanceId = input.getInput().getServiceInformation().getServiceInstanceId(); - SvcLogicContext ctxIn = new SvcLogicContext(); - - // Add input to SvcLogicContext - try { - ctxIn.mergeJson(parentOperation + "-input", objectMapper.writeValueAsString(input.getInput())); - } catch (JsonProcessingException e) { - log.error("exiting {} due to parse error on input data", svcOperation); - return; - } - - // Add config tree data to SvcLogicContext - List<ConfigServices> configServices = configServicesRepository.findBySvcInstanceId(svcInstanceId); - ConfigServices configService = null; - String svcData = null; - if (configServices != null && !configServices.isEmpty()) { - configService = configServices.get(0); - try { - svcData = serviceDataHelper.getServiceDataAsString(svcInstanceId); - } catch (JsonProcessingException e) { - log.error("exiting {} due to parse error on service data", svcOperation); - return; - } - } - if (svcData != null) { - ctxIn.mergeJson("service-data", svcData); - } else { - log.error("exiting {} because there is no service data with id [{}] in SDN", svcOperation, svcInstanceId); - return; - } - - - // Add operational tree data to SvcLogicContext - List<OperationalServices> operServices = operationalServicesRepository.findBySvcInstanceId(svcInstanceId); - OperationalServices operService = null; - - if (operServices != null && !operServices.isEmpty()) { - operService = operServices.get(0); - log.info("Read ({}) data for [{}] operational-data: {}", - "OPERATIONAL_GRA_PORT_MIRROR_CONFIGURATIONS", svcInstanceId, operService.getSvcData().toString()); - //ctxIn.mergeJson("operational-data", operService.getSvcData()); - } else { - log.info("No operational-data found in OPERATIONAL_GRA_PORT_MIRROR_CONFIGURATIONS for [{}]", svcInstanceId); - operService = new OperationalServices(svcInstanceId, null, null); - } - - // Update service status info in config entry from input - configService.setServiceStatusAction(input.getInput().getRequestInformation().getRequestAction().toString()); - configService.setServiceStatusRpcAction(input.getInput().getSdncRequestHeader().getSvcAction().toString()); - configService.setServiceStatusRpcName(svcOperation); - - String respStatus = "SUCCESS"; - String errorMessage = null; - - String ctxSvcDataJson = svcData; - - log.info ("Adding INPUT data for {} [{}] input: {}", svcOperation, svcInstanceId, input.getInput().toString()); - - // Call DG - try { - // Any of these can throw a nullpointer exception - // execute should only throw a SvcLogicException - SvcLogicContext ctxOut = svc.execute(MODULE_NAME, svcOperation, null, "sync", ctxIn); - Properties respProps = ctxOut.toProperties(); - - String ackFinal = respProps.getProperty("ack-final-indicator", "Y"); - String errorCode = respProps.getProperty("error-code", "200"); - errorMessage = respProps.getProperty("error-message", "SUCCESS"); - - if (! "200".equals(errorCode)) { - respStatus = "FAILED"; - } - - // Update status in config services entry - configService.setServiceStatusFinalIndicator(ackFinal); - configService.setServiceStatusResponseTimestamp(Iso8601Util.now()); - configService.setServiceStatusResponseCode(errorCode); - configService.setServiceStatusResponseMessage(errorMessage); - configService - .setServiceStatusRequestStatus(GenericResourceApiRequestStatusEnumeration.SYNCCOMPLETE.toString()); - - ctxSvcDataJson = ctxOut.toJsonString("service-data"); - configServicesRepository.save(configService); - - // Save service data - try { - serviceDataHelper.saveService(configService, ctxSvcDataJson); - } catch (JsonProcessingException e) { - log.error("exiting {} due to error saving service data", svcOperation); - return; - } - - operService.setSvcData(ctxSvcDataJson); - operService.setServiceStatus(configService.getServiceStatus()); - operationalServicesRepository.save(operService); - - } catch (Exception ex) { - log.error("Caught Exception updating service status in SDN for {} [{}] \n", svcOperation, svcInstanceId); - } - log.info("Returned {} for {} [{}] {}.", respStatus, svcOperation, svcInstanceId, errorMessage); - } - - @Override - public ResponseEntity<GenericResourceApiPortMirrorTopologyOperation> operationsGENERICRESOURCEAPIportMirrorTopologyOperationPost( - @Valid GenericResourceApiPortMirrorTopologyOperationInformationBodyparam input) - throws RestException { - final String svcOperation = "port-mirror-topology-operation"; - GenericResourceApiPortMirrorTopologyOperation retval = new GenericResourceApiPortMirrorTopologyOperation(); - GenericResourceApiPortmirrortopologyoperationOutput resp = new GenericResourceApiPortmirrortopologyoperationOutput(); - - log.info(CALLED_STR, svcOperation); - - // Verify input contains configuration-id - if (hasInvalidConfigurationId(input.getInput())) { - log.debug("exiting {} because of null or empty configuration-id", svcOperation); - - resp.setResponseCode("404"); - resp.setResponseMessage("null or empty configuration-id"); - resp.setAckFinalIndicator("Y"); - retval.setOutput(resp); - return new ResponseEntity<>(retval, HttpStatus.OK); - } - - // Verify input contains service instance id - if (hasInvalidServiceId(input.getInput())) { - log.debug("exiting {} because of null or empty service-instance-id", svcOperation); - - resp.setResponseCode("404"); - resp.setResponseMessage("null or empty service-instance-id"); - resp.setAckFinalIndicator("Y"); - retval.setOutput(resp); - return new ResponseEntity<>(retval, HttpStatus.OK); - } - - String svcInstanceId = input.getInput().getServiceInformation().getServiceInstanceId(); - String configurationId = input.getInput().getConfigurationInformation().getConfigurationId(); - - SvcLogicContext ctxIn = new SvcLogicContext(); - - // Add input to SvcLogicContext - try { - ctxIn.mergeJson(svcOperation + "-input", objectMapper.writeValueAsString(input.getInput())); - } catch (JsonProcessingException e) { - log.error("exiting {} due to parse error on input data", svcOperation); - resp.setResponseCode("500"); - resp.setResponseMessage("internal error"); - resp.setAckFinalIndicator("Y"); - retval.setOutput(resp); - return new ResponseEntity<>(retval, HttpStatus.INTERNAL_SERVER_ERROR); - } - - // Add service instance config data to SvcLogicContext - List<ConfigServices> configServices = configServicesRepository.findBySvcInstanceId(svcInstanceId); - ConfigServices configService = null; - if (configServices != null && !configServices.isEmpty()) { - configService = configServices.get(0); - log.info("Read ({}) data for [{}] service-data: {}", "CONFIG_GRA_SERVICES", svcInstanceId, configService.getSvcData()); - ctxIn.mergeJson("service-data", configService.getSvcData()); - - } else { - log.debug("exiting {} because there is no service data with id [{}] in SDN", svcOperation, svcInstanceId); - resp.setResponseCode("404"); - resp.setResponseMessage("invalid input: there is no service-instance with id [{}] in SDNC"); - resp.setAckFinalIndicator("Y"); - - retval.setOutput(resp); - return new ResponseEntity<>(retval, HttpStatus.OK); - } - - // Add configuration config data to SvcLogicContext - List<ConfigPortMirrorConfigurations> configPortMirrorConfigurations = - configPortMirrorConfigurationsRepository.findByConfigurationId(configurationId); - ConfigPortMirrorConfigurations configPortMirrorConfiguration; - if (configPortMirrorConfigurations != null && !configPortMirrorConfigurations.isEmpty()) { - configPortMirrorConfiguration = configPortMirrorConfigurations.get(0); - log.info("Read ({}) data for [{}] configuration-data: {}", - "CONFIG_GRA_PORT_MIRROR_CONFIGURATIONS", configurationId, configPortMirrorConfiguration.getPmcData()); - ctxIn.mergeJson("configuration-data", configPortMirrorConfiguration.getPmcData()); - - } else { - log.info("No configuration-data found ({}) for [{}]", "CONFIG_GRA_PORT_MIRROR_CONFIGURATIONS", configurationId); - configPortMirrorConfiguration = new ConfigPortMirrorConfigurations(configurationId, null); - } - - /* - // Add configuration operational data to SvcLogicContext - List<OperationalPortMirrorConfigurations> operPortMirrorConfigurations = - operationalPortMirrorConfigurationsRepository.findByConfigurationId(configurationId); - OperationalPortMirrorConfigurations operPortMirrorConfiguration; - - if (operPortMirrorConfigurations != null && !operPortMirrorConfigurations.isEmpty()) { - operPortMirrorConfiguration = operPortMirrorConfigurations.get(0); - log.info("Read ({}) data for [{}] operational-data: {}", - "OPERATIONAL_GRA_PORT_MIRROR_CONFIGURATIONS", configurationId, operPortMirrorConfiguration.getPmcData()); - ctxIn.mergeJson("operational-data", operPortMirrorConfiguration.getPmcData()); - - } else { - log.info("No operational-data found ({}) for [{}]", "OPERATIONAL_GRA_PORT_MIRROR_CONFIGURATIONS", configurationId); - operPortMirrorConfiguration = new OperationalPortMirrorConfigurations(configurationId, null, null); - } - - */ - - String ackFinal = "Y"; - String errorCode = "200"; - String errorMessage = "SUCCESS"; - String respStatus = "SUCCESS"; - - log.info(ADDING_INPUT_DATA_LOG, svcOperation, svcInstanceId, input.getInput().toString()); - //log.info(ADDING_INPUT_DATA_LOG, svcOperation, svcInstanceId, input.toString()); - - // Update service status info in config entry from input - configPortMirrorConfiguration.setPortMirrorConfigurationStatusAction(input.getInput().getRequestInformation().getRequestAction().toString()); - configPortMirrorConfiguration.setPortMirrorConfigurationStatusRpcAction(input.getInput().getSdncRequestHeader().getSvcAction().toString()); - configPortMirrorConfiguration.setPortMirrorConfigurationStatusRpcName(svcOperation); - - // Call DG - try { - // Any of these can throw a nullpointer exception - // execute should only throw a SvcLogicException - SvcLogicContext ctxOut = svc.execute(MODULE_NAME, svcOperation, null, "sync", ctxIn); - Properties respProps = ctxOut.toProperties(); - - ackFinal = respProps.getProperty("ack-final", "Y"); - errorCode = respProps.getProperty("error-code", "200"); - errorMessage = respProps.getProperty("error-message", "SUCCESS"); - log.info("ackFinal [{}], error-code [{}], error-message [{}]", ackFinal, errorCode, errorMessage); - - resp.setAckFinalIndicator(ackFinal); - resp.setResponseCode(errorCode); - resp.setResponseMessage(errorMessage); - - // Update status in config services entry - configPortMirrorConfiguration - .setPortMirrorConfigurationStatusRequestStatus(GenericResourceApiRequestStatusEnumeration.SYNCCOMPLETE.toString()); - configPortMirrorConfiguration.setPortMirrorConfigurationStatusFinalIndicator(resp.getAckFinalIndicator()); - configPortMirrorConfiguration.setPortMirrorConfigurationStatusResponseCode(resp.getResponseCode()); - configPortMirrorConfiguration.setPortMirrorConfigurationStatusResponseMessage(resp.getResponseMessage()); - configPortMirrorConfiguration.setPortMirrorConfigurationStatusResponseTimestamp(Iso8601Util.now()); - - GenericResourceApiInstanceReference serviceReference = new GenericResourceApiInstanceReference(); - serviceReference.setInstanceId(svcInstanceId); - serviceReference.setObjectPath(respProps.getProperty(SERVICE_OBJECT_PATH_PARAM)); - resp.setServiceResponseInformation(serviceReference); - - GenericResourceApiInstanceReference pmcReference = new GenericResourceApiInstanceReference(); - serviceReference.setInstanceId(configurationId); - serviceReference.setObjectPath(respProps.getProperty(PORT_MIRROR_OBJECT_PATH_PARAM)); - resp.setServiceResponseInformation(pmcReference); - - retval.setOutput(resp); - - // ONLY update pmcData in config and operational trees - //String ctxJson = ctxOut.toJsonString("configuration-data"); - //configPortMirrorConfiguration.setPmcData(ctxJson); - //operPortMirrorConfiguration.setPmcData(ctxJson); - //configPortMirrorConfigurationsRepository.save(configPortMirrorConfiguration); - - // If necessary, sync status to operation service entry and save - //operPortMirrorConfiguration.setPortMirrorConfigurationStatus(configPortMirrorConfiguration.getPortMirrorConfigurationStatus()); - //operationalPortMirrorConfigurationsRepository.save(operPortMirrorConfiguration); - - if (! "200".equals(errorCode)) { - respStatus = "FAILED"; - } - - } catch (NullPointerException npe) { - resp.setAckFinalIndicator("Y"); - resp.setResponseCode("500"); - resp.setResponseMessage("Check that you populated module, rpc and or mode correctly."); - } catch (SvcLogicException e) { - resp.setAckFinalIndicator("Y"); - } - - if (ackFinal.equals("N")) { - // Spawn background thread to invoke the Async DG - Runnable backgroundThread = new Runnable() { - public void run() { - log.info(BACKGROUND_THREAD_STARTED_MESSAGE); - processAsyncPortMirrorTopologyOperation(svcOperation, input); - } - }; - new Thread(backgroundThread).start(); - } - log.info("Returned {} for {} [{}] {}.", respStatus, svcOperation, configurationId, errorMessage); - return (new ResponseEntity<>(retval, HttpStatus.OK)); - } - - public void processAsyncPortMirrorTopologyOperation( String parentOperation, - @Valid GenericResourceApiPortMirrorTopologyOperationInformationBodyparam input) { - log.info(BACKGROUND_THREAD_INFO, input.getInput().getConfigurationInformation().getConfigurationId()); - final String svcOperation = "port-mirror-topology-operation-async"; - - log.info(CALLED_STR, svcOperation); - String svcInstanceId = input.getInput().getServiceInformation().getServiceInstanceId(); - String configurationId = input.getInput().getConfigurationInformation().getConfigurationId(); - SvcLogicContext ctxIn = new SvcLogicContext(); - - String errorMessage; - - // Add input to SvcLogicContext - try { - ctxIn.mergeJson(parentOperation + "-input", objectMapper.writeValueAsString(input.getInput())); - } catch (JsonProcessingException e) { - log.error("exiting {} due to parse error on input data", svcOperation); - return; - } - - // Add service instance config data to SvcLogicContext - List<ConfigServices> configServices = configServicesRepository.findBySvcInstanceId(svcInstanceId); - ConfigServices configService = null; - if (configServices != null && !configServices.isEmpty()) { - configService = configServices.get(0); - ctxIn.mergeJson("service-data", configService.getSvcData()); - } else { - log.error("exiting {} because there is no service data with id [{}] in SDN", svcOperation, svcInstanceId); - return; - } - - // Add config tree data to SvcLogicContext - List<ConfigPortMirrorConfigurations> configPortMirrorConfigurations = configPortMirrorConfigurationsRepository.findByConfigurationId(configurationId); - ConfigPortMirrorConfigurations configPortMirrorConfiguration; - if (configPortMirrorConfigurations != null && !configPortMirrorConfigurations.isEmpty()) { - configPortMirrorConfiguration = configPortMirrorConfigurations.get(0); - ctxIn.mergeJson("configuration-data", configPortMirrorConfiguration.getPmcData()); - } else { - configPortMirrorConfiguration = new ConfigPortMirrorConfigurations(configurationId, null); - } - - /* - // Add operational tree data to SvcLogicContext - List<OperationalPortMirrorConfigurations> operPortMirrorConfigurations = operationalPortMirrorConfigurationsRepository.findByConfigurationId(configurationId); - OperationalPortMirrorConfigurations operPortMirrorConfiguration = null; - - if (operPortMirrorConfigurations != null && !operPortMirrorConfigurations.isEmpty()) { - operPortMirrorConfiguration = operPortMirrorConfigurations.get(0); - ctxIn.mergeJson("operational-data", operPortMirrorConfiguration.getPmcData()); - } else { - operPortMirrorConfiguration = new OperationalPortMirrorConfigurations(configurationId, null, null); - } - - */ - - // Update service status info in config entry from input - configPortMirrorConfiguration.setPortMirrorConfigurationStatusAction(input.getInput().getRequestInformation().getRequestAction().toString()); - configPortMirrorConfiguration.setPortMirrorConfigurationStatusRpcAction(input.getInput().getSdncRequestHeader().getSvcAction().toString()); - configPortMirrorConfiguration.setPortMirrorConfigurationStatusRpcName(parentOperation); - - log.info("Adding INPUT data for {} [{}] input: {}", svcOperation, svcInstanceId, input.toString()); - - // Call DG - try { - // Any of these can throw a nullpointer exception - // execute should only throw a SvcLogicException - SvcLogicContext ctxOut = svc.execute(MODULE_NAME, svcOperation, null, "sync", ctxIn); - Properties respProps = ctxOut.toProperties(); - - String ackFinalIndicator = respProps.getProperty("ack-final-indicator", "Y"); - String errorCode = respProps.getProperty("error-code", "200"); - errorMessage = respProps.getProperty("error-message", "SUCCESS"); - - // Update status in config services entry - configPortMirrorConfiguration.setPortMirrorConfigurationStatusFinalIndicator(ackFinalIndicator); - configPortMirrorConfiguration.setPortMirrorConfigurationStatusResponseTimestamp(Iso8601Util.now()); - configPortMirrorConfiguration.setPortMirrorConfigurationStatusResponseCode(errorCode); - configPortMirrorConfiguration.setPortMirrorConfigurationStatusResponseMessage(errorMessage); - configPortMirrorConfiguration - .setPortMirrorConfigurationStatusRequestStatus(GenericResourceApiRequestStatusEnumeration.SYNCCOMPLETE.toString()); - - // ONLY update status - //String ctxJson = ctxOut.toJsonString("configuration-data"); - //configPortMirrorConfiguration.setPmcData(ctxJson); - //configPortMirrorConfiguration.setPmcData(ctxJson); - - // Update config tree - configPortMirrorConfigurationsRepository.save(configPortMirrorConfiguration); - - //update operational tree - //operPortMirrorConfiguration.setPortMirrorConfigurationStatus(configPortMirrorConfiguration.getPortMirrorConfigurationStatus()); - //operationalPortMirrorConfigurationsRepository.save(operPortMirrorConfiguration); - - } catch (Exception e) { - log.error("Caught Exception updating configuration status in SDN for {} [{}] \n", svcOperation, configurationId); - } - log.info("Returned SUCCESS for {} [{}]", svcOperation, configurationId); - } - - @Override - public ResponseEntity<GenericResourceApiVnfGetResourceRequest> operationsGENERICRESOURCEAPIvnfGetResourceRequestPost( - @Valid GenericResourceApiVnfgetresourcerequestInputBodyparam input) - throws RestException { - final String svcOperation = "vnf-get-resource-request"; - GenericResourceApiVnfGetResourceRequest retval = new GenericResourceApiVnfGetResourceRequest(); - - log.info(CALLED_STR, svcOperation); - // Verify input contains service instance id - if (hasInvalidServiceId(input.getInput())) { - log.debug("exiting {} because of null or empty service-instance-id", svcOperation); - //return new ResponseEntity<>(retval, HttpStatus.OK); - } - - String svcInstanceId = input.getInput().getServiceInformation().getServiceInstanceId(); - SvcLogicContext ctxIn = new SvcLogicContext(); - - // Add input to SvcLogicContext - try { - ctxIn.mergeJson(svcOperation + "-input", objectMapper.writeValueAsString(input.getInput())); - } catch (JsonProcessingException e) { - log.error("exiting {} due to parse error on input data", svcOperation); - return new ResponseEntity<>(retval, HttpStatus.INTERNAL_SERVER_ERROR); - } - - // Add config tree data to SvcLogicContext - List<ConfigServices> configServices = configServicesRepository.findBySvcInstanceId(svcInstanceId); - ConfigServices configService = null; - if (configServices != null && !configServices.isEmpty()) { - configService = configServices.get(0); - try { - ctxIn.mergeJson("service-data", serviceDataHelper.getServiceDataAsString(svcInstanceId)); - } catch (JsonProcessingException e) { - log.error("exiting {} due to parse error on service data", svcOperation); - return new ResponseEntity<>(retval, HttpStatus.INTERNAL_SERVER_ERROR); - } - } else { - log.debug("exiting {} because the service-instance does not have any service data in SDN", svcOperation); - return new ResponseEntity<>(retval, HttpStatus.OK); - } - - // Call DG - try { - // Any of these can throw a nullpointer exception - // execute should only throw a SvcLogicException - SvcLogicContext ctxOut = svc.execute(MODULE_NAME, svcOperation, null, "sync", ctxIn); - - - String ctxJson = ctxOut.toJsonString("vnf-get-resource-request-output"); - GenericResourceApiVnfgetresourcerequestOutput vnfgetresourcerequestOutput = - objectMapper.readValue(ctxJson, GenericResourceApiVnfgetresourcerequestOutput.class); - - retval.setOutput(vnfgetresourcerequestOutput); - - } catch (Exception e) { - return (new ResponseEntity<>(retval, HttpStatus.INTERNAL_SERVER_ERROR)); - } - return (new ResponseEntity<>(retval, HttpStatus.OK)); - } - - @Override - public ResponseEntity<GenericResourceApiPolicyUpdateNotifyOperation> operationsGENERICRESOURCEAPIpolicyUpdateNotifyOperationPost( - @Valid GenericResourceApiPolicyupdatenotifyoperationInputBodyparam input) - throws RestException { - final String svcOperation = "policy-update-notify-operation"; - GenericResourceApiPolicyUpdateNotifyOperation retval = new GenericResourceApiPolicyUpdateNotifyOperation(); - GenericResourceApiPolicyupdatenotifyoperationOutput resp = new GenericResourceApiPolicyupdatenotifyoperationOutput(); - - log.info(CALLED_STR, svcOperation); - // Verify required input elements - if (hasInvalidPolicyUpdateInput(input.getInput())) { - log.debug("exiting {} because policy name, update type, or version id was not provided", svcOperation); - resp.setErrorCode("404"); - resp.setErrorMsg("policy-name, update-type, and/or version-id is null or empty"); - retval.setOutput(resp); - return new ResponseEntity<>(retval, HttpStatus.OK); - } - - SvcLogicContext ctxIn = new SvcLogicContext(); - - // Add input to SvcLogicContext - try { - ctxIn.mergeJson(svcOperation + "-input", objectMapper.writeValueAsString(input.getInput())); - } catch (JsonProcessingException e) { - log.error("exiting {} due to parse error on input data", svcOperation); - resp.setErrorCode("500"); - resp.setErrorMsg("internal error"); - retval.setOutput(resp); - return new ResponseEntity<>(retval, HttpStatus.INTERNAL_SERVER_ERROR); - } - - // Call DG - try { - // Any of these can throw a nullpointer exception - // execute should only throw a SvcLogicException - SvcLogicContext ctxOut = svc.execute(MODULE_NAME, svcOperation, null, "sync", ctxIn); - Properties respProps = ctxOut.toProperties(); - resp.setErrorCode(respProps.getProperty("error-code", "200")); - resp.setErrorMsg(respProps.getProperty("error-message", "SUCCESS")); - - /* For debugging Only - respProps.forEach((k,v) -> { - log.debug("prop: {} -> {}",k,v); - }); - */ - - } catch (NullPointerException npe) { - resp.setErrorCode("500"); - resp.setErrorMsg("Check that you populated module, rpc and or mode correctly."); - } catch (SvcLogicException e) { - resp.setErrorCode("500"); - resp.setErrorMsg(e.getMessage()); - } - - retval.setOutput(resp); - return (new ResponseEntity<>(retval, HttpStatus.OK)); - } - -} diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/controllers/ServiceDataHelper.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/controllers/ServiceDataHelper.java deleted file mode 100644 index f04a3ac..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/controllers/ServiceDataHelper.java +++ /dev/null @@ -1,567 +0,0 @@ -package org.onap.sdnc.apps.ms.gra.controllers; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -import org.onap.sdnc.apps.ms.gra.data.ConfigNetworks; -import org.onap.sdnc.apps.ms.gra.data.ConfigNetworksRepository; -import org.onap.sdnc.apps.ms.gra.data.ConfigServices; -import org.onap.sdnc.apps.ms.gra.data.ConfigServicesRepository; -import org.onap.sdnc.apps.ms.gra.data.ConfigVfModules; -import org.onap.sdnc.apps.ms.gra.data.ConfigVfModulesRepository; -import org.onap.sdnc.apps.ms.gra.data.ConfigVnfs; -import org.onap.sdnc.apps.ms.gra.data.ConfigVnfsRepository; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiServicedataServiceData; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiServicedataServicedataNetworks; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiServicedataServicedataNetworksNetwork; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiServicedataServicedataNetworksNetworkNetworkData; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiServicedataServicedataVnfs; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiServicedataServicedataVnfsVnf; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiServicedataServicedataVnfsVnfVnfData; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiServicedataServicedataVnfsVnfVnfdataVfModules; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiServicedataServicedataVnfsVnfVnfdataVfmodulesVfModule; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiServicedataServicedataVnfsVnfVnfdataVfmodulesVfmoduleVfModuleData; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; - -@Component -@ComponentScan(basePackages = { "org.onap.sdnc.apps.ms.gra.*", "org.onap.ccsdk.apps.services" }) - -public class ServiceDataHelper { - - @Autowired - private ObjectMapper objectMapper; - - @Autowired - private ConfigServicesRepository configServicesRepository; - - @Autowired - private ConfigNetworksRepository configNetworksRepository; - - @Autowired - private ConfigVnfsRepository configVnfsRepository; - - @Autowired - private ConfigVfModulesRepository configVfModulesRepository; - - public ServiceDataHelper() { - - } - - public class ServiceDataTransaction { - private List<ConfigServices> servicesToSave = new LinkedList<ConfigServices>(); - private List<ConfigNetworks> networksToSave = new LinkedList<ConfigNetworks>(); - private List<ConfigVnfs> vnfsToSave = new LinkedList<ConfigVnfs>(); - private List<ConfigVfModules> vfModulesToSave = new LinkedList<ConfigVfModules>(); - - private List<ConfigServices> servicesToRemove = new LinkedList<ConfigServices>(); - private List<ConfigNetworks> networksToRemove = new LinkedList<ConfigNetworks>(); - private List<ConfigVnfs> vnfsToRemove = new LinkedList<ConfigVnfs>(); - private List<ConfigVfModules> vfModulesToRemove = new LinkedList<ConfigVfModules>(); - - // Deferred saves not working for now - do all immediate - public void save(ConfigServices service) { - // servicesToSave.add(service); - configServicesRepository.save(service); - } - - public void save(ConfigNetworks network) { - // networksToSave.add(network); - configNetworksRepository.save(network); - } - - public void save(ConfigVnfs vnf) { - // vnfsToSave.add(vnf); - configVnfsRepository.save(vnf); - } - - public void save(ConfigVfModules vfModule) { - // vfModulesToSave.add(vfModule); - configVfModulesRepository.save(vfModule); - } - - public void remove(ConfigServices service) { - // servicesToRemove.add(service); - configServicesRepository.delete(service); - } - - public void remove(ConfigNetworks network) { - // networksToRemove.add(network); - configNetworksRepository.delete(network); - } - - public void remove(ConfigVnfs vnf) { - // vnfsToRemove.add(vnf); - configVnfsRepository.delete(vnf); - } - - public void remove(ConfigVfModules vfModule) { - // vfModulesToRemove.add(vfModule); - configVfModulesRepository.delete(vfModule); - } - - - public void commit() { - - long numServicesBefore = configServicesRepository.count(); - long numNetworksBefore = configNetworksRepository.count(); - long numVnfsBefore = configVnfsRepository.count(); - long numVfModulesBefore = configVfModulesRepository.count(); - - // Commit is a no-op for now - return; - /* - for (ConfigServices service : servicesToSave) { - configServicesRepository.save(service); - } - for (ConfigNetworks network : networksToSave) { - configNetworksRepository.save(network); - } - for (ConfigVnfs vnf: vnfsToSave) { - configVnfsRepository.save(vnf); - } - for (ConfigVfModules vfModule : vfModulesToSave) { - configVfModulesRepository.save(vfModule); - } - for (ConfigServices service : servicesToRemove) { - configServicesRepository.delete(service); - } - for (ConfigNetworks network : networksToSave) { - configNetworksRepository.delete(network); - } - for (ConfigVnfs vnf: vnfsToSave) { - configVnfsRepository.delete(vnf); - } - for (ConfigVfModules vfModule : vfModulesToSave) { - configVfModulesRepository.delete(vfModule); - } - long numServicesAfter = configServicesRepository.count(); - long numNetworksAfter = configNetworksRepository.count(); - long numVnfsAfter = configVnfsRepository.count(); - long numVfModulesAfter = configVfModulesRepository.count(); - - System.out.print("Done"); - */ - } - } - - public ServiceDataTransaction createTransaction() { - return new ServiceDataTransaction(); - } - - public GenericResourceApiServicedataServicedataVnfsVnfVnfdataVfmodulesVfModule getVfModule(String svcInstanceId, - String vnfId, String vfModuleId) throws JsonProcessingException { - GenericResourceApiServicedataServicedataVnfsVnfVnfdataVfmodulesVfModule vfModule = null; - List<ConfigVfModules> configVfModules = configVfModulesRepository - .findBySvcInstanceIdAndVnfIdAndVfModuleId(svcInstanceId, vnfId, vfModuleId); - if ((configVfModules != null) && !configVfModules.isEmpty()) { - ConfigVfModules configVfModule = configVfModules.get(0); - vfModule = new GenericResourceApiServicedataServicedataVnfsVnfVnfdataVfmodulesVfModule(); - vfModule.setVfModuleId(configVfModule.getVfModuleId()); - String vfModuleDataAsString = configVfModule.getVfModuleData(); - if (vfModuleDataAsString != null) { - vfModule.setVfModuleData(objectMapper.readValue(vfModuleDataAsString, - GenericResourceApiServicedataServicedataVnfsVnfVnfdataVfmodulesVfmoduleVfModuleData.class)); - } - - } - return (vfModule); - } - - public GenericResourceApiServicedataServicedataVnfsVnfVnfdataVfModules getVfModules(String svcInstanceId, String vnfId) throws JsonProcessingException { - GenericResourceApiServicedataServicedataVnfsVnfVnfdataVfModules vfModules = null; - List<ConfigVfModules> configVfModules = configVfModulesRepository.findBySvcInstanceIdAndVnfId(svcInstanceId, vnfId); - if ((configVfModules != null) && !configVfModules.isEmpty()) { - vfModules = new GenericResourceApiServicedataServicedataVnfsVnfVnfdataVfModules(); - for (ConfigVfModules configVfModule : configVfModules) { - GenericResourceApiServicedataServicedataVnfsVnfVnfdataVfmodulesVfModule vfModule = new GenericResourceApiServicedataServicedataVnfsVnfVnfdataVfmodulesVfModule(); - vfModule.setVfModuleId(configVfModule.getVfModuleId()); - String vfModuleDataAsString = configVfModule.getVfModuleData(); - if (vfModuleDataAsString != null) { - vfModule.setVfModuleData(objectMapper.readValue(vfModuleDataAsString, GenericResourceApiServicedataServicedataVnfsVnfVnfdataVfmodulesVfmoduleVfModuleData.class)); - } - vfModules.addVfModuleItem(vfModule); - } - } - return(vfModules); - } - - public GenericResourceApiServicedataServicedataVnfsVnf getVnf(String svcInstanceId, String vnfId) throws JsonProcessingException { - GenericResourceApiServicedataServicedataVnfsVnf vnf = null; - List<ConfigVnfs> configVnfs = configVnfsRepository.findBySvcInstanceIdAndVnfId(svcInstanceId, vnfId); - if ((configVnfs != null) && !configVnfs.isEmpty()) { - ConfigVnfs configVnf = configVnfs.get(0); - vnf = new GenericResourceApiServicedataServicedataVnfsVnf(); - vnf.setVnfId(configVnf.getVnfId()); - GenericResourceApiServicedataServicedataVnfsVnfVnfData vnfDataAsObject = null; - String vnfDataAsString = configVnf.getVnfData(); - if (vnfDataAsString != null) { - vnfDataAsObject = objectMapper.readValue(vnfDataAsString, GenericResourceApiServicedataServicedataVnfsVnfVnfData.class); - } - - GenericResourceApiServicedataServicedataVnfsVnfVnfdataVfModules vfModules = getVfModules(svcInstanceId, vnfId); - if (vfModules != null) { - if (vnfDataAsObject == null) { - vnfDataAsObject = new GenericResourceApiServicedataServicedataVnfsVnfVnfData(); - } - vnfDataAsObject.setVfModules(vfModules); - } - vnf.setVnfData(vnfDataAsObject); - } - return(vnf); - } - - public GenericResourceApiServicedataServicedataVnfs getVnfs(String svcInstanceId) throws JsonProcessingException { - - GenericResourceApiServicedataServicedataVnfs vnfs = null; - - List<ConfigVnfs> configVnfs = configVnfsRepository.findBySvcInstanceId(svcInstanceId); - if ((configVnfs != null) && !configVnfs.isEmpty()) { - vnfs = new GenericResourceApiServicedataServicedataVnfs(); - for (ConfigVnfs configVnf : configVnfs) { - GenericResourceApiServicedataServicedataVnfsVnf vnf = new GenericResourceApiServicedataServicedataVnfsVnf(); - vnf.setVnfId(configVnf.getVnfId()); - GenericResourceApiServicedataServicedataVnfsVnfVnfData vnfDataAsObject = null; - String vnfDataAsString = configVnf.getVnfData(); - if (vnfDataAsString != null) { - vnfDataAsObject = objectMapper.readValue(vnfDataAsString, - GenericResourceApiServicedataServicedataVnfsVnfVnfData.class); - } - - GenericResourceApiServicedataServicedataVnfsVnfVnfdataVfModules vfModules = getVfModules(svcInstanceId, configVnf.getVnfId()); - if (vfModules != null) { - if (vnfDataAsObject == null) { - vnfDataAsObject = new GenericResourceApiServicedataServicedataVnfsVnfVnfData(); - } - vnfDataAsObject.setVfModules(vfModules); - } - vnf.setVnfData(vnfDataAsObject); - vnfs.addVnfItem(vnf); - } - } - return (vnfs); - } - - public GenericResourceApiServicedataServicedataNetworks getNetworks(String svcInstanceId) throws JsonProcessingException { - GenericResourceApiServicedataServicedataNetworks networks = null; - List<ConfigNetworks> configNetworks = configNetworksRepository.findBySvcInstanceId(svcInstanceId); - if ((configNetworks != null) && !configNetworks.isEmpty()) { - networks = new GenericResourceApiServicedataServicedataNetworks(); - - for (ConfigNetworks configNetwork : configNetworks) { - GenericResourceApiServicedataServicedataNetworksNetwork network = new GenericResourceApiServicedataServicedataNetworksNetwork(); - network.setNetworkId(configNetwork.getNetworkId()); - String networkDataAsString = configNetwork.getNetworkData(); - if (networkDataAsString != null) { - network.setNetworkData(objectMapper.readValue(networkDataAsString, GenericResourceApiServicedataServicedataNetworksNetworkNetworkData.class)); - } - networks.addNetworkItem(network); - } - } - - return(networks); - } - - public String getServiceDataAsString(String svcInstanceId) throws JsonProcessingException { - GenericResourceApiServicedataServiceData svcData = getServiceData(svcInstanceId); - if (svcData == null) { - return(null); - } else { - return(objectMapper.writeValueAsString(getServiceData(svcInstanceId))); - } - } - - public GenericResourceApiServicedataServiceData getServiceData(String svcInstanceId) throws JsonProcessingException { - - List<ConfigServices> configServices = configServicesRepository.findBySvcInstanceId(svcInstanceId); - if ((configServices != null) && !configServices.isEmpty()) { - return(getServiceData(configServices.get(0))); - } else { - return(null); - } - } - - public GenericResourceApiServicedataServiceData getServiceData(ConfigServices configService) throws JsonProcessingException { - if (configService == null) { - return(null); - } - - GenericResourceApiServicedataServiceData svcData; - String svcInstanceId = configService.getSvcInstanceId(); - String svcDataAsString = configService.getSvcData(); - - if ((svcDataAsString != null) && !svcDataAsString.isEmpty()) { - svcData = objectMapper.readValue(svcDataAsString, GenericResourceApiServicedataServiceData.class); - } else { - svcData = new GenericResourceApiServicedataServiceData(); - } - - // Add networks - GenericResourceApiServicedataServicedataNetworks networks = getNetworks(svcInstanceId); - if (networks != null) { - svcData.setNetworks(networks); - } - - //Add Vnfs - GenericResourceApiServicedataServicedataVnfs vnfs = getVnfs(svcInstanceId); - if (vnfs != null) { - svcData.setVnfs(vnfs); - } - - return(svcData); - - } - - public void saveVfModule(String svcInstanceId, String vnfId, GenericResourceApiServicedataServicedataVnfsVnfVnfdataVfmodulesVfModule vfModule, ServiceDataTransaction transaction) throws JsonProcessingException { - if (vfModule == null) { - return; - } - List<ConfigVfModules> configVfModules = configVfModulesRepository.findBySvcInstanceIdAndVnfIdAndVfModuleId(svcInstanceId, vnfId, vfModule.getVfModuleId()); - ConfigVfModules configVfModule; - if ((configVfModules != null) && !configVfModules.isEmpty()) { - configVfModule = configVfModules.get(0); - } else { - configVfModule = new ConfigVfModules(svcInstanceId, vnfId, vfModule.getVfModuleId()); - } - if (vfModule.getVfModuleData() != null) { - configVfModule.setVfModuleData(objectMapper.writeValueAsString(vfModule.getVfModuleData())); - } - if (transaction != null) { - transaction.save(configVfModule); - } else { - configVfModulesRepository.save(configVfModule); - } - } - - public void saveVnf(String svcInstanceId, GenericResourceApiServicedataServicedataVnfsVnf vnf, ServiceDataTransaction transaction) throws JsonProcessingException { - if (vnf == null) { - return; - } - - GenericResourceApiServicedataServicedataVnfsVnfVnfData vnfData = vnf.getVnfData(); - - // Make a list of potential vf modules to remove - HashMap<String, ConfigVfModules> vfModuleMap = new HashMap<>(); - List<ConfigVfModules> configVfModuleList = configVfModulesRepository.findBySvcInstanceIdAndVnfId(svcInstanceId, vnf.getVnfId()); - if ((configVfModuleList != null) && !configVfModuleList.isEmpty()) { - for (ConfigVfModules configVfModuleItem : configVfModuleList) { - vfModuleMap.put(configVfModuleItem.getVfModuleId(), configVfModuleItem); - } - } - - - // Save vf modules - GenericResourceApiServicedataServicedataVnfsVnfVnfdataVfModules vfModules = vnfData.getVfModules(); - if (vfModules != null) { - List<GenericResourceApiServicedataServicedataVnfsVnfVnfdataVfmodulesVfModule> vfModuleList = vfModules.getVfModule(); - if ((vfModuleList != null) && !vfModuleList.isEmpty()) { - for (GenericResourceApiServicedataServicedataVnfsVnfVnfdataVfmodulesVfModule vfModule : vfModuleList) { - saveVfModule(svcInstanceId, vnf.getVnfId(), vfModule, transaction); - if (vfModuleMap.containsKey(vfModule.getVfModuleId())) { - vfModuleMap.remove(vfModule.getVfModuleId()); - } - } - } - - // Clear vf modules from vnfData before saving to avoid duplication - vnfData.setVfModules(null); - } - // Remove any vf Modules for this vnf id not in this list - for (ConfigVfModules vfModuleToRemove : vfModuleMap.values()) { - if (transaction != null) { - transaction.remove(vfModuleToRemove); - } else { - configVfModulesRepository.delete(vfModuleToRemove); - } - } - - // Save Vnf itself - List<ConfigVnfs> configVnfs = configVnfsRepository.findBySvcInstanceIdAndVnfId(svcInstanceId, vnf.getVnfId()); - ConfigVnfs configVnf; - if ((configVnfs != null) && !configVnfs.isEmpty()) { - configVnf = configVnfs.get(0); - } else { - configVnf = new ConfigVnfs(svcInstanceId, vnf.getVnfId()); - } - configVnf.setVnfData(objectMapper.writeValueAsString(vnfData)); - - if (transaction != null) { - transaction.save(configVnf); - } else { - configVnfsRepository.save(configVnf); - } - - } - - public void saveNetwork(String svcInstanceId, GenericResourceApiServicedataServicedataNetworksNetwork network, ServiceDataTransaction transaction) throws JsonProcessingException { - List<ConfigNetworks> configNetworks = configNetworksRepository.findBySvcInstanceIdAndNetworkId(svcInstanceId, network.getNetworkId()); - ConfigNetworks configNetwork; - - if ((configNetworks != null) && !configNetworks.isEmpty()) { - configNetwork = configNetworks.get(0); - } else { - configNetwork = new ConfigNetworks(svcInstanceId, network.getNetworkId()); - } - configNetwork.setNetworkData(objectMapper.writeValueAsString(network.getNetworkData())); - if (transaction != null) { - transaction.save(configNetwork); - } else { - configNetworksRepository.save(configNetwork); - } - } - - public void saveService(ConfigServices configService, String svcDataAsString) throws JsonMappingException, JsonProcessingException { - saveService(configService, svcDataAsString, null); - } - - - public void saveService(ConfigServices configService, String svcDataAsString, ServiceDataTransaction transaction) throws JsonMappingException, JsonProcessingException { - if ((svcDataAsString == null) || (svcDataAsString.length() == 0)) { - configService.setSvcData(null); - configServicesRepository.save(configService); - } else { - saveService(configService, objectMapper.readValue(svcDataAsString, GenericResourceApiServicedataServiceData.class), transaction); - } - } - - public void saveService(ConfigServices configService, GenericResourceApiServicedataServiceData svcData) throws JsonProcessingException { - saveService(configService, svcData, null); - } - - public void saveService(ConfigServices configService, GenericResourceApiServicedataServiceData svcData, ServiceDataTransaction transaction) throws JsonProcessingException { - - if (svcData == null) { - configService.setSvcData(null); - } else { - String svcInstanceId = configService.getSvcInstanceId(); - - // Make a list of current networks for this service - HashMap<String, ConfigNetworks> networkMap = new HashMap<>(); - List<ConfigNetworks> configNetworkList = configNetworksRepository.findBySvcInstanceId(svcInstanceId); - if ((configNetworkList != null) && !configNetworkList.isEmpty()) { - for (ConfigNetworks configNetworkItem : configNetworkList) { - networkMap.put(configNetworkItem.getNetworkId(), configNetworkItem); - } - } - // Save networks - GenericResourceApiServicedataServicedataNetworks networks = svcData.getNetworks(); - if (networks != null) { - List<GenericResourceApiServicedataServicedataNetworksNetwork> networkList = networks.getNetwork(); - if ((networkList != null) && !networkList.isEmpty()) { - for (GenericResourceApiServicedataServicedataNetworksNetwork networkItem : networkList) { - if (networkMap.containsKey(networkItem.getNetworkId())) { - networkMap.remove(networkItem.getNetworkId()); - } - saveNetwork(svcInstanceId, networkItem, transaction); - } - } - } - - // Remove networks removed from service object - for (ConfigNetworks networkToRemove : networkMap.values()) { - if (transaction != null) { - transaction.remove(networkToRemove); - } else { - configNetworksRepository.delete(networkToRemove); - } - } - - svcData.setNetworks(null); - - // Remove any networks no longer associated with this svcInstanceId - HashMap<String, ConfigVnfs> vnfMap = new HashMap<>(); - List<ConfigVnfs> configVnfList = configVnfsRepository.findBySvcInstanceId(svcInstanceId); - if ((configVnfList != null) && !configVnfList.isEmpty()) { - for (ConfigVnfs configVnfItem : configVnfList) { - vnfMap.put(configVnfItem.getVnfId(), configVnfItem); - } - } - - // Save vnfs / vfModules - - // Save current vnfs associated with this service - GenericResourceApiServicedataServicedataVnfs vnfs = svcData.getVnfs(); - if (vnfs != null) { - List<GenericResourceApiServicedataServicedataVnfsVnf> vnfList = vnfs.getVnf(); - if ((vnfList != null) && !vnfList.isEmpty()) { - for (GenericResourceApiServicedataServicedataVnfsVnf vnfItem : vnfList) { - if (vnfMap.containsKey(vnfItem.getVnfId())) { - vnfMap.remove(vnfItem.getVnfId()); - } - saveVnf(svcInstanceId, vnfItem, transaction); - } - } - } - for (ConfigVnfs vnfToRemove : vnfMap.values()) { - if (transaction != null) { - transaction.remove(vnfToRemove); - } else { - configVnfsRepository.delete(vnfToRemove); - } - } - svcData.setVnfs(null); - - configService.setSvcData(objectMapper.writeValueAsString(svcData)); - } - if (transaction != null) { - transaction.save(configService); - } else { - configServicesRepository.save(configService); - } - } - - public long deleteVfModule(String svcInstanceId, String vnfId, String vfModuleId) { - return(configVfModulesRepository.deleteBySvcInstanceIdAndVnfIdAndVfModuleId(svcInstanceId, vnfId, vfModuleId)); - } - - public long deleteVnf(String svcInstanceId, String vnfId) { - configVfModulesRepository.deleteBySvcInstanceIdAndVnfId(svcInstanceId, vnfId); - return(configVnfsRepository.deleteBySvcInstanceIdAndVnfId(svcInstanceId, vnfId)); - } - - public long deleteNetwork(String svcInstanceId, String networkId) { - return(configNetworksRepository.deleteBySvcInstanceIdAndNetworkId(svcInstanceId, networkId)); - } - - public long deleteService(String svcInstanceId) { - configVfModulesRepository.deleteBySvcInstanceId(svcInstanceId); - configVnfsRepository.deleteBySvcInstanceId(svcInstanceId); - configNetworksRepository.deleteBySvcInstanceId(svcInstanceId); - return(configServicesRepository.deleteBySvcInstanceId(svcInstanceId)); - } - - public boolean hasServiceData(ConfigServices service) { - if ((service.getSvcData() != null) && (service.getSvcData().length() > 0)) { - return(true); - } - - List<ConfigNetworks> networks = configNetworksRepository.findBySvcInstanceId(service.getSvcInstanceId()); - if ((networks != null) && !networks.isEmpty()) { - return(true); - } - - List<ConfigVnfs> vnfs = configVnfsRepository.findBySvcInstanceId(service.getSvcInstanceId()); - if ((vnfs != null) && !vnfs.isEmpty()) { - return(true); - } - - return(false); - - } - public void clearServiceData(ConfigServices service) { - configVfModulesRepository.deleteBySvcInstanceId(service.getSvcInstanceId()); - configVnfsRepository.deleteBySvcInstanceId(service.getSvcInstanceId()); - configNetworksRepository.deleteBySvcInstanceId(service.getSvcInstanceId()); - service.setSvcData(null); - configServicesRepository.save(service); - } - -} diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigContrailRouteAllottedResources.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigContrailRouteAllottedResources.java deleted file mode 100755 index 8fcf6d2..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigContrailRouteAllottedResources.java +++ /dev/null @@ -1,181 +0,0 @@ -package org.onap.sdnc.apps.ms.gra.data; - -import org.hibernate.validator.constraints.Length; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiRequestStatusEnumeration; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiAllottedresourcestatusAllottedResourceStatus; - -import javax.persistence.*; - -@Entity(name="CONFIG_GRA_CONTRAIL_ROUTE_ALLOTTED_RESOURCES") -@Table(name="CONFIG_GRA_CONTRAIL_ROUTE_ALLOTTED_RESOURCES") -public class ConfigContrailRouteAllottedResources { - @Id - @Length(max = 255) - @Column(length = 255) - String allottedResourceId; - - @Lob - String arData; - - // allottedResource status fields - String allottedResourceStatusResponseCode; - - String allottedResourceStatusResponseMessage; - - String allottedResourceStatusFinalIndicator; - - String allottedResourceStatusRequestStatus; - - String allottedResourceStatusAction; - - String allottedResourceStatusRpcName; - - String allottedResourceStatusRpcAction; - - String allottedResourceStatusResponseTimestamp; - - - public ConfigContrailRouteAllottedResources() { - this.allottedResourceId = ""; - this.arData = ""; - } - - public ConfigContrailRouteAllottedResources(String allottedResourceId, String arData) { - this.allottedResourceId = allottedResourceId; - this.arData = arData; - } - - public ConfigContrailRouteAllottedResources(String allottedResourceId, String arData, GenericResourceApiAllottedresourcestatusAllottedResourceStatus allottedResourceStatus) { - this.allottedResourceId = allottedResourceId; - this.arData = arData; - - if (allottedResourceStatus != null) { - this.allottedResourceStatusAction = allottedResourceStatus.getAction(); - this.allottedResourceStatusFinalIndicator = allottedResourceStatus.getFinalIndicator(); - this.allottedResourceStatusRequestStatus = allottedResourceStatus.getRequestStatus().toString(); - this.allottedResourceStatusResponseCode = allottedResourceStatus.getResponseCode(); - this.allottedResourceStatusResponseMessage = allottedResourceStatus.getResponseMessage(); - this.allottedResourceStatusResponseTimestamp = allottedResourceStatus.getResponseTimestamp(); - } - } - - public String getAllottedResourceId() { - return allottedResourceId; - } - - public void setAllottedResourceId(String allottedResourceId) { - this.allottedResourceId = allottedResourceId; - } - - public String getArData() { - return arData; - } - - public void setArData(String arData) { - this.arData = arData; - } - - public String getAllottedResourceStatusResponseCode() { - return allottedResourceStatusResponseCode; - } - - public void setAllottedResourceStatusResponseCode(String allottedResourceStatusResponseCode) { - this.allottedResourceStatusResponseCode = allottedResourceStatusResponseCode; - } - - public String getAllottedResourceStatusResponseMessage() { - return allottedResourceStatusResponseMessage; - } - - public void setAllottedResourceStatusResponseMessage(String allottedResourcesStatusResponseMessage) { - this.allottedResourceStatusResponseMessage = allottedResourcesStatusResponseMessage; - } - - public String getAllottedResourceStatusFinalIndicator() { - return allottedResourceStatusFinalIndicator; - } - - public void setAllottedResourceStatusFinalIndicator(String allottedResourceStatusFinalIndicator) { - this.allottedResourceStatusFinalIndicator = allottedResourceStatusFinalIndicator; - } - - public String getAllottedResourceStatusRequestStatus() { - return allottedResourceStatusRequestStatus; - } - - public void setAllottedResourceStatusRequestStatus(String allottedResourceStatusRequestStatus) { - this.allottedResourceStatusRequestStatus = allottedResourceStatusRequestStatus; - } - - public String getAllottedResourceStatusAction() { - return allottedResourceStatusAction; - } - - public void setAllottedResourceStatusAction(String allottedResourceStatusAction) { - this.allottedResourceStatusAction = allottedResourceStatusAction; - } - - public String getAllottedResourceStatusRpcName() { - return allottedResourceStatusRpcName; - } - - public void setAllottedResourceStatusRpcName(String allottedResourceStatusRpcName) { - this.allottedResourceStatusRpcName = allottedResourceStatusRpcName; - } - - public String getAllottedResourceStatusRpcAction() { - return allottedResourceStatusRpcAction; - } - - public void setAllottedResourceStatusRpcAction(String allottedResourceStatusRpcAction) { - this.allottedResourceStatusRpcAction = allottedResourceStatusRpcAction; - } - - public String getAllottedResourceStatusResponseTimestamp() { - return allottedResourceStatusResponseTimestamp; - } - - public void setAllottedResourceStatusResponseTimestamp(String allottedResourceStatusResponseTimestamp) { - this.allottedResourceStatusResponseTimestamp = allottedResourceStatusResponseTimestamp; - } - - public GenericResourceApiAllottedresourcestatusAllottedResourceStatus getAllottedResourceStatus() { - - if ((allottedResourceStatusAction == null) && - (allottedResourceStatusFinalIndicator == null) && - (allottedResourceStatusRequestStatus == null) && - (allottedResourceStatusResponseCode == null) && - (allottedResourceStatusResponseMessage == null) && - (allottedResourceStatusResponseTimestamp == null)) { - return null; - } - - GenericResourceApiAllottedresourcestatusAllottedResourceStatus allottedResourceStatus = new GenericResourceApiAllottedresourcestatusAllottedResourceStatus(); - allottedResourceStatus.setAction(allottedResourceStatusAction); - allottedResourceStatus.setFinalIndicator(allottedResourceStatusFinalIndicator); - allottedResourceStatus.setRequestStatus(GenericResourceApiRequestStatusEnumeration.fromValue(allottedResourceStatusRequestStatus)); - allottedResourceStatus.setResponseCode(allottedResourceStatusResponseCode); - allottedResourceStatus.setResponseMessage(allottedResourceStatusResponseMessage); - allottedResourceStatus.setResponseTimestamp(allottedResourceStatusResponseTimestamp); - - return(allottedResourceStatus); - } - - public void setAllottedResourceStatus(GenericResourceApiAllottedresourcestatusAllottedResourceStatus allottedResourceStatus) { - if (allottedResourceStatus == null) { - this.allottedResourceStatusAction = null; - this.allottedResourceStatusFinalIndicator = null; - this.allottedResourceStatusRequestStatus = null; - this.allottedResourceStatusResponseCode = null; - this.allottedResourceStatusResponseMessage = null; - this.allottedResourceStatusResponseTimestamp = null; - } else { - this.allottedResourceStatusAction = allottedResourceStatus.getAction(); - this.allottedResourceStatusFinalIndicator = allottedResourceStatus.getFinalIndicator(); - this.allottedResourceStatusRequestStatus = allottedResourceStatus.getRequestStatus().toString(); - this.allottedResourceStatusResponseCode = allottedResourceStatus.getResponseCode(); - this.allottedResourceStatusResponseMessage = allottedResourceStatus.getResponseMessage(); - this.allottedResourceStatusResponseTimestamp = allottedResourceStatus.getResponseTimestamp(); - } - } -}
\ No newline at end of file diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigContrailRouteAllottedResourcesRepository.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigContrailRouteAllottedResourcesRepository.java deleted file mode 100755 index 9c3aa91..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigContrailRouteAllottedResourcesRepository.java +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SDNC - * ================================================================================ - * Copyright (C) 2020 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.sdnc.apps.ms.gra.data; - -import org.springframework.data.repository.CrudRepository; -import org.springframework.transaction.annotation.Transactional; -import java.util.List; - -@Transactional -public interface ConfigContrailRouteAllottedResourcesRepository extends CrudRepository<ConfigContrailRouteAllottedResources, Long> { - - List<ConfigContrailRouteAllottedResources> findByAllottedResourceId(String allottedResourceId); - long deleteByAllottedResourceId(String allottedResourceId); - -} diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigNetworks.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigNetworks.java deleted file mode 100644 index 1720ac8..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigNetworks.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.onap.sdnc.apps.ms.gra.data; - -import org.hibernate.validator.constraints.Length; - -import javax.persistence.*; - -@Entity(name="CONFIG_GRA_NETWORKS") -@Table(name="CONFIG_GRA_NETWORKS") -@IdClass(NetworksKey.class) -public class ConfigNetworks { - @Id - @Length(max = 100) - @Column(length = 100) - String svcInstanceId; - - @Id - @Length(max = 100) - @Column(length = 100) - String networkId; - - @Lob - String networkData; - - - public ConfigNetworks() { - this.svcInstanceId = ""; - this.networkId = ""; - this.networkData = ""; - } - - public ConfigNetworks(String svcInstanceId, String networkId) { - this.svcInstanceId = svcInstanceId; - this.networkId = networkId; - this.networkData = ""; - } - - public ConfigNetworks(String svcInstanceId, String networkId, String networkData) { - this.svcInstanceId = svcInstanceId; - this.networkId = networkId; - this.networkData = networkData; - } - - - - public String getSvcInstanceId() { - return svcInstanceId; - } - - public void setSvcInstanceId(String svcInstanceId) { - this.svcInstanceId = svcInstanceId; - } - - public String getNetworkId() { - return networkId; - } - - public void setNetworkId(String networkId) { - this.networkId = networkId; - } - - public String getNetworkData() { - return networkData; - } - - public void setNetworkData(String networkData) { - this.networkData = networkData; - } - - -}
\ No newline at end of file diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigNetworksRepository.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigNetworksRepository.java deleted file mode 100644 index 56fc56c..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigNetworksRepository.java +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SDNC - * ================================================================================ - * Copyright (C) 2020 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.sdnc.apps.ms.gra.data; - -import org.springframework.data.repository.CrudRepository; -import org.springframework.transaction.annotation.Transactional; -import java.util.List; - -@Transactional -public interface ConfigNetworksRepository extends CrudRepository<ConfigNetworks, Long> { - - List<ConfigNetworks> findBySvcInstanceId(String svcInstanceId); - List<ConfigNetworks> findBySvcInstanceIdAndNetworkId(String svcInstanceId, String networkId); - long deleteBySvcInstanceId(String svcInstanceId); - long deleteBySvcInstanceIdAndNetworkId(String svcInstanceId, String networkId); - -} - diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigPortMirrorConfigurations.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigPortMirrorConfigurations.java deleted file mode 100755 index cdc5462..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigPortMirrorConfigurations.java +++ /dev/null @@ -1,181 +0,0 @@ -package org.onap.sdnc.apps.ms.gra.data; - -import org.hibernate.validator.constraints.Length; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiConfigurationstatusConfigurationStatus; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiRequestStatusEnumeration; - -import javax.persistence.*; - -@Entity(name="CONFIG_GRA_PORT_MIRROR_CONFIGURATIONS") -@Table(name="CONFIG_GRA_PORT_MIRROR_CONFIGURATIONS") -public class ConfigPortMirrorConfigurations { - @Id - @Length(max = 255) - @Column(length = 255) - String configurationId; - - @Lob - String pmcData; - - // portMirrorConfiguration status fields - String portMirrorConfigurationStatusResponseCode; - - String portMirrorConfigurationStatusResponseMessage; - - String portMirrorConfigurationStatusFinalIndicator; - - String portMirrorConfigurationStatusRequestStatus; - - String portMirrorConfigurationStatusAction; - - String portMirrorConfigurationStatusRpcName; - - String portMirrorConfigurationStatusRpcAction; - - String portMirrorConfigurationStatusResponseTimestamp; - - - public ConfigPortMirrorConfigurations() { - this.configurationId = ""; - this.pmcData = ""; - } - - public ConfigPortMirrorConfigurations(String configurationId, String pmcData) { - this.configurationId = configurationId; - this.pmcData = pmcData; - } - - public ConfigPortMirrorConfigurations(String configurationId, String pmcData, GenericResourceApiConfigurationstatusConfigurationStatus portMirrorConfigurationStatus) { - this.configurationId = configurationId; - this.pmcData = pmcData; - - if (portMirrorConfigurationStatus != null) { - this.portMirrorConfigurationStatusAction = portMirrorConfigurationStatus.getAction(); - this.portMirrorConfigurationStatusFinalIndicator = portMirrorConfigurationStatus.getFinalIndicator(); - this.portMirrorConfigurationStatusRequestStatus = portMirrorConfigurationStatus.getRequestStatus().toString(); - this.portMirrorConfigurationStatusResponseCode = portMirrorConfigurationStatus.getResponseCode(); - this.portMirrorConfigurationStatusResponseMessage = portMirrorConfigurationStatus.getResponseMessage(); - this.portMirrorConfigurationStatusResponseTimestamp = portMirrorConfigurationStatus.getResponseTimestamp(); - } - } - - public String getConfigureationId() { - return configurationId; - } - - public void setConfigureationId(String configureationId) { - this.configurationId = configureationId; - } - - public String getPmcData() { - return pmcData; - } - - public void setPmcData(String pmcData) { - this.pmcData = pmcData; - } - - public String getPortMirrorConfigurationStatusResponseCode() { - return portMirrorConfigurationStatusResponseCode; - } - - public void setPortMirrorConfigurationStatusResponseCode(String portMirrorConfigurationStatusResponseCode) { - this.portMirrorConfigurationStatusResponseCode = portMirrorConfigurationStatusResponseCode; - } - - public String getPortMirrorConfigurationStatusResponseMessage() { - return portMirrorConfigurationStatusResponseMessage; - } - - public void setPortMirrorConfigurationStatusResponseMessage(String portMirrorConfigurationsStatusResponseMessage) { - this.portMirrorConfigurationStatusResponseMessage = portMirrorConfigurationsStatusResponseMessage; - } - - public String getPortMirrorConfigurationStatusFinalIndicator() { - return portMirrorConfigurationStatusFinalIndicator; - } - - public void setPortMirrorConfigurationStatusFinalIndicator(String portMirrorConfigurationStatusFinalIndicator) { - this.portMirrorConfigurationStatusFinalIndicator = portMirrorConfigurationStatusFinalIndicator; - } - - public String getPortMirrorConfigurationStatusRequestStatus() { - return portMirrorConfigurationStatusRequestStatus; - } - - public void setPortMirrorConfigurationStatusRequestStatus(String portMirrorConfigurationStatusRequestStatus) { - this.portMirrorConfigurationStatusRequestStatus = portMirrorConfigurationStatusRequestStatus; - } - - public String getPortMirrorConfigurationStatusAction() { - return portMirrorConfigurationStatusAction; - } - - public void setPortMirrorConfigurationStatusAction(String portMirrorConfigurationStatusAction) { - this.portMirrorConfigurationStatusAction = portMirrorConfigurationStatusAction; - } - - public String getPortMirrorConfigurationStatusRpcName() { - return portMirrorConfigurationStatusRpcName; - } - - public void setPortMirrorConfigurationStatusRpcName(String portMirrorConfigurationStatusRpcName) { - this.portMirrorConfigurationStatusRpcName = portMirrorConfigurationStatusRpcName; - } - - public String getPortMirrorConfigurationStatusRpcAction() { - return portMirrorConfigurationStatusRpcAction; - } - - public void setPortMirrorConfigurationStatusRpcAction(String portMirrorConfigurationStatusRpcAction) { - this.portMirrorConfigurationStatusRpcAction = portMirrorConfigurationStatusRpcAction; - } - - public String getPortMirrorConfigurationStatusResponseTimestamp() { - return portMirrorConfigurationStatusResponseTimestamp; - } - - public void setPortMirrorConfigurationStatusResponseTimestamp(String portMirrorConfigurationStatusResponseTimestamp) { - this.portMirrorConfigurationStatusResponseTimestamp = portMirrorConfigurationStatusResponseTimestamp; - } - - public GenericResourceApiConfigurationstatusConfigurationStatus getPortMirrorConfigurationStatus() { - - if ((portMirrorConfigurationStatusAction == null) && - (portMirrorConfigurationStatusFinalIndicator == null) && - (portMirrorConfigurationStatusRequestStatus == null) && - (portMirrorConfigurationStatusResponseCode == null) && - (portMirrorConfigurationStatusResponseMessage == null) && - (portMirrorConfigurationStatusResponseTimestamp == null)) { - return null; - } - - GenericResourceApiConfigurationstatusConfigurationStatus portMirrorConfigurationStatus = new GenericResourceApiConfigurationstatusConfigurationStatus(); - portMirrorConfigurationStatus.setAction(portMirrorConfigurationStatusAction); - portMirrorConfigurationStatus.setFinalIndicator(portMirrorConfigurationStatusFinalIndicator); - portMirrorConfigurationStatus.setRequestStatus(GenericResourceApiRequestStatusEnumeration.fromValue(portMirrorConfigurationStatusRequestStatus)); - portMirrorConfigurationStatus.setResponseCode(portMirrorConfigurationStatusResponseCode); - portMirrorConfigurationStatus.setResponseMessage(portMirrorConfigurationStatusResponseMessage); - portMirrorConfigurationStatus.setResponseTimestamp(portMirrorConfigurationStatusResponseTimestamp); - - return(portMirrorConfigurationStatus); - } - - public void setPortMirrorConfigurationStatus(GenericResourceApiConfigurationstatusConfigurationStatus portMirrorConfigurationStatus) { - if (portMirrorConfigurationStatus == null) { - this.portMirrorConfigurationStatusAction = null; - this.portMirrorConfigurationStatusFinalIndicator = null; - this.portMirrorConfigurationStatusRequestStatus = null; - this.portMirrorConfigurationStatusResponseCode = null; - this.portMirrorConfigurationStatusResponseMessage = null; - this.portMirrorConfigurationStatusResponseTimestamp = null; - } else { - this.portMirrorConfigurationStatusAction = portMirrorConfigurationStatus.getAction(); - this.portMirrorConfigurationStatusFinalIndicator = portMirrorConfigurationStatus.getFinalIndicator(); - this.portMirrorConfigurationStatusRequestStatus = portMirrorConfigurationStatus.getRequestStatus().toString(); - this.portMirrorConfigurationStatusResponseCode = portMirrorConfigurationStatus.getResponseCode(); - this.portMirrorConfigurationStatusResponseMessage = portMirrorConfigurationStatus.getResponseMessage(); - this.portMirrorConfigurationStatusResponseTimestamp = portMirrorConfigurationStatus.getResponseTimestamp(); - } - } -} diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigPortMirrorConfigurationsRepository.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigPortMirrorConfigurationsRepository.java deleted file mode 100755 index 9ca148b..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigPortMirrorConfigurationsRepository.java +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SDNC - * ================================================================================ - * Copyright (C) 2020 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.sdnc.apps.ms.gra.data; - -import org.springframework.data.repository.CrudRepository; -import org.springframework.transaction.annotation.Transactional; -import java.util.List; - -@Transactional -public interface ConfigPortMirrorConfigurationsRepository extends CrudRepository<ConfigPortMirrorConfigurations, Long> { - - List<ConfigPortMirrorConfigurations> findByConfigurationId(String configurationId); - long deleteByConfigurationId(String configurationId); - -} diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigPreloadData.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigPreloadData.java deleted file mode 100644 index a23884d..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigPreloadData.java +++ /dev/null @@ -1,81 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SDNC - * ================================================================================ - * Copyright (C) 2020 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.sdnc.apps.ms.gra.data; - -import org.hibernate.validator.constraints.Length; - -import javax.persistence.*; - -@Entity(name = "CONFIG_PRELOAD_DATA") -@Table(name="CONFIG_PRELOAD_DATA") -@IdClass(PreloadDataKey.class) -public class ConfigPreloadData { - - @Id - @Length(max = 100) - @Column(length = 100) - private String preloadId; - - @Id - @Length(max = 25) - @Column(length = 25) - private String preloadType; - - @Lob - @Column(length=10000) - private String preloadData; - - public ConfigPreloadData() { - this.preloadId = ""; - this.preloadType = ""; - this.preloadData = ""; - } - - public ConfigPreloadData(String preloadId, String preloadType, String preloadData) { - this.preloadId = preloadId; - this.preloadType = preloadType; - this.preloadData = preloadData; - } - - public String getPreloadId() { - return preloadId; - } - - public void setPreloadId(String preloadId) { - this.preloadId = preloadId; - } - - public String getPreloadType() { - return preloadType; - } - - public void setPreloadType(String preloadType) { - this.preloadType = preloadType; - } - - public String getPreloadData() { - return preloadData; - } - - public void setPreloadData(String preloadData) { - this.preloadData = preloadData; - } - -} diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigPreloadDataRepository.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigPreloadDataRepository.java deleted file mode 100644 index 0ec45b7..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigPreloadDataRepository.java +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SDNC - * ================================================================================ - * Copyright (C) 2020 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.sdnc.apps.ms.gra.data; - -import org.springframework.data.repository.CrudRepository; -import org.springframework.transaction.annotation.Transactional; - -import java.util.List; - -@Transactional -public interface ConfigPreloadDataRepository extends CrudRepository<ConfigPreloadData, Long> { - - List<ConfigPreloadData> findByPreloadIdAndPreloadType(String preloadId, String preloadType); - long deleteByPreloadIdAndPreloadType(String preloadId, String preloadType); - -} - diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigServices.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigServices.java deleted file mode 100644 index bf5d862..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigServices.java +++ /dev/null @@ -1,201 +0,0 @@ -package org.onap.sdnc.apps.ms.gra.data; - -import org.hibernate.validator.constraints.Length; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiRequestStatusEnumeration; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiServiceStatus; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiServicestatusServiceStatus; - -import javax.persistence.*; - -@Entity(name="CONFIG_GRA_SERVICES") -@Table(name="CONFIG_GRA_SERVICES") -public class ConfigServices { - @Id - @Length(max = 100) - @Column(length = 100) - String svcInstanceId; - - @Lob - String svcData; - - // Service status fields - String serviceStatusResponseCode; - - String serviceStatusResponseMessage; - - String serviceStatusFinalIndicator; - - String serviceStatusRequestStatus; - - String serviceStatusAction; - - String serviceStatusRpcName; - - String serviceStatusRpcAction; - - String serviceStatusResponseTimestamp; - - - public ConfigServices() { - this.svcInstanceId = ""; - this.svcData = ""; - } - - public ConfigServices(String svcInstanceId) { - this.svcInstanceId = svcInstanceId; - this.svcData = ""; - } - - public ConfigServices(String svcInstanceId, String svcData) { - this.svcInstanceId = svcInstanceId; - this.svcData = svcData; - } - - public ConfigServices(String svcInstanceId, GenericResourceApiServicestatusServiceStatus serviceStatus) { - this.svcInstanceId = svcInstanceId; - this.svcData = ""; - - if (serviceStatus != null) { - this.serviceStatusAction = serviceStatus.getAction(); - this.serviceStatusFinalIndicator = serviceStatus.getFinalIndicator(); - this.serviceStatusRequestStatus = serviceStatus.getRequestStatus().toString(); - this.serviceStatusResponseCode = serviceStatus.getResponseCode(); - this.serviceStatusResponseMessage = serviceStatus.getResponseMessage(); - this.serviceStatusResponseTimestamp = serviceStatus.getResponseTimestamp(); - } - } - - public ConfigServices(String svcInstanceId, String svcData, GenericResourceApiServicestatusServiceStatus serviceStatus) { - this.svcInstanceId = svcInstanceId; - this.svcData = svcData; - - if (serviceStatus != null) { - this.serviceStatusAction = serviceStatus.getAction(); - this.serviceStatusFinalIndicator = serviceStatus.getFinalIndicator(); - this.serviceStatusRequestStatus = serviceStatus.getRequestStatus().toString(); - this.serviceStatusResponseCode = serviceStatus.getResponseCode(); - this.serviceStatusResponseMessage = serviceStatus.getResponseMessage(); - this.serviceStatusResponseTimestamp = serviceStatus.getResponseTimestamp(); - } - } - - public String getSvcInstanceId() { - return svcInstanceId; - } - - public void setSvcInstanceId(String svcInstanceId) { - this.svcInstanceId = svcInstanceId; - } - - public String getSvcData() { - return svcData; - } - - public void setSvcData(String svcData) { - this.svcData = svcData; - } - - public String getServiceStatusResponseCode() { - return serviceStatusResponseCode; - } - - public void setServiceStatusResponseCode(String serviceStatusResponseCode) { - this.serviceStatusResponseCode = serviceStatusResponseCode; - } - - public String getServiceStatusResponseMessage() { - return serviceStatusResponseMessage; - } - - public void setServiceStatusResponseMessage(String servicesStatusResponseMessage) { - this.serviceStatusResponseMessage = servicesStatusResponseMessage; - } - - public String getServiceStatusFinalIndicator() { - return serviceStatusFinalIndicator; - } - - public void setServiceStatusFinalIndicator(String serviceStatusFinalIndicator) { - this.serviceStatusFinalIndicator = serviceStatusFinalIndicator; - } - - public String getServiceStatusRequestStatus() { - return serviceStatusRequestStatus; - } - - public void setServiceStatusRequestStatus(String serviceStatusRequestStatus) { - this.serviceStatusRequestStatus = serviceStatusRequestStatus; - } - - public String getServiceStatusAction() { - return serviceStatusAction; - } - - public void setServiceStatusAction(String serviceStatusAction) { - this.serviceStatusAction = serviceStatusAction; - } - - public String getServiceStatusRpcName() { - return serviceStatusRpcName; - } - - public void setServiceStatusRpcName(String serviceStatusRpcName) { - this.serviceStatusRpcName = serviceStatusRpcName; - } - - public String getServiceStatusRpcAction() { - return serviceStatusRpcAction; - } - - public void setServiceStatusRpcAction(String serviceStatusRpcAction) { - this.serviceStatusRpcAction = serviceStatusRpcAction; - } - - public String getServiceStatusResponseTimestamp() { - return serviceStatusResponseTimestamp; - } - - public void setServiceStatusResponseTimestamp(String serviceStatusResponseTimestamp) { - this.serviceStatusResponseTimestamp = serviceStatusResponseTimestamp; - } - - public GenericResourceApiServicestatusServiceStatus getServiceStatus() { - - if ((serviceStatusAction == null) && - (serviceStatusFinalIndicator == null) && - (serviceStatusRequestStatus == null) && - (serviceStatusResponseCode == null) && - (serviceStatusResponseMessage == null) && - (serviceStatusResponseTimestamp == null)) { - return null; - } - - GenericResourceApiServicestatusServiceStatus serviceStatus = new GenericResourceApiServicestatusServiceStatus(); - serviceStatus.setAction(serviceStatusAction); - serviceStatus.setFinalIndicator(serviceStatusFinalIndicator); - serviceStatus.setRequestStatus(GenericResourceApiRequestStatusEnumeration.fromValue(serviceStatusRequestStatus)); - serviceStatus.setResponseCode(serviceStatusResponseCode); - serviceStatus.setResponseMessage(serviceStatusResponseMessage); - serviceStatus.setResponseTimestamp(serviceStatusResponseTimestamp); - - return(serviceStatus); - } - - public void setServiceStatus(GenericResourceApiServicestatusServiceStatus serviceStatus) { - if (serviceStatus == null) { - this.serviceStatusAction = null; - this.serviceStatusFinalIndicator = null; - this.serviceStatusRequestStatus = null; - this.serviceStatusResponseCode = null; - this.serviceStatusResponseMessage = null; - this.serviceStatusResponseTimestamp = null; - } else { - this.serviceStatusAction = serviceStatus.getAction(); - this.serviceStatusFinalIndicator = serviceStatus.getFinalIndicator(); - this.serviceStatusRequestStatus = serviceStatus.getRequestStatus().toString(); - this.serviceStatusResponseCode = serviceStatus.getResponseCode(); - this.serviceStatusResponseMessage = serviceStatus.getResponseMessage(); - this.serviceStatusResponseTimestamp = serviceStatus.getResponseTimestamp(); - } - } -}
\ No newline at end of file diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigServicesRepository.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigServicesRepository.java deleted file mode 100644 index 5b43947..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigServicesRepository.java +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SDNC - * ================================================================================ - * Copyright (C) 2020 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.sdnc.apps.ms.gra.data; - -import org.springframework.data.repository.CrudRepository; -import org.springframework.transaction.annotation.Transactional; -import java.util.List; - -@Transactional -public interface ConfigServicesRepository extends CrudRepository<ConfigServices, Long> { - - List<ConfigServices> findBySvcInstanceId(String svcInstanceId); - long deleteBySvcInstanceId(String svcInstanceId); - -} - diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigVfModules.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigVfModules.java deleted file mode 100644 index d4d5ea5..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigVfModules.java +++ /dev/null @@ -1,84 +0,0 @@ -package org.onap.sdnc.apps.ms.gra.data; - -import org.hibernate.validator.constraints.Length; - -import javax.persistence.*; - -@Entity(name="CONFIG_GRA_VF_MODULES") -@Table(name="CONFIG_GRA_VF_MODULES") -@IdClass(VfModulesKey.class) -public class ConfigVfModules { - @Id - @Length(max = 100) - @Column(length = 100) - String svcInstanceId; - - @Id - @Length(max = 100) - @Column(length = 100) - String vnfId; - - @Id - @Length(max = 100) - @Column(length = 100) - String vfModuleId; - - @Lob - String vfModuleData; - - - public ConfigVfModules() { - this.svcInstanceId = ""; - this.vnfId = ""; - this.vfModuleId = ""; - this.vfModuleData = ""; - } - - public ConfigVfModules(String svcInstanceId, String vnfId, String vfModuleId) { - this.svcInstanceId = svcInstanceId; - this.vnfId = vnfId; - this.vfModuleId = vfModuleId; - this.vfModuleData = ""; - } - - public ConfigVfModules(String svcInstanceId, String vnfId, String vfModuleId, String vfModuleData) { - this.svcInstanceId = svcInstanceId; - this.vnfId = vnfId; - this.vfModuleId = vfModuleId; - this.vfModuleData = vfModuleData; - } - - public String getSvcInstanceId() { - return svcInstanceId; - } - - public void setSvcInstanceId(String svcInstanceId) { - this.svcInstanceId = svcInstanceId; - } - - public String getVnfId() { - return vnfId; - } - - public void setVnfId(String vnfId) { - this.vnfId = vnfId; - } - - public String getVfModuleId() { - return vfModuleId; - } - - public void setVfModuleId(String vfModuleId) { - this.vfModuleId = vfModuleId; - } - - public String getVfModuleData() { - return vfModuleData; - } - - public void setVfModuleData(String vfModuleData) { - this.vfModuleData = vfModuleData; - } - - -}
\ No newline at end of file diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigVfModulesRepository.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigVfModulesRepository.java deleted file mode 100644 index 8203483..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigVfModulesRepository.java +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SDNC - * ================================================================================ - * Copyright (C) 2020 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.sdnc.apps.ms.gra.data; - -import org.springframework.data.repository.CrudRepository; -import org.springframework.transaction.annotation.Transactional; -import java.util.List; - -@Transactional -public interface ConfigVfModulesRepository extends CrudRepository<ConfigVfModules, Long> { - - List<ConfigVfModules> findBySvcInstanceId(String svcInstanceId); - List<ConfigVfModules> findBySvcInstanceIdAndVnfId(String svcInstanceId, String vnfId); - List<ConfigVfModules> findBySvcInstanceIdAndVnfIdAndVfModuleId(String svcInstanceId, String vnfId, String vfModuleId); - long deleteBySvcInstanceId(String svcInstanceId); - long deleteBySvcInstanceIdAndVnfId(String svcInstanceId, String vnfId); - long deleteBySvcInstanceIdAndVnfIdAndVfModuleId(String svcInstanceId, String vnfId, String vfModuleId); - -} - diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigVnfs.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigVnfs.java deleted file mode 100644 index 44337fd..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigVnfs.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.onap.sdnc.apps.ms.gra.data; - -import org.hibernate.validator.constraints.Length; - -import javax.persistence.*; - -@Entity(name="CONFIG_GRA_VNFS") -@Table(name="CONFIG_GRA_VNFS") -@IdClass(VnfsKey.class) -public class ConfigVnfs { - @Id - @Length(max = 100) - @Column(length = 100) - String svcInstanceId; - - @Id - @Length(max = 100) - @Column(length = 100) - String vnfId; - - @Lob - String vnfData; - - - public ConfigVnfs() { - this.svcInstanceId = ""; - this.vnfId = ""; - this.vnfData = ""; - } - - public ConfigVnfs(String svcInstanceId, String vnfId) { - this.svcInstanceId = svcInstanceId; - this.vnfId = vnfId; - this.vnfData = ""; - } - - public ConfigVnfs(String svcInstanceId, String vnfId, String vnfData) { - this.svcInstanceId = svcInstanceId; - this.vnfId = vnfId; - this.vnfData = vnfData; - } - - public String getSvcInstanceId() { - return svcInstanceId; - } - - public void setSvcInstanceId(String svcInstanceId) { - this.svcInstanceId = svcInstanceId; - } - - public String getVnfId() { - return vnfId; - } - - public void setVnfId(String vnfId) { - this.vnfId = vnfId; - } - - public String getVnfData() { - return vnfData; - } - - public void setVnfData(String vnfData) { - this.vnfData = vnfData; - } -}
\ No newline at end of file diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigVnfsRepository.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigVnfsRepository.java deleted file mode 100644 index 3909eb3..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigVnfsRepository.java +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SDNC - * ================================================================================ - * Copyright (C) 2020 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.sdnc.apps.ms.gra.data; - -import org.springframework.data.repository.CrudRepository; -import org.springframework.transaction.annotation.Transactional; -import java.util.List; - -@Transactional -public interface ConfigVnfsRepository extends CrudRepository<ConfigVnfs, Long> { - - List<ConfigVnfs> findBySvcInstanceId(String svcInstanceId); - List<ConfigVnfs> findBySvcInstanceIdAndVnfId(String svcInstanceId, String vnfId); - long deleteBySvcInstanceId(String svcInstanceId); - long deleteBySvcInstanceIdAndVnfId(String svcInstanceId, String vnfId); - -} - diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/NetworksKey.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/NetworksKey.java deleted file mode 100644 index 61f7602..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/NetworksKey.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.onap.sdnc.apps.ms.gra.data; - -import java.io.Serializable; - -public class NetworksKey implements Serializable { - private String svcInstanceId = ""; - private String networkId = ""; - - public NetworksKey() { - this.svcInstanceId = ""; - this.networkId = ""; - } - - public NetworksKey(String svcInstanceId, String networkId) { - this.svcInstanceId = svcInstanceId; - this.networkId = networkId; - } - - @Override - public int hashCode() { - return svcInstanceId.hashCode() + networkId.hashCode(); - } - - @Override - public boolean equals(Object obj) { - return (obj instanceof NetworksKey && - svcInstanceId.equals(((NetworksKey)obj).svcInstanceId) && - networkId.equals(((NetworksKey)obj).networkId)); - } -} diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalContrailRouteAllottedResources.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalContrailRouteAllottedResources.java deleted file mode 100755 index 51ab88f..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalContrailRouteAllottedResources.java +++ /dev/null @@ -1,181 +0,0 @@ -package org.onap.sdnc.apps.ms.gra.data; - -import org.hibernate.validator.constraints.Length; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiAllottedresourcestatusAllottedResourceStatus; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiRequestStatusEnumeration; - -import javax.persistence.*; - -@Entity(name="OPERATIONAL_GRA_CONTRAIL_ROUTE_ALLOTTED_RESOURCES") -@Table(name="OPERATIONAL_GRA_CONTRAIL_ROUTE_ALLOTTED_RESOURCES") -public class OperationalContrailRouteAllottedResources { - @Id - @Length(max = 255) - @Column(length = 255) - String allottedResourceId; - - @Lob - String arData; - - // allottedResource status fields - String allottedResourceStatusResponseCode; - - String allottedResourceStatusResponseMessage; - - String allottedResourceStatusFinalIndicator; - - String allottedResourceStatusRequestStatus; - - String allottedResourceStatusAction; - - String allottedResourceStatusRpcName; - - String allottedResourceStatusRpcAction; - - String allottedResourceStatusResponseTimestamp; - - - public OperationalContrailRouteAllottedResources() { - this.allottedResourceId = ""; - this.arData = ""; - } - - public OperationalContrailRouteAllottedResources(String allottedResourceId, String arData) { - this.allottedResourceId = allottedResourceId; - this.arData = arData; - } - - public OperationalContrailRouteAllottedResources(String allottedResourceId, String arData, GenericResourceApiAllottedresourcestatusAllottedResourceStatus allottedResourceStatus) { - this.allottedResourceId = allottedResourceId; - this.arData = arData; - - if (allottedResourceStatus != null) { - this.allottedResourceStatusAction = allottedResourceStatus.getAction(); - this.allottedResourceStatusFinalIndicator = allottedResourceStatus.getFinalIndicator(); - this.allottedResourceStatusRequestStatus = allottedResourceStatus.getRequestStatus().toString(); - this.allottedResourceStatusResponseCode = allottedResourceStatus.getResponseCode(); - this.allottedResourceStatusResponseMessage = allottedResourceStatus.getResponseMessage(); - this.allottedResourceStatusResponseTimestamp = allottedResourceStatus.getResponseTimestamp(); - } - } - - public String getAllottedResourceId() { - return allottedResourceId; - } - - public void setAllottedResourceId(String allottedResourceId) { - this.allottedResourceId = allottedResourceId; - } - - public String getArData() { - return arData; - } - - public void setArData(String arData) { - this.arData = arData; - } - - public String getAllottedResourceStatusResponseCode() { - return allottedResourceStatusResponseCode; - } - - public void setAllottedResourceStatusResponseCode(String allottedResourceStatusResponseCode) { - this.allottedResourceStatusResponseCode = allottedResourceStatusResponseCode; - } - - public String getAllottedResourceStatusResponseMessage() { - return allottedResourceStatusResponseMessage; - } - - public void setAllottedResourceStatusResponseMessage(String allottedResourcesStatusResponseMessage) { - this.allottedResourceStatusResponseMessage = allottedResourcesStatusResponseMessage; - } - - public String getAllottedResourceStatusFinalIndicator() { - return allottedResourceStatusFinalIndicator; - } - - public void setAllottedResourceStatusFinalIndicator(String allottedResourceStatusFinalIndicator) { - this.allottedResourceStatusFinalIndicator = allottedResourceStatusFinalIndicator; - } - - public String getAllottedResourceStatusRequestStatus() { - return allottedResourceStatusRequestStatus; - } - - public void setAllottedResourceStatusRequestStatus(String allottedResourceStatusRequestStatus) { - this.allottedResourceStatusRequestStatus = allottedResourceStatusRequestStatus; - } - - public String getAllottedResourceStatusAction() { - return allottedResourceStatusAction; - } - - public void setAllottedResourceStatusAction(String allottedResourceStatusAction) { - this.allottedResourceStatusAction = allottedResourceStatusAction; - } - - public String getAllottedResourceStatusRpcName() { - return allottedResourceStatusRpcName; - } - - public void setAllottedResourceStatusRpcName(String allottedResourceStatusRpcName) { - this.allottedResourceStatusRpcName = allottedResourceStatusRpcName; - } - - public String getAllottedResourceStatusRpcAction() { - return allottedResourceStatusRpcAction; - } - - public void setAllottedResourceStatusRpcAction(String allottedResourceStatusRpcAction) { - this.allottedResourceStatusRpcAction = allottedResourceStatusRpcAction; - } - - public String getAllottedResourceStatusResponseTimestamp() { - return allottedResourceStatusResponseTimestamp; - } - - public void setAllottedResourceStatusResponseTimestamp(String allottedResourceStatusResponseTimestamp) { - this.allottedResourceStatusResponseTimestamp = allottedResourceStatusResponseTimestamp; - } - - public GenericResourceApiAllottedresourcestatusAllottedResourceStatus getAllottedResourceStatus() { - - if ((allottedResourceStatusAction == null) && - (allottedResourceStatusFinalIndicator == null) && - (allottedResourceStatusRequestStatus == null) && - (allottedResourceStatusResponseCode == null) && - (allottedResourceStatusResponseMessage == null) && - (allottedResourceStatusResponseTimestamp == null)) { - return null; - } - - GenericResourceApiAllottedresourcestatusAllottedResourceStatus allottedResourceStatus = new GenericResourceApiAllottedresourcestatusAllottedResourceStatus(); - allottedResourceStatus.setAction(allottedResourceStatusAction); - allottedResourceStatus.setFinalIndicator(allottedResourceStatusFinalIndicator); - allottedResourceStatus.setRequestStatus(GenericResourceApiRequestStatusEnumeration.fromValue(allottedResourceStatusRequestStatus)); - allottedResourceStatus.setResponseCode(allottedResourceStatusResponseCode); - allottedResourceStatus.setResponseMessage(allottedResourceStatusResponseMessage); - allottedResourceStatus.setResponseTimestamp(allottedResourceStatusResponseTimestamp); - - return(allottedResourceStatus); - } - - public void setAllottedResourceStatus(GenericResourceApiAllottedresourcestatusAllottedResourceStatus allottedResourceStatus) { - if (allottedResourceStatus == null) { - this.allottedResourceStatusAction = null; - this.allottedResourceStatusFinalIndicator = null; - this.allottedResourceStatusRequestStatus = null; - this.allottedResourceStatusResponseCode = null; - this.allottedResourceStatusResponseMessage = null; - this.allottedResourceStatusResponseTimestamp = null; - } else { - this.allottedResourceStatusAction = allottedResourceStatus.getAction(); - this.allottedResourceStatusFinalIndicator = allottedResourceStatus.getFinalIndicator(); - this.allottedResourceStatusRequestStatus = allottedResourceStatus.getRequestStatus().toString(); - this.allottedResourceStatusResponseCode = allottedResourceStatus.getResponseCode(); - this.allottedResourceStatusResponseMessage = allottedResourceStatus.getResponseMessage(); - this.allottedResourceStatusResponseTimestamp = allottedResourceStatus.getResponseTimestamp(); - } - } -}
\ No newline at end of file diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalContrailRouteAllottedResourcesRepository.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalContrailRouteAllottedResourcesRepository.java deleted file mode 100755 index c737721..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalContrailRouteAllottedResourcesRepository.java +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SDNC - * ================================================================================ - * Copyright (C) 2020 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.sdnc.apps.ms.gra.data; - -import org.springframework.data.repository.CrudRepository; -import org.springframework.transaction.annotation.Transactional; -import java.util.List; - -@Transactional -public interface OperationalContrailRouteAllottedResourcesRepository extends CrudRepository<OperationalContrailRouteAllottedResources, Long> { - - List<OperationalContrailRouteAllottedResources> findByAllottedResourceId(String allottedResourceId); - long deleteByAllottedResourceId(String allottedResourceId); - -} diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalPortMirrorConfigurations.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalPortMirrorConfigurations.java deleted file mode 100755 index da9c0ce..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalPortMirrorConfigurations.java +++ /dev/null @@ -1,181 +0,0 @@ -package org.onap.sdnc.apps.ms.gra.data; - -import org.hibernate.validator.constraints.Length; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiConfigurationstatusConfigurationStatus; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiRequestStatusEnumeration; - -import javax.persistence.*; - -@Entity(name="OPERATIONAL_GRA_PORT_MIRROR_CONFIGURATIONS") -@Table(name="OPERATIONAL_GRA_PORT_MIRROR_CONFIGURATIONS") -public class OperationalPortMirrorConfigurations { - @Id - @Length(max = 255) - @Column(length = 255) - String configurationId; - - @Lob - String pmcData; - - // portMirrorConfiguration status fields - String portMirrorConfigurationStatusResponseCode; - - String portMirrorConfigurationStatusResponseMessage; - - String portMirrorConfigurationStatusFinalIndicator; - - String portMirrorConfigurationStatusRequestStatus; - - String portMirrorConfigurationStatusAction; - - String portMirrorConfigurationStatusRpcName; - - String portMirrorConfigurationStatusRpcAction; - - String portMirrorConfigurationStatusResponseTimestamp; - - - public OperationalPortMirrorConfigurations() { - this.configurationId = ""; - this.pmcData = ""; - } - - public OperationalPortMirrorConfigurations(String configurationId, String pmcData) { - this.configurationId = configurationId; - this.pmcData = pmcData; - } - - public OperationalPortMirrorConfigurations(String configurationId, String pmcData, GenericResourceApiConfigurationstatusConfigurationStatus portMirrorConfigurationStatus) { - this.configurationId = configurationId; - this.pmcData = pmcData; - - if (portMirrorConfigurationStatus != null) { - this.portMirrorConfigurationStatusAction = portMirrorConfigurationStatus.getAction(); - this.portMirrorConfigurationStatusFinalIndicator = portMirrorConfigurationStatus.getFinalIndicator(); - this.portMirrorConfigurationStatusRequestStatus = portMirrorConfigurationStatus.getRequestStatus().toString(); - this.portMirrorConfigurationStatusResponseCode = portMirrorConfigurationStatus.getResponseCode(); - this.portMirrorConfigurationStatusResponseMessage = portMirrorConfigurationStatus.getResponseMessage(); - this.portMirrorConfigurationStatusResponseTimestamp = portMirrorConfigurationStatus.getResponseTimestamp(); - } - } - - public String getConfigurationId() { - return configurationId; - } - - public void setConfigurationId(String configurationId) { - this.configurationId = configurationId; - } - - public String getPmcData() { - return pmcData; - } - - public void setPmcData(String pmcData) { - this.pmcData = pmcData; - } - - public String getPortMirrorConfigurationStatusResponseCode() { - return portMirrorConfigurationStatusResponseCode; - } - - public void setPortMirrorConfigurationStatusResponseCode(String portMirrorConfigurationStatusResponseCode) { - this.portMirrorConfigurationStatusResponseCode = portMirrorConfigurationStatusResponseCode; - } - - public String getPortMirrorConfigurationStatusResponseMessage() { - return portMirrorConfigurationStatusResponseMessage; - } - - public void setPortMirrorConfigurationStatusResponseMessage(String portMirrorConfigurationsStatusResponseMessage) { - this.portMirrorConfigurationStatusResponseMessage = portMirrorConfigurationsStatusResponseMessage; - } - - public String getPortMirrorConfigurationStatusFinalIndicator() { - return portMirrorConfigurationStatusFinalIndicator; - } - - public void setPortMirrorConfigurationStatusFinalIndicator(String portMirrorConfigurationStatusFinalIndicator) { - this.portMirrorConfigurationStatusFinalIndicator = portMirrorConfigurationStatusFinalIndicator; - } - - public String getPortMirrorConfigurationStatusRequestStatus() { - return portMirrorConfigurationStatusRequestStatus; - } - - public void setPortMirrorConfigurationStatusRequestStatus(String portMirrorConfigurationStatusRequestStatus) { - this.portMirrorConfigurationStatusRequestStatus = portMirrorConfigurationStatusRequestStatus; - } - - public String getPortMirrorConfigurationStatusAction() { - return portMirrorConfigurationStatusAction; - } - - public void setPortMirrorConfigurationStatusAction(String portMirrorConfigurationStatusAction) { - this.portMirrorConfigurationStatusAction = portMirrorConfigurationStatusAction; - } - - public String getPortMirrorConfigurationStatusRpcName() { - return portMirrorConfigurationStatusRpcName; - } - - public void setPortMirrorConfigurationStatusRpcName(String portMirrorConfigurationStatusRpcName) { - this.portMirrorConfigurationStatusRpcName = portMirrorConfigurationStatusRpcName; - } - - public String getPortMirrorConfigurationStatusRpcAction() { - return portMirrorConfigurationStatusRpcAction; - } - - public void setPortMirrorConfigurationStatusRpcAction(String portMirrorConfigurationStatusRpcAction) { - this.portMirrorConfigurationStatusRpcAction = portMirrorConfigurationStatusRpcAction; - } - - public String getPortMirrorConfigurationStatusResponseTimestamp() { - return portMirrorConfigurationStatusResponseTimestamp; - } - - public void setPortMirrorConfigurationStatusResponseTimestamp(String portMirrorConfigurationStatusResponseTimestamp) { - this.portMirrorConfigurationStatusResponseTimestamp = portMirrorConfigurationStatusResponseTimestamp; - } - - public GenericResourceApiConfigurationstatusConfigurationStatus getPortMirrorConfigurationStatus() { - - if ((portMirrorConfigurationStatusAction == null) && - (portMirrorConfigurationStatusFinalIndicator == null) && - (portMirrorConfigurationStatusRequestStatus == null) && - (portMirrorConfigurationStatusResponseCode == null) && - (portMirrorConfigurationStatusResponseMessage == null) && - (portMirrorConfigurationStatusResponseTimestamp == null)) { - return null; - } - - GenericResourceApiConfigurationstatusConfigurationStatus portMirrorConfigurationStatus = new GenericResourceApiConfigurationstatusConfigurationStatus(); - portMirrorConfigurationStatus.setAction(portMirrorConfigurationStatusAction); - portMirrorConfigurationStatus.setFinalIndicator(portMirrorConfigurationStatusFinalIndicator); - portMirrorConfigurationStatus.setRequestStatus(GenericResourceApiRequestStatusEnumeration.fromValue(portMirrorConfigurationStatusRequestStatus)); - portMirrorConfigurationStatus.setResponseCode(portMirrorConfigurationStatusResponseCode); - portMirrorConfigurationStatus.setResponseMessage(portMirrorConfigurationStatusResponseMessage); - portMirrorConfigurationStatus.setResponseTimestamp(portMirrorConfigurationStatusResponseTimestamp); - - return(portMirrorConfigurationStatus); - } - - public void setPortMirrorConfigurationStatus(GenericResourceApiConfigurationstatusConfigurationStatus portMirrorConfigurationStatus) { - if (portMirrorConfigurationStatus == null) { - this.portMirrorConfigurationStatusAction = null; - this.portMirrorConfigurationStatusFinalIndicator = null; - this.portMirrorConfigurationStatusRequestStatus = null; - this.portMirrorConfigurationStatusResponseCode = null; - this.portMirrorConfigurationStatusResponseMessage = null; - this.portMirrorConfigurationStatusResponseTimestamp = null; - } else { - this.portMirrorConfigurationStatusAction = portMirrorConfigurationStatus.getAction(); - this.portMirrorConfigurationStatusFinalIndicator = portMirrorConfigurationStatus.getFinalIndicator(); - this.portMirrorConfigurationStatusRequestStatus = portMirrorConfigurationStatus.getRequestStatus().toString(); - this.portMirrorConfigurationStatusResponseCode = portMirrorConfigurationStatus.getResponseCode(); - this.portMirrorConfigurationStatusResponseMessage = portMirrorConfigurationStatus.getResponseMessage(); - this.portMirrorConfigurationStatusResponseTimestamp = portMirrorConfigurationStatus.getResponseTimestamp(); - } - } -} diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalPortMirrorConfigurationsRepository.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalPortMirrorConfigurationsRepository.java deleted file mode 100755 index 1d57c86..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalPortMirrorConfigurationsRepository.java +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SDNC - * ================================================================================ - * Copyright (C) 2020 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.sdnc.apps.ms.gra.data; - -import org.springframework.data.repository.CrudRepository; -import org.springframework.transaction.annotation.Transactional; -import java.util.List; - -@Transactional -public interface OperationalPortMirrorConfigurationsRepository extends CrudRepository<OperationalPortMirrorConfigurations, Long> { - - List<OperationalPortMirrorConfigurations> findByConfigurationId(String configurationId); - long deleteByConfigurationId(String configurationId); - -} diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalPreloadData.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalPreloadData.java deleted file mode 100644 index c63926d..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalPreloadData.java +++ /dev/null @@ -1,81 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SDNC - * ================================================================================ - * Copyright (C) 2020 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.sdnc.apps.ms.gra.data; - -import org.hibernate.validator.constraints.Length; - -import javax.persistence.*; - -@Entity(name = "OPERATIONAL_PRELOAD_DATA") -@Table(name="OPERATIONAL_PRELOAD_DATA") -@IdClass(PreloadDataKey.class) -public class OperationalPreloadData { - - @Id - @Length(max = 100) - @Column(length = 100) - private String preloadId; - - @Id - @Length(max = 25) - @Column(length = 25) - private String preloadType; - - @Lob - @Column(length=10000) - private String preloadData; - - public OperationalPreloadData() { - this.preloadId = ""; - this.preloadType = ""; - this.preloadData = ""; - } - - public OperationalPreloadData(String preloadId, String preloadType, String preloadData) { - this.preloadId = preloadId; - this.preloadType = preloadType; - this.preloadData = preloadData; - } - - public String getPreloadId() { - return preloadId; - } - - public void setPreloadId(String preloadId) { - this.preloadId = preloadId; - } - - public String getPreloadType() { - return preloadType; - } - - public void setPreloadType(String preloadType) { - this.preloadType = preloadType; - } - - public String getPreloadData() { - return preloadData; - } - - public void setPreloadData(String preloadData) { - this.preloadData = preloadData; - } - -} diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalPreloadDataRepository.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalPreloadDataRepository.java deleted file mode 100644 index 34df132..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalPreloadDataRepository.java +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SDNC - * ================================================================================ - * Copyright (C) 2020 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.sdnc.apps.ms.gra.data; - -import org.springframework.data.repository.CrudRepository; - -import java.util.List; - - -public interface OperationalPreloadDataRepository extends CrudRepository<OperationalPreloadData, Long> { - - List<OperationalPreloadData> findByPreloadIdAndPreloadType(String preloadId, String preloadType); - long deleteByPreloadIdAndPreloadType(String preloadId, String preloadType); - -} - diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalServices.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalServices.java deleted file mode 100644 index 5686c4c..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalServices.java +++ /dev/null @@ -1,159 +0,0 @@ -package org.onap.sdnc.apps.ms.gra.data; - -import org.hibernate.validator.constraints.Length; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiRequestStatusEnumeration; -import org.onap.sdnc.apps.ms.gra.swagger.model.GenericResourceApiServicestatusServiceStatus; - -import javax.persistence.*; - -@Entity(name="OPERATIONAL_GRA_SERVICES") -@Table(name="OPERATIONAL_GRA_SERVICES") -public class OperationalServices { - @Id - @Length(max = 100) - @Column(length = 100) - String svcInstanceId; - - @Lob - String svcData; - - // Service status fields - String serviceStatusResponseCode; - - String serviceStatusResponseMessage; - - String serviceStatusFinalIndicator; - - String serviceStatusRequestStatus; - - String serviceStatusAction; - - String serviceStatusRpcName; - - String serviceStatusRpcAction; - - String serviceStatusResponseTimestamp; - - public String getSvcInstanceId() { - return svcInstanceId; - } - - public OperationalServices() { - this.svcInstanceId = ""; - this.svcData = ""; - } - - public OperationalServices(String svcInstanceId, String svcData, GenericResourceApiServicestatusServiceStatus serviceStatus) { - this.svcInstanceId = svcInstanceId; - this.svcData = svcData; - if (serviceStatus != null) { - this.serviceStatusAction = serviceStatus.getAction(); - this.serviceStatusFinalIndicator = serviceStatus.getFinalIndicator(); - this.serviceStatusRequestStatus = serviceStatus.getRequestStatus().toString(); - this.serviceStatusResponseCode = serviceStatus.getResponseCode(); - this.serviceStatusResponseMessage = serviceStatus.getResponseMessage(); - this.serviceStatusResponseTimestamp = serviceStatus.getResponseTimestamp(); - } - } - - public void setSvcInstanceId(String svcInstanceId) { - this.svcInstanceId = svcInstanceId; - } - - public String getSvcData() { - return svcData; - } - - public void setSvcData(String svcData) { - this.svcData = svcData; - } - - public String getServiceStatusResponseCode() { - return serviceStatusResponseCode; - } - - public void setServiceStatusResponseCode(String serviceStatusResponseCode) { - this.serviceStatusResponseCode = serviceStatusResponseCode; - } - - public String getServiceStatusResponseMessage() { - return serviceStatusResponseMessage; - } - - public void setServiceStatusResponseMessage(String serviceStatusResponseMessage) { - this.serviceStatusResponseMessage = serviceStatusResponseMessage; - } - - public String getServiceStatusFinalIndicator() { - return serviceStatusFinalIndicator; - } - - public void setServiceStatusFinalIndicator(String serviceStatusFinalIndicator) { - this.serviceStatusFinalIndicator = serviceStatusFinalIndicator; - } - - public String getServiceStatusRequestStatus() { - return serviceStatusRequestStatus; - } - - public void setServiceStatusRequestStatus(String serviceStatusRequestStatus) { - this.serviceStatusRequestStatus = serviceStatusRequestStatus; - } - - public String getServiceStatusAction() { - return serviceStatusAction; - } - - public void setServiceStatusAction(String serviceStatusAction) { - this.serviceStatusAction = serviceStatusAction; - } - - public String getServiceStatusRpcName() { - return serviceStatusRpcName; - } - - public void setServiceStatusRpcName(String serviceStatusRpcName) { - this.serviceStatusRpcName = serviceStatusRpcName; - } - - public String getServiceStatusRpcAction() { - return serviceStatusRpcAction; - } - - public void setServiceStatusRpcAction(String serviceStatusRpcAction) { - this.serviceStatusRpcAction = serviceStatusRpcAction; - } - - public String getServiceStatusResponseTimestamp() { - return serviceStatusResponseTimestamp; - } - - public void setServiceStatusResponseTimestamp(String serviceStatusResponseTimestamp) { - this.serviceStatusResponseTimestamp = serviceStatusResponseTimestamp; - } - - - public GenericResourceApiServicestatusServiceStatus getServiceStatus() { - GenericResourceApiServicestatusServiceStatus serviceStatus = new GenericResourceApiServicestatusServiceStatus(); - serviceStatus.setAction(serviceStatusAction); - serviceStatus.setFinalIndicator(serviceStatusFinalIndicator); - serviceStatus.setRequestStatus(GenericResourceApiRequestStatusEnumeration.fromValue(serviceStatusRequestStatus)); - serviceStatus.setResponseCode(serviceStatusResponseCode); - serviceStatus.setResponseMessage(serviceStatusResponseMessage); - serviceStatus.setResponseTimestamp(serviceStatusResponseTimestamp); - - return(serviceStatus); - } - - public void setServiceStatus(GenericResourceApiServicestatusServiceStatus serviceStatus) { - this.serviceStatusAction = serviceStatus.getAction(); - this.serviceStatusFinalIndicator = serviceStatus.getFinalIndicator(); - if (serviceStatus.getRequestStatus() != null) { - this.serviceStatusRequestStatus = serviceStatus.getRequestStatus().toString(); - } - - this.serviceStatusResponseCode = serviceStatus.getResponseCode(); - this.serviceStatusResponseMessage = serviceStatus.getResponseMessage(); - this.serviceStatusResponseTimestamp = serviceStatus.getResponseTimestamp(); - } -} diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalServicesRepository.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalServicesRepository.java deleted file mode 100644 index 15b2acc..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalServicesRepository.java +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SDNC - * ================================================================================ - * Copyright (C) 2020 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.sdnc.apps.ms.gra.data; - -import org.springframework.data.repository.CrudRepository; - -import java.util.List; - - -public interface OperationalServicesRepository extends CrudRepository<OperationalServices, Long> { - - List<OperationalServices> findBySvcInstanceId(String svcInstanceId); - long deleteBySvcInstanceId(String svcInstanceId); - -} - diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/PreloadDataKey.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/PreloadDataKey.java deleted file mode 100644 index 34f010c..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/PreloadDataKey.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.onap.sdnc.apps.ms.gra.data; - -import java.io.Serializable; - -public class PreloadDataKey implements Serializable { - private String preloadId = ""; - private String preloadType = ""; - - public PreloadDataKey() { - this.preloadId = ""; - this.preloadType = ""; - } - - public PreloadDataKey(String preloadId, String preloadType) { - this.preloadId = preloadId; - this.preloadType = preloadType; - } - - @Override - public int hashCode() { - return preloadId.hashCode() + preloadType.hashCode(); - } - - @Override - public boolean equals(Object obj) { - return (obj instanceof PreloadDataKey && - preloadId.equals(((PreloadDataKey)obj).preloadId) && - preloadType.equals(((PreloadDataKey)obj).preloadType)); - } -} diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/VfModulesKey.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/VfModulesKey.java deleted file mode 100644 index bf44cc9..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/VfModulesKey.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.onap.sdnc.apps.ms.gra.data; - -import java.io.Serializable; - -public class VfModulesKey implements Serializable { - private String svcInstanceId = ""; - private String vnfId = ""; - private String vfModuleId = ""; - - public VfModulesKey() { - this.svcInstanceId = ""; - this.vnfId = ""; - this.vfModuleId = ""; - } - - public VfModulesKey(String svcInstanceId, String vnfId, String vfModuleId) { - this.svcInstanceId = svcInstanceId; - this.vnfId = vnfId; - this.vfModuleId = vfModuleId; - } - - @Override - public int hashCode() { - return svcInstanceId.hashCode() + vnfId.hashCode()+vfModuleId.hashCode(); - } - - @Override - public boolean equals(Object obj) { - return (obj instanceof VfModulesKey && - svcInstanceId.equals(((VfModulesKey)obj).svcInstanceId) && - vnfId.equals(((VfModulesKey)obj).vnfId) && - vfModuleId.equals(((VfModulesKey)obj).vfModuleId)); - } -} diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/VnfsKey.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/VnfsKey.java deleted file mode 100644 index f19c95e..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/VnfsKey.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.onap.sdnc.apps.ms.gra.data; - -import java.io.Serializable; - -public class VnfsKey implements Serializable { - private String svcInstanceId = ""; - private String vnfId = ""; - - public VnfsKey() { - this.svcInstanceId = ""; - this.vnfId = ""; - } - - public VnfsKey(String svcInstanceId, String vnfId) { - this.svcInstanceId = svcInstanceId; - this.vnfId = vnfId; - } - - @Override - public int hashCode() { - return svcInstanceId.hashCode() + vnfId.hashCode(); - } - - @Override - public boolean equals(Object obj) { - return (obj instanceof VnfsKey && - svcInstanceId.equals(((VnfsKey)obj).svcInstanceId) && - vnfId.equals(((VnfsKey)obj).vnfId)); - } -} |