You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2019/01/16 06:59:21 UTC

[13/17] james-project git commit: JAMES-2637 getAliasSources should use rrt.listSources

JAMES-2637 getAliasSources should use rrt.listSources


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

Branch: refs/heads/master
Commit: c8264529f4aa2be595cbc160b365955fc675170d
Parents: 03420da
Author: Rene Cordier <rc...@linagora.com>
Authored: Tue Jan 15 15:03:31 2019 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Wed Jan 16 13:48:56 2019 +0700

----------------------------------------------------------------------
 .../java/org/apache/james/webadmin/routes/AliasRoutes.java  | 9 ++++-----
 .../org/apache/james/webadmin/routes/AliasRoutesTest.java   | 4 ++--
 2 files changed, 6 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/c8264529/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/AliasRoutes.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/AliasRoutes.java b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/AliasRoutes.java
index e88febf..ceb29af 100644
--- a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/AliasRoutes.java
+++ b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/AliasRoutes.java
@@ -55,6 +55,7 @@ import org.eclipse.jetty.http.HttpStatus;
 import com.github.steveash.guavate.Guavate;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.ImmutableSet;
+
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -221,12 +222,10 @@ public class AliasRoutes implements Routes {
             message = "Internal server error - Something went bad on the server side.")
     })
     public ImmutableSet<AliasSourcesResponse> listAliasesOfAddress(Request request, Response response) throws RecipientRewriteTableException {
-        MailAddress baseAddress = MailAddressParser.parseMailAddress(request.params(ALIAS_DESTINATION_ADDRESS), ADDRESS_TYPE);
+        MailAddress destinationAddress = MailAddressParser.parseMailAddress(request.params(ALIAS_DESTINATION_ADDRESS), ADDRESS_TYPE);
 
-        return recipientRewriteTable.getAllMappings()
-            .entrySet().stream()
-            .filter(e -> e.getValue().contains(Mapping.alias(baseAddress.asString())))
-            .map(Map.Entry::getKey)
+        return recipientRewriteTable.listSources(Mapping.alias(destinationAddress.asString()))
+            .stream()
             .sorted(Comparator.comparing(MappingSource::asMailAddressString))
             .map(AliasSourcesResponse::new)
             .collect(Guavate.toImmutableSet());

http://git-wip-us.apache.org/repos/asf/james-project/blob/c8264529/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/AliasRoutesTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/AliasRoutesTest.java b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/AliasRoutesTest.java
index 3142b8d..5835e49 100644
--- a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/AliasRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/AliasRoutesTest.java
@@ -610,7 +610,7 @@ class AliasRoutesTest {
         void getShouldReturnErrorWhenRecipientRewriteTableExceptionIsThrown() throws Exception {
             doThrow(RecipientRewriteTableException.class)
                 .when(memoryRecipientRewriteTable)
-                .getAllMappings();
+                .listSources(any());
 
             when()
                 .get(BOB)
@@ -622,7 +622,7 @@ class AliasRoutesTest {
         void getShouldReturnErrorWhenRuntimeExceptionIsThrown() throws Exception {
             doThrow(RuntimeException.class)
                 .when(memoryRecipientRewriteTable)
-                .getAllMappings();
+                .listSources(any());
 
             when()
                 .get(BOB)


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