com.ecyrd.jspwiki.providers
Class FileSystemProvider

java.lang.Object
  |
  +--com.ecyrd.jspwiki.providers.FileSystemProvider
All Implemented Interfaces:
WikiPageProvider, WikiProvider
Direct Known Subclasses:
RCSFileProvider, VersioningFileProvider

public class FileSystemProvider
extends java.lang.Object
implements WikiPageProvider

Provides a simple directory based repository for Wiki pages.

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
 class FileSystemProvider.SearchResultImpl
          Searches return this class.
 class FileSystemProvider.WikiFileFilter
           
 
Field Summary
static java.lang.String FILE_EXT
          All files should have this extension to be recognized as JSPWiki files.
protected  java.lang.String m_encoding
           
static java.lang.String PROP_PAGEDIR
          Name of the property that defines where page directories are.
 
Fields inherited from interface com.ecyrd.jspwiki.WikiProvider
LATEST_VERSION
 
Constructor Summary
FileSystemProvider()
           
 
Method Summary
 void deletePage(java.lang.String pageName)
          Removes an entire page from the repository.
 void deleteVersion(java.lang.String pageName, int version)
          Removes a specific version from the repository.
protected  java.io.File findPage(java.lang.String page)
          Finds a Wiki page from the page repository.
 java.util.Collection findPages(QueryItem[] query)
          Finds pages based on the query.
 java.util.Collection getAllChangedSince(java.util.Date date)
          Gets a list of recent changes.
 java.util.Collection getAllPages()
          Returns all pages.
 int getPageCount()
          Gets the number of pages.
 WikiPage getPageInfo(java.lang.String page, int version)
          Always returns the latest version, since FileSystemProvider does not support versioning.
 java.lang.String getPageText(java.lang.String page, int version)
          This implementation just returns the current version, as filesystem does not provide versioning information for now.
 java.lang.String getProviderInfo()
          Return a valid HTML string for information.
 java.util.List getVersionHistory(java.lang.String page)
          The FileSystemProvider provides only one version.
 void initialize(java.util.Properties properties)
          Initializes the page provider.
protected  java.lang.String mangleName(java.lang.String pagename)
          This makes sure that the queried page name is still readable by the file system.
 boolean pageExists(java.lang.String page)
          Return true, if page exists.
 void putPageText(WikiPage page, java.lang.String text)
          Attempts to save the page text for page "page".
protected  java.lang.String unmangleName(java.lang.String filename)
          This makes the reverse of mangleName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_encoding

protected java.lang.String m_encoding

PROP_PAGEDIR

public static final java.lang.String PROP_PAGEDIR
Name of the property that defines where page directories are.

See Also:
Constant Field Values

FILE_EXT

public static final java.lang.String FILE_EXT
All files should have this extension to be recognized as JSPWiki files. We default to .txt, because that is probably easiest for Windows users, and guarantees correct handling.

See Also:
Constant Field Values
Constructor Detail

FileSystemProvider

public FileSystemProvider()
Method Detail

initialize

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

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

mangleName

protected java.lang.String mangleName(java.lang.String pagename)
This makes sure that the queried page name is still readable by the file system.


unmangleName

protected java.lang.String unmangleName(java.lang.String filename)
This makes the reverse of mangleName


findPage

protected java.io.File findPage(java.lang.String page)
Finds a Wiki page from the page repository.


pageExists

public boolean pageExists(java.lang.String page)
Description copied from interface: WikiPageProvider
Return true, if page exists.

Specified by:
pageExists in interface WikiPageProvider

getPageText

public java.lang.String getPageText(java.lang.String page,
                                    int version)
                             throws ProviderException
This implementation just returns the current version, as filesystem does not provide versioning information for now.

Specified by:
getPageText in interface WikiPageProvider
Parameters:
page - Name of the page to fetch.
version - Version of the page to fetch.
ProviderException

putPageText

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

Specified by:
putPageText in interface WikiPageProvider

getAllPages

public java.util.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
ProviderException

getAllChangedSince

public java.util.Collection getAllChangedSince(java.util.Date date)
Description copied from interface: WikiPageProvider
Gets a list of recent changes.

Specified by:
getAllChangedSince in interface WikiPageProvider

getPageCount

public int getPageCount()
Description copied from interface: WikiPageProvider
Gets the number of pages.

Specified by:
getPageCount in interface WikiPageProvider

findPages

public java.util.Collection findPages(QueryItem[] query)
Description copied from interface: WikiPageProvider
Finds pages based on the query.

Specified by:
findPages in interface WikiPageProvider

getPageInfo

public WikiPage getPageInfo(java.lang.String page,
                            int version)
                     throws ProviderException
Always returns the latest version, since FileSystemProvider does not support versioning.

Specified by:
getPageInfo in interface WikiPageProvider
ProviderException

getVersionHistory

public java.util.List getVersionHistory(java.lang.String page)
                                 throws ProviderException
The FileSystemProvider provides only one version.

Specified by:
getVersionHistory in interface WikiPageProvider
Returns:
A collection of wiki pages.
ProviderException

getProviderInfo

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

Specified by:
getProviderInfo in interface WikiProvider

deleteVersion

public void deleteVersion(java.lang.String pageName,
                          int version)
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
Parameters:
pageName - Name of the page to be removed.
version - Version of the page to be removed. May be LATEST_VERSION.

deletePage

public void deletePage(java.lang.String pageName)
Description copied from interface: WikiPageProvider
Removes an entire page 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. You should also delete any auxiliary files that belong to this page, IF they were created by this provider.

The reason why this is named differently from deleteVersion() (logically, this method should be an overloaded version) is that I want to be absolutely sure I don't accidentally use the wrong method. With overloading something like that happens sometimes...

Specified by:
deletePage in interface WikiPageProvider
Parameters:
pageName - Name of the page to be removed completely.