Class SEOFilter

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

public class SEOFilter extends BaseFilter 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 Details

  • Constructor Details

    • SEOFilter

      public SEOFilter()
  • Method Details

    • 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 IOException, javax.servlet.ServletException
      Specified by:
      doFilter in interface javax.servlet.Filter
      Throws:
      IOException
      javax.servlet.ServletException
    • translateSEOURL

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