use of com.box.sdk.BoxAPIException in project camel by apache.
the class BoxFilesManager method moveFile.
/**
* Move file to destination folder while optionally giving it a new name.
*
* @param fileId
* - the id of file to move.
* @param destinationFolderId
* - the id of the destination folder.
* @param newName
* - the new name of moved file; if <code>newName</code> is
* <code>null</code>, the moved file has same name as the
* original.
* @return The moved file.
*/
public BoxFile moveFile(String fileId, String destinationFolderId, String newName) {
try {
LOG.debug("Moving file(id=" + fileId + ") to destination_folder(id=" + destinationFolderId + ")" + (newName == null ? "" : " with new name '" + newName + "'"));
if (fileId == null) {
throw new IllegalArgumentException("Parameter 'fileId' can not be null");
}
if (destinationFolderId == null) {
throw new IllegalArgumentException("Parameter 'destinationFolderId' can not be null");
}
BoxFile fileToMove = new BoxFile(boxConnection, fileId);
BoxFolder destinationFolder = new BoxFolder(boxConnection, destinationFolderId);
if (newName == null) {
return (BoxFile) fileToMove.move(destinationFolder).getResource();
} else {
return (BoxFile) fileToMove.move(destinationFolder, newName).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.BoxAPIException in project camel by apache.
the class BoxTasksManager method updateTaskInfo.
/**
* Update task information.
*
* @param taskId
* - the id of task.
* @param info
* - the updated information
* @return The updated task.
*/
public BoxTask updateTaskInfo(String taskId, BoxTask.Info info) {
try {
LOG.debug("Updating info for task(id=" + taskId + ")");
if (taskId == null) {
throw new IllegalArgumentException("Parameter 'taskId' can not be null");
}
if (info == null) {
throw new IllegalArgumentException("Parameter 'info' can not be null");
}
BoxTask task = new BoxTask(boxConnection, taskId);
task.updateInfo(info);
return task;
} 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.BoxAPIException 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.BoxAPIException 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);
}
}
use of com.box.sdk.BoxAPIException in project camel by apache.
the class BoxUsersManager method getUserEmailAlias.
/**
* Get a collection of all the email aliases for user.
*
* @param userId
* - the id of user.
* @return A collection of all the email aliases for user.
*/
public Collection<EmailAlias> getUserEmailAlias(String userId) {
try {
LOG.debug("Get email aliases for user(id=" + userId + ")");
if (userId == null) {
throw new IllegalArgumentException("Parameter 'userId' can not be null");
}
BoxUser user = new BoxUser(boxConnection, userId);
return user.getEmailAliases();
} catch (BoxAPIException e) {
throw new RuntimeException(String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
}
}
Aggregations