Search in sources :

Example 1 with QueryAllottedResourceCustomization

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();
    }
}
Also used : ArrayList(java.util.ArrayList) Service(org.onap.so.db.catalog.beans.Service) CatalogQueryException(org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException) QueryAllottedResourceCustomization(org.onap.so.adapters.catalogdb.catalogrest.QueryAllottedResourceCustomization) CatalogQueryException(org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException) QueryAllottedResourceCustomization(org.onap.so.adapters.catalogdb.catalogrest.QueryAllottedResourceCustomization) AllottedResourceCustomization(org.onap.so.db.catalog.beans.AllottedResourceCustomization)

Aggregations

ArrayList (java.util.ArrayList)1 CatalogQueryException (org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException)1 QueryAllottedResourceCustomization (org.onap.so.adapters.catalogdb.catalogrest.QueryAllottedResourceCustomization)1 AllottedResourceCustomization (org.onap.so.db.catalog.beans.AllottedResourceCustomization)1 Service (org.onap.so.db.catalog.beans.Service)1