use of com.box.sdk.BoxAPIException in project camel by apache.
the class BoxCommentsManager method deleteComment.
/**
* Delete comment.
*
* @param commentId
* - the id of comment to delete.
*/
public void deleteComment(String commentId) {
try {
LOG.debug("Deleting comment(id=" + commentId + ")");
if (commentId == null) {
throw new IllegalArgumentException("Parameter 'commentId' can not be null");
}
BoxComment comment = new BoxComment(boxConnection, commentId);
comment.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 BoxCommentsManager method getFileComments.
/**
* Get a list of any comments on this file.
*
* @param fileId
* - the id of file.
* @return The list of comments on this file.
*/
public List<BoxComment.Info> getFileComments(String fileId) {
try {
LOG.debug("Getting comments of file(id=" + fileId + ")");
if (fileId == null) {
throw new IllegalArgumentException("Parameter 'fileId' can not be null");
}
BoxFile file = new BoxFile(boxConnection, fileId);
return file.getComments();
} 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 BoxEventsManager method listen.
/**
* Create an event stream with optional starting initial position and add
* listener that will be notified when an event is received.
*
* @param startingPosition
* - the starting position of the event stream.
* @param listener
* - the listener to add to event stream.
*
* @return The event stream.
*/
public void listen(EventListener listener, Long startingPosition) {
try {
LOG.debug("Listening for events with listener=" + listener + " at startingPosition=" + startingPosition);
if (listener == null) {
LOG.debug("Parameter 'listener' is null: will not listen for events");
return;
}
if (startingPosition != null) {
eventStream = new EventStream(boxConnection, startingPosition);
} else {
eventStream = new EventStream(boxConnection);
}
eventStream.addListener(listener);
eventStream.start();
} 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 deleteFileVersion.
/**
* Delete a file version.
*
* @param fileId
* - the id of file with version to delete.
* @param version
* - the version of file to delete; initial version of file has
* value of <code>0</code>, second version of file is
* <code>1</code> and so on.
*/
public void deleteFileVersion(String fileId, Integer version) {
try {
LOG.debug("Deleting file(id=" + fileId + ", version=" + version + ")");
if (fileId == null) {
throw new IllegalArgumentException("Parameter 'fileId' can not be null");
}
if (version == null) {
throw new IllegalArgumentException("Parameter 'version' can not be null");
}
BoxFile file = new BoxFile(boxConnection, fileId);
List<BoxFileVersion> versions = (List<BoxFileVersion>) file.getVersions();
BoxFileVersion fileVersion = versions.get(version);
fileVersion.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 BoxFilesManager method updateFileMetadata.
/**
* Update the file properties metadata.
*
* @param fileId
* - the id of file to delete.
* @param metadata
* - the new metadata values.
* @return The metadata returned from the server.
*/
public Metadata updateFileMetadata(String fileId, Metadata metadata) {
try {
LOG.debug("Updating metadata for file(id=" + fileId + ")");
if (fileId == null) {
throw new IllegalArgumentException("Parameter 'fileId' can not be null");
}
if (metadata == null) {
throw new IllegalArgumentException("Parameter 'metadata' can not be null");
}
BoxFile file = new BoxFile(boxConnection, fileId);
return file.updateMetadata(metadata);
} catch (BoxAPIException e) {
throw new RuntimeException(String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
}
}
Aggregations