Examples of DropboxResult


Examples of org.apache.camel.component.dropbox.dto.DropboxResult

        super(endpoint, configuration);
    }

    @Override
    public void process(Exchange exchange) throws Exception {
        DropboxResult result = DropboxAPIFacade.getInstance(configuration.getClient())
                .del(configuration.getRemotePath());
        result.populateExchange(exchange);
        log.info("Deleted: " + configuration.getRemotePath());

    }
View Full Code Here

Examples of org.apache.camel.component.dropbox.dto.DropboxResult

        super(endpoint, configuration);
    }

    @Override
    public void process(Exchange exchange) throws Exception {
        DropboxResult result = DropboxAPIFacade.getInstance(configuration.getClient())
                .move(configuration.getRemotePath(), configuration.getNewRemotePath());
        result.populateExchange(exchange);
        log.info("Moved from " + configuration.getRemotePath() + " to " + configuration.getNewRemotePath());
    }
View Full Code Here

Examples of org.apache.camel.component.dropbox.dto.DropboxResult

        super(endpoint, configuration);
    }

    @Override
    public void process(Exchange exchange) throws Exception {
        DropboxResult result = DropboxAPIFacade.getInstance(configuration.getClient())
                .get(configuration.getRemotePath());
        result.populateExchange(exchange);
        LOG.info("producer --> downloaded: " + result.toString());

    }
View Full Code Here

Examples of org.apache.camel.component.dropbox.dto.DropboxResult

        super(endpoint, configuration);
    }

    @Override
    public void process(Exchange exchange) throws Exception {
        DropboxResult result = DropboxAPIFacade.getInstance(configuration.getClient())
                .search(configuration.getRemotePath(), configuration.getQuery());
        result.populateExchange(exchange);
    }
View Full Code Here

Examples of org.apache.camel.component.dropbox.dto.DropboxResult

        super(endpoint, configuration);
    }

    @Override
    public void process(Exchange exchange) throws Exception {
        DropboxResult result = DropboxAPIFacade.getInstance(configuration.getClient())
                .put(configuration.getLocalPath(), configuration.getRemotePath(), configuration.getUploadMode());
        result.populateExchange(exchange);
        LOG.info("Uploaded: " + result.toString());

    }
View Full Code Here

Examples of org.apache.camel.component.dropbox.dto.DropboxResult

     * @throws Exception
     */
    @Override
    protected int poll() throws Exception {
        Exchange exchange = endpoint.createExchange();
        DropboxResult result = DropboxAPIFacade.getInstance(configuration.getClient())
                .search(configuration.getRemotePath(), configuration.getQuery());
        result.populateExchange(exchange);
        LOG.info("consumer --> downloaded: " + result.toString());

        try {
            // send message to next processor in the route
            getProcessor().process(exchange);
            return 1; // number of messages polled
View Full Code Here

Examples of org.apache.camel.component.dropbox.dto.DropboxResult

     * @throws Exception
     */
    @Override
    protected int poll() throws Exception {
        Exchange exchange = endpoint.createExchange();
        DropboxResult result = DropboxAPIFacade.getInstance(configuration.getClient())
                .get(configuration.getRemotePath());
        result.populateExchange(exchange);
        LOG.info("consumer --> downloaded: " + result.toString());

        try {
            // send message to next processor in the route
            getProcessor().process(exchange);
            return 1; // number of messages polled
View Full Code Here

Examples of org.apache.camel.component.dropbox.dto.DropboxResult

     *             in case of "force" the file already existing with the same name will be overridden.
     * @return a DropboxResult object reporting for each remote path the result of the operation.
     * @throws DropboxException
     */
    public DropboxResult put(String localPath, String remotePath, DropboxUploadMode mode) throws DropboxException {
        DropboxResult result = new DropboxFileUploadResult();
        //a map representing for each path the result of the put operation
        Map<String, DropboxResultCode> resultEntries = null;
        //in case the remote path is not specified, the remotePath = localPath
        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();
                if (!localPath.endsWith("/")) {
                    indexRemainingPath += 1;
                }
                String remainingPath = absPath.substring(indexRemainingPath);
                dropboxPath = dropboxPath + remainingPath;
                try {
                    LOG.info("uploading:" + fileLocalPath + "," + dropboxPath);
                    DbxEntry.File uploadedFile = putSingleFile(file, dropboxPath, mode);
                    if (uploadedFile == null) {
                        resultEntries.put(dropboxPath, DropboxResultCode.KO);
                    } else {
                        resultEntries.put(dropboxPath, DropboxResultCode.OK);
                    }
                } catch (Exception ex) {
                    resultEntries.put(dropboxPath, DropboxResultCode.KO);
                }
                dropboxPath = oldDropboxPath;
            }
            result.setResultEntries(resultEntries);
            return result;
        }
    }
View Full Code Here

Examples of org.apache.camel.component.dropbox.dto.DropboxResult

     * @param query a space-separated list of substrings to search for. A file matches only if it contains all the substrings
     * @return a DropboxResult object containing all the files found.
     * @throws DropboxException
     */
    public DropboxResult search(String remotePath, String query) throws DropboxException {
        DropboxResult result = new DropboxSearchResult();
        DbxEntry.WithChildren listing = null;
        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.dto.DropboxResult

     * @param remotePath  the remote location to delete
     * @return a DropboxResult object with the result of the delete operation.
     * @throws 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.