Search in sources :

Example 1 with CatalogCategoryList

use of com.emc.vipr.model.catalog.CatalogCategoryList in project coprhd-controller by CoprHD.

the class CatalogCategoryService method getCatalogCategories.

/**
 * Gets the list of sub categories within the category
 *
 * @param id the URN of a Catalog Category
 * @brief List Catalog Categories
 * @return a list of sub categories that belong to the category
 * @throws DatabaseException when a DB error occurs
 */
@GET
@Path("/{id}/categories")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public CatalogCategoryList getCatalogCategories(@PathParam("id") URI id) throws DatabaseException {
    CatalogCategory parentCatalogCategory = queryResource(id);
    // check the user permissions
    verifyAuthorizedInTenantOrg(uri(parentCatalogCategory.getTenant()), getUserFromContext());
    List<CatalogCategory> subCatalogCategories = catalogCategoryManager.getSubCategories(id);
    subCatalogCategories = filterCategoriesByACLs(subCatalogCategories);
    CatalogCategoryList subCatalogCategoryList = new CatalogCategoryList();
    for (CatalogCategory subCatalogCategory : subCatalogCategories) {
        NamedRelatedResourceRep subCatalogCategoryRestRep = toNamedRelatedResource(ResourceTypeEnum.CATALOG_CATEGORY, subCatalogCategory.getId(), subCatalogCategory.getLabel());
        subCatalogCategoryList.getCatalogCategories().add(subCatalogCategoryRestRep);
    }
    return subCatalogCategoryList;
}
Also used : CatalogCategoryMapper.createNewCatalogCategory(com.emc.sa.api.mapper.CatalogCategoryMapper.createNewCatalogCategory) CatalogCategory(com.emc.storageos.db.client.model.uimodels.CatalogCategory) CatalogCategoryList(com.emc.vipr.model.catalog.CatalogCategoryList) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with CatalogCategoryList

use of com.emc.vipr.model.catalog.CatalogCategoryList in project coprhd-controller by CoprHD.

the class CatalogCategories method listByTenant.

@Override
public List<NamedRelatedResourceRep> listByTenant(URI tenantId) {
    CatalogCategoryRestRep rootCatalogCategory = getRootCatalogCategory(asString(tenantId));
    UriBuilder uriBuilder = client.uriBuilder(PathConstants.CATALOG_SUB_CATEGORIES_URL);
    if (tenantId != null) {
        uriBuilder = uriBuilder.queryParam(SearchConstants.TENANT_ID_PARAM, tenantId);
    }
    CatalogCategoryList response = client.getURI(CatalogCategoryList.class, uriBuilder.build(rootCatalogCategory.getId()));
    return ResourceUtils.defaultList(response.getCatalogCategories());
}
Also used : CatalogCategoryList(com.emc.vipr.model.catalog.CatalogCategoryList) UriBuilder(javax.ws.rs.core.UriBuilder) CatalogCategoryRestRep(com.emc.vipr.model.catalog.CatalogCategoryRestRep)

Aggregations

CatalogCategoryList (com.emc.vipr.model.catalog.CatalogCategoryList)2 CatalogCategoryMapper.createNewCatalogCategory (com.emc.sa.api.mapper.CatalogCategoryMapper.createNewCatalogCategory)1 CatalogCategory (com.emc.storageos.db.client.model.uimodels.CatalogCategory)1 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)1 CatalogCategoryRestRep (com.emc.vipr.model.catalog.CatalogCategoryRestRep)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 UriBuilder (javax.ws.rs.core.UriBuilder)1