com.ecyrd.jspwiki
Class PageManager

java.lang.Object
  extended by com.ecyrd.jspwiki.PageManager

public class PageManager
extends Object

Manages the WikiPages. This class functions as an unified interface towards the page providers. It handles initialization and management of the providers, and provides utility methods for accessing the contents.

Since:
2.0
Author:
Janne Jalkanen

Field Summary
protected  HashMap m_pageLocks
           
static String PROP_LOCKEXPIRY
           
static String PROP_PAGEPROVIDER
           
static String PROP_USECACHE
           
 
Constructor Summary
PageManager(WikiEngine engine, Properties props)
          Creates a new PageManager.
 
Method Summary
 void deletePage(WikiPage page)
          Deletes an entire page, all versions, all traces.
 void deleteVersion(WikiPage page)
          Deletes only a specific version of a WikiPage.
 List getActiveLocks()
          Returns a list of currently applicable locks.
 Collection getAllPages()
           
 PageLock getCurrentLock(WikiPage page)
          Returns the current lock owner of a page.
 WikiEngine getEngine()
           
 WikiPage getPageInfo(String pageName, int version)
           
 String getPageText(String pageName, int version)
          Fetches the page text from the repository.
 WikiPageProvider getProvider()
          Returns the page provider currently in use.
 String getProviderDescription()
           
 int getTotalPageCount()
           
 List getVersionHistory(String pageName)
          Gets a version history of page.
 PageLock lockPage(WikiPage page, String user)
          Locks page for editing.
 boolean pageExists(String pageName)
           
 boolean pageExists(String pageName, int 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_PAGEPROVIDER

public static final String PROP_PAGEPROVIDER
See Also:
Constant Field Values

PROP_USECACHE

public static final String PROP_USECACHE
See Also:
Constant Field Values

PROP_LOCKEXPIRY

public static final String PROP_LOCKEXPIRY
See Also:
Constant Field Values

m_pageLocks

protected HashMap m_pageLocks
Constructor Detail

PageManager

public PageManager(WikiEngine engine,
                   Properties props)
            throws WikiException
Creates a new PageManager.

Throws:
WikiException - If anything goes wrong, you get this.
Method Detail

getProvider

public WikiPageProvider getProvider()
Returns the page provider currently in use.


getAllPages

public Collection getAllPages()
                       throws ProviderException
Throws:
ProviderException

getPageText

public String getPageText(String pageName,
                          int version)
                   throws ProviderException
Fetches the page text from the repository. This method also does some sanity checks, like checking for the pageName validity, etc. Also, if the page repository has been modified externally, it is smart enough to handle such occurrences.

Throws:
ProviderException

getEngine

public WikiEngine getEngine()

putPageText

public void putPageText(WikiPage page,
                        String content)
                 throws ProviderException
Puts the page text into the repository. Note that this method does NOT update JSPWiki internal data structures, and therefore you should always use WikiEngine.saveText()

Parameters:
page - Page to save
content - Wikimarkup to save
Throws:
ProviderException - If something goes wrong in the saving phase

lockPage

public PageLock lockPage(WikiPage page,
                         String user)
Locks page for editing. Note, however, that the PageManager will in no way prevent you from actually editing this page; the lock is just for information.

Returns:
null, if page could not be locked.

unlockPage

public void unlockPage(PageLock lock)
Marks a page free to be written again. If there has not been a lock, will fail quietly.

Parameters:
lock - A lock acquired in lockPage(). Safe to be null.

getCurrentLock

public PageLock getCurrentLock(WikiPage page)
Returns the current lock owner of a page. If the page is not locked, will return null.

Returns:
Current lock.

getActiveLocks

public List getActiveLocks()
Returns a list of currently applicable locks. Note that by the time you get the list, the locks may have already expired, so use this only for informational purposes.

Returns:
List of PageLock objects, detailing the locks. If no locks exist, returns an empty list.
Since:
2.0.22.

getPageInfo

public WikiPage getPageInfo(String pageName,
                            int version)
                     throws ProviderException
Throws:
ProviderException

getVersionHistory

public List getVersionHistory(String pageName)
                       throws ProviderException
Gets a version history of page. Each element in the returned List is a WikiPage.

Returns:
If the page does not exist, returns null, otherwise a List of WikiPages.
Throws:
ProviderException

getProviderDescription

public String getProviderDescription()

getTotalPageCount

public int getTotalPageCount()

pageExists

public boolean pageExists(String pageName)
                   throws ProviderException
Throws:
ProviderException

pageExists

public boolean pageExists(String pageName,
                          int version)
                   throws ProviderException
Parameters:
pageName -
version -
Returns:
true if the page exists, false otherwise
Throws:
ProviderException
Since:
2.3.29

deleteVersion

public void deleteVersion(WikiPage page)
                   throws ProviderException
Deletes only a specific version of a WikiPage.

Throws:
ProviderException

deletePage

public void deletePage(WikiPage page)
                throws ProviderException
Deletes an entire page, all versions, all traces.

Throws:
ProviderException