public interface AttachmentService
Modifier and Type | Method and Description |
---|---|
boolean |
delete(Repository repository,
long id)
Deletes the attachment with the specified ID, if it exists.
|
boolean |
deleteMetadata(Repository repository,
long attachmentId)
Deletes that attachment metadata with the specified ID, if it exists.
|
Attachment |
getById(long attachmentId)
Get the attachment that matches the ID that is supplied.
|
long |
getMaxUploadSize()
Retrieves the maximum size, in bytes, for uploaded attachments.
|
AttachmentMetadata |
getMetadata(Repository repository,
long attachmentId)
Get the attachment metadata that is associated with the attachment metadata ID that is supplied.
|
AttachmentSupplier |
read(Repository repository,
long id)
Reads the attachment with the specified ID.
|
Attachment |
save(Repository repository,
AttachmentSupplier attachmentSupplier)
Saves the attachment contained in the provided
supplier , assigning a unique ID to
allow it to be accessed again. |
AttachmentMetadata |
saveMetadata(Repository repository,
long attachmentId,
Map<String,Object> metadata)
Saves the metadata for an attachment that already exists.
|
boolean delete(@Nonnull Repository repository, long id)
Note: If no attachment exists with the specified ID, no exception is thrown.
repository
- the repository to which the attachment belongsid
- the ID as long assigned when the attachment was savedtrue
if the specified attachment was deleted; otherwise false
if it did not exist or
if it could not be deletedAttachmentStoreException
- if no attachment existsboolean deleteMetadata(@Nonnull Repository repository, long attachmentId)
repository
- the repository to which the attachment will have metadata associated withattachmentId
- the ID of the attachmenttrue
if the deletion of the attachment metadata is successful; otherwise false
if we
cannot delete the attachment metadata@Nullable Attachment getById(long attachmentId)
attachmentId
- the ID of the attachmentlong getMaxUploadSize()
@Nonnull AttachmentMetadata getMetadata(@Nonnull Repository repository, long attachmentId)
repository
- the repository to which the attachment metadata belongsattachmentId
- the ID of the attachmentNoSuchObjectException
- if the attachment metadata cannot be found@Nonnull AttachmentSupplier read(@Nonnull Repository repository, long id)
repository
- the repository to which the attachment belongsid
- the ID assigned when the attachment was savedNoSuchObjectException
- if no attachment exists@Nonnull Attachment save(@Nonnull Repository repository, @Nonnull AttachmentSupplier attachmentSupplier)
supplier
, assigning a unique ID to
allow it to be accessed again.repository
- the repository to which the attachment belongsattachmentSupplier
- a supplier containing the attachment data to storeArgumentValidationException
- if the attachment name
uses special characters,
like ..
ServiceException
- if the attachment cannot be stored@Nonnull AttachmentMetadata saveMetadata(@Nonnull Repository repository, long attachmentId, @Nonnull Map<String,Object> metadata)
repository
- the repository to which the attachments belongattachmentId
- the ID of the attachmentmetadata
- the metadata that is to be associated to the attachmentNoSuchObjectException
- if the attachment cannot be found in the databaseCopyright © 2022 Atlassian. All rights reserved.