public class AttachmentManager
extends java.lang.Object
The AttachmentManager provides a facade towards the current WikiAttachmentProvider that is in use. It is created by the WikiEngine as a singleton object, and can be requested through the WikiEngine.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
PROP_ALLOWEDEXTENSIONS
A space-separated list of attachment types which can be uploaded
|
static java.lang.String |
PROP_FORDBIDDENEXTENSIONS
A space-separated list of attachment types which cannot be uploaded
|
static java.lang.String |
PROP_MAXSIZE
The maximum size of attachments that can be uploaded.
|
static java.lang.String |
PROP_PROVIDER
The property name for defining the attachment provider class name.
|
| Constructor and Description |
|---|
AttachmentManager(WikiEngine engine,
java.util.Properties props)
Creates a new AttachmentManager.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
attachmentsEnabled()
Returns true, if attachments are enabled and running.
|
void |
deleteAttachment(Attachment att)
Deletes all versions of the given attachment.
|
void |
deleteVersion(Attachment att)
Deletes the given attachment version.
|
java.util.Collection |
getAllAttachments()
Returns a collection of Attachments, containing each and every attachment
that is in this Wiki.
|
Attachment |
getAttachmentInfo(java.lang.String name)
Gets info on a particular attachment, latest version.
|
Attachment |
getAttachmentInfo(java.lang.String name,
int version)
Gets info on a particular attachment with the given version.
|
Attachment |
getAttachmentInfo(WikiContext context,
java.lang.String attachmentname)
Figures out the full attachment name from the context and
attachment name.
|
Attachment |
getAttachmentInfo(WikiContext context,
java.lang.String attachmentname,
int version)
Figures out the full attachment name from the context and
attachment name.
|
java.io.InputStream |
getAttachmentStream(Attachment att)
Finds a (real) attachment from the repository as a stream.
|
java.io.InputStream |
getAttachmentStream(WikiContext ctx,
Attachment att)
Returns an attachment stream using the particular WikiContext.
|
WikiAttachmentProvider |
getCurrentProvider()
Returns the current attachment provider.
|
DynamicAttachment |
getDynamicAttachment(java.lang.String name)
Finds a DynamicAttachment.
|
java.util.List |
getVersionHistory(java.lang.String attachmentName)
Returns a list of versions of the attachment.
|
boolean |
hasAttachments(WikiPage wikipage)
Returns true, if the page has any attachments at all.
|
java.util.Collection |
listAttachments(WikiPage wikipage)
Returns the list of attachments associated with a given wiki page.
|
void |
storeAttachment(Attachment att,
java.io.File source)
Stores an attachment that lives in the given file.
|
void |
storeAttachment(Attachment att,
java.io.InputStream in)
Stores an attachment directly from a stream.
|
void |
storeDynamicAttachment(WikiContext ctx,
DynamicAttachment att)
Stores a dynamic attachment.
|
public static final java.lang.String PROP_PROVIDER
public static final java.lang.String PROP_MAXSIZE
public static final java.lang.String PROP_ALLOWEDEXTENSIONS
public static final java.lang.String PROP_FORDBIDDENEXTENSIONS
public AttachmentManager(WikiEngine engine, java.util.Properties props)
DO NOT CREATE an AttachmentManager on your own, unless you really know what you're doing. Just use WikiEngine.getAttachmentManager() if you're making a module for JSPWiki.
engine - The wikiengine that owns this attachment manager.props - A list of properties from which the AttachmentManager will seek
its configuration. Typically this is the "jspwiki.properties".public boolean attachmentsEnabled()
public Attachment getAttachmentInfo(java.lang.String name) throws ProviderException
name - A full attachment name.ProviderException - If something goes wrong.public Attachment getAttachmentInfo(java.lang.String name, int version) throws ProviderException
name - A full attachment name.version - A version number.ProviderException - If something goes wrong.public Attachment getAttachmentInfo(WikiContext context, java.lang.String attachmentname) throws ProviderException
context - The current WikiContextattachmentname - The file name of the attachment.ProviderException - If something goes wrong.public Attachment getAttachmentInfo(WikiContext context, java.lang.String attachmentname, int version) throws ProviderException
context - The current WikiContextattachmentname - The file name of the attachment.version - A particular version.ProviderException - If something goes wrong.public java.util.Collection listAttachments(WikiPage wikipage) throws ProviderException
wikipage - The wiki page from which you are seeking attachments for.ProviderException - If there was something wrong in the backend.public boolean hasAttachments(WikiPage wikipage)
wikipage - The wiki page from which you are seeking attachments for.public java.io.InputStream getAttachmentStream(Attachment att) throws java.io.IOException, ProviderException
att - Attachmentjava.io.IOException - If the stream cannot be openedProviderException - If the backend fails due to some other reason.public java.io.InputStream getAttachmentStream(WikiContext ctx, Attachment att) throws ProviderException, java.io.IOException
ctx - The Wiki Contextatt - The Attachment to findProviderException - If the backend fails due to some reasonjava.io.IOException - If the stream cannot be openedpublic void storeDynamicAttachment(WikiContext ctx, DynamicAttachment att)
ctx - A WikiContextatt - An attachment to storepublic DynamicAttachment getDynamicAttachment(java.lang.String name)
name - The name of the attachment to look forgetAttachmentInfo(String)public void storeAttachment(Attachment att, java.io.File source) throws java.io.IOException, ProviderException
att - Attachment to store this under.source - A file to read from.java.io.IOException - If writing the attachment failed.ProviderException - If something else went wrong.public void storeAttachment(Attachment att, java.io.InputStream in) throws java.io.IOException, ProviderException
att - Attachment to store this under.in - InputStream from which the attachment contents will be read.java.io.IOException - If writing the attachment failed.ProviderException - If something else went wrong.public java.util.List getVersionHistory(java.lang.String attachmentName)
throws ProviderException
attachmentName - A fully qualified name of the attachment.ProviderException - If the provider fails for some reason.public java.util.Collection getAllAttachments()
throws ProviderException
ProviderException - If something went wrong with the backendpublic WikiAttachmentProvider getCurrentProvider()
public void deleteVersion(Attachment att) throws ProviderException
att - The attachment to deleteProviderException - If something goes wrong with the backend.public void deleteAttachment(Attachment att) throws ProviderException
att - The Attachment to delete.ProviderException - if something goes wrong with the backend.stSoftware Copyright © 2001-2014 stSoftware All Rights Reserved.