Package com.atlassian.jira.web.servlet
Class AbstractAvatarServlet
java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
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:
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanavatarOkForOwner(String ownerId, Avatar avatar) protected voiddefaultDoGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String ownerId, Long avatarId, Avatar.Size size) Template method that processes the GET request.protected voiddoGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) protected final Optional<AvatarManager>protected final AvatarToStreamprotected final Optional<FeatureManager>protected StringgetOwnerId(javax.servlet.http.HttpServletRequest request) protected abstract StringSlight hack to stay backwards compatible for project avatars via the 'pid' param.protected static voidhandleOutputStreamingException(javax.servlet.http.HttpServletResponse response, boolean bytesWritten, Exception e) protected booleanisFeatureEnabled(FeatureFlag featureFlag, boolean whenFeatureManagerNotPresent) protected abstract AbstractAvatarServlet.PreprocessedInputpreprocessInput(String ownerId, Long avatarId, Avatar.Size size, 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, serviceMethods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
-
Constructor Details
-
AbstractAvatarServlet
public AbstractAvatarServlet()
-
-
Method Details
-
doGet
protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException - Overrides:
doGetin classjavax.servlet.http.HttpServlet- Throws:
javax.servlet.ServletExceptionIOException
-
getOwnerId
-
defaultDoGet
protected void defaultDoGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String ownerId, Long avatarId, Avatar.Size 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:
IOExceptionjavax.servlet.ServletException
-
avatarOkForOwner
-
handleOutputStreamingException
protected static void handleOutputStreamingException(javax.servlet.http.HttpServletResponse response, boolean bytesWritten, Exception e) throws IOException, javax.servlet.ServletException - Throws:
IOExceptionjavax.servlet.ServletException
-
preprocessInput
@Nonnull protected abstract AbstractAvatarServlet.PreprocessedInput preprocessInput(String ownerId, Long avatarId, Avatar.Size size, 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 avataravatarId- The avatarId requestedsize- The size of requested avatarresponse- The response to send- Returns:
- The object containing avatarId to serve to the user or object containing null avatarId if validation fails
- Throws:
IOException- If there's an error updating the response object
-
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.
-
getAvatarManager
-
getFeatureManager
-
isFeatureEnabled
protected boolean isFeatureEnabled(@Nonnull FeatureFlag featureFlag, boolean whenFeatureManagerNotPresent) -
getAvatarToStream
-