Example usage for org.apache.commons.net.ftp FTPClientConfig setShortMonthNames

List of usage examples for org.apache.commons.net.ftp FTPClientConfig setShortMonthNames

Introduction

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

Prototype

public void setShortMonthNames(String shortMonthNames) 

Source Link

Document

setter for the shortMonthNames property.

Usage

From source file:fr.acxio.tools.agia.ftp.DefaultFtpClientFactory.java

public FTPClient getFtpClient() throws IOException {
    FTPClient aClient = new FTPClient();

    // Debug output
    // aClient.addProtocolCommandListener(new PrintCommandListener(new
    // PrintWriter(System.out), true));

    if (activeExternalIPAddress != null) {
        aClient.setActiveExternalIPAddress(activeExternalIPAddress);
    }//from   w w  w  . j av  a 2  s  . c  om
    if (activeMinPort != null && activeMaxPort != null) {
        aClient.setActivePortRange(activeMinPort, activeMaxPort);
    }
    if (autodetectUTF8 != null) {
        aClient.setAutodetectUTF8(autodetectUTF8);
    }
    if (bufferSize != null) {
        aClient.setBufferSize(bufferSize);
    }
    if (charset != null) {
        aClient.setCharset(charset);
    }
    if (connectTimeout != null) {
        aClient.setConnectTimeout(connectTimeout);
    }
    if (controlEncoding != null) {
        aClient.setControlEncoding(controlEncoding);
    }
    if (controlKeepAliveReplyTimeout != null) {
        aClient.setControlKeepAliveReplyTimeout(controlKeepAliveReplyTimeout);
    }
    if (controlKeepAliveTimeout != null) {
        aClient.setControlKeepAliveTimeout(controlKeepAliveTimeout);
    }
    if (dataTimeout != null) {
        aClient.setDataTimeout(dataTimeout);
    }
    if (defaultPort != null) {
        aClient.setDefaultPort(defaultPort);
    }
    if (defaultTimeout != null) {
        aClient.setDefaultTimeout(defaultTimeout);
    }
    if (fileStructure != null) {
        aClient.setFileStructure(fileStructure);
    }
    if (keepAlive != null) {
        aClient.setKeepAlive(keepAlive);
    }
    if (listHiddenFiles != null) {
        aClient.setListHiddenFiles(listHiddenFiles);
    }
    if (parserFactory != null) {
        aClient.setParserFactory(parserFactory);
    }
    if (passiveLocalIPAddress != null) {
        aClient.setPassiveLocalIPAddress(passiveLocalIPAddress);
    }
    if (passiveNatWorkaround != null) {
        aClient.setPassiveNatWorkaround(passiveNatWorkaround);
    }
    if (proxy != null) {
        aClient.setProxy(proxy);
    }
    if (receieveDataSocketBufferSize != null) {
        aClient.setReceieveDataSocketBufferSize(receieveDataSocketBufferSize);
    }
    if (receiveBufferSize != null) {
        aClient.setReceiveBufferSize(receiveBufferSize);
    }
    if (remoteVerificationEnabled != null) {
        aClient.setRemoteVerificationEnabled(remoteVerificationEnabled);
    }
    if (reportActiveExternalIPAddress != null) {
        aClient.setReportActiveExternalIPAddress(reportActiveExternalIPAddress);
    }
    if (sendBufferSize != null) {
        aClient.setSendBufferSize(sendBufferSize);
    }
    if (sendDataSocketBufferSize != null) {
        aClient.setSendDataSocketBufferSize(sendDataSocketBufferSize);
    }
    if (strictMultilineParsing != null) {
        aClient.setStrictMultilineParsing(strictMultilineParsing);
    }
    if (tcpNoDelay != null) {
        aClient.setTcpNoDelay(tcpNoDelay);
    }
    if (useEPSVwithIPv4 != null) {
        aClient.setUseEPSVwithIPv4(useEPSVwithIPv4);
    }

    if (systemKey != null) {
        FTPClientConfig aClientConfig = new FTPClientConfig(systemKey);
        if (defaultDateFormat != null) {
            aClientConfig.setDefaultDateFormatStr(defaultDateFormat);
        }
        if (recentDateFormat != null) {
            aClientConfig.setRecentDateFormatStr(recentDateFormat);
        }
        if (serverLanguageCode != null) {
            aClientConfig.setServerLanguageCode(serverLanguageCode);
        }
        if (shortMonthNames != null) {
            aClientConfig.setShortMonthNames(shortMonthNames);
        }
        if (serverTimeZoneId != null) {
            aClientConfig.setServerTimeZoneId(serverTimeZoneId);
        }
        aClient.configure(aClientConfig);
    }

    if (LOGGER.isInfoEnabled()) {
        LOGGER.info("Connecting to : {}", host);
    }

    if (port == null) {
        aClient.connect(host);
    } else {
        aClient.connect(host, port);
    }

    int aReplyCode = aClient.getReplyCode();

    if (!FTPReply.isPositiveCompletion(aReplyCode)) {
        aClient.disconnect();
        throw new IOException("Cannot connect to " + host + ". Returned code : " + aReplyCode);
    }

    try {
        if (localPassiveMode) {
            aClient.enterLocalPassiveMode();
        }

        boolean aIsLoggedIn = false;
        if (account == null) {
            aIsLoggedIn = aClient.login(username, password);
        } else {
            aIsLoggedIn = aClient.login(username, password, account);
        }
        if (!aIsLoggedIn) {
            throw new IOException(aClient.getReplyString());
        }
    } catch (IOException e) {
        aClient.disconnect();
        throw e;
    }

    if (fileTransferMode != null) {
        aClient.setFileTransferMode(fileTransferMode);
    }
    if (fileType != null) {
        aClient.setFileType(fileType);
    }

    return aClient;
}

