Interface AttachmentService
- All Known Implementing Classes:
AttachmentServiceImpl
public interface AttachmentService
Provides methods for creating, reading, updating and deleting Confluence Attachment
Content
objects.- Since:
- 5.5
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
A finder for locating attachments.static interface
Provides methods for validating the actions on the AttachmentService -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Attachment Comments are stored in theContent
metadata as the "comment" entry.static final String
Attachment file size is stored in theContent
as the "fileSize" extension property.static final String
Attachment Labels is stored in theContent
metadata as the "labels" entry.static final String
Attachment Media Type is stored in theContent
metadata as the "mediaType" entry. -
Method Summary
Modifier and TypeMethodDescriptionaddAttachments
(ContentId containerId, ContentStatus containerStatus, Collection<AttachmentUpload> uploads) Add one or more attachments to a piece ofContent
.addAttachments
(ContentId containerId, ContentStatus containerStatus, Collection<AttachmentUpload> uploads, boolean allowDuplicated, Expansions expansions) Add one or more attachments to a piece ofContent
.addAttachments
(ContentId containerId, Collection<AttachmentUpload> uploads) Add one or more attachments to a piece ofContent
.void
Moves an Attachment to trash.Creates an attachment finder for locating attachments.void
moveAttachment
(ContentId attachmentId, ContentId contentId, ContentId newContentId, String newName) Move an attachment to a different content entity object and/or give it a new name.void
removeAttachment
(ContentId contentId, ContentId attachmentId) Trashes an attachment by attachmentIdvoid
removeAttachmentVersion
(ContentId contentId, ContentId attachmentId, int version) removes a version of an attachment from page by attachmentId and versionUpdates the non-data parts of an AttachmentContent
instance.updateData
(ContentId attachmentId, AttachmentUpload upload) Updates the data part of an AttachmentContent
instance.Provides a validator for validating actions on the AttachmentService and checking permissions related to attachments on Content
-
Field Details
-
COMMENT_METADATA_KEY
Attachment Comments are stored in theContent
metadata as the "comment" entry.- See Also:
-
MEDIA_TYPE_METADATA_KEY
Attachment Media Type is stored in theContent
metadata as the "mediaType" entry.- See Also:
-
LABELS_METADATA_KEY
Attachment Labels is stored in theContent
metadata as the "labels" entry.- See Also:
-
FILE_SIZE
Attachment file size is stored in theContent
as the "fileSize" extension property.- See Also:
-
-
Method Details
-
addAttachments
PageResponse<Content> addAttachments(ContentId containerId, Collection<AttachmentUpload> uploads) throws ServiceException Add one or more attachments to a piece ofContent
.- Parameters:
containerId
- the id of the content to attach touploads
- the attachments being uploaded- Returns:
- the attachments added
- Throws:
ServiceException
-
addAttachments
PageResponse<Content> addAttachments(ContentId containerId, ContentStatus containerStatus, Collection<AttachmentUpload> uploads) throws ServiceException Add one or more attachments to a piece ofContent
.- Parameters:
containerId
- the id of the content to attach tocontainerStatus
- the status of the container, specifically allows adding attachments to draftsuploads
- the attachments being uploaded- Returns:
- the attachments added
- Throws:
ServiceException
-
addAttachments
PageResponse<Content> addAttachments(ContentId containerId, ContentStatus containerStatus, Collection<AttachmentUpload> uploads, boolean allowDuplicated, Expansions expansions) throws ServiceException Add one or more attachments to a piece ofContent
.- Parameters:
containerId
- the id of the content to attach tocontainerStatus
- the status of the container, specifically allows adding attachments to draftsuploads
- the attachments being uploadedexpansions
- the expansions to apply to the values returned after uploaded- Returns:
- the attachments added
- Throws:
ServiceException
-
find
Creates an attachment finder for locating attachments.Currently an attachment finder requires a Content container id, unless the attachment is being requested by its id via the "withId" method.
For example, to locate an attachment in a given page with a particular filename:
Content attachment = attachmentService.find() .withContainerId(pageId) .withFilename("myfile.txt") .fetchOneOrNull();
- Parameters:
expansions
- the expansions to apply to the values returned from a fetch- Returns:
- an AttachmentFinder
-
removeAttachment
Trashes an attachment by attachmentId- Parameters:
attachmentId
- the id of the attachment to trash- Throws:
ServiceException
- if the attachment cannot be found, or cannot be deleted- Since:
- 8.9.0
-
removeAttachmentVersion
removes a version of an attachment from page by attachmentId and version- Parameters:
contentId
- the id of the page to remove the attachment fromattachmentId
- the id of the attachment to removeversion
- the version of the attachment to remove- Throws:
ServiceException
- if the attachment cannot be found, or cannot be deleted- Since:
- 8.9.0
-
update
Updates the non-data parts of an AttachmentContent
instance.This method can be used to update the container, filename, media-type and comment of an Attachment.
- Parameters:
attachment
- the attachment to update, must include an id- Returns:
- the updated attachment as stored in the database
- Throws:
ServiceException
-
updateData
Updates the data part of an AttachmentContent
instance.- Parameters:
attachmentId
- the id of the attachment to updateupload
- the new content of the Attachment- Returns:
- the updated attachment as stored in the database
- Throws:
ServiceException
-
validator
AttachmentService.Validator validator()Provides a validator for validating actions on the AttachmentService and checking permissions related to attachments on Content- Returns:
- an attachmentService Validator
-
moveAttachment
void moveAttachment(ContentId attachmentId, ContentId contentId, ContentId newContentId, String newName) throws ServiceException Move an attachment to a different content entity object and/or give it a new name.- Parameters:
attachmentId
- ID for the attachment to be moved.contentId
- ID for the new content entity object that attachment is on.newContentId
- ID for the new content entity object that attachment should be on.newName
- Name of the new attachment (if being changed).- Throws:
ServiceException
- Since:
- 8.9.0
-
delete
Moves an Attachment to trash. Before Confluence 5.8 this used to remove the attachment without trashing it.- Parameters:
attachment
- the content to trash- Throws:
ServiceException
- if the content cannot be found, or cannot be deleted
-