@BoxResourceType(value="user") 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.
|
BoxCollaborator.CollaboratorType, BoxCollaborator.GroupType
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...) . |
static URLTemplate |
EMAIL_ALIAS_URL_TEMPLATE
E-Mail Alias URL Template.
|
static URLTemplate |
EMAIL_ALIASES_URL_TEMPLATE
E-Mail Aliases URL Template.
|
static URLTemplate |
GET_ME_URL
Get Me URL Template.
|
static URLTemplate |
MOVE_FOLDER_TO_USER_TEMPLATE
Move Folder To User Template.
|
static URLTemplate |
USER_AVATAR_TEMPLATE
User Avatar Template.
|
static URLTemplate |
USER_MEMBERSHIPS_URL_TEMPLATE
User Memberships URL Template.
|
static URLTemplate |
USER_URL_TEMPLATE
User URL Template.
|
static URLTemplate |
USERS_URL_TEMPLATE
Users URL Template.
|
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.
|
EmailAlias |
addEmailAlias(String email,
boolean isConfirmed)
Adds a new email alias to this user's account and confirms it without user interaction.
|
static BoxUser.Info |
createAppUser(BoxAPIConnection api,
String name,
CreateUserParams params,
String... fields)
Provisions a new app user in an enterprise with additional user information using Box Developer Edition.
|
static BoxUser.Info |
createAppUser(BoxAPIConnection api,
String name,
String... fields)
Provisions a new app user in an enterprise using Box Developer Edition.
|
static BoxUser.Info |
createEnterpriseUser(BoxAPIConnection api,
String login,
String name,
CreateUserParams params,
String... fields)
Provisions a new user in an enterprise with additional user information.
|
static BoxUser.Info |
createEnterpriseUser(BoxAPIConnection api,
String login,
String name,
String... fields)
Provisions a new user in an enterprise.
|
void |
delete()
Deletes a user from an enterprise account.
|
void |
delete(boolean notifyUser,
boolean force)
Deletes a user from an enterprise account.
|
void |
deleteAvatar()
Removes avatar from user account.
|
void |
deleteEmailAlias(String emailAliasID)
Deletes an email alias from this user's account.
|
void |
downloadAvatar(OutputStream outputStream)
Writes avatar into specified
OutputStream |
static Iterable<BoxUser.Info> |
getAllEnterpriseOrExternalUsers(BoxAPIConnection api,
String filterTerm,
boolean usemarker,
String marker,
String... fields)
Gets any managed users that match the filter term as well as any external users that
match the filter term.
|
static Iterable<BoxUser.Info> |
getAllEnterpriseOrExternalUsers(BoxAPIConnection api,
String filterTerm,
String... fields)
Gets any managed users that match the filter term as well as any external users that
match the filter term.
|
static Iterable<BoxUser.Info> |
getAllEnterpriseUsers(BoxAPIConnection api)
Returns an iterable containing all the enterprise users.
|
static Iterable<BoxUser.Info> |
getAllEnterpriseUsers(BoxAPIConnection api,
boolean usemarker,
String marker)
Returns an iterable containing all the enterprise users.
|
static Iterable<BoxUser.Info> |
getAllEnterpriseUsers(BoxAPIConnection api,
String filterTerm,
boolean usemarker,
String marker,
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 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.
|
Iterable<BoxGroupMembership.Info> |
getAllMemberships(String... fields)
Gets information about all of the group memberships for this user as iterable with paging support.
|
static Iterable<BoxUser.Info> |
getAppUsersByExternalAppUserID(BoxAPIConnection api,
String externalAppUserId,
boolean usemarker,
String marker,
String... fields)
Gets any app users that has an exact match with the externalAppUserId term using marker based pagination.
|
static Iterable<BoxUser.Info> |
getAppUsersByExternalAppUserID(BoxAPIConnection api,
String externalAppUserId,
String... fields)
Gets any app users that has an exact match with the externalAppUserId term.
|
InputStream |
getAvatar()
Deprecated.
This method loads whole avatar image to memory.
Use
downloadAvatar(OutputStream) to store avatar in file or memory.
That method uses very small buffer to store bytes in memory. |
static BoxUser |
getCurrentUser(BoxAPIConnection api)
Gets the current user.
|
Collection<EmailAlias> |
getEmailAliases()
Gets a collection of all the email aliases for this user.
|
static Iterable<BoxUser.Info> |
getExternalUsers(BoxAPIConnection api,
String filterTerm,
boolean usemarker,
String marker,
String... fields)
Gets a limited set of information about an external user.
|
static Iterable<BoxUser.Info> |
getExternalUsers(BoxAPIConnection api,
String filterTerm,
String... fields)
Gets a limited set of information about an external 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 |
transferContent(String destinationUserID)
Moves all the owned content from within one user’s folder into a new folder in another user's account.
|
void |
updateInfo(BoxUser.Info info,
String... fields)
Updates the information about this user with any info fields that have been modified locally.
|
AvatarUploadResponse |
uploadAvatar(File file)
Upload avatar image to user account.
|
AvatarUploadResponse |
uploadAvatar(File file,
ProgressListener progressListener)
Upload avatar image to user account.
|
AvatarUploadResponse |
uploadAvatar(InputStream content,
String fileName)
Upload avatar image to user account.
|
AvatarUploadResponse |
uploadAvatar(InputStream content,
String fileName,
ProgressListener progressListener)
Upload avatar image to user account.
|
equals, getAPI, getID, getResourceType, hashCode
public static final String[] ALL_FIELDS
getInfo(String...)
.public static final URLTemplate USER_URL_TEMPLATE
public static final URLTemplate GET_ME_URL
public static final URLTemplate USERS_URL_TEMPLATE
public static final URLTemplate USER_MEMBERSHIPS_URL_TEMPLATE
public static final URLTemplate EMAIL_ALIAS_URL_TEMPLATE
public static final URLTemplate EMAIL_ALIASES_URL_TEMPLATE
public static final URLTemplate MOVE_FOLDER_TO_USER_TEMPLATE
public static final URLTemplate USER_AVATAR_TEMPLATE
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, String... fields)
api
- the API connection to be used by the created user.name
- the name of the user.fields
- the fields to retrieve. Leave this out for the standard fields.public static BoxUser.Info createAppUser(BoxAPIConnection api, String name, CreateUserParams params, String... fields)
api
- the API connection to be used by the created user.name
- the name of the user.params
- additional user information.fields
- the fields to retrieve. Leave this out for the standard fields.public static BoxUser.Info createEnterpriseUser(BoxAPIConnection api, String login, String name, String... fields)
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.fields
- the fields to retrieve. Leave this out for the standard fields.public static BoxUser.Info createEnterpriseUser(BoxAPIConnection api, String login, String name, CreateUserParams params, String... fields)
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.fields
- the fields to retrieve. Leave this out for the standard fields.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, boolean usemarker, String marker)
api
- the API connection to be used when retrieving the users.usemarker
- Boolean that determines whether to use marker based pagination.marker
- The marker at which the iterator will begin.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 static Iterable<BoxUser.Info> getAllEnterpriseUsers(BoxAPIConnection api, String filterTerm, boolean usemarker, String marker, 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.usemarker
- Boolean that determines whether to use marker based pagination.marker
- The marker at which the iterator will begin.fields
- the fields to retrieve. Leave this out for the standard fields.public static Iterable<BoxUser.Info> getExternalUsers(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 matching the given login.
This does exact match only, so if no filter term is passed in, nothing
will be returned.fields
- the fields to retrieve. Leave this out for the standard fields.public static Iterable<BoxUser.Info> getExternalUsers(BoxAPIConnection api, String filterTerm, boolean usemarker, String marker, String... fields)
api
- the API connection to be used when retrieving the users.filterTerm
- used to filter the results to only users matching the given login.
This does exact match only, so if no filter term is passed in, nothing
will be returned.usemarker
- Boolean that determines whether to use marker based pagination.marker
- The marker at which the iterator will begin.fields
- the fields to retrieve. Leave this out for the standard fields.public static Iterable<BoxUser.Info> getAllEnterpriseOrExternalUsers(BoxAPIConnection api, String filterTerm, String... fields)
api
- the API connection to be used when retrieving the users.filterTerm
- The filter term to lookup users by (login for external, login or name for managed)fields
- the fields to retrieve. Leave this out for the standard fields.public static Iterable<BoxUser.Info> getAllEnterpriseOrExternalUsers(BoxAPIConnection api, String filterTerm, boolean usemarker, String marker, String... fields)
api
- the API connection to be used when retrieving the users.filterTerm
- The filter term to lookup users by (login for external, login or name for managed)usemarker
- Boolean that determines whether to use marker based pagination.marker
- The marker at which the iterator will begin.fields
- the fields to retrieve. Leave this out for the standard fields.public static Iterable<BoxUser.Info> getAppUsersByExternalAppUserID(BoxAPIConnection api, String externalAppUserId, String... fields)
api
- the API connection to be used when retrieving the users.externalAppUserId
- the external app user id that has been set for app userfields
- the fields to retrieve. Leave this out for the standard fields.public static Iterable<BoxUser.Info> getAppUsersByExternalAppUserID(BoxAPIConnection api, String externalAppUserId, boolean usemarker, String marker, String... fields)
api
- the API connection to be used when retrieving the users.externalAppUserId
- the external app user id that has been set for app userusemarker
- Boolean that determines whether to use marker based pagination.marker
- The marker at which the iterator will begin.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 Iterable<BoxGroupMembership.Info> getAllMemberships(String... fields)
fields
- the fields to retrieve.public EmailAlias addEmailAlias(String email)
email
- the email address to add as an alias.public EmailAlias addEmailAlias(String email, boolean isConfirmed)
email
- the email address to add as an alias.isConfirmed
- whether or not the email alias should be automatically confirmed.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 delete()
public void updateInfo(BoxUser.Info info, String... fields)
Note: This method is only available to enterprise admins.
info
- info the updated info.fields
- the fields to retrieve. Leave this out for the standard fields.public BoxFolder.Info transferContent(String destinationUserID)
See also https://developer.box.com/en/reference/put-users-id-folders-id/
destinationUserID
- the user id of the user that you wish to transfer content to.public void downloadAvatar(OutputStream outputStream)
OutputStream
outputStream
- Stream where to write avatar.public InputStream getAvatar()
downloadAvatar(OutputStream)
to store avatar in file or memory.
That method uses very small buffer to store bytes in memory.public AvatarUploadResponse uploadAvatar(File file)
file
- File containg avatar image.public AvatarUploadResponse uploadAvatar(File file, ProgressListener progressListener)
file
- File
containg avatar image.progressListener
- ProgressListener
set if you want to track upload progresspublic AvatarUploadResponse uploadAvatar(InputStream content, String fileName)
content
- InputStream
containing image datafileName
- file name with extention what will be used to determine content typepublic AvatarUploadResponse uploadAvatar(InputStream content, String fileName, ProgressListener progressListener)
content
- InputStream
containing image datafileName
- file name with extention what will be used to determine content typeprogressListener
- ProgressListener
set if you want to track upload progresspublic void deleteAvatar()