Author: matthieu
Date: Mon Nov  2 13:43:21 2015
New Revision: 1711974

URL: http://svn.apache.org/viewvc?rev=1711974&view=rev
Log:
JAMES-1595 Promote Mappings to a actual object

Added:
    
james/project/trunk/server/data/data-api/src/main/java/org/apache/james/rrt/lib/
    
james/project/trunk/server/data/data-api/src/main/java/org/apache/james/rrt/lib/Mappings.java
    
james/project/trunk/server/data/data-library/src/main/java/org/apache/james/rrt/lib/MappingsImpl.java
    
james/project/trunk/server/data/data-library/src/test/java/org/apache/james/rrt/lib/MappingsImplTest.java
Modified:
    james/project/trunk/server/container/cli/pom.xml
    
james/project/trunk/server/container/cli/src/main/java/org/apache/james/cli/ServerCmd.java
    
james/project/trunk/server/container/cli/src/main/java/org/apache/james/cli/probe/ServerProbe.java
    
james/project/trunk/server/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxServerProbe.java
    
james/project/trunk/server/container/cli/src/test/java/org/apache/james/cli/ServerCmdTest.java
    
james/project/trunk/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java
    
james/project/trunk/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTableManagementMBean.java
    
james/project/trunk/server/data/data-file/src/main/java/org/apache/james/rrt/file/XMLRecipientRewriteTable.java
    
james/project/trunk/server/data/data-file/src/test/java/org/apache/james/rrt/file/XMLRecipientRewriteTableTest.java
    
james/project/trunk/server/data/data-hbase/src/main/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTable.java
    
james/project/trunk/server/data/data-jdbc/src/main/java/org/apache/james/rrt/jdbc/JDBCRecipientRewriteTable.java
    
james/project/trunk/server/data/data-jpa/src/main/java/org/apache/james/rrt/jpa/JPARecipientRewriteTable.java
    james/project/trunk/server/data/data-library/pom.xml
    
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/RecipientRewriteTableManagement.java
    
james/project/trunk/server/data/data-library/src/main/java/org/apache/james/rrt/lib/RecipientRewriteTableUtil.java
    
james/project/trunk/server/data/data-library/src/main/java/org/apache/james/user/lib/AbstractJamesUsersRepository.java
    
james/project/trunk/server/data/data-library/src/test/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTableTest.java
    
james/project/trunk/server/data/data-library/src/test/java/org/apache/james/rrt/lib/RecipientRewriteTableUtilTest.java
    
james/project/trunk/server/data/data-library/src/test/java/org/apache/james/rrt/lib/mock/MockRecipientRewriteTableManagementImpl.java
    
james/project/trunk/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/AbstractRecipientRewriteTableMailet.java
    
james/project/trunk/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTable.java
    
james/project/trunk/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/UsersRepositoryAliasingForwarding.java
    
james/project/trunk/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RecipientRewriteTableMock.java
    
james/project/trunk/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptHandler.java
    
james/project/trunk/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
    
james/project/trunk/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/ValidRcptHandlerTest.java

Modified: james/project/trunk/server/container/cli/pom.xml
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/container/cli/pom.xml?rev=1711974&r1=1711973&r2=1711974&view=diff
==============================================================================
--- james/project/trunk/server/container/cli/pom.xml (original)
+++ james/project/trunk/server/container/cli/pom.xml Mon Nov  2 13:43:21 2015
@@ -40,6 +40,10 @@
         </dependency>
         <dependency>
             <groupId>org.apache.james</groupId>
+            <artifactId>james-server-data-library</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.james</groupId>
             <artifactId>james-server-mailbox-adapter</artifactId>
         </dependency>
         <dependency>

Modified: 
james/project/trunk/server/container/cli/src/main/java/org/apache/james/cli/ServerCmd.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/container/cli/src/main/java/org/apache/james/cli/ServerCmd.java?rev=1711974&r1=1711973&r2=1711974&view=diff
==============================================================================
--- 
james/project/trunk/server/container/cli/src/main/java/org/apache/james/cli/ServerCmd.java
 (original)
+++ 
james/project/trunk/server/container/cli/src/main/java/org/apache/james/cli/ServerCmd.java
 Mon Nov  2 13:43:21 2015
@@ -18,8 +18,12 @@
  ****************************************************************/
 package org.apache.james.cli;
 
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Joiner;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Map.Entry;
+
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.CommandLineParser;
 import org.apache.commons.cli.HelpFormatter;
@@ -40,12 +44,10 @@ import org.apache.james.cli.probe.impl.J
 import org.apache.james.cli.type.CmdType;
 import org.apache.james.cli.utils.ValueWithUnit;
 import org.apache.james.mailbox.model.Quota;
+import org.apache.james.rrt.lib.Mappings;
 
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Map.Entry;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Joiner;
 
 /**
  * Command line utility for managing various aspect of the James server.
@@ -186,7 +188,7 @@ public class ServerCmd {
             print(probe.listMappings(), System.out);
             break;
         case LISTUSERDOMAINMAPPINGS:
-            Collection<String> userDomainMappings = 
probe.listUserDomainMappings(arguments[1], arguments[2]);
+            Mappings userDomainMappings = 
probe.listUserDomainMappings(arguments[1], arguments[2]);
             print(userDomainMappings.toArray(new String[0]), System.out);
             break;
         case ADDADDRESSMAPPING:
@@ -304,16 +306,16 @@ public class ServerCmd {
         return String.valueOf(value);
     }
 
-    private void print(Map<String, Collection<String>> map, PrintStream out) {
+    private void print(Map<String, ? extends Iterable<String>> map, 
PrintStream out) {
         if (map != null) {
-            for (Entry<String, Collection<String>> entry : map.entrySet()) {
+            for (Entry<String, ? extends Iterable<String>> entry : 
map.entrySet()) {
                 out.println(entry.getKey() + '=' + collectionToString(entry));
             }
             out.println();
         }
     }
 
-    private String collectionToString(Entry<String, Collection<String>> entry) 
{
+    private String collectionToString(Entry<String, ? extends 
Iterable<String>> entry) {
         return Joiner.on(',').join(entry.getValue());
     }
 

Modified: 
james/project/trunk/server/container/cli/src/main/java/org/apache/james/cli/probe/ServerProbe.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/container/cli/src/main/java/org/apache/james/cli/probe/ServerProbe.java?rev=1711974&r1=1711973&r2=1711974&view=diff
==============================================================================
--- 
james/project/trunk/server/container/cli/src/main/java/org/apache/james/cli/probe/ServerProbe.java
 (original)
+++ 
james/project/trunk/server/container/cli/src/main/java/org/apache/james/cli/probe/ServerProbe.java
 Mon Nov  2 13:43:21 2015
@@ -27,6 +27,8 @@ import java.io.Closeable;
 import java.util.Collection;
 import java.util.Map;
 
+import org.apache.james.rrt.lib.Mappings;
+
 public interface ServerProbe extends Closeable {
     /**
      * Add a user to this mail server.
@@ -109,7 +111,7 @@ public interface ServerProbe extends Clo
      * @return a Map which holds all mappings.
      * @throws Exception
      */
-    public Map<String, Collection<String>> listMappings() throws Exception;
+       public Map<String, Mappings> listMappings() throws Exception;
 
     /**
      * Add address mapping.
@@ -149,7 +151,7 @@ public interface ServerProbe extends Clo
      *         found.
      * @throws Exception
      */
