Class RuleFileService


  • public final class RuleFileService
    extends java.lang.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.

    The document is assembled in plain Java, not through a FreeMarker template. The filter renders it during its init, which the core runs before it registers the FreeMarker auto-includes : a template processed at that point builds the FreeMarker configuration without the macros, and that configuration is cached for the whole life of the webapp. Every template rendered afterwards then fails on its first macro.

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getRulesXml()
      Renders the rewrite rules held in the database as the XML configuration expected by the rewrite filter.
      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.
      • Methods inherited from class java.lang.Object

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

      • 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 java.lang.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.

        Every URL rewriter rule is written as it was entered, anchored at the start of the path. Every friendly URL is written as an exact match of the whole path. The rule exposing the sitemap comes first.

        Returns:
        The rules, as an urlrewrite configuration document