Example usage for org.apache.commons.vfs.provider.ftp FtpFileSystemConfigBuilder getInstance

List of usage examples for org.apache.commons.vfs.provider.ftp FtpFileSystemConfigBuilder getInstance

Introduction

In this page you can find the example usage for org.apache.commons.vfs.provider.ftp FtpFileSystemConfigBuilder getInstance.

Prototype

public static FtpFileSystemConfigBuilder getInstance() 

Source Link

Usage

From source file:com.adito.networkplaces.store.ftp.FTPMount.java

public FileSystemOptions getOptions(URI uri) {
    FileSystemOptions options = new FileSystemOptions();
    FtpFileSystemConfigBuilder c = FtpFileSystemConfigBuilder.getInstance();
    String mode = Property.getProperty(new ResourceKey("ftp.mode", this.getNetworkPlace().getResourceType(),
            this.getNetworkPlace().getResourceId()));
    c.setPassiveMode(options, mode.equals("passive"));
    int idleTimeout = Property.getPropertyInt(new ResourceKey("ftp.idleTimeout",
            getNetworkPlace().getResourceType(), getNetworkPlace().getResourceId()));
    //NOTE New Apache-commons-vfs does not support setIdleTimeout(options, idleTimeout)
    //c.setIdleTimeout(options, idleTimeout);
    c.setDataTimeout(options, idleTimeout);
    // TODO: Add resource attribute for all these settings.
    c.setUserDirIsRoot(options, true);/*from   w  ww.j  ava2  s  .com*/
    String hostType = Property.getProperty(new ResourceKey("ftp.hostType",
            this.getNetworkPlace().getResourceType(), this.getNetworkPlace().getResourceId()));
    if (!"automatic".equals(hostType)) {
        c.setEntryParser(options, hostType);
    }
    return options;
}

From source file:org.jumpmind.symmetric.io.FtpDataWriter.java

protected void sendFiles() {
    if (fileInfoByTable.size() > 0) {
        try {//  w  w w  .  j ava  2 s. com
            String sftpUri = buildUri();
            FileSystemOptions opts = new FileSystemOptions();
            FtpFileSystemConfigBuilder.getInstance().setUserDirIsRoot(opts, true);
            SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(opts, "no");
            SftpFileSystemConfigBuilder.getInstance().setTimeout(opts, 60000);

            Collection<FileInfo> fileInfos = fileInfoByTable.values();
            for (FileInfo fileInfo : fileInfos) {
                FileObject fileObject = manager.resolveFile(sftpUri + "/" + fileInfo.outputFile.getName(),
                        opts);
                FileObject localFileObject = manager.resolveFile(fileInfo.outputFile.getAbsolutePath());
                fileObject.copyFrom(localFileObject, Selectors.SELECT_SELF);
                fileObject.close();
            }
        } catch (FileSystemException e) {
            logger.warn(
                    "If you have not configured your ftp connection it should be configured in conf/ftp-extensions.xml");
            throw new IoException(e);
        } catch (Exception e) {
            throw new IoException(e);
        } finally {
            manager.close();
        }
    }
}