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 used de.hybris.platform.cms2.misc.AbstractPreviewServlet which actually is obsolete. All necessary logic was adapted and moved here. This is a spring configured filter that is executed by the PlatformFilterChain.
  • Field Details

    • MISSING_CMS_SITE_ERROR_STATUS

      protected static final int MISSING_CMS_SITE_ERROR_STATUS
      See Also:
    • MISSING_CMS_SITE_ERROR_MESSAGE

      protected static final String MISSING_CMS_SITE_ERROR_MESSAGE
      See Also:
    • INCORRECT_CMS_SITE_CHANNEL_ERROR_MESSAGE

      protected static final String INCORRECT_CMS_SITE_CHANNEL_ERROR_MESSAGE
      See Also:
  • Constructor Details

    • CMSSiteFilter

      public CMSSiteFilter()
  • Method Details

    • doFilterInternal

      protected void doFilterInternal(javax.servlet.http.HttpServletRequest httpRequest, javax.servlet.http.HttpServletResponse httpResponse, javax.servlet.FilterChain filterChain) throws javax.servlet.ServletException, IOException
      Specified by:
      doFilterInternal in class org.springframework.web.filter.OncePerRequestFilter
      Throws:
      javax.servlet.ServletException
      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 IOException
      Processing 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 request
      httpResponse - the http response
      Throws:
      IOException
      See Also:
    • isActiveSite

      protected boolean isActiveSite(CMSSiteModel site)
    • processPreviewRequest

      protected String processPreviewRequest(javax.servlet.http.HttpServletRequest httpRequest, CmsPageRequestContextData cmsPageRequestContextData)
      Processing preview request (i.e. request with additional parameters like CMSFilter.PREVIEW_TOKEN requested 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 request
      previewDataModel - the preview data model
      Returns:
      LanguageModel the filtered language for previewing
    • setFallbackLanguage

      protected void setFallbackLanguage(javax.servlet.http.HttpServletRequest httpRequest, Boolean enabled)
      Enables or disables language fall back

      Parameters:
      httpRequest - current request
      enabled - enabled or disabled
    • generatePreviewUrl

      protected String generatePreviewUrl(javax.servlet.http.HttpServletRequest httpRequest, PreviewDataModel previewDataModel)
      Generates target URL accordingly to valid Preview Data passed as a parameter

      Parameters:
      httpRequest - current request
      previewDataModel - 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)