use of com.box.sdk.BoxFolder in project camel by apache.
the class BoxCollaborationsManager method addFolderCollaboration.
/**
* Add a collaboration to this folder.
*
* @param folderId
* - the id of folder to add collaboration to.
* @param collaborator
* - the collaborator to add.
* @param role
* - the role of the collaborator.
*
* @return The new collaboration.
*/
// compiler for some reason thinks 'if
@SuppressWarnings("unused")
public // (collaborator == null)' clause is dead code.
BoxCollaboration addFolderCollaboration(String folderId, BoxCollaborator collaborator, BoxCollaboration.Role role) {
try {
LOG.debug("Creating collaborations for folder(id=" + folderId + ") with collaborator(" + collaborator.getID() + ")");
if (folderId == null) {
throw new IllegalArgumentException("Parameter 'folderId' can not be null");
}
if (collaborator == null) {
throw new IllegalArgumentException("Parameter 'collaborator' can not be null");
}
if (role == null) {
throw new IllegalArgumentException("Parameter 'role' can not be null");
}
BoxFolder folder = new BoxFolder(boxConnection, folderId);
return folder.collaborate(collaborator, 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.BoxFolder in project camel by apache.
the class BoxCollaborationsManager method addFolderCollaborationByEmail.
/**
* Add a collaboration to this folder. An email will be sent to the
* collaborator if they don't already have a Box account.
*
* @param folderId
* - the id of folder to add collaboration to.
* @param email
* - the email address of the collaborator to add.
* @param role
* - the role of the collaborator.
*
* @return The new collaboration.
*/
public BoxCollaboration addFolderCollaborationByEmail(String folderId, String email, BoxCollaboration.Role role) {
try {
LOG.debug("Creating collaborations for folder(id=" + folderId + ") with collaborator(" + email + ")");
if (folderId == null) {
throw new IllegalArgumentException("Parameter 'folderId' can not be null");
}
if (email == null) {
throw new IllegalArgumentException("Parameter 'email' can not be null");
}
if (role == null) {
throw new IllegalArgumentException("Parameter 'role' can not be null");
}
BoxFolder folder = new BoxFolder(boxConnection, folderId);
return folder.collaborate(email, 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.BoxFolder 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.BoxFolder 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.BoxFolder 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);
}
}
Aggregations