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


Java DbxEntry.WithChildren方法代码示例

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


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

示例1: listFiles

import com.dropbox.core.DbxEntry; //导入方法依赖的package包/类
@Override
public URI[] listFiles(URI uri) {
    DbxEntry.WithChildren dirents = null;
    try {
	dirents = client.getMetadataWithChildren(clean_path(uri));
    } catch(DbxException de) {
	return null;
    }

    if(dirents == null || dirents.children.size() == 0)
	return new URI[]{};
    
    URI[] retval = new URI[dirents.children.size()];
    Iterator<DbxEntry> dirent = dirents.children.iterator();
    int idx = 0;
    while(dirent.hasNext()) {
	DbxEntry entry = dirent.next();
	try {
	    retval[idx++] = new URI("dbx:" + entry.path);
	} catch(URISyntaxException urise) {
	    return null;
	}
    }
    return retval;
}
 
开发者ID:kd0kfo,项目名称:dropboxconnector,代码行数:26,代码来源:Plugin.java

示例2: ls

import com.dropbox.core.DbxEntry; //导入方法依赖的package包/类
public static DbxEntry[] ls(String query, DbxClient client) throws DbxException {
	DbxEntry.WithChildren listing = client.getMetadataWithChildren(query);
       if(listing == null) {
       	return new DbxEntry[]{};
       }
	if(listing.entry.isFile()) {
       	return new DbxEntry[]{listing.entry};
       }
	
	DbxEntry[] dirents = new DbxEntry[listing.children.size()];
	int idx = 0;
	for (DbxEntry child : listing.children) {
           dirents[idx++] = child;
       }
	return dirents;
}
 
开发者ID:kd0kfo,项目名称:dropboxconnector,代码行数:17,代码来源:FileUtils.java

示例3: listFilesAndDirectories

import com.dropbox.core.DbxEntry; //导入方法依赖的package包/类
@Override
public FileInstanceAbstract[] listFilesAndDirectories() throws URISyntaxException, IOException {
	try {
		DbxClient dbxClient = connect();
		DbxEntry.WithChildren entries;
		entries = dbxClient.getMetadataWithChildren(getPath());
		if (entries == null || entries.children == null)
			return null;
		FileInstanceAbstract[] fileInstances = new FileInstanceAbstract[entries.children.size()];
		int i = 0;
		for (DbxEntry entry : entries.children)
			fileInstances[i++] = new DropboxFileInstance(filePathItem, this, entry);
		return fileInstances;
	} catch (DbxException e) {
		throw new IOException(e);
	}
}
 
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:18,代码来源:DropboxFileInstance.java

示例4: getChildren

import com.dropbox.core.DbxEntry; //导入方法依赖的package包/类
@Override
public List<RemoteFile> getChildren(String folderName) throws IOException {
    try {
        ArrayList<RemoteFile> result = new ArrayList<>();

        DbxEntry.WithChildren listing = dbClient.getMetadataWithChildren(folderName);

        if (listing == null) {
            throw new IOException("Folder: " + folderName + " does not exist");
        }

        for (DbxEntry child : listing.children) {
            String path = child.path;
            boolean directory = child.isFolder();

            long size = 0;

            if (!directory) {
                size = child.asFile().numBytes;
            }

            String base = "https://api-content.dropbox.com/1/files/dropbox";

            String url = escapeURL(base, path);

            RemoteFile file = new RemoteFile(path, directory, size, url);

            result.add(file);
        }
        return result;
    } catch (DbxException ex) {
        throw new IOException("Dropbox folder listing error.");
    }
}
 
开发者ID:modcs,项目名称:caboclo,代码行数:35,代码来源:DropboxClient.java

示例5: downloadFolder

