use of org.onap.so.adapters.catalogdb.catalogrest.QueryAllottedResourceCustomization in project so by onap.
the class CatalogDbAdapterRest method serviceAllottedResourcesImpl.
public Response serviceAllottedResourcesImpl(String version, boolean isArray, String aUuid, String smUuid, String serviceModelInvariantUuid, String smVer) {
QueryAllottedResourceCustomization qryResp;
int respStatus = HttpStatus.SC_OK;
String uuid = "";
List<AllottedResourceCustomization> ret = new ArrayList<>();
Service service = null;
try {
if (smUuid != null && !"".equals(smUuid)) {
uuid = smUuid;
service = serviceRepo.findFirstOneByModelUUIDOrderByModelVersionDesc(uuid);
} else if (serviceModelInvariantUuid != null && !"".equals(serviceModelInvariantUuid)) {
uuid = serviceModelInvariantUuid;
if (smVer != null && !"".equals(smVer)) {
service = serviceRepo.findFirstByModelVersionAndModelInvariantUUID(smVer, uuid);
} else {
service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(uuid);
}
} else if (aUuid != null && !"".equals(aUuid)) {
uuid = aUuid;
ret = allottedCustomizationRepo.findByModelCustomizationUUID(uuid);
} else {
throw (new Exception(NO_MATCHING_PARAMETERS));
}
if (service != null)
ret = service.getAllottedCustomizations();
if (ret == null || ret.isEmpty()) {
logger.debug("AllottedResourceCustomization not found");
respStatus = HttpStatus.SC_NOT_FOUND;
qryResp = new QueryAllottedResourceCustomization();
} else {
qryResp = new QueryAllottedResourceCustomization(ret);
logger.debug("AllottedResourceCustomization qryResp= {}", qryResp);
}
return respond(version, respStatus, isArray, qryResp);
} catch (Exception e) {
logger.error("Exception - queryAllottedResourceCustomization", 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