com.atlassian.jira.avatar
Interface AvatarService

All Known Implementing Classes:
AvatarServiceImpl

@PublicApi
public interface AvatarService

Service for manipulating Avatar's.

Since:
v4.3

Method Summary
 boolean canSetCustomUserAvatar(com.atlassian.crowd.embedded.api.User remoteUser, String username)
          Returns a boolean indicating whether the calling user can edit the custom user avatar for the user with the given username.
 Avatar getAvatar(com.atlassian.crowd.embedded.api.User remoteUser, String avatarUserId)
          Returns the Avatar for the given user, if configured.
 URI getAvatarAbsoluteURL(com.atlassian.crowd.embedded.api.User remoteUser, String avatarUserId, Avatar.Size size)
          This is the same as getAvatarURL(com.atlassian.crowd.embedded.api.User, String, com.atlassian.jira.avatar.Avatar.Size) but returns an absolute URL.
 URI getAvatarURL(com.atlassian.crowd.embedded.api.User remoteUser, String avatarUserId)
          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(com.atlassian.crowd.embedded.api.User remoteUser, String avatarUserId, 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 getAvatarUrlNoPermCheck(String avatarUserId, Avatar.Size size)
          This is the same as getAvatarURL(com.atlassian.crowd.embedded.api.User, String, com.atlassian.jira.avatar.Avatar.Size) but does no permission checking.
 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.
 boolean hasCustomUserAvatar(com.atlassian.crowd.embedded.api.User remoteUser, String username)
           
 boolean isGravatarEnabled()
          Returns true if Gravatar support is enabled.
 void setCustomUserAvatar(com.atlassian.crowd.embedded.api.User remoteUser, String username, Long avatarId)
          Sets a custom avatar for a given user.
 

Method Detail

getAvatar

Avatar getAvatar(com.atlassian.crowd.embedded.api.User remoteUser,
                 String avatarUserId)
                 throws AvatarsDisabledException
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
avatarUserId - a String containing a username (may have been deleted)
Returns:
an Avatar, or null
Throws:
AvatarsDisabledException - if avatars are disabled
Since:
v4.3

getAvatarURL

URI getAvatarURL(com.atlassian.crowd.embedded.api.User remoteUser,
                 String avatarUserId)
                 throws AvatarsDisabledException
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
avatarUserId - 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
Since:
v5.0.3
See Also:
getAvatar(com.atlassian.crowd.embedded.api.User, String)

getAvatarURL

URI getAvatarURL(com.atlassian.crowd.embedded.api.User remoteUser,
                 String avatarUserId,
                 Avatar.Size size)
                 throws AvatarsDisabledException
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
avatarUserId - 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
Since:
v4.3
See Also:
getAvatar(com.atlassian.crowd.embedded.api.User, String)

getAvatarUrlNoPermCheck

URI getAvatarUrlNoPermCheck(String avatarUserId,
                            Avatar.Size size)
                            throws AvatarsDisabledException
This is the same as getAvatarURL(com.atlassian.crowd.embedded.api.User, String, com.atlassian.jira.avatar.Avatar.Size) but does no permission checking.

Parameters:
avatarUserId - 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
Since:
v5.0

getAvatarAbsoluteURL

URI getAvatarAbsoluteURL(com.atlassian.crowd.embedded.api.User remoteUser,
                         String avatarUserId,
                         Avatar.Size size)
                         throws AvatarsDisabledException
This is the same as getAvatarURL(com.atlassian.crowd.embedded.api.User, String, com.atlassian.jira.avatar.Avatar.Size) but returns an absolute URL.

Throws:
AvatarsDisabledException

getProjectAvatarURL

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

getProjectAvatarAbsoluteURL

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

hasCustomUserAvatar

@ExperimentalApi
boolean hasCustomUserAvatar(com.atlassian.crowd.embedded.api.User remoteUser,
                                            String username)

isGravatarEnabled

@ExperimentalApi
boolean isGravatarEnabled()
Returns true if Gravatar support is enabled.

Returns:
a boolean indicating whether Gravatar support is on

setCustomUserAvatar

@ExperimentalApi
void setCustomUserAvatar(com.atlassian.crowd.embedded.api.User remoteUser,
                                         String username,
                                         Long avatarId)
                         throws AvatarsDisabledException,
                                NoPermissionException
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
Since:
v5.0.3
See Also:
canSetCustomUserAvatar(com.atlassian.crowd.embedded.api.User, String)

canSetCustomUserAvatar

@ExperimentalApi
boolean canSetCustomUserAvatar(com.atlassian.crowd.embedded.api.User remoteUser,
                                               String username)
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
Since:
v5.0.3


Copyright © 2002-2012 Atlassian. All Rights Reserved.