Class CMSSiteFilter
- java.lang.Object
-
- org.springframework.web.filter.GenericFilterBean
-
- org.springframework.web.filter.OncePerRequestFilter
-
- de.hybris.platform.yacceleratorstorefront.filters.cms.CMSSiteFilter
-
- All Implemented Interfaces:
CMSFilter,javax.servlet.Filter,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.InitializingBean,org.springframework.context.EnvironmentAware,org.springframework.core.env.EnvironmentCapable,org.springframework.web.context.ServletContextAware
public class CMSSiteFilter extends org.springframework.web.filter.OncePerRequestFilter implements CMSFilter
Responsible for setting up application - to main responsibility belongs:- Matches current site by current URL
- Setting current site in session (through
CMSSiteService) - Setting current catalog version (through
CMSSiteService) - Setting session catalog versions (through
CatalogService)
Note: In former versions (i.e. 4.1.1 and earlier) as a preview mechanism we usedde.hybris.platform.cms2.misc.AbstractPreviewServletwhich actually is obsolete. All necessary logic was adapted and moved here. This is a spring configured filter that is executed by the PlatformFilterChain.
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringINCORRECT_CMS_SITE_CHANNEL_ERROR_MESSAGEprotected static java.lang.StringMISSING_CMS_SITE_ERROR_MESSAGEprotected static intMISSING_CMS_SITE_ERROR_STATUS-
Fields inherited from class org.springframework.web.filter.OncePerRequestFilter
ALREADY_FILTERED_SUFFIX
-
Fields inherited from interface de.hybris.platform.cms2.misc.CMSFilter
CLEAR_CMSSITE_PARAM, PREVIEW_TICKET_ID_PARAM, PREVIEW_TOKEN
-
-
Constructor Summary
Constructors Constructor Description CMSSiteFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoFilterInternal(javax.servlet.http.HttpServletRequest httpRequest, javax.servlet.http.HttpServletResponse httpResponse, javax.servlet.FilterChain filterChain)protected LanguageModelfilterPreviewLanguageForSite(javax.servlet.http.HttpServletRequest httpRequest, PreviewDataModel previewDataModel)Filters the preview language to a language supported by the site.protected java.lang.StringgeneratePreviewUrl(javax.servlet.http.HttpServletRequest httpRequest, PreviewDataModel previewDataModel)Generates target URL accordingly to valid Preview Data passed as a parameterprotected BaseSiteServicegetBaseSiteService()protected CMSPageContextServicegetCmsPageContextService()protected CMSPreviewServicegetCmsPreviewService()protected CMSSiteServicegetCmsSiteService()protected CommerceCommonI18NServicegetCommerceCommonI18NService()protected ContextInformationLoadergetContextInformationLoader()protected CMSSiteModelgetCurrentCmsSite()protected UrlResolver<PreviewDataModel>getPreviewDataModelUrlResolver()Retrieves current mapping handler in order to generate proper target URL for CMS Pageprotected SessionServicegetSessionService()protected SiteChannelValidationStrategygetSiteChannelValidationStrategy()protected booleanisActiveSite(CMSSiteModel site)protected booleanprocessNormalRequest(javax.servlet.http.HttpServletRequest httpRequest, javax.servlet.http.HttpServletResponse httpResponse)Processing normal request (i.e.protected voidprocessPreviewData(javax.servlet.http.HttpServletRequest httpRequest, PreviewDataModel previewDataModel)protected java.lang.StringprocessPreviewRequest(javax.servlet.http.HttpServletRequest httpRequest, CmsPageRequestContextData cmsPageRequestContextData)Processing preview request (i.e.voidsetBaseSiteService(BaseSiteService baseSiteService)voidsetCmsPageContextService(CMSPageContextService cmsPageContextService)voidsetCmsPreviewService(CMSPreviewService cmsPreviewService)voidsetCmsSiteService(CMSSiteService cmsSiteService)voidsetCommerceCommonI18NService(CommerceCommonI18NService commerceCommonI18NService)voidsetContextInformationLoader(ContextInformationLoader contextInformationLoader)protected voidsetFallbackLanguage(javax.servlet.http.HttpServletRequest httpRequest, java.lang.Boolean enabled)Enables or disables language fall backvoidsetPreviewDataModelUrlResolver(UrlResolver<PreviewDataModel> previewDataModelUrlResolver)voidsetSessionService(SessionService sessionService)voidsetSiteChannelValidationStrategy(SiteChannelValidationStrategy siteChannelValidationStrategy)-
Methods inherited from class org.springframework.web.filter.OncePerRequestFilter
doFilter, getAlreadyFilteredAttributeName, isAsyncDispatch, isAsyncStarted, shouldNotFilter, shouldNotFilterAsyncDispatch, shouldNotFilterErrorDispatch
-
Methods inherited from class org.springframework.web.filter.GenericFilterBean
addRequiredProperty, afterPropertiesSet, createEnvironment, destroy, getEnvironment, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setEnvironment, setServletContext
-
-
-
-
Field Detail
-
MISSING_CMS_SITE_ERROR_STATUS
protected static final int MISSING_CMS_SITE_ERROR_STATUS
- See Also:
- Constant Field Values
-
MISSING_CMS_SITE_ERROR_MESSAGE
protected static final java.lang.String MISSING_CMS_SITE_ERROR_MESSAGE
- See Also:
- Constant Field Values
-
INCORRECT_CMS_SITE_CHANNEL_ERROR_MESSAGE
protected static final java.lang.String INCORRECT_CMS_SITE_CHANNEL_ERROR_MESSAGE
- See Also:
- Constant Field Values
-
-
Method Detail
-
doFilterInternal
protected void doFilterInternal(javax.servlet.http.HttpServletRequest httpRequest, javax.servlet.http.HttpServletResponse httpResponse, javax.servlet.FilterChain filterChain) throws javax.servlet.ServletException, java.io.IOException- Specified by:
doFilterInternalin classorg.springframework.web.filter.OncePerRequestFilter- Throws:
javax.servlet.ServletExceptionjava.io.IOException
-
processPreviewData
protected void processPreviewData(javax.servlet.http.HttpServletRequest httpRequest, PreviewDataModel previewDataModel)
-
processNormalRequest
protected boolean processNormalRequest(javax.servlet.http.HttpServletRequest httpRequest, javax.servlet.http.HttpServletResponse httpResponse) throws java.io.IOExceptionProcessing normal request (i.e. when user goes directly to that application - not from cmscockpit) Note:
We preparing application by setting correct:- Current Site
- Current Catalog Versions
- Enabled language fallback
- Parameters:
httpRequest- current requesthttpResponse- the http response- Throws:
java.io.IOException- See Also:
ContextInformationLoader.initializeSiteFromRequest(String),ContextInformationLoader.setCatalogVersions()
-
isActiveSite
protected boolean isActiveSite(CMSSiteModel site)
-
processPreviewRequest
protected java.lang.String processPreviewRequest(javax.servlet.http.HttpServletRequest httpRequest, CmsPageRequestContextData cmsPageRequestContextData)Processing preview request (i.e. request with additional parameters likeCMSFilter.PREVIEW_TOKENrequested from cmscockpit) ) Note: Processing preview data in order to generate target URL, and load necessary information in user session- Initialize information (Active CMSSite, Catalog versions,Current catalog version ) information getting from valid Preview Data
- Load all fake information (like: User, User group, Language, Time ...)
- Generating target URL according to Preview Data
- Parameters:
httpRequest- current request- Returns:
- target URL
-
filterPreviewLanguageForSite
protected LanguageModel filterPreviewLanguageForSite(javax.servlet.http.HttpServletRequest httpRequest, PreviewDataModel previewDataModel)
Filters the preview language to a language supported by the site. If the requested preview language is not supported, returns the default site language instead.- Parameters:
httpRequest- current requestpreviewDataModel- the preview data model- Returns:
- LanguageModel the filtered language for previewing
-
setFallbackLanguage
protected void setFallbackLanguage(javax.servlet.http.HttpServletRequest httpRequest, java.lang.Boolean enabled)Enables or disables language fall back- Parameters:
httpRequest- current requestenabled- enabled or disabled
-
generatePreviewUrl
protected java.lang.String generatePreviewUrl(javax.servlet.http.HttpServletRequest httpRequest, PreviewDataModel previewDataModel)Generates target URL accordingly to valid Preview Data passed as a parameter- Parameters:
httpRequest- current requestpreviewDataModel- valid data model contains all necessary information- Returns:
- target URL
-
getCurrentCmsSite
protected CMSSiteModel getCurrentCmsSite()
-
getPreviewDataModelUrlResolver
protected UrlResolver<PreviewDataModel> getPreviewDataModelUrlResolver()
Retrieves current mapping handler in order to generate proper target URL for CMS Page- Returns:
- current mapping handler
-
setPreviewDataModelUrlResolver
public void setPreviewDataModelUrlResolver(UrlResolver<PreviewDataModel> previewDataModelUrlResolver)
-
getCmsSiteService
protected CMSSiteService getCmsSiteService()
-
setCmsSiteService
public void setCmsSiteService(CMSSiteService cmsSiteService)
-
getSessionService
protected SessionService getSessionService()
-
setSessionService
public void setSessionService(SessionService sessionService)
-
getCmsPreviewService
protected CMSPreviewService getCmsPreviewService()
-
setCmsPreviewService
public void setCmsPreviewService(CMSPreviewService cmsPreviewService)
-
getCommerceCommonI18NService
protected CommerceCommonI18NService getCommerceCommonI18NService()
-
setCommerceCommonI18NService
public void setCommerceCommonI18NService(CommerceCommonI18NService commerceCommonI18NService)
-
getBaseSiteService
protected BaseSiteService getBaseSiteService()
-
setBaseSiteService
public void setBaseSiteService(BaseSiteService baseSiteService)
-
getContextInformationLoader
protected ContextInformationLoader getContextInformationLoader()
-
setContextInformationLoader
public void setContextInformationLoader(ContextInformationLoader contextInformationLoader)
-
getCmsPageContextService
protected CMSPageContextService getCmsPageContextService()
-
setCmsPageContextService
public void setCmsPageContextService(CMSPageContextService cmsPageContextService)
-
getSiteChannelValidationStrategy
protected SiteChannelValidationStrategy getSiteChannelValidationStrategy()
-
setSiteChannelValidationStrategy
public void setSiteChannelValidationStrategy(SiteChannelValidationStrategy siteChannelValidationStrategy)
-
-