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


Java DbxException.getMessage方法代码示例

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


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

示例1: download

import com.dropbox.core.DbxException; //导入方法依赖的package包/类
/**
 * Download file from Dropbox and store it to a local file.
 */
public VersionedRook download(Uri repoUri, Uri uri, File localFile) throws IOException {
    linkedOrThrow();

    OutputStream out = new BufferedOutputStream(new FileOutputStream(localFile));

    try {
        Metadata pathMetadata = dbxClient.files().getMetadata(uri.getPath());

        if (pathMetadata instanceof FileMetadata) {
            FileMetadata metadata = (FileMetadata) pathMetadata;

            String rev = metadata.getRev();
            long mtime = metadata.getServerModified().getTime();

            dbxClient.files().download(metadata.getPathLower(), rev).download(out);

            return new VersionedRook(repoUri, uri, rev, mtime);

        } else {
            throw new IOException("Failed downloading Dropbox file " + uri + ": Not a file");
        }

    } catch (DbxException e) {
        if (e.getMessage() != null) {
            throw new IOException("Failed downloading Dropbox file " + uri + ": " + e.getMessage());
        } else {
            throw new IOException("Failed downloading Dropbox file " + uri + ": " + e.toString());
        }
    } finally {
        out.close();
    }
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:36,代码来源:DropboxClient.java

示例2: delete

import com.dropbox.core.DbxException; //导入方法依赖的package包/类
public void delete(String path) throws IOException {
    linkedOrThrow();

    try {
        dbxClient.files().delete(path);

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

        if (e.getMessage() != null) {
            throw new IOException("Failed deleting " + path + " on Dropbox: " + e.getMessage());
        } else {
            throw new IOException("Failed deleting " + path + " on Dropbox: " + e.toString());
        }
    }
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:17,代码来源:DropboxClient.java

示例3: upload

import com.dropbox.core.DbxException; //导入方法依赖的package包/类
/** Upload file to Dropbox. */
public VersionedRook upload(File file, Uri repoUri, String fileName) throws IOException {
    linkedOrThrow();

    Uri bookUri = repoUri.buildUpon().appendPath(fileName).build();

    if (file.length() > UPLOAD_FILE_SIZE_LIMIT * 1024 * 1024) {
        throw new IOException(LARGE_FILE);
    }

    FileMetadata metadata;
    InputStream in = new FileInputStream(file);

    try {
        metadata = dbxClient.files()
                .uploadBuilder(bookUri.getPath())
                .withMode(WriteMode.OVERWRITE)
                .uploadAndFinish(in);

    } catch (DbxException e) {
        if (e.getMessage() != null) {
            throw new IOException("Failed overwriting " + bookUri.getPath() + " on Dropbox: " + e.getMessage());
        } else {
            throw new IOException("Failed overwriting " + bookUri.getPath() + " on Dropbox: " + e.toString());
        }
    }

    String rev = metadata.getRev();
    long mtime = metadata.getServerModified().getTime();

    return new VersionedRook(repoUri, bookUri, rev, mtime);
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:33,代码来源:DropboxClient.java

示例4: getBooks

import com.dropbox.core.DbxException; //导入方法依赖的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


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