public abstract class

AbstractAvatarServlet

extends HttpServlet
java.lang.Object
   ↳ javax.servlet.GenericServlet
     ↳ javax.servlet.http.HttpServlet
       ↳ com.atlassian.jira.web.servlet.AbstractAvatarServlet
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Abstract servlet to serve avatar images

Summary

Public Constructors
AbstractAvatarServlet()
Protected Methods
boolean avatarOkForOwner(String ownerId, Avatar avatar)
void defaultDoGet(HttpServletRequest request, HttpServletResponse response, String ownerId, Long avatarId, Avatar.Size size)
Template method that processes the GET request.
void doGet(HttpServletRequest request, HttpServletResponse response)
final AvatarManager getAvatarManager()
final AvatarToStream getAvatarToStream()
String getOwnerId(HttpServletRequest request)
abstract String getOwnerIdParamName()
Slight hack to stay backwards compatible for project avatars via the 'pid' param.
static void handleOutputStreamingException(HttpServletResponse response, boolean bytesWritten, Exception e)
abstract Long validateInput(String ownerId, Long avatarId, HttpServletResponse response)
Ensures the input is valid and if validation passes returns a valid avatarId to serve.
[Expand]
Inherited Methods
From class javax.servlet.http.HttpServlet
From class javax.servlet.GenericServlet
From class java.lang.Object
From interface javax.servlet.Servlet
From interface javax.servlet.ServletConfig

Public Constructors

public AbstractAvatarServlet ()

Protected Methods

protected boolean avatarOkForOwner (String ownerId, Avatar avatar)

protected void defaultDoGet (HttpServletRequest request, HttpServletResponse response, String ownerId, Long avatarId, Avatar.Size size)

Template method that processes the GET request. Subclasses may override this method to change the avatar serving logic.

Throws
IOException
ServletException

protected void doGet (HttpServletRequest request, HttpServletResponse response)

Throws
ServletException
IOException

protected final AvatarManager getAvatarManager ()

protected final AvatarToStream getAvatarToStream ()

protected String getOwnerId (HttpServletRequest request)

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.

protected static void handleOutputStreamingException (HttpServletResponse response, boolean bytesWritten, Exception e)

Throws
IOException
ServletException

protected abstract Long validateInput (String ownerId, Long avatarId, HttpServletResponse response)

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