use of com.box.sdk.BoxItem 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);
}
}
Aggregations