use of com.box.sdk.BoxAPIException in project camel by apache.
the class BoxSearchManager method searchFolder.
/**
* Search folder and all descendant folders using the given query.
*
* @param folderId
* - the id of folder searched.
* @param query
* - the search query.
*
* @return A collection of matching items.
*/
public Collection<BoxItem> searchFolder(String folderId, String query) {
try {
LOG.debug("Searching folder(id=" + folderId + ") with query=" + query);
if (folderId == null) {
throw new IllegalArgumentException("Parameter 'folderId' can not be null");
}
if (query == null) {
throw new IllegalArgumentException("Parameter 'query' can not be null");
}
BoxFolder folder = new BoxFolder(boxConnection, folderId);
Collection<BoxItem> results = new ArrayList<BoxItem>();
for (BoxItem.Info info : folder.search(query)) {
results.add((BoxItem) info.getResource());
}
return results;
} 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 deleteTaskAssignment.
// TODO Add this method when BoxTaskAssignment API fixed:
// BoxTaskAssignment.update method currently
// takes BoxTask.Info instead of BoxTaskAssignment.Info
// /**
// * Update task assignment information.
// *
// * @param taskAssignmentId
// * - the id of task assignment.
// * @param info
// * - the updated information
// * @return The updated task assignment.
// */
// public BoxTaskAssignment updateTaskAssignmentInfo(String
// taskAssignmentId, BoxTaskAssignment.Info info) {
// try {
// LOG.debug("Updating info for task(id=" + taskAssignmentId + ")");
// if (taskAssignmentId == null) {
// throw new IllegalArgumentException("Parameter 'taskAssignmentId' can not
// be null");
// }
// if (info == null) {
// throw new IllegalArgumentException("Parameter 'info' can not be null");
// }
//
// BoxTaskAssignment taskAssignment = new BoxTaskAssignment(boxConnection,
// taskAssignmentId);
// taskAssignment.updateInfo(info);
//
// return taskAssignment;
// } catch (BoxAPIException e) {
// throw new RuntimeException(
// String.format("Box API returned the error code %d\n\n%s",
// e.getResponseCode(), e.getResponse()), e);
// }
// }
/**
* Delete task assignment.
*
* @param taskAssignmentId
* - the id of task assignment to delete.
*/
public void deleteTaskAssignment(String taskAssignmentId) {
try {
LOG.debug("Deleting task(id=" + taskAssignmentId + ")");
if (taskAssignmentId == null) {
throw new IllegalArgumentException("Parameter 'taskAssignmentId' can not be null");
}
BoxTaskAssignment taskAssignment = new BoxTaskAssignment(boxConnection, taskAssignmentId);
taskAssignment.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 BoxTasksManager method addFileTask.
/**
* Add task to file.
*
* @param fileId
* - the id of file to add task to.
* @param action
* - the action the task assignee will be prompted to do.
* @param dueAt
* - - the day at which this task is due.
* @param message
* - an optional message to include with the task.
* @return The new task.
*/
public BoxTask addFileTask(String fileId, BoxTask.Action action, Date dueAt, String message) {
try {
LOG.debug("Adding task to file(id=" + fileId + ") to '" + message + "'");
if (fileId == null) {
throw new IllegalArgumentException("Parameter 'fileId' can not be null");
}
if (action == null) {
throw new IllegalArgumentException("Parameter 'action' can not be null");
}
if (dueAt == null) {
throw new IllegalArgumentException("Parameter 'dueAt' can not be null");
}
BoxFile fileToAddTaskOn = new BoxFile(boxConnection, fileId);
return (BoxTask) fileToAddTaskOn.addTask(action, message, dueAt).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 BoxFilesManagerIntegrationTest method testDeleteFileMetadata.
@Test
public void testDeleteFileMetadata() throws Exception {
testFile.createMetadata(new Metadata());
// using String message body for single parameter "fileId"
requestBody("direct://DELETEFILEMETADATA", testFile.getID());
try {
testFile.getMetadata();
} catch (BoxAPIException e) {
if (e.getResponseCode() == 404) {
// Box API should return a
return;
}
}
fail("deleteFileMetadata metadata");
}
Aggregations