use of com.box.sdk.BoxFolder in project camel by apache.
the class BoxFoldersManager method getFolderInfo.
/**
* Get folder information.
*
* @param folderId
* - the id of folder.
* @param fields
* - the information fields to retrieve; if <code>null</code> all
* information fields are retrieved.
* @return The folder information.
*/
public BoxFolder.Info getFolderInfo(String folderId, String... fields) {
try {
LOG.debug("Getting info for folder(id=" + folderId + ")");
if (folderId == null) {
throw new IllegalArgumentException("Parameter 'folderId' can not be null");
}
BoxFolder folder = new BoxFolder(boxConnection, folderId);
if (fields == null || fields.length == 0) {
return folder.getInfo();
} else {
return folder.getInfo(fields);
}
} 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 getFolder.
/**
* Return the Box folder referenced by <code>path</code>.
*
* @param path
* - Sequence of Box folder names from root folder to returned
* folder.
*
* @return The Box folder referenced by <code>path</code> or
* <code>null</code> if folder is not found.
*/
public BoxFolder getFolder(String... path) {
try {
LOG.debug("Getting folder at path=" + Arrays.toString(path));
BoxFolder folder = BoxFolder.getRootFolder(boxConnection);
if (path == null || path.length == 0) {
// Return root folder if path is null or empty.
return folder;
}
searchPath: for (int folderIndex = 0; folderIndex < path.length; folderIndex++) {
for (BoxItem.Info itemInfo : folder) {
if (itemInfo instanceof BoxFolder.Info && itemInfo.getName().equals(path[folderIndex])) {
folder = (BoxFolder) itemInfo.getResource();
continue searchPath;
}
}
// Failed to find named folder in path: return null
return null;
}
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.BoxFolder in project camel by apache.
the class BoxCollaborationsManager method getFolderCollaborations.
/**
* Get information about all of the collaborations for folder.
*
* @param folderId
* - the id of folder to get collaborations information on.
*
* @return The collection of collaboration information for folder.
*/
public Collection<BoxCollaboration.Info> getFolderCollaborations(String folderId) {
try {
LOG.debug("Getting collaborations for folder(id=" + folderId + ")");
if (folderId == null) {
throw new IllegalArgumentException("Parameter 'folderId' can not be null");
}
BoxFolder folder = new BoxFolder(boxConnection, folderId);
return folder.getCollaborations();
} 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 BoxCollaborationsManagerIntegrationTest method createTestFolder.
private void createTestFolder() throws FileNotFoundException {
BoxFolder rootFolder = BoxFolder.getRootFolder(getConnection());
testFolder = rootFolder.createFolder(CAMEL_TEST_FOLDER).getResource();
}
use of com.box.sdk.BoxFolder in project camel by apache.
the class BoxFilesManagerIntegrationTest method testDeleteFile.
@Test
public void testDeleteFile() throws Exception {
// using String message body for single parameter "fileId"
requestBody("direct://DELETEFILE", testFile.getID());
BoxFolder rootFolder = BoxFolder.getRootFolder(getConnection());
Iterable<BoxItem.Info> it = rootFolder.search("^" + CAMEL_TEST_FILE + "$");
int searchResults = sizeOfIterable(it);
boolean exists = searchResults > 0 ? true : false;
assertEquals("deleteFile exists", false, exists);
LOG.debug("deleteFile: exists? " + exists);
}
Aggregations