public class DefaultAttachmentManager extends java.lang.Object implements AttachmentManager
AttachmentManager.
PROP_ALLOWEDEXTENSIONS, PROP_FORBIDDENEXTENSIONS, PROP_FORCEDOWNLOAD, PROP_MAXSIZE, PROP_PROVIDER, PROP_PROVIDER_DEPRECATED| Constructor and Description |
|---|
DefaultAttachmentManager(Engine 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.
|
boolean |
forceDownload(java.lang.String name)
Check if attachement link should force a download iso opening the attachment in the browser.
|
java.util.Collection<Attachment> |
getAllAttachments()
Returns a collection of Attachments, containing each and every attachment that is in this Wiki.
|
Attachment |
getAttachmentInfo(Context context,
java.lang.String attachmentname,
int version)
Figures out the full attachment name from the context and attachment name.
|
java.lang.String |
getAttachmentInfoName(Context context,
java.lang.String attachmentname)
Figures out the full attachment name from the context and attachment name.
|
java.io.InputStream |
getAttachmentStream(Context ctx,
Attachment att)
Returns an attachment stream using the particular WikiContext.
|
AttachmentProvider |
getCurrentProvider()
Returns the current attachment provider.
|
DynamicAttachment |
getDynamicAttachment(java.lang.String name)
Finds a DynamicAttachment.
|
java.util.List<Attachment> |
getVersionHistory(java.lang.String attachmentName)
Returns a list of versions of the attachment.
|
java.util.List<Attachment> |
listAttachments(Page wikipage)
Returns the list of attachments associated with a given wiki page.
|
void |
storeAttachment(Attachment att,
java.io.InputStream in)
Stores an attachment directly from a stream.
|
void |
storeDynamicAttachment(Context ctx,
DynamicAttachment att)
Stores a dynamic attachment.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetAttachmentInfo, getAttachmentInfo, getAttachmentInfo, getAttachmentStream, hasAttachments, storeAttachment, validateFileNamepublic DefaultAttachmentManager(Engine engine, java.util.Properties props)
DO NOT CREATE an AttachmentManager on your own, unless you really know what you're doing. Just use Wikiengine.getManager( AttachmentManager.class ) 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()
attachmentsEnabled in interface AttachmentManagerpublic java.lang.String getAttachmentInfoName(Context context, java.lang.String attachmentname)
getAttachmentInfoName in interface AttachmentManagercontext - The current WikiContextattachmentname - The file name of the attachment.public Attachment getAttachmentInfo(Context context, java.lang.String attachmentname, int version) throws ProviderException
getAttachmentInfo in interface AttachmentManagercontext - The current WikiContextattachmentname - The file name of the attachment.version - A particular version.ProviderException - If something goes wrong.public java.util.List<Attachment> listAttachments(Page wikipage) throws ProviderException
listAttachments in interface AttachmentManagerwikipage - The wiki page from which you are seeking attachments for.ProviderException - If there was something wrong in the backend.public boolean forceDownload(java.lang.String name)
forceDownload in interface AttachmentManagername - Name of attachment to be checkedpublic java.io.InputStream getAttachmentStream(Context ctx, Attachment att) throws ProviderException, java.io.IOException
AttachmentManager.getAttachmentStream(Attachment), since it also allows the DynamicAttachments to function.getAttachmentStream in interface AttachmentManagerctx - 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(Context ctx, DynamicAttachment att)
storeDynamicAttachment in interface AttachmentManagerctx - A WikiContextatt - An attachment to storepublic DynamicAttachment getDynamicAttachment(java.lang.String name)
AttachmentManager.getAttachmentInfo(String) , since that will find also
DynamicAttachments.getDynamicAttachment in interface AttachmentManagername - The name of the attachment to look forAttachmentManager.getAttachmentInfo(String)public void storeAttachment(Attachment att, java.io.InputStream in) throws java.io.IOException, ProviderException
storeAttachment in interface AttachmentManageratt - 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<Attachment> getVersionHistory(java.lang.String attachmentName) throws ProviderException
getVersionHistory in interface AttachmentManagerattachmentName - A fully qualified name of the attachment.ProviderException - If the provider fails for some reason.public java.util.Collection<Attachment> getAllAttachments() throws ProviderException
getAllAttachments in interface AttachmentManagerProviderException - If something went wrong with the backendpublic AttachmentProvider getCurrentProvider()
getCurrentProvider in interface AttachmentManagerpublic void deleteVersion(Attachment att) throws ProviderException
deleteVersion in interface AttachmentManageratt - The attachment to deleteProviderException - If something goes wrong with the backend.public void deleteAttachment(Attachment att) throws ProviderException
deleteAttachment in interface AttachmentManageratt - The Attachment to delete.ProviderException - if something goes wrong with the backend.Copyright (c) 2001-2022 The Apache Software Foundation. All rights reserved.