Class UserService
- java.lang.Object
-
- org.activecomponents.shortmessages.UserService
-
- All Implemented Interfaces:
IUserService
public class UserService extends java.lang.Object implements IUserService
Class for user management.
-
-
Field Summary
Fields Modifier and Type Field Description protected IInternalAccess
component
The component.protected java.util.Map<User,java.util.Set<User>>
followeds
The followed people (that the user follows).protected java.util.Map<User,java.util.Set<User>>
followers
The followers (that follow the user).protected java.util.Map<java.lang.String,User>
sessions
The active sessions - logged in users.protected java.util.Map<User,User>
users
The users.
-
Constructor Summary
Constructors Constructor Description UserService()
Create a new user service.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IFuture<java.lang.Boolean>
addFollowed(java.lang.String usertoken, User followed)
Add a new followed user.protected boolean
addFollowed(User user, User followed)
Add a followed by person.IFuture<java.lang.Boolean>
addFollower(java.lang.String usertoken, User follower)
Add a new follower.protected boolean
addFollower(User user, User follower)
Add a follower.IFuture<java.util.Collection<User>>
getAllUsers(java.lang.String usertoken)
Get all users.IFuture<java.util.Collection<User>>
getFolloweds(java.lang.String usertoken)
Get the current followers.IFuture<java.util.Collection<User>>
getFollowers(java.lang.String usertoken)
Get the current followers.IFuture<User>
getUser(java.lang.String usertoken)
Get a user per token.IFuture<User>
getUserByEmail(java.lang.String email)
Get a user per email.protected User
internalGetUserByEmail(java.lang.String email)
Get a user per emailprotected boolean
isOnline(User user)
Test if a user is online.IFuture<java.lang.String>
login(User user)
Login a user.IFuture<java.lang.Boolean>
logout(java.lang.String usertoken)
Logout a user.protected IFuture<java.lang.Void>
notifyOnlineState(User user, boolean online)
Notify all connected users of a specific online state.protected java.util.Collection<User>
processForClient(java.util.Collection<User> coll)
Process the user objects before sending to the client.protected User
processForClient(User user)
Process the user objects before sending to the client.IFuture<java.lang.Void>
register(User user)
Register a new user.protected void
registerUser(User user)
Register a new user.IFuture<java.lang.Boolean>
removeFollowed(java.lang.String usertoken, User followed)
Remove a followed user.IFuture<java.lang.Boolean>
removeFollower(java.lang.String usertoken, User follower)
Remove a follower.protected boolean
removeFollower(User user, User follower)
Remove a follower.
-
-
-
Field Detail
-
component
protected IInternalAccess component
The component.
-
followers
protected java.util.Map<User,java.util.Set<User>> followers
The followers (that follow the user).
-
followeds
protected java.util.Map<User,java.util.Set<User>> followeds
The followed people (that the user follows).
-
sessions
protected java.util.Map<java.lang.String,User> sessions
The active sessions - logged in users.
-
-
Method Detail
-
register
public IFuture<java.lang.Void> register(User user)
Register a new user.- Specified by:
register
in interfaceIUserService
- Parameters:
user
- The new user.
-
registerUser
protected void registerUser(User user)
Register a new user.- Parameters:
user
- The new user.
-
login
public IFuture<java.lang.String> login(User user)
Login a user.- Specified by:
login
in interfaceIUserService
- Parameters:
user
- The user.- Returns:
- The token for future access.
-
logout
public IFuture<java.lang.Boolean> logout(java.lang.String usertoken)
Logout a user.- Specified by:
logout
in interfaceIUserService
- Parameters:
usertoken
- The user token.- Returns:
- The token for future access.
-
getUser
public IFuture<User> getUser(java.lang.String usertoken)
Get a user per token.- Specified by:
getUser
in interfaceIUserService
- Parameters:
usertoken
- The user token.- Returns:
- The user or null if none.
-
getUserByEmail
public IFuture<User> getUserByEmail(java.lang.String email)
Get a user per email.- Specified by:
getUserByEmail
in interfaceIUserService
- Parameters:
email
- The user email.- Returns:
- The user.
-
internalGetUserByEmail
protected User internalGetUserByEmail(java.lang.String email)
Get a user per email- Parameters:
email
- The email.- Returns:
- The user or null.
-
getAllUsers
public IFuture<java.util.Collection<User>> getAllUsers(java.lang.String usertoken)
Get all users.- Specified by:
getAllUsers
in interfaceIUserService
- Returns:
- All users.
-
addFollower
public IFuture<java.lang.Boolean> addFollower(java.lang.String usertoken, User follower)
Add a new follower.- Specified by:
addFollower
in interfaceIUserService
- Parameters:
user
- The user.follower
- The follower.- Returns:
- True if changed.
-
addFollower
protected boolean addFollower(User user, User follower)
Add a follower.- Parameters:
user
-follower
-- Returns:
-
removeFollower
public IFuture<java.lang.Boolean> removeFollower(java.lang.String usertoken, User follower)
Remove a follower.- Specified by:
removeFollower
in interfaceIUserService
- Parameters:
user
- The user.follower
- The follower.- Returns:
- True if changed.
-
removeFollower
protected boolean removeFollower(User user, User follower)
Remove a follower.- Parameters:
user
-follower
-- Returns:
-
getFollowers
public IFuture<java.util.Collection<User>> getFollowers(java.lang.String usertoken)
Get the current followers.- Specified by:
getFollowers
in interfaceIUserService
- Parameters:
user
- The user.- Returns:
- The followers.
-
addFollowed
public IFuture<java.lang.Boolean> addFollowed(java.lang.String usertoken, User followed)
Add a new followed user.- Specified by:
addFollowed
in interfaceIUserService
- Parameters:
user
- The user.followed
- The followed user.
-
addFollowed
protected boolean addFollowed(User user, User followed)
Add a followed by person.- Parameters:
user
-followed
-- Returns:
-
removeFollowed
public IFuture<java.lang.Boolean> removeFollowed(java.lang.String usertoken, User followed)
Remove a followed user.- Specified by:
removeFollowed
in interfaceIUserService
- Parameters:
followed
- The followed user.
-
getFolloweds
public IFuture<java.util.Collection<User>> getFolloweds(java.lang.String usertoken)
Get the current followers.- Specified by:
getFolloweds
in interfaceIUserService
- Parameters:
followed
- The followed user.- Returns:
- The user that follow this user.
-
isOnline
protected boolean isOnline(User user)
Test if a user is online.- Parameters:
user
- The user.- Returns:
- True, if is currently online.
-
notifyOnlineState
protected IFuture<java.lang.Void> notifyOnlineState(User user, boolean online)
Notify all connected users of a specific online state.
-
processForClient
protected java.util.Collection<User> processForClient(java.util.Collection<User> coll)
Process the user objects before sending to the client. - Erases password - Sets online state.- Parameters:
coll
- The collection.- Returns:
- The processed collection.
-
-