Package org.apache.wiki.providers
Class VersioningFileProvider
java.lang.Object
org.apache.wiki.providers.AbstractFileProvider
org.apache.wiki.providers.VersioningFileProvider
- All Implemented Interfaces:
PageProvider,WikiProvider
public class VersioningFileProvider extends AbstractFileProvider
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.wiki.providers.AbstractFileProvider
AbstractFileProvider.WikiFileFilter -
Field Summary
Fields Modifier and Type Field Description static StringPAGEDIRName of the directory where the old versions are stored.static StringPROPERTYFILEName of the property file which stores the metadata.Fields inherited from class org.apache.wiki.providers.AbstractFileProvider
DEFAULT_ENCODING, DEFAULT_MAX_PROPKEYLENGTH, DEFAULT_MAX_PROPLIMIT, DEFAULT_MAX_PROPVALUELENGTH, FILE_EXT, m_encoding, m_engine, MAX_PROPKEYLENGTH, MAX_PROPLIMIT, MAX_PROPVALUELENGTH, PROP_CUSTOMPROP_MAXKEYLENGTH, PROP_CUSTOMPROP_MAXLIMIT, PROP_CUSTOMPROP_MAXVALUELENGTH, PROP_PAGEDIRFields inherited from interface org.apache.wiki.api.providers.WikiProvider
LATEST_VERSION -
Constructor Summary
Constructors Constructor Description VersioningFileProvider() -
Method Summary
Modifier and Type Method Description voiddeletePage(String page)Removes the relevant page directory under "OLD" -directory as well, but does not remove any extra subdirectories from it.voiddeleteVersion(String page, int version)Removes a specific version from the repository.Collection<Page>getAllPages()Returns all pages.PagegetPageInfo(String page, int version)Always returns the latest version, since FileSystemProvider does not support versioning.StringgetPageText(String page, int version)This implementation just returns the current version, as filesystem does not provide versioning information for now.StringgetProviderInfo()Return a valid HTML string for information.List<Page>getVersionHistory(String page)The FileSystemProvider provides only one version.voidinitialize(Engine engine, Properties properties)Initializes the page provider.voidmovePage(String from, String to)Move a pagebooleanpageExists(String pageName, int version)Return true, if page with a particular version exists.voidputPageText(Page page, String text)Attempts to save the page text for page "page".Methods inherited from class org.apache.wiki.providers.AbstractFileProvider
addCustomProperties, findPage, findPages, getAllChangedSince, getCustomProperties, getPageCount, mangleName, pageExists, setCustomProperties, unmangleName, validateCustomPageProperties
-
Field Details
-
PAGEDIR
Name of the directory where the old versions are stored.- See Also:
- Constant Field Values
-
PROPERTYFILE
Name of the property file which stores the metadata.- See Also:
- Constant Field Values
-
-
Constructor Details
-
VersioningFileProvider
public VersioningFileProvider()
-
-
Method Details
-
initialize
public void initialize(Engine engine, Properties properties) throws NoRequiredPropertyException, IOExceptionInitializes the page provider.- Specified by:
initializein interfaceWikiProvider- Overrides:
initializein classAbstractFileProvider- Parameters:
engine- Engine to own this providerproperties- A set of properties used to initialize this provider- Throws:
NoRequiredPropertyException- If the provider needs a property which is not found in the property setFileNotFoundException- If the specified page directory does not exist.IOException- In case the specified page directory is a file, not a directory.
-
getPageText
This implementation just returns the current version, as filesystem does not provide versioning information for now. Gets a specific version out of the repository.- Specified by:
getPageTextin interfacePageProvider- Overrides:
getPageTextin classAbstractFileProvider- 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- If something goes wrong.
-
putPageText
Attempts to save the page text for page "page". Note that the provider creates a new version regardless of what the version parameter of the WikiPage is.- Specified by:
putPageTextin interfacePageProvider- Overrides:
putPageTextin classAbstractFileProvider- Parameters:
page- The WikiPage to savetext- The text to save.- Throws:
ProviderException- If something goes wrong.
-
getPageInfo
Always returns the latest version, since FileSystemProvider does not support versioning. Returns info about the page.- Specified by:
getPageInfoin interfacePageProvider- Overrides:
getPageInfoin classAbstractFileProvider- Parameters:
page- The page nameversion- The version number- Returns:
- A filled WikiPage.
- Throws:
ProviderException- If something goes wrong.
-
pageExists
Return true, if page with a particular version exists.- Specified by:
pageExistsin interfacePageProvider- Overrides:
pageExistsin classAbstractFileProvider- Parameters:
pageName- The page name to check forversion- The version to check- Returns:
- True, if page exists; false otherwise.
-
getVersionHistory
The FileSystemProvider provides only one version. Returns version history. Each element should be a WikiPage.- Specified by:
getVersionHistoryin interfacePageProvider- Overrides:
getVersionHistoryin classAbstractFileProvider- Parameters:
page- The name of the page to get the history from.- Returns:
- A collection of WikiPages.
- Throws:
ProviderException- If something goes wrong.
-
deletePage
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:
deletePagein interfacePageProvider- Overrides:
deletePagein classAbstractFileProvider- Parameters:
page- Name of the page to be removed completely.- Throws:
ProviderException- If the page could not be removed for some reason.
-
deleteVersion
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. Deleting versions has never really worked, JSPWiki assumes that version histories are "not gappy". Using deleteVersion() is definitely not recommended.- Specified by:
deleteVersionin interfacePageProvider- Overrides:
deleteVersionin classAbstractFileProvider- 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
Returns all pages. Each element in the returned Collection should be a WikiPage.- Specified by:
getAllPagesin interfacePageProvider- Overrides:
getAllPagesin classAbstractFileProvider- Returns:
- A collection of WikiPages
- Throws:
ProviderException- If something goes wrong.
-
getProviderInfo
Return a valid HTML string for information. May be anything.- Specified by:
getProviderInfoin interfaceWikiProvider- Overrides:
getProviderInfoin classAbstractFileProvider- Returns:
- A string describing the provider.
-
movePage
Move a page- Parameters:
from- Name of the page to move.to- New name of the page.
-