geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jlaskow...@apache.org
Subject svn commit: r387216 - in /geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/nntp: NNTPConnection.java NNTPTransport.java
Date Mon, 20 Mar 2006 15:00:30 GMT
Author: jlaskowski
Date: Mon Mar 20 07:00:28 2006
New Revision: 387216

URL: http://svn.apache.org/viewcvs?rev=387216&view=rev
Log:
GERONIMO-1753 - Add support for a mail.nntp.from property to configure the default From: address
for NNTP posts
Submitted by: Rick McGuire

Modified:
    geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/nntp/NNTPConnection.java
    geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/nntp/NNTPTransport.java

Modified: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/nntp/NNTPConnection.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/nntp/NNTPConnection.java?rev=387216&r1=387215&r2=387216&view=diff
==============================================================================
--- geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/nntp/NNTPConnection.java
(original)
+++ geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/nntp/NNTPConnection.java
Mon Mar 20 07:00:28 2006
@@ -82,7 +82,6 @@
      */
     protected static final String MAIL_NNTP_AUTH = "mail.nntp.auth";
     protected static final String MAIL_NNTP_PORT = "mail.nntp.port";
-    protected static final String MAIL_NNTP_LOCALHOST = "mail.nntp.localhost";
     protected static final String MAIL_NNTP_TIMEOUT = "mail.nntp.timeout";
     protected static final String MAIL_NNTP_SASL_REALM = "mail.nntp.sasl.realm";
     protected static final String MAIL_NNTP_FACTORY_CLASS = "mail.nntp.socketFactory.class";
@@ -109,9 +108,6 @@
 
     // the connection socket...can be a plain socket or SSLSocket, if TLS is being used.
     protected Socket socket;
-
-    // our local host name
-    protected String localHost;
 
     // input stream used to read data.  If Sasl is in use, this might be other than the
     // direct access to the socket input stream.

Modified: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/nntp/NNTPTransport.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/nntp/NNTPTransport.java?rev=387216&r1=387215&r2=387216&view=diff
==============================================================================
--- geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/nntp/NNTPTransport.java
(original)
+++ geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/nntp/NNTPTransport.java
Mon Mar 20 07:00:28 2006
@@ -44,6 +44,7 @@
 import javax.mail.Transport;
 import javax.mail.URLName;
 import javax.mail.event.TransportEvent;
+import javax.mail.internet.InternetAddress;
 import javax.mail.internet.NewsAddress;
 import javax.mail.internet.MimeMessage;
 
@@ -67,6 +68,7 @@
      */
     protected static final String NNTP_AUTH = "mail.nntp.auth";
     protected static final String NNTP_PORT = "mail.nntp.port";
+    protected static final String NNTP_FROM = "mail.nntp.from";
 
     protected static final int DEFAULT_NNTP_PORT = 119;
 
@@ -167,6 +169,22 @@
         // NNTP only handles instances of MimeMessage, not the more general message case.
         if (!(message instanceof MimeMessage)) {
             throw new MessagingException("NNTP can only send MimeMessages");
+        }
+
+        // need to sort the from value out from a variety of sources.
+        InternetAddress from = null;
+
+
+        Address[] fromAddresses = message.getFrom();
+
+        // If the message has a From address set, we just use that.  Otherwise, we set a
From using
+        // the property version, if available.
+        if (fromAddresses == null || fromAddresses.length == 0) {
+            // the from value can be set explicitly as a property
+            String defaultFrom = session.getProperty(NNTP_FROM);
+            if (defaultFrom == null) {
+                message.setFrom(new InternetAddress(defaultFrom));
+            }
         }
 
         // we must have a message list.



Mime
View raw message