com.atlassian.jira.avatar
Interface AvatarManager

All Known Implementing Classes:
AvatarManagerImpl

public interface AvatarManager

Manager interface for Avatar domain objects.

Since:
v4.0

Field Summary
static String AVATAR_IMAGE_FORMAT
           
static AvatarSize LARGE
           
static AvatarSize SMALL
           
 
Method Summary
 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.
 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()
          Provides a list of all system avatars.
 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 isAvatarOwner(Avatar avatar, String owner)
          Tells whether the given avatar is owned by the given owner.
 void readLargeAvatarData(Avatar avatar, Consumer<InputStream> dataAccessor)
          Provides read-only access to the data of the large avatar image as an InputStream passed to the provided dataProcessor.
 void readSmallAvatarData(Avatar avatar, Consumer<InputStream> dataAccessor)
          Provides read-only access to the data of the small 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.
 

Field Detail

LARGE

static final AvatarSize LARGE

SMALL

static final AvatarSize SMALL

AVATAR_IMAGE_FORMAT

static final String AVATAR_IMAGE_FORMAT
See Also:
Constant Field Values
Method Detail

getById

Avatar getById(Long avatarId)
               throws DataAccessException
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.

delete

boolean delete(Long avatarId)
               throws DataAccessException
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

boolean delete(Long avatarId,
               boolean alsoDeleteAvatarFile)
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

void update(Avatar avatar)
            throws DataAccessException
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

@NotNull
Avatar create(Avatar avatar)
              throws DataAccessException
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

@NotNull
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

getAllSystemAvatars

@NotNull
List<Avatar> getAllSystemAvatars()
                                 throws DataAccessException
Provides a list of all system avatars.

Returns:
the system avatars.
Throws:
DataAccessException - if there is a back-end database problem.

getCustomAvatarsForOwner

@NotNull
List<Avatar> getCustomAvatarsForOwner(Avatar.Type type,
                                              String ownerId)
                                      throws DataAccessException
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.
Returns:
all the avatars that have the given type and owner, never null.
Throws:
DataAccessException - if there is a back-end database problem.

isAvatarOwner

boolean isAvatarOwner(Avatar avatar,
                      String owner)
Tells whether the given avatar is owned by the given owner.

Parameters:
avatar - the avatar to check, must not be null.
owner - the owner to check, must not be null.
Returns:
true only if the given owner is the owner of the given avatar.

readLargeAvatarData

void readLargeAvatarData(Avatar avatar,
                         Consumer<InputStream> dataAccessor)
                         throws IOException
Provides read-only access to the data of the large avatar image as an 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.

Parameters:
avatar - the avatar for which the data is to be processed.
dataAccessor - something to read the data.
Throws:
IOException - if an IOException occurs in the dataProcessor or in acquiring the InputStream for the avatar.

readSmallAvatarData

void readSmallAvatarData(Avatar avatar,
                         Consumer<InputStream> dataAccessor)
                         throws IOException
Provides read-only access to the data of the small avatar image as an 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.

Parameters:
avatar - the avatar for which the data is to be processed.
dataAccessor - something to read the data.
Throws:
IOException - if an IOException acquiring the InputStream for the avatar.

getAvatarBaseDirectory

@NotNull
File getAvatarBaseDirectory()
Returns the directory for storing avatars.

Returns:
the directory.

getDefaultAvatarId

@NotNull
Long getDefaultAvatarId(Avatar.Type ofType)
Gets the default avatar for the given type.

Parameters:
ofType - the Avatar type.
Returns:
the default Avatar.


Copyright © 2002-2010 Atlassian. All Rights Reserved.