Class 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.

    • 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 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.
      • 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.
      • 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.
      • 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.