com.atlassian.confluence.api.service.content
Interface AttachmentService

All Known Implementing Classes:
AttachmentServiceImpl

@ExperimentalApi
public interface AttachmentService

Provides methods for creating, reading, updating and deleting Confluence Attachment Content objects.

Since:
5.5

Nested Class Summary
static interface AttachmentService.AttachmentFinder
          A finder for locating attachments.
static interface AttachmentService.Validator
          Provides methods for validating the actions on the AttachmentService
 
Field Summary
static java.lang.String COMMENT_METADATA_KEY
          Attachment Comments are stored in the Content metadata as the "comment" entry.
static java.lang.String MEDIA_TYPE_METADATA_KEY
          Attachment Media Type is stored in the Content metadata as the "mediaType" entry.
 
Method Summary
 PageResponse<Content> addAttachments(ContentId containerId, java.util.Collection<AttachmentUpload> uploads)
          Add one or more attachments to a piece of Content.
 void delete(Content attachment)
          Removes an Attachment from the system.
 AttachmentService.AttachmentFinder find(Expansion... expansions)
          Creates an attachment finder for locating attachments.
 Content update(Content attachment)
          Updates the non-data parts of an Attachment Content instance.
 Content updateData(ContentId attachmentId, AttachmentUpload upload)
          Updates the data part of an Attachment Content instance.
 AttachmentService.Validator validator()
          Provides a validator for validating actions on the AttachmentService and checking permissions related to attachments on Content
 

Field Detail

COMMENT_METADATA_KEY

static final java.lang.String COMMENT_METADATA_KEY
Attachment Comments are stored in the Content metadata as the "comment" entry.

See Also:
Constant Field Values

MEDIA_TYPE_METADATA_KEY

static final java.lang.String MEDIA_TYPE_METADATA_KEY
Attachment Media Type is stored in the Content metadata as the "mediaType" entry.

See Also:
Constant Field Values
Method Detail

addAttachments

PageResponse<Content> addAttachments(ContentId containerId,
                                     java.util.Collection<AttachmentUpload> uploads)
                                     throws ServiceException
Add one or more attachments to a piece of Content.

Parameters:
containerId - the id of the content to attach to
uploads - the attachments being uploaded
Returns:
the attachments added
Throws:
ServiceException

find

AttachmentService.AttachmentFinder find(Expansion... expansions)
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

update

Content update(Content attachment)
               throws ServiceException
Updates the non-data parts of an Attachment Content 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

Content updateData(ContentId attachmentId,
                   AttachmentUpload upload)
                   throws ServiceException
Updates the data part of an Attachment Content instance.

Parameters:
attachmentId - the id of the attachment to update
upload - 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

delete

void delete(Content attachment)
            throws ServiceException
Removes an Attachment from the system.

Parameters:
attachment - the content to remove
Throws:
ServiceException - if the content cannot be found, or cannot be deleted


Copyright © 2003-2014 Atlassian. All Rights Reserved.