Class SEOFilter
java.lang.Object
com.softslate.commerce.customer.core.BaseFilter
com.softslate.commerce.customer.core.SEOFilter
- All Implemented Interfaces:
javax.servlet.Filter
Filter to translate incoming URLs from a search-engine friendly format to the
format understood by the application. Various settings in the application
tell the system how to do the translating. For example, if the
seoProductMarker
setting is set to "product", it tells us to
look for the pattern "/product/<product-code>" in the search-engine
friendly URL, which would be translated to
"/Product.do?code=<product-code>";
If the incoming URL is determined to be in a search-engine friendly format and the translation is successful, the request is forwarded to the translated URL. Otherwise, it is simply passed on to the next filter (if any).
URL paths ending in ".do", as well as common image, stylesheet, and javascript file extensions, are immediately passed through to the next filter.
- Author:
- David Tobey
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
void
doFilter
(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain) extractPageOrCode
(String servletPath, String marker, String suffix) Extracts the page identifier or the product, category, or manufacturer code from a given search-engine friendly URL.void
init
(javax.servlet.FilterConfig filterConfig) translateSEOURL
(Settings settings, String servletPath) Translates a given URL path from a search-engine friendly format to a format recognized by the application.Methods inherited from class com.softslate.commerce.customer.core.BaseFilter
isStaticRequest
-
Field Details
-
log
static org.apache.commons.logging.Log log -
welcomePath
- See Also:
-
productPath
- See Also:
-
productListPath
- See Also:
-
categoryPath
- See Also:
-
manufacturerPath
- See Also:
-
manufacturersPath
- See Also:
-
pageEndPath
- See Also:
-
contentPath
- See Also:
-
filterConfig
private javax.servlet.FilterConfig filterConfig
-
-
Constructor Details
-
SEOFilter
public SEOFilter()
-
-
Method Details
-
init
public void init(javax.servlet.FilterConfig filterConfig) throws javax.servlet.ServletException - Specified by:
init
in interfacejavax.servlet.Filter
- Throws:
javax.servlet.ServletException
-
destroy
public void destroy()- Specified by:
destroy
in interfacejavax.servlet.Filter
-
doFilter
public void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain) throws IOException, javax.servlet.ServletException - Specified by:
doFilter
in interfacejavax.servlet.Filter
- Throws:
IOException
javax.servlet.ServletException
-
translateSEOURL
Translates a given URL path from a search-engine friendly format to a format recognized by the application. Uses the given settings to determine how to translate. Translations are done for the Welcome screen, Page screens, Product Screen, and Category Screen.- Parameters:
settings
- A Bean holding the settings that determine how to translate.servletPath
- The incoming URL path (from after the context path until the query string)- Returns:
- The translated URL.
-
extractPageOrCode
Extracts the page identifier or the product, category, or manufacturer code from a given search-engine friendly URL.- Parameters:
servletPath
- The URL to be parsed.marker
- The marker identifying where to start looking for the page or code.suffix
- The suffix identifying where to stop looking for the page or code.- Returns:
- A string representing the page or code.
-