Class ProductsController


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

      • ProductsController

        public ProductsController()
    • Method Detail

      • searchProducts

        @RequestMapping(method=GET)
        @ResponseBody
        public ProductSearchPageData<SearchStateData,​ProductData> searchProducts​(@RequestParam(required=false)
                                                                                       java.lang.String query,
                                                                                       @RequestParam(required=false,defaultValue="0")
                                                                                       int currentPage,
                                                                                       @RequestParam(required=false,defaultValue="20")
                                                                                       int pageSize,
                                                                                       @RequestParam(required=false)
                                                                                       java.lang.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
                                      java.lang.String baseSiteId,
                                      @PathVariable
                                      java.lang.String productCode,
                                      @RequestParam(required=true)
                                      java.lang.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")
                                              java.lang.String options,
                                              @RequestParam(required=false)
                                              java.lang.String catalog,
                                              @RequestParam(required=false)
                                              java.lang.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")
                                              java.lang.String options,
                                              @RequestParam(required=false)
                                              java.lang.String catalog,
                                              @RequestParam(required=false)
                                              java.lang.String version,
                                              @RequestParam
                                              java.lang.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
                                                             java.lang.String code,
                                                             @RequestParam(required=false,defaultValue="2147483647")
                                                             int pageSize,
                                                             @RequestParam(required=false,defaultValue="BASIC")
                                                             java.lang.String options,
                                                             @RequestParam
                                                             java.lang.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
                                                                 java.lang.String timestamp,
                                                                 @RequestParam(required=false)
                                                                 java.lang.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,
                                                java.util.List<java.lang.String> catalogInfo)
      • convertResultset

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

        protected java.util.Set<ProductOption> extractOptions​(java.lang.String options)
      • getProductByCode

        @RequestMapping(value="/{code}",
                        method=GET)
        @ResponseBody
        public ProductData getProductByCode​(@PathVariable
                                            java.lang.String code,
                                            @RequestParam(required=false,defaultValue="BASIC")
                                            java.lang.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)
                                                 java.lang.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
                                       java.lang.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
                                                                                        java.lang.String code,
                                                                                        @RequestParam(required=true)
                                                                                        java.lang.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
                                                                                               java.lang.String code,
                                                                                               @RequestParam(required=true)
                                                                                               java.lang.Double latitude,
                                                                                               @RequestParam(required=true)
                                                                                               java.lang.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​(java.lang.Double latitude,
                                          java.lang.Double longitude)