james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rouaz...@apache.org
Subject [1/2] james-project git commit: MAILET-128 Slighty rewrite ToRepository to our conding standards
Date Wed, 07 Sep 2016 09:26:36 GMT
Repository: james-project
Updated Branches:
  refs/heads/master 39d0cda0d -> 35c541597


MAILET-128 Slighty rewrite ToRepository to our conding standards


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

Branch: refs/heads/master
Commit: 35c54159790899cd6693d70d1097922db90ed6c4
Parents: 56a0836
Author: Raphael Ouazana <raphael.ouazana@linagora.com>
Authored: Tue Sep 6 11:44:36 2016 +0200
Committer: Raphael Ouazana <raphael.ouazana@linagora.com>
Committed: Wed Sep 7 11:24:43 2016 +0200

----------------------------------------------------------------------
 .../james/transport/mailets/ToRepository.java   | 47 +++++++-------------
 1 file changed, 15 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/35c54159/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 46c8100..46152fd 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
@@ -29,27 +29,15 @@ import org.apache.mailet.base.GenericMailet;
 
 /**
  * Stores incoming Mail in the specified Repository.<br>
- * If the "passThrough" in confs is true the mail will be returned untouched in
- * the pipe. If false will be destroyed.
- * 
- * @version 1.0.0, 24/04/1999
+ * If the "passThrough" in conf is true the mail will be returned untouched in
+ * the pipe and may be processed by additional mailets. If false will be destroyed.
  */
 public class ToRepository extends GenericMailet {
 
-    /**
-     * The repository where this mailet stores mail.
-     */
     private MailRepository repository;
 
-    /**
-     * Whether this mailet should allow mails to be processed by additional
-     * mailets or mark it as finished.
-     */
     private boolean passThrough = false;
 
-    /**
-     * The path to the repository
-     */
     private String repositoryPath;
 
     private MailRepositoryStore mailStore;
@@ -59,31 +47,30 @@ public class ToRepository extends GenericMailet {
         this.mailStore = mailStore;
     }
 
-    /**
-     * Initialize the mailet, loading configuration information.
-     */
+    @Override
     public void init() throws MessagingException {
         repositoryPath = getInitParameter("repositoryPath");
+        passThrough = getPassThroughParameter();
+        repository = selectRepository();
+    }
+
+    private boolean getPassThroughParameter() {
         try {
-            passThrough = Boolean.valueOf(getInitParameter("passThrough"));
+            return getInitParameter("passThrough", false);
         } catch (Exception e) {
-            // Ignore exception, default to false
+            return false;
         }
+    }
 
+    private MailRepository selectRepository() throws MessagingException {
         try {
-            repository = mailStore.select(repositoryPath);
+            return mailStore.select(repositoryPath);
         } catch (Exception e) {
             throw new MessagingException("Failed to retrieve MailRepository for url " + repositoryPath,
e);
         }
-
     }
 
-    /**
-     * Store a mail in a particular repository.
-     * 
-     * @param mail
-     *            the mail to process
-     */
+    @Override
     public void service(Mail mail) throws javax.mail.MessagingException {
         String logBuffer = "Storing mail " + mail.getName() + " in " + repositoryPath;
         log(logBuffer);
@@ -93,11 +80,7 @@ public class ToRepository extends GenericMailet {
         }
     }
 
-    /**
-     * Return a string describing this mailet.
-     * 
-     * @return a string describing this mailet
-     */
+    @Override
     public String getMailetInfo() {
         return "ToRepository 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