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;
}
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());
}
Aggregations