public class DefaultPageManager extends ModuleManager implements PageManager
Modifier and Type | Field and Description |
---|---|
protected ConcurrentHashMap<String,PageLock> |
m_pageLocks |
m_engine, PLUGIN_RESOURCE_LOCATION
PROP_LOCKEXPIRY, PROP_PAGEPROVIDER, PROP_USECACHE
Constructor and Description |
---|
DefaultPageManager(WikiEngine engine,
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,
Principal[] oldPrincipals,
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,
String pagename)
Fires a WikiPageEvent of the provided type and page name
to all registered listeners.
|
List<PageLock> |
getActiveLocks()
Returns a list of currently applicable locks.
|
Collection<WikiPage> |
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.
|
WikiModuleInfo |
getModuleInfo(String moduleName)
Returns null!
|
WikiPage |
getPageInfo(String pageName,
int version)
Finds a WikiPage object describing a particular page and version.
|
PageSorter |
getPageSorter()
Returns the configured
PageSorter . |
String |
getPageText(String pageName,
int version)
Fetches the page text from the repository.
|
WikiPageProvider |
getProvider()
Returns the page provider currently in use.
|
String |
getProviderDescription()
Returns a human-readable description of the current provider.
|
int |
getTotalPageCount()
Returns the total count of all pages in the repository.
|
List<WikiPage> |
getVersionHistory(String pageName)
Gets a version history of page.
|
PageLock |
lockPage(WikiPage page,
String user)
Locks page for editing.
|
Collection<WikiModuleInfo> |
modules()
Returns a collection of modules currently managed by this ModuleManager.
|
boolean |
pageExists(String pageName)
Returns true, if the page exists (any version).
|
boolean |
pageExists(String pageName,
int version)
Checks for existence of a specific page and version.
|
void |
putPageText(WikiPage page,
String content)
Puts the page text into the repository.
|
void |
unlockPage(PageLock lock)
Marks a page free to be written again.
|
checkCompatibility, modules
protected ConcurrentHashMap<String,PageLock> m_pageLocks
public DefaultPageManager(WikiEngine engine, Properties props) throws NoSuchElementException, WikiException
engine
- WikiEngine instanceprops
- Properties to use for initializationNoSuchElementException
- property not found on WikiEngine propertiesWikiException
- If anything goes wrong, you get this.public WikiPageProvider getProvider()
PageManager
getProvider
in interface PageManager
public Collection<WikiPage> getAllPages() throws ProviderException
PageManager
ReferenceManager#findCreated()
, which is probably a lot
faster. This method may cause repository access.getAllPages
in interface PageManager
ProviderException
- If the backend has problems.public String getPageText(String pageName, int version) throws ProviderException
PageManager
getPageText
in interface PageManager
pageName
- The name of the page to fetch.version
- The version to findProviderException
- If the backend has issues.public WikiEngine getEngine()
PageManager
getEngine
in interface PageManager
public void putPageText(WikiPage page, String content) throws ProviderException
PageManager
putPageText
in interface PageManager
page
- Page to savecontent
- Wikimarkup to saveProviderException
- If something goes wrong in the saving phasepublic PageLock lockPage(WikiPage page, String user)
PageManager
lockPage
in interface PageManager
page
- WikiPage to lockuser
- Username to use for lockingpublic void unlockPage(PageLock lock)
PageManager
unlockPage
in interface PageManager
lock
- A lock acquired in lockPage(). Safe to be null.public PageLock getCurrentLock(WikiPage page)
PageManager
getCurrentLock
in interface PageManager
page
- The page to check the lock forpublic List<PageLock> getActiveLocks()
PageManager
getActiveLocks
in interface PageManager
public WikiPage getPageInfo(String pageName, int version) throws ProviderException
PageManager
getPageInfo
in interface PageManager
pageName
- The name of the pageversion
- A version numberProviderException
- If there is something wrong with the page
name or the repositorypublic List<WikiPage> getVersionHistory(String pageName) throws ProviderException
PageManager
getVersionHistory
in interface PageManager
pageName
- The name of the page to fetch history forProviderException
- If the repository fails.public String getProviderDescription()
PageManager
getProviderDescription
in interface PageManager
public int getTotalPageCount()
PageManager
getTotalPageCount
in interface PageManager
public boolean pageExists(String pageName) throws ProviderException
PageManager
pageExists
in interface PageManager
pageName
- Name of the page.ProviderException
- If the backend fails or the name is illegal.public boolean pageExists(String pageName, int version) throws ProviderException
PageManager
pageExists
in interface PageManager
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
PageManager
deleteVersion
in interface PageManager
page
- The page to delete.ProviderException
- if the page failspublic void deletePage(WikiPage page) throws ProviderException
PageManager
deletePage
in interface PageManager
page
- The WikiPage to deleteProviderException
- If the repository operation failsprotected final void fireEvent(int type, String pagename)
type
- the event type to be firedpagename
- the wiki page name as a StringWikiPageEvent
public Collection<WikiModuleInfo> modules()
modules
in class ModuleManager
public WikiModuleInfo getModuleInfo(String moduleName)
WikiModuleInfo
information about the provided moduleName.getModuleInfo
in class ModuleManager
public void actionPerformed(WikiEvent event)
PageManager
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
actionPerformed
in interface PageManager
event
- The eventprotected boolean changeAcl(WikiPage page, Principal[] oldPrincipals, 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()
PageManager
PageSorter
.getPageSorter
in interface PageManager
PageSorter
.Copyright © 2001-2019 The Apache Software Foundation. All rights reserved.