Author: sebb
Date: Fri Jun 19 00:07:46 2015
New Revision: 1686344

URL: http://svn.apache.org/r1686344
Log:
NET-576 Allow FTPClient to use SYST response if system type is not specified in 
configuration

Modified:
    commons/proper/net/trunk/src/changes/changes.xml
    
commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java
    
commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClientConfig.java

Modified: commons/proper/net/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/net/trunk/src/changes/changes.xml?rev=1686344&r1=1686343&r2=1686344&view=diff
==============================================================================
--- commons/proper/net/trunk/src/changes/changes.xml [utf-8] (original)
+++ commons/proper/net/trunk/src/changes/changes.xml [utf-8] Fri Jun 19 
00:07:46 2015
@@ -72,6 +72,9 @@ This is mainly a bug-fix release. See fu
   IMAPExportMbox (example app) allows IMAP folders to be exported into an mbox 
file.
   This is the inverse of the IMAPImportMbox example added previously
         ">
+            <action issue="NET-576" type="update" dev="sebb">
+            Allow FTPClient to use SYST response if system type is not 
specified in configuration
+            </action>
             <action issue="NET-575" type="update" dev="sebb">
             FTPClientExample should support setting the date format
             </action>

Modified: 
commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java
URL: 
http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java?rev=1686344&r1=1686343&r2=1686344&view=diff
==============================================================================
--- 
commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java
 (original)
+++ 
commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java
 Fri Jun 19 00:07:46 2015
@@ -3348,8 +3348,8 @@ implements Configurable
 
             } else {
                 // if no parserKey was supplied, check for a configuration
-                // in the params, and if non-null, use that.
-                if (null != __configuration) {
+                // in the params, and if it has a non-empty system type, use 
that.
+                if (null != __configuration && 
__configuration.getServerSystemKey().length() > 0) {
                     __entryParser =
                         __parserFactory.createFileEntryParser(__configuration);
                     __entryParserKey = __configuration.getServerSystemKey();
@@ -3369,7 +3369,11 @@ implements Configurable
                             }
                         }
                     }
-                    __entryParser = 
__parserFactory.createFileEntryParser(systemType);
+                    if (null != __configuration) { // system type must have 
been empty above
+                        __entryParser = 
__parserFactory.createFileEntryParser(new FTPClientConfig(systemType, 
__configuration));
+                    } else {
+                        __entryParser = 
__parserFactory.createFileEntryParser(systemType);
+                    }
                     __entryParserKey = systemType;
                 }
             }

Modified: 
commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClientConfig.java
URL: 
http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClientConfig.java?rev=1686344&r1=1686343&r2=1686344&view=diff
==============================================================================
--- 
commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClientConfig.java
 (original)
+++ 
commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClientConfig.java
 Fri Jun 19 00:07:46 2015
@@ -233,6 +233,9 @@ public class FTPClientConfig
      * The main constructor for an FTPClientConfig object
      * @param systemKey key representing system type of the  server being
      * connected to. See {@link #getServerSystemKey() serverSystemKey}
+     * If set to the empty string, then FTPClient uses the system type 
returned by the server.
+     * However this is not recommended for general use;
+     * the correct system type should be set if it is known.
      */
     public FTPClientConfig(String systemKey) {
         this.serverSystemKey = systemKey;
@@ -247,7 +250,7 @@ public class FTPClientConfig
     }
 
     /**
-     * Constructor which allows setting of all member fields
+     * Constructor which allows setting of most member fields
      * @param systemKey key representing system type of the  server being
      * connected to. See
      *  {@link #getServerSystemKey() serverSystemKey}
@@ -277,6 +280,57 @@ public class FTPClientConfig
         this.serverTimeZoneId = serverTimeZoneId;
     }
 
+    /**
+     * Constructor which allows setting of all member fields
+     * @param systemKey key representing system type of the  server being
+     * connected to. See
+     *  {@link #getServerSystemKey() serverSystemKey}
+     * @param defaultDateFormatStr See
+     *  {@link  #setDefaultDateFormatStr(String)  defaultDateFormatStr}
+     * @param recentDateFormatStr See
+     *  {@link  #setRecentDateFormatStr(String)  recentDateFormatStr}
+     * @param serverLanguageCode See
+     *  {@link  #setServerLanguageCode(String)  serverLanguageCode}
+     * @param shortMonthNames See
+     *  {@link  #setShortMonthNames(String)  shortMonthNames}
+     * @param serverTimeZoneId See
+     *  {@link  #setServerTimeZoneId(String)  serverTimeZoneId}
+     * @param lenientFutureDates See
+     * {@link  #setLenientFutureDates(boolean)  lenientFutureDates}
+     * @param saveUnparseableEntries See
+     * {@link  #setUnparseableEntries(boolean)  saveUnparseableEntries}
+     */
+    public FTPClientConfig(String systemKey,
+                           String defaultDateFormatStr,
+                           String recentDateFormatStr,
+                           String serverLanguageCode,
+                           String shortMonthNames,
+                           String serverTimeZoneId,
+                           boolean lenientFutureDates,
+                           boolean saveUnparseableEntries)
+    {
+        this(systemKey);
+        this.defaultDateFormatStr = defaultDateFormatStr;
+        this.lenientFutureDates = lenientFutureDates;
+        this.recentDateFormatStr = recentDateFormatStr;
+        this.saveUnparseableEntries = saveUnparseableEntries;
+        this.serverLanguageCode = serverLanguageCode;
+        this.shortMonthNames = shortMonthNames;
+        this.serverTimeZoneId = serverTimeZoneId;
+    }
+
+    // Copy constructor, intended for use by FTPClient only
+    FTPClientConfig(String systemKey, FTPClientConfig config) {
+        this.serverSystemKey = systemKey;
+        this.defaultDateFormatStr = config.defaultDateFormatStr;
+        this.lenientFutureDates = config.lenientFutureDates;
+        this.recentDateFormatStr = config.recentDateFormatStr;
+        this.saveUnparseableEntries = config.saveUnparseableEntries;
+        this.serverLanguageCode = config.serverLanguageCode;
+        this.serverTimeZoneId = config.serverTimeZoneId;
+        this.shortMonthNames = config.shortMonthNames;
+    }
+
     private static final Map<String, Object> LANGUAGE_CODE_MAP = new 
TreeMap<String, Object>();
     static {
 


Reply via email to