com.atlassian.jira.issue
Interface AttachmentManager

All Known Implementing Classes:
DefaultAttachmentManager

public interface AttachmentManager

Manages all attachment related tasks in JIRA, which involves retrieving an attachment, creating an attachment and deleting an attachment.


Method Summary
 boolean attachmentsEnabled()
          Determine if attachments have been enabled in JIRA and if the attachments directory exists.
 java.util.List<ChangeItemBean> convertTemporaryAttachments(com.opensymphony.user.User user, Issue issue, java.util.List<java.lang.Long> selectedAttachments, TemporaryAttachmentsMonitor temporaryAttachmentsMonitor)
          Converts a set of provided temporary attachments to real attachments attached to an issue.
 ChangeItemBean createAttachment(java.io.File file, java.lang.String filename, java.lang.String contentType, com.opensymphony.user.User remoteUser, org.ofbiz.core.entity.GenericValue issue)
          Same as the createAttachment(java.io.File, String, String, com.opensymphony.user.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(java.io.File file, java.lang.String filename, java.lang.String contentType, com.opensymphony.user.User remoteUser, org.ofbiz.core.entity.GenericValue issue, java.util.Map attachmentProperties, java.util.Date createdTime)
          Create an attachment both on disk, and in the database.
 Attachment createAttachment(org.ofbiz.core.entity.GenericValue issue, com.opensymphony.user.User author, java.lang.String mimetype, java.lang.String filename, java.lang.Long filesize, java.util.Map attachmentProperties, java.util.Date createdTime)
          Create an attachment in the database.
 Attachment createAttachmentCopySourceFile(java.io.File file, java.lang.String filename, java.lang.String contentType, java.lang.String attachmentAuthor, Issue issue, java.util.Map attachmentProperties, java.util.Date createdTime)
          Create an attachment both on disk, and in the database by copying the provided file instead of moving it.
 void deleteAttachment(Attachment attachment)
          Delete an attachment from the database and from disk.
 void deleteAttachmentDirectory(org.ofbiz.core.entity.GenericValue issue)
          Deprecated. Please use deleteAttachmentDirectory(Issue) instead. Deprecated since v4.2
 void deleteAttachmentDirectory(Issue issue)
          Delete the attachment directory from disk if the directory is empty.
 Attachment getAttachment(java.lang.Long id)
          Get a single attachment by its ID.
 java.util.List<Attachment> getAttachments(org.ofbiz.core.entity.GenericValue issue)
          Deprecated. use #getAttachments(Issue) instead. Since v4.0
 java.util.List<Attachment> getAttachments(Issue issue)
          Get a list of all attachments for a certain issue.
 java.util.List<Attachment> getAttachments(Issue issue, java.util.Comparator<Attachment> comparator)
          Get a list of all attachments for a certain issue, sorted according to the specified comparator.
 boolean isScreenshotAppletEnabled()
          Determine if screenshot applet has been enabled in JIRA.
 boolean isScreenshotAppletSupportedByOS()
          Determine if the screenshot applet is supported by the user's operating system.
 

Method Detail

getAttachment

Attachment getAttachment(java.lang.Long id)
                         throws DataAccessException
Get a single attachment by its ID.

Parameters:
id - the Attachment ID
Returns:
the Attachment
Throws:
DataAccessException - if there is a problem accessing the database.

getAttachments

java.util.List<Attachment> getAttachments(org.ofbiz.core.entity.GenericValue issue)
                                          throws DataAccessException
Deprecated. use #getAttachments(Issue) instead. Since v4.0

Get a list of all attachments for a certain issue.

Parameters:
issue - the Issue
Returns:
a list of Attachment objects for the given issue.
Throws:
DataAccessException - if there is a problem accessing the database.

getAttachments

java.util.List<Attachment> getAttachments(Issue issue)
                                          throws DataAccessException
Get a list of all attachments for a certain issue.

Parameters:
issue - the Issue
Returns:
a list of Attachment objects
Throws:
DataAccessException - if there is a problem accessing the database.

getAttachments

java.util.List<Attachment> getAttachments(Issue issue,
                                          java.util.Comparator<Attachment> comparator)
                                          throws DataAccessException
Get a list of all attachments for a certain issue, sorted according to the specified comparator.

Parameters:
issue - the Issue
comparator - used for sorting
Returns:
a list of Attachment objects
Throws:
DataAccessException - if there is a problem accessing the database.

createAttachmentCopySourceFile

Attachment createAttachmentCopySourceFile(java.io.File file,
                                          java.lang.String filename,
                                          java.lang.String contentType,
                                          java.lang.String attachmentAuthor,
                                          Issue issue,
                                          java.util.Map attachmentProperties,
                                          java.util.Date createdTime)
                                          throws AttachmentException
Create an attachment both on disk, and in the database by copying the provided file instead of moving it.

Parameters:
file - 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 appropriate
attachmentAuthor - The username of the user who created this attachment, this is not validated so it must be a valid username
issue - The id of the issue that this attachment is attached to
attachmentProperties - 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 properties
createdTime - when the attachment was created
Returns:
the Attachment
Throws:
AttachmentException - if any errors occur.

createAttachment

ChangeItemBean createAttachment(java.io.File file,
                                java.lang.String filename,
                                java.lang.String contentType,
                                com.opensymphony.user.User remoteUser,
                                org.ofbiz.core.entity.GenericValue issue,
                                java.util.Map attachmentProperties,
                                java.util.Date createdTime)
                                throws AttachmentException,
                                       org.ofbiz.core.entity.GenericEntityException
Create an attachment both on disk, and in the database.

Parameters:
file - A file on a locally accessible filesystem
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 appropriate
remoteUser - The use who created this attachment
issue - The issue that this attachment is attached to
attachmentProperties - 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 properties
createdTime - the created time
Returns:
A ChangeItemBean with all the changes to the issue.
Throws:
AttachmentException - if an error occurs while attempting to copy the file
org.ofbiz.core.entity.GenericEntityException - if there is an error in creating the DB record for the attachment

createAttachment

ChangeItemBean createAttachment(java.io.File file,
                                java.lang.String filename,
                                java.lang.String contentType,
                                com.opensymphony.user.User remoteUser,
                                org.ofbiz.core.entity.GenericValue issue)
                                throws AttachmentException,
                                       org.ofbiz.core.entity.GenericEntityException
Same as the createAttachment(java.io.File, String, String, com.opensymphony.user.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.

Parameters:
file - A file on a locally accessible filesystem
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 appropriate
remoteUser - The use who created this attachment
issue - The issue that this attachment is attached to
Returns:
A ChangeItemBean with all the changes to the issue.
Throws:
AttachmentException - if an error occurs while attempting to copy the file
org.ofbiz.core.entity.GenericEntityException - if there is an error in creating the DB record for the attachment

createAttachment

Attachment createAttachment(org.ofbiz.core.entity.GenericValue issue,
                            com.opensymphony.user.User author,
                            java.lang.String mimetype,
                            java.lang.String filename,
                            java.lang.Long filesize,
                            java.util.Map attachmentProperties,
                            java.util.Date createdTime)
                            throws org.ofbiz.core.entity.GenericEntityException
Create an attachment in the database. Note that this does not create it on disk, nor does it create a change item.

Parameters:
issue - the issue that this attachment is attached to
author - The user who created this attachment
mimetype - mimetype
filename - The desired filename for this attachment.
filesize - filesize
attachmentProperties - Attachment properties (a Map of String -> Object properties).
createdTime - when the attachment was created
Returns:
the Attachment
Throws:
org.ofbiz.core.entity.GenericEntityException - if there is an error in creating the DB record for the attachment

deleteAttachment

void deleteAttachment(Attachment attachment)
                      throws RemoveException
Delete an attachment from the database and from disk.

Parameters:
attachment - the Attachment
Throws:
RemoveException - if the attachment cannot be removed from the disk

deleteAttachmentDirectory

void deleteAttachmentDirectory(org.ofbiz.core.entity.GenericValue issue)
                               throws RemoveException
Deprecated. Please use deleteAttachmentDirectory(Issue) instead. Deprecated since v4.2

Delete the attachment directory from disk if the directory is empty.

Parameters:
issue - the issue whose attachment directory we wish to delete.
Throws:
RemoveException - if the directory can not be removed or is not empty.

deleteAttachmentDirectory

void deleteAttachmentDirectory(Issue issue)
                               throws RemoveException
Delete the attachment directory from disk if the directory is empty.

Parameters:
issue - the issue whose attachment directory we wish to delete.
Throws:
RemoveException - if the directory can not be removed or is not empty.

attachmentsEnabled

boolean attachmentsEnabled()
Determine if attachments have been enabled in JIRA and if the attachments directory exists.

Returns:
true if enabled, false otherwise

isScreenshotAppletEnabled

boolean isScreenshotAppletEnabled()
Determine if screenshot applet has been enabled in JIRA.

Returns:
true if enabled, false otherwise

isScreenshotAppletSupportedByOS

boolean isScreenshotAppletSupportedByOS()
Determine if the screenshot applet is supported by the user's operating system. Note. This always returns true now as we support screenshots on all our supported platforms

Returns:
true if applet is supported by the user's OS, false otherwise

convertTemporaryAttachments

java.util.List<ChangeItemBean> convertTemporaryAttachments(com.opensymphony.user.User user,
                                                           Issue issue,
                                                           java.util.List<java.lang.Long> selectedAttachments,
                                                           TemporaryAttachmentsMonitor temporaryAttachmentsMonitor)
                                                           throws AttachmentException,
                                                                  org.ofbiz.core.entity.GenericEntityException
Converts a set of provided temporary attachments to real attachments attached to an issue. This method will also clean up any temporary attachments still linked to the issue via the TemporaryAttachmentsMonitor.

Parameters:
user - The user performing the action
issue - The issue attachments should be linked to
selectedAttachments - The temporary attachment ids to convert as selected by the user
temporaryAttachmentsMonitor - TemporaryAttachmentsMonitor containing information about all temporary attachments
Returns:
A list of ChangeItemBeans for any attachments that got created
Throws:
AttachmentException - If there were problems with the Attachment itself
org.ofbiz.core.entity.GenericEntityException - if there is an error in creating the DB record for the attachment


Copyright © 2002-2010 Atlassian. All Rights Reserved.