Search in sources :

Example 1 with QueryServiceNetworks

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

Aggregations

ArrayList (java.util.ArrayList)1 CatalogQueryException (org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException)1 QueryServiceNetworks (org.onap.so.adapters.catalogdb.catalogrest.QueryServiceNetworks)1 NetworkResource (org.onap.so.db.catalog.beans.NetworkResource)1 NetworkResourceCustomization (org.onap.so.db.catalog.beans.NetworkResourceCustomization)1 Service (org.onap.so.db.catalog.beans.Service)1