Wiki News Projects Sources Tasks New Task Reports
PageProvider
Page Info Get as PDF

PageProvider

Special Interface, defined in JspWiki to get information about Wiki Pages, stored somethere (how page are stored depends from interface implementation). Here is a code of interface from version 2.4.102:

/* 
    JSPWiki - a JSP-based WikiWiki clone.

    Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation; either version 2.1 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
package com.ecyrd.jspwiki.providers;

import java.util.List;
import java.util.Collection;
import java.util.Date;

import com.ecyrd.jspwiki.*;

/**
 *  Each Wiki page provider should implement this interface.
 *  <P>
 *  You can build whatever page providers based on this, just
 *  leave the unused methods do something useful.
 *  <P>
 *  WikiPageProvider uses Strings and ints to refer to pages.  This may
 *  be a bit odd, since WikiAttachmentProviders all use Attachment
 *  instead of name/version.  We will perhaps modify these in the
 *  future.  In the mean time, name/version is quite sufficient.
 *  <P>
 *  FIXME: In reality we should have an AbstractWikiPageProvider,
 *  which would provide intelligent backups for subclasses.
 *
 *  @author Janne Jalkanen
 */
public interface WikiPageProvider
    extends WikiProvider
{
    /**
     *  Attempts to save the page text for page "page".
     */
    public void putPageText( WikiPage page, String text )
        throws ProviderException;

    /**
     *  Return true, if page exists.
     */

    public boolean pageExists( String page );

    /**
     *  Finds pages based on the query.
     */
    public Collection findPages( QueryItem[] query );

    /**
     *  Returns info about the page.
     */
    public WikiPage getPageInfo( String page, int version )
        throws ProviderException;

    /**
     *  Returns all pages.  Each element in the returned
     *  Collection should be a WikiPage.
     */

    public Collection getAllPages()
        throws ProviderException;

    /**
     *  Gets a list of recent changes.
     *  @since 1.6.4
     */

    public Collection getAllChangedSince( Date date );

    /**
     *  Gets the number of pages.
     *  @since 1.6.4
     */

    public int getPageCount()
        throws ProviderException;

    /**
     *  Returns version history.  Each element should be
     *  a WikiPage.
     *
     *  @return A collection of wiki pages.
     */

    public List getVersionHistory( String page )
        throws ProviderException;

    /**
     *  Gets a specific version out of the repository.
     *
     *  @param page Name of the page to fetch.
     *  @param version Version of the page to fetch.
     *
     *  @return The content of the page, or null, if the page does not exist.
     */

    public String getPageText( 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.
     *
     *  @since 2.0.17.
     *
     *  @param pageName Name of the page to be removed.
     *  @param version  Version of the page to be removed.  May be LATEST_VERSION.
     *
     *  @throws ProviderException If the page cannot be removed for some reason.
     */

    public void deleteVersion( String pageName, int version )
        throws ProviderException;

    /**
     *  Removes an entire page 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.  You should also
     *  delete any auxiliary files that belong to this page, IF they were created
     *  by this provider.
     *
     *  <P>The reason why this is named differently from
     *  deleteVersion() (logically, this method should be an
     *  overloaded version) is that I want to be absolutely sure I
     *  don't accidentally use the wrong method.  With overloading
     *  something like that happens sometimes...
     *
     *  @since 2.0.17.
     *
     *  @param pageName Name of the page to be removed completely.
     *
     *  @throws ProviderException If the page could not be removed for some reason.
     */
    public void deletePage( String pageName )
        throws ProviderException;

     
     /**
      * Move a page
      *
      * @param from  Name of the page to move.
      * @param to    New name of the page.
      *
      * @throws ProviderException If the page could not be moved for some reason.
      */
     public void movePage(String from, String to)
         throws ProviderException;

}




Versioning Provider

Versioning provider just adds one more function to work with versions:

/*
 * (C) Janne Jalkanen 2005
 * 
 */
package com.ecyrd.jspwiki.providers;

/**
 *  This is a provider interface which providers can implement, if they
 *  support fast checks of versions.
 *  <p>
 *  Note that this interface is pretty much a hack to support certain functionality
 *  before a complete refactoring of the complete provider interface.  Please
 *  don't bug me too much about it...
 *  
 *  @author jalkanen
 *
 *  @since 2.3.29
 */
public interface VersioningProvider
{
    /**
     *  Return true, if page with a particular version exists.
     */

    public boolean pageExists( String page, int version );
}

Attachment provider

Same as PageProvider - but used for getting attachments for pages:

/* 
    JSPWiki - a JSP-based WikiWiki clone.

    Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation; either version 2.1 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
package com.ecyrd.jspwiki.providers;

import java.io.InputStream;
import java.io.IOException;

import java.util.Collection;
import java.util.Date;
import java.util.List;

import com.ecyrd.jspwiki.*;
import com.ecyrd.jspwiki.attachment.Attachment;

/**
 *  Defines an attachment provider - a class which is capable of saving
 *  binary data as attachments.
 *  <P>
 *  The difference between this class and WikiPageProvider is that there
 *  PageProviders handle Unicode text, whereas we handle binary data.
 *  While there are quite a lot of similarities in how we handle
 *  things, many providers can really use just one.  In addition,
 *  since binary files can be really large, we rely on
 *  Input/OutputStreams.
 *
 *  @author Erik Bunn
 *  @author Janne Jalkanen
 */
public interface WikiAttachmentProvider
    extends WikiProvider
{
    /**
     *  Put new attachment data.
     */
    public void putAttachmentData( Attachment att, InputStream data )
        throws ProviderException,
               IOException;

    /**
     *  Get attachment data.
     */

    public InputStream getAttachmentData( Attachment att )
        throws ProviderException,
               IOException;

    /**
     *  Lists all attachments attached to a page.
     *
     *  @return A collection of Attachment objects.  May be empty, but never null.
     */

    public Collection listAttachments( WikiPage page )
        throws ProviderException;

    /**
     * Finds attachments based on the query.
     */
    public Collection findAttachments( QueryItem[] query );

    /**
     *  Lists changed attachments since given date.  Can also be used to fetch
     *  a list of all pages.
     *  <P>
     *  This is different from WikiPageProvider, where you basically get a list
     *  of all pages, then sort them locally.  However, since some providers
     *  can be more efficient in locating recently changed files (like any database) 
     *  than our non-optimized Java
     *  code, it makes more sense to fetch the whole list this way.
     *  <P>
     *  To get all files, call this with Date(0L);
     *
     *  @param timestamp List all files from this date onward.
     *  @return A List of Attachment objects, in most-recently-changed first order.
     */
    public List listAllChanged( Date timestamp )
        throws ProviderException;

    /**
     *  Returns info about an attachment.
     */
    public Attachment getAttachmentInfo( WikiPage page, String name, int version )
        throws ProviderException;

    /**
     *  Returns version history.  Each element should be
     *  an Attachment.
     */
    public List getVersionHistory( Attachment att );

    /**
     *  Removes a specific version from the repository.  The implementations
     *  should really do no more security checks, since that is the domain
     *  of the AttachmentManager.  Just delete it as efficiently as you can.
     *
     *  @since 2.0.19.
     *
     *  @param att Attachment to be removed.  The version field is checked, and thus
     *             only that version is removed.
     *
     *  @throws ProviderException If the attachment cannot be removed for some reason.
     */

    public void deleteVersion( Attachment att )
        throws ProviderException;

    /**
     *  Removes an entire page from the repository.  The implementations
     *  should really do no more security checks, since that is the domain
     *  of the AttachmentManager.  Just delete it as efficiently as you can.  You should also
     *  delete any auxiliary files and directories that belong to this attachment, 
     *  IF they were created
     *  by this provider.
     *
     *  @since 2.0.17.
     *
     *  @param att Attachment to delete.
     *
     *  @throws ProviderException If the page could not be removed for some reason.
     */
    public void deleteAttachment( Attachment att )
        throws ProviderException;
   
    /**
     * Move all the attachments for a given page so that they are attached to a
     * new page.
     *
     * @param oldParent Name of the page we are to move the attachments from.
     * @param newParent Name of the page we are to move the attachments to.
     *
     * @throws ProviderException If the attachments could not be moved for some
     *                           reason.
     */
    public void moveAttachmentsForPage( String oldParent,
                                        String newParent )
        throws ProviderException;
}


Last Modified by akakunin 1 year ago
Comments (0)
Login to add comment