public class ViewAttachmentServlet extends AbstractViewFileServlet
| Constructor and Description |
|---|
ViewAttachmentServlet() |
| Modifier and Type | Method and Description |
|---|---|
protected Attachment |
getAttachment(String query)
Looks up the attachment by reading the id from the query string.
|
protected void |
getInputStream(String attachmentQuery,
InputStreamConsumer<io.atlassian.blobstore.client.api.Unit> consumer)
Gets the attachment file (not the file name) that corresponds to the requested attachment.
|
protected boolean |
hasPermissionToViewAttachment(String username,
Attachment attachment)
Checks if the given user had permission to see the attachemnt.
|
protected void |
setResponseHeaders(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Sets the content type, content length and "Content-Disposition" header
of the response based on the values of the attachement found.
|
attachmentQuery, doGet, getJiraAuthenticationContext, getUserNamedoDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, serviceprotected void getInputStream(String attachmentQuery, InputStreamConsumer<io.atlassian.blobstore.client.api.Unit> consumer) throws PermissionException, IOException
AbstractViewFileServletgetInputStream in class AbstractViewFileServletattachmentQuery - the attachment pathconsumer - a procedure that consumes the stream with the attachment data.PermissionException - if the user has insufficient permission to see the attachment.IOException - if there is a problem getting the attachment.AbstractViewFileServlet.getInputStream(String, com.atlassian.jira.util.io.InputStreamConsumer)protected Attachment getAttachment(String query)
query - eg. '/10000/foo.txt'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 setResponseHeaders(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws AttachmentNotFoundException,
IOException
setResponseHeaders in class AbstractViewFileServletrequest - HTTP requestresponse - HTTP responseAttachmentNotFoundExceptionIOExceptionprotected boolean hasPermissionToViewAttachment(String username, Attachment attachment) throws DataAccessException
username - username of the user who wants to see the attachmentattachment - attachment to be checkedDataAccessException - if no such user exists.Copyright © 2002-2015 Atlassian. All Rights Reserved.