james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r1054466 - in /james/server/trunk: domainlist-api/src/main/java/org/apache/james/domainlist/api/ domainlist-api/src/test/java/org/apache/james/domainlist/api/mock/ domainlist-jpa/src/main/java/org/apache/james/domainlist/jpa/ domainlist-jpa...
Date Sun, 02 Jan 2011 20:12:39 GMT
Author: norman
Date: Sun Jan  2 20:12:37 2011
New Revision: 1054466

URL: http://svn.apache.org/viewvc?rev=1054466&view=rev
Log:
DomainList should throw Exception.  See JAMES-1171

Added:
    james/server/trunk/domainlist-api/src/main/java/org/apache/james/domainlist/api/DomainListException.java
Modified:
    james/server/trunk/domainlist-api/src/main/java/org/apache/james/domainlist/api/DomainList.java
    james/server/trunk/domainlist-api/src/test/java/org/apache/james/domainlist/api/mock/SimpleDomainList.java
    james/server/trunk/domainlist-jpa/src/main/java/org/apache/james/domainlist/jpa/JPADomainList.java
    james/server/trunk/domainlist-jpa/src/test/java/org/apache/james/domainlist/jpa/JPADomainListTest.java
    james/server/trunk/domainlist-library/src/main/java/org/apache/james/domainlist/lib/AbstractDomainList.java
    james/server/trunk/domainlist-library/src/main/java/org/apache/james/domainlist/lib/DomainListManagement.java
    james/server/trunk/domainlist-xml/src/main/java/org/apache/james/domainlist/xml/XMLDomainList.java
    james/server/trunk/fetchmail/src/main/java/org/apache/james/fetchmail/MessageProcessor.java
    james/server/trunk/fetchmail/src/main/java/org/apache/james/fetchmail/ParsedConfiguration.java
    james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/JamesMailetContext.java
    james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/AbstractVirtualUserTable.java
    james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/AbstractVirtualUserTableMailet.java
    james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/AuthRequiredToRelayRcptHook.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/JamesMailCmdHandler.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/JamesRcptCmdHandler.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationRcptHook.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptHandler.java
    james/server/trunk/user-jdbc/src/main/java/org/apache/james/user/jdbc/DefaultUsersJdbcRepository.java
    james/server/trunk/user-library/src/main/java/org/apache/james/user/lib/AbstractUsersRepository.java

