Class DefaultContextInformationLoader
java.lang.Object
de.hybris.platform.ycommercewebservices.context.impl.DefaultContextInformationLoader
- All Implemented Interfaces:
ContextInformationLoader
Default context information loader
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringgetRequestMapping(String queryString) protected String[]protected Collection<LanguageModel>getStoresLanguages(BaseStoreModel currentBaseStore) initializeSiteFromRequest(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 booleanisNotBaseSiteResource(String requestMapping) protected StringparseBaseSiteId(String requestMapping) protected voidrecalculateCart(String currencyString) Recalculates cart when currency has changedvoidsetActivateBaseSiteInSessionStrategy(ActivateBaseSiteInSessionStrategy activateBaseSiteInSessionStrategy) voidsetBaseSiteResourceExceptions(Set<String> baseSiteResourceExceptions) voidsetBaseSiteService(BaseSiteService baseSiteService) voidsetBaseStoreService(BaseStoreService baseStoreService) voidsetCalculationService(CalculationService calculationService) voidsetCartService(CartService cartService) voidsetCommerceCommonI18NService(CommerceCommonI18NService commerceCommonI18NService) voidsetCommonI18NService(CommonI18NService commonI18NService) voidsetConfigurationService(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) setLanguageFromRequest(javax.servlet.http.HttpServletRequest request) Method set current language base on information from request
-
Constructor Details
-
DefaultContextInformationLoader
public DefaultContextInformationLoader()
-
-
Method Details
-
setLanguageFromRequest
public LanguageModel setLanguageFromRequest(javax.servlet.http.HttpServletRequest request) throws UnsupportedLanguageException Description copied from interface:ContextInformationLoaderMethod set current language base on information from request- Specified by:
setLanguageFromRequestin interfaceContextInformationLoader- Parameters:
request- - request from which we should get language information- Returns:
- language set as current
- Throws:
UnsupportedLanguageException
-
getStoresLanguages
-
setCurrencyFromRequest
public CurrencyModel setCurrencyFromRequest(javax.servlet.http.HttpServletRequest request) throws UnsupportedCurrencyException, RecalculationException Description copied from interface:ContextInformationLoaderMethod set current currency based on information from request and recalculate cart for current session- Specified by:
setCurrencyFromRequestin interfaceContextInformationLoader- Parameters:
request- - request from which we should get currency information- Returns:
- currency set as current
- Throws:
UnsupportedCurrencyExceptionRecalculationException
-
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 interfaceContextInformationLoader- Parameters:
request- - request from which we should get base site uid- Returns:
- baseSite set as current site or null
- Throws:
InvalidResourceException
-
getRequestMapping
-
isNotBaseSiteResource
-
parseBaseSiteId
-
getSpecialUrlCharacters
-
setCurrentBaseSite
-
getConfigurationService
-
setConfigurationService
-
getBaseSiteResourceExceptions
-
setBaseSiteResourceExceptions
-
getBaseSiteService
-
setBaseSiteService
-
getActivateBaseSiteInSessionStrategy
-
setActivateBaseSiteInSessionStrategy
public void setActivateBaseSiteInSessionStrategy(ActivateBaseSiteInSessionStrategy activateBaseSiteInSessionStrategy) -
getCommonI18NService
-
setCommonI18NService
-
getCommerceCommonI18NService
-
setCommerceCommonI18NService
-
getBaseStoreService
-
setBaseStoreService
-
getCartService
-
setCartService
-
getCalculationService
-
setCalculationService
-