org.apache.wiki
Class WikiEngine

java.lang.Object
  extended by org.apache.wiki.WikiEngine

public class WikiEngine
extends Object

Provides Wiki services to the JSP page.

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.


Field Summary
static String DEFAULT_INLINEPATTERN
          The default inlining pattern.
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_BASEURL
          The name for the base URL to use in all references.
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_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.
 
Constructor Summary
  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.
 
Method Summary
 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.
 Collection findPages(String query)
          Parses an incoming search request, then does a search.
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.
 String getAttachmentURL(String attName)
          Deprecated.  
 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.
 String 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.
 String getEditURL(String pageName)
          Deprecated.  
<T extends FilterManager>
T
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.
 PageSorter getPageSorter()
          Get this engine's page name comparator.
<T extends PluginManager>
T
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.
 Collection 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.
 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 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.
 String safeGetParameter(javax.servlet.ServletRequest request, String name)
          Deprecated. JSPWiki now requires servlet API 2.3, which has a better way of dealing with this stuff. This will be removed in the near future.
 String safeGetQueryString(javax.servlet.http.HttpServletRequest request)
          Returns the query string (the portion after the question mark).
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_INLINEPATTERN

public static final String DEFAULT_INLINEPATTERN
The default inlining pattern. Currently "*.png"

See Also:
Constant Field Values

PROP_APPNAME

public static final String PROP_APPNAME
Property for application name

See Also:
Constant Field Values

PROP_INLINEIMAGEPTRN

public static final String PROP_INLINEIMAGEPTRN
This property defines the inline image pattern. It's current value is "jspwiki.translatorReader.inlinePattern"

See Also:
Constant Field Values

PROP_INTERWIKIREF

public static final String PROP_INTERWIKIREF
Property start for any interwiki reference.

See Also:
Constant Field Values

PROP_STOREUSERNAME

public static final String PROP_STOREUSERNAME
If true, then the user name will be stored with the page data.

See Also:
Constant Field Values

PROP_ENCODING

public static final String PROP_ENCODING
Define the used encoding. Currently supported are ISO-8859-1 and UTF-8

See Also:
Constant Field Values

PROP_BASEURL

public static final String PROP_BASEURL
The name for the base URL to use in all references.

See Also:
Constant Field Values

PROP_REFSTYLE

public static final String PROP_REFSTYLE
The name for the property which allows you to set the current reference style. The value is "jspwiki.referenceStyle".

See Also:
Constant Field Values

PROP_BEAUTIFYTITLE

public static final String PROP_BEAUTIFYTITLE
Property name for the "spaces in titles" -hack.

See Also:
Constant Field Values

PROP_WORKDIR

public static final String PROP_WORKDIR
Property name for where the jspwiki work directory should be. If not specified, reverts to ${java.tmpdir}.

See Also:
Constant Field Values

PREFS_COOKIE_NAME

public static final String PREFS_COOKIE_NAME
The name of the cookie that gets stored to the user browser.

See Also:
Constant Field Values

PROP_MATCHPLURALS

public static final String PROP_MATCHPLURALS
Property name for the "match english plurals" -hack.

See Also:
Constant Field Values

PROP_TEMPLATEDIR

public static final String PROP_TEMPLATEDIR
Property name for the template that is used.

See Also:
Constant Field Values

PROP_FRONTPAGE

public static final String PROP_FRONTPAGE
Property name for the default front page.

See Also:
Constant Field Values

PROP_URLCONSTRUCTOR

public static final String PROP_URLCONSTRUCTOR
Property name for setting the url generator instance

See Also:
Constant Field Values

PROP_RUNFILTERS

public static final String PROP_RUNFILTERS
If this property is set to false, all filters are disabled when translating.

See Also:
Constant Field Values

PROP_ACL_MANAGER_IMPL

public static final String PROP_ACL_MANAGER_IMPL
The name of the property containing the ACLManager implementing class. The value is "jspwiki.aclManager".

See Also:
Constant Field Values

