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
Method Summary |
protected Attachment |
getAttachment(String query)
Looks up the attachment by reading the id from the query string. |
protected File |
getFileName(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Returns the file of the attachment. |
protected boolean |
hasPermissionToViewAttachment(String username,
Attachment attachment)
Checks if the given user had permission to see the attachemnt. |
void |
init(javax.servlet.ServletConfig servletConfig)
|
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. |
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, log, log |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ViewAttachmentServlet
public ViewAttachmentServlet()
init
public void init(javax.servlet.ServletConfig servletConfig)
throws javax.servlet.ServletException
- Specified by:
init
in interface javax.servlet.Servlet
- Overrides:
init
in class javax.servlet.GenericServlet
- Throws:
javax.servlet.ServletException
getFileName
protected File getFileName(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws DataAccessException,
PermissionException
- Returns the file of the attachment.
- Specified by:
getFileName
in class AbstractViewFileServlet
- Parameters:
request
- HTTP requestresponse
- HTTP response
- Returns:
- attachment file
- 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
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-2009 Atlassian. All Rights Reserved.