You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2012/10/29 15:58:32 UTC

svn commit: r1403339 - /commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsClientFactory.java

Author: ggregory
Date: Mon Oct 29 14:58:32 2012
New Revision: 1403339

URL: http://svn.apache.org/viewvc?rev=1403339&view=rev
Log:
Format createConnection to fix odd alignment.

Modified:
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsClientFactory.java

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=1403339&r1=1403338&r2=1403339&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 Mon Oct 29 14:58:32 2012
@@ -70,153 +70,149 @@ public final class FtpsClientFactory
 
             final FTPSClient client;
 
-            if (FtpsFileSystemConfigBuilder.getInstance().getFtpsType(fileSystemOptions).equals(
-                    FtpsFileSystemConfigBuilder.FTPS_TYPE_EXPLICIT))
+            if (FtpsFileSystemConfigBuilder.getInstance().getFtpsType(fileSystemOptions)
+                    .equals(FtpsFileSystemConfigBuilder.FTPS_TYPE_EXPLICIT))
             {
                 client = new FTPSClient();
             }
-            else if (FtpsFileSystemConfigBuilder.getInstance().getFtpsType(fileSystemOptions).equals(
-                    FtpsFileSystemConfigBuilder.FTPS_TYPE_IMPLICIT))
+            else if (FtpsFileSystemConfigBuilder.getInstance().getFtpsType(fileSystemOptions)
+                    .equals(FtpsFileSystemConfigBuilder.FTPS_TYPE_IMPLICIT))
             {
                 client = new FTPSClient(true);
             }
             else
             {
-                throw new FileSystemException(
-                    "Invalid FTPS type of " + FtpsFileSystemConfigBuilder.getInstance().getFtpsType(
-                        fileSystemOptions) + " specified. Must be 'implicit' or 'explicit'");
+                throw new FileSystemException("Invalid FTPS type of "
+                        + FtpsFileSystemConfigBuilder.getInstance().getFtpsType(fileSystemOptions)
+                        + " specified. Must be 'implicit' or 'explicit'");
             }
 
