Class RuleFileService

java.lang.Object
fr.paris.lutece.plugins.seo.service.RuleFileService

public final class RuleFileService extends Object
Builds the URL rewriting rules from the database, and publishes them so that every node reloads them.

The rules used to be written to a file read by the rewrite filter. They are a pure derivative of the seo_rule and seo_friendly_url tables, so that file was a copy of data already persisted, and one local to each node. The filter now builds its configuration from getRulesXml(), and publishRules() only stamps a new version in the datastore.

  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    Renders the rewrite rules held in the database as the XML configuration expected by the rewrite filter.
    static boolean
    Publishes the rules held in the database : checks that they form a configuration the rewrite filter accepts, then stamps a new version, which every node compares to the one it has loaded, and records the log shown in the back office.

    Methods inherited from class java.lang.Object

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

    • publishRules

      public static boolean publishRules()
      Publishes the rules held in the database : checks that they form a configuration the rewrite filter accepts, then stamps a new version, which every node compares to the one it has loaded, and records the log shown in the back office.

      The check is what the administrator gets as feedback. A rule holding an invalid regular expression used to break the rewriting silently, the failure only appearing in the log of each node at the next reload : nothing is published unless the rules parse.

      Returns:
      true when the rules were published, false when they were rejected
    • getRulesXml

      public static String getRulesXml()
      Renders the rewrite rules held in the database as the XML configuration expected by the rewrite filter. Free of any side effect : the filter calls it on every reload.
      Returns:
      The rules, as an urlrewrite configuration document