Package com.atlassian.jira.avatar
Interface AvatarManager
- All Known Implementing Classes:
AvatarManagerImpl
@PublicApi
public interface AvatarManager
Manager interface for
Avatar domain objects.- Since:
- v4.0
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final AvatarFormatstatic final AvatarFormatstatic final Stringstatic final Stringstatic final String -
Method Summary
Modifier and TypeMethodDescriptionCreates a database record for the given avatar.create(Avatar.Type avatarType, String owningObjectId, AvatarImageDataProvider imageDataProvider) Deprecated.create(Avatar avatar, InputStream image, Selection selection) Creates a database record for the given avatar and uses the content of the InputStream as the image.create(IconType iconType, IconOwningObjectId owningObjectId, AvatarImageDataProvider imageDataProvider) Creates a database record for the given avatar and uses the content of the InputStream as the image.create(String fileName, String contentType, IconType iconType, IconOwningObjectId owner, InputStream image, Selection selection) Creates a database record for the given avatar and uses the content of the InputStream as the image.create(String fileName, String contentType, ApplicationUser owner, InputStream image, Selection selection) booleanDelete the avatar with the given id and the file on disk.booleanDelete the avatar with the given id.Deprecated.UsegetAllSystemAvatars(IconType)instead.getAllSystemAvatars(IconType iconType) Provides a list of all system avatars.Gets the avatar id to use to represent an unknown or anonymous userRetrieve the avatar with the given id.getByIdTagged(Long avatarId) Retrieve the avatar with the given id, ensuring the avatar file is tagged with metadata identifying the image came from JIRA.getCustomAvatarsForOwner(Avatar.Type type, String ownerId) Deprecated.there can only be one.getCustomAvatarsForOwner(IconType iconType, String ownerId) Provides a list of all avatars that are of the given type which have the given owner.getDefaultAvatar(IconType iconType) Gets the default avatar for the given type.getDefaultAvatarId(Avatar.Type ofType) Deprecated.UsegetDefaultAvatarId(IconType)Since v7.1getDefaultAvatarId(IconType iconType) Gets the default avatar ID for the given type.booleanhasImage(Avatar avatar, Avatar.Size size) Checks if valid image exists for avatar and image can be consumed byreadAvatarData(Avatar, Avatar.Size, AvatarFormatPolicy, MediaConsumer).booleanhasPermissionToEdit(ApplicationUser remoteUser, Avatar.Type type, String ownerId) Deprecated.booleanhasPermissionToEdit(ApplicationUser remoteUser, Project owner) Deprecated.booleanhasPermissionToEdit(ApplicationUser remoteUser, ApplicationUser owner) Deprecated.booleanhasPermissionToView(ApplicationUser remoteUser, Avatar.Type type, String ownerId) Deprecated.UseuserCanView(ApplicationUser, Avatar)Since v6.0booleanhasPermissionToView(ApplicationUser remoteUser, Project owner) Deprecated.UseuserCanView(ApplicationUser, Avatar)Since v7.1booleanhasPermissionToView(ApplicationUser remoteUser, ApplicationUser owner) Deprecated.UseuserCanView(ApplicationUser, Avatar)Since v7.1booleanisAvatarOwner(Avatar avatar, String ownerId) Deprecated.To be removed.booleanisValidIconType(IconType iconType) Check if this is a valid icon type.voidreadAvatarData(Avatar avatar, Avatar.Size size, AvatarFormatPolicy avatarFormatPolicy, MediaConsumer mediaConsumer) Provides read-only access to the data of the avatar image as anInputStreampassed to the provided dataAccessor.voidreadAvatarData(Avatar avatar, Avatar.Size size, Consumer<InputStream> dataAccessor) Provides read-only access to the data of the avatar image as anInputStreampassed to the provided dataAccessor.voidreadAvatarData(Avatar avatar, AvatarManager.ImageSize size, Consumer<InputStream> dataAccessor) Deprecated.v7.0.1 Please usereadAvatarData(Avatar, Avatar.Size, Consumer)voidSaves the avatar as an updated version of the avatar with the same id that is already in the database.booleanuserCanCreateFor(ApplicationUser remoteUser, IconType iconType, IconOwningObjectId owningObjectId) Check if the user could create an avatar for this owning object.booleanuserCanDelete(ApplicationUser remoteUser, Avatar icon) Check if the user can delete the icon.booleanuserCanView(ApplicationUser remoteUser, Avatar icon) Check if the user can view the icon.
-
Field Details
-
AVATAR_IMAGE_FORMAT
- See Also:
-
PNG_CONTENT_TYPE
- See Also:
-
SVG_CONTENT_TYPE
- See Also:
-
AVATAR_IMAGE_FORMAT_FULL
-
AVATAR_IMAGE_FORMAT_SVG
-
USER_AVATAR_ID_KEY
- See Also:
-
-
Method Details
-
getById
Retrieve the avatar with the given id.- Parameters:
avatarId- must not be null.- Returns:
- the Avatar if there is one or null if not.
- Throws:
DataAccessException- if there is a back-end database problem.
-
getByIdTagged
Retrieve the avatar with the given id, ensuring the avatar file is tagged with metadata identifying the image came from JIRA.- Parameters:
avatarId- must not be null.- Returns:
- the Avatar if there is one or null if not.
- Throws:
DataAccessException- if there is a back-end database problem.
-
delete
Delete the avatar with the given id and the file on disk.- Parameters:
avatarId- must not be null.- Returns:
- true only if there was an avatar with the given id which was deleted.
- Throws:
DataAccessException- if there is a back-end database problem.
-
delete
Delete the avatar with the given id.- Parameters:
avatarId- must not be null.alsoDeleteAvatarFile- if false, the avatar file will be left on disk.- Returns:
- true only if there was an avatar with the given id which was deleted.
- Throws:
DataAccessException- if there is a back-end database problem.
-
update
Saves the avatar as an updated version of the avatar with the same id that is already in the database.- Parameters:
avatar- must not be null.- Throws:
DataAccessException- if there is a back-end database problem.
-
create
Creates a database record for the given avatar. Use the return value as the persistent avatar, not the one you passed in.- Parameters:
avatar- must not be null, must have a null id.- Returns:
- the created avatar which has an assigned id.
- Throws:
DataAccessException- if there is a back-end database problem.
-
create
@Nonnull Avatar create(Avatar avatar, InputStream image, Selection selection) throws DataAccessException, IOException Creates a database record for the given avatar and uses the content of the InputStream as the image. Use the return value as the persistent avatar, not the one you passed in.- Parameters:
avatar- must not be null, must have a null id.image- the data of the original avatar image.selection- the cropping selection for the image or null to take whole image.- Returns:
- the created avatar which has an assigned id.
- Throws:
DataAccessException- if there is a back-end database problem.IOException- Since:
- v6.3
-
create
@Nonnull Avatar create(Avatar.Type avatarType, @Nonnull String owningObjectId, @Nonnull AvatarImageDataProvider imageDataProvider) throws IOException Deprecated.Creates a database record for the given avatar and uses the content of the InputStream as the image. Use the return value as the persistent avatar, not the one you passed in.- Parameters:
avatarType- type of new avatar to create.owningObjectId- id of object (project/user/issuetype) to which this avatar is connected to.imageDataProvider- provider of image data- Returns:
- the created avatar which has an assigned id.
- Throws:
DataAccessException- if there is a back-end database problem.IOException- if there are arrors when processing image data- Since:
- v6.3
- See Also:
-
create
@Nonnull Avatar create(@Nonnull IconType iconType, @Nonnull IconOwningObjectId owningObjectId, @Nonnull AvatarImageDataProvider imageDataProvider) throws IOException Creates a database record for the given avatar and uses the content of the InputStream as the image. Use the return value as the persistent avatar, not the one you passed in.- Parameters:
iconType- type of new avatar to create.owningObjectId- id of object (project/user/issuetype) to which this avatar is connected to.imageDataProvider- provider of image data- Returns:
- the created avatar which has an assigned id.
- Throws:
DataAccessException- if there is a back-end database problem.IOException- if there are arrors when processing image data- Since:
- v7.1
- See Also:
-
create
@Nonnull Avatar create(String fileName, String contentType, IconType iconType, IconOwningObjectId owner, InputStream image, Selection selection) throws DataAccessException, IOException Creates a database record for the given avatar and uses the content of the InputStream as the image. Use the return value as the persistent avatar, not the one you passed in.- Parameters:
fileName- the name of the avatarcontentType- MIME content type for the avatariconType- The type of avatar to create.owner- The object that will own the icon.image- the data of the original avatar image (it will be automatically closed)selection- the cropping selection for the image or null to take whole image- Returns:
- the created avatar which has an assigned id
- Throws:
IOException- If there was a problem consuming the image data, or a problem storing the image data.DataAccessException- Since:
- v7.1
-
create
@Nonnull Avatar create(String fileName, String contentType, Project owner, InputStream image, Selection selection) throws DataAccessException, IOException Deprecated.Creates a database record for the given avatar and uses the content of the InputStream as the image. Use the return value as the persistent avatar, not the one you passed in.- Parameters:
fileName- the name of the avatarcontentType- MIME content type for the avatarimage- the data of the original avatar image (it will be automatically closed)selection- the cropping selection for the image or null to take whole image- Returns:
- the created avatar which has an assigned id
- Throws:
DataAccessException- if there is a back-end database problem.IOException
-
create
@Nonnull Avatar create(String fileName, String contentType, ApplicationUser owner, InputStream image, Selection selection) throws DataAccessException, IOException Deprecated.Creates a database record for the given avatar and uses the content of the InputStream as the image. Use the return value as the persistent avatar, not the one you passed in.- Parameters:
fileName- the name of the avatarcontentType- MIME content type for the avatarimage- the data of the original avatar image (it will be automatically closed)selection- the cropping selection for the image or null to take whole image- Returns:
- the created avatar which has an assigned id
- Throws:
DataAccessException- if there is a back-end database problem.IOException
-
getAllSystemAvatars
Deprecated.UsegetAllSystemAvatars(IconType)instead. Since v7.1Provides a list of all system avatars.- Parameters:
type- The type of system avatars to return- Returns:
- the system avatars.
- Throws:
DataAccessException- if there is a back-end database problem.
-
getAllSystemAvatars
Provides a list of all system avatars.- Parameters:
iconType- The type of system avatars to return- Returns:
- the system avatars.
- Throws:
DataAccessException- if there is a back-end database problem.- Since:
- v7.1
-
getCustomAvatarsForOwner
@Nonnull @Deprecated List<Avatar> getCustomAvatarsForOwner(Avatar.Type type, String ownerId) throws DataAccessException Deprecated.there can only be one. Since v6.4.Provides a list of all avatars that are of the given type which have the given owner.- Parameters:
type- the desired type of the avatars to retrieve.ownerId- the id of the owner, matches the type (project id or user key).- Returns:
- all the avatars that have the given type and owner, never null.
- Throws:
DataAccessException- if there is a back-end database problem.
-
getCustomAvatarsForOwner
@Nonnull List<Avatar> getCustomAvatarsForOwner(IconType iconType, String ownerId) throws DataAccessException Provides a list of all avatars that are of the given type which have the given owner.- Parameters:
iconType- the desired type of the avatars to retrieve.ownerId- the id of the owner, matches the type (project id or user key).- Returns:
- all the avatars that have the given type and owner, never null.
- Throws:
DataAccessException- if there is a back-end database problem.
-
isAvatarOwner
Deprecated.To be removed. Since v6.0Tells whether the given avatar is owned by the given ownerId.- Parameters:
avatar- the avatar to check, must not be null.ownerId- the ownerId to check, must not be null.- Returns:
- true only if the given ownerId is the ownerId of the given avatar.
-
readAvatarData
@Deprecated void readAvatarData(Avatar avatar, AvatarManager.ImageSize size, Consumer<InputStream> dataAccessor) throws IOException Deprecated.v7.0.1 Please usereadAvatarData(Avatar, Avatar.Size, Consumer)Provides read-only access to the data of the avatar image as anInputStreampassed to the provided dataAccessor. The InputStream is closed after the dataAccessor completes. The dataAccessor is immediately invoked on the data for the avatar.- Parameters:
avatar- the avatar for which the data is to be processed.size- the size to return for this avatardataAccessor- something to read the data.- Throws:
IOException- if an IOException occurs in the dataAccessor or in acquiring the InputStream for the avatar.- See Also:
-
readAvatarData
void readAvatarData(@Nonnull Avatar avatar, @Nonnull Avatar.Size size, @Nonnull Consumer<InputStream> dataAccessor) throws IOException Provides read-only access to the data of the avatar image as anInputStreampassed to the provided dataAccessor. The InputStream is closed after the dataAccessor completes. The dataAccessor is immediately invoked on the data for the avatar.This is equivalent to calling
readAvatarData(Avatar, Avatar.Size, AvatarFormatPolicy, MediaConsumer)withAvatarFormatPolicy.createOriginalDataPolicy()as the requested type andOptional.empty()as type Accessor.- Parameters:
avatar- the avatar for which the data is to be processed.size- the size to return for this avatardataAccessor- something to read the data.- Throws:
IOException- if an IOException occurs in the dataAccessor or in acquiring the InputStream for the avatar.- Since:
- v7.0.1
- See Also:
-
readAvatarData
@ExperimentalApi void readAvatarData(@Nonnull Avatar avatar, @Nonnull Avatar.Size size, @Nonnull AvatarFormatPolicy avatarFormatPolicy, @Nonnull MediaConsumer mediaConsumer) throws IOException Provides read-only access to the data of the avatar image as anInputStreampassed to the provided dataAccessor. The InputStream is closed after the dataAccessor completes. The dataAccessor is immediately invoked on the data for the avatar.The format that the image will be served in, is determined by the
AvatarFormatPolicythat is provided as a parameter. This should be used to set the content type of the data being provided to the @Consumer<InputStream>. If the parameters are non-strict, it will be a best attempt, and to know which content type has been used please provide a typeAccessor.- Parameters:
avatar- the avatar for which the data is to be processed.size- the size to return for this avataravatarFormatPolicy- the requested format for avatar data.mediaConsumer- consumer that will read the data.- Throws:
IOException- if an IOException occurs in the dataAccessor or in acquiring the InputStream for the avatar.IllegalArgumentException- If a strict request is made, but it is not possible to obey- Since:
- v7.0.1
-
getDefaultAvatarId
Deprecated.UsegetDefaultAvatarId(IconType)Since v7.1Gets the default avatar ID for the given type.- Parameters:
ofType- the Avatar type.- Returns:
- the default Avatar ID.
-
getDefaultAvatarId
Gets the default avatar ID for the given type.- Parameters:
iconType- the Icon type.- Returns:
- the default Avatar ID.
-
getDefaultAvatar
Gets the default avatar for the given type.- Parameters:
iconType- the Icon type.- Returns:
- the default Avatar, or null if the default avatar cannot be found for some reason. (e.g. There are no avatars for this type, or the type is invalid.)
-
isValidIconType
Check if this is a valid icon type.- Parameters:
iconType- The icon type to check.- Returns:
- True if this iconType is recognised, or false otherwise.
-
getAnonymousAvatarId
Long getAnonymousAvatarId()Gets the avatar id to use to represent an unknown or anonymous user- Returns:
- the avatar id for an anonymous user
-
hasPermissionToView
Deprecated.UseuserCanView(ApplicationUser, Avatar)Since v6.0Determines if the remoteUser provided has permission to view avatars of a certain type for the owner provided. For project avatars, this method checks that the user is either and admin, project admin or has browse permission for the owner project. For user avatars, the method checks that the remoteUser has use permission for JIRA or the remoteUser and avatar owner are the same person- Parameters:
remoteUser- The remote user trying to view an avatartype- The type of avatarownerId- The owner id of the avatar being viewed (project id or user key)- Returns:
- true if the remote user has permission to view avatars owned by the owner provided.
-
hasPermissionToView
Deprecated.UseuserCanView(ApplicationUser, Avatar)Since v7.1Determines if the remoteUser provided has permission to view avatars of a certain type for the owner provided. For project avatars, this method checks that the user is either and admin, project admin or has browse permission for the owner project. For user avatars, the method checks that the remoteUser has use permission for JIRA or the remoteUser and avatar owner are the same person- Parameters:
remoteUser- The remote user trying to view an avatarowner- The owner of the avatar being viewed- Returns:
- true if the remote user has permission to view avatars owned by the owner provided.
- Since:
- v6.0
-
hasPermissionToView
Deprecated.UseuserCanView(ApplicationUser, Avatar)Since v7.1Determines if the remoteUser provided has permission to view avatars of a certain type for the owner provided. For project avatars, this method checks that the user is either and admin, project admin or has browse permission for the owner project. For user avatars, the method checks that the remoteUser has use permission for JIRA or the remoteUser and avatar owner are the same person- Parameters:
remoteUser- The remote user trying to view an avatarowner- The owner of the avatar being viewed- Returns:
- true if the remote user has permission to view avatars owned by the owner provided.
- Since:
- v6.0
-
hasPermissionToEdit
Deprecated.Determines if the remoteUser provided has permission to edit avatars of a certain type for the owner provided. For project avatars, this method checks that the user is either and admin or project admin for the owner project. For user avatars, the method checks that the remoteUser has admin permissions for JIRA or the remoteUser and avatar owner are the same person. If external user management is enabled this method returns false- Parameters:
remoteUser- The remote user trying to edit an avatartype- The type of avatarownerId- The owner id of the avatar being edited (project id or user key)- Returns:
- true if the remote user has permission to edit avatars owned by the owner provided.
-
hasPermissionToEdit
Deprecated.Determines if the remoteUser provided has permission to edit avatars of a certain type for the owner provided. For project avatars, this method checks that the user is either and admin or project admin for the owner project. For user avatars, the method checks that the remoteUser has admin permissions for JIRA or the remoteUser and avatar owner are the same person. If external user management is enabled this method returns false- Parameters:
remoteUser- The remote user trying to edit an avatarowner- The owner of the avatar being edited- Returns:
- true if the remote user has permission to edit avatars owned by the owner provided.
- Since:
- v6.0
-
hasPermissionToEdit
Deprecated.Determines if the remoteUser provided has permission to edit avatars of a certain type for the owner provided. For project avatars, this method checks that the user is either and admin or project admin for the owner project. For user avatars, the method checks that the remoteUser has admin permissions for JIRA or the remoteUser and avatar owner are the same person. If external user management is enabled this method returns false- Parameters:
remoteUser- The remote user trying to edit an avatarowner- The owner of the avatar being edited- Returns:
- true if the remote user has permission to edit avatars owned by the owner provided.
- Since:
- v6.0
-
userCanView
Check if the user can view the icon.- Parameters:
remoteUser- user whose permissions should be used. Null means anonymous access.icon- The icon that the user wishes to access.- Returns:
- Returns true if the user is allowed to view the avatar, or false otherwise.
-
userCanDelete
Check if the user can delete the icon.- Parameters:
remoteUser- user whose permissions should be used. Null means anonymous access.icon- The icon that the user wishes to delete.- Returns:
- Returns true if the user is allowed to delete the avatar, or false otherwise.
-
userCanCreateFor
boolean userCanCreateFor(@Nullable ApplicationUser remoteUser, @Nonnull IconType iconType, @Nonnull IconOwningObjectId owningObjectId) Check if the user could create an avatar for this owning object.- Parameters:
remoteUser- user whose permissions should be used. Null means anonymous access.iconType- The type of icon the user is trying to create.owningObjectId- id of the object to which this avatar is connected to. This helps set the scope for the provider of theIconTypeto determine permissions for icons that have not been created yet.
-
hasImage
Checks if valid image exists for avatar and image can be consumed byreadAvatarData(Avatar, Avatar.Size, AvatarFormatPolicy, MediaConsumer). An example of avatar with invalid image would be avatar with its image removed from the filesystem.- Parameters:
avatar- Avatarsize- Avatar size- Returns:
- true if avatar contains valid image that can be consumed.
-
Avatar.Size.