@ParametersAreNonnullByDefault public class DefaultAttachmentStore extends Object implements AttachmentStore
AttachmentStore.AttachmentAdapter
Constructor and Description |
---|
DefaultAttachmentStore(AttachmentDirectoryAccessor directoryAccessor,
AttachmentKeyMapper attachmentKeyMapper,
StoreAttachmentBeanMapper storeAttachmentBeanMapper,
StreamAttachmentStore streamAttachmentStore,
ThumbnailAccessor thumbnailAccessor) |
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.
|
File |
getAttachmentDirectory(Issue issue,
boolean createDirectory)
Returns the physical directory of the attachments for the given issue.
|
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(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 lookup 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.
|
File |
getTemporaryAttachmentDirectory()
Returns the directory for temporary attachments.
|
File |
getThumbnailDirectory(Issue issue)
Returns the physical directory of the thumbnails for the given issue, creating it 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.
|
public DefaultAttachmentStore(AttachmentDirectoryAccessor directoryAccessor, AttachmentKeyMapper attachmentKeyMapper, StoreAttachmentBeanMapper storeAttachmentBeanMapper, StreamAttachmentStore streamAttachmentStore, ThumbnailAccessor thumbnailAccessor)
@Nonnull public File getThumbnailDirectory(Issue issue)
AttachmentStore
getThumbnailDirectory
in interface AttachmentStore
issue
- the issue whose thumbnail directory you wantpublic 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 exist, this method creates it@Nonnull public File getTemporaryAttachmentDirectory()
AttachmentStore
getTemporaryAttachmentDirectory
in interface AttachmentStore
public File getAttachmentDirectory(String attachmentDirectory, String projectKey, String issueKey)
AttachmentStore
The idea is to encapsulate all the path-joinery logic to make future refactoring easier if we ever decide to
move away from attachment-base/project-key/issue-key
.
getAttachmentDirectory
in interface AttachmentStore
attachmentDirectory
- base of attachmentsprojectKey
- the project key the issue belongs toissueKey
- the issue key for the issuepublic File getAttachmentFile(Issue issue, Attachment attachment) throws DataAccessException
AttachmentStore
getAttachmentFile
in interface AttachmentStore
issue
- the issue to which the attachment belongsattachment
- the attachmentDataAccessException
- on failure getting required attachment info.public File getAttachmentFile(AttachmentStore.AttachmentAdapter adapter, File attachmentDir)
AttachmentStore
getAttachmentFile
in interface AttachmentStore
adapter
- it's not an attachment, but it acts like one for our purposes.attachmentDir
- the directory in which the attachments live. This is different to the system-wide attachment
directory, for example "attachments/MKY/MKY-1" rather than simply "attachments"@Nonnull public File getThumbnailFile(Attachment attachment)
AttachmentStore
See JRASERVER-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
See JRASERVER-23311.
getLegacyThumbnailFile
in interface AttachmentStore
attachment
- the attachment in playpublic 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.Copyright © 2002-2024 Atlassian. All Rights Reserved.