| java.lang.Object com.ecyrd.jspwiki.attachment.AttachmentManager
AttachmentManager | public class AttachmentManager (Code) | | Provides facilities for handling attachments. All attachment
handling goes through this class.
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.
author: Janne Jalkanen since: 1.9.28 |
Method Summary | |
public boolean | attachmentsEnabled() Returns true, if attachments are enabled and running. | public void | deleteAttachment(Attachment att) Deletes all versions of the given attachment. | public void | deleteVersion(Attachment att) Deletes the given attachment version. | public Collection | getAllAttachments() Returns a collection of Attachments, containing each and every attachment
that is in this Wiki.
A collection of attachments. | public Attachment | getAttachmentInfo(String name) Gets info on a particular attachment, latest version.
Parameters: name - A full attachment name. | public Attachment | getAttachmentInfo(String name, int version) Gets info on a particular attachment with the given version.
Parameters: name - A full attachment name. Parameters: version - A version number. | public Attachment | getAttachmentInfo(WikiContext context, String attachmentname) Figures out the full attachment name from the context and
attachment name.
Parameters: context - The current WikiContext Parameters: attachmentname - The file name of the attachment. | public Attachment | getAttachmentInfo(WikiContext context, String attachmentname, int version) Figures out the full attachment name from the context and
attachment name.
Parameters: context - The current WikiContext Parameters: attachmentname - The file name of the attachment. Parameters: version - A particular version. | public InputStream | getAttachmentStream(Attachment att) Finds a (real) attachment from the repository as a stream.
Parameters: att - Attachment An InputStream to read from. | public InputStream | getAttachmentStream(WikiContext ctx, Attachment att) Returns an attachment stream using the particular WikiContext. | public WikiAttachmentProvider | getCurrentProvider() Returns the current attachment provider.
The current provider. | public DynamicAttachment | getDynamicAttachment(String name) Finds a DynamicAttachment. | public List | getVersionHistory(String attachmentName) Returns a list of versions of the attachment.
Parameters: attachmentName - A fully qualified name of the attachment. | public boolean | hasAttachments(WikiPage wikipage) Returns true, if the page has any attachments at all. | public Collection | listAttachments(WikiPage wikipage) Returns the list of attachments associated with a given wiki page.
If there are no attachments, returns an empty Collection.
Parameters: wikipage - The wiki page from which you are seeking attachments for. | public void | storeAttachment(Attachment att, File source) Stores an attachment that lives in the given file.
If the attachment did not exist previously, this method
will create it. | public void | storeAttachment(Attachment att, InputStream in) Stores an attachment directly from a stream.
If the attachment did not exist previously, this method
will create it. | public void | storeDynamicAttachment(WikiContext ctx, DynamicAttachment att) Stores a dynamic attachment. |
PROP_ALLOWEDEXTENSIONS | final public static String PROP_ALLOWEDEXTENSIONS(Code) | | A space-separated list of attachment types which can be uploaded
|
PROP_FORDBIDDENEXTENSIONS | final public static String PROP_FORDBIDDENEXTENSIONS(Code) | | A space-separated list of attachment types which cannot be uploaded
|
PROP_MAXSIZE | final public static String PROP_MAXSIZE(Code) | | The maximum size of attachments that can be uploaded.
|
PROP_PROVIDER | final public static String PROP_PROVIDER(Code) | | The property name for defining the attachment provider class name.
|
AttachmentManager | public AttachmentManager(WikiEngine engine, Properties props)(Code) | | Creates a new AttachmentManager. Note that creation will never fail,
but it's quite likely that attachments do not function.
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.
Parameters: engine - The wikiengine that owns this attachment manager. Parameters: props - A list of properties from which the AttachmentManager will seekits configuration. Typically this is the "jspwiki.properties". |
attachmentsEnabled | public boolean attachmentsEnabled()(Code) | | Returns true, if attachments are enabled and running.
A boolean value indicating whether attachment functionality is enabled. |
deleteAttachment | public void deleteAttachment(Attachment att) throws ProviderException(Code) | | Deletes all versions of the given attachment.
Parameters: att - The Attachment to delete. throws: ProviderException - if something goes wrong with the backend. |
getAllAttachments | public Collection getAllAttachments() throws ProviderException(Code) | | Returns a collection of Attachments, containing each and every attachment
that is in this Wiki.
A collection of attachments. If attachments are disabled, willreturn an empty collection. throws: ProviderException - If something went wrong with the backend |
getAttachmentInfo | public Attachment getAttachmentInfo(String name) throws ProviderException(Code) | | Gets info on a particular attachment, latest version.
Parameters: name - A full attachment name. Attachment, or null, if no such attachment exists. throws: ProviderException - If something goes wrong. |
getAttachmentInfo | public Attachment getAttachmentInfo(String name, int version) throws ProviderException(Code) | | Gets info on a particular attachment with the given version.
Parameters: name - A full attachment name. Parameters: version - A version number. Attachment, or null, if no such attachment or version exists. throws: ProviderException - If something goes wrong. |
getAttachmentInfo | public Attachment getAttachmentInfo(WikiContext context, String attachmentname) throws ProviderException(Code) | | Figures out the full attachment name from the context and
attachment name.
Parameters: context - The current WikiContext Parameters: attachmentname - The file name of the attachment. Attachment, or null, if no such attachment exists. throws: ProviderException - If something goes wrong. |
getAttachmentInfo | public Attachment getAttachmentInfo(WikiContext context, String attachmentname, int version) throws ProviderException(Code) | | Figures out the full attachment name from the context and
attachment name.
Parameters: context - The current WikiContext Parameters: attachmentname - The file name of the attachment. Parameters: version - A particular version. Attachment, or null, if no such attachment or version exists. throws: ProviderException - If something goes wrong. |
getAttachmentStream | public InputStream getAttachmentStream(WikiContext ctx, Attachment att) throws ProviderException, IOException(Code) | | Returns an attachment stream using the particular WikiContext. This method
should be used instead of getAttachmentStream(Attachment), since it also allows
the DynamicAttachments to function.
Parameters: ctx - The Wiki Context Parameters: att - The Attachment to find An InputStream. May return null, if attachments are disabled. You musttake care of closing it. throws: ProviderException - If the backend fails due to some reason throws: IOException - If the stream cannot be opened |
getCurrentProvider | public WikiAttachmentProvider getCurrentProvider()(Code) | | Returns the current attachment provider.
The current provider. May be null, if attachments are disabled. |
getVersionHistory | public List getVersionHistory(String attachmentName) throws ProviderException(Code) | | Returns a list of versions of the attachment.
Parameters: attachmentName - A fully qualified name of the attachment. A list of Attachments. May return null, if attachments aredisabled. throws: ProviderException - If the provider fails for some reason. |
hasAttachments | public boolean hasAttachments(WikiPage wikipage)(Code) | | Returns true, if the page has any attachments at all. This is
a convinience method.
Parameters: wikipage - The wiki page from which you are seeking attachments for. True, if the page has attachments, else false. |
listAttachments | public Collection listAttachments(WikiPage wikipage) throws ProviderException(Code) | | Returns the list of attachments associated with a given wiki page.
If there are no attachments, returns an empty Collection.
Parameters: wikipage - The wiki page from which you are seeking attachments for. a valid collection of attachments. throws: ProviderException - If there was something wrong in the backend. |
storeAttachment | public void storeAttachment(Attachment att, File source) throws IOException, ProviderException(Code) | | Stores an attachment that lives in the given file.
If the attachment did not exist previously, this method
will create it. If it did exist, it stores a new version.
Parameters: att - Attachment to store this under. Parameters: source - A file to read from. throws: IOException - If writing the attachment failed. throws: ProviderException - If something else went wrong. |
storeAttachment | public void storeAttachment(Attachment att, InputStream in) throws IOException, ProviderException(Code) | | Stores an attachment directly from a stream.
If the attachment did not exist previously, this method
will create it. If it did exist, it stores a new version.
Parameters: att - Attachment to store this under. Parameters: in - InputStream from which the attachment contents will be read. throws: IOException - If writing the attachment failed. throws: ProviderException - If something else went wrong. |
storeDynamicAttachment | public void storeDynamicAttachment(WikiContext ctx, DynamicAttachment att)(Code) | | Stores a dynamic attachment. Unlike storeAttachment(), this just stores
the attachment in the memory.
Parameters: ctx - A WikiContext Parameters: att - An attachment to store |
|
|