Return-Path: Delivered-To: apmail-incubator-jspwiki-commits-archive@locus.apache.org Received: (qmail 45232 invoked from network); 5 May 2008 06:41:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 May 2008 06:41:36 -0000 Received: (qmail 48338 invoked by uid 500); 5 May 2008 06:41:38 -0000 Delivered-To: apmail-incubator-jspwiki-commits-archive@incubator.apache.org Received: (qmail 48325 invoked by uid 500); 5 May 2008 06:41:38 -0000 Mailing-List: contact jspwiki-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jspwiki-dev@incubator.apache.org Delivered-To: mailing list jspwiki-commits@incubator.apache.org Received: (qmail 48314 invoked by uid 99); 5 May 2008 06:41:38 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 04 May 2008 23:41:38 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 May 2008 06:40:52 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 44BA223889C0; Sun, 4 May 2008 23:41:13 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r653309 - /incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/util/MailUtil.java Date: Mon, 05 May 2008 06:41:13 -0000 To: jspwiki-commits@incubator.apache.org From: jalkanen@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080505064113.44BA223889C0@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jalkanen Date: Sun May 4 23:41:12 2008 New Revision: 653309 URL: http://svn.apache.org/viewvc?rev=653309&view=rev Log: Removed a bunch of CheckStyle warnings Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/util/MailUtil.java Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/util/MailUtil.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/util/MailUtil.java?rev=653309&r1=653308&r2=653309&view=diff ============================================================================== --- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/util/MailUtil.java (original) +++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/util/MailUtil.java Sun May 4 23:41:12 2008 @@ -201,7 +201,7 @@ private static boolean c_useJndi = true; - public static final String PROP_MAIL_AUTH = "mail.smtp.auth"; + private static final String PROP_MAIL_AUTH = "mail.smtp.auth"; protected static final Logger log = Logger.getLogger(MailUtil.class); @@ -237,7 +237,8 @@ protected static final String PROP_MAIL_STARTTLS = "mail.smtp.starttls.enable"; - private static String fromAddress = null; + private static String c_fromAddress = null; + /** * Private constructor prevents instantiation. */ @@ -265,11 +266,11 @@ * @param to the receiver * @param subject the subject line of the message * @param content the contents of the mail message, as plain text - * @throws AddressException - * @throws MessagingException + * @throws AddressException If the address is invalid + * @throws MessagingException If the message cannot be sent. */ public static void sendMessage(WikiEngine engine, String to, String subject, String content) - throws AddressException, MessagingException + throws AddressException, MessagingException { Properties props = engine.getWikiProperties(); Session session = getMailSession(engine); @@ -279,7 +280,7 @@ { // Create and address the message MimeMessage msg = new MimeMessage(session); - msg.setFrom(new InternetAddress(fromAddress)); + msg.setFrom(new InternetAddress(c_fromAddress)); msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to, false)); msg.setSubject(subject); msg.setText(content, "UTF-8"); @@ -311,25 +312,31 @@ */ protected static String getSenderEmailAddress(Session pSession, Properties pProperties) { - if (fromAddress == null) + if( c_fromAddress == null ) { - // First, attempt to get the email address from the JNDI Mail Session. - if (pSession != null && c_useJndi) + // First, attempt to get the email address from the JNDI Mail + // Session. + if( pSession != null && c_useJndi ) + { + c_fromAddress = pSession.getProperty( MailUtil.PROP_MAIL_SENDER ); + } + // If unsuccessful, get the email address from the properties or + // default. + if( c_fromAddress == null ) { - fromAddress = pSession.getProperty(MailUtil.PROP_MAIL_SENDER); + c_fromAddress = pProperties.getProperty( PROP_MAIL_SENDER, DEFAULT_SENDER ).trim(); + if( log.isDebugEnabled() ) + log.debug( "Attempt to get the sender's mail address from the JNDI mail session failed, will use \"" + + c_fromAddress + "\" (configured via jspwiki.properties or the internal default)." ); } - // If unsuccessful, get the email address from the properties or default. - if (fromAddress == null) { - fromAddress = pProperties.getProperty(PROP_MAIL_SENDER, DEFAULT_SENDER).trim(); - if ( log.isDebugEnabled() ) - log.debug("Attempt to get the sender's mail address from the JNDI mail session failed, will use \"" + fromAddress - + "\" (configured via jspwiki.properties or the internal default)."); - } else { - if ( log.isDebugEnabled() ) - log.debug("Attempt to get the sender's mail address from the JNDI mail session was successful (" + fromAddress + ")."); + else + { + if( log.isDebugEnabled() ) + log.debug( "Attempt to get the sender's mail address from the JNDI mail session was successful (" + c_fromAddress + + ")." ); } } - return fromAddress; + return c_fromAddress; } /**