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 bt...@apache.org on 2017/08/24 03:46:56 UTC
[31/38] james-project git commit: JAMES-2114 Deprecate the mailet
Logging APIs
http://git-wip-us.apache.org/repos/asf/james-project/blob/f35ab929/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 b40a542..eb41fcf 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
@@ -35,6 +35,7 @@ import javax.mail.internet.MimeMessage;
import org.apache.commons.lang.time.FastDateFormat;
import org.apache.james.core.MailImpl;
import org.apache.james.dnsservice.api.DNSService;
+import org.apache.james.transport.mailets.managesieve.ManageSieveMailet;
import org.apache.james.transport.mailets.redirect.InitParameters;
import org.apache.james.transport.mailets.redirect.MailModifier;
import org.apache.james.transport.mailets.redirect.NotifyMailetInitParameters;
@@ -57,6 +58,8 @@ import org.apache.mailet.base.GenericMailet;
import org.apache.mailet.base.RFC2822Headers;
import org.apache.mailet.base.StringUtils;
import org.apache.mailet.base.mail.MimeMultipartReport;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
@@ -102,6 +105,7 @@ import com.google.common.collect.ImmutableList;
*/
public class DSNBounce extends GenericMailet implements RedirectNotify {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ManageSieveMailet.class);
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);
@@ -129,7 +133,7 @@ public class DSNBounce extends GenericMailet implements RedirectNotify {
@Override
public void init() throws MessagingException {
if (getInitParameters().isDebug()) {
- log("Initializing");
+ LOGGER.debug("Initializing");
}
// check that all init parameters have been declared in
@@ -138,7 +142,7 @@ public class DSNBounce extends GenericMailet implements RedirectNotify {
if (getInitParameters().isStatic()) {
if (getInitParameters().isDebug()) {
- log(getInitParameters().asString());
+ LOGGER.debug(getInitParameters().asString());
}
}
messageString = getInitParameter("messageString",
@@ -246,7 +250,7 @@ public class DSNBounce extends GenericMailet implements RedirectNotify {
newMail.setRecipients(getSenderAsList(originalMail));
if (getInitParameters().isDebug()) {
- log("New mail - sender: " + newMail.getSender() + ", recipients: " + StringUtils.arrayToString(newMail.getRecipients().toArray()) + ", name: " + newMail.getName() + ", remoteHost: " + newMail.getRemoteHost() + ", remoteAddr: " + newMail.getRemoteAddr() + ", state: " + newMail.getState()
+ LOGGER.debug("New mail - sender: " + newMail.getSender() + ", recipients: " + StringUtils.arrayToString(newMail.getRecipients().toArray()) + ", name: " + newMail.getName() + ", remoteHost: " + newMail.getRemoteHost() + ", remoteAddr: " + newMail.getRemoteAddr() + ", state: " + newMail.getState()
+ ", lastUpdated: " + newMail.getLastUpdated() + ", errorMessage: " + newMail.getErrorMessage());
}
@@ -278,7 +282,7 @@ public class DSNBounce extends GenericMailet implements RedirectNotify {
private boolean hasSender(Mail originalMail) {
if (originalMail.getSender() == null) {
if (getInitParameters().isDebug()) {
- log("Processing a bounce request for a message with an empty reverse-path. No bounce will be sent.");
+ LOGGER.info("Processing a bounce request for a message with an empty reverse-path. No bounce will be sent.");
}
return false;
}
@@ -312,7 +316,7 @@ public class DSNBounce extends GenericMailet implements RedirectNotify {
private List<MailAddress> getSenderAsList(Mail originalMail) {
MailAddress reversePath = originalMail.getSender();
if (getInitParameters().isDebug()) {
- log("Processing a bounce request for a message with a reverse path. The bounce will be sent to " + reversePath);
+ LOGGER.debug("Processing a bounce request for a message with a reverse path. The bounce will be sent to " + reversePath);
}
return ImmutableList.of(reversePath);
@@ -398,7 +402,7 @@ public class DSNBounce extends GenericMailet implements RedirectNotify {
buffer.append("Reporting-MTA: dns; " + dns.getHostName(dns.getLocalHost()))
.append(LINE_BREAK);
} catch (Exception e) {
- log("WARNING: sending DSN without required Reporting-MTA Address");
+ LOGGER.error("Sending DSN without required Reporting-MTA Address", e);
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f35ab929/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 018ef9e..a07b112 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
@@ -41,6 +41,8 @@ import org.apache.james.transport.util.TosUtils;
import org.apache.mailet.Mail;
import org.apache.mailet.MailAddress;
import org.apache.mailet.base.GenericMailet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.base.Optional;
import com.google.common.base.Strings;
@@ -91,6 +93,7 @@ import com.google.common.collect.ImmutableList;
* </p>
*/
public class Forward extends GenericMailet implements RedirectNotify {
+ private static final Logger LOGGER = LoggerFactory.getLogger(Forward.class);
private static final String[] CONFIGURABLE_PARAMETERS = new String[] {
"debug", "passThrough", "fakeDomainCheck", "forwardto", "forwardTo" };
@@ -127,7 +130,7 @@ public class Forward extends GenericMailet implements RedirectNotify {
@Override
public void init() throws MessagingException {
if (getInitParameters().isDebug()) {
- log("Initializing");
+ LOGGER.debug("Initializing");
}
// check that all init parameters have been declared in
@@ -136,7 +139,7 @@ public class Forward extends GenericMailet implements RedirectNotify {
if (getInitParameters().isStatic()) {
if (getInitParameters().isDebug()) {
- log(getInitParameters().asString());
+ LOGGER.debug(getInitParameters().asString());
}
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f35ab929/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/FromRepository.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/FromRepository.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/FromRepository.java
index 57592e1..f6cd581 100755
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/FromRepository.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/FromRepository.java
@@ -29,9 +29,12 @@ import javax.mail.MessagingException;
import org.apache.james.lifecycle.api.LifecycleUtil;
import org.apache.james.mailrepository.api.MailRepository;
import org.apache.james.mailrepository.api.MailRepositoryStore;
+import org.apache.james.transport.mailets.managesieve.ManageSieveMailet;
import org.apache.mailet.Experimental;
import org.apache.mailet.Mail;
import org.apache.mailet.base.GenericMailet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Re-spools Mail found in the specified Repository.
@@ -46,6 +49,7 @@ import org.apache.mailet.base.GenericMailet;
*/
@Experimental
public class FromRepository extends GenericMailet {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ManageSieveMailet.class);
/** The repository from where this mailet spools mail. */
private MailRepository repository;
@@ -102,17 +106,7 @@ public class FromRepository extends GenericMailet {
try {
Mail mail = repository.retrieve(key);
if (mail != null && mail.getRecipients() != null) {
- log((new StringBuffer(160).append("Spooling mail ").append(mail.getName()).append(" from ").append(repositoryPath)).toString());
-
- /*
- * log("Return-Path: " +
- * mail.getMessage().getHeader(RFC2822Headers.RETURN_PATH,
- * ", ")); log("Sender: " + mail.getSender()); log("To: " +
- * mail.getMessage().getHeader(RFC2822Headers.TO, ", "));
- * log("Recipients: "); for (Iterator i =
- * mail.getRecipients().iterator(); i.hasNext(); ) {
- * log(" " + ((MailAddress)i.next()).toString()); };
- */
+ LOGGER.debug((new StringBuffer(160).append("Spooling mail ").append(mail.getName()).append(" from ").append(repositoryPath)).toString());
mail.setAttribute("FromRepository", Boolean.TRUE);
mail.setState(processor);
@@ -122,7 +116,7 @@ public class FromRepository extends GenericMailet {
LifecycleUtil.dispose(mail);
}
} catch (MessagingException e) {
- log((new StringBuffer(160).append("Unable to re-spool mail ").append(key).append(" from ").append(repositoryPath)).toString(), e);
+ LOGGER.error((new StringBuffer(160).append("Unable to re-spool mail ").append(key).append(" from ").append(repositoryPath)).toString(), e);
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f35ab929/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/JDBCAlias.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/JDBCAlias.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/JDBCAlias.java
index df89bd5..6b71b97 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/JDBCAlias.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/JDBCAlias.java
@@ -38,6 +38,8 @@ import org.apache.mailet.Mail;
import org.apache.mailet.MailAddress;
import org.apache.mailet.MailetException;
import org.apache.mailet.base.GenericMailet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Rewrites recipient addresses based on a database table. The connection is
@@ -55,6 +57,7 @@ import org.apache.mailet.base.GenericMailet;
*/
@Experimental
public class JDBCAlias extends GenericMailet {
+ private static final Logger LOGGER = LoggerFactory.getLogger(JDBCAlias.class);
protected DataSource datasource;
protected String query = null;
@@ -65,11 +68,7 @@ public class JDBCAlias extends GenericMailet {
}
// The JDBCUtil helper class
- private final JDBCUtil theJDBCUtil = new JDBCUtil() {
- protected void delegatedLog(String logString) {
- log("JDBCAlias: " + logString);
- }
- };
+ private final JDBCUtil theJDBCUtil = new JDBCUtil();
/**
* Initialize the mailet
@@ -149,7 +148,7 @@ public class JDBCAlias extends GenericMailet {
// Don't alias this address... there's an invalid
// address mapping here
String exceptionBuffer = "There is an invalid alias from " + recipient + " to " + mappingRS.getString(1);
- log(exceptionBuffer);
+ LOGGER.error(exceptionBuffer, pe);
}
} finally {
ResultSet localRS = mappingRS;
http://git-wip-us.apache.org/repos/asf/james-project/blob/f35ab929/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/JDBCRecipientRewriteTable.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/JDBCRecipientRewriteTable.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/JDBCRecipientRewriteTable.java
index c9e77cc..a06266f 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/JDBCRecipientRewriteTable.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/JDBCRecipientRewriteTable.java
@@ -121,11 +121,7 @@ public class JDBCRecipientRewriteTable extends AbstractRecipientRewriteTable {
/**
* The JDBCUtil helper class
*/
- private final JDBCUtil theJDBCUtil = new JDBCUtil() {
- protected void delegatedLog(String logString) {
- log("JDBCRecipientRewriteTable: " + logString);
- }
- };
+ private final JDBCUtil theJDBCUtil = new JDBCUtil();
@Inject
public void setDataSourceSelector(DataSource datasource) {
http://git-wip-us.apache.org/repos/asf/james-project/blob/f35ab929/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 f10cf9e..3522a56 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
@@ -44,6 +44,8 @@ import org.apache.mailet.Mail;
import org.apache.mailet.MailAddress;
import org.apache.mailet.MailetConfig;
import org.apache.mailet.base.GenericMailet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
@@ -121,6 +123,7 @@ import com.google.common.collect.ImmutableList;
* </p>
*/
public class NotifyPostmaster extends GenericMailet implements RedirectNotify {
+ private static final Logger LOGGER = LoggerFactory.getLogger(NotifyPostmaster.class);
private static final String[] CONFIGURABLE_PARAMETERS = new String[]{
"debug", "passThrough", "fakeDomainCheck", "inline", "attachment", "message", "notice", "sender", "sendingAddress", "prefix", "attachError", "to" };
@@ -163,7 +166,7 @@ public class NotifyPostmaster extends GenericMailet implements RedirectNotify {
@Override
public void init() throws MessagingException {
if (getInitParameters().isDebug()) {
- log("Initializing");
+ LOGGER.debug("Initializing");
}
// check that all init parameters have been declared in
@@ -172,7 +175,7 @@ public class NotifyPostmaster extends GenericMailet implements RedirectNotify {
if (getInitParameters().isStatic()) {
if (getInitParameters().isDebug()) {
- log(getInitParameters().asString());
+ LOGGER.debug(getInitParameters().asString());
}
}
}
@@ -201,7 +204,7 @@ public class NotifyPostmaster extends GenericMailet implements RedirectNotify {
if (specialAddress.isPresent()) {
return ImmutableList.of(specialAddress.get().toInternetAddress());
}
- log("\"to\" parameter ignored, set to postmaster");
+ LOGGER.info("\"to\" parameter ignored, set to postmaster");
}
return ImmutableList.of(getMailetContext().getPostmaster().toInternetAddress());
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f35ab929/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 74b12c3..85cec94 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
@@ -44,6 +44,8 @@ import org.apache.mailet.Mail;
import org.apache.mailet.MailAddress;
import org.apache.mailet.MailetConfig;
import org.apache.mailet.base.GenericMailet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
@@ -120,6 +122,7 @@ import com.google.common.collect.ImmutableList;
* </p>
*/
public class NotifySender extends GenericMailet implements RedirectNotify {
+ private static final Logger LOGGER = LoggerFactory.getLogger(NotifySender.class);
private static final String[] CONFIGURABLE_PARAMETERS = new String[]{
"debug", "passThrough", "fakeDomainCheck", "inline", "attachment", "message", "notice", "sender", "sendingAddress", "prefix", "attachError", "to" };
@@ -163,7 +166,7 @@ public class NotifySender extends GenericMailet implements RedirectNotify {
@Override
public void init() throws MessagingException {
if (getInitParameters().isDebug()) {
- log("Initializing");
+ LOGGER.debug("Initializing");
}
// check that all init parameters have been declared in
@@ -172,7 +175,7 @@ public class NotifySender extends GenericMailet implements RedirectNotify {
if (getInitParameters().isStatic()) {
if (getInitParameters().isDebug()) {
- log(getInitParameters().asString());
+ LOGGER.debug(getInitParameters().asString());
}
}
}
@@ -201,7 +204,7 @@ public class NotifySender extends GenericMailet implements RedirectNotify {
if (specialAddress.isPresent()) {
return ImmutableList.of(specialAddress.get().toInternetAddress());
}
- log("\"to\" parameter ignored, set to sender");
+ LOGGER.info("\"to\" parameter ignored, set to sender");
}
return ImmutableList.of(SpecialAddress.SENDER.toInternetAddress());
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f35ab929/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessor.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessor.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessor.java
index 1fe511a..c47b744 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessor.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessor.java
@@ -35,7 +35,8 @@ import org.apache.james.rrt.lib.Mappings;
import org.apache.mailet.Mail;
import org.apache.mailet.MailAddress;
import org.apache.mailet.MailetContext;
-import org.apache.mailet.MailetContext.LogLevel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
@@ -46,6 +47,8 @@ import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList;
public class RecipientRewriteTableProcessor {
+ private static final Logger LOGGER = LoggerFactory.getLogger(RecipientRewriteTableProcessor.class);
+
private final org.apache.james.rrt.api.RecipientRewriteTable virtualTableStore;
private final DomainList domainList;
private final MailetContext mailetContext;
@@ -117,7 +120,7 @@ public class RecipientRewriteTableProcessor {
}
return origin(recipient);
} catch (ErrorMappingException | RecipientRewriteTableException | MessagingException e) {
- mailetContext.log(LogLevel.INFO, "Error while process mail.", e);
+ LOGGER.info("Error while process mail.", e);
return error(recipient);
}
}
@@ -181,9 +184,9 @@ public class RecipientRewriteTableProcessor {
if (!remoteAddress.isEmpty()) {
try {
mailetContext.sendMail(sender, remoteAddress, message);
- mailetContext.log(LogLevel.INFO, "Mail for " + recipient + " forwarded to " + remoteAddress);
+ LOGGER.info("Mail for " + recipient + " forwarded to " + remoteAddress);
} catch (MessagingException ex) {
- mailetContext.log(LogLevel.WARN, "Error forwarding mail to " + remoteAddress);
+ LOGGER.warn("Error forwarding mail to " + remoteAddress);
}
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f35ab929/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 e2c769e..1167408 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
@@ -26,6 +26,7 @@ import javax.mail.MessagingException;
import javax.mail.internet.InternetAddress;
import org.apache.james.dnsservice.api.DNSService;
+import org.apache.james.transport.mailets.managesieve.ManageSieveMailet;
import org.apache.james.transport.mailets.redirect.AddressExtractor;
import org.apache.james.transport.mailets.redirect.InitParameters;
import org.apache.james.transport.mailets.redirect.ProcessRedirectNotify;
@@ -43,6 +44,8 @@ import org.apache.james.transport.util.TosUtils;
import org.apache.mailet.Mail;
import org.apache.mailet.MailAddress;
import org.apache.mailet.base.GenericMailet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.base.Optional;
import com.google.common.collect.FluentIterable;
@@ -300,6 +303,7 @@ import com.google.common.collect.ImmutableList;
*/
public class Redirect extends GenericMailet implements RedirectNotify {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ManageSieveMailet.class);
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" };
@@ -335,7 +339,7 @@ public class Redirect extends GenericMailet implements RedirectNotify {
@Override
public void init() throws MessagingException {
if (getInitParameters().isDebug()) {
- log("Initializing");
+ LOGGER.debug("Initializing");
}
// check that all init parameters have been declared in
@@ -344,7 +348,7 @@ public class Redirect extends GenericMailet implements RedirectNotify {
if (getInitParameters().isStatic()) {
if (getInitParameters().isDebug()) {
- log(getInitParameters().asString());
+ LOGGER.debug(getInitParameters().asString());
}
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f35ab929/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java
index 76736cf..1d74732 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java
@@ -44,6 +44,8 @@ import org.apache.james.transport.mailets.remoteDelivery.RemoteDeliverySocketFac
import org.apache.mailet.Mail;
import org.apache.mailet.MailAddress;
import org.apache.mailet.base.GenericMailet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.collect.HashMultimap;
@@ -118,6 +120,7 @@ import com.google.common.collect.HashMultimap;
* </ul>
*/
public class RemoteDelivery extends GenericMailet {
+ private static final Logger LOGGER = LoggerFactory.getLogger(RemoteDelivery.class);
public enum THREAD_STATE {
START_THREADS,
@@ -158,7 +161,7 @@ public class RemoteDelivery extends GenericMailet {
if (configuration.isBindUsed())
RemoteDeliverySocketFactory.setBindAdress(configuration.getBindAddress());
} catch (UnknownHostException e) {
- log("Invalid bind setting (" + configuration.getBindAddress() + "): " + e.toString());
+ LOGGER.error("Invalid bind setting (" + configuration.getBindAddress() + "): ", e);
}
if (startThreads == THREAD_STATE.START_THREADS) {
initDeliveryThreads();
@@ -187,7 +190,7 @@ public class RemoteDelivery extends GenericMailet {
@Override
public void service(Mail mail) throws MessagingException {
if (configuration.isDebug()) {
- log("Remotely delivering mail " + mail.getName());
+ LOGGER.debug("Remotely delivering mail " + mail.getName());
}
if (configuration.isUsePriority()) {
mail.setAttribute(MailPrioritySupport.MAIL_PRIORITY, MailPrioritySupport.HIGH_PRIORITY);
@@ -199,19 +202,19 @@ public class RemoteDelivery extends GenericMailet {
serviceWithGateway(mail);
}
} else {
- log("Mail " + mail.getName() + " from " + mail.getSender() + " has no recipients and can not be remotely delivered");
+ LOGGER.debug("Mail " + mail.getName() + " from " + mail.getSender() + " has no recipients and can not be remotely delivered");
}
mail.setState(Mail.GHOST);
}
private void serviceWithGateway(Mail mail) {
if (configuration.isDebug()) {
- log("Sending mail to " + mail.getRecipients() + " via " + configuration.getGatewayServer());
+ LOGGER.debug("Sending mail to " + mail.getRecipients() + " via " + configuration.getGatewayServer());
}
try {
queue.enQueue(mail);
} catch (MailQueueException e) {
- log("Unable to queue mail " + mail.getName() + " for recipients + " + mail.getRecipients().toString(), e);
+ LOGGER.error("Unable to queue mail " + mail.getName() + " for recipients + " + mail.getRecipients(), e);
}
}
@@ -225,14 +228,14 @@ public class RemoteDelivery extends GenericMailet {
private void serviceSingleServer(Mail mail, String originalName, Map.Entry<String, Collection<MailAddress>> entry) {
if (configuration.isDebug()) {
- log("Sending mail to " + entry.getValue() + " on host " + entry.getKey());
+ LOGGER.debug("Sending mail to " + entry.getValue() + " on host " + entry.getKey());
}
mail.setRecipients(entry.getValue());
mail.setName(originalName + NAME_JUNCTION + entry.getKey());
try {
queue.enQueue(mail);
} catch (MailQueueException e) {
- log("Unable to queue mail " + mail.getName() + " for recipients + " + mail.getRecipients().toString(), e);
+ LOGGER.error("Unable to queue mail " + mail.getName() + " for recipients + " + mail.getRecipients(), e);
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f35ab929/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 0f78641..891bd16 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
@@ -42,6 +42,8 @@ import org.apache.james.transport.util.TosUtils;
import org.apache.mailet.Mail;
import org.apache.mailet.MailAddress;
import org.apache.mailet.base.GenericMailet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.base.Optional;
import com.google.common.collect.FluentIterable;
@@ -295,6 +297,7 @@ import com.google.common.collect.ImmutableList;
*/
public class Resend extends GenericMailet implements RedirectNotify {
+ private static final Logger LOGGER = LoggerFactory.getLogger(Resend.class);
private static final String[] CONFIGURABLE_PARAMETERS = new String[] {
"debug", "passThrough", "fakeDomainCheck", "inline", "attachment", "message", "recipients", "to", "replyTo", "replyto", "reversePath", "sender", "subject", "prefix", "attachError", "isReply" };
@@ -328,7 +331,7 @@ public class Resend extends GenericMailet implements RedirectNotify {
@Override
public void init() throws MessagingException {
if (getInitParameters().isDebug()) {
- log("Initializing");
+ LOGGER.debug("Initializing");
}
// check that all init parameters have been declared in
@@ -337,7 +340,7 @@ public class Resend extends GenericMailet implements RedirectNotify {
if (getInitParameters().isStatic()) {
if (getInitParameters().isDebug()) {
- log(getInitParameters().asString());
+ LOGGER.debug(getInitParameters().asString());
}
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f35ab929/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java
index 5f8a4ac..6bd7519 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java
@@ -25,10 +25,12 @@ import javax.mail.internet.MimeMessage;
import org.apache.james.jspf.core.Logger;
import org.apache.james.jspf.executor.SPFResult;
import org.apache.james.jspf.impl.DefaultSPF;
+import org.apache.james.transport.mailets.managesieve.ManageSieveMailet;
import org.apache.mailet.Experimental;
-import org.apache.mailet.base.GenericMailet;
import org.apache.mailet.Mail;
import org.apache.mailet.MailAddress;
+import org.apache.mailet.base.GenericMailet;
+import org.slf4j.LoggerFactory;
/**
* Check the ip, sender, helo against SPF. Add the following attributes to the
@@ -52,6 +54,8 @@ import org.apache.mailet.MailAddress;
*/
@Experimental
public class SPF extends GenericMailet {
+ private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(ManageSieveMailet.class);
+
private boolean addHeader = false;
private org.apache.james.jspf.impl.SPF spf;
public final static String EXPLANATION_ATTRIBUTE = "org.apache.james.transport.mailets.spf.explanation";
@@ -86,7 +90,7 @@ public class SPF extends GenericMailet {
mail.setAttribute(EXPLANATION_ATTRIBUTE, result.getExplanation());
mail.setAttribute(RESULT_ATTRIBUTE, result.getResult());
- log("ip:" + remoteAddr + " from:" + sender + " helo:" + helo + " = " + result.getResult());
+ LOGGER.debug("ip:" + remoteAddr + " from:" + sender + " helo:" + helo + " = " + result.getResult());
if (addHeader) {
try {
MimeMessage msg = mail.getMessage();
@@ -114,30 +118,30 @@ public class SPF extends GenericMailet {
public void debug(String arg0) {
if (debug) {
- log(arg0);
+ LOGGER.debug(arg0);
}
}
public void debug(String arg0, Throwable arg1) {
if (debug) {
- log(arg0, arg1);
+ LOGGER.debug(arg0, arg1);
}
}
public void error(String arg0) {
- log(arg0);
+ LOGGER.error(arg0);
}
public void error(String arg0, Throwable arg1) {
- log(arg0, arg1);
+ LOGGER.error(arg0, arg1);
}
public void fatalError(String arg0) {
- log(arg0);
+ LOGGER.error(arg0);
}
public void fatalError(String arg0, Throwable arg1) {
- log(arg0, arg1);
+ LOGGER.error(arg0, arg1);
}
public Logger getChildLogger(String childName) {
@@ -145,39 +149,39 @@ public class SPF extends GenericMailet {
}
public void info(String arg0) {
- log(arg0);
+ LOGGER.info(arg0);
}
public void info(String arg0, Throwable arg1) {
- log(arg0, arg1);
+ LOGGER.info(arg0, arg1);
}
public boolean isDebugEnabled() {
- return debug;
+ return LOGGER.isDebugEnabled();
}
public boolean isErrorEnabled() {
- return true;
+ return LOGGER.isErrorEnabled();
}
public boolean isFatalErrorEnabled() {
- return true;
+ return LOGGER.isErrorEnabled();
}
public boolean isInfoEnabled() {
- return true;
+ return LOGGER.isInfoEnabled();
}
public boolean isWarnEnabled() {
- return true;
+ return LOGGER.isWarnEnabled();
}
public void warn(String arg0) {
- log(arg0);
+ LOGGER.warn(arg0);
}
public void warn(String arg0, Throwable arg1) {
- log(arg0, arg1);
+ LOGGER.warn(arg0, arg1);
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f35ab929/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SpamAssassin.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SpamAssassin.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SpamAssassin.java
index 3e2061b..970bcf1 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SpamAssassin.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SpamAssassin.java
@@ -19,13 +19,16 @@
package org.apache.james.transport.mailets;
+import javax.mail.MessagingException;
+import javax.mail.internet.MimeMessage;
+
+import org.apache.james.transport.mailets.managesieve.ManageSieveMailet;
import org.apache.james.util.scanner.SpamAssassinInvoker;
import org.apache.mailet.Experimental;
-import org.apache.mailet.base.GenericMailet;
import org.apache.mailet.Mail;
-
-import javax.mail.MessagingException;
-import javax.mail.internet.MimeMessage;
+import org.apache.mailet.base.GenericMailet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Sends the message through daemonized SpamAssassin (spamd), visit <a
@@ -53,9 +56,9 @@ import javax.mail.internet.MimeMessage;
*/
@Experimental
public class SpamAssassin extends GenericMailet {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ManageSieveMailet.class);
String spamdHost;
-
int spamdPort;
/**
@@ -98,7 +101,7 @@ public class SpamAssassin extends GenericMailet {
message.saveChanges();
} catch (MessagingException e) {
- log(e.getMessage());
+ LOGGER.error("Encountered exception", e);
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f35ab929/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/ToRepository.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/ToRepository.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/ToRepository.java
index 46152fd..4424721 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/ToRepository.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/ToRepository.java
@@ -26,6 +26,8 @@ import org.apache.james.mailrepository.api.MailRepository;
import org.apache.james.mailrepository.api.MailRepositoryStore;
import org.apache.mailet.Mail;
import org.apache.mailet.base.GenericMailet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Stores incoming Mail in the specified Repository.<br>
@@ -33,6 +35,7 @@ import org.apache.mailet.base.GenericMailet;
* the pipe and may be processed by additional mailets. If false will be destroyed.
*/
public class ToRepository extends GenericMailet {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ToRepository.class);
private MailRepository repository;
@@ -73,7 +76,7 @@ public class ToRepository extends GenericMailet {
@Override
public void service(Mail mail) throws javax.mail.MessagingException {
String logBuffer = "Storing mail " + mail.getName() + " in " + repositoryPath;
- log(logBuffer);
+ LOGGER.info(logBuffer);
repository.store(mail);
if (!passThrough) {
mail.setState(Mail.GHOST);
http://git-wip-us.apache.org/repos/asf/james-project/blob/f35ab929/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/ToSenderFolder.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/ToSenderFolder.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/ToSenderFolder.java
index 41e0749..56f4e77 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/ToSenderFolder.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/ToSenderFolder.java
@@ -30,6 +30,8 @@ import org.apache.mailet.Experimental;
import org.apache.mailet.Mail;
import org.apache.mailet.MailAddress;
import org.apache.mailet.base.GenericMailet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Receives a Mail from the Queue and takes care to deliver the message
@@ -49,6 +51,7 @@ import org.apache.mailet.base.GenericMailet;
*/
@Experimental
public class ToSenderFolder extends GenericMailet {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ToSenderFolder.class);
private final UsersRepository usersRepository;
private final MailboxManager mailboxManager;
@@ -83,7 +86,7 @@ public class ToSenderFolder extends GenericMailet {
mailboxAppender.append(mail.getMessage(), username, folder);
- log("Local delivery with ToSenderFolder mailet for mail " + mail.getName() + " with sender " + sender.toString() + " in folder " + folder);
+ LOGGER.error("Local delivery with ToSenderFolder mailet for mail " + mail.getName() + " with sender " + sender.toString() + " in folder " + folder);
}
private String retrieveUser(MailAddress sender) throws MessagingException {
http://git-wip-us.apache.org/repos/asf/james-project/blob/f35ab929/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java
index 2a16dfa..cc48148 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/WhiteListManager.java
@@ -46,6 +46,7 @@ import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import javax.sql.DataSource;
+import org.apache.james.transport.mailets.managesieve.ManageSieveMailet;
import org.apache.james.user.api.UsersRepository;
import org.apache.james.user.api.model.JamesUser;
import org.apache.james.util.sql.JDBCUtil;
@@ -56,6 +57,8 @@ import org.apache.mailet.MailAddress;
import org.apache.mailet.base.DateFormats;
import org.apache.mailet.base.GenericMailet;
import org.apache.mailet.base.RFC2822Headers;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* <p>
@@ -122,6 +125,7 @@ import org.apache.mailet.base.RFC2822Headers;
@Experimental
@SuppressWarnings("deprecation")
public class WhiteListManager extends GenericMailet {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ManageSieveMailet.class);
private boolean automaticInsert;
private String displayFlag;
@@ -145,11 +149,7 @@ public class WhiteListManager extends GenericMailet {
/**
* The JDBCUtil helper class
*/
- private final JDBCUtil theJDBCUtil = new JDBCUtil() {
- protected void delegatedLog(String logString) {
- log("WhiteListManager: " + logString);
- }
- };
+ private final JDBCUtil theJDBCUtil = new JDBCUtil();
/**
* Contains all of the sql strings for this component.
@@ -184,7 +184,7 @@ public class WhiteListManager extends GenericMailet {
*/
public void init() throws MessagingException {
automaticInsert = Boolean.valueOf(getInitParameter("automaticInsert"));
- log("automaticInsert: " + automaticInsert);
+ LOGGER.debug("automaticInsert: " + automaticInsert);
displayFlag = getInitParameter("displayFlag");
insertFlag = getInitParameter("insertFlag");
@@ -193,7 +193,7 @@ public class WhiteListManager extends GenericMailet {
String whitelistManagerAddressString = getInitParameter("whitelistManagerAddress");
if (whitelistManagerAddressString != null) {
whitelistManagerAddressString = whitelistManagerAddressString.trim();
- log("whitelistManagerAddress: " + whitelistManagerAddressString);
+ LOGGER.debug("whitelistManagerAddress: " + whitelistManagerAddressString);
try {
whitelistManagerAddress = new MailAddress(whitelistManagerAddressString);
} catch (javax.mail.internet.ParseException pe) {
@@ -202,29 +202,29 @@ public class WhiteListManager extends GenericMailet {
if (displayFlag != null) {
displayFlag = displayFlag.trim();
- log("displayFlag: " + displayFlag);
+ LOGGER.debug("displayFlag: " + displayFlag);
} else {
- log("displayFlag is null");
+ LOGGER.debug("displayFlag is null");
}
if (insertFlag != null) {
insertFlag = insertFlag.trim();
- log("insertFlag: " + insertFlag);
+ LOGGER.debug("insertFlag: " + insertFlag);
} else {
- log("insertFlag is null");
+ LOGGER.debug("insertFlag is null");
}
if (removeFlag != null) {
removeFlag = removeFlag.trim();
- log("removeFlag: " + removeFlag);
+ LOGGER.debug("removeFlag: " + removeFlag);
} else {
- log("removeFlag is null");
+ LOGGER.debug("removeFlag is null");
}
} else {
- log("whitelistManagerAddress is null; will ignore commands");
+ LOGGER.debug("whitelistManagerAddress is null; will ignore commands");
}
String repositoryPath = getInitParameter("repositoryPath");
if (repositoryPath != null) {
- log("repositoryPath: " + repositoryPath);
+ LOGGER.debug("repositoryPath: " + repositoryPath);
} else {
throw new MessagingException("repositoryPath is null");
}
@@ -360,7 +360,7 @@ public class WhiteListManager extends GenericMailet {
}
}
} catch (SQLException sqle) {
- log("Error accessing database", sqle);
+ LOGGER.error("Error accessing database", sqle);
throw new MessagingException("Exception thrown", sqle);
} finally {
theJDBCUtil.closeJDBCStatement(selectStmt);
@@ -372,7 +372,7 @@ public class WhiteListManager extends GenericMailet {
dbUpdated = false;
}
} catch (Exception e) {
- log("Ignored exception upon rollback", e);
+ LOGGER.error("Ignored exception upon rollback", e);
}
theJDBCUtil.closeJDBCConnection(conn);
}
@@ -507,7 +507,7 @@ public class WhiteListManager extends GenericMailet {
}
if (dbUpdated) {
- log("Insertion request issued by " + senderMailAddress);
+ LOGGER.debug("Insertion request issued by " + senderMailAddress);
}
// Commit our changes if necessary.
if (conn != null && dbUpdated && !conn.getAutoCommit()) {
@@ -541,7 +541,7 @@ public class WhiteListManager extends GenericMailet {
dbUpdated = false;
}
} catch (Exception e) {
- log("Ignored exception upon rollback", e);
+ LOGGER.error("Ignored exception upon rollback", e);
}
theJDBCUtil.closeJDBCConnection(conn);
}
@@ -628,7 +628,7 @@ public class WhiteListManager extends GenericMailet {
}
if (dbUpdated) {
- log("Removal request issued by " + senderMailAddress);
+ LOGGER.debug("Removal request issued by " + senderMailAddress);
}
// Commit our changes if necessary.
if (conn != null && dbUpdated && !conn.getAutoCommit()) {
@@ -662,7 +662,7 @@ public class WhiteListManager extends GenericMailet {
dbUpdated = false;
}
} catch (Exception e) {
- log("Ignored exception upon rollback", e);
+ LOGGER.error("Ignored exception upon rollback", e);
}
theJDBCUtil.closeJDBCConnection(conn);
}
@@ -719,7 +719,7 @@ public class WhiteListManager extends GenericMailet {
// Send it off...
getMailetContext().sendMail(notifier, recipients, reply);
} catch (Exception e) {
- log("Exception found sending reply", e);
+ LOGGER.error("Exception found sending reply", e);
}
}
@@ -806,7 +806,7 @@ public class WhiteListManager extends GenericMailet {
StringBuffer logBuffer;
logBuffer = new StringBuffer(64).append("Created table '").append(tableName).append("' using sqlResources string '").append(createSqlStringName).append("'.");
- log(logBuffer.toString());
+ LOGGER.info(logBuffer.toString());
} finally {
theJDBCUtil.closeJDBCStatement(createStatement);
http://git-wip-us.apache.org/repos/asf/james-project/blob/f35ab929/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/SieveMailAdapter.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/SieveMailAdapter.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/SieveMailAdapter.java
index 8befe47..dbebaeb 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/SieveMailAdapter.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/SieveMailAdapter.java
@@ -52,6 +52,8 @@ import org.apache.mailet.Mail;
import org.apache.mailet.MailAddress;
import org.apache.mailet.MailetContext;
import org.joda.time.DateTime;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.collect.Lists;
@@ -62,6 +64,8 @@ import com.google.common.collect.Lists;
* </p>
*/
public class SieveMailAdapter implements MailAdapter, EnvelopeAccessors, ActionContext {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SieveMailAdapter.class);
+
/**
* The Mail being adapted.
*/
@@ -170,7 +174,7 @@ public class SieveMailAdapter implements MailAdapter, EnvelopeAccessors, ActionC
{
final List<Action> actions = getActions();
for (final Action action: actions) {
- getMailetContext().log(MailetContext.LogLevel.INFO, "Executing action: " + action.toString());
+ LOGGER.info("Executing action: " + action.toString());
try
{
dispatcher.execute(action, getMail(), this);
http://git-wip-us.apache.org/repos/asf/james-project/blob/f35ab929/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/managesieve/ManageSieveMailet.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/managesieve/ManageSieveMailet.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/managesieve/ManageSieveMailet.java
index 116bf46..927d330 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/managesieve/ManageSieveMailet.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/managesieve/ManageSieveMailet.java
@@ -41,9 +41,9 @@ import org.apache.james.transport.mailets.managesieve.transcode.MessageToCoreToM
import org.apache.james.user.api.UsersRepository;
import org.apache.mailet.Experimental;
import org.apache.mailet.Mail;
-import org.apache.mailet.MailetContext;
-import org.apache.mailet.MailetContext.LogLevel;
import org.apache.mailet.base.GenericMailet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Lists;
@@ -90,6 +90,7 @@ import com.google.common.collect.Lists;
*/
@Experimental
public class ManageSieveMailet extends GenericMailet implements MessageToCoreToMessage.HelpProvider {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ManageSieveMailet.class);
// Injected
private SieveRepository sieveRepository = null;
@@ -123,11 +124,11 @@ public class ManageSieveMailet extends GenericMailet implements MessageToCoreToM
public void service(Mail mail) throws MessagingException {
// Sanity checks
if (mail.getSender() == null) {
- getMailetContext().log(MailetContext.LogLevel.ERROR, "Sender is null");
+ LOGGER.error("Sender is null");
return;
}
if (!getMailetContext().isLocalServer(mail.getSender().getDomain().toLowerCase(Locale.US))) {
- getMailetContext().log(LogLevel.ERROR, "Sender not local");
+ LOGGER.error("Sender not local");
return;
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f35ab929/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 1f0e0b8..b6a956b 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
@@ -31,12 +31,14 @@ import org.apache.james.core.MimeMessageUtil;
import org.apache.james.transport.mailets.utils.MimeMessageUtils;
import org.apache.mailet.Mail;
import org.apache.mailet.base.RFC2822Headers;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
public class MailMessageAlteringUtils {
-
+ private static final Logger LOGGER = LoggerFactory.getLogger(MailMessageAlteringUtils.class);
private static final char LINE_BREAK = '\n';
public static Builder from(RedirectNotify mailet) {
@@ -87,9 +89,6 @@ public class MailMessageAlteringUtils {
/**
* Builds the message of the newMail in case it has to be altered.
- *
- * @param originalMail the original Mail object
- * @param newMail the Mail object to build
*/
private void alterNewMessage() throws MessagingException {
@@ -114,7 +113,7 @@ public class MailMessageAlteringUtils {
multipart.addBodyPart(contentPartRoot);
if (mailet.getInitParameters().isDebug()) {
- mailet.log("attachmentType:" + mailet.getInitParameters().getAttachmentType());
+ LOGGER.debug("attachmentType:" + mailet.getInitParameters().getAttachmentType());
}
if (!mailet.getInitParameters().getAttachmentType().equals(TypeCode.NONE)) {
multipart.addBodyPart(getAttachmentPart(originalMessage, head));
@@ -193,7 +192,7 @@ public class MailMessageAlteringUtils {
}
if (mailet.getInitParameters().isDebug()) {
- mailet.log("inline:" + mailet.getInitParameters().getInLineType());
+ LOGGER.debug("inline:" + mailet.getInitParameters().getInLineType());
}
switch (mailet.getInitParameters().getInLineType()) {
case ALL:
http://git-wip-us.apache.org/repos/asf/james-project/blob/f35ab929/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 9a9d228..ff7c6d9 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
@@ -34,11 +34,14 @@ import org.apache.mailet.MailAddress;
import org.apache.mailet.base.DateFormats;
import org.apache.mailet.base.RFC2822Headers;
import org.apache.mailet.base.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
public class MailModifier {
+ private static final Logger LOGGER = LoggerFactory.getLogger(MailModifier.class);
private static final String LOCAHOST = "127.0.0.1";
@@ -108,7 +111,7 @@ public class MailModifier {
if (!recipients.isEmpty()) {
mail.setRecipients(recipients);
if (mailet.getInitParameters().isDebug()) {
- mailet.log("recipients set to: " + StringUtils.arrayToString(recipients.toArray()));
+ LOGGER.debug("recipients set to: " + StringUtils.arrayToString(recipients.toArray()));
}
}
}
@@ -118,7 +121,7 @@ public class MailModifier {
InternetAddress[] internetAddresses = MailAddressUtils.toInternetAddressArray(mailAddresses);
mail.getMessage().setRecipients(Message.RecipientType.TO, internetAddresses);
if (mailet.getInitParameters().isDebug()) {
- mailet.log("apparentlyTo set to: " + internetAddresses);
+ LOGGER.debug("apparentlyTo set to: " + internetAddresses);
}
}
}
@@ -141,12 +144,12 @@ public class MailModifier {
if (replyTo.equals(SpecialAddress.NULL)) {
mail.getMessage().setReplyTo(null);
if (mailet.getInitParameters().isDebug()) {
- mailet.log("replyTo set to: null");
+ LOGGER.debug("replyTo set to: null");
}
} else {
mail.getMessage().setReplyTo(new InternetAddress[] { replyTo.toInternetAddress() });
if (mailet.getInitParameters().isDebug()) {
- mailet.log("replyTo set to: " + replyTo);
+ LOGGER.debug("replyTo set to: " + replyTo);
}
}
}
@@ -163,12 +166,12 @@ public class MailModifier {
if (reversePath.equals(SpecialAddress.NULL)) {
mail.setSender(null);
if (mailet.getInitParameters().isDebug()) {
- mailet.log("reversePath set to: null");
+ LOGGER.debug("reversePath set to: null");
}
} else {
mail.setSender(reversePath);
if (mailet.getInitParameters().isDebug()) {
- mailet.log("reversePath set to: " + reversePath);
+ LOGGER.debug("reversePath set to: " + reversePath);
}
}
}
@@ -184,7 +187,7 @@ public class MailModifier {
if (messageId != null) {
mail.getMessage().setHeader(RFC2822Headers.IN_REPLY_TO, messageId);
if (mailet.getInitParameters().isDebug()) {
- mailet.log("IN_REPLY_TO set to: " + messageId);
+ LOGGER.debug("IN_REPLY_TO set to: " + messageId);
}
}
}
@@ -195,7 +198,7 @@ public class MailModifier {
mail.getMessage().setFrom(sender.get().toInternetAddress());
if (mailet.getInitParameters().isDebug()) {
- mailet.log("sender set to: " + sender);
+ LOGGER.debug("sender set to: " + sender);
}
}
}
@@ -211,7 +214,7 @@ public class MailModifier {
if (messageId != null) {
mail.getMessage().setHeader(RFC2822Headers.MESSAGE_ID, messageId);
if (mailet.getInitParameters().isDebug()) {
- mailet.log("MESSAGE_ID restored to: " + messageId);
+ LOGGER.debug("MESSAGE_ID restored to: " + messageId);
}
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f35ab929/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 cd7d5e3..44ab401 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
@@ -25,8 +25,11 @@ import javax.mail.internet.MimeMessage;
import org.apache.james.core.MailImpl;
import org.apache.mailet.Mail;
import org.apache.mailet.base.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class ProcessRedirectNotify {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ProcessRedirectNotify.class);
public static ProcessRedirectNotify from(RedirectNotify mailet) {
return new ProcessRedirectNotify(mailet);
@@ -55,7 +58,7 @@ public class ProcessRedirectNotify {
mailModifier.setRemoteHost();
if (mailet.getInitParameters().isDebug()) {
- mailet.log("New mail - sender: " + newMail.getSender() + ", recipients: " + StringUtils.arrayToString(newMail.getRecipients().toArray()) + ", name: " + newMail.getName() + ", remoteHost: " + newMail.getRemoteHost() + ", remoteAddr: " + newMail.getRemoteAddr() + ", state: " + newMail.getState()
+ LOGGER.debug("New mail - sender: " + newMail.getSender() + ", recipients: " + StringUtils.arrayToString(newMail.getRecipients().toArray()) + ", name: " + newMail.getName() + ", remoteHost: " + newMail.getRemoteHost() + ", remoteAddr: " + newMail.getRemoteAddr() + ", state: " + newMail.getState()
+ ", lastUpdated: " + newMail.getLastUpdated() + ", errorMessage: " + newMail.getErrorMessage());
}
@@ -111,7 +114,7 @@ public class ProcessRedirectNotify {
private void createAlterMessage(Mail originalMail, MailImpl newMail) throws MessagingException {
if (isDebug) {
- mailet.log("Alter message");
+ LOGGER.debug("Alter message");
}
newMail.setMessage(new MimeMessage(Session.getDefaultInstance(System.getProperties(), null)));
@@ -129,7 +132,7 @@ public class ProcessRedirectNotify {
newMail.setMessage(new CopiedMimeMessage(originalMail.getMessage()));
}
if (isDebug) {
- mailet.log("Message resent unaltered.");
+ LOGGER.debug("Message resent unaltered.");
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f35ab929/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
index b5fb65a..4323567 100644
--- 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
@@ -145,7 +145,9 @@ public interface RedirectNotify extends Mailet, MailetConfig {
DNSService getDNSService();
+ @Deprecated
void log(String message);
+ @Deprecated
void log(String message, Throwable t);
/**
http://git-wip-us.apache.org/repos/asf/james-project/blob/f35ab929/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractNetworkMatcher.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractNetworkMatcher.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractNetworkMatcher.java
index 083dd77..c58017e 100755
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractNetworkMatcher.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractNetworkMatcher.java
@@ -24,6 +24,8 @@ import javax.mail.MessagingException;
import org.apache.james.dnsservice.api.DNSService;
import org.apache.james.dnsservice.library.netmatcher.NetMatcher;
import org.apache.mailet.base.GenericMatcher;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* <p>
@@ -44,6 +46,7 @@ import org.apache.mailet.base.GenericMatcher;
* @see org.apache.james.dnsservice.library.netmatcher.NetMatcher
*/
public abstract class AbstractNetworkMatcher extends GenericMatcher {
+ private static final Logger LOGGER = LoggerFactory.getLogger(AbstractNetworkMatcher.class);
private NetMatcher authorizedNetworks;
@@ -52,12 +55,8 @@ public abstract class AbstractNetworkMatcher extends GenericMatcher {
@Override
public void init() throws MessagingException {
if (getCondition() != null) {
- authorizedNetworks = new NetMatcher(getCondition(), dnsServer) {
- protected void log(String s) {
- AbstractNetworkMatcher.this.log(s);
- }
- };
- log("Authorized addresses: " + authorizedNetworks.toString());
+ authorizedNetworks = new NetMatcher(getCondition(), dnsServer);
+ LOGGER.info("Authorized addresses: " + authorizedNetworks);
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f35ab929/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractSQLWhitelistMatcher.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractSQLWhitelistMatcher.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractSQLWhitelistMatcher.java
index f429b15..78f0bb7 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractSQLWhitelistMatcher.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractSQLWhitelistMatcher.java
@@ -44,6 +44,8 @@ import org.apache.mailet.Experimental;
import org.apache.mailet.Mail;
import org.apache.mailet.MailAddress;
import org.apache.mailet.base.GenericMatcher;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* No documentation is available for this deprecated, experimental matcher.
@@ -51,6 +53,7 @@ import org.apache.mailet.base.GenericMatcher;
@SuppressWarnings("deprecation")
@Experimental
public abstract class AbstractSQLWhitelistMatcher extends GenericMatcher {
+ private static final Logger LOGGER = LoggerFactory.getLogger(AbstractSQLWhitelistMatcher.class);
/**
* The user repository for this mail server. Contains all the users with
@@ -92,11 +95,7 @@ public abstract class AbstractSQLWhitelistMatcher extends GenericMatcher {
/**
* The JDBCUtil helper class
*/
- protected final JDBCUtil theJDBCUtil = new JDBCUtil() {
- protected void delegatedLog(String logString) {
- log(getMatcherName() + ": " + logString);
- }
- };
+ protected final JDBCUtil theJDBCUtil = new JDBCUtil();
/**
* Contains all of the sql strings for this component.
@@ -118,7 +117,7 @@ public abstract class AbstractSQLWhitelistMatcher extends GenericMatcher {
repositoryPath = st.nextToken().trim();
}
if (repositoryPath != null) {
- log("repositoryPath: " + repositoryPath);
+ LOGGER.info("repositoryPath: " + repositoryPath);
} else {
throw new MessagingException("repositoryPath is null");
}
@@ -264,7 +263,7 @@ public abstract class AbstractSQLWhitelistMatcher extends GenericMatcher {
StringBuffer logBuffer;
logBuffer = new StringBuffer(64).append("Created table '").append(tableName).append("' using sqlResources string '").append(createSqlStringName).append("'.");
- log(logBuffer.toString());
+ LOGGER.info(logBuffer.toString());
} finally {
theJDBCUtil.closeJDBCStatement(createStatement);
http://git-wip-us.apache.org/repos/asf/james-project/blob/f35ab929/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/IsInWhiteList.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/IsInWhiteList.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/IsInWhiteList.java
index 35e8c66..ec6d087 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/IsInWhiteList.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/IsInWhiteList.java
@@ -30,6 +30,8 @@ import javax.mail.MessagingException;
import org.apache.mailet.Experimental;
import org.apache.mailet.Mail;
import org.apache.mailet.MailAddress;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* <p>
@@ -59,6 +61,7 @@ import org.apache.mailet.MailAddress;
*/
@Experimental
public class IsInWhiteList extends AbstractSQLWhitelistMatcher {
+ private static final Logger LOGGER = LoggerFactory.getLogger(IsInWhiteList.class);
private String selectByPK;
@@ -167,7 +170,7 @@ public class IsInWhiteList extends AbstractSQLWhitelistMatcher {
jdbcUtil.closeJDBCStatement(selectStmt);
}
} catch (SQLException sqle) {
- log("Error accessing database", sqle);
+ LOGGER.error("Error accessing database", sqle);
throw new MessagingException("Exception thrown", sqle);
} finally {
theJDBCUtil.closeJDBCConnection(conn);
http://git-wip-us.apache.org/repos/asf/james-project/blob/f35ab929/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/NetworkIsInWhitelist.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/NetworkIsInWhitelist.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/NetworkIsInWhitelist.java
index ef64e21..8542f85 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/NetworkIsInWhitelist.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/NetworkIsInWhitelist.java
@@ -34,6 +34,8 @@ import org.apache.james.dnsservice.library.netmatcher.NetMatcher;
import org.apache.mailet.Experimental;
import org.apache.mailet.Mail;
import org.apache.mailet.MailAddress;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* <p>
@@ -49,6 +51,7 @@ import org.apache.mailet.MailAddress;
*/
@Experimental
public class NetworkIsInWhitelist extends AbstractSQLWhitelistMatcher {
+ private static final Logger LOGGER = LoggerFactory.getLogger(NetworkIsInWhitelist.class);
private DNSService dns;
private String selectNetworks;
@@ -130,7 +133,7 @@ public class NetworkIsInWhitelist extends AbstractSQLWhitelistMatcher {
}
return matched;
} catch (SQLException sqle) {
- log("Error accessing database", sqle);
+ LOGGER.error("Error accessing database", sqle);
throw new MessagingException("Exception thrown", sqle);
} finally {
theJDBCUtil.closeJDBCConnection(conn);
http://git-wip-us.apache.org/repos/asf/james-project/blob/f35ab929/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/SenderInFakeDomain.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/SenderInFakeDomain.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/SenderInFakeDomain.java
index ad9e78e..3279118 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/SenderInFakeDomain.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/SenderInFakeDomain.java
@@ -19,11 +19,13 @@
package org.apache.james.transport.matchers;
+import java.util.Collection;
+
import org.apache.mailet.Experimental;
import org.apache.mailet.Mail;
import org.apache.mailet.MailAddress;
-
-import java.util.Collection;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Does a DNS lookup (MX and A/CNAME records) on the sender's domain. If there
@@ -31,6 +33,7 @@ import java.util.Collection;
*/
@Experimental
public class SenderInFakeDomain extends AbstractNetworkMatcher {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SenderInFakeDomain.class);
public Collection<MailAddress> match(Mail mail) {
if (mail.getSender() == null) {
@@ -43,7 +46,7 @@ public class SenderInFakeDomain extends AbstractNetworkMatcher {
if (servers.size() == 0) {
// No records...could not deliver to this domain, so matches
// criteria.
- log("No MX, A, or CNAME record found for domain: " + domain);
+ LOGGER.info("No MX, A, or CNAME record found for domain: " + domain);
return mail.getRecipients();
} else if (matchNetwork(servers.iterator().next())) {
/*
@@ -62,8 +65,8 @@ public class SenderInFakeDomain extends AbstractNetworkMatcher {
* 203.119.4.6/32 # .PH TLD (.ph)
*
*/
- log("Banned IP found for domain: " + domain);
- log(" --> :" + servers.iterator().next());
+ LOGGER.info("Banned IP found for domain: " + domain);
+ LOGGER.info(" --> :" + servers.iterator().next());
return mail.getRecipients();
} else {
// Some servers were found... the domain is not fake.
http://git-wip-us.apache.org/repos/asf/james-project/blob/f35ab929/server/mailet/mailets/src/main/java/org/apache/james/transport/util/SpecialAddressesUtils.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/util/SpecialAddressesUtils.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/util/SpecialAddressesUtils.java
index 223162a..dc86e09 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/util/SpecialAddressesUtils.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/util/SpecialAddressesUtils.java
@@ -34,6 +34,8 @@ import org.apache.james.transport.mailets.redirect.SpecialAddressKind;
import org.apache.mailet.Mail;
import org.apache.mailet.MailAddress;
import org.apache.mailet.base.RFC2822Headers;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.base.Optional;
import com.google.common.collect.FluentIterable;
@@ -41,6 +43,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
public class SpecialAddressesUtils {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SpecialAddressesUtils.class);
public static SpecialAddressesUtils from(RedirectNotify mailet) {
return new SpecialAddressesUtils(mailet);
@@ -115,7 +118,7 @@ public class SpecialAddressesUtils {
}
return getReplyTos(replyToArray);
} catch (MessagingException ae) {
- mailet.log("Unable to parse the \"REPLY_TO\" header in the original message; ignoring.");
+ LOGGER.warn("Unable to parse the \"REPLY_TO\" header in the original message; ignoring.");
return ImmutableSet.of();
}
}
@@ -134,7 +137,7 @@ public class SpecialAddressesUtils {
try {
builder.add(new MailAddress(replyTo));
} catch (ParseException pe) {
- mailet.log("Unable to parse a \"REPLY_TO\" header address in the original message: " + replyTo + "; ignoring.");
+ LOGGER.warn("Unable to parse a \"REPLY_TO\" header address in the original message: " + replyTo + "; ignoring.");
}
}
return builder.build();
@@ -187,7 +190,7 @@ public class SpecialAddressesUtils {
InternetAddress[] fromArray = (InternetAddress[]) mail.getMessage().getFrom();
return allOrSender(mail, fromArray);
} catch (MessagingException me) {
- mailet.log("Unable to parse the \"FROM\" header in the original message; ignoring.");
+ LOGGER.warn("Unable to parse the \"FROM\" header in the original message; ignoring.");
return ImmutableSet.of();
}
case REPLY_TO:
@@ -195,7 +198,7 @@ public class SpecialAddressesUtils {
InternetAddress[] replyToArray = (InternetAddress[]) mail.getMessage().getReplyTo();
return allOrSender(mail, replyToArray);
} catch (MessagingException me) {
- mailet.log("Unable to parse the \"REPLY_TO\" header in the original message; ignoring.");
+ LOGGER.warn("Unable to parse the \"REPLY_TO\" header in the original message; ignoring.");
return ImmutableSet.of();
}
case TO:
@@ -231,13 +234,13 @@ public class SpecialAddressesUtils {
InternetAddress[] originalToInternetAddresses = InternetAddress.parse(toHeader, false);
return MailAddressUtils.from(originalToInternetAddresses);
} catch (MessagingException ae) {
- mailet.log("Unable to parse a \"TO\" header address in the original message: " + toHeader + "; ignoring.");
+ LOGGER.warn("Unable to parse a \"TO\" header address in the original message: " + toHeader + "; ignoring.");
}
}
}
return ImmutableList.of();
} catch (MessagingException ae) {
- mailet.log("Unable to parse the \"TO\" header in the original message; ignoring.");
+ LOGGER.warn("Unable to parse the \"TO\" header in the original message; ignoring.");
return ImmutableList.of();
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f35ab929/server/mailet/mailets/src/test/java/org/apache/james/samples/mailets/HelloWorldMailet.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/samples/mailets/HelloWorldMailet.java b/server/mailet/mailets/src/test/java/org/apache/james/samples/mailets/HelloWorldMailet.java
index caff256..00d27e6 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/samples/mailets/HelloWorldMailet.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/samples/mailets/HelloWorldMailet.java
@@ -23,13 +23,14 @@ import javax.mail.MessagingException;
import org.apache.mailet.Mail;
import org.apache.mailet.Mailet;
import org.apache.mailet.MailetConfig;
-import org.apache.mailet.MailetContext;
-import org.apache.mailet.MailetContext.LogLevel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Simply logs a message.
*/
public class HelloWorldMailet implements Mailet {
+ private static final Logger LOGGER = LoggerFactory.getLogger(HelloWorldMailet.class);
private MailetConfig config;
@@ -54,8 +55,7 @@ public class HelloWorldMailet implements Mailet {
@Override
public void service(Mail mail) throws MessagingException {
- MailetContext context = config.getMailetContext();
- context.log(LogLevel.INFO, "Hello, World!");
- context.log(LogLevel.INFO, "You have mail from " + mail.getSender().getLocalPart());
+ LOGGER.info("Hello, World!");
+ LOGGER.info( "You have mail from " + mail.getSender().getLocalPart());
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f35ab929/server/mailet/mailets/src/test/java/org/apache/james/samples/mailets/InstrumentationMailet.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/samples/mailets/InstrumentationMailet.java b/server/mailet/mailets/src/test/java/org/apache/james/samples/mailets/InstrumentationMailet.java
index a8e4e6f..266e3b2 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/samples/mailets/InstrumentationMailet.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/samples/mailets/InstrumentationMailet.java
@@ -33,14 +33,21 @@ import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMessage.RecipientType;
import javax.mail.internet.NewsAddress;
-import org.apache.mailet.*;
-import org.apache.mailet.MailetContext.LogLevel;
+import org.apache.james.transport.mailets.managesieve.ManageSieveMailet;
+import org.apache.mailet.Mail;
+import org.apache.mailet.MailAddress;
+import org.apache.mailet.Mailet;
+import org.apache.mailet.MailetConfig;
+import org.apache.mailet.MailetContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Mailet just prints out the details of a message. Sometimes Useful for
* debugging.
*/
public class InstrumentationMailet implements Mailet {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ManageSieveMailet.class);
private MailetConfig config;
@@ -65,47 +72,46 @@ public class InstrumentationMailet implements Mailet {
@Override
public void service(Mail mail) throws MessagingException {
- MailetContext context = config.getMailetContext();
- context.log(LogLevel.INFO, "######## MAIL STARTS");
- context.log(LogLevel.INFO, "");
+ LOGGER.info("######## MAIL STARTS");
+ LOGGER.info("");
MimeMessage message = mail.getMessage();
- context.log(LogLevel.INFO, "Mail named: " + mail.getName());
+ LOGGER.info("Mail named: " + mail.getName());
for (Iterator<String> it = mail.getAttributeNames(); it.hasNext();) {
String attributeName = it.next();
- context.log(LogLevel.INFO, "Attribute " + attributeName);
+ LOGGER.info("Attribute " + attributeName);
}
- context.log(LogLevel.INFO, "Message size: " + mail.getMessageSize());
- context.log(LogLevel.INFO, "Last updated: " + mail.getLastUpdated());
- context.log(LogLevel.INFO, "Remote Address: " + mail.getRemoteAddr());
- context.log(LogLevel.INFO, "Remote Host: " + mail.getRemoteHost());
- context.log(LogLevel.INFO, "State: " + mail.getState());
- context.log(LogLevel.INFO, "Sender host: " + mail.getSender().getDomain());
- context.log(LogLevel.INFO, "Sender user: " + mail.getSender().getLocalPart());
+ LOGGER.info("Message size: " + mail.getMessageSize());
+ LOGGER.info("Last updated: " + mail.getLastUpdated());
+ LOGGER.info("Remote Address: " + mail.getRemoteAddr());
+ LOGGER.info("Remote Host: " + mail.getRemoteHost());
+ LOGGER.info("State: " + mail.getState());
+ LOGGER.info("Sender host: " + mail.getSender().getDomain());
+ LOGGER.info("Sender user: " + mail.getSender().getLocalPart());
Collection<MailAddress> recipients = mail.getRecipients();
for (MailAddress address : recipients) {
- context.log(LogLevel.INFO, "Recipient: " + address.getLocalPart() + "@" + address.getDomain());
+ LOGGER.info("Recipient: " + address.getLocalPart() + "@" + address.getDomain());
}
- context.log(LogLevel.INFO, "Subject: " + message.getSubject());
- context.log(LogLevel.INFO, "MessageID: " + message.getMessageID());
- context.log(LogLevel.INFO, "Received: " + message.getReceivedDate());
- context.log(LogLevel.INFO, "Sent: " + message.getSentDate());
+ LOGGER.info("Subject: " + message.getSubject());
+ LOGGER.info("MessageID: " + message.getMessageID());
+ LOGGER.info("Received: " + message.getReceivedDate());
+ LOGGER.info("Sent: " + message.getSentDate());
@SuppressWarnings("unchecked")
Enumeration<String> allHeadersLines = message.getAllHeaderLines();
while (allHeadersLines.hasMoreElements()) {
String header = (String) allHeadersLines.nextElement();
- context.log(LogLevel.INFO, "Header Line:= " + header);
+ LOGGER.info("Header Line:= " + header);
}
@SuppressWarnings("unchecked")
Enumeration<Header> allHeadersEnumeration = message.getAllHeaders();
while (allHeadersEnumeration.hasMoreElements()) {
Header header = (Header) allHeadersEnumeration.nextElement();
- context.log(LogLevel.INFO, "Header: " + header.getName() + "=" + header.getValue());
+ LOGGER.info("Header: " + header.getName() + "=" + header.getValue());
}
Address[] to = message.getRecipients(RecipientType.TO);
@@ -118,27 +124,27 @@ public class InstrumentationMailet implements Mailet {
Flags flags = message.getFlags();
Flag[] systemFlags = flags.getSystemFlags();
for (Flag systemFlag : systemFlags) {
- context.log(LogLevel.INFO, "System Flag:" + systemFlag);
+ LOGGER.info("System Flag:" + systemFlag);
}
String[] userFlags = flags.getUserFlags();
for (String userFlag : userFlags) {
- context.log(LogLevel.INFO, "User flag: " + userFlag);
+ LOGGER.info("User flag: " + userFlag);
}
String mimeType = message.getContentType();
- context.log(LogLevel.INFO, "Mime type: " + mimeType);
+ LOGGER.info("Mime type: " + mimeType);
if ("text/plain".equals(mimeType)) {
try {
Object content = message.getContent();
- context.log(LogLevel.INFO, "Content: " + content);
+ LOGGER.info("Content: " + content);
} catch (IOException e) {
e.printStackTrace();
}
}
- context.log(LogLevel.INFO, "");
- context.log(LogLevel.INFO, "######## MAIL ENDS");
+ LOGGER.info("");
+ LOGGER.info("######## MAIL ENDS");
}
private void printAddresses(Address[] addresses, String prefix) {
@@ -146,10 +152,10 @@ public class InstrumentationMailet implements Mailet {
for (Address address1 : addresses) {
if (address1 instanceof InternetAddress) {
InternetAddress address = (InternetAddress) address1;
- context.log(LogLevel.INFO, prefix + address.getPersonal() + "@" + address.getAddress());
+ LOGGER.info(prefix + address.getPersonal() + "@" + address.getAddress());
} else if (address1 instanceof NewsAddress) {
NewsAddress address = (NewsAddress) address1;
- context.log(LogLevel.INFO, prefix + address.getNewsgroup() + "@" + address.getHost());
+ LOGGER.info(prefix + address.getNewsgroup() + "@" + address.getHost());
}
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f35ab929/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecordingMailContext.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecordingMailContext.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecordingMailContext.java
index 9b55dd1..1fb078c 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecordingMailContext.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecordingMailContext.java
@@ -34,12 +34,14 @@ import org.apache.mailet.MailetContext;
import org.apache.mailet.TemporaryLookupException;
import org.apache.mailet.base.test.FakeMailContext;
import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* @since 15.12.12 12:02
*/
@SuppressWarnings("deprecation")
public class RecordingMailContext implements MailetContext {
+ private static final Logger LOGGER = LoggerFactory.getLogger(RecordingMailContext.class);
private final List<SendMailEvent> sendmails = new LinkedList<>();
private final FakeMailContext context;
@@ -168,12 +170,12 @@ public class RecordingMailContext implements MailetContext {
@Override
public void log(String message) {
- context.log(message);
+ LOGGER.info(message);
}
@Override
public void log(String message, Throwable t) {
- context.log(message, t);
+ LOGGER.error(message, t);
}
@Override
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org