-    public Collection<String> listUserDomainMappings(String user, String 
domain) throws Exception;
+       public Mappings listUserDomainMappings(String user, String domain) 
throws Exception;
 
     /**
      * Remove regex mapping.

Modified: 
james/project/trunk/server/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxServerProbe.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxServerProbe.java?rev=1711974&r1=1711973&r2=1711974&view=diff
==============================================================================
--- 
james/project/trunk/server/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxServerProbe.java
 (original)
+++ 
james/project/trunk/server/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxServerProbe.java
 Mon Nov  2 13:43:21 2015
@@ -38,6 +38,7 @@ import org.apache.james.cli.probe.Server
 import org.apache.james.domainlist.api.DomainListManagementMBean;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.rrt.api.RecipientRewriteTableManagementMBean;
+import org.apache.james.rrt.lib.Mappings;
 import org.apache.james.user.api.UsersRepositoryManagementMBean;
 
 public class JmxServerProbe implements ServerProbe {
@@ -169,7 +170,7 @@ public class JmxServerProbe implements S
     }
 
     @Override
-    public Map<String, Collection<String>> listMappings() throws Exception {
+    public Map<String, Mappings> listMappings() throws Exception {
         return virtualUserTableProxy.getAllMappings();
     }
 
@@ -184,7 +185,7 @@ public class JmxServerProbe implements S
     }
 
     @Override
-    public Collection<String> listUserDomainMappings(String user, String 
domain) throws Exception {
+    public Mappings listUserDomainMappings(String user, String domain) throws 
Exception {
         return virtualUserTableProxy.getUserDomainMappings(user, domain);
     }
 

Modified: 
james/project/trunk/server/container/cli/src/test/java/org/apache/james/cli/ServerCmdTest.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/container/cli/src/test/java/org/apache/james/cli/ServerCmdTest.java?rev=1711974&r1=1711973&r2=1711974&view=diff
==============================================================================
--- 
james/project/trunk/server/container/cli/src/test/java/org/apache/james/cli/ServerCmdTest.java
 (original)
+++ 
james/project/trunk/server/container/cli/src/test/java/org/apache/james/cli/ServerCmdTest.java
 Mon Nov  2 13:43:21 2015
@@ -26,7 +26,6 @@ import static org.easymock.EasyMock.expe
 import static org.easymock.EasyMock.expectLastCall;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.HashMap;
 
 import org.apache.commons.cli.CommandLine;
@@ -39,6 +38,8 @@ import org.apache.james.cli.exceptions.U
 import org.apache.james.cli.probe.ServerProbe;
 import org.apache.james.cli.type.CmdType;
 import org.apache.james.mailbox.model.Quota;
+import org.apache.james.rrt.lib.Mappings;
+import org.apache.james.rrt.lib.MappingsImpl;
 import org.easymock.IMocksControl;
 import org.junit.Before;
 import org.junit.Test;
@@ -160,7 +161,7 @@ public class ServerCmdTest {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", 
CmdType.LISTMAPPINGS.getCommand()};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
-        expect(serverProbe.listMappings()).andReturn(new HashMap<String, 
Collection<String>>());
+        expect(serverProbe.listMappings()).andReturn(new HashMap<String, 
Mappings>());
 
         control.replay();
         testee.executeCommandLine(commandLine);
@@ -174,7 +175,7 @@ public class ServerCmdTest {
         String[] arguments = { "-h", "127.0.0.1", "-p", "9999", 
CmdType.LISTUSERDOMAINMAPPINGS.getCommand(), user, domain};
         CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
 
-        expect(serverProbe.listUserDomainMappings(user, domain)).andReturn(new 
ArrayList<String>());
+        expect(serverProbe.listUserDomainMappings(user, 
domain)).andReturn(MappingsImpl.empty());
 
         control.replay();
         testee.executeCommandLine(commandLine);

Modified: 
james/project/trunk/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java?rev=1711974&r1=1711973&r2=1711974&view=diff
==============================================================================
--- 
james/project/trunk/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java
 (original)
+++ 
james/project/trunk/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java
 Mon Nov  2 13:43:21 2015
@@ -21,6 +21,8 @@ package org.apache.james.rrt.api;
 import java.util.Collection;
 import java.util.Map;
 
+import org.apache.james.rrt.lib.Mappings;
+
 /**
  * Interface which should be implemented of classes which map recipients.
  */
@@ -57,7 +59,7 @@ public interface RecipientRewriteTable {
      *             get thrown if an error mapping was found
      * @throws RecipientRewriteTableException
      */
-    Collection<String> getMappings(String user, String domain) throws 
ErrorMappingException, RecipientRewriteTableException;
+    Mappings getMappings(String user, String domain) throws 
ErrorMappingException, RecipientRewriteTableException;
 
     /**
      * Add regex mapping
@@ -145,7 +147,7 @@ public interface RecipientRewriteTable {
      * @return the collection which holds the mappings.
      * @throws RecipientRewriteTableException
      */
-    Collection<String> getUserDomainMappings(String user, String domain) 
throws RecipientRewriteTableException;
+    Mappings getUserDomainMappings(String user, String domain) throws 
RecipientRewriteTableException;
 
     /**
      * Add mapping
@@ -180,7 +182,7 @@ public interface RecipientRewriteTable {
      * @return Map which holds all mappings
      * @throws RecipientRewriteTableException
      */
-    Map<String, Collection<String>> getAllMappings() throws 
RecipientRewriteTableException;
+    Map<String, Mappings> getAllMappings() throws 
RecipientRewriteTableException;
 
     /**
      * Add aliasDomain mapping

Modified: 
james/project/trunk/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTableManagementMBean.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTableManagementMBean.java?rev=1711974&r1=1711973&r2=1711974&view=diff
==============================================================================
--- 
james/project/trunk/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTableManagementMBean.java
 (original)
+++ 
james/project/trunk/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTableManagementMBean.java
 Mon Nov  2 13:43:21 2015
@@ -22,6 +22,8 @@ package org.apache.james.rrt.api;
 import java.util.Collection;
 import java.util.Map;
 
+import org.apache.james.rrt.lib.Mappings;
+
 /**
  * Expose virtualusertable management functionality through JMX.
  */
@@ -145,7 +147,7 @@ public interface RecipientRewriteTableMa
      * @throws Exception
      *            If an error occurred
      */
-    Collection<String> getUserDomainMappings(String user, String domain) 
throws Exception;
+    Mappings getUserDomainMappings(String user, String domain) throws 
Exception;
 
     /**
      * Try to identify the right method based on the prefix of the mapping and
@@ -185,5 +187,5 @@ public interface RecipientRewriteTableMa
      * @throws Exception
      *            If an error occurred
      */
-    Map<String, Collection<String>> getAllMappings() throws Exception;
+    Map<String, Mappings> getAllMappings() throws Exception;
 }

Added: 
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=1711974&view=auto
==============================================================================
--- 
james/project/trunk/server/data/data-api/src/main/java/org/apache/james/rrt/lib/Mappings.java
 (added)
+++ 
james/project/trunk/server/data/data-api/src/main/java/org/apache/james/rrt/lib/Mappings.java
 Mon Nov  2 13:43:21 2015
@@ -0,0 +1,46 @@
+/*
+ *   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.rrt.lib;
+
+import java.util.Collection;
+import java.util.List;
+
+public interface Mappings extends Iterable<String> {
+
+    Collection<String> getMappings();
+    
+    void addAll(Mappings toAdd);
+
+    void add(String mapping);
+
+    boolean contains(String mapping);
+
+    int size();
+
+    boolean remove(String mapping);
+
+    void addAll(List<String> target);
+
+    boolean isEmpty();
+
+    String[] toArray(String[] strings);
+
+}
\ No newline at end of file

Modified: 
james/project/trunk/server/data/data-file/src/main/java/org/apache/james/rrt/file/XMLRecipientRewriteTable.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/data/data-file/src/main/java/org/apache/james/rrt/file/XMLRecipientRewriteTable.java?rev=1711974&r1=1711973&r2=1711974&view=diff
==============================================================================
--- 
james/project/trunk/server/data/data-file/src/main/java/org/apache/james/rrt/file/XMLRecipientRewriteTable.java
 (original)
+++ 
james/project/trunk/server/data/data-file/src/main/java/org/apache/james/rrt/file/XMLRecipientRewriteTable.java
 Mon Nov  2 13:43:21 2015
@@ -18,17 +18,18 @@
  ****************************************************************/
 package org.apache.james.rrt.file;
 
-import com.google.common.collect.Maps;
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.HierarchicalConfiguration;
 import org.apache.james.rrt.api.RecipientRewriteTableException;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTable;
+import org.apache.james.rrt.lib.Mappings;
+import org.apache.james.rrt.lib.MappingsImpl;
 import org.apache.james.rrt.lib.RecipientRewriteTableUtil;
 
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
+import com.google.common.collect.Maps;
 
 /**
  * Class responsible to implement the Virtual User Table in XML disk file.
@@ -63,13 +64,13 @@ public class XMLRecipientRewriteTable ex
     }
 
     @Override
-    protected Collection<String> getUserDomainMappingsInternal(String user, 
String domain) throws RecipientRewriteTableException {
+    protected Mappings getUserDomainMappingsInternal(String user, String 
domain) throws RecipientRewriteTableException {
         if (mappings == null) {
             return null;
         } else {
             String maps = mappings.get(user + "@" + domain);
             if (maps != null) {
-                return RecipientRewriteTableUtil.mappingToCollection(maps);
+                return MappingsImpl.fromRawString(maps);
             } else {
                 return null;
             }
@@ -77,11 +78,11 @@ public class XMLRecipientRewriteTable ex
     }
 
     @Override
-    protected Map<String, Collection<String>> getAllMappingsInternal() throws 
RecipientRewriteTableException {
+    protected Map<String, Mappings> getAllMappingsInternal() throws 
RecipientRewriteTableException {
         if (mappings != null && mappings.size() > 0) {
-            Map<String, Collection<String>> mappingsNew = new HashMap<String, 
Collection<String>>();
+            Map<String, Mappings> mappingsNew = new HashMap<String, 
Mappings>();
             for (String key : mappings.keySet()) {
-                mappingsNew.put(key, 
RecipientRewriteTableUtil.mappingToCollection(mappings.get(key)));
+                mappingsNew.put(key, 
MappingsImpl.fromRawString(mappings.get(key)));
             }
             return mappingsNew;
         } else {

Modified: 
james/project/trunk/server/data/data-file/src/test/java/org/apache/james/rrt/file/XMLRecipientRewriteTableTest.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/data/data-file/src/test/java/org/apache/james/rrt/file/XMLRecipientRewriteTableTest.java?rev=1711974&r1=1711973&r2=1711974&view=diff
==============================================================================
--- 
james/project/trunk/server/data/data-file/src/test/java/org/apache/james/rrt/file/XMLRecipientRewriteTableTest.java
 (original)
+++ 
james/project/trunk/server/data/data-file/src/test/java/org/apache/james/rrt/file/XMLRecipientRewriteTableTest.java
 Mon Nov  2 13:43:21 2015
@@ -18,19 +18,20 @@
  ****************************************************************/
 package org.apache.james.rrt.file;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.apache.commons.configuration.DefaultConfigurationBuilder;
 import org.apache.james.rrt.api.RecipientRewriteTable;
 import org.apache.james.rrt.api.RecipientRewriteTableException;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTable;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTableTest;
