Package com.google.gerrit.server.avatar
Interface AvatarProvider
public interface AvatarProvider
Provide avatar URLs for specified user.
Invoked by Gerrit when Avatar image requests are made.
-
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
Indicates whether or not the provider allows to set the image URL.getChangeAvatarUrl
(IdentifiedUser forUser) Gets a URL for a user to modify their avatar image.getUrl
(IdentifiedUser forUser, int imageSize) Get avatar URL.default void
setUrl
(IdentifiedUser forUser, String url, int imageSize) Set the avatar image URL for specified user and specified size.
-
Method Details
-
getUrl
Get avatar URL.- Parameters:
forUser
- The user for which to load an avatar imageimageSize
- A requested image size, in pixels. An imageSize of 0 indicates to use whatever default size the provider determines. AvatarProviders may ignore the requested image size. The web interface will resize any image to match imageSize, so ideally the provider should return an image sized correctly.- Returns:
- a URL of an avatar image for the specified user. A return value of
null
is acceptable, and results in the server responding with a 404. This will hide the avatar image in the web UI.
-
getChangeAvatarUrl
Gets a URL for a user to modify their avatar image.- Parameters:
forUser
- The user wishing to change their avatar image- Returns:
- a URL the user should visit to modify their avatar, or null if modification is not possible.
-
setUrl
Set the avatar image URL for specified user and specified size.It is the default method (not interface method declaration) for back compatibility with old code.
- Parameters:
forUser
- The user for which need to change the avatar image.url
- The avatar image URL for the specified user.imageSize
- The avatar image size in pixels. If imageSize have a zero value this indicates to set URL for default size that provider determines.- Throws:
Exception
- if an error occurred.
-
canSetUrl
default boolean canSetUrl()Indicates whether or not the provider allows to set the image URL.It is the default method (not interface method declaration) for back compatibility with old code.
- Returns:
- true - avatar image URL could be set.
- false - avatar image URL could not be set (for example not Implemented).
-