Class DefaultTmaContextInformationLoader
- java.lang.Object
-
- de.hybris.platform.b2ctelcowebservices.context.impl.DefaultTmaContextInformationLoader
-
- All Implemented Interfaces:
TmaContextInformationLoader
public class DefaultTmaContextInformationLoader extends java.lang.Object implements TmaContextInformationLoader
Default context information loader- Since:
- 1810
-
-
Constructor Summary
Constructors Constructor Description DefaultTmaContextInformationLoader()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description de.hybris.platform.basecommerce.strategies.ActivateBaseSiteInSessionStrategygetActivateBaseSiteInSessionStrategy()java.util.Set<java.lang.String>getBaseSiteResourceExceptions()de.hybris.platform.site.BaseSiteServicegetBaseSiteService()de.hybris.platform.store.services.BaseStoreServicegetBaseStoreService()de.hybris.platform.order.CalculationServicegetCalculationService()de.hybris.platform.order.CartServicegetCartService()de.hybris.platform.commerceservices.i18n.CommerceCommonI18NServicegetCommerceCommonI18NService()de.hybris.platform.servicelayer.i18n.CommonI18NServicegetCommonI18NService()de.hybris.platform.servicelayer.config.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(de.hybris.platform.basecommerce.strategies.ActivateBaseSiteInSessionStrategy activateBaseSiteInSessionStrategy)voidsetBaseSiteResourceExceptions(java.util.Set<java.lang.String> baseSiteResourceExceptions)voidsetBaseSiteService(de.hybris.platform.site.BaseSiteService baseSiteService)voidsetBaseStoreService(de.hybris.platform.store.services.BaseStoreService baseStoreService)voidsetCalculationService(de.hybris.platform.order.CalculationService calculationService)voidsetCartService(de.hybris.platform.order.CartService cartService)voidsetCommerceCommonI18NService(de.hybris.platform.commerceservices.i18n.CommerceCommonI18NService commerceCommonI18NService)voidsetCommonI18NService(de.hybris.platform.servicelayer.i18n.CommonI18NService commonI18NService)voidsetConfigurationService(de.hybris.platform.servicelayer.config.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 TmaUnsupportedLanguageException
Description copied from interface:TmaContextInformationLoaderMethod set current language base on information from request- Specified by:
setLanguageFromRequestin interfaceTmaContextInformationLoader- Parameters:
request- - request from which we should get language information- Returns:
- language set as current
- Throws:
TmaUnsupportedLanguageException
-
getStoresLanguages
protected java.util.Collection<LanguageModel> getStoresLanguages(BaseStoreModel currentBaseStore)
-
setCurrencyFromRequest
public CurrencyModel setCurrencyFromRequest(javax.servlet.http.HttpServletRequest request) throws TmaUnsupportedCurrencyException, TmaRecalculationException
Description copied from interface:TmaContextInformationLoaderMethod set current currency based on information from request and recalculate cart for current session- Specified by:
setCurrencyFromRequestin interfaceTmaContextInformationLoader- Parameters:
request- - request from which we should get currency information- Returns:
- currency set as current
- Throws:
TmaUnsupportedCurrencyExceptionTmaRecalculationException
-
recalculateCart
protected void recalculateCart(java.lang.String currencyString) throws TmaRecalculationExceptionRecalculates cart when currency has changed- Throws:
TmaRecalculationException
-
initializeSiteFromRequest
public BaseSiteModel initializeSiteFromRequest(javax.servlet.http.HttpServletRequest request) throws TmaInvalidResourceException
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 interfaceTmaContextInformationLoader- Parameters:
request- - request from which we should get base site uid- Returns:
- baseSite set as current site or null
- Throws:
InvalidResourceExceptionTmaInvalidResourceException
-
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 de.hybris.platform.servicelayer.config.ConfigurationService getConfigurationService()
-
setConfigurationService
public void setConfigurationService(de.hybris.platform.servicelayer.config.ConfigurationService configurationService)
-
getBaseSiteResourceExceptions
public java.util.Set<java.lang.String> getBaseSiteResourceExceptions()
-
setBaseSiteResourceExceptions
public void setBaseSiteResourceExceptions(java.util.Set<java.lang.String> baseSiteResourceExceptions)
-
getBaseSiteService
public de.hybris.platform.site.BaseSiteService getBaseSiteService()
-
setBaseSiteService
public void setBaseSiteService(de.hybris.platform.site.BaseSiteService baseSiteService)
-
getActivateBaseSiteInSessionStrategy
public de.hybris.platform.basecommerce.strategies.ActivateBaseSiteInSessionStrategy getActivateBaseSiteInSessionStrategy()
-
setActivateBaseSiteInSessionStrategy
public void setActivateBaseSiteInSessionStrategy(de.hybris.platform.basecommerce.strategies.ActivateBaseSiteInSessionStrategy activateBaseSiteInSessionStrategy)
-
getCommonI18NService
public de.hybris.platform.servicelayer.i18n.CommonI18NService getCommonI18NService()
-
setCommonI18NService
public void setCommonI18NService(de.hybris.platform.servicelayer.i18n.CommonI18NService commonI18NService)
-
getCommerceCommonI18NService
public de.hybris.platform.commerceservices.i18n.CommerceCommonI18NService getCommerceCommonI18NService()
-
setCommerceCommonI18NService
public void setCommerceCommonI18NService(de.hybris.platform.commerceservices.i18n.CommerceCommonI18NService commerceCommonI18NService)
-
getBaseStoreService
public de.hybris.platform.store.services.BaseStoreService getBaseStoreService()
-
setBaseStoreService
public void setBaseStoreService(de.hybris.platform.store.services.BaseStoreService baseStoreService)
-
getCartService
public de.hybris.platform.order.CartService getCartService()
-
setCartService
public void setCartService(de.hybris.platform.order.CartService cartService)
-
getCalculationService
public de.hybris.platform.order.CalculationService getCalculationService()
-
setCalculationService
public void setCalculationService(de.hybris.platform.order.CalculationService calculationService)
-
-