Interface UrlFactory


public interface UrlFactory
Factory producing URLs for media and content producers.
Instances are registered in the module.xml file like this:
     <module>
         <components>
             <public>
                 <name>{name}</name>
                 <class>de.espirit.firstspirit.generate.UrlCreatorSpecification</class>
                 <configuration>
                     <UrlFactory>{full qualified class name}</UrlFactory>
                     <!-- insert parameters for your implementation here, see init(java.util.Map, PathLookup) -->
                 </configuration>
             </public>
         </components>
     </module>
 

If the data for a URI component would conflict with the reserved purpose, then the conflicting data must be escaped before forming the URI. Reserved according to RFC-2396 are ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | ",".
Instances created by FirstSpirit are initialized once before any other usage.
Implementations should be thread safe. This is best achieved by avoiding local state despite state derived from initialization.
Since:
5.0.5
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull String
    getUrl(@NotNull ContentProducer node, @NotNull TemplateSet templateSet, @NotNull Language language, @NotNull PageParams pageParams)
    Calculate path to provided combination of node, template set, language, and page params.
    @NotNull String
    getUrl(@NotNull Media node, @NotNull Language language, @Nullable Resolution resolution)
    Calculate path to provided combination of node, language, and resolution.
    default void
    init(@NotNull Map<String,String> settings, @NotNull PathLookup pathLookup)
    Initialization method.
    default void
    setUp(@NotNull UrlFactoryContext context)
    Configures the context in which the UrlFactory is operating.
  • Method Details

    • init

      default void init(@NotNull @NotNull Map<String,String> settings, @NotNull @NotNull PathLookup pathLookup)
      Initialization method. When calculating paths by traversing the parent chain of the provided node you should consult the provided pathLookup for user defined paths.

      Implementers note:
      This method will only get called by the default implementation of setUp(UrlFactoryContext). You must override the setUp-Method if you don't want this to happen for your implementation.
      The default implementation of this method is just a stub and therefor does nothing.

      Parameters:
      settings - Settings provided in module.xml file in section <configuration>..</configuration>. The key is the tag name (converted to lower case), value is the text child node. E.g. <key>value</key>.
      pathLookup - Path lookup for user defined paths.
      Since:
      5.0.5
    • setUp

      default void setUp(@NotNull @NotNull UrlFactoryContext context)
      Configures the context in which the UrlFactory is operating. If the instance is created by FirstSpirit, this method is called once before any other usage.

      For compatibility reasons the default implementation delegates to init(Map, PathLookup).

      Implementers note:
      It is not necessary to call the default implementation.

      Parameters:
      context - The context for this UrlFactory.
      Since:
      5.2.190300
    • getUrl

      @NotNull @NotNull String getUrl(@NotNull @NotNull ContentProducer node, @NotNull @NotNull TemplateSet templateSet, @NotNull @NotNull Language language, @NotNull @NotNull PageParams pageParams)
      Calculate path to provided combination of node, template set, language, and page params. The constructed url should start with a slash.
      If the data for a URI component would conflict with the reserved purpose, then the conflicting data must be escaped before forming the URI. Reserved according to RFC-2396 are ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | ",".
      Parameters:
      node - target node.
      templateSet - target template set.
      language - target language.
      pageParams - the page params.
      Returns:
      the complete path including extension.
      Since:
      5.0.5
    • getUrl

      @NotNull @NotNull String getUrl(@NotNull @NotNull Media node, @NotNull @NotNull Language language, @Nullable @Nullable Resolution resolution)
      Calculate path to provided combination of node, language, and resolution. The constructed url should start with a slash.
      If the data for a URI component would conflict with the reserved purpose, then the conflicting data must be escaped before forming the URI. Reserved according to RFC-2396 are ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | ",".
      Parameters:
      node - Target node.
      language - Target language.
      resolution - Target resolution or null for media nodes of type Media.FILE.
      Returns:
      The complete path including extension.
      Since:
      5.0.5