Author: matthieu
Date: Mon Nov  2 13:44:15 2015
New Revision: 1711977

URL: http://svn.apache.org/viewvc?rev=1711977&view=rev
Log:
JAMES-1595 addAll(Mappings) now create a new Mappings object in the quest to 
immutable Mappings

Modified:
    
james/project/trunk/server/data/data-api/src/main/java/org/apache/james/rrt/lib/Mappings.java
    
james/project/trunk/server/data/data-hbase/src/main/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTable.java
    
james/project/trunk/server/data/data-library/src/main/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTable.java
    
james/project/trunk/server/data/data-library/src/main/java/org/apache/james/rrt/lib/MappingsImpl.java
    
james/project/trunk/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecipientRewriteTableMock.java

Modified: 
james/project/trunk/server/data/data-api/src/main/java/org/apache/james/rrt/lib/Mappings.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/data/data-api/src/main/java/org/apache/james/rrt/lib/Mappings.java?rev=1711977&r1=1711976&r2=1711977&view=diff
==============================================================================
--- 
james/project/trunk/server/data/data-api/src/main/java/org/apache/james/rrt/lib/Mappings.java
 (original)
+++ 
james/project/trunk/server/data/data-api/src/main/java/org/apache/james/rrt/lib/Mappings.java
 Mon Nov  2 13:44:15 2015
@@ -26,7 +26,7 @@ public interface Mappings extends Iterab
 
     Collection<String> getMappings();
     
-    void addAll(Mappings toAdd);
+    Mappings addAll(Mappings toAdd);
 
     void add(String mapping);
 

Modified: 
james/project/trunk/server/data/data-hbase/src/main/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTable.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/data/data-hbase/src/main/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTable.java?rev=1711977&r1=1711976&r2=1711977&view=diff
==============================================================================
--- 
james/project/trunk/server/data/data-hbase/src/main/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTable.java
 (original)
+++ 
james/project/trunk/server/data/data-hbase/src/main/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTable.java
 Mon Nov  2 13:44:15 2015
@@ -96,15 +96,16 @@ public class HBaseRecipientRewriteTable
         return list;
     }
 
-    private void feedUserDomainMappingsList(HTableInterface table, String 
user, String domain, Mappings list) throws
+    private Mappings feedUserDomainMappingsList(HTableInterface table, String 
user, String domain, Mappings list) throws
             IOException {
         Get get = new Get(Bytes.toBytes(getRowKey(user, domain)));
         Result result = table.get(get);
         List<KeyValue> keyValues = 
result.getColumn(HRecipientRewriteTable.COLUMN_FAMILY_NAME,
                                                     
HRecipientRewriteTable.COLUMN.MAPPING);
         if (keyValues.size() > 0) {
-            
list.addAll(MappingsImpl.fromRawString(Bytes.toString(keyValues.get(0).getValue())));
+            return 
list.addAll(MappingsImpl.fromRawString(Bytes.toString(keyValues.get(0).getValue())));
         }
+        return list;
     }
 
     /**

Modified: 
james/project/trunk/server/data/data-library/src/main/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTable.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/data/data-library/src/main/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTable.java?rev=1711977&r1=1711976&r2=1711977&view=diff
==============================================================================
--- 
james/project/trunk/server/data/data-library/src/main/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTable.java
 (original)
+++ 
james/project/trunk/server/data/data-library/src/main/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTable.java
 Mon Nov  2 13:44:15 2015
@@ -180,7 +180,7 @@ public abstract class AbstractRecipientR
                             // add mapping
                             mappings.add(target);
                         } else {
-                            mappings.addAll(childMappings);
+                            mappings = mappings.addAll(childMappings);
                         }
 
                     } else {

Modified: 
james/project/trunk/server/data/data-library/src/main/java/org/apache/james/rrt/lib/MappingsImpl.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/data/data-library/src/main/java/org/apache/james/rrt/lib/MappingsImpl.java?rev=1711977&r1=1711976&r2=1711977&view=diff
==============================================================================
--- 
james/project/trunk/server/data/data-library/src/main/java/org/apache/james/rrt/lib/MappingsImpl.java
 (original)
+++ 
james/project/trunk/server/data/data-library/src/main/java/org/apache/james/rrt/lib/MappingsImpl.java
 Mon Nov  2 13:44:15 2015
@@ -26,6 +26,9 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.StringTokenizer;
 
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
 public class MappingsImpl implements Mappings {
 
     public static MappingsImpl empty() {
@@ -67,8 +70,8 @@ public class MappingsImpl implements Map
     }
     
     @Override
-    public void addAll(Mappings toAdd) {
-        mappings.addAll(toAdd.getMappings());
+    public Mappings addAll(Mappings toAdd) {
+        return 
MappingsImpl.fromCollection(Lists.newArrayList(Iterables.concat(this, 
toAdd.getMappings())));
     }
 
     @Override

Modified: 
james/project/trunk/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecipientRewriteTableMock.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecipientRewriteTableMock.java?rev=1711977&r1=1711976&r2=1711977&view=diff
==============================================================================
--- 
james/project/trunk/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecipientRewriteTableMock.java
 (original)
+++ 
james/project/trunk/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecipientRewriteTableMock.java
 Mon Nov  2 13:44:15 2015
@@ -79,7 +79,7 @@ public class RecipientRewriteTableMock i
     public Mappings getMappings(String user, String domain) throws 
ErrorMappingException, RecipientRewriteTableException {
         Mappings recipients = MappingsImpl.empty();
         for (Mapping m : findUserDomain(user, domain)) {
-            recipients.addAll(m.target);
+            recipients = recipients.addAll(m.target);
         }
         if (recipients.isEmpty()) {
             return null;



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

Reply via email to