当前位置: 首页>>代码示例>>Java>>正文


Java ListFolderResult类代码示例

本文整理汇总了Java中com.dropbox.core.v2.files.ListFolderResult的典型用法代码示例。如果您正苦于以下问题:Java ListFolderResult类的具体用法?Java ListFolderResult怎么用?Java ListFolderResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ListFolderResult类属于com.dropbox.core.v2.files包,在下文中一共展示了ListFolderResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: list

import com.dropbox.core.v2.files.ListFolderResult; //导入依赖的package包/类
@Override
public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException {
    try {
        final AttributedList<Path> children = new AttributedList<>();
        final String path = directory.isRoot() ? StringUtils.EMPTY : directory.getAbsolute();
        ListFolderResult result;
        this.parse(directory, listener, children, result = new DbxUserFilesRequests(session.getClient()).listFolder(path));
        // If true, then there are more entries available. Pass the cursor to list_folder/continue to retrieve the rest.
        while(result.getHasMore()) {
            this.parse(directory, listener, children, result = new DbxUserFilesRequests(session.getClient())
                    .listFolderContinue(result.getCursor()));
        }
        return children;
    }
    catch(DbxException e) {
        throw new DropboxExceptionMappingService().map(e);
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:19,代码来源:DropboxListService.java

示例2: listFiles

import com.dropbox.core.v2.files.ListFolderResult; //导入依赖的package包/类
public 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);
    }
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:27,代码来源:Dropbox.java

示例3: isFolderAlreadyExists

import com.dropbox.core.v2.files.ListFolderResult; //导入依赖的package包/类
@Override
public boolean isFolderAlreadyExists(String folder) {
    ListFolderResult dropboxFolders = null;
    if (android.os.Build.VERSION.SDK_INT > 9) {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
        try {
            String dir = "/" + folder.substring(0, folder.lastIndexOf("/"));
            dropboxFolders = DropboxClientFactory.getClient().files().listFolder(dir);
        } catch (DbxException e) {
            e.printStackTrace();
        }
    }
    if (dropboxFolders != null) {
        Log.d(TAG, dropboxFolders.toString());
        String s = dropboxFolders.toStringMultiline();
        if (s.contains("/" + folder))
            return true;
    }
    return false;
}
 
开发者ID:WorldBank-Transport,项目名称:RoadLab-Pro,代码行数:22,代码来源:DropboxManager.java

示例4: parse

import com.dropbox.core.v2.files.ListFolderResult; //导入依赖的package包/类
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);
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:12,代码来源:DropboxListService.java

示例5: listFiles

import com.dropbox.core.v2.files.ListFolderResult; //导入依赖的package包/类
/**
 *
 * @param folder folder location
 * @param recursively recursive list flag
 * @return List with file paths
 * @throws DbxException
 */
@Override
public List<String> listFiles(String folder, boolean recursively)
        throws DbxException {
    if (folder.endsWith("/")) {
        folder = folder.substring(0, folder.length() - 1);
    }
    ListFolderResult result = client.files().listFolderBuilder(folder).withRecursive(recursively).start();
    List<String> filepaths = new ArrayList<>();
    result.getEntries().forEach((metadata) -> {
        filepaths.add(metadata.getPathLower());
    });
    return filepaths;
}
 
开发者ID:diakogiannis,项目名称:EasyDropboxFileHandler,代码行数:21,代码来源:FileHandler.java

示例6: dropboxGetFiles

import com.dropbox.core.v2.files.ListFolderResult; //导入依赖的package包/类
public static List<String> dropboxGetFiles(String code) {

        DbxRequestConfig config = new DbxRequestConfig("Media Information Service Configuration");
        DbxClientV2 client = new DbxClientV2(config, code);
        ListFolderResult result = null;
        List<String> elements = new LinkedList<String>();


        try {
            result = client.files().listFolderBuilder("/media").withRecursive(true).start();
            while (true) {
                for (Metadata metadata : result.getEntries()) {
                    if (metadata instanceof FileMetadata) {
                        elements.add(metadata.getName());
                    }
                }

                if (!result.getHasMore()) {
                    break;
                }

                result = client.files().listFolderContinue(result.getCursor());
            }

            //System.out.println(elements.toString());
        } catch (DbxException e) {
            e.printStackTrace();
        }


        return elements;


    }
 
开发者ID:LithiumSR,项目名称:media_information_service,代码行数:35,代码来源:DbxAPIOp.java

示例7: logChangedFiles

import com.dropbox.core.v2.files.ListFolderResult; //导入依赖的package包/类
public void logChangedFiles(final String userId) throws Exception {
    final String accessToken = getTokenAndCheckIsTokenExists(userId);
    final DbxClientV2 client = new DbxClientV2(requestConfig, accessToken);
    final String cursor = userTokenRepository.getValue(CURSORS_HASH_KEY, userId);
    final ListFolderResult listFolderContinue = client.files().listFolderContinue(cursor);
    logChangedFilesOfUser(userId, listFolderContinue);
}
 
开发者ID:zeldan,项目名称:dropbox-webhooks-spring-boot-example,代码行数:8,代码来源:DropboxService.java

示例8: finishAuthAndSaveUserDetails

import com.dropbox.core.v2.files.ListFolderResult; //导入依赖的package包/类
public void finishAuthAndSaveUserDetails(final HttpSession session, final Map<String, String[]> parameterMap) throws Exception {
    final DbxSessionStore csrfTokenStore = new DbxStandardSessionStore(session, dropboxConfigProp.getSessionStore().getKey());
    final DbxAuthFinish authFinish = auth.finishFromRedirect(dropboxConfigProp.getRedirectUri(), csrfTokenStore, parameterMap);
    final String accessToken = authFinish.getAccessToken();
    final DbxClientV2 client = new DbxClientV2(requestConfig, accessToken);
    final String userId = authFinish.getUserId();
    final ListFolderResult listFolderResult = client.files().listFolderBuilder("").withRecursive(true).start();
    saveAccessTokenAndActualCursor(userId, accessToken, listFolderResult);
}
 
