Interface ProfileImageLogic
-
public interface ProfileImageLogicAn interface for dealing with images in Profile2Also takes care of image conversion from classic Profile to Profile2
- Author:
- Steve Swinsburg (steve.swinsburg@gmail.com)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanaddGalleryImage(String userUuid, byte[] imageBytes, String mimeType, String fileName)Add a gallery image for the specified user.ProfileImagegetBlankProfileImage()Get the blank profile image, the one a user sees if there is no other image available.List<GalleryImage>getGalleryImages(String userUuid)Retrieves all gallery images for the specified user.intgetGalleryImagesCount(String userUuid)Get a count of the number of gallery images for a userList<GalleryImage>getGalleryImagesRandomized(String userUuid)Retrieves all gallery images in randomized order for the specified user.StringgetGravatarUrl(String userUuid)Generate a gravatar URL for a userProfileImagegetOfficialProfileImage(String userUuid, String siteId)Gets the official profile image for a user.ProfileImagegetProfileAvatarInitials(String userUuid)Generate a profile image for a user with his name/last name initialsProfileImagegetProfileImage(String userUuid, ProfilePreferences prefs, ProfilePrivacy privacy, int size)Get the profile image for a user.ProfileImagegetProfileImage(String userUuid, ProfilePreferences prefs, ProfilePrivacy privacy, int size, String siteId)Get the profile image for a user.ProfileImagegetProfileImage(Person person, int size)Get the profile image for a user.ProfileImagegetProfileImage(Person person, int size, String siteId)Get the profile image for a user.StringgetProfileImageEntityUrl(String userUuid, int size)Get the entity url to a profile image for a user.StringgetUnavailableImageThumbnailURL()Get the full URL to the default unavailable image thumbnail defined in ProfileConstantsStringgetUnavailableImageURL()Get the full URL to the default unavailable image defined in ProfileConstantsbooleanisPicEditorEnabled()Find out if the user is allowed to change his profile picture based on the related propertiesbooleanprofileImageIsDefault(String userUuid)Does this use have a default profile image?booleanremoveGalleryImage(String userId, long imageId)Remove the specified gallery image.booleanresetProfileImage(String userUuid)Reset the profile image for a userbooleansaveOfficialImageUrl(String userUuid, String url)Save the official image url that institutions can set.booleansetExternalProfileImage(String userUuid, String fullSizeUrl, String thumbnailUrl, String avatar)Update the profileImage for a user given the URL to an imagebooleansetUploadedProfileImage(String userUuid, byte[] imageBytes, String mimeType, String fileName)Update the profile image for a user given the byte[] of the image.
-
-
-
Method Detail
-
getBlankProfileImage
ProfileImage getBlankProfileImage()
Get the blank profile image, the one a user sees if there is no other image available.
-
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
- 'privacy' can be null as it won't be considered.
- You should provide 'prefs' (if available) otherwise it will be looked up.
If making a request for someone else's image
- You should provide the privacy settings for that user (if available), otherwise it will be looked up.
- You should provide the preferences object for that user (if available), otherwise it will be looked up.
- If privacy is null, a default image will be returned
- If preferences is still null, the global preference will be used, which may not exist and therefore be default.
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:
-
getOfficialProfileImage
ProfileImage getOfficialProfileImage(String userUuid, String siteId)
Gets the official profile image for a user.- Parameters:
userUuid-siteId- siteId to check that the requesting user has roster.viewofficialphoto permission- Returns:
- The ProfileImage object, populated with either a url or binary data.
-
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 usersize- 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 usersize- 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 userimageBytes- - byte[] of imagemimeType- - mimetype of image, ie image/jpegfilename- - 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 imageWill 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 userfullSizeUrl- - url for main imagethumbnailUrl- - 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:
trueif the gallery image is successfully added,falseif 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:
trueif the gallery image is successfully removed,falseif 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 userurl- 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 usersize- 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 userURLs 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
-
resetProfileImage
boolean resetProfileImage(String userUuid)
Reset the profile image for a user- Parameters:
userUuid- uuid for the user- Returns:
-
profileImageIsDefault
boolean profileImageIsDefault(String userUuid)
Does this use have a default profile image?- Parameters:
userUuid- uuid for the user- Returns:
-
getProfileAvatarInitials
ProfileImage getProfileAvatarInitials(String userUuid)
Generate a profile image for a user with his name/last name initials- Parameters:
userUuid- uuid for the user- Returns:
- The ProfileImage object, populated with either a url or binary data.
-
isPicEditorEnabled
boolean isPicEditorEnabled()
Find out if the user is allowed to change his profile picture based on the related properties- Returns:
-
-