PROP_ALLOW_CREATION_OF_EMPTY_PAGES

public static final String PROP_ALLOW_CREATION_OF_EMPTY_PAGES
If this property is set to false, we don't allow the creation of empty pages

See Also:
Constant Field Values
Constructor Detail

WikiEngine

public WikiEngine(Properties properties)
           throws WikiException
Instantiate the WikiEngine using a given set of properties. Use this constructor for testing purposes only.

Parameters:
properties - A set of properties to use to initialize this WikiEngine.
Throws:
WikiException - If the initialization fails.

WikiEngine

protected WikiEngine(javax.servlet.ServletContext context,
                     String appid,
                     Properties props)
              throws WikiException
Instantiate using this method when you're running as a servlet and WikiEngine will figure out where to look for the property file. Do not use this method - use WikiEngine.getInstance() instead.

Parameters:
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.
Throws:
WikiException - If the WikiEngine construction fails.
Method Detail

getInstance

public static WikiEngine getInstance(javax.servlet.ServletConfig config)
                              throws InternalWikiException
Gets a WikiEngine related to this servlet. Since this method is only called from JSP pages (and JspInit()) to be specific, we throw a RuntimeException if things don't work.

Parameters:
config - The ServletConfig object for this servlet.
Returns:
A WikiEngine instance.
Throws:
InternalWikiException - in case something fails. This is a RuntimeException, so be prepared for it.

getInstance

public static WikiEngine getInstance(javax.servlet.ServletConfig config,
                                     Properties props)
Gets a WikiEngine related to the servlet. Works like getInstance(ServletConfig), but does not force the Properties object. This method is just an optional way of initializing a WikiEngine for embedded JSPWiki applications; normally, you should use getInstance(ServletConfig).

Parameters:
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).
Returns:
One well-behaving WikiEngine instance.

getInstance

public static WikiEngine getInstance(javax.servlet.ServletContext context,
                                     Properties props)
                              throws InternalWikiException
Gets a WikiEngine related to the servlet. Works just like getInstance( ServletConfig )

Parameters:
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).
Returns:
One fully functional, properly behaving WikiEngine.
Throws:
InternalWikiException - If the WikiEngine instantiation fails.

initReferenceManager

public void initReferenceManager()
                          throws WikiException
Initializes the reference manager. Scans all existing WikiPages for internal links and adds them to the ReferenceManager object.

Throws:
WikiException - If the reference manager initialization fails.

getWikiProperties

public Properties getWikiProperties()
Returns the set of properties that the WikiEngine was initialized with. Note that this method returns a direct reference, so it's possible to manipulate the properties. However, this is not advised unless you really know what you're doing.

Returns:
The wiki properties

getWorkDir

public String getWorkDir()
Returns the JSPWiki working directory set with "jspwiki.workDir".

Returns:
The working directory.
Since:
2.1.100

getTemplateDir

public String getTemplateDir()
Returns the current template directory.

Returns:
The template directory as initialized by the engine.
Since:
1.9.20

getTemplateManager

public TemplateManager getTemplateManager()
Returns the current TemplateManager.

Returns:
A TemplateManager instance.

getBaseURL

public String getBaseURL()
Returns the base URL, telling where this Wiki actually lives.

Returns:
The Base URL.
Since:
1.6.1

getStartTime

public Date getStartTime()
Returns the moment when this engine was started.

Returns:
The start time of this wiki.
Since:
2.0.15.

getViewURL

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.

Parameters:
pageName - The name of the page. May be null, in which case defaults to the front page.
Returns:
An absolute URL to the page.
Since:
2.0.3

getEditURL

public String getEditURL(String pageName)
Deprecated. 

Returns the basic URL to an editor. Please use WikiContext.getURL() or WikiEngine.getURL() instead.

Parameters:
pageName - The name of the page.
Returns:
An URI.
Since:
2.0.3
See Also:
getURL(String, String, String, boolean), WikiContext.getURL(String, String)

getAttachmentURL

