org.sakaiproject.profile2.logic
Interface ProfileImageLogic


public interface ProfileImageLogic

An interface for dealing with images in Profile2

Also takes care of image conversion from classic Profile to Profile2

Author:
Steve Swinsburg (steve.swinsburg@gmail.com)

Method Summary
 boolean addGalleryImage(String userUuid, byte[] imageBytes, String mimeType, String fileName)
          Add a gallery image for the specified user.
 List<GalleryImage> getGalleryImages(String userUuid)
          Retrieves all gallery images for the specified user.
 int getGalleryImagesCount(String userUuid)
          Get a count of the number of gallery images for a user
 List<GalleryImage> getGalleryImagesRandomized(String userUuid)
          Retrieves all gallery images in randomized order for the specified user.
 String getGravatarUrl(String userUuid)
          Generate a gravatar URL for a user
 ProfileImage getProfileImage(Person person, int size)
          Get the profile image for a user.
 ProfileImage getProfileImage(Person person, int size, String siteId)
          Get the profile image for a user.
 ProfileImage getProfileImage(String userUuid, ProfilePreferences prefs, ProfilePrivacy privacy, int size)
          Get the profile image for a user.
 ProfileImage getProfileImage(String userUuid, ProfilePreferences prefs, ProfilePrivacy privacy, int size, String siteId)
          Get the profile image for a user.
 String getProfileImageEntityUrl(String userUuid, int size)
          Get the entity url to a profile image for a user.
 String getUnavailableImageThumbnailURL()
          Get the full URL to the default unavailable image thumbnail defined in ProfileConstants
 String getUnavailableImageURL()
          Get the full URL to the default unavailable image defined in ProfileConstants
 boolean removeGalleryImage(String userId, long imageId)
          Remove the specified gallery image.
 boolean saveOfficialImageUrl(String userUuid, String url)
          Save the official image url that institutions can set.
 boolean setExternalProfileImage(String userUuid, String fullSizeUrl, String thumbnailUrl, String avatar)
          Update the profileImage for a user given the URL to an image
 boolean setUploadedProfileImage(String userUuid, byte[] imageBytes, String mimeType, String fileName)
          Update the profile image for a user given the byte[] of the image.
 

Method Detail

getProfileImage

ProfileImage getProfileImage(String userUuid,
                             ProfilePreferences prefs,
                             ProfilePrivacy privacy,
                             int size)
Get the profile image for a user. Takes into account all global settings, user preferences and privacy.

If making a request for your own image

If making a request for someone else's image

The returned ProfileImage object is a wrapper around all of the types of image that can be set. use the getBinarty and getUrl() methods on this object to get the data. See the docs on ProfileImage for how to use this.

Parameters:
userUuid -
prefs -
privacy -
size -
Returns:

getProfileImage

ProfileImage getProfileImage(String userUuid,
                             ProfilePreferences prefs,
                             ProfilePrivacy privacy,
                             int size,
                             String siteId)
Get the profile image for a user. Takes into account all global settings, user preferences, privacy and permissions in the given site. See getProfileImage(String, ProfilePreferences, ProfilePrivacy, int);

Parameters:
userUuid -
prefs -
privacy -
size -
siteId - - optional siteid to check if the current user has permissions in this site to see the target user's image (PRFL-411)
Returns:

getProfileImage

ProfileImage getProfileImage(Person person,
                             int size)
Get the profile image for a user. See getProfileImage(String, ProfilePreferences, ProfilePrivacy, int);

Parameters:
person - Person object that contains all info about a user
size - size of image to return.
Returns:

getProfileImage

ProfileImage getProfileImage(Person person,
                             int size,
                             String siteId)
Get the profile image for a user. See getProfileImage(String, ProfilePreferences, ProfilePrivacy, int);

Parameters:
person - Person object that contains all info about a user
size - size of image to return.
siteId - - optional siteid to check if the current user has permissions in this site to see the target user's image (PRFL-411)
Returns:

