Class ExternalServletURLFactory

  • All Implemented Interfaces:
    XWikiURLFactory

    public class ExternalServletURLFactory
    extends XWikiServletURLFactory
    URL Factory which always prints the absolute (external) form of URLs.
    Since:
    2.6 RC2
    Version:
    $Id: 8c62d8e37fa0dd5eedb043aa629175d7a6323c2a $
    • Constructor Detail

      • ExternalServletURLFactory

        public ExternalServletURLFactory​(XWikiContext context)
        Old-school constructor using the XWikiContext to initialize the factory.
        Parameters:
        context - the current request context
    • Method Detail

      • getURL

        public String getURL​(URL url,
                             XWikiContext context)
        Description copied from class: XWikiServletURLFactory
        Converts a URL to a relative URL if it's a XWiki URL (keeping only the path + query string + anchor) and leave the URL unchanged if it's an external URL.

        An URL is considered to be external if its server component doesn't match the server of the current request URL. This means that URLs are made relative with respect to the current request URL rather than the current wiki set on the XWiki context. Let's take an example:

         
         request URL: http://playground.xwiki.org/xwiki/bin/view/Sandbox/TestURL
         current wiki: code (code.xwiki.org)
         URL (1): http://code.xwiki.org/xwiki/bin/view/Main/WebHome
         URL (2): http://playground.xwiki.org/xwiki/bin/view/Spage/Page
         
         The result will be:
         (1) http://code.xwiki.org/xwiki/bin/view/Main/WebHome
         (2) /xwiki/bin/view/Spage/Page
         
         
        Specified by:
        getURL in interface XWikiURLFactory
        Overrides:
        getURL in class XWikiServletURLFactory
        Parameters:
        url - the URL to convert
        Returns:
        the converted URL as a string
        See Also:
        XWikiDefaultURLFactory.getURL(java.net.URL, com.xpn.xwiki.XWikiContext)