public class DefaultPageManager extends java.lang.Object implements PageManager
| Modifier and Type | Field and Description |
|---|---|
protected java.util.concurrent.ConcurrentHashMap<java.lang.String,PageLock> |
m_pageLocks |
PROP_LOCKEXPIRY, PROP_PAGEPROVIDER| Constructor and Description |
|---|
DefaultPageManager(Engine 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(Page 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(Page page)
Deletes an entire page, all versions, all traces.
|
void |
deletePage(java.lang.String pageName)
Deletes a page or an attachment completely, including all versions.
|
void |
deleteVersion(Page 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<PageLock> |
getActiveLocks()
Returns a list of currently applicable locks.
|
java.util.Collection<Page> |
getAllPages()
Returns all pages in some random order.
|
PageLock |
getCurrentLock(Page page)
Returns the current lock owner of a page.
|
java.lang.String |
getCurrentProvider()
Returns the provider name.
|
protected Engine |
getEngine()
Returns the Engine to which this PageManager belongs to.
|
Page |
getPage(java.lang.String pagereq)
Finds the corresponding WikiPage object based on the page name.
|
Page |
getPage(java.lang.String pagereq,
int version)
Finds the corresponding WikiPage object base on the page name and version.
|
Page |
getPageInfo(java.lang.String pageName,
int version)
Finds a WikiPage object describing a particular page and version.
|
PageSorter |
getPageSorter()
Returns the configured
PageSorter. |
java.lang.String |
getPageText(java.lang.String pageName,
int version)
Fetches the page text from the repository.
|
PageProvider |
getProvider()
Returns the page provider currently in use.
|
java.lang.String |
getProviderDescription()
Returns a human-readable description of the current provider.
|
java.lang.String |
getPureText(java.lang.String page,
int version)
Returns the pure text of a page, no conversions.
|
java.util.Set<Page> |
getRecentChanges()
Returns a Collection of WikiPages, sorted in time order of last change (i.e. first object is the most recently changed).
|
java.lang.String |
getText(java.lang.String page,
int version)
Returns the un-HTMLized text of the given version of a page.
|
int |
getTotalPageCount()
Returns the total count of all pages in the repository.
|
<T extends Page> |
getVersionHistory(java.lang.String pageName)
Gets a version history of page.
|
PageLock |
lockPage(Page page,
java.lang.String user)
Locks page for editing.
|
boolean |
pageExists(java.lang.String pageName)
Returns true, if the page exists (any version) on the underlying WikiPageProvider.
|
boolean |
pageExists(java.lang.String pageName,
int version)
Checks for existence of a specific page and version on the underlying WikiPageProvider.
|
void |
putPageText(Page page,
java.lang.String content)
Puts the page text into the repository.
|
void |
saveText(Context context,
java.lang.String text)
Writes the WikiText of a page into the page repository.
|
void |
unlockPage(PageLock lock)
Marks a page free to be written again.
|
boolean |
wikiPageExists(java.lang.String page)
Returns true, if the requested page (or an alias) exists.
|
boolean |
wikiPageExists(java.lang.String page,
int version)
Returns true, if the requested page (or an alias) exists with the requested version.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetPureText, getText, getText, pageExists, wikiPageExistsprotected final java.util.concurrent.ConcurrentHashMap<java.lang.String,PageLock> m_pageLocks
public DefaultPageManager(Engine engine, java.util.Properties props) throws java.util.NoSuchElementException, WikiException
engine - Engine instanceprops - Properties to use for initializationjava.util.NoSuchElementException - property not found on Engine propertiesWikiException - If anything goes wrong, you get this.public PageProvider getProvider()
getProvider in interface PageManagerPageManager.getProvider()public java.util.Collection<Page> getAllPages() throws ProviderException
ReferenceManager#findCreated(), which is probably a lot
faster. This method may cause repository access.getAllPages in interface PageManagerProviderException - If the backend has problems.PageManager.getAllPages()public java.lang.String getPageText(java.lang.String pageName, int version) throws ProviderException
getPageText in interface PageManagerpageName - The name of the page to fetch.version - The version to findProviderException - If the backend has issues.PageManager.getPageText(java.lang.String, int)public java.lang.String getPureText(java.lang.String page, int version)
PageManager.getPageText(String, int), except that it doesn't throw ProviderException,
it logs and swallows them.getPureText in interface PageManagerpage - The name of the page to fetch.version - If WikiPageProvider.LATEST_VERSION, then uses the latest version.PageManager.getPureText(String, int)public java.lang.String getText(java.lang.String page, int version)
PageManager.getPureText(String, int).getText in interface PageManagerpage - WikiName of the page to fetchversion - Version of the page to fetchPageManager.getText(String, int)public void saveText(Context context, java.lang.String text) throws WikiException
PageManagerjspwiki.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.saveText in interface PageManagercontext - 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.protected Engine getEngine()
public void putPageText(Page page, java.lang.String content) throws ProviderException
putPageText in interface PageManagerpage - Page to savecontent - Wikimarkup to saveProviderException - If something goes wrong in the saving phasePageManager.putPageText(org.apache.wiki.api.core.Page, java.lang.String)public PageLock lockPage(Page page, java.lang.String user)
lockPage in interface PageManagerpage - WikiPage to lockuser - Username to use for lockingPageManager.lockPage(org.apache.wiki.api.core.Page, java.lang.String)public void unlockPage(PageLock lock)
unlockPage in interface PageManagerlock - A lock acquired in lockPage(). Safe to be null.PageManager.unlockPage(org.apache.wiki.pages.PageLock)public PageLock getCurrentLock(Page page)
getCurrentLock in interface PageManagerpage - The page to check the lock forPageManager.getCurrentLock(org.apache.wiki.api.core.Page)public java.util.List<PageLock> getActiveLocks()
getActiveLocks in interface PageManagerPageManager.getActiveLocks()public Page getPage(java.lang.String pagereq)
getPage in interface PageManagerpagereq - The name of the page to look for.PageManager.getPage(java.lang.String)public Page getPage(java.lang.String pagereq, int version)
getPage in interface PageManagerpagereq - 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).PageManager.getPage(java.lang.String, int)public Page getPageInfo(java.lang.String pageName, int version) throws ProviderException
getPageInfo in interface PageManagerpageName - The name of the pageversion - A version numberProviderException - If there is something wrong with the page name or the repositoryPageManager.getPageInfo(java.lang.String, int)public <T extends Page> java.util.List<T> getVersionHistory(java.lang.String pageName)
getVersionHistory in interface PageManagerpageName - The name of the page or attachment to fetch history forPageManager.getVersionHistory(java.lang.String)public java.lang.String getCurrentProvider()
getCurrentProvider in interface PageManagerPageManager.getCurrentProvider()public java.lang.String getProviderDescription()
getProviderDescription in interface PageManagerPageManager.getProviderDescription()public int getTotalPageCount()
getTotalPageCount in interface PageManagerPageManager.getTotalPageCount()public java.util.Set<Page> getRecentChanges()
getRecentChanges in interface PageManagerPageManager.getRecentChanges()public boolean pageExists(java.lang.String pageName) throws ProviderException
pageExists in interface PageManagerpageName - Name of the page.ProviderException - If the backend fails or the name is illegal.PageManager.pageExists(java.lang.String)public boolean pageExists(java.lang.String pageName, int version) throws ProviderException
pageExists in interface PageManagerpageName - Name of the pageversion - The version to checktrue if the page exists, false otherwiseProviderException - If backend fails or name is illegalPageManager.pageExists(java.lang.String, int)public boolean wikiPageExists(java.lang.String page)
wikiPageExists in interface PageManagerpage - WikiName of the page.PageManager.wikiPageExists(java.lang.String)public boolean wikiPageExists(java.lang.String page, int version) throws ProviderException
wikiPageExists in interface PageManagerpage - Page nameversion - Page versionProviderException - If the provider fails.PageManager.wikiPageExists(java.lang.String, int)public void deleteVersion(Page page) throws ProviderException
deleteVersion in interface PageManagerpage - The page to delete.ProviderException - if the page failsPageManager.deleteVersion(org.apache.wiki.api.core.Page)public void deletePage(java.lang.String pageName) throws ProviderException
deletePage in interface PageManagerpageName - The name of the page.ProviderException - If something goes wrong.PageManager.deletePage(java.lang.String)public void deletePage(Page page) throws ProviderException
deletePage in interface PageManagerpage - The WikiPage to deleteProviderException - If the repository operation failsPageManager.deletePage(org.apache.wiki.api.core.Page)protected final void fireEvent(int type, java.lang.String pagename)
type - the event type to be firedpagename - the wiki page name as a StringWikiPageEventpublic 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 WikiEventListenerevent - The eventprotected boolean changeAcl(Page 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 otherwisepublic PageSorter getPageSorter()
PageSorter.getPageSorter in interface PageManagerPageSorter.PageManager.getPageSorter()Copyright (c) 2001-2022 The Apache Software Foundation. All rights reserved.