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


Java ListFolderResult.getEntries方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: backup

import com.dropbox.core.v2.files.ListFolderResult; //导入方法依赖的package包/类
protected void backup() throws Exception {
	Time time = new Time();
	time.setToNow();

	String accessToken = DropboxConfig.getToken(mContext);
	if(accessToken == null) {
		return;
	}
	DbxClientV2 client = DropboxConfig.getDbxClient(accessToken);
	if(client == null) {
		return;
	}

	UploadUploader uploader = client.files().upload("/backup_"+time.toMillis(true)+".zip");
	new Exporter(mContext, uploader.getOutputStream()).run();
	uploader.finish();

	// Удаляем старые

	SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
	int numBackups = Integer.parseInt(prefs.getString("num_backups", "20"));
	if(numBackups > 0) {

		ArrayList<String> items = new ArrayList<String>();
		ListFolderResult result = client.files().listFolder("");
		Pattern p = Pattern.compile("^backup_(\\d+)\\.zip$");
		while (true) {
			for (Metadata metadata : result.getEntries()) {
				Matcher m = p.matcher(metadata.getName());
				if(m.matches())
					items.add(metadata.getName());
			}

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

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

		Collections.sort(items, new AlphanumComparator());

		for(int i=0; i<items.size()-numBackups; i++) {
			client.files().deleteV2("/"+items.get(i));
		}
	}
}
 
开发者ID:jwdroid,项目名称:jwdroid,代码行数:48,代码来源:DropboxBackuper.java


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