com.elasticpath.sfweb.ajax.service.impl
Class ShoppingCartAjaxControllerImpl

java.lang.Object
  extended by com.elasticpath.sfweb.ajax.service.impl.ShoppingCartAjaxControllerImpl
All Implemented Interfaces:
ShoppingCartAjaxController

public class ShoppingCartAjaxControllerImpl
extends java.lang.Object
implements ShoppingCartAjaxController

The default implementation of the ShoppingCartAjaxController.


Constructor Summary
ShoppingCartAjaxControllerImpl()
           
 
Method Summary
 ShoppingCart calculateForSelectedShippingServiceLevel(long selectedShippingServiceLevelUid, javax.servlet.http.HttpServletRequest request)
          Calculate shopping cart with the selected shipping service level.
 ShoppingCartBean calculateShipping(long selectedShippingServiceLevelUid, javax.servlet.http.HttpServletRequest request)
          Calculate shopping cart with the selected shipping service level.
 ShoppingCart changeEstimationAddress(javax.servlet.http.HttpServletRequest request)
          Prepare to reset the address for shipping/taxed.
 ShoppingCart estimateShippingAndTaxes(java.lang.String countryCode, java.lang.String subCountryCode, java.lang.String zipOrPostalCode, java.util.List cartItemQtyList, javax.servlet.http.HttpServletRequest request)
          Estimate the shipping options and taxes for the session shopping cart, based on the given countryCode, subCountryCode and zipOrPostalCode.
 ShoppingCart getCart(javax.servlet.http.HttpServletRequest request)
          Method for retreiving the shopping cart through dwr.
 ShoppingCartBean getCartBean(javax.servlet.http.HttpServletRequest request)
          Retrieve the ShoppingCartBean wrapper.
 java.util.List getCartItemPrices(javax.servlet.http.HttpServletRequest request)
          Retieve the INDEPENDENT shopping cart item prices.
 java.lang.String getEstimateAddressStr(javax.servlet.http.HttpServletRequest request)
          Return the string representation of the address bits entered for shipping and tax estimation.
 ShoppingCartBean removeCartItem(long itemUid, javax.servlet.http.HttpServletRequest request)
          Remove an item from the cart.
 void setCheckoutService(CheckoutService checkoutService)
          Set the checkout service for processing a checkout.
 void setOnePageHelper(OnePageHelper onePageHelper)
           
 void setProductService(ProductService productService)
           
 ShoppingCartBean setPromotionCode(java.lang.String promotionCode, javax.servlet.http.HttpServletRequest request)
          Attempts to apply a given promotion code to the shopping cart.
 void setRequestHelper(RequestHelper requestHelper)
          Set the request helper.
 ShoppingCartBean setShippingServiceLevel(long selectedShippingServiceLevelUid, javax.servlet.http.HttpServletRequest request)
          Calculate shopping cart with the selected shipping service level.
 void setShoppingCartService(ShoppingCartService shoppingCartService)
          Sets the shopping cart service.
 ShoppingCartBean updateCartItemById(long uidPk, java.lang.String guid, int quantity, javax.servlet.http.HttpServletRequest request)
          Handles validation of cart item, such as inventory checks, for dwr before updating.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShoppingCartAjaxControllerImpl

public ShoppingCartAjaxControllerImpl()
Method Detail

calculateForSelectedShippingServiceLevel

public ShoppingCart calculateForSelectedShippingServiceLevel(long selectedShippingServiceLevelUid,
                                                             javax.servlet.http.HttpServletRequest request)
Calculate shopping cart with the selected shipping service level.

Specified by:
calculateForSelectedShippingServiceLevel in interface ShoppingCartAjaxController
Parameters:
selectedShippingServiceLevelUid - - the uid of the selected shipping service level.
request - - the current HttpServletRequest.
Returns:
the update shopping cart.

calculateShipping

public ShoppingCartBean calculateShipping(long selectedShippingServiceLevelUid,
                                          javax.servlet.http.HttpServletRequest request)
Calculate shopping cart with the selected shipping service level.

Specified by:
calculateShipping in interface ShoppingCartAjaxController
Parameters:
selectedShippingServiceLevelUid - - the uid of the selected shipping service level.
request - - the current HttpServletRequest.
Returns:
the updated ShoppingCartBean.

changeEstimationAddress

public ShoppingCart changeEstimationAddress(javax.servlet.http.HttpServletRequest request)
Prepare to reset the address for shipping/taxed.

Specified by:
changeEstimationAddress in interface ShoppingCartAjaxController
Parameters:
request - - the current HttpServletRequest.
Returns:
the updated shopping cart.

estimateShippingAndTaxes

public ShoppingCart estimateShippingAndTaxes(java.lang.String countryCode,
                                             java.lang.String subCountryCode,
                                             java.lang.String zipOrPostalCode,
                                             java.util.List cartItemQtyList,
                                             javax.servlet.http.HttpServletRequest request)
