@PublicApi public interface

AvatarService

com.atlassian.jira.avatar.AvatarService
Known Indirect Subclasses

@PublicApi

This interface is designed for plugins to consume (call its methods).

Clients of @PublicApi can expect that programs compiled against a given version will remain binary compatible with later versions of the @PublicApi as per each product's API policy as long as the client does not implement/extend @PublicApi interfaces or classes (refer to each product's API policy for the exact guarantee---usually binary compatibility is guaranteed at least across minor versions).

Note: since @PublicApi interfaces and classes are not designed to be implemented or extended by clients, we may perform certain types of binary-incompatible changes to these classes and interfaces, but these will not affect well-behaved clients that do not extend/implement these types (in general, only classes and interfaces annotated with @PublicSpi are safe to extend/implement).

Class Overview

Service for manipulating Avatars.

Summary

Public Methods
@ExperimentalApi boolean canSetCustomUserAvatar(ApplicationUser remoteUser, String username)
This method is deprecated. Use canSetCustomUserAvatar(ApplicationUser, ApplicationUser). Since v6.0
@ExperimentalApi boolean canSetCustomUserAvatar(ApplicationUser remoteUser, ApplicationUser user)
Returns a boolean indicating whether the calling user can edit the custom user avatar for the user with the given username.
Avatar getAvatar(ApplicationUser remoteUser, String username)
This method is deprecated. Use getAvatar(ApplicationUser, ApplicationUser). Since v6.0
Avatar getAvatar(ApplicationUser remoteUser, ApplicationUser avatarUser)
Returns the Avatar for the given user, if configured.
URI getAvatarAbsoluteURL(ApplicationUser remoteUser, String username, Avatar.Size size)
This method is deprecated. Use getAvatarAbsoluteURL(ApplicationUser, ApplicationUser, Size). Since v6.0
URI getAvatarAbsoluteURL(ApplicationUser remoteUser, ApplicationUser avatarUser, Avatar.Size size)
This is the same as getAvatarURL(ApplicationUser, String, Avatar.Size) but returns an absolute URL.
Avatar getAvatarTagged(ApplicationUser remoteUser, ApplicationUser avatarUser)
URI getAvatarURL(ApplicationUser remoteUser, String username)
This method is deprecated. Use getAvatarURL(ApplicationUser, ApplicationUser). Since v6.0
URI getAvatarURL(ApplicationUser remoteUser, ApplicationUser avatarUser, Avatar.Size size)
Returns the URL for the avatar of the user having the given username for displaying on a page that should be shown for the passed in remoteUser.
URI getAvatarURL(ApplicationUser remoteUser, ApplicationUser avatarUser)
Returns the URL for the avatar of the user having the given username for displaying on a page that should be shown for the passed in remoteUser.
URI getAvatarURL(ApplicationUser remoteUser, String username, Avatar.Size size)
This method is deprecated. Use getAvatarURL(ApplicationUser, ApplicationUser, Size). Since v6.0
URI getAvatarUrlNoPermCheck(String username, Avatar.Size size)
This method is deprecated. Use getAvatarUrlNoPermCheck(ApplicationUser, Size). Since v6.0
URI getAvatarUrlNoPermCheck(ApplicationUser avatarUser, Avatar.Size size)
This is the same as #getAvatarURL(.ApplicationUser, String, Size) but does no permission checking.
@Deprecated URI getAvatarUrlNoPermCheck(ApplicationUser applicationUser, Avatar avatar, Avatar.Size size)
Returns the URL for an avatar.
Optional<URI> getGravatarAvatarURL(ApplicationUser avatarUser, Avatar.Size size)
If Gravatar is enabled returns Gravatar url for given user at given size.
URI getProjectAvatarAbsoluteURL(Project project, Avatar.Size size)
Returns the URL for the avatar of the given project.
URI getProjectAvatarURL(Project project, Avatar.Size size)
Returns the URL for the avatar of the given project.
URI getProjectDefaultAvatarAbsoluteURL(Avatar.Size size)
Returns the URL for the default avatar of a project.
URI getProjectDefaultAvatarURL(Avatar.Size size)
Returns the URL for the default avatar of a project.
@ExperimentalApi boolean hasCustomUserAvatar(ApplicationUser remoteUser, String username)
This method is deprecated. Use hasCustomUserAvatar(ApplicationUser, ApplicationUser). Since v6.0
@ExperimentalApi boolean hasCustomUserAvatar(ApplicationUser remoteUser, ApplicationUser username)
Returns true if the user has configured a custom avatar, false otherwise.
@ExperimentalApi @Deprecated boolean isGravatarEnabled()
This method is deprecated. this is an avatar-provider plugin-implementation-specific concern
boolean isUsingExternalAvatar(ApplicationUser remoteUser, ApplicationUser avatarUser)
Check whether a user currently has an external avatar (for example, a Gravatar).
@ExperimentalApi void setCustomUserAvatar(ApplicationUser remoteUser, ApplicationUser user, Long avatarId)
Sets a custom avatar for a given user.
@ExperimentalApi void setCustomUserAvatar(ApplicationUser remoteUser, String username, Long avatarId)
This method is deprecated. Use setCustomUserAvatar(ApplicationUser, ApplicationUser, Long). Since v6.0

