axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dee...@apache.org
Subject svn commit: r232977 - in /webservices/axis/trunk/java/modules: core/src/org/apache/axis2/transport/mail/ core/src/org/apache/axis2/transport/mail/server/ integration/test/org/apache/axis2/mail/
Date Tue, 16 Aug 2005 10:44:13 GMT
Author: deepal
Date: Tue Aug 16 03:41:58 2005
New Revision: 232977

URL: http://svn.apache.org/viewcvs?rev=232977&view=rev
Log:
Applying Chamil's patch

Removed:
    webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/MailConstants.java
Modified:
    webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/EMailSender.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/MailConstants.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/MailTransportSender.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/MailServer.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/POP3Worker.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/SMTPWorker.java
    webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mail/MailetRequestResponceRawXMLTest.java
    webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mail/UtilsMailServer.java

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/EMailSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/EMailSender.java?rev=232977&r1=232976&r2=232977&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/EMailSender.java
(original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/EMailSender.java
Tue Aug 16 03:41:58 2005
@@ -55,7 +55,7 @@
         this.password = password;
     }
 
-    public void send(String subject, String targetEmail, String message, String charSetEn)
throws AxisFault {
+    public void send(String subject, String targetEmail, String message, String charSet)
throws AxisFault {
         try {
             final PasswordAuthentication authentication =
                     new PasswordAuthentication(user, password);
@@ -77,14 +77,14 @@
                     new InternetAddress(targetEmail));
             msg.setSubject(subject);
 
-            if (charSetEn.equals("")){
-                charSetEn = MailConstants.DEFAULT_CHAR_SET_ENCODING;
+            if (charSet == null){
+                charSet = MailConstants.DEFAULT_CHAR_SET;
             }
 
-            msg.addHeaderLine("Content-Type: text/plain; charset=" + MailConstants.DEFAULT_CHAR_SET);
+            msg.addHeaderLine("Content-Type: " + MailConstants.DEFAULT_CONTENT_TYPE + ";
charset=" + charSet);
 
             msg.setText(message);
-            msg.setHeader("Content-Transfer-Encoding", charSetEn);
+            msg.setHeader("Content-Transfer-Encoding", MailConstants.DEFAULT_CHAR_SET_ENCODING);
             Transport.send(msg);
         } catch (AddressException e) {
             throw new AxisFault(e);
@@ -103,7 +103,7 @@
 
         sender.send("Testing mail sending",
                 "hemapani@127.0.0.1",
-                "Hellp, testing", "us-ascii");
+                "Hellp, testing", MailConstants.DEFAULT_CHAR_SET);
 
         EmailReceiver receiver = new EmailReceiver(user,
                 host,

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/MailConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/MailConstants.java?rev=232977&r1=232976&r2=232977&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/MailConstants.java
(original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/MailConstants.java
Tue Aug 16 03:41:58 2005
@@ -34,4 +34,5 @@
     
     public final static String DEFAULT_CHAR_SET = "us-ascii";
     public final static String DEFAULT_CHAR_SET_ENCODING = "7bit";
+    public final static String DEFAULT_CONTENT_TYPE = "text/xml";
 }

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/MailTransportSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/MailTransportSender.java?rev=232977&r1=232976&r2=232977&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/MailTransportSender.java
(original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/MailTransportSender.java
Tue Aug 16 03:41:58 2005
@@ -68,7 +68,11 @@
                 //TODO this is just a temporary hack, fix this to use input streams
 
                 String eprAddress = msgContext.getTo().getAddress();
-                String charEncoding = (String)msgContext.getProperty(MessageContext.CHARACTER_SET_ENCODING);
+                // In mail char set is what is being used. Charset encoding is not what is
expected here.
+                String charSet = (String)msgContext.getProperty(MessageContext.CHARACTER_SET_ENCODING);
+                if (charSet == null){
+                    charSet = MailConstants.DEFAULT_CHAR_SET;
+                }
                 int index = eprAddress.indexOf('/');
                 String subject = "";
                 String email = null;
@@ -82,7 +86,7 @@
                 sender.send(
                     subject,
                     email,
-                    new String(byteArrayOutputStream.toByteArray()), charEncoding);
+                    new String(byteArrayOutputStream.toByteArray()), charSet);
             } else {
                 if (user == null) {
                     throw new AxisFault(

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/MailServer.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/MailServer.java?rev=232977&r1=232976&r2=232977&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/MailServer.java
(original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/MailServer.java
Tue Aug 16 03:41:58 2005
@@ -77,8 +77,8 @@
     }
 
     public static void main(String args[]){
-        int smtpPost = MailConstants.SMTP_SERVER_PORT;
-        int popPort = MailConstants.POP_SERVER_PORT;
+        int smtpPost = MailSrvConstants.SMTP_SERVER_PORT;
+        int popPort = MailSrvConstants.POP_SERVER_PORT;
         if (args.length == 2) {
             try {
                 smtpPost = Integer.parseInt(args[0]);

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/POP3Worker.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/POP3Worker.java?rev=232977&r1=232976&r2=232977&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/POP3Worker.java
(original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/POP3Worker.java
Tue Aug 16 03:41:58 2005
@@ -34,7 +34,7 @@
             PrintWriter printWriter = new PrintWriter(socket.getOutputStream(),
                     true);
 
-            printWriter.println(MailConstants.OK + " POP3 server ready");
+            printWriter.println(MailSrvConstants.OK + " POP3 server ready");
             String s;
             String ps; //ProcessedString
             while (!doneProcess) {
@@ -51,7 +51,7 @@
     ArrayList messages = new ArrayList();
 
     private void processInput(String input, PrintWriter printWriter) {
-        int listLen = (MailConstants.LIST + " ").length();
+        int listLen = (MailSrvConstants.LIST + " ").length();
         byte[] CR_LF = new byte[]{0x0D, 0x0A};
         byte[] CR_LF_DOT_CR_LF = new byte[]{0x0D, 0x0A, '.', 0x0D, 0x0A};
         String user = "";
@@ -63,19 +63,19 @@
             while (stk.hasMoreTokens()) {
                 tokens.add(stk.nextToken());
             }
-            if (tokens.get(0).equals(MailConstants.USER)) {
+            if (tokens.get(0).equals(MailSrvConstants.USER)) {
                 user = (String) tokens.get(1);
                 messages = st.popUserMails(user);
-                printWriter.println(MailConstants.OK);
-            } else if (tokens.get(0).equals(MailConstants.PASS)) {
-                printWriter.println(MailConstants.OK); // Passwords are not checked.
-            } else if (input.equals(MailConstants.QUIT)) {
+                printWriter.println(MailSrvConstants.OK);
+            } else if (tokens.get(0).equals(MailSrvConstants.PASS)) {
+                printWriter.println(MailSrvConstants.OK); // Passwords are not checked.
+            } else if (input.equals(MailSrvConstants.QUIT)) {
                 printWriter.println(
-                        MailConstants.OK + "POP3 server signing off");
+                        MailSrvConstants.OK + "POP3 server signing off");
                 doneProcess = true;
-            } else if (input.equals(MailConstants.STAT)) {
-                printWriter.println(MailConstants.OK + messages.size() + " 1"); // We take
the maildrop size as one.
-            } else if (tokens.get(0).equals(MailConstants.LIST)) { // scan listing
+            } else if (input.equals(MailSrvConstants.STAT)) {
+                printWriter.println(MailSrvConstants.OK + messages.size() + " 1"); // We
take the maildrop size as one.
+            } else if (tokens.get(0).equals(MailSrvConstants.LIST)) { // scan listing
                 if (tokens.size() > 1) {
                     try {
                         int optArg = Integer.parseInt((String) tokens.get(1));
@@ -83,11 +83,11 @@
                         if ((messageArrayIndex < messages.size()) &&
                                 (messageArrayIndex >= 0)) { // that is OK careful with
numbering
                             printWriter.println(
-                                    MailConstants.OK + messageArrayIndex + 1 +
+                                    MailSrvConstants.OK + messageArrayIndex + 1 +
                                     " 120"); // Mail size of 120 is just some number.
                         } else {
                             printWriter.println(
-                                    MailConstants.ERR +
+                                    MailSrvConstants.ERR +
                                     "no such message, only " +
                                     (messages.size() + 1) +
                                     " messages in maildrop");
@@ -95,23 +95,23 @@
                     } catch (NumberFormatException e) {
                         log.info(e.getMessage());
                         printWriter.println(
-                                MailConstants.ERR +
+                                MailSrvConstants.ERR +
                                 "problem passing the index. Index submited was " +
                                 tokens.get(1));
                     }
                 } else {
-                    printWriter.println(MailConstants.OK + messages.size());
+                    printWriter.println(MailSrvConstants.OK + messages.size());
                     for (int i = 0; i < messages.size(); i++) {
                         int messageIndex = i + 1;
                         printWriter.println(messageIndex + " 120"); // List out all the messages
with a message size octet of 120
                     }
                     printWriter.println(".");
                 }
-            } else if (tokens.get(0).equals(MailConstants.RETR)) {
+            } else if (tokens.get(0).equals(MailSrvConstants.RETR)) {
                 String i = (String) tokens.get(1);
                 try {
                     int index = Integer.parseInt(i);
-                    printWriter.println(MailConstants.OK);
+                    printWriter.println(MailSrvConstants.OK);
                     MimeMessage m = (MimeMessage) messages.get(index - 1);
 
                     m.writeTo(socket.getOutputStream());
@@ -122,31 +122,31 @@
                     socket.getOutputStream().write(CR_LF_DOT_CR_LF);// This is a bit of a
hack to get it working. Have to find a bette way to handle this.
                     socket.getOutputStream().flush();
                 } catch (NumberFormatException e) {
-                    printWriter.println(MailConstants.ERR);
+                    printWriter.println(MailSrvConstants.ERR);
                 } catch (IOException e1) {
-                    printWriter.println(MailConstants.ERR);
+                    printWriter.println(MailSrvConstants.ERR);
                 } catch (MessagingException e2) {
-                    printWriter.println(MailConstants.ERR);
+                    printWriter.println(MailSrvConstants.ERR);
                 }
-            } else if (tokens.get(0).equals(MailConstants.DELE)) {
+            } else if (tokens.get(0).equals(MailSrvConstants.DELE)) {
                 String smIndex = (String) tokens.get(1);
                 try {
                     int mIndex = Integer.parseInt(smIndex) - 1 - numDeleted; // When one
mail is deleted the index of the other mails will reduce. Asumed that the delete will occure
from bottom up.
                     if ((mIndex >= 0) && (mIndex < messages.size())) {
                         messages.remove(mIndex);
                         numDeleted++;
-                        printWriter.println(MailConstants.OK);
+                        printWriter.println(MailSrvConstants.OK);
                     } else {
-                        printWriter.println(MailConstants.ERR);
+                        printWriter.println(MailSrvConstants.ERR);
                     }
                 } catch (NumberFormatException e) {
-                    printWriter.println(MailConstants.ERR);
+                    printWriter.println(MailSrvConstants.ERR);
                 }
-            } else if (tokens.get(0).equals(MailConstants.NOOP) ||
-                    tokens.get(0).equals(MailConstants.RSET)) {
-                printWriter.println(MailConstants.OK);
+            } else if (tokens.get(0).equals(MailSrvConstants.NOOP) ||
+                    tokens.get(0).equals(MailSrvConstants.RSET)) {
+                printWriter.println(MailSrvConstants.OK);
             } else {
-                printWriter.println(MailConstants.ERR);
+                printWriter.println(MailSrvConstants.ERR);
             }
         }
     }

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/SMTPWorker.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/SMTPWorker.java?rev=232977&r1=232976&r2=232977&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/SMTPWorker.java
(original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/mail/server/SMTPWorker.java
Tue Aug 16 03:41:58 2005
@@ -88,7 +88,7 @@
 
                 String retString = processInput(input);
 
-                if (MailConstants.COMMAND_EXIT.equals(retString)) {
+                if (MailSrvConstants.COMMAND_EXIT.equals(retString)) {
                     exitWorker();
                 } else {
                     if (retString != null) {
@@ -131,9 +131,9 @@
     private String processInput(String input) {
         byte[] CR_LF = new byte[] { 0x0D, 0x0A };
         if (input == null)
-            return MailConstants.COMMAND_UNKNOWN;
+            return MailSrvConstants.COMMAND_UNKNOWN;
         if (mail != null && transmitionEnd)
-            return MailConstants.COMMAND_TRANSMISSION_END;
+            return MailSrvConstants.COMMAND_TRANSMISSION_END;
 
         if (input.startsWith("MAIL")) {
             mail = new MimeMessage(Session.getInstance(new Properties(),
@@ -169,15 +169,15 @@
                 }
             }
 
-            return MailConstants.MAIL_OK;
+            return MailSrvConstants.MAIL_OK;
 
         }
         if (input.startsWith("HELO")) {
-            return MailConstants.HELO_REPLY;
+            return MailSrvConstants.HELO_REPLY;
 
         } else if (input.startsWith("RCPT")) {
 
-            String domain = MailConstants.SERVER_DOMAIN;
+            String domain = MailSrvConstants.SERVER_DOMAIN;
             //System.out.println("RCPT:" + input);
             //temp += input + "\n"; TODO Check this
             int start = input.indexOf("<") + 1;
@@ -187,12 +187,12 @@
                 start = input.indexOf("TO:") + 3;
                 /*
                  * if(!input.endsWith(domain)){ System.out.println("ERROR: wrong
-                 * donmain name"); return MailConstants.RCPT_ERROR; }
+                 * donmain name"); return MailSrvConstants.RCPT_ERROR; }
                  */
             } else {
                 /*
                  * if(!input.endsWith(domain + ">")){ System.out.println("ERROR:
-                 * wrong donmain name"); return MailConstants.RCPT_ERROR; }
+                 * wrong donmain name"); return MailSrvConstants.RCPT_ERROR; }
                  */
             }
 
@@ -208,20 +208,20 @@
                 // TODO Auto-generated catch block
 //                e.printStackTrace();
             }
-            return MailConstants.RCPT_OK;
+            return MailSrvConstants.RCPT_OK;
 
         } else if (input.equalsIgnoreCase("DATA")) {
             dataWriting = true;
-            return MailConstants.DATA_START_SUCCESS;
+            return MailSrvConstants.DATA_START_SUCCESS;
 
         } else if (input.equalsIgnoreCase("QUIT")) {
             dataWriting = true;
             transmitionEnd = true;
-            return MailConstants.COMMAND_TRANSMISSION_END;
+            return MailSrvConstants.COMMAND_TRANSMISSION_END;
 
         } else if (input.equals(".")) {
             dataWriting = false;
-            return MailConstants.DATA_END_SUCCESS;
+            return MailSrvConstants.DATA_END_SUCCESS;
         } else if (input.equals("") && !bodyData) {
             bodyData = true;
             return null;
@@ -241,7 +241,7 @@
             return null;
 
         } else {
-            return MailConstants.COMMAND_UNKNOWN;
+            return MailSrvConstants.COMMAND_UNKNOWN;
         }
 
     }

Modified: webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mail/MailetRequestResponceRawXMLTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mail/MailetRequestResponceRawXMLTest.java?rev=232977&r1=232976&r2=232977&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mail/MailetRequestResponceRawXMLTest.java
(original)
+++ webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mail/MailetRequestResponceRawXMLTest.java
Tue Aug 16 03:41:58 2005
@@ -51,7 +51,7 @@
  */
 public class MailetRequestResponceRawXMLTest extends TestCase {
     private EndpointReference targetEPR =
-            new EndpointReference("axis2-server@127.0.0.1" +
+            new EndpointReference("foo@127.0.0.1" +
             "/axis/services/EchoXMLService/echoOMElement");
     private Log log = LogFactory.getLog(getClass());
     private QName serviceName = new QName("EchoXMLService");

Modified: webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mail/UtilsMailServer.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mail/UtilsMailServer.java?rev=232977&r1=232976&r2=232977&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mail/UtilsMailServer.java
(original)
+++ webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mail/UtilsMailServer.java
Tue Aug 16 03:41:58 2005
@@ -22,7 +22,7 @@
 import org.apache.axis2.Constants;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.ConfigurationContextFactory;
-import org.apache.axis2.transport.mail.server.MailConstants;
+import org.apache.axis2.transport.mail.server.MailSrvConstants;
 import org.apache.axis2.transport.mail.server.MailServer;
 
 import java.io.File;
@@ -46,8 +46,8 @@
             server =
                 new MailServer(
             SERVER_CONFIG_CONTEXT,
-                    MailConstants.POP_SERVER_PORT,
-                    MailConstants.SMTP_SERVER_PORT);
+                    MailSrvConstants.POP_SERVER_PORT,
+                    MailSrvConstants.SMTP_SERVER_PORT);
         }
         runningServerCount++;
         return SERVER_CONFIG_CONTEXT;



Mime
View raw message