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,Component,Serviceable
public class UserHelper extends AbstractLogEnabled implements Component, Serviceable
Simple user helper, for common function working onUser
-
-
Field Summary
Fields Modifier and Type Field Description private UserDirectoryFactory_userDirectoryFactoryThe user directory factoryprivate UserManager_userManagerprivate UserPopulationDAO_userPopulationDAOThe user population DAOstatic StringROLEThe Avalon role
-
Constructor Summary
Constructors Constructor Description UserHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private Map<String,Object>_user2json(User user, boolean full)UsergetUser(UserIdentity userIdentity)Deprecated.useUserManager.getUser(UserIdentity)insteadUsergetUserByEmail(String populationId, String email)Deprecated.useUserManager.getUserByEmail(String, String)insteadStringgetUserFullName(UserIdentity userIdentity)Get the user's full name handling request cacheStringgetUserSortableName(UserIdentity userIdentity)Get the user's sortable name handling request cacheUserIdentityjson2userIdentity(Map<String,? extends Object> json)Get the user identity from a JSON objectvoidsaxUser(User user, ContentHandler handler)SAX an uservoidsaxUser(User user, ContentHandler handler, String tagName)SAX an uservoidsaxUserIdentity(UserIdentity userIdentity, ContentHandler handler)SAX an user identityvoidsaxUserIdentity(UserIdentity userIdentity, ContentHandler handler, String tagName)SAX an user identityvoidservice(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.UserIdentityxml2userIdentity(Configuration userConfiguration)Get the user identity from an XML configurationUserIdentityxml2userIdentity(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
-
_userPopulationDAO
private UserPopulationDAO _userPopulationDAO
The user population DAO
-
_userDirectoryFactory
private UserDirectoryFactory _userDirectoryFactory
The user directory factory
-
_userManager
private UserManager _userManager
-
-
Constructor Detail
-
UserHelper
public UserHelper()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
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 totrueto 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 totrueto 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 totrueto 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
@Deprecated public User getUser(UserIdentity userIdentity)
Deprecated.useUserManager.getUser(UserIdentity)insteadGet the user from its identity- Parameters:
userIdentity- The user identity- Returns:
- The user or null if not found
-
getUserByEmail
@Deprecated public User getUserByEmail(String populationId, String email)
Deprecated.useUserManager.getUserByEmail(String, String)insteadGet 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(Configuration userConfiguration) throws ConfigurationException
Get the user identity from an XML configuration- Parameters:
userConfiguration- The configuration- Returns:
- The user identity
- Throws:
ConfigurationException- if an error occurs during value retrieving
-
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
-
-