
public class VersioningFileProvider extends AbstractFileProvider
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.
AbstractFileProvider.WikiFileFilter| Modifier and Type | Field and Description |
|---|---|
static String |
PAGEDIR
Name of the directory where the old versions are stored.
|
static String |
PROPERTYFILE
Name of the property file which stores the metadata.
|
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_PAGEDIRLATEST_VERSION| Constructor and Description |
|---|
VersioningFileProvider() |
| Modifier and Type | Method and Description |
|---|---|
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)
The FileSystemProvider provides only one version.
|
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".
|
addCustomProperties, findPage, findPages, getAllChangedSince, getCustomProperties, getPageCount, mangleName, pageExists, setCustomProperties, unmangleName, validateCustomPagePropertiespublic static final String PAGEDIR
public static final String PROPERTYFILE
public VersioningFileProvider()
public void initialize(WikiEngine engine, Properties properties) throws NoRequiredPropertyException, IOException
initialize in interface WikiProviderinitialize in class AbstractFileProviderengine - WikiEngine to own this providerproperties - A set of properties used to initialize this providerNoRequiredPropertyException - 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.public String getPageText(String page, int version) throws ProviderException
getPageText in interface WikiPageProvidergetPageText in class AbstractFileProviderpage - Name of the page to fetch.version - Version of the page to fetch.ProviderException - If something goes wrong.public void putPageText(WikiPage page, String text) throws ProviderException
putPageText in interface WikiPageProviderputPageText in class AbstractFileProviderpage - The WikiPage to savetext - The text to save.ProviderException - If something goes wrong.public WikiPage getPageInfo(String page, int version) throws ProviderException
getPageInfo in interface WikiPageProvidergetPageInfo in class AbstractFileProviderpage - The page nameversion - The version numberProviderException - If something goes wrong.public boolean pageExists(String pageName, int version)
pageExists in interface WikiPageProviderpageExists in class AbstractFileProviderpageName - The page name to check forversion - The version to checkpublic List getVersionHistory(String page) throws ProviderException
getVersionHistory in interface WikiPageProvidergetVersionHistory in class AbstractFileProviderpage - The name of the page to get the history from.ProviderException - If something goes wrong.public void deletePage(String page) throws ProviderException
deletePage in interface WikiPageProviderdeletePage in class AbstractFileProviderpage - Name of the page to be removed completely.{@inheritDoc}ProviderException - If the page could not be removed for some reason.public void deleteVersion(String page, int version) throws ProviderException
deleteVersion in interface WikiPageProviderdeleteVersion in class AbstractFileProviderpage - Name of the page to be removed.version - Version of the page to be removed. May be LATEST_VERSION.ProviderException - If the page cannot be removed for some reason.public Collection getAllPages() throws ProviderException
getAllPages in interface WikiPageProvidergetAllPages in class AbstractFileProviderProviderException - If something goes wrong.public String getProviderInfo()
getProviderInfo in interface WikiProvidergetProviderInfo in class AbstractFileProviderpublic void movePage(String from, String to) throws ProviderException
from - Name of the page to move.to - New name of the page.ProviderException - If the page could not be moved for some reason.Copyright © 2001-2018 The Apache Software Foundation. All rights reserved.