james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [11/34] james-project git commit: JAMES-2085 Improve error management in James23ImporterManagement
Date Wed, 05 Jul 2017 13:59:18 GMT
JAMES-2085 Improve error management in James23ImporterManagement


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

Branch: refs/heads/master
Commit: abf61efe781e39930bc22dc246946eec69a05186
Parents: ec72dbf
Author: benwa <btellier@linagora.com>
Authored: Mon Jul 3 15:41:04 2017 +0700
Committer: benwa <btellier@linagora.com>
Committed: Wed Jul 5 17:13:47 2017 +0700

----------------------------------------------------------------------
 .../spring/tool/James23ImporterManagement.java  | 48 ++++----------------
 1 file changed, 10 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/abf61efe/server/container/spring/src/main/java/org/apache/james/container/spring/tool/James23ImporterManagement.java
----------------------------------------------------------------------
diff --git a/server/container/spring/src/main/java/org/apache/james/container/spring/tool/James23ImporterManagement.java
b/server/container/spring/src/main/java/org/apache/james/container/spring/tool/James23ImporterManagement.java
index b1a5e49..2f0f203 100644
--- a/server/container/spring/src/main/java/org/apache/james/container/spring/tool/James23ImporterManagement.java
+++ b/server/container/spring/src/main/java/org/apache/james/container/spring/tool/James23ImporterManagement.java
@@ -18,19 +18,18 @@
  ****************************************************************/
 package org.apache.james.container.spring.tool;
 
-import org.apache.james.domainlist.api.DomainListException;
-import org.apache.james.mailrepository.api.MailRepositoryStore.MailRepositoryStoreException;
-import org.apache.james.user.api.UsersRepositoryException;
-
 import javax.inject.Inject;
-import javax.mail.MessagingException;
-import java.io.IOException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * {@link James23Importer} support via JMX.
  */
 public class James23ImporterManagement implements James23ImporterManagementMBean {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(James23ImporterManagement.class);
+
     @Inject
     private James23Importer james23Importer;
 
@@ -38,16 +37,8 @@ public class James23ImporterManagement implements James23ImporterManagementMBean
     public void importUsersAndMailsFromJames23(String james23MailRepositoryPath, String defaultPassword)
throws Exception {
         try {
             james23Importer.importUsersAndMailsFromJames23(james23MailRepositoryPath, defaultPassword);
-        } catch (MailRepositoryStoreException e) {
-            throw new Exception(e.getMessage());
-        } catch (MessagingException e) {
-            throw new Exception(e.getMessage());
-        } catch (UsersRepositoryException e) {
-            throw new Exception(e.getMessage());
-        } catch (DomainListException e) {
-            throw new Exception(e.getMessage());
-        } catch (IOException e) {
-            throw new Exception(e.getMessage());
+        } catch (Exception e) {
+            throw new Exception("Error while importing users and mails", e);
         }
     }
 
@@ -55,12 +46,8 @@ public class James23ImporterManagement implements James23ImporterManagementMBean
     public void importUsersFromJames23(String defaultPassword) throws Exception {
         try {
             james23Importer.importUsersFromJames23(defaultPassword);
-        } catch (MessagingException e) {
-            throw new Exception(e.getMessage());
-        } catch (UsersRepositoryException e) {
-            throw new Exception(e.getMessage());
-        } catch (DomainListException e) {
-            throw new Exception(e.getMessage());
+        } catch (Exception e) {
+            throw new Exception("Error while importing users", e);
         }
     }
 
@@ -69,23 +56,8 @@ public class James23ImporterManagement implements James23ImporterManagementMBean
         try {
             james23Importer.importMailsFromJames23(james23MailRepositoryPath);
         } catch (Exception e) {
-            e.printStackTrace();
+            LOGGER.error("Error while importing mail", e);
             throw new Exception(e.getMessage());
-            // } catch (MailboxException e) {
-            // e.printStackTrace();
-            // throw new Exception(e.getMessage());
-            // } catch (MailRepositoryStoreException e) {
-            // e.printStackTrace();
-            // throw new Exception(e.getMessage());
-            // } catch (MessagingException e) {
-            // e.printStackTrace();
-            // throw new Exception(e.getMessage());
-            // } catch (UsersRepositoryException e) {
-            // e.printStackTrace();
-            // throw new Exception(e.getMessage());
-            // } catch (IOException e) {
-            // e.printStackTrace();
-            // throw new Exception(e.getMessage());
         }
     }
 


---------------------------------------------------------------------
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