1 18 package org.apache.tools.ant.taskdefs.optional.net; 19 import org.apache.commons.net.ftp.FTPClient; 20 import org.apache.commons.net.ftp.FTPClientConfig; 21 import org.apache.tools.ant.Project; 22 23 31 class FTPConfigurator { 32 40 static FTPClient configure(FTPClient client, FTP task) { 41 task.log("custom configuration", Project.MSG_VERBOSE); 42 FTPClientConfig config; 43 String systemTypeKey = task.getSystemTypeKey(); 44 if (systemTypeKey != null && !"".equals(systemTypeKey)) { 45 config = new FTPClientConfig(systemTypeKey); 46 task.log("custom config: system key = " 47 + systemTypeKey, Project.MSG_VERBOSE); 48 } else { 49 config = new FTPClientConfig(); 50 task.log("custom config: system key = default (UNIX)", 51 Project.MSG_VERBOSE); 52 } 53 54 String defaultDateFormatConfig = task.getDefaultDateFormatConfig(); 55 if (defaultDateFormatConfig != null) { 56 config.setDefaultDateFormatStr(defaultDateFormatConfig); 57 task.log("custom config: default date format = " 58 + defaultDateFormatConfig, Project.MSG_VERBOSE); 59 } 60 61 String recentDateFormatConfig = task.getRecentDateFormatConfig(); 62 if (recentDateFormatConfig != null) { 63 config.setRecentDateFormatStr(recentDateFormatConfig); 64 task.log("custom config: recent date format = " 65 + recentDateFormatConfig, Project.MSG_VERBOSE); 66 } 67 68 String serverLanguageCodeConfig = task.getServerLanguageCodeConfig(); 69 if (serverLanguageCodeConfig != null) { 70 config.setServerLanguageCode(serverLanguageCodeConfig); 71 task.log("custom config: server language code = " 72 + serverLanguageCodeConfig, Project.MSG_VERBOSE); 73 } 74 75 String serverTimeZoneConfig = task.getServerTimeZoneConfig(); 76 if (serverTimeZoneConfig != null) { 77 config.setServerTimeZoneId(serverTimeZoneConfig); 78 task.log("custom config: server time zone ID = " 79 + serverTimeZoneConfig, Project.MSG_VERBOSE); 80 } 81 82 String shortMonthNamesConfig = task.getShortMonthNamesConfig(); 83 if (shortMonthNamesConfig != null) { 84 config.setShortMonthNames(shortMonthNamesConfig); 85 task.log("custom config: short month names = " 86 + shortMonthNamesConfig, Project.MSG_VERBOSE); 87 } 88 client.configure(config); 89 return client; 90 } 91 } 92 | Popular Tags |