Public Methods

@ExperimentalApi public boolean canSetCustomUserAvatar (ApplicationUser remoteUser, String username)

@ExperimentalApi

This method is considered usable by external developers but its contracts have not stabilized.

Experimental APIs may be changed at any time before being marked @Internal or @PublicApi.

This method is deprecated.
Use canSetCustomUserAvatar(ApplicationUser, ApplicationUser). Since v6.0

Returns a boolean indicating whether the calling user can edit the custom user avatar for the user with the given username.

Parameters
remoteUser a User object for the currently logged in user
username the username of the user whose avatar we will configure
Returns
  • a indicating whether the calling user can edit the custom user avatar for another user

@ExperimentalApi public boolean canSetCustomUserAvatar (ApplicationUser remoteUser, ApplicationUser user)

@ExperimentalApi

This method is considered usable by external developers but its contracts have not stabilized.

Experimental APIs may be changed at any time before being marked @Internal or @PublicApi.

Returns a boolean indicating whether the calling user can edit the custom user avatar for the user with the given username.

Parameters
remoteUser a User object for the currently logged in user
user the user whose avatar we will configure
Returns
  • a indicating whether the calling user can edit the custom user avatar for another user

public Avatar getAvatar (ApplicationUser remoteUser, String username)

This method is deprecated.
Use getAvatar(ApplicationUser, ApplicationUser). Since v6.0

Returns the Avatar for the given user, if configured. If the user does not have a custom avatar, or if the calling user does not have permission to view the Avatar, this method returns the default avatar. If the user does not exist, this method returns the anonymous avatar.

If this method would return the default user avatar but none is configured, or if this method would return the anonymous avatar but none is configured, this method returns null.

Parameters
remoteUser the User that wants to view an Avatar
username a String containing a username (may have been deleted)
Returns
  • an Avatar, or null
Throws
AvatarsDisabledException if avatars are disabled

public Avatar getAvatar (ApplicationUser remoteUser, ApplicationUser avatarUser)

Returns the Avatar for the given user, if configured. If the user does not have a custom avatar, or if the calling user does not have permission to view the Avatar, this method returns the default avatar. If the user does not exist, this method returns the anonymous avatar.

If this method would return the default user avatar but none is configured, or if this method would return the anonymous avatar but none is configured, this method returns null.

