org.broadleafcommerce.cms.web
Class BroadleafProcessURLFilter

java.lang.Object
  extended by org.springframework.web.filter.GenericFilterBean
      extended by org.springframework.web.filter.OncePerRequestFilter
          extended by org.broadleafcommerce.cms.web.BroadleafProcessURLFilter
All Implemented Interfaces:
javax.servlet.Filter, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.web.context.ServletContextAware

@Component(value="blProcessURLFilter")
public class BroadleafProcessURLFilter
extends org.springframework.web.filter.OncePerRequestFilter

This filter sets up the CMS system by setting the current sandbox, locale, time of day, and languageCode that used by content items.

After setting up content variables, it checks to see if a request can be processed by an instance of URLProcessor and if so, delegates the request to that processor. This filter creates an internal cache to quickly determine if the request should be processed by an instance of URLProcessor or be passed to the next filter in the filter chain. The cache settings (including expiration seconds, maximum elements, and concurrency) can be configured via Spring at startup. See com.google.common.cache.CacheBuilder for more information on these parameters.

Author:
bpolster

Field Summary
static String LOCALE_CODE_PARAM
          Parameter/Attribute name for the current language
static String LOCALE_VAR
          Parameter/Attribute name for the current language
static String REQUEST_DTO
          Parameter/Attribute name for the current language
static String SANDBOX_VAR
          Request attribute to store the current sandbox
protected  Boolean sandBoxPreviewEnabled
           
 
Fields inherited from class org.springframework.web.filter.OncePerRequestFilter
ALREADY_FILTERED_SUFFIX
 
Fields inherited from class org.springframework.web.filter.GenericFilterBean
logger
 
Constructor Summary
BroadleafProcessURLFilter()
           
 
Method Summary
 void doFilterInternal(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.FilterChain filterChain)
          (non-Javadoc)
 int getCacheExpirationSeconds()
           
protected  Set getIgnoreSuffixes()
          Returns a set of suffixes that can be ignored by content processing.
 int getMaxCacheConcurrency()
           
 int getMaxCacheElements()
           
 Boolean getSandBoxPreviewEnabled()
           
 List<URLProcessor> getUrlProcessorList()
           
 void setCacheExpirationSeconds(int cacheExpirationSeconds)
           
 void setMaxCacheConcurrency(int maxCacheConcurrency)
           
 void setMaxCacheElements(int maxCacheElements)
           
 void setSandBoxPreviewEnabled(Boolean sandBoxPreviewEnabled)
           
 void setUrlProcessorList(List<URLProcessor> urlProcessorList)
           
protected  boolean shouldProcessURL(javax.servlet.http.HttpServletRequest request, String requestURI)
          Determines if the passed in URL should be processed by the content management system.
 
Methods inherited from class org.springframework.web.filter.OncePerRequestFilter
doFilter, getAlreadyFilteredAttributeName, shouldNotFilter
 
Methods inherited from class org.springframework.web.filter.GenericFilterBean
addRequiredProperty, afterPropertiesSet, destroy, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setServletContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sandBoxPreviewEnabled

protected Boolean sandBoxPreviewEnabled

LOCALE_VAR

public static String LOCALE_VAR
Parameter/Attribute name for the current language


LOCALE_CODE_PARAM

public static String LOCALE_CODE_PARAM
Parameter/Attribute name for the current language


REQUEST_DTO

public static String REQUEST_DTO
Parameter/Attribute name for the current language


SANDBOX_VAR

public static String SANDBOX_VAR
Request attribute to store the current sandbox

Constructor Detail

BroadleafProcessURLFilter

public BroadleafProcessURLFilter()
Method Detail

doFilterInternal

public void doFilterInternal(javax.servlet.http.HttpServletRequest request,
                             javax.servlet.http.HttpServletResponse response,
                             javax.servlet.FilterChain filterChain)
                      throws IOException,
                             javax.servlet.ServletException
(non-Javadoc)

Specified by:
doFilterInternal in class org.springframework.web.filter.OncePerRequestFilter
Throws:
IOException
javax.servlet.ServletException
See Also:
Filter.doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)

shouldProcessURL

protected boolean shouldProcessURL(javax.servlet.http.HttpServletRequest request,
                                   String requestURI)
Determines if the passed in URL should be processed by the content management system.

By default, this method returns false for any BLC-Admin URLs and service calls and for all common image/digital mime-types (as determined by an internal call to getIgnoreSuffixes.

This check is called with the doFilterInternal method to short-circuit the content processing which can be expensive for requests that do not require it.

Parameters:
requestURI - - the HttpServletRequest.getRequestURI
Returns:
true if the HttpServletRequest should be processed

getIgnoreSuffixes

protected Set getIgnoreSuffixes()
Returns a set of suffixes that can be ignored by content processing. The following are returned:

List of suffixes ignored: ".aif", ".aiff", ".asf", ".avi", ".bin", ".bmp", ".doc", ".eps", ".gif", ".hqx", ".jpg", ".jpeg", ".mid", ".midi", ".mov", ".mp3", ".mpg", ".mpeg", ".p65", ".pdf", ".pic", ".pict", ".png", ".ppt", ".psd", ".qxd", ".ram", ".ra", ".rm", ".sea", ".sit", ".stk", ".swf", ".tif", ".tiff", ".txt", ".rtf", ".vob", ".wav", ".wmf", ".xls", ".zip";

Returns:
set of suffixes to ignore.

getMaxCacheElements

public int getMaxCacheElements()

setMaxCacheElements

public void setMaxCacheElements(int maxCacheElements)

getCacheExpirationSeconds

public int getCacheExpirationSeconds()

setCacheExpirationSeconds

public void setCacheExpirationSeconds(int cacheExpirationSeconds)

getMaxCacheConcurrency

public int getMaxCacheConcurrency()

setMaxCacheConcurrency

public void setMaxCacheConcurrency(int maxCacheConcurrency)

getUrlProcessorList

public List<URLProcessor> getUrlProcessorList()

setUrlProcessorList

public void setUrlProcessorList(List<URLProcessor> urlProcessorList)

getSandBoxPreviewEnabled

public Boolean getSandBoxPreviewEnabled()

setSandBoxPreviewEnabled

public void setSandBoxPreviewEnabled(Boolean sandBoxPreviewEnabled)


Copyright © 2012. All Rights Reserved.