Class ProductsController

java.lang.Object
de.hybris.platform.ycommercewebservices.v1.controller.BaseController
de.hybris.platform.ycommercewebservices.v1.controller.ProductsController

@Controller("productsControllerV1") @RequestMapping("/{baseSiteId}/products") public class ProductsController extends BaseController
Web Services Controller to expose the functionality of the ProductFacade and SearchFacade.
  • Constructor Details

    • ProductsController

      public ProductsController()
  • Method Details

    • searchProducts

      @RequestMapping(method=GET) @ResponseBody public ProductSearchPageData<SearchStateData,ProductData> searchProducts(@RequestParam(required=false) String query, @RequestParam(required=false,defaultValue="0") int currentPage, @RequestParam(required=false,defaultValue="20") int pageSize, @RequestParam(required=false) String sort)
      Web service handler for search. Implementation has to catch up once the SearchFacade exists.
      Parameters:
      query - serialized query in format: freeTextSearch:sort:facetKey1:facetValue1:facetKey2:facetValue2
      currentPage - the current result page requested
      pageSize - the number of results returned per page
      sort - sorting method applied to the display search results
      Returns:
      FacetSearchPageData
    • getStockData

      @RequestMapping(value="/{productCode}/stock", method=GET) @ResponseBody public StockData getStockData(@PathVariable String baseSiteId, @PathVariable String productCode, @RequestParam(required=true) String storeName) throws WebserviceValidationException, StockSystemException
      Web service handler for getting stock level in a given store.
      Sample Call: http://localhost:9001/rest/v1/:site/products/:code/stock?storeName=
      Parameters:
      storeName - name of the store
      Returns:
      StockData
      Throws:
      WebserviceValidationException
      StockSystemException
    • exportProducts

      @Secured("ROLE_TRUSTED_CLIENT") @RequestMapping(value="/export/full", method=GET) @ResponseBody public ProductDataList exportProducts(@RequestParam(required=false,defaultValue="0") int currentPage, @RequestParam(required=false,defaultValue="2147483647") int pageSize, @RequestParam(required=false,defaultValue="BASIC") String options, @RequestParam(required=false) String catalog, @RequestParam(required=false) String version)
      Web service handler for product export. If no 'options' query parameter is defined, it will assume BASIC. The options are turned into a Set and passed on to the facade.
      Sample Call: http://localhost:9001/rest/v1/{SITE}/products/export/full
      Parameters:
      currentPage - - index position of the first Product, which will be included in the returned List
      pageSize - - number of Products which will be returned in each page
      options - - a String enumerating the detail level, values are BASIC, PROMOTIONS, STOCK, REVIEW, CLASSIFICATION, REFERENCES. Combine by using a ',', which needs to be encoded as part of a URI using URLEncoding: %2C
      Returns:
      ProductDataList
    • exportProducts

      @Secured("ROLE_TRUSTED_CLIENT") @RequestMapping(value="/export/incremental", method=GET) @ResponseBody public ProductDataList exportProducts(@RequestParam(required=false,defaultValue="0") int currentPage, @RequestParam(required=false,defaultValue="2147483647") int pageSize, @RequestParam(required=false,defaultValue="BASIC") String options, @RequestParam(required=false) String catalog, @RequestParam(required=false) String version, @RequestParam String timestamp)
      Web service handler for incremental product export. Timestamp specifies which product to export. If no 'options' query parameter is defined, it will assume BASIC. The options are turned into a Set and passed on to the facade.
      Sample Call: http://localhost:9001/rest/v1/{SITE}/products/export/incremental
      Parameters:
      currentPage - - index position of the first Product, which will be included in the returned List
      pageSize - - number of Products which will be returned in each page
      options - - a String enumerating the detail level, values are BASIC, PROMOTIONS, STOCK, REVIEW, CLASSIFICATION, REFERENCES. Combine by using a ',', which needs to be encoded as part of a URI using URLEncoding: %2C
      catalog - catalog from which get products
      version - version of catalog
      timestamp - time in ISO-8601 format
      Returns:
      ProductDataList
    • exportProductReferences

      @Secured("ROLE_TRUSTED_CLIENT") @RequestMapping(value="/export/references/{code}", method=GET) @ResponseBody public ProductReferencesData exportProductReferences(@PathVariable String code, @RequestParam(required=false,defaultValue="2147483647") int pageSize, @RequestParam(required=false,defaultValue="BASIC") String options, @RequestParam String referenceType)
      Web service handler for export product references. Reference type specifies which references to return. If no 'options' query parameter is defined, it will assume BASIC. The options are turned into a Set and passed on to the facade. Sample Call: http://localhost:9001/rest/v1/{SITE}/products/export/references/{code}?referenceType =CROSSELLING&catalog=hwcatalog&version=Online
      Parameters:
      code - - product code
      referenceType - - reference type according to enum ProductReferenceTypeEnum
      pageSize - - number of Products which will be returned in each page
      options - - a String enumerating the detail level, values are BASIC, PROMOTIONS, STOCK, REVIEW, CLASSIFICATION, REFERENCES. Combine by using a ',', which needs to be encoded as part of a URI using URLEncoding: %2C
      Returns:
      collection of ProductReferenceData
    • expressUpdate

      @Secured("ROLE_TRUSTED_CLIENT") @RequestMapping(value="/expressUpdate", method=GET) @ResponseBody public ProductExpressUpdateElementDataList expressUpdate(@RequestParam String timestamp, @RequestParam(required=false) String catalog) throws RequestParameterException
      Web service handler for product express update. Returns only elements newer than timestamp. Sample Call: http://localhost:9001/rest/v1/{SITE}/products/expressUpdate
      This method requires trusted client authentication.
      Method type : GET.
      Method is restricted for HTTPS channel.
      Parameters:
      timestamp - - time in ISO-8601 format
      catalog - - the product catalog to return queue for. If not set all products from all catalogs in queue will be returned. Format: catalogId:catalogVersion
      Returns:
      ProductExpressUpdateElementDataList
      Throws:
      RequestParameterException
    • filterExpressUpdateQueue

      protected void filterExpressUpdateQueue(ProductExpressUpdateElementDataList productExpressUpdateDataList, List<String> catalogInfo)
    • validateAndSplitCatalog

      protected List<String> validateAndSplitCatalog(String catalog) throws RequestParameterException
      Throws:
      RequestParameterException
    • convertResultset

      protected ProductDataList convertResultset(int page, int pageSize, String catalog, String version, ProductResultData modifiedProducts)
    • extractOptions

      protected Set<ProductOption> extractOptions(String options)
    • getProductByCode

      @RequestMapping(value="/{code}", method=GET) @ResponseBody public ProductData getProductByCode(@PathVariable String code, @RequestParam(required=false,defaultValue="BASIC") String options)
      Web service handler for the getProductByCode call. If no 'options' query parameter is defined, it will assume BASIC. The options are turned into a Set and passed on to the facade. Sample Call: http://localhost:9001/rest/v1/{SITE}/products/{CODE}?options=BASIC%2CPROMOTIONS Keep in mind ',' needs to be encoded as %2C
      Parameters:
      code - - the unique code used to identify a product
      options - - a String enumerating the detail level, values are BASIC, PROMOTIONS, STOCK, REVIEW, CLASSIFICATION, REFERENCES. Combine by using a ',', which needs to be encoded as part of a URI using URLEncoding: %2C
      Returns:
      the ProdcutData DTO which will be marshaled to JSON or XML based on Accept-Header
    • getSuggestions

      @RequestMapping(value="/suggest", method=GET) @ResponseBody public SuggestionDataList getSuggestions(@RequestParam(required=true) String term, @RequestParam(required=true,defaultValue="10") int max)
      Web service handler for giving the auto complete suggestions as List
      Parameters:
      term - - the term that user inputs for search
      max - - the limit of the suggestions
      Returns:
      the list of auto suggestions
    • createReview

      @RequestMapping(value="/{code}/reviews", method=POST) @ResponseBody public ReviewData createReview(@PathVariable String code, javax.servlet.http.HttpServletRequest request) throws WebserviceValidationException
      Web service handler for the postReview call. Review will be posted as anonymous principal. Method uses HttpRequestReviewDataPopulator to populate review data from request parameters.

      There is no default validation for the posted value!

      Request Method: POST Sample Call: http://localhost:9001/rest/v1/{SITE}/products/{CODE}/review Request parameters:

      • rating (required)
      • headline
      • comment
      • alias
      Parameters:
      code - - the unique code used to identify a product
      request -
      Returns:
      the ReviewData DTO which will be marshaled to JSON or XML based on Accept-Header
      Throws:
      WebserviceValidationException
    • searchProductStockByLocation

      @RequestMapping(value="/{code}/nearLocation", method=GET) @ResponseBody public StoreFinderStockSearchPageData<ProductData> searchProductStockByLocation(@PathVariable String code, @RequestParam(required=true) String location, @RequestParam(required=false,defaultValue="0") int currentPage, @RequestParam(required=false,defaultValue="2147483647") int pageSize)
      Web service handler for searching product's stock level sorted by distance from specific location passed by the free-text parameter. Sample Call: http://localhost:9001/rest/v1/{SITE}/products/{CODE}/nearLocation
      Parameters:
      code - - the unique code used to identify a product
      location - - free-text location
      Returns:
      the StoreFinderStockSearchPageData of ProductData objects sorted by distance from location ascending
    • searchProductStockByLocationGeoCode

      @RequestMapping(value="/{code}/nearLatLong", method=GET) @ResponseBody public StoreFinderStockSearchPageData<ProductData> searchProductStockByLocationGeoCode(@PathVariable String code, @RequestParam(required=true) Double latitude, @RequestParam(required=true) Double longitude, @RequestParam(required=false,defaultValue="0") int currentPage, @RequestParam(required=false,defaultValue="2147483647") int pageSize)
      Web service handler for searching product's stock level sorted by distance from specific location passed by the free-text parameter. Sample Call: http://localhost:9001/rest/v1/{SITE}/products/{CODE}/nearLatLong
      Parameters:
      code - - the unique code used to identify a product
      latitude - - location's latitude
      longitude - - location's longitude
      Returns:
      the StoreFinderStockSearchPageData of ProductData objects sorted by distance from location ascending
    • createPageableData

      protected PageableData createPageableData(int currentPage, int pageSize)
    • createGeoPoint

      protected GeoPoint createGeoPoint(Double latitude, Double longitude)