Package com.xpn.xwiki.web
Class ExportURLFactory
- java.lang.Object
-
- com.xpn.xwiki.web.XWikiDefaultURLFactory
-
- com.xpn.xwiki.web.XWikiServletURLFactory
-
- com.xpn.xwiki.web.ExportURLFactory
-
- All Implemented Interfaces:
XWikiURLFactory
public class ExportURLFactory extends XWikiServletURLFactory
Handle URL generation in rendered wiki pages. This implementation makes sure that generated URLs will be file URLs pointing to the local filesystem, for exported content (like skin, attachment and pages). This is needed for example for the HTML export.- Version:
- $Id: 2caf23e74c6d47ef4181ee05e4b028f27a3ce564 $
-
-
Field Summary
Fields Modifier and Type Field Description protected File
exportDir
Deprecated.since 6.2RC1, use {link #getExportURLFactoryContext} insteadprotected Set<String>
exportedPages
Deprecated.since 6.2RC1, use {link #getExportURLFactoryContext} insteadprotected static org.slf4j.Logger
LOGGER
Logging tool.-
Fields inherited from class com.xpn.xwiki.web.XWikiServletURLFactory
contextPath, daemon, defaultURL, defaultURLs, originalURL
-
-
Constructor Summary
Constructors Constructor Description ExportURLFactory()
ExportURLFactory constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description URL
createAttachmentRevisionURL(String filename, String spaces, String name, String revision, String xwikidb, XWikiContext context)
URL
createAttachmentURL(String filename, String spaces, String name, String action, String querystring, String xwikidb, XWikiContext context)
URL
createResourceURL(String filename, boolean forceSkinAction, XWikiContext context)
Create an URL for the file resource.URL
createResourceURL(String filename, boolean forceSkinAction, XWikiContext context, Map<String,Object> queryParameters)
Create an URL for the file resource.URL
createSkinURL(String filename, String skin, XWikiContext context)
Create a skin URL for the given filename and skin directory.URL
createSkinURL(String filename, String skin, XWikiContext context, Map<String,Object> queryParameters)
Create an URL for the given filename in the given skin directory.URL
createSkinURL(String filename, String spaces, String name, XWikiContext context)
Create an URL for the filename located in the spaces and with given repository.URL
createSkinURL(String filename, String spaces, String name, XWikiContext context, boolean skipSkinDirectory)
URL
createSkinURL(String fileName, String spaces, String name, String wikiId, XWikiContext context)
Create an URL for the filename located in the spaces and with given repository.URL
createSkinURL(String fileName, String spaces, String name, String wikiId, XWikiContext context, boolean skipSkinDirectory)
URL
createSkinURL(String filename, String spaces, String name, String xwikidb, XWikiContext context, Map<String,Object> queryParameters)
Create an URL for the filename located in the spaces and with given repository.URL
createURL(String spaces, String name, String action, String querystring, String anchor, String xwikidb, XWikiContext context)
Collection<String>
getExportedSkinFiles()
Deprecated.since 6.2RC1, usegetFilesystemExportContext()
FilesystemExportContext
getFilesystemExportContext()
Collection<String>
getNeededSkins()
Deprecated.since 6.2RC1, usegetFilesystemExportContext()
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(Collection<String> exportedPages, File exportDir, XWikiContext context)
Deprecated.starting with 8.4.5/9.0, useinit(Collection, File, FilesystemExportContext, XWikiContext)
void
init(Collection<DocumentReference> exportedPages, File exportDir, FilesystemExportContext exportContext, XWikiContext context)
Init the url factory.-
Methods inherited from class com.xpn.xwiki.web.XWikiServletURLFactory
addFileName, addFileName, createAttachmentRevisionURL, createAttachmentRevisionURL, createExternalURL, createTemplateURL, createURL, findAttachmentForDocRevision, findDeletedAttachmentForDocRevision, getContextPath, getDefaultURL, getRequestURL, getServerURL, getServerURL, init, isContextDoc, normalizeURL, normalizeURL, setDefaultURL
-
Methods inherited from class com.xpn.xwiki.web.XWikiDefaultURLFactory
createAttachmentRevisionURL, createAttachmentURL, createExternalURL, createSkinURL, createURL, createURL, createURL
-
-
-
-
Field Detail
-
LOGGER
protected static final org.slf4j.Logger LOGGER
Logging tool.
-
exportedPages
@Deprecated protected Set<String> exportedPages
Deprecated.since 6.2RC1, use {link #getExportURLFactoryContext} insteadPages for which to convert URL to local.
-
exportDir
@Deprecated protected File exportDir
Deprecated.since 6.2RC1, use {link #getExportURLFactoryContext} insteadDirectory where to export attachment.
-
-
Method Detail
-
getFilesystemExportContext
public FilesystemExportContext getFilesystemExportContext()
- Since:
- 7.2M1
-
getNeededSkins
@Deprecated public Collection<String> getNeededSkins()
Deprecated.since 6.2RC1, usegetFilesystemExportContext()
- Returns:
- the list skins names used.
-
getExportedSkinFiles
@Deprecated public Collection<String> getExportedSkinFiles()
Deprecated.since 6.2RC1, usegetFilesystemExportContext()
- Returns:
- the list of custom skin files.
-
init
public void init(Collection<DocumentReference> exportedPages, File exportDir, FilesystemExportContext exportContext, XWikiContext context)
Init the url factory.- Parameters:
exportedPages
- the pages that will be exported.exportDir
- the directory where to copy exported objects (attachments).exportContext
- the context for the exportcontext
- the XWiki context.- Since:
- 8.4.5, 9.0
-
init
@Deprecated public void init(Collection<String> exportedPages, File exportDir, XWikiContext context)
Deprecated.starting with 8.4.5/9.0, useinit(Collection, File, FilesystemExportContext, XWikiContext)
Init the url factory.- Parameters:
exportedPages
- the pages that will be exported.exportDir
- the directory where to copy exported objects (attachments).context
- the XWiki context.
-
createSkinURL
public URL createSkinURL(String filename, String skin, XWikiContext context, Map<String,Object> queryParameters)
Description copied from interface:XWikiURLFactory
Create an URL for the given filename in the given skin directory.- Specified by:
createSkinURL
in interfaceXWikiURLFactory
- Overrides:
createSkinURL
in classXWikiServletURLFactory
- Parameters:
filename
- the file to reach.skin
- the skin where the file should be loadedcontext
- current contextqueryParameters
- the parameters to put at the end of the URL- Returns:
- a URL to load the given file with the given query parameters.
-
createSkinURL
public URL createSkinURL(String filename, String skin, XWikiContext context)
Description copied from interface:XWikiURLFactory
Create a skin URL for the given filename and skin directory.- Specified by:
createSkinURL
in interfaceXWikiURLFactory
- Overrides:
createSkinURL
in classXWikiDefaultURLFactory
- Parameters:
filename
- the file to reach.skin
- the skin where the file should be loadedcontext
- current context- Returns:
- a URL to load the given file.
-
createSkinURL
public URL createSkinURL(String filename, String spaces, String name, XWikiContext context)
Description copied from interface:XWikiURLFactory
Create an URL for the filename located in the spaces and with given repository.- Specified by:
createSkinURL
in interfaceXWikiURLFactory
- Overrides:
createSkinURL
in classXWikiDefaultURLFactory
- Parameters:
filename
- the path of the file to reach.spaces
- the spaces where the file is located.name
- the directory where the file is located.context
- current context.- Returns:
- an URL to load the given file.
-
createSkinURL
public URL createSkinURL(String filename, String spaces, String name, XWikiContext context, boolean skipSkinDirectory)
-
createSkinURL
public URL createSkinURL(String fileName, String spaces, String name, String wikiId, XWikiContext context)
Description copied from interface:XWikiURLFactory
Create an URL for the filename located in the spaces and with given repository.- Specified by:
createSkinURL
in interfaceXWikiURLFactory
- Overrides:
createSkinURL
in classXWikiDefaultURLFactory
- Parameters:
fileName
- the path of the file to reach.spaces
- the spaces where the file is located.name
- the directory where the file is located.wikiId
- the wiki in which the file is located.context
- current context.- Returns:
- an URL to load the given file.
-
createSkinURL
public URL createSkinURL(String filename, String spaces, String name, String xwikidb, XWikiContext context, Map<String,Object> queryParameters)
Description copied from interface:XWikiURLFactory
Create an URL for the filename located in the spaces and with given repository.- Specified by:
createSkinURL
in interfaceXWikiURLFactory
- Overrides:
createSkinURL
in classXWikiServletURLFactory
- Parameters:
filename
- the path of the file to reach.spaces
- the spaces where the file is located.name
- the directory where the file is located.xwikidb
- the wiki in which the file is located.context
- current context.queryParameters
- parameters to put at the end of the URL.- Returns:
- an URL to load the given file.
-
createSkinURL
public URL createSkinURL(String fileName, String spaces, String name, String wikiId, XWikiContext context, boolean skipSkinDirectory)
-
createResourceURL
public URL createResourceURL(String filename, boolean forceSkinAction, XWikiContext context, Map<String,Object> queryParameters)
Description copied from interface:XWikiURLFactory
Create an URL for the file resource.- Specified by:
createResourceURL
in interfaceXWikiURLFactory
- Overrides:
createResourceURL
in classXWikiServletURLFactory
- Parameters:
filename
- the path of the file to load.forceSkinAction
- if true specify the skin directory in the URL.context
- the current context.queryParameters
- the parameters to put at the end of the URL.- Returns:
- an URL to load the given file
-
createResourceURL
public URL createResourceURL(String filename, boolean forceSkinAction, XWikiContext context)
Description copied from interface:XWikiURLFactory
Create an URL for the file resource.- Specified by:
createResourceURL
in interfaceXWikiURLFactory
- Overrides:
createResourceURL
in classXWikiDefaultURLFactory
- Parameters:
filename
- the path of the file to load.forceSkinAction
- if true specify the skin directory in the URL.context
- the current context.- Returns:
- an URL to load the given file
-
createURL
public URL createURL(String spaces, String name, String action, String querystring, String anchor, String xwikidb, XWikiContext context)
- Specified by:
createURL
in interfaceXWikiURLFactory
- Overrides:
createURL
in classXWikiServletURLFactory
- Parameters:
spaces
- a serialized space reference which can contain one or several spaces (e.g. "space1.space2"). If a space name contains a dot (".") it must be passed escaped as in "space1\.with\.dot.space2"querystring
- the URL-encoded Query String. It's important to realize that the implementation of this method cannot encode it automatically since the Query String is passed as a String (and it's not possible to differentiate between a '=' character that should be encoded and one that shouldn't. Imagine an input of 'a=&b=c' which can be understood either as 'a' = '&b=c' or as 'a' = '' and 'b' = 'c'). Ideally we would need an API signature that accepts aMap<String, String>
for the Query String, for example
-
createAttachmentURL
public URL createAttachmentURL(String filename, String spaces, String name, String action, String querystring, String xwikidb, XWikiContext context)
- Specified by:
createAttachmentURL
in interfaceXWikiURLFactory
- Overrides:
createAttachmentURL
in classXWikiServletURLFactory
spaces
- a serialized space reference which can contain one or several spaces (e.g. "space1.space2"). If a space name contains a dot (".") it must be passed escaped as in "space1\.with\.dot.space2"querystring
- the URL-encoded Query String. It's important to realize that the implementation of this method cannot encode it automatically since the Query String is passed as a String (and it's not possible to differentiate between a '=' character that should be encoded and one that shouldn't. Imagine an input of 'a=&b=c' which can be understood either as 'a' = '&b=c' or as 'a' = '' and 'b' = 'c'). Ideally we would need an API signature that accepts aMap<String, String>
for the Query String, for example
-
createAttachmentRevisionURL
public URL createAttachmentRevisionURL(String filename, String spaces, String name, String revision, String xwikidb, XWikiContext context)
- Specified by:
createAttachmentRevisionURL
in interfaceXWikiURLFactory
- Overrides:
createAttachmentRevisionURL
in classXWikiDefaultURLFactory
spaces
- a serialized space reference which can contain one or several spaces (e.g. "space1.space2"). If a space name contains a dot (".") it must be passed escaped as in "space1\.with\.dot.space2"xwikidb
- the URL-encoded Query String. It's important to realize that the implementation of this method cannot encode it automatically since the Query String is passed as a String (and it's not possible to differentiate between a '=' character that should be encoded and one that shouldn't. Imagine an input of 'a=&b=c' which can be understood either as 'a' = '&b=c' or as 'a' = '' and 'b' = 'c'). Ideally we would need an API signature that accepts aMap<String, String>
for the Query String, for example
-
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)
-
-