|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.xpn.xwiki.web.XWikiDefaultURLFactory
com.xpn.xwiki.web.XWikiServletURLFactory
public class XWikiServletURLFactory
Field Summary | |
---|---|
protected String |
contextPath
|
protected URL |
serverURL
This is the URL which was requested by the user possibly with the host modified if x-forwarded-host header is set or if xwiki.home parameter is set and we are viewing the main page. |
Constructor Summary | |
---|---|
XWikiServletURLFactory()
|
|
XWikiServletURLFactory(URL serverURL,
String contextPath,
String actionPath)
|
|
XWikiServletURLFactory(XWikiContext context)
Creates a new URL factory that uses the server URL and context path specified by the given XWiki context. |
Method Summary | |
---|---|
protected void |
addFileName(StringBuffer newpath,
String filename,
boolean encode,
XWikiContext context)
|
protected void |
addFileName(StringBuffer newpath,
String filename,
XWikiContext context)
|
URL |
createAttachmentRevisionURL(String filename,
String web,
String name,
String revision,
long recycleId,
String querystring,
String xwikidb,
XWikiContext context)
|
URL |
createAttachmentRevisionURL(String filename,
String web,
String name,
String revision,
String querystring,
String xwikidb,
XWikiContext context)
|
URL |
createAttachmentURL(String filename,
String web,
String name,
String action,
String querystring,
String xwikidb,
XWikiContext context)
|
URL |
createExternalURL(String web,
String name,
String action,
String querystring,
String anchor,
String xwikidb,
XWikiContext context)
|
URL |
createResourceURL(String filename,
boolean forceSkinAction,
XWikiContext context)
|
URL |
createSkinURL(String filename,
String web,
String name,
String xwikidb,
XWikiContext context)
|
URL |
createSkinURL(String filename,
String skin,
XWikiContext context)
|
URL |
createTemplateURL(String filename,
XWikiContext context)
|
URL |
createURL(String web,
String name,
String action,
boolean redirect,
XWikiContext context)
|
URL |
createURL(String web,
String name,
String action,
String querystring,
String anchor,
String xwikidb,
XWikiContext context)
|
XWikiAttachment |
findAttachmentForDocRevision(XWikiDocument doc,
String docRevision,
String filename,
XWikiContext context)
|
long |
findDeletedAttachmentForDocRevision(XWikiDocument doc,
String docRevision,
String filename,
XWikiContext context)
|
String |
getContextPath()
Returns the part of the URL identifying the web application. |
URL |
getRequestURL(XWikiContext context)
|
URL |
getServerURL(String xwikidb,
XWikiContext context)
Get the url of the server EG: http://www.xwiki.org/ This function sometimes will return a URL with a trailing / and other times not. |
URL |
getServerURL(XWikiContext context)
Generate the base external URL to access this server. |
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. |
void |
init(XWikiContext context)
|
protected boolean |
isContextDoc(String wiki,
String space,
String name,
XWikiContext context)
Check if a document is the original context document. |
protected static URL |
normalizeURL(String url,
XWikiContext context)
Encodes the passed URL and offers the possibility for Servlet Filter to perform URL rewriting (this is used for example by Tuckey's URLRewriteFilter for rewriting outbound URLs, see http://platform.xwiki.org/xwiki/bin/view/Main/ShortURLs). |
protected static URL |
normalizeURL(URL url,
XWikiContext context)
Encodes the passed URL and offers the possibility for Servlet Filter to perform URL rewriting (this is used for example by Tuckey's URLRewriteFilter for rewriting outbound URLs, see http://platform.xwiki.org/xwiki/bin/view/Main/ShortURLs). |
Methods inherited from class com.xpn.xwiki.web.XWikiDefaultURLFactory |
---|
createAttachmentRevisionURL, createAttachmentRevisionURL, createAttachmentURL, createExternalURL, createSkinURL, createURL, createURL, createURL |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected URL serverURL
protected String contextPath
Constructor Detail |
---|
public XWikiServletURLFactory()
public XWikiServletURLFactory(URL serverURL, String contextPath, String actionPath)
public XWikiServletURLFactory(XWikiContext context)
XWikiContext.setURL(URL)
is called before this
constructor.
context
- Method Detail |
---|
public void init(XWikiContext context)
public String getContextPath()
public URL getServerURL(XWikiContext context) throws MalformedURLException
XWikiURLFactory
context
- the XWiki context.
MalformedURLException
- error when creating the URL
.public URL getServerURL(String xwikidb, XWikiContext context) throws MalformedURLException
xwikidb
- the name of the database (subwiki) if null it is assumed to be the same as the wiki which we are
currently displaying.context
- the XWikiContext used to determine the current wiki and the value if the xwiki.home parameter if
needed as well as access the xwiki server document if in virtual mode.
MalformedURLException
public URL createURL(String web, String name, String action, boolean redirect, XWikiContext context)
public URL createURL(String web, String name, String action, String querystring, String anchor, String xwikidb, XWikiContext context)
protected void addFileName(StringBuffer newpath, String filename, XWikiContext context)
protected void addFileName(StringBuffer newpath, String filename, boolean encode, XWikiContext context)
public URL createExternalURL(String web, String name, String action, String querystring, String anchor, String xwikidb, XWikiContext context)
public URL createSkinURL(String filename, String skin, XWikiContext context)
public URL createSkinURL(String filename, String web, String name, String xwikidb, XWikiContext context)
public URL createResourceURL(String filename, boolean forceSkinAction, XWikiContext context)
public URL createTemplateURL(String filename, XWikiContext context)
public URL createAttachmentURL(String filename, String web, String name, String action, String querystring, String xwikidb, XWikiContext context)
protected boolean isContextDoc(String wiki, String space, String name, XWikiContext context)
wiki
- the wiki name of the document to checkspace
- the space name of the document to checkname
- the document name of the document to checkcontext
- the current request context
true
if the provided document is the same as the current context document, false
otherwisepublic URL createAttachmentRevisionURL(String filename, String web, String name, String revision, String querystring, String xwikidb, XWikiContext context)
public URL createAttachmentRevisionURL(String filename, String web, String name, String revision, long recycleId, String querystring, String xwikidb, XWikiContext context)
public String getURL(URL url, XWikiContext context)
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
getURL
in interface XWikiURLFactory
getURL
in class XWikiDefaultURLFactory
url
- the URL to convert
XWikiDefaultURLFactory.getURL(java.net.URL, com.xpn.xwiki.XWikiContext)
public URL getRequestURL(XWikiContext context)
getRequestURL
in interface XWikiURLFactory
getRequestURL
in class XWikiDefaultURLFactory
public XWikiAttachment findAttachmentForDocRevision(XWikiDocument doc, String docRevision, String filename, XWikiContext context) throws XWikiException
XWikiException
public long findDeletedAttachmentForDocRevision(XWikiDocument doc, String docRevision, String filename, XWikiContext context) throws XWikiException
XWikiException
protected static URL normalizeURL(URL url, XWikiContext context) throws MalformedURLException
url
- the URL to encode and normalizecontext
- the XWiki Context used to get access to the Response for encoding the URL
MalformedURLException
- if the passed URL is invalidprotected static URL normalizeURL(String url, XWikiContext context) throws MalformedURLException
url
- the URL to encode and normalizecontext
- the XWiki Context used to get access to the Response for encoding the URL
MalformedURLException
- if the passed URL is invalid
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |