Search in sources :

Example 1 with BoxItem

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);
    }
}
Also used : ArrayList(java.util.ArrayList) BoxAPIException(com.box.sdk.BoxAPIException) BoxFolder(com.box.sdk.BoxFolder) BoxItem(com.box.sdk.BoxItem)

Aggregations

BoxAPIException (com.box.sdk.BoxAPIException)1 BoxFolder (com.box.sdk.BoxFolder)1 BoxItem (com.box.sdk.BoxItem)1 ArrayList (java.util.ArrayList)1