Class DefaultTravelWsContextInformationLoaderV2

java.lang.Object
de.hybris.platform.coretravelcommonsocc.context.impl.DefaultTravelWsContextInformationLoaderV2
All Implemented Interfaces:
TravelContextInformationLoader

public class DefaultTravelWsContextInformationLoaderV2 extends Object implements TravelContextInformationLoader
Default context information loader
  • Constructor Details

    • DefaultTravelWsContextInformationLoaderV2

      public DefaultTravelWsContextInformationLoaderV2()
  • Method Details

    • setLanguageFromRequest

      public LanguageModel setLanguageFromRequest(javax.servlet.http.HttpServletRequest request) throws UnsupportedLanguageWsException
      This method sets the locale language from Accept-Language in the Request Header. Examples of Accept-Language syntax: Accept-Language: de Accept-Language: de-CH Accept-Language: en-US,en;q=0.5 Accept-Language: fr-CH, fr;q=0.9, en;q=0.8, de;q=0.7, *;q=0.5 (Multiple types, weighted with the quality value syntax)
      Specified by:
      setLanguageFromRequest in interface TravelContextInformationLoader
      Parameters:
      request - the request from which we should get language information
      Returns:
      the language to be set in the system
      Throws:
      UnsupportedLanguageWsException
    • getStoresLanguages

      protected Collection<LanguageModel> getStoresLanguages(BaseStoreModel currentBaseStore)
      Gets the stores languages from the base store
      Parameters:
      currentBaseStore -
      Returns:
    • setCurrencyFromRequest

      public CurrencyModel setCurrencyFromRequest(javax.servlet.http.HttpServletRequest request) throws UnsupportedCurrencyWsException, RecalculationException
      Description copied from interface: TravelContextInformationLoader
      Method set current currency based on information from request and recalculate cart for current session
      Specified by:
      setCurrencyFromRequest in interface TravelContextInformationLoader
      Parameters:
      request - - request from which we should get currency information
      Returns:
      currency set as current
      Throws:
      UnsupportedCurrencyWsException
      RecalculationException
    • recalculateCart

      protected void recalculateCart(String currencyString) throws RecalculationException
      Recalculates cart when currency has changed
      Throws:
      RecalculationException
    • initializeSiteFromRequest

      public BaseSiteModel initializeSiteFromRequest(javax.servlet.http.HttpServletRequest request) throws InvalidResourceException
      Method resolves base site uid from request URL and set it as current site i.e
      /rest/v1/mysite/cart, or
      /rest/v1/mysite/customers/current
      would try to set base site with uid=mysite as a current site.

      One should define the path which is expected to be before the site resource in the project properties file (commercewebservices.rootcontext).
      Default and fallback value equals to /rest/v1/

      Method uses also a comma separated list of url special characters that are used to parse the site id resource. You can reconfigure it in properties file (commercewebservices.url.special.characters). The default and fallback value is equal to "?,/".

      Method will throw InvalidResourceException if it fails to find the site which is in the resource url.
      However, you can configure exceptions that doesn't require the site mapping in the resource path. You can configure them in a spring bean called 'baseFilterResourceExceptions'.

      Specified by:
      initializeSiteFromRequest in interface TravelContextInformationLoader
      Parameters:
      request - - request from which we should get base site uid
      Returns:
      baseSite set as current site or null
      Throws:
      InvalidResourceException
    • getRequestMapping

      protected String getRequestMapping(String queryString)
      get the request mapping from the input
      Parameters:
      queryString -
      Returns:
    • isNotBaseSiteResource

      protected boolean isNotBaseSiteResource(String requestMapping)
      validates the input for baseSite resource exception
      Parameters:
      requestMapping -
      Returns:
    • parseBaseSiteId

      protected String parseBaseSiteId(String requestMapping)
      get the baseSiteId from the request mapping
      Parameters:
      requestMapping -
      Returns:
    • getSpecialUrlCharacters

      protected String[] getSpecialUrlCharacters()
      get the special url characters from the configuration
      Returns:
    • setCurrentBaseSite

      protected void setCurrentBaseSite(BaseSiteModel baseSiteModel)
      sets the given bases site in the session
      Parameters:
      baseSiteModel -
    • isExcludedURL

      protected boolean isExcludedURL(String path)
      This method check whether the given path is part of excluded url as configured in the properties file.
      Parameters:
      path -
      Returns:
    • getExcludedUrls

      protected String[] getExcludedUrls()
    • getConfigurationService

      public de.hybris.platform.servicelayer.config.ConfigurationService getConfigurationService()
      Gets configurationService.
      Returns:
      the configuration service
    • setConfigurationService

      public void setConfigurationService(de.hybris.platform.servicelayer.config.ConfigurationService configurationService)
    • getBaseSiteResourceExceptions

      public Set<String> getBaseSiteResourceExceptions()
      Gets baseSiteResourceExceptions.
      Returns:
      the base Site Resource Exceptions
    • setBaseSiteResourceExceptions

      public void setBaseSiteResourceExceptions(Set<String> baseSiteResourceExceptions)
    • getBaseSiteService

      public de.hybris.platform.site.BaseSiteService getBaseSiteService()
      Gets baseSiteService.
      Returns:
      the base site Service
    • setBaseSiteService

      public void setBaseSiteService(de.hybris.platform.site.BaseSiteService baseSiteService)
      Sets the base Site Service
      Parameters:
      baseSiteService -
    • getActivateBaseSiteInSessionStrategy

      public de.hybris.platform.basecommerce.strategies.ActivateBaseSiteInSessionStrategy getActivateBaseSiteInSessionStrategy()
    • setActivateBaseSiteInSessionStrategy

      public void setActivateBaseSiteInSessionStrategy(de.hybris.platform.basecommerce.strategies.ActivateBaseSiteInSessionStrategy activateBaseSiteInSessionStrategy)
      Sets the activate BaseSite In SessionStrategy
      Parameters:
      activateBaseSiteInSessionStrategy -
    • getCommonI18NService

      public de.hybris.platform.servicelayer.i18n.CommonI18NService getCommonI18NService()
      Gets commonI18NService.
      Returns:
      the commonI18NService
    • setCommonI18NService

      public void setCommonI18NService(de.hybris.platform.servicelayer.i18n.CommonI18NService commonI18NService)
      Sets the common I18N Service
      Parameters:
      commonI18NService -
    • getCommerceCommonI18NService

      public de.hybris.platform.commerceservices.i18n.CommerceCommonI18NService getCommerceCommonI18NService()
      Gets commerceCommonI18NService.
      Returns:
      the commerce Common I18NService
    • setCommerceCommonI18NService

      public void setCommerceCommonI18NService(de.hybris.platform.commerceservices.i18n.CommerceCommonI18NService commerceCommonI18NService)
      Sets the commerce Common I18N Service
      Parameters:
      commerceCommonI18NService -
    • getBaseStoreService

      public de.hybris.platform.store.services.BaseStoreService getBaseStoreService()
      Gets baseStoreService.
      Returns:
      the base Store Service
    • setBaseStoreService

      public void setBaseStoreService(de.hybris.platform.store.services.BaseStoreService baseStoreService)
      Sets the base Store Service
      Parameters:
      baseStoreService -
    • getCartService

      public de.hybris.platform.order.CartService getCartService()
      Gets cartService.
      Returns:
      the cart service
    • setCartService

      public void setCartService(de.hybris.platform.order.CartService cartService)
      Sets the cart service
      Parameters:
      cartService -
    • getCalculationService

      public de.hybris.platform.order.CalculationService getCalculationService()
      geta the calculation service
      Returns:
      calculationService
    • setCalculationService

      public void setCalculationService(de.hybris.platform.order.CalculationService calculationService)
      Sets the calculationService
      Parameters:
      calculationService -
    • getErrorCodeResolver

      protected ErrorCodeResolver getErrorCodeResolver()
      Gets error code resolver.
      Returns:
      the error code resolver
    • setErrorCodeResolver

      public void setErrorCodeResolver(ErrorCodeResolver errorCodeResolver)
      Sets error code resolver.
      Parameters:
      errorCodeResolver - the error code resolver