setUploadedProfileImage

boolean setUploadedProfileImage(String userUuid,
                                byte[] imageBytes,
                                String mimeType,
                                String fileName)
Update the profile image for a user given the byte[] of the image.

Will work, but not have visible effect if the setting for the image type used in sakai.properties is not upload. ie its using URL instead

Parameters:
userUuid - - uuid for the user
imageBytes - - byte[] of image
mimeType - - mimetype of image, ie image/jpeg
filename - - name of file, used by ContentHosting, optional.
Returns:

setExternalProfileImage

boolean setExternalProfileImage(String userUuid,
                                String fullSizeUrl,
                                String thumbnailUrl,
                                String avatar)
Update the profileImage for a user given the URL to an image

Will work, but not have visible effect if the setting for the image type used in sakai.properties is not url. ie its using an uploaded image instead

Parameters:
userUuid - - uuid for the user
fullSizeUrl - - url for main image
thumbnailUrl - - thumbnail for main image to be used when thumbnail sizes are requested. Leave blank or null for none and when a thumbnail is requested it will return the full image which can be scaled in the markup.
avatar - - avatar for main image to be used when avatar sizes are requested. Can be blank and it will fallback as per thumbnail
Returns:

getUnavailableImageURL

String getUnavailableImageURL()
Get the full URL to the default unavailable image defined in ProfileConstants

Returns:

getUnavailableImageThumbnailURL

String getUnavailableImageThumbnailURL()
Get the full URL to the default unavailable image thumbnail defined in ProfileConstants

Returns:

addGalleryImage

boolean addGalleryImage(String userUuid,
                        byte[] imageBytes,
                        String mimeType,
                        String fileName)
Add a gallery image for the specified user.

Parameters:
userUuid - the ID of the user.
imageBytes - the image bytes.
mimeType - the MIME type of the image.
fileName - the filename of the image.
Returns:
true if the gallery image is successfully added, false if the gallery image is not added.

getGalleryImages

List<GalleryImage> getGalleryImages(String userUuid)
Retrieves all gallery images for the specified user.

Parameters:
userUuid - the ID of the user.
Returns:
all profile gallery images for the specified user.

getGalleryImagesRandomized

List<GalleryImage> getGalleryImagesRandomized(String userUuid)
Retrieves all gallery images in randomized order for the specified user.

Parameters:
userUuid - the ID of the user.
Returns:
all profile gallery images in randomized order for the specified user.

removeGalleryImage

boolean removeGalleryImage(String userId,
                           long imageId)
Remove the specified gallery image.

Parameters:
userUuid - the user ID.
imageUuid - the image ID.
Returns:
true if the gallery image is successfully removed, false if the gallery image is not removed.

saveOfficialImageUrl

boolean saveOfficialImageUrl(String userUuid,
                             String url)
Save the official image url that institutions can set.

Parameters:
userUuid - uuid of the user
url - url to image
Returns:

getProfileImageEntityUrl

String getProfileImageEntityUrl(String userUuid,
                                int size)
Get the entity url to a profile image for a user. It can be added to any profile without checks as the retrieval of the image does the checks, and a default image is used if not allowed or none available.

Parameters:
userUuid - uuid for the user
size - size of image, from ProfileConstants

getGalleryImagesCount

int getGalleryImagesCount(String userUuid)
Get a count of the number of gallery images for a user

Parameters:
userUuid - uuid for the user
Returns:

getGravatarUrl

String getGravatarUrl(String userUuid)
Generate a gravatar URL for a user

URLs are of the form http://www.gravatar.com/avatar/HASH?s=200 where HASH is an MD5 hash of the user's email address and s is the size. We always use the larger size (200) and then scale it in the markup where required, to take advantage of caching.

If no email address for the user, returns null.

Parameters:
userUuid - uuid for the user
Returns:
gravatar URL or null


Copyright © 2008-2012 The Sakai Foundation. All Rights Reserved.