Class DefaultContextInformationLoader
- java.lang.Object
-
- de.hybris.platform.ycommercewebservices.context.impl.DefaultContextInformationLoader
-
- All Implemented Interfaces:
ContextInformationLoader
public class DefaultContextInformationLoader extends java.lang.Object implements ContextInformationLoader
Default context information loader
-
-
Constructor Summary
Constructors Constructor Description DefaultContextInformationLoader()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ActivateBaseSiteInSessionStrategygetActivateBaseSiteInSessionStrategy()java.util.Set<java.lang.String>getBaseSiteResourceExceptions()BaseSiteServicegetBaseSiteService()BaseStoreServicegetBaseStoreService()CalculationServicegetCalculationService()CartServicegetCartService()CommerceCommonI18NServicegetCommerceCommonI18NService()CommonI18NServicegetCommonI18NService()ConfigurationServicegetConfigurationService()protected java.lang.StringgetRequestMapping(java.lang.String queryString)protected java.lang.String[]getSpecialUrlCharacters()protected java.util.Collection<LanguageModel>getStoresLanguages(BaseStoreModel currentBaseStore)BaseSiteModelinitializeSiteFromRequest(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.
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.protected booleanisNotBaseSiteResource(java.lang.String requestMapping)protected java.lang.StringparseBaseSiteId(java.lang.String requestMapping)protected voidrecalculateCart(java.lang.String currencyString)Recalculates cart when currency has changedvoidsetActivateBaseSiteInSessionStrategy(ActivateBaseSiteInSessionStrategy activateBaseSiteInSessionStrategy)voidsetBaseSiteResourceExceptions(java.util.Set<java.lang.String> baseSiteResourceExceptions)voidsetBaseSiteService(BaseSiteService baseSiteService)voidsetBaseStoreService(BaseStoreService baseStoreService)voidsetCalculationService(CalculationService calculationService)voidsetCartService(CartService cartService)voidsetCommerceCommonI18NService(CommerceCommonI18NService commerceCommonI18NService)voidsetCommonI18NService(CommonI18NService commonI18NService)voidsetConfigurationService(ConfigurationService configurationService)CurrencyModelsetCurrencyFromRequest(javax.servlet.http.HttpServletRequest request)Method set current currency based on information from request and recalculate cart for current sessionprotected voidsetCurrentBaseSite(BaseSiteModel baseSiteModel)LanguageModelsetLanguageFromRequest(javax.servlet.http.HttpServletRequest request)Method set current language base on information from request
-
-
-
Method Detail
-
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
protected java.util.Collection<LanguageModel> getStoresLanguages(BaseStoreModel currentBaseStore)
-
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
protected void recalculateCart(java.lang.String currencyString) throws RecalculationExceptionRecalculates 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 throwInvalidResourceExceptionif 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
protected java.lang.String getRequestMapping(java.lang.String queryString)
-
isNotBaseSiteResource
protected boolean isNotBaseSiteResource(java.lang.String requestMapping)
-
parseBaseSiteId
protected java.lang.String parseBaseSiteId(java.lang.String requestMapping)
-
getSpecialUrlCharacters
protected java.lang.String[] getSpecialUrlCharacters()
-
setCurrentBaseSite
protected void setCurrentBaseSite(BaseSiteModel baseSiteModel)
-
getConfigurationService
public ConfigurationService getConfigurationService()
-
setConfigurationService
public void setConfigurationService(ConfigurationService configurationService)
-
getBaseSiteResourceExceptions
public java.util.Set<java.lang.String> getBaseSiteResourceExceptions()
-
setBaseSiteResourceExceptions
public void setBaseSiteResourceExceptions(java.util.Set<java.lang.String> baseSiteResourceExceptions)
-
getBaseSiteService
public BaseSiteService getBaseSiteService()
-
setBaseSiteService
public void setBaseSiteService(BaseSiteService baseSiteService)
-
getActivateBaseSiteInSessionStrategy
public ActivateBaseSiteInSessionStrategy getActivateBaseSiteInSessionStrategy()
-
setActivateBaseSiteInSessionStrategy
public void setActivateBaseSiteInSessionStrategy(ActivateBaseSiteInSessionStrategy activateBaseSiteInSessionStrategy)
-
getCommonI18NService
public CommonI18NService getCommonI18NService()
-
setCommonI18NService
public void setCommonI18NService(CommonI18NService commonI18NService)
-
getCommerceCommonI18NService
public CommerceCommonI18NService getCommerceCommonI18NService()
-
setCommerceCommonI18NService
public void setCommerceCommonI18NService(CommerceCommonI18NService commerceCommonI18NService)
-
getBaseStoreService
public BaseStoreService getBaseStoreService()
-
setBaseStoreService
public void setBaseStoreService(BaseStoreService baseStoreService)
-
getCartService
public CartService getCartService()
-
setCartService
public void setCartService(CartService cartService)
-
getCalculationService
public CalculationService getCalculationService()
-
setCalculationService
public void setCalculationService(CalculationService calculationService)
-
-