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.

  • Field Details

  • Constructor Details

  • Method Details

    • initialize

      public void initialize​(Engine engine, java.util.Properties properties) throws NoRequiredPropertyException, java.io.IOException
      Initializes the page provider.
      Specified by:
      initialize in interface WikiProvider
      Overrides:
      initialize in class AbstractFileProvider
      Parameters:
      engine - Engine to own this provider
      properties - A set of properties used to initialize this provider
      Throws:
      NoRequiredPropertyException - If the provider needs a property which is not found in the property set
      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.
    • 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 interface PageProvider
      Overrides:
      getPageText in class AbstractFileProvider
      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 interface PageProvider
      Overrides:
      putPageText in class AbstractFileProvider
      Parameters:
      page - The WikiPage to save
      text - 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 interface PageProvider
      Overrides:
      getPageInfo in class AbstractFileProvider
      Parameters:
      page - The page name
      version - 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 interface PageProvider
      Overrides:
      pageExists in class AbstractFileProvider
      Parameters:
      pageName - The page name to check for
      version - 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 interface PageProvider
      Overrides:
      getVersionHistory in class AbstractFileProvider
      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 interface PageProvider
      Overrides:
      deletePage in class AbstractFileProvider
      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 interface PageProvider
      Overrides:
      deleteVersion in class AbstractFileProvider
      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 interface PageProvider
      Overrides:
      getAllPages in class AbstractFileProvider
      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 interface WikiProvider
      Overrides:
      getProviderInfo in class AbstractFileProvider
      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.