com.ecyrd.jspwiki.providers
Interface WikiAttachmentProvider

All Superinterfaces:
WikiProvider
All Known Implementing Classes:
BasicAttachmentProvider

public interface WikiAttachmentProvider
extends WikiProvider

Defines an attachment provider - a class which is capable of saving binary data as attachments.

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, Janne Jalkanen

Field Summary
 
Fields inherited from interface com.ecyrd.jspwiki.WikiProvider
LATEST_VERSION
 
Method Summary
 void deleteAttachment(Attachment att)
          Removes an entire page from the repository.
 void deleteVersion(Attachment att)
          Removes a specific version from the repository.
 java.util.Collection findAttachments(QueryItem[] query)
          Finds attachments based on the query.
 java.io.InputStream getAttachmentData(Attachment att)
          Get attachment data.
 Attachment getAttachmentInfo(WikiPage page, java.lang.String name, int version)
          Returns info about an attachment.
 java.util.List getVersionHistory(Attachment att)
          Returns version history.
 java.util.List listAllChanged(java.util.Date timestamp)
          Lists changed attachments since given date.
 java.util.Collection listAttachments(WikiPage page)
          Lists all attachments attached to a page.
 void putAttachmentData(Attachment att, java.io.InputStream data)
          Put new attachment data.
 
Methods inherited from interface com.ecyrd.jspwiki.WikiProvider
getProviderInfo, initialize
 

Method Detail

putAttachmentData

public void putAttachmentData(Attachment att,
                              java.io.InputStream data)
                       throws ProviderException,
                              java.io.IOException
Put new attachment data.

ProviderException
java.io.IOException

getAttachmentData

public java.io.InputStream getAttachmentData(Attachment att)
                                      throws ProviderException,
                                             java.io.IOException
Get attachment data.

ProviderException
java.io.IOException

listAttachments

public java.util.Collection listAttachments(WikiPage page)
                                     throws ProviderException
Lists all attachments attached to a page.

Returns:
A collection of Attachment objects. May be empty, but never null.
ProviderException

findAttachments

public java.util.Collection findAttachments(QueryItem[] query)
Finds attachments based on the query.


listAllChanged

public java.util.List listAllChanged(java.util.Date timestamp)
                              throws ProviderException
Lists changed attachments since given date. Can also be used to fetch a list of all pages.

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.

To get all files, call this with Date(0L);

Parameters:
timestamp - List all files from this date onward.
Returns:
A List of Attachment objects, in most-recently-changed first order.
ProviderException

getAttachmentInfo

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

ProviderException

getVersionHistory

public java.util.List getVersionHistory(Attachment att)
Returns version history. Each element should be an Attachment.


deleteVersion

public void deleteVersion(Attachment att)
                   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 AttachmentManager. Just delete it as efficiently as you can.

Parameters:
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.
Since:
2.0.19.

deleteAttachment

public void deleteAttachment(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.

Parameters:
att - Attachment to delete.
Throws:
ProviderException - If the page could not be removed for some reason.
Since:
2.0.17.