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.RestApplicationException;
import org.onap.ccsdk.apps.services.RestException;
import java.util.stream.Stream;
@Controller
-@ComponentScan(basePackages = {"org.onap.sdnc.apps.ms.gra.*"})
+@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);
}
@Override
- public ResponseEntity<GenericResourceApiPreloadModelInformation> configGENERICRESOURCEAPIpreloadInformationGet() throws RestApplicationException {
+ 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());
+ 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()) {
preloadListItem.setPreloadId(configPreloadData.getPreloadId());
preloadListItem.setPreloadType(configPreloadData.getPreloadType());
try {
- preloadListItem.setPreloadData(objectMapper.readValue(configPreloadData.getPreloadData(), GenericResourceApiPreloaddataPreloadData.class));
+ 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());
+ 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<Void> configGENERICRESOURCEAPIpreloadInformationPost(@Valid GenericResourceApiPreloadModelInformation graPreloadModelInfo) throws RestApplicationException, RestProtocolException {
+ 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<>();
// Verification pass - if any items already exist, return an error
for (GenericResourceApiPreloadmodelinformationPreloadList curItem : preloadList) {
- List<ConfigPreloadData> curPreloadData = configPreloadDataRepository.findByPreloadIdAndPreloadType(curItem.getPreloadId(), curItem.getPreloadType());
+ 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());
+ 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())));
+ 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());
+ throw new RestApplicationException("data-conversion",
+ "Request could not be completed due to internal error", e,
+ HttpStatus.INTERNAL_SERVER_ERROR.value());
}
}
configPreloadDataRepository.save(newDataItem);
}
} else {
- throw new RestProtocolException("data-missing", "No preload-list entries found to add", HttpStatus.CONFLICT.value());
+ 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 {
+ public ResponseEntity<Void> configGENERICRESOURCEAPIpreloadInformationPut(
+ @Valid GenericResourceApiPreloadModelInformation graPreloadModelInfo) throws RestApplicationException {
boolean addedNew = false;
List<GenericResourceApiPreloadmodelinformationPreloadList> preloadList = graPreloadModelInfo.getPreloadList();
Iterator<GenericResourceApiPreloadmodelinformationPreloadList> iter = preloadList.iterator();
while (iter.hasNext()) {
GenericResourceApiPreloadmodelinformationPreloadList curItem = iter.next();
- List<ConfigPreloadData> curPreloadData = configPreloadDataRepository.findByPreloadIdAndPreloadType(curItem.getPreloadId(), curItem.getPreloadType());
+ 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())));
+ 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());
+ throw new RestApplicationException("data-conversion",
+ "Request could not be completed due to internal error", e,
+ HttpStatus.INTERNAL_SERVER_ERROR.value());
}
}
}
@Override
- public ResponseEntity<Void> configGENERICRESOURCEAPIpreloadInformationPreloadListPost(@Valid GenericResourceApiPreloadmodelinformationPreloadList preloadListItem) throws RestProtocolException {
+ public ResponseEntity<Void> configGENERICRESOURCEAPIpreloadInformationPreloadListPost(
+ @Valid GenericResourceApiPreloadmodelinformationPreloadList preloadListItem) throws RestProtocolException {
- throw new RestProtocolException("data-missing", "Missing key for list \"preload-list\"", HttpStatus.NOT_FOUND.value());
+ throw new RestProtocolException("data-missing", "Missing key for list \"preload-list\"",
+ HttpStatus.NOT_FOUND.value());
}
-
@Override
- public ResponseEntity<Void> configGENERICRESOURCEAPIpreloadInformationPreloadListPreloadIdPreloadTypeDelete(String preloadId, String preloadType) {
+ 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);
+ 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);
preloadDataList.setPreloadId(preloadDataItem.getPreloadId());
preloadDataList.setPreloadType(preloadDataItem.getPreloadType());
try {
- preloadDataList.setPreloadData(objectMapper.readValue(preloadDataItem.getPreloadData(), GenericResourceApiPreloaddataPreloadData.class));
+ 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());
+ 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);
}
}
@Override
- public ResponseEntity<Void> configGENERICRESOURCEAPIpreloadInformationPreloadListPreloadIdPreloadTypePost(String preloadId, String preloadType, @Valid GenericResourceApiPreloadmodelinformationPreloadList preloadListItem) throws RestApplicationException, RestProtocolException {
- List<ConfigPreloadData> preloadDataItems = configPreloadDataRepository.findByPreloadIdAndPreloadType(preloadId, preloadType);
+ 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());
+ 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())));
+ 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());
+ 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);
+ 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)) {
+ 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));
+ 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())));
+ 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());
+ throw new RestApplicationException("data-conversion",
+ "Request could not be completed due to internal error", e,
+ HttpStatus.INTERNAL_SERVER_ERROR.value());
}
}
}
-
@Override
- public ResponseEntity<Void> configGENERICRESOURCEAPIpreloadInformationPreloadListPreloadIdPreloadTypePreloadDataDelete(String preloadId, String preloadType) throws RestProtocolException {
- List<ConfigPreloadData> preloadData = configPreloadDataRepository.findByPreloadIdAndPreloadType(preloadId, preloadType);
+ 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());
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);
+ 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());
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);
+ 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());
+ 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> preloadDataEntries = configPreloadDataRepository.findByPreloadIdAndPreloadType(preloadId, preloadType);
-
- List<ConfigPreloadData> preloadDataItems = configPreloadDataRepository.findByPreloadIdAndPreloadType(preloadId, preloadType);
+ public ResponseEntity<Void> configGENERICRESOURCEAPIpreloadInformationPreloadListPreloadIdPreloadTypePreloadDataPost(
+ String preloadId, String preloadType, @Valid GenericResourceApiPreloaddataPreloadData preloadData)
+ throws RestApplicationException, RestProtocolException {
+ List<ConfigPreloadData> preloadDataEntries = configPreloadDataRepository
+ .findByPreloadIdAndPreloadType(preloadId, preloadType);
+
+ 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());
+ 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());
+ throw new RestProtocolException("data-exists", "Data already exists for " + preloadId + ":" + preloadType,
+ HttpStatus.CONFLICT.value());
}
try {
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());
+ 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 {
+ public ResponseEntity<Void> configGENERICRESOURCEAPIpreloadInformationPreloadListPreloadIdPreloadTypePreloadDataPut(
+ String preloadId, String preloadType, @Valid GenericResourceApiPreloaddataPreloadData preloadData)
+ throws RestApplicationException, RestProtocolException {
boolean dataExists = false;
- List<ConfigPreloadData> preloadDataItems = configPreloadDataRepository.findByPreloadIdAndPreloadType(preloadId, preloadType);
+ 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());
+ if ((preloadData == null) || (preloadData.getPreloadNetworkTopologyInformation() == null)) {
+ throw new RestProtocolException("bad-attribute", "Invalid preloadData received",
+ HttpStatus.BAD_REQUEST.value());
}
ConfigPreloadData preloadDataItem = preloadDataItems.get(0);
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());
+ throw new RestApplicationException("data-conversion",
+ "Request could not be completed due to internal error", e,
+ HttpStatus.INTERNAL_SERVER_ERROR.value());
}
if (dataExists) {
}
@Override
- public ResponseEntity<GenericResourceApiServiceModelInfrastructure> configGENERICRESOURCEAPIservicesGet() throws RestApplicationException {
+ 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());
+ 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();
serviceItem.setServiceInstanceId(service.getSvcInstanceId());
if (service.getSvcData() != null) {
- try {
- serviceItem.setServiceData(objectMapper.readValue(service.getSvcData(), GenericResourceApiServicedataServiceData.class));
- } 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());
+ try {
+ serviceItem.setServiceData(objectMapper.readValue(service.getSvcData(),
+ GenericResourceApiServicedataServiceData.class));
+ } 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());
+ }
}
- }
serviceItem.setServiceStatus(service.getServiceStatus());
modelInfrastructure.addServiceItem(serviceItem);
}
-
return new ResponseEntity<>(modelInfrastructure, HttpStatus.OK);
}
@Override
- public ResponseEntity<Void> configGENERICRESOURCEAPIservicesPost(@Valid GenericResourceApiServiceModelInfrastructure modelInfrastructure) throws RestApplicationException, RestProtocolException {
+ public ResponseEntity<Void> configGENERICRESOURCEAPIservicesPost(
+ @Valid GenericResourceApiServiceModelInfrastructure modelInfrastructure)
+ throws RestApplicationException, RestProtocolException {
List<ConfigServices> newServices = new LinkedList<>();
for (GenericResourceApiServicemodelinfrastructureService serviceItem : modelInfrastructure.getService()) {
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());
+ throw new RestProtocolException("data-exists",
+ "Data already exists for service-instance-id " + svcInstanceId, HttpStatus.CONFLICT.value());
}
ConfigServices service = new ConfigServices();
service.setSvcInstanceId(svcInstanceId);
service.setSvcData(objectMapper.writeValueAsString(serviceItem.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());
+ throw new RestApplicationException("data-conversion",
+ "Request could not be completed due to internal error", e,
+ HttpStatus.INTERNAL_SERVER_ERROR.value());
}
service.setServiceStatus(serviceItem.getServiceStatus());
}
@Override
- public ResponseEntity<Void> configGENERICRESOURCEAPIservicesPut(@Valid GenericResourceApiServiceModelInfrastructure modelInfrastructure) throws RestApplicationException {
+ public ResponseEntity<Void> configGENERICRESOURCEAPIservicesPut(
+ @Valid GenericResourceApiServiceModelInfrastructure modelInfrastructure) throws RestApplicationException {
List<ConfigServices> newServices = new LinkedList<>();
boolean dataExists = false;
service.setSvcData(objectMapper.writeValueAsString(serviceItem.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());
+ throw new RestApplicationException("data-conversion",
+ "Request could not be completed due to internal error", e,
+ HttpStatus.INTERNAL_SERVER_ERROR.value());
}
service.setServiceStatus(serviceItem.getServiceStatus());
}
@Override
- public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServicePost(@Valid GenericResourceApiServicemodelinfrastructureService servicesData) throws RestApplicationException {
+ public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServicePost(
+ @Valid GenericResourceApiServicemodelinfrastructureService servicesData) throws RestApplicationException {
String svcInstanceId = servicesData.getServiceInstanceId();
try {
String svcData = objectMapper.writeValueAsString(servicesData.getServiceData());
configServicesRepository.save(configService);
} 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());
+ 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) {
+ public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdDelete(
+ String serviceInstanceId) {
configServicesRepository.deleteBySvcInstanceId(serviceInstanceId);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@Override
- public ResponseEntity<GenericResourceApiServicemodelinfrastructureService> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdGet(String serviceInstanceId) throws RestApplicationException {
+ public ResponseEntity<GenericResourceApiServicemodelinfrastructureService> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdGet(
+ String serviceInstanceId) throws RestApplicationException {
GenericResourceApiServicemodelinfrastructureService retval = null;
List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId);
retval.setServiceInstanceId(serviceInstanceId);
retval.setServiceStatus(service.getServiceStatus());
try {
- retval.setServiceData(objectMapper.readValue(service.getSvcData(), GenericResourceApiServicedataServiceData.class));
+ retval.setServiceData(
+ objectMapper.readValue(service.getSvcData(), GenericResourceApiServicedataServiceData.class));
} 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());
+ 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 {
+ 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());
+ throw new RestProtocolException("data-exists",
+ "Data already exists for service-instance-id " + svcInstanceId, HttpStatus.CONFLICT.value());
}
ConfigServices service = new ConfigServices();
service.setSvcInstanceId(svcInstanceId);
service.setSvcData(objectMapper.writeValueAsString(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());
+ throw new RestApplicationException("data-conversion",
+ "Request could not be completed due to internal error", e,
+ HttpStatus.INTERNAL_SERVER_ERROR.value());
}
service.setServiceStatus(newService.getServiceStatus());
}
@Override
- public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdPut(String serviceInstanceId, @Valid GenericResourceApiServicemodelinfrastructureService newService) throws RestApplicationException {
+ public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdPut(String serviceInstanceId,
+ @Valid GenericResourceApiServicemodelinfrastructureService newService) throws RestApplicationException {
boolean dataExists = false;
service.setSvcData(objectMapper.writeValueAsString(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());
+ throw new RestApplicationException("data-conversion",
+ "Request could not be completed due to internal error", e,
+ HttpStatus.INTERNAL_SERVER_ERROR.value());
}
service.setServiceStatus(newService.getServiceStatus());
}
}
-
@Override
- public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataDelete(String serviceInstanceId) throws RestProtocolException {
+ public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataDelete(
+ String serviceInstanceId) throws RestProtocolException {
List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId);
if ((services == null) || (services.isEmpty())) {
}
@Override
- public ResponseEntity<GenericResourceApiServicedataServiceData> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataGet(String serviceInstanceId) throws RestApplicationException, RestProtocolException {
+ public ResponseEntity<GenericResourceApiServicedataServiceData> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataGet(
+ String serviceInstanceId) throws RestApplicationException, RestProtocolException {
GenericResourceApiServicedataServiceData serviceData = null;
List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId);
}
try {
- serviceData = objectMapper.readValue(services.get(0).getSvcData(), GenericResourceApiServicedataServiceData.class);
+ 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);
- throw new RestApplicationException("data-conversion", "Request could not be completed due to internal error", e, HttpStatus.INTERNAL_SERVER_ERROR.value());
+ 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 {
+ 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());
+ if ((serviceData == null) || (serviceData.getServiceInformation() == null)) {
+ throw new RestProtocolException("bad-attribute", "Invalid service-data received",
+ HttpStatus.BAD_REQUEST.value());
}
service = services.get(0);
- if ((service.getSvcData() != null) && (service.getSvcData().length() > 0)){
+ if ((service.getSvcData() != null) && (service.getSvcData().length() > 0)) {
log.error("service-data already exists for svcInstanceId {}", serviceInstanceId);
- throw new RestProtocolException("data-exists", "Data already exists for " + serviceInstanceId, HttpStatus.CONFLICT.value());
+ throw new RestProtocolException("data-exists", "Data already exists for " + serviceInstanceId,
+ HttpStatus.CONFLICT.value());
}
-
try {
service.setSvcData(objectMapper.writeValueAsString(serviceData));
configServicesRepository.save(service);
} 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());
+ 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 {
+ public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataPut(
+ String serviceInstanceId, @Valid GenericResourceApiServicedataServiceData serviceData)
+ throws RestApplicationException, RestProtocolException {
ConfigServices service;
boolean dataExists = false;
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());
+ if ((serviceData == null) || (serviceData.getServiceInformation() == null)) {
+ throw new RestProtocolException("bad-attribute", "Invalid service-data received",
+ HttpStatus.BAD_REQUEST.value());
}
service = services.get(0);
configServicesRepository.save(service);
} 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());
+ throw new RestApplicationException("data-conversion",
+ "Request could not be completed due to internal error", e,
+ HttpStatus.INTERNAL_SERVER_ERROR.value());
}
if (dataExists) {
}
@Override
- public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceStatusDelete(String serviceInstanceId) throws RestProtocolException {
+ public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceStatusDelete(
+ String serviceInstanceId) throws RestProtocolException {
List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId);
if ((services == null) || (services.isEmpty())) {
}
@Override
- public ResponseEntity<GenericResourceApiServicestatusServiceStatus> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceStatusGet(String serviceInstanceId) throws RestApplicationException, RestProtocolException {
+ public ResponseEntity<GenericResourceApiServicestatusServiceStatus> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceStatusGet(
+ String serviceInstanceId) throws RestApplicationException, RestProtocolException {
GenericResourceApiServicestatusServiceStatus serviceStatus = null;
List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId);
}
@Override
- public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceStatusPost(String serviceInstanceId, @Valid GenericResourceApiServicestatusServiceStatus serviceStatus) throws RestProtocolException {
+ 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());
+ 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());
+ 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 {
+ public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceStatusPut(
+ String serviceInstanceId, @Valid GenericResourceApiServicestatusServiceStatus serviceStatus)
+ throws RestProtocolException {
ConfigServices service;
boolean dataExists = false;
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());
+ if ((serviceStatus == null) || (serviceStatus.getAction() == null)) {
+ throw new RestProtocolException("bad-attribute", "Invalid service-status received",
+ HttpStatus.BAD_REQUEST.value());
}
service = services.get(0);
dataExists = true;
}
-
service.setServiceStatus(serviceStatus);
configServicesRepository.save(service);
/**
* 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}/
+ * 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 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.
+ * 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.
+ * HttpStatus.NOT_FOUND (404) if {@code serviceInstanceId} does not
+ * exist.
*/
@Override
- public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataVnfsVnfVnfIdDelete(String serviceInstanceId, String vnfId) throws RestException {
+ public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataVnfsVnfVnfIdDelete(
+ String serviceInstanceId, String vnfId) throws RestException {
log.info("DELETE | VNF Data for ({})", vnfId);
- /* The logic may need to be moved inside of this check or this check
- * may need to be removed.
+ /*
+ * The logic may need to be moved inside of this check or this check may need to
+ * be removed.
*/
- if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
+ if (getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
log.info("Something with header.");
} else {
- log.warn("ObjectMapper or HttpServletRequest not configured in default ConfigApi interface so no example is generated");
+ log.warn(
+ "ObjectMapper or HttpServletRequest not configured in default ConfigApi interface so no example is generated");
}
List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId);
ConfigServices data;
- if((services == null) || (services.isEmpty())) {
+ 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());
+ throw new RestProtocolException("data-missing", "Service Instance ID not found.",
+ HttpStatus.NOT_FOUND.value());
} else {
data = services.get(0);
}
GenericResourceApiServicedataServiceData svcData;
try {
svcData = objectMapper.readValue(data.getSvcData(), GenericResourceApiServicedataServiceData.class);
- } catch(JsonProcessingException e) {
+ } catch (JsonProcessingException e) {
// Or throw the data not found error?
log.error("Could not map service data for ({})", serviceInstanceId);
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
- if(svcData == null) {
+ if (svcData == null) {
// Or throw the data not found error?
log.info("Could not find Service Data for ({}).", serviceInstanceId);
throw new RestProtocolException("data-missing", "Service data not found.", HttpStatus.NOT_FOUND.value());
}
GenericResourceApiServicedataServicedataVnfs vnfs = svcData.getVnfs();
- if(vnfs == null) {
+ if (vnfs == null) {
// Or throw the data not found error?
log.info("VNF List not found for ({}).", serviceInstanceId);
throw new RestProtocolException("data-missing", "VNFs not found.", HttpStatus.NOT_FOUND.value());
}
Stream<GenericResourceApiServicedataServicedataVnfsVnf> vnfStream = svcData.getVnfs().getVnf().stream();
- if(vnfStream.noneMatch(targetVnf -> targetVnf.getVnfId().equals(vnfId))) {
+ if (vnfStream.noneMatch(targetVnf -> targetVnf.getVnfId().equals(vnfId))) {
// 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());
}
// Recreate the stream per Sonar?
vnfStream = svcData.getVnfs().getVnf().stream();
- svcData.getVnfs().setVnf(vnfStream.filter(targetVnf -> !targetVnf.getVnfId().equals(vnfId)).collect(Collectors.toList()));
+ svcData.getVnfs().setVnf(
+ vnfStream.filter(targetVnf -> !targetVnf.getVnfId().equals(vnfId)).collect(Collectors.toList()));
// Map and save the new data
try {
data.setSvcData(objectMapper.writeValueAsString(svcData));
configServicesRepository.save(data);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
- } catch(JsonProcessingException e) {
+ } catch (JsonProcessingException e) {
log.error("Error mapping object to JSON", e);
// Should probably be a 500 INTERNAL_SERVICE_ERROR
- throw new RestProtocolException("internal-service-error", "Failed to save data.", HttpStatus.BAD_REQUEST.value());
+ throw new RestProtocolException("internal-service-error", "Failed to save data.",
+ HttpStatus.BAD_REQUEST.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}/
+ * 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
+ * @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 {
+ public ResponseEntity<GenericResourceApiServicedataServicedataVnfsVnf> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataVnfsVnfVnfIdGet(
+ String serviceInstanceId, String vnfId) throws RestException {
log.info("GET | VNF Data for ({})", vnfId);
- if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
- if(getAcceptHeader().get().contains("application/json")) {
+ if (getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
+ if (getAcceptHeader().get().contains("application/json")) {
}
} else {
- log.warn("ObjectMapper or HttpServletRequest not configured in default ConfigApi interface so no example is generated");
+ log.warn(
+ "ObjectMapper or HttpServletRequest not configured in default ConfigApi interface so no example is generated");
}
List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId);
- if((services == null) || (services.isEmpty())) {
+ if ((services == null) || (services.isEmpty())) {
throw new RestProtocolException("data-missing", "No service entry found", HttpStatus.NOT_FOUND.value());
}
Optional<GenericResourceApiServicedataServicedataVnfsVnf> vnf = getVnfObject(services.get(0), vnfId);
- if(vnf.isPresent()) {
+ if (vnf.isPresent()) {
return new ResponseEntity<>(vnf.get(), 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());
+ 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.
+ * 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
+ * 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.
+ * 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 genericResourceApiServicedataServicedataVnfsVnfBodyParam) throws RestException {
+ public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataVnfsVnfVnfIdPut(
+ String serviceInstanceId, String vnfId,
+ GenericResourceApiServicedataServicedataVnfsVnf genericResourceApiServicedataServicedataVnfsVnfBodyParam)
+ throws RestException {
log.info("PUT | VNF Data for ({})", vnfId);
- if(!vnfId.equals(genericResourceApiServicedataServicedataVnfsVnfBodyParam.getVnfId())) {
+ if (!vnfId.equals(genericResourceApiServicedataServicedataVnfsVnfBodyParam.getVnfId())) {
throw new RestProtocolException("bad-attribute", "vnf-id mismatch", HttpStatus.BAD_REQUEST.value());
}
- if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
+ if (getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
log.info("Something with header");
} else {
- log.warn("ObjectMapper or HttpServletRequest not configured in default ConfigApi interface so no example is generated");
+ log.warn(
+ "ObjectMapper or HttpServletRequest not configured in default ConfigApi interface so no example is generated");
}
List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId);
ConfigServices data;
- if((services == null) || (services.isEmpty())) {
+ if ((services == null) || (services.isEmpty())) {
log.info("Could not find data for ({}). Creating new Service Object.", serviceInstanceId);
data = new ConfigServices();
data.setSvcInstanceId(serviceInstanceId);
GenericResourceApiServicedataServiceData svcData = null;
try {
svcData = objectMapper.readValue(data.getSvcData(), GenericResourceApiServicedataServiceData.class);
- } catch(JsonProcessingException e) {
+ } catch (JsonProcessingException e) {
log.error("Could not map service data for ({})", serviceInstanceId);
}
- if(svcData == null) {
+ if (svcData == null) {
log.info("Could not find Service Data for ({}). Creating new Service Data Container", serviceInstanceId);
svcData = new GenericResourceApiServicedataServiceData();
}
- if(svcData.getVnfs() == null) {
+ if (svcData.getVnfs() == null) {
log.info("VNF List not found for ({}). Creating new VNF List Container.", serviceInstanceId);
svcData.setVnfs(new GenericResourceApiServicedataServicedataVnfs());
svcData.getVnfs().setVnf(new ArrayList<>());
GenericResourceApiServicedataServicedataVnfs vnflist = new GenericResourceApiServicedataServicedataVnfs();
HttpStatus responseStatus = HttpStatus.NO_CONTENT;
- if(svcData.getVnfs().getVnf().isEmpty()) {
+ if (svcData.getVnfs().getVnf().isEmpty()) {
log.info("Creating VNF data for ({})", vnfId);
vnflist.addVnfItem(genericResourceApiServicedataServicedataVnfsVnfBodyParam);
responseStatus = HttpStatus.CREATED;
log.info("Updating VNF data for ({})", vnfId);
// Filter out all of the other vnf objects into a new VNF List
// Replace if a delete method exists
- svcData.getVnfs()
- .getVnf()
- .stream()
- .filter(targetVnf -> !targetVnf.getVnfId().equals(vnfId))
+ svcData.getVnfs().getVnf().stream().filter(targetVnf -> !targetVnf.getVnfId().equals(vnfId))
.forEach(vnflist::addVnfItem);
vnflist.addVnfItem(genericResourceApiServicedataServicedataVnfsVnfBodyParam);
}
data.setSvcData(objectMapper.writeValueAsString(svcData));
configServicesRepository.save(data);
return new ResponseEntity<>(responseStatus);
- } catch(JsonProcessingException e) {
+ } 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 VNF Topology data from the Config table specified Service
- * Instance and VNF ID.
+ * 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/
+ * 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.
+ * @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 {
+ public ResponseEntity<GenericResourceApiVnftopologyVnfTopology> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataVnfsVnfVnfIdVnfDataVnfTopologyGet(
+ String serviceInstanceId, String vnfId) throws RestException {
log.info("GET | VNF Topology for ({})", vnfId);
- if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
+ if (getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
if (getAcceptHeader().get().contains("application/json")) {
}
} else {
- log.warn("ObjectMapper or HttpServletRequest not configured in default ConfigApi interface so no example is generated");
+ log.warn(
+ "ObjectMapper or HttpServletRequest not configured in default ConfigApi interface so no example is generated");
}
List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId);
- if((services == null) || (services.isEmpty())) {
+ if ((services == null) || (services.isEmpty())) {
throw new RestProtocolException("data-missing", "No service entry found", HttpStatus.NOT_FOUND.value());
}
Optional<GenericResourceApiServicedataServicedataVnfsVnf> vnf = getVnfObject(services.get(0), vnfId);
// Drill down to find the data
- if(vnf.isPresent()
- && vnf.get().getVnfData() != null
- && vnf.get().getVnfData().getVnfTopology() != null) {
+ if (vnf.isPresent() && vnf.get().getVnfData() != null && vnf.get().getVnfData().getVnfTopology() != null) {
return new ResponseEntity<>(vnf.get().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());
+ 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.
+ * 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
+ * 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>
* @throws RestException
*/
@Override
- public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataVnfsVnfVnfIdVnfDataVnfLevelOperStatusPut(String serviceInstanceId, String vnfId, GenericResourceApiOperStatusData genericResourceApiOperStatusDataBodyParam) throws RestException {
+ public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataVnfsVnfVnfIdVnfDataVnfLevelOperStatusPut(
+ String serviceInstanceId, String vnfId,
+ GenericResourceApiOperStatusData genericResourceApiOperStatusDataBodyParam) throws RestException {
log.info("PUT | VNF Level Oper Status ({})", vnfId);
- if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
+ if (getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
} else {
- log.warn("ObjectMapper or HttpServletRequest not configured in default ConfigApi interface so no example is generated");
+ log.warn(
+ "ObjectMapper or HttpServletRequest not configured in default ConfigApi interface so no example is generated");
}
List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId);
ConfigServices data;
- if((services == null) || (services.isEmpty())) {
+ if ((services == null) || (services.isEmpty())) {
log.info("Could not find data for ({}). Creating new Service Object.", serviceInstanceId);
data = new ConfigServices();
data.setSvcInstanceId(serviceInstanceId);
GenericResourceApiServicedataServiceData svcData = null;
try {
svcData = objectMapper.readValue(data.getSvcData(), GenericResourceApiServicedataServiceData.class);
- } catch(JsonProcessingException e) {
+ } catch (JsonProcessingException e) {
log.error("Could not map service data for ({})", serviceInstanceId);
}
- if(svcData == null) {
+ if (svcData == null) {
log.info("Could not find Service Data for ({}). Creating new Service Data Container", serviceInstanceId);
svcData = new GenericResourceApiServicedataServiceData();
}
- if(svcData.getVnfs() == null) {
+ if (svcData.getVnfs() == null) {
log.info("VNF List not found for ({}). Creating new VNF List Container.", serviceInstanceId);
svcData.setVnfs(new GenericResourceApiServicedataServicedataVnfs());
svcData.getVnfs().setVnf(new ArrayList<>());
GenericResourceApiServicedataServicedataVnfs vnflist = new GenericResourceApiServicedataServicedataVnfs();
HttpStatus responseStatus = HttpStatus.NO_CONTENT;
- if(svcData.getVnfs().getVnf().isEmpty()) {
+ if (svcData.getVnfs().getVnf().isEmpty()) {
log.info("Creating VNF data for ({})", vnfId);
GenericResourceApiServicedataServicedataVnfsVnf vnf = new GenericResourceApiServicedataServicedataVnfsVnf();
vnf.setVnfId(vnfId);
log.info("Updating VNF data for ({})", vnfId);
// Filter out all of the other vnf objects into a new VNF List
// Replace if a delete method exists
- svcData.getVnfs()
- .getVnf()
- .stream()
- .filter(targetVnf -> !targetVnf.getVnfId().equals(vnfId))
+ svcData.getVnfs().getVnf().stream().filter(targetVnf -> !targetVnf.getVnfId().equals(vnfId))
.forEach(vnflist::addVnfItem);
GenericResourceApiServicedataServicedataVnfsVnf vnf = new GenericResourceApiServicedataServicedataVnfsVnf();
// If the vnf exists, set it up with new data
Optional<GenericResourceApiServicedataServicedataVnfsVnf> vnfOptional = getVnfObject(data, vnfId);
- if(vnfOptional.isPresent()) {
+ if (vnfOptional.isPresent()) {
vnf = vnfOptional.get();
}
- if(vnf.getVnfData() == null) {
+ if (vnf.getVnfData() == null) {
vnf.setVnfData(new GenericResourceApiServicedataServicedataVnfsVnfVnfData());
responseStatus = HttpStatus.CREATED;
}
data.setSvcData(objectMapper.writeValueAsString(svcData));
configServicesRepository.save(data);
return new ResponseEntity<>(responseStatus);
- } catch(JsonProcessingException e) {
+ } 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 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.
+ * 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
+ * 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.
* @throws RestException
*/
@Override
- public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataVnfsVnfVnfIdVnfDataVnfTopologyOnapModelInformationPut(String serviceInstanceId, String vnfId, GenericResourceApiOnapmodelinformationOnapModelInformation genericResourceApiOnapmodelinformationOnapModelInformationBodyParam) throws RestException {
+ public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataVnfsVnfVnfIdVnfDataVnfTopologyOnapModelInformationPut(
+ String serviceInstanceId, String vnfId,
+ GenericResourceApiOnapmodelinformationOnapModelInformation genericResourceApiOnapmodelinformationOnapModelInformationBodyParam)
+ throws RestException {
log.info("PUT | VNF Topology Onap Model Information ({})", vnfId);
- if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
+ if (getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
} else {
- log.warn("ObjectMapper or HttpServletRequest not configured in default ConfigApi interface so no example is generated");
+ log.warn(
+ "ObjectMapper or HttpServletRequest not configured in default ConfigApi interface so no example is generated");
}
List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId);
ConfigServices data;
- if((services == null) || (services.isEmpty())) {
+ if ((services == null) || (services.isEmpty())) {
log.info("Could not find data for ({}). Creating new Service Object.", serviceInstanceId);
data = new ConfigServices();
data.setSvcInstanceId(serviceInstanceId);
GenericResourceApiServicedataServiceData svcData = null;
try {
svcData = objectMapper.readValue(data.getSvcData(), GenericResourceApiServicedataServiceData.class);
- } catch(JsonProcessingException e) {
+ } catch (JsonProcessingException e) {
log.error("Could not map service data for ({})", serviceInstanceId);
}
- if(svcData == null) {
+ if (svcData == null) {
log.info("Could not find Service Data for ({}). Creating new Service Data Container", serviceInstanceId);
svcData = new GenericResourceApiServicedataServiceData();
}
- if(svcData.getVnfs() == null) {
+ if (svcData.getVnfs() == null) {
log.info("VNF List not found for ({}). Creating new VNF List Container.", serviceInstanceId);
svcData.setVnfs(new GenericResourceApiServicedataServicedataVnfs());
svcData.getVnfs().setVnf(new ArrayList<>());
GenericResourceApiServicedataServicedataVnfs vnflist = new GenericResourceApiServicedataServicedataVnfs();
HttpStatus responseStatus = HttpStatus.NO_CONTENT;
- if(svcData.getVnfs().getVnf().isEmpty()) {
+ if (svcData.getVnfs().getVnf().isEmpty()) {
log.info("Creating VNF data for ({})", vnfId);
GenericResourceApiServicedataServicedataVnfsVnf vnf = new GenericResourceApiServicedataServicedataVnfsVnf();
vnf.setVnfId(vnfId);
vnf.setVnfData(new GenericResourceApiServicedataServicedataVnfsVnfVnfData());
vnf.getVnfData().setVnfTopology(new GenericResourceApiVnftopologyVnfTopology());
- vnf.getVnfData().getVnfTopology().setOnapModelInformation(genericResourceApiOnapmodelinformationOnapModelInformationBodyParam);
+ vnf.getVnfData().getVnfTopology()
+ .setOnapModelInformation(genericResourceApiOnapmodelinformationOnapModelInformationBodyParam);
vnflist.addVnfItem(vnf);
responseStatus = HttpStatus.CREATED;
} else {
log.info("Updating VNF data for ({})", vnfId);
// Filter out all of the other vnf objects into a new VNF List
// Replace if a delete method exists
- svcData.getVnfs()
- .getVnf()
- .stream()
- .filter(targetVnf -> !targetVnf.getVnfId().equals(vnfId))
+ svcData.getVnfs().getVnf().stream().filter(targetVnf -> !targetVnf.getVnfId().equals(vnfId))
.forEach(vnflist::addVnfItem);
GenericResourceApiServicedataServicedataVnfsVnf vnf = new GenericResourceApiServicedataServicedataVnfsVnf();
// If the vnf exists, set it up with new data
Optional<GenericResourceApiServicedataServicedataVnfsVnf> vnfOptional = getVnfObject(data, vnfId);
- if(vnfOptional.isPresent()) {
+ if (vnfOptional.isPresent()) {
vnf = vnfOptional.get();
}
- if(vnf.getVnfData() == null) {
+ if (vnf.getVnfData() == null) {
vnf.setVnfData(new GenericResourceApiServicedataServicedataVnfsVnfVnfData());
}
- if(vnf.getVnfData().getVnfTopology() == null) {
+ if (vnf.getVnfData().getVnfTopology() == null) {
vnf.getVnfData().setVnfTopology(new GenericResourceApiVnftopologyVnfTopology());
responseStatus = HttpStatus.CREATED;
}
- vnf.getVnfData().getVnfTopology().setOnapModelInformation(genericResourceApiOnapmodelinformationOnapModelInformationBodyParam);
+ vnf.getVnfData().getVnfTopology()
+ .setOnapModelInformation(genericResourceApiOnapmodelinformationOnapModelInformationBodyParam);
vnflist.addVnfItem(vnf);
}
data.setSvcData(objectMapper.writeValueAsString(svcData));
configServicesRepository.save(data);
return new ResponseEntity<>(responseStatus);
- } catch(JsonProcessingException e) {
+ } 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.
+ * 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
+ * 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.
* @throws RestException
*/
@Override
- public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataVnfsVnfVnfIdVnfDataVnfTopologyVnfResourceAssignmentsVnfNetworksPut(String serviceInstanceId, String vnfId, GenericResourceApiVnfresourceassignmentsVnfresourceassignmentsVnfNetworks genericResourceApiVnfresourceassignmentsVnfresourceassignmentsVnfNetworksBodyParam) throws RestException {
+ public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataVnfsVnfVnfIdVnfDataVnfTopologyVnfResourceAssignmentsVnfNetworksPut(
+ String serviceInstanceId, String vnfId,
+ GenericResourceApiVnfresourceassignmentsVnfresourceassignmentsVnfNetworks genericResourceApiVnfresourceassignmentsVnfresourceassignmentsVnfNetworksBodyParam)
+ throws RestException {
log.info("PUT | VNF Topology VNF Resource Assignments VNF Networks ({})", vnfId);
- if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
+ if (getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
} else {
- log.warn("ObjectMapper or HttpServletRequest not configured in default ConfigApi interface so no example is generated");
+ log.warn(
+ "ObjectMapper or HttpServletRequest not configured in default ConfigApi interface so no example is generated");
}
List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId);
ConfigServices data;
- if((services == null) || (services.isEmpty())) {
+ if ((services == null) || (services.isEmpty())) {
log.info("Could not find data for ({}). Creating new Service Object.", serviceInstanceId);
data = new ConfigServices();
data.setSvcInstanceId(serviceInstanceId);
GenericResourceApiServicedataServiceData svcData = null;
try {
svcData = objectMapper.readValue(data.getSvcData(), GenericResourceApiServicedataServiceData.class);
- } catch(JsonProcessingException e) {
+ } catch (JsonProcessingException e) {
log.error("Could not map service data for ({})", serviceInstanceId);
}
- if(svcData == null) {
+ if (svcData == null) {
log.info("Could not find Service Data for ({}). Creating new Service Data Container", serviceInstanceId);
svcData = new GenericResourceApiServicedataServiceData();
}
- if(svcData.getVnfs() == null) {
+ if (svcData.getVnfs() == null) {
log.info("VNF List not found for ({}). Creating new VNF List Container.", serviceInstanceId);
svcData.setVnfs(new GenericResourceApiServicedataServicedataVnfs());
svcData.getVnfs().setVnf(new ArrayList<>());
GenericResourceApiServicedataServicedataVnfs vnflist = new GenericResourceApiServicedataServicedataVnfs();
HttpStatus responseStatus = HttpStatus.NO_CONTENT;
- if(svcData.getVnfs().getVnf().isEmpty()) {
+ if (svcData.getVnfs().getVnf().isEmpty()) {
log.info("Creating VNF data for ({})", vnfId);
GenericResourceApiServicedataServicedataVnfsVnf vnf = new GenericResourceApiServicedataServicedataVnfsVnf();
vnf.setVnfId(vnfId);
vnf.setVnfData(new GenericResourceApiServicedataServicedataVnfsVnfVnfData());
vnf.getVnfData().setVnfTopology(new GenericResourceApiVnftopologyVnfTopology());
- vnf.getVnfData().getVnfTopology().setVnfResourceAssignments(new GenericResourceApiVnfresourceassignmentsVnfResourceAssignments());
- vnf.getVnfData().getVnfTopology().getVnfResourceAssignments().setVnfNetworks(genericResourceApiVnfresourceassignmentsVnfresourceassignmentsVnfNetworksBodyParam);
+ vnf.getVnfData().getVnfTopology()
+ .setVnfResourceAssignments(new GenericResourceApiVnfresourceassignmentsVnfResourceAssignments());
+ vnf.getVnfData().getVnfTopology().getVnfResourceAssignments()
+ .setVnfNetworks(genericResourceApiVnfresourceassignmentsVnfresourceassignmentsVnfNetworksBodyParam);
vnflist.addVnfItem(vnf);
responseStatus = HttpStatus.CREATED;
} else {
log.info("Updating VNF data for ({})", vnfId);
// Filter out all of the other vnf objects into a new VNF List
// Replace if a delete method exists
- svcData.getVnfs()
- .getVnf()
- .stream()
- .filter(targetVnf -> !targetVnf.getVnfId().equals(vnfId))
+ svcData.getVnfs().getVnf().stream().filter(targetVnf -> !targetVnf.getVnfId().equals(vnfId))
.forEach(vnflist::addVnfItem);
GenericResourceApiServicedataServicedataVnfsVnf vnf = new GenericResourceApiServicedataServicedataVnfsVnf();
// If the vnf exists, set it up with new data
Optional<GenericResourceApiServicedataServicedataVnfsVnf> vnfOptional = getVnfObject(data, vnfId);
- if(vnfOptional.isPresent()) {
+ if (vnfOptional.isPresent()) {
vnf = vnfOptional.get();
}
- if(vnf.getVnfData() == null) {
+ if (vnf.getVnfData() == null) {
vnf.setVnfData(new GenericResourceApiServicedataServicedataVnfsVnfVnfData());
}
- if(vnf.getVnfData().getVnfTopology() == null) {
+ if (vnf.getVnfData().getVnfTopology() == null) {
vnf.getVnfData().setVnfTopology(new GenericResourceApiVnftopologyVnfTopology());
}
- if(vnf.getVnfData().getVnfTopology().getVnfResourceAssignments() == null) {
- vnf.getVnfData().getVnfTopology().setVnfResourceAssignments(new GenericResourceApiVnfresourceassignmentsVnfResourceAssignments());
+ if (vnf.getVnfData().getVnfTopology().getVnfResourceAssignments() == null) {
+ vnf.getVnfData().getVnfTopology().setVnfResourceAssignments(
+ new GenericResourceApiVnfresourceassignmentsVnfResourceAssignments());
responseStatus = HttpStatus.CREATED;
}
- vnf.getVnfData().getVnfTopology().getVnfResourceAssignments().setVnfNetworks(genericResourceApiVnfresourceassignmentsVnfresourceassignmentsVnfNetworksBodyParam);
+ vnf.getVnfData().getVnfTopology().getVnfResourceAssignments()
+ .setVnfNetworks(genericResourceApiVnfresourceassignmentsVnfresourceassignmentsVnfNetworksBodyParam);
vnflist.addVnfItem(vnf);
}
data.setSvcData(objectMapper.writeValueAsString(svcData));
configServicesRepository.save(data);
return new ResponseEntity<>(responseStatus);
- } catch(JsonProcessingException e) {
+ } 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.
+ * 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
+ * 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>
* @throws RestException
*/
@Override
- public ResponseEntity<Void> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataVnfsVnfVnfIdVnfDataVnfTopologyVnfResourceAssignmentsVnfNetworksVnfNetworkNetworkRolePut(String serviceInstanceId, String vnfId, String networkRole, GenericResourceApiVnfNetworkData genericResourceApiVnfNetworkDataBodyParam) throws RestException {
+ 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())) {
+ if (!networkRole.equals(genericResourceApiVnfNetworkDataBodyParam.getNetworkRole())) {
throw new RestProtocolException("bad-attribute", "network-role mismatch", HttpStatus.BAD_REQUEST.value());
}
- if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
+ if (getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
} else {
- log.warn("ObjectMapper or HttpServletRequest not configured in default ConfigApi interface so no example is generated");
+ log.warn(
+ "ObjectMapper or HttpServletRequest not configured in default ConfigApi interface so no example is generated");
}
List<ConfigServices> services = configServicesRepository.findBySvcInstanceId(serviceInstanceId);
ConfigServices data;
- if((services == null) || (services.isEmpty())) {
+ if ((services == null) || (services.isEmpty())) {
log.info("Could not find data for ({}). Creating new Service Object.", serviceInstanceId);
data = new ConfigServices();
data.setSvcInstanceId(serviceInstanceId);
GenericResourceApiServicedataServiceData svcData = null;
try {
svcData = objectMapper.readValue(data.getSvcData(), GenericResourceApiServicedataServiceData.class);
- } catch(JsonProcessingException e) {
+ } catch (JsonProcessingException e) {
log.error("Could not map service data for ({})", serviceInstanceId);
}
- if(svcData == null) {
+ if (svcData == null) {
log.info("Could not find Service Data for ({}). Creating new Service Data Container", serviceInstanceId);
svcData = new GenericResourceApiServicedataServiceData();
}
- if(svcData.getVnfs() == null) {
+ if (svcData.getVnfs() == null) {
log.info("VNF List not found for ({}). Creating new VNF List Container.", serviceInstanceId);
svcData.setVnfs(new GenericResourceApiServicedataServicedataVnfs());
svcData.getVnfs().setVnf(new ArrayList<>());
GenericResourceApiServicedataServicedataVnfs vnflist = new GenericResourceApiServicedataServicedataVnfs();
HttpStatus responseStatus = HttpStatus.NO_CONTENT;
- if(svcData.getVnfs().getVnf().isEmpty()) {
+ if (svcData.getVnfs().getVnf().isEmpty()) {
log.info("Creating VNF data for ({})", vnfId);
GenericResourceApiServicedataServicedataVnfsVnf vnf = new GenericResourceApiServicedataServicedataVnfsVnf();
vnf.setVnfId(vnfId);
vnf.setVnfData(new GenericResourceApiServicedataServicedataVnfsVnfVnfData());
vnf.getVnfData().setVnfTopology(new GenericResourceApiVnftopologyVnfTopology());
- vnf.getVnfData().getVnfTopology().setVnfResourceAssignments(new GenericResourceApiVnfresourceassignmentsVnfResourceAssignments());
- vnf.getVnfData().getVnfTopology().getVnfResourceAssignments().setVnfNetworks(new GenericResourceApiVnfresourceassignmentsVnfresourceassignmentsVnfNetworks());
- vnf.getVnfData().getVnfTopology().getVnfResourceAssignments().getVnfNetworks().setVnfNetwork(new ArrayList<>());
- vnf.getVnfData().getVnfTopology().getVnfResourceAssignments().getVnfNetworks().addVnfNetworkItem(genericResourceApiVnfNetworkDataBodyParam);
+ vnf.getVnfData().getVnfTopology()
+ .setVnfResourceAssignments(new GenericResourceApiVnfresourceassignmentsVnfResourceAssignments());
+ vnf.getVnfData().getVnfTopology().getVnfResourceAssignments()
+ .setVnfNetworks(new GenericResourceApiVnfresourceassignmentsVnfresourceassignmentsVnfNetworks());
+ vnf.getVnfData().getVnfTopology().getVnfResourceAssignments().getVnfNetworks()
+ .setVnfNetwork(new ArrayList<>());
+ vnf.getVnfData().getVnfTopology().getVnfResourceAssignments().getVnfNetworks()
+ .addVnfNetworkItem(genericResourceApiVnfNetworkDataBodyParam);
vnflist.addVnfItem(vnf);
responseStatus = HttpStatus.CREATED;
} else {
log.info("Updating VNF data for ({})", vnfId);
// Filter out all of the other vnf objects into a new VNF List
// Replace if a delete method exists
- svcData.getVnfs()
- .getVnf()
- .stream()
- .filter(targetVnf -> !targetVnf.getVnfId().equals(vnfId))
+ svcData.getVnfs().getVnf().stream().filter(targetVnf -> !targetVnf.getVnfId().equals(vnfId))
.forEach(vnflist::addVnfItem);
GenericResourceApiServicedataServicedataVnfsVnf vnf = new GenericResourceApiServicedataServicedataVnfsVnf();
// If the vnf exists, set it up with new data
Optional<GenericResourceApiServicedataServicedataVnfsVnf> vnfOptional = getVnfObject(data, vnfId);
- if(vnfOptional.isPresent()) {
+ if (vnfOptional.isPresent()) {
vnf = vnfOptional.get();
}
- if(vnf.getVnfData() == null) {
+ if (vnf.getVnfData() == null) {
vnf.setVnfData(new GenericResourceApiServicedataServicedataVnfsVnfVnfData());
}
- if(vnf.getVnfData().getVnfTopology() == null) {
+ if (vnf.getVnfData().getVnfTopology() == null) {
vnf.getVnfData().setVnfTopology(new GenericResourceApiVnftopologyVnfTopology());
}
- if(vnf.getVnfData().getVnfTopology().getVnfResourceAssignments() == null) {
- vnf.getVnfData().getVnfTopology().setVnfResourceAssignments(new GenericResourceApiVnfresourceassignmentsVnfResourceAssignments());
+ if (vnf.getVnfData().getVnfTopology().getVnfResourceAssignments() == null) {
+ vnf.getVnfData().getVnfTopology().setVnfResourceAssignments(
+ new GenericResourceApiVnfresourceassignmentsVnfResourceAssignments());
}
- if(vnf.getVnfData().getVnfTopology().getVnfResourceAssignments().getVnfNetworks() == null) {
+ if (vnf.getVnfData().getVnfTopology().getVnfResourceAssignments().getVnfNetworks() == null) {
log.info("Creating new VnfNetworks");
- vnf.getVnfData().getVnfTopology().getVnfResourceAssignments().setVnfNetworks(new GenericResourceApiVnfresourceassignmentsVnfresourceassignmentsVnfNetworks());
+ vnf.getVnfData().getVnfTopology().getVnfResourceAssignments().setVnfNetworks(
+ new GenericResourceApiVnfresourceassignmentsVnfresourceassignmentsVnfNetworks());
}
GenericResourceApiVnfresourceassignmentsVnfresourceassignmentsVnfNetworks networkList = new GenericResourceApiVnfresourceassignmentsVnfresourceassignmentsVnfNetworks();
- if(vnf.getVnfData().getVnfTopology().getVnfResourceAssignments().getVnfNetworks().getVnfNetwork().isEmpty()) {
+ if (vnf.getVnfData().getVnfTopology().getVnfResourceAssignments().getVnfNetworks().getVnfNetwork()
+ .isEmpty()) {
log.info("First entry into network info.");
- vnf.getVnfData().getVnfTopology().getVnfResourceAssignments().getVnfNetworks().addVnfNetworkItem(genericResourceApiVnfNetworkDataBodyParam);
+ vnf.getVnfData().getVnfTopology().getVnfResourceAssignments().getVnfNetworks()
+ .addVnfNetworkItem(genericResourceApiVnfNetworkDataBodyParam);
responseStatus = HttpStatus.CREATED;
} else {
log.info("Found networks. Filtering.");
.forEach(networkList::addVnfNetworkItem);
networkList.addVnfNetworkItem(genericResourceApiVnfNetworkDataBodyParam);
- if(networkList.getVnfNetwork().size() != vnf.getVnfData().getVnfTopology().getVnfResourceAssignments().getVnfNetworks().getVnfNetwork().size()) {
+ if (networkList.getVnfNetwork().size() != vnf.getVnfData().getVnfTopology().getVnfResourceAssignments()
+ .getVnfNetworks().getVnfNetwork().size()) {
log.info("Added a new Item");
responseStatus = HttpStatus.CREATED;
}
data.setSvcData(objectMapper.writeValueAsString(svcData));
configServicesRepository.save(data);
return new ResponseEntity<>(responseStatus);
- } catch(JsonProcessingException e) {
+ } 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 a VNF object from the database,
+ *
* @param configServices A Config Services option created from a Service
* Instance ID
- * @param vnfId the target VNF ID
+ * @param vnfId the target VNF ID
* @return An empty Optional if the Service Data does not exist, an empty
- * Optional if the VNF is not found, or an optional containing the
- * found VNF.
+ * Optional if the VNF is not found, or an optional containing the found
+ * VNF.
*/
- private Optional<GenericResourceApiServicedataServicedataVnfsVnf> getVnfObject(ConfigServices configServices, String vnfId) {
+ private Optional<GenericResourceApiServicedataServicedataVnfsVnf> getVnfObject(ConfigServices configServices,
+ String vnfId) {
// Map the Marshall the JSON String into a Java Object
log.info("Getting VNF Data for ({})", vnfId);
GenericResourceApiServicedataServiceData svcData;
try {
- svcData = objectMapper.readValue(configServices.getSvcData(), GenericResourceApiServicedataServiceData.class);
- } catch(JsonProcessingException e) {
+ svcData = objectMapper.readValue(configServices.getSvcData(),
+ GenericResourceApiServicedataServiceData.class);
+ } catch (JsonProcessingException e) {
log.error("Error", e);
return Optional.empty();
}
- /*Get a stream of the VNF Objects and return the target if it's found,
- * assuming that each VNF ID is unique within a Service Instance Object
+ /*
+ * Get a stream of the VNF Objects and return the target if it's found, assuming
+ * that each VNF ID is unique within a Service Instance Object
*/
- return svcData.getVnfs().getVnf()
- .stream()
- .filter(targetVnf -> targetVnf.getVnfId().equals(vnfId))
- .findFirst();
+ return svcData.getVnfs().getVnf().stream().filter(targetVnf -> targetVnf.getVnfId().equals(vnfId)).findFirst();
}
@Override
- public ResponseEntity<GenericResourceApiServicetopologyServiceTopology> configGENERICRESOURCEAPIservicesServiceServiceInstanceIdServiceDataServiceTopologyGet(String serviceInstanceId) throws RestApplicationException, RestProtocolException {
+ 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());
}
try {
- if ( services.get(0).getSvcData().isEmpty()) {
- throw new RestProtocolException("data-missing", "No service-data entry found", HttpStatus.NOT_FOUND.value());
+ if (services.get(0).getSvcData().isEmpty()) {
+ throw new RestProtocolException("data-missing", "No service-data entry found",
+ HttpStatus.NOT_FOUND.value());
} else {
- serviceData = objectMapper.readValue(services.get(0).getSvcData(), GenericResourceApiServicedataServiceData.class);
+ serviceData = objectMapper.readValue(services.get(0).getSvcData(),
+ GenericResourceApiServicedataServiceData.class);
serviceTopology = serviceData.getServiceTopology();
}
if (serviceTopology == null) {
- throw new RestProtocolException("data-missing", "No service-topology entry found", HttpStatus.NOT_FOUND.value());
+ 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());
+ throw new RestApplicationException("data-conversion",
+ "Request could not be completed due to internal error", e,
+ HttpStatus.INTERNAL_SERVER_ERROR.value());
}
}
+
}
--- /dev/null
+### preload data (network)\r
+POST {{hostname}}/restconf/operations/GENERIC-RESOURCE-API:preload-network-topology-operation/\r
+Authorization: Basic {{token}}\r
+Content-Type: application/json\r
+Accept: application/json\r
+\r
+{\r
+ "input": {\r
+ "preload-network-topology-information": {\r
+ "host-routes": [\r
+ {\r
+ "next-hop": "10.1.12.1",\r
+ "route-prefix": "12"\r
+ }\r
+ ],\r
+ "is-external-network": true,\r
+ "is-provider-network": true,\r
+ "is-shared-network": true,\r
+ "network-policy": [\r
+ {\r
+ "network-policy-fqdn": "policy-sdnc.onap.org",\r
+ "network-policy-id": "123"\r
+ }\r
+ ],\r
+ "network-topology-identifier-structure": {\r
+ "eipam-v4-address-plan": "plan9",\r
+ "eipam-v6-address-plan": "plan9v6",\r
+ "is-trunked": true,\r
+ "network-id": "vUSP-23804-T-01-wnv1a_int_csdb_net_1",\r
+ "network-instance-group-id": "abc123",\r
+ "network-name": "syfy",\r
+ "network-role": "secret",\r
+ "network-technology": "soupcan",\r
+ "network-type": "fake",\r
+ "related-networks": {\r
+ "related-network": [\r
+ {\r
+ "network-id": "skynet",\r
+ "network-role": "master",\r
+ "vlan-tags": {\r
+ "is-private": true,\r
+ "lower-tag-id": 0,\r
+ "upper-tag-id": 0,\r
+ "vlan-interface": "le0"\r
+ }\r
+ }\r
+ ]\r
+ },\r
+ "segmentation-id": "seg1"\r
+ },\r
+ "physical-network-name": "skynet",\r
+ "route-table-reference": [\r
+ {\r
+ "route-table-reference-fqdn": "sky.net",\r
+ "route-table-reference-id": "ref1"\r
+ }\r
+ ],\r
+ "subnets": [\r
+ {\r
+ "addr-from-start": "Y",\r
+ "cidr-mask": "255.255.0.0",\r
+ "dhcp-enabled": "Y",\r
+ "dhcp-end-address": "10.1.2.254",\r
+ "dhcp-start-address": "10.1.2.1",\r
+ "gateway-address": "10.1.2.255",\r
+ "ip-version": "ipv4",\r
+ "start-address": "10.1.2.1",\r
+ "subnet-name": "subnet1",\r
+ "subnet-role": "puppies",\r
+ "subnet-sequence": 0\r
+ }\r
+ ],\r
+ "vpn-bindings": [\r
+ {\r
+ "aic-zone": "zone1",\r
+ "global-route-target": "string",\r
+ "route-target-role": "string",\r
+ "vpn-binding-id": "string",\r
+ "vpn-name": "string"\r
+ }\r
+ ]\r
+ },\r
+ "request-information": {\r
+ "notification-url": "http://dev.null.com",\r
+ "order-number": "123456",\r
+ "order-version": "2010.06",\r
+ "request-action": "CreateNetworkInstance",\r
+ "request-id": "REQ123456",\r
+ "source": "curl"\r
+ },\r
+ "sdnc-request-header": {\r
+ "svc-action": "reserve",\r
+ "svc-notification-url": "http://dev.null.com",\r
+ "svc-request-id": "SVCREQ123456"\r
+ }\r
+ }\r
+}\r
+\r
+### service-topology (assign)\r
+POST {{hostname}}/restconf/operations/GENERIC-RESOURCE-API:service-topology-operation/\r
+Authorization: Basic {{token}}\r
+Content-Type: application/json\r
+Accept: application/json\r
+\r
+{\r
+ "input": {\r
+ "request-information": {\r
+ "notification-url": "http://dev.null",\r
+ "order-number": "123",\r
+ "order-version": "version1",\r
+ "request-action": "CreateServiceInstance",\r
+ "request-id": "{{$guid}}",\r
+ "source": "simulator"\r
+ },\r
+ "sdnc-request-header": {\r
+ "svc-action": "assign",\r
+ "svc-notification-url": "http://dev.null",\r
+ "svc-request-id": "svc-{{$guid}}"\r
+ },\r
+ "service-information": {\r
+ "global-customer-id": "{{$guid}}",\r
+ "onap-model-information": {\r
+ "model-customization-uuid": "12341234",\r
+ "model-invariant-uuid": "12341234",\r
+ "model-name": "vBNG_0202",\r
+ "model-uuid": "00e50cbd-ef0f-4b28-821e-f2b583752dd3",\r
+ "model-version": "1920"\r
+ },\r
+ "service-id": "5c4f2d89-57a3-47e9-b49b-d3c63eb0b3ca",\r
+ "service-instance-id": "5c4f2d89-57a3-47e9-b49b-d3c63eb0b3ca",\r
+ "subscriber-name": "test",\r
+ "subscription-service-type": "test"\r
+ },\r
+ "service-request-input": {\r
+ "service-instance-name": "zrdm61asmsf01_svc"\r
+ }\r
+ }\r
+ }\r
+\r
+\r
+### service-topology (changeassign)\r
+POST {{hostname}}/restconf/operations/GENERIC-RESOURCE-API:service-topology-operation/\r
+Authorization: Basic {{token}}\r
+Content-Type: application/json\r
+Accept: application/json\r
+\r
+{\r
+ "input": {\r
+ "request-information": {\r
+ "notification-url": "http://dev.null",\r
+ "order-number": "123",\r
+ "order-version": "version1",\r
+ "request-action": "CreateServiceInstance",\r
+ "request-id": "{{$guid}}",\r
+ "source": "simulator"\r
+ },\r
+ "sdnc-request-header": {\r
+ "svc-action": "changeassign",\r
+ "svc-notification-url": "http://dev.null",\r
+ "svc-request-id": "svc-{{$guid}}"\r
+ },\r
+ "service-information": {\r
+ "global-customer-id": "{{$guid}}",\r
+ "onap-model-information": {\r
+ "model-customization-uuid": "12341234",\r
+ "model-invariant-uuid": "12341234",\r
+ "model-name": "vcpesvc_vbng_0412a",\r
+ "model-uuid": "12eb33fa-b221-4d87-939c-d808b5799a7c",\r
+ "model-version": "1933"\r
+ }, \r
+ "service-id": "5c4f2d89-57a3-47e9-b49b-d3c63eb0b3ca",\r
+ "service-instance-id": "5c4f2d89-57a3-47e9-b49b-d3c63eb0b3ca",\r
+ "subscriber-name": "test",\r
+ "subscription-service-type": "test"\r
+ },\r
+ "service-request-input": {\r
+ "service-instance-name": "zrdm61asmsf01_svc"\r
+ }\r
+ }\r
+ }\r
+\r
+### service-topology (deactivate)\r
+POST {{hostname}}/restconf/operations/GENERIC-RESOURCE-API:service-topology-operation/\r
+Authorization: Basic {{token}}\r
+Content-Type: application/json\r
+Accept: application/json\r
+\r
+{\r
+ "input": {\r
+ "request-information": {\r
+ "notification-url": "http://dev.null",\r
+ "order-number": "123",\r
+ "order-version": "version1",\r
+ "request-action": "DeleteServiceInstance",\r
+ "request-id": "{{$guid}}",\r
+ "source": "simulator"\r
+ },\r
+ "sdnc-request-header": {\r
+ "svc-action": "deactivate",\r
+ "svc-notification-url": "http://dev.null",\r
+ "svc-request-id": "svc-{{$guid}}"\r
+ },\r
+ "service-information": {\r
+ "global-customer-id": "{{$guid}}",\r
+ "onap-model-information": {\r
+ "model-customization-uuid": "12341234",\r
+ "model-invariant-uuid": "12341234",\r
+ "model-name": "vcpesvc_vbng_0412a",\r
+ "model-uuid": "12eb33fa-b221-4d87-939c-d808b5799a7c",\r
+ "model-version": "1933"\r
+ }, \r
+ "service-id": "5c4f2d89-57a3-47e9-b49b-d3c63eb0b3ca",\r
+ "service-instance-id": "5c4f2d89-57a3-47e9-b49b-d3c63eb0b3ca",\r
+ "subscriber-name": "test",\r
+ "subscription-service-type": "test"\r
+ },\r
+ "service-request-input": {\r
+ "service-instance-name": "zrdm61asmsf01_svc"\r
+ }\r
+ }\r
+ }\r
+\r
+### service-topology (delete)\r
+POST {{hostname}}/restconf/operations/GENERIC-RESOURCE-API:service-topology-operation/\r
+Authorization: Basic {{token}}\r
+Content-Type: application/json\r
+Accept: application/json\r
+\r
+{\r
+ "input": {\r
+ "request-information": {\r
+ "notification-url": "http://dev.null",\r
+ "order-number": "123",\r
+ "order-version": "version1",\r
+ "request-action": "DeleteServiceInstance",\r
+ "request-id": "{{$guid}}",\r
+ "source": "simulator"\r
+ },\r
+ "sdnc-request-header": {\r
+ "svc-action": "delete",\r
+ "svc-notification-url": "http://dev.null",\r
+ "svc-request-id": "svc-{{$guid}}"\r
+ },\r
+ "service-information": {\r
+ "global-customer-id": "{{$guid}}",\r
+ "onap-model-information": {\r
+ "model-customization-uuid": "12341234",\r
+ "model-invariant-uuid": "12341234",\r
+ "model-name": "vcpesvc_vbng_0412a",\r
+ "model-uuid": "12eb33fa-b221-4d87-939c-d808b5799a7c",\r
+ "model-version": "1933"\r
+ }, \r
+ "service-id": "5c4f2d89-57a3-47e9-b49b-d3c63eb0b3ca",\r
+ "service-instance-id": "5c4f2d89-57a3-47e9-b49b-d3c63eb0b3ca",\r
+ "subscriber-name": "test",\r
+ "subscription-service-type": "test"\r
+ },\r
+ "service-request-input": {\r
+ "service-instance-name": "zrdm61asmsf01_svc"\r
+ }\r
+ }\r
+ }\r
+\r
+\r
+### network-topology (assign)\r
+POST {{hostname}}/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation/\r
+Authorization: Basic {{token}}\r
+Content-Type: application/json\r
+Accept: application/json\r
+\r
+{\r
+ "input": {\r
+ "network-information": {\r
+ "onap-model-information": {\r
+ "model-name": "VcpesvcVbng0412a.bng_mux",\r
+ "model-version": "1.0",\r
+ "model-customization-uuid": "b0cf3385-a390-488c-b6a0-d879fb4a4825",\r
+ "model-uuid": "9b7c1cbe-ddcd-458c-8792-d76391419b72",\r
+ "model-invariant-uuid": "206d5e6c-4cba-4c14-b942-5d946c881869"\r
+ },\r
+ "network-id": "2e723205-7f96-49a9-bd60-24168fbd9f07"\r
+ },\r
+ "network-request-input": {\r
+ "aic-cloud-region": "wnv1a",\r
+ "cloud-owner": "att-nc",\r
+ "tenant": "1795554216e946af8a3c788f195eb813",\r
+ "network-name": "vUSP-23804-T-01-wnv1a_int_csdb_net_1"\r
+ },\r
+ "request-information": {\r
+ "request-action": "CreateNetworkInstance",\r
+ "source": "simulator",\r
+ "request-id": "{{$guid}}"\r
+ },\r
+ "sdnc-request-header": {\r
+ "svc-request-id": "svc-{{$guid}}",\r
+ "svc-action": "assign"\r
+ },\r
+ "service-information": {\r
+ "onap-model-information": {\r
+ "model-name": "vcpesvc_vbng_0412a",\r
+ "model-version": "3.0",\r
+ "model-uuid": "12eb33fa-b221-4d87-939c-d808b5799a7c",\r
+ "model-invariant-uuid": "ead151e2-e18a-44fc-b6ac-3ae3d819dcd6"\r
+ },\r
+ "subscription-service-type": "VIRTUAL USP",\r
+ "service-id": "svc-{{$guid}}",\r
+ "global-customer-id": "{{$guid}}",\r
+ "service-instance-id": "5c4f2d89-57a3-47e9-b49b-d3c63eb0b3ca"\r
+ }\r
+ }\r
+}\r
+\r
+\r
+### network-topology (activate)\r
+POST {{hostname}}/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation/\r
+Authorization: Basic {{token}}\r
+Content-Type: application/json\r
+Accept: application/json\r
+\r
+{\r
+ "input": {\r
+ "network-information": {\r
+ "onap-model-information": {\r
+ "model-name": "VcpesvcVbng0412a.bng_mux",\r
+ "model-version": "1.0",\r
+ "model-customization-uuid": "b0cf3385-a390-488c-b6a0-d879fb4a4825",\r
+ "model-uuid": "9b7c1cbe-ddcd-458c-8792-d76391419b72",\r
+ "model-invariant-uuid": "206d5e6c-4cba-4c14-b942-5d946c881869"\r
+ },\r
+ "network-technology": "",\r
+ "network-id": "2e723205-7f96-49a9-bd60-24168fbd9f07",\r
+ "network-type": ""\r
+ },\r
+ "network-request-input": {\r
+ "aic-cloud-region": "wnv1a",\r
+ "cloud-owner": "att-nc",\r
+ "tenant": "1795554216e946af8a3c788f195eb813",\r
+ "network-name": "vUSP-23804-T-01-wnv1a_int_ccfx_net_1"\r
+ },\r
+ "request-information": {\r
+ "request-action": "CreateNetworkInstance",\r
+ "source": "simulator",\r
+ "request-id": "{{$guid}}"\r
+ },\r
+ "sdnc-request-header": {\r
+ "svc-request-id": "svc-{{$guid}}",\r
+ "svc-action": "activate"\r
+ },\r
+ "service-information": {\r
+ "onap-model-information": {\r
+ "model-name": "vcpesvc_vbng_0412a",\r
+ "model-version": "3.0",\r
+ "model-uuid": "12eb33fa-b221-4d87-939c-d808b5799a7c",\r
+ "model-invariant-uuid": "ead151e2-e18a-44fc-b6ac-3ae3d819dcd6"\r
+ },\r
+ "subscription-service-type": "VIRTUAL USP",\r
+ "service-id": "svc-{{$guid}}",\r
+ "global-customer-id": "{{$guid}}",\r
+ "service-instance-id": "5c4f2d89-57a3-47e9-b49b-d3c63eb0b3ca"\r
+ }\r
+ }\r
+}\r
+\r
+### network-topology (deactivate)\r
+POST {{hostname}}/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation/\r
+Authorization: Basic {{token}}\r
+Content-Type: application/json\r
+Accept: application/json\r
+\r
+{\r
+ "input": {\r
+ "network-information": {\r
+ "onap-model-information": {\r
+ "model-name": "VcpesvcVbng0412a.bng_mux",\r
+ "model-version": "1.0",\r
+ "model-customization-uuid": "b0cf3385-a390-488c-b6a0-d879fb4a4825",\r
+ "model-uuid": "9b7c1cbe-ddcd-458c-8792-d76391419b72",\r
+ "model-invariant-uuid": "206d5e6c-4cba-4c14-b942-5d946c881869"\r
+ },\r
+ "network-technology": "",\r
+ "network-id": "2e723205-7f96-49a9-bd60-24168fbd9f07",\r
+ "network-type": ""\r
+ },\r
+ "network-request-input": {\r
+ "aic-cloud-region": "wnv1a",\r
+ "cloud-owner": "att-nc",\r
+ "tenant": "1795554216e946af8a3c788f195eb813",\r
+ "network-name": "vUSP-23804-T-01-wnv1a_int_ccfx_net_1"\r
+ },\r
+ "request-information": {\r
+ "request-action": "DeleteNetworkInstance",\r
+ "source": "simulator",\r
+ "request-id": "{{$guid}}"\r
+ },\r
+ "sdnc-request-header": {\r
+ "svc-request-id": "svc-{{$guid}}",\r
+ "svc-action": "deactivate"\r
+ },\r
+ "service-information": {\r
+ "onap-model-information": {\r
+ "model-name": "vcpesvc_vbng_0412a",\r
+ "model-version": "3.0",\r
+ "model-uuid": "12eb33fa-b221-4d87-939c-d808b5799a7c",\r
+ "model-invariant-uuid": "ead151e2-e18a-44fc-b6ac-3ae3d819dcd6"\r
+ },\r
+ "subscription-service-type": "VIRTUAL USP",\r
+ "service-id": "svc-{{$guid}}",\r
+ "global-customer-id": "{{$guid}}",\r
+ "service-instance-id": "5c4f2d89-57a3-47e9-b49b-d3c63eb0b3ca"\r
+ }\r
+ }\r
+}\r
+\r
+### network-topology (unassign)\r
+POST {{hostname}}/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation/\r
+Authorization: Basic {{token}}\r
+Content-Type: application/json\r
+Accept: application/json\r
+\r
+{\r
+ "input": {\r
+ "network-information": {\r
+ "onap-model-information": {\r
+ "model-name": "VcpesvcVbng0412a.bng_mux",\r
+ "model-version": "1.0",\r
+ "model-customization-uuid": "b0cf3385-a390-488c-b6a0-d879fb4a4825",\r
+ "model-uuid": "9b7c1cbe-ddcd-458c-8792-d76391419b72",\r
+ "model-invariant-uuid": "206d5e6c-4cba-4c14-b942-5d946c881869"\r
+ },\r
+ "network-technology": "",\r
+ "network-id": "2e723205-7f96-49a9-bd60-24168fbd9f07",\r
+ "network-type": ""\r
+ },\r
+ "network-request-input": {\r
+ "aic-cloud-region": "wnv1a",\r
+ "cloud-owner": "att-nc",\r
+ "tenant": "1795554216e946af8a3c788f195eb813",\r
+ "network-name": "vUSP-23804-T-01-wnv1a_int_ccfx_net_1"\r
+ },\r
+ "request-information": {\r
+ "request-action": "DeleteNetworkInstance",\r
+ "source": "simulator",\r
+ "request-id": "{{$guid}}"\r
+ },\r
+ "sdnc-request-header": {\r
+ "svc-request-id": "svc-{{$guid}}",\r
+ "svc-action": "unassign"\r
+ },\r
+ "service-information": {\r
+ "onap-model-information": {\r
+ "model-name": "vcpesvc_vbng_0412a",\r
+ "model-version": "3.0",\r
+ "model-uuid": "12eb33fa-b221-4d87-939c-d808b5799a7c",\r
+ "model-invariant-uuid": "ead151e2-e18a-44fc-b6ac-3ae3d819dcd6"\r
+ },\r
+ "subscription-service-type": "VIRTUAL USP",\r
+ "service-id": "svc-{{$guid}}",\r
+ "global-customer-id": "{{$guid}}",\r
+ "service-instance-id": "5c4f2d89-57a3-47e9-b49b-d3c63eb0b3ca"\r
+ }\r
+ }\r
+}\r
+\r
+### Healthcheck\r
+POST {{hostname}}/restconf/operations/SLI-API:healthcheck/\r
+Authorization: Basic {{token}}\r
+Content-Type: application/json\r
+Accept: application/json\r
+\r
+{ input: {}}\r
+\r
+### get service instance / topology\r
+GET {{hostname}}/restconf/config/GENERIC-RESOURCE-API:services/service/5c4f2d89-57a3-47e9-b49b-d3c63eb0b3ca/service-data/service-topology/\r
+Authorization: Basic {{token}}\r
+Content-Type: application/json\r
+Accept: application/json\r
+\r
+### top level get\r
+GET {{hostname}}/restconf/config/GENERIC-RESOURCE-API:services/service/5c4f2d89-57a3-47e9-b49b-d3c63eb0b3ca/\r
+Authorization: Basic {{token}}\r
+Content-Type: application/json\r
+Accept: application/json
\ No newline at end of file