james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rouaz...@apache.org
Subject [01/10] james-project git commit: MAILET-117 upgrade SetMimeHeader to new style
Date Mon, 05 Sep 2016 13:42:00 GMT
Repository: james-project
Updated Branches:
  refs/heads/master 526f8b5e1 -> f97e46346


MAILET-117 upgrade SetMimeHeader to new style


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/de8f9263
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/de8f9263
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/de8f9263

Branch: refs/heads/master
Commit: de8f92630eba268226100afac89ddb6508c04f47
Parents: 9ff634d
Author: Matthieu Baechler <matthieu.baechler@linagora.com>
Authored: Tue Aug 30 16:04:19 2016 +0200
Committer: Matthieu Baechler <matthieu.baechler@linagora.com>
Committed: Mon Sep 5 14:17:50 2016 +0200

----------------------------------------------------------------------
 .../james/transport/mailets/SetMimeHeader.java  | 37 +++++---------------
 1 file changed, 9 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/de8f9263/mailet/standard/src/main/java/org/apache/james/transport/mailets/SetMimeHeader.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/mailets/SetMimeHeader.java
b/mailet/standard/src/main/java/org/apache/james/transport/mailets/SetMimeHeader.java
index adeb699..14fab6e 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/mailets/SetMimeHeader.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/mailets/SetMimeHeader.java
@@ -25,6 +25,9 @@ import javax.mail.MessagingException;
 import javax.mail.internet.MimeMessage ;
 
 import org.apache.mailet.base.GenericMailet ;
+
+import com.google.common.base.Strings;
+
 import org.apache.mailet.Mail ;
 
 /**
@@ -41,56 +44,34 @@ import org.apache.mailet.Mail ;
  *
  * @version 1.0.0, 2002-09-11
  */
-public class SetMimeHeader
-       extends GenericMailet {
+public class SetMimeHeader extends GenericMailet {
 
-    /**
-     * The name of the header to be added.
-     */
     private String headerName;
-
-    /**
-     * The value to be set for the header.
-     */
     private String headerValue;
 
-    /**
-     * Initialize the mailet.
-     */
+    @Override
     public void init() throws MessagingException {
         headerName = getInitParameter("name");
         headerValue = getInitParameter("value");
         
-        // Check if needed config values are used
-        if (headerName == null || headerName.equals("") || headerValue == null
-                || headerValue.equals("")) {
+        if (Strings.isNullOrEmpty(headerName) || Strings.isNullOrEmpty(headerValue)) {
             throw new MessagingException("Please configure a name and a value");
         }
     }
 
-    /**
-     * Takes the message and adds a header to it.
-     *
-     * @param mail the mail being processed
-     *
-     */
+    @Override
     public void service(Mail mail) {
         try {
             MimeMessage message = mail.getMessage () ;
 
-            //Set the header name and value (supplied at init time).
             message.setHeader(headerName, headerValue);
             message.saveChanges();
         } catch (javax.mail.MessagingException me) {
-            log (me.getMessage());
+            log(me.getMessage());
         }
     }
 
-    /**
-     * Return a string describing this mailet.
-     *
-     * @return a string describing this mailet
-     */
+    @Override
     public String getMailetInfo() {
         return "SetMimeHeader Mailet" ;
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message