public class DefaultAttachmentManager extends Object implements AttachmentManager
THUMBS_SUBDIR| Constructor and Description |
|---|
DefaultAttachmentManager(IssueManager issueManager,
OfBizDelegator ofBizDelegator,
MimeManager mimeManager,
ApplicationProperties applicationProperties,
AttachmentPathManager attachmentPathManager,
ComponentLocator componentLocator,
I18nHelper.BeanFactory i18nBeanFactory,
UserManager userManager,
AttachmentStore attachmentStore,
AttachmentIndexManager attachmentIndexManager,
StreamAttachmentStore streamAttachmentStore,
ThumbnailAccessor thumbnailAccessor,
AttachmentIdSequencer attachmentIdSequencer) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
attachmentsEnabled()
Determine if attachments have been enabled in JIRA and if the attachments directory exists.
|
io.atlassian.fugue.Either<AttachmentError,ChangeItemBean> |
convertTemporaryAttachment(ConvertTemporaryAttachmentParams params)
Converts temporary attachment into real attachment.
|
List<ChangeItemBean> |
convertTemporaryAttachments(ApplicationUser user,
Issue issue,
List<Long> selectedAttachments,
TemporaryAttachmentsMonitor temporaryAttachmentsMonitor)
Converts a set of provided temporary attachments to real attachments attached to an issue.
|
io.atlassian.fugue.Either<AttachmentError,Attachment> |
copyAttachment(Attachment attachment,
ApplicationUser author,
String newIssueKey)
Copy an attachment to another issue.
|
Map<Long,io.atlassian.fugue.Either<AttachmentError,Attachment>> |
copyAttachments(Context context,
Issue issue,
ApplicationUser author,
String newIssueKey)
Copy Issue attachments to another issue.
|
Map<Long,io.atlassian.fugue.Either<AttachmentError,Attachment>> |
copyAttachments(Issue issue,
ApplicationUser author,
String newIssueKey)
Copy Issue attachments to another issue.
|
ChangeItemBean |
createAttachment(CreateAttachmentParamsBean bean)
Create an attachment both on disk, and in the database.
|
ChangeItemBean |
createAttachment(File file,
String filename,
String contentType,
ApplicationUser remoteUser,
org.ofbiz.core.entity.GenericValue issue)
Same as the
#createAttachment(java.io.File, String, String, User, org.ofbiz.core.entity.GenericValue, java.util.Map, java.util.Date) method, except it
submits no attachmentProperties and uses now() for the created time. |
ChangeItemBean |
createAttachment(File file,
String filename,
String contentType,
ApplicationUser author,
org.ofbiz.core.entity.GenericValue issue,
Boolean zip,
Boolean thumbnailable,
Map<String,Object> attachmentProperties,
Date createdTime)
Create an attachment both on disk, and in the database.
|
ChangeItemBean |
createAttachment(File file,
String filename,
String contentType,
ApplicationUser author,
org.ofbiz.core.entity.GenericValue issue,
Map<String,Object> attachmentProperties,
Date createdTime)
Create an attachment both on disk, and in the database.
|
ChangeItemBean |
createAttachment(File file,
String filename,
String contentType,
ApplicationUser remoteUser,
Issue issue)
Same as the
#createAttachment(File, String, String, User, Issue, Map, Date) method, except it submits no
attachmentProperties and uses now() for the created time. |
ChangeItemBean |
createAttachment(File file,
String filename,
String contentType,
ApplicationUser remoteUser,
Issue issue,
Boolean zip,
Boolean thumbnailable,
Map<String,Object> attachmentProperties,
Date createdTime)
Create an attachment both on disk, and in the database.
|
ChangeItemBean |
createAttachment(File file,
String filename,
String contentType,
ApplicationUser remoteUser,
Issue issue,
Map<String,Object> attachmentProperties,
Date createdTime)
Create an attachment both on disk, and in the database.
|
Attachment |
createAttachment(org.ofbiz.core.entity.GenericValue issue,
ApplicationUser author,
String mimetype,
String filename,
Long filesize,
Map<String,Object> attachmentProperties,
Date createdTime)
Create an attachment in the database.
|
Attachment |
createAttachmentCopySourceFile(File file,
String filename,
String contentType,
String attachmentAuthor,
Issue issue,
Map<String,Object> attachmentProperties,
Date createdTime)
Create an attachment both on disk, and in the database by copying the provided file instead of moving it.
|
TemporaryAttachmentId |
createTemporaryAttachment(InputStream stream,
long size)
Creates new temporary attachment which may be later converted into real attachment.
|
void |
deleteAttachment(Attachment attachment)
Delete an attachment from the database and from the attachment store.
|
void |
deleteAttachmentDirectory(Issue issue)
Delete the attachment directory from disk if the directory is empty.
|
void |
deleteTemporaryAttachment(TemporaryAttachmentId temporaryAttachmentId)
Removes temporary attachment with given id
|
Attachment |
getAttachment(Long id)
Get a single attachment by its ID.
|
List<Attachment> |
getAttachments(Issue issue)
Get a list of all attachments for a certain issue.
|
List<Attachment> |
getAttachments(Issue issue,
Comparator<? super Attachment> comparator)
Get a list of all attachments for a certain issue, sorted according to the specified comparator.
|
List<Attachment> |
getStoredAttachments(Issue issue) |
boolean |
isScreenshotAppletEnabled()
Determine if screenshot applet has been enabled in JIRA.
|
protected boolean |
isScreenshotAppletEnabledForLinux() |
boolean |
isScreenshotAppletSupportedByOS()
Determine if the screenshot applet is supported by the user's operating system.
|
void |
moveAttachments(Issue oldIssue,
String newIssueKey)
Create a new directory for this issue, and move all the attachments from the old directory to the new directory.
|
Attachment |
setThumbnailable(Attachment attachment,
boolean thumbnailable)
Stores the thumbnailble flag for this attachment
|
Attachment |
setZip(Attachment attachment,
boolean zip)
Stores the zip flag for this attachment
|
<T> T |
streamAttachmentContent(Attachment attachment,
InputStreamConsumer<T> consumer)
Get binary content of the attachment
|
<T> T |
streamTemporaryAttachmentContent(TemporaryAttachmentId attachmentId,
InputStreamConsumer<T> consumer)
Get binary content of temporary attachment
|
AttachmentsBulkOperationResult<ChangeItemBean> |
tryConvertTemporaryAttachments(ApplicationUser user,
Issue issue,
List<Long> selectedAttachments,
TemporaryAttachmentsMonitor temporaryAttachmentsMonitor)
Converts a set of provided temporary attachments to real attachments attached to an issue.
|
io.atlassian.fugue.Either<AttachmentError,ChangeItemBean> |
tryCreateAttachment(CreateAttachmentParamsBean params)
Create an attachment.
|
public DefaultAttachmentManager(IssueManager issueManager, OfBizDelegator ofBizDelegator, MimeManager mimeManager, ApplicationProperties applicationProperties, AttachmentPathManager attachmentPathManager, ComponentLocator componentLocator, I18nHelper.BeanFactory i18nBeanFactory, UserManager userManager, AttachmentStore attachmentStore, AttachmentIndexManager attachmentIndexManager, StreamAttachmentStore streamAttachmentStore, ThumbnailAccessor thumbnailAccessor, AttachmentIdSequencer attachmentIdSequencer)
public Attachment getAttachment(Long id)
AttachmentManagergetAttachment in interface AttachmentManagerid - the Attachment IDpublic List<Attachment> getAttachments(Issue issue)
AttachmentManagergetAttachments in interface AttachmentManagerissue - the IssueAttachment objectspublic List<Attachment> getStoredAttachments(Issue issue)
public List<Attachment> getAttachments(Issue issue, Comparator<? super Attachment> comparator)
AttachmentManagergetAttachments in interface AttachmentManagerissue - the Issuecomparator - used for sortingAttachment objectspublic Attachment createAttachmentCopySourceFile(File file, String filename, String contentType, String attachmentAuthor, Issue issue, Map<String,Object> attachmentProperties, Date createdTime) throws AttachmentException
AttachmentManagercreateAttachmentCopySourceFile in interface AttachmentManagerfile - A file on a locally accessible filesystem, this will be copied, not moved.filename - The desired filename for this attachment. This may be different to the filename on disk (for example with temp files used in file uploads)contentType - The desired contentType. Implementations of this interface can choose to override this value as appropriateattachmentAuthor - The username of the user who created this attachment, this is not validated so it must be a valid usernameissue - The id of the issue that this attachment is attached toattachmentProperties - Attachment properties (a Map of String -> Object properties). These are optional,
and are used to populate a PropertySet on the Attachment (Attachment.getProperties(). Pass null to set no propertiescreatedTime - when the attachment was createdAttachmentException - if any errors occur.public Attachment createAttachment(org.ofbiz.core.entity.GenericValue issue, @Nullable ApplicationUser author, String mimetype, String filename, Long filesize, Map<String,Object> attachmentProperties, Date createdTime)
AttachmentManagercreateAttachment in interface AttachmentManagerissue - the issue that this attachment is attached toauthor - The user who created this attachmentmimetype - mimetypefilename - The desired filename for this attachment.filesize - filesizeattachmentProperties - Attachment properties (a Map of String -> Object properties).createdTime - when the attachment was createdpublic void deleteAttachment(Attachment attachment) throws RemoveException
AttachmentManagerdeleteAttachment in interface AttachmentManagerattachment - the AttachmentRemoveException - if the attachment cannot be removed from the attachment storepublic void deleteAttachmentDirectory(Issue issue) throws RemoveException
AttachmentManagerdeleteAttachmentDirectory in interface AttachmentManagerissue - the issue whose attachment directory we wish to delete.RemoveException - if the directory can not be removed or is not empty.public boolean attachmentsEnabled()
AttachmentManagerattachmentsEnabled in interface AttachmentManagerpublic boolean isScreenshotAppletEnabled()
AttachmentManagerisScreenshotAppletEnabled in interface AttachmentManagerprotected boolean isScreenshotAppletEnabledForLinux()
public boolean isScreenshotAppletSupportedByOS()
AttachmentManagerNote. This always returns true now as we support screenshots on all our supported platforms
isScreenshotAppletSupportedByOS in interface AttachmentManagerpublic AttachmentsBulkOperationResult<ChangeItemBean> tryConvertTemporaryAttachments(@Nullable ApplicationUser user, Issue issue, List<Long> selectedAttachments, TemporaryAttachmentsMonitor temporaryAttachmentsMonitor)
AttachmentManagertryConvertTemporaryAttachments in interface AttachmentManageruser - The user performing the actionissue - The issue attachments should be linked toselectedAttachments - The temporary attachment ids to convert as selected by the usertemporaryAttachmentsMonitor - TemporaryAttachmentsMonitor containing information about all temporary attachmentspublic ChangeItemBean createAttachment(File file, String filename, String contentType, @Nullable ApplicationUser remoteUser, Issue issue, Map<String,Object> attachmentProperties, Date createdTime) throws AttachmentException
AttachmentManagercreateAttachment in interface AttachmentManagerfile - A file on a locally accessible filesystemfilename - The desired filename for this attachment. This may be different to the filename on disk (for example with temp files used in file uploads)contentType - The desired contentType. Implementations of this interface can choose to override this value as appropriateremoteUser - The user who created this attachmentissue - The issue that this file is to be attached toattachmentProperties - Attachment properties (a Map of String -> Object properties). These are optional,
and are used to populate a PropertySet on the Attachment (Attachment.getProperties(). Pass null to set no propertiescreatedTime - the created timeChangeItemBean with all the changes to the issue.AttachmentException - if an IO error occurs while attempting to copy the file#createAttachment(java.io.File, String, String, com.atlassian.crowd.embedded.api.User, Issue)public ChangeItemBean createAttachment(File file, String filename, String contentType, @Nullable ApplicationUser remoteUser, Issue issue, Boolean zip, Boolean thumbnailable, Map<String,Object> attachmentProperties, Date createdTime) throws AttachmentException
AttachmentManagercreateAttachment in interface AttachmentManagerfile - A file on a locally accessible filesystemfilename - The desired filename for this attachment. This may be different to the filename on disk (for example with temp files used in file uploads)contentType - The desired contentType. Implementations of this interface can choose to override this value as appropriateremoteUser - The user who created this attachmentissue - The issue that this file is to be attached tozip - This file is a zip file. Null indicates that it is not know if this attachment is a zip file or notthumbnailable - This file is thumbnailable (e.g. a png image). Null indicates that it is not know if this attachment is thumbnailable or notattachmentProperties - Attachment properties (a Map of String -> Object properties). These are optional,
and are used to populate a PropertySet on the Attachment (Attachment.getProperties(). Pass null to set no propertiescreatedTime - the created timeChangeItemBean with all the changes to the issue.AttachmentException - if an IO error occurs while attempting to copy the file#createAttachment(java.io.File, String, String, com.atlassian.crowd.embedded.api.User, Issue)public ChangeItemBean createAttachment(File file, String filename, String contentType, @Nullable ApplicationUser author, org.ofbiz.core.entity.GenericValue issue, Map<String,Object> attachmentProperties, Date createdTime) throws AttachmentException
AttachmentManagercreateAttachment in interface AttachmentManagercontentType - The desired contentType. This may be modified if a better alternative is suggested by MimeManager.getSanitisedMimeType(String, String)attachmentProperties - String -> Object property mapfile - A file on a locally accessible filesystemfilename - The desired filename for this attachment. This may be different to the filename on disk (for example with temp files used in file uploads)author - The user who created this attachmentissue - The issue that this attachment is attached tocreatedTime - the created timeChangeItemBean with all the changes to the issue.AttachmentException - if an error occurs while attempting to copy the filepublic ChangeItemBean createAttachment(File file, String filename, String contentType, @Nullable ApplicationUser author, org.ofbiz.core.entity.GenericValue issue, Boolean zip, Boolean thumbnailable, Map<String,Object> attachmentProperties, Date createdTime) throws AttachmentException
AttachmentManagercreateAttachment in interface AttachmentManagercontentType - The desired contentType. This may be modified if a better alternative is suggested by MimeManager.getSanitisedMimeType(String, String)attachmentProperties - String -> Object property mapfile - A file on a locally accessible filesystemfilename - The desired filename for this attachment. This may be different to the filename on disk (for example with temp files used in file uploads)author - The user who created this attachmentissue - The issue that this attachment is attached tozip - This file is a zip file. Null indicates that it is not know if this attachment is a zip file or notthumbnailable - This file is thumbnailable (e.g. a png image). Null indicates that it is not know if this attachment is thumbnailable or notcreatedTime - the created timeChangeItemBean with all the changes to the issue.AttachmentException - if an error occurs while attempting to copy the filepublic ChangeItemBean createAttachment(File file, String filename, String contentType, @Nullable ApplicationUser remoteUser, org.ofbiz.core.entity.GenericValue issue) throws AttachmentException
AttachmentManager#createAttachment(java.io.File, String, String, User, org.ofbiz.core.entity.GenericValue, java.util.Map, java.util.Date) method, except it
submits no attachmentProperties and uses now() for the created time.createAttachment in interface AttachmentManagerfile - A file on a locally accessible filesystemfilename - The desired filename for this attachment. This may be different to the filename on disk (for example with temp files used in file uploads)contentType - The desired contentType. Implementations of this interface can choose to override this value as appropriateremoteUser - The user who created this attachmentissue - The issue that this attachment is attached toChangeItemBean with all the changes to the issue.AttachmentException - if an error occurs while attempting to copy the filepublic ChangeItemBean createAttachment(File file, String filename, String contentType, @Nullable ApplicationUser remoteUser, Issue issue) throws AttachmentException
AttachmentManager#createAttachment(File, String, String, User, Issue, Map, Date) method, except it submits no
attachmentProperties and uses now() for the created time.createAttachment in interface AttachmentManagerfile - A file on a locally accessible filesystemfilename - The desired filename for this attachment. This may be different to the filename on disk (for example with temp files used in file uploads)contentType - The desired contentType. Implementations of this interface can choose to override this value as appropriateremoteUser - The user who created this attachmentissue - The issue that this attachment is attached toChangeItemBean with all the changes to the issue.AttachmentException - if an IO error occurs while attempting to copy the file#createAttachment(java.io.File, String, String, com.atlassian.crowd.embedded.api.User, Issue, java.util.Map, java.util.Date)public ChangeItemBean createAttachment(CreateAttachmentParamsBean bean) throws AttachmentException
AttachmentManagercreateAttachment in interface AttachmentManagerbean - Parameters which describe created attachmentChangeItemBean with all the changes to the issue.AttachmentException - if an IO error occurs while attempting to copy the filefor creating beanspublic io.atlassian.fugue.Either<AttachmentError,ChangeItemBean> tryCreateAttachment(CreateAttachmentParamsBean params)
AttachmentManagertryCreateAttachment in interface AttachmentManagerparams - Parameters which describe created attachmentChangeItemBean with all the changes to the issue or the AttachmentError in case of any
errors while attempting to create attachment.for creating paramspublic List<ChangeItemBean> convertTemporaryAttachments(@Nullable ApplicationUser user, Issue issue, List<Long> selectedAttachments, TemporaryAttachmentsMonitor temporaryAttachmentsMonitor) throws AttachmentException
AttachmentManagerconvertTemporaryAttachments in interface AttachmentManageruser - The user performing the actionissue - The issue attachments should be linked toselectedAttachments - The temporary attachment ids to convert as selected by the usertemporaryAttachmentsMonitor - TemporaryAttachmentsMonitor containing information about all temporary attachmentsAttachmentException - If there were problems with the Attachment itselfpublic Attachment setThumbnailable(Attachment attachment, boolean thumbnailable)
AttachmentManagersetThumbnailable in interface AttachmentManagerattachment - The attachmentthumbnailable - True if this attachment is thumnailablepublic Attachment setZip(Attachment attachment, boolean zip)
AttachmentManagersetZip in interface AttachmentManagerattachment - The attachmentzip - True if this attachment is a zip filepublic <T> T streamAttachmentContent(@Nonnull Attachment attachment, InputStreamConsumer<T> consumer) throws AttachmentReadException, NoAttachmentDataException
AttachmentManagerstreamAttachmentContent in interface AttachmentManagerattachment - the attachment whose content to stream (required)consumer - the consumer of the stream (required)AttachmentReadException - if a problem occurs when the consumer processes the attachment's contents.NoAttachmentDataException - if the attachment's contents cannot be found.public void moveAttachments(Issue oldIssue, String newIssueKey)
NB - this will fail if the old directory and new directory are on different filesystems as File.renameTo(java.io.File)
fails across filesystems.
moveAttachments in interface AttachmentManageroldIssue - the issue we're moving attachments fromnewIssueKey - the new destination issue keypublic io.atlassian.fugue.Either<AttachmentError,Attachment> copyAttachment(Attachment attachment, @Nullable ApplicationUser author, String newIssueKey)
AttachmentManagercopyAttachment in interface AttachmentManagerattachment - the attachment to copy to a new issueauthor - the user that will own the new attachmentnewIssueKey - the key of the issue that the attachment will be copied topublic Map<Long,io.atlassian.fugue.Either<AttachmentError,Attachment>> copyAttachments(Issue issue, @Nullable ApplicationUser author, String newIssueKey)
AttachmentManagercopyAttachments in interface AttachmentManagerissue - the issue attachments will be copied fromauthor - the user that will own the new attachmentsnewIssueKey - the key of the issue that the attachment will be copied topublic Map<Long,io.atlassian.fugue.Either<AttachmentError,Attachment>> copyAttachments(Context context, Issue issue, @Nullable ApplicationUser author, String newIssueKey)
AttachmentManagercopyAttachments in interface AttachmentManagercontext - Task context for recording progress.issue - the issue attachments will be copied fromauthor - the user that will own the new attachmentsnewIssueKey - the key of the issue that the attachment will be copied topublic TemporaryAttachmentId createTemporaryAttachment(InputStream stream, long size)
AttachmentManagercreateTemporaryAttachment in interface AttachmentManagerstream - Stream with temporary attachment contentsize - Size of temporary attachmentpublic void deleteTemporaryAttachment(TemporaryAttachmentId temporaryAttachmentId)
AttachmentManagerdeleteTemporaryAttachment in interface AttachmentManagertemporaryAttachmentId - id of temporary attachmentpublic io.atlassian.fugue.Either<AttachmentError,ChangeItemBean> convertTemporaryAttachment(ConvertTemporaryAttachmentParams params)
AttachmentManagerconvertTemporaryAttachment in interface AttachmentManagerparams - Parameters describingChangeItemBean with all the changes to the issue.public <T> T streamTemporaryAttachmentContent(@Nonnull TemporaryAttachmentId attachmentId, InputStreamConsumer<T> consumer) throws AttachmentReadException, NoAttachmentDataException
AttachmentManagerstreamTemporaryAttachmentContent in interface AttachmentManagerattachmentId - id of temporary attachment whose content to stream (required)consumer - the consumer of the stream (required)AttachmentReadException - if a problem occurs when the consumer processes the attachment's contents.NoAttachmentDataException - if the attachment's contents cannot be found.Copyright © 2002-2022 Atlassian. All Rights Reserved.