Class AttachmentServiceImpl
- java.lang.Object
-
- com.atlassian.confluence.api.impl.service.content.AttachmentServiceImpl
-
- All Implemented Interfaces:
AttachmentService
public class AttachmentServiceImpl extends Object implements AttachmentService
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.atlassian.confluence.api.service.content.AttachmentService
AttachmentService.AttachmentFinder, AttachmentService.Validator
-
-
Field Summary
-
Fields inherited from interface com.atlassian.confluence.api.service.content.AttachmentService
COMMENT_METADATA_KEY, FILE_SIZE, LABELS_METADATA_KEY, MEDIA_TYPE_METADATA_KEY
-
-
Constructor Summary
Constructors Constructor Description AttachmentServiceImpl(PermissionManager permissionManager, ContentEntityManager contentEntityManager, FileUploadManager fileUploadManager, AttachmentManagerInternal attachmentManager, ContentFactory contentFactory, AttachmentContentTypeApiSupport binding, FinderProxyFactory finderProxyFactory, ContentTrashService trashService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PageResponse<Content>
addAttachments(ContentId containerId, ContentStatus containerStatus, Collection<AttachmentUpload> uploads)
Add one or more attachments to a piece ofContent
.PageResponse<Content>
addAttachments(ContentId containerId, ContentStatus containerStatus, Collection<AttachmentUpload> uploads, boolean allowDuplicated, Expansions expansions)
Add one or more attachments to a piece ofContent
.PageResponse<Content>
addAttachments(ContentId containerId, Collection<AttachmentUpload> uploads)
Add one or more attachments to a piece ofContent
.void
delete(Content attachmentContent)
Moves an Attachment to trash.AttachmentService.AttachmentFinder
find(Expansion... expansions)
Creates an attachment finder for locating attachments.Content
update(Content updatedContent)
Updates the non-data parts of an AttachmentContent
instance.Content
updateData(ContentId attachmentId, AttachmentUpload upload)
Updates the data part of an AttachmentContent
instance.com.atlassian.confluence.api.impl.service.content.AttachmentServiceImpl.ValidatorImpl
validator()
Provides a validator for validating actions on the AttachmentService and checking permissions related to attachments on Content
-
-
-
Constructor Detail
-
AttachmentServiceImpl
public AttachmentServiceImpl(PermissionManager permissionManager, ContentEntityManager contentEntityManager, FileUploadManager fileUploadManager, AttachmentManagerInternal attachmentManager, ContentFactory contentFactory, AttachmentContentTypeApiSupport binding, FinderProxyFactory finderProxyFactory, ContentTrashService trashService)
-
-
Method Detail
-
addAttachments
public PageResponse<Content> addAttachments(ContentId containerId, Collection<AttachmentUpload> uploads) throws ServiceException
Description copied from interface:AttachmentService
Add one or more attachments to a piece ofContent
.- Specified by:
addAttachments
in interfaceAttachmentService
- Parameters:
containerId
- the id of the content to attach touploads
- the attachments being uploaded- Returns:
- the attachments added
- Throws:
ServiceException
-
addAttachments
public PageResponse<Content> addAttachments(ContentId containerId, ContentStatus containerStatus, Collection<AttachmentUpload> uploads) throws ServiceException
Description copied from interface:AttachmentService
Add one or more attachments to a piece ofContent
.- Specified by:
addAttachments
in interfaceAttachmentService
- 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
public PageResponse<Content> addAttachments(ContentId containerId, ContentStatus containerStatus, Collection<AttachmentUpload> uploads, boolean allowDuplicated, Expansions expansions) throws ServiceException
Description copied from interface:AttachmentService
Add one or more attachments to a piece ofContent
.- Specified by:
addAttachments
in interfaceAttachmentService
- 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
public AttachmentService.AttachmentFinder find(Expansion... expansions)
Description copied from interface:AttachmentService
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();
- Specified by:
find
in interfaceAttachmentService
- Parameters:
expansions
- the expansions to apply to the values returned from a fetch- Returns:
- an AttachmentFinder
-
update
public Content update(Content updatedContent) throws ServiceException
Description copied from interface:AttachmentService
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.
- Specified by:
update
in interfaceAttachmentService
- Parameters:
updatedContent
- the attachment to update, must include an id- Returns:
- the updated attachment as stored in the database
- Throws:
ServiceException
-
updateData
public Content updateData(ContentId attachmentId, AttachmentUpload upload) throws ServiceException
Description copied from interface:AttachmentService
Updates the data part of an AttachmentContent
instance.- Specified by:
updateData
in interfaceAttachmentService
- 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
-
delete
public void delete(Content attachmentContent) throws ServiceException
Description copied from interface:AttachmentService
Moves an Attachment to trash. Before Confluence 5.8 this used to remove the attachment without trashing it.- Specified by:
delete
in interfaceAttachmentService
- Parameters:
attachmentContent
- the content to trash- Throws:
ServiceException
- if the content cannot be found, or cannot be deleted
-
validator
public com.atlassian.confluence.api.impl.service.content.AttachmentServiceImpl.ValidatorImpl validator()
Description copied from interface:AttachmentService
Provides a validator for validating actions on the AttachmentService and checking permissions related to attachments on Content- Specified by:
validator
in interfaceAttachmentService
- Returns:
- an attachmentService Validator
-
-