Examples of DropboxException


Examples of com.dropbox.client2.exception.DropboxException

                }

                try {
                    post.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
                } catch (UnsupportedEncodingException e) {
                    throw new DropboxException(e);
                }
            }

            req = post;
        }
View Full Code Here

Examples of com.dropbox.client2.exception.DropboxException

            } else {
                // This is from Dropbox, and we shouldn't be getting it
                throw new DropboxParseException(bin);
            }
        } catch (OutOfMemoryError e) {
            throw new DropboxException(e);
        } finally {
            if (bin != null) {
                try {
                    bin.close();
                } catch (IOException e) {
View Full Code Here

Examples of com.dropbox.client2.exception.DropboxException

        } catch (IOException e) {
            // Quite common for network going up & down or the request being
            // cancelled, so don't worry about logging this
            throw new DropboxIOException(e);
        } catch (OutOfMemoryError e) {
            throw new DropboxException(e);
        }
    }
View Full Code Here

Examples of com.dropbox.client2.exception.DropboxException

            // handle errors better.
            super(null);

            HttpEntity entity = response.getEntity();
            if (entity == null) {
                throw new DropboxException("Didn't get entity from HttpResponse");
            }

            // Now set the input stream on FilterInputStream. This will throw
            // an IOException itself if something goes wrong.
            try {
View Full Code Here

Examples of org.apache.camel.component.dropbox.util.DropboxException

        } else if (this.configuration.getOperation() == DropboxOperation.get) {
            return new DropboxGetProducer(this, configuration);
        } else if (this.configuration.getOperation() == DropboxOperation.move) {
            return new DropboxMoveProducer(this, configuration);
        } else {
            throw new DropboxException("operation specified is not valid for producer!");
        }
    }
View Full Code Here

Examples of org.apache.camel.component.dropbox.util.DropboxException

        } else if (this.configuration.getOperation() == DropboxOperation.get) {
            consumer = new DropboxScheduledPollGetConsumer(this, processor, configuration);
            consumer.setDelay(POLL_CONSUMER_DELAY);
            return consumer;
        } else {
            throw new DropboxException("operation specified is not valid for consumer!");
        }
    }
View Full Code Here

Examples of org.apache.camel.component.dropbox.util.DropboxException

    public void createClient() throws DropboxException {
        DbxRequestConfig config =
                new DbxRequestConfig(clientIdentifier, Locale.getDefault().toString());
        DbxClient client = new DbxClient(config, accessToken);
        if (client == null) {
            throw new DropboxException("can't establish a Dropbox conenction!");
        }
        this.client = client;

    }
View Full Code Here

Examples of org.apache.camel.component.dropbox.util.DropboxException

        String dropboxPath = remotePath == null ? localPath : remotePath;
        DbxEntry entry = null;
        try {
            entry = DropboxAPIFacade.client.getMetadata(dropboxPath);
        } catch (DbxException e) {
            throw new DropboxException(dropboxPath + " does not exist or can't obtain metadata");
        }
        File fileLocalPath = new File(localPath);
        //verify uploading of a single file
        if (fileLocalPath.isFile()) {
            //check if dropbox file exists
            if (entry != null && !entry.isFile()) {
                throw new DropboxException(dropboxPath + " exists on dropbox and is not a file!");
            }
            //in case the entry not exists on dropbox check if the filename should be appended
            if (entry == null) {
                if (dropboxPath.endsWith(DROPBOX_FILE_SEPARATOR)) {
                    dropboxPath = dropboxPath + fileLocalPath.getName();
                }
            }
            resultEntries = new HashMap<String, DropboxResultCode>(1);
            try {
                DbxEntry.File uploadedFile = putSingleFile(fileLocalPath, dropboxPath, mode);
                if (uploadedFile == null) {
                    resultEntries.put(dropboxPath, DropboxResultCode.KO);
                } else {
                    resultEntries.put(dropboxPath, DropboxResultCode.OK);
                }

            } catch (Exception ex) {
                resultEntries.put(dropboxPath, DropboxResultCode.KO);
            } finally {
                result.setResultEntries(resultEntries);
            }
            return result;
        } else {       //verify uploading of a list of files inside a dir
            LOG.info("uploading a dir...");
            //check if dropbox folder exists
            if (entry != null && !entry.isFolder()) {
                throw new DropboxException(dropboxPath + " exists on dropbox and is not a folder!");
            }
            if (!dropboxPath.endsWith(DROPBOX_FILE_SEPARATOR)) {
                dropboxPath = dropboxPath + DROPBOX_FILE_SEPARATOR;
            }
            //revert to old path
            String oldDropboxPath = dropboxPath;
            //list all files in a dir
            Collection<File> listFiles = FileUtils.listFiles(fileLocalPath, null, true);
            if (listFiles == null || listFiles.isEmpty()) {
                throw new DropboxException(localPath + " doesn't contain any files");
            }
            resultEntries = new HashMap<String, DropboxResultCode>(listFiles.size());
            for (File file : listFiles) {
                String absPath = file.getAbsolutePath();
                int indexRemainingPath = localPath.length();
View Full Code Here

Examples of org.apache.camel.component.dropbox.util.DropboxException

        if (query == null) {
            LOG.info("search no query");
            try {
                listing = DropboxAPIFacade.client.getMetadataWithChildren(remotePath);
            } catch (DbxException e) {
                throw new DropboxException(remotePath + " does not exist or can't obtain metadata");
            }
            result.setResultEntries(listing.children);
        } else {
            LOG.info("search by query:" + query);
            List<DbxEntry> entries = null;
            try {
                entries = DropboxAPIFacade.client.searchFileAndFolderNames(remotePath, query);
            } catch (DbxException e) {
                throw new DropboxException(remotePath + " does not exist or can't obtain metadata");
            }
            result.setResultEntries(entries);
        }
        return result;
    }
View Full Code Here

Examples of org.apache.camel.component.dropbox.util.DropboxException

    public DropboxResult del(String remotePath) throws DropboxException {
        DropboxResult result = null;
        try {
            DropboxAPIFacade.client.delete(remotePath);
        } catch (DbxException e) {
            throw new DropboxException(remotePath + " does not exist or can't obtain metadata");
        }
        result = new DropboxDelResult();
        result.setResultEntries(remotePath);
        return result;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.