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


Java DbxException类代码示例

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


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

import com.dropbox.core.DbxException; //导入依赖的package包/类
@Override
public String createFolder(String parentPath, String newDirName) throws Exception {
    try
    {
        String path = parentPath;
        if (!path.endsWith("/"))
            path = path + "/";
        path = path + newDirName;

        String pathWithoutProtocol = removeProtocol(path);
        dbxClient.files().createFolder(pathWithoutProtocol);

        return path;
    }
    catch (DbxException e) {
        throw convertException(e);
    }
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:19,代码来源:DropboxV2Storage.java

示例3: getFileEntry

import com.dropbox.core.DbxException; //导入依赖的package包/类
@Override
public FileEntry getFileEntry(String filename) throws Exception {
    try
    {
        filename = removeProtocol(filename);
        Log.d("KP2AJ", "getFileEntry(), " +filename);

        //querying root is not supported
        if ((filename.equals("")) || (filename.equals("/")))
            return getRootFileEntry();
        if (filename.endsWith("/"))
            filename = filename.substring(0,filename.length()-1);

        Metadata dbEntry = dbxClient.files().getMetadata(filename);
        return convertToFileEntry(dbEntry);

    } catch (DbxException e) {

        throw convertException(e);
    }
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:22,代码来源:DropboxV2Storage.java

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

示例5: write

import com.dropbox.core.DbxException; //导入依赖的package包/类
@Override
public HttpResponseOutputStream<String> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException {
    try {
        final DbxUserFilesRequests files = new DbxUserFilesRequests(session.getClient());
        final UploadSessionStartUploader start = files.uploadSessionStart();
        new DefaultStreamCloser().close(start.getOutputStream());
        final String sessionId = start.finish().getSessionId();
        if(log.isDebugEnabled()) {
            log.debug(String.format("Obtained session id %s for upload %s", sessionId, file));
        }
        final UploadSessionAppendV2Uploader uploader = open(files, sessionId, 0L);
        return new SegmentingUploadProxyOutputStream(file, status, files, uploader, sessionId);
    }
    catch(DbxException ex) {
        throw new DropboxExceptionMappingService().map("Upload failed.", ex, file);
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:18,代码来源:DropboxWriteFeature.java

示例6: get

import com.dropbox.core.DbxException; //导入依赖的package包/类
@Override
public Space get() throws BackgroundException {
    try {
        final SpaceUsage usage = new DbxUserUsersRequests(session.getClient()).getSpaceUsage();
        final SpaceAllocation allocation = usage.getAllocation();
        if(allocation.isIndividual()) {
            return new Space(usage.getUsed(), allocation.getIndividualValue().getAllocated());
        }
        else if(allocation.isTeam()) {
            return new Space(usage.getUsed(), allocation.getTeamValue().getAllocated());
        }
        return new Space(0L, Long.MAX_VALUE);
    }
    catch(DbxException e) {
        throw new DropboxExceptionMappingService().map("Failure to read attributes of {0}", e,
                new Path(String.valueOf(Path.DELIMITER), EnumSet.of(Path.Type.volume, Path.Type.directory)));
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:19,代码来源:DropboxQuotaFeature.java

示例7: list

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

示例8: toUrl

import com.dropbox.core.DbxException; //导入依赖的package包/类
@Override
public DescriptiveUrlBag toUrl(final Path file) {
    final DescriptiveUrlBag list = new DescriptiveUrlBag();
    if(file.isFile()) {
        try {
            // This link will expire in four hours and afterwards you will get 410 Gone.
            final String link = new DbxUserFilesRequests(session.getClient()).getTemporaryLink(file.getAbsolute()).getLink();
            // Determine expiry time for URL
            final Calendar expiry = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
            expiry.add(Calendar.HOUR, 4);
            list.add(new DescriptiveUrl(URI.create(link), DescriptiveUrl.Type.http,
                    MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Temporary", "S3"))
                            + " (" + MessageFormat.format(LocaleFactory.localizedString("Expires {0}", "S3") + ")",
                            UserDateFormatterFactory.get().getMediumFormat(expiry.getTimeInMillis()))
            ));
        }
        catch(DbxException e) {
            log.warn(String.format("Failure retrieving shared link. %s", e.getMessage()));
        }
    }
    return list;
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:23,代码来源:DropboxUrlProvider.java

示例9: doInBackground

import com.dropbox.core.DbxException; //导入依赖的package包/类
@Override
protected User doInBackground(Void... params) {
    try {
        FullAccount account = mDbxClient.users().getCurrentAccount();
        if (account != null) {
            User user = new User();
            user.email = account.getEmail();
            user.givenName = account.getName().getDisplayName();
            PreferencesUtil.getInstance().setDropboxAccountUserName(user.givenName);
            return user;
        }
    } catch (DbxException e) {
        mException = e;
    }
    return null;
}
 
开发者ID:WorldBank-Transport,项目名称:RoadLab-Pro,代码行数:17,代码来源:GetCurrentAccountTaskDropbox.java

示例10: isFolderAlreadyExists

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

示例11: should_download_file

import com.dropbox.core.DbxException; //导入依赖的package包/类
public void should_download_file() throws ListFolderErrorException, DbxException, FileNotFoundException, IOException, URISyntaxException {
	// GIVEN
	DropboxServiceImpl dboxSvc = assumeDroptboxRequirement();
	String imageOriginPath = getTestImagePath();
	File imageOrigin = new File(imageOriginPath);

	// WHEN
	String downloadTmpFile = dboxSvc.downloadFile("/essaiUpload/image.jpg");
	// THEN
	Assertions.assertThat(downloadTmpFile).isNotNull();
	File tmpFile = new File(downloadTmpFile);
	try {
		boolean contentEquals = FileUtils.contentEquals(tmpFile, imageOrigin);
		Assertions.assertThat(contentEquals).isTrue();
		log.info("{} and (uploaded) tmp file {} are identicals", imageOriginPath, downloadTmpFile);
	} finally {
		tmpFile.setWritable(true);
		tmpFile.delete();
	}
}
 
开发者ID:boly38,项目名称:mongodbdump-java-wrapper,代码行数:21,代码来源:DropboxServiceITest.java

示例12: deleteCommand

import com.dropbox.core.DbxException; //导入依赖的package包/类
private String deleteCommand(IMessage message, OptionSet optionSet) {
    Set<String> nonOptions = optionSet.valuesOf(shareNonOptionSpec).stream().collect(Collectors.toSet());
    if (optionSet.has("?") || nonOptions.isEmpty()) {
        return null;
    }
    StringBuilder response = new StringBuilder();
    for (String arg : nonOptions) {
        if (arg.contains("..")) {
            response.append("File can't contain \"..\"\n");
        } else {
            try {
                Metadata metadata = dropboxService.deleteFile(uploadsDir + arg);
                log.debug("Deleted: {}", metadata);
                response.append(String.format("*Deleted %s*\n", uploadsDir + arg));
            } catch (DbxException e) {
                log.warn("Failed to delete: {}", e.toString());
                response.append(String.format("*Failed to delete %s*\n", uploadsDir + arg));
            }
        }
    }
    return response.toString();
}
 
开发者ID:quanticc,项目名称:ugc-bot-redux,代码行数:23,代码来源:DropboxPresenter.java

示例13: changeAvatar

import com.dropbox.core.DbxException; //导入依赖的package包/类
/**
 * Change a teams avatar
 *
 * @param session       (Resolved)
 * @param multipartFile (Image)
 * @param id            ID of team to change picture
 * @return Response
 * @throws IOException
 */
@UnitOfWork
@RequestMapping(value = "/{id}/avatar", method = RequestMethod.POST)
public ResponseEntity changeAvatar(SessionImpl session,
                                   @AuthedUser User user,
                                   @RequestParam("image") MultipartFile multipartFile,
                                   @PathVariable("id") int id) throws IOException, DbxException {
    UserTeam userTeam = (UserTeam) session.get(UserTeam.class, id);

    if (userTeam == null)
        return new ResponseEntity("Team not found", HttpStatus.NOT_FOUND);

    if (!userTeamService.doesUserHaveAuthorization(user, userTeam))
        return new ResponseEntity("You cannot do that", HttpStatus.FORBIDDEN);

    userTeamService.changeTeamPicture(userTeam, multipartFile.getInputStream());

    return new ResponseEntity("Successfully changed picture", HttpStatus.OK);
}
 
开发者ID:DevWars,项目名称:devwars.tv,代码行数:28,代码来源:UserTeamController.java

示例14: editTeam

import com.dropbox.core.DbxException; //导入依赖的package包/类
/**
 * Change a teams avatar
 *
 * @param id ID of team to edit
 * @return Response
 * @throws IOException
 */
@RequestMapping(value = "/{id}/edit", method = RequestMethod.POST)
@PreAuthorization(minRole = User.Role.ADMIN)
public ResponseEntity editTeam(@AuthedUser User user,
                               @JSONParam("userTeam") UserTeam userTeam,
                               @PathVariable("id") int id) throws IOException, DbxException {

    UserTeam oldUserTeam = (UserTeam) UserTeam.byID(UserTeam.class, id);

    if (oldUserTeam == null)
        return new ResponseEntity("Team not found", HttpStatus.NOT_FOUND);

    userTeamService.editTeam(userTeam);

    return new ResponseEntity(userTeam, HttpStatus.OK);
}
 
开发者ID:DevWars,项目名称:devwars.tv,代码行数:23,代码来源:UserTeamController.java

示例15: changeAvatar

import com.dropbox.core.DbxException; //导入依赖的package包/类
/**
 * Method to change the avatar picture for the signed in user
 *
 * @param image
 * @return
 */
@PreAuthorization(minRole = User.Role.PENDING)
@RequestMapping("/changeavatar")
public ResponseEntity changeAvatar(@AuthedUser User user, @RequestParam("file") MultipartFile image) throws IOException, DbxException {

    if (user.getInventory().getAvatarChanges() < 1) {
        return new ResponseEntity("You must purchase an avatar change before you can do this.", HttpStatus.FORBIDDEN);
    }

    userService.changeProfilePictureForUser(user, image.getInputStream());

    if (user.getInventory().getAvatarChanges() > 0) {
        userService.changeProfilePictureForUser(user, image.getInputStream());
        userService.useAvatarChange(user);
    } else return new ResponseEntity("Not Enough Avatar Changes", HttpStatus.CONFLICT);
    return new ResponseEntity("Successfully change profile picture", HttpStatus.OK);
}
 
开发者ID:DevWars,项目名称:devwars.tv,代码行数:23,代码来源:UserController.java


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