use of com.box.sdk.BoxUser in project camel by apache.
the class BoxUsersManager method getUserInfo.
/**
* Get user information.
*
* @param userId
* - the id of user.
* @return The user information.
*/
public BoxUser.Info getUserInfo(String userId) {
try {
LOG.debug("Getting info for user(id=" + userId + ")");
if (userId == null) {
throw new IllegalArgumentException("Parameter 'userId' can not be null");
}
BoxUser user = new BoxUser(boxConnection, userId);
return user.getInfo();
} catch (BoxAPIException e) {
throw new RuntimeException(String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
}
}
use of com.box.sdk.BoxUser in project camel by apache.
the class BoxUsersManager method updateUserInfo.
/**
* Update user information.
*
* @param userId
* - the id of user to update.
* @param info
* - the updated information
* @return The updated user.
*/
public BoxUser updateUserInfo(String userId, BoxUser.Info info) {
try {
LOG.debug("Updating info for user(id=" + userId + ")");
if (userId == null) {
throw new IllegalArgumentException("Parameter 'userId' can not be null");
}
if (info == null) {
throw new IllegalArgumentException("Parameter 'info' can not be null");
}
BoxUser user = new BoxUser(boxConnection, userId);
user.updateInfo(info);
return user;
} catch (BoxAPIException e) {
throw new RuntimeException(String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
}
}
use of com.box.sdk.BoxUser in project camel by apache.
the class BoxGroupsManager method addGroupMembership.
/**
* Add a member to group with the specified role.
*
* @param groupId
* - the id of group.
* @param userId
* - the id of user to be added to group.
* @param role
* - the role of the user in this group. Can be <code>null</code>
* to assign the default role.
* @return The group information.
*/
public BoxGroupMembership addGroupMembership(String groupId, String userId, BoxGroupMembership.Role role) {
try {
LOG.debug("Adding user(id=" + userId + ") as member to group(id=" + groupId + (role == null ? ")" : ") with role=" + role.name()));
if (groupId == null) {
throw new IllegalArgumentException("Parameter 'groupId' can not be null");
}
if (userId == null) {
throw new IllegalArgumentException("Parameter 'userId' can not be null");
}
BoxGroup group = new BoxGroup(boxConnection, groupId);
BoxUser user = new BoxUser(boxConnection, userId);
return group.addMembership(user, role).getResource();
} catch (BoxAPIException e) {
throw new RuntimeException(String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
}
}
use of com.box.sdk.BoxUser in project camel by apache.
the class BoxUsersManager method deleteUser.
/**
* Delete user from an enterprise account.
*
* @param userId
* - the id of user to delete.
* @param notifyUser
* - whether or not to send an email notification to the user
* that their account has been deleted.
* @param force
* - whether or not this user should be deleted even if they
* still own files.
*/
public void deleteUser(String userId, boolean notifyUser, boolean force) {
try {
LOG.debug("Deleting user(id=" + userId + ") notifyUser=" + notifyUser + " force=" + force);
if (userId == null) {
throw new IllegalArgumentException("Parameter 'fileId' can not be null");
}
BoxUser file = new BoxUser(boxConnection, userId);
file.delete(notifyUser, force);
} catch (BoxAPIException e) {
throw new RuntimeException(String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
}
}
use of com.box.sdk.BoxUser in project camel by apache.
the class BoxUsersManager method addUserEmailAlias.
/**
* Add a new email alias to user's account.
*
* @param userId
* - the id of user.
* @param email
* - the email address to add as an alias.
* @return The newly created email alias.
*/
public EmailAlias addUserEmailAlias(String userId, String email) {
try {
LOG.debug("Adding email alias '" + email + "' to user(id=" + userId + ")");
if (userId == null) {
throw new IllegalArgumentException("Parameter 'userId' can not be null");
}
if (email == null) {
throw new IllegalArgumentException("Paramerer 'email' can not be null");
}
BoxUser user = new BoxUser(boxConnection, userId);
return user.addEmailAlias(email);
} catch (BoxAPIException e) {
throw new RuntimeException(String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
}
}
Aggregations