james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e...@apache.org
Subject svn commit: r1241456 - /james/server/trunk/data-hbase/src/main/java/org/apache/james/domainlist/hbase/HBaseDomainList.java
Date Tue, 07 Feb 2012 13:08:24 GMT
Author: eric
Date: Tue Feb  7 13:08:23 2012
New Revision: 1241456

URL: http://svn.apache.org/viewvc?rev=1241456&view=rev
Log:
Lower cases and check if existing before JPA domain creation (JAMES-1369)

Modified:
    james/server/trunk/data-hbase/src/main/java/org/apache/james/domainlist/hbase/HBaseDomainList.java

Modified: james/server/trunk/data-hbase/src/main/java/org/apache/james/domainlist/hbase/HBaseDomainList.java
URL: http://svn.apache.org/viewvc/james/server/trunk/data-hbase/src/main/java/org/apache/james/domainlist/hbase/HBaseDomainList.java?rev=1241456&r1=1241455&r2=1241456&view=diff
==============================================================================
--- james/server/trunk/data-hbase/src/main/java/org/apache/james/domainlist/hbase/HBaseDomainList.java
(original)
+++ james/server/trunk/data-hbase/src/main/java/org/apache/james/domainlist/hbase/HBaseDomainList.java
Tue Feb  7 13:08:23 2012
@@ -52,14 +52,10 @@ public class HBaseDomainList extends Abs
      */
     @Override
     public boolean containsDomain(String domain) throws DomainListException {
-        String lowerCasedDomain = domain.toLowerCase();
-        if (containsDomain(lowerCasedDomain)) {
-            throw new DomainListException(lowerCasedDomain + " already exists.");
-        }
         HTable table = null;
         try {
             table = TablePool.getInstance().getDomainlistTable();
-            Get get = new Get(Bytes.toBytes(lowerCasedDomain));
+            Get get = new Get(Bytes.toBytes(domain));
             Result result = table.get(get);
             if (! result.isEmpty()) {
                 return true;
@@ -84,10 +80,14 @@ public class HBaseDomainList extends Abs
      */
     @Override
     public void addDomain(String domain) throws DomainListException {
+        String lowerCasedDomain = domain.toLowerCase();
+        if (containsDomain(lowerCasedDomain)) {
+            throw new DomainListException(lowerCasedDomain + " already exists.");
+        }
         HTable table = null;
         try {
             table = TablePool.getInstance().getDomainlistTable();
-            Put put = new Put(Bytes.toBytes(domain));
+            Put put = new Put(Bytes.toBytes(lowerCasedDomain));
             put.add(HDomainList.COLUMN_FAMILY_NAME, HDomainList.COLUMN.DOMAIN, null);
             table.put(put);
             table.flushCommits();



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