Class AttachmentServiceImpl
java.lang.Object
com.atlassian.confluence.api.impl.service.content.AttachmentServiceImpl
- All Implemented Interfaces:
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
ConstructorsConstructorDescriptionAttachmentServiceImpl
(PermissionManager permissionManager, ContentEntityManager contentEntityManager, FileUploadManager fileUploadManager, AttachmentManagerInternal attachmentManager, ContentFactory contentFactory, AttachmentContentTypeApiSupport binding, FinderProxyFactory finderProxyFactory, ContentTrashService trashService) -
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.com.atlassian.confluence.api.impl.service.content.AttachmentServiceImpl.ValidatorImpl
Provides a validator for validating actions on the AttachmentService and checking permissions related to attachments on Content
-
Constructor Details
-
AttachmentServiceImpl
public AttachmentServiceImpl(PermissionManager permissionManager, ContentEntityManager contentEntityManager, FileUploadManager fileUploadManager, AttachmentManagerInternal attachmentManager, ContentFactory contentFactory, AttachmentContentTypeApiSupport binding, FinderProxyFactory finderProxyFactory, ContentTrashService trashService)
-
-
Method Details
-
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
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
-
removeAttachment
Description copied from interface:AttachmentService
Trashes an attachment by attachmentId- Specified by:
removeAttachment
in interfaceAttachmentService
- Parameters:
attachmentId
- the id of the attachment to trash- Throws:
ServiceException
- if the attachment cannot be found, or cannot be deleted
-
removeAttachmentVersion
public void removeAttachmentVersion(ContentId contentId, ContentId attachmentId, int version) throws ServiceException Description copied from interface:AttachmentService
removes a version of an attachment from page by attachmentId and version- Specified by:
removeAttachmentVersion
in interfaceAttachmentService
- 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
-
update
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
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
-
moveAttachment
public void moveAttachment(ContentId attachmentId, ContentId contentId, ContentId newContentId, String newName) throws ServiceException Description copied from interface:AttachmentService
Move an attachment to a different content entity object and/or give it a new name.- Specified by:
moveAttachment
in interfaceAttachmentService
- 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
-
delete
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
-