@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 String |
USER_AVATAR_ID_KEY |
Modifier and Type | Method and Description |
---|---|
Avatar |
create(Avatar.Type avatarType,
String owningObjectId,
AvatarImageDataProvider imageDataProvider)
Creates a database record for the given avatar and uses the content of the InputStream as the image.
|
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(String fileName,
String contentType,
ApplicationUser 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)
Creates a database record for the given avatar and uses the content of the InputStream as the image.
|
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)
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.
|
Long |
getDefaultAvatarId(Avatar.Type ofType)
Gets the default avatar for the given type.
|
boolean |
hasPermissionToEdit(ApplicationUser remoteUser,
ApplicationUser owner)
Determines if the remoteUser provided has permission to edit avatars of a certain type for the owner provided.
|
boolean |
hasPermissionToEdit(ApplicationUser remoteUser,
Project owner)
Determines if the remoteUser provided has permission to edit avatars of a certain type for the owner provided.
|
boolean |
hasPermissionToEdit(com.atlassian.crowd.embedded.api.User remoteUser,
Avatar.Type type,
String ownerId)
|
boolean |
hasPermissionToView(ApplicationUser remoteUser,
ApplicationUser owner)
Determines if the remoteUser provided has permission to view avatars of a certain type for the owner provided.
|
boolean |
hasPermissionToView(ApplicationUser remoteUser,
Project owner)
Determines if the remoteUser provided has permission to view avatars of a certain type for the owner provided.
|
boolean |
hasPermissionToView(com.atlassian.crowd.embedded.api.User remoteUser,
Avatar.Type type,
String ownerId)
|
boolean |
isAvatarOwner(Avatar avatar,
String ownerId)
Deprecated.
To be removed. Since v6.0
|
void |
readAvatarData(Avatar avatar,
AvatarManager.ImageSize size,
Consumer<InputStream> dataAccessor)
Provides read-only access to the data of the avatar image as an
InputStream passed to the
provided dataProcessor. |
void |
update(Avatar avatar)
Saves the avatar as an updated version of the avatar with the same id that is already in the database.
|
static final String AVATAR_IMAGE_FORMAT
static final AvatarFormat AVATAR_IMAGE_FORMAT_FULL
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
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 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, Project owner, InputStream image, Selection selection) throws DataAccessException, IOException
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 Avatar create(String fileName, String contentType, ApplicationUser owner, InputStream image, Selection selection) throws DataAccessException, IOException
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
type
- 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.boolean isAvatarOwner(Avatar avatar, String ownerId)
avatar
- the avatar to check, must not be null.ownerId
- the ownerId to check, must not be null.void readAvatarData(Avatar avatar, AvatarManager.ImageSize size, Consumer<InputStream> dataAccessor) throws IOException
InputStream
passed to the
provided dataProcessor. The InputStream is closed after the dataProcessor completes. The dataProcessor 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 dataProcessor or in acquiring the InputStream for the
avatar.@Nonnull File getAvatarBaseDirectory()
Long getDefaultAvatarId(Avatar.Type ofType)
ofType
- the Avatar type.Long getAnonymousAvatarId()
boolean hasPermissionToView(com.atlassian.crowd.embedded.api.User remoteUser, Avatar.Type type, String ownerId)
hasPermissionToView(com.atlassian.jira.user.ApplicationUser, ApplicationUser)
or hasPermissionToView(com.atlassian.jira.user.ApplicationUser, com.atlassian.jira.project.Project)
. 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)
remoteUser
- The remote user trying to view an avatarowner
- The owner of the avatar being viewedboolean hasPermissionToView(ApplicationUser remoteUser, Project owner)
remoteUser
- The remote user trying to view an avatarowner
- The owner of the avatar being viewedboolean hasPermissionToEdit(com.atlassian.crowd.embedded.api.User remoteUser, Avatar.Type type, String ownerId)
hasPermissionToEdit(ApplicationUser, ApplicationUser)
or hasPermissionToEdit(com.atlassian.jira.user.ApplicationUser, com.atlassian.jira.project.Project)
. Since v6.0remoteUser
- 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)
remoteUser
- The remote user trying to edit an avatarowner
- The owner of the avatar being editedboolean hasPermissionToEdit(ApplicationUser remoteUser, Project owner)
remoteUser
- The remote user trying to edit an avatarowner
- The owner of the avatar being editedCopyright © 2002-2015 Atlassian. All Rights Reserved.