Search in sources :

Example 1 with QueryServiceVnfs

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();
    }
}
Also used : VnfRecipe(org.onap.so.db.catalog.beans.VnfRecipe) QueryServiceMacroHolder(org.onap.so.adapters.catalogdb.catalogrest.QueryServiceMacroHolder) NetworkRecipeRepository(org.onap.so.db.catalog.data.repository.NetworkRecipeRepository) Produces(javax.ws.rs.Produces) Path(javax.ws.rs.Path) VfModule(org.onap.so.db.catalog.beans.VfModule) LoggerFactory(org.slf4j.LoggerFactory) HttpStatus(org.apache.http.HttpStatus) Autowired(org.springframework.beans.factory.annotation.Autowired) StringUtils(org.apache.commons.lang3.StringUtils) VnfRecipeRepository(org.onap.so.db.catalog.data.repository.VnfRecipeRepository) QueryServiceNetworks(org.onap.so.adapters.catalogdb.catalogrest.QueryServiceNetworks) MediaType(javax.ws.rs.core.MediaType) QueryParam(javax.ws.rs.QueryParam) Service(org.onap.so.db.catalog.beans.Service) VFModuleRepository(org.onap.so.db.catalog.data.repository.VFModuleRepository) NetworkResourceRepository(org.onap.so.db.catalog.data.repository.NetworkResourceRepository) ProcessingFlagsRepository(org.onap.so.db.catalog.data.repository.ProcessingFlagsRepository) QueryServiceCsar(org.onap.so.adapters.catalogdb.catalogrest.QueryServiceCsar) GenericEntity(javax.ws.rs.core.GenericEntity) QueryServiceVnfs(org.onap.so.adapters.catalogdb.catalogrest.QueryServiceVnfs) ProcessingFlags(org.onap.so.db.catalog.beans.ProcessingFlags) List(java.util.List) AllottedResource(org.onap.so.db.catalog.beans.AllottedResource) HttpHeaders(javax.ws.rs.core.HttpHeaders) Response(javax.ws.rs.core.Response) NetworkResourceCustomizationRepository(org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository) NetworkResource(org.onap.so.db.catalog.beans.NetworkResource) VnfCustomizationRepository(org.onap.so.db.catalog.data.repository.VnfCustomizationRepository) QueryAllottedResourceCustomization(org.onap.so.adapters.catalogdb.catalogrest.QueryAllottedResourceCustomization) Recipe(org.onap.so.db.catalog.beans.Recipe) PathParam(javax.ws.rs.PathParam) QueryVfModule(org.onap.so.adapters.catalogdb.catalogrest.QueryVfModule) GET(javax.ws.rs.GET) InstanceGroupRepository(org.onap.so.db.catalog.data.repository.InstanceGroupRepository) CatalogQuery(org.onap.so.adapters.catalogdb.catalogrest.CatalogQuery) ArrayList(java.util.ArrayList) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) AllottedResourceCustomizationRepository(org.onap.so.db.catalog.data.repository.AllottedResourceCustomizationRepository) CatalogQueryExceptionCategory(org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryExceptionCategory) AllottedResourceRepository(org.onap.so.db.catalog.data.repository.AllottedResourceRepository) VnfResource(org.onap.so.db.catalog.beans.VnfResource) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) Logger(org.slf4j.Logger) ServiceMacroHolder(org.onap.so.db.catalog.rest.beans.ServiceMacroHolder) QueryResourceRecipe(org.onap.so.adapters.catalogdb.catalogrest.QueryResourceRecipe) InstanceGroup(org.onap.so.db.catalog.beans.InstanceGroup) VnfResourceRepository(org.onap.so.db.catalog.data.repository.VnfResourceRepository) CatalogQueryException(org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException) ToscaCsar(org.onap.so.db.catalog.beans.ToscaCsar) NetworkResourceCustomization(org.onap.so.db.catalog.beans.NetworkResourceCustomization) Component(org.springframework.stereotype.Component) ArRecipeRepository(org.onap.so.db.catalog.data.repository.ArRecipeRepository) ServiceRepository(org.onap.so.db.catalog.data.repository.ServiceRepository) AllottedResourceCustomization(org.onap.so.db.catalog.beans.AllottedResourceCustomization) PUT(javax.ws.rs.PUT) ToscaCsarRepository(org.onap.so.db.catalog.data.repository.ToscaCsarRepository) Transactional(org.springframework.transaction.annotation.Transactional) ArrayList(java.util.ArrayList) Service(org.onap.so.db.catalog.beans.Service) QueryServiceVnfs(org.onap.so.adapters.catalogdb.catalogrest.QueryServiceVnfs) CatalogQueryException(org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) CatalogQueryException(org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 GET (javax.ws.rs.GET)1 PUT (javax.ws.rs.PUT)1 Path (javax.ws.rs.Path)1 PathParam (javax.ws.rs.PathParam)1 Produces (javax.ws.rs.Produces)1 QueryParam (javax.ws.rs.QueryParam)1 GenericEntity (javax.ws.rs.core.GenericEntity)1 HttpHeaders (javax.ws.rs.core.HttpHeaders)1 MediaType (javax.ws.rs.core.MediaType)1 Response (javax.ws.rs.core.Response)1 StringUtils (org.apache.commons.lang3.StringUtils)1 HttpStatus (org.apache.http.HttpStatus)1 CatalogQuery (org.onap.so.adapters.catalogdb.catalogrest.CatalogQuery)1 CatalogQueryException (org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException)1 CatalogQueryExceptionCategory (org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryExceptionCategory)1 QueryAllottedResourceCustomization (org.onap.so.adapters.catalogdb.catalogrest.QueryAllottedResourceCustomization)1 QueryResourceRecipe (org.onap.so.adapters.catalogdb.catalogrest.QueryResourceRecipe)1 QueryServiceCsar (org.onap.so.adapters.catalogdb.catalogrest.QueryServiceCsar)1