com.atlassian.jira.web.servlet
Class ViewAttachmentServlet
java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
com.atlassian.jira.web.servlet.AbstractViewFileServlet
com.atlassian.jira.web.servlet.ViewAttachmentServlet
- All Implemented Interfaces:
- Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
- Direct Known Subclasses:
- ViewThumbnailServlet
public class ViewAttachmentServlet
- extends AbstractViewFileServlet
- See Also:
- Serialized Form
Methods inherited from class javax.servlet.http.HttpServlet |
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service |
Methods inherited from class javax.servlet.GenericServlet |
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ViewAttachmentServlet
public ViewAttachmentServlet()
getInputStream
protected void getInputStream(String attachmentQuery,
InputStreamConsumer<Void> consumer)
throws DataAccessException,
PermissionException,
IOException
- Returns the file of the attachment.
- Specified by:
getInputStream
in class AbstractViewFileServlet
- Parameters:
attachmentQuery
- the query describing which attachment to get
- Throws:
DataAccessException
- if attachment or user cannot be retrieved due to some kind of db access problem.
PermissionException
- if user is denied permission to see the attachment
IOException
- if there is a problem getting the File.
getAttachment
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
setResponseHeaders
protected void setResponseHeaders(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws AttachmentNotFoundException,
IOException
- Sets the content type, content length and "Content-Disposition" header
of the response based on the values of the attachement found.
- Specified by:
setResponseHeaders
in class AbstractViewFileServlet
- Parameters:
request
- HTTP requestresponse
- HTTP response
- Throws:
AttachmentNotFoundException
IOException
hasPermissionToViewAttachment
protected boolean hasPermissionToViewAttachment(String username,
Attachment attachment)
throws DataAccessException
- Checks if the given user had permission to see the attachemnt.
- Parameters:
username
- username of the user who wants to see the attachmentattachment
- attachment to be checked
- Returns:
- true if user can see the attachment, false otherwise
- Throws:
DataAccessException
- if no such user exists.
Copyright © 2002-2014 Atlassian. All Rights Reserved.