Interface URLConstructor

  • All Superinterfaces:
    Initializable
    All Known Implementing Classes:
    DefaultURLConstructor, ShortURLConstructor, ShortViewURLConstructor

    public interface URLConstructor
    extends Initializable
    Provides an interface through which JSPWiki constructs URLs. JSPWiki calls the methods of this interface whenever an URL that points to any JSPWiki internals is required. For example, if you need to find an URL to the editor page for page "TextFormattingRules", you would call makeURL( WikiContext.EDIT, "TextFormattingRules", false, null );
    Since:
    2.2
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.String getForwardPage​(javax.servlet.http.HttpServletRequest request)
      Returns information which JSP page should continue handling this type of request.
      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.
      static java.lang.String parsePageFromURL​(javax.servlet.http.HttpServletRequest request, java.nio.charset.Charset encoding)
      Takes the name of the page from the request URI.
    • Method Detail

      • makeURL

        java.lang.String makeURL​(java.lang.String context,
                                 java.lang.String name,
                                 java.lang.String parameters)
        Constructs the URL with a bunch of parameters.
        Parameters:
        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.
        parameters - An URL parameter string (these must be URL-encoded, and separated with &)
        Returns:
        An URL pointing to the resource. Must never return null - throw an InternalWikiException if something goes wrong.
      • parsePage

        java.lang.String parsePage​(java.lang.String context,
                                   javax.servlet.http.HttpServletRequest request,
                                   java.nio.charset.Charset encoding)
                            throws java.io.IOException
        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.
        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.
        Throws:
        java.io.IOException - If parsing failes
      • getForwardPage

        java.lang.String getForwardPage​(javax.servlet.http.HttpServletRequest request)
        Returns information which JSP page should continue handling this type of request.
        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.
      • parsePageFromURL

        static java.lang.String parsePageFromURL​(javax.servlet.http.HttpServletRequest request,
                                                 java.nio.charset.Charset encoding)
        Takes the name of the page from the request URI. The initial slash is also removed. If there is no page, returns null.
        Parameters:
        request - The request to parse
        encoding - The encoding to use
        Returns:
        a parsed page name, or null, if it cannot be found