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 BaseControllerWeb Services Controller to expose the functionality of theProductFacadeand SearchFacade.
-
-
Field Summary
-
Fields inherited from class de.hybris.platform.ycommercewebservices.v1.controller.BaseController
DEFAULT_CURRENT_PAGE, DEFAULT_PAGE_SIZE
-
-
Constructor Summary
Constructors Constructor Description ProductsController()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ProductDataListconvertResultset(int page, int pageSize, java.lang.String catalog, java.lang.String version, ProductResultData modifiedProducts)protected GeoPointcreateGeoPoint(java.lang.Double latitude, java.lang.Double longitude)protected PageableDatacreatePageableData(int currentPage, int pageSize)ReviewDatacreateReview(java.lang.String code, javax.servlet.http.HttpServletRequest request)Web service handler for the postReview call.ProductReferencesDataexportProductReferences(java.lang.String code, int pageSize, java.lang.String options, java.lang.String referenceType)Web service handler for export product references.ProductDataListexportProducts(int currentPage, int pageSize, java.lang.String options, java.lang.String catalog, java.lang.String version)Web service handler for product export.ProductDataListexportProducts(int currentPage, int pageSize, java.lang.String options, java.lang.String catalog, java.lang.String version, java.lang.String timestamp)Web service handler for incremental product export.ProductExpressUpdateElementDataListexpressUpdate(java.lang.String timestamp, java.lang.String catalog)Web service handler for product express update.protected java.util.Set<ProductOption>extractOptions(java.lang.String options)protected voidfilterExpressUpdateQueue(ProductExpressUpdateElementDataList productExpressUpdateDataList, java.util.List<java.lang.String> catalogInfo)ProductDatagetProductByCode(java.lang.String code, java.lang.String options)Web service handler for the getProductByCode call.StockDatagetStockData(java.lang.String baseSiteId, java.lang.String productCode, java.lang.String storeName)Web service handler for getting stock level in a given store.
Sample Call: http://localhost:9001/rest/v1/:site/products/:code/stock?storeName=SuggestionDataListgetSuggestions(java.lang.String term, int max)Web service handler for giving the auto complete suggestions as ListProductSearchPageData<SearchStateData,ProductData>searchProducts(java.lang.String query, int currentPage, int pageSize, java.lang.String sort)Web service handler for search.StoreFinderStockSearchPageData<ProductData>searchProductStockByLocation(java.lang.String code, java.lang.String location, int currentPage, int pageSize)Web service handler for searching product's stock level sorted by distance from specific location passed by the free-text parameter.StoreFinderStockSearchPageData<ProductData>searchProductStockByLocationGeoCode(java.lang.String code, java.lang.Double latitude, java.lang.Double longitude, int currentPage, int pageSize)Web service handler for searching product's stock level sorted by distance from specific location passed by the free-text parameter.protected java.util.List<java.lang.String>validateAndSplitCatalog(java.lang.String catalog)-
Methods inherited from class de.hybris.platform.ycommercewebservices.v1.controller.BaseController
handleErrorInternal, handleModelNotFoundException, sanitize
-
-
-
-
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:facetValue2currentPage- the current result page requestedpageSize- the number of results returned per pagesort- 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, StockSystemExceptionWeb 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:
WebserviceValidationExceptionStockSystemException
-
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 Setand 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 ListpageSize- - number of Products which will be returned in each pageoptions- - 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 Setand 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 ListpageSize- - number of Products which will be returned in each pageoptions- - 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: %2Ccatalog- catalog from which get productsversion- version of catalogtimestamp- 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 Setand 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 codereferenceType- - reference type according to enum ProductReferenceTypeEnumpageSize- - number of Products which will be returned in each pageoptions- - 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 RequestParameterExceptionWeb 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 forHTTPSchannel.- Parameters:
timestamp- - time in ISO-8601 formatcatalog- - 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)
-
validateAndSplitCatalog
protected java.util.List<java.lang.String> validateAndSplitCatalog(java.lang.String catalog) throws RequestParameterException- Throws:
RequestParameterException
-
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 Setand 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 productoptions- - 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 searchmax- - 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 WebserviceValidationExceptionWeb service handler for the postReview call. Review will be posted as anonymous principal. Method usesHttpRequestReviewDataPopulatorto populate review data from request parameters. There is no default validation for the posted value! Request Method:POSTSample 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 productrequest-- 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 productlocation- - 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 productlatitude- - location's latitudelongitude- - 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)
-
-