summaryrefslogtreecommitdiffstats
path: root/ms/generic-resource-api/src/main/java/org/onap
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2020-06-08 12:16:24 -0400
committerDan Timoney <dtimoney@att.com>2020-06-19 14:15:10 -0400
commitd99e2dfa5c1db6daed4e98ea208089969a0867cf (patch)
tree9c4cdfdfff13d37f184cb4f1aa86a6d23bebf6f1 /ms/generic-resource-api/src/main/java/org/onap
parent5563f521d8ca0b38f93d51246d2aea8c6648c3a4 (diff)
Implement GRA preload and service data objects
Implements CRUD operations and RPCs for GRA preload data, as well as adding data object for service-data. Change-Id: I93d268e7f1cfbcd4e839e122f72ce02928dad807 Issue-ID: SDNC-1205 Issue-ID: SDNC-1209 Issue-ID: SDNC-1210 Issue-ID: SDNC-1213 Signed-off-by: Dan Timoney <dtimoney@att.com>
Diffstat (limited to 'ms/generic-resource-api/src/main/java/org/onap')
-rw-r--r--ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiController.java322
-rw-r--r--ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/controllers/OperationsApiController.java384
-rw-r--r--ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/core/GenericResourceMsApp.java78
-rw-r--r--ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/core/WebConfig.java54
-rw-r--r--ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigPreloadData.java80
-rw-r--r--ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigPreloadDataRepository.java34
-rw-r--r--ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigServices.java164
-rw-r--r--ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigServicesRepository.java34
-rw-r--r--ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalPreloadData.java80
-rw-r--r--ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalPreloadDataRepository.java34
-rw-r--r--ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalServices.java156
-rw-r--r--ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalServicesRepository.java34
-rw-r--r--ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/PreloadDataKey.java30
13 files changed, 1484 insertions, 0 deletions
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
new file mode 100644
index 0000000..d6bc2b0
--- /dev/null
+++ b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiController.java
@@ -0,0 +1,322 @@
+/*-
+ * ============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 com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+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.swagger.ConfigApi;
+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;
+
+@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
+ public ConfigApiController(ObjectMapper objectMapper, HttpServletRequest request) {
+ 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.OK));
+ }
+
+ @Override
+ public ResponseEntity<GenericResourceApiPreloadModelInformation> configGENERICRESOURCEAPIpreloadInformationGet() {
+ GenericResourceApiPreloadModelInformation genericResourceApiPreloadModelInformation = new GenericResourceApiPreloadModelInformation();
+
+ configPreloadDataRepository.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<Void> configGENERICRESOURCEAPIpreloadInformationPost(@Valid GenericResourceApiPreloadModelInformation graPreloadModelInfo) {
+
+ List<GenericResourceApiPreloadmodelinformationPreloadList> preloadList = graPreloadModelInfo.getPreloadList();
+
+ if (preloadList != null) {
+ Iterator<GenericResourceApiPreloadmodelinformationPreloadList> iter = preloadList.iterator();
+ while (iter.hasNext()) {
+ GenericResourceApiPreloadmodelinformationPreloadList curItem = iter.next();
+
+ // Remove any entries already existing for this preloadId/preloadType
+ configPreloadDataRepository.deleteByPreloadIdAndPreloadType(curItem.getPreloadId(), curItem.getPreloadType());
+
+ try {
+ configPreloadDataRepository.save(new ConfigPreloadData(curItem.getPreloadId(), curItem.getPreloadType(), objectMapper.writeValueAsString(curItem.getPreloadData())));
+ } catch (JsonProcessingException e) {
+ log.error("Cannot convert preload data", e);
+ }
+ }
+ }
+
+ return new ResponseEntity<>(HttpStatus.OK);
+ }
+
+ @Override
+ public ResponseEntity<Void> configGENERICRESOURCEAPIpreloadInformationGENERICRESOURCEAPIpreloadListPost(@Valid GenericResourceApiPreloadmodelinformationPreloadList preloadListItem) {
+
+ // Remove any entries already existing for this preloadId/preloadType
+ configPreloadDataRepository.deleteByPreloadIdAndPreloadType(preloadListItem.getPreloadId(), preloadListItem.getPreloadType());
+
+ try {
+ configPreloadDataRepository.save(new ConfigPreloadData(preloadListItem.getPreloadId(), preloadListItem.getPreloadType(), objectMapper.writeValueAsString(preloadListItem.getPreloadData())));
+ } catch (JsonProcessingException e) {
+ log.error("Cannot convert preload data", e);
+ }
+ return new ResponseEntity<>(HttpStatus.OK);
+ }
+
+ @Override
+ public ResponseEntity<Void> configGENERICRESOURCEAPIpreloadInformationGENERICRESOURCEAPIpreloadListPreloadIdPreloadTypeDelete(String preloadId, String preloadType) {
+ configPreloadDataRepository.deleteByPreloadIdAndPreloadType(preloadId, preloadType);
+ return new ResponseEntity<>(HttpStatus.OK);
+ }
+
+ @Override
+ public ResponseEntity<GenericResourceApiPreloadmodelinformationPreloadList> configGENERICRESOURCEAPIpreloadInformationGENERICRESOURCEAPIpreloadListPreloadIdPreloadTypeGet(String preloadId, String preloadType) {
+ 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);
+ }
+ return new ResponseEntity<>(preloadDataList, HttpStatus.OK);
+ }
+ }
+ return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+ }
+
+ @Override
+ public ResponseEntity<Void> configGENERICRESOURCEAPIpreloadInformationGENERICRESOURCEAPIpreloadListPreloadIdPreloadTypePost(String preloadId, String preloadType, @Valid GenericResourceApiPreloadmodelinformationPreloadList preloadListItem) {
+ configPreloadDataRepository.deleteByPreloadIdAndPreloadType(preloadId, preloadType);
+ try {
+ configPreloadDataRepository.save(new ConfigPreloadData(preloadId, preloadType, objectMapper.writeValueAsString(preloadListItem.getPreloadData())));
+ } catch (JsonProcessingException e) {
+ log.error("Cannot convert preload data", e);
+ }
+ return new ResponseEntity<>(HttpStatus.OK);
+ }
+
+
+ @Override
+ public ResponseEntity<Void> configGENERICRESOURCEAPIpreloadInformationGENERICRESOURCEAPIpreloadListPreloadIdPreloadTypeGENERICRESOURCEAPIpreloadDataDelete(String preloadId, String preloadType) {
+ List<ConfigPreloadData> preloadData = configPreloadDataRepository.findByPreloadIdAndPreloadType(preloadId, preloadType);
+
+ if (preloadData != null) {
+ Iterator<ConfigPreloadData> iter = preloadData.iterator();
+
+ while (iter.hasNext()) {
+ configPreloadDataRepository.delete(iter.next());
+ }
+ }
+ return new ResponseEntity<>(HttpStatus.OK);
+ }
+
+ @Override
+ public ResponseEntity<Void> configGENERICRESOURCEAPIpreloadInformationPut(@Valid GenericResourceApiPreloadModelInformation genericResourceApiPreloadModelInformationBodyParam) {
+ return null;
+ }
+
+ @Override
+ public ResponseEntity<GenericResourceApiPreloaddataPreloadData> configGENERICRESOURCEAPIpreloadInformationGENERICRESOURCEAPIpreloadListPreloadIdPreloadTypeGENERICRESOURCEAPIpreloadDataGet(String preloadId, String preloadType) {
+ List<ConfigPreloadData> preloadData = configPreloadDataRepository.findByPreloadIdAndPreloadType(preloadId, preloadType);
+ if (preloadData != null) {
+ if (!preloadData.isEmpty()) {
+ ConfigPreloadData 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<Void> configGENERICRESOURCEAPIpreloadInformationGENERICRESOURCEAPIpreloadListPreloadIdPreloadTypeGENERICRESOURCEAPIpreloadDataPost(String preloadId, String preloadType, @Valid GenericResourceApiPreloaddataPreloadData preloadData) {
+ configPreloadDataRepository.deleteByPreloadIdAndPreloadType(preloadId, preloadType);
+ try {
+ configPreloadDataRepository.save(new ConfigPreloadData(preloadId, preloadType, objectMapper.writeValueAsString(preloadData)));
+ } catch (JsonProcessingException e) {
+ log.error("Cannot convert preload data", e);
+ }
+ return new ResponseEntity<>(HttpStatus.OK);
+ }
+
+ @Override
+ public ResponseEntity<Void> configGENERICRESOURCEAPIservicesDelete() {
+ configServicesRepository.deleteAll();
+ return new ResponseEntity<>(HttpStatus.OK);
+ }
+
+ @Override
+ public ResponseEntity<Void> configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIservicePost(@Valid GenericResourceApiServicemodelinfrastructureService servicesData) {
+ String svcInstanceId = servicesData.getServiceInstanceId();
+ try {
+ String svcData = objectMapper.writeValueAsString(servicesData.getServiceData());
+ ConfigServices configService = new ConfigServices(svcInstanceId, svcData, servicesData.getServiceStatus());
+ configServicesRepository.deleteBySvcInstanceId(svcInstanceId);
+ configServicesRepository.save(configService);
+ } catch (JsonProcessingException e) {
+ log.error("Cannot convert service data", e);
+ }
+ return new ResponseEntity<>(HttpStatus.OK);
+ }
+
+ @Override
+ public ResponseEntity<Void> configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdDelete(String serviceInstanceId) {
+ configServicesRepository.deleteBySvcInstanceId(serviceInstanceId);
+ return new ResponseEntity<>(HttpStatus.OK);
+ }
+
+ @Override
+ public ResponseEntity<Void> configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceDataDelete(String serviceInstanceId) {
+ return null;
+ }
+
+ @Override
+ public ResponseEntity<GenericResourceApiServicedataServiceData> configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceDataGet(String serviceInstanceId) {
+ return null;
+ }
+
+ @Override
+ public ResponseEntity<Void> configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceDataPost(String serviceInstanceId, @Valid GenericResourceApiServicedataServiceData genericResourceApiServicedataServiceDataBodyParam) {
+ return null;
+ }
+
+ @Override
+ public ResponseEntity<Void> configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceDataPut(String serviceInstanceId, @Valid GenericResourceApiServicedataServiceData genericResourceApiServicedataServiceDataBodyParam) {
+ return null;
+ }
+
+ @Override
+ public ResponseEntity<Void> configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceStatusDelete(String serviceInstanceId) {
+ return null;
+ }
+
+ @Override
+ public ResponseEntity<GenericResourceApiServicestatusServiceStatus> configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceStatusGet(String serviceInstanceId) {
+ return null;
+ }
+
+ @Override
+ public ResponseEntity<Void> configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceStatusPost(String serviceInstanceId, @Valid GenericResourceApiServicestatusServiceStatus genericResourceApiServicestatusServiceStatusBodyParam) {
+ return null;
+ }
+
+ @Override
+ public ResponseEntity<Void> configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGENERICRESOURCEAPIserviceStatusPut(String serviceInstanceId, @Valid GenericResourceApiServicestatusServiceStatus genericResourceApiServicestatusServiceStatusBodyParam) {
+ return null;
+ }
+
+ @Override
+ public ResponseEntity<GenericResourceApiServicemodelinfrastructureService> configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdGet(String serviceInstanceId) {
+ return null;
+ }
+
+ @Override
+ public ResponseEntity<Void> configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdPost(String serviceInstanceId, @Valid GenericResourceApiServicemodelinfrastructureService genericResourceApiServicemodelinfrastructureServiceBodyParam) {
+ return null;
+ }
+
+ @Override
+ public ResponseEntity<Void> configGENERICRESOURCEAPIservicesGENERICRESOURCEAPIserviceServiceInstanceIdPut(String serviceInstanceId, @Valid GenericResourceApiServicemodelinfrastructureService genericResourceApiServicemodelinfrastructureServiceBodyParam) {
+ return null;
+ }
+
+ @Override
+ public ResponseEntity<GenericResourceApiServiceModelInfrastructure> configGENERICRESOURCEAPIservicesGet() {
+ return null;
+ }
+
+ @Override
+ public ResponseEntity<Void> configGENERICRESOURCEAPIservicesPost(@Valid GenericResourceApiServiceModelInfrastructure genericResourceApiServiceModelInfrastructureBodyParam) {
+ return null;
+ }
+
+ @Override
+ public ResponseEntity<Void> configGENERICRESOURCEAPIservicesPut(@Valid GenericResourceApiServiceModelInfrastructure genericResourceApiServiceModelInfrastructureBodyParam) {
+ return null;
+ }
+}
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
new file mode 100644
index 0000000..e2065ae
--- /dev/null
+++ b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/controllers/OperationsApiController.java
@@ -0,0 +1,384 @@
+/*-
+ * ============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 com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.JsonParser;
+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.provider.base.SvcLogicServiceBase;
+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.OperationalPreloadData;
+import org.onap.sdnc.apps.ms.gra.data.OperationalPreloadDataRepository;
+import org.onap.sdnc.apps.ms.gra.swagger.OperationsApi;
+import org.onap.sdnc.apps.ms.gra.swagger.model.*;
+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;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.validation.Valid;
+import java.util.*;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+
+@Controller
+@ComponentScan(basePackages = {"org.onap.sdnc.apps.ms.gra.*"})
+@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 final ObjectMapper objectMapper;
+
+ private final HttpServletRequest request;
+
+ @Autowired
+ protected SvcLogicServiceBase svc;
+
+ @Autowired
+ private ConfigPreloadDataRepository configPreloadDataRepository;
+
+ @Autowired
+ private OperationalPreloadDataRepository operationalPreloadDataRepository;
+
+
+ @org.springframework.beans.factory.annotation.Autowired
+ public OperationsApiController(ObjectMapper objectMapper, HttpServletRequest request) {
+ 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();
+
+ GenericResourceApiPreloadModelInformation preloadModelInfo = null;
+
+
+ // Add input to SvcLogicContext
+ try {
+ ctxIn.mergeJson("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 {
+ preloadModelInfo = getConfigPreloadData(preloadId, preloadType);
+ ctxIn.mergeJson("preload-data", objectMapper.writeValueAsString(preloadModelInfo.getPreloadList()));
+ } 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 {
+ preloadModelInfo = getOperationalPreloadData(preloadId, preloadType);
+ ctxIn.mergeJson("operational-data", objectMapper.writeValueAsString(preloadModelInfo.getPreloadList()));
+ } 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");
+ GenericResourceApiPreloadModelInformation preloadToLoad = objectMapper.readValue(ctxJson, GenericResourceApiPreloadModelInformation.class);
+ saveConfigPreloadData(preloadToLoad);
+ saveOperationalPreloadData(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()))));
+ }
+
+ @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();
+
+ GenericResourceApiPreloadModelInformation preloadModelInfo = null;
+
+
+ // Add input to SvcLogicContext
+ try {
+ ctxIn.mergeJson("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 {
+ preloadModelInfo = getConfigPreloadData(preloadId, preloadType);
+ ctxIn.mergeJson("preload-data", objectMapper.writeValueAsString(preloadModelInfo.getPreloadList()));
+ } 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 {
+ preloadModelInfo = getOperationalPreloadData(preloadId, preloadType);
+ ctxIn.mergeJson("operational-data", objectMapper.writeValueAsString(preloadModelInfo.getPreloadList()));
+ } 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");
+ GenericResourceApiPreloadModelInformation preloadToLoad = objectMapper.readValue(ctxJson, GenericResourceApiPreloadModelInformation.class);
+ saveConfigPreloadData(preloadToLoad);
+ saveOperationalPreloadData(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 GenericResourceApiPreloadModelInformation getConfigPreloadData(String preloadId, String preloadType) throws JsonProcessingException {
+ GenericResourceApiPreloadModelInformation preloadModelInfo = new GenericResourceApiPreloadModelInformation();
+ List<ConfigPreloadData> configPreloadData = configPreloadDataRepository.findByPreloadIdAndPreloadType(preloadId, preloadType);
+
+ for (ConfigPreloadData preloadItem : configPreloadData) {
+
+ GenericResourceApiPreloadmodelinformationPreloadList preloadListItem = new GenericResourceApiPreloadmodelinformationPreloadList();
+ preloadListItem.setPreloadId(preloadItem.getPreloadId());
+ preloadListItem.setPreloadType(preloadItem.getPreloadType());
+ preloadListItem.setPreloadData(objectMapper.readValue(preloadItem.getPreloadData(), GenericResourceApiPreloaddataPreloadData.class));
+ preloadModelInfo.addPreloadListItem(preloadListItem);
+
+ }
+ return (preloadModelInfo);
+ }
+
+ private void saveConfigPreloadData(GenericResourceApiPreloadModelInformation preloadModelInfo) throws JsonProcessingException {
+ List<GenericResourceApiPreloadmodelinformationPreloadList> preloadListItems = preloadModelInfo.getPreloadList();
+
+ for (GenericResourceApiPreloadmodelinformationPreloadList preloadListItem: preloadListItems) {
+ String preloadId = preloadListItem.getPreloadId();
+ String preloadType = preloadListItem.getPreloadType();
+ configPreloadDataRepository.deleteByPreloadIdAndPreloadType(preloadId, preloadType);
+ configPreloadDataRepository.save(new ConfigPreloadData(preloadId, preloadType, objectMapper.writeValueAsString(preloadListItem.getPreloadData())));
+ }
+ }
+ private void saveOperationalPreloadData(GenericResourceApiPreloadModelInformation preloadModelInfo) throws JsonProcessingException {
+ List<GenericResourceApiPreloadmodelinformationPreloadList> preloadListItems = preloadModelInfo.getPreloadList();
+
+ for (GenericResourceApiPreloadmodelinformationPreloadList preloadListItem: preloadListItems) {
+ String preloadId = preloadListItem.getPreloadId();
+ String preloadType = preloadListItem.getPreloadType();
+ operationalPreloadDataRepository.deleteByPreloadIdAndPreloadType(preloadId, preloadType);
+ operationalPreloadDataRepository.save(new OperationalPreloadData(preloadId, preloadType, objectMapper.writeValueAsString(preloadListItem.getPreloadData())));
+ }
+ }
+
+
+ private GenericResourceApiPreloadModelInformation getOperationalPreloadData(String preloadId, String preloadType) throws JsonProcessingException {
+ GenericResourceApiPreloadModelInformation preloadModelInfo = new GenericResourceApiPreloadModelInformation();
+ List<OperationalPreloadData> operPreloadData = operationalPreloadDataRepository.findByPreloadIdAndPreloadType(preloadId, preloadType);
+
+ for (OperationalPreloadData preloadItem : operPreloadData) {
+
+ GenericResourceApiPreloadmodelinformationPreloadList preloadListItem = new GenericResourceApiPreloadmodelinformationPreloadList();
+ preloadListItem.setPreloadId(preloadItem.getPreloadId());
+ preloadListItem.setPreloadType(preloadItem.getPreloadType());
+ preloadListItem.setPreloadData(objectMapper.readValue(preloadItem.getPreloadData(), GenericResourceApiPreloaddataPreloadData.class));
+ preloadModelInfo.addPreloadListItem(preloadListItem);
+
+ }
+ return (preloadModelInfo);
+ }
+
+
+}
diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/core/GenericResourceMsApp.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/core/GenericResourceMsApp.java
new file mode 100644
index 0000000..a195c0c
--- /dev/null
+++ b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/core/GenericResourceMsApp.java
@@ -0,0 +1,78 @@
+/*-
+ * ============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.core;
+
+import org.apache.shiro.realm.Realm;
+import org.apache.shiro.realm.text.PropertiesRealm;
+import org.apache.shiro.spring.web.config.DefaultShiroFilterChainDefinition;
+import org.apache.shiro.spring.web.config.ShiroFilterChainDefinition;
+import org.onap.aaf.cadi.shiro.AAFRealm;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Import;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+@SpringBootApplication(scanBasePackages= { "org.onap.sdnc.apps.ms.gra.*" })
+@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);
+ }
+
+ @Bean
+ public Realm realm() {
+
+ // If cadi prop files is not defined use local properties realm
+ // src/main/resources/shiro-users.properties
+ if ("none".equals(System.getProperty("cadi_prop_files", "none"))) {
+ log.info("cadi_prop_files undefined, AAF Realm will not be set");
+ PropertiesRealm realm = new PropertiesRealm();
+ return realm;
+ } else {
+ AAFRealm realm = new AAFRealm();
+ return realm;
+ }
+
+ }
+
+ @Bean
+ public ShiroFilterChainDefinition shiroFilterChainDefinition() {
+ DefaultShiroFilterChainDefinition chainDefinition = new DefaultShiroFilterChainDefinition();
+
+ // if cadi prop files is not set disable authentication
+ if ("none".equals(System.getProperty("cadi_prop_files", "none"))) {
+ chainDefinition.addPathDefinition("/**", "anon");
+ } else {
+ log.info("Loaded property cadi_prop_files, AAF REALM set");
+ chainDefinition.addPathDefinition("/**", "authcBasic, rest[org.onap.sdnc.odl:odl-api]");
+ }
+
+ return chainDefinition;
+ }
+
+}
diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/core/WebConfig.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/core/WebConfig.java
new file mode 100644
index 0000000..c71ac98
--- /dev/null
+++ b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/core/WebConfig.java
@@ -0,0 +1,54 @@
+/*-
+ * ============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.core;
+
+import org.onap.logging.filter.spring.LoggingInterceptor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.domain.EntityScan;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+import org.springframework.jdbc.datasource.DriverManagerDataSource;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
+import org.springframework.orm.jpa.JpaTransactionManager;
+import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
+import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
+import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+import org.springframework.web.servlet.config.annotation.EnableWebMvc;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+import javax.persistence.EntityManagerFactory;
+import javax.sql.DataSource;
+
+@Configuration
+@EnableJpaRepositories("org.onap.sdnc.apps.ms.gra.*")
+@ComponentScan(basePackages={"org.onap.sdnc.apps.ms.gra.*"})
+@EntityScan("org.onap.sdnc.apps.ms.gra.*")
+@EnableTransactionManagement
+public class WebConfig implements WebMvcConfigurer {
+
+
+}
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
new file mode 100644
index 0000000..4d0f9da
--- /dev/null
+++ b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigPreloadData.java
@@ -0,0 +1,80 @@
+/*-
+ * ============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
+ 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
new file mode 100644
index 0000000..603611d
--- /dev/null
+++ b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigPreloadDataRepository.java
@@ -0,0 +1,34 @@
+/*-
+ * ============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 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
new file mode 100644
index 0000000..187169a
--- /dev/null
+++ b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigServices.java
@@ -0,0 +1,164 @@
+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;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+import javax.persistence.Table;
+
+@Entity(name="CONFIG_GRA_SERVICES")
+@Table(name="CONFIG_GRA_SERVICES")
+public class ConfigServices {
+ @Id
+ 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, String svcData) {
+ this.svcInstanceId = svcInstanceId;
+ this.svcData = svcData;
+ }
+
+ 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() {
+ 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();
+ 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
new file mode 100644
index 0000000..62e09b7
--- /dev/null
+++ b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/ConfigServicesRepository.java
@@ -0,0 +1,34 @@
+/*-
+ * ============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 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/OperationalPreloadData.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalPreloadData.java
new file mode 100644
index 0000000..936d2f7
--- /dev/null
+++ b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalPreloadData.java
@@ -0,0 +1,80 @@
+/*-
+ * ============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
+ 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
new file mode 100644
index 0000000..34df132
--- /dev/null
+++ b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalPreloadDataRepository.java
@@ -0,0 +1,34 @@
+/*-
+ * ============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
new file mode 100644
index 0000000..eb46816
--- /dev/null
+++ b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalServices.java
@@ -0,0 +1,156 @@
+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;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+import javax.persistence.Table;
+
+@Entity(name="OPERATIONAL_GRA_SERVICES")
+@Table(name="OPERATIONAL_GRA_SERVICES")
+public class OperationalServices {
+ @Id
+ 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();
+ 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
new file mode 100644
index 0000000..15b2acc
--- /dev/null
+++ b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/OperationalServicesRepository.java
@@ -0,0 +1,34 @@
+/*-
+ * ============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
new file mode 100644
index 0000000..34f010c
--- /dev/null
+++ b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/data/PreloadDataKey.java
@@ -0,0 +1,30 @@
+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));
+ }
+}