Author: joehni
Date: Thu Feb 21 14:47:37 2013
New Revision: 1448668

URL: http://svn.apache.org/r1448668
Log:
Deprecate FtpsFileSystemConfigBuilder.setFtpsType and 
FtpsFileSystemConfigBuilder.getFtpsType in favor of 
FtpsFileSystemConfigBuilder.setFtpsMode and 
FtpsFileSystemConfigBuilder.getFtpsMode which use new enum FtpsMode instead 
(VFS-462).

Added:
    
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsMode.java
   (with props)
Modified:
    
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpFileSystemConfigBuilder.java
    
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsClientFactory.java
    
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsFileSystemConfigBuilder.java
    
commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/ftps/test/FtpsProviderExplicitTestCase.java
    
commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/ftps/test/FtpsProviderImplicitTestCase_Disabled.java
    commons/proper/vfs/trunk/src/changes/changes.xml

Modified: 
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpFileSystemConfigBuilder.java
URL: 
http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpFileSystemConfigBuilder.java?rev=1448668&r1=1448667&r2=1448668&view=diff
==============================================================================
--- 
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpFileSystemConfigBuilder.java
 (original)
+++ 
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ftp/FtpFileSystemConfigBuilder.java
 Thu Feb 21 14:47:37 2013
@@ -95,7 +95,7 @@ public class FtpFileSystemConfigBuilder 
 
     /**
      * @param opts The FileSystemOptions.
-     * @return The timeout as an Integer.
+     * @return The timeout for opening the data channel as an Integer.
      * @see #setDataTimeout
      */
     public Integer getDataTimeout(final FileSystemOptions opts)

Modified: 
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsClientFactory.java
URL: 
http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsClientFactory.java?rev=1448668&r1=1448667&r2=1448668&view=diff
==============================================================================
--- 
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsClientFactory.java
 (original)
+++ 
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsClientFactory.java
 Thu Feb 21 14:47:37 2013
