use of com.box.sdk.BoxAPIException in project camel by apache.
the class BoxFilesManager method copyFile.
/**
* Copy file to destination folder while optionally giving it a new name.
*
* @param fileId
* - the id of file to copy.
* @param destinationFolderId
* - the id of the destination folder.
* @param newName
* - the new name for copied file; if <code>newName</code> is
* <code>null</code>, the copied file has same name as the
* original.
* @return The copied file.
*/
public BoxFile copyFile(String fileId, String destinationFolderId, String newName) {
try {
LOG.debug("Copying 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 fileToCopy = new BoxFile(boxConnection, fileId);
BoxFolder destinationFolder = new BoxFolder(boxConnection, destinationFolderId);
if (newName == null) {
return fileToCopy.copy(destinationFolder).getResource();
} else {
return fileToCopy.copy(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 BoxFoldersManager method copyFolder.
/**
* Copy folder to destination folder while optionally giving it a new name.
*
* @param folderId
* - the id of folder to copy.
* @param destinationFolderId
* - the id of the destination folder.
* @param newName
* - the new name for copied folder; if <code>newName</code> is
* <code>null</code>, the copied folder has same name as the
* original.
* @return The copied folder.
*/
public BoxFolder copyFolder(String folderId, String destinationFolderId, String newName) {
try {
LOG.debug("Copying folder(id=" + folderId + ") to destination_folder(id=" + destinationFolderId + ")" + (newName == null ? "" : " with new name '" + newName + "'"));
if (folderId == null) {
throw new IllegalArgumentException("Parameter 'folderId' can not be null");
}
if (destinationFolderId == null) {
throw new IllegalArgumentException("Parameter 'destinationFolderId' can not be null");
}
BoxFolder folderToCopy = new BoxFolder(boxConnection, folderId);
BoxFolder destinationFolder = new BoxFolder(boxConnection, destinationFolderId);
if (newName == null) {
return folderToCopy.copy(destinationFolder).getResource();
} else {
return folderToCopy.copy(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 BoxFoldersManager method updateFolderInfo.
/**
* Update folder information.
*
* @param folderId
* - the id of folder to update.
* @param info
* - the updated information
* @return The updated folder.
*/
public BoxFolder updateFolderInfo(String folderId, BoxFolder.Info info) {
try {
LOG.debug("Updating info for folder(id=" + folderId + ")");
if (folderId == null) {
throw new IllegalArgumentException("Parameter 'folderId' can not be null");
}
if (info == null) {
throw new IllegalArgumentException("Parameter 'info' can not be null");
}
BoxFolder folder = new BoxFolder(boxConnection, folderId);
folder.updateInfo(info);
return folder;
} 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 BoxCommentsManager method getCommentInfo.
/**
* Get comment information.
*
* @param commentId
* - the id of comment.
* @return The comment information.
*/
public BoxComment.Info getCommentInfo(String commentId) {
try {
LOG.debug("Getting info for comment(id=" + commentId + ")");
if (commentId == null) {
throw new IllegalArgumentException("Parameter 'commentId' can not be null");
}
BoxComment comment = new BoxComment(boxConnection, commentId);
return comment.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.BoxAPIException in project camel by apache.
the class BoxCommentsManager method changeCommentMessage.
/**
* Change comment message.
*
* @param commentId
* - the id of comment to change.
* @param message
* - the new message for the comment.
* @return The comment with changed message.
*/
public BoxComment changeCommentMessage(String commentId, String message) {
try {
LOG.debug("Changing comment(id=" + commentId + ") message=" + message);
if (commentId == null) {
throw new IllegalArgumentException("Parameter 'commentId' can not be null");
}
if (message == null) {
throw new IllegalArgumentException("Parameter 'message' can not be null");
}
BoxComment comment = new BoxComment(boxConnection, commentId);
return comment.changeMessage(message).getResource();
} catch (BoxAPIException e) {
throw new RuntimeException(String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
}
}
Aggregations