public String getAttachmentURL(String attName)
Deprecated. 

Returns the basic attachment URL.Please use WikiContext.getURL() or WikiEngine.getURL() instead.

Parameters:
attName - Attachment name
Returns:
An URI.
Since:
2.0.42.
See Also:
getURL(String, String, String, boolean), WikiContext.getURL(String, String)

getURL

public String getURL(String context,
                     String pageName,
                     String params,
                     boolean absolute)
Returns an URL if a WikiContext is not available.

Parameters:
context - The WikiContext (VIEW, EDIT, etc...)
pageName - Name of the page, as usual
params - List of parameters. May be null, if no parameters.
absolute - If true, will generate an absolute URL regardless of properties setting.
Returns:
An URL (absolute or relative).

getFrontPage

public String getFrontPage()
Returns the default front page, if no page is used.

Returns:
The front page name.

getServletContext

public javax.servlet.ServletContext getServletContext()
Returns the ServletContext that this particular WikiEngine was initialized with. It may return null, if the WikiEngine is not running inside a servlet container!

Returns:
ServletContext of the WikiEngine, or null.
Since:
1.7.10

safeGetParameter

public String safeGetParameter(javax.servlet.ServletRequest request,
                               String name)
Deprecated. JSPWiki now requires servlet API 2.3, which has a better way of dealing with this stuff. This will be removed in the near future.

This is a safe version of the Servlet.Request.getParameter() routine. Unfortunately, the default version always assumes that the incoming character set is ISO-8859-1, even though it was something else. This means that we need to make a new string using the correct encoding.

For more information, see: JGuru FAQ.

Incidentally, this is almost the same as encodeName(), below. I am not yet entirely sure if it's safe to merge the code.

Parameters:
request - The servlet request
name - The parameter name to get.
Returns:
The parameter value or null
Since:
1.5.3

safeGetQueryString

public String safeGetQueryString(javax.servlet.http.HttpServletRequest request)
Returns the query string (the portion after the question mark).

Parameters:
request - The HTTP request to parse.
Returns:
The query string. If the query string is null, returns an empty string.
Since:
2.1.3

getInterWikiURL

public String getInterWikiURL(String wikiName)
Returns an URL to some other Wiki that we know.

Parameters:
wikiName - The name of the other wiki.
Returns:
null, if no such reference was found.

getAllInterWikiLinks

public Collection<String> getAllInterWikiLinks()
Returns a collection of all supported InterWiki links.

Returns:
A Collection of Strings.

getAllInlinedImagePatterns

public Collection<String> getAllInlinedImagePatterns()
Returns a collection of all image types that get inlined.

Returns:
A Collection of Strings with a regexp pattern.

getSpecialPageReference

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.

Parameters:
original - The page to check
Returns:
A reference to the page, or null, if there's no special page.

getApplicationName

public String getApplicationName()
Returns the name of the application.

Returns:
A string describing the name of this application.

beautifyTitle

public 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. However, attachment names are only beautified by the name.

Parameters:
title - The title to beautify
Returns:
A beautified title (or, if beautification is off, returns the title without modification)
Since:
1.7.11

beautifyTitleNoBreak

public String beautifyTitleNoBreak(String title)
Beautifies the title of the page by appending non-breaking spaces in suitable places. This is really suitable only for HTML output, as it uses the &nbsp; -character.

Parameters:
title - The title to beautify
Returns:
A beautified title.
Since:
2.1.127

pageExists

public boolean pageExists(String page)
Returns true, if the requested page (or an alias) exists. Will consider any version as existing. Will also consider attachments.

Parameters:
page - WikiName of the page.
Returns:
true, if page (or attachment) exists.

pageExists

public boolean pageExists(String page,
                          int version)
                   throws ProviderException
Returns true, if the requested page (or an alias) exists with the requested version.

Parameters:
page - Page name
version - Page version
Returns:
True, if page (or alias, or attachment) exists
Throws:
ProviderException - If the provider fails.

pageExists

