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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionde.hybris.platform.basecommerce.strategies.ActivateBaseSiteInSessionStrategyGets baseSiteResourceExceptions.de.hybris.platform.site.BaseSiteServiceGets baseSiteService.de.hybris.platform.store.services.BaseStoreServiceGets baseStoreService.de.hybris.platform.order.CalculationServicegeta the calculation servicede.hybris.platform.order.CartServiceGets cartService.de.hybris.platform.commerceservices.i18n.CommerceCommonI18NServiceGets commerceCommonI18NService.de.hybris.platform.servicelayer.i18n.CommonI18NServiceGets commonI18NService.de.hybris.platform.servicelayer.config.ConfigurationServiceGets configurationService.protected ErrorCodeResolverGets error code resolver.protected String[]protected StringgetRequestMapping(String queryString) get the request mapping from the inputprotected String[]get the special url characters from the configurationprotected Collection<LanguageModel>getStoresLanguages(BaseStoreModel currentBaseStore) Gets the stores languages from the base storeinitializeSiteFromRequest(javax.servlet.http.HttpServletRequest request) 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.protected booleanisExcludedURL(String path) This method check whether the given path is part of excluded url as configured in the properties file.protected booleanisNotBaseSiteResource(String requestMapping) validates the input for baseSite resource exceptionprotected StringparseBaseSiteId(String requestMapping) get the baseSiteId from the request mappingprotected voidrecalculateCart(String currencyString) Recalculates cart when currency has changedvoidsetActivateBaseSiteInSessionStrategy(de.hybris.platform.basecommerce.strategies.ActivateBaseSiteInSessionStrategy activateBaseSiteInSessionStrategy) Sets the activate BaseSite In SessionStrategyvoidsetBaseSiteResourceExceptions(Set<String> baseSiteResourceExceptions) voidsetBaseSiteService(de.hybris.platform.site.BaseSiteService baseSiteService) Sets the base Site ServicevoidsetBaseStoreService(de.hybris.platform.store.services.BaseStoreService baseStoreService) Sets the base Store ServicevoidsetCalculationService(de.hybris.platform.order.CalculationService calculationService) Sets the calculationServicevoidsetCartService(de.hybris.platform.order.CartService cartService) Sets the cart servicevoidsetCommerceCommonI18NService(de.hybris.platform.commerceservices.i18n.CommerceCommonI18NService commerceCommonI18NService) Sets the commerce Common I18N ServicevoidsetCommonI18NService(de.hybris.platform.servicelayer.i18n.CommonI18NService commonI18NService) Sets the common I18N ServicevoidsetConfigurationService(de.hybris.platform.servicelayer.config.ConfigurationService configurationService) setCurrencyFromRequest(javax.servlet.http.HttpServletRequest request) Method set current currency based on information from request and recalculate cart for current sessionprotected voidsetCurrentBaseSite(BaseSiteModel baseSiteModel) sets the given bases site in the sessionvoidsetErrorCodeResolver(ErrorCodeResolver errorCodeResolver) Sets error code resolver.setLanguageFromRequest(javax.servlet.http.HttpServletRequest request) This method sets the locale language from Accept-Language in the Request Header.
-
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:
setLanguageFromRequestin interfaceTravelContextInformationLoader- Parameters:
request- the request from which we should get language information- Returns:
- the language to be set in the system
- Throws:
UnsupportedLanguageWsException
-
getStoresLanguages
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:TravelContextInformationLoaderMethod set current currency based on information from request and recalculate cart for current session- Specified by:
setCurrencyFromRequestin interfaceTravelContextInformationLoader- Parameters:
request- - request from which we should get currency information- Returns:
- currency set as current
- Throws:
UnsupportedCurrencyWsExceptionRecalculationException
-
recalculateCart
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
InvalidResourceExceptionif 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:
initializeSiteFromRequestin interfaceTravelContextInformationLoader- Parameters:
request- - request from which we should get base site uid- Returns:
- baseSite set as current site or null
- Throws:
InvalidResourceException
-
getRequestMapping
get the request mapping from the input- Parameters:
queryString-- Returns:
-
isNotBaseSiteResource
validates the input for baseSite resource exception- Parameters:
requestMapping-- Returns:
-
parseBaseSiteId
get the baseSiteId from the request mapping- Parameters:
requestMapping-- Returns:
-
getSpecialUrlCharacters
get the special url characters from the configuration- Returns:
-
setCurrentBaseSite
sets the given bases site in the session- Parameters:
baseSiteModel-
-
isExcludedURL
This method check whether the given path is part of excluded url as configured in the properties file.- Parameters:
path-- Returns:
-
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
Gets baseSiteResourceExceptions.- Returns:
- the base Site Resource Exceptions
-
setBaseSiteResourceExceptions
-
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
Gets error code resolver.- Returns:
- the error code resolver
-
setErrorCodeResolver
Sets error code resolver.- Parameters:
errorCodeResolver- the error code resolver
-