public class WikiEngine extends Object
This is the main interface through which everything should go.
Using this class: Always get yourself an instance from JSP page by using the WikiEngine.getInstance() method. Never create a new WikiEngine() from scratch, unless you're writing tests.
There's basically only a single WikiEngine for each web application, and you should always get it using the WikiEngine.getInstance() method.
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_INLINEPATTERN
The default inlining pattern.
|
static String |
DEFAULT_TEMPLATE_NAME
The name used for the default template.
|
static String |
PREFS_COOKIE_NAME
The name of the cookie that gets stored to the user browser.
|
static String |
PROP_ACL_MANAGER_IMPL
The name of the property containing the ACLManager implementing class.
|
static String |
PROP_ALLOW_CREATION_OF_EMPTY_PAGES
If this property is set to false, we don't allow the creation of empty pages
|
static String |
PROP_APPNAME
Property for application name
|
static String |
PROP_BEAUTIFYTITLE
Property name for the "spaces in titles" -hack.
|
static String |
PROP_ENCODING
Define the used encoding.
|
static String |
PROP_FRONTPAGE
Property name for the default front page.
|
static String |
PROP_INLINEIMAGEPTRN
This property defines the inline image pattern.
|
static String |
PROP_INTERWIKIREF
Property start for any interwiki reference.
|
static String |
PROP_MATCHPLURALS
Property name for the "match english plurals" -hack.
|
static String |
PROP_NO_FILTER_ENCODING
Do not use encoding in WikiJSPFilter, default is false for most servers.
|
static String |
PROP_REFSTYLE
The name for the property which allows you to set the current reference
style.
|
static String |
PROP_RUNFILTERS
If this property is set to false, all filters are disabled when translating.
|
static String |
PROP_STOREUSERNAME
If true, then the user name will be stored with the page data.
|
static String |
PROP_TEMPLATEDIR
Property name for the template that is used.
|
static String |
PROP_URLCONSTRUCTOR
Property name for setting the url generator instance
|
static String |
PROP_WORKDIR
Property name for where the jspwiki work directory should be.
|
Modifier | Constructor and Description |
---|---|
|
WikiEngine(Properties properties)
Instantiate the WikiEngine using a given set of properties.
|
protected |
WikiEngine(javax.servlet.ServletContext context,
String appid,
Properties props)
Instantiate using this method when you're running as a servlet and
WikiEngine will figure out where to look for the property
file.
|
Modifier and Type | Method and Description |
---|---|
void |
addWikiEventListener(WikiEventListener listener)
Registers a WikiEventListener with this instance.
|
String |
beautifyTitle(String title)
Beautifies the title of the page by appending spaces in suitable
places, if the user has so decreed in the properties when constructing
this WikiEngine.
|
String |
beautifyTitleNoBreak(String title)
Beautifies the title of the page by appending non-breaking spaces
in suitable places.
|
WikiContext |
createContext(javax.servlet.http.HttpServletRequest request,
String requestContext)
Shortcut to create a WikiContext from a supplied HTTP request,
using a default wiki context.
|
String |
decodeName(String pagerequest)
Decodes a URL-encoded request back to regular life.
|
void |
deletePage(String pageName)
Deletes a page or an attachment completely, including all versions.
|
void |
deleteVersion(WikiPage page)
Deletes a specific version of a page or an attachment.
|
String |
encodeName(String pagename)
Turns a WikiName into something that can be
called through using an URL.
|
protected void |
fireEvent(int type)
Fires a WikiEngineEvent to all registered listeners.
|
protected void |
firePageEvent(int type,
String pageName)
Fires a WikiPageEvent to all registered listeners.
|
protected void |
firePageRenameEvent(String oldName,
String newName)
Fires a WikiPageRenameEvent to all registered listeners.
|
AclManager |
getAclManager()
Returns the AclManager employed by this WikiEngine.
|
AdminBeanManager |
getAdminBeanManager()
Returns the current
AdminBeanManager . |
Collection<String> |
getAllInlinedImagePatterns()
Returns a collection of all image types that get inlined.
|
Collection<String> |
getAllInterWikiLinks()
Returns a collection of all supported InterWiki links.
|
String |
getApplicationName()
Returns the name of the application.
|
AttachmentManager |
getAttachmentManager()
Returns the current AttachmentManager, which is responsible for
storing and managing attachments.
|
Object |
getAttribute(String key)
Gets an attribute from the engine.
|
AuthenticationManager |
getAuthenticationManager()
Returns the currently used authentication manager.
|
AuthorizationManager |
getAuthorizationManager()
Returns the currently used authorization manager.
|
String |
getBaseURL()
Returns the base URL, telling where this Wiki actually lives.
|
CommandResolver |
getCommandResolver()
Returns the CommandResolver for this wiki engine.
|
Charset |
getContentEncoding()
Returns the IANA name of the character set encoding we're
supposed to be using right now.
|
String |
getCurrentProvider()
Returns the provider name.
|
String |
getCurrentProviderInfo()
Return information about current provider.
|
WatchDog |
getCurrentWatchDog()
Returns a WatchDog for current thread.
|
String |
getDiff(WikiContext context,
int version1,
int version2)
Returns a diff of two versions of a page.
|
DifferenceManager |
getDifferenceManager()
Returns the DifferenceManager so that texts can be compared.
|
EditorManager |
getEditorManager()
Returns the current EditorManager instance.
|
<T extends FilterManager> |
getFilterManager()
Returns the manager responsible for the filters.
|
String |
getFinalPageName(String page)
Returns the correct page name, or null, if no such
page can be found.
|
String |
getFrontPage()
Returns the default front page, if no page is used.
|
String |
getGlobalRSSURL()
Returns the URL of the global RSS file.
|
GroupManager |
getGroupManager()
Returns the GroupManager employed by this WikiEngine.
|
String |
getHTML(String page)
Returns the converted HTML of the page.
|
String |
getHTML(String pagename,
int version)
Returns the converted HTML of the page's specific version.
|
String |
getHTML(WikiContext context,
WikiPage page)
Returns the converted HTML of the page using a different
context than the default context.
|
static WikiEngine |
getInstance(javax.servlet.ServletConfig config)
Gets a WikiEngine related to this servlet.
|
static WikiEngine |
getInstance(javax.servlet.ServletConfig config,
Properties props)
Gets a WikiEngine related to the servlet.
|
static WikiEngine |
getInstance(javax.servlet.ServletContext context,
Properties props)
Gets a WikiEngine related to the servlet.
|
InternationalizationManager |
getInternationalizationManager()
Returns the current i18n manager.
|
String |
getInterWikiURL(String wikiName)
Returns an URL to some other Wiki that we know.
|
WikiPage |
getPage(String pagereq)
Finds the corresponding WikiPage object based on the page name.
|
WikiPage |
getPage(String pagereq,
int version)
Finds the corresponding WikiPage object base on the page name and version.
|
int |
getPageCount()
Returns the number of pages in this Wiki
|
PageManager |
getPageManager()
Returns the current PageManager which is responsible for storing
and managing WikiPages.
|
PageRenamer |
getPageRenamer()
Returns the PageRenamer employed by this WikiEngine.
|
<T extends PluginManager> |
getPluginManager()
Returns the current plugin manager.
|
ProgressManager |
getProgressManager()
Returns the progress manager we're using
|
String |
getPureText(String page,
int version)
Returns the pure text of a page, no conversions.
|
String |
getPureText(WikiPage page)
Returns the pure text of a page, no conversions.
|
Set<WikiPage> |
getRecentChanges()
Returns a Collection of WikiPages, sorted in time
order of last change (i.e. first object is the most
recently changed).
|
String |
getRedirectURL(WikiContext context)
Figure out to which page we are really going to.
|
ReferenceManager |
getReferenceManager()
Returns this object's ReferenceManager.
|
RenderingManager |
getRenderingManager()
Returns the current rendering manager for this wiki application.
|
String |
getRootPath()
Returns the root path.
|
RSSGenerator |
getRSSGenerator()
Returns the RSSGenerator.
|
SearchManager |
getSearchManager()
Returns the manager responsible for searching the Wiki.
|
javax.servlet.ServletContext |
getServletContext()
Returns the ServletContext that this particular WikiEngine was
initialized with.
|
String |
getSpecialPageReference(String original)
If the page is a special page, then returns a direct URL
to that page.
|
Date |
getStartTime()
Returns the moment when this engine was started.
|
TasksManager |
getTasksManager()
Returns the TasksManager employed by this WikiEngine.
|
String |
getTemplateDir()
Returns the current template directory.
|
TemplateManager |
getTemplateManager()
Returns the current TemplateManager.
|
String |
getText(String page)
Returns the un-HTMLized text of the latest version of a page.
|
String |
getText(String page,
int version)
Returns the un-HTMLized text of the given version of a page.
|
String |
getText(WikiContext context,
WikiPage page)
Returns the un-HTMLized text of the given version of a page in
the given context.
|
String |
getURL(String context,
String pageName,
String params,
boolean absolute)
Returns an URL if a WikiContext is not available.
|
URLConstructor |
getURLConstructor() |
UserManager |
getUserManager()
Returns the UserManager employed by this WikiEngine.
|
String |
getVariable(WikiContext context,
String name)
Shortcut to getVariableManager().getValue().
|
VariableManager |
getVariableManager()
Returns the current variable manager.
|
List<? extends WikiPage> |
getVersionHistory(String page)
Returns a Collection of WikiPages containing the version history of a page.
|
String |
getViewURL(String pageName)
Returns the basic absolute URL to a page, without any modifications.
|
Properties |
getWikiProperties()
Returns the set of properties that the WikiEngine was initialized
with.
|
String |
getWorkDir()
Returns the JSPWiki working directory set with "jspwiki.workDir".
|
WorkflowManager |
getWorkflowManager()
Returns the
WorkflowManager associated with this
WikiEngine. |
void |
initReferenceManager()
Initializes the reference manager.
|
boolean |
pageExists(String page)
Returns true, if the requested page (or an alias) exists.
|
boolean |
pageExists(String page,
int version)
Returns true, if the requested page (or an alias) exists with the
requested version.
|
boolean |
pageExists(WikiPage page)
Returns true, if the requested page (or an alias) exists, with the
specified version in the WikiPage.
|
Object |
removeAttribute(String key)
Removes an attribute.
|
void |
removeWikiEventListener(WikiEventListener listener)
Un-registers a WikiEventListener with this instance.
|
String |
renamePage(WikiContext context,
String renameFrom,
String renameTo,
boolean changeReferrers)
Renames, or moves, a wiki page.
|
void |
saveText(WikiContext context,
String text)
Writes the WikiText of a page into the page repository.
|
Collection<String> |
scanWikiLinks(WikiPage page,
String pagedata)
Reads a WikiPageful of data from a String and returns all links
internal to this Wiki in a Collection.
|
void |
setAttribute(String key,
Object value)
Adds an attribute to the engine for the duration of this engine.
|
protected void |
shutdown()
Protected method that signals that the WikiEngine will be
shut down by the servlet container.
|
String |
textToHTML(WikiContext context,
String pagedata)
Converts raw page data to HTML.
|
String |
textToHTML(WikiContext context,
String pagedata,
StringTransmutator localLinkHook,
StringTransmutator extLinkHook)
Just convert WikiText to HTML.
|
String |
textToHTML(WikiContext context,
String pagedata,
StringTransmutator localLinkHook,
StringTransmutator extLinkHook,
StringTransmutator attLinkHook)
Just convert WikiText to HTML.
|
void |
updateReferences(WikiPage page)
Updates all references for the given page.
|
public static final String DEFAULT_INLINEPATTERN
public static final String DEFAULT_TEMPLATE_NAME
public static final String PROP_APPNAME
public static final String PROP_INLINEIMAGEPTRN
public static final String PROP_INTERWIKIREF
public static final String PROP_STOREUSERNAME
public static final String PROP_ENCODING
public static final String PROP_NO_FILTER_ENCODING
public static final String PROP_REFSTYLE
public static final String PROP_BEAUTIFYTITLE
public static final String PROP_WORKDIR
public static final String PREFS_COOKIE_NAME
public static final String PROP_MATCHPLURALS
public static final String PROP_TEMPLATEDIR
public static final String PROP_FRONTPAGE
public static final String PROP_URLCONSTRUCTOR
public static final String PROP_RUNFILTERS
public static final String PROP_ACL_MANAGER_IMPL
public static final String PROP_ALLOW_CREATION_OF_EMPTY_PAGES
public WikiEngine(Properties properties) throws WikiException
properties
- A set of properties to use to initialize this WikiEngine.WikiException
- If the initialization fails.protected WikiEngine(javax.servlet.ServletContext context, String appid, Properties props) throws WikiException
context
- A ServletContext.appid
- An Application ID. This application is an unique random string which
is used to recognize this WikiEngine.props
- The WikiEngine configuration.WikiException
- If the WikiEngine construction fails.public static WikiEngine getInstance(javax.servlet.ServletConfig config) throws InternalWikiException
config
- The ServletConfig object for this servlet.InternalWikiException
- in case something fails. This
is a RuntimeException, so be prepared for it.public static WikiEngine getInstance(javax.servlet.ServletConfig config, Properties props)
config
- The ServletConfig of the webapp servlet/JSP calling this method.props
- A set of properties, or null, if we are to load JSPWiki's default
jspwiki.properties (this is the usual case).public static WikiEngine getInstance(javax.servlet.ServletContext context, Properties props) throws InternalWikiException
context
- The ServletContext of the webapp servlet/JSP calling this method.props
- A set of properties, or null, if we are to load JSPWiki's default
jspwiki.properties (this is the usual case).InternalWikiException
- If the WikiEngine instantiation fails.public void initReferenceManager() throws WikiException
WikiException
- If the reference manager initialization fails.public Properties getWikiProperties()
public String getWorkDir()
public String getTemplateDir()
public TemplateManager getTemplateManager()
public String getBaseURL()
public Date getStartTime()
public String getViewURL(String pageName)
Returns the basic absolute URL to a page, without any modifications. You may add any parameters to this.
Since 2.3.90 it is safe to call this method with null
pageName, in which case it will default to the front page.
pageName
- The name of the page. May be null, in which case defaults to the front page.public String getURL(String context, String pageName, String params, boolean absolute)
context
- The WikiContext (VIEW, EDIT, etc...)pageName
- Name of the page, as usualparams
- List of parameters. May be null, if no parameters.absolute
- If true, will generate an absolute URL regardless of properties setting.public String getFrontPage()
public javax.servlet.ServletContext getServletContext()
public String getInterWikiURL(String wikiName)
wikiName
- The name of the other wiki.public Collection<String> getAllInterWikiLinks()
public Collection<String> getAllInlinedImagePatterns()
public String getSpecialPageReference(String original)
If the page is a special page, then returns a direct URL
to that page. Otherwise returns null
.
This method delegates requests to
CommandResolver.getSpecialPageReference(String)
.
Special pages are defined in jspwiki.properties using the jspwiki.specialPage setting. They're typically used to give Wiki page names to e.g. custom JSP pages.
original
- The page to checkpublic String getApplicationName()
public String beautifyTitle(String title)
title
- The title to beautifypublic String beautifyTitleNoBreak(String title)
title
- The title to beautifypublic boolean pageExists(String page)
page
- WikiName of the page.public boolean pageExists(String page, int version) throws ProviderException
page
- Page nameversion
- Page versionProviderException
- If the provider fails.public boolean pageExists(WikiPage page) throws ProviderException
page
- A WikiPage object describing the name and version.ProviderException
- If something goes badly wrong.public String getFinalPageName(String page) throws ProviderException
CommandResolver.getFinalPageName(String)
.page
- Page name.ProviderException
- If something goes wrong in the backend.public String encodeName(String pagename)
pagename
- A name. Can be actually any string.decodeName(String)
public String decodeName(String pagerequest)
pagerequest
- The URL-encoded string to decodeencodeName(String)
public Charset getContentEncoding()
public WorkflowManager getWorkflowManager()
WorkflowManager
associated with this
WikiEngine. If the WIkiEngine has not been initialized, this method will return
null
.public String getText(String page)
page
- WikiName of the page to fetch.public String getText(String page, int version)
page
- WikiName of the page to fetchversion
- Version of the page to fetchpublic String getText(WikiContext context, WikiPage page)
This method also replaces the < and & -characters with their respective HTML entities, thus making it suitable for inclusion on an HTML page. If you want to have the page text without any conversions, use getPureText().
context
- The WikiContextpage
- A page reference (not an attachment)getPureText(WikiPage)
public String getPureText(String page, int version)
page
- The name of the page to fetch.version
- If WikiPageProvider.LATEST_VERSION, then uses the
latest version.public String getPureText(WikiPage page)
page
- A handle to the WikiPagepublic String getHTML(WikiContext context, WikiPage page)
context
- A WikiContext in which you wish to render this page in.page
- WikiPage reference.public String getHTML(String page)
page
- WikiName of the page to convert.public String getHTML(String pagename, int version)
pagename
- WikiName of the page to convert.version
- Version number to fetchpublic String textToHTML(WikiContext context, String pagedata)
pagedata
- Raw page data to convert to HTMLcontext
- The WikiContext in which the page is to be renderedprotected void shutdown()
WikiServlet.destroy()
. When this method is called,
it fires a "shutdown" WikiEngineEvent to all registered
listeners.public Collection<String> scanWikiLinks(WikiPage page, String pagedata)
page
- The WikiPage to scanpagedata
- The page contentspublic String textToHTML(WikiContext context, String pagedata, StringTransmutator localLinkHook, StringTransmutator extLinkHook)
context
- The WikiContext in which to do the conversionpagedata
- The data to renderlocalLinkHook
- Is called whenever a wiki link is foundextLinkHook
- Is called whenever an external link is foundpublic String textToHTML(WikiContext context, String pagedata, StringTransmutator localLinkHook, StringTransmutator extLinkHook, StringTransmutator attLinkHook)
context
- The WikiContext in which to do the conversionpagedata
- The data to renderlocalLinkHook
- Is called whenever a wiki link is foundextLinkHook
- Is called whenever an external link is foundattLinkHook
- Is called whenever an attachment link is foundpublic void updateReferences(WikiPage page)
page
- wiki page for which references should be updatedpublic void saveText(WikiContext context, String text) throws WikiException
jspwiki.properties
file contains
the property jspwiki.approver.workflow.saveWikiPage
and its value resolves to a valid user,
Group
or Role
, this method will
place a Decision
in the approver's workflow inbox and throw a
DecisionRequiredException
. If the submitting user is authenticated and the
page save is rejected, a notification will be placed in the user's decision queue.context
- The current WikiContexttext
- The Wiki markup for the page.WikiException
- if the save operation encounters an error during the save operation. If the page-save
operation requires approval, the exception will be of type DecisionRequiredException
.
Individual PageFilters, such as the SpamFilter
may also throw a
RedirectException
.public int getPageCount()
public String getCurrentProvider()
public String getCurrentProviderInfo()
public Set<WikiPage> getRecentChanges()
public WikiPage getPage(String pagereq)
pagereq
- The name of the page to look for.public WikiPage getPage(String pagereq, int version)
pagereq
- The name of the page to look for.version
- The version number to look for. May be WikiProvider.LATEST_VERSION,
in which case it will look for the latest version (and this method then becomes
the equivalent of getPage(String).public List<? extends WikiPage> getVersionHistory(String page)
page
- Name of the page to look forpublic String getDiff(WikiContext context, int version1, int version2)
Note that the API was changed in 2.6 to provide a WikiContext object!
context
- The WikiContext of the page you wish to get a diff fromversion1
- Version number of the old page. If WikiPageProvider.LATEST_VERSION (-1), then uses current page.version2
- Version number of the new page. If WikiPageProvider.LATEST_VERSION (-1), then uses current page.public ReferenceManager getReferenceManager()
public RenderingManager getRenderingManager()
public <T extends PluginManager> T getPluginManager()
public VariableManager getVariableManager()
public String getVariable(WikiContext context, String name)
context
- WikiContext to look the variable inname
- Name of the variable to look forpublic PageManager getPageManager()
public CommandResolver getCommandResolver()
public AttachmentManager getAttachmentManager()
public AuthorizationManager getAuthorizationManager()
public AuthenticationManager getAuthenticationManager()
public <T extends FilterManager> T getFilterManager()
public SearchManager getSearchManager()
public ProgressManager getProgressManager()
public String getRedirectURL(WikiContext context)
WikiContext.getRedirectURL()
.context
- The Wiki Context in which the request is being made.public WikiContext createContext(javax.servlet.http.HttpServletRequest request, String requestContext)
request
- the HTTP requestrequestContext
- the default context to useCommandResolver
,
Command
public void deletePage(String pageName) throws ProviderException
pageName
- The name of the page.ProviderException
- If something goes wrong.public void deleteVersion(WikiPage page) throws ProviderException
page
- The page object.ProviderException
- If something goes wrong.public String getGlobalRSSURL()
public String getRootPath()
public URLConstructor getURLConstructor()
public RSSGenerator getRSSGenerator()
jspwiki.rss.generate
has not been set to true
, this method will return null
,
and callers should check for this value.public String renamePage(WikiContext context, String renameFrom, String renameTo, boolean changeReferrers) throws WikiException
context
- The context during which this rename takes
place.renameFrom
- Name of the source page.renameTo
- Name of the destination page.changeReferrers
- If true, then changes any referring links
to point to the renamed page.WikiException
- In the case of an error, such as the destination
page already existing.public PageRenamer getPageRenamer()
public UserManager getUserManager()
public TasksManager getTasksManager()
public GroupManager getGroupManager()
public AdminBeanManager getAdminBeanManager()
AdminBeanManager
.AdminBeanManager
.public AclManager getAclManager()
The AclManager implementing class may be set by the
System property PROP_ACL_MANAGER_IMPL
.
public DifferenceManager getDifferenceManager()
public EditorManager getEditorManager()
public InternationalizationManager getInternationalizationManager()
public final void addWikiEventListener(WikiEventListener listener)
listener
- the event listenerpublic final void removeWikiEventListener(WikiEventListener listener)
listener
- the event listenerprotected final void fireEvent(int type)
type
- the event typeprotected final void firePageEvent(int type, String pageName)
type
- the event typeprotected final void firePageRenameEvent(String oldName, String newName)
oldName
- the former page namenewName
- the new page namepublic void setAttribute(String key, Object value)
key
- the attribute namevalue
- the valuepublic Object getAttribute(String key)
key
- the attribute namepublic Object removeAttribute(String key)
key
- The key of the attribute to remove.public WatchDog getCurrentWatchDog()
Copyright © 2001-2019 The Apache Software Foundation. All rights reserved.