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 rd...@apache.org on 2009/05/10 21:08:49 UTC

svn commit: r773385 - in /james/imap/trunk: api/src/main/java/org/apache/james/imap/api/display/ jpa/src/main/java/org/apache/james/imap/jpa/user/ mailbox/src/main/java/org/apache/james/imap/mailbox/

Author: rdonkin
Date: Sun May 10 19:08:48 2009
New Revision: 773385

URL: http://svn.apache.org/viewvc?rev=773385&view=rev
Log:
Enforce setting an internationalisable message. IMAP-72 https://issues.apache.org/jira/browse/IMAP-72

Modified:
    james/imap/trunk/api/src/main/java/org/apache/james/imap/api/display/HumanReadableTextKey.java
    james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/user/JPASubscriptionMapper.java
    james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/SubscriptionException.java

Modified: james/imap/trunk/api/src/main/java/org/apache/james/imap/api/display/HumanReadableTextKey.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/api/src/main/java/org/apache/james/imap/api/display/HumanReadableTextKey.java?rev=773385&r1=773384&r2=773385&view=diff
==============================================================================
--- james/imap/trunk/api/src/main/java/org/apache/james/imap/api/display/HumanReadableTextKey.java (original)
+++ james/imap/trunk/api/src/main/java/org/apache/james/imap/api/display/HumanReadableTextKey.java Sun May 10 19:08:48 2009
@@ -75,6 +75,26 @@
             "org.apache.james.imap.FAILURE_NO_SUCH_MAILBOX",
             "failed. No such mailbox.");
 
+    public static final HumanReadableTextKey START_TRANSACTION_FAILED = new HumanReadableTextKey(
+            "org.apache.james.imap.START_TRANSACTION_FAILED",
+            "failed. Cannot start transaction.");
+    
+    public static final HumanReadableTextKey COMMIT_TRANSACTION_FAILED = new HumanReadableTextKey(
+            "org.apache.james.imap.COMMIT_TRANSACTION_FAILED",
+            "failed. Transaction commit failed.");
+    
+    public static final HumanReadableTextKey DELETED_FAILED = new HumanReadableTextKey(
+            "org.apache.james.imap.DELETED_FAILED",
+            "failed. Deletion failed.");
+    
+    public static final HumanReadableTextKey SEARCH_FAILED = new HumanReadableTextKey(
+            "org.apache.james.imap.SEARCH_FAILED",
+            "failed. Search failed.");
+    
+    public static final HumanReadableTextKey SAVE_FAILED = new HumanReadableTextKey(
+            "org.apache.james.imap.SAVE_FAILED",
+            "failed. Save failed.");
+    
     public static final HumanReadableTextKey GENERIC_FAILURE_DURING_PROCESSING = new HumanReadableTextKey(
             "org.apache.james.imap.GENERIC_FAILURE_DURING_PROCESSING",
             "processing failed.");

Modified: james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/user/JPASubscriptionMapper.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/user/JPASubscriptionMapper.java?rev=773385&r1=773384&r2=773385&view=diff
==============================================================================
--- james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/user/JPASubscriptionMapper.java (original)
+++ james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/user/JPASubscriptionMapper.java Sun May 10 19:08:48 2009
@@ -24,6 +24,7 @@
 import javax.persistence.NoResultException;
 import javax.persistence.PersistenceException;
 
+import org.apache.james.imap.api.display.HumanReadableTextKey;
 import org.apache.james.imap.mailbox.SubscriptionException;
 import org.apache.james.imap.store.user.SubscriptionMapper;
 import org.apache.james.imap.store.user.model.Subscription;
@@ -47,7 +48,7 @@
         try {
             entityManager.getTransaction().begin();
         } catch (PersistenceException e) {
-            throw new SubscriptionException(e);
+            throw new SubscriptionException(HumanReadableTextKey.START_TRANSACTION_FAILED, e);
         }
     }
 
@@ -59,7 +60,7 @@
         try {
             entityManager.getTransaction().commit();
         } catch (PersistenceException e) {
-            throw new SubscriptionException(e);
+            throw new SubscriptionException(HumanReadableTextKey.COMMIT_TRANSACTION_FAILED, e);
         }
     }
 
@@ -74,7 +75,7 @@
         } catch (NoResultException e) {
             return null;
         } catch (PersistenceException e) {
-            throw new SubscriptionException(e);
+            throw new SubscriptionException(HumanReadableTextKey.SEARCH_FAILED, e);
         }
     }
 
@@ -86,7 +87,7 @@
         try {
             entityManager.persist(subscription);
         } catch (PersistenceException e) {
-            throw new SubscriptionException(e);
+            throw new SubscriptionException(HumanReadableTextKey.SAVE_FAILED, e);
         }
     }
 
@@ -99,7 +100,7 @@
         try {
             return (List<Subscription>) entityManager.createNamedQuery("findSubscriptionsForUser").setParameter("userParam", user).getResultList();
         } catch (PersistenceException e) {
-            throw new SubscriptionException(e);
+            throw new SubscriptionException(HumanReadableTextKey.SEARCH_FAILED, e);
         }
     }
 
@@ -111,7 +112,7 @@
         try {
             entityManager.remove(subscription);
         } catch (PersistenceException e) {
-            throw new SubscriptionException(e);
+            throw new SubscriptionException(HumanReadableTextKey.DELETED_FAILED, e);
         }
     }
 }

Modified: james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/SubscriptionException.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/SubscriptionException.java?rev=773385&r1=773384&r2=773385&view=diff
==============================================================================
--- james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/SubscriptionException.java (original)
+++ james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/SubscriptionException.java Sun May 10 19:08:48 2009
@@ -30,19 +30,14 @@
 
     private final HumanReadableTextKey key;
 
-    public SubscriptionException(HumanReadableTextKey key, Throwable cause) {
-        super(key.toString(), cause);
-        this.key = key;
-    }
-
-    public SubscriptionException(HumanReadableTextKey key) {
+    public SubscriptionException(final HumanReadableTextKey key) {
         super(key.toString());
         this.key = key;
     }
 
-    public SubscriptionException(Throwable cause) {
+    public SubscriptionException(final HumanReadableTextKey key, Throwable cause) {
         super(cause);
-        key = null;
+        this.key = key;
     }
 
     /**



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