public boolean pageExists(WikiPage page)
                   throws ProviderException
Returns true, if the requested page (or an alias) exists, with the specified version in the WikiPage.

Parameters:
page - A WikiPage object describing the name and version.
Returns:
true, if the page (or alias, or attachment) exists.
Throws:
ProviderException - If something goes badly wrong.
Since:
2.0

getFinalPageName

public String getFinalPageName(String page)
                        throws ProviderException
Returns the correct page name, or null, if no such page can be found. Aliases are considered. This method simply delegates to CommandResolver.getFinalPageName(String).

Parameters:
page - Page name.
Returns:
The rewritten page name, or null, if the page does not exist.
Throws:
ProviderException - If something goes wrong in the backend.
Since:
2.0

encodeName

public String encodeName(String pagename)
Turns a WikiName into something that can be called through using an URL.

Parameters:
pagename - A name. Can be actually any string.
Returns:
A properly encoded name.
Since:
1.4.1
See Also:
decodeName(String)

decodeName

public String decodeName(String pagerequest)
Decodes a URL-encoded request back to regular life. This properly heeds the encoding as defined in the settings file.

Parameters:
pagerequest - The URL-encoded string to decode
Returns:
A decoded string.
See Also:
encodeName(String)

getContentEncoding

public String getContentEncoding()
Returns the IANA name of the character set encoding we're supposed to be using right now.

Returns:
The content encoding (either UTF-8 or ISO-8859-1).
Since:
1.5.3

getWorkflowManager

public WorkflowManager getWorkflowManager()
Returns the WorkflowManager associated with this WikiEngine. If the WIkiEngine has not been initialized, this method will return null.

Returns:
the task queue

getText

public String getText(String page)
Returns the un-HTMLized text of the latest version of a 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().

Parameters:
page - WikiName of the page to fetch.
Returns:
WikiText.

getText

public String getText(String page,
                      int version)
Returns the un-HTMLized text of the given version of a 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().

Parameters:
page - WikiName of the page to fetch
version - Version of the page to fetch
Returns:
WikiText.

getText

public String getText(WikiContext context,
                      WikiPage page)
Returns the un-HTMLized text of the given version of a page in the given context. USE THIS METHOD if you don't know what doing.

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().

Parameters:
context - The WikiContext
page - A page reference (not an attachment)
Returns:
The page content as HTMLized String.
Since:
1.9.15.
See Also:
getPureText(WikiPage)

getPureText

public String getPureText(String page,
                          int version)
Returns the pure text of a page, no conversions. Use this if you are writing something that depends on the parsing of the page. Note that you should always check for page existence through pageExists() before attempting to fetch the page contents.

Parameters:
page - The name of the page to fetch.
version - If WikiPageProvider.LATEST_VERSION, then uses the latest version.
Returns:
The page contents. If the page does not exist, returns an empty string.

getPureText

public String getPureText(WikiPage page)
Returns the pure text of a page, no conversions. Use this if you are writing something that depends on the parsing the page. Note that you should always check for page existence through pageExists() before attempting to fetch the page contents.

Parameters:
page - A handle to the WikiPage
Returns:
String of WikiText.
Since:
2.1.13.

getHTML

public String getHTML(WikiContext context,
                      WikiPage page)
Returns the converted HTML of the page using a different context than the default context.

Parameters:
context - A WikiContext in which you wish to render this page in.
page - WikiPage reference.
Returns:
HTML-rendered version of the page.

getHTML

public String getHTML(String page)
Returns the converted HTML of the page.

Parameters:
page - WikiName of the page to convert.
Returns:
HTML-rendered version of the page.

getHTML

public String getHTML(String pagename,
                      int version)
Returns the converted HTML of the page's specific version. The version must be a positive integer, otherwise the current version is returned.

Parameters:
pagename - WikiName of the page to convert.
version - Version number to fetch
Returns:
HTML-rendered page text.

textToHTML

public String textToHTML(WikiContext context,
                         String pagedata)