Parameters
remoteUser the User that wants to view an Avatar
avatarUser the User that the avatar will be returned for (if null it will return a default avatar if it's set or null)
Returns
  • an Avatar, or null
Throws
AvatarsDisabledException if avatars are disabled

public URI getAvatarAbsoluteURL (ApplicationUser remoteUser, String username, Avatar.Size size)

This method is deprecated.
Use getAvatarAbsoluteURL(ApplicationUser, ApplicationUser, Size). Since v6.0

This is the same as getAvatarURL(ApplicationUser, String, Avatar.Size) but returns an absolute URL.

public URI getAvatarAbsoluteURL (ApplicationUser remoteUser, ApplicationUser avatarUser, Avatar.Size size)

This is the same as getAvatarURL(ApplicationUser, String, Avatar.Size) but returns an absolute URL.

public Avatar getAvatarTagged (ApplicationUser remoteUser, ApplicationUser avatarUser)

public URI getAvatarURL (ApplicationUser remoteUser, String username)

This method is deprecated.
Use getAvatarURL(ApplicationUser, ApplicationUser). Since v6.0

Returns the URL for the avatar of the user having the given username for displaying on a page that should be shown for the passed in remoteUser. This method returns a URL for an avatar with the default size.

If the user does not have a custom avatar, or if the calling user does not have permission to view the Avatar, this method returns the URL of the default avatar. If the user does not exist, this method returns the URL of the anonymous avatar.

Parameters
remoteUser a User object for the currently logged in user
username a String containing a username (may have been deleted)
Returns
  • a URL that can be used to display the avatar
Throws
AvatarsDisabledException if avatars are disabled

public URI getAvatarURL (ApplicationUser remoteUser, ApplicationUser avatarUser, Avatar.Size size)

Returns the URL for the avatar of the user having the given username for displaying on a page that should be shown for the passed in remoteUser.

If the user does not have a custom avatar, or if the calling user does not have permission to view the Avatar, this method returns the URL of the default avatar. If the user does not exist, this method returns the URL of the anonymous avatar.

Parameters
remoteUser a User object for the currently logged in user
avatarUser a User to get the avatar for (if null, the default avatar is used)
size the size of the avatar to be displayed (if null, the default size is used)
Returns
  • a URL that can be used to display the avatar
Throws
AvatarsDisabledException if avatars are disabled

public URI getAvatarURL (ApplicationUser remoteUser, ApplicationUser avatarUser)

Returns the URL for the avatar of the user having the given username for displaying on a page that should be shown for the passed in remoteUser. This method returns a URL for an avatar with the default size.

If the user does not have a custom avatar, or if the calling user does not have permission to view the Avatar, this method returns the URL of the default avatar. If the user does not exist, this method returns the URL of the anonymous avatar.

Parameters
remoteUser a User object for the currently logged in user
avatarUser a User object to get the avatar for (if null, the default avatar is used)
Returns
  • a URL that can be used to display the avatar
Throws
AvatarsDisabledException if avatars are disabled

public URI getAvatarURL (ApplicationUser remoteUser, String username, Avatar.Size size)

This method is deprecated.
Use getAvatarURL(ApplicationUser, ApplicationUser, Size). Since v6.0

Returns the URL for the avatar of the user having the given username for displaying on a page that should be shown for the passed in remoteUser.

If the user does not have a custom avatar, or if the calling user does not have permission to view the Avatar, this method returns the URL of the default avatar. If the user does not exist, this method returns the URL of the anonymous avatar.

Parameters
remoteUser a User object for the currently logged in user
username a String containing a username (may have been deleted)
size the size of the avatar to be displayed (if null, the default size is used)
Returns
  • a URL that can be used to display the avatar
Throws
AvatarsDisabledException if avatars are disabled

public URI getAvatarUrlNoPermCheck (String username, Avatar.Size size)

This method is deprecated.
Use getAvatarUrlNoPermCheck(ApplicationUser, Size). Since v6.0

This is the same as getAvatarURL(ApplicationUser, String, Size) but does no permission checking.

Parameters
username a String containing a username (may have been deleted)
size the size of the avatar to be displayed
Returns
  • a URL that can be used to display the avatar
Throws
AvatarsDisabledException if avatars are disabled

public URI getAvatarUrlNoPermCheck (ApplicationUser avatarUser, Avatar.Size size)

This is the same as #getAvatarURL(.ApplicationUser, String, Size) but does no permission checking.

Parameters
avatarUser a String containing a username (if null, the default avatar is used)
size the size of the avatar to be displayed
Returns
  • a URL that can be used to display the avatar
Throws
AvatarsDisabledException if avatars are disabled

@Deprecated public URI getAvatarUrlNoPermCheck (ApplicationUser applicationUser, Avatar avatar, Avatar.Size size)

Returns the URL for an avatar.

Parameters
size the size of the avatar to be displayed (if null, the default size is used)
Returns
  • a URL that can be used to display the avatar
Throws
AvatarsDisabledException if avatars are disabled

public Optional<URI> getGravatarAvatarURL (ApplicationUser avatarUser, Avatar.Size size)

If Gravatar is enabled returns Gravatar url for given user at given size.

Parameters
avatarUser a User to get the avatar for (if null, Optional.empty() is returned)
size the size of the avatar to be displayed (if null, the default size is used)
Returns
  • a URL that can be used to display the avatar

public URI getProjectAvatarAbsoluteURL (Project project, Avatar.Size size)

Returns the URL for the avatar of the given project.

This will always return an absolute URL (eg. "http://example.com/jira/...").

Parameters
project the Project of which to get the avatar URL
size the size of the avatar to be displayed (if null, the default size is used)
Returns
  • a URL that can be used to display the avatar

public URI getProjectAvatarURL (Project project, Avatar.Size size)

Returns the URL for the avatar of the given project.

If running in the context of a web request, this will return a URL relative to the server root (ie "/jira/..."). Otherwise, it will return an absolute URL (eg. "http://example.com/jira/...").

Parameters
project the Project of which to get the avatar URL
size the size of the avatar to be displayed (if null, the default size is used)
Returns
  • a URL that can be used to display the avatar

public URI getProjectDefaultAvatarAbsoluteURL (Avatar.Size size)

Returns the URL for the default avatar of a project.

This will always return an absolute URL (eg. "http://example.com/jira/...").

Parameters
size the size of the avatar to be displayed (if null, the default size is used)
Returns
  • a URL that can be used to display the avatar

public URI getProjectDefaultAvatarURL (Avatar.Size size)

Returns the URL for the default avatar of a project.

If running in the context of a web request, this will return a URL relative to the server root (ie "/jira/..."). Otherwise, it will return an absolute URL (eg. "http://example.com/jira/...").

Parameters
size the size of the avatar to be displayed (if null, the default size is used)
Returns
  • a URL that can be used to display the avatar

@ExperimentalApi public boolean hasCustomUserAvatar (ApplicationUser remoteUser, String username)

@ExperimentalApi

This method is considered usable by external developers but its contracts have not stabilized.

Experimental APIs may be changed at any time before being marked @Internal or @PublicApi.

This method is deprecated.
Use hasCustomUserAvatar(ApplicationUser, ApplicationUser). Since v6.0

Returns true if the user has configured a custom avatar, false otherwise.

Parameters
remoteUser a User object for the currently logged in user
username the username of the user whose avatar we will check
Returns
  • a boolean indicating whether the given user has configued a custom avatar

@ExperimentalApi public boolean hasCustomUserAvatar (ApplicationUser remoteUser, ApplicationUser username)

@ExperimentalApi

This method is considered usable by external developers but its contracts have not stabilized.

Experimental APIs may be changed at any time before being marked @Internal or @PublicApi.

Returns true if the user has configured a custom avatar, false otherwise.

Parameters
remoteUser a User object for the currently logged in user
username the username of the user whose avatar we will check
Returns
  • a boolean indicating whether the given user has configued a custom avatar

@ExperimentalApi @Deprecated public boolean isGravatarEnabled ()

@ExperimentalApi

This method is considered usable by external developers but its contracts have not stabilized.

Experimental APIs may be changed at any time before being marked @Internal or @PublicApi.

This method is deprecated.
this is an avatar-provider plugin-implementation-specific concern

Returns true if Gravatar support is enabled.

Returns
  • a boolean indicating whether Gravatar support is on

public boolean isUsingExternalAvatar (ApplicationUser remoteUser, ApplicationUser avatarUser)

Check whether a user currently has an external avatar (for example, a Gravatar). Use getAvatarURL(ApplicationUser, ApplicationUser) to get the avatar URL.

Returns
  • a boolean indicating whether the given currently user has an external avatar

@ExperimentalApi public void setCustomUserAvatar (ApplicationUser remoteUser, ApplicationUser user, Long avatarId)

@ExperimentalApi

This method is considered usable by external developers but its contracts have not stabilized.

Experimental APIs may be changed at any time before being marked @Internal or @PublicApi.

Sets a custom avatar for a given user.

Parameters
remoteUser a User object for the currently logged in user
user the user whose avatar we will configure
avatarId the id of the avatar to configure for the user
Throws
AvatarsDisabledException if avatars are disabled
NoPermissionException if the remote user does not have permission to update the given user's avatar

@ExperimentalApi public void setCustomUserAvatar (ApplicationUser remoteUser, String username, Long avatarId)

@ExperimentalApi

This method is considered usable by external developers but its contracts have not stabilized.

Experimental APIs may be changed at any time before being marked @Internal or @PublicApi.

This method is deprecated.
Use setCustomUserAvatar(ApplicationUser, ApplicationUser, Long). Since v6.0

Sets a custom avatar for a given user.

Parameters
remoteUser a User object for the currently logged in user
username the username of the user whose avatar we will configure
avatarId the id of the avatar to configure for the user
Throws
AvatarsDisabledException if avatars are disabled
NoPermissionException if the remote user does not have permission to update the given user's avatar