public interface AttachmentManager
The AttachmentManager provides a facade towards the current WikiAttachmentProvider that is in use. It is created by the Engine as a singleton object, and can be requested through the Engine.
| 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_FORBIDDENEXTENSIONS
A space-separated list of attachment types which cannot be uploaded
|
static java.lang.String |
PROP_FORCEDOWNLOAD
A space-separated list of attachment types which will never open in the browser.
|
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.
|
static java.lang.String |
PROP_PROVIDER_DEPRECATED
Deprecated.
|
| 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.
|
default Attachment |
getAttachmentInfo(Context context,
java.lang.String attachmentname)
Figures out the full attachment name from the context and attachment name.
|
Attachment |
getAttachmentInfo(Context context,
java.lang.String attachmentname,
int version)
Figures out the full attachment name from the context and attachment name.
|
default Attachment |
getAttachmentInfo(java.lang.String name)
Gets info on a particular attachment, latest version.
|
default Attachment |
getAttachmentInfo(java.lang.String name,
int version)
Gets info on a particular attachment with the given version.
|
java.lang.String |
getAttachmentInfoName(Context context,
java.lang.String attachmentname)
Figures out the full attachment name from the context and attachment name.
|
default java.io.InputStream |
getAttachmentStream(Attachment att)
Finds a (real) attachment from the repository as an
InputStream. |
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.
|
default boolean |
hasAttachments(Page wikipage)
Returns true, if the page has any attachments at all.
|
java.util.List<Attachment> |
listAttachments(Page wikipage)
Returns the list of attachments associated with a given wiki page.
|
default 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(Context ctx,
DynamicAttachment att)
Stores a dynamic attachment.
|
static java.lang.String |
validateFileName(java.lang.String filename)
Validates the filename and makes sure it is legal.
|
static final java.lang.String PROP_PROVIDER
@Deprecated static final java.lang.String PROP_PROVIDER_DEPRECATED
static final java.lang.String PROP_MAXSIZE
static final java.lang.String PROP_ALLOWEDEXTENSIONS
static final java.lang.String PROP_FORBIDDENEXTENSIONS
static final java.lang.String PROP_FORCEDOWNLOAD
boolean attachmentsEnabled()
default Attachment getAttachmentInfo(java.lang.String name) throws ProviderException
name - A full attachment name.ProviderException - If something goes wrong.default Attachment getAttachmentInfo(java.lang.String name, int version) throws ProviderException
name - A full attachment name.version - A version number.ProviderException - If something goes wrong.default Attachment getAttachmentInfo(Context context, java.lang.String attachmentname) throws ProviderException
context - The current WikiContextattachmentname - The file name of the attachment.ProviderException - If something goes wrong.Attachment getAttachmentInfo(Context 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.java.lang.String getAttachmentInfoName(Context context, java.lang.String attachmentname)
context - The current WikiContextattachmentname - The file name of the attachment.java.util.List<Attachment> listAttachments(Page wikipage) throws ProviderException
wikipage - The wiki page from which you are seeking attachments for.ProviderException - If there was something wrong in the backend.default boolean hasAttachments(Page wikipage)
wikipage - The wiki page from which you are seeking attachments for.boolean forceDownload(java.lang.String name)
name - Name of attachment to be checkeddefault java.io.InputStream getAttachmentStream(Attachment att) throws java.io.IOException, ProviderException
InputStream.att - Attachmentjava.io.IOException - If the stream cannot be openedProviderException - If the backend fails due to some other reason.java.io.InputStream getAttachmentStream(Context ctx, Attachment att) throws ProviderException, java.io.IOException
getAttachmentStream(Attachment), since it also allows the DynamicAttachments to function.ctx - The Wiki Contextatt - The Attachment to findProviderException - If the backend fails due to some reasonjava.io.IOException - If the stream cannot be openedvoid storeDynamicAttachment(Context ctx, DynamicAttachment att)
ctx - A WikiContextatt - An attachment to storeDynamicAttachment getDynamicAttachment(java.lang.String name)
getAttachmentInfo(String) , since that will find also
DynamicAttachments.name - The name of the attachment to look forgetAttachmentInfo(String)default 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.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.java.util.List<Attachment> getVersionHistory(java.lang.String attachmentName) throws ProviderException
attachmentName - A fully qualified name of the attachment.ProviderException - If the provider fails for some reason.java.util.Collection<Attachment> getAllAttachments() throws ProviderException
ProviderException - If something went wrong with the backendAttachmentProvider getCurrentProvider()
void deleteVersion(Attachment att) throws ProviderException
att - The attachment to deleteProviderException - If something goes wrong with the backend.void deleteAttachment(Attachment att) throws ProviderException
att - The Attachment to delete.ProviderException - if something goes wrong with the backend.static java.lang.String validateFileName(java.lang.String filename) throws WikiException
filename - file name to validate.WikiException - If the filename is not legal (e.g. empty)Copyright (c) 2001-2022 The Apache Software Foundation. All rights reserved.