@ParametersAreNonnullByDefault public class BackwardCompatibleAttachmentStore extends Object implements AttachmentStore, StreamAttachmentStore
AttachmentStore and StreamAttachmentStore implementation
that delegates calls to FileSystemAttachmentStore.AttachmentStore.AttachmentAdapterStreamAttachmentStore.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.
|
com.atlassian.util.concurrent.Promise<Attachment> |
copy(Attachment originalAttachment,
Attachment metaData,
String newIssueKey)
Copy an attachment to another issue.
|
com.atlassian.util.concurrent.Promise<com.atlassian.fugue.Unit> |
copyAttachment(AttachmentKey sourceAttachmentKey,
AttachmentKey newAttachmentKey)
Copies attachment identified by
oldAttachmentKey to be identified also by newAttachmentKey. |
com.atlassian.util.concurrent.Promise<Void> |
deleteAttachment(Attachment attachment)
Delete the specified attachment.
|
com.atlassian.util.concurrent.Promise<com.atlassian.fugue.Unit> |
deleteAttachment(AttachmentKey attachmentKey)
Delete the attachment identified by provided attachmentKey.
|
com.atlassian.util.concurrent.Promise<Void> |
deleteAttachmentContainerForIssue(Issue issue)
Delete the container for attachments for a given issue.
|
com.atlassian.util.concurrent.Promise<com.atlassian.fugue.Unit> |
deleteTemporaryAttachment(TemporaryAttachmentId temporaryAttachmentId)
Deletes temporary attachment created previously by
StreamAttachmentStore.putTemporaryAttachment(java.io.InputStream, long). |
com.atlassian.fugue.Option<ErrorCollection> |
errors()
Health status for this component.
|
com.atlassian.util.concurrent.Promise<Boolean> |
exists(AttachmentKey attachmentKey)
Checks if attachment exists.
|
<A> com.atlassian.util.concurrent.Promise<A> |
getAttachment(Attachment metaData,
com.atlassian.util.concurrent.Function<InputStream,A> inputStreamProcessor)
Retrieve data for a given attachment.
|
<A> com.atlassian.util.concurrent.Promise<A> |
getAttachment(AttachmentKey attachmentKey,
com.atlassian.util.concurrent.Function<InputStream,A> inputStreamProcessor)
Retrieve data for a given attachment.
|
<A> com.atlassian.util.concurrent.Promise<A> |
getAttachmentData(AttachmentKey attachmentKey,
com.atlassian.util.concurrent.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> com.atlassian.util.concurrent.Promise<A> |
getTemporaryAttachment(TemporaryAttachmentId temporaryAttachmentId,
com.atlassian.util.concurrent.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.
|
com.atlassian.util.concurrent.Promise<Void> |
move(Attachment metaData,
String newIssueKey)
Moves an attachment from its current issue under a new one
|
com.atlassian.util.concurrent.Promise<com.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. |
com.atlassian.util.concurrent.Promise<com.atlassian.fugue.Unit> |
moveTemporaryToAttachment(TemporaryAttachmentId temporaryAttachmentId,
AttachmentKey destinationKey)
Moving temporary attachment created by
StreamAttachmentStore.putTemporaryAttachment(java.io.InputStream, long) to real attachment. |
com.atlassian.util.concurrent.Promise<Attachment> |
putAttachment(Attachment metadata,
File source)
Store attachment data for a given attachment.
|
com.atlassian.util.concurrent.Promise<Attachment> |
putAttachment(Attachment metadata,
InputStream source)
Store attachment data for a given attachment.
|
com.atlassian.util.concurrent.Promise<StoreAttachmentResult> |
putAttachment(StoreAttachmentBean storeAttachmentBean)
Store attachment data for a given attachment.
|
com.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)
AttachmentStoregetThumbnailDirectory in interface AttachmentStoreissue - the issue whose thumbnail directory you wantpublic File getAttachmentDirectory(String issueKey)
getAttachmentDirectory in interface AttachmentStorepublic File getAttachmentDirectory(Issue issue, boolean createDirectory)
AttachmentStoregetAttachmentDirectory in interface AttachmentStoreissue - 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 AttachmentStorepublic File getAttachmentDirectory(Issue issue)
AttachmentStoregetAttachmentDirectory in interface AttachmentStoreissue - the issue whose attachment directory you wantpublic File getAttachmentDirectory(String attachmentDirectory, String projectKey, String issueKey)
AttachmentStoreThe 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 AttachmentStoreattachmentDirectory - base of attachmentsprojectKey - the project key the issue belongs toissueKey - the issue key for the issuepublic void checkValidAttachmentDirectory(Issue issue) throws AttachmentException
AttachmentStorecheckValidAttachmentDirectory in interface AttachmentStoreissue - 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
AttachmentStorecheckValidTemporaryAttachmentDirectory in interface AttachmentStoreAttachmentException - if the directory is not writable or missing and cannot be created.public File getAttachmentFile(AttachmentStore.AttachmentAdapter adapter, File attachmentDir)
AttachmentStoreIn practice, this is just used during Project Import
getAttachmentFile in interface AttachmentStoreadapter - 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)
AttachmentStorehttp://jira.atlassian.com/browse/JRA-23311
getThumbnailFile in interface AttachmentStoreattachment - the attachment for which to get the thumbnail fileAttachmentStore.getThumbnailFile(com.atlassian.jira.issue.Issue, Attachment)@Nonnull public File getThumbnailFile(Issue issue, Attachment attachment)
AttachmentStoreAttachmentStore.getThumbnailFile(Attachment) if you already have the issue.getThumbnailFile in interface AttachmentStoreissue - the issue to which the attachment belongsattachment - the attachment for which to get the thumbnail fileAttachmentStore.getThumbnailFile(Attachment)public File getLegacyThumbnailFile(Attachment attachment)
AttachmentStorehttp://jira.atlassian.com/browse/JRA-23311
getLegacyThumbnailFile in interface AttachmentStoreattachment - the attachment in playpublic File getAttachmentFile(Issue issue, Attachment attachment) throws DataAccessException
AttachmentStoregetAttachmentFile in interface AttachmentStoreissue - the issue the attachment belongs to.attachment - the attachment.DataAccessException - on failure getting required attachment info.public File getAttachmentFile(Attachment attachment) throws DataAccessException
AttachmentStoregetAttachmentFile in interface AttachmentStoreattachment - the attachment.DataAccessException - on failure getting required attachment info.public com.atlassian.util.concurrent.Promise<Attachment> putAttachment(Attachment metadata, InputStream source)
AttachmentStoreputAttachment in interface AttachmentStoremetadata - 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 com.atlassian.util.concurrent.Promise<Attachment> putAttachment(Attachment metadata, File source)
AttachmentStoreputAttachment in interface AttachmentStoremetadata - 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 com.atlassian.util.concurrent.Promise<StoreAttachmentResult> putAttachment(StoreAttachmentBean storeAttachmentBean)
StreamAttachmentStoreputAttachment in interface StreamAttachmentStorestoreAttachmentBean - attachment metadata, used to determine the logical key under which to store the
attachment dataAttachmentRuntimeException in case of error.public <A> com.atlassian.util.concurrent.Promise<A> getAttachment(AttachmentKey attachmentKey, com.atlassian.util.concurrent.Function<InputStream,A> inputStreamProcessor)
StreamAttachmentStoregetAttachment in interface StreamAttachmentStoreA - 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> com.atlassian.util.concurrent.Promise<A> getAttachmentData(AttachmentKey attachmentKey, com.atlassian.util.concurrent.Function<AttachmentGetData,A> attachmentGetDataProcessor)
StreamAttachmentStoregetAttachmentData in interface StreamAttachmentStoreA - 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.util.concurrent.Promise<com.atlassian.fugue.Unit> moveAttachment(AttachmentKey oldAttachmentKey, AttachmentKey newAttachmentKey)
StreamAttachmentStoreoldAttachmentKey to be identified by newAttachmentKey and will be not
reachable under oldAttachmentKey anymore.moveAttachment in interface StreamAttachmentStoreoldAttachmentKey - the old AttachmentKeynewAttachmentKey - the new AttachmentKeypublic com.atlassian.util.concurrent.Promise<com.atlassian.fugue.Unit> copyAttachment(AttachmentKey sourceAttachmentKey, AttachmentKey newAttachmentKey)
StreamAttachmentStoreoldAttachmentKey to be identified also by newAttachmentKey.copyAttachment in interface StreamAttachmentStoresourceAttachmentKey - attachmentKey of existing attachment which should be copiednewAttachmentKey - attachmentKey under which copiedpublic com.atlassian.util.concurrent.Promise<com.atlassian.fugue.Unit> deleteAttachment(AttachmentKey attachmentKey)
StreamAttachmentStoredeleteAttachment in interface StreamAttachmentStorepublic com.atlassian.util.concurrent.Promise<TemporaryAttachmentId> putTemporaryAttachment(InputStream inputStream, long size)
StreamAttachmentStoreStreamAttachmentStore.moveTemporaryToAttachment(TemporaryAttachmentId, AttachmentKey)putTemporaryAttachment in interface StreamAttachmentStoreinputStream - stream to temporary attachment datasize - the size of provided streampublic com.atlassian.util.concurrent.Promise<com.atlassian.fugue.Unit> moveTemporaryToAttachment(TemporaryAttachmentId temporaryAttachmentId, AttachmentKey destinationKey)
StreamAttachmentStoreStreamAttachmentStore.putTemporaryAttachment(java.io.InputStream, long) to real attachment.moveTemporaryToAttachment in interface StreamAttachmentStoretemporaryAttachmentId - id of temporary attachment, returned by StreamAttachmentStore.putTemporaryAttachment(java.io.InputStream, long)destinationKey - destination key of under which attachment will be identifiedpublic com.atlassian.util.concurrent.Promise<com.atlassian.fugue.Unit> deleteTemporaryAttachment(TemporaryAttachmentId temporaryAttachmentId)
StreamAttachmentStoreStreamAttachmentStore.putTemporaryAttachment(java.io.InputStream, long).deleteTemporaryAttachment in interface StreamAttachmentStoretemporaryAttachmentId - id of temporary attachmentpublic <A> com.atlassian.util.concurrent.Promise<A> getTemporaryAttachment(TemporaryAttachmentId temporaryAttachmentId, com.atlassian.util.concurrent.Function<InputStream,A> inputStreamProcessor)
StreamAttachmentStoregetTemporaryAttachment in interface StreamAttachmentStoreA - 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 com.atlassian.util.concurrent.Promise<Boolean> exists(AttachmentKey attachmentKey)
StreamAttachmentStoreexists in interface StreamAttachmentStoreattachmentKey - key of attachment to check for existencePromise to boolean result, true if attachment exists and false
otherwisepublic <A> com.atlassian.util.concurrent.Promise<A> getAttachment(Attachment metaData, com.atlassian.util.concurrent.Function<InputStream,A> inputStreamProcessor)
AttachmentStoregetAttachment in interface AttachmentStoreA - 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 com.atlassian.util.concurrent.Promise<Void> move(Attachment metaData, String newIssueKey)
AttachmentStoremove in interface AttachmentStoremetaData - 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 com.atlassian.util.concurrent.Promise<Void> deleteAttachment(@Nonnull Attachment attachment)
AttachmentStoredeleteAttachment in interface AttachmentStorepublic com.atlassian.util.concurrent.Promise<Void> deleteAttachmentContainerForIssue(@Nonnull Issue issue)
AttachmentStoredeleteAttachmentContainerForIssue in interface AttachmentStoreissue - The issue to delete attachments for.@Nonnull public com.atlassian.util.concurrent.Promise<Attachment> copy(@Nonnull Attachment originalAttachment, @Nonnull Attachment metaData, @Nonnull String newIssueKey)
AttachmentStorecopy in interface AttachmentStoreoriginalAttachment - the original attachment.metaData - the meta data of the copied attachment.newIssueKey - the issue that the attachment will be copied to.@Nonnull public com.atlassian.fugue.Option<ErrorCollection> errors()
AttachmentStoreerrors in interface AttachmentHealtherrors in interface AttachmentStoreCopyright © 2002-2018 Atlassian. All Rights Reserved.