Class CatalogEndpoint
java.lang.Object
com.broadleafcommerce.rest.api.endpoint.BaseEndpoint
com.broadleafcommerce.rest.api.endpoint.catalog.CatalogEndpoint
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware,org.springframework.context.MessageSourceAware
@FrameworkRestController
@FrameworkMapping(value="/catalog/",
produces={"application/json","application/xml"})
public class CatalogEndpoint
extends BaseEndpoint
This class exposes catalog services as RESTful APIs. It is dependent on
a JAX-RS implementation such as Jersey. This class must be extended, with appropriate JAX-RS
annotations, such as:
etc...
... in the subclass. The subclass must also be a Spring Bean. The subclass can then override the methods, and specify custom inputs and outputs. It will also specify
javax.ws.rs.@Scope javax.ws.rs.@Path javax.ws.rs.@Produces javax.ws.rs.@Consumes javax.ws.rs.@Context etc...
... in the subclass. The subclass must also be a Spring Bean. The subclass can then override the methods, and specify custom inputs and outputs. It will also specify
javax.ws.rs.@Path annotations, javax.ws.rs.@Context,
javax.ws.rs.@PathParam, javax.ws.rs.@QueryParam,
javax.ws.rs.@GET, javax.ws.rs.@POST, etc... Essentially, the subclass
will override and extend the methods of this class, add new methods, and control the JAX-RS behavior
using annotations according to the JAX-RS specification.- Author:
- Jay Aisenbrey (cja769)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.broadleafcommerce.core.catalog.service.CatalogServiceprotected org.broadleafcommerce.common.security.service.ExploitProtectionServiceprotected org.broadleafcommerce.core.web.service.SearchFacetDTOServiceprotected org.broadleafcommerce.core.inventory.service.InventoryServiceprotected PromotionMessageDTOWrapperServiceprotected org.broadleafcommerce.core.search.service.SearchServiceprotected org.broadleafcommerce.common.file.service.StaticAssetPathServiceFields inherited from class com.broadleafcommerce.rest.api.endpoint.BaseEndpoint
context, messageSource -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindActiveSubCategories(jakarta.servlet.http.HttpServletRequest request, Long id, int limit, int offset) findAllCategories(jakarta.servlet.http.HttpServletRequest request, String name, int limit, int offset) findCategoryAttributesForCategory(jakarta.servlet.http.HttpServletRequest request, Long categoryId) findCategoryById(jakarta.servlet.http.HttpServletRequest request, Long id, int productLimit, int productOffset, int subcategoryLimit, int subcategoryOffset) findCategoryByIdOrName(jakarta.servlet.http.HttpServletRequest request, String searchParameter, int productLimit, int productOffset, int subcategoryLimit, int subcategoryOffset) Allows you to search for a category by ID or by name.findCrossSaleProductsByProduct(jakarta.servlet.http.HttpServletRequest request, Long id, int limit, int offset) findDefaultSkuByProductId(jakarta.servlet.http.HttpServletRequest request, Long id) findInventoryForSkus(jakarta.servlet.http.HttpServletRequest request, List<Long> ids) findMediaForCategory(jakarta.servlet.http.HttpServletRequest request, Long id) findMediaForProduct(jakarta.servlet.http.HttpServletRequest request, Long id) findMediaForSku(jakarta.servlet.http.HttpServletRequest request, Long id) findParentCategoriesForProduct(jakarta.servlet.http.HttpServletRequest request, Long id) findProductAttributesForProduct(jakarta.servlet.http.HttpServletRequest request, Long id) findProductById(jakarta.servlet.http.HttpServletRequest request, Long id) Search forProductby product idfindProductById(jakarta.servlet.http.HttpServletRequest request, Long id, Boolean includePromotionMessages, Boolean includePriceData) Search forProductby product idfindSearchResultsByCategoryAndQuery(jakarta.servlet.http.HttpServletRequest request, Long categoryId, String q, Integer pageSize, Integer page, Boolean includePromotionMessages, Boolean includePriceData) This uses Broadleaf's search service to search for products or skus within a category.findSearchResultsByQuery(jakarta.servlet.http.HttpServletRequest request, String q, Integer pageSize, Integer page, Boolean includePromotionMessages, Boolean includePriceData) Queries for products or skus.findSkuAttributesForSku(jakarta.servlet.http.HttpServletRequest request, Long id) findSkuById(jakarta.servlet.http.HttpServletRequest request, Long id) findSkusByProductById(jakarta.servlet.http.HttpServletRequest request, Long id) Search forSkuinstances for a given productfindSubCategories(jakarta.servlet.http.HttpServletRequest request, Long id, int limit, int offset, boolean active) findUpSaleProductsByProduct(jakarta.servlet.http.HttpServletRequest request, Long id, int limit, int offset) protected org.broadleafcommerce.core.search.service.SearchServiceMethods inherited from class com.broadleafcommerce.rest.api.endpoint.BaseEndpoint
getApplicationContext, getMessageSource, setApplicationContext, setMessageSource
-
Field Details
-
catalogService
protected org.broadleafcommerce.core.catalog.service.CatalogService catalogService -
searchService
protected org.broadleafcommerce.core.search.service.SearchService searchService -
facetService
protected org.broadleafcommerce.core.web.service.SearchFacetDTOService facetService -
exploitProtectionService
protected org.broadleafcommerce.common.security.service.ExploitProtectionService exploitProtectionService -
staticAssetPathService
protected org.broadleafcommerce.common.file.service.StaticAssetPathService staticAssetPathService -
inventoryService
protected org.broadleafcommerce.core.inventory.service.InventoryService inventoryService -
promotionMessageDTOWrapperService
-
-
Constructor Details
-
CatalogEndpoint
public CatalogEndpoint()
-
-
Method Details
-
findProductById
Search forProductby product id- Parameters:
id- the product id- Returns:
- the product instance with the given product id
-
findProductById
@FrameworkMapping(value="product/{id}", method=GET) public ProductWrapper findProductById(jakarta.servlet.http.HttpServletRequest request, @PathVariable("id") Long id, @RequestParam(value="includePromotionMessages",required=false) Boolean includePromotionMessages, @RequestParam(value="includePriceData",required=false) Boolean includePriceData) Search forProductby product id- Parameters:
id- the product idincludePromotionMessages- whether or not PromotionMessages should be includedincludePriceData-- Returns:
- the product instance with the given product id
-
findSearchResultsByCategoryAndQuery
@FrameworkMapping(value="search/category/{categoryId}", method=GET) public SearchResultsWrapper findSearchResultsByCategoryAndQuery(jakarta.servlet.http.HttpServletRequest request, @PathVariable("categoryId") Long categoryId, @RequestParam(value="q",required=false) String q, @RequestParam(value="pageSize",required=false,defaultValue="15") Integer pageSize, @RequestParam(value="page",required=false,defaultValue="1") Integer page, @RequestParam(value="includePromotionMessages",required=false) Boolean includePromotionMessages, @RequestParam(value="includePriceData",required=false) Boolean includePriceData) This uses Broadleaf's search service to search for products or skus within a category.- Parameters:
request-q-categoryId-pageSize-page-- Returns:
-
findSearchResultsByQuery
@FrameworkMapping(value="search", method=GET) public SearchResultsWrapper findSearchResultsByQuery(jakarta.servlet.http.HttpServletRequest request, @RequestParam("q") String q, @RequestParam(value="pageSize",defaultValue="15") Integer pageSize, @RequestParam(value="page",defaultValue="1") Integer page, @RequestParam(value="includePromotionMessages",required=false) Boolean includePromotionMessages, @RequestParam(value="includePriceData",required=false) Boolean includePriceData) Queries for products or skus. The parameter q, which represents the query, is required. It can be any string, but is typically a name or keyword, similar to a search engine search.- Parameters:
request-q-pageSize-page-- Returns:
-
findSkusByProductById
@FrameworkMapping(value="product/{productId}/skus", method=GET) public List<SkuWrapper> findSkusByProductById(jakarta.servlet.http.HttpServletRequest request, @PathVariable("productId") Long id) Search forSkuinstances for a given product- Parameters:
id-- Returns:
- the list of sku instances for the product
-
findDefaultSkuByProductId
@FrameworkMapping(value="product/{productId}/defaultSku", method=GET) public SkuWrapper findDefaultSkuByProductId(jakarta.servlet.http.HttpServletRequest request, @PathVariable("productId") Long id) -
findAllCategories
@FrameworkMapping(value="categories", method=GET) public CategoriesWrapper findAllCategories(jakarta.servlet.http.HttpServletRequest request, @RequestParam(value="name",required=false) String name, @RequestParam(value="limit",defaultValue="20") int limit, @RequestParam(value="offset",defaultValue="0") int offset) -
findSubCategories
@FrameworkMapping(value="category/{categoryId}/categories", method=GET) public CategoriesWrapper findSubCategories(jakarta.servlet.http.HttpServletRequest request, @PathVariable("categoryId") Long id, @RequestParam(value="limit",defaultValue="20") int limit, @RequestParam(value="offset",defaultValue="0") int offset, @RequestParam(value="active",defaultValue="true") boolean active) -
findActiveSubCategories
@FrameworkMapping(value="category/{categoryId}/activeSubcategories", method=GET) public CategoriesWrapper findActiveSubCategories(jakarta.servlet.http.HttpServletRequest request, @PathVariable("categoryId") Long id, @RequestParam(value="limit",defaultValue="20") int limit, @RequestParam(value="offset",defaultValue="0") int offset) -
findCategoryById
@FrameworkMapping(value="category/{categoryId}", method=GET) public CategoryWrapper findCategoryById(jakarta.servlet.http.HttpServletRequest request, @PathVariable("categoryId") Long id, @RequestParam(value="productLimit",defaultValue="20") int productLimit, @RequestParam(value="productOffset",defaultValue="1") int productOffset, @RequestParam(value="subcategoryLimit",defaultValue="20") int subcategoryLimit, @RequestParam(value="subcategoryOffset",defaultValue="1") int subcategoryOffset) -
findCategoryByIdOrName
@FrameworkMapping(value="category", method=GET) public CategoryWrapper findCategoryByIdOrName(jakarta.servlet.http.HttpServletRequest request, @RequestParam("searchParameter") String searchParameter, @RequestParam(value="productLimit",defaultValue="20") int productLimit, @RequestParam(value="productOffset",defaultValue="1") int productOffset, @RequestParam(value="subcategoryLimit",defaultValue="20") int subcategoryLimit, @RequestParam(value="subcategoryOffset",defaultValue="1") int subcategoryOffset) Allows you to search for a category by ID or by name.- Parameters:
request-searchParameter-productLimit-productOffset-subcategoryLimit-subcategoryOffset-- Returns:
-
findCategoryAttributesForCategory
@FrameworkMapping(value="category/{categoryId}/attributes", method=GET) public List<CategoryAttributeWrapper> findCategoryAttributesForCategory(jakarta.servlet.http.HttpServletRequest request, @PathVariable("categoryId") Long categoryId) -
findUpSaleProductsByProduct
@FrameworkMapping(value="product/{productId}/upsale", method=GET) public List<RelatedProductWrapper> findUpSaleProductsByProduct(jakarta.servlet.http.HttpServletRequest request, @PathVariable("productId") Long id, @RequestParam(value="limit",defaultValue="20") int limit, @RequestParam(value="offset",defaultValue="0") int offset) -
findCrossSaleProductsByProduct
@FrameworkMapping(value="product/{productId}/crosssale", method=GET) public List<RelatedProductWrapper> findCrossSaleProductsByProduct(jakarta.servlet.http.HttpServletRequest request, @PathVariable("productId") Long id, @RequestParam(value="limit",defaultValue="20") int limit, @RequestParam(value="offset",defaultValue="0") int offset) -
findProductAttributesForProduct
@FrameworkMapping(value="product/{productId}/attributes", method=GET) public List<ProductAttributeWrapper> findProductAttributesForProduct(jakarta.servlet.http.HttpServletRequest request, @PathVariable("productId") Long id) -
findSkuAttributesForSku
@FrameworkMapping(value="sku/{skuId}/attributes", method=GET) public List<SkuAttributeWrapper> findSkuAttributesForSku(jakarta.servlet.http.HttpServletRequest request, @PathVariable("skuId") Long id) -
findMediaForSku
@FrameworkMapping(value="sku/{skuId}/media", method=GET) public List<MediaWrapper> findMediaForSku(jakarta.servlet.http.HttpServletRequest request, @PathVariable("skuId") Long id) -
findSkuById
@FrameworkMapping(value="sku/{skuId}", method=GET) public SkuWrapper findSkuById(jakarta.servlet.http.HttpServletRequest request, @PathVariable("skuId") Long id) -
findInventoryForSkus
@FrameworkMapping(value="sku/inventory", method=GET) public List<InventoryWrapper> findInventoryForSkus(jakarta.servlet.http.HttpServletRequest request, @RequestParam("id") List<Long> ids) -
findMediaForProduct
@FrameworkMapping(value="product/{productId}/media", method=GET) public List<MediaWrapper> findMediaForProduct(jakarta.servlet.http.HttpServletRequest request, @PathVariable("productId") Long id) -
findMediaForCategory
@FrameworkMapping(value="category/{id}/media", method=GET) public List<MediaWrapper> findMediaForCategory(jakarta.servlet.http.HttpServletRequest request, @PathVariable("id") Long id) -
findParentCategoriesForProduct
@FrameworkMapping(value="product/{productId}/categories", method=GET) public CategoriesWrapper findParentCategoriesForProduct(jakarta.servlet.http.HttpServletRequest request, @PathVariable("productId") Long id) -
getSearchService
protected org.broadleafcommerce.core.search.service.SearchService getSearchService()
-