Converts raw page data to HTML.

Parameters:
pagedata - Raw page data to convert to HTML
context - The WikiContext in which the page is to be rendered
Returns:
Rendered page text

shutdown

protected void shutdown()
Protected method that signals that the WikiEngine will be shut down by the servlet container. It is called by WikiServlet.destroy(). When this method is called, it fires a "shutdown" WikiEngineEvent to all registered listeners.


scanWikiLinks

public 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.

Parameters:
page - The WikiPage to scan
pagedata - The page contents
Returns:
a Collection of Strings

textToHTML

public String textToHTML(WikiContext context,
                         String pagedata,
                         StringTransmutator localLinkHook,
                         StringTransmutator extLinkHook)
Just convert WikiText to HTML.

Parameters:
context - The WikiContext in which to do the conversion
pagedata - The data to render
localLinkHook - Is called whenever a wiki link is found
extLinkHook - Is called whenever an external link is found
Returns:
HTML-rendered page text.

textToHTML

public String textToHTML(WikiContext context,
                         String pagedata,
                         StringTransmutator localLinkHook,
                         StringTransmutator extLinkHook,
                         StringTransmutator attLinkHook)
Just convert WikiText to HTML.

Parameters:
context - The WikiContext in which to do the conversion
pagedata - The data to render
localLinkHook - Is called whenever a wiki link is found
extLinkHook - Is called whenever an external link is found
attLinkHook - Is called whenever an attachment link is found
Returns:
HTML-rendered page text.

updateReferences

public void updateReferences(WikiPage page)
Updates all references for the given page.

Parameters:
page - wiki page for which references should be updated

saveText

public void saveText(WikiContext context,
                     String text)
              throws WikiException
Writes the WikiText of a page into the page repository. If the 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.

Parameters:
context - The current WikiContext
text - The Wiki markup for the page.
Throws:
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.
Since:
2.1.28

getPageCount

public int getPageCount()
Returns the number of pages in this Wiki

Returns:
The total number of pages.

getCurrentProvider

public String getCurrentProvider()
Returns the provider name.

Returns:
The full class name of the current page provider.

getCurrentProviderInfo

public String getCurrentProviderInfo()
Return information about current provider. This method just calls the corresponding PageManager method, which in turn calls the provider method.

Returns:
A textual description of the current provider.
Since:
1.6.4

getRecentChanges

public Collection getRecentChanges()
Returns a Collection of WikiPages, sorted in time order of last change (i.e. first object is the most recently changed). This method also includes attachments.

Returns:
Collection of WikiPage objects. In reality, the returned collection is a Set, but due to API compatibility reasons, we're not changing the signature soon...

findPages

public Collection findPages(String query)
                     throws ProviderException,
                            IOException
Parses an incoming search request, then does a search.

The query is dependent on the actual chosen search provider - each one of them has a language of its own.

Parameters:
query - The query string
Returns:
A Collection of SearchResult objects.
Throws:
ProviderException - If the searching failed
IOException - If the searching failed

getPage

public WikiPage getPage(String pagereq)
Finds the corresponding WikiPage object based on the page name. It always finds the latest version of a page.

Parameters:
pagereq - The name of the page to look for.
Returns:
A WikiPage object, or null, if the page by the name could not be found.

getPage

public WikiPage getPage(String pagereq,
                        int version)
Finds the corresponding WikiPage object base on the page name and version.

Parameters:
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).
Returns:
A WikiPage object, or null, if the page could not be found; or if there is no such version of the page.
Since:
1.6.7.

getVersionHistory

public List getVersionHistory(String page)
Returns a Collection of WikiPages containing the version history of a page.

Parameters:
page - Name of the page to look for
Returns:
an ordered List of WikiPages, each corresponding to a different revision of the page.

getDiff

public String getDiff(WikiContext context,
                      int version1,
                      int version2)
Returns a diff of two versions of a page.

Note that the API was changed in 2.6 to provide a WikiContext object!

