com.atlassian.jira.bc.issue.attachment
Class DefaultAttachmentService

java.lang.Object
  extended by com.atlassian.jira.bc.issue.attachment.DefaultAttachmentService
All Implemented Interfaces:
AttachmentService

public class DefaultAttachmentService
extends Object
implements AttachmentService


Constructor Summary
DefaultAttachmentService(AttachmentManager attachmentManager, PermissionManager permissionManager, JiraAuthenticationContext jiraAuthenticationContext, IssueUpdater issueUpdater, IssueManager issueManager)
           
 
Method Summary
 boolean canAttachScreenshots(JiraServiceContext jiraServiceContext, Issue issue)
          Determines whether the user: has the required permission (Permissions.CREATE_ATTACHMENT) to create an attachment has the screenshot enabled is using a screenshot applet compatible OS (Windows or OSX) the issue is in an editable workflow state
 boolean canCreateAttachments(JiraServiceContext jiraServiceContext, Issue issue)
          Determines whether attachments are enabled in JIRA and that the user has the required permission (Permissions.CREATE_ATTACHMENT) to create an attachment for this issue.
 boolean canDeleteAttachment(JiraServiceContext jiraServiceContext, Long attachmentId)
          Retrieves the attachment specified by the attachment id and determines if the user can delete it.
 boolean canManageAttachments(JiraServiceContext jiraServiceContext, Issue issue)
          Checks whether the user has permission to manage the attachments of the specified issue.
 void delete(JiraServiceContext jiraServiceContext, Long attachmentId)
          Deletes the specified attachment and updates the issue change history and 'updated' date.
 Attachment getAttachment(JiraServiceContext jiraServiceContext, Long attachmentId)
          Retrieves the specified issue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultAttachmentService

public DefaultAttachmentService(AttachmentManager attachmentManager,
                                PermissionManager permissionManager,
                                JiraAuthenticationContext jiraAuthenticationContext,
                                IssueUpdater issueUpdater,
                                IssueManager issueManager)
Method Detail

canDeleteAttachment

public boolean canDeleteAttachment(JiraServiceContext jiraServiceContext,
                                   Long attachmentId)
Description copied from interface: AttachmentService
Retrieves the attachment specified by the attachment id and determines if the user can delete it. The user can delete it if:

Specified by:
canDeleteAttachment in interface AttachmentService
Parameters:
jiraServiceContext - containing the user who the permission checks will be run against (can be null, indicating an anonymous user) and the errorCollection that will contain any errors in calling the method
attachmentId - specifies the attachment to be deleted
Returns:
true if the user has permission to delete the attachment; false otherwise

canManageAttachments

public boolean canManageAttachments(JiraServiceContext jiraServiceContext,
                                    Issue issue)
Description copied from interface: AttachmentService
Checks whether the user has permission to manage the attachments of the specified issue. This is true if

Specified by:
canManageAttachments in interface AttachmentService
Parameters:
jiraServiceContext - containing the user who the permission checks will be run against (can be null, indicating an anonymous user) and the errorCollection that will contain any errors in calling the method
issue - who's attachments will be checked against the specified user's delete permissions (if the issue is null an error will be placed into the supplied ErrorCollection and false will be returned)
Returns:
true if the user has permission to manage attachments

delete

public void delete(JiraServiceContext jiraServiceContext,
                   Long attachmentId)
Description copied from interface: AttachmentService
Deletes the specified attachment and updates the issue change history and 'updated' date.

This method expects that AttachmentService.canDeleteAttachment(com.atlassian.jira.bc.JiraServiceContext, Long) has been successfully called.

Specified by:
delete in interface AttachmentService
Parameters:
jiraServiceContext - containing the user who is attempting to delete the attachment and the errorCollection that will contain any errors in calling the method
attachmentId - of the target attachment, must not be null and must identify a valid attachment

getAttachment

public Attachment getAttachment(JiraServiceContext jiraServiceContext,
                                Long attachmentId)
Description copied from interface: AttachmentService
Retrieves the specified issue. Does not perform permission checks.

Specified by:
getAttachment in interface AttachmentService
Parameters:
jiraServiceContext - containing the user who is attempting to retrieve the attachment and the errorCollection that will contain any errors in calling the method
attachmentId - of the target attachment, must not be null and must identify a valid attachment
Returns:
target attachment if no errors occur, null otherwise

canCreateAttachments

public boolean canCreateAttachments(JiraServiceContext jiraServiceContext,
                                    Issue issue)
Description copied from interface: AttachmentService
Determines whether attachments are enabled in JIRA and that the user has the required permission (Permissions.CREATE_ATTACHMENT) to create an attachment for this issue. This method also checks that the provided issue is in an editable workflow state.

Specified by:
canCreateAttachments in interface AttachmentService
Parameters:
jiraServiceContext - containing the user who wishes to create an attachment and the errorCollection that will contain any errors in calling the method
issue - that will have an attachment attached to it
Returns:
true if the user has permission to attach an attachment to the issue and the issue is in an editable workflow state, false otherwise

canAttachScreenshots

public boolean canAttachScreenshots(JiraServiceContext jiraServiceContext,
                                    Issue issue)
Description copied from interface: AttachmentService
Determines whether the user:

Specified by:
canAttachScreenshots in interface AttachmentService
Parameters:
jiraServiceContext - containing the user who wishes to attach a screenshot and the errorCollection that will contain any errors in calling the method
issue - that will have the screenshot attached to it
Returns:
true if the user may attach a screenshot, false otherwise


Copyright © 2002-2010 Atlassian. All Rights Reserved.