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.-
Field Summary
Fields inherited from class de.hybris.platform.ycommercewebservices.v1.controller.BaseController
DEFAULT_CURRENT_PAGE, DEFAULT_PAGE_SIZE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ProductDataListconvertResultset(int page, int pageSize, String catalog, String version, ProductResultData modifiedProducts) protected GeoPointcreateGeoPoint(Double latitude, Double longitude) protected PageableDatacreatePageableData(int currentPage, int pageSize) createReview(String code, javax.servlet.http.HttpServletRequest request) Web service handler for the postReview call.exportProductReferences(String code, int pageSize, String options, String referenceType) Web service handler for export product references.exportProducts(int currentPage, int pageSize, String options, String catalog, String version) Web service handler for product export.exportProducts(int currentPage, int pageSize, String options, String catalog, String version, String timestamp) Web service handler for incremental product export.expressUpdate(String timestamp, String catalog) Web service handler for product express update.protected Set<ProductOption>extractOptions(String options) protected voidfilterExpressUpdateQueue(ProductExpressUpdateElementDataList productExpressUpdateDataList, List<String> catalogInfo) getProductByCode(String code, String options) Web service handler for the getProductByCode call.getStockData(String baseSiteId, String productCode, 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=getSuggestions(String term, int max) Web service handler for giving the auto complete suggestions as ListsearchProducts(String query, int currentPage, int pageSize, String sort) Web service handler for search.searchProductStockByLocation(String code, 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.searchProductStockByLocationGeoCode(String code, Double latitude, 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.validateAndSplitCatalog(String catalog) Methods inherited from class de.hybris.platform.ycommercewebservices.v1.controller.BaseController
handleErrorInternal, handleModelNotFoundException, sanitize
-
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: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 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:
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") 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 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") 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 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 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 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 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 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, List<String> catalogInfo) -
validateAndSplitCatalog
- Throws:
RequestParameterException
-
convertResultset
protected ProductDataList convertResultset(int page, int pageSize, String catalog, String version, ProductResultData modifiedProducts) -
extractOptions
-
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 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) 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 String code, javax.servlet.http.HttpServletRequest request) throws WebserviceValidationException Web 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 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 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 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 productlatitude- - location's latitudelongitude- - location's longitude- Returns:
- the StoreFinderStockSearchPageData of ProductData objects sorted by distance from location ascending
-
createPageableData
-
createGeoPoint
-