Parameters:
context - The WikiContext of the page you wish to get a diff from
version1 - 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.
Returns:
A HTML-ized difference between two pages. If there is no difference, returns an empty string.

getReferenceManager

public ReferenceManager getReferenceManager()
Returns this object's ReferenceManager.

Returns:
The current ReferenceManager instance.
Since:
1.6.1

getRenderingManager

public RenderingManager getRenderingManager()
Returns the current rendering manager for this wiki application.

Returns:
A RenderingManager object.
Since:
2.3.27

getPluginManager

public <T extends PluginManager> T getPluginManager()
Returns the current plugin manager. In 2.10 the PluginManager will be returned instead of the generic

Returns:
The current PluginManager instance
Since:
1.6.1

getVariableManager

public VariableManager getVariableManager()
Returns the current variable manager.

Returns:
The current VariableManager.

getVariable

public String getVariable(WikiContext context,
                          String name)
Shortcut to getVariableManager().getValue(). However, this method does not throw a NoSuchVariableException, but returns null in case the variable does not exist.

Parameters:
context - WikiContext to look the variable in
name - Name of the variable to look for
Returns:
Variable value, or null, if there is no such variable.
Since:
2.2

getPageManager

public PageManager getPageManager()
Returns the current PageManager which is responsible for storing and managing WikiPages.

Returns:
The current PageManager instance.

getCommandResolver

public CommandResolver getCommandResolver()
Returns the CommandResolver for this wiki engine.

Returns:
the resolver

getAttachmentManager

public AttachmentManager getAttachmentManager()
Returns the current AttachmentManager, which is responsible for storing and managing attachments.

Returns:
The current AttachmentManager instance
Since:
1.9.31.

getAuthorizationManager

public AuthorizationManager getAuthorizationManager()
Returns the currently used authorization manager.

Returns:
The current AuthorizationManager instance

getAuthenticationManager

public AuthenticationManager getAuthenticationManager()
Returns the currently used authentication manager.

Returns:
The current AuthenticationManager instance.

getFilterManager

public <T extends FilterManager> T getFilterManager()
Returns the manager responsible for the filters.

Returns:
The current FilterManager instance
Since:
2.1.88

getSearchManager

public SearchManager getSearchManager()
Returns the manager responsible for searching the Wiki.

Returns:
The current SearchManager instance
Since:
2.2.21

getProgressManager

public ProgressManager getProgressManager()
Returns the progress manager we're using

Returns:
A ProgressManager
Since:
2.6

getRedirectURL

public String getRedirectURL(WikiContext context)
Figure out to which page we are really going to. Considers special page names from the jspwiki.properties, and possible aliases. This method delgates requests to WikiContext.getRedirectURL().

Parameters:
context - The Wiki Context in which the request is being made.
Returns:
A complete URL to the new page to redirect to
Since:
2.2

createContext

public WikiContext createContext(javax.servlet.http.HttpServletRequest request,
                                 String requestContext)
Shortcut to create a WikiContext from a supplied HTTP request, using a default wiki context.

Parameters:
request - the HTTP request
requestContext - the default context to use
Returns:
a new WikiContext object.
Since:
2.1.15.
See Also:
CommandResolver, Command

deletePage

public void deletePage(String pageName)
                throws ProviderException
Deletes a page or an attachment completely, including all versions. If the page does not exist, does nothing.

Parameters:
pageName - The name of the page.
Throws:
ProviderException - If something goes wrong.

deleteVersion

public void deleteVersion(WikiPage page)
                   throws ProviderException
Deletes a specific version of a page or an attachment.

Parameters:
page - The page object.
Throws:
ProviderException - If something goes wrong.

getGlobalRSSURL

public String getGlobalRSSURL()
Returns the URL of the global RSS file. May be null, if the RSS file generation is not operational.

Returns:
The global RSS url
Since:
1.7.10

getRootPath

public String getRootPath()
Returns the root path. The root path is where the WikiEngine is located in the file system.

