public class VersioningFileProvider extends AbstractFileProvider
Main.txt Foobar.txt OLD/ Main/ 1.txt 2.txt page.properties Foobar/ page.propertiesIn 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_PAGEDIR
LATEST_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<WikiPage> |
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<WikiPage> |
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, validateCustomPageProperties
public static final String PAGEDIR
public static final String PROPERTYFILE
public VersioningFileProvider()
public void initialize(WikiEngine engine, Properties properties) throws NoRequiredPropertyException, IOException
initialize
in interface WikiProvider
initialize
in class AbstractFileProvider
engine
- 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 WikiPageProvider
getPageText
in class AbstractFileProvider
page
- 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 WikiPageProvider
putPageText
in class AbstractFileProvider
page
- 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 WikiPageProvider
getPageInfo
in class AbstractFileProvider
page
- The page nameversion
- The version numberProviderException
- If something goes wrong.public boolean pageExists(String pageName, int version)
pageExists
in interface WikiPageProvider
pageExists
in class AbstractFileProvider
pageName
- The page name to check forversion
- The version to checkpublic List<WikiPage> getVersionHistory(String page) throws ProviderException
getVersionHistory
in interface WikiPageProvider
getVersionHistory
in class AbstractFileProvider
page
- 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 WikiPageProvider
deletePage
in class AbstractFileProvider
page
- 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 WikiPageProvider
deleteVersion
in class AbstractFileProvider
page
- 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<WikiPage> getAllPages() throws ProviderException
getAllPages
in interface WikiPageProvider
getAllPages
in class AbstractFileProvider
ProviderException
- If something goes wrong.public String getProviderInfo()
getProviderInfo
in interface WikiProvider
getProviderInfo
in class AbstractFileProvider
Copyright © 2001-2019 The Apache Software Foundation. All rights reserved.