Interface StreamAttachmentStore
- All Known Implementing Classes:
DefaultStreamAttachmentStore
@ParametersAreNonnullByDefault
public interface StreamAttachmentStore
Stream based operations on attachments. This interface contains subset of methods from
com.atlassian.jira.issue.attachment.AttachmentStore and is dedicated to replace it.- Since:
- v6.4
-
Method Summary
Modifier and TypeMethodDescriptionio.atlassian.util.concurrent.Promise<io.atlassian.fugue.Unit> copyAttachment(AttachmentKey sourceAttachmentKey, AttachmentKey newAttachmentKey) Copies the attachment identified byoldAttachmentKeyto be identified also bynewAttachmentKey.io.atlassian.util.concurrent.Promise<io.atlassian.fugue.Unit> deleteAttachment(AttachmentKey attachmentKey) Deletes the specified attachment.io.atlassian.util.concurrent.Promise<io.atlassian.fugue.Unit> Delete the container for attachments for a given issue if it exists.io.atlassian.util.concurrent.Promise<io.atlassian.fugue.Unit> deleteTemporaryAttachment(TemporaryAttachmentId temporaryAttachmentId) Deletes temporary attachment created previously byputTemporaryAttachment(java.io.InputStream, long).io.atlassian.util.concurrent.Promise<Boolean> exists(AttachmentKey attachmentKey) Indicates whether the specified attachment exists.<A> io.atlassian.util.concurrent.Promise<A> getAttachment(AttachmentKey attachmentKey, Function<InputStream, A> inputStreamProcessor) Retrieves the specified attachment.<A> io.atlassian.util.concurrent.Promise<A> getAttachmentData(AttachmentKey attachmentKey, Function<AttachmentGetData, A> attachmentGetDataProcessor) Retrieves the specified attachment.com.atlassian.dc.filestore.api.FileStore.PathgetAttachmentPath(com.atlassian.dc.filestore.api.FileStore.Path rootAttachmentPath, String projectKey, String issueKey) Get the attachment path for the given attachment base directory, project key, and issue key.com.atlassian.dc.filestore.api.FileStore.PathgetAttachmentPath(Attachment attachment) Returns the file for the given attachment.com.atlassian.dc.filestore.api.FileStore.PathgetAttachmentPath(AttachmentKey attachmentKey) Returns the physical File for the given Attachment.Optional<com.atlassian.dc.filestore.api.FileStore.Path> getAttachmentPathForIssue(Issue issue) Returns the path of the attachments for the given issue.<A> io.atlassian.util.concurrent.Promise<A> getTemporaryAttachment(TemporaryAttachmentId temporaryAttachmentId, Function<InputStream, A> inputStreamProcessor) Retrieve data for temporary attachment.io.atlassian.util.concurrent.Promise<Void> move(Attachment attachment, String newIssueKey) Moves an attachment from its current issue to the one with the given key.io.atlassian.util.concurrent.Promise<io.atlassian.fugue.Unit> moveTemporaryToAttachment(TemporaryAttachmentId temporaryAttachmentId, AttachmentKey destinationKey) Moving temporary attachment created byputTemporaryAttachment(java.io.InputStream, long)to real attachment.io.atlassian.util.concurrent.Promise<StoreAttachmentResult> putAttachment(StoreAttachmentBean storeAttachmentBean) Stores the given attachment.io.atlassian.util.concurrent.Promise<TemporaryAttachmentId> putTemporaryAttachment(InputStream inputStream, long size) Creates temporaryAttachment in store which can be later moved to attachment viamoveTemporaryToAttachment(TemporaryAttachmentId, AttachmentKey)
-
Method Details
-
putAttachment
io.atlassian.util.concurrent.Promise<StoreAttachmentResult> putAttachment(StoreAttachmentBean storeAttachmentBean) Stores the given attachment.- Parameters:
storeAttachmentBean- attachment metadata, used to determine the logical key under which to store the attachment data- Returns:
- A promise of an attachment that performs the 'put' operation once the promise is claimed. The promise
will contain an
AttachmentRuntimeExceptionin case of error.
-
getAttachment
<A> io.atlassian.util.concurrent.Promise<A> getAttachment(AttachmentKey attachmentKey, Function<InputStream, A> inputStreamProcessor) Retrieves the specified attachment.- Type Parameters:
A- The class that the inputStreamProcessor returns when run.- Parameters:
attachmentKey- The key of attachment used to identify attachment datainputStreamProcessor- Function that processes the attachment data.- Returns:
- A promise of an object that represented the processed attachment data (i.e. from running the
inputStreamProcessor over the attachment data). The promise will contain an
AttachmentRuntimeExceptionin case of error.
-
getAttachmentData
<A> io.atlassian.util.concurrent.Promise<A> getAttachmentData(AttachmentKey attachmentKey, Function<AttachmentGetData, A> attachmentGetDataProcessor) Retrieves the specified attachment. Provides more information to the consumer thangetAttachment(AttachmentKey, Function).- Type Parameters:
A- The class that the attachmentGetDataProcessor returns when run.- Parameters:
attachmentKey- The key of attachment used to identify attachment dataattachmentGetDataProcessor- Function that processes the attachment data.- Returns:
- A promise of an object that represented the processed attachment data (i.e. from running the
inputStreamProcessor over the attachment data). The promise will contain an
AttachmentRuntimeExceptionin case of error.
-
move
Moves an attachment from its current issue to the one with the given key.- Parameters:
attachment- provides the logical key of the attachment to be movednewIssueKey- the key of the new issue under which the attachment will reside- Returns:
- a promise that will be completed when the operation is complete. It will
contain an
AttachmentRuntimeExceptionin case of error.
-
copyAttachment
io.atlassian.util.concurrent.Promise<io.atlassian.fugue.Unit> copyAttachment(AttachmentKey sourceAttachmentKey, AttachmentKey newAttachmentKey) Copies the attachment identified byoldAttachmentKeyto be identified also bynewAttachmentKey.- Parameters:
sourceAttachmentKey- attachmentKey of existing attachment which should be copiednewAttachmentKey- attachmentKey under which copied- Returns:
- a promise of unit
-
deleteAttachment
io.atlassian.util.concurrent.Promise<io.atlassian.fugue.Unit> deleteAttachment(@Nullable AttachmentKey attachmentKey) Deletes the specified attachment.- Parameters:
attachmentKey- the attachment key- Returns:
- a promise that will contain an AttachmentCleanupException in case of error.
-
putTemporaryAttachment
io.atlassian.util.concurrent.Promise<TemporaryAttachmentId> putTemporaryAttachment(InputStream inputStream, long size) Creates temporaryAttachment in store which can be later moved to attachment viamoveTemporaryToAttachment(TemporaryAttachmentId, AttachmentKey)- Parameters:
inputStream- stream to temporary attachment datasize- the size of provided stream- Returns:
- returns promise to temporaryAttachmentId
-
moveTemporaryToAttachment
io.atlassian.util.concurrent.Promise<io.atlassian.fugue.Unit> moveTemporaryToAttachment(TemporaryAttachmentId temporaryAttachmentId, AttachmentKey destinationKey) Moving temporary attachment created byputTemporaryAttachment(java.io.InputStream, long)to real attachment.- Parameters:
temporaryAttachmentId- id of temporary attachment, returned byputTemporaryAttachment(java.io.InputStream, long)destinationKey- destination key of under which attachment will be identified- Returns:
- a promise of unit
-
deleteTemporaryAttachment
io.atlassian.util.concurrent.Promise<io.atlassian.fugue.Unit> deleteTemporaryAttachment(TemporaryAttachmentId temporaryAttachmentId) Deletes temporary attachment created previously byputTemporaryAttachment(java.io.InputStream, long).- Parameters:
temporaryAttachmentId- id of temporary attachment- Returns:
- a promise of unit
-
getTemporaryAttachment
<A> io.atlassian.util.concurrent.Promise<A> getTemporaryAttachment(TemporaryAttachmentId temporaryAttachmentId, Function<InputStream, A> inputStreamProcessor) Retrieve data for temporary attachment.- Type Parameters:
A- The class that the inputStreamProcessor returns when run.- Parameters:
temporaryAttachmentId- The id of temporary attachmentinputStreamProcessor- Function that processes the attachment data.- Returns:
- A promise of an object that represented the processed attachment data (i.e. from running the
inputStreamProcessor over the attachment data). The promise will contain an
AttachmentRuntimeExceptionin case of error.
-
exists
Indicates whether the specified attachment exists.- Parameters:
attachmentKey- key of attachment to check for existence- Returns:
- a
Promiseto boolean result, true if attachment exists and false otherwise
-
deleteAttachmentContainerForIssue
io.atlassian.util.concurrent.Promise<io.atlassian.fugue.Unit> deleteAttachmentContainerForIssue(Issue issue) Delete the container for attachments for a given issue if it exists. For file systems, this means the attachment directory for that issue.- Parameters:
issue- The issue to delete attachments for.- Returns:
- A promise that will contain a AttachmentCleanupException if there is a problem deleting the attachment container.
-
getAttachmentPathForIssue
Returns the path of the attachments for the given issue.- Parameters:
issue- the issue whose attachment directory you want- Returns:
- The issue's attachment path if a base attachment path exists and the issue has a project. Otherwise, an empty optional.
-
getAttachmentPath
com.atlassian.dc.filestore.api.FileStore.Path getAttachmentPath(com.atlassian.dc.filestore.api.FileStore.Path rootAttachmentPath, String projectKey, String issueKey) Get the attachment path for the given attachment base directory, project key, and issue key.- Parameters:
rootAttachmentPath- base of attachmentsprojectKey- the project key the issue belongs toissueKey- the issue key for the issue- Returns:
- the directory attachments for this issue live in
-
getAttachmentPath
Returns the file for the given attachment.- Parameters:
attachment- the attachment for which to retrieve the file.- Returns:
- the filestore path
- Throws:
AttachmentsDisabledException- in case attachments have been disabled by the administrator.AttachmentCleanupException- in case the attachment file cannot be found.- Since:
- 9.6
-
getAttachmentPath
com.atlassian.dc.filestore.api.FileStore.Path getAttachmentPath(AttachmentKey attachmentKey) throws AttachmentsDisabledException Returns the physical File for the given Attachment. If you are calling this on multiple attachments for the same issue, consider using the overriden method that passes in the issue. Else, this goes to the database for each call.- Parameters:
attachmentKey- the key of the attachment- Returns:
- the file.
- Throws:
AttachmentsDisabledException- in case attachments have been disabled by the administrator.- Since:
- 9.7
-