com.ecyrd.jspwiki.providers
Class VersioningFileProvider

java.lang.Object
  extended by com.ecyrd.jspwiki.providers.AbstractFileProvider
      extended by com.ecyrd.jspwiki.providers.VersioningFileProvider
All Implemented Interfaces:
VersioningProvider, WikiPageProvider, WikiProvider

public class VersioningFileProvider
extends AbstractFileProvider
implements VersioningProvider

Provides a simple directory based repository for Wiki pages. Pages are held in a directory structure:

    Main.txt
    Foobar.txt
    OLD/
       Main/
          1.txt
          2.txt
          page.properties
       Foobar/
          page.properties
  
In this case, "Main" has three versions, and "Foobar" just one version.

The properties file contains the necessary metainformation (such as author) information of the page. DO NOT MESS WITH IT!

All files have ".txt" appended to make life easier for those who insist on using Windows or other software which makes assumptions on the files contents based on its name.

Author:
Janne Jalkanen

Nested Class Summary
 
Nested classes/interfaces inherited from class com.ecyrd.jspwiki.providers.AbstractFileProvider
AbstractFileProvider.WikiFileFilter
 
Field Summary
static String PAGEDIR
           
static String PROPERTYFILE
           
 
Fields inherited from class com.ecyrd.jspwiki.providers.AbstractFileProvider
DEFAULT_ENCODING, FILE_EXT, m_encoding, m_engine, PROP_PAGEDIR
 
Fields inherited from interface com.ecyrd.jspwiki.WikiProvider
LATEST_VERSION
 
Constructor Summary
VersioningFileProvider()
           
 
Method Summary
 void deletePage(String page)
          Removes the relevant page directory under "OLD" -directory as well, but does not remove any extra subdirectories from it.
 void deleteVersion(String page, int version)
          Removes a specific version from the repository.
 Collection getAllPages()
          Returns all pages.
 WikiPage getPageInfo(String page, int version)
          Always returns the latest version, since FileSystemProvider does not support versioning.
 String getPageText(String page, int version)
          This implementation just returns the current version, as filesystem does not provide versioning information for now.
 String getProviderInfo()
          Return a valid HTML string for information.
 List getVersionHistory(String page)
          FIXME: Does not get user information.
 void initialize(WikiEngine engine, Properties properties)
          Initializes the page provider.
 void movePage(String from, String to)
          Move a page
 boolean pageExists(String pageName, int version)
          Return true, if page with a particular version exists.
 void putPageText(WikiPage page, String text)
          Attempts to save the page text for page "page".
 
Methods inherited from class com.ecyrd.jspwiki.providers.AbstractFileProvider
findPage, findPages, getAllChangedSince, getPageCount, mangleName, pageExists, unmangleName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PAGEDIR

public static final String PAGEDIR
See Also:
Constant Field Values

PROPERTYFILE

public static final String PROPERTYFILE
See Also:
Constant Field Values
Constructor Detail

VersioningFileProvider

public VersioningFileProvider()
Method Detail

initialize

public void initialize(WikiEngine engine,
                       Properties properties)
                throws NoRequiredPropertyException,
                       IOException
Description copied from interface: WikiProvider
Initializes the page provider.

Specified by:
initialize in interface WikiProvider
Overrides:
initialize in class AbstractFileProvider
Throws:
FileNotFoundException - If the specified page directory does not exist.
IOException - In case the specified page directory is a file, not a directory.
NoRequiredPropertyException

getPageText

public String getPageText(String page,
                          int version)
                   throws ProviderException
Description copied from class: AbstractFileProvider
This implementation just returns the current version, as filesystem does not provide versioning information for now.

Specified by:
getPageText in interface WikiPageProvider
Overrides:
getPageText in class AbstractFileProvider
Parameters:
page - Name of the page to fetch.
version - Version of the page to fetch.
Returns:
The content of the page, or null, if the page does not exist.
Throws:
ProviderException

putPageText

public void putPageText(WikiPage page,
                        String text)
                 throws ProviderException
Description copied from interface: WikiPageProvider
Attempts to save the page text for page "page".

Specified by:
putPageText in interface WikiPageProvider
Overrides:
putPageText in class AbstractFileProvider
Throws:
ProviderException

getPageInfo

public WikiPage getPageInfo(String page,
                            int version)
                     throws ProviderException
Description copied from class: AbstractFileProvider
Always returns the latest version, since FileSystemProvider does not support versioning.

Specified by:
getPageInfo in interface WikiPageProvider
Overrides:
getPageInfo in class AbstractFileProvider
Throws:
ProviderException

pageExists

public boolean pageExists(String pageName,
                          int version)
Description copied from interface: VersioningProvider
Return true, if page with a particular version exists.

Specified by:
pageExists in interface VersioningProvider

getVersionHistory

public List getVersionHistory(String page)
                       throws ProviderException
FIXME: Does not get user information.

Specified by:
getVersionHistory in interface WikiPageProvider
Overrides:
getVersionHistory in class AbstractFileProvider
Returns:
A collection of wiki pages.
Throws:
ProviderException

deletePage

public void deletePage(String page)
                throws ProviderException
Removes the relevant page directory under "OLD" -directory as well, but does not remove any extra subdirectories from it. It will only touch those files that it thinks to be WikiPages.

Specified by:
deletePage in interface WikiPageProvider
Overrides:
deletePage in class AbstractFileProvider
Parameters:
page - Name of the page to be removed completely.
Throws:
ProviderException - If the page could not be removed for some reason.

deleteVersion

public void deleteVersion(String page,
                          int version)
                   throws ProviderException
Description copied from interface: WikiPageProvider
Removes a specific version from the repository. The implementations should really do no more security checks, since that is the domain of the PageManager. Just delete it as efficiently as you can.

Specified by:
deleteVersion in interface WikiPageProvider
Overrides:
deleteVersion in class AbstractFileProvider
Parameters:
page - Name of the page to be removed.
version - Version of the page to be removed. May be LATEST_VERSION.
Throws:
ProviderException - If the page cannot be removed for some reason.

getAllPages

public Collection getAllPages()
                       throws ProviderException
Description copied from interface: WikiPageProvider
Returns all pages. Each element in the returned Collection should be a WikiPage.

Specified by:
getAllPages in interface WikiPageProvider
Overrides:
getAllPages in class AbstractFileProvider
Throws:
ProviderException

getProviderInfo

public String getProviderInfo()
Description copied from interface: WikiProvider
Return a valid HTML string for information. May be anything.

Specified by:
getProviderInfo in interface WikiProvider
Overrides:
getProviderInfo in class AbstractFileProvider

movePage

public void movePage(String from,
                     String to)
              throws ProviderException
Description copied from interface: WikiPageProvider
Move a page

Specified by:
movePage in interface WikiPageProvider
Parameters:
from - Name of the page to move.
to - New name of the page.
Throws:
ProviderException - If the page could not be moved for some reason.