com.atlassian.jira.web.servlet
Class AbstractAvatarServlet

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

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

Abstract servlet to serve avatar images

Since:
v4.2
See Also:
Serialized Form

Constructor Summary
AbstractAvatarServlet()
           
 
Method Summary
protected  boolean avatarOkForOwner(String ownerId, Avatar avatar)
           
protected  void defaultDoGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String ownerId, Long avatarId, AvatarManager.ImageSize size)
          Template method that processes the GET request.
protected  void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
protected abstract  String getOwnerIdParamName()
          Slight hack to stay backwards compatible for project avatars via the 'pid' param.
protected static void handleOutputStreamingException(javax.servlet.http.HttpServletResponse response, boolean bytesWritten, Exception e)
           
protected abstract  Long validateInput(String ownerId, Long avatarId, javax.servlet.http.HttpServletResponse response)
          Ensures the input is valid and if validation passes returns a valid avatarId to serve.
 
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

AbstractAvatarServlet

public AbstractAvatarServlet()
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

defaultDoGet

protected void defaultDoGet(javax.servlet.http.HttpServletRequest request,
                            javax.servlet.http.HttpServletResponse response,
                            String ownerId,
                            Long avatarId,
                            AvatarManager.ImageSize size)
                     throws IOException,
                            javax.servlet.ServletException
Template method that processes the GET request. Subclasses may override this method to change the avatar serving logic.

Throws:
IOException
javax.servlet.ServletException

avatarOkForOwner

protected boolean avatarOkForOwner(String ownerId,
                                   Avatar avatar)

handleOutputStreamingException

protected static void handleOutputStreamingException(javax.servlet.http.HttpServletResponse response,
                                                     boolean bytesWritten,
                                                     Exception e)
                                              throws IOException,
                                                     javax.servlet.ServletException
Throws:
IOException
javax.servlet.ServletException

validateInput

protected abstract Long validateInput(String ownerId,
                                      Long avatarId,
                                      javax.servlet.http.HttpServletResponse response)
                               throws IOException
Ensures the input is valid and if validation passes returns a valid avatarId to serve. If validation fails, this method should send errors on the response and return a null avatar id.

Parameters:
ownerId - The owner of the avatar
avatarId - The avatarId requested
response - The response to send
Returns:
The avatarId to serve to the user or null if validation fails
Throws:
IOException - If there's an error updating the response object

getOwnerIdParamName

protected abstract String getOwnerIdParamName()
Slight hack to stay backwards compatible for project avatars via the 'pid' param. The project avatar servlet implementation can return pid here instead of ownerId.

Returns:
The parameter used to identify the owner in the request.


Copyright © 2002-2013 Atlassian. All Rights Reserved.