Class GravatarServiceImpl
- java.lang.Object
-
- com.atlassian.bamboo.user.gravatar.GravatarServiceImpl
-
- All Implemented Interfaces:
GravatarService
public class GravatarServiceImpl extends Object implements GravatarService
A gravatar is a dynamic image resource that is requested from the gravatar.com server. This class calculates the gravatar url and fetches gravatar images. See http://en.gravatar.com/site/implement/url .This class is thread-safe, Gravatar objects can be shared.
Currently this service is set to only allow images for general audiences and the Default image is hardcoded.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_SIZE
-
Fields inherited from interface com.atlassian.bamboo.user.gravatar.GravatarService
DEFAULT_GRAVATAR_URL
-
-
Constructor Summary
Constructors Constructor Description GravatarServiceImpl(AdministrationConfigurationPersister administrationConfigurationPersister, AdministrationConfigurationAccessor administrationConfigurationAccessor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
download(String email, int size)
Downloads the gravatar for the given URL using JavaURL
and returns a byte array containing the gravatar jpg, returns null if no gravatar was found.@Nullable String
getDefaultGravatarUrl(int size)
Returns the url for the default gravatar.@NotNull String
getGravatarServerUrl()
@Nullable String
getGravatarUrl(@Nullable String email)
Returns A gravatar for the given emails with the default size of 25 pixels.@Nullable String
getGravatarUrl(@Nullable String email, int size)
boolean
isGravatarSupportEnabled()
void
setGravatarSupported(boolean enabled, @NotNull String newUrl)
Updates whether or not gravatars are enabled for this Bamboo instance
-
-
-
Field Detail
-
DEFAULT_SIZE
public static final int DEFAULT_SIZE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GravatarServiceImpl
public GravatarServiceImpl(AdministrationConfigurationPersister administrationConfigurationPersister, AdministrationConfigurationAccessor administrationConfigurationAccessor)
-
-
Method Detail
-
getGravatarUrl
@Nullable public @Nullable String getGravatarUrl(@Nullable @Nullable String email, int size)
- Specified by:
getGravatarUrl
in interfaceGravatarService
- Parameters:
email
- to get gravatar url forsize
- Specify a gravatar size between 1 and 512 pixels.- Returns:
- url to the users image on the gravatar server
-
getGravatarUrl
@Nullable public @Nullable String getGravatarUrl(@Nullable @Nullable String email)
Returns A gravatar for the given emails with the default size of 25 pixels.- Specified by:
getGravatarUrl
in interfaceGravatarService
- Parameters:
email
- to get gravatar url for- Returns:
- url to the users image on the gravatar server
-
getDefaultGravatarUrl
@Nullable public @Nullable String getDefaultGravatarUrl(int size)
Returns the url for the default gravatar.- Specified by:
getDefaultGravatarUrl
in interfaceGravatarService
- Parameters:
size
- a gravatar size between 1 and 512 pixels.- Returns:
- the url for the default gravatar.
-
download
public byte[] download(String email, int size) throws GravatarDownloadException
Downloads the gravatar for the given URL using JavaURL
and returns a byte array containing the gravatar jpg, returns null if no gravatar was found.- Parameters:
email
- to get gravatar forsize
- a gravatar size between 1 and 512 pixels.- Returns:
- byte stream of gravatar image
- Throws:
GravatarDownloadException
- if something goes wrong...
-
setGravatarSupported
public void setGravatarSupported(boolean enabled, @NotNull @NotNull String newUrl)
Updates whether or not gravatars are enabled for this Bamboo instance- Specified by:
setGravatarSupported
in interfaceGravatarService
- Parameters:
enabled
- whether its enabled or notnewUrl
- the URL of the Gravatar server the user wants to use
-
isGravatarSupportEnabled
public boolean isGravatarSupportEnabled()
- Specified by:
isGravatarSupportEnabled
in interfaceGravatarService
- Returns:
- true if gravatar support enabled.
-
getGravatarServerUrl
@NotNull public @NotNull String getGravatarServerUrl()
- Specified by:
getGravatarServerUrl
in interfaceGravatarService
- Returns:
- the String value of the URL of the Gravatar server being used
-
-