Package com.atlassian.bamboo.avatar
Class AvatarServiceImpl
java.lang.Object
com.atlassian.bamboo.avatar.AvatarServiceImpl
- All Implemented Interfaces:
AvatarService
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull String
convertToValidId
(@NotNull String input) void
deleteForUser
(@NotNull String userName) Delete the avatar associated with a user's name.void
deleteForUser
(@NotNull Principal user) Delete the avatar associated with a user.@Nullable CacheableAvatarSupplier
getForUser
(@NotNull Principal user, int size) Retrieves the current avatar for the specifieduser
.long
Retrieves the maximum size, in bytes, for uploaded avatars.@NotNull CacheableAvatarSupplier
getUserDefault
(int size) Retrieves a stable default user avatar, suitable for display in anonymous contexts.boolean
isUserAvatarStored
(@NotNull Principal user) Checks whether the user has an avatar stored.void
moveForUser
(@NotNull String oldUserName, @NotNull String newUserName) Moves the avatar associated with a user to another user.void
saveForUser
(@NotNull Principal user, @NotNull Supplier<AvatarSupplier> metaSupplier) Saves the avatar contained in the providedavatarSupplier
obtained from the providedmetaSupplier
as the new avatar for the specifiedUser
, removing any previously-stored avatar.
-
Constructor Details
-
AvatarServiceImpl
-
-
Method Details
-
getUserDefault
Description copied from interface:AvatarService
Retrieves a stable default user avatar, suitable for display in anonymous contexts.- Specified by:
getUserDefault
in interfaceAvatarService
- Parameters:
size
- the size to retrieve the avatar in- Returns:
- an
AvatarSupplier
which can be used to read the avatar
-
getForUser
@Nullable public @Nullable CacheableAvatarSupplier getForUser(@NotNull @NotNull Principal user, int size) Description copied from interface:AvatarService
Retrieves the current avatar for the specifieduser
. If no explicit avatar has been set, a null will be returned.- Specified by:
getForUser
in interfaceAvatarService
- Parameters:
user
- the user to retrieve the avatar forsize
- the size to retrieve the avatar in- Returns:
- an
AvatarSupplier
which can be used to read the avatar
-
saveForUser
public void saveForUser(@NotNull @NotNull Principal user, @NotNull @NotNull Supplier<AvatarSupplier> metaSupplier) Description copied from interface:AvatarService
Saves the avatar contained in the providedavatarSupplier
obtained from the providedmetaSupplier
as the new avatar for the specifiedUser
, removing any previously-stored avatar.Previous avatars are not maintained. The only way to restore a previous avatar is to save it again.
- Specified by:
saveForUser
in interfaceAvatarService
- Parameters:
user
- the user whose avatar is being setmetaSupplier
- a supplier providing access to the new avatar to use
-
isUserAvatarStored
Description copied from interface:AvatarService
Checks whether the user has an avatar stored.- Specified by:
isUserAvatarStored
in interfaceAvatarService
- Parameters:
user
- the user to check- Returns:
true
if the user's avatar is stored.
-
deleteForUser
Description copied from interface:AvatarService
Delete the avatar associated with a user.This will revert the avatar of the user in the UI to their Gravatar image (if the Gravatar integration is enabled) or to the default user avatar (if the Gravatar integration is disabled)
- Specified by:
deleteForUser
in interfaceAvatarService
- Parameters:
user
- the user whose (local) avatar will be removed
-
deleteForUser
Description copied from interface:AvatarService
Delete the avatar associated with a user's name.This will revert the avatar of the user in the UI to their Gravatar image (if the Gravatar integration is enabled) or to the default user avatar (if the Gravatar integration is disabled)
- Specified by:
deleteForUser
in interfaceAvatarService
- Parameters:
userName
- the user's name whose (local) avatar will be removed
-
moveForUser
Description copied from interface:AvatarService
Moves the avatar associated with a user to another user.- Specified by:
moveForUser
in interfaceAvatarService
- Parameters:
oldUserName
- the user whose avatar will be movednewUserName
- the user whose avatar will be replaced
-
getMaxUploadSize
public long getMaxUploadSize()Description copied from interface:AvatarService
Retrieves the maximum size, in bytes, for uploaded avatars. Avatars larger than this will be rejected by the server.- Specified by:
getMaxUploadSize
in interfaceAvatarService
- Returns:
- the maximum size, in bytes, for uploaded avatars
-
convertToValidId
-