Package com.atlassian.bamboo.avatar
Interface AvatarRepository
- All Known Implementing Classes:
DiskAvatarRepository
public interface AvatarRepository
- Since:
- 9.5
-
Method Summary
Modifier and TypeMethodDescriptionvoid
delete
(@NotNull AvatarType type, @NotNull String id) Deletes any stored avatars for the specified object and type.long
Retrieves the configured file size limit for stored avatars.getVersionId
(@NotNull AvatarType type, @NotNull String id) Retrieves a version identifier for the avatar with the specified object and type.boolean
isStored
(@NotNull AvatarType type, @NotNull String id) Retrieves a flag indicating whether an avatar has been stored for the specified object and type.@Nullable CacheableAvatarSupplier
load
(@NotNull AvatarType type, @NotNull String id, int size) Retrieves the current avatar for the specified object and type, or a null if no avatar has been stored.@NotNull CacheableAvatarSupplier
loadDefault
(@NotNull AvatarType type, int size) Loads a default avatar for the specified type in an approximation of the requested size.void
move
(@NotNull AvatarType type, @NotNull String oldId, @NotNull String newId) Moves any stored avatars for the specified object and type from the old ID to the new ID.void
store
(@NotNull AvatarType type, @NotNull String id, @NotNull AvatarSupplier supplier) Stores the provided avatar for the specified object and type.
-
Method Details
-
loadDefault
Loads a default avatar for the specified type in an approximation of the requested size. Default avatars are only available in a fixed set of sizes, and dynamic sizes are not created, so the request size is normalized into that set.- Parameters:
type
- the type of object to retrieve a default avatar forsize
- the size to retrieve the avatar in- Returns:
- a supplier for accessing the requested default avatar
-
load
@Nullable @Nullable CacheableAvatarSupplier load(@NotNull @NotNull AvatarType type, @NotNull @NotNull String id, int size) Retrieves the current avatar for the specified object and type, or a null if no avatar has been stored.- Parameters:
type
- the type of object associated with the provided IDid
- the object's IDsize
- the size to retrieve the avatar in- Returns:
- a supplier for accessing the requested avatar
-
store
void store(@NotNull @NotNull AvatarType type, @NotNull @NotNull String id, @NotNull @NotNull AvatarSupplier supplier) Stores the provided avatar for the specified object and type.The file size for the avatar image is not checked by the repository. That restriction is expected to be applied at the system's edges (REST, SpringMVC, etc.).
- Parameters:
type
- the type of object associated with the provided IDid
- the object's IDsupplier
- a supplier providing access to the avatar data
-
isStored
Retrieves a flag indicating whether an avatar has been stored for the specified object and type.- Parameters:
type
- the type of object associated with the provided IDid
- the object's ID- Returns:
true
if a local avatar exists for the specified object; otherwise,false
-
delete
Deletes any stored avatars for the specified object and type. This removes the original as well as any scaled copies that have been created based on requested sizes.- Parameters:
type
- the type of object associated with the provided IDid
- the object's ID
-
move
void move(@NotNull @NotNull AvatarType type, @NotNull @NotNull String oldId, @NotNull @NotNull String newId) Moves any stored avatars for the specified object and type from the old ID to the new ID.- Parameters:
type
- the type of object associated with the provided IDoldId
- the object's old IDnewId
- the object's new ID
-
getMaxSize
long getMaxSize()Retrieves the configured file size limit for stored avatars. Avatars which are larger than this on disk cannot be stored, and callingstore(com.atlassian.bamboo.avatar.AvatarType, java.lang.String, com.atlassian.bamboo.avatar.AvatarSupplier)
will result in anAvatarStoreException
.- Returns:
- the configured file size limit for stored avatars
-
getVersionId
@NotNull @NotNull Optional<Long> getVersionId(@NotNull @NotNull AvatarType type, @NotNull @NotNull String id) Retrieves a version identifier for the avatar with the specified object and type.- Parameters:
type
- the type of the object to retrieve a version forid
- the Object's ID- Returns:
- a version identifier for the avatar identified by the id and type, which will change only when the underlying avatar is modified
-