some code additions to help debug Casey's issues with the mail gateway
This commit is contained in:
parent
ef0ef37b09
commit
cad8b1108f
21
samples/debug.js
Normal file
21
samples/debug.js
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
// The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
// (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.mozilla.org/MPL/>.
|
||||||
|
//
|
||||||
|
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
// WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
// language governing rights and limitations under the License.
|
||||||
|
//
|
||||||
|
// The Original Code is the Venice Web Communities System - Generic Mail Gateway.
|
||||||
|
//
|
||||||
|
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
// Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Contributor(s):
|
||||||
|
|
||||||
|
importPackage(Packages.com.silverwrist.mailgate);
|
||||||
|
|
||||||
|
// get the message, dump it
|
||||||
|
message = bsf.lookupBean("message");
|
||||||
|
message.dump();
|
29
samples/debug.properties
Normal file
29
samples/debug.properties
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
# The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||||
|
# (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.mozilla.org/MPL/>.
|
||||||
|
#
|
||||||
|
# Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||||
|
# WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
# language governing rights and limitations under the License.
|
||||||
|
#
|
||||||
|
# The Original Code is the Venice Web Communities System - Generic Mail Gateway.
|
||||||
|
#
|
||||||
|
# The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||||
|
# for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
# Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Contributor(s):
|
||||||
|
|
||||||
|
# The script to be run by the gateway for each received message.
|
||||||
|
mailgate.script=debug.js
|
||||||
|
|
||||||
|
# Temporary directory for script engines.
|
||||||
|
mailgate.script.tmpdir=/tmp
|
||||||
|
|
||||||
|
# Configuration parameters
|
||||||
|
# (none)
|
||||||
|
|
||||||
|
# Properties used by the mail session object.
|
||||||
|
mail.transport.protocol=smtp
|
||||||
|
mail.smtp.host=localhost
|
||||||
|
|
3
samples/debug.sh
Executable file
3
samples/debug.sh
Executable file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/sh
|
||||||
|
exec java -cp "mailgate.jar:bsf.jar:js.jar:jacl.jar:tcljava.jar:xmlrpc.jar" \
|
||||||
|
com.silverwrist.mailgate.Main debug.properties
|
|
@ -45,6 +45,7 @@ my_topic = lib.castInteger(lib.getConfigParam("topic"));
|
||||||
parms.add(my_topic);
|
parms.add(my_topic);
|
||||||
parms.add(message.subject);
|
parms.add(message.subject);
|
||||||
parms.add(lib.castString(text));
|
parms.add(lib.castString(text));
|
||||||
|
parms.add("email");
|
||||||
ndx = lib.castInteger(rpc.execute("venice:conferencing.topic.postMessage",parms));
|
ndx = lib.castInteger(rpc.execute("venice:conferencing.topic.postMessage",parms));
|
||||||
|
|
||||||
if (message.hasAttachments())
|
if (message.hasAttachments())
|
||||||
|
@ -61,6 +62,7 @@ if (message.hasAttachments())
|
||||||
parms.add(my_topic);
|
parms.add(my_topic);
|
||||||
parms.add(message.subject);
|
parms.add(message.subject);
|
||||||
parms.add(lib.castString(new_text));
|
parms.add(lib.castString(new_text));
|
||||||
|
parms.add("email");
|
||||||
ndx = lib.castInteger(rpc.execute("venice:conferencing.topic.postMessage",parms));
|
ndx = lib.castInteger(rpc.execute("venice:conferencing.topic.postMessage",parms));
|
||||||
|
|
||||||
} // end if
|
} // end if
|
||||||
|
|
|
@ -84,4 +84,10 @@ public class AttachmentData
|
||||||
|
|
||||||
} // end getData
|
} // end getData
|
||||||
|
|
||||||
|
public final void dump()
|
||||||
|
{
|
||||||
|
System.out.println("\tName: " + name + " Type: " + type + " Length: " + data.length);
|
||||||
|
|
||||||
|
} // end dump
|
||||||
|
|
||||||
} // end class AttachmentData
|
} // end class AttachmentData
|
||||||
|
|
|
@ -85,4 +85,16 @@ public class Library
|
||||||
|
|
||||||
} // end createVector
|
} // end createVector
|
||||||
|
|
||||||
|
public final void failPermanent(String message) throws PermanentExit
|
||||||
|
{
|
||||||
|
throw new PermanentExit("failPermanent: " + message);
|
||||||
|
|
||||||
|
} // end failPermanent
|
||||||
|
|
||||||
|
public final void failTemporary(String message) throws TemporaryExit
|
||||||
|
{
|
||||||
|
throw new TemporaryExit("failTemporary: " + message);
|
||||||
|
|
||||||
|
} // end failTemporary
|
||||||
|
|
||||||
} // end class Library
|
} // end class Library
|
||||||
|
|
|
@ -32,6 +32,7 @@ public class MessageData
|
||||||
private Set recipients; // the set of addresses the message was sent to
|
private Set recipients; // the set of addresses the message was sent to
|
||||||
private String sender; // the sender
|
private String sender; // the sender
|
||||||
private String subject; // the message subject
|
private String subject; // the message subject
|
||||||
|
private Map headers; // the headers
|
||||||
private String text = null; // the message text
|
private String text = null; // the message text
|
||||||
private ArrayList attachments = new ArrayList(); // the attachments
|
private ArrayList attachments = new ArrayList(); // the attachments
|
||||||
|
|
||||||
|
@ -47,13 +48,14 @@ public class MessageData
|
||||||
Address[] tmp_array = msg.getAllRecipients();
|
Address[] tmp_array = msg.getAllRecipients();
|
||||||
HashSet tmp_set = new HashSet();
|
HashSet tmp_set = new HashSet();
|
||||||
int i;
|
int i;
|
||||||
|
if (tmp_array!=null)
|
||||||
for (i=0; i<tmp_array.length; i++)
|
for (i=0; i<tmp_array.length; i++)
|
||||||
if (tmp_array[i].getType().equals("rfc822"))
|
if (tmp_array[i].getType().equals("rfc822"))
|
||||||
{ // peel out the actual E-mail address and stick it in the set
|
{ // peel out the actual E-mail address and stick it in the set
|
||||||
InternetAddress addr = (InternetAddress)(tmp_array[i]);
|
InternetAddress addr = (InternetAddress)(tmp_array[i]);
|
||||||
tmp_set.add(addr.getAddress().toLowerCase());
|
tmp_set.add(addr.getAddress().toLowerCase());
|
||||||
|
|
||||||
} // end if and for
|
} // end if, for, and if
|
||||||
|
|
||||||
if (tmp_set.isEmpty())
|
if (tmp_set.isEmpty())
|
||||||
recipients = Collections.EMPTY_SET;
|
recipients = Collections.EMPTY_SET;
|
||||||
|
@ -63,6 +65,7 @@ public class MessageData
|
||||||
// Get the list of senders and put it together into the "sender" label.
|
// Get the list of senders and put it together into the "sender" label.
|
||||||
tmp_array = msg.getFrom();
|
tmp_array = msg.getFrom();
|
||||||
StringBuffer buf = new StringBuffer();
|
StringBuffer buf = new StringBuffer();
|
||||||
|
if (tmp_array!=null)
|
||||||
for (i=0; i<tmp_array.length; i++)
|
for (i=0; i<tmp_array.length; i++)
|
||||||
{ // append the addresses together
|
{ // append the addresses together
|
||||||
InternetAddress addr = (InternetAddress)(tmp_array[i]);
|
InternetAddress addr = (InternetAddress)(tmp_array[i]);
|
||||||
|
@ -70,12 +73,45 @@ public class MessageData
|
||||||
buf.append(", ");
|
buf.append(", ");
|
||||||
buf.append(addr.toUnicodeString());
|
buf.append(addr.toUnicodeString());
|
||||||
|
|
||||||
} // end for
|
} // end for and if
|
||||||
|
|
||||||
sender = buf.toString();
|
sender = buf.toString();
|
||||||
|
|
||||||
// Get the subject line.
|
// Get the subject line.
|
||||||
subject = msg.getSubject();
|
subject = msg.getSubject();
|
||||||
|
if (subject==null)
|
||||||
|
subject = "";
|
||||||
|
|
||||||
|
// Get all the message headers.
|
||||||
|
Map tmp_headers = new HashMap();
|
||||||
|
Enumeration hdr_enum = msg.getAllHeaders();
|
||||||
|
if (hdr_enum!=null)
|
||||||
|
{ // get out all the headers
|
||||||
|
while (hdr_enum.hasMoreElements())
|
||||||
|
{ // get each header in turn
|
||||||
|
Header hdr = (Header)(hdr_enum.nextElement());
|
||||||
|
String label = hdr.getName().toLowerCase();
|
||||||
|
int n = label.indexOf(':');
|
||||||
|
if (n>=0)
|
||||||
|
label = label.substring(0,n);
|
||||||
|
List val_list = (List)(tmp_headers.get(label));
|
||||||
|
if (val_list==null)
|
||||||
|
{ // create new list
|
||||||
|
val_list = new ArrayList();
|
||||||
|
tmp_headers.put(label,val_list);
|
||||||
|
|
||||||
|
} // end if
|
||||||
|
|
||||||
|
val_list.add(hdr.getValue());
|
||||||
|
|
||||||
|
} // end while
|
||||||
|
|
||||||
|
} // end if
|
||||||
|
|
||||||
|
if (tmp_headers.isEmpty())
|
||||||
|
headers = Collections.EMPTY_MAP;
|
||||||
|
else
|
||||||
|
headers = Collections.unmodifiableMap(tmp_headers);
|
||||||
|
|
||||||
if (msg.getContentType().toLowerCase().startsWith("multipart/"))
|
if (msg.getContentType().toLowerCase().startsWith("multipart/"))
|
||||||
{ // we need to break up the multipart object
|
{ // we need to break up the multipart object
|
||||||
|
@ -188,6 +224,24 @@ public class MessageData
|
||||||
|
|
||||||
} // end getSubject
|
} // end getSubject
|
||||||
|
|
||||||
|
public final boolean headerContains(String name, String value)
|
||||||
|
{
|
||||||
|
List foo = (List)(headers.get(name.trim().toLowerCase()));
|
||||||
|
if (foo==null)
|
||||||
|
return false;
|
||||||
|
Iterator it = foo.iterator();
|
||||||
|
while (it.hasNext())
|
||||||
|
{ // look for a matching string value
|
||||||
|
String s = (String)(it.next());
|
||||||
|
if (s.indexOf(value)>=0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} // end while
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
} // end headerContains
|
||||||
|
|
||||||
public final String getText()
|
public final String getText()
|
||||||
{
|
{
|
||||||
return text;
|
return text;
|
||||||
|
@ -212,4 +266,41 @@ public class MessageData
|
||||||
|
|
||||||
} // end getAttachment
|
} // end getAttachment
|
||||||
|
|
||||||
|
public final void dump()
|
||||||
|
{
|
||||||
|
System.out.println("==== Begin Message Data ====");
|
||||||
|
System.out.println(recipients.size() + " recipients");
|
||||||
|
Iterator it = recipients.iterator();
|
||||||
|
while (it.hasNext())
|
||||||
|
System.out.println("\t" + it.next().toString());
|
||||||
|
System.out.println("Sender: " + sender);
|
||||||
|
System.out.println("Subject: " + subject);
|
||||||
|
System.out.println(headers.size() + " distinct headers");
|
||||||
|
it = headers.entrySet().iterator();
|
||||||
|
while (it.hasNext())
|
||||||
|
{ // get each map entry
|
||||||
|
Map.Entry ntry = (Map.Entry)(it.next());
|
||||||
|
String name = ntry.getKey().toString();
|
||||||
|
List values = (List)(ntry.getValue());
|
||||||
|
System.out.println("\tName: " + name + " [" + values.size() + " entries]");
|
||||||
|
Iterator it2 = values.iterator();
|
||||||
|
while (it2.hasNext())
|
||||||
|
System.out.println("\t\t" + it2.next().toString());
|
||||||
|
|
||||||
|
} // end while
|
||||||
|
|
||||||
|
System.out.println("Message text: " + text.length() + " characters");
|
||||||
|
System.out.println(attachments.size() + " attachments");
|
||||||
|
it = attachments.iterator();
|
||||||
|
while (it.hasNext())
|
||||||
|
{ // dump the attachments, too
|
||||||
|
AttachmentData ad = (AttachmentData)(it.next());
|
||||||
|
ad.dump();
|
||||||
|
|
||||||
|
} // end while
|
||||||
|
|
||||||
|
System.out.println("===== End Message Data =====");
|
||||||
|
|
||||||
|
} // end dump
|
||||||
|
|
||||||
} // end class MessageData
|
} // end class MessageData
|
||||||
|
|
Loading…
Reference in New Issue
Block a user