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 java.lang.String
PAGEDIR
Name of the directory where the old versions are stored.static java.lang.String
PROPERTYFILE
Name 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_PAGEDIR
-
Fields inherited from interface org.apache.wiki.api.providers.WikiProvider
LATEST_VERSION
-
-
Constructor Summary
Constructors Constructor Description VersioningFileProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deletePage(java.lang.String page)
Removes the relevant page directory under "OLD" -directory as well, but does not remove any extra subdirectories from it.void
deleteVersion(java.lang.String page, int version)
Removes a specific version from the repository.java.util.Collection<Page>
getAllPages()
Returns all pages.Page
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<Page>
getVersionHistory(java.lang.String page)
The FileSystemProvider provides only one version.void
initialize(Engine engine, java.util.Properties properties)
Initializes the page provider.void
movePage(java.lang.String from, java.lang.String to)
Move a pageboolean
pageExists(java.lang.String pageName, int version)
Return true, if page with a particular version exists.void
putPageText(Page page, java.lang.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 Detail
-
PAGEDIR
public static final java.lang.String PAGEDIR
Name of the directory where the old versions are stored.- See Also:
- Constant Field Values
-
PROPERTYFILE
public static final java.lang.String PROPERTYFILE
Name of the property file which stores the metadata.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
VersioningFileProvider
public VersioningFileProvider()
-
-
Method Detail
-
initialize
public void initialize(Engine engine, java.util.Properties properties) throws NoRequiredPropertyException, java.io.IOException
Initializes the page provider.- Specified by:
initialize
in interfaceWikiProvider
- Overrides:
initialize
in 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 setjava.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.
-
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. Gets a specific version out of the repository.- Specified by:
getPageText
in interfacePageProvider
- Overrides:
getPageText
in 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
public void putPageText(Page page, java.lang.String text) throws ProviderException
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:
putPageText
in interfacePageProvider
- Overrides:
putPageText
in classAbstractFileProvider
- Parameters:
page
- The WikiPage to savetext
- The text to save.- Throws:
ProviderException
- If something goes wrong.
-
getPageInfo
public Page getPageInfo(java.lang.String page, int version) throws ProviderException
Always returns the latest version, since FileSystemProvider does not support versioning. Returns info about the page.- Specified by:
getPageInfo
in interfacePageProvider
- Overrides:
getPageInfo
in classAbstractFileProvider
- Parameters:
page
- The page nameversion
- The version number- Returns:
- A filled WikiPage.
- Throws:
ProviderException
- If something goes wrong.
-
pageExists
public boolean pageExists(java.lang.String pageName, int version)
Return true, if page with a particular version exists.- Specified by:
pageExists
in interfacePageProvider
- Overrides:
pageExists
in classAbstractFileProvider
- Parameters:
pageName
- The page name to check forversion
- The version to check- Returns:
- True, if page exists; false otherwise.
-
getVersionHistory
public java.util.List<Page> getVersionHistory(java.lang.String page) throws ProviderException
The FileSystemProvider provides only one version. Returns version history. Each element should be a WikiPage.- Specified by:
getVersionHistory
in interfacePageProvider
- Overrides:
getVersionHistory
in 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
public void deletePage(java.lang.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 interfacePageProvider
- Overrides:
deletePage
in classAbstractFileProvider
- 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(java.lang.String page, int version) throws ProviderException
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:
deleteVersion
in interfacePageProvider
- Overrides:
deleteVersion
in 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
public java.util.Collection<Page> getAllPages() throws ProviderException
Returns all pages. Each element in the returned Collection should be a WikiPage.- Specified by:
getAllPages
in interfacePageProvider
- Overrides:
getAllPages
in classAbstractFileProvider
- Returns:
- A collection of WikiPages
- Throws:
ProviderException
- If something goes wrong.
-
getProviderInfo
public java.lang.String getProviderInfo()
Return a valid HTML string for information. May be anything.- Specified by:
getProviderInfo
in interfaceWikiProvider
- Overrides:
getProviderInfo
in classAbstractFileProvider
- Returns:
- A string describing the provider.
-
movePage
public void movePage(java.lang.String from, java.lang.String to)
Move a page- Parameters:
from
- Name of the page to move.to
- New name of the page.
-
-