use of org.onap.so.adapters.catalogdb.catalogrest.QueryServiceVnfs in project so by onap.
the class CatalogDbAdapterRest method serviceVnfsImpl.
public Response serviceVnfsImpl(String version, boolean isArray, String vnfUuid, String serviceModelUUID, String smiUuid, String smVer, String smName, String filter) {
QueryServiceVnfs qryResp = null;
int respStatus = HttpStatus.SC_OK;
List<VnfResourceCustomization> ret = new ArrayList<>();
Service service = null;
try {
if (vnfUuid != null && !"".equals(vnfUuid))
ret = vnfCustomizationRepo.findByModelCustomizationUUID(vnfUuid);
else if (serviceModelUUID != null && !"".equals(serviceModelUUID))
service = serviceRepo.findFirstOneByModelUUIDOrderByModelVersionDesc(serviceModelUUID);
else if (smiUuid != null && !"".equals(smiUuid))
if (smVer != null && !"".equals(smVer))
service = serviceRepo.findFirstByModelVersionAndModelInvariantUUID(smVer, smiUuid);
else
service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(smiUuid);
else if (smName != null && !"".equals(smName)) {
if (smVer != null && !"".equals(smVer))
service = serviceRepo.findByModelNameAndModelVersion(smName, smVer);
else
service = serviceRepo.findFirstByModelNameOrderByModelVersionDesc(smName);
} else {
throw (new Exception(NO_MATCHING_PARAMETERS));
}
if (service == null && ret.isEmpty()) {
respStatus = HttpStatus.SC_NOT_FOUND;
qryResp = new QueryServiceVnfs();
} else if (service == null && !ret.isEmpty()) {
if (StringUtils.isNotEmpty(filter) && RESOURCE_INPUT_FILTER.equalsIgnoreCase(filter)) {
ret.forEach(vnfCustomization -> vnfCustomization.setResourceInput(null));
}
qryResp = new QueryServiceVnfs(ret);
} else if (service != null) {
ret = service.getVnfCustomizations();
if (StringUtils.isNotEmpty(filter) && RESOURCE_INPUT_FILTER.equalsIgnoreCase(filter)) {
ret.forEach(vnfCustomization -> vnfCustomization.setResourceInput(null));
}
qryResp = new QueryServiceVnfs(ret);
}
logger.debug("serviceVnfs qryResp= {}", qryResp);
return respond(version, respStatus, isArray, qryResp);
} catch (Exception e) {
logger.error("Exception - queryServiceVnfs", 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