com.softslate.commerce.customer.core
Class SEOFilter

java.lang.Object
  extended by com.softslate.commerce.customer.core.SEOFilter
All Implemented Interfaces:
javax.servlet.Filter

public class SEOFilter
extends java.lang.Object
implements 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
static java.lang.String categoryPath
           
static java.lang.String contentPath
           
private  javax.servlet.FilterConfig filterConfig
           
(package private) static org.apache.commons.logging.Log log
           
static java.lang.String manufacturerPath
           
static java.lang.String manufacturersPath
           
static java.lang.String pageEndPath
           
static java.lang.String productListPath
           
static java.lang.String productPath
           
static java.lang.String welcomePath
           
 
Constructor Summary
SEOFilter()
           
 
Method Summary
 void destroy()
           
 void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)
           
 java.lang.String extractPageOrCode(java.lang.String servletPath, java.lang.String marker, java.lang.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)
           
 java.lang.String translateSEOURL(Settings settings, java.lang.String servletPath)
          Translates a given URL path from a search-engine friendly format to a format recognized by the application.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

static org.apache.commons.logging.Log log

welcomePath

public static final java.lang.String welcomePath
See Also:
Constant Field Values

productPath

public static final java.lang.String productPath
See Also:
Constant Field Values

productListPath

public static final java.lang.String productListPath
See Also:
Constant Field Values

categoryPath

public static final java.lang.String categoryPath
See Also:
Constant Field Values

manufacturerPath

public static final java.lang.String manufacturerPath
See Also:
Constant Field Values

manufacturersPath

public static final java.lang.String manufacturersPath
See Also:
Constant Field Values

pageEndPath

public static final java.lang.String pageEndPath
See Also:
Constant Field Values

contentPath

public static final java.lang.String contentPath
See Also:
Constant Field Values

filterConfig

private javax.servlet.FilterConfig filterConfig
Constructor Detail

SEOFilter

public SEOFilter()
Method Detail

init

public void init(javax.servlet.FilterConfig filterConfig)
          throws javax.servlet.ServletException
Specified by:
init in interface javax.servlet.Filter
Throws:
javax.servlet.ServletException

destroy

public void destroy()
Specified by:
destroy in interface javax.servlet.Filter

doFilter

public void doFilter(javax.servlet.ServletRequest request,
                     javax.servlet.ServletResponse response,
                     javax.servlet.FilterChain chain)
              throws java.io.IOException,
                     javax.servlet.ServletException
Specified by:
doFilter in interface javax.servlet.Filter
Throws:
java.io.IOException
javax.servlet.ServletException

translateSEOURL

public java.lang.String translateSEOURL(Settings settings,
                                        java.lang.String servletPath)
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

public java.lang.String extractPageOrCode(java.lang.String servletPath,
                                          java.lang.String marker,
                                          java.lang.String suffix)
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.


Copyright © SoftSlate, LLC 2003–2005