Package org.ametys.plugins.core.ui.user
Class SafeProfileImageProvider
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.ametys.plugins.core.ui.user.SafeProfileImageProvider
-
- All Implemented Interfaces:
ProfileImageProvider
,LogEnabled
,Serviceable
- Direct Known Subclasses:
DefaultProfileImageProvider
public class SafeProfileImageProvider extends AbstractLogEnabled implements ProfileImageProvider, Serviceable
Image provider working in safe mode
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.ametys.plugins.core.ui.user.ProfileImageProvider
ProfileImageProvider.UserProfileImage
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
__DEFAULT_FILE_NAME
Name of the default imageprotected static String
__USER_PROFILES_DIR_PATH
Relative path of the user profiles directory, which contains all the image subdirectoriesprotected SourceResolver
_sourceResolver
Source resolverprotected UserManager
_userManager
Users manager-
Fields inherited from interface org.ametys.plugins.core.ui.user.ProfileImageProvider
ROLE
-
-
Constructor Summary
Constructors Constructor Description SafeProfileImageProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private Source
_getGravatarImageSource(UserIdentity userIdentity, Integer size)
Get the source of a gravatar imageprotected ProfileImageProvider.UserProfileImage
getDefaultImage()
Get the default user imageprotected ProfileImageProvider.UserProfileImage
getGravatarImage(UserIdentity user, int size)
Get gravatar imageProfileImageProvider.UserProfileImage
getImage(UserIdentity user, String imageSource, int size, int maxSize)
Get the avatarboolean
hasGravatarImage(UserIdentity user)
Test if the gravatar image existsvoid
service(ServiceManager smanager)
-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
__USER_PROFILES_DIR_PATH
protected static final String __USER_PROFILES_DIR_PATH
Relative path of the user profiles directory, which contains all the image subdirectories- See Also:
- Constant Field Values
-
__DEFAULT_FILE_NAME
protected static final String __DEFAULT_FILE_NAME
Name of the default image- See Also:
- Constant Field Values
-
_sourceResolver
protected SourceResolver _sourceResolver
Source resolver
-
_userManager
protected UserManager _userManager
Users manager
-
-
Constructor Detail
-
SafeProfileImageProvider
public SafeProfileImageProvider()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getImage
public ProfileImageProvider.UserProfileImage getImage(UserIdentity user, String imageSource, int size, int maxSize) throws ProcessingException
Description copied from interface:ProfileImageProvider
Get the avatar- Specified by:
getImage
in interfaceProfileImageProvider
- Parameters:
user
- The userimageSource
- The image source. Can be null to get the default onesize
- The size in px. Can be 0.maxSize
- The maxSize in px. Can be 0.- Returns:
- The image
- Throws:
ProcessingException
- If an error occurred
-
getDefaultImage
protected ProfileImageProvider.UserProfileImage getDefaultImage()
Get the default user image- Returns:
- The UserProfileImage for the default image
-
getGravatarImage
protected ProfileImageProvider.UserProfileImage getGravatarImage(UserIdentity user, int size)
Get gravatar image- Parameters:
user
- The usersize
- The image size- Returns:
- The UserProfileImage or null if not found
-
_getGravatarImageSource
private Source _getGravatarImageSource(UserIdentity userIdentity, Integer size) throws IOException
Get the source of a gravatar image- Parameters:
userIdentity
- The usersize
- The requested size- Returns:
- The source or null
- Throws:
IOException
- If an error occurs while resolving the source uri
-
hasGravatarImage
public boolean hasGravatarImage(UserIdentity user)
Test if the gravatar image exists- Parameters:
user
- The user- Returns:
- True if the image exists
-
-