From source file:com.github.carlosrubio.org.apache.tools.ant.taskdefs.optional.net.FTPConfigurator.java

/**
 * configures the supplied FTPClient with the various
 * attributes set in the supplied FTP task.
 * @param client the FTPClient to be configured
 * @param task the FTP task whose attributes are used to
 * configure the client// ww  w. j a va 2 s .com
 * @return the client as configured.
 */
static FTPClient configure(FTPClient client, FTP task) {
    task.log("custom configuration", Project.MSG_VERBOSE);
    FTPClientConfig config;
    String systemTypeKey = task.getSystemTypeKey();
    if (systemTypeKey != null && !"".equals(systemTypeKey)) {
        config = new FTPClientConfig(systemTypeKey);
        task.log("custom config: system key = " + systemTypeKey, Project.MSG_VERBOSE);
    } else {
        config = new FTPClientConfig();
        task.log("custom config: system key = default (UNIX)", Project.MSG_VERBOSE);
    }

    String defaultDateFormatConfig = task.getDefaultDateFormatConfig();
    if (defaultDateFormatConfig != null) {
        config.setDefaultDateFormatStr(defaultDateFormatConfig);
        task.log("custom config: default date format = " + defaultDateFormatConfig, Project.MSG_VERBOSE);
    }

    String recentDateFormatConfig = task.getRecentDateFormatConfig();
    if (recentDateFormatConfig != null) {
        config.setRecentDateFormatStr(recentDateFormatConfig);
        task.log("custom config: recent date format = " + recentDateFormatConfig, Project.MSG_VERBOSE);
    }

    String serverLanguageCodeConfig = task.getServerLanguageCodeConfig();
    if (serverLanguageCodeConfig != null) {
        if (!"".equals(serverLanguageCodeConfig)
                && !FTPClientConfig.getSupportedLanguageCodes().contains(serverLanguageCodeConfig)) {
            throw new BuildException("unsupported language code" + serverLanguageCodeConfig);
        }
        config.setServerLanguageCode(serverLanguageCodeConfig);
        task.log("custom config: server language code = " + serverLanguageCodeConfig, Project.MSG_VERBOSE);
    }

    String serverTimeZoneConfig = task.getServerTimeZoneConfig();
    if (serverTimeZoneConfig != null) {
        config.setServerTimeZoneId(serverTimeZoneConfig);
        task.log("custom config: server time zone ID = " + serverTimeZoneConfig, Project.MSG_VERBOSE);
    }

    String shortMonthNamesConfig = task.getShortMonthNamesConfig();
    if (shortMonthNamesConfig != null) {
        config.setShortMonthNames(shortMonthNamesConfig);
        task.log("custom config: short month names = " + shortMonthNamesConfig, Project.MSG_VERBOSE);
    }
    client.configure(config);
    return client;
}

From source file:org.apache.tools.ant.taskdefs.optional.net.FTPConfigurator.java

/**
 * configures the supplied FTPClient with the various
 * attributes set in the supplied FTP task.
 * @param client the FTPClient to be configured
 * @param task the FTP task whose attributes are used to
 * configure the client//from w  w  w . j  a v  a2  s.  c om
 * @return the client as configured.
 */
static FTPClient configure(FTPClient client, FTPTaskConfig task) {
    task.log("custom configuration", Project.MSG_VERBOSE);
    FTPClientConfig config;
    String systemTypeKey = task.getSystemTypeKey();
    if (systemTypeKey != null && !"".equals(systemTypeKey)) {
        config = new FTPClientConfig(systemTypeKey);
        task.log("custom config: system key = " + systemTypeKey, Project.MSG_VERBOSE);
    } else {
        config = new FTPClientConfig();
        task.log("custom config: system key = default (UNIX)", Project.MSG_VERBOSE);
    }

    String defaultDateFormatConfig = task.getDefaultDateFormatConfig();
    if (defaultDateFormatConfig != null) {
        config.setDefaultDateFormatStr(defaultDateFormatConfig);
        task.log("custom config: default date format = " + defaultDateFormatConfig, Project.MSG_VERBOSE);
    }

    String recentDateFormatConfig = task.getRecentDateFormatConfig();
    if (recentDateFormatConfig != null) {
        config.setRecentDateFormatStr(recentDateFormatConfig);
        task.log("custom config: recent date format = " + recentDateFormatConfig, Project.MSG_VERBOSE);
    }

    String serverLanguageCodeConfig = task.getServerLanguageCodeConfig();
    if (serverLanguageCodeConfig != null) {
        if (!"".equals(serverLanguageCodeConfig)
                && !FTPClientConfig.getSupportedLanguageCodes().contains(serverLanguageCodeConfig)) {
            throw new BuildException("unsupported language code" + serverLanguageCodeConfig);
        }
        config.setServerLanguageCode(serverLanguageCodeConfig);
        task.log("custom config: server language code = " + serverLanguageCodeConfig, Project.MSG_VERBOSE);
    }

    String serverTimeZoneConfig = task.getServerTimeZoneConfig();
    if (serverTimeZoneConfig != null) {
        config.setServerTimeZoneId(serverTimeZoneConfig);
        task.log("custom config: server time zone ID = " + serverTimeZoneConfig, Project.MSG_VERBOSE);
    }

    String shortMonthNamesConfig = task.getShortMonthNamesConfig();
    if (shortMonthNamesConfig != null) {
        config.setShortMonthNames(shortMonthNamesConfig);
        task.log("custom config: short month names = " + shortMonthNamesConfig, Project.MSG_VERBOSE);
    }
    client.configure(config);
    return client;
}