MAILET-115 Rename AbstractRedirect
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/5a81c0d9 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/5a81c0d9 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/5a81c0d9 Branch: refs/heads/master Commit: 5a81c0d9ccfd6a0e46319bd0a58946c1eab194b3 Parents: 30c8a8c Author: Antoine Duprat <[email protected]> Authored: Thu Nov 17 15:16:03 2016 +0100 Committer: Benoit Tellier <[email protected]> Committed: Wed Jan 11 10:03:31 2017 +0700 ---------------------------------------------------------------------- .../apache/james/transport/mailets/Bounce.java | 8 +- .../james/transport/mailets/DSNBounce.java | 8 +- .../apache/james/transport/mailets/Forward.java | 4 +- .../transport/mailets/NotifyPostmaster.java | 8 +- .../james/transport/mailets/NotifySender.java | 8 +- .../james/transport/mailets/Redirect.java | 6 +- .../apache/james/transport/mailets/Resend.java | 8 +- .../mailets/redirect/AbstractRedirect.java | 316 ------------------- .../redirect/MailMessageAlteringUtils.java | 10 +- .../mailets/redirect/MailModifier.java | 8 +- .../mailets/redirect/ProcessRedirectNotify.java | 6 +- .../mailets/redirect/RedirectNotify.java | 316 +++++++++++++++++++ .../james/transport/util/RecipientsUtils.java | 8 +- .../apache/james/transport/util/TosUtils.java | 8 +- .../redirect/MailMessageAlteringUtilsTest.java | 14 +- .../mailets/redirect/MailModifierTest.java | 6 +- .../transport/util/RecipientsUtilsTest.java | 6 +- .../james/transport/util/TosUtilsTest.java | 6 +- 18 files changed, 377 insertions(+), 377 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/5a81c0d9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Bounce.java ---------------------------------------------------------------------- diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Bounce.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Bounce.java index 40cebb5..2b1d3e2 100644 --- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Bounce.java +++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Bounce.java @@ -24,7 +24,7 @@ import java.util.List; import javax.mail.MessagingException; import javax.mail.internet.InternetAddress; -import org.apache.james.transport.mailets.redirect.AbstractRedirect; +import org.apache.james.transport.mailets.redirect.RedirectNotify; import org.apache.james.transport.mailets.redirect.InitParameters; import org.apache.james.transport.mailets.redirect.NotifyMailetInitParameters; import org.apache.james.transport.mailets.redirect.NotifyMailetsMessage; @@ -117,7 +117,7 @@ import com.google.common.collect.ImmutableList; * * @since 2.2.0 */ -public class Bounce extends AbstractRedirect { +public class Bounce extends RedirectNotify { private static final String[] CONFIGURABLE_PARAMETERS = new String[] { "debug", "passThrough", "fakeDomainCheck", "inline", "attachment", "message", "notice", "sender", "sendingAddress", "prefix", "attachError" }; @@ -182,13 +182,13 @@ public class Bounce extends AbstractRedirect { @Override protected MailAddress getReversePath() throws MessagingException { return SpecialAddressesUtils.from(this) - .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getReversePath(), AbstractRedirect.REVERSE_PATH_ALLOWED_SPECIALS); + .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getReversePath(), RedirectNotify.REVERSE_PATH_ALLOWED_SPECIALS); } @Override public MailAddress getSender() throws MessagingException { return SpecialAddressesUtils.from(this) - .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getSender(), AbstractRedirect.SENDER_ALLOWED_SPECIALS); + .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getSender(), RedirectNotify.SENDER_ALLOWED_SPECIALS); } @Override http://git-wip-us.apache.org/repos/asf/james-project/blob/5a81c0d9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java ---------------------------------------------------------------------- diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java index 3fba468..c47645c 100755 --- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java +++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java @@ -32,7 +32,7 @@ import javax.mail.internet.MimeBodyPart; import javax.mail.internet.MimeMessage; import org.apache.james.core.MailImpl; -import org.apache.james.transport.mailets.redirect.AbstractRedirect; +import org.apache.james.transport.mailets.redirect.RedirectNotify; import org.apache.james.transport.mailets.redirect.InitParameters; import org.apache.james.transport.mailets.redirect.MailModifier; import org.apache.james.transport.mailets.redirect.NotifyMailetInitParameters; @@ -96,7 +96,7 @@ import com.google.common.collect.ImmutableList; * @see org.apache.james.transport.mailets.AbstractNotify */ -public class DSNBounce extends AbstractRedirect { +public class DSNBounce extends RedirectNotify { private static final String[] CONFIGURABLE_PARAMETERS = new String[]{ "debug", "passThrough", "messageString", "attachment", "sender", "prefix" }; private static final List<MailAddress> RECIPIENT_MAIL_ADDRESSES = ImmutableList.of(SpecialAddress.REVERSE_PATH); @@ -169,7 +169,7 @@ public class DSNBounce extends AbstractRedirect { @Override protected MailAddress getReversePath() throws MessagingException { return SpecialAddressesUtils.from(this) - .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getReversePath(), AbstractRedirect.REVERSE_PATH_ALLOWED_SPECIALS); + .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getReversePath(), RedirectNotify.REVERSE_PATH_ALLOWED_SPECIALS); } @Override @@ -180,7 +180,7 @@ public class DSNBounce extends AbstractRedirect { @Override public MailAddress getSender() throws MessagingException { return SpecialAddressesUtils.from(this) - .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getSender(), AbstractRedirect.SENDER_ALLOWED_SPECIALS); + .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getSender(), RedirectNotify.SENDER_ALLOWED_SPECIALS); } @Override http://git-wip-us.apache.org/repos/asf/james-project/blob/5a81c0d9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Forward.java ---------------------------------------------------------------------- diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Forward.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Forward.java index 77b3c6d..fcab123 100644 --- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Forward.java +++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Forward.java @@ -25,7 +25,7 @@ import javax.mail.MessagingException; import javax.mail.internet.AddressException; import javax.mail.internet.InternetAddress; -import org.apache.james.transport.mailets.redirect.AbstractRedirect; +import org.apache.james.transport.mailets.redirect.RedirectNotify; import org.apache.james.transport.mailets.redirect.AddressExtractor; import org.apache.james.transport.mailets.redirect.InitParameters; import org.apache.james.transport.mailets.redirect.ProcessRedirectNotify; @@ -87,7 +87,7 @@ import com.google.common.collect.ImmutableList; * for backward compatibility. * </p> */ -public class Forward extends AbstractRedirect { +public class Forward extends RedirectNotify { private static final String[] CONFIGURABLE_PARAMETERS = new String[] { "debug", "passThrough", "fakeDomainCheck", "forwardto", "forwardTo" }; http://git-wip-us.apache.org/repos/asf/james-project/blob/5a81c0d9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifyPostmaster.java ---------------------------------------------------------------------- diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifyPostmaster.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifyPostmaster.java index 2c309bf..47f6ece 100644 --- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifyPostmaster.java +++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifyPostmaster.java @@ -24,7 +24,7 @@ import java.util.List; import javax.mail.MessagingException; import javax.mail.internet.InternetAddress; -import org.apache.james.transport.mailets.redirect.AbstractRedirect; +import org.apache.james.transport.mailets.redirect.RedirectNotify; import org.apache.james.transport.mailets.redirect.AddressExtractor; import org.apache.james.transport.mailets.redirect.InitParameters; import org.apache.james.transport.mailets.redirect.NotifyMailetInitParameters; @@ -117,7 +117,7 @@ import com.google.common.collect.ImmutableList; * are kept for backward compatibility. * </p> */ -public class NotifyPostmaster extends AbstractRedirect { +public class NotifyPostmaster extends RedirectNotify { private static final String[] CONFIGURABLE_PARAMETERS = new String[]{ "debug", "passThrough", "fakeDomainCheck", "inline", "attachment", "message", "notice", "sender", "sendingAddress", "prefix", "attachError", "to" }; @@ -193,7 +193,7 @@ public class NotifyPostmaster extends AbstractRedirect { @Override protected MailAddress getReversePath() throws MessagingException { return SpecialAddressesUtils.from(this) - .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getReversePath(), AbstractRedirect.REVERSE_PATH_ALLOWED_SPECIALS); + .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getReversePath(), RedirectNotify.REVERSE_PATH_ALLOWED_SPECIALS); } @Override @@ -204,7 +204,7 @@ public class NotifyPostmaster extends AbstractRedirect { @Override public MailAddress getSender() throws MessagingException { return SpecialAddressesUtils.from(this) - .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getSender(), AbstractRedirect.SENDER_ALLOWED_SPECIALS); + .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getSender(), RedirectNotify.SENDER_ALLOWED_SPECIALS); } @Override http://git-wip-us.apache.org/repos/asf/james-project/blob/5a81c0d9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifySender.java ---------------------------------------------------------------------- diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifySender.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifySender.java index f426d1e..11a46cb 100644 --- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifySender.java +++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifySender.java @@ -24,7 +24,7 @@ import java.util.List; import javax.mail.MessagingException; import javax.mail.internet.InternetAddress; -import org.apache.james.transport.mailets.redirect.AbstractRedirect; +import org.apache.james.transport.mailets.redirect.RedirectNotify; import org.apache.james.transport.mailets.redirect.AddressExtractor; import org.apache.james.transport.mailets.redirect.InitParameters; import org.apache.james.transport.mailets.redirect.NotifyMailetInitParameters; @@ -116,7 +116,7 @@ import com.google.common.collect.ImmutableList; * are kept for backward compatibility. * </p> */ -public class NotifySender extends AbstractRedirect { +public class NotifySender extends RedirectNotify { private static final String[] CONFIGURABLE_PARAMETERS = new String[]{ "debug", "passThrough", "fakeDomainCheck", "inline", "attachment", "message", "notice", "sender", "sendingAddress", "prefix", "attachError", "to" }; @@ -193,7 +193,7 @@ public class NotifySender extends AbstractRedirect { @Override protected MailAddress getReversePath() throws MessagingException { return SpecialAddressesUtils.from(this) - .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getReversePath(), AbstractRedirect.REVERSE_PATH_ALLOWED_SPECIALS); + .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getReversePath(), RedirectNotify.REVERSE_PATH_ALLOWED_SPECIALS); } @Override @@ -204,7 +204,7 @@ public class NotifySender extends AbstractRedirect { @Override public MailAddress getSender() throws MessagingException { return SpecialAddressesUtils.from(this) - .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getSender(), AbstractRedirect.SENDER_ALLOWED_SPECIALS); + .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getSender(), RedirectNotify.SENDER_ALLOWED_SPECIALS); } @Override http://git-wip-us.apache.org/repos/asf/james-project/blob/5a81c0d9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Redirect.java ---------------------------------------------------------------------- diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Redirect.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Redirect.java index fa08a6d..1e86f56 100644 --- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Redirect.java +++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Redirect.java @@ -24,7 +24,7 @@ import java.util.List; import javax.mail.MessagingException; import javax.mail.internet.InternetAddress; -import org.apache.james.transport.mailets.redirect.AbstractRedirect; +import org.apache.james.transport.mailets.redirect.RedirectNotify; import org.apache.james.transport.mailets.redirect.AddressExtractor; import org.apache.james.transport.mailets.redirect.InitParameters; import org.apache.james.transport.mailets.redirect.ProcessRedirectNotify; @@ -296,7 +296,7 @@ import com.google.common.collect.ImmutableList; * </p> */ -public class Redirect extends AbstractRedirect { +public class Redirect extends RedirectNotify { private static final String[] CONFIGURABLE_PARAMETERS = new String[] { "static", "debug", "passThrough", "fakeDomainCheck", "inline", "attachment", "message", "recipients", "to", "replyTo", "replyto", "reversePath", "sender", "subject", "prefix", "attachError", "isReply" }; @@ -424,7 +424,7 @@ public class Redirect extends AbstractRedirect { @Override public MailAddress getSender() throws MessagingException { return SpecialAddressesUtils.from(this) - .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getSender(), AbstractRedirect.SENDER_ALLOWED_SPECIALS); + .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getSender(), RedirectNotify.SENDER_ALLOWED_SPECIALS); } @Override http://git-wip-us.apache.org/repos/asf/james-project/blob/5a81c0d9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Resend.java ---------------------------------------------------------------------- diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Resend.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Resend.java index ad84e41..bde2c78 100644 --- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Resend.java +++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Resend.java @@ -24,7 +24,7 @@ import java.util.List; import javax.mail.MessagingException; import javax.mail.internet.InternetAddress; -import org.apache.james.transport.mailets.redirect.AbstractRedirect; +import org.apache.james.transport.mailets.redirect.RedirectNotify; import org.apache.james.transport.mailets.redirect.AddressExtractor; import org.apache.james.transport.mailets.redirect.InitParameters; import org.apache.james.transport.mailets.redirect.ProcessRedirectNotify; @@ -291,7 +291,7 @@ import com.google.common.collect.ImmutableList; * @since 2.2.0 */ -public class Resend extends AbstractRedirect { +public class Resend extends RedirectNotify { private static final String[] CONFIGURABLE_PARAMETERS = new String[] { "debug", "passThrough", "fakeDomainCheck", "inline", "attachment", "message", "recipients", "to", "replyTo", "replyto", "reversePath", "sender", "subject", "prefix", "attachError", "isReply" }; @@ -370,7 +370,7 @@ public class Resend extends AbstractRedirect { @Override protected MailAddress getReversePath() throws MessagingException { return SpecialAddressesUtils.from(this) - .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getReversePath(), AbstractRedirect.REVERSE_PATH_ALLOWED_SPECIALS); + .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getReversePath(), RedirectNotify.REVERSE_PATH_ALLOWED_SPECIALS); } @Override @@ -387,7 +387,7 @@ public class Resend extends AbstractRedirect { @Override public MailAddress getSender() throws MessagingException { return SpecialAddressesUtils.from(this) - .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getSender(), AbstractRedirect.SENDER_ALLOWED_SPECIALS); + .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getSender(), RedirectNotify.SENDER_ALLOWED_SPECIALS); } @Override http://git-wip-us.apache.org/repos/asf/james-project/blob/5a81c0d9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/AbstractRedirect.java ---------------------------------------------------------------------- diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/AbstractRedirect.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/AbstractRedirect.java deleted file mode 100644 index 70ccf76..0000000 --- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/AbstractRedirect.java +++ /dev/null @@ -1,316 +0,0 @@ -/**************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one * - * or more contributor license agreements. See the NOTICE file * - * distributed with this work for additional information * - * regarding copyright ownership. The ASF licenses this file * - * to you under the Apache License, Version 2.0 (the * - * "License"); you may not use this file except in compliance * - * with the License. You may obtain a copy of the License at * - * * - * http://www.apache.org/licenses/LICENSE-2.0 * - * * - * Unless required by applicable law or agreed to in writing, * - * software distributed under the License is distributed on an * - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * - * KIND, either express or implied. See the License for the * - * specific language governing permissions and limitations * - * under the License. * - ****************************************************************/ - -package org.apache.james.transport.mailets.redirect; - -import java.util.List; - -import javax.inject.Inject; -import javax.mail.MessagingException; -import javax.mail.internet.InternetAddress; - -import org.apache.james.dnsservice.api.DNSService; -import org.apache.james.transport.mailets.Redirect; -import org.apache.james.transport.mailets.utils.MimeMessageModifier; -import org.apache.mailet.Mail; -import org.apache.mailet.MailAddress; -import org.apache.mailet.base.GenericMailet; - -import com.google.common.base.Optional; -import com.google.common.collect.ImmutableList; - -/** - * <p> - * Abstract mailet providing configurable redirection services.<br> - * This mailet can be subclassed to make authoring redirection mailets simple.<br> - * By extending it and overriding one or more of these methods new behaviour can - * be quickly created without the author having to address any other issue than - * the relevant one: - * </p> - * <ul> - * <li>attachError() , should error messages be appended to the message</li> - * <li>getAttachmentType(), what should be attached to the message</li> - * <li>getInLineType(), what should be included in the message</li> - * <li>getMessage(), The text of the message itself</li> - * <li>getRecipients(), the recipients the mail is sent to</li> - * <li>getReplyTo(), where replies to this message will be sent</li> - * <li>getReversePath(), what to set the reverse-path to</li> - * <li>getSender(), who the mail is from</li> - * <li>getSubject(), a string to replace the message subject</li> - * <li>getSubjectPrefix(), a prefix to be added to the message subject, possibly - * already replaced by a new subject</li> - * <li>getTo(), a list of people to whom the mail is *apparently* sent</li> - * <li>isReply(), should this mailet set the IN_REPLY_TO header to the id of the - * current message</li> - * <li>getPassThrough(), should this mailet allow the original message to - * continue processing or GHOST it.</li> - * <li>getFakeDomainCheck(), should this mailet check if the sender domain - * address is valid.</li> - * <li>isStatic(), should this mailet run the get methods for every mail, or - * just once.</li> - * </ul> - * <p> - * For each of the methods above (generically called "getX()" methods in this - * class and its subclasses), there is an associated "getX(Mail)" method and - * most times a "setX(Mail, Tx, Mail)" method.<br> - * The roles are the following: - * </p> - * <ul> - * <li>a "getX()" method returns the correspondent "X" value that can be - * evaluated "statically" once at init time and then stored in a variable and - * made available for later use by a "getX(Mail)" method;</li> - * <li>a "getX(Mail)" method is the one called to return the correspondent "X" - * value that can be evaluated "dynamically", tipically based on the currently - * serviced mail; the default behaviour is to return the value of getX();</li> - * <li>a "setX(Mail, Tx, Mail)" method is called to change the correspondent "X" - * value of the redirected Mail object, using the value returned by - * "gexX(Mail)"; if such value is null, it does nothing.</li> - * </ul> - * <p> - * Here follows the typical pattern of those methods: - * </p> - * <p/> - * <pre> - * <code> - * ... - * Tx x; - * ... - * protected boolean getX(Mail originalMail) throws MessagingException { - * boolean x = (isStatic()) ? this.x : getX(); - * ... - * return x; - * } - * ... - * public void init() throws MessagingException { - * ... - * isStatic = (getInitParameter("static") == null) ? false : new Boolean(getInitParameter("static")).booleanValue(); - * if(isStatic()) { - * ... - * X = getX(); - * ... - * } - * ... - * public void service(Mail originalMail) throws MessagingException { - * ... - * setX(newMail, getX(originalMail), originalMail); - * ... - * } - * ... - * </code> - * </pre> - * <p> - * The <i>isStatic</i> variable and method is used to allow for the situations - * (deprecated since version 2.2, but possibly used by previoulsy written - * extensions to {@link Redirect}) in which the getX() methods are non static: - * in this case {@link #isStatic()} must return false.<br> - * Finally, a "getX()" method may return a "special address" (see - * {@link SpecialAddress}), that later will be resolved ("late bound") by a - * "getX(Mail)" or "setX(Mail, Tx, Mail)": it is a dynamic value that does not - * require <code>isStatic</code> to be false. - * </p> - * <p/> - * <p> - * Supports by default the <code>passThrough</code> init parameter (false if - * missing). Subclasses can override this behaviour overriding - * {@link #getPassThrough()}. - * </p> - * - * @since 2.2.0 - */ - -public abstract class AbstractRedirect extends GenericMailet { - - public static final List<String> REVERSE_PATH_ALLOWED_SPECIALS = ImmutableList.of("postmaster", "sender", "null", "unaltered"); - public static final List<String> SENDER_ALLOWED_SPECIALS = ImmutableList.of("postmaster", "sender", "unaltered"); - - public abstract InitParameters getInitParameters(); - - protected abstract String[] getAllowedInitParameters(); - - protected DNSService dns; - - @Inject - public void setDNSService(DNSService dns) { - this.dns = dns; - } - - /** - * Gets the <code>message</code> property, built dynamically using the - * original Mail object. Is a "getX(Mail)" method. - * - * @return {@link #getMessage()} - */ - public abstract String getMessage(Mail originalMail) throws MessagingException; - - /** - * Gets the <code>recipients</code> property. Returns the collection of - * recipients of the new message, or null if no change is requested. Is a - * "getX()" method. - * - * @return the <code>recipients</code> init parameter or the postmaster - * address or <code>SpecialAddress.SENDER</code> or - * <code>SpecialAddress.FROM</code> or - * <code>SpecialAddress.REPLY_TO</code> or - * <code>SpecialAddress.REVERSE_PATH</code> or - * <code>SpecialAddress.UNALTERED</code> or - * <code>SpecialAddress.RECIPIENTS</code> or <code>null</code> if - * missing - */ - public abstract List<MailAddress> getRecipients() throws MessagingException; - - /** - * Gets the <code>recipients</code> property, built dynamically using the - * original Mail object. Is a "getX(Mail)" method. - * - * @return {@link #replaceMailAddresses} on {@link #getRecipients()}, - */ - protected abstract List<MailAddress> getRecipients(Mail originalMail) throws MessagingException; - - /** - * Gets the <code>to</code> property. Returns the "To:" recipients of the - * new message. or null if no change is requested. Is a "getX()" method. - * - * @return the <code>to</code> init parameter or the postmaster address or - * <code>SpecialAddress.SENDER</code> or - * <code>SpecialAddress.REVERSE_PATH</code> or - * <code>SpecialAddress.FROM</code> or - * <code>SpecialAddress.REPLY_TO</code> or - * <code>SpecialAddress.UNALTERED</code> or - * <code>SpecialAddress.TO</code> or <code>null</code> if missing - */ - public abstract List<InternetAddress> getTo() throws MessagingException; - - /** - * Gets the <code>to</code> property, built dynamically using the original - * Mail object. Its outcome will be the the value the <i>TO:</i> header will - * be set to, that could be different from the real recipient (see - * {@link Mail#getRecipients}). Is a "getX(Mail)" method. - * - * @return {@link #replaceInternetAddresses} on {@link #getRecipients()}, - */ - protected abstract List<MailAddress> getTo(Mail originalMail) throws MessagingException; - - /** - * Gets the <code>replyto</code> property. Returns the Reply-To address of - * the new message, or null if no change is requested. Is a "getX()" method. - * - * @return the <code>replyto</code> init parameter or the postmaster address - * or <code>SpecialAddress.SENDER</code> or - * <code>SpecialAddress.UNALTERED</code> or - * <code>SpecialAddress.NULL</code> or <code>null</code> if missing - */ - public abstract MailAddress getReplyTo() throws MessagingException; - - /** - * Gets the <code>replyTo</code> property, built dynamically using the - * original Mail object. Is a "getX(Mail)" method. - * - * @return {@link #getReplyTo()} replacing - * <code>SpecialAddress.UNALTERED</code> if applicable with null and - * <code>SpecialAddress.SENDER</code> with the original mail sender - */ - protected abstract MailAddress getReplyTo(Mail originalMail) throws MessagingException; - - /** - * Gets the <code>reversePath</code> property. Returns the reverse-path of - * the new message, or null if no change is requested. Is a "getX()" method. - * - * @return the <code>reversePath</code> init parameter or the postmaster - * address or <code>SpecialAddress.SENDER</code> or - * <code>SpecialAddress.NULL</code> or - * <code>SpecialAddress.UNALTERED</code> or <code>null</code> if - * missing - */ - protected abstract MailAddress getReversePath() throws MessagingException; - - /** - * Gets the <code>reversePath</code> property, built dynamically using the - * original Mail object. Is a "getX(Mail)" method. - * - * @return {@link #getReversePath()}, replacing - * <code>SpecialAddress.SENDER</code> if applicable with null, - * replacing <code>SpecialAddress.UNALTERED</code> and - * <code>SpecialAddress.REVERSE_PATH</code> if applicable with null, - * but not replacing <code>SpecialAddress.NULL</code> that will be - * handled by {@link #setReversePath} - */ - protected abstract MailAddress getReversePath(Mail originalMail) throws MessagingException; - - /** - * Gets the <code>sender</code> property. Returns the new sender as a - * MailAddress, or null if no change is requested. Is a "getX()" method. - * - * @return the <code>sender</code> init parameter or the postmaster address - * or <code>SpecialAddress.SENDER</code> or - * <code>SpecialAddress.UNALTERED</code> or <code>null</code> if - * missing - */ - public abstract MailAddress getSender() throws MessagingException; - - /** - * Gets the <code>sender</code> property, built dynamically using the - * original Mail object. Is a "getX(Mail)" method. - * - * @return {@link #getSender()} replacing - * <code>SpecialAddress.UNALTERED</code> and - * <code>SpecialAddress.SENDER</code> if applicable with null - */ - protected abstract Optional<MailAddress> getSender(Mail originalMail) throws MessagingException; - - /** - * Builds the subject of <i>newMail</i> appending the subject of - * <i>originalMail</i> to <i>subjectPrefix</i>. Is a "setX(Mail, Tx, Mail)" - * method. - */ - protected abstract Optional<String> getSubjectPrefix(Mail newMail, String subjectPrefix, Mail originalMail) throws MessagingException; - - /** - * Mailet initialization routine. Will setup static values for each "x" - * initialization parameter in config.xml, using getX(), if - * {@link #isStatic()} returns true. - */ - @Override - public void init() throws MessagingException { - if (getInitParameters().isDebug()) { - log("Initializing"); - } - - // check that all init parameters have been declared in - // allowedInitParameters - checkInitParameters(getAllowedInitParameters()); - - if (getInitParameters().isStatic()) { - if (getInitParameters().isDebug()) { - log(getInitParameters().asString()); - } - } - } - - /** - * Service does the hard work,and redirects the originalMail in the form - * specified. - * - * @param originalMail the mail to process and redirect - * @throws MessagingException if a problem arises formulating the redirected mail - */ - @Override - public abstract void service(Mail originalMail) throws MessagingException; - - protected abstract MimeMessageModifier getMimeMessageModifier(Mail newMail, Mail originalMail) throws MessagingException; -} http://git-wip-us.apache.org/repos/asf/james-project/blob/5a81c0d9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/MailMessageAlteringUtils.java ---------------------------------------------------------------------- diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/MailMessageAlteringUtils.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/MailMessageAlteringUtils.java index f83adb5..f040e90 100644 --- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/MailMessageAlteringUtils.java +++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/MailMessageAlteringUtils.java @@ -39,17 +39,17 @@ public class MailMessageAlteringUtils { private static final char LINE_BREAK = '\n'; - public static Builder from(AbstractRedirect mailet) { + public static Builder from(RedirectNotify mailet) { return new Builder(mailet); } public static class Builder { - private AbstractRedirect mailet; + private RedirectNotify mailet; private Mail originalMail; private Mail newMail; - private Builder(AbstractRedirect mailet) { + private Builder(RedirectNotify mailet) { this.mailet = mailet; } @@ -75,11 +75,11 @@ public class MailMessageAlteringUtils { } } - private final AbstractRedirect mailet; + private final RedirectNotify mailet; private final Mail originalMail; private final Mail newMail; - private MailMessageAlteringUtils(AbstractRedirect mailet, Mail originalMail, Mail newMail) { + private MailMessageAlteringUtils(RedirectNotify mailet, Mail originalMail, Mail newMail) { this.mailet = mailet; this.originalMail = originalMail; this.newMail = newMail; http://git-wip-us.apache.org/repos/asf/james-project/blob/5a81c0d9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/MailModifier.java ---------------------------------------------------------------------- diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/MailModifier.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/MailModifier.java index 12312e9..198acfd 100644 --- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/MailModifier.java +++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/MailModifier.java @@ -47,14 +47,14 @@ public class MailModifier { public static class Builder { - private AbstractRedirect mailet; + private RedirectNotify mailet; private MailImpl mail; private DNSService dns; private Builder() { } - public Builder mailet(AbstractRedirect mailet) { + public Builder mailet(RedirectNotify mailet) { this.mailet = mailet; return this; } @@ -77,11 +77,11 @@ public class MailModifier { } } - private final AbstractRedirect mailet; + private final RedirectNotify mailet; private final MailImpl mail; private final DNSService dns; - private MailModifier(AbstractRedirect mailet, MailImpl mail, DNSService dns) { + private MailModifier(RedirectNotify mailet, MailImpl mail, DNSService dns) { this.mailet = mailet; this.mail = mail; this.dns = dns; http://git-wip-us.apache.org/repos/asf/james-project/blob/5a81c0d9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/ProcessRedirectNotify.java ---------------------------------------------------------------------- diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/ProcessRedirectNotify.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/ProcessRedirectNotify.java index e41ca83..12f27bb 100644 --- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/ProcessRedirectNotify.java +++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/ProcessRedirectNotify.java @@ -27,14 +27,14 @@ import org.apache.mailet.Mail; public class ProcessRedirectNotify { - public static ProcessRedirectNotify from(AbstractRedirect mailet) { + public static ProcessRedirectNotify from(RedirectNotify mailet) { return new ProcessRedirectNotify(mailet); } - private final AbstractRedirect mailet; + private final RedirectNotify mailet; private final boolean isDebug; - private ProcessRedirectNotify(AbstractRedirect mailet) { + private ProcessRedirectNotify(RedirectNotify mailet) { this.mailet = mailet; this.isDebug = mailet.getInitParameters().isDebug(); } http://git-wip-us.apache.org/repos/asf/james-project/blob/5a81c0d9/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/RedirectNotify.java ---------------------------------------------------------------------- diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/RedirectNotify.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/RedirectNotify.java new file mode 100644 index 0000000..aa5c19e --- /dev/null +++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/RedirectNotify.java @@ -0,0 +1,316 @@ +/**************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + ****************************************************************/ + +package org.apache.james.transport.mailets.redirect; + +import java.util.List; + +import javax.inject.Inject; +import javax.mail.MessagingException; +import javax.mail.internet.InternetAddress; + +import org.apache.james.dnsservice.api.DNSService; +import org.apache.james.transport.mailets.Redirect; +import org.apache.james.transport.mailets.utils.MimeMessageModifier; +import org.apache.mailet.Mail; +import org.apache.mailet.MailAddress; +import org.apache.mailet.base.GenericMailet; + +import com.google.common.base.Optional; +import com.google.common.collect.ImmutableList; + +/** + * <p> + * Abstract mailet providing configurable redirection services.<br> + * This mailet can be subclassed to make authoring redirection mailets simple.<br> + * By extending it and overriding one or more of these methods new behaviour can + * be quickly created without the author having to address any other issue than + * the relevant one: + * </p> + * <ul> + * <li>attachError() , should error messages be appended to the message</li> + * <li>getAttachmentType(), what should be attached to the message</li> + * <li>getInLineType(), what should be included in the message</li> + * <li>getMessage(), The text of the message itself</li> + * <li>getRecipients(), the recipients the mail is sent to</li> + * <li>getReplyTo(), where replies to this message will be sent</li> + * <li>getReversePath(), what to set the reverse-path to</li> + * <li>getSender(), who the mail is from</li> + * <li>getSubject(), a string to replace the message subject</li> + * <li>getSubjectPrefix(), a prefix to be added to the message subject, possibly + * already replaced by a new subject</li> + * <li>getTo(), a list of people to whom the mail is *apparently* sent</li> + * <li>isReply(), should this mailet set the IN_REPLY_TO header to the id of the + * current message</li> + * <li>getPassThrough(), should this mailet allow the original message to + * continue processing or GHOST it.</li> + * <li>getFakeDomainCheck(), should this mailet check if the sender domain + * address is valid.</li> + * <li>isStatic(), should this mailet run the get methods for every mail, or + * just once.</li> + * </ul> + * <p> + * For each of the methods above (generically called "getX()" methods in this + * class and its subclasses), there is an associated "getX(Mail)" method and + * most times a "setX(Mail, Tx, Mail)" method.<br> + * The roles are the following: + * </p> + * <ul> + * <li>a "getX()" method returns the correspondent "X" value that can be + * evaluated "statically" once at init time and then stored in a variable and + * made available for later use by a "getX(Mail)" method;</li> + * <li>a "getX(Mail)" method is the one called to return the correspondent "X" + * value that can be evaluated "dynamically", tipically based on the currently + * serviced mail; the default behaviour is to return the value of getX();</li> + * <li>a "setX(Mail, Tx, Mail)" method is called to change the correspondent "X" + * value of the redirected Mail object, using the value returned by + * "gexX(Mail)"; if such value is null, it does nothing.</li> + * </ul> + * <p> + * Here follows the typical pattern of those methods: + * </p> + * <p/> + * <pre> + * <code> + * ... + * Tx x; + * ... + * protected boolean getX(Mail originalMail) throws MessagingException { + * boolean x = (isStatic()) ? this.x : getX(); + * ... + * return x; + * } + * ... + * public void init() throws MessagingException { + * ... + * isStatic = (getInitParameter("static") == null) ? false : new Boolean(getInitParameter("static")).booleanValue(); + * if(isStatic()) { + * ... + * X = getX(); + * ... + * } + * ... + * public void service(Mail originalMail) throws MessagingException { + * ... + * setX(newMail, getX(originalMail), originalMail); + * ... + * } + * ... + * </code> + * </pre> + * <p> + * The <i>isStatic</i> variable and method is used to allow for the situations + * (deprecated since version 2.2, but possibly used by previoulsy written + * extensions to {@link Redirect}) in which the getX() methods are non static: + * in this case {@link #isStatic()} must return false.<br> + * Finally, a "getX()" method may return a "special address" (see + * {@link SpecialAddress}), that later will be resolved ("late bound") by a + * "getX(Mail)" or "setX(Mail, Tx, Mail)": it is a dynamic value that does not + * require <code>isStatic</code> to be false. + * </p> + * <p/> + * <p> + * Supports by default the <code>passThrough</code> init parameter (false if + * missing). Subclasses can override this behaviour overriding + * {@link #getPassThrough()}. + * </p> + * + * @since 2.2.0 + */ + +public abstract class RedirectNotify extends GenericMailet { + + public static final List<String> REVERSE_PATH_ALLOWED_SPECIALS = ImmutableList.of("postmaster", "sender", "null", "unaltered"); + public static final List<String> SENDER_ALLOWED_SPECIALS = ImmutableList.of("postmaster", "sender", "unaltered"); + + public abstract InitParameters getInitParameters(); + + protected abstract String[] getAllowedInitParameters(); + + protected DNSService dns; + + @Inject + public void setDNSService(DNSService dns) { + this.dns = dns; + } + + /** + * Gets the <code>message</code> property, built dynamically using the + * original Mail object. Is a "getX(Mail)" method. + * + * @return {@link #getMessage()} + */ + public abstract String getMessage(Mail originalMail) throws MessagingException; + + /** + * Gets the <code>recipients</code> property. Returns the collection of + * recipients of the new message, or null if no change is requested. Is a + * "getX()" method. + * + * @return the <code>recipients</code> init parameter or the postmaster + * address or <code>SpecialAddress.SENDER</code> or + * <code>SpecialAddress.FROM</code> or + * <code>SpecialAddress.REPLY_TO</code> or + * <code>SpecialAddress.REVERSE_PATH</code> or + * <code>SpecialAddress.UNALTERED</code> or + * <code>SpecialAddress.RECIPIENTS</code> or <code>null</code> if + * missing + */ + public abstract List<MailAddress> getRecipients() throws MessagingException; + + /** + * Gets the <code>recipients</code> property, built dynamically using the + * original Mail object. Is a "getX(Mail)" method. + * + * @return {@link #replaceMailAddresses} on {@link #getRecipients()}, + */ + protected abstract List<MailAddress> getRecipients(Mail originalMail) throws MessagingException; + + /** + * Gets the <code>to</code> property. Returns the "To:" recipients of the + * new message. or null if no change is requested. Is a "getX()" method. + * + * @return the <code>to</code> init parameter or the postmaster address or + * <code>SpecialAddress.SENDER</code> or + * <code>SpecialAddress.REVERSE_PATH</code> or + * <code>SpecialAddress.FROM</code> or + * <code>SpecialAddress.REPLY_TO</code> or + * <code>SpecialAddress.UNALTERED</code> or + * <code>SpecialAddress.TO</code> or <code>null</code> if missing + */ + public abstract List<InternetAddress> getTo() throws MessagingException; + + /** + * Gets the <code>to</code> property, built dynamically using the original + * Mail object. Its outcome will be the the value the <i>TO:</i> header will + * be set to, that could be different from the real recipient (see + * {@link Mail#getRecipients}). Is a "getX(Mail)" method. + * + * @return {@link #replaceInternetAddresses} on {@link #getRecipients()}, + */ + protected abstract List<MailAddress> getTo(Mail originalMail) throws MessagingException; + + /** + * Gets the <code>replyto</code> property. Returns the Reply-To address of + * the new message, or null if no change is requested. Is a "getX()" method. + * + * @return the <code>replyto</code> init parameter or the postmaster address + * or <code>SpecialAddress.SENDER</code> or + * <code>SpecialAddress.UNALTERED</code> or + * <code>SpecialAddress.NULL</code> or <code>null</code> if missing + */ + public abstract MailAddress getReplyTo() throws MessagingException; + + /** + * Gets the <code>replyTo</code> property, built dynamically using the + * original Mail object. Is a "getX(Mail)" method. + * + * @return {@link #getReplyTo()} replacing + * <code>SpecialAddress.UNALTERED</code> if applicable with null and + * <code>SpecialAddress.SENDER</code> with the original mail sender + */ + protected abstract MailAddress getReplyTo(Mail originalMail) throws MessagingException; + + /** + * Gets the <code>reversePath</code> property. Returns the reverse-path of + * the new message, or null if no change is requested. Is a "getX()" method. + * + * @return the <code>reversePath</code> init parameter or the postmaster + * address or <code>SpecialAddress.SENDER</code> or + * <code>SpecialAddress.NULL</code> or + * <code>SpecialAddress.UNALTERED</code> or <code>null</code> if + * missing + */ + protected abstract MailAddress getReversePath() throws MessagingException; + + /** + * Gets the <code>reversePath</code> property, built dynamically using the + * original Mail object. Is a "getX(Mail)" method. + * + * @return {@link #getReversePath()}, replacing + * <code>SpecialAddress.SENDER</code> if applicable with null, + * replacing <code>SpecialAddress.UNALTERED</code> and + * <code>SpecialAddress.REVERSE_PATH</code> if applicable with null, + * but not replacing <code>SpecialAddress.NULL</code> that will be + * handled by {@link #setReversePath} + */ + protected abstract MailAddress getReversePath(Mail originalMail) throws MessagingException; + + /** + * Gets the <code>sender</code> property. Returns the new sender as a + * MailAddress, or null if no change is requested. Is a "getX()" method. + * + * @return the <code>sender</code> init parameter or the postmaster address + * or <code>SpecialAddress.SENDER</code> or + * <code>SpecialAddress.UNALTERED</code> or <code>null</code> if + * missing + */ + public abstract MailAddress getSender() throws MessagingException; + + /** + * Gets the <code>sender</code> property, built dynamically using the + * original Mail object. Is a "getX(Mail)" method. + * + * @return {@link #getSender()} replacing + * <code>SpecialAddress.UNALTERED</code> and + * <code>SpecialAddress.SENDER</code> if applicable with null + */ + protected abstract Optional<MailAddress> getSender(Mail originalMail) throws MessagingException; + + /** + * Builds the subject of <i>newMail</i> appending the subject of + * <i>originalMail</i> to <i>subjectPrefix</i>. Is a "setX(Mail, Tx, Mail)" + * method. + */ + protected abstract Optional<String> getSubjectPrefix(Mail newMail, String subjectPrefix, Mail originalMail) throws MessagingException; + + /** + * Mailet initialization routine. Will setup static values for each "x" + * initialization parameter in config.xml, using getX(), if + * {@link #isStatic()} returns true. + */ + @Override + public void init() throws MessagingException { + if (getInitParameters().isDebug()) { + log("Initializing"); + } + + // check that all init parameters have been declared in + // allowedInitParameters + checkInitParameters(getAllowedInitParameters()); + + if (getInitParameters().isStatic()) { + if (getInitParameters().isDebug()) { + log(getInitParameters().asString()); + } + } + } + + /** + * Service does the hard work,and redirects the originalMail in the form + * specified. + * + * @param originalMail the mail to process and redirect + * @throws MessagingException if a problem arises formulating the redirected mail + */ + @Override + public abstract void service(Mail originalMail) throws MessagingException; + + protected abstract MimeMessageModifier getMimeMessageModifier(Mail newMail, Mail originalMail) throws MessagingException; +} http://git-wip-us.apache.org/repos/asf/james-project/blob/5a81c0d9/server/mailet/mailets/src/main/java/org/apache/james/transport/util/RecipientsUtils.java ---------------------------------------------------------------------- diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/util/RecipientsUtils.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/util/RecipientsUtils.java index f99ae25..e1220c1 100644 --- a/server/mailet/mailets/src/main/java/org/apache/james/transport/util/RecipientsUtils.java +++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/util/RecipientsUtils.java @@ -22,7 +22,7 @@ import java.util.List; import javax.mail.MessagingException; -import org.apache.james.transport.mailets.redirect.AbstractRedirect; +import org.apache.james.transport.mailets.redirect.RedirectNotify; import org.apache.james.transport.mailets.redirect.SpecialAddress; import org.apache.mailet.Mail; import org.apache.mailet.MailAddress; @@ -31,13 +31,13 @@ import com.google.common.collect.ImmutableList; public class RecipientsUtils { - public static RecipientsUtils from(AbstractRedirect mailet) { + public static RecipientsUtils from(RedirectNotify mailet) { return new RecipientsUtils(mailet); } - private final AbstractRedirect mailet; + private final RedirectNotify mailet; - private RecipientsUtils(AbstractRedirect mailet) { + private RecipientsUtils(RedirectNotify mailet) { this.mailet = mailet; } http://git-wip-us.apache.org/repos/asf/james-project/blob/5a81c0d9/server/mailet/mailets/src/main/java/org/apache/james/transport/util/TosUtils.java ---------------------------------------------------------------------- diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/util/TosUtils.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/util/TosUtils.java index db31c87..44c03a1 100644 --- a/server/mailet/mailets/src/main/java/org/apache/james/transport/util/TosUtils.java +++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/util/TosUtils.java @@ -23,7 +23,7 @@ import java.util.List; import javax.mail.MessagingException; import javax.mail.internet.InternetAddress; -import org.apache.james.transport.mailets.redirect.AbstractRedirect; +import org.apache.james.transport.mailets.redirect.RedirectNotify; import org.apache.james.transport.mailets.redirect.SpecialAddress; import org.apache.mailet.Mail; import org.apache.mailet.MailAddress; @@ -32,13 +32,13 @@ import com.google.common.collect.ImmutableList; public class TosUtils { - public static TosUtils from(AbstractRedirect mailet) { + public static TosUtils from(RedirectNotify mailet) { return new TosUtils(mailet); } - private final AbstractRedirect mailet; + private final RedirectNotify mailet; - private TosUtils(AbstractRedirect mailet) { + private TosUtils(RedirectNotify mailet) { this.mailet = mailet; } http://git-wip-us.apache.org/repos/asf/james-project/blob/5a81c0d9/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/MailMessageAlteringUtilsTest.java ---------------------------------------------------------------------- diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/MailMessageAlteringUtilsTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/MailMessageAlteringUtilsTest.java index b43d883..70a7768 100644 --- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/MailMessageAlteringUtilsTest.java +++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/MailMessageAlteringUtilsTest.java @@ -42,7 +42,7 @@ public class MailMessageAlteringUtilsTest { public void buildShouldThrowWhenOriginalMailIsNull() { expectedException.expect(NullPointerException.class); expectedException.expectMessage("'originalMail' is mandatory"); - MailMessageAlteringUtils.from(mock(AbstractRedirect.class)) + MailMessageAlteringUtils.from(mock(RedirectNotify.class)) .build(); } @@ -50,14 +50,14 @@ public class MailMessageAlteringUtilsTest { public void buildShouldThrowWhenNewMailIsNull() { expectedException.expect(NullPointerException.class); expectedException.expectMessage("'newMail' is mandatory"); - MailMessageAlteringUtils.from(mock(AbstractRedirect.class)) + MailMessageAlteringUtils.from(mock(RedirectNotify.class)) .originalMail(mock(Mail.class)) .build(); } @Test public void buildShouldWorkWhenEverythingProvided() { - MailMessageAlteringUtils.from(mock(AbstractRedirect.class)) + MailMessageAlteringUtils.from(mock(RedirectNotify.class)) .originalMail(mock(Mail.class)) .newMail(mock(Mail.class)) .build(); @@ -65,7 +65,7 @@ public class MailMessageAlteringUtilsTest { @Test public void getFileNameShouldReturnNoSubjectWhenSubjectIsNull() { - MailMessageAlteringUtils alteredMailUtils = MailMessageAlteringUtils.from(mock(AbstractRedirect.class)) + MailMessageAlteringUtils alteredMailUtils = MailMessageAlteringUtils.from(mock(RedirectNotify.class)) .originalMail(mock(Mail.class)) .newMail(mock(Mail.class)) .build(); @@ -77,7 +77,7 @@ public class MailMessageAlteringUtilsTest { @Test public void getFileNameShouldReturnNoSubjectWhenSubjectContainsOnlySpaces() { - MailMessageAlteringUtils alteredMailUtils = MailMessageAlteringUtils.from(mock(AbstractRedirect.class)) + MailMessageAlteringUtils alteredMailUtils = MailMessageAlteringUtils.from(mock(RedirectNotify.class)) .originalMail(mock(Mail.class)) .newMail(mock(Mail.class)) .build(); @@ -89,7 +89,7 @@ public class MailMessageAlteringUtilsTest { @Test public void getFileNameShouldReturnSubjectWhenSubjectIsGiven() { - MailMessageAlteringUtils alteredMailUtils = MailMessageAlteringUtils.from(mock(AbstractRedirect.class)) + MailMessageAlteringUtils alteredMailUtils = MailMessageAlteringUtils.from(mock(RedirectNotify.class)) .originalMail(mock(Mail.class)) .newMail(mock(Mail.class)) .build(); @@ -101,7 +101,7 @@ public class MailMessageAlteringUtilsTest { @Test public void getFileNameShouldReturnTrimmedSubjectWhenSubjectStartsWithSpaces() { - MailMessageAlteringUtils alteredMailUtils = MailMessageAlteringUtils.from(mock(AbstractRedirect.class)) + MailMessageAlteringUtils alteredMailUtils = MailMessageAlteringUtils.from(mock(RedirectNotify.class)) .originalMail(mock(Mail.class)) .newMail(mock(Mail.class)) .build(); http://git-wip-us.apache.org/repos/asf/james-project/blob/5a81c0d9/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/MailModifierTest.java ---------------------------------------------------------------------- diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/MailModifierTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/MailModifierTest.java index 335e968..f996bf5 100644 --- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/MailModifierTest.java +++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/redirect/MailModifierTest.java @@ -43,7 +43,7 @@ public class MailModifierTest { expectedException.expect(NullPointerException.class); expectedException.expectMessage("'mail' is mandatory"); MailModifier.builder() - .mailet(mock(AbstractRedirect.class)) + .mailet(mock(RedirectNotify.class)) .build(); } @@ -52,7 +52,7 @@ public class MailModifierTest { expectedException.expect(NullPointerException.class); expectedException.expectMessage("'dns' is mandatory"); MailModifier.builder() - .mailet(mock(AbstractRedirect.class)) + .mailet(mock(RedirectNotify.class)) .mail(mock(MailImpl.class)) .build(); } @@ -60,7 +60,7 @@ public class MailModifierTest { @Test public void buildShouldWorkWhenEverythingProvided() { MailModifier.builder() - .mailet(mock(AbstractRedirect.class)) + .mailet(mock(RedirectNotify.class)) .mail(mock(MailImpl.class)) .dns(mock(DNSService.class)) .build(); http://git-wip-us.apache.org/repos/asf/james-project/blob/5a81c0d9/server/mailet/mailets/src/test/java/org/apache/james/transport/util/RecipientsUtilsTest.java ---------------------------------------------------------------------- diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/RecipientsUtilsTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/RecipientsUtilsTest.java index 68080d1..8649088 100644 --- a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/RecipientsUtilsTest.java +++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/RecipientsUtilsTest.java @@ -29,7 +29,7 @@ import javax.mail.Session; import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMessage.RecipientType; -import org.apache.james.transport.mailets.redirect.AbstractRedirect; +import org.apache.james.transport.mailets.redirect.RedirectNotify; import org.apache.james.transport.mailets.redirect.SpecialAddress; import org.apache.mailet.MailAddress; import org.apache.mailet.base.test.FakeMail; @@ -40,12 +40,12 @@ import com.google.common.collect.ImmutableList; public class RecipientsUtilsTest { - private AbstractRedirect mailet; + private RedirectNotify mailet; private RecipientsUtils testee; @Before public void setup() { - mailet = mock(AbstractRedirect.class); + mailet = mock(RedirectNotify.class); testee = RecipientsUtils.from(mailet); } http://git-wip-us.apache.org/repos/asf/james-project/blob/5a81c0d9/server/mailet/mailets/src/test/java/org/apache/james/transport/util/TosUtilsTest.java ---------------------------------------------------------------------- diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/TosUtilsTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/TosUtilsTest.java index f8fc000..21c8846 100644 --- a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/TosUtilsTest.java +++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/TosUtilsTest.java @@ -30,7 +30,7 @@ import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMessage.RecipientType; -import org.apache.james.transport.mailets.redirect.AbstractRedirect; +import org.apache.james.transport.mailets.redirect.RedirectNotify; import org.apache.james.transport.mailets.redirect.SpecialAddress; import org.apache.mailet.MailAddress; import org.apache.mailet.base.test.FakeMail; @@ -41,12 +41,12 @@ import com.google.common.collect.ImmutableList; public class TosUtilsTest { - private AbstractRedirect mailet; + private RedirectNotify mailet; private TosUtils testee; @Before public void setup() { - mailet = mock(AbstractRedirect.class); + mailet = mock(RedirectNotify.class); testee = TosUtils.from(mailet); } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
