public class PageManager extends ModuleManager implements WikiEventListener
Saving a page is a two-stage Task; first the pre-save operations and then the actual save. See the descriptions of the tasks for further information.
Modifier and Type | Class and Description |
---|---|
static class |
PageManager.PreSaveWikiPageTask
Inner class that handles the page pre-save actions.
|
static class |
PageManager.SaveWikiPageTask
Inner class that handles the actual page save and post-save actions.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
FACT_CURRENT_TEXT
Fact name for storing the current text.
|
static java.lang.String |
FACT_DIFF_TEXT
Fact name for storing a diff text.
|
static java.lang.String |
FACT_IS_AUTHENTICATED
Fact name for storing whether the user is authenticated or not.
|
static java.lang.String |
FACT_PAGE_NAME
Fact name for storing the page name.
|
static java.lang.String |
FACT_PROPOSED_TEXT
Fact name for storing the proposed (edited) text.
|
protected java.util.HashMap<java.lang.String,PageLock> |
m_pageLocks |
static java.lang.String |
PRESAVE_TASK_MESSAGE_KEY
The message key for storing the text for the presave task.
|
static java.lang.String |
PRESAVE_WIKI_CONTEXT
The workflow attribute which stores the wikiContext.
|
static java.lang.String |
PROP_LOCKEXPIRY
The property value for setting the amount of time before the page locks expire.
|
static java.lang.String |
PROP_PAGEPROVIDER
The property value for setting the current page provider.
|
static java.lang.String |
PROP_USECACHE
The property value for setting the cache on/off.
|
static java.lang.String |
SAVE_APPROVER
The name of the key from jspwiki.properties which defines who shall approve
the workflow of storing a wikipage.
|
static java.lang.String |
SAVE_DECISION_MESSAGE_KEY
The message key for storing the Decision text for saving a page.
|
static java.lang.String |
SAVE_REJECT_MESSAGE_KEY
The message key for rejecting the decision to save the page.
|
static java.lang.String |
SAVE_TASK_MESSAGE_KEY
The message key of the text to finally approve a page save.
|
PLUGIN_RESOURCE_LOCATION
Constructor and Description |
---|
PageManager(WikiEngine engine,
java.util.Properties props)
Creates a new PageManager.
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(WikiEvent event)
Listens for
WikiSecurityEvent.PROFILE_NAME_CHANGED
events. |
protected boolean |
changeAcl(WikiPage page,
java.security.Principal[] oldPrincipals,
java.security.Principal newPrincipal)
For a single wiki page, replaces all Acl entries matching a supplied array of Principals
with a new Principal.
|
void |
deletePage(WikiPage page)
Deletes an entire page, all versions, all traces.
|
void |
deleteVersion(WikiPage page)
Deletes only a specific version of a WikiPage.
|
protected void |
fireEvent(int type,
java.lang.String pagename)
Fires a WikiPageEvent of the provided type and page name
to all registered listeners.
|
java.util.List |
getActiveLocks()
Returns a list of currently applicable locks.
|
java.util.Collection |
getAllPages()
Returns all pages in some random order.
|
PageLock |
getCurrentLock(WikiPage page)
Returns the current lock owner of a page.
|
WikiEngine |
getEngine()
Returns the WikiEngine to which this PageManager belongs to.
|
WikiPage |
getPageInfo(java.lang.String pageName,
int version)
Finds a WikiPage object describing a particular page and version.
|
java.lang.String |
getPageText(java.lang.String pageName,
int version)
Fetches the page text from the repository.
|
WikiPageProvider |
getProvider()
Returns the page provider currently in use.
|
java.lang.String |
getProviderDescription()
Returns a human-readable description of the current provider.
|
int |
getTotalPageCount()
Returns the total count of all pages in the repository.
|
java.util.List |
getVersionHistory(java.lang.String pageName)
Gets a version history of page.
|
PageLock |
lockPage(WikiPage page,
java.lang.String user)
Locks page for editing.
|
java.util.Collection |
modules()
Returns a collection of modules currently managed by this ModuleManager.
|
boolean |
pageExists(java.lang.String pageName)
Returns true, if the page exists (any version).
|
boolean |
pageExists(java.lang.String pageName,
int version)
Checks for existence of a specific page and version.
|
void |
putPageText(WikiPage page,
java.lang.String content)
Puts the page text into the repository.
|
void |
unlockPage(PageLock lock)
Marks a page free to be written again.
|
checkCompatibility
public static final java.lang.String PROP_PAGEPROVIDER
public static final java.lang.String PROP_USECACHE
public static final java.lang.String PROP_LOCKEXPIRY
public static final java.lang.String PRESAVE_TASK_MESSAGE_KEY
public static final java.lang.String PRESAVE_WIKI_CONTEXT
public static final java.lang.String SAVE_APPROVER
public static final java.lang.String SAVE_DECISION_MESSAGE_KEY
public static final java.lang.String SAVE_REJECT_MESSAGE_KEY
public static final java.lang.String SAVE_TASK_MESSAGE_KEY
public static final java.lang.String FACT_PAGE_NAME
public static final java.lang.String FACT_DIFF_TEXT
public static final java.lang.String FACT_CURRENT_TEXT
public static final java.lang.String FACT_PROPOSED_TEXT
public static final java.lang.String FACT_IS_AUTHENTICATED
protected java.util.HashMap<java.lang.String,PageLock> m_pageLocks
public PageManager(WikiEngine engine, java.util.Properties props) throws WikiException
engine
- WikiEngine instanceprops
- Properties to use for initializationWikiException
- If anything goes wrong, you get this.public WikiPageProvider getProvider()
public java.util.Collection getAllPages() throws ProviderException
ReferenceManager.findCreated()
, which is probably a lot
faster. This method may cause repository access.ProviderException
- If the backend has problems.public java.lang.String getPageText(java.lang.String pageName, int version) throws ProviderException
pageName
- The name of the page to fetch.version
- The version to findProviderException
- If the backend has issues.public WikiEngine getEngine()
public void putPageText(WikiPage page, java.lang.String content) throws ProviderException
page
- Page to savecontent
- Wikimarkup to saveProviderException
- If something goes wrong in the saving phasepublic PageLock lockPage(WikiPage page, java.lang.String user)
page
- WikiPage to lockuser
- Username to use for lockingpublic void unlockPage(PageLock lock)
lock
- A lock acquired in lockPage(). Safe to be null.public PageLock getCurrentLock(WikiPage page)
page
- The page to check the lock forpublic java.util.List getActiveLocks()
public WikiPage getPageInfo(java.lang.String pageName, int version) throws ProviderException
pageName
- The name of the pageversion
- A version numberProviderException
- If there is something wrong with the page
name or the repositorypublic java.util.List getVersionHistory(java.lang.String pageName) throws ProviderException
pageName
- The name of the page to fetch history forProviderException
- If the repository fails.public java.lang.String getProviderDescription()
public int getTotalPageCount()
public boolean pageExists(java.lang.String pageName) throws ProviderException
pageName
- Name of the page.ProviderException
- If the backend fails or the name is illegal.public boolean pageExists(java.lang.String pageName, int version) throws ProviderException
pageName
- Name of the pageversion
- The version to checktrue
if the page exists, false
otherwiseProviderException
- If backend fails or name is illegalpublic void deleteVersion(WikiPage page) throws ProviderException
page
- The page to delete.ProviderException
- if the page failspublic void deletePage(WikiPage page) throws ProviderException
page
- The WikiPage to deleteProviderException
- If the repository operation failsprotected final void fireEvent(int type, java.lang.String pagename)
type
- the event type to be firedpagename
- the wiki page name as a StringWikiPageEvent
public java.util.Collection modules()
modules
in class ModuleManager
public void actionPerformed(WikiEvent event)
WikiSecurityEvent.PROFILE_NAME_CHANGED
events. If a user profile's name changes, each page ACL is inspected. If an entry contains
a name that has changed, it is replaced with the new one. No events are emitted
as a consequence of this method, because the page contents are still the same; it is
only the representations of the names within the ACL that are changing.actionPerformed
in interface WikiEventListener
event
- The eventprotected boolean changeAcl(WikiPage page, java.security.Principal[] oldPrincipals, java.security.Principal newPrincipal)
page
- the wiki page whose Acl is to be modifiedoldPrincipals
- an array of Principals to replace; all AclEntry objects whose
AclEntry.getPrincipal()
method returns one of these Principals will be replacednewPrincipal
- the Principal that should receive the old Principals' permissionstrue
if the Acl was actually changed; false
otherwisestSoftware Copyright © 2001-2014 stSoftware All Rights Reserved.