Java Code Examples for com.dropbox.core.v2.files.ListFolderResult#getEntries()
The following examples show how to use
com.dropbox.core.v2.files.ListFolderResult#getEntries() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Dropbox.java From financisto with GNU General Public License v2.0 | 6 votes |
List<String> listFiles() throws Exception { if (authSession()) { try { List<String> files = new ArrayList<String>(); ListFolderResult listFolderResult = dropboxClient.files().listFolder(""); for (Metadata metadata : listFolderResult.getEntries()) { String name = metadata.getName(); if (name.endsWith(".backup")) { files.add(name); } } Collections.sort(files, new Comparator<String>() { @Override public int compare(String s1, String s2) { return s2.compareTo(s1); } }); return files; } catch (Exception e) { Log.e("Financisto", "Dropbox: Something wrong", e); throw new ImportExportException(R.string.dropbox_error, e); } } else { throw new ImportExportException(R.string.dropbox_auth_error); } }
Example 2
Source File: DropboxDirectory.java From sling-whiteboard with Apache License 2.0 | 6 votes |
@Override public @NotNull List<RemoteResourceReference> getChildren() { ArrayList<RemoteResourceReference> children = new ArrayList<>(); ListFolderResult result; try { result = client.files().listFolder(metadata.getPathLower()); boolean hasMoreResults = true; while (hasMoreResults) { for (Metadata entry : result.getEntries()) { if (!(entry instanceof DeletedMetadata)) { children.add(new DropboxResourceReference(dropboxStorageProvider, entry)); } } result = client.files().listFolderContinue(result.getCursor()); hasMoreResults = result.getHasMore(); } } catch (ListFolderContinueErrorException e) { LOGGER.error(String.format("Cannot read all children of folder %s.", metadata.getPathLower()), e); } catch ( DbxException ex) { LOGGER.error(String.format("Cannot access path %s on Dropbox.", metadata.getPathLower()), ex); } return children; }
Example 3
Source File: Main.java From dropbox-sdk-java with MIT License | 6 votes |
/** * Prints changes made to a folder in Dropbox since the given * cursor was retrieved. * * @param dbxClient Dropbox client to use for fetching folder changes * @param cursor lastest cursor received since last set of changes * * @return latest cursor after changes */ private static String printChanges(DbxClientV2 client, String cursor) throws DbxApiException, DbxException { while (true) { ListFolderResult result = client.files() .listFolderContinue(cursor); for (Metadata metadata : result.getEntries()) { String type; String details; if (metadata instanceof FileMetadata) { FileMetadata fileMetadata = (FileMetadata) metadata; type = "file"; details = "(rev=" + fileMetadata.getRev() + ")"; } else if (metadata instanceof FolderMetadata) { FolderMetadata folderMetadata = (FolderMetadata) metadata; type = "folder"; details = folderMetadata.getSharingInfo() != null ? "(shared)" : ""; } else if (metadata instanceof DeletedMetadata) { type = "deleted"; details = ""; } else { throw new IllegalStateException("Unrecognized metadata type: " + metadata.getClass()); } System.out.printf("\t%10s %24s \"%s\"\n", type, details, metadata.getPathLower()); } // update cursor to fetch remaining results cursor = result.getCursor(); if (!result.getHasMore()) { break; } } return cursor; }
Example 4
Source File: DropboxListService.java From cyberduck with GNU General Public License v3.0 | 5 votes |
private void parse(final Path directory, final ListProgressListener listener, final AttributedList<Path> children, final ListFolderResult result) throws ConnectionCanceledException { for(Metadata md : result.getEntries()) { final Path child = this.parse(directory, md); if(child == null) { continue; } children.add(child); listener.chunk(directory, children); } }
Example 5
Source File: DbxFileActions.java From Open-LaTeX-Studio with MIT License | 5 votes |
/** * @return List with user's files or empty List if error occurs */ public List<DbxEntryDto> getDbxTexEntries(DbxClientV2 client) { List<DbxEntryDto> dbxEntries = new ArrayList<>(); if (client == null) { return dbxEntries; } try { ListFolderResult result = client.files().listFolderBuilder("").withRecursive(true).start(); while (true) { for (Metadata metadata : result.getEntries()) { if (metadata instanceof FileMetadata) { String name = metadata.getName(); if (name.endsWith(TEX_EXTENSION)) { dbxEntries.add(new DbxEntryDto((FileMetadata) metadata)); } } } if (!result.getHasMore()) { break; } result = client.files().listFolderContinue(result.getCursor()); } } catch (DbxException ex) { DbxUtil.showDbxAccessDeniedPrompt(); dbxEntries = new ArrayList<>(); //Empty list } finally { return dbxEntries; } }