import com.dropbox.core.DbxEntry; //导入方法依赖的package包/类
public void downloadFolder(String remotePath, String targetPath, int depth)
		throws CSPException {
	try {
		DbxEntry folder = client.getMetadata(remotePath);
		if (folder.isFolder()) {
			File remoteFolder = new File(remotePath);
			File targetFolder = new File(targetPath + File.separator
					+ remoteFolder.getName());
			if (!targetFolder.exists()) {
				targetFolder.mkdirs();
			}
			DbxEntry.WithChildren folderWithChildren = client
					.getMetadataWithChildren(remotePath);
			for (DbxEntry file : folderWithChildren.children) {
				if (depth >= DropboxConstants.MAX_TREE_SEARCH_DEPTH) {
					break;
				}
				if (file.isFile()) {
					downloadFile(file.path, targetPath + "/" + folder.name
							+ "/" + file.name);
				} else if (file.isFolder()) {
					downloadFolder(file.path, targetPath + "/"
							+ folder.name, depth + 1);
				}
			}
		}
	} catch (DbxException e) {
		e.printStackTrace();
	}
}
 
开发者ID:Rohde-Schwarz-Cybersecurity,项目名称:PanBox,代码行数:31,代码来源:DropboxAPIIntegration.java

示例6: readFolder

import com.dropbox.core.DbxEntry; //导入方法依赖的package包/类
@Override
public List<RemoteItem> readFolder(final Handler handler, final Item parentItem) throws CloudsyncException
{
	initService(handler);

	int retryCount = 0;
	do
	{
		try
		{
			// refreshCredential();

			final List<RemoteItem> child_items = new ArrayList<>();
			Map<String, DbxEntry[]> childContainer = new HashMap<>();
			DbxEntry.WithChildren listing = client.getMetadataWithChildren(buildPath(parentItem));
			for (DbxEntry child : listing.children)
			{
				String[] nameParts = child.name.split("\\.");

				DbxEntry[] entries = childContainer.get(nameParts[0]);
				if (entries == null) entries = new DbxEntry[2];
				if (nameParts.length == 2) entries[1] = child;
				else entries[0] = child;

				childContainer.put(nameParts[0], entries);

			}

			for (final DbxEntry[] childData : childContainer.values())
			{
				child_items.add(_prepareBackupItem(childData, handler));
			}
			return child_items;
		}
		catch (final DbxException e)
		{
			retryCount = validateException("remote fetch", parentItem, e, retryCount);
		}
	}
	while (true);
}
 
开发者ID:HolgerHees,项目名称:cloudsync,代码行数:42,代码来源:RemoteDropboxConnector.java

示例7: dropboxImport

import com.dropbox.core.DbxEntry; //导入方法依赖的package包/类
public void dropboxImport() throws DCMAException {
	DropboxHelper helper = new DropboxHelper(getProperties());
	helper.setPluginName("dcma-dropboximport-plugin");
	DbxClient client = helper.authenticateApp();

	String[] bcs = getBatchClassConfig().split(";");
	for (String batchClassIdentifier : bcs) {

		LOGGER.debug("Importing the batch class " + batchClassIdentifier);

		try {
			String dropboxFolder = getProperty(batchClassIdentifier, "folder");
			String filePattern = getProperty(batchClassIdentifier, "pattern");
			String action = getProperty(batchClassIdentifier, "action");
			String actionName = action.split("\\|")[0];

			LOGGER.debug(" - Dropbox folder: " + dropboxFolder);
			LOGGER.debug(" - File pattern: " + filePattern);

			DbxEntry.WithChildren listing = client.getMetadataWithChildren(dropboxFolder);
			LOGGER.debug(" - Files in the folder:");
			if (listing != null) {
				for (DbxEntry child : listing.children) {
					System.out.println(" -- " + child.name);

					if (child.name.matches(filePattern)) {
						System.out.println(" -- Import file");
						importFilesFromDropbox(child, batchClassIdentifier, client);

						if (actionName.equalsIgnoreCase("moveTo")) {
							String targetFolder = action.split("\\|")[1];
							client.move(child.path, targetFolder + "/" + child.name);
						} else if (actionName.equalsIgnoreCase("delete"))
							client.delete(child.path);

					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
 
开发者ID:bchevallereau,项目名称:ephesoft-extension,代码行数:44,代码来源:DropboxImporter.java


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