|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.atlassian.jira.avatar.AvatarManagerImpl
public class AvatarManagerImpl
Manager for Avatars.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface com.atlassian.jira.avatar.AvatarManager |
---|
AvatarManager.ImageSize |
Field Summary |
---|
Fields inherited from interface com.atlassian.jira.avatar.AvatarManager |
---|
AVATAR_IMAGE_FORMAT, USER_AVATAR_ID_KEY |
Constructor Summary | |
---|---|
AvatarManagerImpl(AvatarStore store,
JiraHome jiraHome,
ApplicationProperties applicationProperties,
PermissionManager permissionManager)
|
Method Summary | |
---|---|
Avatar |
create(Avatar avatar)
Creates a database record for the given avatar. |
Avatar |
create(Avatar avatar,
InputStream imageData,
Selection croppingSelection)
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. |
List<Avatar> |
getCustomAvatarsForOwner(Avatar.Type type,
String ownerId)
Provides a list of all avatars that are of the given type which have the given owner. |
Long |
getDefaultAvatarId(Avatar.Type ofType)
Gets the default avatar for the given type. |
boolean |
hasPermissionToEdit(com.atlassian.crowd.embedded.api.User remoteUser,
Avatar.Type type,
String ownerId)
Determines if the remoteUser provided has permission to edit avatars of a certain type for the owner provided. |
boolean |
hasPermissionToView(com.atlassian.crowd.embedded.api.User remoteUser,
Avatar.Type type,
String ownerId)
Determines if the remoteUser provided has permission to view avatars of a certain type for the owner provided. |
boolean |
isAvatarOwner(Avatar avatar,
String owner)
Tells whether the given avatar is owned by the given owner. |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AvatarManagerImpl(AvatarStore store, JiraHome jiraHome, ApplicationProperties applicationProperties, PermissionManager permissionManager)
Method Detail |
---|
public Avatar getById(Long avatarId)
AvatarManager
getById
in interface AvatarManager
avatarId
- must not be null.
public boolean delete(Long avatarId)
AvatarManager
delete
in interface AvatarManager
avatarId
- must not be null.
public boolean delete(Long avatarId, boolean alsoDeleteAvatarFile)
AvatarManager
delete
in interface AvatarManager
avatarId
- must not be null.alsoDeleteAvatarFile
- if false, the avatar file will be left on disk.
public void update(Avatar avatar)
AvatarManager
update
in interface AvatarManager
avatar
- must not be null.public Avatar create(Avatar avatar)
AvatarManager
create
in interface AvatarManager
avatar
- must not be null, must have a null id.
public Avatar create(Avatar avatar, InputStream imageData, Selection croppingSelection) throws DataAccessException, IOException
AvatarManager
create
in interface AvatarManager
avatar
- must not be null, must have a null id.imageData
- the data of the original avatar image.croppingSelection
- the cropping selection for the image or null to take whole image.
DataAccessException
- if there is a back-end database problem.
IOException
public File getAvatarBaseDirectory()
AvatarManager
getAvatarBaseDirectory
in interface AvatarManager
public List<Avatar> getAllSystemAvatars(Avatar.Type type)
AvatarManager
getAllSystemAvatars
in interface AvatarManager
type
- The type of system avatars to return
public List<Avatar> getCustomAvatarsForOwner(Avatar.Type type, String ownerId)
AvatarManager
getCustomAvatarsForOwner
in interface AvatarManager
type
- the desired type of the avatars to retrieve.ownerId
- the id of the owner, matches the type.
public boolean isAvatarOwner(Avatar avatar, String owner)
AvatarManager
isAvatarOwner
in interface AvatarManager
avatar
- the avatar to check, must not be null.owner
- the owner to check, must not be null.
public void readAvatarData(Avatar avatar, AvatarManager.ImageSize size, Consumer<InputStream> dataAccessor) throws IOException
AvatarManager
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.
readAvatarData
in interface AvatarManager
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.public Long getDefaultAvatarId(Avatar.Type ofType)
AvatarManager
getDefaultAvatarId
in interface AvatarManager
ofType
- the Avatar type.
public Long getAnonymousAvatarId()
AvatarManager
getAnonymousAvatarId
in interface AvatarManager
public boolean hasPermissionToView(com.atlassian.crowd.embedded.api.User remoteUser, Avatar.Type type, String ownerId)
AvatarManager
hasPermissionToView
in interface AvatarManager
remoteUser
- The remote user trying to view an avatartype
- The type of avatarownerId
- The owner id of the avatar being viewed
public boolean hasPermissionToEdit(com.atlassian.crowd.embedded.api.User remoteUser, Avatar.Type type, String ownerId)
AvatarManager
hasPermissionToEdit
in interface AvatarManager
remoteUser
- The remote user trying to edit an avatartype
- The type of avatarownerId
- The owner id of the avatar being edited
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |