Class WikiEngine
- All Implemented Interfaces:
Engine
public class WikiEngine extends java.lang.Object implements Engine
Engine
.
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.
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.Class<?>,java.lang.Object>
managers
Stores WikiEngine's associated managers.Fields inherited from interface org.apache.wiki.api.core.Engine
DEFAULT_INLINEPATTERN, DEFAULT_TEMPLATE_NAME, PREFS_COOKIE_NAME, PROP_ACL_MANAGER_IMPL, PROP_ALLOW_CREATION_OF_EMPTY_PAGES, PROP_APPNAME, PROP_ENCODING, PROP_FRONTPAGE, PROP_INLINEIMAGEPTRN, PROP_INTERWIKIREF, PROP_MATCHPLURALS, PROP_NO_FILTER_ENCODING, PROP_SEARCHPATH, PROP_STOREUSERNAME, PROP_TEMPLATEDIR, PROP_URLCONSTRUCTOR, PROP_WORKDIR
-
Constructor Summary
Constructors Modifier Constructor Description WikiEngine(java.util.Properties properties)
Instantiate the WikiEngine using a given set of properties.protected
WikiEngine(javax.servlet.ServletContext context, java.lang.String appid, java.util.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
Modifier and Type Method Description void
addWikiEventListener(WikiEventListener listener)
Registers a WikiEventListener with this instance.java.lang.String
decodeName(java.lang.String pagerequest)
Decodes a URL-encoded request back to regular life.java.lang.String
encodeName(java.lang.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, java.lang.String pageName)
Fires a WikiPageEvent to all registered listeners.AclManager
getAclManager()
Deprecated.AdminBeanManager
getAdminBeanManager()
Deprecated.usegetManager( AdminBeanManager.class )
instead.java.util.Collection<java.lang.String>
getAllInlinedImagePatterns()
Returns a collection of all image types that get inlined.java.util.Collection<java.lang.String>
getAllInterWikiLinks()
Returns a collection of all supported InterWiki links.java.lang.String
getApplicationName()
Returns the name of the application.AttachmentManager
getAttachmentManager()
Deprecated.usegetManager( AttachmentManager.class )
instead.<T> T
getAttribute(java.lang.String key)
Gets an attribute from the engine.AuthenticationManager
getAuthenticationManager()
Deprecated.usegetManager( AuthenticationManager.class )
instead.AuthorizationManager
getAuthorizationManager()
Deprecated.usegetManager( AuthorizationManager.class )
instead.java.lang.String
getBaseURL()
Returns the base URL, telling where this Wiki actually lives.CommandResolver
getCommandResolver()
Deprecated.usegetManager( CommandResolver.class )
instead.java.nio.charset.Charset
getContentEncoding()
Returns the IANA name of the character set encoding we're supposed to be using right now.DifferenceManager
getDifferenceManager()
Deprecated.usegetManager( DifferenceManager.class )
instead.EditorManager
getEditorManager()
Deprecated.usegetManager( EditorManager.class )
instead.FilterManager
getFilterManager()
Deprecated.usegetManager( FilterManager.class )
instead.java.lang.String
getFinalPageName(java.lang.String page)
Returns the correct page name, or null, if no such page can be found.java.lang.String
getFrontPage()
Returns the default front page, if no page is used.java.lang.String
getGlobalRSSURL()
Returns the URL of the global RSS file.GroupManager
getGroupManager()
Deprecated.usegetManager( GroupManager.class )
instead.static WikiEngine
getInstance(javax.servlet.ServletConfig config)
Gets a WikiEngine related to this servlet.static WikiEngine
getInstance(javax.servlet.ServletConfig config, java.util.Properties props)
Gets a WikiEngine related to the servlet.static WikiEngine
getInstance(javax.servlet.ServletContext context, java.util.Properties props)
Gets a WikiEngine related to the servlet.InternationalizationManager
getInternationalizationManager()
Deprecated.usegetManager( InternationalizationManager.class )
instead.java.lang.String
getInterWikiURL(java.lang.String wikiName)
Returns an URL to some other Wiki that we know.<T> T
getManager(java.lang.Class<T> manager)
Retrieves the object instantiated by the Engine matching the requested type.<T> java.util.List<T>
getManagers(java.lang.Class<T> manager)
Retrieves the objects instantiated by the Engine that can be assigned to the requested type.PageManager
getPageManager()
Deprecated.usegetManager( PageManager.class )
instead.PageRenamer
getPageRenamer()
Deprecated.usegetManager( PageRenamer.class )
instead.PluginManager
getPluginManager()
Deprecated.usegetManager( PluginManager.class )
instead.ProgressManager
getProgressManager()
Deprecated.usegetManager( ProgressManager.class )
instead.ReferenceManager
getReferenceManager()
Deprecated.usegetManager( ReferenceManager.class )
instead.RenderingManager
getRenderingManager()
Deprecated.usegetManager( RenderingManager.class )
instead.java.lang.String
getRootPath()
Returns the root path.RSSGenerator
getRSSGenerator()
Deprecated.usegetManager( RSSGenerator.class )
instead.SearchManager
getSearchManager()
Deprecated.usegetManager( SearchManager.class )
instead.javax.servlet.ServletContext
getServletContext()
Returns the ServletContext that this particular Engine was initialized with.java.lang.String
getSpecialPageReference(java.lang.String original)
If the page is a special page, then returns a direct URL to that page.java.util.Date
getStartTime()
Returns the moment when this engine was started.TasksManager
getTasksManager()
Deprecated.usegetManager( TaskManager.class )
instead.java.lang.String
getTemplateDir()
Returns the current template directory.TemplateManager
getTemplateManager()
Deprecated.usegetManager( TemplateManager.class )
instead.java.lang.String
getURL(java.lang.String context, java.lang.String pageName, java.lang.String params)
Returns an URL if a WikiContext is not available.URLConstructor
getURLConstructor()
Deprecated.usegetManager( URLConstructor.class )
instead.UserManager
getUserManager()
Deprecated.usegetManager( UserManager.class )
instead.VariableManager
getVariableManager()
Deprecated.usegetManager( VariableManager.class )
instead.java.util.Properties
getWikiProperties()
Returns the set of properties that the Engine was initialized with.java.lang.String
getWorkDir()
Returns the JSPWiki working directory set with "jspwiki.workDir".WorkflowManager
getWorkflowManager()
Deprecated.usegetManager( WorkflowManager.class )
instead.void
initReferenceManager()
Initializes the reference manager.boolean
isConfigured()
check if the Engine has been configured.<T> T
removeAttribute(java.lang.String key)
Removes an attribute.void
removeWikiEventListener(WikiEventListener listener)
Un-registers a WikiEventListener with this instance.void
setAttribute(java.lang.String key, java.lang.Object value)
Adds an attribute to the engine for the duration of this engine.void
shutdown()
Signals that the Engine will be shut down by the servlet container.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.wiki.api.core.Engine
adapt, findConfigFile, getPluginSearchPath
-
Field Details
-
managers
Stores WikiEngine's associated managers.
-
-
Constructor Details
-
WikiEngine
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, java.lang.String appid, java.util.Properties props) throws WikiExceptionInstantiate 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 Details
-
getInstance
public static WikiEngine getInstance(javax.servlet.ServletConfig config) throws InternalWikiExceptionGets 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, java.util.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, java.util.Properties props) throws InternalWikiExceptionGets 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.
-
getManager
Retrieves the object instantiated by the Engine matching the requested type.- Specified by:
getManager
in interfaceEngine
- Type Parameters:
T
- type of the requested object.- Parameters:
manager
- requested object instantiated by the Engine.- Returns:
- requested object instantiated by the Engine,
null
if not available.
-
getManagers
Retrieves the objects instantiated by the Engine that can be assigned to the requested type.- Specified by:
getManagers
in interfaceEngine
- Type Parameters:
T
- type of the requested object.- Parameters:
manager
- requested objectx instantiated by the Engine.- Returns:
- collection of requested objects instantiated by the Engine,
empty
list if none available.
-
isConfigured
check if the Engine has been configured.- Specified by:
isConfigured
in interfaceEngine
- Returns:
true
if it has,false
otherwise.
-
initReferenceManager
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
Returns the set of properties that the Engine 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.- Specified by:
getWikiProperties
in interfaceEngine
- Returns:
- The wiki properties
-
getWorkDir
Returns the JSPWiki working directory set with "jspwiki.workDir".- Specified by:
getWorkDir
in interfaceEngine
- Returns:
- The working directory.
-
getTemplateDir
Returns the current template directory.- Specified by:
getTemplateDir
in interfaceEngine
- Returns:
- The template directory as initialized by the engine.
-
getStartTime
Returns the moment when this engine was started.- Specified by:
getStartTime
in interfaceEngine
- Returns:
- The start time of this wiki.
-
getBaseURL
Returns the base URL, telling where this Wiki actually lives.- Specified by:
getBaseURL
in interfaceEngine
- Returns:
- The Base URL.
-
getGlobalRSSURL
Returns the URL of the global RSS file. May be null, if the RSS file generation is not operational.- Specified by:
getGlobalRSSURL
in interfaceEngine
- Returns:
- The global RSS url
-
getInterWikiURL
Returns an URL to some other Wiki that we know.- Specified by:
getInterWikiURL
in interfaceEngine
- Parameters:
wikiName
- The name of the other wiki.- Returns:
- null, if no such reference was found.
-
getURL
public java.lang.String getURL(java.lang.String context, java.lang.String pageName, java.lang.String params)Returns an URL if a WikiContext is not available. -
getFrontPage
Returns the default front page, if no page is used.- Specified by:
getFrontPage
in interfaceEngine
- Returns:
- The front page name.
-
getServletContext
Returns the ServletContext that this particular Engine was initialized with. It may returnnull
, if the Engine is not running inside a servlet container!- Specified by:
getServletContext
in interfaceEngine
- Returns:
- ServletContext of the Engine, or
null
.
-
getAllInterWikiLinks
Returns a collection of all supported InterWiki links.- Specified by:
getAllInterWikiLinks
in interfaceEngine
- Returns:
- A Collection of Strings.
-
getAllInlinedImagePatterns
Returns a collection of all image types that get inlined.- Specified by:
getAllInlinedImagePatterns
in interfaceEngine
- Returns:
- A Collection of Strings with a regexp pattern.
-
getSpecialPageReference
If the page is a special page, then returns a direct URL to that page. Otherwise returns
null
. This method delegates requests toCommandResolver.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.
- Specified by:
getSpecialPageReference
in interfaceEngine
- Parameters:
original
- The page to check- Returns:
- A reference to the page, or null, if there's no special page.
-
getApplicationName
Returns the name of the application.- Specified by:
getApplicationName
in interfaceEngine
- Returns:
- A string describing the name of this application.
-
getFinalPageName
Returns the correct page name, or null, if no such page can be found. Aliases are considered. This method simply delegates toCommandResolver.getFinalPageName(String)
.- Specified by:
getFinalPageName
in interfaceEngine
- 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.
-
encodeName
Turns a WikiName into something that can be called through using an URL.- Specified by:
encodeName
in interfaceEngine
- Parameters:
pagename
- A name. Can be actually any string.- Returns:
- A properly encoded name.
- See Also:
Engine.decodeName(String)
-
decodeName
Decodes a URL-encoded request back to regular life. This properly heeds the encoding as defined in the settings file.- Specified by:
decodeName
in interfaceEngine
- Parameters:
pagerequest
- The URL-encoded string to decode- Returns:
- A decoded string.
- See Also:
Engine.encodeName(String)
-
getContentEncoding
Returns the IANA name of the character set encoding we're supposed to be using right now.- Specified by:
getContentEncoding
in interfaceEngine
- Returns:
- The content encoding (either UTF-8 or ISO-8859-1).
-
shutdown
Signals that the Engine 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. -
getTemplateManager
Deprecated.usegetManager( TemplateManager.class )
instead.Returns the current TemplateManager.- Returns:
- A TemplateManager instance.
-
getWorkflowManager
Deprecated.usegetManager( WorkflowManager.class )
instead.Returns theWorkflowManager
associated with this WikiEngine. If the WikiEngine has not been initialized, this method will returnnull
.- Returns:
- the task queue
-
getReferenceManager
Deprecated.usegetManager( ReferenceManager.class )
instead.Returns this object's ReferenceManager.- Returns:
- The current ReferenceManager instance.
- Since:
- 1.6.1
-
getRenderingManager
Deprecated.usegetManager( RenderingManager.class )
instead.Returns the current rendering manager for this wiki application.- Returns:
- A RenderingManager object.
- Since:
- 2.3.27
-
getPluginManager
Deprecated.usegetManager( PluginManager.class )
instead.Returns the current plugin manager.- Returns:
- The current PluginManager instance
- Since:
- 1.6.1
-
getVariableManager
Deprecated.usegetManager( VariableManager.class )
instead.Returns the current variable manager.- Returns:
- The current VariableManager.
-
getPageManager
Deprecated.usegetManager( PageManager.class )
instead.Returns the current PageManager which is responsible for storing and managing WikiPages.- Returns:
- The current PageManager instance.
-
getCommandResolver
Deprecated.usegetManager( CommandResolver.class )
instead.Returns the CommandResolver for this wiki engine.- Returns:
- the resolver
-
getAttachmentManager
Deprecated.usegetManager( AttachmentManager.class )
instead.Returns the current AttachmentManager, which is responsible for storing and managing attachments.- Returns:
- The current AttachmentManager instance
- Since:
- 1.9.31.
-
getAuthorizationManager
Deprecated.usegetManager( AuthorizationManager.class )
instead.Returns the currently used authorization manager.- Returns:
- The current AuthorizationManager instance.
-
getAuthenticationManager
Deprecated.usegetManager( AuthenticationManager.class )
instead.Returns the currently used authentication manager.- Returns:
- The current AuthenticationManager instance.
-
getFilterManager
Deprecated.usegetManager( FilterManager.class )
instead.Returns the manager responsible for the filters.- Returns:
- The current FilterManager instance.
- Since:
- 2.1.88
-
getSearchManager
Deprecated.usegetManager( SearchManager.class )
instead.Returns the manager responsible for searching the Wiki.- Returns:
- The current SearchManager instance.
- Since:
- 2.2.21
-
getProgressManager
Deprecated.usegetManager( ProgressManager.class )
instead.Returns the progress manager we're using- Returns:
- A ProgressManager.
- Since:
- 2.6
-
getRootPath
Returns the root path. The root path is where the Engine is located in the file system.- Specified by:
getRootPath
in interfaceEngine
- Returns:
- A path to where the Wiki is installed in the local filesystem.
-
getURLConstructor
Deprecated.usegetManager( URLConstructor.class )
instead.- Returns:
- the URL constructor.
- Since:
- 2.2.6
-
getRSSGenerator
Deprecated.usegetManager( RSSGenerator.class )
instead.Returns the RSSGenerator. If the propertyjspwiki.rss.generate
has not been set totrue
, this method will returnnull
, and callers should check for this value.- Returns:
- the RSS generator
- Since:
- 2.1.165
-
getPageRenamer
Deprecated.usegetManager( PageRenamer.class )
instead.Returns the PageRenamer employed by this WikiEngine.- Returns:
- The current PageRenamer instance.
- Since:
- 2.5.141
-
getUserManager
Deprecated.usegetManager( UserManager.class )
instead.Returns the UserManager employed by this WikiEngine.- Returns:
- The current UserManager instance.
- Since:
- 2.3
-
getTasksManager
Deprecated.usegetManager( TaskManager.class )
instead.Returns the TasksManager employed by this WikiEngine.- Returns:
- The current TasksManager instance.
-
getGroupManager
Deprecated.usegetManager( GroupManager.class )
instead.Returns the GroupManager employed by this WikiEngine.- Returns:
- The current GroupManager instance.
- Since:
- 2.3
-
getAdminBeanManager
Deprecated.usegetManager( AdminBeanManager.class )
instead.Returns the currentAdminBeanManager
.- Returns:
- The current
AdminBeanManager
. - Since:
- 2.6
-
getAclManager
Deprecated.usegetManager( AclManager.class )
instead.Returns the AclManager employed by this WikiEngine. The AclManager is lazily initialized.The AclManager implementing class may be set by the System property
Engine.PROP_ACL_MANAGER_IMPL
.- Returns:
- The current AclManager.
- Since:
- 2.3
-
getDifferenceManager
Deprecated.usegetManager( DifferenceManager.class )
instead.Returns the DifferenceManager so that texts can be compared.- Returns:
- the difference manager.
-
getEditorManager
Deprecated.usegetManager( EditorManager.class )
instead.Returns the current EditorManager instance.- Returns:
- The current EditorManager.
-
getInternationalizationManager
Deprecated.usegetManager( InternationalizationManager.class )
instead.Returns the current i18n manager.- Returns:
- The current Intertan... Interante... Internatatializ... Whatever.
-
addWikiEventListener
Registers a WikiEventListener with this instance.- Specified by:
addWikiEventListener
in interfaceEngine
- Parameters:
listener
- the event listener
-
removeWikiEventListener
Un-registers a WikiEventListener with this instance.- Specified by:
removeWikiEventListener
in interfaceEngine
- Parameters:
listener
- the event listener
-
fireEvent
Fires a WikiEngineEvent to all registered listeners.- Parameters:
type
- the event type
-
firePageEvent
Fires a WikiPageEvent to all registered listeners.- Parameters:
type
- the event type
-
setAttribute
Adds an attribute to the engine for the duration of this engine. The value is not persisted.- Specified by:
setAttribute
in interfaceEngine
- Parameters:
key
- the attribute namevalue
- the value
-
getAttribute
Gets an attribute from the engine.- Specified by:
getAttribute
in interfaceEngine
- Parameters:
key
- the attribute name- Returns:
- the value
-
removeAttribute
Removes an attribute.- Specified by:
removeAttribute
in interfaceEngine
- Parameters:
key
- The key of the attribute to remove.- Returns:
- The previous attribute, if it existed.
-
getManager( AclManager.class )
instead.