Class DefaultURLConstructor

java.lang.Object
org.apache.wiki.url.DefaultURLConstructor
All Implemented Interfaces:
Initializable, URLConstructor
Direct Known Subclasses:
ShortURLConstructor

public class DefaultURLConstructor
extends java.lang.Object
implements URLConstructor
Implements the default URL constructor using links directly to the JSP pages. This is what JSPWiki by default is using. For example, WikiContext.VIEW points at "Wiki.jsp", etc.
Since:
2.2
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected Engine m_engine  
    protected java.lang.String m_pathPrefix
    Contains the absolute path of the JSPWiki Web application without the actual servlet (which is the m_urlPrefix).
  • Constructor Summary

    Constructors
    Constructor Description
    DefaultURLConstructor()  
  • Method Summary

    Modifier and Type Method Description
    protected java.lang.String doReplacement​(java.lang.String baseptrn, java.lang.String name)
    Does replacement of some particular variables.
    java.lang.String getForwardPage​(javax.servlet.http.HttpServletRequest request)
    This method is not needed for the DefaultURLConstructor.
    static java.lang.String getURLPattern​(java.lang.String context, java.lang.String name)
    Returns the URL pattern for a supplied wiki request context.
    void initialize​(Engine engine, java.util.Properties properties)
    Initializes this Engine component.
    java.lang.String makeURL​(java.lang.String context, java.lang.String name, java.lang.String parameters)
    Constructs the URL with a bunch of parameters.
    java.lang.String parsePage​(java.lang.String context, javax.servlet.http.HttpServletRequest request, java.nio.charset.Charset encoding)
    Should parse the "page" parameter from the actual request.

    Methods inherited from class java.lang.Object

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

    • m_engine

      protected Engine m_engine
    • m_pathPrefix

      protected java.lang.String m_pathPrefix
      Contains the absolute path of the JSPWiki Web application without the actual servlet (which is the m_urlPrefix).
  • Constructor Details

  • Method Details

    • initialize

      public void initialize​(Engine engine, java.util.Properties properties)

      Initializes this Engine component. Note that the engine is not fully initialized at this point, so don't do anything fancy here - use lazy init, if you have to.
       

      Specified by:
      initialize in interface Initializable
      Parameters:
      engine - Engine performing the initialization.
      properties - Properties for setup.
    • doReplacement

      protected final java.lang.String doReplacement​(java.lang.String baseptrn, java.lang.String name)
      Does replacement of some particular variables. The variables are:
      • "%u" - inserts either the base URL (when absolute is required), or the base path (which is an absolute path without the host name).
      • "%U" - always inserts the base URL
      • "%p" - always inserts the base path
      • "%n" - inserts the page name
      Parameters:
      baseptrn - The pattern to use
      name - The page name
      Returns:
      A replacement.
    • getURLPattern

      public static java.lang.String getURLPattern​(java.lang.String context, java.lang.String name) throws java.lang.IllegalArgumentException
      Returns the URL pattern for a supplied wiki request context.
      Parameters:
      context - the wiki context
      name - the wiki page
      Returns:
      A pattern for replacement.
      Throws:
      java.lang.IllegalArgumentException - if the context cannot be found
    • makeURL

      public java.lang.String makeURL​(java.lang.String context, java.lang.String name, java.lang.String parameters)
      Constructs the URL with a bunch of parameters.
      Specified by:
      makeURL in interface URLConstructor
      Parameters:
      parameters - If null or empty, no parameters are added. An URL parameter string (these must be URL-encoded, and separated with &)
      context - The request context (@see WikiContext) that you want the URL for
      name - The page name (or in case of WikiContext.NONE, the auxiliary JSP page or resource you want to point at). This must be URL encoded. Null is NOT safe.
      Returns:
      An URL pointing to the resource. Must never return null - throw an InternalWikiException if something goes wrong.
    • parsePage

      public java.lang.String parsePage​(java.lang.String context, javax.servlet.http.HttpServletRequest request, java.nio.charset.Charset encoding)
      Should parse the "page" parameter from the actual request. Should parse the "page" parameter from the actual request. This is essentially the reverse of makeURL() - whenever a request constructed by calls to makeURL() is passed to this routine, it MUST be able to parse the resource name (WikiPage, Attachment, other resource) from the request.
      Specified by:
      parsePage in interface URLConstructor
      Parameters:
      context - In which request context the request was made (this should help in parsing)
      request - The HTTP request that was used when coming here
      encoding - The encoding with which the request was made (UTF-8 or ISO-8859-1).
      Returns:
      This method must return the name of the resource.
    • getForwardPage

      public java.lang.String getForwardPage​(javax.servlet.http.HttpServletRequest request)
      This method is not needed for the DefaultURLConstructor.
      Specified by:
      getForwardPage in interface URLConstructor
      Parameters:
      request - The HTTP Request that was used to end up in this page.
      Returns:
      "Wiki.jsp", "PageInfo.jsp", etc. Just return the name, JSPWiki will figure out the page.