Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 31504 invoked from network); 2 Nov 2010 00:00:05 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 2 Nov 2010 00:00:05 -0000 Received: (qmail 73384 invoked by uid 500); 2 Nov 2010 00:00:34 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 73324 invoked by uid 500); 2 Nov 2010 00:00:34 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 73103 invoked by uid 99); 2 Nov 2010 00:00:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Nov 2010 00:00:33 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED,T_FRT_STOCK2 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; Tue, 02 Nov 2010 00:00:31 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 20070238897A; Mon, 1 Nov 2010 23:59:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1029898 [1/3] - in /commons/proper/email/trunk/src: changes/ java/org/apache/commons/mail/ java/org/apache/commons/mail/impl/ java/org/apache/commons/mail/util/ test/eml/ test/org/apache/commons/mail/ test/org/apache/commons/mail/util/ Date: Mon, 01 Nov 2010 23:59:17 -0000 To: commits@commons.apache.org From: sgoeschl@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101101235918.20070238897A@eris.apache.org> Author: sgoeschl Date: Mon Nov 1 23:59:16 2010 New Revision: 1029898 URL: http://svn.apache.org/viewvc?rev=1029898&view=rev Log: +) Adding MimeMessageParser and MimeMessageUtils +) cleand up most CheckStyle errors +) improved test coverage Added: commons/proper/email/trunk/src/java/org/apache/commons/mail/DataSourceResolver.java commons/proper/email/trunk/src/java/org/apache/commons/mail/impl/DataSourceResolverImpl.java commons/proper/email/trunk/src/java/org/apache/commons/mail/util/ commons/proper/email/trunk/src/java/org/apache/commons/mail/util/MimeMessageParser.java commons/proper/email/trunk/src/java/org/apache/commons/mail/util/MimeMessageUtils.java commons/proper/email/trunk/src/java/org/apache/commons/mail/util/URLFactory.java commons/proper/email/trunk/src/java/org/apache/commons/mail/util/package.html commons/proper/email/trunk/src/test/eml/ commons/proper/email/trunk/src/test/eml/html-attachment.eml commons/proper/email/trunk/src/test/eml/simple.eml commons/proper/email/trunk/src/test/org/apache/commons/mail/DataSourceResolverTest.java (contents, props changed) - copied, changed from r1006345, commons/proper/email/trunk/src/test/org/apache/commons/mail/DefaultAuthenticatorTest.java commons/proper/email/trunk/src/test/org/apache/commons/mail/util/ commons/proper/email/trunk/src/test/org/apache/commons/mail/util/MimeMessageParserTest.java commons/proper/email/trunk/src/test/org/apache/commons/mail/util/URLFactoryTest.java Removed: commons/proper/email/trunk/src/java/org/apache/commons/mail/impl/URLFactory.java Modified: commons/proper/email/trunk/src/changes/changes.xml commons/proper/email/trunk/src/java/org/apache/commons/mail/Email.java commons/proper/email/trunk/src/java/org/apache/commons/mail/EmailConstants.java commons/proper/email/trunk/src/java/org/apache/commons/mail/EmailUtils.java commons/proper/email/trunk/src/java/org/apache/commons/mail/ImageHtmlEmail.java commons/proper/email/trunk/src/java/org/apache/commons/mail/MultiPartEmail.java commons/proper/email/trunk/src/java/org/apache/commons/mail/impl/package.html commons/proper/email/trunk/src/test/org/apache/commons/mail/BaseEmailTestCase.java commons/proper/email/trunk/src/test/org/apache/commons/mail/EmailAttachmentTest.java commons/proper/email/trunk/src/test/org/apache/commons/mail/EmailLiveTest.java commons/proper/email/trunk/src/test/org/apache/commons/mail/HtmlEmailTest.java commons/proper/email/trunk/src/test/org/apache/commons/mail/ImageHtmlEmailTest.java Modified: commons/proper/email/trunk/src/changes/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/changes/changes.xml?rev=1029898&r1=1029897&r2=1029898&view=diff ============================================================================== --- commons/proper/email/trunk/src/changes/changes.xml (original) +++ commons/proper/email/trunk/src/changes/changes.xml Mon Nov 1 23:59:16 2010 @@ -23,6 +23,9 @@ + + Added MimeMessageParser and MimeMessageUtils. + Throwing an IllegalStateException when setting mail session properties for an already created mail session because the settings would be ignored. Please note that this Added: commons/proper/email/trunk/src/java/org/apache/commons/mail/DataSourceResolver.java URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/java/org/apache/commons/mail/DataSourceResolver.java?rev=1029898&view=auto ============================================================================== --- commons/proper/email/trunk/src/java/org/apache/commons/mail/DataSourceResolver.java (added) +++ commons/proper/email/trunk/src/java/org/apache/commons/mail/DataSourceResolver.java Mon Nov 1 23:59:16 2010 @@ -0,0 +1,37 @@ +/* + * 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.mail; + +import javax.activation.DataSource; +import java.io.IOException; + +/** + * Creates a DataSource based on an URL. + * + * @since 1.3 + */ +public interface DataSourceResolver +{ + /** + * Resolves the given resource location to a DataSource. + * + * @param resourceLocation the location of the resource + * @return the DataSource + * @throws IOException the resource was not found + */ + DataSource resolve(final String resourceLocation) throws IOException; +} Modified: commons/proper/email/trunk/src/java/org/apache/commons/mail/Email.java URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/java/org/apache/commons/mail/Email.java?rev=1029898&r1=1029897&r2=1029898&view=diff ============================================================================== --- commons/proper/email/trunk/src/java/org/apache/commons/mail/Email.java (original) +++ commons/proper/email/trunk/src/java/org/apache/commons/mail/Email.java Mon Nov 1 23:59:16 2010 @@ -147,15 +147,19 @@ public abstract class Email implements E * Used to determine whether to use pop3 before smtp, and if so the settings. */ protected boolean popBeforeSmtp; + /** the host name of the pop3 server */ protected String popHost; + /** the user name to log into the pop3 server */ protected String popUsername; + /** the password to log into the pop3 server */ protected String popPassword; /** does server require TLS encryption for authentication */ protected boolean tls; + /** does the current transport use SSL encryption? */ protected boolean ssl; @@ -347,7 +351,7 @@ public abstract class Email implements E /** * Set the port number of the outgoing mail server. - * + * * @param aPortNumber aPortNumber * @return An Email. * @since 1.0 @@ -417,7 +421,7 @@ public abstract class Email implements E /** * Supply a mail Session object from a JNDI directory. - * + * * @param jndiName name of JNDI ressource (javax.mail.Session type), ressource * if searched in java:comp/env if name dont start with "java:" * @return An Email. @@ -1437,6 +1441,7 @@ public abstract class Email implements E * Default is 60 second timeout. * * @param socketTimeout the socket I/O timeout + * @return An Email. * @since 1.2 */ public Email setSocketTimeout(int socketTimeout) @@ -1482,7 +1487,7 @@ public abstract class Email implements E { result = MimeUtility.fold(name.length() + 2, MimeUtility.encodeText(value.toString(), this.charset, null)); } - catch(UnsupportedEncodingException e) + catch (UnsupportedEncodingException e) { result = value.toString(); } @@ -1550,7 +1555,7 @@ public abstract class Email implements E * @throws IllegalStateException when the mail session is * already initialized */ - private void checkSessionAlreadyInitialized() throws IllegalStateException + private void checkSessionAlreadyInitialized() { if (this.session != null) { Modified: commons/proper/email/trunk/src/java/org/apache/commons/mail/EmailConstants.java URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/java/org/apache/commons/mail/EmailConstants.java?rev=1029898&r1=1029897&r2=1029898&view=diff ============================================================================== --- commons/proper/email/trunk/src/java/org/apache/commons/mail/EmailConstants.java (original) +++ commons/proper/email/trunk/src/java/org/apache/commons/mail/EmailConstants.java Mon Nov 1 23:59:16 2010 @@ -52,13 +52,18 @@ public interface EmailConstants String MAIL_SMTP_PASSWORD = "mail.smtp.password"; String MAIL_TRANSPORT_PROTOCOL = "mail.transport.protocol"; + ///////////////////////////////////////////////////////////////////////// // since 1.1 + ///////////////////////////////////////////////////////////////////////// + String MAIL_TRANSPORT_TLS = "mail.smtp.starttls.enable"; String MAIL_SMTP_SOCKET_FACTORY_FALLBACK = "mail.smtp.socketFactory.fallback"; String MAIL_SMTP_SOCKET_FACTORY_CLASS = "mail.smtp.socketFactory.class"; String MAIL_SMTP_SOCKET_FACTORY_PORT = "mail.smtp.socketFactory.port"; + ///////////////////////////////////////////////////////////////////////// // since 1.2 + ///////////////////////////////////////////////////////////////////////// /** * Socket connection timeout value in milliseconds. Default is infinite timeout. Modified: commons/proper/email/trunk/src/java/org/apache/commons/mail/EmailUtils.java URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/java/org/apache/commons/mail/EmailUtils.java?rev=1029898&r1=1029897&r2=1029898&view=diff ============================================================================== --- commons/proper/email/trunk/src/java/org/apache/commons/mail/EmailUtils.java (original) +++ commons/proper/email/trunk/src/java/org/apache/commons/mail/EmailUtils.java Mon Nov 1 23:59:16 2010 @@ -17,10 +17,11 @@ package org.apache.commons.mail; +import org.apache.commons.mail.util.MimeMessageUtils; + import javax.mail.internet.MimeMessage; import javax.mail.MessagingException; import java.util.Random; -import java.io.FileOutputStream; import java.io.File; import java.io.IOException; @@ -237,45 +238,6 @@ final class EmailUtils */ static void writeMimeMessage(File resultFile, MimeMessage mimeMessage) throws IOException, MessagingException { - FileOutputStream fos = null; - - if (mimeMessage == null) - { - throw new IllegalArgumentException("mimeMessage is null"); - } - - if (resultFile == null) - { - throw new IllegalArgumentException("resultFile is null"); - } - - if (resultFile.getParentFile() != null) - { - resultFile.getParentFile().mkdirs(); - } - - try - { - fos = new FileOutputStream(resultFile); - mimeMessage.writeTo(fos); - fos.flush(); - fos.close(); - fos = null; - } - finally - { - if (fos != null) - { - try - { - fos.close(); - fos = null; - } - catch (Exception e) - { - // ignore - } - } - } + MimeMessageUtils.writeMimeMessage(mimeMessage, resultFile); } } Modified: commons/proper/email/trunk/src/java/org/apache/commons/mail/ImageHtmlEmail.java URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/java/org/apache/commons/mail/ImageHtmlEmail.java?rev=1029898&r1=1029897&r2=1029898&view=diff ============================================================================== --- commons/proper/email/trunk/src/java/org/apache/commons/mail/ImageHtmlEmail.java (original) +++ commons/proper/email/trunk/src/java/org/apache/commons/mail/ImageHtmlEmail.java Mon Nov 1 23:59:16 2010 @@ -16,14 +16,8 @@ */ package org.apache.commons.mail; -import org.apache.commons.mail.impl.URLFactory; - import javax.activation.DataSource; -import javax.activation.URLDataSource; -import java.io.File; import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; import java.util.HashMap; import java.util.Map; import java.util.regex.Matcher; @@ -67,73 +61,35 @@ public class ImageHtmlEmail extends Html /** pattern for extracting