+import org.apache.james.rrt.lib.Mappings;
+import org.apache.james.rrt.lib.MappingsImpl;
 import org.apache.james.rrt.lib.RecipientRewriteTableUtil;
 import org.junit.Before;
 import org.slf4j.LoggerFactory;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
 /**
  * Test the XML Virtual User Table implementation.
  */
@@ -56,10 +57,10 @@ public class XMLRecipientRewriteTableTes
     protected boolean addMapping(String user, String domain, String mapping, 
int type) throws
             RecipientRewriteTableException {
 
-        Collection<String> mappings = 
virtualUserTable.getUserDomainMappings(user, domain);
+        Mappings mappings = virtualUserTable.getUserDomainMappings(user, 
domain);
 
         if (mappings == null) {
-            mappings = new ArrayList<String>();
+            mappings = MappingsImpl.empty();
         } else {
             removeMappingsFromConfig(user, domain, mappings);
         }
@@ -93,7 +94,7 @@ public class XMLRecipientRewriteTableTes
     protected boolean removeMapping(String user, String domain, String 
mapping, int type) throws
             RecipientRewriteTableException {
 
-        Collection<String> mappings = 
virtualUserTable.getUserDomainMappings(user, domain);
+        Mappings mappings = virtualUserTable.getUserDomainMappings(user, 
domain);
 
         if (mappings == null) {
             return false;
@@ -124,7 +125,7 @@ public class XMLRecipientRewriteTableTes
         return true;
     }
 
-    private void removeMappingsFromConfig(String user, String domain, 
Collection<String> mappings) {
+    private void removeMappingsFromConfig(String user, String domain, Mappings 
mappings) {
         List<String> stored = new ArrayList<String>();
         for (String c : defaultConfiguration.getStringArray("mapping")) {
             String mapping = user + "@" + domain + "=" + 
RecipientRewriteTableUtil.CollectionToMapping(mappings);

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=1711974&r1=1711973&r2=1711974&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:43:21 2015
@@ -19,8 +19,6 @@
 package org.apache.james.rrt.hbase;
 
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -37,6 +35,8 @@ import org.apache.hadoop.hbase.util.Byte
 import org.apache.james.rrt.api.RecipientRewriteTableException;
 import org.apache.james.rrt.hbase.def.HRecipientRewriteTable;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTable;
+import org.apache.james.rrt.lib.Mappings;
+import org.apache.james.rrt.lib.MappingsImpl;
 import org.apache.james.rrt.lib.RecipientRewriteTableUtil;
 import org.apache.james.system.hbase.TablePool;
 import org.slf4j.Logger;
@@ -60,7 +60,7 @@ public class HBaseRecipientRewriteTable
     protected void addMappingInternal(String user, String domain, String 
mapping) throws RecipientRewriteTableException {
         String fixedUser = getFixedUser(user);
         String fixedDomain = getFixedDomain(domain);
-        Collection<String> map = getUserDomainMappings(fixedUser, fixedDomain);
+        Mappings map = getUserDomainMappings(fixedUser, fixedDomain);
         if (map != null && map.size() != 0) {
             map.add(mapping);
             doUpdateMapping(fixedUser, fixedDomain, 
RecipientRewriteTableUtil.CollectionToMapping(map));
@@ -73,10 +73,10 @@ public class HBaseRecipientRewriteTable
      * @see 
org.apache.james.rrt.lib.AbstractRecipientRewriteTable#getUserDomainMappingsInternal(String,
 String)
      */
     @Override
-    protected Collection<String> getUserDomainMappingsInternal(String user, 
String domain) throws
+    protected Mappings getUserDomainMappingsInternal(String user, String 
domain) throws
             RecipientRewriteTableException {
         HTableInterface table = null;
-        List<String> list = new ArrayList<String>();
+        Mappings list = MappingsImpl.empty();
         try {
             table = TablePool.getInstance().getRecipientRewriteTable();
             // Optimize this to only make one call.
@@ -96,14 +96,14 @@ public class HBaseRecipientRewriteTable
         return list;
     }
 
-    private void feedUserDomainMappingsList(HTableInterface table, String 
user, String domain, Collection<String> list) throws
+    private void 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(RecipientRewriteTableUtil.mappingToCollection(Bytes.toString(keyValues.get(0).getValue())));
+            
list.addAll(MappingsImpl.fromRawString(Bytes.toString(keyValues.get(0).getValue())));
         }
     }
 
@@ -111,10 +111,10 @@ public class HBaseRecipientRewriteTable
      * @see 
org.apache.james.rrt.lib.AbstractRecipientRewriteTable#getAllMappingsInternal()
      */
     @Override
-    protected Map<String, Collection<String>> getAllMappingsInternal() throws 
RecipientRewriteTableException {
+    protected Map<String, Mappings> getAllMappingsInternal() throws 
RecipientRewriteTableException {
         HTableInterface table = null;
         ResultScanner resultScanner = null;
-        Map<String, Collection<String>> map = null;
+        Map<String, Mappings> map = null;
         try {
             table = TablePool.getInstance().getRecipientRewriteTable();
             Scan scan = new Scan();
@@ -128,11 +128,11 @@ public class HBaseRecipientRewriteTable
                     for (KeyValue keyValue : keyValues) {
                         String email = Bytes.toString(keyValue.getRow());
                         if (map == null) {
-                            map = new HashMap<String, Collection<String>>();
+                            map = new HashMap<String, Mappings>();
                         }
-                        Collection<String> list = map.get(email);
+                        Mappings list = map.get(email);
                         if (list == null) {
-                            list = new ArrayList<String>();
+                            list = MappingsImpl.empty();
                         }
                         list.add(Bytes.toString(keyValue.getRow()));
                         map.put(email, list);
@@ -207,7 +207,7 @@ public class HBaseRecipientRewriteTable
             RecipientRewriteTableException {
         String fixedUser = getFixedUser(user);
         String fixedDomain = getFixedDomain(domain);
-        Collection<String> map = getUserDomainMappings(fixedUser, fixedDomain);
+        Mappings map = getUserDomainMappings(fixedUser, fixedDomain);
         if (map != null && map.size() > 1) {
             map.remove(mapping);
             doUpdateMapping(fixedUser, fixedDomain, 
RecipientRewriteTableUtil.CollectionToMapping(map));

Modified: 
james/project/trunk/server/data/data-jdbc/src/main/java/org/apache/james/rrt/jdbc/JDBCRecipientRewriteTable.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/data/data-jdbc/src/main/java/org/apache/james/rrt/jdbc/JDBCRecipientRewriteTable.java?rev=1711974&r1=1711973&r2=1711974&view=diff
==============================================================================
--- 
james/project/trunk/server/data/data-jdbc/src/main/java/org/apache/james/rrt/jdbc/JDBCRecipientRewriteTable.java
 (original)
+++ 
james/project/trunk/server/data/data-jdbc/src/main/java/org/apache/james/rrt/jdbc/JDBCRecipientRewriteTable.java
 Mon Nov  2 13:43:21 2015
@@ -25,7 +25,6 @@ import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -39,6 +38,8 @@ import org.apache.commons.configuration.
 import org.apache.james.filesystem.api.FileSystem;
 import org.apache.james.rrt.api.RecipientRewriteTableException;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTable;
+import org.apache.james.rrt.lib.Mappings;
+import org.apache.james.rrt.lib.MappingsImpl;
 import org.apache.james.rrt.lib.RecipientRewriteTableUtil;
 import org.apache.james.util.sql.JDBCUtil;
 import org.apache.james.util.sql.SqlResources;
@@ -206,7 +207,7 @@ public class JDBCRecipientRewriteTable e
     protected void addMappingInternal(String user, String domain, String 
regex) throws RecipientRewriteTableException {
         String fixedUser = getFixedUser(user);
         String fixedDomain = getFixedDomain(domain);
-        Collection<String> map = getUserDomainMappings(fixedUser, fixedDomain);
+        Mappings map = getUserDomainMappings(fixedUser, fixedDomain);
         if (map != null && map.size() != 0) {
             map.add(regex);
             doUpdateMapping(fixedUser, fixedDomain, 
RecipientRewriteTableUtil.CollectionToMapping(map));
@@ -252,7 +253,7 @@ public class JDBCRecipientRewriteTable e
      * @see 
org.apache.james.rrt.lib.AbstractRecipientRewriteTable#mapAddress(java.lang.String,
      *      java.lang.String)
      */
-    protected Collection<String> getUserDomainMappingsInternal(String user, 
String domain) throws RecipientRewriteTableException {
+    protected Mappings getUserDomainMappingsInternal(String user, String 
domain) throws RecipientRewriteTableException {
         Connection conn = null;
         PreparedStatement mappingStmt = null;
         try {
@@ -264,7 +265,7 @@ public class JDBCRecipientRewriteTable e
                 mappingStmt.setString(2, domain);
                 mappingRS = mappingStmt.executeQuery();
                 if (mappingRS.next()) {
-                    return 
RecipientRewriteTableUtil.mappingToCollection(mappingRS.getString(1));
+                    return MappingsImpl.fromRawString(mappingRS.getString(1));
                 }
             } finally {
                 theJDBCUtil.closeJDBCResultSet(mappingRS);
@@ -283,10 +284,10 @@ public class JDBCRecipientRewriteTable e
      * @throws RecipientRewriteTableException
      * @see 
org.apache.james.rrt.lib.AbstractRecipientRewriteTable#getAllMappingsInternal()
      */
-    protected Map<String, Collection<String>> getAllMappingsInternal() throws 
RecipientRewriteTableException {
+    protected Map<String, Mappings> getAllMappingsInternal() throws 
RecipientRewriteTableException {
         Connection conn = null;
         PreparedStatement mappingStmt = null;
-        Map<String, Collection<String>> mapping = new HashMap<String, 
Collection<String>>();
+        Map<String, Mappings> mapping = new HashMap<String, Mappings>();
         try {
             conn = dataSource.getConnection();
             mappingStmt = 
conn.prepareStatement(sqlQueries.getSqlString("selectAllMappings", true));
@@ -297,7 +298,7 @@ public class JDBCRecipientRewriteTable e
                     String user = mappingRS.getString(1);
                     String domain = mappingRS.getString(2);
                     String map = mappingRS.getString(3);
-                    mapping.put(user + "@" + domain, 
RecipientRewriteTableUtil.mappingToCollection(map));
+                    mapping.put(user + "@" + domain, 
MappingsImpl.fromRawString(map));
                 }
                 if (mapping.size() > 0)
                     return mapping;
@@ -323,7 +324,7 @@ public class JDBCRecipientRewriteTable e
     protected void removeMappingInternal(String user, String domain, String 
mapping) throws RecipientRewriteTableException {
         String fixedUser = getFixedUser(user);
         String fixedDomain = getFixedDomain(domain);
-        Collection<String> map = getUserDomainMappings(fixedUser, fixedDomain);
+        Mappings map = getUserDomainMappings(fixedUser, fixedDomain);
         if (map != null && map.size() > 1) {
             map.remove(mapping);
             doUpdateMapping(fixedUser, fixedDomain, 
RecipientRewriteTableUtil.CollectionToMapping(map));

Modified: 
james/project/trunk/server/data/data-jpa/src/main/java/org/apache/james/rrt/jpa/JPARecipientRewriteTable.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/data/data-jpa/src/main/java/org/apache/james/rrt/jpa/JPARecipientRewriteTable.java?rev=1711974&r1=1711973&r2=1711974&view=diff
==============================================================================
--- 
james/project/trunk/server/data/data-jpa/src/main/java/org/apache/james/rrt/jpa/JPARecipientRewriteTable.java
 (original)
+++ 
james/project/trunk/server/data/data-jpa/src/main/java/org/apache/james/rrt/jpa/JPARecipientRewriteTable.java
 Mon Nov  2 13:43:21 2015
@@ -18,7 +18,6 @@
  ****************************************************************/
 package org.apache.james.rrt.jpa;
 
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -32,6 +31,8 @@ import javax.persistence.PersistenceUnit
 import org.apache.james.rrt.api.RecipientRewriteTableException;
 import org.apache.james.rrt.jpa.model.JPARecipientRewrite;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTable;
+import org.apache.james.rrt.lib.Mappings;
+import org.apache.james.rrt.lib.MappingsImpl;
 import org.apache.james.rrt.lib.RecipientRewriteTableUtil;
 
 /**
@@ -62,7 +63,7 @@ public class JPARecipientRewriteTable ex
     protected void addMappingInternal(String user, String domain, String 
mapping) throws RecipientRewriteTableException {
         String fixedUser = getFixedUser(user);
         String fixedDomain = getFixedDomain(domain);
-        Collection<String> map = getUserDomainMappings(fixedUser, fixedDomain);
+        Mappings map = getUserDomainMappings(fixedUser, fixedDomain);
         if (map != null && map.size() != 0) {
             map.add(mapping);
             doUpdateMapping(fixedUser, fixedDomain, 
RecipientRewriteTableUtil.CollectionToMapping(map));
@@ -102,7 +103,7 @@ public class JPARecipientRewriteTable ex
      * @throws RecipientRewriteTableException
      * @see 
org.apache.james.rrt.lib.AbstractRecipientRewriteTable#mapAddress(java.lang.String,
 java.lang.String)
      */
-    protected Collection<String> getUserDomainMappingsInternal(String user, 
String domain) throws RecipientRewriteTableException {
+    protected Mappings getUserDomainMappingsInternal(String user, String 
domain) throws RecipientRewriteTableException {
         EntityManager entityManager = 
entityManagerFactory.createEntityManager();
         final EntityTransaction transaction = entityManager.getTransaction();
         try {
@@ -110,7 +111,7 @@ public class JPARecipientRewriteTable ex
             List<JPARecipientRewrite> virtualUsers = 
entityManager.createNamedQuery("selectUserDomainMapping").setParameter("user", 
user).setParameter("domain", domain).getResultList();
             transaction.commit();
             if (virtualUsers.size() > 0) {
-                return 
RecipientRewriteTableUtil.mappingToCollection(virtualUsers.get(0).getTargetAddress());
+                return 
MappingsImpl.fromRawString(virtualUsers.get(0).getTargetAddress());
             }
         } catch (PersistenceException e) {
             getLogger().debug("Failed to get user domain mappings", e);
@@ -129,16 +130,16 @@ public class JPARecipientRewriteTable ex
      * @throws RecipientRewriteTableException
      * @see 
org.apache.james.rrt.lib.AbstractRecipientRewriteTable#getAllMappingsInternal()
      */
-    protected Map<String, Collection<String>> getAllMappingsInternal() throws 
RecipientRewriteTableException {
+    protected Map<String, Mappings> getAllMappingsInternal() throws 
RecipientRewriteTableException {
         EntityManager entityManager = 
entityManagerFactory.createEntityManager();
         final EntityTransaction transaction = entityManager.getTransaction();
-        Map<String, Collection<String>> mapping = new HashMap<String, 
Collection<String>>();
+        Map<String, Mappings> mapping = new HashMap<String, Mappings>();
         try {
             transaction.begin();
             List<JPARecipientRewrite> virtualUsers = 
entityManager.createNamedQuery("selectAllMappings").getResultList();
             transaction.commit();
             for (JPARecipientRewrite virtualUser : virtualUsers) {
-                mapping.put(virtualUser.getUser() + "@" + 
virtualUser.getDomain(), 
RecipientRewriteTableUtil.mappingToCollection(virtualUser.getTargetAddress()));
+                mapping.put(virtualUser.getUser() + "@" + 
virtualUser.getDomain(), 
MappingsImpl.fromRawString(virtualUser.getTargetAddress()));
             }
             if (mapping.size() > 0)
                 return mapping;
@@ -162,7 +163,7 @@ public class JPARecipientRewriteTable ex
     protected void removeMappingInternal(String user, String domain, String 
mapping) throws RecipientRewriteTableException {
         String fixedUser = getFixedUser(user);
         String fixedDomain = getFixedDomain(domain);
-        Collection<String> map = getUserDomainMappings(fixedUser, fixedDomain);
+        Mappings map = getUserDomainMappings(fixedUser, fixedDomain);
         if (map != null && map.size() > 1) {
             map.remove(mapping);
             doUpdateMapping(fixedUser, fixedDomain, 
RecipientRewriteTableUtil.CollectionToMapping(map));

Modified: james/project/trunk/server/data/data-library/pom.xml
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/data/data-library/pom.xml?rev=1711974&r1=1711973&r2=1711974&view=diff
==============================================================================
--- james/project/trunk/server/data/data-library/pom.xml (original)
+++ james/project/trunk/server/data/data-library/pom.xml Mon Nov  2 13:43:21 
2015
@@ -78,11 +78,6 @@
 
         <!-- Test dependencies -->
         <dependency>
-            <groupId>com.google.guava</groupId>
-            <artifactId>guava</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>info.cukes</groupId>
             <artifactId>cucumber-java</artifactId>
             <scope>test</scope>

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=1711974&r1=1711973&r2=1711974&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:43:21 2015
@@ -19,7 +19,6 @@
 package org.apache.james.rrt.lib;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -112,11 +111,11 @@ public abstract class AbstractRecipientR
      * @see org.apache.james.rrt.api.RecipientRewriteTable#getMappings(String,
      *      String)
      */
-    public Collection<String> getMappings(String user, String domain) throws 
ErrorMappingException, RecipientRewriteTableException {
+    public Mappings getMappings(String user, String domain) throws 
ErrorMappingException, RecipientRewriteTableException {
         return getMappings(user, domain, mappingLimit);
     }
 
-    public Collection<String> getMappings(String user, String domain, int 
mappingLimit) throws ErrorMappingException, RecipientRewriteTableException {
+    public Mappings getMappings(String user, String domain, int mappingLimit) 
throws ErrorMappingException, RecipientRewriteTableException {
 
         // We have to much mappings throw ErrorMappingException to avoid
         // infinity loop
@@ -127,13 +126,13 @@ public abstract class AbstractRecipientR
 
         // Only non-null mappings are translated
         if (targetString != null) {
-            Collection<String> mappings = new ArrayList<String>();
+            Mappings mappings = MappingsImpl.empty();
             if (targetString.startsWith(RecipientRewriteTable.ERROR_PREFIX)) {
                 throw new 
ErrorMappingException(targetString.substring(RecipientRewriteTable.ERROR_PREFIX.length()));
 
             } else {
 
-                for (String target : 
RecipientRewriteTableUtil.mappingToCollection(targetString)) {
+                for (String target : MappingsImpl.fromRawString(targetString)) 
{
                     if (target.startsWith(RecipientRewriteTable.REGEX_PREFIX)) 
{
                         try {
                             target = RecipientRewriteTableUtil.regexMap(new 
MailAddress(user, domain), target);
@@ -175,7 +174,7 @@ public abstract class AbstractRecipientR
                             return null;
                         }
 
-                        Collection<String> childMappings = 
getMappings(userName, domainName, mappingLimit - 1);
+                        Mappings childMappings = getMappings(userName, 
domainName, mappingLimit - 1);
 
                         if (childMappings == null) {
                             // add mapping
@@ -329,9 +328,9 @@ public abstract class AbstractRecipientR
     /**
      * @see org.apache.james.rrt.api.RecipientRewriteTable#getAllMappings()
      */
-    public Map<String, Collection<String>> getAllMappings() throws 
RecipientRewriteTableException {
+    public Map<String, Mappings> getAllMappings() throws 
RecipientRewriteTableException {
         int count = 0;
-        Map<String, Collection<String>> mappings = getAllMappingsInternal();
+        Map<String, Mappings> mappings = getAllMappingsInternal();
 
         if (mappings != null) {
             count = mappings.size();
@@ -344,7 +343,7 @@ public abstract class AbstractRecipientR
      * @see 
org.apache.james.rrt.api.RecipientRewriteTable#getUserDomainMappings(java.lang.String,
      *      java.lang.String)
      */
-    public Collection<String> getUserDomainMappings(String user, String 
domain) throws RecipientRewriteTableException {
+    public Mappings getUserDomainMappings(String user, String domain) throws 
RecipientRewriteTableException {
         return getUserDomainMappingsInternal(user, domain);
     }
 
@@ -405,14 +404,14 @@ public abstract class AbstractRecipientR
      *            the domain
      * @return Collection which hold the mappings
      */
-    protected abstract Collection<String> getUserDomainMappingsInternal(String 
user, String domain) throws RecipientRewriteTableException;
+    protected abstract Mappings getUserDomainMappingsInternal(String user, 
String domain) throws RecipientRewriteTableException;
 
     /**
      * Return a Map which holds all Mappings
      * 
      * @return Map
      */
-    protected abstract Map<String, Collection<String>> 
getAllMappingsInternal() throws RecipientRewriteTableException;
+    protected abstract Map<String, Mappings> getAllMappingsInternal() throws 
RecipientRewriteTableException;
 
     /**
      * Override to map virtual recipients to real recipients, both local and
@@ -452,7 +451,7 @@ public abstract class AbstractRecipientR
         // check if we need to sort
         // TODO: Maybe we should just return the aliasdomain mapping
         if (mappings != null && 
mappings.contains(RecipientRewriteTable.ALIASDOMAIN_PREFIX)) {
-            Collection<String> mapCol = 
RecipientRewriteTableUtil.mappingToCollection(mappings);
+            Mappings mapCol = MappingsImpl.fromRawString(mappings);
             Iterator<String> mapIt = mapCol.iterator();
 
             List<String> col = new ArrayList<String>(mapCol.size());
@@ -475,7 +474,7 @@ public abstract class AbstractRecipientR
     }
 
     private void checkMapping(String user, String domain, String mapping) 
throws RecipientRewriteTableException {
-        Collection<String> mappings = getUserDomainMappings(user, domain);
+        Mappings mappings = getUserDomainMappings(user, domain);
         if (mappings != null && mappings.contains(mapping)) {
             throw new RecipientRewriteTableException("Mapping " + mapping + " 
for user " + user + " domain " + domain + " already exist!");
         }

Added: 
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=1711974&view=auto
==============================================================================
--- 
james/project/trunk/server/data/data-library/src/main/java/org/apache/james/rrt/lib/MappingsImpl.java
 (added)
+++ 
james/project/trunk/server/data/data-library/src/main/java/org/apache/james/rrt/lib/MappingsImpl.java
 Mon Nov  2 13:43:21 2015
@@ -0,0 +1,108 @@
+/*
+ *   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.rrt.lib;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+
+public class MappingsImpl implements Mappings {
+
+    public static MappingsImpl empty() {
+        return new MappingsImpl(new ArrayList<String>());
+    }
+    
+    public static MappingsImpl fromRawString(String raw) {
+        return new MappingsImpl(mappingToCollection(raw));
+    }
+    
+    private static ArrayList<String> mappingToCollection(String rawMapping) {
+        ArrayList<String> map = new ArrayList<String>();
+        StringTokenizer tokenizer = new StringTokenizer(rawMapping, 
RecipientRewriteTableUtil.getSeparator(rawMapping));
+        while (tokenizer.hasMoreTokens()) {
+            final String raw = tokenizer.nextToken().trim();
+            map.add(raw);
+        }
+        return map;
+    }
+    
+    public static Mappings fromCollection(Collection<String> mappings) {
+        return new MappingsImpl(mappings);
+    }
+    
+    private final Collection<String> mappings;
+
+    private MappingsImpl(Collection<String> mappings) {
+        this.mappings = mappings;
+    }
+    
+    @Override
+    public Iterator<String> iterator() {
+        return mappings.iterator();
+    }
+
+    @Override
+    public Collection<String> getMappings() {
+        return mappings;
+    }
+    
+    @Override
+    public void addAll(Mappings toAdd) {
+        mappings.addAll(toAdd.getMappings());
+    }
+
+    @Override
+    public void add(String mapping) {
+       mappings.add(mapping); 
+    }
+
+    @Override
+    public boolean contains(String mapping) {
+        return mappings.contains(mapping);
+    }
+
+    @Override
+    public int size() {
+        return mappings.size();
+    }
+
+    @Override
+    public boolean remove(String mapping) {
+        return mappings.remove(mapping);
+    }
+
+    public void addAll(List<String> target) {
+        mappings.addAll(target);
+    }
+
+    @Override
+    public boolean isEmpty() {
+        return mappings.isEmpty();
+    }
+
+    @Override
+    public String[] toArray(String[] strings) {
+        return mappings.toArray(strings);
+    }
+
+}
\ No newline at end of file

Modified: 
james/project/trunk/server/data/data-library/src/main/java/org/apache/james/rrt/lib/RecipientRewriteTableManagement.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/data/data-library/src/main/java/org/apache/james/rrt/lib/RecipientRewriteTableManagement.java?rev=1711974&r1=1711973&r2=1711974&view=diff
==============================================================================
--- 
james/project/trunk/server/data/data-library/src/main/java/org/apache/james/rrt/lib/RecipientRewriteTableManagement.java
 (original)
+++ 
james/project/trunk/server/data/data-library/src/main/java/org/apache/james/rrt/lib/RecipientRewriteTableManagement.java
 Mon Nov  2 13:43:21 2015
@@ -18,7 +18,6 @@
  ****************************************************************/
 package org.apache.james.rrt.lib;
 
-import java.util.Collection;
 import java.util.Map;
 
 import javax.annotation.Resource;
@@ -146,7 +145,7 @@ public class RecipientRewriteTableManage
      * @see org.apache.james.rrt.api.RecipientRewriteTableManagementMBean
      * #getUserDomainMappings(java.lang.String, java.lang.String)
      */
-    public Collection<String> getUserDomainMappings(String user, String 
domain) throws Exception {
+    public Mappings getUserDomainMappings(String user, String domain) throws 
Exception {
         try {
             return rrt.getUserDomainMappings(user, domain);
         } catch (RecipientRewriteTableException e) {
@@ -184,7 +183,7 @@ public class RecipientRewriteTableManage
      * @see
      * 
org.apache.james.rrt.api.RecipientRewriteTableManagementMBean#getAllMappings()
      */
-    public Map<String, Collection<String>> getAllMappings() throws Exception {
+    public Map<String, Mappings> getAllMappings() throws Exception {
         try {
             return rrt.getAllMappings();
         } catch (RecipientRewriteTableException e) {

Modified: 
james/project/trunk/server/data/data-library/src/main/java/org/apache/james/rrt/lib/RecipientRewriteTableUtil.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/data/data-library/src/main/java/org/apache/james/rrt/lib/RecipientRewriteTableUtil.java?rev=1711974&r1=1711973&r2=1711974&view=diff
==============================================================================
--- 
james/project/trunk/server/data/data-library/src/main/java/org/apache/james/rrt/lib/RecipientRewriteTableUtil.java
 (original)
+++ 
james/project/trunk/server/data/data-library/src/main/java/org/apache/james/rrt/lib/RecipientRewriteTableUtil.java
 Mon Nov  2 13:43:21 2015
@@ -212,41 +212,13 @@ public class RecipientRewriteTableUtil {
     }
 
     /**
-     * Return a Collection which holds the extracted mappings of the given
-     * String
-     * 
-     * @param rawMapping
-     * @deprecated Use mappingToCollection(String rawMapping)
-     */
-    public static Collection<String> getMappings(String rawMapping) {
-        return mappingToCollection(rawMapping);
-    }
-
-    /**
-     * Convert a raw mapping String to a Collection
-     * 
-     * @param rawMapping
-     *            the mapping String
-     * @return map a collection which holds all mappings
-     */
-    public static ArrayList<String> mappingToCollection(String rawMapping) {
-        ArrayList<String> map = new ArrayList<String>();
-        StringTokenizer tokenizer = new StringTokenizer(rawMapping, 
RecipientRewriteTableUtil.getSeparator(rawMapping));
-        while (tokenizer.hasMoreTokens()) {
-            final String raw = tokenizer.nextToken().trim();
-            map.add(raw);
-        }
-        return map;
-    }
-
-    /**
      * Convert a Collection which holds mappings to a raw mapping String
      * 
      * @param map
      *            the Collection
      * @return mapping the mapping String
      */
-    public static String CollectionToMapping(Collection<String> map) {
+    public static String CollectionToMapping(Iterable<String> map) {
         return Joiner.on(';').join(map);
     }
 

Modified: 
james/project/trunk/server/data/data-library/src/main/java/org/apache/james/user/lib/AbstractJamesUsersRepository.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/data/data-library/src/main/java/org/apache/james/user/lib/AbstractJamesUsersRepository.java?rev=1711974&r1=1711973&r2=1711974&view=diff
==============================================================================
--- 
james/project/trunk/server/data/data-library/src/main/java/org/apache/james/user/lib/AbstractJamesUsersRepository.java
 (original)
+++ 
james/project/trunk/server/data/data-library/src/main/java/org/apache/james/user/lib/AbstractJamesUsersRepository.java
 Mon Nov  2 13:43:21 2015
@@ -19,10 +19,16 @@
 
 package org.apache.james.user.lib;
 
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.HierarchicalConfiguration;
 import org.apache.james.rrt.api.RecipientRewriteTable;
 import org.apache.james.rrt.api.RecipientRewriteTableException;
+import org.apache.james.rrt.lib.Mappings;
+import org.apache.james.rrt.lib.MappingsImpl;
 import org.apache.james.user.api.JamesUsersRepository;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.api.UsersRepositoryException;
@@ -30,12 +36,6 @@ import org.apache.james.user.api.model.J
 import org.apache.james.user.api.model.User;
 import org.apache.james.user.lib.model.DefaultJamesUser;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
 /**
  * A partial implementation of a Repository to store users.
  * <p>
@@ -120,8 +120,8 @@ public abstract class AbstractJamesUsers
      * @see 
org.apache.james.rrt.api.RecipientRewriteTable#getMappings(java.lang.String,
      *      java.lang.String)
      */
-    public Collection<String> getMappings(String username, String domain) 
throws ErrorMappingException, RecipientRewriteTableException {
-        Collection<String> mappings = new ArrayList<String>();
+    public Mappings getMappings(String username, String domain) throws 
ErrorMappingException, RecipientRewriteTableException {
+        MappingsImpl mappings = MappingsImpl.empty();
         try {
             User user = getUserByName(username);
 
@@ -179,8 +179,8 @@ public abstract class AbstractJamesUsers
     /**
      * @see org.apache.james.rrt.api.RecipientRewriteTable#getAllMappings()
      */
-    public Map<String, Collection<String>> getAllMappings() throws 
RecipientRewriteTableException {
-        Map<String, Collection<String>> mappings = new HashMap<String, 
Collection<String>>();
+    public Map<String, Mappings> getAllMappings() throws 
RecipientRewriteTableException {
+        Map<String, Mappings> mappings = new HashMap<String, Mappings>();
         if (enableAliases || enableForwarding) {
             try {
                 Iterator<String> users = list();
@@ -214,8 +214,8 @@ public abstract class AbstractJamesUsers
      * @see
      * 
org.apache.james.rrt.api.RecipientRewriteTable#getUserDomainMappings(java.lang.String,
 java.lang.String)
      */
-    public Collection<String> getUserDomainMappings(String user, String 
domain) throws RecipientRewriteTableException {
-        return new ArrayList<String>();
+    public Mappings getUserDomainMappings(String user, String domain) throws 
RecipientRewriteTableException {
+        return MappingsImpl.empty();
     }
 
     public void addRegexMapping(String user, String domain, String regex) 
throws RecipientRewriteTableException {

Modified: 
james/project/trunk/server/data/data-library/src/test/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTableTest.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/data/data-library/src/test/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTableTest.java?rev=1711974&r1=1711973&r2=1711974&view=diff
==============================================================================
--- 
james/project/trunk/server/data/data-library/src/test/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTableTest.java
 (original)
+++ 
james/project/trunk/server/data/data-library/src/test/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTableTest.java
 Mon Nov  2 13:43:21 2015
@@ -24,7 +24,6 @@ import static org.junit.Assert.assertTru
 import static org.junit.Assert.fail;
 
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.Iterator;
 import java.util.Map;
 
@@ -57,14 +56,14 @@ public abstract class AbstractRecipientR
     @After
     public void tearDown() throws Exception {
 
-        Map<String, Collection<String>> mappings = 
virtualUserTable.getAllMappings();
+        Map<String, Mappings> mappings = virtualUserTable.getAllMappings();
 
         if (mappings != null) {
 
             for (String key : virtualUserTable.getAllMappings().keySet()) {
                 String args[] = key.split("@");
 
-                Collection<String> map = mappings.get(key);
+                Mappings map = mappings.get(key);
 
                 for (String aMap : map) {
                     try {

Added: 
james/project/trunk/server/data/data-library/src/test/java/org/apache/james/rrt/lib/MappingsImplTest.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/data/data-library/src/test/java/org/apache/james/rrt/lib/MappingsImplTest.java?rev=1711974&view=auto
==============================================================================
--- 
james/project/trunk/server/data/data-library/src/test/java/org/apache/james/rrt/lib/MappingsImplTest.java
 (added)
+++ 
james/project/trunk/server/data/data-library/src/test/java/org/apache/james/rrt/lib/MappingsImplTest.java
 Mon Nov  2 13:43:21 2015
@@ -0,0 +1,123 @@
+/*
+ *   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.rrt.lib;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.junit.Test;
+
+
+public class MappingsImplTest {
+
+    @Test(expected=NullPointerException.class)
+    public void fromRawStringShouldThrowWhenNull() {
+        MappingsImpl.fromRawString(null);
+    }
+
+    @Test
+    public void fromRawStringShouldReturnEmptyCollectionWhenEmptyString() {
+        MappingsImpl actual = MappingsImpl.fromRawString("");
+        assertThat(actual).isEmpty();
+    }
+    
+    @Test
+    public void 
fromRawStringShouldReturnSingletonCollectionWhenSingleElementString() {
+        MappingsImpl actual = MappingsImpl.fromRawString("value");
+        assertThat(actual).containsExactly("value");
+    }
+
+    @Test
+    public void fromRawStringShouldReturnCollectionWhenSeveralElementsString() 
{
+        MappingsImpl actual = MappingsImpl.fromRawString("value1;value2");
+        assertThat(actual).containsExactly("value1", "value2");
+    }
+    
+    @Test
+    public void 
fromRawStringShouldReturnSingleElementCollectionWhenTrailingDelimiterString() {
+        MappingsImpl actual = MappingsImpl.fromRawString("value1;");
+        assertThat(actual).containsExactly("value1");
+    }
+
+    @Test
+    public void 
fromRawStringShouldReturnSingleElementCollectionWhenHeadingDelimiterString() {
+        MappingsImpl actual = MappingsImpl.fromRawString(";value1");
+        assertThat(actual).containsExactly("value1");
+    }
+    
+
+    @Test
+    public void fromRawStringShouldTrimValues() {
+        MappingsImpl actual = MappingsImpl.fromRawString("value1 ; value2  ");
+        assertThat(actual).containsExactly("value1", "value2");
+    }
+    
+    @Test
+    public void fromRawStringShouldNotSkipEmptyValue() {
+        MappingsImpl actual = MappingsImpl.fromRawString("value1; ;value2");
+        assertThat(actual).containsExactly("value1", "", "value2");
+    }
+    
+    @Test
+    public void 
fromRawStringShouldReturnCollectionWhenValueContainsCommaSeperatedValues() {
+        MappingsImpl actual = MappingsImpl.fromRawString("value1,value2");
+        assertThat(actual).containsExactly("value1","value2");
+    }
+
+    @Test
+    public void 
fromRawStringShouldReturnCollectionWhenValueContainsColonSeperatedValues() {
+        MappingsImpl actual = MappingsImpl.fromRawString("value1:value2");
+        assertThat(actual).containsExactly("value1","value2");
+    }
+
+    @Test
+    public void 
fromRawStringShouldUseCommaDelimiterBeforeSemicolonWhenValueContainsBoth() {
+        MappingsImpl actual = 
MappingsImpl.fromRawString("value1;value1,value2");
+        assertThat(actual).containsExactly("value1;value1","value2");
+    }
+
+    @Test
+    public void 
fromRawStringShouldUseSemicolonDelimiterBeforeColonWhenValueContainsBoth() {
+        MappingsImpl actual = 
MappingsImpl.fromRawString("value1:value1;value2");
+        assertThat(actual).containsExactly("value1:value1","value2");
+    }
+    
+    @Test
+    public void 
fromRawStringShouldNotUseColonDelimiterWhenValueStartsWithError() {
+        MappingsImpl actual = MappingsImpl.fromRawString("error:test");
+        assertThat(actual).containsExactly("error:test");
+    }
+    
+
+    @Test
+    public void 
fromRawStringShouldNotUseColonDelimiterWhenValueStartsWithDomain() {
+        MappingsImpl actual = MappingsImpl.fromRawString("domain:test");
+        assertThat(actual).containsExactly("domain:test");
+    }
+    
+
+    @Test
+    public void 
fromRawStringShouldNotUseColonDelimiterWhenValueStartsWithRegex() {
+        MappingsImpl actual = MappingsImpl.fromRawString("regex:test");
+        assertThat(actual).containsExactly("regex:test");
+    }
+
+    
+}

Modified: 
james/project/trunk/server/data/data-library/src/test/java/org/apache/james/rrt/lib/RecipientRewriteTableUtilTest.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/data/data-library/src/test/java/org/apache/james/rrt/lib/RecipientRewriteTableUtilTest.java?rev=1711974&r1=1711973&r2=1711974&view=diff
==============================================================================
--- 
james/project/trunk/server/data/data-library/src/test/java/org/apache/james/rrt/lib/RecipientRewriteTableUtilTest.java
 (original)
+++ 
james/project/trunk/server/data/data-library/src/test/java/org/apache/james/rrt/lib/RecipientRewriteTableUtilTest.java
 Mon Nov  2 13:43:21 2015
@@ -2,8 +2,6 @@ package org.apache.james.rrt.lib;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
-import java.util.List;
-
 import org.junit.Test;
 
 import com.google.common.collect.ImmutableList;
@@ -33,96 +31,4 @@ public class RecipientRewriteTableUtilTe
         assertThat(actual).isEqualTo("value1;value2");
     }
     
-    @Test(expected=NullPointerException.class)
-    public void mappingToCollectionShouldThrowWhenNull() {
-        RecipientRewriteTableUtil.mappingToCollection(null);
-    }
-
-    @Test
-    public void 
mappingToCollectionShouldReturnEmptyCollectionWhenEmptyString() {
-        List<String> actual = 
RecipientRewriteTableUtil.mappingToCollection("");
-        assertThat(actual).isEmpty();
-    }
-    
-    @Test
-    public void 
mappingToCollectionShouldReturnSingletonCollectionWhenSingleElementString() {
-        List<String> actual = 
RecipientRewriteTableUtil.mappingToCollection("value");
-        assertThat(actual).containsExactly("value");
-    }
-
-    @Test
-    public void 
mappingToCollectionShouldReturnCollectionWhenSeveralElementsString() {
-        List<String> actual = 
RecipientRewriteTableUtil.mappingToCollection("value1;value2");
-        assertThat(actual).containsExactly("value1", "value2");
-    }
-    
-    @Test
-    public void 
mappingToCollectionShouldReturnSingleElementCollectionWhenTrailingDelimiterString()
 {
-        List<String> actual = 
RecipientRewriteTableUtil.mappingToCollection("value1;");
-        assertThat(actual).containsExactly("value1");
-    }
-
-    @Test
-    public void 
mappingToCollectionShouldReturnSingleElementCollectionWhenHeadingDelimiterString()
 {
-        List<String> actual = 
RecipientRewriteTableUtil.mappingToCollection(";value1");
-        assertThat(actual).containsExactly("value1");
-    }
-    
-
-    @Test
-    public void mappingToCollectionShouldTrimValues() {
-        List<String> actual = 
RecipientRewriteTableUtil.mappingToCollection("value1 ; value2  ");
-        assertThat(actual).containsExactly("value1", "value2");
-    }
-    
-    @Test
-    public void mappingToCollectionShouldNotSkipEmptyValue() {
-        List<String> actual = 
RecipientRewriteTableUtil.mappingToCollection("value1; ;value2");
-        assertThat(actual).containsExactly("value1", "", "value2");
-    }
-    
-    @Test
-    public void 
mappingToCollectionShouldReturnCollectionWhenValueContainsCommaSeperatedValues()
 {
-        List<String> actual = 
RecipientRewriteTableUtil.mappingToCollection("value1,value2");
-        assertThat(actual).containsExactly("value1","value2");
-    }
-
-    @Test
-    public void 
mappingToCollectionShouldReturnCollectionWhenValueContainsColonSeperatedValues()
 {
-        List<String> actual = 
RecipientRewriteTableUtil.mappingToCollection("value1:value2");
-        assertThat(actual).containsExactly("value1","value2");
-    }
-
-    @Test
-    public void 
mappingToCollectionShouldUseCommaDelimiterBeforeSemicolonWhenValueContainsBoth()
 {
-        List<String> actual = 
RecipientRewriteTableUtil.mappingToCollection("value1;value1,value2");
-        assertThat(actual).containsExactly("value1;value1","value2");
-    }
-
-    @Test
-    public void 
mappingToCollectionShouldUseSemicolonDelimiterBeforeColonWhenValueContainsBoth()
 {
-        List<String> actual = 
RecipientRewriteTableUtil.mappingToCollection("value1:value1;value2");
-        assertThat(actual).containsExactly("value1:value1","value2");
-    }
-    
-    @Test
-    public void 
mappingToCollectionShouldNotUseColonDelimiterWhenValueStartsWithError() {
-        List<String> actual = 
RecipientRewriteTableUtil.mappingToCollection("error:test");
-        assertThat(actual).containsExactly("error:test");
-    }
-    
-
-    @Test
-    public void 
mappingToCollectionShouldNotUseColonDelimiterWhenValueStartsWithDomain() {
-        List<String> actual = 
RecipientRewriteTableUtil.mappingToCollection("domain:test");
-        assertThat(actual).containsExactly("domain:test");
-    }
-    
-
-    @Test
-    public void 
mappingToCollectionShouldNotUseColonDelimiterWhenValueStartsWithRegex() {
-        List<String> actual = 
RecipientRewriteTableUtil.mappingToCollection("regex:test");
-        assertThat(actual).containsExactly("regex:test");
-    }
-
 }

Modified: 
james/project/trunk/server/data/data-library/src/test/java/org/apache/james/rrt/lib/mock/MockRecipientRewriteTableManagementImpl.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/data/data-library/src/test/java/org/apache/james/rrt/lib/mock/MockRecipientRewriteTableManagementImpl.java?rev=1711974&r1=1711973&r2=1711974&view=diff
==============================================================================
--- 
james/project/trunk/server/data/data-library/src/test/java/org/apache/james/rrt/lib/mock/MockRecipientRewriteTableManagementImpl.java
 (original)
+++ 
james/project/trunk/server/data/data-library/src/test/java/org/apache/james/rrt/lib/mock/MockRecipientRewriteTableManagementImpl.java
 Mon Nov  2 13:43:21 2015
@@ -18,12 +18,13 @@
  ****************************************************************/
 package org.apache.james.rrt.lib.mock;
 
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.james.rrt.api.RecipientRewriteTable;
 import org.apache.james.rrt.api.RecipientRewriteTableException;
+import org.apache.james.rrt.lib.Mappings;
+import org.apache.james.rrt.lib.MappingsImpl;
 import org.apache.james.rrt.lib.RecipientRewriteTableUtil;
 
 public class MockRecipientRewriteTableManagementImpl implements 
RecipientRewriteTable {
@@ -66,10 +67,10 @@ public class MockRecipientRewriteTableMa
     }
 
     @Override
-    public Collection getUserDomainMappings(String user, String domain) throws 
RecipientRewriteTableException {
+    public Mappings getUserDomainMappings(String user, String domain) throws 
RecipientRewriteTableException {
         String mapping = (String) store.get(user + "@" + domain);
         if (mapping != null) {
-            return RecipientRewriteTableUtil.mappingToCollection(mapping);
+            return MappingsImpl.fromRawString(mapping);
         } else {
             return null;
         }
@@ -102,18 +103,18 @@ public class MockRecipientRewriteTableMa
     }
 
     @Override
-    public Collection<String> getMappings(String user, String domain) throws 
ErrorMappingException,
+    public Mappings getMappings(String user, String domain) throws 
ErrorMappingException,
             RecipientRewriteTableException {
         throw new UnsupportedOperationException("Not implemented yet");
     }
 
     private void addRawMapping(String user, String domain, String mapping) 
throws RecipientRewriteTableException {
-        Collection map;
+        MappingsImpl map;
         String key = user + "@" + domain;
         String mappings = (String) store.get(key);
 
         if (mappings != null) {
-            map = RecipientRewriteTableUtil.mappingToCollection(mappings);
+            map = MappingsImpl.fromRawString(mappings);
 
             if (map.contains(mapping)) {
                 throw new RecipientRewriteTableException("Mapping " + mapping 
+ " already exist!");
@@ -127,11 +128,11 @@ public class MockRecipientRewriteTableMa
     }
 
     private void removeRawMapping(String user, String domain, String mapping) 
throws RecipientRewriteTableException {
-        Collection map;
+        MappingsImpl map;
         String key = user + "@" + domain;
         String mappings = (String) store.get(key);
         if (mappings != null) {
-            map = RecipientRewriteTableUtil.mappingToCollection(mappings);
+            map = MappingsImpl.fromRawString(mappings);
             if (map.remove(mapping)) {
                 store.put(key, 
RecipientRewriteTableUtil.CollectionToMapping(map));
             }

Modified: 
james/project/trunk/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/AbstractRecipientRewriteTableMailet.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/AbstractRecipientRewriteTableMailet.java?rev=1711974&r1=1711973&r2=1711974&view=diff
==============================================================================
--- 
james/project/trunk/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/AbstractRecipientRewriteTableMailet.java
 (original)
+++ 
james/project/trunk/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/AbstractRecipientRewriteTableMailet.java
 Mon Nov  2 13:43:21 2015
@@ -31,6 +31,7 @@ import javax.mail.internet.MimeMessage;
 
 import org.apache.james.domainlist.api.DomainList;
 import org.apache.james.domainlist.api.DomainListException;
+import org.apache.james.rrt.lib.Mappings;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
 import org.apache.mailet.base.GenericMailet;
@@ -123,7 +124,7 @@ public abstract class AbstractRecipientR
      * 
      * @throws MessagingException
      */
-    protected Collection<MailAddress> handleMappings(Collection<String> 
mappings, MailAddress sender, MailAddress recipient, MimeMessage message) 
throws MessagingException {
+    protected Collection<MailAddress> handleMappings(Mappings mappings, 
MailAddress sender, MailAddress recipient, MimeMessage message) throws 
MessagingException {
         Iterator<String> i = mappings.iterator();
         Collection<MailAddress> remoteRecipients = new 
ArrayList<MailAddress>();
         Collection<MailAddress> localRecipients = new ArrayList<MailAddress>();

Modified: 
james/project/trunk/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTable.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTable.java?rev=1711974&r1=1711973&r2=1711974&view=diff
==============================================================================
--- 
james/project/trunk/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTable.java
 (original)
+++ 
james/project/trunk/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTable.java
 Mon Nov  2 13:43:21 2015
@@ -28,6 +28,7 @@ import javax.mail.internet.MimeMessage;
 
 import org.apache.james.rrt.api.RecipientRewriteTable.ErrorMappingException;
 import org.apache.james.rrt.api.RecipientRewriteTableException;
+import org.apache.james.rrt.lib.Mappings;
 import org.apache.mailet.MailAddress;
 
 /**
@@ -53,7 +54,7 @@ public class RecipientRewriteTable exten
      */
     public Collection<MailAddress> processMail(MailAddress sender, MailAddress 
recipient, MimeMessage message) throws MessagingException {
         try {
-            Collection<String> mappings = 
vut.getMappings(recipient.getLocalPart(), recipient.getDomain());
+            Mappings mappings = vut.getMappings(recipient.getLocalPart(), 
recipient.getDomain());
 
             if (mappings != null) {
                 return handleMappings(mappings, sender, recipient, message);

Modified: 
james/project/trunk/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/UsersRepositoryAliasingForwarding.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/UsersRepositoryAliasingForwarding.java?rev=1711974&r1=1711973&r2=1711974&view=diff
==============================================================================
--- 
james/project/trunk/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/UsersRepositoryAliasingForwarding.java
 (original)
+++ 
james/project/trunk/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/UsersRepositoryAliasingForwarding.java
 Mon Nov  2 13:43:21 2015
@@ -29,6 +29,7 @@ import javax.mail.internet.MimeMessage;
 import org.apache.james.rrt.api.RecipientRewriteTable;
 import org.apache.james.rrt.api.RecipientRewriteTable.ErrorMappingException;
 import org.apache.james.rrt.api.RecipientRewriteTableException;
+import org.apache.james.rrt.lib.Mappings;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.mailet.MailAddress;
 
@@ -88,7 +89,7 @@ public class UsersRepositoryAliasingForw
         }
 
         if (usersRepository instanceof RecipientRewriteTable) {
-            Collection<String> mappings;
+            Mappings mappings;
             try {
                 mappings = ((RecipientRewriteTable) 
usersRepository).getMappings(recipient.getLocalPart(), recipient.getDomain());
             } catch (ErrorMappingException e) {

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=1711974&r1=1711973&r2=1711974&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:43:21 2015
@@ -19,6 +19,8 @@
 package org.apache.james.transport.mailets;
 
 import org.apache.james.rrt.api.RecipientRewriteTableException;
+import org.apache.james.rrt.lib.Mappings;
+import org.apache.james.rrt.lib.MappingsImpl;
 
 import java.util.*;
 
@@ -74,8 +76,8 @@ public class RecipientRewriteTableMock i
     }
 
     @Override
-    public Collection<String> getMappings(String user, String domain) throws 
ErrorMappingException, RecipientRewriteTableException {
-        List<String> recipients = new LinkedList<String>();
+    public Mappings getMappings(String user, String domain) throws 
ErrorMappingException, RecipientRewriteTableException {
+        Mappings recipients = MappingsImpl.empty();
         for (Mapping m : findUserDomain(user, domain)) {
             recipients.addAll(m.target);
         }
@@ -117,7 +119,7 @@ public class RecipientRewriteTableMock i
     }
 
     @Override
-    public Collection<String> getUserDomainMappings(String user, String 
domain) throws RecipientRewriteTableException {
+    public Mappings getUserDomainMappings(String user, String domain) throws 
RecipientRewriteTableException {
         throw new UnsupportedOperationException("Not implemented");
     }
 
@@ -132,7 +134,7 @@ public class RecipientRewriteTableMock i
     }
 
     @Override
-    public Map<String, Collection<String>> getAllMappings() throws 
RecipientRewriteTableException {
+    public Map<String, Mappings> getAllMappings() throws 
RecipientRewriteTableException {
         throw new UnsupportedOperationException("Not implemented");
     }
 

Modified: 
james/project/trunk/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptHandler.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptHandler.java?rev=1711974&r1=1711973&r2=1711974&view=diff
==============================================================================
--- 
james/project/trunk/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptHandler.java
 (original)
+++ 
james/project/trunk/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptHandler.java
 Mon Nov  2 13:43:21 2015
@@ -18,8 +18,6 @@
  ****************************************************************/
 package org.apache.james.smtpserver.fastfail;
 
-import java.util.Collection;
-
 import javax.inject.Inject;
 import javax.inject.Named;
 
@@ -34,6 +32,7 @@ import org.apache.james.protocols.smtp.c
 import org.apache.james.rrt.api.RecipientRewriteTable;
 import org.apache.james.rrt.api.RecipientRewriteTable.ErrorMappingException;
 import org.apache.james.rrt.api.RecipientRewriteTableException;
+import org.apache.james.rrt.lib.Mappings;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.api.UsersRepositoryException;
 
@@ -110,7 +109,7 @@ public class ValidRcptHandler extends Ab
                     session.getLogger().debug("Unknown user " + username + " 
check if its an alias");
 
                     try {
-                        Collection<String> targetString = 
vut.getMappings(recipient.getLocalPart(), recipient.getDomain());
+                        Mappings targetString = 
vut.getMappings(recipient.getLocalPart(), recipient.getDomain());
 
                         if (targetString != null && !targetString.isEmpty()) {
                             return true;

Modified: 
james/project/trunk/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java?rev=1711974&r1=1711973&r2=1711974&view=diff
==============================================================================
--- 
james/project/trunk/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
 (original)
+++ 
james/project/trunk/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
 Mon Nov  2 13:43:21 2015
@@ -18,6 +18,13 @@
  ****************************************************************/
 package org.apache.james.smtpserver;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.io.BufferedReader;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -32,8 +39,10 @@ import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+
 import javax.mail.MessagingException;
 import javax.mail.internet.MimeMessage;
+
 import org.apache.commons.net.ProtocolCommandEvent;
 import org.apache.commons.net.ProtocolCommandListener;
 import org.apache.commons.net.smtp.SMTPClient;
@@ -49,18 +58,13 @@ import org.apache.james.queue.api.mock.M
 import org.apache.james.queue.api.mock.MockMailQueueFactory;
 import org.apache.james.rrt.api.RecipientRewriteTable;
 import org.apache.james.rrt.api.RecipientRewriteTableException;
+import org.apache.james.rrt.lib.Mappings;
 import org.apache.james.smtpserver.netty.SMTPServer;
 import org.apache.james.user.lib.mock.MockUsersRepository;
 import org.apache.mailet.HostAddress;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
 import org.junit.After;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -264,7 +268,7 @@ public class SMTPServerTest {
             }
     
             @Override
-            public Collection<String> getUserDomainMappings(String user, 
String domain) throws
+            public Mappings getUserDomainMappings(String user, String domain) 
throws
                     RecipientRewriteTableException {
                 throw new UnsupportedOperationException("Not implemented");
             }
@@ -280,7 +284,7 @@ public class SMTPServerTest {
             }
     
             @Override
-            public Map<String, Collection<String>> getAllMappings() throws 
RecipientRewriteTableException {
+            public Map<String, Mappings> getAllMappings() throws 
RecipientRewriteTableException {
                 throw new UnsupportedOperationException("Not implemented");
             }
     
@@ -297,7 +301,7 @@ public class SMTPServerTest {
             }
     
             @Override
-            public Collection<String> getMappings(String user, String domain) 
throws ErrorMappingException,
+            public Mappings getMappings(String user, String domain) throws 
ErrorMappingException,
                     RecipientRewriteTableException {
                 throw new UnsupportedOperationException("Not implemented");
             }



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