com.atlassian.jira.web.servlet
Class AbstractViewFileServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by com.atlassian.jira.web.servlet.AbstractViewFileServlet
All Implemented Interfaces:
Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
ViewAttachmentServlet

public abstract class AbstractViewFileServlet
extends javax.servlet.http.HttpServlet

See Also:
Serialized Form

Constructor Summary
AbstractViewFileServlet()
           
 
Method Summary
protected  String attachmentQuery(javax.servlet.http.HttpServletRequest request)
          Validates that path is valid attachment path.
protected  void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
protected abstract  void getInputStream(String attachmentPath, InputStreamConsumer<Void> consumer)
          Gets the attachment file (not the file name) that corresponds to the requested attachment.
protected  JiraAuthenticationContext getJiraAuthenticationContext()
           
protected  String getUserName()
           
protected abstract  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, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractViewFileServlet

public AbstractViewFileServlet()
Method Detail

doGet

protected void doGet(javax.servlet.http.HttpServletRequest request,
                     javax.servlet.http.HttpServletResponse response)
              throws javax.servlet.ServletException,
                     IOException
Overrides:
doGet in class javax.servlet.http.HttpServlet
Throws:
javax.servlet.ServletException
IOException

attachmentQuery

protected final String attachmentQuery(javax.servlet.http.HttpServletRequest request)
Validates that path is valid attachment path.

Parameters:
request - HTTP request
Returns:
attachment path

getInputStream

protected abstract void getInputStream(String attachmentPath,
                                       InputStreamConsumer<Void> consumer)
                                throws InvalidAttachmentPathException,
                                       DataAccessException,
                                       IOException,
                                       PermissionException
Gets the attachment file (not the file name) that corresponds to the requested attachment.

Parameters:
attachmentPath - the attachment path
Throws:
DataAccessException - If there is a problem looking up the data to support the attachment.
IOException - if there is a problem getting the File.
PermissionException - if the user has insufficient permission to see the attachment.
InvalidAttachmentPathException - if the path to the attachment was invalid in some way.

setResponseHeaders

protected abstract void setResponseHeaders(javax.servlet.http.HttpServletRequest request,
                                           javax.servlet.http.HttpServletResponse response)
                                    throws InvalidAttachmentPathException,
                                           DataAccessException,
                                           IOException
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:
InvalidAttachmentPathException
DataAccessException
IOException

getUserName

protected final String getUserName()
Returns:
The logged-in user's name, or null (anonymous)

getJiraAuthenticationContext

protected JiraAuthenticationContext getJiraAuthenticationContext()


Copyright © 2002-2014 Atlassian. All Rights Reserved.