You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ie...@apache.org on 2012/12/26 15:53:15 UTC
svn commit: r1425929 - in /james/mailet/trunk/standard/src:
main/java/org/apache/james/mailet/standard/mailets/
main/java/org/apache/james/mailet/standard/matchers/
test/java/org/apache/james/mailet/standard/matchers/
Author: ieugen
Date: Wed Dec 26 14:53:14 2012
New Revision: 1425929
URL: http://svn.apache.org/viewvc?rev=1425929&view=rev
Log:
MAILET-90 Code clean-up - IDE analisys
Modified:
james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/AddSubjectPrefix.java
james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/ClamAVScan.java
james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/ClassifyBounce.java
james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/HeadersToHTTP.java
james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/LogMessage.java
james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/OnlyText.java
james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/RemoveMailAttribute.java
james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/UnwrapText.java
james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/UseHeaderRecipients.java
james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/matchers/AttachmentFileNameIs.java
james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/matchers/HasHeader.java
james/mailet/trunk/standard/src/test/java/org/apache/james/mailet/standard/matchers/AbstractSenderIsTest.java
james/mailet/trunk/standard/src/test/java/org/apache/james/mailet/standard/matchers/RecipientIsTest.java
james/mailet/trunk/standard/src/test/java/org/apache/james/mailet/standard/matchers/UserIsTest.java
Modified: james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/AddSubjectPrefix.java
URL: http://svn.apache.org/viewvc/james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/AddSubjectPrefix.java?rev=1425929&r1=1425928&r2=1425929&view=diff
==============================================================================
--- james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/AddSubjectPrefix.java (original)
+++ james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/AddSubjectPrefix.java Wed Dec 26 14:53:14 2012
@@ -18,20 +18,19 @@
****************************************************************/
-
package org.apache.james.mailet.standard.mailets;
-import javax.mail.MessagingException;
-import javax.mail.internet.MimeMessage;
-
-import org.apache.mailet.base.GenericMailet;
import org.apache.mailet.Mail;
+import org.apache.mailet.base.GenericMailet;
import org.apache.mailet.base.RFC2822Headers;
+import javax.mail.MessagingException;
+import javax.mail.internet.MimeMessage;
+
/**
* Add an prefix (tag) to the subject of a message <br>
* <br>
- *
+ * <p/>
* Sample Configuration: <br>
* <pre><code>
* <mailet match="RecipientIs=robot@james.apache.org" class="TagMessage">
@@ -57,12 +56,9 @@ public class AddSubjectPrefix extends Ge
/**
* Takes the message and adds a prefix to the subject
- *
- * @param mail
- * the mail being processed
- *
- * @throws MessagingException
- * if an error arises during message processing
+ *
+ * @param mail the mail being processed
+ * @throws MessagingException if an error arises during message processing
*/
public void service(Mail mail) throws MessagingException {
String newSubject;
@@ -115,15 +111,14 @@ public class AddSubjectPrefix extends Ge
* It attempts to determine the charset used to encode an "unstructured" RFC
* 822 header (like Subject). The encoding is specified in RFC 2047. If it
* cannot determine or the the text is not encoded then it returns null.
- *
+ * <p/>
* Here is an example raw text: Subject:
* =?iso-8859-2?Q?leg=FAjabb_pr=F3ba_l=F5elemmel?=
- *
+ * <p/>
* TODO: Should we include this in a util class ?
- *
- * @param rawText
- * the raw (not decoded) value of the header. Null means that the
- * header was not present (in this case it always return null).
+ *
+ * @param rawText the raw (not decoded) value of the header. Null means that the
+ * header was not present (in this case it always return null).
* @return the MIME charset name or null if no encoding applied
*/
static private String determineMailHeaderEncodingCharset(String rawText) {
@@ -144,9 +139,7 @@ public class AddSubjectPrefix extends Ge
return null; // there must be one after encoding
if (-1 == rawText.indexOf("?=", iThirdQuestionMark + 1))
return null; // closing tag
- String mimeCharset = rawText.substring(iCharsetBegin,
- iSecondQuestionMark);
- return mimeCharset;
+ return rawText.substring(iCharsetBegin, iSecondQuestionMark);
}
}
Modified: james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/ClamAVScan.java
URL: http://svn.apache.org/viewvc/james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/ClamAVScan.java?rev=1425929&r1=1425928&r2=1425929&view=diff
==============================================================================
--- james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/ClamAVScan.java (original)
+++ james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/ClamAVScan.java Wed Dec 26 14:53:14 2012
@@ -18,17 +18,15 @@
****************************************************************/
-
package org.apache.james.mailet.standard.mailets;
-import org.apache.mailet.base.RFC2822Headers;
-import org.apache.mailet.base.GenericMailet;
import org.apache.mailet.Mail;
import org.apache.mailet.MailAddress;
+import org.apache.mailet.base.GenericMailet;
+import org.apache.mailet.base.RFC2822Headers;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
-
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
@@ -51,7 +49,7 @@ import java.util.Set;
/**
* <P>Does an antivirus scan check using a ClamAV daemon (CLAMD)</P>
- *
+ * <p/>
* <P> Interacts directly with the daemon using the "stream" method,
* which should have the lowest possible overhead.</P>
* <P>The CLAMD daemon will typically reside on <I>localhost</I>, but could reside on a
@@ -60,172 +58,172 @@ import java.util.Set;
* server and on different IP number.
* In such case a DNS host name with multiple IP addresses (round-robin load sharing)
* is supported by the mailet (but on the same port number).</P>
- *
+ * <p/>
* <P>Handles the following init parameters:</P>
* <UL>
- * <LI><CODE><debug></CODE>.</LI>
- * <LI><CODE><host></CODE>: the host name of the server where CLAMD runs. It can either be
- * a machine name, such as
- * "<code>java.sun.com</code>", or a textual representation of its
- * IP address. If a literal IP address is supplied, only the
- * validity of the address format is checked.
- * If the machine name resolves to multiple IP addresses, <I>round-robin load sharing</I> will
- * be used.
- * The default is <CODE>localhost</CODE>.</LI>
- * <LI><CODE><port></CODE>: the port on which CLAMD listens. The default is <I>3310</I>.</LI>
- * <LI><CODE><maxPings></CODE>: the maximum number of connection retries during startup.
- * If the value is <I>0</I> no startup test will be done.
- * The default is <I>6</I>.</LI>
- * <LI><CODE><pingIntervalMilli></CODE>: the interval (in milliseconds)
- * between each connection retry during startup.
- * The default is <I>30000</I> (30 seconds).</LI>
- * <LI><CODE><streamBufferSize></CODE>: the BufferedOutputStream buffer size to use
- * writing to the <I>stream connection</I>. The default is <I>8192</I>.</LI>
+ * <LI><CODE><debug></CODE>.</LI>
+ * <LI><CODE><host></CODE>: the host name of the server where CLAMD runs. It can either be
+ * a machine name, such as
+ * "<code>java.sun.com</code>", or a textual representation of its
+ * IP address. If a literal IP address is supplied, only the
+ * validity of the address format is checked.
+ * If the machine name resolves to multiple IP addresses, <I>round-robin load sharing</I> will
+ * be used.
+ * The default is <CODE>localhost</CODE>.</LI>
+ * <LI><CODE><port></CODE>: the port on which CLAMD listens. The default is <I>3310</I>.</LI>
+ * <LI><CODE><maxPings></CODE>: the maximum number of connection retries during startup.
+ * If the value is <I>0</I> no startup test will be done.
+ * The default is <I>6</I>.</LI>
+ * <LI><CODE><pingIntervalMilli></CODE>: the interval (in milliseconds)
+ * between each connection retry during startup.
+ * The default is <I>30000</I> (30 seconds).</LI>
+ * <LI><CODE><streamBufferSize></CODE>: the BufferedOutputStream buffer size to use
+ * writing to the <I>stream connection</I>. The default is <I>8192</I>.</LI>
* </UL>
- *
+ * <p/>
* <P>The actions performed are as follows:</P>
* <UL>
- * <LI>During initialization:</LI>
- * <OL>
- * <LI>Gets all <CODE>config.xml</CODE> parameters, handling the defaults;</LI>
- * <LI>resolves the <CODE><host></CODE> parameter, creating the round-robin IP list;</LI>
- * <LI>connects to CLAMD at the first IP in the round-robin list, on
- * the specified <CODE><port></CODE>;</LI>
- * <LI>if unsuccessful, retries every <CODE><pingIntervalMilli></CODE> milliseconds up to
- * <CODE><maxPings></CODE> times;</LI>
- * <LI>sends a <CODE>PING</CODE> request;</LI>
- * <LI>waits for a <CODE>PONG</CODE> answer;</LI>
- * <LI>repeats steps 3-6 for every other IP resolved.
- * </OL>
- * <LI>For every mail</LI>
- * <OL>
- * <LI>connects to CLAMD at the "next" IP in the round-robin list, on
- * the specified <CODE><port></CODE>, and increments the "next" index;
- * if the connection request is not accepted tries with the next one
- * in the list unless all of them have failed;</LI>
- * <LI>sends a "<CODE>STREAM</CODE>" request;</LI>
- * <LI>parses the "<CODE>PORT <I>streamPort</I></CODE>" answer obtaining the port number;</LI>
- * <LI>makes a second connection (the <I>stream connection</I>) to CLAMD at the same host (or IP)
- * on the <I>streamPort</I> just obtained;</LI>
- * <LI>sends the mime message to CLAMD (using {@link MimeMessage#writeTo(java.io.OutputStream)})
- * through the <I>stream connection</I>;</LI>
- * <LI>closes the <I>stream connection</I>;</LI>
- * <LI>gets the "<CODE>OK</CODE>" or "<CODE>... FOUND</CODE>" answer from the main connection;</LI>
- * <LI>closes the main connection;</LI>
- * <LI>sets the "<CODE>org.apache.james.infected</CODE>" <I>mail attribute</I> to either
- * "<CODE>true</CODE>" or "<CODE>false</CODE>";</LI>
- * <LI>adds the "<CODE>X-MessageIsInfected</CODE>" <I>header</I> to either
- * "<CODE>true</CODE>" or "<CODE>false</CODE>";</LI>
- * </OL>
+ * <LI>During initialization:</LI>
+ * <OL>
+ * <LI>Gets all <CODE>config.xml</CODE> parameters, handling the defaults;</LI>
+ * <LI>resolves the <CODE><host></CODE> parameter, creating the round-robin IP list;</LI>
+ * <LI>connects to CLAMD at the first IP in the round-robin list, on
+ * the specified <CODE><port></CODE>;</LI>
+ * <LI>if unsuccessful, retries every <CODE><pingIntervalMilli></CODE> milliseconds up to
+ * <CODE><maxPings></CODE> times;</LI>
+ * <LI>sends a <CODE>PING</CODE> request;</LI>
+ * <LI>waits for a <CODE>PONG</CODE> answer;</LI>
+ * <LI>repeats steps 3-6 for every other IP resolved.
+ * </OL>
+ * <LI>For every mail</LI>
+ * <OL>
+ * <LI>connects to CLAMD at the "next" IP in the round-robin list, on
+ * the specified <CODE><port></CODE>, and increments the "next" index;
+ * if the connection request is not accepted tries with the next one
+ * in the list unless all of them have failed;</LI>
+ * <LI>sends a "<CODE>STREAM</CODE>" request;</LI>
+ * <LI>parses the "<CODE>PORT <I>streamPort</I></CODE>" answer obtaining the port number;</LI>
+ * <LI>makes a second connection (the <I>stream connection</I>) to CLAMD at the same host (or IP)
+ * on the <I>streamPort</I> just obtained;</LI>
+ * <LI>sends the mime message to CLAMD (using {@link MimeMessage#writeTo(java.io.OutputStream)})
+ * through the <I>stream connection</I>;</LI>
+ * <LI>closes the <I>stream connection</I>;</LI>
+ * <LI>gets the "<CODE>OK</CODE>" or "<CODE>... FOUND</CODE>" answer from the main connection;</LI>
+ * <LI>closes the main connection;</LI>
+ * <LI>sets the "<CODE>org.apache.james.infected</CODE>" <I>mail attribute</I> to either
+ * "<CODE>true</CODE>" or "<CODE>false</CODE>";</LI>
+ * <LI>adds the "<CODE>X-MessageIsInfected</CODE>" <I>header</I> to either
+ * "<CODE>true</CODE>" or "<CODE>false</CODE>";</LI>
+ * </OL>
* </UL>
- *
+ * <p/>
* <P>Some notes regarding <a href="http://www.clamav.net/">clamav.conf</a>:</p>
* <UL>
- * <LI><CODE>LocalSocket</CODE> must be commented out</LI>
- * <LI><CODE>TCPSocket</CODE> must be set to a port# (typically 3310)</LI>
- * <LI><CODE>StreamMaxLength</CODE> must be >= the James config.xml parameter
- * <<CODE>maxmessagesize</CODE>> in SMTP <<CODE>handler</CODE>></LI>
- * <LI><CODE>MaxThreads</CODE> should? be >= the James config.xml parameter
- * <<CODE>threads</CODE>> in <<CODE>spoolmanager</CODE>></LI>
- * <LI><CODE>ScanMail</CODE> must be uncommented</LI>
+ * <LI><CODE>LocalSocket</CODE> must be commented out</LI>
+ * <LI><CODE>TCPSocket</CODE> must be set to a port# (typically 3310)</LI>
+ * <LI><CODE>StreamMaxLength</CODE> must be >= the James config.xml parameter
+ * <<CODE>maxmessagesize</CODE>> in SMTP <<CODE>handler</CODE>></LI>
+ * <LI><CODE>MaxThreads</CODE> should? be >= the James config.xml parameter
+ * <<CODE>threads</CODE>> in <<CODE>spoolmanager</CODE>></LI>
+ * <LI><CODE>ScanMail</CODE> must be uncommented</LI>
* </UL>
- *
+ * <p/>
* <P>Here follows an example of config.xml definitions deploying CLAMD on localhost,
* and handling the infected messages:</P>
* <PRE><CODE>
- *
+ * <p/>
* ...
- *
- * <!-- Do an antivirus scan -->
- * <mailet match="All" class="ClamAVScan" onMailetException="ignore"/>
- *
- * <!-- If infected go to virus processor -->
- * <mailet match="HasMailAttributeWithValue=org.apache.james.infected, true" class="ToProcessor">
- * <processor> virus </processor>
- * </mailet>
- *
- * <!-- Check attachment extensions for possible viruses -->
- * <mailet match="AttachmentFileNameIs=-d -z *.exe *.com *.bat *.cmd *.pif *.scr *.vbs *.avi *.mp3 *.mpeg *.shs" class="ToProcessor">
- * <processor> bad-extensions </processor>
- * </mailet>
- *
+ * <p/>
+ * <!-- Do an antivirus scan -->
+ * <mailet match="All" class="ClamAVScan" onMailetException="ignore"/>
+ * <p/>
+ * <!-- If infected go to virus processor -->
+ * <mailet match="HasMailAttributeWithValue=org.apache.james.infected, true" class="ToProcessor">
+ * <processor> virus </processor>
+ * </mailet>
+ * <p/>
+ * <!-- Check attachment extensions for possible viruses -->
+ * <mailet match="AttachmentFileNameIs=-d -z *.exe *.com *.bat *.cmd *.pif *.scr *.vbs *.avi *.mp3 *.mpeg *.shs" class="ToProcessor">
+ * <processor> bad-extensions </processor>
+ * </mailet>
+ * <p/>
* ...
- *
+ * <p/>
* <!-- Messages containing viruses -->
* <processor name="virus">
- *
- * <!-- To avoid a loop while bouncing -->
- * <mailet match="All" class="SetMailAttribute">
- * <org.apache.james.infected>true, bouncing</org.apache.james.infected>
- * </mailet>
- *
- * <mailet match="SMTPAuthSuccessful" class="Bounce">
- * <sender>bounce-admin@xxx.com</sender>
- * <inline>heads</inline>
- * <attachment>none</attachment>
- * <notice> Warning: We were unable to deliver the message below because it was found infected by virus(es). </notice>
- * </mailet>
- *
- * <!--
- * <mailet match="All" class="ToRepository">
- * <repositoryPath>file://var/mail/infected/</repositoryPath>
- * </mailet>
- * -->
- *
- * <mailet match="All" class="Null" />
+ * <p/>
+ * <!-- To avoid a loop while bouncing -->
+ * <mailet match="All" class="SetMailAttribute">
+ * <org.apache.james.infected>true, bouncing</org.apache.james.infected>
+ * </mailet>
+ * <p/>
+ * <mailet match="SMTPAuthSuccessful" class="Bounce">
+ * <sender>bounce-admin@xxx.com</sender>
+ * <inline>heads</inline>
+ * <attachment>none</attachment>
+ * <notice> Warning: We were unable to deliver the message below because it was found infected by virus(es). </notice>
+ * </mailet>
+ * <p/>
+ * <!--
+ * <mailet match="All" class="ToRepository">
+ * <repositoryPath>file://var/mail/infected/</repositoryPath>
+ * </mailet>
+ * -->
+ * <p/>
+ * <mailet match="All" class="Null" />
* </processor>
* </CODE></PRE>
*
* @version 2.2.1
- * @since 2.2.1
* @see <a href="http://www.clamav.net/">ClamAV Home Page</a>
* @see <a href="http://www.sosdg.org/clamav-win32/">ClamAV For Windows</a>
+ * @since 2.2.1
*/
public class ClamAVScan extends GenericMailet {
-
+
private static final int DEFAULT_PORT = 3310;
-
+
private static final int DEFAULT_MAX_PINGS = 6;
-
+
private static final int DEFAULT_PING_INTERVAL_MILLI = 30000;
-
+
private static final int DEFAULT_STREAM_BUFFER_SIZE = 8192;
-
+
//private static final int DEFAULT_CONNECTION_TIMEOUT = 20000;
private static final String STREAM_PORT_STRING = "PORT ";
-
+
private static final String FOUND_STRING = "FOUND";
-
+
private static final String MAIL_ATTRIBUTE_NAME = "org.apache.james.infected";
-
+
private static final String HEADER_NAME = "X-MessageIsInfected";
-
+
/**
* Holds value of property debug.
*/
private boolean debug;
-
+
/**
* Holds value of property host.
*/
private String host;
-
+
/**
* Holds value of property port.
*/
private int port;
-
+
/**
* Holds value of property maxPings.
*/
private int maxPings;
-
+
/**
* Holds value of property pingIntervalMilli.
*/
private int pingIntervalMilli;
-
+
/**
* Holds value of property streamBufferSize.
*/
@@ -235,7 +233,7 @@ public class ClamAVScan extends GenericM
* Holds value of property addresses.
*/
private InetAddress[] addresses;
-
+
/**
* Holds the index of the next address to connect to
*/
@@ -249,21 +247,22 @@ public class ClamAVScan extends GenericM
public String getMailetInfo() {
return "Antivirus Check using ClamAV (CLAMD)";
}
-
- /** Gets the expected init parameters. */
- protected String[] getAllowedInitParameters() {
- String[] allowedArray = {
- // "static",
- "debug",
- "host",
- "port",
- "maxPings",
- "pingIntervalMilli",
- "streamBufferSize"
+
+ /**
+ * Gets the expected init parameters.
+ */
+ protected String[] getAllowedInitParameters() {
+ return new String[]{
+ // "static",
+ "debug",
+ "host",
+ "port",
+ "maxPings",
+ "pingIntervalMilli",
+ "streamBufferSize"
};
- return allowedArray;
}
-
+
/**
* Initializer for property debug.
*/
@@ -271,25 +270,28 @@ public class ClamAVScan extends GenericM
String debugParam = getInitParameter("debug");
setDebug((debugParam == null) ? false : Boolean.valueOf(debugParam));
}
-
+
/**
* Getter for property debug.
+ *
* @return Value of property debug.
*/
public boolean isDebug() {
return this.debug;
}
-
+
/**
* Setter for property debug.
+ *
* @param debug New value of property debug.
*/
public void setDebug(boolean debug) {
this.debug = debug;
}
-
+
/**
* Initializer for property host.
+ *
* @throws UnknownHostException if unable to resolve the host name, or if invalid
*/
protected void initHost() throws UnknownHostException {
@@ -298,33 +300,35 @@ public class ClamAVScan extends GenericM
log("host: " + getHost());
}
}
-
+
/**
* Getter for property host.
+ *
* @return Value of property host.
*/
public String getHost() {
-
+
return this.host;
}
-
+
/**
* Setter for property host.
* Resolves also the host name into the corresponding IP addresses, issues
* a {@link #setAddresses} and resets the <CODE>nextAddressIndex</CODE>
* variable to <I>0</I> for dealing with <I>round-robin</I>.
+ *
* @param host New value of property host.
* @throws UnknownHostException if unable to resolve the host name, or if invalid
*/
public void setHost(String host) throws UnknownHostException {
-
+
this.host = host;
-
+
setAddresses(InetAddress.getAllByName(host));
-
+
nextAddressIndex = 0;
}
-
+
/**
* Initializer for property port.
*/
@@ -335,25 +339,27 @@ public class ClamAVScan extends GenericM
log("port: " + getPort());
}
}
-
+
/**
* Getter for property port.
+ *
* @return Value of property port.
*/
public int getPort() {
-
+
return this.port;
}
-
+
/**
* Setter for property port.
+ *
* @param port New value of property port.
*/
public void setPort(int port) {
-
+
this.port = port;
}
-
+
/**
* Initializer for property maxPings.
*/
@@ -364,25 +370,27 @@ public class ClamAVScan extends GenericM
log("maxPings: " + getMaxPings());
}
}
-
+
/**
* Getter for property maxPings.
+ *
* @return Value of property maxPings.
*/
public int getMaxPings() {
-
+
return this.maxPings;
}
-
+
/**
* Setter for property maxPings.
+ *
* @param maxPings New value of property maxPings.
*/
public void setMaxPings(int maxPings) {
-
+
this.maxPings = maxPings;
}
-
+
/**
* Initializer for property pingIntervalMilli.
*/
@@ -393,25 +401,27 @@ public class ClamAVScan extends GenericM
log("pingIntervalMilli: " + getPingIntervalMilli());
}
}
-
+
/**
* Getter for property pingIntervalMilli.
+ *
* @return Value of property pingIntervalMilli.
*/
public int getPingIntervalMilli() {
-
+
return this.pingIntervalMilli;
}
-
+
/**
* Setter for property pingIntervalMilli.
+ *
* @param pingIntervalMilli New value of property pingIntervalMilli.
*/
public void setPingIntervalMilli(int pingIntervalMilli) {
-
+
this.pingIntervalMilli = pingIntervalMilli;
}
-
+
/**
* Initializer for property streamBufferSize.
*/
@@ -422,27 +432,30 @@ public class ClamAVScan extends GenericM
log("streamBufferSize: " + getStreamBufferSize());
}
}
-
+
/**
* Getter for property streamBufferSize.
+ *
* @return Value of property streamBufferSize.
*/
public int getStreamBufferSize() {
-
+
return this.streamBufferSize;
}
-
+
/**
* Setter for property streamBufferSize.
+ *
* @param streamBufferSize New value of property streamBufferSize.
*/
public void setStreamBufferSize(int streamBufferSize) {
-
+
this.streamBufferSize = streamBufferSize;
}
-
+
/**
* Indexed getter for property addresses.
+ *
* @param index Index of the property.
* @return Value of the property at <CODE>index</CODE>.
*/
@@ -453,6 +466,7 @@ public class ClamAVScan extends GenericM
/**
* Getter for property addresses.
+ *
* @return Value of property addresses.
*/
protected InetAddress[] getAddresses() {
@@ -462,34 +476,37 @@ public class ClamAVScan extends GenericM
/**
* Setter for property addresses.
+ *
* @param addresses New value of property addresses.
*/
protected void setAddresses(InetAddress[] addresses) {
this.addresses = addresses;
}
-
+
/**
* Getter for property nextAddress.
- *
+ * <p/>
* Gets the address of the next CLAMD server to connect to in this round, using round-robin.
* Increments the nextAddressIndex for the next round.
+ *
* @return Value of property address.
*/
protected synchronized InetAddress getNextAddress() {
-
+
InetAddress address = getAddresses(nextAddressIndex);
-
+
nextAddressIndex++;
if (nextAddressIndex >= getAddressesCount()) {
nextAddressIndex = 0;
}
-
+
return address;
}
/**
* Getter for property addressesCount.
+ *
* @return Value of property addressesCount.
*/
public int getAddressesCount() {
@@ -498,18 +515,19 @@ public class ClamAVScan extends GenericM
/**
* Gets a Socket connected to CLAMD.
- *
+ * <p/>
* Will loop though the round-robin address list until the first one accepts
* the connection.
+ *
* @return a socket connected to CLAMD
* @throws MessagingException if no CLAMD in the round-robin address list has accepted the connection
*/
protected Socket getClamdSocket() throws MessagingException {
-
+
InetAddress address;
-
+
Set<InetAddress> usedAddresses = new HashSet<InetAddress>(getAddressesCount());
- for (;;) {
+ for (; ; ) {
// this do-while loop is needed because other threads could in the meantime
// calling getNextAddress(), and because of that the current thread may skip
// some working address
@@ -527,44 +545,43 @@ public class ClamAVScan extends GenericM
} catch (IOException ioe) {
log("Exception caught acquiring main socket to CLAMD on "
+ address + " on port " + getPort() + ": " + ioe.getMessage());
- address = getNextAddress();
+ getNextAddress();
// retry
}
}
}
-
+
/**
* Mailet initialization routine.
*/
public void init() throws MessagingException {
-
+
// check that all init parameters have been declared in allowedInitParameters
checkInitParameters(getAllowedInitParameters());
-
+
try {
initDebug();
if (isDebug()) {
log("Initializing");
}
-
+
initHost();
initPort();
initMaxPings();
initPingIntervalMilli();
initStreamBufferSize();
-
+
// If "maxPings is > ping the CLAMD server to check if it is up
if (getMaxPings() > 0) {
ping();
}
-
+
} catch (Exception e) {
log("Exception thrown", e);
throw new MessagingException("Exception thrown", e);
}
-
}
-
+
/**
* Scans the mail.
*
@@ -572,14 +589,14 @@ public class ClamAVScan extends GenericM
* @throws MessagingException if a problem arises
*/
public void service(Mail mail) throws MessagingException {
-
+
// if already checked no action
if (mail.getAttribute(MAIL_ATTRIBUTE_NAME) != null) {
return;
}
-
+
MimeMessage mimeMessage = mail.getMessage();
-
+
if (mimeMessage == null) {
log("Null MimeMessage. Will send to ghost");
// write mail info to log
@@ -587,45 +604,45 @@ public class ClamAVScan extends GenericM
mail.setState(Mail.GHOST);
return;
}
-
+
// get the socket
Socket socket = getClamdSocket();
BufferedReader reader = null;
PrintWriter writer = null;
Socket streamSocket = null;
BufferedOutputStream bos = null;
-
+
try {
-
+
// prepare the reader and writer for the commands
reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), "ASCII"));
writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())), true);
-
+
// write a request for a port to use for streaming out the data to scan
writer.println("STREAM");
writer.flush();
-
+
// parse and get the "stream" port#
int streamPort = getStreamPortFromAnswer(reader.readLine());
-
+
// get the "stream" socket and the related (buffered) output stream
streamSocket = new Socket(socket.getInetAddress(), streamPort);
bos = new BufferedOutputStream(streamSocket.getOutputStream(), getStreamBufferSize());
-
+
// stream out the message to the scanner
mimeMessage.writeTo(bos);
bos.flush();
bos.close();
streamSocket.close();
-
+
String answer;
boolean virusFound = false;
String logMessage = "";
- for (;;) {
+ for (; ; ) {
answer = reader.readLine();
if (answer != null) {
answer = answer.trim();
-
+
// if a virus is found the answer will be '... FOUND'
if (answer.substring(answer.length() - FOUND_STRING.length()).equals(FOUND_STRING)) {
virusFound = true;
@@ -636,10 +653,10 @@ public class ClamAVScan extends GenericM
break;
}
}
-
+
reader.close();
writer.close();
-
+
if (virusFound) {
String errorMessage = mail.getErrorMessage();
if (errorMessage == null) {
@@ -649,37 +666,37 @@ public class ClamAVScan extends GenericM
}
StringBuilder sb = new StringBuilder(errorMessage);
sb.append(logMessage).append("\r\n");
-
+
// write mail and message info to log
logMailInfo(mail);
logMessageInfo(mimeMessage);
-
+
// mark the mail with a mail attribute to check later on by other matchers/mailets
mail.setAttribute(MAIL_ATTRIBUTE_NAME, "true");
-
+
// sets the error message to be shown in any "notifyXxx" message
mail.setErrorMessage(sb.toString());
-
+
// mark the message with a header string
mimeMessage.setHeader(HEADER_NAME, "true");
-
+
} else {
if (isDebug()) {
log("OK (by CLAMD on " + socket.getInetAddress() + ")");
}
mail.setAttribute(MAIL_ATTRIBUTE_NAME, "false");
-
+
// mark the message with a header string
mimeMessage.setHeader(HEADER_NAME, "false");
-
+
}
-
+
try {
saveChanges(mimeMessage);
} catch (Exception ex) {
log("Exception caught while saving changes (header) to the MimeMessage. Ignoring ...", ex);
}
-
+
} catch (Exception ex) {
log("Exception caught calling CLAMD on " + socket.getInetAddress() + ": " + ex.getMessage(), ex);
throw new MessagingException("Exception caught", ex);
@@ -690,111 +707,99 @@ public class ClamAVScan extends GenericM
shutdownSocket(streamSocket);
shutdownSocket(socket);
}
-
+
}
-
+
/**
* Unconditionally close an <code>OutputStream</code>.
* Equivalent to {@link OutputStream#close()}, except any exceptions will be ignored.
+ *
* @param output A (possibly null) OutputStream
*/
- private static void shutdownStream( final OutputStream output )
- {
- if( null == output )
- {
+ private static void shutdownStream(final OutputStream output) {
+ if (null == output) {
return;
}
- try
- {
+ try {
output.close();
- }
- catch( final IOException ioe )
- {
+ } catch (final IOException ignored) {
}
}
-
+
/**
* Unconditionally close an <code>Socket</code>.
* Equivalent to {@link Socket#close()}, except any exceptions will be ignored.
+ *
* @param socket A (possibly null) Socket
*/
- private static void shutdownSocket( final Socket socket ) {
- if( null == socket ) {
+ private static void shutdownSocket(final Socket socket) {
+ if (null == socket) {
return;
}
try {
socket.close();
- } catch( final IOException ioe ){
+ } catch (final IOException ioe) {
}
}
-
+
/**
* Unconditionally close an <code>Writer</code>.
* Equivalent to {@link Writer#close()}, except any exceptions will be ignored.
*
* @param output A (possibly null) Writer
*/
- private void shutdownWriter( final Writer output )
- {
- if( null == output )
- {
+ private void shutdownWriter(final Writer output) {
+ if (null == output) {
return;
}
- try
- {
+ try {
output.close();
- }
- catch( final IOException ioe )
- {
+ } catch (final IOException ioe) {
}
}
-
+
/**
* Unconditionally close an <code>Reader</code>.
* Equivalent to {@link Reader#close()}, except any exceptions will be ignored.
*
* @param input A (possibly null) Reader
*/
- private void shutdownReader( final Reader input )
- {
- if( null == input )
- {
+ private void shutdownReader(final Reader input) {
+ if (null == input) {
return;
}
- try
- {
+ try {
input.close();
- }
- catch( final IOException ioe )
- {
+ } catch (final IOException ioe) {
}
}
-
+
/**
* Tries to "ping" all the CLAMD daemons to
* check if they are up and accepting requests.
- **/
-
+ */
+
protected void ping() throws Exception {
-
+
for (int i = 0; i < getAddressesCount(); i++) {
ping(getAddresses(i));
}
}
-
+
/**
* Tries (and retries as specified up to 'getMaxPings()') to "ping" the specified CLAMD daemon to
* check if it is up and accepting requests.
+ *
* @param address the address to "ping"
*/
protected void ping(InetAddress address) throws Exception {
Socket socket = null;
-
+
int ping = 1;
for (; ; ) {
if (isDebug()) {
@@ -814,23 +819,23 @@ public class ClamAVScan extends GenericM
}
}
}
-
+
// if 'socket' is still null then 'maxPings' has been exceeded
if (socket == null) {
throw new ConnectException("maxPings exceeded: " + getMaxPings() + ". Giving up. The clamd daemon seems not to be running");
}
-
+
try {
// get the reader and writer to ping and receive pong
BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), "ASCII"));
PrintWriter writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())), true);
-
+
log("Sending: \"PING\" to " + address + " ...");
writer.println("PING");
writer.flush();
-
+
boolean pongReceived = false;
- for (;;) {
+ for (; ; ) {
String answer = reader.readLine();
if (answer != null) {
answer = answer.trim();
@@ -839,15 +844,15 @@ public class ClamAVScan extends GenericM
if (answer.equals("PONG")) {
pongReceived = true;
}
-
+
} else {
break;
}
}
-
+
reader.close();
writer.close();
-
+
if (!pongReceived) {
throw new ConnectException("Bad answer from \"PING\" probe: expecting \"PONG\"");
}
@@ -855,7 +860,7 @@ public class ClamAVScan extends GenericM
socket.close();
}
}
-
+
/**
* Parses the answer from a STREAM request and gets the port number.
*
@@ -868,17 +873,17 @@ public class ClamAVScan extends GenericM
try {
port = Integer.parseInt(answer.substring(STREAM_PORT_STRING.length()));
} catch (NumberFormatException nfe) {
-
+
}
}
-
+
if (port <= 0) {
throw new ConnectException("\"PORT nn\" expected - unable to parse: " + "\"" + answer + "\"");
}
-
+
return port;
}
-
+
/**
* Saves changes resetting the original message id.
*
@@ -893,11 +898,11 @@ public class ClamAVScan extends GenericM
}
private void logMailInfo(Mail mail) {
-
+
// writes the error message to the log
StringWriter sout = new StringWriter();
PrintWriter out = new PrintWriter(sout, true);
-
+
out.print("Mail details:");
out.print(" MAIL FROM: " + mail.getSender());
Iterator<MailAddress> rcptTo = mail.getRecipients().iterator();
@@ -905,18 +910,18 @@ public class ClamAVScan extends GenericM
while (rcptTo.hasNext()) {
out.print(", " + rcptTo.next());
}
-
+
log(sout.toString());
}
-
+
private void logMessageInfo(MimeMessage mimeMessage) {
-
+
// writes the error message to the log
StringWriter sout = new StringWriter();
PrintWriter out = new PrintWriter(sout, true);
-
+
out.println("MimeMessage details:");
-
+
try {
if (mimeMessage.getSubject() != null) {
out.println(" Subject: " + mimeMessage.getSubject());
@@ -954,10 +959,10 @@ public class ClamAVScan extends GenericM
if (mimeMessage.getLineCount() >= 0) {
out.print(", Number of lines: " + mimeMessage.getLineCount());
}
- } catch (MessagingException me) {
+ } catch (MessagingException me) {
log("Exception caught reporting message details", me);
}
-
+
log(sout.toString());
}
Modified: james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/ClassifyBounce.java
URL: http://svn.apache.org/viewvc/james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/ClassifyBounce.java?rev=1425929&r1=1425928&r2=1425929&view=diff
==============================================================================
--- james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/ClassifyBounce.java (original)
+++ james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/ClassifyBounce.java Wed Dec 26 14:53:14 2012
@@ -18,30 +18,28 @@
****************************************************************/
package org.apache.james.mailet.standard.mailets;
-import java.io.IOException;
-import java.util.StringTokenizer;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import org.apache.mailet.Mail;
+import org.apache.mailet.base.GenericMailet;
import javax.mail.BodyPart;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.internet.MimeMessage;
-
-import org.apache.mailet.Mail;
-import org.apache.mailet.base.GenericMailet;
+import java.io.IOException;
+import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* Assesses the message to determine if it was a hard or soft bounce, and if it was a soft bounce, something of its nature..
- *
+ * <p/>
* Sample configuration:
- *
+ * <p/>
* <mailet match="All" class="ClassifyBounce">
- * <headerName>X-MailetHeader</headerName>
+ * <headerName>X-MailetHeader</headerName>
* </mailet>
- *
*/
public class ClassifyBounce extends GenericMailet {
@@ -55,7 +53,7 @@ public class ClassifyBounce extends Gene
*/
public void init() throws MessagingException {
headerName = getInitParameter("headerName");
-
+
// Check if needed config values are used
if (headerName == null || headerName.equals("")) {
throw new MessagingException("Please configure a header name to contain the classification (if any).");
@@ -66,20 +64,19 @@ public class ClassifyBounce extends Gene
* Takes the message and adds a header to it.
*
* @param mail the mail being processed
- *
* @throws MessagingException if an error arises during message processing
*/
public void service(Mail mail) {
try {
- MimeMessage message = mail.getMessage () ;
+ MimeMessage message = mail.getMessage();
Classifier classifier = this.new Classifier(message);
String classification = classifier.getClassification();
//if ( !classification.equals("Normal") ) {
- message.setHeader(headerName, classification);
- message.saveChanges();
+ message.setHeader(headerName, classification);
+ message.saveChanges();
//}
} catch (javax.mail.MessagingException me) {
- log ("Error classifying message: " + me.getMessage());
+ log("Error classifying message: " + me.getMessage());
}
}
@@ -89,7 +86,7 @@ public class ClassifyBounce extends Gene
* @return a string describing this mailet
*/
public String getMailetInfo() {
- return "SetMimeHeader Mailet" ;
+ return "SetMimeHeader Mailet";
}
private class Classifier {
@@ -99,95 +96,113 @@ public class ClassifyBounce extends Gene
try {
text = getRawText(message.getContent());
} catch (IOException e) {
- throw(new MessagingException("Unable to extract message body. [" + e.getClass().getName() + "] " + e.getMessage()));
+ throw (new MessagingException("Unable to extract message body. [" + e.getClass().getName() + "] " + e.getMessage()));
}
}
public String getClassification() throws MessagingException {
String classification = "Normal";
- switch(assess()) {
- case TYPE_DELIVERY_FAILURE: classification = "Delivery failure"; break;
- case TYPE_MAILBOX_FULL: classification = "Mailbox full"; break;
- case TYPE_OUT_OF_OFFICE: classification = "Out of the office"; break;
+ switch (assess()) {
+ case TYPE_DELIVERY_FAILURE:
+ classification = "Delivery failure";
+ break;
+ case TYPE_MAILBOX_FULL:
+ classification = "Mailbox full";
+ break;
+ case TYPE_OUT_OF_OFFICE:
+ classification = "Out of the office";
+ break;
}
return classification;
}
-
+
private int assess() throws MessagingException {
-
+
int messageNature = TYPE_NORMAL;
-
+
boolean outOfOffice;
boolean mailBoxFull = false;
boolean failure = false;
-
+
outOfOffice = assessMessageSubjectOutOfOffice();
- if (!outOfOffice) { mailBoxFull = assessMessageSubjectMailboxFull(); }
- if ((!outOfOffice) && (!mailBoxFull)) { failure = assessMessageSubjectFailure(); }
+ if (!outOfOffice) {
+ mailBoxFull = assessMessageSubjectMailboxFull();
+ }
+ if ((!outOfOffice) && (!mailBoxFull)) {
+ failure = assessMessageSubjectFailure();
+ }
if (!(outOfOffice || mailBoxFull || failure)) {
if (assessMessageUnreadable()) {
//get quite a few of these
failure = true;
} else {
outOfOffice = assessMessageOutOfOffice();
- if (!mailBoxFull) { mailBoxFull = assessMessageMailboxFull(); }
- if ((!outOfOffice) && (!mailBoxFull)) { failure = assessMessageFailure(); }
+ mailBoxFull = assessMessageMailboxFull();
+ if ((!outOfOffice) && (!mailBoxFull)) {
+ failure = assessMessageFailure();
+ }
}
}
- if (failure) { messageNature = TYPE_DELIVERY_FAILURE; }
- if (mailBoxFull) { messageNature = TYPE_MAILBOX_FULL; }
- if (outOfOffice) { messageNature = TYPE_OUT_OF_OFFICE; }
-
+ if (failure) {
+ messageNature = TYPE_DELIVERY_FAILURE;
+ }
+ if (mailBoxFull) {
+ messageNature = TYPE_MAILBOX_FULL;
+ }
+ if (outOfOffice) {
+ messageNature = TYPE_OUT_OF_OFFICE;
+ }
+
return messageNature;
}
-
+
private String getRawText(Object o) throws MessagingException, IOException {
-
+
String s = null;
-
- if (o instanceof Multipart){
- Multipart multi = (Multipart)o;
- for(int i=0; i < multi.getCount(); i++) {
+
+ if (o instanceof Multipart) {
+ Multipart multi = (Multipart) o;
+ for (int i = 0; i < multi.getCount(); i++) {
s = getRawText(multi.getBodyPart(i));
- if (s!=null) {
- if (s.length()>0) {
+ if (s != null) {
+ if (s.length() > 0) {
break;
}
}
- }
+ }
} else if (o instanceof BodyPart) {
- BodyPart aBodyContent = (BodyPart)o;
+ BodyPart aBodyContent = (BodyPart) o;
StringTokenizer aTypeTokenizer = new StringTokenizer(aBodyContent.getContentType(), "/");
- String abstractType = aTypeTokenizer.nextToken();
- if(abstractType.compareToIgnoreCase("MESSAGE")==0) {
- Message inlineMessage = (Message)aBodyContent.getContent();
+ String abstractType = aTypeTokenizer.nextToken();
+ if (abstractType.compareToIgnoreCase("MESSAGE") == 0) {
+ Message inlineMessage = (Message) aBodyContent.getContent();
s = getRawText(inlineMessage.getContent());
}
- if (abstractType.compareToIgnoreCase("APPLICATION")==0) {
- s = "Attached File: " + aBodyContent.getFileName();
+ if (abstractType.compareToIgnoreCase("APPLICATION") == 0) {
+ s = "Attached File: " + aBodyContent.getFileName();
}
- if (abstractType.compareToIgnoreCase("TEXT")==0) {
+ if (abstractType.compareToIgnoreCase("TEXT") == 0) {
try {
Object oS = aBodyContent.getContent();
- if (oS instanceof String) {
- s = (String)oS;
+ if (oS instanceof String) {
+ s = (String) oS;
} else {
- throw( new MessagingException("Unkown MIME Type (?): " + oS.getClass() ) );
+ throw (new MessagingException("Unkown MIME Type (?): " + oS.getClass()));
}
- } catch(Exception e) {
- throw( new MessagingException("Unable to read message contents (" + e.getMessage() + ")" ) );
+ } catch (Exception e) {
+ throw (new MessagingException("Unable to read message contents (" + e.getMessage() + ")"));
}
}
- if (abstractType.compareToIgnoreCase("MULTIPART")==0 ) {
+ if (abstractType.compareToIgnoreCase("MULTIPART") == 0) {
s = getRawText(aBodyContent.getContent());
}
}
-
+
if (o instanceof String) {
- s = (String)o;
+ s = (String) o;
}
-
+
// else {
// if (m.isMimeType("text/html")) {
// s = m.getContent().toString();
@@ -196,103 +211,162 @@ public class ClassifyBounce extends Gene
// s = m.getContent().toString();
// }
// }
-
+
return s;
}
-
+
private boolean assessMessageUnreadable() throws MessagingException {
boolean evil = false;
- if (subject.compareToIgnoreCase("Delivery Status Notification (Failure)")==0) {
+ if (subject.compareToIgnoreCase("Delivery Status Notification (Failure)") == 0) {
evil = findInBody("Unable to read message contents");
}
return evil;
}
-
+
private boolean assessMessageFailure() {
- boolean failed = false;
- if (!failed) { failed = findInBody("User[\\s]+unknown"); }
- if (!failed) { failed = findInBody("No[\\s]+such[\\s]+user"); }
- if (!failed) { failed = findInBody("550[\\s]+Invalid[\\s]+recipient"); }
- if (!failed) { failed = findInBody("550[\\s]+Bogus[\\s]+Address"); }
- if (!failed) { failed = findInBody("addresses[\\s]+were[\\s]+unknown"); }
- if (!failed) { failed = findInBody("user[\\s]+is[\\s]+no[\\s]+longer[\\s]+associated[\\s]+with[\\s]+this[\\s]+company"); }
- if (!failed) { failed = findInBody("Unknown[\\s]+Recipient"); }
- if (!failed) { failed = findInBody("destination[\\s]+addresses[\\s]+were[\\s]+unknown"); }
- if (!failed) { failed = findInBody("unknown[\\s]+user"); }
- if (!failed) { failed = findInBody("recipient[\\s]+name[\\s]+is[\\s]+not[\\s]+recognized"); }
- if (!failed) { failed = findInBody("not[\\s]+listed[\\s]+in[\\s]+Domino[\\s]+Directory"); }
- if (!failed) { failed = findInBody("Delivery[\\s]+Status[\\s]+Notification[\\s]+\\Q(\\EFailure\\Q)\\E"); }
- if (!failed) { failed = findInBody("This[\\s]+is[\\s]+a[\\s]+permanent[\\s]+error"); }
- if (!failed) { failed = findInBody("This[\\s]+account[\\s]+has[\\s]+been[\\s]+closed"); }
- if (!failed) { failed = findInBody("addresses[\\s]+had[\\s]+permanent[\\s]+fatal[\\s]+errors"); }
+ boolean failed = findInBody("User[\\s]+unknown");
+ if (!failed) {
+ failed = findInBody("No[\\s]+such[\\s]+user");
+ }
+ if (!failed) {
+ failed = findInBody("550[\\s]+Invalid[\\s]+recipient");
+ }
+ if (!failed) {
+ failed = findInBody("550[\\s]+Bogus[\\s]+Address");
+ }
+ if (!failed) {
+ failed = findInBody("addresses[\\s]+were[\\s]+unknown");
+ }
+ if (!failed) {
+ failed = findInBody("user[\\s]+is[\\s]+no[\\s]+longer[\\s]+associated[\\s]+with[\\s]+this[\\s]+company");
+ }
+ if (!failed) {
+ failed = findInBody("Unknown[\\s]+Recipient");
+ }
+ if (!failed) {
+ failed = findInBody("destination[\\s]+addresses[\\s]+were[\\s]+unknown");
+ }
+ if (!failed) {
+ failed = findInBody("unknown[\\s]+user");
+ }
+ if (!failed) {
+ failed = findInBody("recipient[\\s]+name[\\s]+is[\\s]+not[\\s]+recognized");
+ }
+ if (!failed) {
+ failed = findInBody("not[\\s]+listed[\\s]+in[\\s]+Domino[\\s]+Directory");
+ }
+ if (!failed) {
+ failed = findInBody("Delivery[\\s]+Status[\\s]+Notification[\\s]+\\Q(\\EFailure\\Q)\\E");
+ }
+ if (!failed) {
+ failed = findInBody("This[\\s]+is[\\s]+a[\\s]+permanent[\\s]+error");
+ }
+ if (!failed) {
+ failed = findInBody("This[\\s]+account[\\s]+has[\\s]+been[\\s]+closed");
+ }
+ if (!failed) {
+ failed = findInBody("addresses[\\s]+had[\\s]+permanent[\\s]+fatal[\\s]+errors");
+ }
return failed;
}
-
+
private boolean assessMessageMailboxFull() {
- boolean full = false;
- if (!full) { full = findInBody("Connection[\\s]+timed[\\s]+out"); }
- if (!full) { full = findInBody("Over[\\s]+quota"); }
- if (!full) { full = findInBody("size[\\s]+limit"); }
- if (!full) { full = findInBody("account[\\s]+is[\\s]+full"); }
- if (!full) { full = findInBody("diskspace[\\s]+quota"); }
- if (!full) { full = findInBody("rejected[\\s]+for[\\s]+policy[\\s]+reasons"); }
- if (!full) { full = findInBody("mailbox[\\s]+size[\\s]+limit"); }
+ boolean full = findInBody("Connection[\\s]+timed[\\s]+out");
+ if (!full) {
+ full = findInBody("Over[\\s]+quota");
+ }
+ if (!full) {
+ full = findInBody("size[\\s]+limit");
+ }
+ if (!full) {
+ full = findInBody("account[\\s]+is[\\s]+full");
+ }
+ if (!full) {
+ full = findInBody("diskspace[\\s]+quota");
+ }
+ if (!full) {
+ full = findInBody("rejected[\\s]+for[\\s]+policy[\\s]+reasons");
+ }
+ if (!full) {
+ full = findInBody("mailbox[\\s]+size[\\s]+limit");
+ }
return full;
}
-
+
private boolean assessMessageOutOfOffice() {
- boolean out = false;
//if ( subject.toLowerCase().startsWith("re:") ) {
- if (!out) { out = findInBody("out[\\s]+of[\\s]+the[\\s]+office"); }
- if (!out) { out = findInBody("out[\\s]+of[\\s]+my[\\s]+office"); }
- if (!out) { out = findInBody("back[\\s]+in[\\s]+the[\\s]+office"); }
- if (!out) { out = findInBody("I[\\s]+am[\\s]+overseas"); }
- if (!out) { out = findInBody("I[\\s]+am[\\s]+away"); }
- if (!out) { out = findInBody("I[\\s]+am[\\s]+on[\\s]+leave"); }
- if (!out) { out = (findInBody("Auto[\\s]*generated") && findInBody("on[\\s]+leave")); }
+ boolean out = findInBody("out[\\s]+of[\\s]+the[\\s]+office");
+ if (!out) {
+ out = findInBody("out[\\s]+of[\\s]+my[\\s]+office");
+ }
+ if (!out) {
+ out = findInBody("back[\\s]+in[\\s]+the[\\s]+office");
+ }
+ if (!out) {
+ out = findInBody("I[\\s]+am[\\s]+overseas");
+ }
+ if (!out) {
+ out = findInBody("I[\\s]+am[\\s]+away");
+ }
+ if (!out) {
+ out = findInBody("I[\\s]+am[\\s]+on[\\s]+leave");
+ }
+ if (!out) {
+ out = (findInBody("Auto[\\s]*generated") && findInBody("on[\\s]+leave"));
+ }
//}
return out;
}
-
+
private boolean assessMessageSubjectOutOfOffice() {
- boolean out = false;
- if (!out) { out = findInSubject("Out[\\s]+of[\\s]+office"); }
- if (!out) { out = findInSubject("Out[\\s]+of[\\s]+my[\\s]+office"); }
- if (!out) { out = findInSubject("out[\\s]+of[\\s]+the[\\s]+office"); }
- if (!out) { out = findInSubject("away[\\s]+from[\\s]+my[\\s]+mail"); }
- if (!out) { out = findInSubject("on[\\s]+leave"); }
+ boolean out = findInSubject("Out[\\s]+of[\\s]+office");
+ if (!out) {
+ out = findInSubject("Out[\\s]+of[\\s]+my[\\s]+office");
+ }
+ if (!out) {
+ out = findInSubject("out[\\s]+of[\\s]+the[\\s]+office");
+ }
+ if (!out) {
+ out = findInSubject("away[\\s]+from[\\s]+my[\\s]+mail");
+ }
+ if (!out) {
+ out = findInSubject("on[\\s]+leave");
+ }
return out;
}
-
+
private boolean assessMessageSubjectMailboxFull() {
- boolean full = false;
- if (!full) { full = ((findInSubject("Email[\\s]+message[\\s]+blocked") && findInSubject("Image[\\s]+File[\\s]+Type"))); }
- return full;
+ return ((findInSubject("Email[\\s]+message[\\s]+blocked") && findInSubject("Image[\\s]+File[\\s]+Type")));
}
-
+
private boolean assessMessageSubjectFailure() {
- boolean failed = false;
- if (!failed) { failed = ((findInSubject("DELIVERY[\\s]+FAILURE") && findInSubject("does[\\s]+not[\\s]+exist"))); }
- if (!failed) { failed = ((findInSubject("DELIVERY[\\s]+FAILURE") && findInSubject("not[\\s]+listed"))); }
- if (!failed) { failed = findInSubject("Permanent[\\s]+Delivery[\\s]+Failure"); }
- if (!failed) { failed = findInSubject("User[\\s]+unknown"); }
+ boolean failed = ((findInSubject("DELIVERY[\\s]+FAILURE") && findInSubject("does[\\s]+not[\\s]+exist")));
+ if (!failed) {
+ failed = ((findInSubject("DELIVERY[\\s]+FAILURE") && findInSubject("not[\\s]+listed")));
+ }
+ if (!failed) {
+ failed = findInSubject("Permanent[\\s]+Delivery[\\s]+Failure");
+ }
+ if (!failed) {
+ failed = findInSubject("User[\\s]+unknown");
+ }
if (!failed) { //no idea...
String s = subject.toLowerCase();
- failed = ( s.indexOf("user") > 0 && ( s.indexOf("unknown") > s.indexOf("user") ) );
+ failed = (s.indexOf("user") > 0 && (s.indexOf("unknown") > s.indexOf("user")));
}
return failed;
}
-
+
private boolean findInBody(String regExp) {
boolean retval = false;
- if (text!=null) {
+ if (text != null) {
Pattern pat = Pattern.compile(regExp, Pattern.CASE_INSENSITIVE);
Matcher m = pat.matcher(text);
retval = m.find();
}
return retval;
}
-
+
private boolean findInSubject(String regExp) {
Pattern pat = Pattern.compile(regExp, Pattern.CASE_INSENSITIVE);
Matcher m = pat.matcher(subject);
@@ -301,14 +375,14 @@ public class ClassifyBounce extends Gene
private String subject;
private String text;
-
+
public final static int TYPE_NORMAL = 1;
public final static int TYPE_SPAM = 2; // should be trapped elsewhere
public final static int TYPE_OUT_OF_OFFICE = 3;
public final static int TYPE_DELIVERY_FAILURE = 4;
public final static int TYPE_MAILBOX_FULL = 5;
public final static int TYPE_OUTBOUND = 6;
-
+
}
}
Modified: james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/HeadersToHTTP.java
URL: http://svn.apache.org/viewvc/james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/HeadersToHTTP.java?rev=1425929&r1=1425928&r2=1425929&view=diff
==============================================================================
--- james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/HeadersToHTTP.java (original)
+++ james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/HeadersToHTTP.java Wed Dec 26 14:53:14 2012
@@ -35,6 +35,7 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.Arrays;
import java.util.HashSet;
/**
@@ -172,7 +173,7 @@ public class HeadersToHTTP extends Gener
pairs.add( new BasicNameValuePair( "from", message.getSender().toString() ) );
}
if (message.getReplyTo()!=null) {
- pairs.add( new BasicNameValuePair( "reply_to", message.getReplyTo().toString() ) );
+ pairs.add( new BasicNameValuePair( "reply_to", Arrays.toString(message.getReplyTo())) );
}
if (message.getMessageID()!=null) {
pairs.add( new BasicNameValuePair( "message_id", message.getMessageID() ) );
Modified: james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/LogMessage.java
URL: http://svn.apache.org/viewvc/james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/LogMessage.java?rev=1425929&r1=1425928&r2=1425929&view=diff
==============================================================================
--- james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/LogMessage.java (original)
+++ james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/LogMessage.java Wed Dec 26 14:53:14 2012
@@ -71,7 +71,7 @@ public class LogMessage extends GenericM
* @param mail the mail to process
*/
public void service(Mail mail) {
- log(new StringBuffer(160).append("Logging mail ").append(mail.getName()).toString());
+ log("Logging mail " + mail.getName());
if (comment != null) log(comment);
try {
if (headers) log(getMessageHeaders(mail.getMessage()));
Modified: james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/OnlyText.java
URL: http://svn.apache.org/viewvc/james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/OnlyText.java?rev=1425929&r1=1425928&r2=1425929&view=diff
==============================================================================
--- james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/OnlyText.java (original)
+++ james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/OnlyText.java Wed Dec 26 14:53:14 2012
@@ -19,16 +19,15 @@
package org.apache.james.mailet.standard.mailets;
-import org.apache.mailet.base.GenericMailet;
import org.apache.mailet.Mail;
import org.apache.mailet.MailetException;
+import org.apache.mailet.base.GenericMailet;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.Part;
import javax.mail.internet.ContentType;
-
import java.io.IOException;
import java.util.HashMap;
@@ -42,13 +41,13 @@ import java.util.HashMap;
*/
public class OnlyText extends GenericMailet {
private static final String PARAMETER_NAME_NOTEXT_PROCESSOR = "NoTextProcessor";
-
+
private String optionsNotextProcessor = null;
private final HashMap<String, String> charMap = new HashMap<String, String>();
-
+
/**
* returns a String describing this mailet.
- *
+ *
* @return A desciption of this mailet
*/
public String getMailetInfo() {
@@ -60,7 +59,7 @@ public class OnlyText extends GenericMai
initEntityTable();
}
- private int[] process(Mail mail, Multipart mp, int found, int htmlPart, int stringPart) throws MessagingException, IOException {
+ private int[] process(Mail mail, Multipart mp, int found, int htmlPart, int stringPart) throws MessagingException, IOException {
for (int i = 0; found < 0 && i < mp.getCount(); i++) {
Object content = null;
try {
@@ -72,13 +71,12 @@ public class OnlyText extends GenericMai
if (mp.getBodyPart(i).isMimeType("text/plain")) {
setContentFromPart(mail.getMessage(), mp.getBodyPart(i), null, false);
found = 1;
- }
- else if (htmlPart == -1 && mp.getBodyPart(i).isMimeType("text/html"))
+ } else if (htmlPart == -1 && mp.getBodyPart(i).isMimeType("text/html"))
htmlPart = i;
-
+
else if (stringPart == -1 && content instanceof String)
stringPart = i;
-
+
else if (content instanceof Multipart) {
int[] res = process(mail, (Multipart) content, found, htmlPart, stringPart);
found = res[0];
@@ -87,17 +85,17 @@ public class OnlyText extends GenericMai
}
}
}
-
- return new int[] {found, htmlPart, stringPart};
-
+
+ return new int[]{found, htmlPart, stringPart};
+
}
-
+
public void service(Mail mail) throws MailetException {
try {
Object content = mail.getMessage().getContent();
if (content instanceof Multipart) {
Multipart mp = (Multipart) content;
-
+
int found = -1;
int htmlPart = -1;
int stringPart = -1;
@@ -105,36 +103,35 @@ public class OnlyText extends GenericMai
found = res[0];
htmlPart = res[1];
stringPart = res[2];
-
+
if (found < 0 && htmlPart != -1) {
setContentFromPart(mail.getMessage(), mp.getBodyPart(htmlPart), html2Text((String) mp.getBodyPart(htmlPart).getContent()), true);
found = 1;
}
-
+
if (found < 0 && stringPart != -1) {
setContentFromPart(mail.getMessage(), mp.getBodyPart(htmlPart), null, false);
found = 1;
}
-
+
if (found < 0 && optionsNotextProcessor != null) mail.setState(optionsNotextProcessor);
-
- }
-
- else if (!(content instanceof String) && optionsNotextProcessor != null) mail.setState(optionsNotextProcessor);
-
+
+ } else if (!(content instanceof String) && optionsNotextProcessor != null)
+ mail.setState(optionsNotextProcessor);
+
else if (mail.getMessage().isMimeType("text/html")) {
setContentFromPart(mail.getMessage(), mail.getMessage(), html2Text((String) mail.getMessage().getContent()), true);
}
-
+
} catch (IOException e) {
throw new MailetException("Failed fetching text part", e);
-
+
} catch (MessagingException e) {
throw new MailetException("Failed fetching text part", e);
}
}
-
+
private static void setContentFromPart(Message m, Part p, String newText, boolean setTextPlain) throws MessagingException, IOException {
String contentType = p.getContentType();
if (setTextPlain) {
@@ -148,16 +145,16 @@ public class OnlyText extends GenericMai
if (h != null && h.length > 0) m.setHeader("Content-Transfer-Encoding", h[0]);
m.saveChanges();
}
-
+
public String html2Text(String html) {
return decodeEntities(html
- .replaceAll("\\<([bB][rR]|[dD][lL])[ ]*[/]*[ ]*\\>", "\n")
- .replaceAll("\\</([pP]|[hH]5|[dD][tT]|[dD][dD]|[dD][iI][vV])[ ]*\\>", "\n")
- .replaceAll("\\<[lL][iI][ ]*[/]*[ ]*\\>", "\n* ")
- .replaceAll("\\<[dD][dD][ ]*[/]*[ ]*\\>", " - ")
- .replaceAll("\\<.*?\\>", ""));
+ .replaceAll("\\<([bB][rR]|[dD][lL])[ ]*[/]*[ ]*\\>", "\n")
+ .replaceAll("\\</([pP]|[hH]5|[dD][tT]|[dD][dD]|[dD][iI][vV])[ ]*\\>", "\n")
+ .replaceAll("\\<[lL][iI][ ]*[/]*[ ]*\\>", "\n* ")
+ .replaceAll("\\<[dD][dD][ ]*[/]*[ ]*\\>", " - ")
+ .replaceAll("\\<.*?\\>", ""));
}
-
+
public String decodeEntities(String data) {
StringBuffer buffer = new StringBuffer();
StringBuilder res = new StringBuilder();
@@ -171,8 +168,7 @@ public class OnlyText extends GenericMai
else res.append("&").append(buffer.toString()).append(";");
lastAmp = -1;
buffer = new StringBuffer();
- }
- else if (lastAmp == -1) res.append(c);
+ } else if (lastAmp == -1) res.append(c);
else buffer.append(c);
}
return res.toString();
@@ -182,10 +178,10 @@ public class OnlyText extends GenericMai
for (int index = 11; index < 32; index++) charMap.put("#0" + index, String.valueOf((char) index));
for (int index = 32; index < 128; index++) charMap.put("#" + index, String.valueOf((char) index));
for (int index = 128; index < 256; index++) charMap.put("#" + index, String.valueOf((char) index));
-
+
// A complete reference is here:
// http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references
-
+
charMap.put("#09", "\t");
charMap.put("#10", "\n");
charMap.put("#13", "\r");
Modified: james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/RemoveMailAttribute.java
URL: http://svn.apache.org/viewvc/james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/RemoveMailAttribute.java?rev=1425929&r1=1425928&r2=1425929&view=diff
==============================================================================
--- james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/RemoveMailAttribute.java (original)
+++ james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/RemoveMailAttribute.java Wed Dec 26 14:53:14 2012
@@ -85,8 +85,7 @@ public class RemoveMailAttribute extends
*/
public void service(Mail mail) throws MessagingException {
for (String anAttributesToRemove : attributesToRemove) {
- String attribute_name = anAttributesToRemove;
- mail.removeAttribute(attribute_name);
+ mail.removeAttribute(anAttributesToRemove);
}
}
Modified: james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/UnwrapText.java
URL: http://svn.apache.org/viewvc/james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/UnwrapText.java?rev=1425929&r1=1425928&r2=1425929&view=diff
==============================================================================
--- james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/UnwrapText.java (original)
+++ james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/UnwrapText.java Wed Dec 26 14:53:14 2012
@@ -133,6 +133,7 @@ public class UnwrapText extends GenericM
boolean b;
int w;
// if patterns match, the quote level are identical and if the line length added to the length of the following word is greater than width then it is a wrapped line.
+ assert m2 != null;
if (m1.matches() && i < lines.length - 1 && m2.matches() && (
// The following line has the same quoting of the previous.
((b = m1.group(1).trim().equals(m2.group(1).trim())) && l.length() + m2.group(3).length() + 1 > width)
Modified: james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/UseHeaderRecipients.java
URL: http://svn.apache.org/viewvc/james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/UseHeaderRecipients.java?rev=1425929&r1=1425928&r2=1425929&view=diff
==============================================================================
--- james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/UseHeaderRecipients.java (original)
+++ james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/mailets/UseHeaderRecipients.java Wed Dec 26 14:53:14 2012
@@ -18,12 +18,11 @@
****************************************************************/
-
package org.apache.james.mailet.standard.mailets;
-import org.apache.mailet.base.GenericMailet;
import org.apache.mailet.Mail;
import org.apache.mailet.MailAddress;
+import org.apache.mailet.base.GenericMailet;
import javax.mail.MessagingException;
import javax.mail.internet.InternetAddress;
@@ -37,14 +36,14 @@ import java.util.Vector;
* than the recipients specified in the SMTP message header. This can be
* useful if your mail is redirected on-route by a mail server that
* substitutes a fixed recipient address for the original.</p>
- *
+ * <p/>
* <p>To use this, match against the redirection address using the
* <code>RecipientIs</code> matcher and set the mailet 'class' to
* <code>UseHeaderRecipients</code>. This will cause the email to be
* re-injected into the root process with the recipient substituted
* by all the recipients in the Mail-For, To and Cc headers
* of the message.</p>
- *
+ * <p/>
* <p>e.g.</p>
* <pre><code>
* <mailet match="RecipientIs=forwarded@myhost"
@@ -63,7 +62,7 @@ public class UseHeaderRecipients extends
/**
* Initialize the mailet
- *
+ * <p/>
* initializes the DEBUG flag
*/
public void init() {
@@ -117,18 +116,13 @@ public class UseHeaderRecipients extends
* extract all the mail addresses as a collection of addresses.
*
* @param message the mail message to read
- * @param name the header name as a String
+ * @param name the header name as a String
* @return the collection of MailAddress objects.
*/
private Collection<MailAddress> getHeaderMailAddresses(MimeMessage message, String name) throws MessagingException {
if (isDebug) {
- StringBuilder logBuffer =
- new StringBuilder(64)
- .append("Checking ")
- .append(name)
- .append(" headers");
- log(logBuffer.toString());
+ log("Checking " + name + " headers");
}
Collection<MailAddress> addresses = new Vector<MailAddress>();
String[] headers = message.getHeader(name);
Modified: james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/matchers/AttachmentFileNameIs.java
URL: http://svn.apache.org/viewvc/james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/matchers/AttachmentFileNameIs.java?rev=1425929&r1=1425928&r2=1425929&view=diff
==============================================================================
--- james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/matchers/AttachmentFileNameIs.java (original)
+++ james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/matchers/AttachmentFileNameIs.java Wed Dec 26 14:53:14 2012
@@ -221,13 +221,12 @@ public class AttachmentFileNameIs extend
protected boolean matchFound(String fileName) {
for (Mask mask1 : masks) {
boolean fMatch;
- Mask mask = mask1;
//XXX: file names in mail may contain directory - theoretically
- if (mask.suffixMatch) {
- fMatch = fileName.endsWith(mask.matchString);
+ if (mask1.suffixMatch) {
+ fMatch = fileName.endsWith(mask1.matchString);
} else {
- fMatch = fileName.equals(mask.matchString);
+ fMatch = fileName.equals(mask1.matchString);
}
if (fMatch) {
return true; // matching file found
Modified: james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/matchers/HasHeader.java
URL: http://svn.apache.org/viewvc/james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/matchers/HasHeader.java?rev=1425929&r1=1425928&r2=1425929&view=diff
==============================================================================
--- james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/matchers/HasHeader.java (original)
+++ james/mailet/trunk/standard/src/main/java/org/apache/james/mailet/standard/matchers/HasHeader.java Wed Dec 26 14:53:14 2012
@@ -18,23 +18,21 @@
****************************************************************/
-
package org.apache.james.mailet.standard.matchers;
-import org.apache.mailet.base.GenericMatcher;
import org.apache.mailet.Mail;
import org.apache.mailet.MailAddress;
+import org.apache.mailet.base.GenericMatcher;
+import javax.mail.MessagingException;
+import javax.mail.internet.MimeMessage;
import java.util.Collection;
import java.util.LinkedList;
import java.util.StringTokenizer;
-import javax.mail.MessagingException;
-import javax.mail.internet.MimeMessage;
-
/**
* use: <pre><code><mailet match="HasHeader={<header>[=value]}+" class="..." /></code></pre>
- *
+ * <p/>
* <p>This matcher checks if the header named is present. If complements the
* AddHeader mailet.</p>
*/
@@ -58,9 +56,6 @@ public class HasHeader extends GenericMa
boolean match = false;
MimeMessage message = mail.getMessage();
-
- header:
- // goes through the headernames one by one
for (String element : conditionline_) {
StringTokenizer st = new StringTokenizer(element, "=", false);
String header;
Modified: james/mailet/trunk/standard/src/test/java/org/apache/james/mailet/standard/matchers/AbstractSenderIsTest.java
URL: http://svn.apache.org/viewvc/james/mailet/trunk/standard/src/test/java/org/apache/james/mailet/standard/matchers/AbstractSenderIsTest.java?rev=1425929&r1=1425928&r2=1425929&view=diff
==============================================================================
--- james/mailet/trunk/standard/src/test/java/org/apache/james/mailet/standard/matchers/AbstractSenderIsTest.java (original)
+++ james/mailet/trunk/standard/src/test/java/org/apache/james/mailet/standard/matchers/AbstractSenderIsTest.java Wed Dec 26 14:53:14 2012
@@ -80,7 +80,7 @@ public abstract class AbstractSenderIsTe
ArrayList<MailAddress> r = new ArrayList<MailAddress>();
try {
r.add(new MailAddress("test@localhost"));
- } catch (ParseException e) {
+ } catch (ParseException ignored) {
}
return r;
}
Modified: james/mailet/trunk/standard/src/test/java/org/apache/james/mailet/standard/matchers/RecipientIsTest.java
URL: http://svn.apache.org/viewvc/james/mailet/trunk/standard/src/test/java/org/apache/james/mailet/standard/matchers/RecipientIsTest.java?rev=1425929&r1=1425928&r2=1425929&view=diff
==============================================================================
--- james/mailet/trunk/standard/src/test/java/org/apache/james/mailet/standard/matchers/RecipientIsTest.java (original)
+++ james/mailet/trunk/standard/src/test/java/org/apache/james/mailet/standard/matchers/RecipientIsTest.java Wed Dec 26 14:53:14 2012
@@ -35,8 +35,7 @@ public class RecipientIsTest extends Abs
}
protected String getRecipientName() {
- String RECIPIENT_NAME = "test@james.apache.org";
- return RECIPIENT_NAME;
+ return "test@james.apache.org";
}
// test if the recipients get returned as matched
Modified: james/mailet/trunk/standard/src/test/java/org/apache/james/mailet/standard/matchers/UserIsTest.java
URL: http://svn.apache.org/viewvc/james/mailet/trunk/standard/src/test/java/org/apache/james/mailet/standard/matchers/UserIsTest.java?rev=1425929&r1=1425928&r2=1425929&view=diff
==============================================================================
--- james/mailet/trunk/standard/src/test/java/org/apache/james/mailet/standard/matchers/UserIsTest.java (original)
+++ james/mailet/trunk/standard/src/test/java/org/apache/james/mailet/standard/matchers/UserIsTest.java Wed Dec 26 14:53:14 2012
@@ -35,8 +35,7 @@ public class UserIsTest extends Abstract
}
protected String getRecipientName() {
- String USER = "test";
- return USER;
+ return "test";
}
// test if the recipients get returned as matched
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org