Package org.ametys.plugins.core.user
Class UserHelper
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.core.user.UserHelper
-
- All Implemented Interfaces:
LogEnabled
,Initializable
,Component
,Serviceable
public class UserHelper extends AbstractLogEnabled implements Component, Serviceable, Initializable
Simple user helper, for common function working onUser
-
-
Field Summary
Fields Modifier and Type Field Description private static String
__USER_CACHE_BY_EMAIL_ID
private static String
__USER_CACHE_ID
private AbstractCacheManager
_abstractCacheManager
private UserDirectoryFactory
_userDirectoryFactory
The user directory factoryprivate UserManager
_userManager
private UserPopulationDAO
_userPopulationDAO
The user population DAOstatic String
ROLE
The Avalon role
-
Constructor Summary
Constructors Constructor Description UserHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private Map<String,Object>
_user2json(User user, boolean full)
User
getUser(UserIdentity userIdentity)
Get the user from its identityUser
getUserByEmail(String populationId, String email)
Get the user from its emailprivate Cache<Pair<String,String>,User>
getUserByEmailCache()
private Cache<UserIdentity,User>
getUserCache()
String
getUserFullName(UserIdentity userIdentity)
Get the user's full name handling request cacheString
getUserSortableName(UserIdentity userIdentity)
Get the user's sortable name handling request cachevoid
initialize()
UserIdentity
json2userIdentity(Map<String,? extends Object> json)
Get the user identity from a JSON objectvoid
saxUser(User user, ContentHandler handler)
SAX an uservoid
saxUser(User user, ContentHandler handler, String tagName)
SAX an uservoid
saxUserIdentity(UserIdentity userIdentity, ContentHandler handler)
SAX an user identityvoid
saxUserIdentity(UserIdentity userIdentity, ContentHandler handler, String tagName)
SAX an user identityvoid
service(ServiceManager smanager)
Map<String,Object>
user2json(User user)
Get the JSON object representing a userMap<String,Object>
user2json(UserIdentity userIdentity)
Get the JSON object representing a userMap<String,Object>
user2json(UserIdentity userIdentity, boolean full)
Get the JSON object representing a userMap<String,Object>
user2json(User user, boolean full)
Get the JSON object representing a userList<Map<String,Object>>
userIdentities2json(Collection<UserIdentity> users)
Populate a list of map, where each map representing an user.List<Map<String,Object>>
users2json(Collection<User> users)
Populate a list of map, where each map representing an user.List<Map<String,Object>>
users2json(Collection<User> users, boolean full)
Populate a list of map, where each map representing an user.UserIdentity
xml2userIdentity(Node userNode)
Get the user identity from a DOM Node object-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
__USER_CACHE_ID
private static final String __USER_CACHE_ID
-
__USER_CACHE_BY_EMAIL_ID
private static final String __USER_CACHE_BY_EMAIL_ID
-
_userPopulationDAO
private UserPopulationDAO _userPopulationDAO
The user population DAO
-
_userDirectoryFactory
private UserDirectoryFactory _userDirectoryFactory
The user directory factory
-
_userManager
private UserManager _userManager
-
_abstractCacheManager
private AbstractCacheManager _abstractCacheManager
-
-
Constructor Detail
-
UserHelper
public UserHelper()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
initialize
public void initialize() throws Exception
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
getUserFullName
public String getUserFullName(UserIdentity userIdentity)
Get the user's full name handling request cache- Parameters:
userIdentity
- The user identity- Returns:
- user's full name or null if user does not exist
-
getUserSortableName
public String getUserSortableName(UserIdentity userIdentity)
Get the user's sortable name handling request cache- Parameters:
userIdentity
- The user identity- Returns:
- user's full name or null if user does not exist
-
userIdentities2json
public List<Map<String,Object>> userIdentities2json(Collection<UserIdentity> users)
Populate a list of map, where each map representing an user.- Parameters:
users
- The list of users- Returns:
- The list of map.
-
users2json
public List<Map<String,Object>> users2json(Collection<User> users)
Populate a list of map, where each map representing an user.- Parameters:
users
- The list of users- Returns:
- The list of map.
-
users2json
public List<Map<String,Object>> users2json(Collection<User> users, boolean full)
Populate a list of map, where each map representing an user.- Parameters:
users
- The list of usersfull
- Set totrue
to get full information on user- Returns:
- The list of map.
-
user2json
public Map<String,Object> user2json(UserIdentity userIdentity)
Get the JSON object representing a user- Parameters:
userIdentity
- The user identity- Returns:
- The user as JSON object
-
user2json
public Map<String,Object> user2json(UserIdentity userIdentity, boolean full)
Get the JSON object representing a user- Parameters:
userIdentity
- The user identityfull
- Set totrue
to get full information on user- Returns:
- The user as JSON object
-
user2json
public Map<String,Object> user2json(User user)
Get the JSON object representing a user- Parameters:
user
- The user- Returns:
- The user as JSON object
-
user2json
public Map<String,Object> user2json(User user, boolean full)
Get the JSON object representing a user- Parameters:
user
- The userfull
- Set totrue
to get full information on user- Returns:
- The user as JSON object or null, if the given user is null
-
_user2json
private Map<String,Object> _user2json(User user, boolean full)
-
json2userIdentity
public UserIdentity json2userIdentity(Map<String,? extends Object> json)
Get the user identity from a JSON object- Parameters:
json
- the JSON object representing the user- Returns:
- the user identity
-
getUser
public User getUser(UserIdentity userIdentity)
Get the user from its identity- Parameters:
userIdentity
- The user identity- Returns:
- The user or null if not found
-
getUserCache
private Cache<UserIdentity,User> getUserCache()
-
getUserByEmail
public User getUserByEmail(String populationId, String email)
Get the user from its email- Parameters:
populationId
- The population idemail
- The email- Returns:
- The user or null if not found or if multiple user were found with this email
-
saxUserIdentity
public void saxUserIdentity(UserIdentity userIdentity, ContentHandler handler) throws SAXException
SAX an user identity- Parameters:
userIdentity
- The user identity to SAXhandler
- The content handler- Throws:
SAXException
- If a SAX error occurs
-
saxUserIdentity
public void saxUserIdentity(UserIdentity userIdentity, ContentHandler handler, String tagName) throws SAXException
SAX an user identity- Parameters:
userIdentity
- The user identity to SAXhandler
- The content handlertagName
- The XML tag for saxed user- Throws:
SAXException
- If a SAX error occurs
-
saxUser
public void saxUser(User user, ContentHandler handler) throws SAXException
SAX an user- Parameters:
user
- The user. If null no sax events will be generated.handler
- The content handler- Throws:
SAXException
- If a SAX error occurs
-
saxUser
public void saxUser(User user, ContentHandler handler, String tagName) throws SAXException
SAX an user- Parameters:
user
- The user. If null no sax events will be generated.handler
- The content handlertagName
- The XML tag for saxed user- Throws:
SAXException
- If a SAX error occurs
-
xml2userIdentity
public UserIdentity xml2userIdentity(Node userNode) throws TransformerException
Get the user identity from a DOM Node object- Parameters:
userNode
- The node- Returns:
- The user identity
- Throws:
TransformerException
- if an error occurs during value retrieving
-
-