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
-
-
Constructor Summary
Constructors Constructor Description UserHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description User
getUser(UserIdentity userIdentity)
Deprecated.useUserManager.getUser(UserIdentity)
insteadUser
getUserByEmail(String populationId, String email)
Deprecated.useUserManager.getUserByEmail(String, String)
insteadString
getUserFullName(UserIdentity userIdentity)
Get the user's full name handling request cacheString
getUserSortableName(UserIdentity userIdentity)
Get the user's sortable name handling request cacheUserIdentity
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(Configuration userConfiguration)
Get the user identity from an XML configurationUserIdentity
xml2userIdentity(Node userNode)
Get the user identity from a DOM Node object-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Constructor Detail
-
UserHelper
public UserHelper()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
service
in 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 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
-
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
-
-