-                String key = FtpsFileSystemConfigBuilder.getInstance().getEntryParser(fileSystemOptions);
-                if (key != null)
-                {
-                    FTPClientConfig config = new FTPClientConfig(key);
+            String key = FtpsFileSystemConfigBuilder.getInstance().getEntryParser(fileSystemOptions);
+            if (key != null)
+            {
+                FTPClientConfig config = new FTPClientConfig(key);
 
-                    String serverLanguageCode = FtpsFileSystemConfigBuilder.getInstance().getServerLanguageCode(
+                String serverLanguageCode = FtpsFileSystemConfigBuilder.getInstance().getServerLanguageCode(
                         fileSystemOptions);
-                    if (serverLanguageCode != null)
-                    {
-                        config.setServerLanguageCode(serverLanguageCode);
-                    }
-                    String defaultDateFormat = FtpsFileSystemConfigBuilder.getInstance().getDefaultDateFormat(
+                if (serverLanguageCode != null)
+                {
+                    config.setServerLanguageCode(serverLanguageCode);
+                }
+                String defaultDateFormat = FtpsFileSystemConfigBuilder.getInstance().getDefaultDateFormat(
                         fileSystemOptions);
-                    if (defaultDateFormat != null)
-                    {
-                        config.setDefaultDateFormatStr(defaultDateFormat);
-                    }
-                    String recentDateFormat = FtpsFileSystemConfigBuilder.getInstance().getRecentDateFormat(
+                if (defaultDateFormat != null)
+                {
+                    config.setDefaultDateFormatStr(defaultDateFormat);
+                }
+                String recentDateFormat = FtpsFileSystemConfigBuilder.getInstance().getRecentDateFormat(
                         fileSystemOptions);
-                    if (recentDateFormat != null)
-                    {
-                        config.setRecentDateFormatStr(recentDateFormat);
-                    }
-                    String serverTimeZoneId = FtpsFileSystemConfigBuilder.getInstance().getServerTimeZoneId(
+                if (recentDateFormat != null)
+                {
+                    config.setRecentDateFormatStr(recentDateFormat);
+                }
+                String serverTimeZoneId = FtpsFileSystemConfigBuilder.getInstance().getServerTimeZoneId(
                         fileSystemOptions);
-                    if (serverTimeZoneId != null)
-                    {
-                        config.setServerTimeZoneId(serverTimeZoneId);
-                    }
-                    String[] shortMonthNames = FtpsFileSystemConfigBuilder.getInstance().getShortMonthNames(
+                if (serverTimeZoneId != null)
+                {
+                    config.setServerTimeZoneId(serverTimeZoneId);
+                }
+                String[] shortMonthNames = FtpsFileSystemConfigBuilder.getInstance().getShortMonthNames(
                         fileSystemOptions);
-                    if (shortMonthNames != null)
+                if (shortMonthNames != null)
+                {
+                    StringBuilder shortMonthNamesStr = new StringBuilder(SHORT_MONTH_NAME_LEN);
+                    for (String shortMonthName : shortMonthNames)
                     {
-                        StringBuilder shortMonthNamesStr = new StringBuilder(SHORT_MONTH_NAME_LEN);
-                        for (String shortMonthName : shortMonthNames)
+                        if (shortMonthNamesStr.length() > 0)
                         {
-                            if (shortMonthNamesStr.length() > 0)
-                            {
-                                shortMonthNamesStr.append("|");
-                            }
-                            shortMonthNamesStr.append(shortMonthName);
+                            shortMonthNamesStr.append("|");
                         }
-                        config.setShortMonthNames(shortMonthNamesStr.toString());
+                        shortMonthNamesStr.append(shortMonthName);
                     }
-
-                    client.configure(config);
+                    config.setShortMonthNames(shortMonthNamesStr.toString());
                 }
 
-                FTPFileEntryParserFactory myFactory = FtpsFileSystemConfigBuilder.getInstance().getEntryParserFactory(
-                    fileSystemOptions);
-                if (myFactory != null)
-                {
-                    client.setParserFactory(myFactory);
-                }
+                client.configure(config);
+            }
 
-                try
-                {
-                    client.connect(hostname, port);
+            FTPFileEntryParserFactory myFactory = FtpsFileSystemConfigBuilder.getInstance().getEntryParserFactory(
+                    fileSystemOptions);
+            if (myFactory != null)
+            {
+                client.setParserFactory(myFactory);
+            }
 
-// For VFS-412
-//                    String execPROT = FtpsFileSystemConfigBuilder.getInstance().getDataChannelProtectionLevel(
-//                          fileSystemOptions);
-//                    if (execPROT != null)
-//                    {
-//                        client.execPROT(execPROT);
-//                    }
+            try
+            {
+                client.connect(hostname, port);
 
-                    int reply = client.getReplyCode();
-                    if (!FTPReply.isPositiveCompletion(reply))
-                    {
-                        throw new FileSystemException("vfs.provider.ftp/connect-rejected.error", hostname);
-                    }
+                // For VFS-412
+                // String execPROT = FtpsFileSystemConfigBuilder.getInstance().getDataChannelProtectionLevel(
+                // fileSystemOptions);
+                // if (execPROT != null)
+                // {
+                // client.execPROT(execPROT);
+                // }
 
-                    // Login
-                    if (!client.login(
-                        UserAuthenticatorUtils.toString(username),
-                        UserAuthenticatorUtils.toString(password)))
-                    {
-                        throw new FileSystemException("vfs.provider.ftp/login.error",
-                            hostname, UserAuthenticatorUtils.toString(username));
-                    }
+                int reply = client.getReplyCode();
+                if (!FTPReply.isPositiveCompletion(reply))
+                {
+                    throw new FileSystemException("vfs.provider.ftp/connect-rejected.error", hostname);
+                }
 
-                    // Set binary mode
-                    if (!client.setFileType(FTP.BINARY_FILE_TYPE))
-                    {
-                        throw new FileSystemException("vfs.provider.ftp/set-binary.error", hostname);
-                    }
+                // Login
+                if (!client.login(UserAuthenticatorUtils.toString(username), UserAuthenticatorUtils.toString(password)))
+                {
+                    throw new FileSystemException("vfs.provider.ftp/login.error", hostname,
+                            UserAuthenticatorUtils.toString(username));
+                }
 
-                    // Set dataTimeout value
-                    Integer dataTimeout = FtpsFileSystemConfigBuilder.getInstance().getDataTimeout(fileSystemOptions);
-                    if (dataTimeout != null)
-                    {
-                        client.setDataTimeout(dataTimeout.intValue());
-                    }
+                // Set binary mode
+                if (!client.setFileType(FTP.BINARY_FILE_TYPE))
+                {
+                    throw new FileSystemException("vfs.provider.ftp/set-binary.error", hostname);
+                }
 
-                    // Change to root by default
-                    // All file operations a relative to the filesystem-root
-                    // String root = getRoot().getName().getPath();
+                // Set dataTimeout value
+                Integer dataTimeout = FtpsFileSystemConfigBuilder.getInstance().getDataTimeout(fileSystemOptions);
+                if (dataTimeout != null)
+                {
+                    client.setDataTimeout(dataTimeout.intValue());
+                }
 
-                    Boolean userDirIsRoot = FtpsFileSystemConfigBuilder.getInstance().getUserDirIsRoot(
-                        fileSystemOptions);
-                    if (workingDirectory != null && (userDirIsRoot == null || !userDirIsRoot.booleanValue()))
-                    {
-                        if (!client.changeWorkingDirectory(workingDirectory))
-                        {
-                            throw new FileSystemException("vfs.provider.ftp/change-work-directory.error",
-                                workingDirectory);
-                        }
-                    }
+                // Change to root by default
+                // All file operations a relative to the filesystem-root
+                // String root = getRoot().getName().getPath();
 
-                    Boolean passiveMode = FtpsFileSystemConfigBuilder.getInstance().getPassiveMode(fileSystemOptions);
-                    if (passiveMode != null && passiveMode.booleanValue())
-                    {
-                        client.enterLocalPassiveMode();
-                    }
-                }
-                catch (final IOException e)
+                Boolean userDirIsRoot = FtpsFileSystemConfigBuilder.getInstance().getUserDirIsRoot(fileSystemOptions);
+                if (workingDirectory != null && (userDirIsRoot == null || !userDirIsRoot.booleanValue()))
                 {
-                    if (client.isConnected())
+                    if (!client.changeWorkingDirectory(workingDirectory))
                     {
-                        client.disconnect();
+                        throw new FileSystemException("vfs.provider.ftp/change-work-directory.error", workingDirectory);
                     }
-                    throw e;
                 }
 
-                return client;
+                Boolean passiveMode = FtpsFileSystemConfigBuilder.getInstance().getPassiveMode(fileSystemOptions);
+                if (passiveMode != null && passiveMode.booleanValue())
+                {
+                    client.enterLocalPassiveMode();
+                }
             }
-            catch (final Exception exc)
+            catch (final IOException e)
             {
-                throw new FileSystemException("vfs.provider.sftp/connect.error", exc, hostname);
+                if (client.isConnected())
+                {
+                    client.disconnect();
+                }
+                throw e;
             }
+
+            return client;
+        }
+        catch (final Exception exc)
+        {
+            throw new FileSystemException("vfs.provider.sftp/connect.error", exc, hostname);
         }
     }
+    }