com.xpn.xwiki.web
Class ExternalServletURLFactory
java.lang.Object
com.xpn.xwiki.web.XWikiDefaultURLFactory
com.xpn.xwiki.web.XWikiServletURLFactory
com.xpn.xwiki.web.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: 23a37219db8dd7d212e376fe24b8419932bfc187 $
Method Summary |
String |
getURL(URL url,
XWikiContext context)
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. |
Methods inherited from class com.xpn.xwiki.web.XWikiServletURLFactory |
addFileName, addFileName, createAttachmentRevisionURL, createAttachmentRevisionURL, createAttachmentURL, createExternalURL, createResourceURL, createSkinURL, createSkinURL, createTemplateURL, createURL, createURL, findAttachmentForDocRevision, findDeletedAttachmentForDocRevision, getContextPath, getRequestURL, getServerURL, getServerURL, init, isContextDoc, normalizeURL, normalizeURL |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ExternalServletURLFactory
public ExternalServletURLFactory(XWikiContext context)
- Old-school constructor using the XWikiContext to initialize the factory.
- Parameters:
context
- the current request context
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)
Copyright © 2004–2014 XWiki. All rights reserved.