use of com.box.sdk.BoxAPIException 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.BoxAPIException in project camel by apache.
the class BoxCollaborationsManager method deleteCollaboration.
/**
* Delete collaboration.
*
* @param collaborationId
* - the id of comment to change.
* @return The comment with changed message.
*/
public void deleteCollaboration(String collaborationId) {
try {
LOG.debug("Deleting collaboration(id=" + collaborationId + ")");
if (collaborationId == null) {
throw new IllegalArgumentException("Parameter 'collaborationId' can not be null");
}
BoxCollaboration collaboration = new BoxCollaboration(boxConnection, collaborationId);
collaboration.delete();
} 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 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.BoxAPIException in project camel by apache.
the class BoxFilesManager method getFilePreviewLink.
/**
* Get an expiring URL for creating an embedded preview session. The URL
* will expire after 60 seconds and the preview session will expire after 60
* minutes.
*
* @param fileId
* - the id of the file to get preview link on.
* @return The preview link.
*/
public URL getFilePreviewLink(String fileId) {
try {
LOG.debug("Getting preview link for file(id=" + fileId + ")");
if (fileId == null) {
throw new IllegalArgumentException("Parameter 'fileId' can not be null");
}
BoxFile file = new BoxFile(boxConnection, fileId);
return file.getPreviewLink();
} 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 BoxFilesManager method getFileMetadata.
/**
* Gets the file properties metadata.
*
* @param fileId
* - the id of the file to retrieve metadata for.
* @param typeName
* - the metadata template type name; if <code>null</code> the
* global properties template type is used.
* @return The metadata returned from the server.
*/
public Metadata getFileMetadata(String fileId, String typeName) {
try {
LOG.debug("Get metadata for file(id=" + fileId + ")");
if (fileId == null) {
throw new IllegalArgumentException("Parameter 'fileId' can not be null");
}
BoxFile file = new BoxFile(boxConnection, fileId);
if (typeName != null) {
return file.getMetadata(typeName);
} else {
return file.getMetadata();
}
} catch (BoxAPIException e) {
throw new RuntimeException(String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
}
}
Aggregations