public class BaasUser
extends java.lang.Object
implements android.os.Parcelable
BaasUser.withUserName(String)
Users have associated profile data with different levels of
visibility as specified by BaasUser.Scope
.
Accounts on BaasBox are managed through this class BaasUser.signup(BaasHandler)
BaasUser.login(String, BaasHandler)
and BaasUser.logout(BaasHandler)
family
of methods, and their *sync counterpart.
The currently logged in user can be retrieved through BaasUser.current()
, and
it is the only one that is modifiable.
BaasUser also exposes methods to handle friendship, through BaasUser.follow(BaasHandler)
/BaasUser.unfollow(BaasHandler)
and direct gcm messaging throuhg #send(com.baasbox.android.json.JsonObject, BaasHandler)
In any other respect users are treated similarly to other resources
exposed by the server.
Created by Andrea Tortorella on 02/01/14.Modifier and Type | Class and Description |
---|---|
static class |
BaasUser.Scope
Scopes of visibility of user related data.
|
static class |
BaasUser.Social |
Modifier and Type | Field and Description |
---|---|
static android.os.Parcelable.Creator<BaasUser> |
CREATOR |
Modifier and Type | Method and Description |
---|---|
RequestToken |
changePassword(java.lang.String password,
BaasHandler<java.lang.Void> handler) |
RequestToken |
changePassword(java.lang.String password,
int flags,
BaasHandler<java.lang.Void> handler) |
BaasResult<java.lang.Void> |
changePasswordSync(java.lang.String password) |
static BaasUser |
current()
Returns the current logged in user if
one is logged in or
null |
int |
describeContents() |
boolean |
equals(java.lang.Object o) |
static RequestToken |
fetch(java.lang.String username,
BaasHandler<BaasUser> handler)
Asynchronously fetches an existing
BaasUser from the server
given it's username. |
static RequestToken |
fetch(java.lang.String username,
int flags,
BaasHandler<BaasUser> handler)
Asynchronously fetches an existing
BaasUser from the server
given it's username |
static RequestToken |
fetchAll(BaasHandler<java.util.List<BaasUser>> handler)
Asynchronously fetches the list of users from the server.
|
static RequestToken |
fetchAll(BaasQuery.Criteria filter,
BaasHandler<java.util.List<BaasUser>> handler)
Asynchronously fetches the list of users from the server.
|
static RequestToken |
fetchAll(BaasQuery.Criteria filter,
int flags,
BaasHandler<java.util.List<BaasUser>> handler)
Asynchronously fetches the list of users from the server.
|
static BaasResult<java.util.List<BaasUser>> |
fetchAllSync() |
static BaasResult<java.util.List<BaasUser>> |
fetchAllSync(BaasQuery.Criteria filter) |
RequestToken |
fetchLinkedSocialNetworks(BaasHandler<JsonArray> handler) |
RequestToken |
fetchLinkedSocialNetworks(int flags,
BaasHandler<JsonArray> handler) |
BaasResult<JsonArray> |
fetchLinkedSocialNetworksSync() |
static BaasResult<BaasUser> |
fetchSync(java.lang.String username) |
RequestToken |
follow(BaasHandler<BaasUser> handler)
Asynchronously requests to follow the user.
|
RequestToken |
follow(int flags,
BaasHandler<BaasUser> handler)
Asynchronously requests to follow the user.
|
RequestToken |
followers(BaasHandler<java.util.List<BaasUser>> handler) |
RequestToken |
followers(BaasQuery.Criteria filter,
BaasHandler<java.util.List<BaasUser>> handler) |
RequestToken |
followers(BaasQuery.Criteria filter,
int flags,
BaasHandler<java.util.List<BaasUser>> handler) |
BaasResult<java.util.List<BaasUser>> |
followersSync() |
BaasResult<java.util.List<BaasUser>> |
followersSync(BaasQuery.Criteria filter) |
RequestToken |
following(BaasHandler<java.util.List<BaasUser>> handler) |
RequestToken |
following(BaasQuery.Criteria filter,
BaasHandler<java.util.List<BaasUser>> handler) |
RequestToken |
following(BaasQuery.Criteria filter,
int flags,
BaasHandler<java.util.List<BaasUser>> handler) |
BaasResult<java.util.List<BaasUser>> |
followingSync() |
BaasResult<java.util.List<BaasUser>> |
followingSync(BaasQuery.Criteria filter) |
BaasResult<BaasUser> |
followSync() |
java.lang.String |
getName()
Returns the name of the user.
|
java.lang.String |
getPassword()
Returns the password of this user, if there is one.
|
java.util.Set<java.lang.String> |
getRoles()
Returns an unmodifialble set of the roles
to which the user belongs if it's available
|
JsonObject |
getScope(BaasUser.Scope scope)
Returns data associate to this user for the specific
scope as a
JsonObject . |
java.lang.String |
getSignupDate()
Returns the signupdate for this user if available or null.
|
java.lang.String |
getStatus()
Returns the registration status of the user if available or null.
|
java.lang.String |
getToken()
Returns the authtoken used by this user.
|
int |
hashCode() |
boolean |
hasRole(java.lang.String role)
Checks if the user has a specific role
|
static boolean |
isAuthentcated()
Verifies if there is a currently logged in user on this device
|
boolean |
isCurrent()
Checks if this user is the currently logged in user on this device.
|
RequestToken |
linkToProvider(java.lang.String provider,
java.lang.String token,
java.lang.String secret,
BaasHandler<JsonObject> handler) |
RequestToken |
linkToProvider(java.lang.String provider,
java.lang.String token,
java.lang.String secret,
int flags,
BaasHandler<JsonObject> handler) |
BaasResult<JsonObject> |
linkToProviderSync(java.lang.String provider,
java.lang.String token,
java.lang.String secret) |
RequestToken |
login(BaasHandler<BaasUser> handler)
Asynchronously logins this user.
|
RequestToken |
login(java.lang.String registrationId,
BaasHandler<BaasUser> handler)
Asynchronously logins this user with password and registrationId obtained through
gcm.
|
RequestToken |
login(java.lang.String regitrationId,
int flags,
BaasHandler<BaasUser> handler)
Asynchronously logins the user with password and registrationId obtained through gcm.
|
BaasResult<BaasUser> |
loginSync()
Synchronously logins the user with password.
|
BaasResult<BaasUser> |
loginSync(java.lang.String registrationId)
Synchronously logins the user with password and registrationId obtained through gcm.
|
RequestToken |
logout(BaasHandler<java.lang.Void> handler)
Logouts the user from the server.
|
RequestToken |
logout(java.lang.String registration,
BaasHandler<java.lang.Void> handler)
Logouts the user from the specific device.
|
RequestToken |
logout(java.lang.String registration,
int flags,
BaasHandler<java.lang.Void> handler)
Logouts the user from the specific device.
|
BaasResult<java.lang.Void> |
logoutSync()
Sychronously logouts current user from the server
|
BaasResult<java.lang.Void> |
logoutSync(java.lang.String registration)
Synchronously logouts current user from the server.
|
RequestToken |
refresh(BaasHandler<BaasUser> handler) |
RequestToken |
refresh(int flags,
BaasHandler<BaasUser> handler) |
BaasResult<BaasUser> |
refreshSync() |
static RequestToken |
requestPasswordReset(java.lang.String username,
int flags,
BaasHandler<java.lang.Void> handler) |
static BaasResult<java.lang.Void> |
requestPasswordResetSync(java.lang.String username) |
static RequestToken |
requestPaswordReset(java.lang.String username,
BaasHandler<java.lang.Void> handler) |
RequestToken |
save(BaasHandler<BaasUser> handler)
Asynchronously saves the updates made to the current user.
|
RequestToken |
save(int flags,
BaasHandler<BaasUser> handler)
Asynchronously saves the updates made to the current user.
|
BaasResult<BaasUser> |
saveSync()
Synchronously saves the updates made to the current user.
|
BaasUser |
setPassword(java.lang.String password)
Sets the password for this user.
|
RequestToken |
signup(BaasHandler<BaasUser> handler)
Asynchronously signups this user to baasbox
using provided password and default
RequestOptions |
RequestToken |
signup(int flags,
BaasHandler<BaasUser> handler)
Asynchronously signups this user to baasbox
using provided password and priority
|
BaasResult<BaasUser> |
signupSync()
Synchronously signups this user to BaasBox.
|
static RequestToken |
signupWithProvider(java.lang.String provider,
java.lang.String token,
java.lang.String secret,
BaasHandler<BaasUser> handler) |
static RequestToken |
signupWithProvider(java.lang.String provider,
java.lang.String token,
java.lang.String secret,
int flags,
BaasHandler<BaasUser> handler) |
static BaasResult<BaasUser> |
signupWithProviderSync(java.lang.String provider,
java.lang.String token,
java.lang.String secret) |
java.lang.String |
toString() |
RequestToken |
unfollow(BaasHandler<BaasUser> user) |
RequestToken |
unfollow(int flags,
BaasHandler<BaasUser> handler)
Asynchronously requests to unfollow the user
|
BaasResult<BaasUser> |
unfollowSync() |
RequestToken |
unlinkFromProvider(java.lang.String provider,
BaasHandler<java.lang.Void> handler) |
RequestToken |
unlinkFromProvider(java.lang.String provider,
int flags,
BaasHandler<java.lang.Void> handler) |
BaasResult<java.lang.Void> |
unlinkFromProviderSync(java.lang.String provider) |
static BaasUser |
withUserName(java.lang.String username)
Creates a new user bound to username.
|
void |
writeToParcel(android.os.Parcel dest,
int flags) |
public static final android.os.Parcelable.Creator<BaasUser> CREATOR
public static boolean isAuthentcated()
public static BaasUser current()
null
BaasUser
public static BaasResult<BaasUser> signupWithProviderSync(java.lang.String provider, java.lang.String token, java.lang.String secret)
public static RequestToken signupWithProvider(java.lang.String provider, java.lang.String token, java.lang.String secret, BaasHandler<BaasUser> handler)
public static RequestToken signupWithProvider(java.lang.String provider, java.lang.String token, java.lang.String secret, int flags, BaasHandler<BaasUser> handler)
public RequestToken linkToProvider(java.lang.String provider, java.lang.String token, java.lang.String secret, int flags, BaasHandler<JsonObject> handler)
public RequestToken linkToProvider(java.lang.String provider, java.lang.String token, java.lang.String secret, BaasHandler<JsonObject> handler)
public BaasResult<JsonObject> linkToProviderSync(java.lang.String provider, java.lang.String token, java.lang.String secret)
public RequestToken unlinkFromProvider(java.lang.String provider, int flags, BaasHandler<java.lang.Void> handler)
public RequestToken unlinkFromProvider(java.lang.String provider, BaasHandler<java.lang.Void> handler)
public BaasResult<java.lang.Void> unlinkFromProviderSync(java.lang.String provider)
public RequestToken fetchLinkedSocialNetworks(int flags, BaasHandler<JsonArray> handler)
public RequestToken fetchLinkedSocialNetworks(BaasHandler<JsonArray> handler)
public BaasResult<JsonArray> fetchLinkedSocialNetworksSync()
public static BaasResult<java.lang.Void> requestPasswordResetSync(java.lang.String username)
public static RequestToken requestPaswordReset(java.lang.String username, BaasHandler<java.lang.Void> handler)
public static RequestToken requestPasswordReset(java.lang.String username, int flags, BaasHandler<java.lang.Void> handler)
public static RequestToken fetch(java.lang.String username, BaasHandler<BaasUser> handler)
BaasUser
from the server
given it's username.username
- a non empty usernamehandler
- an handler to be invoked when the request completesRequestToken
to manage the requestpublic static BaasUser withUserName(java.lang.String username)
BaasUser.current()
is returned.username
- a non empty usernameBaasUser
public RequestToken refresh(BaasHandler<BaasUser> handler)
public static RequestToken fetch(java.lang.String username, int flags, BaasHandler<BaasUser> handler)
BaasUser
from the server
given it's usernameusername
- a non empty usernameflags
- RequestOptions
handler
- an handler to be invoked when the request completesRequestToken
to manage the requestpublic RequestToken refresh(int flags, BaasHandler<BaasUser> handler)
public static BaasResult<BaasUser> fetchSync(java.lang.String username)
public BaasResult<BaasUser> refreshSync()
public static BaasResult<java.util.List<BaasUser>> fetchAllSync()
public static BaasResult<java.util.List<BaasUser>> fetchAllSync(BaasQuery.Criteria filter)
public static RequestToken fetchAll(BaasHandler<java.util.List<BaasUser>> handler)
handler
- an handler to be invoked upon completion of the requestRequestToken
to manage the requestpublic static RequestToken fetchAll(BaasQuery.Criteria filter, BaasHandler<java.util.List<BaasUser>> handler)
filter
- an optional filter to apply to the requesthandler
- an handler to be invoked upon completion of the requestRequestToken
to manage the requestpublic static RequestToken fetchAll(BaasQuery.Criteria filter, int flags, BaasHandler<java.util.List<BaasUser>> handler)
flags
- RequestOptions
handler
- an handler to be invoked upon completion of the requestRequestToken
to manage the requestpublic java.lang.String getPassword()
String
representing the password of the user.public java.lang.String getSignupDate()
public java.lang.String getStatus()
public java.lang.String toString()
toString
in class java.lang.Object
public int describeContents()
describeContents
in interface android.os.Parcelable
public void writeToParcel(android.os.Parcel dest, int flags)
writeToParcel
in interface android.os.Parcelable
public RequestToken changePassword(java.lang.String password, BaasHandler<java.lang.Void> handler)
public RequestToken changePassword(java.lang.String password, int flags, BaasHandler<java.lang.Void> handler)
public BaasResult<java.lang.Void> changePasswordSync(java.lang.String password)
public RequestToken follow(BaasHandler<BaasUser> handler)
handler
- an handler to be invoked when the request completesRequestToken
to manage the requestpublic RequestToken follow(int flags, BaasHandler<BaasUser> handler)
flags
- RequestOptions
handler
- an handler to be invoked when the request completesRequestToken
to manage the requestpublic BaasResult<BaasUser> followSync()
public RequestToken followers(BaasHandler<java.util.List<BaasUser>> handler)
public RequestToken followers(BaasQuery.Criteria filter, BaasHandler<java.util.List<BaasUser>> handler)
public RequestToken followers(BaasQuery.Criteria filter, int flags, BaasHandler<java.util.List<BaasUser>> handler)
public boolean isCurrent()
this == BaasUser.current()
public java.lang.String getName()
public BaasResult<java.util.List<BaasUser>> followersSync()
public BaasResult<java.util.List<BaasUser>> followersSync(BaasQuery.Criteria filter)
public RequestToken following(BaasHandler<java.util.List<BaasUser>> handler)
public RequestToken following(BaasQuery.Criteria filter, BaasHandler<java.util.List<BaasUser>> handler)
public RequestToken following(BaasQuery.Criteria filter, int flags, BaasHandler<java.util.List<BaasUser>> handler)
public BaasResult<java.util.List<BaasUser>> followingSync()
public BaasResult<java.util.List<BaasUser>> followingSync(BaasQuery.Criteria filter)
public java.util.Set<java.lang.String> getRoles()
Set
of role namespublic JsonObject getScope(BaasUser.Scope scope)
JsonObject
.
If the data is not visible to the current logged in user
returns null.
The returned JsonObject
should be treated
as read-only unless the user to whom belongs is the current user as per BaasUser.isCurrent()
.scope
- a scope BaasUser.Scope
not null
JsonObject
or null if the data is not visible.java.lang.NullPointerException
- if scope
is null
public java.lang.String getToken()
public boolean hasRole(java.lang.String role)
role
- a role namerole
java.lang.NullPointerException
- if role
is null
public RequestToken login(BaasHandler<BaasUser> handler)
handler
- an handler to be invoked when the request completesRequestToken
to handle the async requestpublic RequestToken login(java.lang.String registrationId, BaasHandler<BaasUser> handler)
registrationId
- a registration id for gcmhandler
- an handler to be invoked when the request completesRequestToken
to handle the async requestpublic RequestToken login(java.lang.String regitrationId, int flags, BaasHandler<BaasUser> handler)
regitrationId
- the registrationIdflags
- RequestOptions
handler
- an handler to be invoked when the request completesRequestToken
to handle the async requestpublic BaasResult<BaasUser> loginSync()
public BaasResult<BaasUser> loginSync(java.lang.String registrationId)
registrationId
- a registration id for gcmpublic RequestToken logout(BaasHandler<java.lang.Void> handler)
BaasUser.current()
will return null
.handler
- an handler to be invoked upon completion of the requestRequestToken
to handle the async requestpublic RequestToken logout(java.lang.String registration, BaasHandler<java.lang.Void> handler)
BaasUser.current()
will return null
.
And on this device the user will not receive any new message from google cloud messaging.registration
- a registration id to removehandler
- an handler to be invoked upon completion of the requestRequestToken
to handle the async requestpublic RequestToken logout(java.lang.String registration, int flags, BaasHandler<java.lang.Void> handler)
BaasUser.current()
will return null
.
And on this device the user will not receive any new message from google cloud messaging.registration
- a registration id to removeflags
- RequestOptions
handler
- an handler to be invoked upon completion of the requestRequestToken
to handle the async requestpublic BaasResult<java.lang.Void> logoutSync()
public BaasResult<java.lang.Void> logoutSync(java.lang.String registration)
registration
- a registration id to removepublic RequestToken save(BaasHandler<BaasUser> handler)
handler
- an handler to be invoked when the request completesDownloadManager.Request
to handle the requestpublic RequestToken save(int flags, BaasHandler<BaasUser> handler)
flags
- RequestOptions
handler
- an handler to be invoked when the request completesRequestToken
to handle the async requestpublic BaasResult<BaasUser> saveSync()
public BaasUser setPassword(java.lang.String password)
password
- the passwordpublic RequestToken signup(BaasHandler<BaasUser> handler)
RequestOptions
handler
- an handler to be invoked when the request completesRequestToken
to manage the asynchronous requestpublic RequestToken signup(int flags, BaasHandler<BaasUser> handler)
flags
- RequestOptions
handler
- an handler to be invoked when the request completesRequestToken
to manage the asynchronous requestpublic BaasResult<BaasUser> signupSync()
public RequestToken unfollow(BaasHandler<BaasUser> user)
public RequestToken unfollow(int flags, BaasHandler<BaasUser> handler)
flags
- RequestOptions
handler
- an handler to be invoked when the request completesRequestToken
to manage the requestpublic BaasResult<BaasUser> unfollowSync()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object