Return-Path: X-Original-To: apmail-commons-dev-archive@www.apache.org Delivered-To: apmail-commons-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5A468DDEC for ; Mon, 29 Oct 2012 16:52:19 +0000 (UTC) Received: (qmail 47809 invoked by uid 500); 29 Oct 2012 16:52:18 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 47693 invoked by uid 500); 29 Oct 2012 16:52:18 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 47671 invoked by uid 99); 29 Oct 2012 16:52:18 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Oct 2012 16:52:18 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,URIBL_DBL_REDIR X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of garydgregory@gmail.com designates 209.85.210.43 as permitted sender) Received: from [209.85.210.43] (HELO mail-da0-f43.google.com) (209.85.210.43) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Oct 2012 16:52:14 +0000 Received: by mail-da0-f43.google.com with SMTP id u36so2683808dak.30 for ; Mon, 29 Oct 2012 09:51:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=fx4JZO6sTDB1I3sjHbJ7n2CQ1AepQlIPc6Lqmg9qTkQ=; b=PnUIc5kQaDVUniYhqiydBauz4X53lU+YxmSJhqUc3cWeoJPhApJ3sBjU3DHzKA4Wwu bnNZ3P4EBBc8lYzJPk5zfCuK0iKgCn9grn4I+qb8KK4FBRdXgBdUA5tvq+1fLz4Z+TIe BDXbyAiKiERkKYlKu6luga9Rwu6af7VOdThsW03mVJVahZyuAlhZFZ46LMCyw+z7mMvU d0++dcFE7v+cTk6InkG3i+8I/2Dp9w2uOrv6j1+9aB6R9Rzup7aWxBLhmFNwpaHRogYr Y1DoyfR2gW50Sd5uujyzqirXyKrngXN3ht9FbMvqKtTn/OMgzpyhdIg5DWuhnrTOnlzO YEjw== MIME-Version: 1.0 Received: by 10.68.248.70 with SMTP id yk6mr93970871pbc.160.1351529513859; Mon, 29 Oct 2012 09:51:53 -0700 (PDT) Received: by 10.68.40.130 with HTTP; Mon, 29 Oct 2012 09:51:53 -0700 (PDT) In-Reply-To: <621588D5-8C70-4F11-A4C6-29985C725E19@dslextreme.com> References: <20121029150648.88F8F23888E4@eris.apache.org> <621588D5-8C70-4F11-A4C6-29985C725E19@dslextreme.com> Date: Mon, 29 Oct 2012 12:51:53 -0400 Message-ID: Subject: Re: svn commit: r1403346 - /commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ftps/FtpsClientFactory.java From: Gary Gregory To: Commons Developers List Content-Type: multipart/alternative; boundary=047d7b2ee87593b99604cd357cca X-Virus-Checked: Checked by ClamAV on apache.org --047d7b2ee87593b99604cd357cca Content-Type: text/plain; charset=UTF-8 I got that comment from the HTML checkstyle report! Might be a checkstyle reporting bug? Gary On Mon, Oct 29, 2012 at 12:29 PM, Ralph Goers wrote: > Gary, > > What are you using to validate checkstyle? checkstyle.xml says the max > line length is 120 yet your log message says it is 150. > > Ralph > > On Oct 29, 2012, at 8:06 AM, ggregory@apache.org wrote: > > > Author: ggregory > > Date: Mon Oct 29 15:06:48 2012 > > New Revision: 1403346 > > > > URL: http://svn.apache.org/viewvc?rev=1403346&view=rev > > Log: > > Checkstyle: Method length is 166 lines (max allowed is 150). Refactor > large method. Refactor anon constant. > > > > 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=1403346&r1=1403345&r2=1403346&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 15:06:48 2012 > > @@ -34,12 +34,9 @@ import org.apache.commons.vfs2.util.User > > */ > > public final class FtpsClientFactory > > { > > + private static final char[] ANON_CHAR_ARRAY = > "anonymous".toCharArray(); > > private static final int SHORT_MONTH_NAME_LEN = 40; > > > > - private FtpsClientFactory() > > - { > > - } > > - > > /** > > * Creates a new connection to the server. > > * @param hostname The host name. > > @@ -57,81 +54,23 @@ public final class FtpsClientFactory > > // Determine the username and password to use > > if (username == null) > > { > > - username = "anonymous".toCharArray(); > > + username = ANON_CHAR_ARRAY; > > } > > > > if (password == null) > > { > > - password = "anonymous".toCharArray(); > > + password = ANON_CHAR_ARRAY; > > } > > > > try > > { > > > > - final FTPSClient client; > > - > > - if > (FtpsFileSystemConfigBuilder.getInstance().getFtpsType(fileSystemOptions) > > - > .equals(FtpsFileSystemConfigBuilder.FTPS_TYPE_EXPLICIT)) > > - { > > - client = new FTPSClient(); > > - } > > - 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'"); > > - } > > + final FTPSClient client = > createFTPSClient(fileSystemOptions); > > > > String key = > FtpsFileSystemConfigBuilder.getInstance().getEntryParser(fileSystemOptions); > > if (key != null) > > { > > - FTPClientConfig config = new FTPClientConfig(key); > > - > > - String serverLanguageCode = > FtpsFileSystemConfigBuilder.getInstance().getServerLanguageCode( > > - fileSystemOptions); > > - if (serverLanguageCode != null) > > - { > > - config.setServerLanguageCode(serverLanguageCode); > > - } > > - String defaultDateFormat = > FtpsFileSystemConfigBuilder.getInstance().getDefaultDateFormat( > > - fileSystemOptions); > > - if (defaultDateFormat != null) > > - { > > - config.setDefaultDateFormatStr(defaultDateFormat); > > - } > > - String recentDateFormat = > FtpsFileSystemConfigBuilder.getInstance().getRecentDateFormat( > > - fileSystemOptions); > > - if (recentDateFormat != null) > > - { > > - config.setRecentDateFormatStr(recentDateFormat); > > - } > > - String serverTimeZoneId = > FtpsFileSystemConfigBuilder.getInstance().getServerTimeZoneId( > > - fileSystemOptions); > > - if (serverTimeZoneId != null) > > - { > > - config.setServerTimeZoneId(serverTimeZoneId); > > - } > > - String[] shortMonthNames = > FtpsFileSystemConfigBuilder.getInstance().getShortMonthNames( > > - fileSystemOptions); > > - if (shortMonthNames != null) > > - { > > - StringBuilder shortMonthNamesStr = new > StringBuilder(SHORT_MONTH_NAME_LEN); > > - for (String shortMonthName : shortMonthNames) > > - { > > - if (shortMonthNamesStr.length() > 0) > > - { > > - shortMonthNamesStr.append("|"); > > - } > > - shortMonthNamesStr.append(shortMonthName); > > - } > > - > config.setShortMonthNames(shortMonthNamesStr.toString()); > > - } > > - > > + FTPClientConfig config = > createFTPClientConfig(fileSystemOptions, key); > > client.configure(config); > > } > > > > @@ -215,4 +154,75 @@ public final class FtpsClientFactory > > throw new > FileSystemException("vfs.provider.sftp/connect.error", exc, hostname); > > } > > } > > + > > + private static FTPClientConfig > createFTPClientConfig(FileSystemOptions fileSystemOptions, String key) > > + { > > + FTPClientConfig config = new FTPClientConfig(key); > > + > > + String serverLanguageCode = > FtpsFileSystemConfigBuilder.getInstance().getServerLanguageCode( > > + fileSystemOptions); > > + if (serverLanguageCode != null) > > + { > > + config.setServerLanguageCode(serverLanguageCode); > > + } > > + String defaultDateFormat = > FtpsFileSystemConfigBuilder.getInstance().getDefaultDateFormat( > > + fileSystemOptions); > > + if (defaultDateFormat != null) > > + { > > + config.setDefaultDateFormatStr(defaultDateFormat); > > + } > > + String recentDateFormat = > FtpsFileSystemConfigBuilder.getInstance().getRecentDateFormat( > > + fileSystemOptions); > > + if (recentDateFormat != null) > > + { > > + config.setRecentDateFormatStr(recentDateFormat); > > + } > > + String serverTimeZoneId = > FtpsFileSystemConfigBuilder.getInstance().getServerTimeZoneId( > > + fileSystemOptions); > > + if (serverTimeZoneId != null) > > + { > > + config.setServerTimeZoneId(serverTimeZoneId); > > + } > > + String[] shortMonthNames = > FtpsFileSystemConfigBuilder.getInstance().getShortMonthNames( > > + fileSystemOptions); > > + if (shortMonthNames != null) > > + { > > + StringBuilder shortMonthNamesStr = new > StringBuilder(SHORT_MONTH_NAME_LEN); > > + for (String shortMonthName : shortMonthNames) > > + { > > + if (shortMonthNamesStr.length() > 0) > > + { > > + shortMonthNamesStr.append("|"); > > + } > > + shortMonthNamesStr.append(shortMonthName); > > + } > > + config.setShortMonthNames(shortMonthNamesStr.toString()); > > + } > > + return config; > > + } > > + > > + private static FTPSClient createFTPSClient(FileSystemOptions > fileSystemOptions) > > + throws FileSystemException > > + { > > + if > (FtpsFileSystemConfigBuilder.getInstance().getFtpsType(fileSystemOptions) > > + .equals(FtpsFileSystemConfigBuilder.FTPS_TYPE_EXPLICIT)) > > + { > > + return new FTPSClient(); > > + } > > + else if > (FtpsFileSystemConfigBuilder.getInstance().getFtpsType(fileSystemOptions) > > + .equals(FtpsFileSystemConfigBuilder.FTPS_TYPE_IMPLICIT)) > > + { > > + return new FTPSClient(true); > > + } > > + else > > + { > > + throw new FileSystemException("Invalid FTPS type of " > > + + > FtpsFileSystemConfigBuilder.getInstance().getFtpsType(fileSystemOptions) > > + + " specified. Must be 'implicit' or 'explicit'"); > > + } > > + } > > + > > + private FtpsClientFactory() > > + { > > + } > > } > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org > For additional commands, e-mail: dev-help@commons.apache.org > > -- E-Mail: garydgregory@gmail.com | ggregory@apache.org JUnit in Action, 2nd Ed: http://bit.ly/ECvg0 Spring Batch in Action: http://bit.ly/bqpbCK Blog: http://garygregory.wordpress.com Home: http://garygregory.com/ Tweet! http://twitter.com/GaryGregory --047d7b2ee87593b99604cd357cca--