Returns:
A path to where the Wiki is installed in the local filesystem.
Since:
2.2

getURLConstructor

public URLConstructor getURLConstructor()
Returns:
the URL constructor
Since:
2.2.6

getRSSGenerator

public RSSGenerator getRSSGenerator()
Returns the RSSGenerator. If the property jspwiki.rss.generate has not been set to true, this method will return null, and callers should check for this value.

Returns:
the RSS generator
Since:
2.1.165

renamePage

public String renamePage(WikiContext context,
                         String renameFrom,
                         String renameTo,
                         boolean changeReferrers)
                  throws WikiException
Renames, or moves, a wiki page. Can also alter referring wiki links to point to the renamed page.

Parameters:
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.
Returns:
The name of the page that the source was renamed to.
Throws:
WikiException - In the case of an error, such as the destination page already existing.

getPageRenamer

public PageRenamer getPageRenamer()
Returns the PageRenamer employed by this WikiEngine.

Returns:
The current PageRenamer instance.
Since:
2.5.141

getUserManager

public UserManager getUserManager()
Returns the UserManager employed by this WikiEngine.

Returns:
The current UserManager instance.
Since:
2.3

getGroupManager

public GroupManager getGroupManager()
Returns the GroupManager employed by this WikiEngine.

Returns:
The current GroupManager instance
Since:
2.3

getAdminBeanManager

public AdminBeanManager getAdminBeanManager()
Returns the current AdminBeanManager.

Returns:
The current AdminBeanManager.
Since:
2.6

getAclManager

public AclManager getAclManager()
Returns the AclManager employed by this WikiEngine. The AclManager is lazily initialized.

The AclManager implementing class may be set by the System property PROP_ACL_MANAGER_IMPL.

Returns:
The current AclManager.
Since:
2.3

getDifferenceManager

public DifferenceManager getDifferenceManager()
Returns the DifferenceManager so that texts can be compared.

Returns:
the difference manager

getEditorManager

public EditorManager getEditorManager()
Returns the current EditorManager instance.

Returns:
The current EditorManager.

getInternationalizationManager

public InternationalizationManager getInternationalizationManager()
Returns the current i18n manager.

Returns:
The current Intertan... Interante... Internatatializ... Whatever.

addWikiEventListener

public final void addWikiEventListener(WikiEventListener listener)
Registers a WikiEventListener with this instance.

Parameters:
listener - the event listener

removeWikiEventListener

public final void removeWikiEventListener(WikiEventListener listener)
Un-registers a WikiEventListener with this instance.

Parameters:
listener - the event listener

fireEvent

protected final void fireEvent(int type)
Fires a WikiEngineEvent to all registered listeners.

Parameters:
type - the event type

firePageEvent

protected final void firePageEvent(int type,
                                   String pageName)
Fires a WikiPageEvent to all registered listeners.

Parameters:
type - the event type

firePageRenameEvent

protected final void firePageRenameEvent(String oldName,
                                         String newName)
Fires a WikiPageRenameEvent to all registered listeners.

Parameters:
oldName - the former page name
newName - the new page name

setAttribute

public void setAttribute(String key,
                         Object value)
Adds an attribute to the engine for the duration of this engine. The value is not persisted.

Parameters:
key - the attribute name
value - the value
Since:
2.4.91

getAttribute

public Object getAttribute(String key)
Gets an attribute from the engine.

Parameters:
key - the attribute name
Returns:
the value

removeAttribute

public Object removeAttribute(String key)
Removes an attribute.

Parameters:
key - The key of the attribute to remove.
Returns:
The previous attribute, if it existed.

getCurrentWatchDog

public WatchDog getCurrentWatchDog()
Returns a WatchDog for current thread.

Returns:
The current thread WatchDog.
Since:
2.4.92

getPageSorter

public PageSorter getPageSorter()
Get this engine's page name comparator.

Returns:
the PageSorter used to sort pages by name in this engine


Copyright © {inceptionYear}-2014 The Apache Software Foundation. All rights reserved.