Package 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: 8c62d8e37fa0dd5eedb043aa629175d7a6323c2a $
-
-
Field Summary
-
Fields inherited from class com.xpn.xwiki.web.XWikiServletURLFactory
contextPath, daemon, defaultURL, defaultURLs, originalURL
-
-
Constructor Summary
Constructors Constructor Description ExternalServletURLFactory()
Constructor used byXWikiURLFactoryServiceImpl
.ExternalServletURLFactory(XWikiContext context)
Old-school constructor using the XWikiContext to initialize the factory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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, getDefaultURL, getRequestURL, getServerURL, getServerURL, init, isContextDoc, normalizeURL, normalizeURL, setDefaultURL
-
Methods inherited from class com.xpn.xwiki.web.XWikiDefaultURLFactory
createAttachmentRevisionURL, createAttachmentRevisionURL, createAttachmentURL, createExternalURL, createResourceURL, createSkinURL, createSkinURL, createSkinURL, createSkinURL, createURL, createURL, createURL
-
-
-
-
Constructor Detail
-
ExternalServletURLFactory
public ExternalServletURLFactory(XWikiContext context)
Old-school constructor using the XWikiContext to initialize the factory.- Parameters:
context
- the current request context
-
ExternalServletURLFactory
public ExternalServletURLFactory()
Constructor used byXWikiURLFactoryServiceImpl
.
-
-
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 interfaceXWikiURLFactory
- Overrides:
getURL
in classXWikiServletURLFactory
- Parameters:
url
- the URL to convert- Returns:
- the converted URL as a string
- See Also:
XWikiDefaultURLFactory.getURL(java.net.URL, com.xpn.xwiki.XWikiContext)
-
-