james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [14/24] james-project git commit: JAMES-2366 Introduce convenience method Mappings::asStream()
Date Tue, 03 Apr 2018 10:03:00 GMT
JAMES-2366 Introduce convenience method Mappings::asStream()


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/dafe72b8
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/dafe72b8
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/dafe72b8

Branch: refs/heads/master
Commit: dafe72b8d9c5da1ca1e3555f428470244880d932
Parents: 5ef8203
Author: benwa <btellier@linagora.com>
Authored: Wed Mar 28 10:31:09 2018 +0700
Committer: benwa <btellier@linagora.com>
Committed: Tue Apr 3 16:59:44 2018 +0700

----------------------------------------------------------------------
 .../src/main/java/org/apache/james/rrt/lib/Mappings.java  |  3 +++
 .../main/java/org/apache/james/rrt/lib/MappingsImpl.java  |  5 +++++
 .../transport/mailets/RecipientRewriteTableProcessor.java | 10 ++++------
 .../org/apache/james/webadmin/routes/GroupsRoutes.java    |  5 ++---
 4 files changed, 14 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/dafe72b8/server/data/data-api/src/main/java/org/apache/james/rrt/lib/Mappings.java
----------------------------------------------------------------------
diff --git a/server/data/data-api/src/main/java/org/apache/james/rrt/lib/Mappings.java b/server/data/data-api/src/main/java/org/apache/james/rrt/lib/Mappings.java
index 4fdd8f1..51b30bf 100644
--- a/server/data/data-api/src/main/java/org/apache/james/rrt/lib/Mappings.java
+++ b/server/data/data-api/src/main/java/org/apache/james/rrt/lib/Mappings.java
@@ -21,6 +21,7 @@
 package org.apache.james.rrt.lib;
 
 import java.util.Optional;
+import java.util.stream.Stream;
 
 import org.apache.james.rrt.lib.Mapping.Type;
 
@@ -49,4 +50,6 @@ public interface Mappings extends Iterable<Mapping> {
     Optional<Mappings> toOptional();
 
     Mappings union(Mappings mappings);
+
+    Stream<Mapping> asStream();
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/dafe72b8/server/data/data-library/src/main/java/org/apache/james/rrt/lib/MappingsImpl.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/main/java/org/apache/james/rrt/lib/MappingsImpl.java
b/server/data/data-library/src/main/java/org/apache/james/rrt/lib/MappingsImpl.java
index 2267829..fa91828 100644
--- a/server/data/data-library/src/main/java/org/apache/james/rrt/lib/MappingsImpl.java
+++ b/server/data/data-library/src/main/java/org/apache/james/rrt/lib/MappingsImpl.java
@@ -209,6 +209,11 @@ public class MappingsImpl implements Mappings, Serializable {
     }
 
     @Override
+    public Stream<Mapping> asStream() {
+        return mappings.stream();
+    }
+
+    @Override
     public int hashCode() {
         return Objects.hashCode(mappings);
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/dafe72b8/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessor.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessor.java
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessor.java
index 293a297..55f6a6a 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessor.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/RecipientRewriteTableProcessor.java
@@ -38,7 +38,6 @@ import org.apache.james.rrt.api.RecipientRewriteTable.ErrorMappingException;
 import org.apache.james.rrt.api.RecipientRewriteTableException;
 import org.apache.james.rrt.lib.Mapping;
 import org.apache.james.rrt.lib.Mappings;
-import org.apache.james.util.streams.Iterators;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailetContext;
 import org.slf4j.Logger;
@@ -145,10 +144,9 @@ public class RecipientRewriteTableProcessor {
         return getLocalAddresses(mailAddresses);
     }
 
-    private ImmutableList<Mapping> convertToNewMappings(final Mappings mappings,
-            ImmutableList<Mapping> addressWithoutDomains) {
-        return Stream.concat(Iterators.toStream(mappings.iterator())
-                    .filter(Mapping::hasDomain),
+    private ImmutableList<Mapping> convertToNewMappings(Mappings mappings, ImmutableList<Mapping>
addressWithoutDomains) {
+        return Stream.concat(
+                mappings.asStream().filter(Mapping::hasDomain),
                 addressWithoutDomains.stream())
             .collect(Guavate.toImmutableList());
     }
@@ -168,7 +166,7 @@ public class RecipientRewriteTableProcessor {
     }
 
     private ImmutableList<Mapping> getAddressWithNoDomain(Mappings mappings, DomainList
domainList) throws MessagingException {
-        ImmutableList<Mapping> addressWithoutDomains = Iterators.toStream(mappings.iterator())
+        ImmutableList<Mapping> addressWithoutDomains = mappings.asStream()
             .filter(address -> !address.hasDomain())
             .collect(Guavate.toImmutableList());
         

http://git-wip-us.apache.org/repos/asf/james-project/blob/dafe72b8/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/GroupsRoutes.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/GroupsRoutes.java
b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/GroupsRoutes.java
index 7699a63..5126804 100644
--- a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/GroupsRoutes.java
+++ b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/GroupsRoutes.java
@@ -48,7 +48,6 @@ import org.apache.james.rrt.lib.Mapping;
 import org.apache.james.rrt.lib.Mappings;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.api.UsersRepositoryException;
-import org.apache.james.util.streams.Iterators;
 import org.apache.james.webadmin.Constants;
 import org.apache.james.webadmin.Routes;
 import org.apache.james.webadmin.utils.ErrorResponder;
@@ -227,8 +226,8 @@ public class GroupsRoutes implements Routes {
 
         ensureNonEmptyMappings(mappings);
 
-        return Iterators
-                .toStream(mappings.select(Mapping.Type.Address).iterator())
+        return mappings.select(Mapping.Type.Address)
+                .asStream()
                 .map(Mapping::getAddress)
                 .collect(Guavate.toImmutableSortedSet());
     }


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


Mime
View raw message