Modified: james/server/trunk/domainlist-api/src/main/java/org/apache/james/domainlist/api/DomainList.java
URL: http://svn.apache.org/viewvc/james/server/trunk/domainlist-api/src/main/java/org/apache/james/domainlist/api/DomainList.java?rev=1054466&r1=1054465&r2=1054466&view=diff
==============================================================================
--- james/server/trunk/domainlist-api/src/main/java/org/apache/james/domainlist/api/DomainList.java (original)
+++ james/server/trunk/domainlist-api/src/main/java/org/apache/james/domainlist/api/DomainList.java Sun Jan  2 20:12:37 2011
@@ -32,7 +32,7 @@ public interface DomainList {
      * 
      * @return domains
      */
-    public String[] getDomains();
+    public String[] getDomains() throws DomainListException;
     
     /**
      * Return true if the domain exists in the service 
@@ -40,7 +40,7 @@ public interface DomainList {
      * @param domain the domain
      * @return true if the given domain exists in the service
      */
-    public boolean containsDomain(String domain);
+    public boolean containsDomain(String domain) throws DomainListException;
 
     
     /**
@@ -49,7 +49,7 @@ public interface DomainList {
      * @param domain domain to add
      * @return true if successfull
      */
-    public boolean addDomain(String domain);
+    public void addDomain(String domain) throws DomainListException;
     
     /**
      * Remove domain from the service
@@ -57,7 +57,7 @@ public interface DomainList {
      * @param domain domain to remove
      * @return true if successfull
      */
-    public boolean removeDomain(String domain);
+    public void removeDomain(String domain) throws DomainListException;
     
     
     
@@ -67,6 +67,6 @@ public interface DomainList {
      * 
      * @return the defaultdomain
      */
-    public String getDefaultDomain();
+    public String getDefaultDomain() throws DomainListException;
     
 }

Added: james/server/trunk/domainlist-api/src/main/java/org/apache/james/domainlist/api/DomainListException.java
URL: http://svn.apache.org/viewvc/james/server/trunk/domainlist-api/src/main/java/org/apache/james/domainlist/api/DomainListException.java?rev=1054466&view=auto
==============================================================================
--- james/server/trunk/domainlist-api/src/main/java/org/apache/james/domainlist/api/DomainListException.java (added)
+++ james/server/trunk/domainlist-api/src/main/java/org/apache/james/domainlist/api/DomainListException.java Sun Jan  2 20:12:37 2011
@@ -0,0 +1,30 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.domainlist.api;
+
+public class DomainListException extends Exception{
+
+    public DomainListException(String msg) {
+        super(msg);
+    }
+    
+    public DomainListException(String msg, Throwable t) {
+        super(msg, t);
+    }
+}

Modified: james/server/trunk/domainlist-api/src/test/java/org/apache/james/domainlist/api/mock/SimpleDomainList.java
URL: http://svn.apache.org/viewvc/james/server/trunk/domainlist-api/src/test/java/org/apache/james/domainlist/api/mock/SimpleDomainList.java?rev=1054466&r1=1054465&r2=1054466&view=diff
==============================================================================
--- james/server/trunk/domainlist-api/src/test/java/org/apache/james/domainlist/api/mock/SimpleDomainList.java (original)
+++ james/server/trunk/domainlist-api/src/test/java/org/apache/james/domainlist/api/mock/SimpleDomainList.java Sun Jan  2 20:12:37 2011
@@ -25,6 +25,7 @@ import java.util.LinkedList;
 import java.util.List;
 
 import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.domainlist.api.DomainListException;
 
 /**
  * Simplest implementation for ManageableDomainList
@@ -32,21 +33,23 @@ import org.apache.james.domainlist.api.D
 public class SimpleDomainList implements DomainList {
     private List<String> domains = new LinkedList<String>();
 
-    public boolean containsDomain(String domain) {
+    public boolean containsDomain(String domain) throws DomainListException {
         return domains.contains(domain);
     }
 
-    public String[] getDomains() {
+    public String[] getDomains() throws DomainListException{
         return domains.toArray(new String[domains.size()]);
     }
 
-    public boolean addDomain(String domain) {
-        if (domains.contains(domain)) return false;
-        return domains.add(domain);
+    public void addDomain(String domain) throws DomainListException{
+        if (domains.contains(domain)) throw new DomainListException("Domain " + domain + " already exist");
+        domains.add(domain);
     }
 
-    public boolean removeDomain(String domain) {
-        return domains.remove(domain);
+    public void removeDomain(String domain) throws DomainListException {
+        if(domains.remove(domain) == false) {
+            throw new DomainListException("Domain " + domain + " does not exist");
+        }
     }
 
     public String getDefaultDomain() {

Modified: james/server/trunk/domainlist-jpa/src/main/java/org/apache/james/domainlist/jpa/JPADomainList.java
URL: http://svn.apache.org/viewvc/james/server/trunk/domainlist-jpa/src/main/java/org/apache/james/domainlist/jpa/JPADomainList.java?rev=1054466&r1=1054465&r2=1054466&view=diff
==============================================================================
--- james/server/trunk/domainlist-jpa/src/main/java/org/apache/james/domainlist/jpa/JPADomainList.java (original)
+++ james/server/trunk/domainlist-jpa/src/main/java/org/apache/james/domainlist/jpa/JPADomainList.java Sun Jan  2 20:12:37 2011
@@ -28,8 +28,7 @@ import javax.persistence.EntityTransacti
 import javax.persistence.PersistenceException;
 import javax.persistence.PersistenceUnit;
 
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.domainlist.jpa.model.JPADomain;
 import org.apache.james.domainlist.lib.AbstractDomainList;
 import org.apache.james.lifecycle.api.Configurable;
@@ -61,22 +60,13 @@ public class JPADomainList extends Abstr
         createEntityManager().close();
     }
 
+   
     /*
      * (non-Javadoc)
-     * @see org.apache.james.lifecycle.Configurable#configure(org.apache.commons.configuration.HierarchicalConfiguration)
-     */
-    @SuppressWarnings("unchecked")
-    public void configure(HierarchicalConfiguration config) throws ConfigurationException {
-        super.configure(config);
-        // TODO The common configuration could be migrated to AbstractDomainList (should it implement Configurable?)
-        setAutoDetect(config.getBoolean("autodetect", true));    
-        setAutoDetectIP(config.getBoolean("autodetectIP", true));    
-    }
-   
-    /**
      * @see org.apache.james.domainlist.lib.AbstractDomainList#getDomainListInternal()
      */
-    protected List<String> getDomainListInternal() {
+    @SuppressWarnings("unchecked")
+    protected List<String> getDomainListInternal() throws DomainListException {
         List<String> domains = new ArrayList<String>();
         EntityManager entityManager = entityManagerFactory.createEntityManager();
         final EntityTransaction transaction = entityManager.getTransaction();
@@ -89,6 +79,8 @@ public class JPADomainList extends Abstr
             if (transaction.isActive()) {
                 transaction.rollback();
             }
+            
+            throw new DomainListException("Unable to retrieve domains", e);
         } finally {
             entityManager.close();
         }
@@ -102,7 +94,7 @@ public class JPADomainList extends Abstr
     /**
      * @see org.apache.james.domainlist.api.DomainList#containsDomain(java.lang.String)
      */
-    public boolean containsDomain(String domain) {
+    public boolean containsDomain(String domain) throws DomainListException{
         EntityManager entityManager = entityManagerFactory.createEntityManager();
         final EntityTransaction transaction = entityManager.getTransaction();
         try {
@@ -115,16 +107,18 @@ public class JPADomainList extends Abstr
             if (transaction.isActive()) {
                 transaction.rollback();
             }
+            throw new DomainListException("Unable to retrieve domains", e);
         } finally {
             entityManager.close();
         }    
-        return false;
     }
 
-    /**
-     * @see org.apache.james.domainlist.lib.AbstractDomainList#addDomainInternal(java.lang.String)
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.domainlist.api.DomainList#addDomain(java.lang.String)
      */
-    protected boolean addDomainInternal(String domain) {
+    public void addDomain(String domain) throws DomainListException{
         EntityManager entityManager = entityManagerFactory.createEntityManager();
         final EntityTransaction transaction = entityManager.getTransaction();
         try {
@@ -132,38 +126,39 @@ public class JPADomainList extends Abstr
             JPADomain jpaDomain = new JPADomain(domain);
             entityManager.persist(jpaDomain);
             transaction.commit();
-            return true;
         } catch (PersistenceException e) {
             getLogger().debug("Failed to save domain", e);
             if (transaction.isActive()) {
                 transaction.rollback();
             }
+            throw new DomainListException("Unable to add domain " + domain, e);
         } finally {
             entityManager.close();
         }
-        return false;
     }
 
-    /**
-     * @see org.apache.james.domainlist.lib.AbstractDomainList#removeDomainInternal(java.lang.String)
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.domainlist.api.DomainList#removeDomain(java.lang.String)
      */
-    protected boolean removeDomainInternal(String domain) {
+    public void removeDomain(String domain) throws DomainListException{
         EntityManager entityManager = entityManagerFactory.createEntityManager();
         final EntityTransaction transaction = entityManager.getTransaction();
         try {
             transaction.begin();
             entityManager.createNamedQuery("deleteDomainByName").setParameter("name", domain).executeUpdate();
             transaction.commit();
-            return true;
         } catch (PersistenceException e) {
             getLogger().debug("Failed to remove domain", e);
             if (transaction.isActive()) {
                 transaction.rollback();
             }
+            throw new DomainListException("Unable to remove domain " + domain, e);
+
         } finally {
             entityManager.close();
         }
-        return false;
     }
 
     /**

Modified: james/server/trunk/domainlist-jpa/src/test/java/org/apache/james/domainlist/jpa/JPADomainListTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/domainlist-jpa/src/test/java/org/apache/james/domainlist/jpa/JPADomainListTest.java?rev=1054466&r1=1054465&r2=1054466&view=diff
==============================================================================
--- james/server/trunk/domainlist-jpa/src/test/java/org/apache/james/domainlist/jpa/JPADomainListTest.java (original)
+++ james/server/trunk/domainlist-jpa/src/test/java/org/apache/james/domainlist/jpa/JPADomainListTest.java Sun Jan  2 20:12:37 2011
@@ -27,6 +27,7 @@ import junit.framework.TestCase;
 import org.apache.commons.logging.impl.SimpleLog;
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.dnsservice.api.mock.MockDNSService;
+import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.domainlist.jpa.JPADomainList;
 import org.apache.james.domainlist.jpa.model.JPADomain;
 import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
@@ -94,50 +95,55 @@ public class JPADomainListTest extends T
     
     /**
      * Add 3 domains and list them.
+     * @throws DomainListException 
      */
-    public void createListDomains() {
-        assertEquals(true, jpaDomainList.addDomain(DOMAIN_3));
-        assertEquals(true, jpaDomainList.addDomain(DOMAIN_4));
-        assertEquals(true, jpaDomainList.addDomain(DOMAIN_5));
+    public void createListDomains() throws DomainListException {
+        jpaDomainList.addDomain(DOMAIN_3);
+        jpaDomainList.addDomain(DOMAIN_4);
+        jpaDomainList.addDomain(DOMAIN_5);
         assertEquals(3, jpaDomainList.getDomains().length);
     }
 
     /**
      * Add a domain and check it is present.
+     * @throws DomainListException 
      */
-    public void testAddContainsDomain() {
-        assertEquals(true, jpaDomainList.addDomain(DOMAIN_2));
-        assertEquals(true, jpaDomainList.containsDomain(DOMAIN_2));
+    public void testAddContainsDomain() throws DomainListException {
+        jpaDomainList.addDomain(DOMAIN_2);
+        jpaDomainList.containsDomain(DOMAIN_2);
     }
 
     /**
      * Add and remove a domain, and check database is empty.
+     * @throws DomainListException 
      */
-    public void testAddRemoveContainsSameDomain() {
-        assertEquals(true, jpaDomainList.addDomain(DOMAIN_1));
-        assertEquals(true, jpaDomainList.removeDomain(DOMAIN_1));
+    public void testAddRemoveContainsSameDomain() throws DomainListException {
+        jpaDomainList.addDomain(DOMAIN_1);
+        jpaDomainList.removeDomain(DOMAIN_1);
         assertEquals(null, jpaDomainList.getDomains());
     }
 
     /**
      * Add a domain and remove another domain, and check first domain is still present.
+     * @throws DomainListException 
      */
-    public void testAddRemoveContainsDifferentDomain() {
-        assertEquals(true, jpaDomainList.addDomain(DOMAIN_1));
-        assertEquals(true, jpaDomainList.removeDomain(DOMAIN_2));
+    public void testAddRemoveContainsDifferentDomain() throws DomainListException {
+        jpaDomainList.addDomain(DOMAIN_1);
+        jpaDomainList.removeDomain(DOMAIN_2);
         assertEquals(1, jpaDomainList.getDomains().length);
         assertEquals(true, jpaDomainList.containsDomain(DOMAIN_1));
     }
     
     /**
      * Delete all possible domains from database.
+     * @throws DomainListException 
      */
-    private void deleteAll() {
-        assertEquals(true, jpaDomainList.removeDomain(DOMAIN_1));
-        assertEquals(true, jpaDomainList.removeDomain(DOMAIN_2));
-        assertEquals(true, jpaDomainList.removeDomain(DOMAIN_3));
-        assertEquals(true, jpaDomainList.removeDomain(DOMAIN_4));
-        assertEquals(true, jpaDomainList.removeDomain(DOMAIN_5));
+    private void deleteAll() throws DomainListException {
+        jpaDomainList.removeDomain(DOMAIN_1);
+        jpaDomainList.removeDomain(DOMAIN_2);
+        jpaDomainList.removeDomain(DOMAIN_3);
+        jpaDomainList.removeDomain(DOMAIN_4);
+        jpaDomainList.removeDomain(DOMAIN_5);
     }
 
     /**

Modified: james/server/trunk/domainlist-library/src/main/java/org/apache/james/domainlist/lib/AbstractDomainList.java
URL: http://svn.apache.org/viewvc/james/server/trunk/domainlist-library/src/main/java/org/apache/james/domainlist/lib/AbstractDomainList.java?rev=1054466&r1=1054465&r2=1054466&view=diff
==============================================================================
--- james/server/trunk/domainlist-library/src/main/java/org/apache/james/domainlist/lib/AbstractDomainList.java (original)
+++ james/server/trunk/domainlist-library/src/main/java/org/apache/james/domainlist/lib/AbstractDomainList.java Sun Jan  2 20:12:37 2011
@@ -35,6 +35,7 @@ import org.apache.commons.configuration.
 import org.apache.commons.logging.Log;
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.lifecycle.api.Configurable;
 import org.apache.james.lifecycle.api.LogEnabled;
 
@@ -76,7 +77,7 @@ public abstract class AbstractDomainList
      * (non-Javadoc)
      * @see org.apache.james.domainlist.api.DomainList#getDefaultDomain()
      */
-    public String getDefaultDomain() {
+    public String getDefaultDomain() throws DomainListException{
         return defaultDomain;
     }
 
@@ -85,7 +86,7 @@ public abstract class AbstractDomainList
      * (non-Javadoc)
      * @see org.apache.james.api.domainlist.DomainList#getDomains()
      */
-    public String[] getDomains() {  
+    public String[] getDomains() throws DomainListException{  
         List<String> domains = getDomainListInternal();
         if (domains != null) {
             
@@ -164,27 +165,6 @@ public abstract class AbstractDomainList
         return domainIP;
     }
     
-    /**
-     * @see org.apache.james.domainlist.api.ManageableDomainList#addDomain(java.lang.String)
-     */
-    public boolean addDomain(String domain) {
-        getLogger().info("Add domain " + domain + " to DomainList");
-    
-        //TODO: Should we care about autoDetectIP ?
-        return addDomainInternal(domain);
-    }
-    
-    /**
-     * @see org.apache.james.domainlist.api.ManageableDomainList#removeDomain(java.lang.String)
-     */
-    public boolean removeDomain(String domain) {
-        getLogger().info("Remove domain " + domain + " from DomainList");
-    
-    
-        //TODO: Should we care about autoDetectIP ?
-        return removeDomainInternal(domain);
-    }
-    
 
     /**
      * Set to true to autodetect the hostname of the host on which
@@ -225,21 +205,6 @@ public abstract class AbstractDomainList
      * 
      * @return List
      */
-    protected abstract List<String> getDomainListInternal();
-    
-    /**
-     * Add domain
-     * 
-     * @param domain domain to add
-     * @return true if successfully
-     */
-    protected abstract boolean addDomainInternal(String domain);
-    
-    /**
-     * Remove domain
-     * 
-     * @param domain domain to remove
-     * @return true if successfully
-     */
-    protected abstract boolean removeDomainInternal(String domain);
+    protected abstract List<String> getDomainListInternal() throws DomainListException;
+
 }

Modified: james/server/trunk/domainlist-library/src/main/java/org/apache/james/domainlist/lib/DomainListManagement.java
URL: http://svn.apache.org/viewvc/james/server/trunk/domainlist-library/src/main/java/org/apache/james/domainlist/lib/DomainListManagement.java?rev=1054466&r1=1054465&r2=1054466&view=diff
==============================================================================
--- james/server/trunk/domainlist-library/src/main/java/org/apache/james/domainlist/lib/DomainListManagement.java (original)
+++ james/server/trunk/domainlist-library/src/main/java/org/apache/james/domainlist/lib/DomainListManagement.java Sun Jan  2 20:12:37 2011
@@ -23,6 +23,7 @@ import javax.management.NotCompliantMBea
 import javax.management.StandardMBean;
 
 import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.domainlist.api.DomainListManagementMBean;
 
 public class DomainListManagement extends StandardMBean implements DomainListManagementMBean{
@@ -38,23 +39,23 @@ public class DomainListManagement extend
         this.domainList = domainList;
     }
     
-    public boolean addDomain(String domain) {
-        return domainList.addDomain(domain);
+    public void addDomain(String domain) throws DomainListException{
+        domainList.addDomain(domain);
     }
 
-    public boolean containsDomain(String domain) {
+    public boolean containsDomain(String domain) throws DomainListException{
         return domainList.containsDomain(domain);
     }
 
-    public String[] getDomains() {
+    public String[] getDomains() throws DomainListException{
         return domainList.getDomains();
     }
 
-    public boolean removeDomain(String domain) {
-        return domainList.removeDomain(domain);
+    public void removeDomain(String domain) throws DomainListException{
+        domainList.removeDomain(domain);
     }
 
-    public String getDefaultDomain() {
+    public String getDefaultDomain() throws DomainListException{
         return domainList.getDefaultDomain();
     }
 

Modified: james/server/trunk/domainlist-xml/src/main/java/org/apache/james/domainlist/xml/XMLDomainList.java
URL: http://svn.apache.org/viewvc/james/server/trunk/domainlist-xml/src/main/java/org/apache/james/domainlist/xml/XMLDomainList.java?rev=1054466&r1=1054465&r2=1054466&view=diff
==============================================================================
--- james/server/trunk/domainlist-xml/src/main/java/org/apache/james/domainlist/xml/XMLDomainList.java (original)
+++ james/server/trunk/domainlist-xml/src/main/java/org/apache/james/domainlist/xml/XMLDomainList.java Sun Jan  2 20:12:37 2011
@@ -27,6 +27,7 @@ import java.util.Locale;
 
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.domainlist.lib.AbstractDomainList;
 import org.apache.james.lifecycle.api.Configurable;
 
@@ -49,9 +50,16 @@ public class XMLDomainList extends Abstr
         super.configure(config);
         List<String> serverNameConfs = config.getList( "domainnames.domainname" );
         for ( int i = 0; i < serverNameConfs.size(); i++ ) {
-            addDomainInternal( serverNameConfs.get(i));
+            try {
+                addDomain( serverNameConfs.get(i));
+            } catch (DomainListException e) {
+                throw new ConfigurationException("Unable to add domain to memory", e);
+            }
         }
         
+        managementDisabled = true;
+
+        
     }
    
    
@@ -61,45 +69,41 @@ public class XMLDomainList extends Abstr
      * @see org.apache.james.domainlist.lib.AbstractDomainList#getDomainListInternal()
      */
     protected List<String> getDomainListInternal() {
-        // TODO: Remove temporary fix!
-        // This is set to true to get sure now new domain can get added or removed
-        // after the domains were retrieved by James.java. See is a workaround!
-        managementDisabled = true;
+        
         return new ArrayList<String>(domainNames);
     }
 
     /**
      * @see org.apache.james.domainlist.api.DomainList#containsDomain(java.lang.String)
      */
-    public boolean containsDomain(String domains) {
+    public boolean containsDomain(String domains) throws DomainListException{
         return domainNames.contains(domains);
     }
 
-    /**
-     * The added domains will only added in memory!
-     * 
-     * @see org.apache.james.domainlist.lib.AbstractDomainList#addDomainInternal(java.lang.String)
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.domainlist.api.DomainList#addDomain(java.lang.String)
      */
-    protected boolean addDomainInternal(String domain) {
+    public void addDomain(String domain) throws DomainListException{
         // TODO: Remove later. Temporary fix to get sure no domains can be added to the XMLDomainList
-        if (managementDisabled) throw new UnsupportedOperationException("Management not supported");
+        if (managementDisabled) throw new DomainListException("Read-Only DomainList implementation");
         
         String newDomain = domain.toLowerCase(Locale.US);
         if (containsDomain(newDomain) == false) {
             domainNames.add(newDomain);
-            return true;
-        } else {
-            return false;
         }
+        
     }
 
-    /**
-     * @see org.apache.james.domainlist.lib.AbstractDomainList#removeDomainInternal(java.lang.String)
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.domainlist.api.DomainList#removeDomain(java.lang.String)
      */
-    protected boolean removeDomainInternal(String domain) {
+    public void removeDomain(String domain) throws DomainListException {
         // TODO: Remove later. Temporary fix to get sure no domains can be added to the XMLDomainList
-        if (managementDisabled) throw new UnsupportedOperationException("Management not supported");
+        if (managementDisabled) throw new DomainListException("Read-Only DomainList implementation");
        
-        return domainNames.remove(domain.toLowerCase(Locale.US));
+        domainNames.remove(domain.toLowerCase(Locale.US));
     }
 }

Modified: james/server/trunk/fetchmail/src/main/java/org/apache/james/fetchmail/MessageProcessor.java
URL: http://svn.apache.org/viewvc/james/server/trunk/fetchmail/src/main/java/org/apache/james/fetchmail/MessageProcessor.java?rev=1054466&r1=1054465&r2=1054466&view=diff
==============================================================================
--- james/server/trunk/fetchmail/src/main/java/org/apache/james/fetchmail/MessageProcessor.java (original)
+++ james/server/trunk/fetchmail/src/main/java/org/apache/james/fetchmail/MessageProcessor.java Sun Jan  2 20:12:37 2011
@@ -36,6 +36,7 @@ import javax.mail.internet.MimeMessage;
 import javax.mail.internet.ParseException;
 
 import org.apache.james.core.MailImpl;
+import org.apache.james.domainlist.api.DomainListException;
 import org.apache.mailet.base.RFC2822Headers;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
@@ -912,7 +913,12 @@ public class MessageProcessor extends Pr
      */
     protected boolean isLocalServer(MailAddress recipient)
     {
-        return getConfiguration().getDomainList().containsDomain(recipient.getDomain());
+        try {
+            return getConfiguration().getDomainList().containsDomain(recipient.getDomain());
+        } catch (DomainListException e) {
+            getLogger().error("Unable to access DomainList",e);
+            return false;
+        }
     }
     
     /**

Modified: james/server/trunk/fetchmail/src/main/java/org/apache/james/fetchmail/ParsedConfiguration.java
URL: http://svn.apache.org/viewvc/james/server/trunk/fetchmail/src/main/java/org/apache/james/fetchmail/ParsedConfiguration.java?rev=1054466&r1=1054465&r2=1054466&view=diff
==============================================================================
--- james/server/trunk/fetchmail/src/main/java/org/apache/james/fetchmail/ParsedConfiguration.java (original)
+++ james/server/trunk/fetchmail/src/main/java/org/apache/james/fetchmail/ParsedConfiguration.java Sun Jan  2 20:12:37 2011
@@ -33,6 +33,7 @@ import org.apache.commons.configuration.
 import org.apache.commons.logging.Log;
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.queue.api.MailQueue;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.mailet.MailAddress;
@@ -857,11 +858,15 @@ protected void setDNSServer(DNSService d
      */
     protected void validateDefaultDomainName(String defaultDomainName) throws ConfigurationException
     {
-        if (!getDomainList().containsDomain(defaultDomainName))
-        {
-            throw new ConfigurationException(
-                "Default domain name is not a local server: "
-                    + defaultDomainName);
+        try {
+            if (!getDomainList().containsDomain(defaultDomainName))
+            {
+                throw new ConfigurationException(
+                    "Default domain name is not a local server: "
+                        + defaultDomainName);
+            }
+        } catch (DomainListException e) {
+            throw new ConfigurationException("Unable to access DomainList", e);
         }
     }
     

Modified: james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/JamesMailetContext.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/JamesMailetContext.java?rev=1054466&r1=1054465&r2=1054466&view=diff
==============================================================================
--- james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/JamesMailetContext.java (original)
+++ james/server/trunk/mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/JamesMailetContext.java Sun Jan  2 20:12:37 2011
@@ -46,6 +46,7 @@ import org.apache.james.core.MailImpl;
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.dnsservice.api.TemporaryResolutionException;
 import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.lifecycle.api.Configurable;
 import org.apache.james.lifecycle.api.LifecycleUtil;
 import org.apache.james.lifecycle.api.LogEnabled;
@@ -242,7 +243,12 @@ public class JamesMailetContext implemen
         }
         try {
             if (name.indexOf("@") == -1) {
-                return isLocalEmail(new MailAddress(name, domains.getDefaultDomain()));
+                try {
+                    return isLocalEmail(new MailAddress(name, domains.getDefaultDomain()));
+                } catch (DomainListException e) {
+                    log("Unable to access DomainList",e);
+                    return false;
+                }
             } else {
                 return isLocalEmail(new MailAddress(name));
             }
@@ -327,7 +333,12 @@ public class JamesMailetContext implemen
      * @see org.apache.mailet.MailetContext#isLocalServer(java.lang.String)
      */
     public boolean isLocalServer(String name) {
-        return domains.containsDomain(name);
+        try {
+            return domains.containsDomain(name);
+        } catch (DomainListException e) {
+            log.error("Unable to retrieve domains", e);
+            return false;
+        }
     }
 
     /*
@@ -437,41 +448,49 @@ public class JamesMailetContext implemen
      * 
      */
     public void configure(HierarchicalConfiguration config) throws ConfigurationException {
-        // Get postmaster
-        String postMasterAddress = config.getString("postmaster", "postmaster").toLowerCase(Locale.US);
-        // if there is no @domain part, then add the first one from the
-        // list of supported domains that isn't localhost. If that
-        // doesn't work, use the hostname, even if it is localhost.
-        if (postMasterAddress.indexOf('@') < 0) {
-            String domainName = null; // the domain to use
-            // loop through candidate domains until we find one or exhaust the
-            // list
-            String[] doms = domains.getDomains();
-            if (doms != null) {
-                for (int i = 0; i < doms.length; i++) {
-                    String serverName = doms[i].toLowerCase(Locale.US);
-                    if (!("localhost".equals(serverName))) {
-                        domainName = serverName; // ok, not localhost, so use it
-                        continue;
+        try {
+
+            // Get postmaster
+            String postMasterAddress = config.getString("postmaster", "postmaster").toLowerCase(Locale.US);
+            // if there is no @domain part, then add the first one from the
+            // list of supported domains that isn't localhost. If that
+            // doesn't work, use the hostname, even if it is localhost.
+            if (postMasterAddress.indexOf('@') < 0) {
+                String domainName = null; // the domain to use
+                // loop through candidate domains until we find one or exhaust
+                // the
+                // list
+                String[] doms = domains.getDomains();
+                if (doms != null) {
+                    for (int i = 0; i < doms.length; i++) {
+                        String serverName = doms[i].toLowerCase(Locale.US);
+                        if (!("localhost".equals(serverName))) {
+                            domainName = serverName; // ok, not localhost, so
+                                                     // use it
+                            continue;
+                        }
                     }
+
                 }
-            
+
+                // if we found a suitable domain, use it. Otherwise fallback to
+                // the
+                // host name.
+                postMasterAddress = postMasterAddress + "@" + (domainName != null ? domainName : domains.getDefaultDomain());
             }
-            // if we found a suitable domain, use it. Otherwise fallback to the
-            // host name.
-            postMasterAddress = postMasterAddress + "@" + (domainName != null ? domainName : domains.getDefaultDomain());
-        }
-        try {
-            this.postmaster = new MailAddress(postMasterAddress);
-            if (!domains.containsDomain(postmaster.getDomain())) {
-                StringBuffer warnBuffer = new StringBuffer(320).append("The specified postmaster address ( ").append(postmaster).append(
-                        " ) is not a local address.  This is not necessarily a problem, but it does mean that emails addressed to the postmaster will be routed to another server.  For some configurations this may cause problems.");
-                log.warn(warnBuffer.toString());
-            }    
-        } catch (AddressException e) {
-            throw new ConfigurationException("Postmaster address " + postMasterAddress + "is invalid",e);
+            try {
+                this.postmaster = new MailAddress(postMasterAddress);
+                if (!domains.containsDomain(postmaster.getDomain())) {
+                    StringBuffer warnBuffer = new StringBuffer(320).append("The specified postmaster address ( ").append(postmaster)
+                            .append(" ) is not a local address.  This is not necessarily a problem, but it does mean that emails addressed to the postmaster will be routed to another server.  For some configurations this may cause problems.");
+                    log.warn(warnBuffer.toString());
+                }
+            } catch (AddressException e) {
+                throw new ConfigurationException("Postmaster address " + postMasterAddress + "is invalid", e);
+            }
+        } catch (DomainListException e) {
+            throw new ConfigurationException("Unable to access DomainList", e);
         }
 
-    
     }
 }

Modified: james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/AbstractVirtualUserTable.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/AbstractVirtualUserTable.java?rev=1054466&r1=1054465&r2=1054466&view=diff
==============================================================================
--- james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/AbstractVirtualUserTable.java (original)
+++ james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/AbstractVirtualUserTable.java Sun Jan  2 20:12:37 2011
@@ -37,6 +37,7 @@ import javax.mail.internet.ParseExceptio
 import org.apache.james.core.MailImpl;
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.vut.lib.VirtualUserTableUtil;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
@@ -157,6 +158,8 @@ public abstract class AbstractVirtualUse
                                 .append(targetAddress);
                             log(exceptionBuffer.toString());
                             continue;
+                        } catch (DomainListException e) {
+                            log("Unable to access DomainList" ,e);
                         }
                     }
                 }

Modified: james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/AbstractVirtualUserTableMailet.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/AbstractVirtualUserTableMailet.java?rev=1054466&r1=1054465&r2=1054466&view=diff
==============================================================================
--- james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/AbstractVirtualUserTableMailet.java (original)
+++ james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/AbstractVirtualUserTableMailet.java Sun Jan  2 20:12:37 2011
@@ -30,6 +30,7 @@ import javax.mail.MessagingException;
 import javax.mail.internet.MimeMessage;
 
 import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.domainlist.api.DomainListException;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
 import org.apache.mailet.base.GenericMailet;
@@ -137,7 +138,11 @@ public abstract class AbstractVirtualUse
 
             if (rcpt.indexOf("@") < 0) {
                 // the mapping contains no domain name, use the default domain
-                rcpt = rcpt + "@" + domainList.getDefaultDomain();
+                try {
+                    rcpt = rcpt + "@" + domainList.getDefaultDomain();
+                } catch (DomainListException e) {
+                    throw new MessagingException("Unable to access DomainList" ,e);
+                }
             }
 
             MailAddress nextMap = new MailAddress(rcpt);

Modified: james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java?rev=1054466&r1=1054465&r2=1054466&view=diff
==============================================================================
--- james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java (original)
+++ james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java Sun Jan  2 20:12:37 2011
@@ -24,6 +24,7 @@ package org.apache.james.transport.maile
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.dnsservice.api.TemporaryResolutionException;
 import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.lifecycle.api.LifecycleUtil;
 import org.apache.james.queue.api.MailQueue;
 import org.apache.james.queue.api.MailQueueFactory;
@@ -1621,7 +1622,12 @@ public class RemoteDelivery extends Gene
     protected String getHeloName() {
         if (heloName == null) {
             //TODO: Maybe we should better just lookup the hostname via dns
-            return domainList.getDefaultDomain();
+            try {
+                return domainList.getDefaultDomain();
+            } catch (DomainListException e) {
+                log("Unable to access DomainList" ,e );
+                return "localhost";
+            }
         } else {
             return heloName;
         }

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/AuthRequiredToRelayRcptHook.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/AuthRequiredToRelayRcptHook.java?rev=1054466&r1=1054465&r2=1054466&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/AuthRequiredToRelayRcptHook.java (original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/AuthRequiredToRelayRcptHook.java Sun Jan  2 20:12:37 2011
@@ -21,6 +21,7 @@ package org.apache.james.smtpserver;
 import javax.annotation.Resource;
 
 import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.protocols.smtp.core.AbstractAuthRequiredToRelayRcptHook;
 
 public class AuthRequiredToRelayRcptHook extends AbstractAuthRequiredToRelayRcptHook {  
@@ -38,6 +39,10 @@ public class AuthRequiredToRelayRcptHook
      * @see org.apache.james.protocols.smtp.core.AbstractAuthRequiredToRelayRcptHook#isLocalDomain(java.lang.String)
      */
     protected boolean isLocalDomain(String domain) {
-        return domains.containsDomain(domain);
+        try {
+            return domains.containsDomain(domain);
+        } catch (DomainListException e) {
+            return false;
+        }
     }
 }

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/JamesMailCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/JamesMailCmdHandler.java?rev=1054466&r1=1054465&r2=1054466&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/JamesMailCmdHandler.java (original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/JamesMailCmdHandler.java Sun Jan  2 20:12:37 2011
@@ -21,6 +21,7 @@ package org.apache.james.smtpserver;
 import javax.annotation.Resource;
 
 import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.protocols.smtp.core.MailCmdHandler;
 
 public class JamesMailCmdHandler extends MailCmdHandler{
@@ -36,7 +37,11 @@ public class JamesMailCmdHandler extends
      * @see org.apache.james.protocols.smtp.core.MailCmdHandler#getDefaultDomain()
      */
     public String getDefaultDomain() {
-        return domainList.getDefaultDomain();
+        try {
+            return domainList.getDefaultDomain();
+        } catch (DomainListException e) {
+            return super.getDefaultDomain();
+        }
     }
     
     

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/JamesRcptCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/JamesRcptCmdHandler.java?rev=1054466&r1=1054465&r2=1054466&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/JamesRcptCmdHandler.java (original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/JamesRcptCmdHandler.java Sun Jan  2 20:12:37 2011
@@ -22,6 +22,7 @@ package org.apache.james.smtpserver;
 import javax.annotation.Resource;
 
 import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.protocols.smtp.core.RcptCmdHandler;
 
 public class JamesRcptCmdHandler extends RcptCmdHandler{
@@ -37,6 +38,10 @@ public class JamesRcptCmdHandler extends
      * @see org.apache.james.protocols.smtp.core.MailCmdHandler#getDefaultDomain()
      */
     public String getDefaultDomain() {
-        return domainList.getDefaultDomain();
+        try {
+            return domainList.getDefaultDomain();
+        } catch (DomainListException e) {
+            return super.getDefaultDomain();
+        }
     }
 }

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationRcptHook.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationRcptHook.java?rev=1054466&r1=1054465&r2=1054466&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationRcptHook.java (original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationRcptHook.java Sun Jan  2 20:12:37 2011
@@ -21,6 +21,7 @@ package org.apache.james.smtpserver;
 import javax.annotation.Resource;
 
 import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.core.AbstractSenderAuthIdentifyVerificationRcptHook;
 import org.apache.james.protocols.smtp.hook.HookResult;
@@ -64,7 +65,11 @@ public class SenderAuthIdentifyVerificat
      * @see org.apache.james.protocols.smtp.core.AbstractSenderAuthIdentifyVerificationRcptHook#isLocalDomain(java.lang.String)
      */
     protected boolean isLocalDomain(String domain) {
-        return domains.containsDomain(domain);
+        try {
+            return domains.containsDomain(domain);
+        } catch (DomainListException e) {
+            return false;
+        }
     }
 
     /*

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptHandler.java?rev=1054466&r1=1054465&r2=1054466&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptHandler.java (original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptHandler.java Sun Jan  2 20:12:37 2011
@@ -26,6 +26,7 @@ import javax.annotation.Resource;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.HierarchicalConfiguration;
 import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.lifecycle.api.Configurable;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.core.fastfail.AbstractValidRcptHandler;
@@ -132,6 +133,11 @@ public class ValidRcptHandler extends Ab
      * @see org.apache.james.protocols.smtp.core.fastfail.AbstractValidRcptHandler#isLocalDomain(org.apache.james.protocols.smtp.SMTPSession, java.lang.String)
      */
     protected boolean isLocalDomain(SMTPSession session, String domain) {
-        return domains.containsDomain(domain);
+        try {
+            return domains.containsDomain(domain);
+        } catch (DomainListException e) {
+            session.getLogger().error("Unable to get domains", e);
+            return false;
+        }
     }
 }

Modified: james/server/trunk/user-jdbc/src/main/java/org/apache/james/user/jdbc/DefaultUsersJdbcRepository.java
URL: http://svn.apache.org/viewvc/james/server/trunk/user-jdbc/src/main/java/org/apache/james/user/jdbc/DefaultUsersJdbcRepository.java?rev=1054466&r1=1054465&r2=1054466&view=diff
==============================================================================
--- james/server/trunk/user-jdbc/src/main/java/org/apache/james/user/jdbc/DefaultUsersJdbcRepository.java (original)
+++ james/server/trunk/user-jdbc/src/main/java/org/apache/james/user/jdbc/DefaultUsersJdbcRepository.java Sun Jan  2 20:12:37 2011
@@ -21,6 +21,7 @@
 
 package org.apache.james.user.jdbc;
 
+import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.user.api.model.User;
 import org.apache.james.user.lib.model.DefaultUser;
 
@@ -89,7 +90,12 @@ public class DefaultUsersJdbcRepository 
      * @see org.apache.james.user.api.UsersRepository#addUser(java.lang.String, java.lang.String)
      */
     public boolean addUser(String username, String password)  {
-        if (contains(username) == true ||  isValidUsername(username) == false) {
+        try {
+            if (contains(username) == true ||  isValidUsername(username) == false) {
+                return false;
+            }
+        } catch (DomainListException e) {
+            getLogger().error("Unable to access DomainList", e);
             return false;
         }
         User newbie = new DefaultUser(username, "SHA");

Modified: james/server/trunk/user-library/src/main/java/org/apache/james/user/lib/AbstractUsersRepository.java
URL: http://svn.apache.org/viewvc/james/server/trunk/user-library/src/main/java/org/apache/james/user/lib/AbstractUsersRepository.java?rev=1054466&r1=1054465&r2=1054466&view=diff
==============================================================================
--- james/server/trunk/user-library/src/main/java/org/apache/james/user/lib/AbstractUsersRepository.java (original)
+++ james/server/trunk/user-library/src/main/java/org/apache/james/user/lib/AbstractUsersRepository.java Sun Jan  2 20:12:37 2011
@@ -26,6 +26,7 @@ import org.apache.commons.configuration.
 import org.apache.commons.configuration.HierarchicalConfiguration;
 import org.apache.commons.logging.Log;
 import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.domainlist.api.DomainListException;
 import org.apache.james.lifecycle.api.Configurable;
 import org.apache.james.lifecycle.api.LogEnabled;
 import org.apache.james.user.api.UsersRepository;
@@ -75,7 +76,7 @@ public abstract class AbstractUsersRepos
         this.domainList = domainList;
     }
     
-    protected boolean isValidUsername(String username) {
+    protected boolean isValidUsername(String username) throws DomainListException {
         int i = username.indexOf("@");
         if (supportVirtualHosting()) {
             // need a @ in the username
@@ -105,8 +106,13 @@ public abstract class AbstractUsersRepos
      */
     public boolean addUser(String username, String password) {
         
-        if (contains(username) == false && isValidUsername(username)) {
-            return doAddUser(username, password);
+        try {
+            if (contains(username) == false && isValidUsername(username)) {
+                return doAddUser(username, password);
+            }
+        } catch (DomainListException e) {
+            logger.error("Unable to access DomainList" ,e);
+            return false;
         }
         return false;
     }



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