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.voidMoves an Attachment to trash.Creates an attachment finder for locating attachments.voidmoveAttachment(ContentId attachmentId, ContentId contentId, ContentId newContentId, String newName) Move an attachment to a different content entity object and/or give it a new name.voidremoveAttachment(ContentId contentId, ContentId attachmentId) Trashes an attachment by attachmentIdvoidremoveAttachmentVersion(ContentId contentId, ContentId attachmentId, int version) removes a version of an attachment from page by attachmentId and versionUpdates the non-data parts of an AttachmentContentinstance.updateData(ContentId attachmentId, AttachmentUpload upload) Updates the data part of an AttachmentContentinstance.com.atlassian.confluence.api.impl.service.content.AttachmentServiceImpl.ValidatorImplProvides 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:AttachmentServiceAdd one or more attachments to a piece ofContent.- Specified by:
addAttachmentsin 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:AttachmentServiceAdd one or more attachments to a piece ofContent.- Specified by:
addAttachmentsin 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:AttachmentServiceAdd one or more attachments to a piece ofContent.- Specified by:
addAttachmentsin 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:AttachmentServiceCreates 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:
findin interfaceAttachmentService- Parameters:
expansions- the expansions to apply to the values returned from a fetch- Returns:
- an AttachmentFinder
-
removeAttachment
Description copied from interface:AttachmentServiceTrashes an attachment by attachmentId- Specified by:
removeAttachmentin interfaceAttachmentServiceattachmentId- 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:AttachmentServiceremoves a version of an attachment from page by attachmentId and version- Specified by:
removeAttachmentVersionin 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:AttachmentServiceUpdates the non-data parts of an AttachmentContentinstance.This method can be used to update the container, filename, media-type and comment of an Attachment.
- Specified by:
updatein 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:AttachmentServiceUpdates the data part of an AttachmentContentinstance.- Specified by:
updateDatain 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:AttachmentServiceMove an attachment to a different content entity object and/or give it a new name.- Specified by:
moveAttachmentin 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:AttachmentServiceMoves an Attachment to trash. Before Confluence 5.8 this used to remove the attachment without trashing it.- Specified by:
deletein 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:AttachmentServiceProvides a validator for validating actions on the AttachmentService and checking permissions related to attachments on Content- Specified by:
validatorin interfaceAttachmentService- Returns:
- an attachmentService Validator
-