@@ -68,19 +68,13 @@ public final class FtpsClientFactory
                protected FTPSClient createClient(final FileSystemOptions 
fileSystemOptions) throws FileSystemException
                {
                        final FTPSClient client;
-               if 
(builder.getFtpsType(fileSystemOptions).equals(FtpsFileSystemConfigBuilder.FTPS_TYPE_EXPLICIT))
-               {
-                   client = new FTPSClient();
-               }
-               else if 
(builder.getFtpsType(fileSystemOptions).equals(FtpsFileSystemConfigBuilder.FTPS_TYPE_IMPLICIT))
+               if (builder.getFtpsMode(fileSystemOptions) == FtpsMode.IMPLICIT)
                {
                    client = new FTPSClient(true);
                }
-               else
+               else 
                {
-                   throw new FileSystemException("Invalid FTPS type of "
-                           + 
FtpsFileSystemConfigBuilder.getInstance().getFtpsType(fileSystemOptions)
-                           + " specified. Must be 'implicit' or 'explicit'");
+                   client = new FTPSClient();
                }
                
                        final TrustManager trustManager = 
TrustManagerUtils.getValidateServerCertificateTrustManager();

Modified: 
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsFileSystemConfigBuilder.java
URL: 
http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsFileSystemConfigBuilder.java?rev=1448668&r1=1448667&r2=1448668&view=diff
==============================================================================
--- 
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsFileSystemConfigBuilder.java
 (original)
+++ 
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsFileSystemConfigBuilder.java
 Thu Feb 21 14:47:37 2013
@@ -28,22 +28,11 @@ public final class FtpsFileSystemConfigB
 {
     private static final String _PREFIX = 
FtpsFileSystemConfigBuilder.class.getName();
 
-    private static final FtpsFileSystemConfigBuilder BUILDER =
-        new FtpsFileSystemConfigBuilder();
+    private static final FtpsFileSystemConfigBuilder BUILDER = new 
FtpsFileSystemConfigBuilder();
 
-    private static final String FTPS_TYPE = _PREFIX + ".FTPS_TYPE";
+    private static final String FTPS_MODE = _PREFIX + ".FTPS_MODE";
     private static final String PROT = _PREFIX + ".PROT";
 
-    /**
-     * FTPS implicit file type.
-     */
-    public static final String FTPS_TYPE_IMPLICIT = "implicit";
-
-    /**
-     * FTPS explicit file type.
-     */
-    public static final String FTPS_TYPE_EXPLICIT = "explicit";
-
     private FtpsFileSystemConfigBuilder()
     {
         super("ftps.");
@@ -60,31 +49,79 @@ public final class FtpsFileSystemConfigB
     }
 
     /**
-     * Set FTPS security mode, either "implicit" or "explicit".
+     * Set FTPS mode, either "implicit" or "explicit".
      *
      * <p>Note, that implicit mode is not standardized and considered as 
deprecated. Some unit tests for VFS fail with
      * implicit mode and it is not yet clear if its a problem with Commons 
VFS/Commons Net or our test server Apache
      * FTP/SSHD.</p>
      *  
      * @param opts The FileSystemOptions.
-     * @param ftpsType The file type.
+     * @param ftpsMode The mode to establish a FTPS connection.
      * @see <a href="http://en.wikipedia.org/wiki/FTPS#Implicit";>Wikipedia: 
FTPS/Implicit</a>
+     * @since 2.1
+     */
+    public void setFtpsMode(final FileSystemOptions opts, final FtpsMode 
ftpsMode)
+    {
+        setParam(opts, FTPS_MODE, ftpsMode);
+    }
+
+    /**
+     * Return the FTPS mode. Defaults to "explicit" if not defined.
+     *
+     * @param opts The FileSystemOptions.
+     * @return The file type.
+     * @see #setFtpsType
      */
-    public void setFtpsType(final FileSystemOptions opts, final String 
ftpsType)
+    public FtpsMode getFtpsMode(final FileSystemOptions opts)
     {
-        setParam(opts, FTPS_TYPE, ftpsType);
+        final FtpsMode mode = (FtpsMode)getParam(opts, FTPS_MODE);
+               return mode == null ? FtpsMode.EXPLICIT : mode;
     }
 
+       /**
+        * Set FTPS type, either "implicit" or "explicit".
+        * <p>
+        * Note, that implicit mode is not standardized and considered as 
deprecated. Some unit tests for VFS fail with
+        * implicit mode and it is not yet clear if its a problem with Commons 
VFS/Commons Net or our test server Apache
+        * FTP/SSHD.
+        * </p>
+        * 
+        * @param opts The FileSystemOptions.
+        * @param ftpsType The file type.
+        * @see <a href="http://en.wikipedia.org/wiki/FTPS#Implicit";>Wikipedia: 
FTPS/Implicit</a>
+        * @deprecated As of 2.1, use {@link #setFtpsMode(FileSystemOptions, 
FtpsMode)}
+        */
+       @Deprecated
+       public void setFtpsType(final FileSystemOptions opts, final String 
ftpsType)
+       {
+               final FtpsMode mode;
+               if (ftpsType != null)
+               {
+                       mode = FtpsMode.valueOf(ftpsType.toUpperCase());
+                       if (mode == null)
+                       {
+                               throw new IllegalArgumentException("Not a 
proper FTPS mode: " + ftpsType);
+                       }
+               }
+               else
+               { 
+                       mode = null;
+               }
+               setFtpsMode(opts, mode);
+       }
+
     /**
-     * Return the FTPS security mode. Defaults to "explicit" if not defined.
+     * Return the FTPS type. Defaults to "explicit" if not defined.
      *
      * @param opts The FileSystemOptions.
      * @return The file type.
      * @see #setFtpsType
+        * @deprecated As of 2.1, use {@link #getFtpsType(FileSystemOptions)}
      */
+       @Deprecated
     public String getFtpsType(final FileSystemOptions opts)
     {
-        return getString(opts, FTPS_TYPE, 
FtpsFileSystemConfigBuilder.FTPS_TYPE_EXPLICIT);
+        return getFtpsMode(opts).name().toLowerCase();
     }
 
        /**

Added: 
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsMode.java
URL: 
http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsMode.java?rev=1448668&view=auto
==============================================================================
--- 
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsMode.java
 (added)
+++ 
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsMode.java
 Thu Feb 21 14:47:37 2013
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs2.provider.ftps;
+
+/**
+ * Mode of the FTPS connection.
+ *
+ * <p>Note, that 'implicit' mode is not standardized and considered as 
deprecated. Some unit tests for VFS fail with
+ * 'implicit' mode and it is not yet clear if its a problem with Commons 
VFS/Commons Net or our test server Apache
+ * FTP/SSHD.</p>
+ * 
+ * @see <a href="http://en.wikipedia.org/wiki/FTPS#Implicit";>Wikipedia: 
FTPS/Implicit</a>
+ * @since 2.1
+ */
+public enum FtpsMode
+{
+       IMPLICIT, EXPLICIT
+}

Propchange: 
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsMode.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsMode.java
------------------------------------------------------------------------------
    svn:keywords = Author Id HeadURL Revision

Modified: 
commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/ftps/test/FtpsProviderExplicitTestCase.java
URL: 
http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/ftps/test/FtpsProviderExplicitTestCase.java?rev=1448668&r1=1448667&r2=1448668&view=diff
==============================================================================
--- 
commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/ftps/test/FtpsProviderExplicitTestCase.java
 (original)
+++ 
commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/ftps/test/FtpsProviderExplicitTestCase.java
 Thu Feb 21 14:47:37 2013
@@ -18,6 +18,7 @@ package org.apache.commons.vfs2.provider
 
 import org.apache.commons.vfs2.provider.ftps.FtpsDataChannelProtectionLevel;
 import org.apache.commons.vfs2.provider.ftps.FtpsFileSystemConfigBuilder;
+import org.apache.commons.vfs2.provider.ftps.FtpsMode;
 
 import junit.framework.Test;
 
@@ -37,7 +38,7 @@ public class FtpsProviderExplicitTestCas
        {
                super.setupOptions(builder);
                builder.setDataChannelProtectionLevel(fileSystemOptions, 
FtpsDataChannelProtectionLevel.P);
-               builder.setFtpsType(fileSystemOptions, 
FtpsFileSystemConfigBuilder.FTPS_TYPE_EXPLICIT);
+               builder.setFtpsMode(fileSystemOptions, FtpsMode.EXPLICIT);
        }
 
        /**

Modified: 
commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/ftps/test/FtpsProviderImplicitTestCase_Disabled.java
URL: 
http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/ftps/test/FtpsProviderImplicitTestCase_Disabled.java?rev=1448668&r1=1448667&r2=1448668&view=diff
==============================================================================
--- 
commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/ftps/test/FtpsProviderImplicitTestCase_Disabled.java
 (original)
+++ 
commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/ftps/test/FtpsProviderImplicitTestCase_Disabled.java
 Thu Feb 21 14:47:37 2013
@@ -17,6 +17,7 @@
 package org.apache.commons.vfs2.provider.ftps.test;
 
 import org.apache.commons.vfs2.provider.ftps.FtpsFileSystemConfigBuilder;
+import org.apache.commons.vfs2.provider.ftps.FtpsMode;
 
 import junit.framework.Test;
 
@@ -39,7 +40,7 @@ public class FtpsProviderImplicitTestCas
        protected void setupOptions(final FtpsFileSystemConfigBuilder builder)
        {
                super.setupOptions(builder);
-               builder.setFtpsType(fileSystemOptions, 
FtpsFileSystemConfigBuilder.FTPS_TYPE_IMPLICIT);
+               builder.setFtpsMode(fileSystemOptions, FtpsMode.IMPLICIT);
        }
 
        /**

Modified: commons/proper/vfs/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/vfs/trunk/src/changes/changes.xml?rev=1448668&r1=1448667&r2=1448668&view=diff
==============================================================================
--- commons/proper/vfs/trunk/src/changes/changes.xml (original)
+++ commons/proper/vfs/trunk/src/changes/changes.xml Thu Feb 21 14:47:37 2013
@@ -26,6 +26,11 @@
 <!--       <action issue="VFS-443" dev="ggregory" type="update" 
due-to="nickallen"> -->
 <!--           [Local] Need an easy way to convert from a FileObject to a 
File. -->
 <!--       </action> -->
+      <action issue="VFS-462" dev="joehni" type="update">
+        [FTPS] Deprecate FtpsFileSystemConfigBuilder.setFtpsType and 
FtpsFileSystemConfigBuilder.getFtpsType
+        in favor of FtpsFileSystemConfigBuilder.setFtpsMode and 
FtpsFileSystemConfigBuilder.getFtpsMode which
+        use new enum FtpsMode instead.
+      </action>
       <action issue="VFS-461" dev="joehni" type="fix">
         [FTP/FTPS] ConfigBuilder does not consider system properties for the 
value of SoTimeout and Encoding.
       </action>


Reply via email to