public class BoxUser extends BoxCollaborator
Unless otherwise noted, the methods in this class can throw an unchecked BoxAPIException
(unchecked
meaning that the compiler won't force you to handle it) if an error occurs. If you wish to implement custom error
handling for errors related to the Box REST API, you should capture this exception explicitly.
Modifier and Type | Class and Description |
---|---|
class |
BoxUser.Info
Contains information about a BoxUser.
|
static class |
BoxUser.Role
Enumerates the possible roles that a user can have within an enterprise.
|
static class |
BoxUser.Status
Enumerates the possible statuses that a user's account can have.
|
Modifier and Type | Field and Description |
---|---|
static String[] |
ALL_FIELDS
An array of all possible file fields that can be requested when calling
getInfo(String...) . |
Constructor and Description |
---|
BoxUser(BoxAPIConnection api,
String id)
Constructs a BoxUser for a user with a given ID.
|
Modifier and Type | Method and Description |
---|---|
EmailAlias |
addEmailAlias(String email)
Adds a new email alias to this user's account.
|
static BoxUser.Info |
createAppUser(BoxAPIConnection api,
String name)
Provisions a new app user in an enterprise using Box Developer Edition.
|
static BoxUser.Info |
createAppUser(BoxAPIConnection api,
String name,
CreateUserParams params)
Provisions a new app user in an enterprise with additional user information using Box Developer Edition.
|
static BoxUser.Info |
createEnterpriseUser(BoxAPIConnection api,
String login,
String name)
Provisions a new user in an enterprise.
|
static BoxUser.Info |
createEnterpriseUser(BoxAPIConnection api,
String login,
String name,
CreateUserParams params)
Provisions a new user in an enterprise with additional user information.
|
void |
delete(boolean notifyUser,
boolean force)
Deletes a user from an enterprise account.
|
void |
deleteEmailAlias(String emailAliasID)
Deletes an email alias from this user's account.
|
static Iterable<BoxUser.Info> |
getAllEnterpriseUsers(BoxAPIConnection api)
Returns an iterable containing all the enterprise users.
|
static Iterable<BoxUser.Info> |
getAllEnterpriseUsers(BoxAPIConnection api,
String filterTerm,
String... fields)
Returns an iterable containing all the enterprise users that matches the filter and specifies which child fields
to retrieve from the API.
|
static BoxUser |
getCurrentUser(BoxAPIConnection api)
Gets the current user.
|
Collection<EmailAlias> |
getEmailAliases()
Gets a collection of all the email aliases for this user.
|
BoxUser.Info |
getInfo(String... fields)
Gets information about this user.
|
Collection<BoxGroupMembership.Info> |
getMemberships()
Gets information about all of the group memberships for this user.
|
BoxFolder.Info |
moveFolderToUser(String sourceUserID)
Moves all of the owned content from within one user’s folder into a new folder in another user's account.
|
void |
updateInfo(BoxUser.Info info)
Updates the information about this user with any info fields that have been modified locally.
|
equals, getAPI, getID, hashCode
public static final String[] ALL_FIELDS
getInfo(String...)
.public BoxUser(BoxAPIConnection api, String id)
api
- the API connection to be used by the user.id
- the ID of the user.public static BoxUser.Info createAppUser(BoxAPIConnection api, String name)
api
- the API connection to be used by the created user.name
- the name of the user.public static BoxUser.Info createAppUser(BoxAPIConnection api, String name, CreateUserParams params)
api
- the API connection to be used by the created user.name
- the name of the user.params
- additional user information.public static BoxUser.Info createEnterpriseUser(BoxAPIConnection api, String login, String name)
api
- the API connection to be used by the created user.login
- the email address the user will use to login.name
- the name of the user.public static BoxUser.Info createEnterpriseUser(BoxAPIConnection api, String login, String name, CreateUserParams params)
api
- the API connection to be used by the created user.login
- the email address the user will use to login.name
- the name of the user.params
- additional user information.public static BoxUser getCurrentUser(BoxAPIConnection api)
api
- the API connection of the current user.public static Iterable<BoxUser.Info> getAllEnterpriseUsers(BoxAPIConnection api)
api
- the API connection to be used when retrieving the users.public static Iterable<BoxUser.Info> getAllEnterpriseUsers(BoxAPIConnection api, String filterTerm, String... fields)
api
- the API connection to be used when retrieving the users.filterTerm
- used to filter the results to only users starting with this string in either the name or the
login. Can be null to not filter the results.fields
- the fields to retrieve. Leave this out for the standard fields.public BoxUser.Info getInfo(String... fields)
fields
- the optional fields to retrieve.public Collection<BoxGroupMembership.Info> getMemberships()
Note: This method is only available to enterprise admins.
public EmailAlias addEmailAlias(String email)
email
- the email address to add as an alias.public void deleteEmailAlias(String emailAliasID)
The IDs of the user's email aliases can be found by calling getEmailAliases()
.
emailAliasID
- the ID of the email alias to delete.public Collection<EmailAlias> getEmailAliases()
Note that the user's primary login email is not included in the collection of email aliases.
public void delete(boolean notifyUser, boolean force)
notifyUser
- whether or not to send an email notification to the user that their account has been deleted.force
- whether or not this user should be deleted even if they still own files.public void updateInfo(BoxUser.Info info)
Note: This method is only available to enterprise admins.
info
- info the updated info.public BoxFolder.Info moveFolderToUser(String sourceUserID)
sourceUserID
- the user id of the user whose files will be the source for this operation