开发者ID:zeldan,项目名称:dropbox-webhooks-spring-boot-example,代码行数:10,代码来源:DropboxService.java

示例9: logChangedFilesOfUser

import com.dropbox.core.v2.files.ListFolderResult; //导入依赖的package包/类
private void logChangedFilesOfUser(final String userId, final ListFolderResult listFolderContinue) {
    boolean hasMore = true;
    while (hasMore) {
        for (final Metadata md : listFolderContinue.getEntries()) {
            LOG.info("Changed metadata: '{}'", md);
        }
        hasMore = listFolderContinue.getHasMore();
    }
    userTokenRepository.setValue(CURSORS_HASH_KEY, userId, listFolderContinue.getCursor());
}
 
开发者ID:zeldan,项目名称:dropbox-webhooks-spring-boot-example,代码行数:11,代码来源:DropboxService.java

示例10: onPostExecute

import com.dropbox.core.v2.files.ListFolderResult; //导入依赖的package包/类
@Override
protected void onPostExecute(ListFolderResult result) {
    super.onPostExecute(result);

    if (mException != null) {
        mCallback.onError(mException);
    } else {
        mCallback.onDataLoaded(result);
    }
}
 
开发者ID:dropbox,项目名称:dropbox-sdk-java,代码行数:11,代码来源:ListFolderTask.java

示例11: doInBackground

import com.dropbox.core.v2.files.ListFolderResult; //导入依赖的package包/类
@Override
protected ListFolderResult doInBackground(String... params) {
    try {
        return mDbxClient.files().listFolder(params[0]);
    } catch (DbxException e) {
        mException = e;
    }

    return null;
}
 
开发者ID:dropbox,项目名称:dropbox-sdk-java,代码行数:11,代码来源:ListFolderTask.java

示例12: loadData

import com.dropbox.core.v2.files.ListFolderResult; //导入依赖的package包/类
@Override
protected void loadData() {

    final ProgressDialog dialog = new ProgressDialog(this);
    dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    dialog.setCancelable(false);
    dialog.setMessage("Loading");
    dialog.show();

    new ListFolderTask(DropboxClientFactory.getClient(), new ListFolderTask.Callback() {
        @Override
        public void onDataLoaded(ListFolderResult result) {
            dialog.dismiss();

            mFilesAdapter.setFiles(result.getEntries());
        }

        @Override
        public void onError(Exception e) {
            dialog.dismiss();

            Log.e(TAG, "Failed to list folder.", e);
            Toast.makeText(FilesActivity.this,
                    "An error has occurred",
                    Toast.LENGTH_SHORT)
                    .show();
        }
    }).execute(mPath);
}
 
开发者ID:dropbox,项目名称:dropbox-sdk-java,代码行数:30,代码来源:FilesActivity.java

示例13: printChanges

import com.dropbox.core.v2.files.ListFolderResult; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:dropbox,项目名称:dropbox-sdk-java,代码行数:46,代码来源:Main.java

示例14: getBooks

import com.dropbox.core.v2.files.ListFolderResult; //导入依赖的package包/类
public List<VersionedRook> getBooks(Uri repoUri) throws IOException {
    linkedOrThrow();

    List<VersionedRook> list = new ArrayList<>();

    String path = repoUri.getPath();

    /* Fix root path. */
    if (path == null || path.equals("/")) {
        path = ROOT_PATH;
    }

    /* Strip trailing slashes. */
    path = path.replaceAll("/+$", "");

    try {
        if (ROOT_PATH.equals(path) || dbxClient.files().getMetadata(path) instanceof FolderMetadata) {
            /* Get folder content. */
            ListFolderResult result = dbxClient.files().listFolder(path);
            while (true) {
                for (Metadata metadata : result.getEntries()) {
                    if (metadata instanceof FileMetadata) {
                        FileMetadata file = (FileMetadata) metadata;

                        if (BookName.isSupportedFormatFileName(file.getName())) {
                            Uri uri = repoUri.buildUpon().appendPath(file.getName()).build();
                            VersionedRook book = new VersionedRook(
                                    repoUri,
                                    uri,
                                    file.getRev(),
                                    file.getServerModified().getTime());

                            list.add(book);
                        }
                    }
                }

                if (!result.getHasMore()) {
                    break;
                }

                result = dbxClient.files().listFolderContinue(result.getCursor());
            }

        } else {
            throw new IOException("Not a directory: " + repoUri);
        }

    } catch (DbxException e) {
        e.printStackTrace();

        /* If we get NOT_FOUND from Dropbox, just return the empty list. */
        if (e instanceof GetMetadataErrorException) {
            if (((GetMetadataErrorException) e).errorValue.getPathValue() == LookupError.NOT_FOUND) {
                return list;
            }
        }

        throw new IOException("Failed getting the list of files in " + repoUri +
                              " listing " + path + ": " +
                              (e.getMessage() != null ? e.getMessage() : e.toString()));
    }

    return list;
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:66,代码来源:DropboxClient.java

示例15: listFolder

import com.dropbox.core.v2.files.ListFolderResult; //导入依赖的package包/类
public synchronized ListFolderResult listFolder(String path) throws DbxException {
    return client.files().listFolder(path);
}
 
开发者ID:quanticc,项目名称:ugc-bot-redux,代码行数:4,代码来源:DropboxService.java


注:本文中的com.dropbox.core.v2.files.ListFolderResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。