@PublicApi
public interface AvatarManager
Avatar
domain objects.Modifier and Type | Interface and Description |
---|---|
static class |
AvatarManager.ImageSize
Deprecated.
in JIRA 6.0 -- use
Avatar.Size . |
Modifier and Type | Field and Description |
---|---|
static String |
AVATAR_IMAGE_FORMAT |
static AvatarFormat |
AVATAR_IMAGE_FORMAT_FULL |
static AvatarFormat |
AVATAR_IMAGE_FORMAT_SVG |
static String |
PNG_CONTENT_TYPE |
static String |
SVG_CONTENT_TYPE |
static String |
USER_AVATAR_ID_KEY |
Modifier and Type | Method and Description |
---|---|
Avatar |
create(Avatar.Type avatarType,
String owningObjectId,
AvatarImageDataProvider imageDataProvider)
Deprecated.
|
Avatar |
create(Avatar avatar)
Creates a database record for the given avatar.
|
Avatar |
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.
|
Avatar |
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.
|
Avatar |
create(String fileName,
String contentType,
ApplicationUser owner,
InputStream image,
Selection selection)
Deprecated.
|
Avatar |
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.
|
Avatar |
create(String fileName,
String contentType,
Project owner,
InputStream image,
Selection selection)
Deprecated.
|
boolean |
delete(Long avatarId)
Delete the avatar with the given id and the file on disk.
|
boolean |
delete(Long avatarId,
boolean alsoDeleteAvatarFile)
Delete the avatar with the given id.
|
List<Avatar> |
getAllSystemAvatars(Avatar.Type type)
Deprecated.
Use
getAllSystemAvatars(IconType) instead. Since v7.1 |
List<Avatar> |
getAllSystemAvatars(IconType iconType)
Provides a list of all system avatars.
|
Long |
getAnonymousAvatarId()
Gets the avatar id to use to represent an unknown or anonymous user
|
File |
getAvatarBaseDirectory()
Returns the directory for storing avatars.
|
Avatar |
getById(Long avatarId)
Retrieve the avatar with the given id.
|
Avatar |
getByIdTagged(Long avatarId)
Retrieve the avatar with the given id,
ensuring the avatar file is tagged with metadata identifying the image came from JIRA.
|
List<Avatar> |
getCustomAvatarsForOwner(Avatar.Type type,
String ownerId)
Deprecated.
there can only be one. Since v6.4.
|
List<Avatar> |
getCustomAvatarsForOwner(IconType iconType,
String ownerId)
Provides a list of all avatars that are of the given type which have the given owner.
|
Avatar |
getDefaultAvatar(IconType iconType)
Gets the default avatar for the given type.
|
Long |
getDefaultAvatarId(Avatar.Type ofType)
Deprecated.
Use
getDefaultAvatarId(IconType) Since v7.1 |
Long |
getDefaultAvatarId(IconType iconType)
Gets the default avatar ID for the given type.
|
boolean |
hasPermissionToEdit(ApplicationUser remoteUser,
ApplicationUser owner)
Deprecated.
|
boolean |
hasPermissionToEdit(ApplicationUser remoteUser,
Avatar.Type type,
String ownerId)
Deprecated.
|
boolean |
hasPermissionToEdit(ApplicationUser remoteUser,
Project owner)
Deprecated.
|
boolean |
hasPermissionToView(ApplicationUser remoteUser,
ApplicationUser owner)
Deprecated.
Use
userCanView(ApplicationUser, Avatar) Since v7.1 |
boolean |
hasPermissionToView(ApplicationUser remoteUser,
Avatar.Type type,
String ownerId)
Deprecated.
Use
userCanView(ApplicationUser, Avatar) Since v6.0 |
boolean |
hasPermissionToView(ApplicationUser remoteUser,
Project owner)
Deprecated.
Use
userCanView(ApplicationUser, Avatar) Since v7.1 |
boolean |
isAvatarOwner(Avatar avatar,
String ownerId)
Deprecated.
To be removed. Since v6.0
|
boolean |
isValidIconType(IconType iconType)
Check if this is a valid icon type.
|
void |
readAvatarData(Avatar avatar,
Avatar.Size size,
AvatarFormatPolicy avatarFormatPolicy,
MediaConsumer mediaConsumer)
Provides read-only access to the data of the avatar image as an
InputStream passed to the
provided dataAccessor. |
void |
readAvatarData(Avatar avatar,
Avatar.Size size,
Consumer<InputStream> dataAccessor)
Provides read-only access to the data of the avatar image as an
InputStream passed to the
provided dataAccessor. |
void |
readAvatarData(Avatar avatar,
AvatarManager.ImageSize size,
Consumer<InputStream> dataAccessor)
Deprecated.
v7.0.1 Please use
readAvatarData(Avatar, Avatar.Size, Consumer) |
void |
update(Avatar avatar)
Saves the avatar as an updated version of the avatar with the same id that is already in the database.
|
boolean |
userCanCreateFor(ApplicationUser remoteUser,
IconType iconType,
IconOwningObjectId owningObjectId)
Check if the user could create an avatar for this owning object.
|
boolean |
userCanDelete(ApplicationUser remoteUser,
Avatar icon)
Check if the user can delete the icon.
|
boolean |
userCanView(ApplicationUser remoteUser,
Avatar icon)
Check if the user can view the icon.
|
static final String AVATAR_IMAGE_FORMAT
static final String PNG_CONTENT_TYPE
static final String SVG_CONTENT_TYPE
static final AvatarFormat AVATAR_IMAGE_FORMAT_FULL
static final AvatarFormat AVATAR_IMAGE_FORMAT_SVG
static final String USER_AVATAR_ID_KEY
Avatar getById(Long avatarId) throws DataAccessException
avatarId
- must not be null.DataAccessException
- if there is a back-end database problem.Avatar getByIdTagged(Long avatarId) throws DataAccessException
avatarId
- must not be null.DataAccessException
- if there is a back-end database problem.boolean delete(Long avatarId) throws DataAccessException
avatarId
- must not be null.DataAccessException
- if there is a back-end database problem.boolean delete(Long avatarId, boolean alsoDeleteAvatarFile)
avatarId
- must not be null.alsoDeleteAvatarFile
- if false, the avatar file will be left on disk.DataAccessException
- if there is a back-end database problem.void update(Avatar avatar) throws DataAccessException
avatar
- must not be null.DataAccessException
- if there is a back-end database problem.@Nonnull Avatar create(Avatar avatar) throws DataAccessException
avatar
- must not be null, must have a null id.DataAccessException
- if there is a back-end database problem.@Nonnull Avatar create(Avatar avatar, InputStream image, Selection selection) throws DataAccessException, IOException
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.DataAccessException
- if there is a back-end database problem.IOException
@Nonnull Avatar create(Avatar.Type avatarType, @Nonnull String owningObjectId, @Nonnull AvatarImageDataProvider imageDataProvider) throws IOException
create(IconType, IconOwningObjectId, AvatarImageDataProvider)
since v7.1avatarType
- type of new avatar to create.owningObjectId
- id of object (project/user/issuetype) to which this avatar is connected to.imageDataProvider
- provider of image dataDataAccessException
- if there is a back-end database problem.IOException
- if there are arrors when processing image dataCroppingAvatarImageDataProviderFactory
@Nonnull Avatar create(@Nonnull IconType iconType, @Nonnull IconOwningObjectId owningObjectId, @Nonnull AvatarImageDataProvider imageDataProvider) throws IOException
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 dataDataAccessException
- if there is a back-end database problem.IOException
- if there are arrors when processing image dataCroppingAvatarImageDataProviderFactory
@Nonnull Avatar create(String fileName, String contentType, IconType iconType, IconOwningObjectId owner, InputStream image, Selection selection) throws DataAccessException, IOException
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 imageIOException
- If there was a problem consuming the image data, or a problem storing the image data.DataAccessException
@Nonnull Avatar create(String fileName, String contentType, Project owner, InputStream image, Selection selection) throws DataAccessException, IOException
create(String, String, IconType, IconOwningObjectId, InputStream, Selection)
. Since v7.1fileName
- 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 imageDataAccessException
- if there is a back-end database problem.IOException
@Nonnull Avatar create(String fileName, String contentType, ApplicationUser owner, InputStream image, Selection selection) throws DataAccessException, IOException
create(String, String, IconType, IconOwningObjectId, InputStream, Selection)
. Since v7.1.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 imageDataAccessException
- if there is a back-end database problem.IOException
@Nonnull List<Avatar> getAllSystemAvatars(Avatar.Type type) throws DataAccessException
getAllSystemAvatars(IconType)
instead. Since v7.1type
- The type of system avatars to returnDataAccessException
- if there is a back-end database problem.@Nonnull List<Avatar> getAllSystemAvatars(IconType iconType) throws DataAccessException
iconType
- The type of system avatars to returnDataAccessException
- if there is a back-end database problem.@Nonnull @Deprecated List<Avatar> getCustomAvatarsForOwner(Avatar.Type type, String ownerId) throws DataAccessException
type
- the desired type of the avatars to retrieve.ownerId
- the id of the owner, matches the type (project id or user key).DataAccessException
- if there is a back-end database problem.@Nonnull List<Avatar> getCustomAvatarsForOwner(IconType iconType, String ownerId) throws DataAccessException
iconType
- the desired type of the avatars to retrieve.ownerId
- the id of the owner, matches the type (project id or user key).DataAccessException
- if there is a back-end database problem.boolean isAvatarOwner(Avatar avatar, String ownerId)
avatar
- the avatar to check, must not be null.ownerId
- the ownerId to check, must not be null.@Deprecated void readAvatarData(Avatar avatar, AvatarManager.ImageSize size, Consumer<InputStream> dataAccessor) throws IOException
readAvatarData(Avatar, Avatar.Size, Consumer)
InputStream
passed to the
provided dataAccessor. The InputStream is closed after the dataAccessor completes. The dataAccessor is
immediately invoked on the data for the avatar.avatar
- the avatar for which the data is to be processed.size
- the size to return for this avatardataAccessor
- something to read the data.IOException
- if an IOException occurs in the dataAccessor or in acquiring the InputStream for the
avatar.readAvatarData(Avatar, Avatar.Size, AvatarFormatPolicy, MediaConsumer)
void readAvatarData(@Nonnull Avatar avatar, @Nonnull Avatar.Size size, @Nonnull Consumer<InputStream> dataAccessor) throws IOException
InputStream
passed 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)
with
AvatarFormatPolicy.createOriginalDataPolicy()
as the requested type and Optional.empty()
as type Accessor.
avatar
- the avatar for which the data is to be processed.size
- the size to return for this avatardataAccessor
- something to read the data.IOException
- if an IOException occurs in the dataAccessor or in acquiring the InputStream for the
avatar.readAvatarData(Avatar, Avatar.Size, AvatarFormatPolicy, MediaConsumer)
@ExperimentalApi void readAvatarData(@Nonnull Avatar avatar, @Nonnull Avatar.Size size, @Nonnull AvatarFormatPolicy avatarFormatPolicy, @Nonnull MediaConsumer mediaConsumer) throws IOException
InputStream
passed 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 AvatarFormatPolicy
that is provided
as a parameter. This should be used to set the content type of the data being provided to the @Consumer
. 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.
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.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@Nonnull File getAvatarBaseDirectory()
Long getDefaultAvatarId(@Nonnull Avatar.Type ofType)
getDefaultAvatarId(IconType)
Since v7.1ofType
- the Avatar type.Long getDefaultAvatarId(@Nonnull IconType iconType)
iconType
- the Icon type.Avatar getDefaultAvatar(@Nonnull IconType iconType)
iconType
- the Icon type.boolean isValidIconType(@Nonnull IconType iconType)
iconType
- The icon type to check.Long getAnonymousAvatarId()
boolean hasPermissionToView(ApplicationUser remoteUser, Avatar.Type type, String ownerId)
userCanView(ApplicationUser, Avatar)
Since v6.0remoteUser
- 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)boolean hasPermissionToView(ApplicationUser remoteUser, ApplicationUser owner)
userCanView(ApplicationUser, Avatar)
Since v7.1remoteUser
- The remote user trying to view an avatarowner
- The owner of the avatar being viewedboolean hasPermissionToView(ApplicationUser remoteUser, Project owner)
userCanView(ApplicationUser, Avatar)
Since v7.1remoteUser
- The remote user trying to view an avatarowner
- The owner of the avatar being viewedboolean hasPermissionToEdit(ApplicationUser remoteUser, Avatar.Type type, String ownerId)
userCanCreateFor(ApplicationUser, IconType, IconOwningObjectId)
Since v7.1remoteUser
- 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)boolean hasPermissionToEdit(ApplicationUser remoteUser, ApplicationUser owner)
userCanCreateFor(ApplicationUser, IconType, IconOwningObjectId)
Since v6.0remoteUser
- The remote user trying to edit an avatarowner
- The owner of the avatar being editedboolean hasPermissionToEdit(ApplicationUser remoteUser, Project owner)
userCanCreateFor(ApplicationUser, IconType, IconOwningObjectId)
Since v7.1remoteUser
- The remote user trying to edit an avatarowner
- The owner of the avatar being editedboolean userCanView(@Nullable ApplicationUser remoteUser, @Nonnull Avatar icon)
remoteUser
- user whose permissions should be used. Null means anonymous access.icon
- The icon that the user wishes to access.boolean userCanDelete(@Nullable ApplicationUser remoteUser, @Nonnull Avatar icon)
remoteUser
- user whose permissions should be used. Null means anonymous access.icon
- The icon that the user wishes to delete.boolean userCanCreateFor(@Nullable ApplicationUser remoteUser, @Nonnull IconType iconType, @Nonnull IconOwningObjectId owningObjectId)
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 the IconType
to determine permissions for icons that
have not been created yet.Copyright © 2002-2019 Atlassian. All Rights Reserved.