@Component public class

AvatarResourceHelper

extends Object
java.lang.Object
   ↳ com.atlassian.jira.rest.v2.issue.AvatarResourceHelper

Class Overview

A helper resource for Project and User avatars.

Summary

Public Constructors
@Inject AvatarResourceHelper(JiraAuthenticationContext authContext, AvatarManager avatarManager, AvatarService avatarService, AvatarPickerHelper avatarPickerHelper, AttachmentHelper attachmentHelper, UserManager userManager, JiraAvatarSupport jiraAvatarSupport)
Public Methods
Response createAvatarFromTemporary(Avatar.Type type, String ownerId, AvatarCroppingBean croppingInstructions)
Converts temporary avatar into a real avatar
Response cropTemporaryAvatar(Avatar.Type type, String ownerId, AvatarCroppingBean croppingInstructions)
Response deleteAvatar(Long id)
Deletes avatar
Map<StringList<AvatarBean>> getAllAvatars(Avatar.Type type, String ownerId, Long selectedAvatarId)
Returns all avatars which are visible for the currently logged in user.
Response getAllSystemAvatars(Avatar.Type type)
Returns all system avatars of the given type.
Response storeTemporaryAvatar(Avatar.Type type, String ownerId, String filename, Long size, HttpServletRequest request)
Creates temporary avatar and provides instructions for cropping (if needed)
Response storeTemporaryAvatarUsingMultiPart(Avatar.Type type, String ownerId, FilePart filePart, HttpServletRequest request)
Creates temporary avatar using multipart.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

@Inject public AvatarResourceHelper (JiraAuthenticationContext authContext, AvatarManager avatarManager, AvatarService avatarService, AvatarPickerHelper avatarPickerHelper, AttachmentHelper attachmentHelper, UserManager userManager, JiraAvatarSupport jiraAvatarSupport)

Public Methods

public Response createAvatarFromTemporary (Avatar.Type type, String ownerId, AvatarCroppingBean croppingInstructions)

Converts temporary avatar into a real avatar

Parameters
type - Type of avatars (User or Project)
ownerId - (project id or username)
croppingInstructions - Corrdinates to crop image
Returns
  • created avatar

public Response cropTemporaryAvatar (Avatar.Type type, String ownerId, AvatarCroppingBean croppingInstructions)

public Response deleteAvatar (Long id)

Deletes avatar

Parameters
id database id for avatar
Returns
  • temporary avatar cropping instructions

public Map<StringList<AvatarBean>> getAllAvatars (Avatar.Type type, String ownerId, Long selectedAvatarId)

Returns all avatars which are visible for the currently logged in user.

Parameters
type - Type of avatars (User or Project)
ownerId - (project id or username)
selectedAvatarId - id of selected avatar
Returns
  • all avatars, system and custom for given type

public Response getAllSystemAvatars (Avatar.Type type)

Returns all system avatars of the given type.

Parameters
type - Type of avatars (User or Project)
Returns
  • all system avatars for the given type

public Response storeTemporaryAvatar (Avatar.Type type, String ownerId, String filename, Long size, HttpServletRequest request)

Creates temporary avatar and provides instructions for cropping (if needed)

Parameters
type - Type of avatars (User or Project)
ownerId - (project id or username)
filename - name of file being uploaded
size - size of file
request - servlet request
Returns
  • temporary avatar cropping instructions

public Response storeTemporaryAvatarUsingMultiPart (Avatar.Type type, String ownerId, FilePart filePart, HttpServletRequest request)

Creates temporary avatar using multipart. The cropping instructions (or validation errors) are sent back as JSON stored in a textarea. This is because the client uses remote iframing to submit avatars using multipart. So we must send them a valid HTML page back from which the client parses the JSON.

Parameters
type - Type of avatars (User or Project)
ownerId - (project id or username)
filePart - File body
request - servlet request
Returns
  • html fragment that will be added to iframe (client will parse this out into JSON)