Class SeoUrlRewriteFilter

java.lang.Object
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter
fr.paris.lutece.plugins.seo.web.SeoUrlRewriteFilter
All Implemented Interfaces:
jakarta.servlet.Filter

public class SeoUrlRewriteFilter extends org.tuckey.web.filters.urlrewrite.UrlRewriteFilter
UrlRewriteFilter whose init parameters can be overridden through the configuration API used by lutece-core (MicroProfile Config, exposed by AppPropertiesService).

For an init parameter named xxx declared in seo.xml, the configuration property seo.urlrewriter.xxx takes precedence whenever it is defined and not blank. Since the resolution goes through MicroProfile Config, the value may come from a plugin properties file, a system property, an environment variable (SEO_URLREWRITER_XXX) or any other config source registered in the application.

The filter is instantiated by reflection by the core FilterService, outside of the CDI container : the programmatic configuration API is used instead of @ConfigProperty injection.

The rewrite rules are read from the database rather than from a configuration file. They are a pure derivative of the seo_rule and seo_friendly_url tables, so a file would only be a copy of data already persisted, and one local to each node : in a multi node deployment, generating it from the back office wrote it on the node that served the request while the others kept the former rules indefinitely. Every node now builds its rules from the same tables, and reloads them when the version stamped in the datastore changes.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Prefix of the configuration properties overriding the filter init parameters

    Fields inherited from class org.tuckey.web.filters.urlrewrite.UrlRewriteFilter

    DEFAULT_MOD_REWRITE_STYLE_CONF_PATH, DEFAULT_WEB_CONF_PATH
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    init(jakarta.servlet.FilterConfig filterConfig)
    boolean
    The parent returns false as soon as the configuration did not come from a file, which is always the case here, and tracks the interval with a private field.
    void
    The parent compares the last modified date of the configuration file, which no longer exists : the version stamped in the datastore when the rules were last published is compared instead, so a publication from any node is picked up by all of them.

    Methods inherited from class org.tuckey.web.filters.urlrewrite.UrlRewriteFilter

    destroy, destroyActual, doFilter, getConfReloadCheckInterval, getConfReloadLastCheck, getFullVersionString, getStatusPath, isConfReloadCheckEnabled, isLoaded, isStatusEnabled

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • PREFIX_CONFIG_PARAM

      public static final String PREFIX_CONFIG_PARAM
      Prefix of the configuration properties overriding the filter init parameters
      See Also:
  • Constructor Details

    • SeoUrlRewriteFilter

      public SeoUrlRewriteFilter()
  • Method Details

    • init

      public void init(jakarta.servlet.FilterConfig filterConfig) throws jakarta.servlet.ServletException
      Specified by:
      init in interface jakarta.servlet.Filter
      Overrides:
      init in class org.tuckey.web.filters.urlrewrite.UrlRewriteFilter
      Throws:
      jakarta.servlet.ServletException
    • isTimeToReloadConf

      public boolean isTimeToReloadConf()
      The parent returns false as soon as the configuration did not come from a file, which is always the case here, and tracks the interval with a private field. Both are replaced by this filter.

      Beware of the unit : the parent stores the interval in milliseconds but its getter returns seconds.

      Overrides:
      isTimeToReloadConf in class org.tuckey.web.filters.urlrewrite.UrlRewriteFilter
    • reloadConf

      public void reloadConf()
      The parent compares the last modified date of the configuration file, which no longer exists : the version stamped in the datastore when the rules were last published is compared instead, so a publication from any node is picked up by all of them.
      Overrides:
      reloadConf in class org.tuckey.web.filters.urlrewrite.UrlRewriteFilter