Estimate the shipping options and taxes for the session shopping cart, based on the given countryCode, subCountryCode and zipOrPostalCode. The session shopping cart shoud be updated afterwards.

Specified by:
estimateShippingAndTaxes in interface ShoppingCartAjaxController
Parameters:
countryCode - - the selected country code for the shipping options and taxes estimation.
subCountryCode - - the selected subCountry code for the shipping options and taxes estimation.
zipOrPostalCode - - the zip or postal code for the shipping options and taxes estimation.
cartItemQtyList - - the list of cart item qty.
request - - the current HttpServletRequest.
Returns:
the update shopping cart.

getCart

public ShoppingCart getCart(javax.servlet.http.HttpServletRequest request)
Method for retreiving the shopping cart through dwr.

Specified by:
getCart in interface ShoppingCartAjaxController
Parameters:
request - the current request (filled in automatically by dwr)
Returns:
the shopping cart object

getCartBean

public ShoppingCartBean getCartBean(javax.servlet.http.HttpServletRequest request)
Retrieve the ShoppingCartBean wrapper.

Specified by:
getCartBean in interface ShoppingCartAjaxController
Parameters:
request - the current HttpServletRequest
Returns:
the ShoppingCartBean wrapper object

getCartItemPrices

public java.util.List getCartItemPrices(javax.servlet.http.HttpServletRequest request)
Retieve the INDEPENDENT shopping cart item prices.

Specified by:
getCartItemPrices in interface ShoppingCartAjaxController
Parameters:
request - - the current HttpServletRequest.
Returns:
the list of cart item prices.

getEstimateAddressStr

public java.lang.String getEstimateAddressStr(javax.servlet.http.HttpServletRequest request)
Return the string representation of the address bits entered for shipping and tax estimation.

Specified by:
getEstimateAddressStr in interface ShoppingCartAjaxController
Parameters:
request - - the current HttpServletRequest.
Returns:
the string representation of the address.

removeCartItem

public ShoppingCartBean removeCartItem(long itemUid,
                                       javax.servlet.http.HttpServletRequest request)
Remove an item from the cart.

Specified by:
removeCartItem in interface ShoppingCartAjaxController
Parameters:
itemUid - the uidPk of the CartItem to remove
request - the current HttpServletRequest
Returns:
the updated ShoppingCartBean object

setCheckoutService

public void setCheckoutService(CheckoutService checkoutService)
Set the checkout service for processing a checkout.

Specified by:
setCheckoutService in interface ShoppingCartAjaxController
Parameters:
checkoutService - the checkout service

setOnePageHelper

public void setOnePageHelper(OnePageHelper onePageHelper)
Specified by:
setOnePageHelper in interface ShoppingCartAjaxController
Parameters:
onePageHelper - the onePageHelper to set

setProductService

public void setProductService(ProductService productService)
Specified by:
setProductService in interface ShoppingCartAjaxController
Parameters:
productService - the productService to set

setPromotionCode

public ShoppingCartBean setPromotionCode(java.lang.String promotionCode,
                                         javax.servlet.http.HttpServletRequest request)
                                  throws DwrValidationException
Attempts to apply a given promotion code to the shopping cart.

Specified by:
setPromotionCode in interface ShoppingCartAjaxController
Parameters:
promotionCode - the promotion code to apply
request - the current HttpServletRequest
Returns:
the updated ShoppingCartBean object
Throws:
DwrValidationException - if the promotion code is not accepted

setRequestHelper

public void setRequestHelper(RequestHelper requestHelper)
Set the request helper.

Specified by:
setRequestHelper in interface ShoppingCartAjaxController
Parameters:
requestHelper - the request helper.

setShippingServiceLevel

public ShoppingCartBean setShippingServiceLevel(long selectedShippingServiceLevelUid,
                                                javax.servlet.http.HttpServletRequest request)
Calculate shopping cart with the selected shipping service level.

Specified by:
setShippingServiceLevel in interface ShoppingCartAjaxController
Parameters:
selectedShippingServiceLevelUid - - the uid of the selected shipping service level.
request - - the current HttpServletRequest.
Returns:
the updated shopping cart ajax bean.

setShoppingCartService

public void setShoppingCartService(ShoppingCartService shoppingCartService)
Sets the shopping cart service.

Parameters:
shoppingCartService - the shopping cart service

updateCartItemById

public ShoppingCartBean updateCartItemById(long uidPk,
                                           java.lang.String guid,
                                           int quantity,
                                           javax.servlet.http.HttpServletRequest request)
                                    throws DwrValidationException
Handles validation of cart item, such as inventory checks, for dwr before updating.

Specified by:
updateCartItemById in interface ShoppingCartAjaxController
Parameters:
uidPk - the id of the cart item
guid - the guid of the product sku
quantity - the new quantity
request - the current request (filled in automatically by dwr)
Returns:
the updated ShoppingCart object and cart items wrapped in a ShoppingCartBean object
Throws:
DwrValidationException - the map of field names to error messages