Example usage for org.apache.commons.net.ftp FTPSClient getConnectTimeout

List of usage examples for org.apache.commons.net.ftp FTPSClient getConnectTimeout

Introduction

In this page you can find the example usage for org.apache.commons.net.ftp FTPSClient getConnectTimeout.

Prototype

public int getConnectTimeout() 

Source Link

Document

Get the underlying socket connection timeout.

Usage

From source file:org.apache.camel.component.file.remote.FtpsEndpoint.java

@Override
public RemoteFileOperations<FTPFile> createRemoteFileOperations() throws Exception {
    // configure ftp client
    FTPSClient client = getFtpsClient();

    if (client == null) {
        // must use a new client if not explicit configured to use a custom client
        client = (FTPSClient) createFtpClient();
    }/*from   ww  w. j ava  2s.  c o  m*/

    // set any endpoint configured timeouts
    if (getConfiguration().getConnectTimeout() > -1) {
        client.setConnectTimeout(getConfiguration().getConnectTimeout());
    }
    if (getConfiguration().getSoTimeout() > -1) {
        soTimeout = getConfiguration().getSoTimeout();
    }
    dataTimeout = getConfiguration().getTimeout();

    if (ftpClientParameters != null) {
        Map<String, Object> localParameters = new HashMap<String, Object>(ftpClientParameters);
        // setting soTimeout has to be done later on FTPClient (after it has connected)
        Object timeout = localParameters.remove("soTimeout");
        if (timeout != null) {
            soTimeout = getCamelContext().getTypeConverter().convertTo(int.class, timeout);
        }
        // and we want to keep data timeout so we can log it later
        timeout = localParameters.remove("dataTimeout");
        if (timeout != null) {
            dataTimeout = getCamelContext().getTypeConverter().convertTo(int.class, dataTimeout);
        }
        setProperties(client, localParameters);
    }

    if (ftpClientConfigParameters != null) {
        // client config is optional so create a new one if we have parameter for it
        if (ftpClientConfig == null) {
            ftpClientConfig = new FTPClientConfig();
        }
        Map<String, Object> localConfigParameters = new HashMap<String, Object>(ftpClientConfigParameters);
        setProperties(ftpClientConfig, localConfigParameters);
    }

    if (dataTimeout > 0) {
        client.setDataTimeout(dataTimeout);
    }

    if (log.isDebugEnabled()) {
        log.debug("Created FTPSClient [connectTimeout: {}, soTimeout: {}, dataTimeout: {}]: {}",
                new Object[] { client.getConnectTimeout(), getSoTimeout(), dataTimeout, client });
    }

    FtpsOperations operations = new FtpsOperations(client, getFtpClientConfig());
    operations.setEndpoint(this);
    return operations;
}