Class CategoryEndpoint

java.lang.Object
com.broadleafcommerce.catalog.web.endpoint.CategoryEndpoint

@FrameworkRestController @FrameworkMapping("/categories") @DataRouteByExample(Category.class) public class CategoryEndpoint extends Object
  • Field Details

  • Constructor Details

  • Method Details

    • readAllCategories

      @FrameworkGetMapping @Policy(permissionRoots="CATEGORY") public org.springframework.data.domain.Page<Category> readAllCategories(jakarta.servlet.http.HttpServletRequest request, @ContextOperation(READ) com.broadleafcommerce.data.tracking.core.context.ContextInfo context, @RequestParam(value="rootsOnly",required=false,defaultValue="true") boolean rootsOnly, @RequestParam(value="q",required=false) String query, @PageableDefault(size=50) org.springframework.data.domain.Pageable page, cz.jirutka.rsql.parser.ast.Node filters, @RequestParam(required=false) List<String> ids)
    • readCategoryById

      @FrameworkGetMapping("/{id}") @Policy(permissionRoots="CATEGORY") public Category readCategoryById(jakarta.servlet.http.HttpServletRequest request, @ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo context, @PathVariable("id") String id)
    • updateCategory

      @FrameworkPatchMapping(value="/{id}", consumes="application/json") @Policy(permissionRoots="CATEGORY") public Category updateCategory(jakarta.servlet.http.HttpServletRequest request, @ContextOperation(UPDATE) com.broadleafcommerce.data.tracking.core.context.ContextInfo context, @PathVariable("id") String id, @RequestBody Category req) throws InvalidParentCategoryException
      Throws:
      InvalidParentCategoryException
    • replaceAllCategoryTranslations

      @FrameworkPutMapping(value="/{id}/translations/{locale}", consumes="application/json") @Policy(permissionRoots="CATEGORY") public com.broadleafcommerce.translation.service.dto.TranslationsPayload replaceAllCategoryTranslations(@ContextOperation(UPDATE) com.broadleafcommerce.data.tracking.core.context.ContextInfo context, @PathVariable("id") String id, @PathVariable("locale") Locale locale, @RequestBody com.broadleafcommerce.translation.service.dto.TranslationsPayload translationRequest)
    • replaceCategory

      @FrameworkPutMapping(value="/{id}", consumes="application/json") @Policy(permissionRoots="CATEGORY") public Category replaceCategory(jakarta.servlet.http.HttpServletRequest request, @ContextOperation(UPDATE) com.broadleafcommerce.data.tracking.core.context.ContextInfo context, @PathVariable("id") String id, @RequestBody Category req) throws InvalidParentCategoryException
      Throws:
      InvalidParentCategoryException
    • createCategory

      @FrameworkPostMapping(consumes="application/json") @Policy(permissionRoots="CATEGORY") public Category createCategory(jakarta.servlet.http.HttpServletRequest request, @ContextOperation(CREATE) com.broadleafcommerce.data.tracking.core.context.ContextInfo context, @RequestBody Category req) throws InvalidParentCategoryException
      Throws:
      InvalidParentCategoryException
    • deleteCategory

      @FrameworkDeleteMapping("/{id}") @Policy(permissionRoots="CATEGORY") public void deleteCategory(jakarta.servlet.http.HttpServletRequest request, @ContextOperation(DELETE) com.broadleafcommerce.data.tracking.core.context.ContextInfo context, @PathVariable("id") String id) throws InvalidCategoryDeleteException
      Throws:
      InvalidCategoryDeleteException
    • cloneCategory

      @FrameworkPostMapping(value="/{id}/clone", consumes="application/json") @Policy(permissionRoots="CATEGORY") public Category cloneCategory(@ContextOperation(CREATE) com.broadleafcommerce.data.tracking.core.context.ContextInfo context, @PathVariable("id") String categoryId, @RequestBody CloneCategoryRequest cloneCategoryRequest)
    • getAncestors

      @FrameworkGetMapping("/{id}/ancestors") @Policy(permissionRoots="CATEGORY") public CategoryAncestorList getAncestors(@ContextOperation(READ) com.broadleafcommerce.data.tracking.core.context.ContextInfo context, @PathVariable("id") String id)
    • readGeneralProducts

      @FrameworkGetMapping("/{id}/products") @Policy(permissionRoots="CATEGORY") public org.springframework.data.domain.Page<CategoryProduct> readGeneralProducts(@PathVariable("id") String categoryId, @PageableDefault(size=50) org.springframework.data.domain.Pageable page, @ContextOperation(READ) com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, @RequestParam(value="isSorted",required=false) Boolean isSorted, cz.jirutka.rsql.parser.ast.Node filters)
    • readGeneralProduct

      @FrameworkGetMapping("/{id}/products/{categoryProductId}") @Policy(permissionRoots="CATEGORY") public CategoryProduct readGeneralProduct(@PathVariable("id") String categoryId, @PathVariable("categoryProductId") String categoryProductId, @ContextOperation(READ) com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) throws InvalidCategoryTypeException
      Throws:
      InvalidCategoryTypeException
    • addGeneralProduct

      @FrameworkPostMapping(value="/{categoryId}/products", consumes="application/json") @Policy(permissionRoots="CATEGORY") public CategoryProduct addGeneralProduct(@PathVariable("categoryId") String categoryId, @RequestBody CategoryProduct categoryProduct, OptionalSortPositionRequest givenSortRequest, @ContextOperation(CREATE) com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) throws InvalidRelatedProductException, InvalidCategoryTypeException
      Throws:
      InvalidRelatedProductException
      InvalidCategoryTypeException
    • replaceGeneralProduct

      @FrameworkPutMapping(value="/{id}/products/{categoryProductId}", consumes="application/json") @Policy(permissionRoots="CATEGORY") public CategoryProduct replaceGeneralProduct(@PathVariable("id") String categoryId, @PathVariable("categoryProductId") String categoryProductId, @RequestBody CategoryProduct categoryProduct, @ContextOperation(UPDATE) com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) throws InvalidRelatedProductException, InvalidCategoryTypeException
      Throws:
      InvalidRelatedProductException
      InvalidCategoryTypeException
    • removeGeneralProduct

      @FrameworkDeleteMapping("/{id}/products/{categoryProductId}") @Policy(permissionRoots="CATEGORY") public void removeGeneralProduct(@PathVariable("id") String categoryId, @PathVariable("categoryProductId") String categoryProductId, @ContextOperation(DELETE) com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) throws InvalidCategoryTypeException
      Throws:
      InvalidCategoryTypeException
    • checkProductMembershipInCategory

      @FrameworkGetMapping("/{id}/products/contains") @Policy(permissionRoots="CATEGORY") public org.springframework.http.ResponseEntity<CategoryEndpoint.ProductInCategoryResponse> checkProductMembershipInCategory(@ContextOperation com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, @PathVariable("id") String categoryId, @RequestParam("productId") String productId)
    • reorderGeneralProduct

      @FrameworkPatchMapping("/{id}/products/{categoryProductId}/sort") @Policy(permissionRoots="CATEGORY") public CategoryProduct reorderGeneralProduct(jakarta.servlet.http.HttpServletRequest request, @ContextOperation(UPDATE) com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, @PathVariable("id") String categoryId, @PathVariable("categoryProductId") String categoryProductId, @UpdateSortOperation("categoryProductId") com.broadleafcommerce.data.tracking.core.sort.SortPositionRequest sortPositionRequest) throws InvalidCategoryTypeException
      Throws:
      InvalidCategoryTypeException
    • reorderGeneralProducts

      @FrameworkPatchMapping(value="/{id}/products", params="sort", consumes="application/json") @Policy(permissionRoots="CATEGORY") public org.springframework.data.domain.Page<CategoryProduct> reorderGeneralProducts(jakarta.servlet.http.HttpServletRequest request, @ContextOperation(UPDATE) com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, @PathVariable("id") String categoryId, @RequestBody com.broadleafcommerce.data.tracking.core.sort.SortPositionRequest sortPositionRequest) throws InvalidCategoryTypeException
      Throws:
      InvalidCategoryTypeException
    • readPromotionalProducts

      @FrameworkGetMapping("/{id}/promotional-products") @Policy(permissionRoots="CATEGORY") public org.springframework.data.domain.Page<PromotionalCategoryProduct> readPromotionalProducts(@PathVariable("id") String categoryId, @RequestParam(value="type",required=false) String type, @PageableDefault(size=50) org.springframework.data.domain.Pageable page, @ContextOperation(READ) com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • readPromotionalProduct

      @FrameworkGetMapping("/{id}/promotional-products/{promotionalCategoryProductId}") @Policy(permissionRoots="CATEGORY") public PromotionalCategoryProduct readPromotionalProduct(@PathVariable("id") String categoryId, @PathVariable("promotionalCategoryProductId") String promotionalCategoryProductId, @ContextOperation(READ) com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • addPromotionalProduct

      @FrameworkPostMapping(value="/{id}/promotional-products", consumes="application/json") @Policy(permissionRoots="CATEGORY") public PromotionalCategoryProduct addPromotionalProduct(@PathVariable("id") String categoryId, @RequestBody PromotionalCategoryProduct promotionalCategoryProduct, OptionalSortPositionRequest givenSortRequest, @ContextOperation(CREATE) com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) throws InvalidRelatedProductException
      Throws:
      InvalidRelatedProductException
    • reorderPromotionalProduct

      @FrameworkPatchMapping("/{id}/promotional-products/{promotionalCategoryProductId}/sort") @Policy(permissionRoots="CATEGORY") public PromotionalCategoryProduct reorderPromotionalProduct(jakarta.servlet.http.HttpServletRequest request, @ContextOperation(UPDATE) com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, @PathVariable("id") String categoryId, @PathVariable("promotionalCategoryProductId") String promotionalCategoryProductId, @UpdateSortOperation("promotionalCategoryProductId") com.broadleafcommerce.data.tracking.core.sort.SortPositionRequest sortPositionRequest)
    • replaceAllPromotionalProductTranslations

      @FrameworkPutMapping(value="/{id}/promotional-products/{promotionalCategoryProductId}/translations/{locale}", consumes="application/json") @Policy(permissionRoots="CATEGORY") public com.broadleafcommerce.translation.service.dto.TranslationsPayload replaceAllPromotionalProductTranslations(@ContextOperation(UPDATE) com.broadleafcommerce.data.tracking.core.context.ContextInfo context, @PathVariable("id") String categoryId, @PathVariable("promotionalCategoryProductId") String promotionalCategoryProductId, @PathVariable("locale") Locale locale, @RequestBody com.broadleafcommerce.translation.service.dto.TranslationsPayload translationRequest)
    • replacePromotionalProduct

      @FrameworkPutMapping(value="/{id}/promotional-products/{promotionalCategoryProductId}", consumes="application/json") @Policy(permissionRoots="CATEGORY") public PromotionalCategoryProduct replacePromotionalProduct(@PathVariable("id") String categoryId, @PathVariable("promotionalCategoryProductId") String promotionalCategoryProductId, @RequestBody PromotionalCategoryProduct promotionalCategoryProduct, @ContextOperation(UPDATE) com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) throws InvalidRelatedProductException
      Throws:
      InvalidRelatedProductException
    • removePromotionalProduct

      @FrameworkDeleteMapping("/{id}/promotional-products/{promotionalCategoryProductId}") @Policy(permissionRoots="CATEGORY") public void removePromotionalProduct(@PathVariable("id") String categoryId, @PathVariable("promotionalCategoryProductId") String promotionalCategoryProductId, @ContextOperation(DELETE) com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • readSubcategories

      @FrameworkGetMapping("/{id}/subcategories") @Policy(permissionRoots="CATEGORY") public org.springframework.data.domain.Page<Category> readSubcategories(@PathVariable("id") String categoryId, cz.jirutka.rsql.parser.ast.Node filters, @PageableDefault(size=50) org.springframework.data.domain.Pageable page, @ContextOperation(READ) com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • readSubcategoriesByCategoryIds

      @FrameworkGetMapping("/subcategories") @Policy(permissionRoots="CATEGORY") public org.springframework.data.domain.Page<Category> readSubcategoriesByCategoryIds(@RequestParam("parentCategoryIds") List<String> parentCategoryIds, cz.jirutka.rsql.parser.ast.Node filters, @PageableDefault(size=50) org.springframework.data.domain.Pageable page, @ContextOperation(READ) com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • ensureCategoryExistsAndReturn

      protected Category ensureCategoryExistsAndReturn(String categoryId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • createCategoryRefFromCategory

      protected CategoryRef createCategoryRefFromCategory(Category category)
    • validateAndGetCategoryAndCategoryProductRequest

      protected org.apache.commons.lang3.tuple.Pair<Category,CategoryProduct> validateAndGetCategoryAndCategoryProductRequest(String categoryId, String categoryProductId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) throws InvalidCategoryTypeException
      Throws:
      InvalidCategoryTypeException
    • validateAndGetCategoryAndPromoCategoryProduct

      protected org.apache.commons.lang3.tuple.Pair<Category,PromotionalCategoryProduct> validateAndGetCategoryAndPromoCategoryProduct(String categoryId, String promotionalCategoryProductId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Validates that the category and promotional category product with the given IDs exist, and that they are related to each other. If so, returns them in a pair.
      Parameters:
      categoryId - the ID of the category to find
      promotionalCategoryProductId - the ID of the promotional category product to find
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      a pair of the category and promotional category product if found
      Throws:
      com.broadleafcommerce.data.tracking.core.exception.EntityMissingException - if the category or promotional category product were not found, or if they were not related to each other
    • handleInvalidCategoryTypeException

      @ExceptionHandler(InvalidCategoryTypeException.class) public org.springframework.http.ResponseEntity<com.broadleafcommerce.common.error.ApiError> handleInvalidCategoryTypeException(Exception ex, org.springframework.web.context.request.WebRequest request)
    • handleInvalidParentCategoryException

      @ExceptionHandler(InvalidParentCategoryException.class) public org.springframework.http.ResponseEntity<com.broadleafcommerce.common.error.ApiError> handleInvalidParentCategoryException(Exception ex, org.springframework.web.context.request.WebRequest request)
    • handleCategoryAncestryHydrationException

      @ExceptionHandler(CategoryAncestryHydrationException.class) public org.springframework.http.ResponseEntity<com.broadleafcommerce.common.error.ApiError> handleCategoryAncestryHydrationException(Exception ex, org.springframework.web.context.request.WebRequest request)
    • logDebug

      protected void logDebug(Exception ex, org.springframework.web.context.request.WebRequest request)
    • getCategoryService

      protected CategoryService<Category> getCategoryService()
    • getCategoryAncestryHydrationService

      protected CategoryAncestryHydrationService getCategoryAncestryHydrationService()
    • getPromotionalCategoryProductService

      protected PromotionalCategoryProductService<PromotionalCategoryProduct> getPromotionalCategoryProductService()
    • getProductService

      protected ProductService<Product> getProductService()
    • getProductAssetService

      @NonNull protected ProductAssetService<ProductAsset> getProductAssetService()
    • getCategoryProductService

      protected CategoryProductService<CategoryProduct> getCategoryProductService()
    • getCatalogFactory

      protected com.broadleafcommerce.common.extension.TypeFactory getCatalogFactory()
    • getTranslationEntityService

      protected com.broadleafcommerce.translation.service.TranslationEntityService<com.broadleafcommerce.translation.domain.Translation> getTranslationEntityService()
    • getCloneCategorySvc

      protected CloneCategoryService<Category,CloneCategoryRequest> getCloneCategorySvc()