@ParametersAreNonnullByDefault public class DefaultStreamAttachmentStore extends Object implements StreamAttachmentStore
StreamAttachmentStore
interface, the intention behind this class is that
it will work with any FileStore
implementation, so do not add filesystem specific code. There are some
FS-specific code paths that will be removed when S3 support is added for Jira 10.Constructor and Description |
---|
DefaultStreamAttachmentStore(AttachmentConfigStore attachmentConfigStore,
AttachmentKeyMapper attachmentKeyMapper,
com.atlassian.event.api.EventPublisher eventPublisher,
ExecutorServiceWrapper managedExecutor,
LocalTemporaryFileStore localTemporaryFileStore,
ProjectManager projectManager) |
Modifier and Type | Method and Description |
---|---|
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 . |
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> |
deleteAttachmentContainerForIssue(Issue issue)
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 by
StreamAttachmentStore.putTemporaryAttachment(java.io.InputStream, long) . |
ErrorCollection |
errors()
Checks that the attachment root directory and the temporary attachment directories exist and are writeable.
|
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,
java.util.function.Function<InputStream,A> inputStreamProcessor)
Retrieves the specified attachment.
|
<A> io.atlassian.util.concurrent.Promise<A> |
getAttachmentData(AttachmentKey attachmentKey,
java.util.function.Function<AttachmentGetData,A> attachmentGetDataProcessor)
Retrieves the specified attachment.
|
com.atlassian.dc.filestore.api.FileStore.Path |
getAttachmentPath(Attachment attachment)
Returns the file for the given attachment.
|
com.atlassian.dc.filestore.api.FileStore.Path |
getAttachmentPath(AttachmentKey attachmentKey)
Returns the physical File for the given attachment key.
|
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.
|
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,
java.util.function.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 by
StreamAttachmentStore.putTemporaryAttachment(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 via
StreamAttachmentStore.moveTemporaryToAttachment(TemporaryAttachmentId, AttachmentKey) |
public DefaultStreamAttachmentStore(AttachmentConfigStore attachmentConfigStore, AttachmentKeyMapper attachmentKeyMapper, com.atlassian.event.api.EventPublisher eventPublisher, ExecutorServiceWrapper managedExecutor, LocalTemporaryFileStore localTemporaryFileStore, ProjectManager projectManager)
public io.atlassian.util.concurrent.Promise<StoreAttachmentResult> putAttachment(StoreAttachmentBean storeAttachmentBean)
StreamAttachmentStore
putAttachment
in interface StreamAttachmentStore
storeAttachmentBean
- attachment metadata, used to determine the logical key under which to store the
attachment dataAttachmentRuntimeException
in case of error.public <A> io.atlassian.util.concurrent.Promise<A> getAttachment(AttachmentKey attachmentKey, java.util.function.Function<InputStream,A> inputStreamProcessor)
StreamAttachmentStore
getAttachment
in interface StreamAttachmentStore
A
- The class that the inputStreamProcessor returns when run.attachmentKey
- The key of attachment used to identify attachment datainputStreamProcessor
- Function that processes the attachment data.AttachmentRuntimeException
in case of error.public <A> io.atlassian.util.concurrent.Promise<A> getAttachmentData(AttachmentKey attachmentKey, java.util.function.Function<AttachmentGetData,A> attachmentGetDataProcessor)
StreamAttachmentStore
StreamAttachmentStore.getAttachment(AttachmentKey, Function)
.getAttachmentData
in interface StreamAttachmentStore
A
- The class that the attachmentGetDataProcessor returns when run.attachmentKey
- The key of attachment used to identify attachment dataattachmentGetDataProcessor
- Function that processes the attachment data.AttachmentRuntimeException
in case of error.public com.atlassian.dc.filestore.api.FileStore.Path getAttachmentPath(Attachment attachment)
StreamAttachmentStore
getAttachmentPath
in interface StreamAttachmentStore
attachment
- the attachment for which to retrieve the file.public com.atlassian.dc.filestore.api.FileStore.Path getAttachmentPath(AttachmentKey attachmentKey) throws AttachmentsDisabledException
getAttachmentPath
in interface StreamAttachmentStore
attachmentKey
- the key of attachmentAttachmentsDisabledException
- if attachments are disabled.public io.atlassian.util.concurrent.Promise<io.atlassian.fugue.Unit> deleteAttachmentContainerForIssue(Issue issue)
StreamAttachmentStore
deleteAttachmentContainerForIssue
in interface StreamAttachmentStore
issue
- The issue to delete attachments for.public Optional<com.atlassian.dc.filestore.api.FileStore.Path> getAttachmentPathForIssue(Issue issue)
StreamAttachmentStore
getAttachmentPathForIssue
in interface StreamAttachmentStore
issue
- the issue whose attachment directory you wantpublic com.atlassian.dc.filestore.api.FileStore.Path getAttachmentPath(com.atlassian.dc.filestore.api.FileStore.Path rootAttachmentPath, String projectKey, String issueKey)
StreamAttachmentStore
getAttachmentPath
in interface StreamAttachmentStore
rootAttachmentPath
- base of attachmentsprojectKey
- the project key the issue belongs toissueKey
- the issue key for the issuepublic io.atlassian.util.concurrent.Promise<Void> move(Attachment attachment, String newIssueKey)
StreamAttachmentStore
move
in interface StreamAttachmentStore
attachment
- provides the logical key of the attachment to be movednewIssueKey
- the key of the new issue under which the attachment will resideAttachmentRuntimeException
in case of error.public io.atlassian.util.concurrent.Promise<io.atlassian.fugue.Unit> copyAttachment(AttachmentKey sourceAttachmentKey, AttachmentKey newAttachmentKey)
StreamAttachmentStore
oldAttachmentKey
to be identified also by newAttachmentKey
.copyAttachment
in interface StreamAttachmentStore
sourceAttachmentKey
- attachmentKey of existing attachment which should be copiednewAttachmentKey
- attachmentKey under which copiedpublic io.atlassian.util.concurrent.Promise<io.atlassian.fugue.Unit> deleteAttachment(AttachmentKey attachmentKey)
StreamAttachmentStore
deleteAttachment
in interface StreamAttachmentStore
attachmentKey
- the attachment keypublic io.atlassian.util.concurrent.Promise<TemporaryAttachmentId> putTemporaryAttachment(InputStream inputStream, long size)
StreamAttachmentStore
StreamAttachmentStore.moveTemporaryToAttachment(TemporaryAttachmentId, AttachmentKey)
putTemporaryAttachment
in interface StreamAttachmentStore
inputStream
- stream to temporary attachment datasize
- the size of provided streampublic io.atlassian.util.concurrent.Promise<io.atlassian.fugue.Unit> moveTemporaryToAttachment(TemporaryAttachmentId temporaryAttachmentId, AttachmentKey destinationKey)
StreamAttachmentStore
StreamAttachmentStore.putTemporaryAttachment(java.io.InputStream, long)
to real attachment.moveTemporaryToAttachment
in interface StreamAttachmentStore
temporaryAttachmentId
- id of temporary attachment, returned by StreamAttachmentStore.putTemporaryAttachment(java.io.InputStream, long)
destinationKey
- destination key of under which attachment will be identifiedpublic io.atlassian.util.concurrent.Promise<io.atlassian.fugue.Unit> deleteTemporaryAttachment(TemporaryAttachmentId temporaryAttachmentId)
StreamAttachmentStore
StreamAttachmentStore.putTemporaryAttachment(java.io.InputStream, long)
.deleteTemporaryAttachment
in interface StreamAttachmentStore
temporaryAttachmentId
- id of temporary attachmentpublic <A> io.atlassian.util.concurrent.Promise<A> getTemporaryAttachment(TemporaryAttachmentId temporaryAttachmentId, java.util.function.Function<InputStream,A> inputStreamProcessor)
StreamAttachmentStore
getTemporaryAttachment
in interface StreamAttachmentStore
A
- The class that the inputStreamProcessor returns when run.temporaryAttachmentId
- The id of temporary attachmentinputStreamProcessor
- Function that processes the attachment data.AttachmentRuntimeException
in case of error.public io.atlassian.util.concurrent.Promise<Boolean> exists(AttachmentKey attachmentKey)
StreamAttachmentStore
exists
in interface StreamAttachmentStore
attachmentKey
- key of attachment to check for existencePromise
to boolean result, true if attachment exists and false
otherwise@Nonnull public ErrorCollection errors()
errors
in interface AttachmentHealth
Copyright © 2002-2023 Atlassian. All Rights Reserved.