public class

ViewAttachmentServlet

extends AbstractViewFileServlet
java.lang.Object
   ↳ javax.servlet.GenericServlet
     ↳ javax.servlet.http.HttpServlet
       ↳ com.atlassian.jira.web.servlet.AbstractViewFileServlet
         ↳ com.atlassian.jira.web.servlet.ViewAttachmentServlet
Known Direct Subclasses

Summary

Public Constructors
ViewAttachmentServlet()
Protected Methods
Attachment getAttachment(String query)
Looks up the attachment by reading the id from the query string.
void getInputStream(String attachmentQuery, InputStreamConsumer<Unit> consumer)
Gets the attachment file (not the file name) that corresponds to the requested attachment.
boolean hasPermissionToViewAttachment(String username, Attachment attachment)
Checks if the given user had permission to see the attachemnt.
void setResponseHeaders(HttpServletRequest request, HttpServletResponse response)
Sets the content type, content length and "Content-Disposition" header of the response based on the values of the attachement found.
[Expand]
Inherited Methods
From class com.atlassian.jira.web.servlet.AbstractViewFileServlet
From class javax.servlet.http.HttpServlet
From class javax.servlet.GenericServlet
From class java.lang.Object
From interface javax.servlet.Servlet
From interface javax.servlet.ServletConfig

Public Constructors

public ViewAttachmentServlet ()

Protected Methods

protected Attachment getAttachment (String query)

Looks up the attachment by reading the id from the query string.

Parameters
query eg. '/10000/foo.txt'
Returns
  • attachment found
Throws
AttachmentNotFoundException if no attachment is found after parsing the query string or if the resulting attachment id does not exist.
DataAccessException if there is a problem accessing the database.

protected void getInputStream (String attachmentQuery, InputStreamConsumer<Unit> consumer)

Gets the attachment file (not the file name) that corresponds to the requested attachment.

Parameters
attachmentQuery the attachment path
consumer a procedure that consumes the stream with the attachment data.

protected boolean hasPermissionToViewAttachment (String username, Attachment attachment)

Checks if the given user had permission to see the attachemnt.

Parameters
username username of the user who wants to see the attachment
attachment attachment to be checked
Returns
  • true if user can see the attachment, false otherwise
Throws
DataAccessException if no such user exists.

protected void setResponseHeaders (HttpServletRequest request, HttpServletResponse response)

Sets the content type, content length and "Content-Disposition" header of the response based on the values of the attachement found.

Parameters
request HTTP request
response HTTP response
Throws
AttachmentNotFoundException
IOException
AttachmentNotFoundException