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 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 AttachmentRuntimeException in 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 data
      inputStreamProcessor - 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 AttachmentRuntimeException in 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 than getAttachment(AttachmentKey, Function).
      Type Parameters:
      A - The class that the attachmentGetDataProcessor returns when run.
      Parameters:
      attachmentKey - The key of attachment used to identify attachment data
      attachmentGetDataProcessor - 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 AttachmentRuntimeException in case of error.
    • move

      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.
      Parameters:
      attachment - provides the logical key of the attachment to be moved
      newIssueKey - 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 AttachmentRuntimeException in case of error.
    • copyAttachment

      io.atlassian.util.concurrent.Promise<io.atlassian.fugue.Unit> copyAttachment(AttachmentKey sourceAttachmentKey, AttachmentKey newAttachmentKey)
      Copies the attachment identified by oldAttachmentKey to be identified also by newAttachmentKey.
      Parameters:
      sourceAttachmentKey - attachmentKey of existing attachment which should be copied
      newAttachmentKey - 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 via moveTemporaryToAttachment(TemporaryAttachmentId, AttachmentKey)
      Parameters:
      inputStream - stream to temporary attachment data
      size - 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 by putTemporaryAttachment(java.io.InputStream, long) to real attachment.
      Parameters:
      temporaryAttachmentId - id of temporary attachment, returned by putTemporaryAttachment(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 by putTemporaryAttachment(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 attachment
      inputStreamProcessor - 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 AttachmentRuntimeException in case of error.
    • exists

      io.atlassian.util.concurrent.Promise<Boolean> exists(AttachmentKey attachmentKey)
      Indicates whether the specified attachment exists.
      Parameters:
      attachmentKey - key of attachment to check for existence
      Returns:
      a Promise to 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

      Optional<com.atlassian.dc.filestore.api.FileStore.Path> getAttachmentPathForIssue(Issue issue)
      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 attachments
      projectKey - the project key the issue belongs to
      issueKey - the issue key for the issue
      Returns:
      the directory attachments for this issue live in
    • getAttachmentPath

      com.atlassian.dc.filestore.api.FileStore.Path getAttachmentPath(Attachment attachment)
      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