@ParametersAreNonnullByDefault public class BackwardCompatibleAttachmentStore extends Object implements AttachmentStore, StreamAttachmentStore
AttachmentStore
and StreamAttachmentStore
implementation
that delegates calls to FileSystemAttachmentStore
.AttachmentStore.AttachmentAdapter
StreamAttachmentStore.Factory
Constructor and Description |
---|
BackwardCompatibleAttachmentStore(AttachmentDirectoryAccessor directoryAccessor,
ThumbnailAccessor thumbnailAccessor,
StoreAttachmentBeanMapper storeAttachmentBeanMapper,
FileSystemAttachmentStore fileSystemAttachmentStore,
AttachmentKeyMapper attachmentKeyMapper,
ProjectManager projectManager) |
Modifier and Type | Method and Description |
---|---|
void |
checkValidAttachmentDirectory(Issue issue)
Checks that the Attachment directory of the given issue is right to go - writable, accessible etc.
|
void |
checkValidTemporaryAttachmentDirectory()
Checks that the temporary directory for attachment uploads is right to go - writable, accessible etc.
|
io.atlassian.util.concurrent.Promise<Attachment> |
copy(Attachment originalAttachment,
Attachment metaData,
String newIssueKey)
Copy an attachment to another issue.
|
io.atlassian.util.concurrent.Promise<io.atlassian.fugue.Unit> |
copyAttachment(AttachmentKey sourceAttachmentKey,
AttachmentKey newAttachmentKey)
Copies attachment identified by
oldAttachmentKey to be identified also by newAttachmentKey . |
io.atlassian.util.concurrent.Promise<Void> |
deleteAttachment(Attachment attachment)
Delete the specified attachment.
|
io.atlassian.util.concurrent.Promise<io.atlassian.fugue.Unit> |
deleteAttachment(AttachmentKey attachmentKey)
Delete the attachment identified by provided attachmentKey.
|
io.atlassian.util.concurrent.Promise<Void> |
deleteAttachmentContainerForIssue(Issue issue)
Delete the container for attachments for a given issue.
|
io.atlassian.util.concurrent.Promise<io.atlassian.fugue.Unit> |
deleteTemporaryAttachment(TemporaryAttachmentId temporaryAttachmentId)
Deletes temporary attachment created previously by
StreamAttachmentStore.putTemporaryAttachment(java.io.InputStream, long) . |
io.atlassian.fugue.Option<ErrorCollection> |
errors()
Health status for this component.
|
io.atlassian.util.concurrent.Promise<Boolean> |
exists(AttachmentKey attachmentKey)
Checks if attachment exists.
|
<A> io.atlassian.util.concurrent.Promise<A> |
getAttachment(Attachment metaData,
java.util.function.Function<InputStream,A> inputStreamProcessor)
Retrieve data for a given attachment.
|
<A> io.atlassian.util.concurrent.Promise<A> |
getAttachment(AttachmentKey attachmentKey,
java.util.function.Function<InputStream,A> inputStreamProcessor)
Retrieve data for a given attachment.
|
<A> io.atlassian.util.concurrent.Promise<A> |
getAttachmentData(AttachmentKey attachmentKey,
java.util.function.Function<AttachmentGetData,A> attachmentGetDataProcessor)
Retrieve data for a given attachment.
|
File |
getAttachmentDirectory(Issue issue)
Returns the physical directory of the attachments for the given issue.
|
File |
getAttachmentDirectory(Issue issue,
boolean createDirectory)
Returns the physical directory of the attachments for the given issue.
|
File |
getAttachmentDirectory(String issueKey) |
File |
getAttachmentDirectory(String attachmentDirectory,
String projectKey,
String issueKey)
Get the attachment directory for the given attachment base directory, project key, and issue key.
|
File |
getAttachmentFile(Attachment attachment)
Returns the physical File for the given Attachment.
|
File |
getAttachmentFile(AttachmentStore.AttachmentAdapter adapter,
File attachmentDir)
This is intended for cases where you want more control over where the attachment actually lives and you just want
something to handle the look up logic for the various possible filenames an attachment can have.
|
File |
getAttachmentFile(Issue issue,
Attachment attachment)
Returns the physical File for the given Attachment.
|
File |
getLegacyThumbnailFile(Attachment attachment)
Returns the old legacy file name for thumbnails.
|
<A> io.atlassian.util.concurrent.Promise<A> |
getTemporaryAttachment(TemporaryAttachmentId temporaryAttachmentId,
java.util.function.Function<InputStream,A> inputStreamProcessor)
Retrieve data for temporary attachment.
|
File |
getTemporaryAttachmentDirectory() |
File |
getThumbnailDirectory(Issue issue)
Returns the physical directory of the thumbnails for the given issue, creating if necessary.
|
File |
getThumbnailFile(Attachment attachment)
Just like the attachments themselves, thumbnails can succumb to file system encoding problems.
|
File |
getThumbnailFile(Issue issue,
Attachment attachment)
Returns the file handle for the given attachment's thumbnail.
|
io.atlassian.util.concurrent.Promise<Void> |
move(Attachment metaData,
String newIssueKey)
Moves an attachment from its current issue under a new one
|
io.atlassian.util.concurrent.Promise<io.atlassian.fugue.Unit> |
moveAttachment(AttachmentKey oldAttachmentKey,
AttachmentKey newAttachmentKey)
Move attachment identified by
oldAttachmentKey to be identified by newAttachmentKey and will be not
reachable under oldAttachmentKey anymore. |
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<Attachment> |
putAttachment(Attachment metadata,
File source)
Store attachment data for a given attachment.
|
io.atlassian.util.concurrent.Promise<Attachment> |
putAttachment(Attachment metadata,
InputStream source)
Store attachment data for a given attachment.
|
io.atlassian.util.concurrent.Promise<StoreAttachmentResult> |
putAttachment(StoreAttachmentBean storeAttachmentBean)
Store attachment data for a 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 BackwardCompatibleAttachmentStore(@Nonnull AttachmentDirectoryAccessor directoryAccessor, @Nonnull ThumbnailAccessor thumbnailAccessor, @Nonnull StoreAttachmentBeanMapper storeAttachmentBeanMapper, @Nonnull FileSystemAttachmentStore fileSystemAttachmentStore, @Nonnull AttachmentKeyMapper attachmentKeyMapper, @Nonnull ProjectManager projectManager)
@Nonnull public File getThumbnailDirectory(Issue issue)
AttachmentStore
getThumbnailDirectory
in interface AttachmentStore
issue
- the issue whose thumbnail directory you wantpublic File getAttachmentDirectory(String issueKey)
getAttachmentDirectory
in interface AttachmentStore
public File getAttachmentDirectory(Issue issue, boolean createDirectory)
AttachmentStore
getAttachmentDirectory
in interface AttachmentStore
issue
- the issue whose attachment directory you wantcreateDirectory
- If true, and the directory does not currently exist, then the directory is created.public File getTemporaryAttachmentDirectory()
getTemporaryAttachmentDirectory
in interface AttachmentStore
public File getAttachmentDirectory(Issue issue)
AttachmentStore
getAttachmentDirectory
in interface AttachmentStore
issue
- the issue whose attachment directory you wantpublic File getAttachmentDirectory(String attachmentDirectory, String projectKey, String issueKey)
AttachmentStore
The idea is to encapsulate all of the path-joinery magic to make future refactoring easier if we ever decide to move away from attachment-base/project-key/issue-ket
getAttachmentDirectory
in interface AttachmentStore
attachmentDirectory
- base of attachmentsprojectKey
- the project key the issue belongs toissueKey
- the issue key for the issuepublic void checkValidAttachmentDirectory(Issue issue) throws AttachmentException
AttachmentStore
checkValidAttachmentDirectory
in interface AttachmentStore
issue
- the issue whose attachment directory to check.AttachmentException
- if the directory is not writable or missing and cannot be created.public void checkValidTemporaryAttachmentDirectory() throws AttachmentException
AttachmentStore
checkValidTemporaryAttachmentDirectory
in interface AttachmentStore
AttachmentException
- if the directory is not writable or missing and cannot be created.public File getAttachmentFile(AttachmentStore.AttachmentAdapter adapter, File attachmentDir)
AttachmentStore
In practice, this is just used during Project Import
getAttachmentFile
in interface AttachmentStore
adapter
- it's not an attachment but it acts like one for our purposes.attachmentDir
- the directory the attachments live in. This is different that the system-wide attachment
directory. i.e. this would "attachments/MKY/MKY-1" and not just "attachments"@Nonnull public File getThumbnailFile(Attachment attachment)
AttachmentStore
http://jira.atlassian.com/browse/JRA-23311
getThumbnailFile
in interface AttachmentStore
attachment
- the attachment for which to get the thumbnail fileAttachmentStore.getThumbnailFile(com.atlassian.jira.issue.Issue, Attachment)
@Nonnull public File getThumbnailFile(Issue issue, Attachment attachment)
AttachmentStore
AttachmentStore.getThumbnailFile(Attachment)
if you already have the issue.getThumbnailFile
in interface AttachmentStore
issue
- the issue to which the attachment belongsattachment
- the attachment for which to get the thumbnail fileAttachmentStore.getThumbnailFile(Attachment)
public File getLegacyThumbnailFile(Attachment attachment)
AttachmentStore
http://jira.atlassian.com/browse/JRA-23311
getLegacyThumbnailFile
in interface AttachmentStore
attachment
- the attachment in playpublic File getAttachmentFile(Issue issue, Attachment attachment) throws DataAccessException
AttachmentStore
getAttachmentFile
in interface AttachmentStore
issue
- the issue the attachment belongs to.attachment
- the attachment.DataAccessException
- on failure getting required attachment info.public File getAttachmentFile(Attachment attachment) throws DataAccessException
AttachmentStore
getAttachmentFile
in interface AttachmentStore
attachment
- the attachment.DataAccessException
- on failure getting required attachment info.public io.atlassian.util.concurrent.Promise<Attachment> putAttachment(Attachment metadata, InputStream source)
AttachmentStore
putAttachment
in interface AttachmentStore
metadata
- attachment metadata, used to determine the logical key under which to store the attachment datasource
- source data. The attachment store will close this stream when it has completed.
The stream will be closed once the operation is complete.AttachmentRuntimeException
in case of error.public io.atlassian.util.concurrent.Promise<Attachment> putAttachment(Attachment metadata, File source)
AttachmentStore
putAttachment
in interface AttachmentStore
metadata
- attachment metadata, used to determine the logical key under which to store the attachment datasource
- source data. It is assumed that the file will exist during the attachment process (i.e. relatively
long lived).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
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 io.atlassian.util.concurrent.Promise<io.atlassian.fugue.Unit> moveAttachment(AttachmentKey oldAttachmentKey, AttachmentKey newAttachmentKey)
StreamAttachmentStore
oldAttachmentKey
to be identified by newAttachmentKey
and will be not
reachable under oldAttachmentKey
anymore.moveAttachment
in interface StreamAttachmentStore
oldAttachmentKey
- the old AttachmentKeynewAttachmentKey
- the new AttachmentKeypublic 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
public 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
otherwisepublic <A> io.atlassian.util.concurrent.Promise<A> getAttachment(Attachment metaData, java.util.function.Function<InputStream,A> inputStreamProcessor)
AttachmentStore
getAttachment
in interface AttachmentStore
A
- The class that the inputStreamProcessor returns when run.metaData
- attachment metadata, used to determine the logical key under which to store the attachment datainputStreamProcessor
- Function that processes the attachment data.AttachmentRuntimeException
in case of error.public io.atlassian.util.concurrent.Promise<Void> move(Attachment metaData, String newIssueKey)
AttachmentStore
move
in interface AttachmentStore
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.AttachmentRuntimeException
in case of error.public io.atlassian.util.concurrent.Promise<Void> deleteAttachment(@Nonnull Attachment attachment)
AttachmentStore
deleteAttachment
in interface AttachmentStore
public io.atlassian.util.concurrent.Promise<Void> deleteAttachmentContainerForIssue(@Nonnull Issue issue)
AttachmentStore
deleteAttachmentContainerForIssue
in interface AttachmentStore
issue
- The issue to delete attachments for.@Nonnull public io.atlassian.util.concurrent.Promise<Attachment> copy(@Nonnull Attachment originalAttachment, @Nonnull Attachment metaData, @Nonnull String newIssueKey)
AttachmentStore
copy
in interface AttachmentStore
originalAttachment
- the original attachment.metaData
- the meta data of the copied attachment.newIssueKey
- the issue that the attachment will be copied to.@Nonnull public io.atlassian.fugue.Option<ErrorCollection> errors()
AttachmentStore
errors
in interface AttachmentHealth
errors
in interface AttachmentStore
Copyright © 2002-2022 Atlassian. All Rights Reserved.