james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [04/14] james-project git commit: JAMES-2556 Fix reprocessing when several repositories with same path
Date Wed, 10 Oct 2018 08:48:17 GMT
JAMES-2556 Fix reprocessing when several repositories with same path

We need to aggregate repositories to check for mail existence before reprocessing


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

Branch: refs/heads/master
Commit: 9d52d569f749a28163719ea0ee709a55153ebbc4
Parents: f15655b
Author: Benoit Tellier <btellier@linagora.com>
Authored: Wed Oct 10 10:43:41 2018 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Wed Oct 10 15:46:19 2018 +0700

----------------------------------------------------------------------
 .../james/webadmin/service/ReprocessingService.java  | 15 +++++++++------
 .../webadmin/routes/MailRepositoriesRoutesTest.java  |  2 --
 2 files changed, 9 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/9d52d569/server/protocols/webadmin/webadmin-mailrepository/src/main/java/org/apache/james/webadmin/service/ReprocessingService.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailrepository/src/main/java/org/apache/james/webadmin/service/ReprocessingService.java
b/server/protocols/webadmin/webadmin-mailrepository/src/main/java/org/apache/james/webadmin/service/ReprocessingService.java
index c316b95..6ccb045 100644
--- a/server/protocols/webadmin/webadmin-mailrepository/src/main/java/org/apache/james/webadmin/service/ReprocessingService.java
+++ b/server/protocols/webadmin/webadmin-mailrepository/src/main/java/org/apache/james/webadmin/service/ReprocessingService.java
@@ -25,6 +25,7 @@ import java.util.function.Consumer;
 import javax.inject.Inject;
 import javax.mail.MessagingException;
 
+import org.apache.commons.lang3.tuple.Pair;
 import org.apache.james.mailrepository.api.MailKey;
 import org.apache.james.mailrepository.api.MailRepository;
 import org.apache.james.mailrepository.api.MailRepositoryPath;
@@ -90,13 +91,15 @@ public class ReprocessingService {
     public void reprocess(MailRepositoryPath path, MailKey key, Optional<String> targetProcessor,
String targetQueue) throws MailRepositoryStore.MailRepositoryStoreException, MessagingException
{
         Reprocessor reprocessor = new Reprocessor(getMailQueue(targetQueue), targetProcessor);
 
-        mailRepositoryStoreService
+        Pair<MailRepository, Mail> mailPair = mailRepositoryStoreService
             .getRepositories(path)
-            .forEach(Throwing.consumer((MailRepository repository) ->
-                reprocessor.reprocess(repository,
-                    Optional.ofNullable(repository.retrieve(key))
-                        .orElseThrow(() -> new MissingKeyException(key))))
-                .sneakyThrow());
+            .map(Throwing.function(repository -> Pair.of(repository, Optional.ofNullable(repository.retrieve(key)))))
+            .filter(pair -> pair.getRight().isPresent())
+            .map(pair -> Pair.of(pair.getLeft(), pair.getRight().get()))
+            .findFirst()
+            .orElseThrow(() -> new MissingKeyException(key));
+
+        reprocessor.reprocess(mailPair.getKey(), mailPair.getValue());
     }
 
     private MailQueue getMailQueue(String targetQueue) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/9d52d569/server/protocols/webadmin/webadmin-mailrepository/src/test/java/org/apache/james/webadmin/routes/MailRepositoriesRoutesTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-mailrepository/src/test/java/org/apache/james/webadmin/routes/MailRepositoriesRoutesTest.java
b/server/protocols/webadmin/webadmin-mailrepository/src/test/java/org/apache/james/webadmin/routes/MailRepositoriesRoutesTest.java
index ea78e4c..7d98451 100644
--- a/server/protocols/webadmin/webadmin-mailrepository/src/test/java/org/apache/james/webadmin/routes/MailRepositoriesRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-mailrepository/src/test/java/org/apache/james/webadmin/routes/MailRepositoriesRoutesTest.java
@@ -83,7 +83,6 @@ import org.apache.mailet.base.test.FakeMail;
 import org.eclipse.jetty.http.HttpStatus;
 import org.junit.After;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 
 import com.google.common.collect.Sets;
@@ -1506,7 +1505,6 @@ public class MailRepositoriesRoutesTest {
             .body("completedDate", is(notNullValue()));
     }
 
-    @Ignore
     @Test
     public void reprocessingOneTaskShouldNotFailWhenSeveralRepositoryWithSamePath() throws
Exception {
         MailRepository mailRepository = mailRepositoryStore.create(URL_MY_REPO);


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