* @param query a space-separated list of substrings to search for. A file matches only if it contains all the substrings
* @return a DropboxResult object containing all the files found.
* @throws DropboxException
*/
public DropboxResult search(String remotePath, String query) throws DropboxException {
DropboxResult result = new DropboxSearchResult();
DbxEntry.WithChildren listing = null;
if (query == null) {
LOG.info("search no query");
try {
listing = DropboxAPIFacade.client.getMetadataWithChildren(remotePath);
} catch (DbxException e) {
throw new DropboxException(remotePath + " does not exist or can't obtain metadata");
}
result.setResultEntries(listing.children);
} else {
LOG.info("search by query:" + query);
List<DbxEntry> entries = null;
try {
entries = DropboxAPIFacade.client.searchFileAndFolderNames(remotePath, query);
} catch (DbxException e) {
throw new DropboxException(remotePath + " does not exist or can't obtain metadata");
}
result.setResultEntries(entries);
}
return result;
}