use of org.onap.so.adapters.catalogdb.catalogrest.QueryServiceNetworks in project so by onap.
the class CatalogDbAdapterRest method serviceNetworksImpl.
public Response serviceNetworksImpl(String version, boolean isArray, String networkModelCustomizationUuid, String networkType, String serviceModelUuid, String serviceModelInvariantUuid, String serviceModelVersion) {
QueryServiceNetworks qryResp;
int respStatus = HttpStatus.SC_OK;
String uuid = "";
List<NetworkResourceCustomization> ret = new ArrayList<>();
Service service = null;
try {
if (networkModelCustomizationUuid != null && !"".equals(networkModelCustomizationUuid)) {
uuid = networkModelCustomizationUuid;
ret = networkCustomizationRepo.findByModelCustomizationUUID(networkModelCustomizationUuid);
} else if (networkType != null && !"".equals(networkType)) {
uuid = networkType;
NetworkResource networkResources = networkResourceRepo.findFirstByModelNameOrderByModelVersionDesc(networkType);
if (networkResources != null)
ret = networkResources.getNetworkResourceCustomization();
} else if (serviceModelInvariantUuid != null && !"".equals(serviceModelInvariantUuid)) {
uuid = serviceModelInvariantUuid;
if (serviceModelVersion != null && !"".equals(serviceModelVersion)) {
service = serviceRepo.findFirstByModelVersionAndModelInvariantUUID(serviceModelVersion, uuid);
} else {
service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(uuid);
}
} else if (serviceModelUuid != null && !"".equals(serviceModelUuid)) {
uuid = serviceModelUuid;
service = serviceRepo.findOneByModelUUID(serviceModelUuid);
} else {
throw (new Exception(NO_MATCHING_PARAMETERS));
}
if (service != null)
ret = service.getNetworkCustomizations();
if (ret == null || ret.isEmpty()) {
logger.debug("serviceNetworks not found");
respStatus = HttpStatus.SC_NOT_FOUND;
qryResp = new QueryServiceNetworks();
} else {
qryResp = new QueryServiceNetworks(ret);
logger.debug("serviceNetworks found qryResp= {}", qryResp);
}
return respond(version, respStatus, isArray, qryResp);
} catch (Exception e) {
logger.error("Exception - queryServiceNetworks", e);
CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).entity(new GenericEntity<CatalogQueryException>(excResp) {
}).build();
}
}
Aggregations