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 String |
CACHE_NAME
Name of the page cache.
|
static int |
DEFAULT_CACHECAPACITY
The capacity of the cache, if you want something else, tweak ehcache.xml.
|
static String |
PROP_ALLOWEDEXTENSIONS
A space-separated list of attachment types which can be uploaded
|
static String |
PROP_FORBIDDENEXTENSIONS
A space-separated list of attachment types which cannot be uploaded
|
static String |
PROP_FORCEDOWNLOAD
A space-separated list of attachment types which never will open in the browser.
|
static String |
PROP_MAXSIZE
The maximum size of attachments that can be uploaded.
|
static String |
PROP_PROVIDER
The property name for defining the attachment provider class name.
|
| 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(String name)
Check if attachement link should force a download iso opening the attachment in the browser.
|
Collection<Attachment> |
getAllAttachments()
Returns a collection of Attachments, containing each and every attachment that is in this Wiki.
|
default Attachment |
getAttachmentInfo(Context context,
String attachmentname)
Figures out the full attachment name from the context and attachment name.
|
Attachment |
getAttachmentInfo(Context context,
String attachmentname,
int version)
Figures out the full attachment name from the context and attachment name.
|
default Attachment |
getAttachmentInfo(String name)
Gets info on a particular attachment, latest version.
|
default Attachment |
getAttachmentInfo(String name,
int version)
Gets info on a particular attachment with the given version.
|
String |
getAttachmentInfoName(Context context,
String attachmentname)
Figures out the full attachment name from the context and attachment name.
|
default InputStream |
getAttachmentStream(Attachment att)
Finds a (real) attachment from the repository as an
InputStream. |
InputStream |
getAttachmentStream(Context ctx,
Attachment att)
Returns an attachment stream using the particular WikiContext.
|
AttachmentProvider |
getCurrentProvider()
Returns the current attachment provider.
|
DynamicAttachment |
getDynamicAttachment(String name)
Finds a DynamicAttachment.
|
List<Attachment> |
getVersionHistory(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.
|
List<Attachment> |
listAttachments(Page wikipage)
Returns the list of attachments associated with a given wiki page.
|
default void |
storeAttachment(Attachment att,
File source)
Stores an attachment that lives in the given file.
|
void |
storeAttachment(Attachment att,
InputStream in)
Stores an attachment directly from a stream.
|
void |
storeDynamicAttachment(Context ctx,
DynamicAttachment att)
Stores a dynamic attachment.
|
static String |
validateFileName(String filename)
Validates the filename and makes sure it is legal.
|
static final String PROP_PROVIDER
static final String PROP_MAXSIZE
static final String PROP_ALLOWEDEXTENSIONS
static final String PROP_FORBIDDENEXTENSIONS
static final String PROP_FORCEDOWNLOAD
static final String CACHE_NAME
static final int DEFAULT_CACHECAPACITY
boolean attachmentsEnabled()
default Attachment getAttachmentInfo(String name) throws ProviderException
name - A full attachment name.ProviderException - If something goes wrong.default Attachment getAttachmentInfo(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, String attachmentname) throws ProviderException
context - The current WikiContextattachmentname - The file name of the attachment.ProviderException - If something goes wrong.Attachment getAttachmentInfo(Context context, 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.String getAttachmentInfoName(Context context, String attachmentname)
context - The current WikiContextattachmentname - The file name of the attachment.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(String name)
name - Name of attachment to be checkeddefault InputStream getAttachmentStream(Attachment att) throws IOException, ProviderException
InputStream.att - AttachmentIOException - If the stream cannot be openedProviderException - If the backend fails due to some other reason.InputStream getAttachmentStream(Context ctx, Attachment att) throws ProviderException, 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 reasonIOException - If the stream cannot be openedvoid storeDynamicAttachment(Context ctx, DynamicAttachment att)
ctx - A WikiContextatt - An attachment to storeDynamicAttachment getDynamicAttachment(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, File source) throws IOException, ProviderException
att - Attachment to store this under.source - A file to read from.IOException - If writing the attachment failed.ProviderException - If something else went wrong.void storeAttachment(Attachment att, InputStream in) throws IOException, ProviderException
att - Attachment to store this under.in - InputStream from which the attachment contents will be read.IOException - If writing the attachment failed.ProviderException - If something else went wrong.List<Attachment> getVersionHistory(String attachmentName) throws ProviderException
attachmentName - A fully qualified name of the attachment.ProviderException - If the provider fails for some reason.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 String validateFileName(String filename) throws WikiException
filename - file name to validate.WikiException - If the filename is not legal (e.g. empty)Copyright © 2001-2020 The Apache Software Foundation. All rights reserved.