public interface

SimpleAttachmentStore

implements AttachmentHealth
com.atlassian.jira.issue.attachment.SimpleAttachmentStore

Class Overview

Represents the most fundamental functionality of an attachment store - streams.

This may eventually replace AttachmentStore.

Summary

Nested Classes
interface SimpleAttachmentStore.Factory Factory for external plugins to retrieve a new store  
Public Methods
@Nonnull Promise<Attachment> copy(Attachment originalAttachment, Attachment metaData, String newIssueKey)
@Nonnull Promise<Unit> delete(Attachment attachment)
Delete the specified attachment.
@Nonnull Promise<Boolean> exists(Attachment metaData)
Returns true if the attachment exists in the store.
@Nonnull <A> Promise<A> get(Attachment metaData, Function<InputStream, A> inputStreamProcessor)
Retrieve data for a given attachment.
@Nonnull Promise<Unit> move(Attachment metaData, String newIssueKey)
Moves an attachment from its current issue under a new one
@Nonnull Promise<Attachment> put(Attachment metaData, File data)
Store attachment data for a given attachment.
@Nonnull Promise<Attachment> put(Attachment metaData, InputStream data)
Store attachment data for a given attachment.
[Expand]
Inherited Methods
From interface com.atlassian.jira.issue.attachment.AttachmentHealth

Public Methods

@Nonnull public Promise<Attachment> copy (Attachment originalAttachment, Attachment metaData, String newIssueKey)

@Nonnull public Promise<Unit> delete (Attachment attachment)

Delete the specified attachment.

Parameters
attachment The attachment to delete.
Returns
  • a promise that contains an AttachmentCleanupException in case of error.

@Nonnull public Promise<Boolean> exists (Attachment metaData)

Returns true if the attachment exists in the store.

Parameters
metaData attachment metadata, used to determine the logical key under which to store the attachment data
Returns
  • a promise that when claimed will return true if the attachment exists in the store. The promise will contain an AttachmentRuntimeException in case of error.

@Nonnull public Promise<A> get (Attachment metaData, Function<InputStream, A> inputStreamProcessor)

Retrieve data for a given attachment.

Parameters
metaData attachment metadata, used to determine the logical key under which to store the attachment data
inputStreamProcessor Function that processes the attachment data. This function MUST clean up upon failure of reading from the input stream, and must support being re-executed. e.g. If the function writes out to a temp file, the temp file should be created by the function.
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 AttachmentRuntimeException in case of error.

@Nonnull public Promise<Unit> move (Attachment metaData, String newIssueKey)

Moves an attachment from its current issue under a new one

Parameters
metaData attachment metadata, used to determine the logical key of the attachment to be moved.
newIssueKey the key of the new issue under which the attachment will reside.
Returns

@Nonnull public Promise<Attachment> put (Attachment metaData, File data)

Store attachment data for a given attachment.

Parameters
metaData attachment metadata, used to determine the logical key under which to store the attachment data
data source data. It is assumed that the file will exist during the attachment process (i.e. relatively long lived).
Returns
  • A promise of an attachment that performs the 'put' operation once the promise is claimed.

@Nonnull public Promise<Attachment> put (Attachment metaData, InputStream data)

Store attachment data for a given attachment.

Parameters
metaData attachment metadata, used to determine the logical key under which to store the attachment data
data source data. The attachment store will close this stream when it has completed. The stream will be closed once the operation is complete.
Returns
  • A promise of an attachment that performs the 'put' operation once the promise is claimed. The promise will contain an AttachmentRuntimeException in case of error.