[james-project] 03/09: JAMES-3924 Test and fix browse start updates

2023-08-29 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch 3.8.x
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit e48da3073ddef517b2035cc73119b400700b2e5f
Author: Benoit Tellier 
AuthorDate: Wed May 3 11:25:28 2023 +0700

JAMES-3924 Test and fix browse start updates

 -> Propose unit tests for browseStart updates using Cassandra session 
instrumentation
   (Ease testing a behaviour not visible at the API level)
 -> The update limitation to not occur more than once er slice was not 
correctly applied
 -> Fix a couple of warnings
---
 .../cassandra/CassandraMailQueueMailDelete.java| 13 +-
 .../queue/rabbitmq/RabbitMQMailQueueTest.java  | 29 +-
 2 files changed, 35 insertions(+), 7 deletions(-)

diff --git 
a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueMailDelete.java
 
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueMailDelete.java
index 4d4cdc818e..d519c534ba 100644
--- 
a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueMailDelete.java
+++ 
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueMailDelete.java
@@ -93,12 +93,13 @@ public class CassandraMailQueueMailDelete {
 }
 
 private Mono findNewBrowseStart(MailQueueName mailQueueName) {
-Slice currentSlice = Slice.of(clock.instant());
+Instant now= clock.instant();
 return browseStartDao.findBrowseStart(mailQueueName)
-.filter(browseStart -> 
browseStart.isBefore(currentSlice.getStartSliceInstant()))
-.flatMapMany(browseStart -> 
cassandraMailQueueBrowser.browseReferences(mailQueueName, browseStart))
-.map(enqueuedItem -> 
enqueuedItem.getSlicingContext().getTimeRangeStart())
-.next();
+.filter(browseStart -> 
browseStart.isBefore(now.minus(configuration.getSliceWindow(
+.flatMap(browseStart -> 
cassandraMailQueueBrowser.browseReferences(mailQueueName, browseStart)
+.map(enqueuedItem -> 
enqueuedItem.getSlicingContext().getTimeRangeStart())
+.next()
+.filter(newBrowseStart -> 
newBrowseStart.isAfter(browseStart)));
 }
 
 private Mono updateNewBrowseStart(MailQueueName mailQueueName, 
Instant newBrowseStartInstant) {
@@ -128,6 +129,6 @@ public class CassandraMailQueueMailDelete {
 
 private boolean shouldUpdateBrowseStart() {
 int threshold = configuration.getUpdateBrowseStartPace();
-return Math.abs(ThreadLocalRandom.current().nextInt()) % threshold == 
0;
+return ThreadLocalRandom.current().nextInt(threshold) % threshold == 0;
 }
 }
diff --git 
a/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
 
b/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
index 0e037d5ca3..124a40ab3a 100644
--- 
a/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
+++ 
b/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
@@ -25,6 +25,7 @@ import static java.time.temporal.ChronoUnit.HOURS;
 import static 
org.apache.james.backends.cassandra.Scenario.Builder.executeNormally;
 import static org.apache.james.backends.cassandra.Scenario.Builder.fail;
 import static org.apache.james.backends.cassandra.Scenario.Builder.returnEmpty;
+import static 
org.apache.james.backends.cassandra.StatementRecorder.Selector.preparedStatementStartingWith;
 import static org.apache.james.backends.rabbitmq.Constants.EMPTY_ROUTING_KEY;
 import static org.apache.james.queue.api.Mails.defaultMail;
 import static org.apache.james.queue.api.Mails.defaultMailNoRecipient;
@@ -54,6 +55,7 @@ import java.util.stream.Stream;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
 import org.apache.james.backends.cassandra.CassandraClusterExtension;
+import org.apache.james.backends.cassandra.StatementRecorder;
 import org.apache.james.backends.cassandra.components.CassandraModule;
 import 
org.apache.james.backends.cassandra.versions.CassandraSchemaVersionModule;
 import org.apache.james.backends.rabbitmq.RabbitMQExtension;
@@ -90,6 +92,7 @@ import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Nested;
+import org.junit.jupiter.api.RepeatedTest;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
 import org.mockito.ArgumentCaptor;
@@ -107,7 +110,7 @@ import reactor.rabbitmq.Sender;
 class RabbitMQMailQueueTest {
 private static final HashBlobId.Factory BLOB_ID_FAC

[james-project] 09/09: JAMES-3924 Remove repeated tests

2023-08-29 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch 3.8.x
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit ff6c17a653042ea994be16f7ff87f671d0fcb72d
Author: Benoit TELLIER 
AuthorDate: Fri Aug 25 12:28:58 2023 +0700

JAMES-3924 Remove repeated tests

2 * 50 * 6s =~ 10 minutes ... too long
---
 .../java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
 
b/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
index 10ae765893..55fa07907d 100644
--- 
a/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
+++ 
b/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
@@ -203,7 +203,7 @@ class RabbitMQMailQueueTest {
 "5-1", "5-2", "5-3", "5-4", "5-5");
 }
 
-@RepeatedTest(50)
+@Test
 void browseStartShouldBeUpdated(CassandraCluster cassandraCluster, 
MailQueueMetricExtension.MailQueueMetricTestSystem metricTestSystem) throws 
Exception {
 setUp(cassandraCluster, metricTestSystem,
 RabbitMQMailQueueConfiguration.builder()
@@ -236,7 +236,7 @@ class RabbitMQMailQueueTest {
 .hasSizeBetween(2, 12);
 }
 
-@RepeatedTest(50)
+@Test
 void contentStartShouldBeUpdated(CassandraCluster cassandraCluster, 
MailQueueMetricExtension.MailQueueMetricTestSystem metricTestSystem) throws 
Exception {
 setUp(cassandraCluster, metricTestSystem,
 RabbitMQMailQueueConfiguration.builder()


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



[james-project] 02/09: JAMES-3924 Allow conditional Cassandra statement recording

2023-08-29 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch 3.8.x
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 44d87f8cdc131357e8660b07497b5a3285442aaf
Author: Benoit Tellier 
AuthorDate: Fri Jun 30 22:06:50 2023 +0700

JAMES-3924 Allow conditional Cassandra statement recording
---
 .../java/org/apache/james/backends/cassandra/StatementRecorder.java   | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git 
a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/StatementRecorder.java
 
b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/StatementRecorder.java
index e4204fe07b..e7689f1124 100644
--- 
a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/StatementRecorder.java
+++ 
b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/StatementRecorder.java
@@ -61,9 +61,7 @@ public class StatementRecorder {
 }
 
 void recordStatement(Statement statement) {
-if (statements.addAll(selector.select(ImmutableList.of(statement {
-System.out.println("recordStatement");
-}
+statements.addAll(selector.select(ImmutableList.of(statement)));
 }
 
 public List listExecutedStatements() {


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



[james-project] 06/09: JAMES-3924 Review CassandraMailQueueBrowser parallelism

2023-08-29 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch 3.8.x
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 660068a3e3da2e0ed604201d76f22ba2d8f18308
Author: Benoit Tellier 
AuthorDate: Fri Jun 30 21:51:29 2023 +0700

JAMES-3924 Review CassandraMailQueueBrowser parallelism
---
 .../rabbitmq/view/cassandra/CassandraMailQueueBrowser.java| 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git 
a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueBrowser.java
 
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueBrowser.java
index 64f85be0b1..9c1241351d 100644
--- 
a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueBrowser.java
+++ 
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueBrowser.java
@@ -134,7 +134,7 @@ public class CassandraMailQueueBrowser {
 
 Flux browseReferences(MailQueueName 
queueName, Instant browseStart) {
 return allSlicesStartingAt(browseStart)
-.flatMapSequential(slice -> browseSlice(queueName, slice), 4);
+.concatMap(slice -> browseSlice(queueName, slice));
 }
 
 private Mono> 
toMailFuture(EnqueuedItemWithSlicingContext enqueuedItemWithSlicingContext) {
@@ -156,15 +156,14 @@ public class CassandraMailQueueBrowser {
 }
 
 private Flux browseSlice(MailQueueName 
queueName, Slice slice) {
-return
-allBucketIds()
-.concatMap(bucketId -> browseBucket(queueName, slice, 
bucketId), DEFAULT_CONCURRENCY)
-.sort(Comparator.comparing(enqueuedMail -> 
enqueuedMail.getEnqueuedItem().getEnqueuedTime()));
+return allBucketIds()
+.concatMap(bucketId -> browseBucket(queueName, slice, bucketId), 4)
+.sort(Comparator.comparing(enqueuedMail -> 
enqueuedMail.getEnqueuedItem().getEnqueuedTime()));
 }
 
 private Flux browseBucket(MailQueueName 
queueName, Slice slice, BucketId bucketId) {
 return enqueuedMailsDao.selectEnqueuedMails(queueName, slice, bucketId)
-.filterWhen(mailReference -> 
deletedMailsDao.isStillEnqueued(queueName, 
mailReference.getEnqueuedItem().getEnqueueId()), DEFAULT_CONCURRENCY);
+.filterWhen(mailReference -> 
deletedMailsDao.isStillEnqueued(queueName, 
mailReference.getEnqueuedItem().getEnqueueId()), 4);
 }
 
 private Flux allSlicesStartingAt(Instant browseStart) {


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



[james-project] 01/09: JAMES-3924 Allow conditional Cassandra statement recording

2023-08-29 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch 3.8.x
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 143567b6b21b099cd05c78d677bbd52c4bb4ca6c
Author: Benoit Tellier 
AuthorDate: Fri Jun 30 21:49:36 2023 +0700

JAMES-3924 Allow conditional Cassandra statement recording

Upon massive operations, recording all statements leads to OOM
---
 .../org/apache/james/backends/cassandra/StatementRecorder.java| 8 ++--
 .../java/org/apache/james/backends/cassandra/TestingSession.java  | 6 +-
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git 
a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/StatementRecorder.java
 
b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/StatementRecorder.java
index 99a0d59908..e4204fe07b 100644
--- 
a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/StatementRecorder.java
+++ 
b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/StatementRecorder.java
@@ -52,14 +52,18 @@ public class StatementRecorder {
 List select(List statements);
 }
 
+private final StatementRecorder.Selector selector;
 private final ConcurrentLinkedDeque statements;
 
-StatementRecorder() {
+StatementRecorder(Selector selector) {
+this.selector = selector;
 statements = new ConcurrentLinkedDeque();
 }
 
 void recordStatement(Statement statement) {
-statements.add(statement);
+if (statements.addAll(selector.select(ImmutableList.of(statement {
+System.out.println("recordStatement");
+}
 }
 
 public List listExecutedStatements() {
diff --git 
a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/TestingSession.java
 
b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/TestingSession.java
index 226c60ae5c..6b856e2ea8 100644
--- 
a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/TestingSession.java
+++ 
b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/TestingSession.java
@@ -85,7 +85,11 @@ public class TestingSession implements CqlSession {
 }
 
 public StatementRecorder recordStatements() {
-StatementRecorder statementRecorder = new StatementRecorder();
+return recordStatements(StatementRecorder.Selector.ALL);
+}
+
+public StatementRecorder recordStatements(StatementRecorder.Selector 
selector) {
+StatementRecorder statementRecorder = new StatementRecorder(selector);
 this.statementRecorder = Optional.of(statementRecorder);
 return statementRecorder;
 }


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



[james-project] 05/09: JAMES-3924 Improve dequeuer Lifecycle management

2023-08-29 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch 3.8.x
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 810fcfe7f215dbc1d0791160781021f9ed7aa996
Author: Benoit Tellier 
AuthorDate: Fri Jun 30 21:50:53 2023 +0700

JAMES-3924 Improve dequeuer Lifecycle management
---
 .../src/main/java/org/apache/james/queue/rabbitmq/Dequeuer.java   | 4 
 1 file changed, 4 insertions(+)

diff --git 
a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Dequeuer.java
 
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Dequeuer.java
index 98d2d28b6d..98ed284354 100644
--- 
a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Dequeuer.java
+++ 
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Dequeuer.java
@@ -25,6 +25,7 @@ import java.util.function.Consumer;
 
 import org.apache.james.backends.rabbitmq.ReceiverProvider;
 import org.apache.james.blob.api.ObjectNotFoundException;
+import org.apache.james.lifecycle.api.LifecycleUtil;
 import org.apache.james.metrics.api.Metric;
 import org.apache.james.metrics.api.MetricFactory;
 import org.apache.james.queue.api.MailQueue;
@@ -142,12 +143,15 @@ class Dequeuer {
 dequeueMetric.increment();
 response.ack();
 
Mono.from(mailQueueView.delete(DeleteCondition.withEnqueueId(mailWithEnqueueId.getEnqueueId(),
 mailWithEnqueueId.getBlobIds(.block();
+LifecycleUtil.dispose(mailWithEnqueueId.getMail());
 break;
 case RETRY:
 response.nack(REQUEUE);
+LifecycleUtil.dispose(mailWithEnqueueId.getMail());
 break;
 case REJECT:
 response.nack(!REQUEUE);
+LifecycleUtil.dispose(mailWithEnqueueId.getMail());
 break;
 }
 };


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



[james-project] 07/09: JAMES-3924 Fix checkstyles and some unstable tests

2023-08-29 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch 3.8.x
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 6f6fdcd53cc306283dbb0d6adc1f0cf3bec9d250
Author: Benoit Tellier 
AuthorDate: Sat Jul 1 19:03:40 2023 +0700

JAMES-3924 Fix checkstyles and some unstable tests

Co-authored-by: Rene Cordier 
Co-authored-by: Quan Tran 
---
 .../view/cassandra/CassandraMailQueueBrowser.java  |  1 -
 .../cassandra/CassandraMailQueueMailDelete.java|  2 +-
 .../queue/rabbitmq/RabbitMQMailQueueTest.java  | 56 +++---
 3 files changed, 28 insertions(+), 31 deletions(-)

diff --git 
a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueBrowser.java
 
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueBrowser.java
index 9c1241351d..40ca47a197 100644
--- 
a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueBrowser.java
+++ 
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueBrowser.java
@@ -21,7 +21,6 @@ package org.apache.james.queue.rabbitmq.view.cassandra;
 
 import static 
org.apache.james.queue.rabbitmq.view.cassandra.model.BucketedSlices.BucketId;
 import static 
org.apache.james.queue.rabbitmq.view.cassandra.model.BucketedSlices.Slice;
-import static org.apache.james.util.ReactorUtils.DEFAULT_CONCURRENCY;
 
 import java.time.Clock;
 import java.time.Instant;
diff --git 
a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueMailDelete.java
 
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueMailDelete.java
index d519c534ba..9cecbddb36 100644
--- 
a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueMailDelete.java
+++ 
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueMailDelete.java
@@ -93,7 +93,7 @@ public class CassandraMailQueueMailDelete {
 }
 
 private Mono findNewBrowseStart(MailQueueName mailQueueName) {
-Instant now= clock.instant();
+Instant now = clock.instant();
 return browseStartDao.findBrowseStart(mailQueueName)
 .filter(browseStart -> 
browseStart.isBefore(now.minus(configuration.getSliceWindow(
 .flatMap(browseStart -> 
cassandraMailQueueBrowser.browseReferences(mailQueueName, browseStart)
diff --git 
a/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
 
b/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
index b83d2431f8..7fe8fec2ee 100644
--- 
a/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
+++ 
b/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
@@ -67,10 +67,12 @@ import 
org.apache.james.blob.cassandra.CassandraBlobStoreFactory;
 import org.apache.james.blob.mail.MimeMessageStore;
 import org.apache.james.core.builder.MimeMessageBuilder;
 import 
org.apache.james.eventsourcing.eventstore.cassandra.CassandraEventStoreModule;
+import org.apache.james.junit.categories.Unstable;
 import org.apache.james.lifecycle.api.LifecycleUtil;
 import org.apache.james.metrics.api.Gauge;
 import org.apache.james.metrics.tests.RecordingMetricFactory;
 import org.apache.james.queue.api.MailQueue;
+import org.apache.james.queue.api.MailQueueFactory;
 import org.apache.james.queue.api.MailQueueMetricContract;
 import org.apache.james.queue.api.MailQueueMetricExtension;
 import org.apache.james.queue.api.ManageableMailQueue;
@@ -89,12 +91,12 @@ import org.apache.james.utils.UpdatableTickingClock;
 import org.apache.mailet.Mail;
 import org.apache.mailet.base.test.FakeMail;
 import org.assertj.core.api.SoftAssertions;
-import org.awaitility.Awaitility;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Nested;
 import org.junit.jupiter.api.RepeatedTest;
+import org.junit.jupiter.api.Tag;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
 import org.mockito.ArgumentCaptor;
@@ -112,7 +114,7 @@ import reactor.rabbitmq.Sender;
 class RabbitMQMailQueueTest {
 private static final HashBlobId.Factory BLOB_ID_FACTORY = new 
HashBlobId.Factory();
 private static final int THREE_BUCKET_COUNT = 3;
-private static final int UPDATE_BROWSE_START_PACE = 10;
+private static final int UPDATE_BROWSE_START_PACE = 25;
 private static final Duration ONE_HOUR_SLICE_WINDOW = Duration.ofHours(1);
 private static

[james-project] 05/09: JAMES-3924 Improve dequeuer Lifecycle management

2023-08-26 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit c7e08e48b8bc6b27cf8f99aacfd53d3505bb8573
Author: Benoit Tellier 
AuthorDate: Fri Jun 30 21:50:53 2023 +0700

JAMES-3924 Improve dequeuer Lifecycle management
---
 .../src/main/java/org/apache/james/queue/rabbitmq/Dequeuer.java   | 4 
 1 file changed, 4 insertions(+)

diff --git 
a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Dequeuer.java
 
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Dequeuer.java
index 98d2d28b6d..98ed284354 100644
--- 
a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Dequeuer.java
+++ 
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Dequeuer.java
@@ -25,6 +25,7 @@ import java.util.function.Consumer;
 
 import org.apache.james.backends.rabbitmq.ReceiverProvider;
 import org.apache.james.blob.api.ObjectNotFoundException;
+import org.apache.james.lifecycle.api.LifecycleUtil;
 import org.apache.james.metrics.api.Metric;
 import org.apache.james.metrics.api.MetricFactory;
 import org.apache.james.queue.api.MailQueue;
@@ -142,12 +143,15 @@ class Dequeuer {
 dequeueMetric.increment();
 response.ack();
 
Mono.from(mailQueueView.delete(DeleteCondition.withEnqueueId(mailWithEnqueueId.getEnqueueId(),
 mailWithEnqueueId.getBlobIds(.block();
+LifecycleUtil.dispose(mailWithEnqueueId.getMail());
 break;
 case RETRY:
 response.nack(REQUEUE);
+LifecycleUtil.dispose(mailWithEnqueueId.getMail());
 break;
 case REJECT:
 response.nack(!REQUEUE);
+LifecycleUtil.dispose(mailWithEnqueueId.getMail());
 break;
 }
 };


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



[james-project] 08/09: JAMES-3924 QoS 1 for browser/content start update tests

2023-08-26 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 62cf3a1f9490fc204671a60d315daf7ab2e496f5
Author: Quan Tran 
AuthorDate: Thu Aug 3 13:53:43 2023 +0700

JAMES-3924 QoS 1 for browser/content start update tests
---
 .../queue/rabbitmq/RabbitMQMailQueueTest.java  | 38 +++---
 1 file changed, 27 insertions(+), 11 deletions(-)

diff --git 
a/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
 
b/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
index 7fe8fec2ee..10ae765893 100644
--- 
a/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
+++ 
b/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
@@ -67,7 +67,6 @@ import 
org.apache.james.blob.cassandra.CassandraBlobStoreFactory;
 import org.apache.james.blob.mail.MimeMessageStore;
 import org.apache.james.core.builder.MimeMessageBuilder;
 import 
org.apache.james.eventsourcing.eventstore.cassandra.CassandraEventStoreModule;
-import org.apache.james.junit.categories.Unstable;
 import org.apache.james.lifecycle.api.LifecycleUtil;
 import org.apache.james.metrics.api.Gauge;
 import org.apache.james.metrics.tests.RecordingMetricFactory;
@@ -96,7 +95,6 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Nested;
 import org.junit.jupiter.api.RepeatedTest;
-import org.junit.jupiter.api.Tag;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
 import org.mockito.ArgumentCaptor;
@@ -156,7 +154,8 @@ class RabbitMQMailQueueTest {
 .sizeMetricsEnabled(true)
 .build(),
 CassandraBlobStoreFactory.forTesting(cassandra.getConf(), new 
RecordingMetricFactory())
-.passthrough());
+.passthrough(),
+MailQueueFactory.prefetchCount(3));
 }
 
 @Override
@@ -205,8 +204,15 @@ class RabbitMQMailQueueTest {
 }
 
 @RepeatedTest(50)
-@Tag(Unstable.TAG)
-void browseStartShouldBeUpdated(CassandraCluster cassandraCluster) {
+void browseStartShouldBeUpdated(CassandraCluster cassandraCluster, 
MailQueueMetricExtension.MailQueueMetricTestSystem metricTestSystem) throws 
Exception {
+setUp(cassandraCluster, metricTestSystem,
+RabbitMQMailQueueConfiguration.builder()
+.sizeMetricsEnabled(true)
+.build(),
+
CassandraBlobStoreFactory.forTesting(cassandraCluster.getConf(), new 
RecordingMetricFactory())
+.passthrough(),
+MailQueueFactory.prefetchCount(1));
+
 int emailCount = 250;
 
 StatementRecorder.Selector selector = 
preparedStatementStartingWith("UPDATE browsestart");
@@ -231,8 +237,15 @@ class RabbitMQMailQueueTest {
 }
 
 @RepeatedTest(50)
-@Tag(Unstable.TAG)
-void contentStartShouldBeUpdated(CassandraCluster cassandraCluster) {
+void contentStartShouldBeUpdated(CassandraCluster cassandraCluster, 
MailQueueMetricExtension.MailQueueMetricTestSystem metricTestSystem) throws 
Exception {
+setUp(cassandraCluster, metricTestSystem,
+RabbitMQMailQueueConfiguration.builder()
+.sizeMetricsEnabled(true)
+.build(),
+
CassandraBlobStoreFactory.forTesting(cassandraCluster.getConf(), new 
RecordingMetricFactory())
+.passthrough(),
+MailQueueFactory.prefetchCount(1));
+
 int emailCount = 250;
 
 StatementRecorder.Selector selector = 
preparedStatementStartingWith("UPDATE contentstart");
@@ -982,7 +995,8 @@ class RabbitMQMailQueueTest {
 .sizeMetricsEnabled(false)
 .build(),
 CassandraBlobStoreFactory.forTesting(cassandra.getConf(), new 
RecordingMetricFactory())
-.passthrough());
+.passthrough(),
+MailQueueFactory.prefetchCount(3));
 }
 
 @Test
@@ -1005,7 +1019,8 @@ class RabbitMQMailQueueTest {
 .sizeMetricsEnabled(true)
 .build(),
 CassandraBlobStoreFactory.forTesting(cassandra.getConf(), new 
RecordingMetricFactory())
-.deduplication());
+.deduplication(),
+MailQueueFactory.prefetchCount(3));
 }
 
 @Test
@@ -1039,7 +1054,8 @@ class RabbitMQMailQueueTest {
 }
 }
 
-private void setUp(CassandraCluster cassandra, 
MailQueueMetricExtension.MailQueueMetricTestSys

[james-project] 06/09: JAMES-3924 Review CassandraMailQueueBrowser parallelism

2023-08-26 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 2763b2a05c1061a851311f81019f131f81617d67
Author: Benoit Tellier 
AuthorDate: Fri Jun 30 21:51:29 2023 +0700

JAMES-3924 Review CassandraMailQueueBrowser parallelism
---
 .../rabbitmq/view/cassandra/CassandraMailQueueBrowser.java| 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git 
a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueBrowser.java
 
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueBrowser.java
index 64f85be0b1..9c1241351d 100644
--- 
a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueBrowser.java
+++ 
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueBrowser.java
@@ -134,7 +134,7 @@ public class CassandraMailQueueBrowser {
 
 Flux browseReferences(MailQueueName 
queueName, Instant browseStart) {
 return allSlicesStartingAt(browseStart)
-.flatMapSequential(slice -> browseSlice(queueName, slice), 4);
+.concatMap(slice -> browseSlice(queueName, slice));
 }
 
 private Mono> 
toMailFuture(EnqueuedItemWithSlicingContext enqueuedItemWithSlicingContext) {
@@ -156,15 +156,14 @@ public class CassandraMailQueueBrowser {
 }
 
 private Flux browseSlice(MailQueueName 
queueName, Slice slice) {
-return
-allBucketIds()
-.concatMap(bucketId -> browseBucket(queueName, slice, 
bucketId), DEFAULT_CONCURRENCY)
-.sort(Comparator.comparing(enqueuedMail -> 
enqueuedMail.getEnqueuedItem().getEnqueuedTime()));
+return allBucketIds()
+.concatMap(bucketId -> browseBucket(queueName, slice, bucketId), 4)
+.sort(Comparator.comparing(enqueuedMail -> 
enqueuedMail.getEnqueuedItem().getEnqueuedTime()));
 }
 
 private Flux browseBucket(MailQueueName 
queueName, Slice slice, BucketId bucketId) {
 return enqueuedMailsDao.selectEnqueuedMails(queueName, slice, bucketId)
-.filterWhen(mailReference -> 
deletedMailsDao.isStillEnqueued(queueName, 
mailReference.getEnqueuedItem().getEnqueueId()), DEFAULT_CONCURRENCY);
+.filterWhen(mailReference -> 
deletedMailsDao.isStillEnqueued(queueName, 
mailReference.getEnqueuedItem().getEnqueueId()), 4);
 }
 
 private Flux allSlicesStartingAt(Instant browseStart) {


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



[james-project] 09/09: JAMES-3924 Remove repeated tests

2023-08-26 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit a4b9d629da83ee3751baa2baa5b9219514108063
Author: Benoit TELLIER 
AuthorDate: Fri Aug 25 12:28:58 2023 +0700

JAMES-3924 Remove repeated tests

2 * 50 * 6s =~ 10 minutes ... too long
---
 .../java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
 
b/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
index 10ae765893..55fa07907d 100644
--- 
a/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
+++ 
b/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
@@ -203,7 +203,7 @@ class RabbitMQMailQueueTest {
 "5-1", "5-2", "5-3", "5-4", "5-5");
 }
 
-@RepeatedTest(50)
+@Test
 void browseStartShouldBeUpdated(CassandraCluster cassandraCluster, 
MailQueueMetricExtension.MailQueueMetricTestSystem metricTestSystem) throws 
Exception {
 setUp(cassandraCluster, metricTestSystem,
 RabbitMQMailQueueConfiguration.builder()
@@ -236,7 +236,7 @@ class RabbitMQMailQueueTest {
 .hasSizeBetween(2, 12);
 }
 
-@RepeatedTest(50)
+@Test
 void contentStartShouldBeUpdated(CassandraCluster cassandraCluster, 
MailQueueMetricExtension.MailQueueMetricTestSystem metricTestSystem) throws 
Exception {
 setUp(cassandraCluster, metricTestSystem,
 RabbitMQMailQueueConfiguration.builder()


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



[james-project] 07/09: JAMES-3924 Fix checkstyles and some unstable tests

2023-08-26 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 428cf2c58425b5b6c07927bce4de97bfb566189f
Author: Benoit Tellier 
AuthorDate: Sat Jul 1 19:03:40 2023 +0700

JAMES-3924 Fix checkstyles and some unstable tests

Co-authored-by: Rene Cordier 
Co-authored-by: Quan Tran 
---
 .../view/cassandra/CassandraMailQueueBrowser.java  |  1 -
 .../cassandra/CassandraMailQueueMailDelete.java|  2 +-
 .../queue/rabbitmq/RabbitMQMailQueueTest.java  | 56 +++---
 3 files changed, 28 insertions(+), 31 deletions(-)

diff --git 
a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueBrowser.java
 
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueBrowser.java
index 9c1241351d..40ca47a197 100644
--- 
a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueBrowser.java
+++ 
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueBrowser.java
@@ -21,7 +21,6 @@ package org.apache.james.queue.rabbitmq.view.cassandra;
 
 import static 
org.apache.james.queue.rabbitmq.view.cassandra.model.BucketedSlices.BucketId;
 import static 
org.apache.james.queue.rabbitmq.view.cassandra.model.BucketedSlices.Slice;
-import static org.apache.james.util.ReactorUtils.DEFAULT_CONCURRENCY;
 
 import java.time.Clock;
 import java.time.Instant;
diff --git 
a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueMailDelete.java
 
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueMailDelete.java
index d519c534ba..9cecbddb36 100644
--- 
a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueMailDelete.java
+++ 
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueMailDelete.java
@@ -93,7 +93,7 @@ public class CassandraMailQueueMailDelete {
 }
 
 private Mono findNewBrowseStart(MailQueueName mailQueueName) {
-Instant now= clock.instant();
+Instant now = clock.instant();
 return browseStartDao.findBrowseStart(mailQueueName)
 .filter(browseStart -> 
browseStart.isBefore(now.minus(configuration.getSliceWindow(
 .flatMap(browseStart -> 
cassandraMailQueueBrowser.browseReferences(mailQueueName, browseStart)
diff --git 
a/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
 
b/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
index b83d2431f8..7fe8fec2ee 100644
--- 
a/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
+++ 
b/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
@@ -67,10 +67,12 @@ import 
org.apache.james.blob.cassandra.CassandraBlobStoreFactory;
 import org.apache.james.blob.mail.MimeMessageStore;
 import org.apache.james.core.builder.MimeMessageBuilder;
 import 
org.apache.james.eventsourcing.eventstore.cassandra.CassandraEventStoreModule;
+import org.apache.james.junit.categories.Unstable;
 import org.apache.james.lifecycle.api.LifecycleUtil;
 import org.apache.james.metrics.api.Gauge;
 import org.apache.james.metrics.tests.RecordingMetricFactory;
 import org.apache.james.queue.api.MailQueue;
+import org.apache.james.queue.api.MailQueueFactory;
 import org.apache.james.queue.api.MailQueueMetricContract;
 import org.apache.james.queue.api.MailQueueMetricExtension;
 import org.apache.james.queue.api.ManageableMailQueue;
@@ -89,12 +91,12 @@ import org.apache.james.utils.UpdatableTickingClock;
 import org.apache.mailet.Mail;
 import org.apache.mailet.base.test.FakeMail;
 import org.assertj.core.api.SoftAssertions;
-import org.awaitility.Awaitility;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Nested;
 import org.junit.jupiter.api.RepeatedTest;
+import org.junit.jupiter.api.Tag;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
 import org.mockito.ArgumentCaptor;
@@ -112,7 +114,7 @@ import reactor.rabbitmq.Sender;
 class RabbitMQMailQueueTest {
 private static final HashBlobId.Factory BLOB_ID_FACTORY = new 
HashBlobId.Factory();
 private static final int THREE_BUCKET_COUNT = 3;
-private static final int UPDATE_BROWSE_START_PACE = 10;
+private static final int UPDATE_BROWSE_START_PACE = 25;
 private static final Duration ONE_HOUR_SLICE_WINDOW = Duration.ofHours(1);
 private static

[james-project] 04/09: JAMES-3924 Tests for contentStart updates

2023-08-26 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit b65d0139f4b135dfbfd363b8dbbaed6dd7a35a07
Author: Benoit Tellier 
AuthorDate: Wed May 3 13:14:11 2023 +0700

JAMES-3924 Tests for contentStart updates
---
 .../queue/rabbitmq/RabbitMQMailQueueTest.java  | 49 ++
 1 file changed, 41 insertions(+), 8 deletions(-)

diff --git 
a/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
 
b/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
index 124a40ab3a..b83d2431f8 100644
--- 
a/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
+++ 
b/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
@@ -67,6 +67,7 @@ import 
org.apache.james.blob.cassandra.CassandraBlobStoreFactory;
 import org.apache.james.blob.mail.MimeMessageStore;
 import org.apache.james.core.builder.MimeMessageBuilder;
 import 
org.apache.james.eventsourcing.eventstore.cassandra.CassandraEventStoreModule;
+import org.apache.james.lifecycle.api.LifecycleUtil;
 import org.apache.james.metrics.api.Gauge;
 import org.apache.james.metrics.tests.RecordingMetricFactory;
 import org.apache.james.queue.api.MailQueue;
@@ -86,6 +87,7 @@ import 
org.apache.james.queue.rabbitmq.view.cassandra.model.BucketedSlices.Slice
 import org.apache.james.util.streams.Iterators;
 import org.apache.james.utils.UpdatableTickingClock;
 import org.apache.mailet.Mail;
+import org.apache.mailet.base.test.FakeMail;
 import org.assertj.core.api.SoftAssertions;
 import org.awaitility.Awaitility;
 import org.junit.jupiter.api.AfterEach;
@@ -204,8 +206,9 @@ class RabbitMQMailQueueTest {
 void browseStartShouldBeUpdated(CassandraCluster cassandraCluster) {
 int emailCount = 100;
 
-StatementRecorder statementRecorder = new StatementRecorder();
-cassandraCluster.getConf().recordStatements(statementRecorder);
+StatementRecorder.Selector selector = 
preparedStatementStartingWith("UPDATE browsestart");
+StatementRecorder statementRecorder = cassandraCluster.getConf()
+.recordStatements(selector);
 
 clock.setInstant(IN_SLICE_1);
 enqueueSomeMails(namePatternForSlice(1), emailCount);
@@ -220,8 +223,32 @@ class RabbitMQMailQueueTest {
 dequeueMails(emailCount);
 
 // The actual rate of update should actually be lower than the 
update probability.
-
assertThat(statementRecorder.listExecutedStatements(preparedStatementStartingWith("UPDATE
 browsestart")))
-.hasSizeBetween(2, 5);
+assertThat(statementRecorder.listExecutedStatements(selector))
+.hasSizeBetween(2, 9);
+}
+
+@Test
+void contentStartShouldBeUpdated(CassandraCluster cassandraCluster) {
+int emailCount = 100;
+
+StatementRecorder.Selector selector = 
preparedStatementStartingWith("UPDATE contentstart");
+StatementRecorder statementRecorder = 
cassandraCluster.getConf().recordStatements(selector);
+
+clock.setInstant(IN_SLICE_1);
+enqueueSomeMails(namePatternForSlice(1), emailCount);
+dequeueMails(emailCount);
+
+clock.setInstant(IN_SLICE_2);
+enqueueSomeMails(namePatternForSlice(2), emailCount);
+dequeueMails(emailCount);
+
+clock.setInstant(IN_SLICE_3);
+enqueueSomeMails(namePatternForSlice(3), emailCount);
+dequeueMails(emailCount);
+
+// The actual rate of update should actually be lower than the 
update probability.
+assertThat(statementRecorder.listExecutedStatements(selector))
+.hasSizeBetween(2, 9);
 }
 
 @Test
@@ -678,9 +705,13 @@ class RabbitMQMailQueueTest {
 
 private void enqueueSomeMails(Function namePattern, 
int emailCount) {
 IntStream.rangeClosed(1, emailCount)
-.forEach(Throwing.intConsumer(i -> enQueue(defaultMail()
-.name(namePattern.apply(i))
-.build(;
+.forEach(Throwing.intConsumer(i -> {
+FakeMail mail = defaultMail()
+.name(namePattern.apply(i))
+.build();
+enQueue(mail);
+LifecycleUtil.dispose(mail);
+}));
 }
 
 private void dequeueMails(int times) {
@@ -700,7 +731,9 @@ class RabbitMQMailQueueTest {
 .subscribe();
 
 try {
-await().untilAsserted(() -> 
assertThat(counter.get()).isGreaterThanOrEqualTo(times));
+a

[james-project] 03/09: JAMES-3924 Test and fix browse start updates

2023-08-26 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit bd3d2291958d428f871de5e9a6299b85187439cd
Author: Benoit Tellier 
AuthorDate: Wed May 3 11:25:28 2023 +0700

JAMES-3924 Test and fix browse start updates

 -> Propose unit tests for browseStart updates using Cassandra session 
instrumentation
   (Ease testing a behaviour not visible at the API level)
 -> The update limitation to not occur more than once er slice was not 
correctly applied
 -> Fix a couple of warnings
---
 .../cassandra/CassandraMailQueueMailDelete.java| 13 +-
 .../queue/rabbitmq/RabbitMQMailQueueTest.java  | 29 +-
 2 files changed, 35 insertions(+), 7 deletions(-)

diff --git 
a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueMailDelete.java
 
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueMailDelete.java
index 4d4cdc818e..d519c534ba 100644
--- 
a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueMailDelete.java
+++ 
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/cassandra/CassandraMailQueueMailDelete.java
@@ -93,12 +93,13 @@ public class CassandraMailQueueMailDelete {
 }
 
 private Mono findNewBrowseStart(MailQueueName mailQueueName) {
-Slice currentSlice = Slice.of(clock.instant());
+Instant now= clock.instant();
 return browseStartDao.findBrowseStart(mailQueueName)
-.filter(browseStart -> 
browseStart.isBefore(currentSlice.getStartSliceInstant()))
-.flatMapMany(browseStart -> 
cassandraMailQueueBrowser.browseReferences(mailQueueName, browseStart))
-.map(enqueuedItem -> 
enqueuedItem.getSlicingContext().getTimeRangeStart())
-.next();
+.filter(browseStart -> 
browseStart.isBefore(now.minus(configuration.getSliceWindow(
+.flatMap(browseStart -> 
cassandraMailQueueBrowser.browseReferences(mailQueueName, browseStart)
+.map(enqueuedItem -> 
enqueuedItem.getSlicingContext().getTimeRangeStart())
+.next()
+.filter(newBrowseStart -> 
newBrowseStart.isAfter(browseStart)));
 }
 
 private Mono updateNewBrowseStart(MailQueueName mailQueueName, 
Instant newBrowseStartInstant) {
@@ -128,6 +129,6 @@ public class CassandraMailQueueMailDelete {
 
 private boolean shouldUpdateBrowseStart() {
 int threshold = configuration.getUpdateBrowseStartPace();
-return Math.abs(ThreadLocalRandom.current().nextInt()) % threshold == 
0;
+return ThreadLocalRandom.current().nextInt(threshold) % threshold == 0;
 }
 }
diff --git 
a/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
 
b/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
index 0e037d5ca3..124a40ab3a 100644
--- 
a/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
+++ 
b/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/RabbitMQMailQueueTest.java
@@ -25,6 +25,7 @@ import static java.time.temporal.ChronoUnit.HOURS;
 import static 
org.apache.james.backends.cassandra.Scenario.Builder.executeNormally;
 import static org.apache.james.backends.cassandra.Scenario.Builder.fail;
 import static org.apache.james.backends.cassandra.Scenario.Builder.returnEmpty;
+import static 
org.apache.james.backends.cassandra.StatementRecorder.Selector.preparedStatementStartingWith;
 import static org.apache.james.backends.rabbitmq.Constants.EMPTY_ROUTING_KEY;
 import static org.apache.james.queue.api.Mails.defaultMail;
 import static org.apache.james.queue.api.Mails.defaultMailNoRecipient;
@@ -54,6 +55,7 @@ import java.util.stream.Stream;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
 import org.apache.james.backends.cassandra.CassandraClusterExtension;
+import org.apache.james.backends.cassandra.StatementRecorder;
 import org.apache.james.backends.cassandra.components.CassandraModule;
 import 
org.apache.james.backends.cassandra.versions.CassandraSchemaVersionModule;
 import org.apache.james.backends.rabbitmq.RabbitMQExtension;
@@ -90,6 +92,7 @@ import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Nested;
+import org.junit.jupiter.api.RepeatedTest;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
 import org.mockito.ArgumentCaptor;
@@ -107,7 +110,7 @@ import reactor.rabbitmq.Sender;
 class RabbitMQMailQueueTest {
 private static final HashBlobId.Factory BLOB_ID_FAC

[james-project] 01/09: JAMES-3924 Allow conditional Cassandra statement recording

2023-08-26 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 453a0c41bc52ac1438da760f076c1971730779c8
Author: Benoit Tellier 
AuthorDate: Fri Jun 30 21:49:36 2023 +0700

JAMES-3924 Allow conditional Cassandra statement recording

Upon massive operations, recording all statements leads to OOM
---
 .../org/apache/james/backends/cassandra/StatementRecorder.java| 8 ++--
 .../java/org/apache/james/backends/cassandra/TestingSession.java  | 6 +-
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git 
a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/StatementRecorder.java
 
b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/StatementRecorder.java
index 99a0d59908..e4204fe07b 100644
--- 
a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/StatementRecorder.java
+++ 
b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/StatementRecorder.java
@@ -52,14 +52,18 @@ public class StatementRecorder {
 List select(List statements);
 }
 
+private final StatementRecorder.Selector selector;
 private final ConcurrentLinkedDeque statements;
 
-StatementRecorder() {
+StatementRecorder(Selector selector) {
+this.selector = selector;
 statements = new ConcurrentLinkedDeque();
 }
 
 void recordStatement(Statement statement) {
-statements.add(statement);
+if (statements.addAll(selector.select(ImmutableList.of(statement {
+System.out.println("recordStatement");
+}
 }
 
 public List listExecutedStatements() {
diff --git 
a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/TestingSession.java
 
b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/TestingSession.java
index 226c60ae5c..6b856e2ea8 100644
--- 
a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/TestingSession.java
+++ 
b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/TestingSession.java
@@ -85,7 +85,11 @@ public class TestingSession implements CqlSession {
 }
 
 public StatementRecorder recordStatements() {
-StatementRecorder statementRecorder = new StatementRecorder();
+return recordStatements(StatementRecorder.Selector.ALL);
+}
+
+public StatementRecorder recordStatements(StatementRecorder.Selector 
selector) {
+StatementRecorder statementRecorder = new StatementRecorder(selector);
 this.statementRecorder = Optional.of(statementRecorder);
 return statementRecorder;
 }


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



[james-project] 02/09: JAMES-3924 Allow conditional Cassandra statement recording

2023-08-26 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 042e6e088ddc645dcfbc09e5f190ef23baf507cf
Author: Benoit Tellier 
AuthorDate: Fri Jun 30 22:06:50 2023 +0700

JAMES-3924 Allow conditional Cassandra statement recording
---
 .../java/org/apache/james/backends/cassandra/StatementRecorder.java   | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git 
a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/StatementRecorder.java
 
b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/StatementRecorder.java
index e4204fe07b..e7689f1124 100644
--- 
a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/StatementRecorder.java
+++ 
b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/StatementRecorder.java
@@ -61,9 +61,7 @@ public class StatementRecorder {
 }
 
 void recordStatement(Statement statement) {
-if (statements.addAll(selector.select(ImmutableList.of(statement {
-System.out.println("recordStatement");
-}
+statements.addAll(selector.select(ImmutableList.of(statement)));
 }
 
 public List listExecutedStatements() {


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



[james-project] branch master updated (cd94e5434e -> a4b9d629da)

2023-08-26 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


from cd94e5434e JAMES-3925 Define an API to store current values of JMAP 
uploads (#1699)
 new 453a0c41bc JAMES-3924 Allow conditional Cassandra statement recording
 new 042e6e088d JAMES-3924 Allow conditional Cassandra statement recording
 new bd3d229195 JAMES-3924 Test and fix browse start updates
 new b65d0139f4 JAMES-3924 Tests for contentStart updates
 new c7e08e48b8 JAMES-3924 Improve dequeuer Lifecycle management
 new 2763b2a05c JAMES-3924 Review CassandraMailQueueBrowser parallelism
 new 428cf2c584 JAMES-3924 Fix checkstyles and some unstable tests
 new 62cf3a1f94 JAMES-3924 QoS 1 for browser/content start update tests
 new a4b9d629da JAMES-3924 Remove repeated tests

The 9 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../backends/cassandra/StatementRecorder.java  |   6 +-
 .../james/backends/cassandra/TestingSession.java   |   6 +-
 .../org/apache/james/queue/rabbitmq/Dequeuer.java  |   4 +
 .../view/cassandra/CassandraMailQueueBrowser.java  |  12 +-
 .../cassandra/CassandraMailQueueMailDelete.java|  13 ++-
 .../queue/rabbitmq/RabbitMQMailQueueTest.java  | 126 -
 6 files changed, 125 insertions(+), 42 deletions(-)


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



[james-project] branch master updated: JAMES-3925 Define an API to store current values of JMAP uploads (#1699)

2023-08-25 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
 new cd94e5434e JAMES-3925 Define an API to store current values of JMAP 
uploads (#1699)
cd94e5434e is described below

commit cd94e5434e528fc076ebc3635ee4ab06cb2c0528
Author: hungphan227 <45198168+hungphan...@users.noreply.github.com>
AuthorDate: Sat Aug 26 12:53:29 2023 +0700

JAMES-3925 Define an API to store current values of JMAP uploads (#1699)
---
 .../james/modules/data/CassandraJmapModule.java|  3 +
 .../james/modules/mailbox/MemoryQuotaModule.java   |  3 +
 .../upload/CassandraUploadUsageRepository.java | 67 +++
 .../upload/CassandraUploadUsageRepositoryTest.java | 48 ++
 .../jmap/api/upload/UploadUsageRepository.java | 34 ++
 .../upload/InMemoryUploadUsageRepository.java  | 75 ++
 .../api/upload/UploadUsageRepositoryContract.scala | 50 +++
 .../upload/InMemoryUploadUsageRepositoryTest.java  | 41 
 8 files changed, 321 insertions(+)

diff --git 
a/server/container/guice/cassandra/src/main/java/org/apache/james/modules/data/CassandraJmapModule.java
 
b/server/container/guice/cassandra/src/main/java/org/apache/james/modules/data/CassandraJmapModule.java
index e1b9584628..a6c0884c27 100644
--- 
a/server/container/guice/cassandra/src/main/java/org/apache/james/modules/data/CassandraJmapModule.java
+++ 
b/server/container/guice/cassandra/src/main/java/org/apache/james/modules/data/CassandraJmapModule.java
@@ -41,6 +41,7 @@ import 
org.apache.james.jmap.api.projections.MessageFastViewProjectionHealthChec
 import org.apache.james.jmap.api.pushsubscription.PushDeleteUserDataTaskStep;
 import org.apache.james.jmap.api.pushsubscription.PushSubscriptionRepository;
 import org.apache.james.jmap.api.upload.UploadRepository;
+import org.apache.james.jmap.api.upload.UploadUsageRepository;
 import org.apache.james.jmap.cassandra.access.CassandraAccessModule;
 import org.apache.james.jmap.cassandra.access.CassandraAccessTokenRepository;
 import org.apache.james.jmap.cassandra.change.CassandraEmailChangeModule;
@@ -57,6 +58,7 @@ import 
org.apache.james.jmap.cassandra.projections.CassandraMessageFastViewProje
 import 
org.apache.james.jmap.cassandra.pushsubscription.CassandraPushSubscriptionModule;
 import 
org.apache.james.jmap.cassandra.pushsubscription.CassandraPushSubscriptionRepository;
 import org.apache.james.jmap.cassandra.upload.CassandraUploadRepository;
+import org.apache.james.jmap.cassandra.upload.CassandraUploadUsageRepository;
 import org.apache.james.jmap.cassandra.upload.UploadConfiguration;
 import org.apache.james.jmap.cassandra.upload.UploadDAO;
 import org.apache.james.jmap.cassandra.upload.UploadModule;
@@ -80,6 +82,7 @@ public class CassandraJmapModule extends AbstractModule {
 bind(CassandraUploadRepository.class).in(Scopes.SINGLETON);
 bind(UploadDAO.class).in(Scopes.SINGLETON);
 bind(UploadRepository.class).to(CassandraUploadRepository.class);
+
bind(UploadUsageRepository.class).to(CassandraUploadUsageRepository.class);
 
bind(UploadConfiguration.class).toInstance(UploadConfiguration.SINGLETON);
 
 bind(CassandraCustomIdentityDAO.class).in(Scopes.SINGLETON);
diff --git 
a/server/container/guice/memory/src/main/java/org/apache/james/modules/mailbox/MemoryQuotaModule.java
 
b/server/container/guice/memory/src/main/java/org/apache/james/modules/mailbox/MemoryQuotaModule.java
index 1fd76c36f7..dc389d74d6 100644
--- 
a/server/container/guice/memory/src/main/java/org/apache/james/modules/mailbox/MemoryQuotaModule.java
+++ 
b/server/container/guice/memory/src/main/java/org/apache/james/modules/mailbox/MemoryQuotaModule.java
@@ -20,6 +20,8 @@
 package org.apache.james.modules.mailbox;
 
 import org.apache.james.events.EventListener;
+import org.apache.james.jmap.api.upload.UploadUsageRepository;
+import org.apache.james.jmap.memory.upload.InMemoryUploadUsageRepository;
 import org.apache.james.mailbox.inmemory.quota.InMemoryCurrentQuotaManager;
 import org.apache.james.mailbox.inmemory.quota.InMemoryPerUserMaxQuotaManager;
 import org.apache.james.mailbox.quota.CurrentQuotaManager;
@@ -52,6 +54,7 @@ public class MemoryQuotaModule extends AbstractModule {
 bind(MaxQuotaManager.class).to(InMemoryPerUserMaxQuotaManager.class);
 bind(QuotaManager.class).to(StoreQuotaManager.class);
 bind(CurrentQuotaManager.class).to(InMemoryCurrentQuotaManager.class);
+
bind(UploadUsageRepository.class).to(InMemoryUploadUsageRepository.class);
 
 bind(ListeningCurrentQuotaUpdater.class).in(Scopes.SINGLETON);
 bind(QuotaUpdater.class).to(ListeningCurrentQuotaUpdater.class);
diff --git 
a/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/

[james-project] branch master updated (4d7aae72b4 -> 7280c36399)

2023-08-25 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


from 4d7aae72b4 JAMES-3925 Rework JMAP upload APIs
 new 9fcb888081 JAMES-3936 Forward + Alias + Group + Address Mapping Routes 
should not decode URL path two times
 new 7df0dd0168 JAMES-3936 MailRepositoriesRoutes should not decode request 
param 2 times
 new cbc2313e26 JAMES-3936 DomainsRoutes should not decode request param 2 
times
 new 0f9adc382f JAMES-3936 RegexMappingRoutes should not decode request 
param 2 times
 new f5ac5279c4 JAMES-3936 UserQuotaRoutes should not decode URL path two 
times
 new ed3fb56ce2 JAMES-3936 Better notating ticket number in tests
 new 7280c36399 JAMES-3936 Fix some failing tests

The 7 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../mailets/ToRepositoryIntegrationTest.java   |  1 +
 ...rTaskSerializationIntegrationImmutableTest.java |  1 +
 ...dminServerTaskSerializationIntegrationTest.java |  1 +
 .../org/apache/james/webadmin/WebAdminUtils.java   |  3 ++-
 .../james/webadmin/routes/DomainsRoutes.java   | 21 ++--
 .../james/webadmin/routes/MailAddressParser.java   | 15 +--
 .../james/webadmin/routes/RegexMappingRoutes.java  |  7 ++
 .../webadmin/routes/AddressMappingRoutesTest.java  | 18 +++---
 .../james/webadmin/routes/AliasRoutesTest.java |  1 +
 .../james/webadmin/routes/DomainsRoutesTest.java   | 21 ++--
 .../james/webadmin/routes/ForwardRoutesTest.java   | 14 +++
 .../james/webadmin/routes/GroupsRoutesTest.java|  1 +
 .../webadmin/routes/RegexMappingRoutesTest.java| 26 ---
 .../webadmin/routes/SieveScriptRoutesTest.java |  5 ++--
 .../james/webadmin/routes/UserRoutesTest.java  | 29 +++---
 .../james/webadmin/routes/UserQuotaRoutes.java | 10 ++--
 .../webadmin/routes/UserMailboxesRoutesTest.java   | 16 ++--
 .../james/webadmin/routes/UserQuotaRoutesTest.java |  3 ++-
 .../webadmin/routes/MailRepositoriesRoutes.java| 27 ++--
 19 files changed, 109 insertions(+), 111 deletions(-)


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



[james-project] 04/07: JAMES-3936 RegexMappingRoutes should not decode request param 2 times

2023-08-25 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 0f9adc382f8f21a4fb488d2bcc8b801028efa2cd
Author: Quan Tran 
AuthorDate: Wed Aug 23 17:03:53 2023 +0700

JAMES-3936 RegexMappingRoutes should not decode request param 2 times

Once has been handled by Spark.
---
 .../james/webadmin/routes/RegexMappingRoutes.java  |  7 ++
 .../webadmin/routes/RegexMappingRoutesTest.java| 26 ++
 2 files changed, 24 insertions(+), 9 deletions(-)

diff --git 
a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/RegexMappingRoutes.java
 
b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/RegexMappingRoutes.java
index 1df59788ad..aac6f6d308 100644
--- 
a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/RegexMappingRoutes.java
+++ 
b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/RegexMappingRoutes.java
@@ -22,9 +22,6 @@ package org.apache.james.webadmin.routes;
 import static org.apache.james.webadmin.Constants.SEPARATOR;
 import static spark.Spark.halt;
 
-import java.net.URLDecoder;
-import java.nio.charset.StandardCharsets;
-
 import javax.inject.Inject;
 
 import org.apache.james.core.Username;
@@ -75,7 +72,7 @@ public class RegexMappingRoutes implements Routes {
 private HaltException addRegexMapping(Request request, Response response) 
throws Exception {
 try {
 MappingSource mappingSource = extractMappingSource(request);
-String regex = URLDecoder.decode(request.params(REGEX_PARAM), 
StandardCharsets.UTF_8.toString());
+String regex = request.params(REGEX_PARAM);
 recipientRewriteTable.addRegexMapping(mappingSource, regex);
 } catch (InvalidRegexException e) {
 throw ErrorResponder.builder()
@@ -90,7 +87,7 @@ public class RegexMappingRoutes implements Routes {
 private HaltException removeRegexMapping(Request request, Response 
response) throws Exception {
 try {
 MappingSource mappingSource = 
MappingSource.parse(request.params(MAPPING_SOURCE_PARAM));
-String regex = URLDecoder.decode(request.params(REGEX_PARAM), 
StandardCharsets.UTF_8.toString());
+String regex = request.params(REGEX_PARAM);
 recipientRewriteTable.removeRegexMapping(mappingSource, regex);
 } catch (RecipientRewriteTableException e) {
 throw ErrorResponder.builder()
diff --git 
a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/RegexMappingRoutesTest.java
 
b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/RegexMappingRoutesTest.java
index b1abf71dc4..dd4c8d8293 100644
--- 
a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/RegexMappingRoutesTest.java
+++ 
b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/RegexMappingRoutesTest.java
@@ -24,10 +24,11 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.hamcrest.core.Is.is;
 import static org.mockito.Mockito.mock;
 
+import java.net.URLEncoder;
+
 import org.apache.james.core.Domain;
 import org.apache.james.core.Username;
 import org.apache.james.dnsservice.api.DNSService;
-import org.apache.james.domainlist.api.DomainList;
 import org.apache.james.domainlist.lib.DomainListConfiguration;
 import org.apache.james.domainlist.memory.MemoryDomainList;
 import org.apache.james.rrt.lib.Mapping;
@@ -41,7 +42,6 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
 import io.restassured.RestAssured;
-import io.restassured.filter.log.LogDetail;
 import io.restassured.http.ContentType;
 
 class RegexMappingRoutesTest {
@@ -63,6 +63,7 @@ class RegexMappingRoutesTest {
 
 RestAssured.requestSpecification = 
WebAdminUtils.buildRequestSpecification(webAdminServer)
 .setBasePath(RegexMappingRoutes.BASE_PATH)
+.setUrlEncodingEnabled(false) // no further automatically encoding 
by Rest Assured client
 .build();
 }
 
@@ -136,7 +137,7 @@ class RegexMappingRoutesTest {
 @Test
 void addRegexMappingShouldReturnBadRequestWhenRegexIsInvalid() {
 with()
-.post("ja...@domain.tld/targets/O.*[]")
+.post("ja...@domain.tld/targets/"+ URLEncoder.encode("O.*[]"))
 .then()
 .statusCode(HttpStatus.BAD_REQUEST_400)
 .contentType(ContentType.JSON)
@@ -148,7 +149,7 @@ class RegexMappingRoutesTest {
 @Test
 void addRegexMappingShouldReturnNoContentWhenRegexContainsQuestionMark() {
 with()
-.post("ja...@domain.tld/targets/^[aei%3Fou].*ja...@domain.tld")
+   

[james-project] 07/07: JAMES-3936 Fix some failing tests

2023-08-25 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 7280c3639900d0e0ce5eb395ee7c1e7f29fa97d0
Author: Quan Tran 
AuthorDate: Thu Aug 24 11:25:38 2023 +0700

JAMES-3936 Fix some failing tests

Rest assured client no longer encodes now, we need to encode ourselves some 
special characters.
---
 .../mailets/ToRepositoryIntegrationTest.java   |  1 +
 ...rTaskSerializationIntegrationImmutableTest.java |  1 +
 ...dminServerTaskSerializationIntegrationTest.java |  1 +
 .../org/apache/james/webadmin/WebAdminUtils.java   |  3 ++-
 .../webadmin/routes/SieveScriptRoutesTest.java |  5 ++--
 .../james/webadmin/routes/UserRoutesTest.java  | 29 +++---
 .../webadmin/routes/UserMailboxesRoutesTest.java   | 16 ++--
 7 files changed, 32 insertions(+), 24 deletions(-)

diff --git 
a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ToRepositoryIntegrationTest.java
 
b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ToRepositoryIntegrationTest.java
index a7653f1286..2411ef085b 100644
--- 
a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ToRepositoryIntegrationTest.java
+++ 
b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ToRepositoryIntegrationTest.java
@@ -88,6 +88,7 @@ class ToRepositoryIntegrationTest {
 webAdminAPI = WebAdminUtils.buildRequestSpecification(
 jamesServer.getProbe(WebAdminGuiceProbe.class)
 .getWebAdminPort())
+.setUrlEncodingEnabled(false) // no further automatically encoding 
by Rest Assured client. rf: 
https://issues.apache.org/jira/projects/JAMES/issues/JAMES-3936
 .build();
 }
 
diff --git 
a/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQWebAdminServerTaskSerializationIntegrationImmutableTest.java
 
b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQWebAdminServerTaskSerializationIntegrationImmutableTest.java
index dbcdaa1f64..ad1e468e52 100644
--- 
a/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQWebAdminServerTaskSerializationIntegrationImmutableTest.java
+++ 
b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQWebAdminServerTaskSerializationIntegrationImmutableTest.java
@@ -95,6 +95,7 @@ class 
RabbitMQWebAdminServerTaskSerializationIntegrationImmutableTest {
 WebAdminGuiceProbe webAdminGuiceProbe = 
guiceJamesServer.getProbe(WebAdminGuiceProbe.class);
 
 RestAssured.requestSpecification = 
WebAdminUtils.buildRequestSpecification(webAdminGuiceProbe.getWebAdminPort())
+.setUrlEncodingEnabled(false) // no further automatically encoding 
by Rest Assured client. rf: 
https://issues.apache.org/jira/projects/JAMES/issues/JAMES-3936
 .build();
 RestAssured.enableLoggingOfRequestAndResponseIfValidationFails();
 }
diff --git 
a/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQWebAdminServerTaskSerializationIntegrationTest.java
 
b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQWebAdminServerTaskSerializationIntegrationTest.java
index e54a15d3da..5bc4b26532 100644
--- 
a/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQWebAdminServerTaskSerializationIntegrationTest.java
+++ 
b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQWebAdminServerTaskSerializationIntegrationTest.java
@@ -130,6 +130,7 @@ class 
RabbitMQWebAdminServerTaskSerializationIntegrationTest {
 mailboxProbe = guiceJamesServer.getProbe(MailboxProbeImpl.class);
 
 RestAssured.requestSpecification = 
WebAdminUtils.buildRequestSpecification(webAdminGuiceProbe.getWebAdminPort())
+.setUrlEncodingEnabled(false) // no further automatically encoding 
by Rest Assured client. rf: 
https://issues.apache.org/jira/projects/JAMES/issues/JAMES-3936
 .build();
 RestAssured.enableLoggingOfRequestAndResponseIfValidationFails();
 }
diff --git 
a/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/WebAdminUtils.java
 
b/server/protocols/webadmin/webadmin

[james-project] 05/07: JAMES-3936 UserQuotaRoutes should not decode URL path two times

2023-08-25 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit f5ac5279c4fa91a229ad2374e540abc6b082f26e
Author: Quan Tran 
AuthorDate: Wed Aug 23 17:17:47 2023 +0700

JAMES-3936 UserQuotaRoutes should not decode URL path two times
---
 .../java/org/apache/james/webadmin/routes/UserQuotaRoutes.java | 10 ++
 .../org/apache/james/webadmin/routes/UserQuotaRoutesTest.java  |  3 ++-
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git 
a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/UserQuotaRoutes.java
 
b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/UserQuotaRoutes.java
index be0511e1f3..b3c6a9578b 100644
--- 
a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/UserQuotaRoutes.java
+++ 
b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/UserQuotaRoutes.java
@@ -21,9 +21,6 @@ package org.apache.james.webadmin.routes;
 
 import static org.apache.james.webadmin.routes.MailboxesRoutes.TASK_PARAMETER;
 
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.nio.charset.StandardCharsets;
 import java.util.Optional;
 import java.util.Set;
 import java.util.stream.Collectors;
@@ -280,11 +277,8 @@ public class UserQuotaRoutes implements Routes {
 }, jsonTransformer);
 }
 
-private Username checkUserExist(Request request) throws 
UsersRepositoryException, UnsupportedEncodingException {
-String user = URLDecoder.decode(request.params(USER),
-StandardCharsets.UTF_8.displayName());
-
-Username username = Username.of(user);
+private Username checkUserExist(Request request) throws 
UsersRepositoryException {
+Username username = Username.of(request.params(USER));
 
 if (!usersRepository.contains(username)) {
 throw ErrorResponder.builder()
diff --git 
a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/UserQuotaRoutesTest.java
 
b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/UserQuotaRoutesTest.java
index 85f31398a5..f7311b3e2c 100644
--- 
a/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/UserQuotaRoutesTest.java
+++ 
b/server/protocols/webadmin/webadmin-mailbox/src/test/java/org/apache/james/webadmin/routes/UserQuotaRoutesTest.java
@@ -102,7 +102,8 @@ class UserQuotaRoutesTest {
 usersRepository.addUser(JACK, PASSWORD);
 usersRepository.addUser(GUY_WITH_STRANGE_DOMAIN, PASSWORD);
 
-RestAssured.requestSpecification = 
testSystem.getRequestSpecification();
+RestAssured.requestSpecification = testSystem.getRequestSpecification()
+.urlEncodingEnabled(false); // no further automatically encoding 
by Rest Assured client. rf: 
https://issues.apache.org/jira/projects/JAMES/issues/JAMES-3936
 RestAssured.enableLoggingOfRequestAndResponseIfValidationFails();
 }
 


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



[james-project] 01/07: JAMES-3936 Forward + Alias + Group + Address Mapping Routes should not decode URL path two times

2023-08-25 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 9fcb8880812098f09e8e37131b06fb892a213000
Author: Quan Tran 
AuthorDate: Wed Aug 23 15:33:05 2023 +0700

JAMES-3936 Forward + Alias + Group + Address Mapping Routes should not 
decode URL path two times

We already have Spark handle URL decoding once, no need one more time 
within MailAddressParser.
---
 .../james/webadmin/routes/MailAddressParser.java   | 15 +--
 .../webadmin/routes/AddressMappingRoutesTest.java  | 18 +++---
 .../apache/james/webadmin/routes/AliasRoutesTest.java  |  1 +
 .../james/webadmin/routes/ForwardRoutesTest.java   | 14 ++
 .../apache/james/webadmin/routes/GroupsRoutesTest.java |  1 +
 5 files changed, 32 insertions(+), 17 deletions(-)

diff --git 
a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/MailAddressParser.java
 
b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/MailAddressParser.java
index 0f7b03b41d..666cd1ab9a 100644
--- 
a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/MailAddressParser.java
+++ 
b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/MailAddressParser.java
@@ -19,10 +19,6 @@
 
 package org.apache.james.webadmin.routes;
 
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.nio.charset.StandardCharsets;
-
 import javax.mail.internet.AddressException;
 
 import org.apache.james.core.MailAddress;
@@ -37,8 +33,7 @@ class MailAddressParser {
 
 static MailAddress parseMailAddress(String address, String addressType) {
 try {
-String decodedAddress = URLDecoder.decode(address, 
StandardCharsets.UTF_8.displayName());
-return new MailAddress(decodedAddress);
+return new MailAddress(address);
 } catch (AddressException e) {
 LOGGER.error("The {} {} is not an email address", addressType, 
address);
 throw ErrorResponder.builder()
@@ -47,14 +42,6 @@ class MailAddressParser {
 .message("The %s is not an email address", addressType)
 .cause(e)
 .haltError();
-} catch (UnsupportedEncodingException e) {
-LOGGER.error("UTF-8 should be a valid encoding");
-throw ErrorResponder.builder()
-.statusCode(HttpStatus.INTERNAL_SERVER_ERROR_500)
-.type(ErrorResponder.ErrorType.SERVER_ERROR)
-.message("Internal server error - Something went bad on the 
server side.")
-.cause(e)
-.haltError();
 }
 }
 
diff --git 
a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/AddressMappingRoutesTest.java
 
b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/AddressMappingRoutesTest.java
index aac29ea4b3..f57d76a75c 100644
--- 
a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/AddressMappingRoutesTest.java
+++ 
b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/AddressMappingRoutesTest.java
@@ -46,9 +46,11 @@ import io.restassured.RestAssured;
 import io.restassured.http.ContentType;
 
 class AddressMappingRoutesTest {
-private static String MAPPING_SOURCE = "sou...@domain.tld";
-private static String ALICE_ADDRESS = "al...@domain.tld";
-private static String BOB_ADDRESS = "b...@domain.tld";
+private static final String MAPPING_SOURCE = "sou...@domain.tld";
+private static final String ALICE_ADDRESS = "al...@domain.tld";
+private static final String ALICE_WITH_SLASH = "alice/@domain.tld";
+private static final String ALICE_WITH_ENCODED_SLASH = 
"alice...@domain.tld";
+private static final String BOB_ADDRESS = "b...@domain.tld";
 
 private WebAdminServer webAdminServer;
 private MemoryRecipientRewriteTable recipientRewriteTable;
@@ -70,6 +72,7 @@ class AddressMappingRoutesTest {
 
 RestAssured.requestSpecification = 
WebAdminUtils.buildRequestSpecification(webAdminServer)
 .setBasePath(AddressMappingRoutes.BASE_PATH)
+.setUrlEncodingEnabled(false) // no further automatically encoding 
by Rest Assured client
 .build();
 }
 
@@ -87,6 +90,15 @@ class AddressMappingRoutesTest {
 .containsAnyOf(Mapping.of(ALICE_ADDRESS));
 }
 
+@Test
+void addAddressMappingShouldSupportOneTimeEncodedAddress() {
+when()
+.post(MAPPING_SOURCE + "/targets/" + ALICE_WITH_ENCODED_SLASH);
+
+
assertThat(recipientRewriteTable.getS

[james-project] 06/07: JAMES-3936 Better notating ticket number in tests

2023-08-25 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit ed3fb56ce2e9bc32c4424663d50c2e38e78464e1
Author: Quan Tran 
AuthorDate: Wed Aug 23 17:38:25 2023 +0700

JAMES-3936 Better notating ticket number in tests
---
 .../java/org/apache/james/webadmin/routes/AddressMappingRoutesTest.java | 2 +-
 .../src/test/java/org/apache/james/webadmin/routes/AliasRoutesTest.java | 2 +-
 .../test/java/org/apache/james/webadmin/routes/DomainsRoutesTest.java   | 2 +-
 .../test/java/org/apache/james/webadmin/routes/ForwardRoutesTest.java   | 2 +-
 .../test/java/org/apache/james/webadmin/routes/GroupsRoutesTest.java| 2 +-
 .../java/org/apache/james/webadmin/routes/RegexMappingRoutesTest.java   | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git 
a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/AddressMappingRoutesTest.java
 
b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/AddressMappingRoutesTest.java
index f57d76a75c..215081d27d 100644
--- 
a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/AddressMappingRoutesTest.java
+++ 
b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/AddressMappingRoutesTest.java
@@ -72,7 +72,7 @@ class AddressMappingRoutesTest {
 
 RestAssured.requestSpecification = 
WebAdminUtils.buildRequestSpecification(webAdminServer)
 .setBasePath(AddressMappingRoutes.BASE_PATH)
-.setUrlEncodingEnabled(false) // no further automatically encoding 
by Rest Assured client
+.setUrlEncodingEnabled(false) // no further automatically encoding 
by Rest Assured client. rf: 
https://issues.apache.org/jira/projects/JAMES/issues/JAMES-3936
 .build();
 }
 
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 a5b35824ca..9d0d9e32ae 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
@@ -90,7 +90,7 @@ class AliasRoutesTest {
 
 RestAssured.requestSpecification = 
WebAdminUtils.buildRequestSpecification(webAdminServer)
 .setBasePath("address/aliases")
-.setUrlEncodingEnabled(false) // no further automatically encoding 
by Rest Assured client
+.setUrlEncodingEnabled(false) // no further automatically encoding 
by Rest Assured client. rf: 
https://issues.apache.org/jira/projects/JAMES/issues/JAMES-3936
 .build();
 }
 
diff --git 
a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainsRoutesTest.java
 
b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainsRoutesTest.java
index 7a61cc1a48..9804973478 100644
--- 
a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainsRoutesTest.java
+++ 
b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainsRoutesTest.java
@@ -117,7 +117,7 @@ class DomainsRoutesTest {
 
 RestAssured.requestSpecification = 
WebAdminUtils.buildRequestSpecification(webAdminServer)
 .setBasePath(DomainsRoutes.DOMAINS)
-.setUrlEncodingEnabled(false) // no further automatically encoding 
by Rest Assured client
+.setUrlEncodingEnabled(false) // no further automatically encoding 
by Rest Assured client. rf: 
https://issues.apache.org/jira/projects/JAMES/issues/JAMES-3936
 .build();
 }
 
diff --git 
a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/ForwardRoutesTest.java
 
b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/ForwardRoutesTest.java
index 663964bda3..317997dfb0 100644
--- 
a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/ForwardRoutesTest.java
+++ 
b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/ForwardRoutesTest.java
@@ -88,7 +88,7 @@ class ForwardRoutesTest {
 
 RestAssured.requestSpecification = 
WebAdminUtils.buildRequestSpecification(webAdminServer)
 .setBasePath("address/forwards")
-.setUrlEncodingEnabled(false) // no further automatically encoding 
by Rest Assured client
+.setUrlEncodingEnabled(false) // no further automatically encoding 
by Rest Assured client. rf: 
https://issues.apache.org/jira/projects/JAMES/issues/JAMES-3936
 .build();
 }
 
diff --git

[james-project] 02/07: JAMES-3936 MailRepositoriesRoutes should not decode request param 2 times

2023-08-25 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 7df0dd016876c4807705076c90494b8473f09b6d
Author: Quan Tran 
AuthorDate: Wed Aug 23 16:11:30 2023 +0700

JAMES-3936 MailRepositoriesRoutes should not decode request param 2 times

Besides, MailRepositoryPath.fromEncoded is being used by some Task DTOs - 
good to keep there.
---
 .../webadmin/routes/MailRepositoriesRoutes.java| 27 +++---
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git 
a/server/protocols/webadmin/webadmin-mailrepository/src/main/java/org/apache/james/webadmin/routes/MailRepositoriesRoutes.java
 
b/server/protocols/webadmin/webadmin-mailrepository/src/main/java/org/apache/james/webadmin/routes/MailRepositoriesRoutes.java
index 2b1c6b2f8f..407408aaf8 100644
--- 
a/server/protocols/webadmin/webadmin-mailrepository/src/main/java/org/apache/james/webadmin/routes/MailRepositoriesRoutes.java
+++ 
b/server/protocols/webadmin/webadmin-mailrepository/src/main/java/org/apache/james/webadmin/routes/MailRepositoriesRoutes.java
@@ -21,7 +21,6 @@ package org.apache.james.webadmin.routes;
 
 import java.io.IOException;
 import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
 import java.time.Clock;
 import java.util.Optional;
 import java.util.Set;
@@ -119,7 +118,7 @@ public class MailRepositoriesRoutes implements Routes {
 
 public void definePutMailRepository() {
 service.put(MAIL_REPOSITORIES + "/:encodedPath", (request, response) 
-> {
-MailRepositoryPath path = decodedRepositoryPath(request);
+MailRepositoryPath path = getRepositoryPath(request);
 String protocol = request.queryParams("protocol");
 try {
 repositoryStoreService.createMailRepository(path, protocol);
@@ -146,7 +145,7 @@ public class MailRepositoriesRoutes implements Routes {
 service.get(MAIL_REPOSITORIES + "/:encodedPath/mails", (request, 
response) -> {
 Offset offset = ParametersExtractor.extractOffset(request);
 Limit limit = ParametersExtractor.extractLimit(request);
-MailRepositoryPath path = decodedRepositoryPath(request);
+MailRepositoryPath path = getRepositoryPath(request);
 try {
 return repositoryStoreService.listMails(path, offset, limit)
 .orElseThrow(() -> 
repositoryNotFound(request.params("encodedPath"), path));
@@ -171,13 +170,13 @@ public class MailRepositoriesRoutes implements Routes {
 public void defineGetMail() {
 service.get(MAIL_REPOSITORIES + "/:encodedPath/mails/:mailKey", 
Constants.JSON_CONTENT_TYPE,
 (request, response) ->
-getMailAsJson(decodedRepositoryPath(request), new 
MailKey(request.params("mailKey")), request),
+getMailAsJson(getRepositoryPath(request), new 
MailKey(request.params("mailKey")), request),
 jsonTransformer);
 
 service.get(MAIL_REPOSITORIES + "/:encodedPath/mails/:mailKey", 
Constants.RFC822_CONTENT_TYPE,
 (request, response) -> writeMimeMessage(
 getMailAsMimeMessage(
-decodedRepositoryPath(request),
+getRepositoryPath(request),
 new MailKey(request.params("mailKey"))),
 response.raw()));
 }
@@ -262,7 +261,7 @@ public class MailRepositoriesRoutes implements Routes {
 
 public void defineGetMailRepository() {
 service.get(MAIL_REPOSITORIES + "/:encodedPath", (request, response) 
-> {
-MailRepositoryPath path = decodedRepositoryPath(request);
+MailRepositoryPath path = getRepositoryPath(request);
 try {
 long size = repositoryStoreService.size(path)
 .orElseThrow(() -> 
repositoryNotFound(request.params("encodedPath"), path));
@@ -280,7 +279,7 @@ public class MailRepositoriesRoutes implements Routes {
 
 public void defineDeleteMail() {
 service.delete(MAIL_REPOSITORIES + "/:encodedPath/mails/:mailKey", 
(request, response) -> {
-MailRepositoryPath path = decodedRepositoryPath(request);
+MailRepositoryPath path = getRepositoryPath(request);
 MailKey mailKey = new MailKey(request.params("mailKey"));
 try {
 repositoryStoreService.deleteMail(path, mailKey);
@@ -298,7 +297,7 @@ public class MailRepositoriesRoutes implements Routes {
 
 public void defineDeleteAll() {
 TaskFromRequest taskFromRequest = request -> {
-MailRepositoryPath path = decodedRepositoryPath(request);
+MailRepositoryPath pa

[james-project] 03/07: JAMES-3936 DomainsRoutes should not decode request param 2 times

2023-08-25 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit cbc2313e26aa99cf73f2c6514f982ad4dc8df13a
Author: Quan Tran 
AuthorDate: Wed Aug 23 16:40:22 2023 +0700

JAMES-3936 DomainsRoutes should not decode request param 2 times
---
 .../apache/james/webadmin/routes/DomainsRoutes.java | 21 ++---
 .../james/webadmin/routes/DomainsRoutesTest.java| 21 ++---
 2 files changed, 4 insertions(+), 38 deletions(-)

diff --git 
a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/DomainsRoutes.java
 
b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/DomainsRoutes.java
index 34ef2f9ab9..cba41954db 100644
--- 
a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/DomainsRoutes.java
+++ 
b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/DomainsRoutes.java
@@ -21,9 +21,6 @@ package org.apache.james.webadmin.routes;
 
 import static org.apache.james.webadmin.Constants.SEPARATOR;
 
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.nio.charset.StandardCharsets;
 import java.util.stream.Collectors;
 
 import javax.inject.Inject;
@@ -203,27 +200,13 @@ public class DomainsRoutes implements Routes {
 }
 
 private Domain checkValidDomain(String domainName) {
-String urlDecodedDomainName = urlDecodeDomain(domainName);
 try {
-return Domain.of(urlDecodedDomainName);
+return Domain.of(domainName);
 } catch (IllegalArgumentException e) {
 throw ErrorResponder.builder()
 .statusCode(HttpStatus.BAD_REQUEST_400)
 .type(ErrorType.INVALID_ARGUMENT)
-.message("Invalid request for domain creation %s", 
urlDecodedDomainName)
-.cause(e)
-.haltError();
-}
-}
-
-private String urlDecodeDomain(String domainName) {
-try {
-return URLDecoder.decode(domainName, 
StandardCharsets.UTF_8.toString());
-} catch (IllegalArgumentException | UnsupportedEncodingException e) {
-throw ErrorResponder.builder()
-.statusCode(HttpStatus.BAD_REQUEST_400)
-.type(ErrorType.INVALID_ARGUMENT)
-.message("Invalid request for domain creation %s unable to url 
decode some characters", domainName)
+.message("Invalid request for domain creation %s", domainName)
 .cause(e)
 .haltError();
 }
diff --git 
a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainsRoutesTest.java
 
b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainsRoutesTest.java
index 82b88af391..7a61cc1a48 100644
--- 
a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainsRoutesTest.java
+++ 
b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DomainsRoutesTest.java
@@ -117,6 +117,7 @@ class DomainsRoutesTest {
 
 RestAssured.requestSpecification = 
WebAdminUtils.buildRequestSpecification(webAdminServer)
 .setBasePath(DomainsRoutes.DOMAINS)
+.setUrlEncodingEnabled(false) // no further automatically encoding 
by Rest Assured client
 .build();
 }
 
@@ -332,7 +333,7 @@ class DomainsRoutesTest {
 }
 
 @Test
-void putShouldReturnUserErrorWhenNameContainsUrlEncodedUrlOperator() {
+void putWithDomainNameContainsSlashEncodedShouldDecodeAndReturnError() 
{
 Map errors = when()
 .put(DOMAIN + "%2F" + DOMAIN)
 .then()
@@ -349,24 +350,6 @@ class DomainsRoutesTest {
 .containsEntry("message", "Invalid request for domain creation 
domain/domain");
 }
 
-@Test
-void 
putShouldReturnUserErrorWhenNameContainsInvalidUrlEncodedCharacters() {
-Map errors = when()
-.put(DOMAIN + "%GG" + DOMAIN)
-.then()
-.statusCode(HttpStatus.BAD_REQUEST_400)
-.contentType(ContentType.JSON)
-.extract()
-.body()
-.jsonPath()
-.getMap(".");
-
-assertThat(errors)
-.containsEntry("statusCode", HttpStatus.BAD_REQUEST_400)
-.containsEntry("type", "InvalidArgument")
-.containsEntry("message", "Invalid request for domain creation 
domain%GGdomain unable to url decode some characters");
-}
-
 @Test
 void putShouldReturnUserErrorWhenNameContainsU

[james-project] 02/05: JAMES-3500 delete dynamic cassandra image after usage

2023-08-24 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 8999fd2c1cf686df0dc441b090019177dd591b45
Author: Tung Tran 
AuthorDate: Fri Aug 18 08:57:17 2023 +0700

JAMES-3500 delete dynamic cassandra image after usage
---
 .../apache/james/backends/cassandra/DockerCassandra.java  | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git 
a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandra.java
 
b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandra.java
index 7d5e2d4920..cc7a74210d 100644
--- 
a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandra.java
+++ 
b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandra.java
@@ -117,11 +117,15 @@ public class DockerCassandra {
 // If available try to access the image shared by all maven projects
 // This avoids rebuilding one for each maven surefire fork.
 // BUILD_ID should be set by the execution context, here JenkinsFile
-return Optional.ofNullable(System.getenv("BUILD_ID"))
+return getFixedBuildId()
 // Default to an image discriminator specific to this JVM
 .orElse(UUID.randomUUID().toString());
 }
 
+private static Optional getFixedBuildId() {
+return Optional.ofNullable(System.getenv("BUILD_ID"));
+}
+
 private static final int CASSANDRA_PORT = 9042;
 private static final int CASSANDRA_MEMORY = 1024;
 
@@ -133,10 +137,12 @@ public class DockerCassandra {
 
 @SuppressWarnings("resource")
 public DockerCassandra() {
-this("cassandra_4_1_3-" + buildSpecificImageDiscriminator(), 
AdditionalDockerFileStep.IDENTITY);
+this("cassandra_4_1_3-" + buildSpecificImageDiscriminator(),
+getFixedBuildId().isEmpty(),
+AdditionalDockerFileStep.IDENTITY);
 }
 
-private DockerCassandra(String imageName, AdditionalDockerFileStep 
additionalSteps) {
+private DockerCassandra(String imageName, boolean deleteImageAfterUsage, 
AdditionalDockerFileStep additionalSteps) {
 client = DockerClientFactory.instance().client();
 EventsCmd eventsCmd = 
client.eventsCmd().withEventTypeFilter(EventType.IMAGE).withImageFilter(imageName);
 eventsCmd.exec(new ResultCallback() {
@@ -163,9 +169,8 @@ public class DockerCassandra {
 public void close() {
 }
 });
-boolean doNotDeleteImageAfterUsage = false;
 cassandraContainer = new GenericContainer<>(
-new ImageFromDockerfile(imageName,doNotDeleteImageAfterUsage)
+new ImageFromDockerfile(imageName,deleteImageAfterUsage)
 .withDockerfileFromBuilder(builder ->
 additionalSteps.applyStep(builder
 .from("cassandra:4.1.3")


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



[james-project] 03/05: [BUILD] Setting Cassandra memory based on CI environment or not

2023-08-24 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 8c3df5cc712e34df3614df7c84378582ee905c61
Author: Tung Tran 
AuthorDate: Mon Aug 21 10:07:31 2023 +0700

[BUILD] Setting Cassandra memory based on CI environment or not
---
 .../apache/james/backends/cassandra/DockerCassandra.java   | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git 
a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandra.java
 
b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandra.java
index cc7a74210d..aadf259917 100644
--- 
a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandra.java
+++ 
b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandra.java
@@ -169,20 +169,26 @@ public class DockerCassandra {
 public void close() {
 }
 });
+
+String memorySettingCommand = Optional.ofNullable(System.getenv("CI"))
+.map(Boolean::parseBoolean)
+.filter(Boolean.TRUE::equals)
+.map(ci -> "echo \"\" ")
+.orElse("echo \"-Xms" + CASSANDRA_MEMORY + "M\" >> " + JVM_OPTIONS
++ "&& echo \"-Xmx" + CASSANDRA_MEMORY + "M\" >> " + 
JVM_OPTIONS);
+
 cassandraContainer = new GenericContainer<>(
 new ImageFromDockerfile(imageName,deleteImageAfterUsage)
 .withDockerfileFromBuilder(builder ->
 additionalSteps.applyStep(builder
 .from("cassandra:4.1.3")
 .env("CASSANDRA_CONFIG", "/etc/cassandra")
-.run("echo \"-Xms" + CASSANDRA_MEMORY + "M\" >> " + 
JVM_OPTIONS
-+ "&& echo \"-Xmx" + CASSANDRA_MEMORY + "M\" >> " 
+ JVM_OPTIONS
+.run(memorySettingCommand
 + "&& echo 
\"-Dcassandra.skip_wait_for_gossip_to_settle=0\" >> " + JVM_OPTIONS
 + "&& echo \"-Dcassandra.load_ring_state=false\" 
>> " + JVM_OPTIONS
 + "&& echo \"-Dcassandra.initial_token=1 \" >> " + 
JVM_OPTIONS
-+ "&& echo \"-Dcassandra.num_tokens=nil \" >> " + 
JVM_OPTIONS
-+ "&& echo 
\"-Dcassandra.allocate_tokens_for_local_replication_factor=nil \" >> " + 
JVM_OPTIONS
 + "&& sed -i 's/auto_snapshot: true/auto_snapshot: 
false/g' /etc/cassandra/cassandra.yaml"
++ "&& sed -i 
's/allocate_tokens_for_local_replication_factor: 
3/allocate_tokens_for_local_replication_factor: 0/g' 
/etc/cassandra/cassandra.yaml"
 + "&& echo 'authenticator: PasswordAuthenticator' 
>> /etc/cassandra/cassandra.yaml"
 + "&& echo 'authorizer: 
org.apache.cassandra.auth.CassandraAuthorizer' >> 
/etc/cassandra/cassandra.yaml"))
 .build()))


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



[james-project] 05/05: Fix SessionWithInitializedTablesFactoryTest - updateVersion miss `.block`

2023-08-24 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit b671e3660643e7db8b0989b1e0aa7cb4b8218883
Author: Tung Tran 
AuthorDate: Mon Aug 21 19:19:56 2023 +0700

Fix SessionWithInitializedTablesFactoryTest - updateVersion miss `.block`
---
 .../cassandra/init/SessionWithInitializedTablesFactoryTest.java | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git 
a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/SessionWithInitializedTablesFactoryTest.java
 
b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/SessionWithInitializedTablesFactoryTest.java
index 50425bfb76..6df654e066 100644
--- 
a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/SessionWithInitializedTablesFactoryTest.java
+++ 
b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/init/SessionWithInitializedTablesFactoryTest.java
@@ -99,7 +99,7 @@ class SessionWithInitializedTablesFactoryTest {
 .isEqualTo(MAX_VERSION);
 
 new CassandraTableManager(MODULE, session).clearTables(t -> true);
-versionManagerDAO(session).updateVersion(MIN_VERSION);
+versionManagerDAO(session).updateVersion(MIN_VERSION).block();
 assertThat(versionManager(session).computeVersion().block())
 .isEqualTo(MIN_VERSION);
 
@@ -114,7 +114,7 @@ class SessionWithInitializedTablesFactoryTest {
 .isEqualTo(MAX_VERSION);
 
 new CassandraTableManager(MODULE, session).clearTables(t -> true);
-versionManagerDAO(session).updateVersion(MIN_VERSION);
+versionManagerDAO(session).updateVersion(MIN_VERSION).block();
 assertThat(versionManager(session).computeVersion().block())
 .isEqualTo(MIN_VERSION);
 session.execute(SchemaBuilder.dropTable(TABLE_NAME).build());
@@ -131,7 +131,7 @@ class SessionWithInitializedTablesFactoryTest {
 CqlSession cluster = ClusterFactory.create(clusterConfiguration, 
keyspaceConfiguration);
 KeyspaceFactory.createKeyspace(keyspaceConfiguration, cluster).block();
 
-return () -> new SessionWithInitializedTablesFactory( cluster, 
MODULE).get();
+return () -> new SessionWithInitializedTablesFactory(cluster, 
MODULE).get();
 }
 
 private static void cleanCassandra(CqlSession session) {


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



[james-project] 01/05: Fix jvm-*.options when upgrade Docker Cassandra 3 -> 4

2023-08-24 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 52be0e4ae46e115e66786bacd4e11ec8a081cb66
Author: Tung Tran 
AuthorDate: Fri Aug 18 08:56:32 2023 +0700

Fix jvm-*.options when upgrade Docker Cassandra 3 -> 4

Ref: 
https://cassandra.apache.org/doc/latest/cassandra/configuration/cass_jvm_options_file.html
---
 .../test/java/org/apache/james/backends/cassandra/DockerCassandra.java  | 2 +-
 server/apps/cassandra-app/docker-compose.yml| 2 ++
 server/apps/distributed-app/docker-compose.yml  | 2 ++
 server/apps/distributed-pop3-app/docker-compose.yml | 2 ++
 third-party/clamav/docker-compose.yml   | 2 ++
 third-party/rspamd/docker-compose-distributed.yml   | 2 ++
 6 files changed, 11 insertions(+), 1 deletion(-)

diff --git 
a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandra.java
 
b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandra.java
index 8c1b69b4e0..7d5e2d4920 100644
--- 
a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandra.java
+++ 
b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/DockerCassandra.java
@@ -126,7 +126,7 @@ public class DockerCassandra {
 private static final int CASSANDRA_MEMORY = 1024;
 
 private static final String CASSANDRA_CONFIG_DIR = "$CASSANDRA_CONFIG";
-private static final String JVM_OPTIONS = CASSANDRA_CONFIG_DIR + 
"/jvm.options";
+private static final String JVM_OPTIONS = CASSANDRA_CONFIG_DIR + 
"/jvm-server.options";
 
 private final GenericContainer cassandraContainer;
 private final DockerClient client;
diff --git a/server/apps/cassandra-app/docker-compose.yml 
b/server/apps/cassandra-app/docker-compose.yml
index f415df0641..5821b34c48 100644
--- a/server/apps/cassandra-app/docker-compose.yml
+++ b/server/apps/cassandra-app/docker-compose.yml
@@ -47,6 +47,8 @@ services:
   interval: 3s
   timeout: 20s
   retries: 5
+environment:
+  - JVM_OPTS=-Dcassandra.skip_wait_for_gossip_to_settle=0 
-Dcassandra.initial_token=1
 networks:
   - james
 
diff --git a/server/apps/distributed-app/docker-compose.yml 
b/server/apps/distributed-app/docker-compose.yml
index 2a08c60040..5ad5c55ed4 100644
--- a/server/apps/distributed-app/docker-compose.yml
+++ b/server/apps/distributed-app/docker-compose.yml
@@ -51,6 +51,8 @@ services:
   interval: 3s
   timeout: 20s
   retries: 5
+environment:
+  - JVM_OPTS=-Dcassandra.skip_wait_for_gossip_to_settle=0 
-Dcassandra.initial_token=1
 networks:
   - james
 
diff --git a/server/apps/distributed-pop3-app/docker-compose.yml 
b/server/apps/distributed-pop3-app/docker-compose.yml
index 0ecff28630..71d2715e43 100644
--- a/server/apps/distributed-pop3-app/docker-compose.yml
+++ b/server/apps/distributed-pop3-app/docker-compose.yml
@@ -51,6 +51,8 @@ services:
   interval: 3s
   timeout: 20s
   retries: 5
+environment:
+  - JVM_OPTS=-Dcassandra.skip_wait_for_gossip_to_settle=0 
-Dcassandra.initial_token=1
 networks:
   - james
 
diff --git a/third-party/clamav/docker-compose.yml 
b/third-party/clamav/docker-compose.yml
index 2fb8d44e6f..663d2c8328 100644
--- a/third-party/clamav/docker-compose.yml
+++ b/third-party/clamav/docker-compose.yml
@@ -56,6 +56,8 @@ services:
   interval: 3s
   timeout: 20s
   retries: 5
+environment:
+  - JVM_OPTS=-Dcassandra.skip_wait_for_gossip_to_settle=0 
-Dcassandra.initial_token=1
 networks:
   - james
 
diff --git a/third-party/rspamd/docker-compose-distributed.yml 
b/third-party/rspamd/docker-compose-distributed.yml
index bd6c841161..3c04c5510d 100644
--- a/third-party/rspamd/docker-compose-distributed.yml
+++ b/third-party/rspamd/docker-compose-distributed.yml
@@ -61,6 +61,8 @@ services:
   interval: 3s
   timeout: 20s
   retries: 5
+environment:
+  - JVM_OPTS=-Dcassandra.skip_wait_for_gossip_to_settle=0 
-Dcassandra.initial_token=1
 networks:
   - james
 


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



[james-project] branch master updated (6f4084b05b -> b671e36606)

2023-08-24 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


from 6f4084b05b JAMES-3491 Explicitly add tests for subaddressing (#1694)
 new 52be0e4ae4 Fix jvm-*.options when upgrade Docker Cassandra 3 -> 4
 new 8999fd2c1c JAMES-3500 delete dynamic cassandra image after usage
 new 8c3df5cc71 [BUILD] Setting Cassandra memory based on CI environment or 
not
 new 6fa75f196c ClamAVScan - update logger error when ConnectException - 
only messages
 new b671e36606 Fix SessionWithInitializedTablesFactoryTest - updateVersion 
miss `.block`

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../james/backends/cassandra/DockerCassandra.java  | 31 +++---
 .../SessionWithInitializedTablesFactoryTest.java   |  6 ++---
 server/apps/cassandra-app/docker-compose.yml   |  2 ++
 server/apps/distributed-app/docker-compose.yml |  2 ++
 .../apps/distributed-pop3-app/docker-compose.yml   |  2 ++
 third-party/clamav/docker-compose.yml  |  2 ++
 .../java/org/apache/james/clamav/ClamAVScan.java   |  2 ++
 third-party/rspamd/docker-compose-distributed.yml  |  2 ++
 8 files changed, 36 insertions(+), 13 deletions(-)


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



[james-project] 04/05: ClamAVScan - update logger error when ConnectException - only messages

2023-08-24 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 6fa75f196cacf7bf1edbfabb13d92d9f25abfab5
Author: Tung Tran 
AuthorDate: Mon Aug 21 17:37:58 2023 +0700

ClamAVScan - update logger error when ConnectException - only messages

- avoid print stacktrace (noise)
---
 .../clamav/src/main/java/org/apache/james/clamav/ClamAVScan.java| 2 ++
 1 file changed, 2 insertions(+)

diff --git 
a/third-party/clamav/src/main/java/org/apache/james/clamav/ClamAVScan.java 
b/third-party/clamav/src/main/java/org/apache/james/clamav/ClamAVScan.java
index ec7aee5a7c..2d639e3ef2 100644
--- a/third-party/clamav/src/main/java/org/apache/james/clamav/ClamAVScan.java
+++ b/third-party/clamav/src/main/java/org/apache/james/clamav/ClamAVScan.java
@@ -556,6 +556,8 @@ public class ClamAVScan extends GenericMailet {
 ping();
 }
 
+} catch (ConnectException ce) {
+LOGGER.error("ConnectException caught {}", ce.getMessage());
 } catch (Exception e) {
 LOGGER.error("Exception thrown", e);
 }


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



[james-project] branch master updated: JAMES-3491 Explicitly add tests for subaddressing (#1694)

2023-08-24 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
 new 6f4084b05b JAMES-3491 Explicitly add tests for subaddressing (#1694)
6f4084b05b is described below

commit 6f4084b05bb94a7a0ce21199caae7f151bcffad9
Author: Benoit TELLIER 
AuthorDate: Thu Aug 24 13:07:14 2023 +0700

JAMES-3491 Explicitly add tests for subaddressing (#1694)
---
 .../org/apache/james/core/MailAddressTest.java |   3 +-
 .../org/apache/james/SubAddressingRelayTest.java   | 164 +
 .../james/webadmin/routes/ForwardRoutesTest.java   |  15 ++
 3 files changed, 181 insertions(+), 1 deletion(-)

diff --git a/core/src/test/java/org/apache/james/core/MailAddressTest.java 
b/core/src/test/java/org/apache/james/core/MailAddressTest.java
index 1920c357b9..bebde4703c 100644
--- a/core/src/test/java/org/apache/james/core/MailAddressTest.java
+++ b/core/src/test/java/org/apache/james/core/MailAddressTest.java
@@ -53,6 +53,7 @@ class MailAddressTest {
 "Abc@10.42.0.1",
 "abc@example.com",
 "user+mailbox/department=shipp...@example.com",
+"user+mail...@example.com",
 "\"Abc@def\"@example.com",
 "\"Fred Bloggs\"@example.com",
 "\"Joe.\\Blow\"@example.com",
@@ -95,7 +96,7 @@ class MailAddressTest {
 "server-dev\\.@james.apache.org", // Javax.mail is unable to 
handle this so we better reject it
 "a...@domain.com",
 // According to wikipedia these addresses are valid but as 
javax.mail is unable
-// to work with thenm we shall rather reject them (note that 
this is not breaking retro-compatibility)
+// to work with them we shall rather reject them (note that 
this is not breaking retro-compatibility)
 "Loïc.Accentué@voilà.fr8",
 "pelé@exemple.com",
 "δοκιμή@παράδειγμα.δοκιμή",
diff --git 
a/server/mailet/remote-delivery-integration-testing/src/test/java/org/apache/james/SubAddressingRelayTest.java
 
b/server/mailet/remote-delivery-integration-testing/src/test/java/org/apache/james/SubAddressingRelayTest.java
new file mode 100644
index 00..896d9d44da
--- /dev/null
+++ 
b/server/mailet/remote-delivery-integration-testing/src/test/java/org/apache/james/SubAddressingRelayTest.java
@@ -0,0 +1,164 @@
+/
+ * 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;
+
+import static org.apache.james.MemoryJamesServerMain.SMTP_AND_IMAP_MODULE;
+import static org.apache.james.mailets.configuration.Constants.DEFAULT_DOMAIN;
+import static org.apache.james.mailets.configuration.Constants.LOCALHOST_IP;
+import static org.apache.james.mailets.configuration.Constants.PASSWORD;
+import static org.apache.james.mailets.configuration.Constants.calmlyAwait;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Durations.TEN_SECONDS;
+
+import java.io.File;
+
+import org.apache.commons.net.smtp.AuthenticatingSMTPClient;
+import org.apache.james.core.MailAddress;
+import org.apache.james.dnsservice.api.DNSService;
+import org.apache.james.dnsservice.api.InMemoryDNSService;
+import org.apache.james.mailets.TemporaryJamesServer;
+import org.apache.james.mailets.configuration.CommonProcessors;
+import org.apache.james.mailets.configuration.MailetConfiguration;
+import org.apache.james.mailets.configuration.MailetContainer;
+import org.apache.james.mai

[james-project] branch master updated: JAMES-3899 - Fix test case unstable (#1695)

2023-08-23 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
 new 71d06b5c2d JAMES-3899 - Fix test case unstable (#1695)
71d06b5c2d is described below

commit 71d06b5c2d4e5cb26a021012657e251adcd801e0
Author: vttran 
AuthorDate: Thu Aug 24 04:39:28 2023 +0700

JAMES-3899 - Fix test case unstable (#1695)

- ImapTestClient got an error "failed. Command not valid in this state."
---
 .../WithStorageDirectiveIntegrationTest.java   | 42 +++---
 1 file changed, 30 insertions(+), 12 deletions(-)

diff --git 
a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/WithStorageDirectiveIntegrationTest.java
 
b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/WithStorageDirectiveIntegrationTest.java
index e7b28c82bd..39c7060fc6 100644
--- 
a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/WithStorageDirectiveIntegrationTest.java
+++ 
b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/WithStorageDirectiveIntegrationTest.java
@@ -26,8 +26,12 @@ import static 
org.apache.james.mailets.configuration.Constants.PASSWORD;
 import static org.apache.james.mailets.configuration.Constants.RECIPIENT;
 import static 
org.apache.james.mailets.configuration.Constants.awaitAtMostOneMinute;
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.awaitility.Durations.FIVE_HUNDRED_MILLISECONDS;
+import static org.awaitility.Durations.TEN_SECONDS;
 
 import java.io.File;
+import java.io.IOException;
 
 import org.apache.james.mailets.configuration.CommonProcessors;
 import org.apache.james.mailets.configuration.MailetConfiguration;
@@ -38,10 +42,11 @@ import org.apache.james.probe.DataProbe;
 import org.apache.james.transport.mailets.WithStorageDirective;
 import org.apache.james.transport.matchers.SenderIsLocal;
 import org.apache.james.utils.DataProbeImpl;
-import org.apache.james.utils.MailRepositoryProbeImpl;
 import org.apache.james.utils.SMTPMessageSender;
 import org.apache.james.utils.SpoolerProbe;
 import org.apache.james.utils.TestIMAPClient;
+import org.awaitility.Awaitility;
+import org.awaitility.core.ConditionFactory;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
@@ -56,8 +61,10 @@ class WithStorageDirectiveIntegrationTest {
 private TemporaryJamesServer jamesServer;
 
 @AfterEach
-void tearDown() {
+void tearDown() throws IOException {
 jamesServer.shutdown();
+testIMAPClient.close();
+messageSender.close();
 }
 
 @Test
@@ -116,16 +123,27 @@ class WithStorageDirectiveIntegrationTest {
 .sendMessage(FROM, RECIPIENT);
 
 awaitAtMostOneMinute.until(() -> 
jamesServer.getProbe(SpoolerProbe.class).processingFinished());
-testIMAPClient.connect(LOCALHOST_IP, 
jamesServer.getProbe(ImapGuiceProbe.class).getImapPort())
-.login(RECIPIENT, PASSWORD)
-.select("target1")
-.awaitMessage(awaitAtMostOneMinute)
-.close();
-testIMAPClient.connect(LOCALHOST_IP, 
jamesServer.getProbe(ImapGuiceProbe.class).getImapPort())
-.login(RECIPIENT, PASSWORD)
-.select("target2")
-.awaitMessage(awaitAtMostOneMinute)
-.close();
+
+ConditionFactory imapAwait = Awaitility.with()
+.pollInterval(FIVE_HUNDRED_MILLISECONDS)
+.await()
+.atMost(TEN_SECONDS);
+
+awaitAtMostOneMinute.untilAsserted(() ->
+assertThatCode(() -> testIMAPClient.connect(LOCALHOST_IP, 
jamesServer.getProbe(ImapGuiceProbe.class).getImapPort())
+.login(RECIPIENT, PASSWORD)
+.select("target1")
+.awaitMessage(imapAwait)
+.close())
+.doesNotThrowAnyException());
+
+awaitAtMostOneMinute.untilAsserted(() ->
+assertThatCode(() -> testIMAPClient.connect(LOCALHOST_IP, 
jamesServer.getProbe(ImapGuiceProbe.class).getImapPort())
+.login(RECIPIENT, PASSWORD)
+.select("target2")
+.awaitMessage(imapAwait)
+.close())
+.doesNotThrowAnyException());
 }
 
 @Test


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



[james-project] branch master updated (5243d007fc -> c30d0afcfe)

2023-08-23 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


from 5243d007fc JAMES-4840 refactor quota for cassandra: create cassandra 
DAOs (#1673)
 add c30d0afcfe [FIX] VerifySenderIdentity makes sense when auth is not 
announced (#1693)

No new revisions were added by this update.

Summary of changes:
 .../sample-configuration/smtpserver.xml  |  6 +++---
 .../sample-configuration/smtpserver.xml  |  8 +++-
 .../sample-configuration/smtpserver.xml  |  8 +++-
 .../apps/jpa-app/sample-configuration/smtpserver.xml |  8 +++-
 .../jpa-smtp-app/sample-configuration/smtpserver.xml |  8 +++-
 .../memory-app/sample-configuration/smtpserver.xml   |  8 +++-
 .../spring-app/src/main/resources/smtpserver.xml |  2 --
 .../james/smtp/SmtpIdentityVerificationTest.java | 20 
 .../apache/james/smtpserver/netty/SMTPServer.java|  7 +--
 .../org/apache/james/smtpserver/SMTPServerTest.java  |  8 
 10 files changed, 39 insertions(+), 44 deletions(-)


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



[james-project] branch master updated: [ADR-68] Mutualize Cassandra storage for Quota (#1692)

2023-08-23 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
 new 233b784002 [ADR-68] Mutualize Cassandra storage for Quota (#1692)
233b784002 is described below

commit 233b784002f21fcd3e5a56faeb0192843a7b4b32
Author: Benoit TELLIER 
AuthorDate: Wed Aug 23 22:29:53 2023 +0700

[ADR-68] Mutualize Cassandra storage for Quota (#1692)
---
 .../0068-mutualize-cassandra-storge-for-quota.md   |  76 +
 src/adr/img/adr-68-architecture-diagram.png| Bin 0 -> 77041 bytes
 2 files changed, 76 insertions(+)

diff --git a/src/adr/0068-mutualize-cassandra-storge-for-quota.md 
b/src/adr/0068-mutualize-cassandra-storge-for-quota.md
new file mode 100644
index 00..758234db2a
--- /dev/null
+++ b/src/adr/0068-mutualize-cassandra-storge-for-quota.md
@@ -0,0 +1,76 @@
+# 68. Mutualize Cassandra storage for Quota
+
+Date: 2023-08-18
+
+## Status
+
+Accepted (lazy consensus).
+
+Not implemented yet.
+
+## Context
+
+One generic threat is resource abuse. Meaning a user uses an unfair amount of 
resources.
+
+Similarily resource limitation is a way to decrease operating costs.
+
+Quota, standardized in IMAP via 
[RFC-9208](https://www.rfc-editor.org/rfc/rfc9208.html) and in JMAP via
+[RFC-9425](https://datatracker.ietf.org/doc/rfc9425/) are a mechanism designed 
to keep track of
+user current usage of the resource and match it against the stored limit.
+
+Resource limitation is a broad use case that we might want to better enforce 
in Apache James. This is especially
+important when operating in SaaS mode, and actual users might be badly 
intentionned. See
+[ADR-67 Quota for JMAP uploads](0067-quota-for-jmap-uploads.md).
+
+As such, there is duplication, especially at the storage layers. Similar 
features might benefit from mutualized storage.
+
+Especially, it is worth mentionning that Cassandra tables do not come for 
free: we have a strong incentive to reduce their count.
+See [The Last Pickle blog post on this 
topic](https://thelastpickle.com/blog/2020/11/25/impacts-of-many-tables-on-cassandra.html).
+
+In particular (quote from the above article):
+
+```
+If some tables share the same columns, it could be interesting to merge them 
into a single one, 
+adding a column to the partition key to distinguish data belonging to 
different tables.
+```
+
+## Decision
+
+Add Cassandra storage helpers, exposing a generic interface for Cassandra 
quota implementation of various services to mutualize their
+storage. This relies on a part of the primary key allowing to distinguish the 
component.
+
+![Architecture diagram for quota related 
features](img/adr-68-architecture-diagram.png)
+
+The helper will consist of 2 tables:
+- One composed of counters to track current value
+- One composed of regular `long` to track limits
+
+(one can not mix counters and regular values in the same table in Cassandra).
+
+Port exising Cassandra implementations of quota for various services to use 
those helpers. Namely the Cassandra mailbox, Sieve storage. Use those
+helpers to implement JMAP quota uploads.
+
+## Consequences
+
+We expect a small decrease of the count of tables in our Cassandra schema, 
going from 7 (one for mailbox quota current value, one for mailbox quota
+per user limit, one for mailbox quota per domain limit, one for mailbox quota 
global limit, one for Sieve uota current value, one for Sieve quota
+per user limit, one for Sieve Quota global limit, one for JMAP uploads current 
value) to just 2 (helper tables: one for current value, one for limits).
+
+We expect to make it easier to implement quota related features in the future.
+
+We need to set up Cassandra migration tasks and to record the schema upgrade 
into the upgrade instructions. A compaibility mode will need to be
+explicitly configured in order to run the migration.
+
+## Alternatives
+
+Keep the current, exploded table structure and either do not care about table 
count increase or do not implement further important resource limitation
+use cases.
+
+## References
+
+- [JIRA](https://issues.apache.org/jira/projects/JAMES/issues/JAMES-3926)
+- [PR of the ADR](https://github.com/apache/james-project/pull/1692)
+- [The last pickle article: impacts of many tables in a Cassandra daa 
model](https://thelastpickle.com/blog/2020/11/25/impacts-of-many-tables-on-cassandra.html)
+- [RFC-9208 IMAP quotas](https://www.rfc-editor.org/rfc/rfc9208.html)
+- [RFC-9425 JMAP quotas](https://datatracker.ietf.org/doc/rfc9425/)
+- [ADR-67 Quota for JMAP uploads](0067-quota-for-jmap-uploads.md)
\ No newline at end of file
diff --git a/src/adr/img/adr-68-architecture-diagram.png 
b/src/adr/img/adr-68-architecture-diagram.png
new file mode 100644
index 00..25087fa3b4
Binary files /dev/null and b/src/adr/img/adr-68-architecture-diagram.png dif

[james-project] branch master updated: ADR-67 Quota for JMAP uploads (#1688)

2023-08-23 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
 new 6cc42a7f51 ADR-67 Quota for JMAP uploads (#1688)
6cc42a7f51 is described below

commit 6cc42a7f5124e49fd482cc0a95a23583862b6794
Author: Benoit TELLIER 
AuthorDate: Wed Aug 23 22:29:43 2023 +0700

ADR-67 Quota for JMAP uploads (#1688)
---
 src/adr/0048-cleanup-jmap-uploads.md   |  2 +
 src/adr/0067-quota-for-jmap-uploads.md | 90 ++
 2 files changed, 92 insertions(+)

diff --git a/src/adr/0048-cleanup-jmap-uploads.md 
b/src/adr/0048-cleanup-jmap-uploads.md
index 55a2499ca0..84aa833044 100644
--- a/src/adr/0048-cleanup-jmap-uploads.md
+++ b/src/adr/0048-cleanup-jmap-uploads.md
@@ -8,6 +8,8 @@ Accepted (lazy consensus).
 
 Implemented.
 
+Overridden by [Quota for JMAP uploads](0067-quota-for-jmap-uploads.md)
+
 ## Context
 
 JMAP allows users to upload binary content called blobs to be later referenced 
via method calls. This includes but is not
diff --git a/src/adr/0067-quota-for-jmap-uploads.md 
b/src/adr/0067-quota-for-jmap-uploads.md
new file mode 100644
index 00..9d5f6f0228
--- /dev/null
+++ b/src/adr/0067-quota-for-jmap-uploads.md
@@ -0,0 +1,90 @@
+# 67. Quota for JMAP uploads
+
+Date: 2023-08-17
+
+## Status
+
+Accepted (lazy consensus).
+
+Not implemented yet.
+
+Overrides [ADR-48 Cleaup JMAP uploads](0048-cleanup-jmap-uploads.md).
+
+## Context
+
+The [JMAP] protocol offers a distinct API to upload blobs, that can later be 
referenced when creating emails. The 
+specification mentions that implementers `SHOULD` enforce a quota for this use 
case. For security reason this quota is 
+set by user, and exceeded his quota should result in older data being deleted.
+
+Apache James currently do not implement limitations on data being uploaded by 
users, meaning that authenticated user can 
+essentially store unlimited amount of binary data. This is especially 
problematic for deployments whose users can be 
+attackers (eg SAAS).
+
+## Decision
+
+Implement quota for JMAP uploads. We need a generic interface for JMAP upload 
quota current values that existing 
+implementation can implement.
+
+Store current values on a per user basis. Current value is increased upon 
uploads, and decreased when a blob is deleted.
+
+Limit is set globally via the JMAP configuration. Default value: 10MB.
+
+## Consequences
+
+Improved security for SaaS operation.
+
+Storing such values in Cassandra incurs a cost as it needs extra tables. The 
count of tables shall be limited (memory and
+operational overhead per table.) We plan complementary work to expose a 
technical Cassandra storage interface for quota,
+that can be used to implement arbitrary quota-like use cases.
+
+Cassandra counters that would be used to keep track of users current space 
usage are easy to get out of synchronisation
+(namely because of counters consistency level ONE usage and non-idempotence 
causing the driver not to retry failed 
+updates). We thus need a corrective task in order to recompute the current 
values.
+
+Care needs to be taken with concurrency. Given the nature of the quota, we 
expect data races (because 100MB of storage 
+space is not much, exceeding the quota should be considered a regular 
operation. Clients uploading files parallely might
+trigger data races upon older data deletion). In practice this means:
+ - Be eventually consistent and cleanup data after the upload returns as 
upfront quota validation with JMAP upload 
+constraints on to of Cassandra counter data model is especially prone to data 
races
+ - Upon cleanup, free at least 50% of the space: this would decrease the 
frequency of updates
+ - Expose a configurable probability of recomputing the upload quota
+ - If inconsistent space usage is reported, recompute the quota
+
+JMAP upload storage evolutions:
+ - As we add an application behaviour, common for any implementation, we need 
further layers in the design in
+order to mutualize quota handling for all implementations. A service layer 
`UploadService` would expose the JMAP facade
+(today `UploadRepository` interface) and would be responsible to enforce 
quotas, and related behaviour. Ten it would 
+act on the storage layer, `UploadReposiory`, implemented by `cassandra` and 
`memory`.
+ - Upon exceeded quota, we need to delete older uploads. In order to do so, we 
need to add the date of upload to the
+upload metadata. Migration is trivial: we can assume UNIX timestamp when 
missing, causing the upload to be considered 
+the oldest.
+ - Recomputation of JMAP upload quotas requires listing stored upload 
metadata, we need to add a way to list uploads 
+of a user on `UploadReposiory` (without retrieving the uploads contents).
+ - `UploadService` needs a method to delete 
+
+Asynchronous storage based cleanup using

[james-project] 04/04: Checkstyle - support check license in the header - add message

2023-08-22 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit e4aea550f12e9cde3410efb9ea7e76e09c79c472
Author: Tung Tran 
AuthorDate: Fri Aug 18 09:24:12 2023 +0700

Checkstyle - support check license in the header - add message
---
 checkstyle.xml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/checkstyle.xml b/checkstyle.xml
index 3b74c6fe89..17bb1b634c 100644
--- a/checkstyle.xml
+++ b/checkstyle.xml
@@ -38,6 +38,8 @@
   
 
 
+
+
   
   
 


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



[james-project] 03/04: [CLEAN CODE] Use one license template in the header

2023-08-22 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit b84a2ad83cd5104dbf80582824393739712c3b91
Author: Tung Tran 
AuthorDate: Thu Aug 17 18:18:04 2023 +0700

[CLEAN CODE] Use one license template in the header
---
 .../cassandra/versions/SchemaVersionTest.java  | 18 +++
 .../james/backends/rabbitmq/QueueArguments.java| 18 +++
 .../mailbox/exception/InboxAlreadyCreated.java | 11 ---
 ...MailboxMergingTaskAdditionalInformationDTO.java | 11 ---
 .../cassandra/mail/task/MailboxMergingTaskDTO.java | 11 ---
 .../mailbox/inmemory/InMemoryMessageManager.java   | 18 +++
 .../mailbox/opensearch/json/MessageUpdateJson.java |  2 --
 .../opensearch/search/OpenSearchSearcherTest.java  |  7 ++---
 ...bageCollectionTaskAdditionalInformationDTO.java |  7 ++---
 .../BlobStoreVaultGarbageCollectionTaskDTO.java| 11 ---
 .../org/apache/james/vault/search/FieldName.java   | 18 +++
 ...aultGarbageCollectionTaskSerializationTest.java |  7 ++---
 .../mailbox/store/mail/model/DefaultMessageId.java | 18 +++
 .../mailbox/store/quota/FixedMaxQuotaManager.java  | 18 +++
 .../mpt/script/SimpleScriptedTestProtocol.java | 18 +++
 .../imapmailbox/suite/ACLScriptedTestProtocol.java | 18 +++
 .../imap/api/message/request/SearchOperation.java  |  2 +-
 .../imap/decode/parser/MoveCommandParser.java  | 18 +++
 .../imap/utils/FastByteArrayOutputStream.java  | 35 +++---
 .../protocols/lmtp/netty/NettyLMTPSServerTest.java | 18 +++
 ...PolicyConfigurationSanityEnforcementModule.java | 18 +++
 .../james/modules/server/HostnameModule.java   | 11 ---
 .../modules/DistributedTaskManagerModule.java  | 11 ---
 ...urcesMigrationTaskAdditionalInformationDTO.java |  8 ++---
 .../migration/MappingsSourcesMigrationTaskDTO.java | 11 ---
 .../apache/james/sieve/cassandra/model/Script.java | 19 +++-
 ...pingsSourcesMigrationTaskSerializationTest.java |  7 ++---
 .../file/SieveFileRepositoryTest.java  | 19 +++-
 .../upload/CassandraUploadRepository.java  | 18 +++
 .../memory/ForwardUsernameChangeTaskStepTest.java  | 18 +++
 .../dnsjava/ZoneCacheLookupRecordsAnswer.java  | 18 +++
 .../james/mailetcontainer/impl/matchers/And.java   |  4 +--
 .../org/apache/james/transport/util/Patterns.java  | 18 +++
 .../james/mailrepository/api/package-info.java | 20 +
 .../jmap/draft/exceptions/BadRequestException.java | 18 +++
 .../lib/mock/MockProtocolHandlerLoader.java| 18 +++
 .../MetaDataFixInconsistenciesServiceTest.java | 18 +++
 .../memory/MemoryQuotaSearchIntegrationTest.java   | 18 +++
 ...gesVaultExportTaskAdditionalInformationDTO.java | 11 ---
 .../routes/DeletedMessagesVaultExportTaskDTO.java  | 11 ---
 ...esVaultRestoreTaskAdditionalInformationDTO.java |  7 ++---
 .../routes/DeletedMessagesVaultRestoreTaskDTO.java |  8 ++---
 ...esVaultRestoreTaskAdditionalInformationDTO.java |  7 ++---
 ...tersRedeliveryTaskAdditionalInformationDTO.java | 18 +++
 .../james/queue/api/MailQueueFactoryTest.java  | 18 +++
 .../distributed/CancelRequestQueueName.java| 11 ---
 .../distributed/RabbitMQTerminationSubscriber.java | 11 ---
 .../distributed/RabbitMQWorkQueue.java | 11 ---
 .../RabbitMQWorkQueueReconnectionHandler.java  | 11 ---
 .../distributed/TerminationQueueName.java  | 11 ---
 .../TerminationReconnectionHandler.java| 11 ---
 ...andraTaskExecutionDetailsProjectionDAOTest.java | 11 ---
 .../RabbitMQTerminationSubscriberTest.java | 11 ---
 .../RabbitMQWorkQueuePersistenceTest.java  | 11 ---
 .../distributed/RabbitMQWorkQueueTest.java | 11 ---
 .../task/json/dto/MemoryReferenceTaskStore.java|  7 ++---
 .../dto/MemoryReferenceWithCounterTaskStore.java   |  7 ++---
 .../MemoryTaskExecutionDetailsProjectionTest.java  |  7 ++---
 .../MemoryTerminationSubscriberTest.java   |  7 ++---
 .../TaskExecutionDetailsProjectionContract.java| 11 ---
 .../TerminationSubscriberContract.java | 11 ---
 61 files changed, 598 insertions(+), 198 deletions(-)

diff --git 
a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/versions/SchemaVersionTest.java
 
b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/versions/SchemaVersionTest.java
index f53085c82b..2684e96f14 100644
--- 
a/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/versions/SchemaVersionTest.java
+++ 
b/backends-common/cassandra/src/test/java/org/apache/james/backends/cassandra/versions/SchemaVersionTest.java
@@ -1,3 +1,21

[james-project] 01/04: Checkstyle - support avoid debug code

2023-08-22 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit edf81389c08a066eff397f43de5ff80c38368778
Author: Tung Tran 
AuthorDate: Thu Aug 17 13:32:21 2023 +0700

Checkstyle - support avoid debug code
---
 .scalafix.conf| 8 +++-
 checkstyle.xml| 5 +
 .../integration/WebAdminServerIntegrationImmutableTest.java   | 2 +-
 .../james/webadmin/integration/WebAdminServerIntegrationTest.java | 2 +-
 4 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/.scalafix.conf b/.scalafix.conf
index 392b670b6d..be03f4b941 100644
--- a/.scalafix.conf
+++ b/.scalafix.conf
@@ -30,4 +30,10 @@ DisableSyntax.noDefaultArgs = false
 DisableSyntax.noFinalVal = true
 DisableSyntax.noFinalize = true
 DisableSyntax.noValPatterns = false
-DisableSyntax.noUniversalEquality = false
\ No newline at end of file
+DisableSyntax.noUniversalEquality = false
+DisableSyntax.regex = [
+  {
+pattern = ".prettyPeek()"
+message = "Found a debug code"
+  }
+]
\ No newline at end of file
diff --git a/checkstyle.xml b/checkstyle.xml
index 794862a826..2f80a5d7b0 100644
--- a/checkstyle.xml
+++ b/checkstyle.xml
@@ -30,6 +30,11 @@
   
   
   
+  
+
+
+
+  
   
 
   
diff --git 
a/server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationImmutableTest.java
 
b/server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationImmutableTest.java
index 3eb1b128d6..e4badb62cf 100644
--- 
a/server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationImmutableTest.java
+++ 
b/server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationImmutableTest.java
@@ -67,7 +67,7 @@ public abstract class WebAdminServerIntegrationImmutableTest {
 @Test
 void metricsRoutesShouldBeExposed() {
 String body = when()
-.get("/metrics").prettyPeek()
+.get("/metrics")
 .then()
 .statusCode(HttpStatus.OK_200)
 .extract()
diff --git 
a/server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
 
b/server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
index 59cdfc07ae..f70425b6b1 100644
--- 
a/server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
+++ 
b/server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
@@ -112,7 +112,7 @@ public abstract class WebAdminServerIntegrationTest {
 @Test
 void metricsRoutesShouldBeExposed() {
 String body = when()
-.get("/metrics").prettyPeek()
+.get("/metrics")
 .then()
 .statusCode(HttpStatus.OK_200)
 .extract()


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



[james-project] branch master updated (38ed64d6fc -> e4aea550f1)

2023-08-22 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


from 38ed64d6fc JAMES-3693 RedisHealthCheck (#1671)
 new edf81389c0 Checkstyle - support avoid debug code
 new c4372c875b Checkstyle - support check license in the header
 new b84a2ad83c [CLEAN CODE] Use one license template in the header
 new e4aea550f1 Checkstyle - support check license in the header - add 
message

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .scalafix.conf |  8 -
 .../cassandra/versions/SchemaVersionTest.java  | 18 +++
 .../james/backends/rabbitmq/QueueArguments.java| 18 +++
 checkstyle.xml | 11 +++
 .../mailbox/exception/InboxAlreadyCreated.java | 11 ---
 ...MailboxMergingTaskAdditionalInformationDTO.java | 11 ---
 .../cassandra/mail/task/MailboxMergingTaskDTO.java | 11 ---
 .../mailbox/inmemory/InMemoryMessageManager.java   | 18 +++
 .../mailbox/opensearch/json/MessageUpdateJson.java |  2 --
 .../opensearch/search/OpenSearchSearcherTest.java  |  7 ++---
 ...bageCollectionTaskAdditionalInformationDTO.java |  7 ++---
 .../BlobStoreVaultGarbageCollectionTaskDTO.java| 11 ---
 .../org/apache/james/vault/search/FieldName.java   | 18 +++
 ...aultGarbageCollectionTaskSerializationTest.java |  7 ++---
 .../mailbox/store/mail/model/DefaultMessageId.java | 18 +++
 .../mailbox/store/quota/FixedMaxQuotaManager.java  | 18 +++
 .../mpt/script/SimpleScriptedTestProtocol.java | 18 +++
 .../imapmailbox/suite/ACLScriptedTestProtocol.java | 18 +++
 .../imap/api/message/request/SearchOperation.java  |  2 +-
 .../imap/decode/parser/MoveCommandParser.java  | 18 +++
 .../imap/utils/FastByteArrayOutputStream.java  | 35 +++---
 .../protocols/lmtp/netty/NettyLMTPSServerTest.java | 18 +++
 ...PolicyConfigurationSanityEnforcementModule.java | 18 +++
 .../james/modules/server/HostnameModule.java   | 11 ---
 .../modules/DistributedTaskManagerModule.java  | 11 ---
 ...urcesMigrationTaskAdditionalInformationDTO.java |  8 ++---
 .../migration/MappingsSourcesMigrationTaskDTO.java | 11 ---
 .../apache/james/sieve/cassandra/model/Script.java | 19 +++-
 ...pingsSourcesMigrationTaskSerializationTest.java |  7 ++---
 .../file/SieveFileRepositoryTest.java  | 19 +++-
 .../upload/CassandraUploadRepository.java  | 18 +++
 .../memory/ForwardUsernameChangeTaskStepTest.java  | 18 +++
 .../dnsjava/ZoneCacheLookupRecordsAnswer.java  | 18 +++
 .../james/mailetcontainer/impl/matchers/And.java   |  4 +--
 .../org/apache/james/transport/util/Patterns.java  | 18 +++
 .../james/mailrepository/api/package-info.java | 20 +
 .../jmap/draft/exceptions/BadRequestException.java | 18 +++
 .../lib/mock/MockProtocolHandlerLoader.java| 18 +++
 .../MetaDataFixInconsistenciesServiceTest.java | 18 +++
 .../memory/MemoryQuotaSearchIntegrationTest.java   | 18 +++
 .../WebAdminServerIntegrationImmutableTest.java|  2 +-
 .../integration/WebAdminServerIntegrationTest.java |  2 +-
 ...gesVaultExportTaskAdditionalInformationDTO.java | 11 ---
 .../routes/DeletedMessagesVaultExportTaskDTO.java  | 11 ---
 ...esVaultRestoreTaskAdditionalInformationDTO.java |  7 ++---
 .../routes/DeletedMessagesVaultRestoreTaskDTO.java |  8 ++---
 ...esVaultRestoreTaskAdditionalInformationDTO.java |  7 ++---
 ...tersRedeliveryTaskAdditionalInformationDTO.java | 18 +++
 .../james/queue/api/MailQueueFactoryTest.java  | 18 +++
 .../distributed/CancelRequestQueueName.java| 11 ---
 .../distributed/RabbitMQTerminationSubscriber.java | 11 ---
 .../distributed/RabbitMQWorkQueue.java | 11 ---
 .../RabbitMQWorkQueueReconnectionHandler.java  | 11 ---
 .../distributed/TerminationQueueName.java  | 11 ---
 .../TerminationReconnectionHandler.java| 11 ---
 ...andraTaskExecutionDetailsProjectionDAOTest.java | 11 ---
 .../RabbitMQTerminationSubscriberTest.java | 11 ---
 .../RabbitMQWorkQueuePersistenceTest.java  | 11 ---
 .../distributed/RabbitMQWorkQueueTest.java | 11 ---
 .../task/json/dto/MemoryReferenceTaskStore.java|  7 ++---
 .../dto/MemoryReferenceWithCounterTaskStore.java   |  7 ++---
 .../MemoryTaskExecutionDetailsProjectionTest.java  |  7 ++---
 .../MemoryTerminationSubscriberTest.java   |  7 ++---
 .../TaskExecutionDetailsProjectionC

[james-project] branch master updated: JAMES-3693 RedisHealthCheck (#1671)

2023-08-18 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
 new 38ed64d6fc JAMES-3693 RedisHealthCheck (#1671)
38ed64d6fc is described below

commit 38ed64d6fc68b4e076d421c459b9217c28001d71
Author: Trần Hồng Quân <55171818+quantranhong1...@users.noreply.github.com>
AuthorDate: Fri Aug 18 15:39:09 2023 +0700

JAMES-3693 RedisHealthCheck (#1671)
---
 .../rate/limiter/redis/RedisHealthCheck.scala  |  64 +
 .../rate/limiter/redis/RedisRateLimiter.scala  |  13 ++-
 .../org/apache/james/rate/limiter/DockerRedis.java |  15 +++
 .../james/rate/limiter/RedisHealthCheckTest.scala  | 102 +
 4 files changed, 192 insertions(+), 2 deletions(-)

diff --git 
a/server/mailet/rate-limiter-redis/src/main/scala/org/apache/james/rate/limiter/redis/RedisHealthCheck.scala
 
b/server/mailet/rate-limiter-redis/src/main/scala/org/apache/james/rate/limiter/redis/RedisHealthCheck.scala
new file mode 100644
index 00..93690aa579
--- /dev/null
+++ 
b/server/mailet/rate-limiter-redis/src/main/scala/org/apache/james/rate/limiter/redis/RedisHealthCheck.scala
@@ -0,0 +1,64 @@
+/
+ * 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.rate.limiter.redis
+
+import java.time.Duration
+
+import io.lettuce.core.api.StatefulConnection
+import io.lettuce.core.cluster.RedisClusterClient
+import io.lettuce.core.codec.StringCodec
+import io.lettuce.core.{RedisClient, RedisURI}
+import javax.inject.Inject
+import org.apache.james.core.healthcheck.{ComponentName, HealthCheck, Result}
+import org.reactivestreams.Publisher
+import reactor.core.scala.publisher.SMono
+
+import scala.concurrent.ExecutionContext.Implicits.global
+import scala.jdk.CollectionConverters._
+import scala.jdk.FutureConverters._
+
+class RedisHealthCheck @Inject()(redisConfiguration: 
RedisRateLimiterConfiguration) extends HealthCheck {
+  private val redisComponent: ComponentName = new ComponentName("Redis")
+  private val healthcheckTimeout = Duration.ofSeconds(3)
+
+  override def componentName(): ComponentName = redisComponent
+
+  override def check(): Publisher[Result] =
+connectRedis()
+  .`then`(SMono.just(Result.healthy(redisComponent)))
+  .onErrorResume(_ => SMono.just(Result.degraded(redisComponent, "Can not 
connect to Redis.")))
+
+  private def connectRedis(): SMono[StatefulConnection[String, String]] =
+if (redisConfiguration.isCluster) {
+  val redisUris = redisConfiguration.redisURI.value.asJava
+  redisUris.forEach(redisUri => redisUri.setTimeout(healthcheckTimeout))
+  val redisClusterClient = RedisClusterClient.create(redisUris)
+
+  
SMono.fromFuture(redisClusterClient.connectAsync(StringCodec.UTF8).asScala)
+.doOnTerminate(() => redisClusterClient.shutdownAsync())
+} else {
+  val redisUri: RedisURI = redisConfiguration.redisURI.value.last
+  redisUri.setTimeout(healthcheckTimeout)
+  val redisClient = RedisClient.create(redisUri)
+
+  SMono.fromFuture(redisClient.connectAsync(StringCodec.UTF8, 
redisUri).asScala)
+.doOnTerminate(() => redisClient.shutdownAsync())
+}
+}
diff --git 
a/server/mailet/rate-limiter-redis/src/main/scala/org/apache/james/rate/limiter/redis/RedisRateLimiter.scala
 
b/server/mailet/rate-limiter-redis/src/main/scala/org/apache/james/rate/limiter/redis/RedisRateLimiter.scala
index 26a0d7b8ed..f04b86f0ce 100644
--- 
a/server/mailet/rate-limiter-redis/src/main/scala/org/apache/james/rate/limiter/redis/RedisRateLimiter.scala
+++ 
b/server/mailet/rate-limiter-redis/src/main/scala/org/apache/james/rate/limite

[james-project] branch master updated (b308d99c34 -> 2f0922d03d)

2023-08-18 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


from b308d99c34 [FIX] PropagateLookupRightListener: skip owner entries
 add 2f0922d03d JAMES-1975 Enhance DKIM integration tests (#1680)

No new revisions were added by this update.

Summary of changes:
 .../apache/james/mailets/DKIMIntegrationTest.java  | 68 +++---
 1 file changed, 46 insertions(+), 22 deletions(-)


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



[james-project] branch master updated (79774993f2 -> b308d99c34)

2023-08-18 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


from 79774993f2 [BUILD] Fix unstable SpamTrapHandlerTest.testSpamTrap test 
(#1685)
 add 933598fde2 [FIX] PropagateLookupRightListener should not fail on 
missing mailbox
 add b308d99c34 [FIX] PropagateLookupRightListener: skip owner entries

No new revisions were added by this update.

Summary of changes:
 .../apache/james/jmap/event/PropagateLookupRightListener.java| 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)


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



[james-project] branch master updated (7baf9da56b -> 79774993f2)

2023-08-18 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


from 7baf9da56b JAMES-3934 Allow external scheduling for RabbitMQ mailQueue 
browse st… (#1682)
 add 79774993f2 [BUILD] Fix unstable SpamTrapHandlerTest.testSpamTrap test 
(#1685)

No new revisions were added by this update.

Summary of changes:
 protocols/smtp/pom.xml |  5 +++
 .../smtp/core/fastfail/SpamTrapHandler.java| 38 +++--
 .../smtp/core/fastfail/SpamTrapHandlerTest.java| 49 +-
 .../james/smtpserver/fastfail/SpamTrapHandler.java |  7 
 4 files changed, 57 insertions(+), 42 deletions(-)


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



[james-project] branch master updated: JAMES-3934 Allow external scheduling for RabbitMQ mailQueue browse st… (#1682)

2023-08-18 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
 new 7baf9da56b JAMES-3934 Allow external scheduling for RabbitMQ mailQueue 
browse st… (#1682)
7baf9da56b is described below

commit 7baf9da56bbd42e4fc94c9cf5ae2a15ee0700b7a
Author: Benoit TELLIER 
AuthorDate: Fri Aug 18 07:24:51 2023 +0200

JAMES-3934 Allow external scheduling for RabbitMQ mailQueue browse st… 
(#1682)
---
 .../docs/modules/ROOT/pages/operate/webadmin.adoc  | 15 
 .../modules/server/BrowseStartTaskModule.java  | 63 +++
 .../server/RabbitMailQueueRoutesModule.java|  6 +-
 .../queue/rabbitmq/MailQueueViewChoice.java|  5 +-
 .../RabbitMQWebAdminServerIntegrationTest.java | 72 +
 .../routes/BrowseStartUpdateTaskRegistration.java} | 24 +++---
 .../webadmin/routes/RabbitMQMailQueuesRoutes.java  | 13 +++-
 .../webadmin/service/BrowseStartUpdateTask.java| 90 ++
 ...wseStartUpdateTaskAdditionalInformationDTO.java | 71 +
 .../webadmin/service/BrowseStartUpdateTaskDTO.java | 61 +++
 .../routes/RabbitMQMailQueuesRoutesTest.java   |  4 +-
 .../cassandra/CassandraMailQueueMailDelete.java| 10 ++-
 .../view/cassandra/CassandraMailQueueView.java |  4 +
 src/site/markdown/server/manage-webadmin.md| 15 
 14 files changed, 432 insertions(+), 21 deletions(-)

diff --git 
a/server/apps/distributed-app/docs/modules/ROOT/pages/operate/webadmin.adoc 
b/server/apps/distributed-app/docs/modules/ROOT/pages/operate/webadmin.adoc
index 46c5d00439..dcaec35bee 100644
--- a/server/apps/distributed-app/docs/modules/ROOT/pages/operate/webadmin.adoc
+++ b/server/apps/distributed-app/docs/modules/ROOT/pages/operate/webadmin.adoc
@@ -4076,6 +4076,21 @@ Response codes:
 The response body contains the id of the republishing task.
 `{  "taskId": "a650a66a-5984-431e-bdad-f1baad885856"  }`
 
+=== Cassandra view of the RabbitMQ mailQueue: browse start update
+
+
+curl -XPOST 'http://ip:port/mailQueues/{mailQueueName}?action=updateBrowseStart
+
+
+Will return a task that updates the browse start of the aforementioned 
mailQueue, regardless of the configuration.
+
+link:#_endpoints_returning_a_task[More details about endpoints returning
+a task].
+
+This is an advanced, potentially expensive operation which requires a good 
understanding of the RabbitMQMailQueue design
+(https://github.com/apache/james-project/blob/master/src/adr/0031-distributed-mail-queue.md).
 Especially, care needs to
+be taken to call this at most once per slice (not doing so might be expensive).
+
 == Sending email over webAdmin
 
 
diff --git 
a/server/container/guice/protocols/webadmin-rabbitmq-mailqueue/src/main/java/org/apache/james/modules/server/BrowseStartTaskModule.java
 
b/server/container/guice/protocols/webadmin-rabbitmq-mailqueue/src/main/java/org/apache/james/modules/server/BrowseStartTaskModule.java
new file mode 100644
index 00..60bb0fb882
--- /dev/null
+++ 
b/server/container/guice/protocols/webadmin-rabbitmq-mailqueue/src/main/java/org/apache/james/modules/server/BrowseStartTaskModule.java
@@ -0,0 +1,63 @@
+/
+ * 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.modules.server;
+
+import org.apache.james.queue.rabbitmq.view.cassandra.CassandraMailQueueView;
+import org.apache.james.server.task.json.dto.AdditionalInformationDTO;
+import org.apache.james.server.task.json.dto.AdditionalInformationDTOModule;
+import org.apache.james.server.task.json.dto.TaskDTO;
+import org.apache.james.server.task.json.dto.TaskDTOModule;
+im

[james-project] branch master updated: [BUILD] Changing OpenSearch waiting strategy (#1681)

2023-08-17 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
 new be816d0779 [BUILD] Changing OpenSearch waiting strategy (#1681)
be816d0779 is described below

commit be816d0779292ad7d1c00cfe07ec21a06681de1b
Author: Rene Cordier 
AuthorDate: Thu Aug 17 22:18:31 2023 +0700

[BUILD] Changing OpenSearch waiting strategy (#1681)
---
 .../james/backends/opensearch/DockerOpenSearch.java  | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git 
a/backends-common/opensearch/src/test/java/org/apache/james/backends/opensearch/DockerOpenSearch.java
 
b/backends-common/opensearch/src/test/java/org/apache/james/backends/opensearch/DockerOpenSearch.java
index e803d57fb2..ad94fb6a88 100644
--- 
a/backends-common/opensearch/src/test/java/org/apache/james/backends/opensearch/DockerOpenSearch.java
+++ 
b/backends-common/opensearch/src/test/java/org/apache/james/backends/opensearch/DockerOpenSearch.java
@@ -19,6 +19,7 @@
 
 package org.apache.james.backends.opensearch;
 
+import static java.net.HttpURLConnection.HTTP_OK;
 import static 
org.apache.james.backends.opensearch.DockerOpenSearch.Fixture.OS_HTTP_PORT;
 import static 
org.apache.james.backends.opensearch.DockerOpenSearch.Fixture.OS_MEMORY;
 
@@ -42,11 +43,11 @@ import 
org.apache.james.backends.opensearch.OpenSearchConfiguration.HostScheme;
 import org.apache.james.util.Host;
 import org.apache.james.util.docker.DockerContainer;
 import org.apache.james.util.docker.Images;
-import org.apache.james.util.docker.RateLimiters;
 import org.slf4j.LoggerFactory;
 import org.testcontainers.containers.GenericContainer;
 import org.testcontainers.containers.Network;
-import org.testcontainers.containers.wait.strategy.HostPortWaitStrategy;
+import org.testcontainers.containers.wait.strategy.HttpWaitStrategy;
+import org.testcontainers.containers.wait.strategy.WaitStrategy;
 import org.testcontainers.images.builder.ImageFromDockerfile;
 
 import com.google.common.collect.ImmutableMap;
@@ -130,6 +131,13 @@ public interface DockerOpenSearch {
 }
 
 class NoAuth implements DockerOpenSearch {
+private static WaitStrategy openSearchWaitStrategy() {
+return new HttpWaitStrategy()
+.forPort(OS_HTTP_PORT)
+.forStatusCodeMatching(response -> response == HTTP_OK)
+.withReadTimeout(Duration.ofSeconds(10))
+.withStartupTimeout(Duration.ofMinutes(3));
+}
 
 static DockerContainer defaultContainer(String imageName) {
 return DockerContainer.fromName(imageName)
@@ -138,10 +146,10 @@ public interface DockerOpenSearch {
 .withEnv("discovery.type", "single-node")
 .withEnv("DISABLE_INSTALL_DEMO_CONFIG", "true")
 .withEnv("DISABLE_SECURITY_PLUGIN", "true")
-.withEnv("ES_JAVA_OPTS", "-Xms" + OS_MEMORY + "m -Xmx" + 
OS_MEMORY + "m")
+.withEnv("OPENSEARCH_JAVA_OPTS", "-Xms" + OS_MEMORY + "m -Xmx" 
+ OS_MEMORY + "m")
 .withAffinityToContainer()
 .withName("james-testing-opensearch-" + UUID.randomUUID())
-.waitingFor(new 
HostPortWaitStrategy().withRateLimiter(RateLimiters.TWENTIES_PER_SECOND));
+.waitingFor(openSearchWaitStrategy());
 }
 
 private final DockerContainer eSContainer;


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



[james-project] branch master updated (00849bd72f -> cb544e3b46)

2023-08-16 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


from 00849bd72f JAMES-3927 Improve mailbox subscription management for JMAP 
(#1674)
 add cb544e3b46 [BUILD] Increase timeout of Cassandra Docker container wait 
strategy to 3 minutes (#1679)

No new revisions were added by this update.

Summary of changes:
 .../java/org/apache/james/backends/cassandra/CassandraWaitStrategy.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


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



[james-project] branch master updated (2b16647fd3 -> 00849bd72f)

2023-08-15 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


from 2b16647fd3 Exclude old JMS spec from dependencies to fix 
NoSuchMethodError when sending a message via SMTP
 add 00849bd72f JAMES-3927 Improve mailbox subscription management for JMAP 
(#1674)

No new revisions were added by this update.

Summary of changes:
 .../listener/MailboxSubscriptionListenerTest.java  | 148 +
 .../store/event/MailboxSubscriptionListener.java   | 106 +++
 .../modules/mailbox/CassandraMailboxModule.java|   3 +
 .../james/modules/mailbox/JPAMailboxModule.java|   5 +
 .../james/modules/mailbox/MemoryMailboxModule.java |   5 +
 .../contract/MailboxSetMethodContract.scala| 133 +-
 6 files changed, 397 insertions(+), 3 deletions(-)
 create mode 100644 
mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/listener/MailboxSubscriptionListenerTest.java
 create mode 100644 
mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxSubscriptionListener.java


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



[james-project] branch master updated: JAMES-3908 implement JMAP filtering: combine rule conditions (#1643)

2023-07-19 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
 new 76ac78344d JAMES-3908 implement JMAP filtering: combine rule 
conditions (#1643)
76ac78344d is described below

commit 76ac78344d489d2935b62d8cfefc5266eba3588d
Author: hungphan227 <45198168+hungphan...@users.noreply.github.com>
AuthorDate: Thu Jul 20 09:53:14 2023 +0700

JAMES-3908 implement JMAP filtering: combine rule conditions (#1643)
---
 .../james/jmap/cassandra/filtering/RuleDTO.java|  86 ++--
 .../james/jmap/cassandra/filtering/DTOTest.java|  32 -
 .../src/test/resources/json/event-v3.json  |  53 
 .../src/test/resources/json/eventComplex-v3.json   |  99 ++
 .../src/test/resources/json/increment-v3.json  | 114 
 .../org/apache/james/jmap/api/filtering/Rule.java  |  90 +++--
 .../james/jmap/api/filtering/RuleFixture.java  |  68 +-
 .../apache/james/jmap/api/filtering/RuleTest.java  |  24 ++--
 .../impl/FilterUsernameChangeTaskStepTest.java |   2 +-
 .../apache/james/jmap/draft/model/JmapRuleDTO.java |   8 +-
 .../james/jmap/mailet/filter/MailMatcher.java  |  75 ---
 .../jmap/mailet/filter/JMAPFilteringExtension.java |   2 +-
 .../jmap/mailet/filter/JMAPFilteringTest.java  | 150 +++--
 .../memory/MemoryUserDeletionIntegrationTest.java  |   2 +-
 .../MemoryUsernameChangeIntegrationTest.java   |   2 +-
 ...pulateFilteringProjectionRequestToTaskTest.java |   2 +-
 16 files changed, 668 insertions(+), 141 deletions(-)

diff --git 
a/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/RuleDTO.java
 
b/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/RuleDTO.java
index 86a39ac00a..a653d90e11 100644
--- 
a/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/RuleDTO.java
+++ 
b/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/RuleDTO.java
@@ -21,6 +21,7 @@ package org.apache.james.jmap.cassandra.filtering;
 
 import java.util.List;
 import java.util.Objects;
+import java.util.Optional;
 
 import org.apache.james.jmap.api.filtering.Rule;
 
@@ -32,6 +33,50 @@ import com.google.common.collect.ImmutableList;
 
 public class RuleDTO {
 
+public static class ConditionGroupDTO {
+
+private final Rule.ConditionCombiner conditionCombiner;
+private final List conditionDTOs;
+
+@JsonCreator
+public ConditionGroupDTO(@JsonProperty("conditionCombiner") 
Rule.ConditionCombiner conditionCombiner,
+ @JsonProperty("conditions") 
List conditionDTOs) {
+this.conditionCombiner = conditionCombiner;
+this.conditionDTOs = conditionDTOs;
+}
+
+public Rule.ConditionCombiner getConditionCombiner() {
+return conditionCombiner;
+}
+
+public List getConditions() {
+return conditionDTOs;
+}
+
+public Rule.ConditionGroup toConditionGroup() {
+return Rule.ConditionGroup.of(conditionCombiner, 
conditionDTOs.stream().map(ConditionDTO::toCondition).collect(ImmutableList.toImmutableList()));
+}
+
+public static ConditionGroupDTO from(Rule.ConditionGroup 
conditionGroup) {
+return new 
ConditionGroupDTO(conditionGroup.getConditionCombiner(), 
conditionGroup.getConditions().stream().map(ConditionDTO::from).collect(ImmutableList.toImmutableList()));
+}
+
+@Override
+public final boolean equals(Object o) {
+if (o instanceof ConditionGroupDTO) {
+ConditionGroupDTO other = (ConditionGroupDTO) o;
+return Objects.equals(conditionCombiner, 
other.conditionCombiner)
+&& Objects.equals(conditionDTOs, other.conditionDTOs);
+}
+return false;
+}
+
+@Override
+public int hashCode() {
+return Objects.hash(conditionCombiner, conditionDTOs);
+}
+}
+
 public static class ConditionDTO {
 
 public static ConditionDTO from(Rule.Condition condition) {
@@ -215,24 +260,44 @@ public class RuleDTO {
 public static RuleDTO from(Rule rule) {
 return new RuleDTO(rule.getId().asString(),
 rule.getName(),
-ConditionDTO.from(rule.getCondition()),
+ConditionGroupDTO.from(rule.getConditionGroup()),
 ActionDTO.from(rule.getAction()));
 }
 
 private final String id;
 private final String name;
-private final ConditionDTO conditionDTO;
+private final ConditionGroupDTO conditionGroupDTO;
 private final ActionDTO actionDTO;
 
+public RuleDTO(Str

[james-project] branch master updated (533b94b140 -> 2af7d4efb6)

2023-07-17 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


from 533b94b140 JAMES-3830 JMAP Quota draft compatibility (#1644)
 add 91ae7881ea JAMES-3755 More flexible startup timeout for Rspamd/ClamAV
 add 7bd96842e1 JAMES-3755 Update Unauthorized Code of Rspamd
 add 2af7d4efb6 JAMES-3755 Healthcheck for Rspamd

No new revisions were added by this update.

Summary of changes:
 third-party/rspamd/README.md   |  6 ++
 third-party/rspamd/docker-compose-distributed.yml  |  1 +
 third-party/rspamd/docker-compose.yml  |  1 +
 .../sample-configuration/healthcheck.properties|  9 +--
 .../james/rspamd/client/RspamdHttpClient.java  | 13 +++-
 .../rspamd/healthcheck/RspamdHealthCheck.java  | 28 ---
 .../java/org/apache/james/rspamd/DockerClamAV.java |  8 +-
 .../java/org/apache/james/rspamd/DockerRspamd.java | 19 -
 .../james/rspamd/client/RspamdHttpClientTest.java  | 15 +++-
 .../rspamd/healthcheck/RspamdHealthcheckTest.java  | 88 ++
 10 files changed, 157 insertions(+), 31 deletions(-)
 copy server/apps/distributed-app/sample-configuration/tika.properties => 
third-party/rspamd/sample-configuration/healthcheck.properties (75%)
 copy 
server/blob/blob-api/src/main/java/org/apache/james/blob/api/ObjectStorageHealthCheck.java
 => 
third-party/rspamd/src/main/java/org/apache/james/rspamd/healthcheck/RspamdHealthCheck.java
 (73%)
 create mode 100644 
third-party/rspamd/src/test/java/org/apache/james/rspamd/healthcheck/RspamdHealthcheckTest.java


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



[james-project] branch master updated: JAMES-3830 JMAP Quota draft compatibility (#1644)

2023-07-17 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
 new 533b94b140 JAMES-3830 JMAP Quota draft compatibility (#1644)
533b94b140 is described below

commit 533b94b1404475391996a260119bb5009b9923c6
Author: Trần Hồng Quân <55171818+quantranhong1...@users.noreply.github.com>
AuthorDate: Tue Jul 18 08:18:20 2023 +0700

JAMES-3830 JMAP Quota draft compatibility (#1644)
---
 .../docs/modules/ROOT/pages/configure/jvm.adoc |  13 +++
 .../rfc8621/contract/QuotaGetMethodContract.scala  | 128 +
 .../scala/org/apache/james/jmap/mail/Quotas.scala  |  20 +++-
 .../apache/james/jmap/method/QuotaGetMethod.scala  |   7 +-
 .../james/jmap/json/QuotaSerializerTest.scala  |  49 
 src/site/xdoc/server/config-system.xml |   4 +
 6 files changed, 216 insertions(+), 5 deletions(-)

diff --git 
a/server/apps/distributed-app/docs/modules/ROOT/pages/configure/jvm.adoc 
b/server/apps/distributed-app/docs/modules/ROOT/pages/configure/jvm.adoc
index d95acb2414..f1b9055822 100644
--- a/server/apps/distributed-app/docs/modules/ROOT/pages/configure/jvm.adoc
+++ b/server/apps/distributed-app/docs/modules/ROOT/pages/configure/jvm.adoc
@@ -65,3 +65,16 @@ james.blob.id.hash.encoding=base16
 
 Optional. String. Defaults to base64Url.
 
+== JMAP Quota draft compatibility
+
+Some JMAP clients depend on the JMAP Quota draft specifications. The property 
`james.jmap.quota.draft.compatibility` allows
+to enable JMAP Quota draft compatibility for those clients and allow them a 
time window to adapt to the RFC-9245 JMAP Quota.
+
+Optional. Boolean. Default to false.
+
+Ex in `jvm.properties`
+
+james.jmap.quota.draft.compatibility=true
+
+To enable the compatibility.
+
diff --git 
a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/QuotaGetMethodContract.scala
 
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/QuotaGetMethodContract.scala
index a095d89ac2..d4f80c22a5 100644
--- 
a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/QuotaGetMethodContract.scala
+++ 
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/QuotaGetMethodContract.scala
@@ -64,6 +64,8 @@ trait QuotaGetMethodContract {
   .setAuth(authScheme(UserCredential(BOB, BOB_PASSWORD)))
   .addHeader(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
   .build
+
+System.clearProperty("james.jmap.quota.draft.compatibility")
   }
 
   @Test
@@ -1359,4 +1361,130 @@ trait QuotaGetMethodContract {
  |""".stripMargin)
   }
 
+  @Test
+  def shouldSupportQuotaGetDraftCompatibilityWhenEnabled(server: 
GuiceJamesServer): Unit = {
+System.setProperty("james.jmap.quota.draft.compatibility", "true")
+
+val quotaProbe = server.getProbe(classOf[QuotaProbesImpl])
+val bobQuotaRoot = quotaProbe.getQuotaRoot(MailboxPath.inbox(BOB))
+quotaProbe.setMaxMessageCount(bobQuotaRoot, QuotaCountLimit.count(100L))
+quotaProbe.setMaxStorage(bobQuotaRoot, QuotaSizeLimit.unlimited())
+
+val response = `given`
+  .body(
+s"""{
+   |  "using": [
+   |"urn:ietf:params:jmap:core",
+   |"urn:ietf:params:jmap:quota"],
+   |  "methodCalls": [[
+   |"Quota/get",
+   |{
+   |  "accountId": 
"29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+   |  "ids": null
+   |},
+   |"c1"]]
+   |}""".stripMargin)
+.when
+  .post
+.`then`
+  .statusCode(SC_OK)
+  .contentType(JSON)
+  .extract
+  .body
+  .asString
+
+assertThatJson(response)
+  .withOptions(new Options(IGNORING_ARRAY_ORDER))
+  .isEqualTo(
+  s"""{
+ |"sessionState": "${SESSION_STATE.value}",
+ |"methodResponses": [
+ |[
+ |"Quota/get",
+ |{
+ |"accountId": 
"29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ |"notFound": [],
+ |"state": "84c40a2e-76a1-3f84-a1e8-862104c7a697",
+ |"list": [
+ |{
+ |  

[james-project] 01/03: JAMES-3920 SPF integration test

2023-07-17 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch 3.8.x
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 280b27162e18e793629d3afc43a3d33f7d40e2e9
Author: Benoit Tellier 
AuthorDate: Tue Jul 4 00:21:14 2023 +0700

JAMES-3920 SPF integration test

Check gmail is recognised as spoofed
---
 .../apache/james/mailets/SPFIntegrationTests.java  | 113 +
 .../org/apache/james/transport/mailets/SPF.java|   4 +-
 .../apache/james/transport/mailets/SPFTest.java|  21 ++--
 3 files changed, 123 insertions(+), 15 deletions(-)

diff --git 
a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SPFIntegrationTests.java
 
b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SPFIntegrationTests.java
new file mode 100644
index 00..3f1d71ff44
--- /dev/null
+++ 
b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SPFIntegrationTests.java
@@ -0,0 +1,113 @@
+/
+ * 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.mailets;
+
+import static 
org.apache.james.mailets.configuration.CommonProcessors.ERROR_REPOSITORY;
+import static org.apache.james.mailets.configuration.Constants.DEFAULT_DOMAIN;
+import static org.apache.james.mailets.configuration.Constants.FROM;
+import static org.apache.james.mailets.configuration.Constants.LOCALHOST_IP;
+import static org.apache.james.mailets.configuration.Constants.PASSWORD;
+import static org.apache.james.mailets.configuration.Constants.RECIPIENT;
+import static 
org.apache.james.mailets.configuration.Constants.awaitAtMostOneMinute;
+
+import java.io.File;
+
+import org.apache.james.MemoryJamesServerMain;
+import org.apache.james.mailbox.model.MailboxConstants;
+import org.apache.james.mailets.configuration.CommonProcessors;
+import org.apache.james.mailets.configuration.MailetConfiguration;
+import org.apache.james.mailets.configuration.MailetContainer;
+import org.apache.james.mailets.configuration.ProcessorConfiguration;
+import org.apache.james.modules.MailboxProbeImpl;
+import org.apache.james.modules.protocols.ImapGuiceProbe;
+import org.apache.james.modules.protocols.SieveProbeImpl;
+import org.apache.james.modules.protocols.SmtpGuiceProbe;
+import org.apache.james.probe.DataProbe;
+import org.apache.james.transport.mailets.SPF;
+import org.apache.james.transport.mailets.ToRepository;
+import org.apache.james.transport.matchers.All;
+import org.apache.james.transport.matchers.HasMailAttribute;
+import org.apache.james.transport.matchers.HasMailAttributeWithValue;
+import org.apache.james.transport.matchers.SizeGreaterThan;
+import org.apache.james.utils.DataProbeImpl;
+import org.apache.james.utils.MailRepositoryProbeImpl;
+import org.apache.james.utils.SMTPMessageSender;
+import org.apache.james.utils.TestIMAPClient;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+import org.junit.jupiter.api.io.TempDir;
+
+class SPFIntegrationTests {
+public static final String FROM = "u...@gmail.com";
+public static final String POSTMASTER = "postmaster@" + DEFAULT_DOMAIN;
+
+@RegisterExtension
+public TestIMAPClient testIMAPClient = new TestIMAPClient();
+@RegisterExtension
+public SMTPMessageSender messageSender = new 
SMTPMessageSender(DEFAULT_DOMAIN);
+
+private TemporaryJamesServer jamesServer;
+
+@BeforeEach
+void setup(@TempDir File temporaryFolder) throws Exception {
+jamesServer = TemporaryJamesServer.builder()
+.withBase(MemoryJamesServerMain.SMTP_AND_IMAP_MODUL

[james-project] 03/03: JAMES-3920 Add todo once AsynchronousSPFExecutor is fixed

2023-07-17 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch 3.8.x
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit a915dd19dc37238240a801c073ca22f435dab9a2
Author: Benoit Tellier 
AuthorDate: Tue Jul 4 00:29:53 2023 +0700

JAMES-3920 Add todo once AsynchronousSPFExecutor is fixed
---
 .../test/java/org/apache/james/mailets/SPFIntegrationTests.java  | 2 +-
 .../src/main/java/org/apache/james/transport/mailets/SPF.java| 9 +
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git 
a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SPFIntegrationTests.java
 
b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SPFIntegrationTests.java
index 3f1d71ff44..ebfdb0a2a5 100644
--- 
a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SPFIntegrationTests.java
+++ 
b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SPFIntegrationTests.java
@@ -101,7 +101,7 @@ class SPFIntegrationTests {
 .addMailet(MailetConfiguration.builder()
 .matcher(All.class)
 .mailet(SPF.class)
-.addProperty("checkLocalIps", "true"))
+.addProperty("ignoreLocalIps", "false"))
 .addMailet(MailetConfiguration.builder()
 .matcher(HasMailAttributeWithValue.class)
 
.matcherCondition("org.apache.james.transport.mailets.spf.result, softfail")
diff --git 
a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java
 
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java
index d215a73591..a6d9e4e5c9 100644
--- 
a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java
+++ 
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java
@@ -75,7 +75,7 @@ public class SPF extends GenericMailet {
 
 private boolean debug = false;
 private boolean addHeader = false;
-private boolean ignoreLocalIps = false;
+private boolean ignoreLocalIps = true;
 private org.apache.james.jspf.impl.SPF spf;
 public static final AttributeName EXPLANATION_ATTRIBUTE = 
AttributeName.of("org.apache.james.transport.mailets.spf.explanation");
 public static final AttributeName RESULT_ATTRIBUTE = 
AttributeName.of("org.apache.james.transport.mailets.spf.result");
@@ -100,7 +100,7 @@ public class SPF extends GenericMailet {
 public void init() {
 debug = Boolean.parseBoolean(getInitParameter("debug", "false"));
 addHeader = Boolean.parseBoolean(getInitParameter("addHeader", 
"false"));
-addHeader = Boolean.parseBoolean(getInitParameter("checkLocalIps", 
"false"));
+ignoreLocalIps = 
Boolean.parseBoolean(getInitParameter("ignoreLocalIps", "true"));
 
 if (spfDnsService == null) {
 createSPF(new DNSServiceXBillImpl());
@@ -118,13 +118,14 @@ public class SPF extends GenericMailet {
 }
 
 private void createSPF(org.apache.james.jspf.core.DNSService dnsProbe) {
+// TODO use once fixed AsynchronousSPFExecutor (see JAMES-3920)
 WiringServiceTable wiringService = new WiringServiceTable();
 wiringService.put(DNSServiceEnabled.class, dnsProbe);
 MacroExpand macroExpand = new MacroExpand(dnsProbe);
 wiringService.put(MacroExpandEnabled.class, macroExpand);
 RFC4408SPF1Parser parser = new RFC4408SPF1Parser(new 
DefaultTermsFactory(wiringService));
 SynchronousSPFExecutor executor = new SynchronousSPFExecutor(dnsProbe);
-spf = new org.apache.james.jspf.impl.SPF(dnsProbe, parser, 
macroExpand,executor );
+spf = new org.apache.james.jspf.impl.SPF(dnsProbe, parser, 
macroExpand, executor);
 wiringService.put(SPFCheckEnabled.class, spf);
 }
 
@@ -132,7 +133,7 @@ public class SPF extends GenericMailet {
 public void service(Mail mail) throws MessagingException {
 String remoteAddr = mail.getRemoteAddr();
 
-if (ignoreLocalIps || netMatcher.matchInetNetwork(remoteAddr)) {
+if (ignoreLocalIps && netMatcher.matchInetNetwork(remoteAddr)) {
 LOGGER.debug("ignore SPF check for ip:{}", remoteAddr);
 } else {
 String helo = AttributeUtils.getValueAndCastFromMail(mail, 
Mail.SMTP_HELO, String.class).orElse(mail.getRemoteHost());


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



[james-project] branch 3.8.x updated (e8e6152813 -> a915dd19dc)

2023-07-17 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a change to branch 3.8.x
in repository https://gitbox.apache.org/repos/asf/james-project.git


from e8e6152813 JAMES-3921 Fix Lucene indexing issues (#1621) (#1625)
 new 280b27162e JAMES-3920 SPF integration test
 new ce2f0b7161 JAMES-3920 Switch tu synchronous SPF executor
 new a915dd19dc JAMES-3920 Add todo once AsynchronousSPFExecutor is fixed

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 ...tegrationTest.java => SPFIntegrationTests.java} | 57 ++
 .../org/apache/james/transport/mailets/SPF.java| 30 ++--
 .../apache/james/transport/mailets/SPFTest.java| 35 ++---
 3 files changed, 67 insertions(+), 55 deletions(-)
 copy 
server/mailet/integration-testing/src/test/java/org/apache/james/mailets/{SizeGreaterThanIntegrationTest.java
 => SPFIntegrationTests.java} (73%)


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



[james-project] 02/03: JAMES-3920 Switch tu synchronous SPF executor

2023-07-17 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch 3.8.x
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit ce2f0b716122dc49ae3e1f124b6a2ec5e949136d
Author: Benoit Tellier 
AuthorDate: Tue Jul 4 00:23:06 2023 +0700

JAMES-3920 Switch tu synchronous SPF executor
---
 .../org/apache/james/transport/mailets/SPF.java| 25 +++---
 .../apache/james/transport/mailets/SPFTest.java| 14 ++--
 2 files changed, 29 insertions(+), 10 deletions(-)

diff --git 
a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java
 
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java
index 1bda369912..d215a73591 100644
--- 
a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java
+++ 
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java
@@ -27,8 +27,16 @@ import javax.mail.internet.MimeMessage;
 
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.dnsservice.library.netmatcher.NetMatcher;
+import org.apache.james.jspf.core.DNSServiceEnabled;
+import org.apache.james.jspf.core.MacroExpand;
+import org.apache.james.jspf.core.MacroExpandEnabled;
+import org.apache.james.jspf.core.SPFCheckEnabled;
 import org.apache.james.jspf.executor.SPFResult;
-import org.apache.james.jspf.impl.DefaultSPF;
+import org.apache.james.jspf.executor.SynchronousSPFExecutor;
+import org.apache.james.jspf.impl.DNSServiceXBillImpl;
+import org.apache.james.jspf.impl.DefaultTermsFactory;
+import org.apache.james.jspf.parser.RFC4408SPF1Parser;
+import org.apache.james.jspf.wiring.WiringServiceTable;
 import org.apache.mailet.Attribute;
 import org.apache.mailet.AttributeName;
 import org.apache.mailet.AttributeUtils;
@@ -95,9 +103,9 @@ public class SPF extends GenericMailet {
 addHeader = Boolean.parseBoolean(getInitParameter("checkLocalIps", 
"false"));
 
 if (spfDnsService == null) {
-spf = new DefaultSPF();
+createSPF(new DNSServiceXBillImpl());
 } else {
-spf = new org.apache.james.jspf.impl.SPF(spfDnsService);
+createSPF(spfDnsService);
 }
 
 Collection ignoredNetworks = Splitter.on(',')
@@ -109,6 +117,17 @@ public class SPF extends GenericMailet {
 LOGGER.info("SPF addHeader={} debug={} ignoredNetworks={}", addHeader, 
debug, ignoredNetworks);
 }
 
+private void createSPF(org.apache.james.jspf.core.DNSService dnsProbe) {
+WiringServiceTable wiringService = new WiringServiceTable();
+wiringService.put(DNSServiceEnabled.class, dnsProbe);
+MacroExpand macroExpand = new MacroExpand(dnsProbe);
+wiringService.put(MacroExpandEnabled.class, macroExpand);
+RFC4408SPF1Parser parser = new RFC4408SPF1Parser(new 
DefaultTermsFactory(wiringService));
+SynchronousSPFExecutor executor = new SynchronousSPFExecutor(dnsProbe);
+spf = new org.apache.james.jspf.impl.SPF(dnsProbe, parser, 
macroExpand,executor );
+wiringService.put(SPFCheckEnabled.class, spf);
+}
+
 @Override
 public void service(Mail mail) throws MessagingException {
 String remoteAddr = mail.getRemoteAddr();
diff --git 
a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/SPFTest.java
 
b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/SPFTest.java
index c7e378d731..688ac35187 100644
--- 
a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/SPFTest.java
+++ 
b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/SPFTest.java
@@ -60,7 +60,7 @@ public class SPFTest {
 @BeforeAll
 public static void setupMockedSPFDNSService() throws TimeoutException {
 mockedSPFDNSService = 
mock(org.apache.james.jspf.core.DNSService.class);
-when(mockedSPFDNSService.getRecordsAsync(any(DNSRequest.class)))
+when(mockedSPFDNSService.getRecords(any(DNSRequest.class)))
 .thenAnswer(invocation -> {
 DNSRequest req = invocation.getArgument(0);
 switch (req.getRecordType()) {
@@ -69,26 +69,26 @@ public class SPFTest {
 List l = new ArrayList<>();
 switch (req.getHostname()) {
 case "some.host.local":
-return CompletableFuture.completedFuture(l);
+return l;
 case "spf1.james.apache.org":
 // pass
 l.add("v=spf1 +all");
-return CompletableFuture.completedFuture(l);
+return l;
 case "spf2.james.apache.org":
 // fail
   

[james-project] branch master updated (ec09fd59fd -> 225dba3fc8)

2023-07-12 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


from ec09fd59fd [EXAMPLE] Add Outlook auto configuration Demo and sample 
auto configuration file in the Docker image
 add 594e883124 TLS Host name verification was added in 3.7.3
 add 225dba3fc8 Adjust change-list and fix link

No new revisions were added by this update.

Summary of changes:
 upgrade-instructions.md | 41 ++---
 1 file changed, 22 insertions(+), 19 deletions(-)


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



[james-project] 03/03: JAMES-3920 Add todo once AsynchronousSPFExecutor is fixed

2023-07-11 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 5a5db5f138a3b22c4833d860e8017e6ac7af4c43
Author: Benoit Tellier 
AuthorDate: Tue Jul 4 00:29:53 2023 +0700

JAMES-3920 Add todo once AsynchronousSPFExecutor is fixed
---
 .../test/java/org/apache/james/mailets/SPFIntegrationTests.java  | 2 +-
 .../src/main/java/org/apache/james/transport/mailets/SPF.java| 9 +
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git 
a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SPFIntegrationTests.java
 
b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SPFIntegrationTests.java
index 3f1d71ff44..ebfdb0a2a5 100644
--- 
a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SPFIntegrationTests.java
+++ 
b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SPFIntegrationTests.java
@@ -101,7 +101,7 @@ class SPFIntegrationTests {
 .addMailet(MailetConfiguration.builder()
 .matcher(All.class)
 .mailet(SPF.class)
-.addProperty("checkLocalIps", "true"))
+.addProperty("ignoreLocalIps", "false"))
 .addMailet(MailetConfiguration.builder()
 .matcher(HasMailAttributeWithValue.class)
 
.matcherCondition("org.apache.james.transport.mailets.spf.result, softfail")
diff --git 
a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java
 
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java
index d215a73591..a6d9e4e5c9 100644
--- 
a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java
+++ 
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java
@@ -75,7 +75,7 @@ public class SPF extends GenericMailet {
 
 private boolean debug = false;
 private boolean addHeader = false;
-private boolean ignoreLocalIps = false;
+private boolean ignoreLocalIps = true;
 private org.apache.james.jspf.impl.SPF spf;
 public static final AttributeName EXPLANATION_ATTRIBUTE = 
AttributeName.of("org.apache.james.transport.mailets.spf.explanation");
 public static final AttributeName RESULT_ATTRIBUTE = 
AttributeName.of("org.apache.james.transport.mailets.spf.result");
@@ -100,7 +100,7 @@ public class SPF extends GenericMailet {
 public void init() {
 debug = Boolean.parseBoolean(getInitParameter("debug", "false"));
 addHeader = Boolean.parseBoolean(getInitParameter("addHeader", 
"false"));
-addHeader = Boolean.parseBoolean(getInitParameter("checkLocalIps", 
"false"));
+ignoreLocalIps = 
Boolean.parseBoolean(getInitParameter("ignoreLocalIps", "true"));
 
 if (spfDnsService == null) {
 createSPF(new DNSServiceXBillImpl());
@@ -118,13 +118,14 @@ public class SPF extends GenericMailet {
 }
 
 private void createSPF(org.apache.james.jspf.core.DNSService dnsProbe) {
+// TODO use once fixed AsynchronousSPFExecutor (see JAMES-3920)
 WiringServiceTable wiringService = new WiringServiceTable();
 wiringService.put(DNSServiceEnabled.class, dnsProbe);
 MacroExpand macroExpand = new MacroExpand(dnsProbe);
 wiringService.put(MacroExpandEnabled.class, macroExpand);
 RFC4408SPF1Parser parser = new RFC4408SPF1Parser(new 
DefaultTermsFactory(wiringService));
 SynchronousSPFExecutor executor = new SynchronousSPFExecutor(dnsProbe);
-spf = new org.apache.james.jspf.impl.SPF(dnsProbe, parser, 
macroExpand,executor );
+spf = new org.apache.james.jspf.impl.SPF(dnsProbe, parser, 
macroExpand, executor);
 wiringService.put(SPFCheckEnabled.class, spf);
 }
 
@@ -132,7 +133,7 @@ public class SPF extends GenericMailet {
 public void service(Mail mail) throws MessagingException {
 String remoteAddr = mail.getRemoteAddr();
 
-if (ignoreLocalIps || netMatcher.matchInetNetwork(remoteAddr)) {
+if (ignoreLocalIps && netMatcher.matchInetNetwork(remoteAddr)) {
 LOGGER.debug("ignore SPF check for ip:{}", remoteAddr);
 } else {
 String helo = AttributeUtils.getValueAndCastFromMail(mail, 
Mail.SMTP_HELO, String.class).orElse(mail.getRemoteHost());


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



[james-project] 01/03: JAMES-3920 SPF integration test

2023-07-11 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit cf0897bff90cef3df94e483b648d1eb3eaabd30d
Author: Benoit Tellier 
AuthorDate: Tue Jul 4 00:21:14 2023 +0700

JAMES-3920 SPF integration test

Check gmail is recognised as spoofed
---
 .../apache/james/mailets/SPFIntegrationTests.java  | 113 +
 .../org/apache/james/transport/mailets/SPF.java|   4 +-
 .../apache/james/transport/mailets/SPFTest.java|  21 ++--
 3 files changed, 123 insertions(+), 15 deletions(-)

diff --git 
a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SPFIntegrationTests.java
 
b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SPFIntegrationTests.java
new file mode 100644
index 00..3f1d71ff44
--- /dev/null
+++ 
b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SPFIntegrationTests.java
@@ -0,0 +1,113 @@
+/
+ * 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.mailets;
+
+import static 
org.apache.james.mailets.configuration.CommonProcessors.ERROR_REPOSITORY;
+import static org.apache.james.mailets.configuration.Constants.DEFAULT_DOMAIN;
+import static org.apache.james.mailets.configuration.Constants.FROM;
+import static org.apache.james.mailets.configuration.Constants.LOCALHOST_IP;
+import static org.apache.james.mailets.configuration.Constants.PASSWORD;
+import static org.apache.james.mailets.configuration.Constants.RECIPIENT;
+import static 
org.apache.james.mailets.configuration.Constants.awaitAtMostOneMinute;
+
+import java.io.File;
+
+import org.apache.james.MemoryJamesServerMain;
+import org.apache.james.mailbox.model.MailboxConstants;
+import org.apache.james.mailets.configuration.CommonProcessors;
+import org.apache.james.mailets.configuration.MailetConfiguration;
+import org.apache.james.mailets.configuration.MailetContainer;
+import org.apache.james.mailets.configuration.ProcessorConfiguration;
+import org.apache.james.modules.MailboxProbeImpl;
+import org.apache.james.modules.protocols.ImapGuiceProbe;
+import org.apache.james.modules.protocols.SieveProbeImpl;
+import org.apache.james.modules.protocols.SmtpGuiceProbe;
+import org.apache.james.probe.DataProbe;
+import org.apache.james.transport.mailets.SPF;
+import org.apache.james.transport.mailets.ToRepository;
+import org.apache.james.transport.matchers.All;
+import org.apache.james.transport.matchers.HasMailAttribute;
+import org.apache.james.transport.matchers.HasMailAttributeWithValue;
+import org.apache.james.transport.matchers.SizeGreaterThan;
+import org.apache.james.utils.DataProbeImpl;
+import org.apache.james.utils.MailRepositoryProbeImpl;
+import org.apache.james.utils.SMTPMessageSender;
+import org.apache.james.utils.TestIMAPClient;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+import org.junit.jupiter.api.io.TempDir;
+
+class SPFIntegrationTests {
+public static final String FROM = "u...@gmail.com";
+public static final String POSTMASTER = "postmaster@" + DEFAULT_DOMAIN;
+
+@RegisterExtension
+public TestIMAPClient testIMAPClient = new TestIMAPClient();
+@RegisterExtension
+public SMTPMessageSender messageSender = new 
SMTPMessageSender(DEFAULT_DOMAIN);
+
+private TemporaryJamesServer jamesServer;
+
+@BeforeEach
+void setup(@TempDir File temporaryFolder) throws Exception {
+jamesServer = TemporaryJamesServer.builder()
+.withBase(MemoryJamesServerMain.SMTP_AND_IMAP_MODUL

[james-project] 02/03: JAMES-3920 Switch tu synchronous SPF executor

2023-07-11 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 2dfe0ed14ba582a1c507f14f6d3cab531125d516
Author: Benoit Tellier 
AuthorDate: Tue Jul 4 00:23:06 2023 +0700

JAMES-3920 Switch tu synchronous SPF executor
---
 .../org/apache/james/transport/mailets/SPF.java| 25 +++---
 .../apache/james/transport/mailets/SPFTest.java| 14 ++--
 2 files changed, 29 insertions(+), 10 deletions(-)

diff --git 
a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java
 
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java
index 1bda369912..d215a73591 100644
--- 
a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java
+++ 
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java
@@ -27,8 +27,16 @@ import javax.mail.internet.MimeMessage;
 
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.dnsservice.library.netmatcher.NetMatcher;
+import org.apache.james.jspf.core.DNSServiceEnabled;
+import org.apache.james.jspf.core.MacroExpand;
+import org.apache.james.jspf.core.MacroExpandEnabled;
+import org.apache.james.jspf.core.SPFCheckEnabled;
 import org.apache.james.jspf.executor.SPFResult;
-import org.apache.james.jspf.impl.DefaultSPF;
+import org.apache.james.jspf.executor.SynchronousSPFExecutor;
+import org.apache.james.jspf.impl.DNSServiceXBillImpl;
+import org.apache.james.jspf.impl.DefaultTermsFactory;
+import org.apache.james.jspf.parser.RFC4408SPF1Parser;
+import org.apache.james.jspf.wiring.WiringServiceTable;
 import org.apache.mailet.Attribute;
 import org.apache.mailet.AttributeName;
 import org.apache.mailet.AttributeUtils;
@@ -95,9 +103,9 @@ public class SPF extends GenericMailet {
 addHeader = Boolean.parseBoolean(getInitParameter("checkLocalIps", 
"false"));
 
 if (spfDnsService == null) {
-spf = new DefaultSPF();
+createSPF(new DNSServiceXBillImpl());
 } else {
-spf = new org.apache.james.jspf.impl.SPF(spfDnsService);
+createSPF(spfDnsService);
 }
 
 Collection ignoredNetworks = Splitter.on(',')
@@ -109,6 +117,17 @@ public class SPF extends GenericMailet {
 LOGGER.info("SPF addHeader={} debug={} ignoredNetworks={}", addHeader, 
debug, ignoredNetworks);
 }
 
+private void createSPF(org.apache.james.jspf.core.DNSService dnsProbe) {
+WiringServiceTable wiringService = new WiringServiceTable();
+wiringService.put(DNSServiceEnabled.class, dnsProbe);
+MacroExpand macroExpand = new MacroExpand(dnsProbe);
+wiringService.put(MacroExpandEnabled.class, macroExpand);
+RFC4408SPF1Parser parser = new RFC4408SPF1Parser(new 
DefaultTermsFactory(wiringService));
+SynchronousSPFExecutor executor = new SynchronousSPFExecutor(dnsProbe);
+spf = new org.apache.james.jspf.impl.SPF(dnsProbe, parser, 
macroExpand,executor );
+wiringService.put(SPFCheckEnabled.class, spf);
+}
+
 @Override
 public void service(Mail mail) throws MessagingException {
 String remoteAddr = mail.getRemoteAddr();
diff --git 
a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/SPFTest.java
 
b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/SPFTest.java
index c7e378d731..688ac35187 100644
--- 
a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/SPFTest.java
+++ 
b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/SPFTest.java
@@ -60,7 +60,7 @@ public class SPFTest {
 @BeforeAll
 public static void setupMockedSPFDNSService() throws TimeoutException {
 mockedSPFDNSService = 
mock(org.apache.james.jspf.core.DNSService.class);
-when(mockedSPFDNSService.getRecordsAsync(any(DNSRequest.class)))
+when(mockedSPFDNSService.getRecords(any(DNSRequest.class)))
 .thenAnswer(invocation -> {
 DNSRequest req = invocation.getArgument(0);
 switch (req.getRecordType()) {
@@ -69,26 +69,26 @@ public class SPFTest {
 List l = new ArrayList<>();
 switch (req.getHostname()) {
 case "some.host.local":
-return CompletableFuture.completedFuture(l);
+return l;
 case "spf1.james.apache.org":
 // pass
 l.add("v=spf1 +all");
-return CompletableFuture.completedFuture(l);
+return l;
 case "spf2.james.apache.org":
 

[james-project] branch master updated (92353c9144 -> 5a5db5f138)

2023-07-11 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


from 92353c9144 Register the DNSPublicKeyRecordRetriever bean so the 
DKIMVerify mailet works correctly (#1638)
 new cf0897bff9 JAMES-3920 SPF integration test
 new 2dfe0ed14b JAMES-3920 Switch tu synchronous SPF executor
 new 5a5db5f138 JAMES-3920 Add todo once AsynchronousSPFExecutor is fixed

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 ...tegrationTest.java => SPFIntegrationTests.java} | 57 ++
 .../org/apache/james/transport/mailets/SPF.java| 30 ++--
 .../apache/james/transport/mailets/SPFTest.java| 35 ++---
 3 files changed, 67 insertions(+), 55 deletions(-)
 copy 
server/mailet/integration-testing/src/test/java/org/apache/james/mailets/{SizeGreaterThanIntegrationTest.java
 => SPFIntegrationTests.java} (73%)


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



[james-project] branch master updated: Register the DNSPublicKeyRecordRetriever bean so the DKIMVerify mailet works correctly (#1638)

2023-07-11 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
 new 92353c9144 Register the DNSPublicKeyRecordRetriever bean so the 
DKIMVerify mailet works correctly (#1638)
92353c9144 is described below

commit 92353c914487cc1420a22089939a91e0fc4d318a
Author: asdfjkluiop <47774017+asdfjklu...@users.noreply.github.com>
AuthorDate: Tue Jul 11 02:32:46 2023 -0700

Register the DNSPublicKeyRecordRetriever bean so the DKIMVerify mailet 
works correctly (#1638)

Co-authored-by: Scoopta 
---
 .../main/resources/META-INF/org/apache/james/spring-server.xml| 8 
 1 file changed, 8 insertions(+)

diff --git 
a/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
 
b/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
index 9165e0b055..7e68e89591 100644
--- 
a/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
+++ 
b/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
@@ -315,4 +315,12 @@
 
 
 
+
+
+
+
 


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



[james-project] branch master updated: JAMES-2600 implement an object storage healthcheck (#1637)

2023-07-11 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
 new 63740a8efd JAMES-2600 implement an object storage healthcheck (#1637)
63740a8efd is described below

commit 63740a8efd739fcdc9b040e1e2a6fb7a8e9cd519
Author: hungphan227 <45198168+hungphan...@users.noreply.github.com>
AuthorDate: Tue Jul 11 14:23:01 2023 +0700

JAMES-2600 implement an object storage healthcheck (#1637)
---
 server/blob/blob-api/pom.xml   |  8 +++
 .../james/blob/api/ObjectStorageHealthCheck.java   | 59 
 .../objectstorage/aws/DockerAwsS3Container.java| 15 
 .../blob/objectstorage/aws/S3HealthCheckTest.java  | 82 ++
 server/container/guice/distributed/pom.xml |  4 ++
 .../modules/blobstore/BlobStoreModulesChooser.java |  4 ++
 ...itMQWebAdminServerIntegrationImmutableTest.java |  2 +-
 7 files changed, 173 insertions(+), 1 deletion(-)

diff --git a/server/blob/blob-api/pom.xml b/server/blob/blob-api/pom.xml
index 8c779e796f..5613a52e17 100644
--- a/server/blob/blob-api/pom.xml
+++ b/server/blob/blob-api/pom.xml
@@ -33,6 +33,10 @@
 Apache James :: Server :: Blob :: API
 
 
+
+${james.groupId}
+james-core
+
 
 ${james.groupId}
 james-server-util
@@ -61,6 +65,10 @@
 commons-io
 test
 
+
+io.projectreactor.addons
+reactor-extra
+
 
 javax.inject
 javax.inject
diff --git 
a/server/blob/blob-api/src/main/java/org/apache/james/blob/api/ObjectStorageHealthCheck.java
 
b/server/blob/blob-api/src/main/java/org/apache/james/blob/api/ObjectStorageHealthCheck.java
new file mode 100644
index 00..555c1d5fed
--- /dev/null
+++ 
b/server/blob/blob-api/src/main/java/org/apache/james/blob/api/ObjectStorageHealthCheck.java
@@ -0,0 +1,59 @@
+/
+ * 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.blob.api;
+
+import java.time.Duration;
+
+import javax.inject.Inject;
+
+import org.apache.james.core.healthcheck.ComponentName;
+import org.apache.james.core.healthcheck.HealthCheck;
+import org.apache.james.core.healthcheck.Result;
+
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
+
+public class ObjectStorageHealthCheck implements HealthCheck {
+
+private static final Integer HEALTH_CHECK_TIMEOUT = 10;
+
+private static final ComponentName COMPONENT_NAME = new 
ComponentName("ObjectStorage");
+
+private final BlobStoreDAO blobStoreDAO;
+
+@Inject
+public ObjectStorageHealthCheck(BlobStoreDAO blobStoreDAO) {
+this.blobStoreDAO = blobStoreDAO;
+}
+
+@Override
+public ComponentName componentName() {
+return COMPONENT_NAME;
+}
+
+@Override
+public Mono check() {
+return Flux.from(blobStoreDAO.listBuckets())
+.timeout(Duration.ofSeconds(HEALTH_CHECK_TIMEOUT))
+.next()
+.thenReturn(Result.healthy(COMPONENT_NAME))
+.onErrorResume(e -> Mono.just(Result.unhealthy(COMPONENT_NAME, 
"Error checking ObjectSotrage", e)));
+}
+}
diff --git 
a/server/blob/blob-s3/src/test/java/org/apache/james/blob/objectstorage/aws/DockerAwsS3Container.java
 
b/server/blob/blob-s3/src/test/java/org/apache/james/blob/objectstorage/aws/DockerAwsS3Container.java
index 98e0e8070b..d47469054c 100644
--- 
a/server/blob/blob-s3/src/test/java/org/apache/james/blob/objectstorage/aws/DockerAwsS3Container.java
+++ 
b/server/blob/blob-s3/src/test/java/org/apache/james/blob/objectstorage/aws/Do

[james-project] branch master updated: Upgrade EmailSubmissionSetMethodFutureReleaseTest for distributed test (#1635)

2023-07-09 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
 new 572c4d76bf Upgrade EmailSubmissionSetMethodFutureReleaseTest for 
distributed test (#1635)
572c4d76bf is described below

commit 572c4d76bf86b9fe9691379b0a5052fb09cfe0c8
Author: vtbui <87489927+thanhbv200...@users.noreply.github.com>
AuthorDate: Mon Jul 10 10:45:55 2023 +0700

Upgrade EmailSubmissionSetMethodFutureReleaseTest for distributed test 
(#1635)
---
 ...dEmailSubmissionSetMethodFutureReleaseTest.java |  96 +++
 ...lSubmissionSetMethodFutureReleaseContract.scala | 105 -
 2 files changed, 175 insertions(+), 26 deletions(-)

diff --git 
a/server/protocols/jmap-rfc-8621-integration-tests/distributed-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/distributed/DistributedEmailSubmissionSetMethodFutureReleaseTest.java
 
b/server/protocols/jmap-rfc-8621-integration-tests/distributed-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/distributed/DistributedEmailSubmissionSetMethodFutureReleaseTest.java
new file mode 100644
index 00..1c67d4b24b
--- /dev/null
+++ 
b/server/protocols/jmap-rfc-8621-integration-tests/distributed-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/distributed/DistributedEmailSubmissionSetMethodFutureReleaseTest.java
@@ -0,0 +1,96 @@
+/
+ * 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.jmap.rfc8621.distributed;
+
+import org.apache.james.CassandraExtension;
+import org.apache.james.CassandraRabbitMQJamesConfiguration;
+import org.apache.james.CassandraRabbitMQJamesServerMain;
+import org.apache.james.ClockExtension;
+import org.apache.james.DockerOpenSearchExtension;
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.JamesServerBuilder;
+import org.apache.james.JamesServerExtension;
+import org.apache.james.SearchConfiguration;
+import 
org.apache.james.jmap.rfc8621.contract.EmailSubmissionSetMethodFutureReleaseContract;
+import org.apache.james.jmap.rfc8621.contract.probe.DelegationProbeModule;
+import org.apache.james.mailbox.cassandra.ids.CassandraMessageId;
+import org.apache.james.mailbox.model.MessageId;
+import org.apache.james.modules.AwsS3BlobStoreExtension;
+import org.apache.james.modules.RabbitMQExtension;
+import org.apache.james.modules.TestJMAPServerModule;
+import org.apache.james.modules.blobstore.BlobStoreConfiguration;
+import org.apache.james.utils.UpdatableTickingClock;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import com.datastax.oss.driver.api.core.uuid.Uuids;
+import com.google.inject.name.Names;
+
+public class DistributedEmailSubmissionSetMethodFutureReleaseTest implements 
EmailSubmissionSetMethodFutureReleaseContract {
+public static final CassandraMessageId.Factory MESSAGE_ID_FACTORY = new 
CassandraMessageId.Factory();
+
+@RegisterExtension
+static JamesServerExtension testExtension = new 
JamesServerBuilder(tmpDir ->
+CassandraRabbitMQJamesConfiguration.builder()
+.workingDirectory(tmpDir)
+.configurationFromClasspath()
+.enableJMAP()
+.blobStore(BlobStoreConfiguration.builder()
+.s3()
+.disableCache()
+.deduplication()
+.noCryptoConfig())
+.searchConfiguration(SearchConfiguration.openSearch())
+.build())
+.extension(new DockerOpenSearchExtension())
+.extension(new CassandraExtension())
+.extension(new RabbitMQExtensi

[james-project] branch master updated: JAMES-2287 HashBlobId.Factory support encoding type (#1632)

2023-07-09 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
 new c1c9c268f3 JAMES-2287 HashBlobId.Factory support encoding type (#1632)
c1c9c268f3 is described below

commit c1c9c268f3f42a18387b3a2bba2e08a3270eb956
Author: vttran 
AuthorDate: Mon Jul 10 09:01:01 2023 +0700

JAMES-2287 HashBlobId.Factory support encoding type (#1632)
---
 .../docs/modules/ROOT/pages/configure/jvm.adoc |  12 ++
 .../java/org/apache/james/blob/api/HashBlobId.java |  33 +-
 .../org/apache/james/blob/api/HashBlobIdTest.java  |  42 ++-
 server/blob/blob-s3/pom.xml|   5 +
 .../james/blob/objectstorage/aws/S3MinioTest.java  | 123 +
 src/site/xdoc/server/config-system.xml |   3 +
 6 files changed, 214 insertions(+), 4 deletions(-)

diff --git 
a/server/apps/distributed-app/docs/modules/ROOT/pages/configure/jvm.adoc 
b/server/apps/distributed-app/docs/modules/ROOT/pages/configure/jvm.adoc
index f0440ab4b2..d95acb2414 100644
--- a/server/apps/distributed-app/docs/modules/ROOT/pages/configure/jvm.adoc
+++ b/server/apps/distributed-app/docs/modules/ROOT/pages/configure/jvm.adoc
@@ -53,3 +53,15 @@ james.protocols.mdc.hostname=false
 
 Optional. Boolean. Defaults to true.
 
+== Change the encoding type used for the blobId
+
+By default, the blobId is encoded in base64 url. The property 
`james.blob.id.hash.encoding` allows to change the encoding type.
+The support value are: base16, hex, base32, base32Hex, base64, base64Url.
+
+Ex in `jvm.properties`
+
+james.blob.id.hash.encoding=base16
+
+
+Optional. String. Defaults to base64Url.
+
diff --git 
a/server/blob/blob-api/src/main/java/org/apache/james/blob/api/HashBlobId.java 
b/server/blob/blob-api/src/main/java/org/apache/james/blob/api/HashBlobId.java
index e716df4040..55c1329e27 100644
--- 
a/server/blob/blob-api/src/main/java/org/apache/james/blob/api/HashBlobId.java
+++ 
b/server/blob/blob-api/src/main/java/org/apache/james/blob/api/HashBlobId.java
@@ -20,7 +20,7 @@
 package org.apache.james.blob.api;
 
 import java.io.IOException;
-import java.util.Base64;
+import java.util.Optional;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.MoreObjects;
@@ -29,11 +29,22 @@ import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
 import com.google.common.hash.HashCode;
 import com.google.common.hash.Hashing;
+import com.google.common.io.BaseEncoding;
 import com.google.common.io.ByteSource;
 
 public class HashBlobId implements BlobId {
+private static final String HASH_BLOB_ID_ENCODING_TYPE_PROPERTY = 
"james.blob.id.hash.encoding";
+private static final BaseEncoding HASH_BLOB_ID_ENCODING_DEFAULT = 
BaseEncoding.base64Url();
 
 public static class Factory implements BlobId.Factory {
+private final BaseEncoding baseEncoding;
+
+public Factory() {
+this.baseEncoding = 
Optional.ofNullable(System.getProperty(HASH_BLOB_ID_ENCODING_TYPE_PROPERTY))
+.map(Factory::baseEncodingFrom)
+.orElse(HASH_BLOB_ID_ENCODING_DEFAULT);
+}
+
 @Override
 public HashBlobId forPayload(byte[] payload) {
 Preconditions.checkArgument(payload != null);
@@ -51,7 +62,7 @@ public class HashBlobId implements BlobId {
 
 private HashBlobId base64(HashCode hashCode) {
 byte[] bytes = hashCode.asBytes();
-return new HashBlobId(Base64.getEncoder().encodeToString(bytes));
+return new HashBlobId(baseEncoding.encode(bytes));
 }
 
 @Override
@@ -59,6 +70,24 @@ public class HashBlobId implements BlobId {
 Preconditions.checkArgument(!Strings.isNullOrEmpty(id));
 return new HashBlobId(id);
 }
+
+private static BaseEncoding baseEncodingFrom(String encodingType) {
+switch (encodingType) {
+case "base16":
+case "hex":
+return BaseEncoding.base16();
+case "base64":
+return BaseEncoding.base64();
+case "base64Url":
+return BaseEncoding.base64Url();
+case "base32":
+return BaseEncoding.base32();
+case "base32Hex":
+return BaseEncoding.base32Hex();
+default:
+throw new IllegalArgumentException("Unknown encoding type: 
" + encodingType);
+}
+}
 }
 
 private final String id;
diff --git 
a/server/blob/blob-api/src/test/java/org/apache/james/blob/api/HashBlobIdTest.java
 
b/server/blob/blob-api/src/test/java/org/apache/james/blob/api/HashBlobIdTest.java
i

[james-project] branch master updated: Move rabbitMQ channel close operation to boundedElastic thread (#1639)

2023-07-09 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
 new 3011d23f9a Move rabbitMQ channel close operation to boundedElastic 
thread (#1639)
3011d23f9a is described below

commit 3011d23f9a2837e245a2616391168f51f765f195
Author: Arooba Shahoor <56495631+arooba-...@users.noreply.github.com>
AuthorDate: Mon Jul 10 10:59:35 2023 +0900

Move rabbitMQ channel close operation to boundedElastic thread (#1639)

This prevents the call from blocking the reactive pipeline
---
 .../apache/james/backends/rabbitmq/ReactorRabbitMQChannelPool.java| 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git 
a/backends-common/rabbitmq/src/main/java/org/apache/james/backends/rabbitmq/ReactorRabbitMQChannelPool.java
 
b/backends-common/rabbitmq/src/main/java/org/apache/james/backends/rabbitmq/ReactorRabbitMQChannelPool.java
index fc65f6b1d6..80368108ca 100644
--- 
a/backends-common/rabbitmq/src/main/java/org/apache/james/backends/rabbitmq/ReactorRabbitMQChannelPool.java
+++ 
b/backends-common/rabbitmq/src/main/java/org/apache/james/backends/rabbitmq/ReactorRabbitMQChannelPool.java
@@ -685,7 +685,9 @@ public class ReactorRabbitMQChannelPool implements 
ChannelPool, Startable {
 if (channel.isOpen()) {
 channel.close();
 }
-})))
+}))
+.then()
+.subscribeOn(Schedulers.boundedElastic()))
 .buildPool();
 }
 


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



[james-project] branch master updated: [FIX] JMAP Session should use temporary redirects (#1636)

2023-07-06 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
 new dba61ffc9e [FIX] JMAP Session should use temporary redirects (#1636)
dba61ffc9e is described below

commit dba61ffc9ee1e4a69fa9e02f53a7f36c5f9cff4f
Author: Benoit TELLIER 
AuthorDate: Fri Jul 7 12:14:11 2023 +0700

[FIX] JMAP Session should use temporary redirects (#1636)

Permanent redirects causes Safari to drop
Authorization headers
---
 .../test/scala/org/apache/james/jmap/routes/SessionRoutesTest.scala   | 2 +-
 .../jmap/src/main/java/org/apache/james/jmap/JMAPRoutes.java  | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git 
a/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/routes/SessionRoutesTest.scala
 
b/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/routes/SessionRoutesTest.scala
index 57650bf80d..699f51dbab 100644
--- 
a/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/routes/SessionRoutesTest.scala
+++ 
b/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/routes/SessionRoutesTest.scala
@@ -116,7 +116,7 @@ class SessionRoutesTest extends AnyFlatSpec with 
BeforeAndAfter with Matchers {
   .redirects().follow(false)
   .get
 .`then`
-  .statusCode(308)
+  .statusCode(302)
   .header("Location", "/jmap/session")
   }
 
diff --git 
a/server/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPRoutes.java 
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPRoutes.java
index fe7e4a3386..94dea485ac 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPRoutes.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPRoutes.java
@@ -20,8 +20,8 @@
 package org.apache.james.jmap;
 
 import static io.netty.handler.codec.http.HttpResponseStatus.BAD_REQUEST;
+import static io.netty.handler.codec.http.HttpResponseStatus.FOUND;
 import static 
io.netty.handler.codec.http.HttpResponseStatus.INTERNAL_SERVER_ERROR;
-import static 
io.netty.handler.codec.http.HttpResponseStatus.PERMANENT_REDIRECT;
 import static io.netty.handler.codec.http.HttpResponseStatus.UNAUTHORIZED;
 
 import java.util.stream.Stream;
@@ -45,7 +45,7 @@ public interface JMAPRoutes {
 }
 
 static JMAPRoute.Action redirectTo(String location) {
-return (req, res) -> res.status(PERMANENT_REDIRECT).header("Location", 
location).send();
+return (req, res) -> res.status(FOUND).header("Location", 
location).send();
 }
 
 default Mono handleInternalError(HttpServerResponse response, Logger 
logger, Throwable e) {


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



[james-project] 07/07: [UPGRADE] reactor-rabbitmq 1.5.5 -> 1.5.6

2023-07-06 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit c94d134ae8bba116e34f664a873a880c56462d72
Author: Quan Tran 
AuthorDate: Thu Jul 6 11:20:27 2023 +0700

[UPGRADE] reactor-rabbitmq 1.5.5 -> 1.5.6
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 2c059020de..bbea10ea76 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2448,7 +2448,7 @@
 
 io.projectreactor.rabbitmq
 reactor-rabbitmq
-1.5.5
+1.5.6
 
 
 io.rest-assured


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



[james-project] 04/07: [UPGRADE] amqp-client 5.16.0 -> 5.18.0

2023-07-06 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 392634382972b08238045471daf692decd64ad90
Author: Quan Tran 
AuthorDate: Thu Jul 6 10:18:48 2023 +0700

[UPGRADE] amqp-client 5.16.0 -> 5.18.0
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index a2740d1a22..6e41bab8a1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2211,7 +2211,7 @@
 
 com.rabbitmq
 amqp-client
-5.16.0
+5.18.0
 
 
 com.sparkjava


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



[james-project] 05/07: [UPGRADE] Cassandra driver 4.15.0 -> 4.16.0

2023-07-06 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit cae37b91ddbadc0f46476197208fc037cdad7cf3
Author: Quan Tran 
AuthorDate: Thu Jul 6 10:25:00 2023 +0700

[UPGRADE] Cassandra driver 4.15.0 -> 4.16.0
---
 backends-common/cassandra/pom.xml | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/backends-common/cassandra/pom.xml 
b/backends-common/cassandra/pom.xml
index d6966e7117..29f620aa73 100644
--- a/backends-common/cassandra/pom.xml
+++ b/backends-common/cassandra/pom.xml
@@ -30,6 +30,10 @@
 apache-james-backends-cassandra
 Apache James :: Backends Common :: Cassandra
 
+
+4.16.0
+
+
 
 
 ${james.groupId}
@@ -60,12 +64,12 @@
 
 com.datastax.oss
 java-driver-core
-4.15.0
+${cassandra.driver.version}
 
 
 com.datastax.oss
 java-driver-query-builder
-4.15.0
+${cassandra.driver.version}
 
 
 com.google.guava


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



[james-project] 06/07: [UPGRADE] lettuce core 6.2.2 -> 6.2.4

2023-07-06 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 7d150111fcb46a965262350be5d2b1f1278342e5
Author: Quan Tran 
AuthorDate: Thu Jul 6 10:28:49 2023 +0700

[UPGRADE] lettuce core 6.2.2 -> 6.2.4
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 6e41bab8a1..2c059020de 100644
--- a/pom.xml
+++ b/pom.xml
@@ -653,7 +653,7 @@
 5.1.0
 1.4.5
 1.7.0
-6.2.2.RELEASE
+6.2.4.RELEASE
 
 1.70
 


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



[james-project] 03/07: [UPGRADE] reactor-bom 2022.0.1 -> 2022.0.8

2023-07-06 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit b6f1eeceb7d02d7ece1841bc82c234fde9dd3209
Author: Quan Tran 
AuthorDate: Thu Jul 6 10:17:16 2023 +0700

[UPGRADE] reactor-bom 2022.0.1 -> 2022.0.8
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index b82ffad8e8..a2740d1a22 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2436,7 +2436,7 @@
 
 io.projectreactor
 reactor-bom
-2022.0.1
+2022.0.8
 pom
 import
 


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



[james-project] 02/07: [UPGRADE] Netty 4.1.86 -> 4.1.94

2023-07-06 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit a7bc13eb487397c347c04aad8c11220b23a4a4f4
Author: Quan Tran 
AuthorDate: Thu Jul 6 10:13:31 2023 +0700

[UPGRADE] Netty 4.1.86 -> 4.1.94
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index fc9d32a2a6..b82ffad8e8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -620,7 +620,7 @@
 5.8.2
 1.3.4
 4.21
-4.1.86.Final
+4.1.94.Final
 2.4.0
 
 1.6.4


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



[james-project] branch master updated (a4867def74 -> c94d134ae8)

2023-07-06 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


from a4867def74 JAMES-3775 Add Wait for healthcheck to ClaimAV/RspamD 
extension (#1630)
 new 16ad3c9a84 [UPGRADE] s3 2.19.8 -> 2.20.98
 new a7bc13eb48 [UPGRADE] Netty 4.1.86 -> 4.1.94
 new b6f1eeceb7 [UPGRADE] reactor-bom 2022.0.1 -> 2022.0.8
 new 3926343829 [UPGRADE] amqp-client 5.16.0 -> 5.18.0
 new cae37b91dd [UPGRADE] Cassandra driver 4.15.0 -> 4.16.0
 new 7d150111fc [UPGRADE] lettuce core 6.2.2 -> 6.2.4
 new c94d134ae8 [UPGRADE] reactor-rabbitmq 1.5.5 -> 1.5.6

The 7 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 backends-common/cassandra/pom.xml |  8 ++--
 pom.xml   | 10 +-
 server/blob/blob-s3/pom.xml   |  2 +-
 3 files changed, 12 insertions(+), 8 deletions(-)


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



[james-project] 01/07: [UPGRADE] s3 2.19.8 -> 2.20.98

2023-07-06 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 16ad3c9a845c0dc0f6d0b6dfcf85223507f1a245
Author: Quan Tran 
AuthorDate: Thu Jul 6 10:11:23 2023 +0700

[UPGRADE] s3 2.19.8 -> 2.20.98
---
 server/blob/blob-s3/pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/server/blob/blob-s3/pom.xml b/server/blob/blob-s3/pom.xml
index 97b039b61c..e56fc0da9d 100644
--- a/server/blob/blob-s3/pom.xml
+++ b/server/blob/blob-s3/pom.xml
@@ -33,7 +33,7 @@
 Apache James :: Server :: Blob :: S3
 
 
-2.19.8
+2.20.98
 
 
 


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



[james-project] branch master updated: JAMES-3775 Add Wait for healthcheck to ClaimAV/RspamD extension (#1630)

2023-07-06 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
 new a4867def74 JAMES-3775 Add Wait for healthcheck to ClaimAV/RspamD 
extension (#1630)
a4867def74 is described below

commit a4867def7468067f69bf12039f6c6f74518d7426
Author: vttran 
AuthorDate: Thu Jul 6 22:33:50 2023 +0700

JAMES-3775 Add Wait for healthcheck to ClaimAV/RspamD extension (#1630)
---
 .../src/test/java/org/apache/james/rspamd/DockerClamAV.java   | 8 ++--
 .../src/test/java/org/apache/james/rspamd/DockerRspamd.java   | 7 +--
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git 
a/third-party/rspamd/src/test/java/org/apache/james/rspamd/DockerClamAV.java 
b/third-party/rspamd/src/test/java/org/apache/james/rspamd/DockerClamAV.java
index 3020e4cfb8..fcc772e62b 100644
--- a/third-party/rspamd/src/test/java/org/apache/james/rspamd/DockerClamAV.java
+++ b/third-party/rspamd/src/test/java/org/apache/james/rspamd/DockerClamAV.java
@@ -21,8 +21,11 @@ package org.apache.james.rspamd;
 
 import org.testcontainers.containers.GenericContainer;
 import org.testcontainers.containers.Network;
+import org.testcontainers.containers.wait.strategy.Wait;
 import org.testcontainers.utility.DockerImageName;
 
+import java.util.UUID;
+
 public class DockerClamAV {
 private static final DockerImageName DEFAULT_IMAGE_NAME = 
DockerImageName.parse("clamav/clamav");
 private static final String DEFAULT_TAG = "0.105";
@@ -36,8 +39,9 @@ public class DockerClamAV {
 .withEnv("CLAMAV_NO_FRESHCLAMD", "true")
 .withEnv("CLAMAV_NO_MILTERD", "true")
 .withNetwork(network)
-.withCreateContainerCmdModifier(createContainerCmd -> 
createContainerCmd.withName("james-clamav-test"))
-.withNetworkAliases("clamav");
+.withCreateContainerCmdModifier(createContainerCmd -> 
createContainerCmd.withName("james-clamav-test-" + UUID.randomUUID()))
+.withNetworkAliases("clamav")
+.waitingFor(Wait.forHealthcheck());
 }
 
 public void start() {
diff --git 
a/third-party/rspamd/src/test/java/org/apache/james/rspamd/DockerRspamd.java 
b/third-party/rspamd/src/test/java/org/apache/james/rspamd/DockerRspamd.java
index dd379b8c46..2896ecf806 100644
--- a/third-party/rspamd/src/test/java/org/apache/james/rspamd/DockerRspamd.java
+++ b/third-party/rspamd/src/test/java/org/apache/james/rspamd/DockerRspamd.java
@@ -19,11 +19,13 @@
 
 package org.apache.james.rspamd;
 
+import java.util.UUID;
 import java.util.stream.Stream;
 
 import org.apache.james.rate.limiter.DockerRedis;
 import org.testcontainers.containers.GenericContainer;
 import org.testcontainers.containers.Network;
+import org.testcontainers.containers.wait.strategy.Wait;
 import org.testcontainers.utility.DockerImageName;
 import org.testcontainers.utility.MountableFile;
 
@@ -58,8 +60,9 @@ public class DockerRspamd {
 
.withCopyFileToContainer(MountableFile.forClasspathResource("rspamd-config/antivirus.conf"),
 "/etc/rspamd/override.d/")
 
.withCopyFileToContainer(MountableFile.forClasspathResource("rspamd-config/actions.conf"),
 "/etc/rspamd/")
 
.withCopyFileToContainer(MountableFile.forClasspathResource("rspamd-config/statistic.conf"),
 "/etc/rspamd/")
-.withCreateContainerCmdModifier(createContainerCmd -> 
createContainerCmd.withName("james-rspamd-test"))
-.withNetwork(network);
+.withCreateContainerCmdModifier(createContainerCmd -> 
createContainerCmd.withName("james-rspamd-test-" + UUID.randomUUID()))
+.withNetwork(network)
+.waitingFor(Wait.forHealthcheck());
 }
 
 public Integer getPort() {


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



[james-project] branch 3.8.x updated: JAMES-3921 Fix Lucene indexing issues (#1621) (#1625)

2023-07-06 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch 3.8.x
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/3.8.x by this push:
 new e8e6152813 JAMES-3921 Fix Lucene indexing issues (#1621) (#1625)
e8e6152813 is described below

commit e8e615281327b44b25bdd074fe17a3044678f7af
Author: Benoit TELLIER 
AuthorDate: Thu Jul 6 22:33:18 2023 +0700

JAMES-3921 Fix Lucene indexing issues (#1621) (#1625)
---
 .../lucene/search/LuceneMessageSearchIndex.java| 24 ++
 .../LuceneMailboxMessageSearchIndexTest.java   | 24 +-
 2 files changed, 25 insertions(+), 23 deletions(-)

diff --git 
a/mailbox/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndex.java
 
b/mailbox/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndex.java
index c71e17ce5e..141c6d06ee 100644
--- 
a/mailbox/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndex.java
+++ 
b/mailbox/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndex.java
@@ -22,7 +22,6 @@ import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
-import java.io.StringReader;
 import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.Calendar;
@@ -79,11 +78,9 @@ import org.apache.james.mime4j.dom.address.Address;
 import org.apache.james.mime4j.dom.address.AddressList;
 import org.apache.james.mime4j.dom.address.Group;
 import org.apache.james.mime4j.dom.address.MailboxList;
-import org.apache.james.mime4j.dom.datetime.DateTime;
 import org.apache.james.mime4j.dom.field.DateTimeField;
 import org.apache.james.mime4j.field.address.AddressFormatter;
 import org.apache.james.mime4j.field.address.LenientAddressParser;
-import org.apache.james.mime4j.field.datetime.parser.DateTimeParser;
 import org.apache.james.mime4j.message.SimpleContentHandler;
 import org.apache.james.mime4j.parser.MimeStreamParser;
 import org.apache.james.mime4j.stream.BodyDescriptor;
@@ -116,8 +113,6 @@ import org.apache.lucene.search.TopDocs;
 import org.apache.lucene.search.WildcardQuery;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.Version;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import com.github.fge.lambdas.Throwing;
 import com.google.common.base.Preconditions;
@@ -135,7 +130,6 @@ public class LuceneMessageSearchIndex extends 
ListeningMessageSearchIndex {
 
 }
 
-private static final Logger LOGGER = 
LoggerFactory.getLogger(LuceneMessageSearchIndex.class);
 private static final Date MAX_DATE;
 private static final Date MIN_DATE;
 public static final org.apache.james.events.Group GROUP = new 
LuceneMessageSearchIndexGroup();
@@ -628,22 +622,8 @@ public class LuceneMessageSearchIndex extends 
ListeningMessageSearchIndex {
 doc.add(new Field(PREFIX_HEADER_FIELD + headerName, 
headerValue, Store.NO, Index.ANALYZED));
 
 if (f instanceof DateTimeField) {
-// We need to make sure we convert it to GMT
-try (StringReader reader = new 
StringReader(f.getBody())) {
-DateTime dateTime = new 
DateTimeParser(reader).parseAll();
-Calendar cal = getGMT();
-cal.set(dateTime.getYear(), dateTime.getMonth() - 
1, dateTime.getDay(), dateTime.getHour(), dateTime.getMinute(), 
dateTime.getSecond());
-sentDate = cal.getTime();
-
-} catch 
(org.apache.james.mime4j.field.datetime.parser.ParseException e) {
-LOGGER.debug("Unable to parse Date header for 
proper indexing", e);
-// This should never happen anyway fallback to the 
already parsed field
-sentDate = ((DateTimeField) f).getDate();
-}
-if (sentDate == null) {
-sentDate = membership.getInternalDate();
-}
-
+DateTimeField dateTimeField = (DateTimeField) f;
+sentDate = dateTimeField.getDate();
 }
 String field = null;
 if ("To".equalsIgnoreCase(headerName)) {
diff --git 
a/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java
 
b/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java
index 9508ffeba0..1a7e7fd338 100644
--- 
a/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java
+++ 
b/mailbox/lucene/src/test/java/org/apache/james/m

[james-project] 01/02: [FIX] JAMES-3919 RabbitMQMailQueue: clean up cassandra projection when we can't publish to Rabbit

2023-07-05 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch 3.7.x
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit f780cb5b6dd7ad2aba7bbfe3c7d4db3bb1b859b0
Author: Rene Cordier 
AuthorDate: Wed Jul 5 10:19:33 2023 +0700

[FIX] JAMES-3919 RabbitMQMailQueue: clean up cassandra projection when we 
can't publish to Rabbit
---
 .../org/apache/james/queue/rabbitmq/view/api/FakeMailQueueView.java   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/api/FakeMailQueueView.java
 
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/api/FakeMailQueueView.java
index eecdc5c7bd..c91123bc46 100644
--- 
a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/api/FakeMailQueueView.java
+++ 
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/view/api/FakeMailQueueView.java
@@ -54,8 +54,8 @@ public class FakeMailQueueView
 }
 
 @Override
-public long delete(DeleteCondition deleteCondition) {
-return 0;
+public Mono delete(DeleteCondition deleteCondition) {
+return Mono.just(0L);
 }
 
 @Override


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



[james-project] branch 3.7.x updated (f44d1efc37 -> c5f5d33c8f)

2023-07-05 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a change to branch 3.7.x
in repository https://gitbox.apache.org/repos/asf/james-project.git


from f44d1efc37 JAMES-3919 RabbitMQMailQueue: clean up cassandra projection 
when we c… (#1609) (#1616)
 new f780cb5b6d [FIX] JAMES-3919 RabbitMQMailQueue: clean up cassandra 
projection when we can't publish to Rabbit
 new c5f5d33c8f JAMES-3604 Fix issue when creating quorum rabbitmq queues

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/james/backends/rabbitmq/RabbitMQConfiguration.java | 4 ++--
 .../src/main/java/org/apache/james/events/GroupRegistration.java  | 2 +-
 .../main/java/org/apache/james/events/GroupRegistrationHandler.java   | 2 +-
 .../src/main/java/org/apache/james/events/KeyReconnectionHandler.java | 2 +-
 .../src/main/java/org/apache/james/events/KeyRegistrationHandler.java | 2 +-
 .../org/apache/james/queue/rabbitmq/RabbitMQMailQueueFactory.java | 2 +-
 .../org/apache/james/queue/rabbitmq/view/api/FakeMailQueueView.java   | 4 ++--
 7 files changed, 9 insertions(+), 9 deletions(-)


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



[james-project] 02/02: JAMES-3604 Fix issue when creating quorum rabbitmq queues

2023-07-05 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch 3.7.x
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit c5f5d33c8f39067e71484d8d3a9306b0fd831ba0
Author: Rene Cordier 
AuthorDate: Thu Sep 29 17:53:43 2022 +0700

JAMES-3604 Fix issue when creating quorum rabbitmq queues

We can't create a quorum queue and mark it as auto-delete, RabbitMQ does 
not allow it. So we keep the jmap event bus notification queues as classic for 
now.
---
 .../org/apache/james/backends/rabbitmq/RabbitMQConfiguration.java | 4 ++--
 .../src/main/java/org/apache/james/events/GroupRegistration.java  | 2 +-
 .../main/java/org/apache/james/events/GroupRegistrationHandler.java   | 2 +-
 .../src/main/java/org/apache/james/events/KeyReconnectionHandler.java | 2 +-
 .../src/main/java/org/apache/james/events/KeyRegistrationHandler.java | 2 +-
 .../org/apache/james/queue/rabbitmq/RabbitMQMailQueueFactory.java | 2 +-
 6 files changed, 7 insertions(+), 7 deletions(-)

diff --git 
a/backends-common/rabbitmq/src/main/java/org/apache/james/backends/rabbitmq/RabbitMQConfiguration.java
 
b/backends-common/rabbitmq/src/main/java/org/apache/james/backends/rabbitmq/RabbitMQConfiguration.java
index 48588d478b..e98f142555 100644
--- 
a/backends-common/rabbitmq/src/main/java/org/apache/james/backends/rabbitmq/RabbitMQConfiguration.java
+++ 
b/backends-common/rabbitmq/src/main/java/org/apache/james/backends/rabbitmq/RabbitMQConfiguration.java
@@ -722,9 +722,9 @@ public class RabbitMQConfiguration {
 return sslConfiguration;
 }
 
-public QueueArguments.Builder workQueueArgumentsBuilder() {
+public QueueArguments.Builder workQueueArgumentsBuilder(boolean 
autoDeleteQueue) {
 QueueArguments.Builder builder = QueueArguments.builder();
-if (useQuorumQueues) {
+if (!autoDeleteQueue && useQuorumQueues) {
 
builder.quorumQueue().replicationFactor(quorumQueueReplicationFactor);
 }
 queueTTL.ifPresent(builder::queueTTL);
diff --git 
a/event-bus/distributed/src/main/java/org/apache/james/events/GroupRegistration.java
 
b/event-bus/distributed/src/main/java/org/apache/james/events/GroupRegistration.java
index bd1a9d3398..794a60e59b 100644
--- 
a/event-bus/distributed/src/main/java/org/apache/james/events/GroupRegistration.java
+++ 
b/event-bus/distributed/src/main/java/org/apache/james/events/GroupRegistration.java
@@ -128,7 +128,7 @@ class GroupRegistration implements Registration {
 .durable(DURABLE)
 .exclusive(!EXCLUSIVE)
 .autoDelete(!AUTO_DELETE)
-.arguments(configuration.workQueueArgumentsBuilder()
+
.arguments(configuration.workQueueArgumentsBuilder(!AUTO_DELETE)
 .deadLetter(namingStrategy.deadLetterExchange())
 .build()));
 }
diff --git 
a/event-bus/distributed/src/main/java/org/apache/james/events/GroupRegistrationHandler.java
 
b/event-bus/distributed/src/main/java/org/apache/james/events/GroupRegistrationHandler.java
index def37aa477..74c6ca0974 100644
--- 
a/event-bus/distributed/src/main/java/org/apache/james/events/GroupRegistrationHandler.java
+++ 
b/event-bus/distributed/src/main/java/org/apache/james/events/GroupRegistrationHandler.java
@@ -104,7 +104,7 @@ class GroupRegistrationHandler {
 .durable(DURABLE)
 .exclusive(!EXCLUSIVE)
 .autoDelete(!AUTO_DELETE)
-.arguments(configuration.workQueueArgumentsBuilder()
+
.arguments(configuration.workQueueArgumentsBuilder(!AUTO_DELETE)
 .deadLetter(namingStrategy.deadLetterExchange())
 .build()),
 BindingSpecification.binding()
diff --git 
a/event-bus/distributed/src/main/java/org/apache/james/events/KeyReconnectionHandler.java
 
b/event-bus/distributed/src/main/java/org/apache/james/events/KeyReconnectionHandler.java
index 95e6810c1e..cd8b1f21e2 100644
--- 
a/event-bus/distributed/src/main/java/org/apache/james/events/KeyReconnectionHandler.java
+++ 
b/event-bus/distributed/src/main/java/org/apache/james/events/KeyReconnectionHandler.java
@@ -55,7 +55,7 @@ public class KeyReconnectionHandler implements 
SimpleConnectionPool.Reconnection
 return Mono.fromRunnable(() -> {
 try (Channel channel = connection.createChannel()) {
 
channel.queueDeclare(namingStrategy.queueName(eventBusId).asString(), DURABLE, 
!EXCLUSIVE, AUTO_DELETE,
-configuration.workQueueArgumentsBuilder().build());
+
configuration.workQueueArgumentsBuilder(AUTO_DELETE).build());
 } catch (Exception e) {
 LOGGER.error("Error recovering connection", e);
 }
diff --git 
a/event-bus/distributed/src/main/java/org/apache/james/events/KeyRegistrationHandler.java
 
b/event-bus/distributed/src

[james-project] branch master updated: JAMES 3551 - implement naive mailbox query changes (#1624)

2023-07-05 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
 new 9b18644177 JAMES 3551 - implement naive mailbox query changes (#1624)
9b18644177 is described below

commit 9b18644177bb8ef3797793f1cb4046c3df7aa61b
Author: hungphan227 <45198168+hungphan...@users.noreply.github.com>
AuthorDate: Thu Jul 6 08:30:22 2023 +0700

JAMES 3551 - implement naive mailbox query changes (#1624)
---
 .../james/jmap/rfc8621/RFC8621MethodsModule.java   |   2 +
 .../DistributedMailboxQueryChangesMethodTest.java  |  25 +++
 .../contract/MailboxQueryChangesContract.scala | 179 +
 .../MemoryMailboxQueryChangesMethodTest.java   |  25 +++
 .../james/jmap/json/MailboxQuerySerializer.scala   |   4 +-
 .../james/jmap/mail/MailboxQueryChanges.scala  |  30 
 .../jmap/method/MailboxQueryChangesMethod.scala|  50 ++
 7 files changed, 314 insertions(+), 1 deletion(-)

diff --git 
a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/rfc8621/RFC8621MethodsModule.java
 
b/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/rfc8621/RFC8621MethodsModule.java
index 4a5ab902af..fe5ac86d43 100644
--- 
a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/rfc8621/RFC8621MethodsModule.java
+++ 
b/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/rfc8621/RFC8621MethodsModule.java
@@ -65,6 +65,7 @@ import org.apache.james.jmap.method.MDNParseMethod;
 import org.apache.james.jmap.method.MDNSendMethod;
 import org.apache.james.jmap.method.MailboxChangesMethod;
 import org.apache.james.jmap.method.MailboxGetMethod;
+import org.apache.james.jmap.method.MailboxQueryChangesMethod;
 import org.apache.james.jmap.method.MailboxQueryMethod;
 import org.apache.james.jmap.method.MailboxSetMethod;
 import org.apache.james.jmap.method.Method;
@@ -164,6 +165,7 @@ public class RFC8621MethodsModule extends AbstractModule {
 methods.addBinding().to(DelegateGetMethod.class);
 methods.addBinding().to(DelegateSetMethod.class);
 methods.addBinding().to(DelegatedAccountSetMethod.class);
+methods.addBinding().to(MailboxQueryChangesMethod.class);
 
 Multibinder routes = Multibinder.newSetBinder(binder(), 
JMAPRoutes.class);
 routes.addBinding().to(SessionRoutes.class);
diff --git 
a/server/protocols/jmap-rfc-8621-integration-tests/distributed-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/distributed/DistributedMailboxQueryChangesMethodTest.java
 
b/server/protocols/jmap-rfc-8621-integration-tests/distributed-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/distributed/DistributedMailboxQueryChangesMethodTest.java
new file mode 100644
index 00..c188ab8d57
--- /dev/null
+++ 
b/server/protocols/jmap-rfc-8621-integration-tests/distributed-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/distributed/DistributedMailboxQueryChangesMethodTest.java
@@ -0,0 +1,25 @@
+/
+ * 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.jmap.rfc8621.distributed;
+
+import org.apache.james.jmap.rfc8621.contract.MailboxQueryChangesContract;
+
+public class DistributedMailboxQueryChangesMethodTest extends DistributedBase 
implements MailboxQueryChangesContract {
+}
diff --git 
a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxQueryChangesContract.scala
 
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/s

[james-project] 02/02: JAMES-3830 Update JMAP quotas specs

2023-07-04 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 3a79d411fb4b340ebbdf27998cd033893a5900ab
Author: Quan Tran 
AuthorDate: Wed Feb 1 15:05:49 2023 +0700

JAMES-3830 Update JMAP quotas specs
---
 .../doc/specs/spec/quotas/intro.mdown  | 24 +++---
 .../doc/specs/spec/quotas/quota.mdown  | 87 --
 2 files changed, 56 insertions(+), 55 deletions(-)

diff --git a/server/protocols/jmap-rfc-8621/doc/specs/spec/quotas/intro.mdown 
b/server/protocols/jmap-rfc-8621/doc/specs/spec/quotas/intro.mdown
index 95616a0e49..1d6999c6ae 100644
--- a/server/protocols/jmap-rfc-8621/doc/specs/spec/quotas/intro.mdown
+++ b/server/protocols/jmap-rfc-8621/doc/specs/spec/quotas/intro.mdown
@@ -38,32 +38,28 @@ This document defines one additional capability URI.
 
 ### urn:ietf:params:jmap:quota
 
-This represents support for the Quota data type and associated API methods. 
Servers supporting this specification MUST add a property called 
urn:ietf:params:jmap:quota to the capabilities object.
+This represents support for the Quota data type and associated API methods. 
Servers supporting this specification **MUST** add a property called 
`urn:ietf:params:jmap:quota` to the capabilities object.
 
 The value of this property is an empty object in both the JMAP session 
capabilities property and an account’s accountCapabilities property.
 
-## Data types
+## Sub-types of the Quota Data Type
 
-In addition to the standard JSON data types, a couple of additional data types 
are common to the definition of Quota objects and properties.
+There are two fields within the `Quota` data type, which have an enumerated 
set of possible values. These are:
 
 ### Scope
 
-The **Scope** is a `String` from an enumeration defined list of values, 
handled by the server.
+The **Scope** data type is used to represent the entities the quota applies 
to. It is defined as a "String" with values from the following set:
 
-It explains the entities this value applies to. Values for the **Scope** are:
-
-* `account`: Applies for this account
-* `domain`: All accounts of this domain share this part of the quota
-* `global`: All accounts of this server share this part of the quota
+* `account`: The quota information applies to just the client's account.
+* `domain`: The quota information applies to all accounts sharing this domain.
+* `global`: The quota information applies to all accounts belonging to the 
server.
 
 ### ResourceType
 
-The **ResourceType** is a `String` from an enumeration defined list of values, 
handled by the server.
-
-A resource type is like an unit of measure for the quota usage. Values for the 
**ResourceType** are:
+The **ResourceType** data type is used to act as a unit of measure for the 
quota usage. It is defined as a "String" with values from the following set:
 
-* `count`: The quota is measured in number of data type objects. For example, 
a quota can have a limit of 50 `Mail` objects.
-* `octets`: The quota is measured in size (in `octets`). For example, a quota 
can have a limit of 25000 `octets`.
+* `count`: The quota is measured in a number of data type objects. For 
example, a quota can have a limit of 50 "Mail" objects.
+* `octets`: The quota is measured in size (in octets). For example, a quota 
can have a limit of 25000 octets.
 
 ## Push
 
diff --git a/server/protocols/jmap-rfc-8621/doc/specs/spec/quotas/quota.mdown 
b/server/protocols/jmap-rfc-8621/doc/specs/spec/quotas/quota.mdown
index d1c109eecc..1aad42f0d0 100644
--- a/server/protocols/jmap-rfc-8621/doc/specs/spec/quotas/quota.mdown
+++ b/server/protocols/jmap-rfc-8621/doc/specs/spec/quotas/quota.mdown
@@ -5,62 +5,65 @@
 
 The quota is an object that displays the limit set to an account usage as well 
as the current usage in regard to that limit.
 
-The quota object MUST contain the following fields:
+The quota object **MUST** contain the following fields:
 
-* **id**: `Id` The unique identifier for this object. It should respect the 
JMAP ID datatype defined in section 1.2 of [@!RFC8620]
+* **id**: `Id` The unique identifier for this object.
 
-* **resourceType**: `ResourceType` The resource type of the quota.
+* **resourceType**: `String` The resource type of the quota.
 
-* **used**: `UnsignedInt` The current usage of the defined quota. Computation 
of this value is handled by the server.
+* **used**: `UnsignedInt` The current usage of the defined quota, using the 
"resourceType" defined as unit of measure. Computation of this value is handled 
by the server.
 
-* **limit**: `UnsignedInt` The hard limit set by this quota. Objects in scope 
may not be created or updated if we reach this limit. It should be higher than 
the `warnLimit` and the `softLimit`.
+* **hardLimit**: `UnsignedInt` The hard limit set by this quota, using the 
"reso

[james-project] 01/02: JAMES-3830 Adapt Quota RFC-9245 changes in code

2023-07-04 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 898a76a157a41aacfd4738bf24cc93fb22aaafac
Author: Quan Tran 
AuthorDate: Wed Feb 1 12:19:30 2023 +0700

JAMES-3830 Adapt Quota RFC-9245 changes in code

Quota object changes:
- "dataTypes" -> "types"
- "limit" -> "hardLimit"

Quota filter condition object changes:
- "dataTypes" String[] -> "type" String
- "resourceTypes" ResourceType[] -> "resourceType" String
- "scopes" Scope[] -> "scope" String
---
 .../rfc8621/contract/QuotaGetMethodContract.scala  | 64 +++---
 .../contract/QuotaQueryMethodContract.scala| 30 +-
 .../scala/org/apache/james/jmap/mail/Quotas.scala  | 24 
 .../james/jmap/method/QuotaQueryMethod.scala   | 13 +++--
 .../james/jmap/json/QuotaSerializerTest.scala  | 20 +++
 5 files changed, 77 insertions(+), 74 deletions(-)

diff --git 
a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/QuotaGetMethodContract.scala
 
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/QuotaGetMethodContract.scala
index 1b36049303..a095d89ac2 100644
--- 
a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/QuotaGetMethodContract.scala
+++ 
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/QuotaGetMethodContract.scala
@@ -153,10 +153,10 @@ trait QuotaGetMethodContract {
  |"used": 0,
  |"name": 
"#private@domain.tld@domain.tld:account:count:Mail",
  |"id": 
"08417be420b6dd6fa77d48fb2438e0d19108cd29424844bb109b52d356fab528",
- |"dataTypes": [
+ |"types": [
  |"Mail"
  |],
- |"limit": 100,
+ |"hardLimit": 100,
  |"warnLimit": 90,
  |"resourceType": "count",
  |"scope": "account"
@@ -165,10 +165,10 @@ trait QuotaGetMethodContract {
  |"used": 0,
  |"name": 
"#private@domain.tld@domain.tld:account:octets:Mail",
  |"id": 
"eab6ce8ac5d9730a959e614854410cf39df98ff3760a623b8e540f36f5184947",
- |"dataTypes": [
+ |"types": [
  |"Mail"
  |],
- |"limit": 99,
+ |"hardLimit": 99,
  |"warnLimit": 89,
  |"resourceType": "octets",
  |"scope": "account"
@@ -229,10 +229,10 @@ trait QuotaGetMethodContract {
  |"used": 0,
  |"name": 
"#private@domain.tld@domain.tld:account:count:Mail",
  |"id": 
"08417be420b6dd6fa77d48fb2438e0d19108cd29424844bb109b52d356fab528",
- |"dataTypes": [
+ |"types": [
  |"Mail"
  |],
- |"limit": 100,
+ |"hardLimit": 100,
  |"warnLimit": 90,
  |"resourceType": "count",
  |"scope": "account"
@@ -341,10 +341,10 @@ trait QuotaGetMethodContract {
|"used": 0,
|"name": 
"#private@domain.tld@domain.tld:account:count:Mail",
|"id": 
"08417be420b6dd6fa77d48fb2438e0d19108cd29424844bb109b52d356fab528",
-   | 

[james-project] branch master updated (b53c363150 -> 3a79d411fb)

2023-07-04 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


from b53c363150 JAMES-3899 WithStorageDirective should support extra 
mailboxes that do not yet exists (#1628)
 new 898a76a157 JAMES-3830 Adapt Quota RFC-9245 changes in code
 new 3a79d411fb JAMES-3830 Update JMAP quotas specs

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../rfc8621/contract/QuotaGetMethodContract.scala  | 64 
 .../contract/QuotaQueryMethodContract.scala| 30 
 .../doc/specs/spec/quotas/intro.mdown  | 24 +++---
 .../doc/specs/spec/quotas/quota.mdown  | 87 --
 .../scala/org/apache/james/jmap/mail/Quotas.scala  | 24 +++---
 .../james/jmap/method/QuotaQueryMethod.scala   | 13 ++--
 .../james/jmap/json/QuotaSerializerTest.scala  | 20 ++---
 7 files changed, 133 insertions(+), 129 deletions(-)


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



[james-project] branch 3.7.x updated: JAMES-3919 RabbitMQMailQueue: clean up cassandra projection when we c… (#1609) (#1616)

2023-07-04 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch 3.7.x
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/3.7.x by this push:
 new f44d1efc37 JAMES-3919 RabbitMQMailQueue: clean up cassandra projection 
when we c… (#1609) (#1616)
f44d1efc37 is described below

commit f44d1efc37c26cfabfdc9dfe482698149d5caa78
Author: Benoit TELLIER 
AuthorDate: Wed Jul 5 08:46:09 2023 +0700

JAMES-3919 RabbitMQMailQueue: clean up cassandra projection when we c… 
(#1609) (#1616)
---
 .../backends/rabbitmq/RabbitMQManagementAPI.java   |  3 ++
 .../org/apache/james/queue/rabbitmq/Dequeuer.java  |  2 +-
 .../org/apache/james/queue/rabbitmq/Enqueuer.java  | 13 -
 .../james/queue/rabbitmq/RabbitMQMailQueue.java|  4 +-
 .../queue/rabbitmq/view/api/MailQueueView.java |  3 +-
 .../view/cassandra/CassandraMailQueueView.java | 12 ++---
 .../queue/rabbitmq/RabbitMQMailQueueTest.java  | 58 ++
 7 files changed, 61 insertions(+), 34 deletions(-)

diff --git 
a/backends-common/rabbitmq/src/main/java/org/apache/james/backends/rabbitmq/RabbitMQManagementAPI.java
 
b/backends-common/rabbitmq/src/main/java/org/apache/james/backends/rabbitmq/RabbitMQManagementAPI.java
index 5661a4d314..826925ef1e 100644
--- 
a/backends-common/rabbitmq/src/main/java/org/apache/james/backends/rabbitmq/RabbitMQManagementAPI.java
+++ 
b/backends-common/rabbitmq/src/main/java/org/apache/james/backends/rabbitmq/RabbitMQManagementAPI.java
@@ -441,6 +441,9 @@ public interface RabbitMQManagementAPI {
 @RequestLine(value = "DELETE /api/queues/{vhost}/{name}", decodeSlash = 
false)
 void deleteQueue(@Param("vhost") String vhost, @Param("name") String name);
 
+@RequestLine(value = "DELETE /api/queues/{vhost}/{name}/contents", 
decodeSlash = false)
+void purgeQueue(@Param("vhost") String vhost, @Param("name") String name);
+
 @RequestLine(value = "GET /api/exchanges/{vhost}/{name}/bindings/source", 
decodeSlash = false)
 List listBindings(@Param("vhost") String vhost, 
@Param("name") String name);
 
diff --git 
a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Dequeuer.java
 
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Dequeuer.java
index 573b7a2497..671400a06d 100644
--- 
a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Dequeuer.java
+++ 
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Dequeuer.java
@@ -140,7 +140,7 @@ class Dequeuer {
 if (success) {
 dequeueMetric.increment();
 response.ack();
-
mailQueueView.delete(DeleteCondition.withEnqueueId(mailWithEnqueueId.getEnqueueId(),
 mailWithEnqueueId.getBlobIds()));
+
Mono.from(mailQueueView.delete(DeleteCondition.withEnqueueId(mailWithEnqueueId.getEnqueueId(),
 mailWithEnqueueId.getBlobIds(.block();
 } else {
 response.nack(REQUEUE);
 }
diff --git 
a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Enqueuer.java
 
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Enqueuer.java
index b72139c942..b6d97b74fc 100644
--- 
a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Enqueuer.java
+++ 
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Enqueuer.java
@@ -25,6 +25,7 @@ import static 
org.apache.james.queue.api.MailQueue.ENQUEUED_METRIC_NAME_PREFIX;
 
 import java.time.Clock;
 import java.time.Duration;
+import java.util.function.Function;
 
 import javax.mail.MessagingException;
 import javax.mail.internet.MimeMessage;
@@ -34,6 +35,7 @@ import org.apache.james.blob.mail.MimeMessagePartsId;
 import org.apache.james.metrics.api.Metric;
 import org.apache.james.metrics.api.MetricFactory;
 import org.apache.james.queue.api.MailQueue;
+import org.apache.james.queue.rabbitmq.view.api.DeleteCondition;
 import org.apache.james.queue.rabbitmq.view.api.MailQueueView;
 import 
org.apache.james.queue.rabbitmq.view.cassandra.CassandraMailQueueBrowser;
 import org.apache.mailet.Mail;
@@ -79,11 +81,20 @@ class Enqueuer {
 return Flux.mergeDelayError(2,
 mailQueueView.storeMail(enqueuedItem),
 publishReferenceToRabbit(mailReference))
-.then();
+.then()
+.onErrorResume(cleanupMailQueueView(enqueueId, 
mailReference));
 }).sneakyThrow())
 .thenEmpty(Mono.fromRunnable(enqueueMetric::increment));
 }
 
+private Function> cleanupMailQueueView(EnqueueId 
enqueueId, MailReference mailReference) {
+return (Throwable e) -> {
+DeleteCondition.Wi

[james-project] branch 3.7.x updated: JAMES-3768 Allow disabling Cassandra Mail queue view (#1009) (#1631)

2023-07-04 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch 3.7.x
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/3.7.x by this push:
 new 5d26226fe2 JAMES-3768 Allow disabling Cassandra Mail queue view 
(#1009) (#1631)
5d26226fe2 is described below

commit 5d26226fe29ee7a3077a35fec5ec0058b0114306
Author: Rene Cordier 
AuthorDate: Wed Jul 5 08:30:10 2023 +0700

JAMES-3768 Allow disabling Cassandra Mail queue view (#1009) (#1631)

Co-authored-by: Benoit TELLIER 
---
 .../modules/ROOT/pages/configure/rabbitmq.adoc |  5 ++
 .../sample-configuration/rabbitmq.properties   |  4 +
 .../james/CassandraRabbitMQJamesConfiguration.java | 23 +-
 .../james/CassandraRabbitMQJamesServerMain.java|  2 +
 .../james/WithoutMailQueueViewImmutableTest.java   | 55 ++
 .../sample-configuration/rabbitmq.properties   |  4 +
 .../james/DistributedPOP3JamesConfiguration.java   | 18 -
 .../james/DistributedPOP3JamesServerMain.java  |  2 +
 .../modules/mailbox/CassandraMailboxModule.java| 23 +-
 .../rabbitmq/CassandraMailQueueViewModule.java | 88 ++
 .../queue/rabbitmq/FakeMailQueueViewModule.java| 35 +
 .../queue/rabbitmq/MailQueueViewChoice.java| 67 
 .../modules/queue/rabbitmq/RabbitMQModule.java | 52 -
 .../queue/rabbitmq/view/api/FakeMailQueueView.java | 80 
 src/site/xdoc/server/config-rabbitmq.xml   |  5 ++
 15 files changed, 406 insertions(+), 57 deletions(-)

diff --git 
a/server/apps/distributed-app/docs/modules/ROOT/pages/configure/rabbitmq.adoc 
b/server/apps/distributed-app/docs/modules/ROOT/pages/configure/rabbitmq.adoc
index 5b91a0d935..610baa1ce9 100644
--- 
a/server/apps/distributed-app/docs/modules/ROOT/pages/configure/rabbitmq.adoc
+++ 
b/server/apps/distributed-app/docs/modules/ROOT/pages/configure/rabbitmq.adoc
@@ -104,6 +104,11 @@ this implementation relies on Cassandra.
 |===
 | Property name | explanation
 
+| cassandra.view.enabled
+| Whether the Cassandra administrative view should be activated. Boolean value 
defaulting to true.
+Not necessarily needed for MDA deployments, mail queue management adds 
significant complexity.
+
+
 | mailqueue.view.sliceWindow
 | James divides the view into slices, each slice contains data for a given 
period, sliceWindow parameter controls this period.
 This dividing of periods allows faster browsing of the mail queue. Tips for 
choosing sliceWindow are explained in
diff --git 
a/server/apps/distributed-app/sample-configuration/rabbitmq.properties 
b/server/apps/distributed-app/sample-configuration/rabbitmq.properties
index b412d1d354..5ce229846a 100644
--- a/server/apps/distributed-app/sample-configuration/rabbitmq.properties
+++ b/server/apps/distributed-app/sample-configuration/rabbitmq.properties
@@ -43,6 +43,10 @@ management.password=guest
 
 # Parameters for the Cassandra administrative view
 
+# Whether the Cassandra administrative view should be activated. Boolean value 
defaulting to true.
+# Not necessarily needed for MDA deployments, mail queue management adds 
significant complexity.
+# cassandra.view.enabled=true
+
 # Period of the window. Too large values will lead to wide rows while too 
little values might lead to many queries.
 # Use the number of mail per Cassandra row, along with your expected traffic, 
to determine this value
 # This value can only be decreased to a value dividing the current value
diff --git 
a/server/apps/distributed-app/src/main/java/org/apache/james/CassandraRabbitMQJamesConfiguration.java
 
b/server/apps/distributed-app/src/main/java/org/apache/james/CassandraRabbitMQJamesConfiguration.java
index 738977bb04..1a07d32a91 100644
--- 
a/server/apps/distributed-app/src/main/java/org/apache/james/CassandraRabbitMQJamesConfiguration.java
+++ 
b/server/apps/distributed-app/src/main/java/org/apache/james/CassandraRabbitMQJamesConfiguration.java
@@ -26,6 +26,7 @@ import org.apache.james.data.UsersRepositoryModuleChooser;
 import org.apache.james.filesystem.api.FileSystem;
 import org.apache.james.filesystem.api.JamesDirectoriesProvider;
 import org.apache.james.modules.blobstore.BlobStoreConfiguration;
+import org.apache.james.modules.queue.rabbitmq.MailQueueViewChoice;
 import org.apache.james.server.core.JamesServerResourceLoader;
 import org.apache.james.server.core.MissingArgumentException;
 import org.apache.james.server.core.configuration.Configuration;
@@ -41,6 +42,7 @@ public class CassandraRabbitMQJamesConfiguration implements 
Configuration {
 private Optional blobStoreConfiguration;
 private Optional rootDirectory;
 private Optional configurationPath;
+private Optional mailQueueViewChoice;
 private Optional 
usersRepositoryImplementation;
 
 private Builder() {
@@ -49,6 +51,7 @@ public class

[james-project] branch master updated: JAMES-3899 WithStorageDirective should support extra mailboxes that do not yet exists (#1628)

2023-07-03 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
 new b53c363150 JAMES-3899 WithStorageDirective should support extra 
mailboxes that do not yet exists (#1628)
b53c363150 is described below

commit b53c36315062c8e3483162f8945e66f46bcb2ff4
Author: Benoit TELLIER 
AuthorDate: Tue Jul 4 05:33:29 2023 +0200

JAMES-3899 WithStorageDirective should support extra mailboxes that do not 
yet exists (#1628)

Those are created if need be.
---
 .../WithStorageDirectiveIntegrationTest.java   | 29 ++
 .../mailets/delivery/MailboxAppenderImpl.java  | 15 ---
 2 files changed, 41 insertions(+), 3 deletions(-)

diff --git 
a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/WithStorageDirectiveIntegrationTest.java
 
b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/WithStorageDirectiveIntegrationTest.java
index 066d64..e7b28c82bd 100644
--- 
a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/WithStorageDirectiveIntegrationTest.java
+++ 
b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/WithStorageDirectiveIntegrationTest.java
@@ -38,7 +38,9 @@ import org.apache.james.probe.DataProbe;
 import org.apache.james.transport.mailets.WithStorageDirective;
 import org.apache.james.transport.matchers.SenderIsLocal;
 import org.apache.james.utils.DataProbeImpl;
+import org.apache.james.utils.MailRepositoryProbeImpl;
 import org.apache.james.utils.SMTPMessageSender;
+import org.apache.james.utils.SpoolerProbe;
 import org.apache.james.utils.TestIMAPClient;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Test;
@@ -99,6 +101,33 @@ class WithStorageDirectiveIntegrationTest {
 .awaitMessage(awaitAtMostOneMinute);
 }
 
+@Test
+void targetFolderNamesShouldWorkWhenTargetFolderDoNotExist(@TempDir File 
temporaryFolder) throws Exception {
+setUp(temporaryFolder, MailetConfiguration.builder()
+.matcher(SenderIsLocal.class)
+.mailet(WithStorageDirective.class)
+.addProperty("targetFolderNames", "target1, target2"));
+
+testIMAPClient.connect(LOCALHOST_IP, 
jamesServer.getProbe(ImapGuiceProbe.class).getImapPort())
+.login(RECIPIENT, PASSWORD);
+
+messageSender.connect(LOCALHOST_IP, 
jamesServer.getProbe(SmtpGuiceProbe.class).getSmtpPort())
+.authenticate(FROM, PASSWORD)
+.sendMessage(FROM, RECIPIENT);
+
+awaitAtMostOneMinute.until(() -> 
jamesServer.getProbe(SpoolerProbe.class).processingFinished());
+testIMAPClient.connect(LOCALHOST_IP, 
jamesServer.getProbe(ImapGuiceProbe.class).getImapPort())
+.login(RECIPIENT, PASSWORD)
+.select("target1")
+.awaitMessage(awaitAtMostOneMinute)
+.close();
+testIMAPClient.connect(LOCALHOST_IP, 
jamesServer.getProbe(ImapGuiceProbe.class).getImapPort())
+.login(RECIPIENT, PASSWORD)
+.select("target2")
+.awaitMessage(awaitAtMostOneMinute)
+.close();
+}
+
 @Test
 void seenShouldWork(@TempDir File temporaryFolder) throws Exception {
 setUp(temporaryFolder, MailetConfiguration.builder()
diff --git 
a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailboxAppenderImpl.java
 
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailboxAppenderImpl.java
index 5e793b8f4a..e1fd413b65 100644
--- 
a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailboxAppenderImpl.java
+++ 
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailboxAppenderImpl.java
@@ -82,11 +82,10 @@ public class MailboxAppenderImpl implements MailboxAppender 
{
 return Flux.fromIterable(folders)
 .skip(1)
 .flatMap(Throwing.function(extraTargetFolder -> {
-MailboxPath targetMailboxPath = 
MailboxPath.forUser(session.getUser(), targetFolder);
+MailboxPath originMailboxPath = 
MailboxPath.forUser(session.getUser(), targetFolder);
 MailboxPath destinationMailboxPath = 
MailboxPath.forUser(session.getUser(), useSlashAsSeparator(extraTargetFolder, 
session));
 
-return 
mailboxManager.copyMessagesReactive(MessageRange.one(id.getUid()),
-targetMailboxPath, destinationMailboxPath, session);
+return copyToExtraMailbox(id, originMailboxPath, 
destinationMailboxPath, session);
 }))
 .then(Mono.fromRunnable(() -> LOGGER.info("{} copied to {} 
extra mailboxes", id

[james-project] branch 3.8.x updated: JAMES-3922: Enforce non-null Property contract and add missing null-check in Prope (#1619) (#1622)

2023-07-03 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch 3.8.x
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/3.8.x by this push:
 new 3cd1125bb4 JAMES-3922: Enforce non-null Property contract and add 
missing null-check in Prope (#1619) (#1622)
3cd1125bb4 is described below

commit 3cd1125bb42087cd5dbca7239b60ba619e27db90
Author: Benoit TELLIER 
AuthorDate: Tue Jul 4 05:17:59 2023 +0200

JAMES-3922: Enforce non-null Property contract and add missing null-check 
in Prope (#1619) (#1622)

Co-authored-by: Wojtek 
---
 .../james/mailbox/store/mail/model/Property.java   | 10 ++
 .../mailbox/store/mail/model/impl/PropertyBuilder.java |  8 ++--
 .../store/mail/model/impl/PropertyBuilderTest.java | 18 ++
 3 files changed, 30 insertions(+), 6 deletions(-)

diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/Property.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/Property.java
index 2e0e7a3ce1..350a17ef7d 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/Property.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/Property.java
@@ -22,6 +22,8 @@ import java.util.Objects;
 
 import com.google.common.base.MoreObjects;
 
+import reactor.util.annotation.NonNull;
+
 /**
  * Values a namespaced property.
  * 
@@ -51,11 +53,11 @@ public class Property {
  * @param localName not null
  * @param value not null
  */
-public Property(String namespace, String localName, String value) {
+public Property(@NonNull String namespace, @NonNull String localName, 
@NonNull String value) {
 super();
-this.namespace = namespace;
-this.localName = localName;
-this.value = value;
+this.namespace = Objects.requireNonNull(namespace);
+this.localName = Objects.requireNonNull(localName);
+this.value = Objects.requireNonNull(value);
 }
 
 public Property(Property property) {
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/PropertyBuilder.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/PropertyBuilder.java
index 74f5409822..4356add478 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/PropertyBuilder.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/PropertyBuilder.java
@@ -111,7 +111,9 @@ public class PropertyBuilder {
 properties.removeIf(property -> property.isNamed(namespace, 
localName));
 if (values != null) {
 for (String value:values) {
-properties.add(new Property(namespace, localName, value));
+if (value != null) {
+properties.add(new Property(namespace, localName, value));
+}
 }
 }
 }
@@ -126,7 +128,9 @@ public class PropertyBuilder {
 private void setProperties(String namespace, Map 
valuesByLocalName) {
 properties.removeIf(property -> property.isInSpace(namespace));
 for (Map.Entry 
valueByLocalName:valuesByLocalName.entrySet()) {
-properties.add(new Property(namespace, 
valueByLocalName.getKey().toLowerCase(Locale.US), valueByLocalName.getValue()));
+if (valueByLocalName.getValue() != null) {
+properties.add(new Property(namespace, 
valueByLocalName.getKey().toLowerCase(Locale.US), valueByLocalName.getValue()));
+}
 }
 }
 
diff --git 
a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/PropertyBuilderTest.java
 
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/PropertyBuilderTest.java
index 1e10873a07..20054f7b68 100644
--- 
a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/PropertyBuilderTest.java
+++ 
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/PropertyBuilderTest.java
@@ -26,12 +26,30 @@ import static org.assertj.core.api.Assertions.assertThat;
 import org.apache.james.mailbox.store.mail.model.Property;
 import org.junit.jupiter.api.Test;
 
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
 class PropertyBuilderTest {
 @Test
 void emptyPropertyBuilderShouldCreateEmptyProperties() {
 assertThat(new PropertyBuilder().toProperties()).isEmpty();
 }
 
+@Test
+void nullValuePropertyBuilderShouldCreateEmptyProperties() {
+List listOfNulls = Arrays.asList(null, null, null);
+Map  mapWithNullValues = Collections.singletonMap("k1", 
null);
+
+PropertyBuilder builder = new PropertyBuilder();
+builder.setContentLanguage(listOfNulls);
+builder.setConte

[james-site] branch asf-site updated: Remove bash + DockerFiles

2023-07-03 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/james-site.git


The following commit(s) were added to refs/heads/asf-site by this push:
 new fe538ba16 Remove bash + DockerFiles
fe538ba16 is described below

commit fe538ba162118e6aa59bbdc55e9ca905a109b9f2
Author: Benoit Tellier 
AuthorDate: Mon Jul 3 22:31:25 2023 +0700

Remove bash + DockerFiles
---
 content/Dockerfile | 25 -
 content/compile.sh | 43 ---
 2 files changed, 68 deletions(-)

diff --git a/content/Dockerfile b/content/Dockerfile
deleted file mode 100644
index 9ee311b98..0
--- a/content/Dockerfile
+++ /dev/null
@@ -1,25 +0,0 @@
-FROM ruby:2.6.8-buster
-
-RUN apt-get update \
-  && apt-get install -y \
-nodejs \
-python-pygments \
-  && apt-get clean \
-  && rm -rf /var/lib/apt/lists/
-
-RUN gem install \
-  github-pages \
-  jekyll \
-  jekyll-feed \
-  jekyll-redirect-from \
-  jekyll-seo-tag \
-  kramdown \
-  rdiscount \
-  rouge
-
-# Copy the script
-COPY compile.sh /root/compile.sh
-
-# Define the entrypoint
-WORKDIR /james-project
-ENTRYPOINT ["/root/compile.sh"]
diff --git a/content/compile.sh b/content/compile.sh
deleted file mode 100755
index bc02c3f45..0
--- a/content/compile.sh
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/bin/sh -e
-#
-
-printUsage() {
-   echo "Usage : "
-   echo "./compile.sh SHA1"
-   echo "SHA1: SHA1 to build (optional)"
-   exit 1
-}
-
-ORIGIN=/origin
-DESTINATION=/destination
-
-for arg in "$@"
-do
-   case $arg in
-  -*)
- echo "Invalid option: -$OPTARG"
- printUsage
- ;;
-  *)
- if ! [ -z "$1" ]; then
-SHA1=$1
- fi
- ;;
-   esac
-   if [ "0" -lt "$#" ]; then
-  shift
-   fi
-done
-
-if [ -z "$SHA1" ]; then
-   SHA1=master
-fi
-
-# Sources retrieval
-git clone $ORIGIN/.
-git checkout $SHA1
-
-# Compilation /james-project/src/jekyll/_site
-
-jekyll build --source src/homepage --destination $DESTINATION
-


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



[james-project] branch master updated: Add documentation for future release jmap (#1620)

2023-07-03 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
 new c3799748f8 Add documentation for future release jmap (#1620)
c3799748f8 is described below

commit c3799748f86d1b5a0432a1ae0a1ea693b339b1e1
Author: vtbui <87489927+thanhbv200...@users.noreply.github.com>
AuthorDate: Mon Jul 3 13:27:37 2023 +0700

Add documentation for future release jmap (#1620)
---
 .../apps/distributed-app/docs/modules/ROOT/pages/configure/jmap.adoc   | 2 ++
 server/apps/memory-app/sample-configuration/jmap.properties| 1 +
 src/site/xdoc/server/config-jmap.xml   | 3 +++
 3 files changed, 6 insertions(+)

diff --git 
a/server/apps/distributed-app/docs/modules/ROOT/pages/configure/jmap.adoc 
b/server/apps/distributed-app/docs/modules/ROOT/pages/configure/jmap.adoc
index eb3e31bb14..c879306a01 100644
--- a/server/apps/distributed-app/docs/modules/ROOT/pages/configure/jmap.adoc
+++ b/server/apps/distributed-app/docs/modules/ROOT/pages/configure/jmap.adoc
@@ -92,6 +92,8 @@ then `capabilities."urn:ietf:params:jmap:websocket".url` in 
response will be "ws
 for JMAP filters. This projection optimizes reads, but needs to be correctly 
populated. Turning it on on
 systems with filters already defined would result in those filters to be not 
read.
 
+| delay.sends.enabled
+| Optional boolean. Defaults to false. Whether to support or not the delay 
send with JMAP protocol.
 |===
 
 == Wire tapping
diff --git a/server/apps/memory-app/sample-configuration/jmap.properties 
b/server/apps/memory-app/sample-configuration/jmap.properties
index 56e61af55a..f8b06115ef 100644
--- a/server/apps/memory-app/sample-configuration/jmap.properties
+++ b/server/apps/memory-app/sample-configuration/jmap.properties
@@ -5,6 +5,7 @@ enabled=true
 
 tls.keystoreURL=file://conf/keystore
 tls.secret=james72laBalle
+delay.sends.enabled=true
 
 # Alternatively TLS keys can be supplied via PEM files
 # tls.privateKey=file://conf/private.nopass.key
diff --git a/src/site/xdoc/server/config-jmap.xml 
b/src/site/xdoc/server/config-jmap.xml
index ff375f99ad..7687ad44ba 100644
--- a/src/site/xdoc/server/config-jmap.xml
+++ b/src/site/xdoc/server/config-jmap.xml
@@ -131,6 +131,9 @@
 for JMAP filters. This projection optimizes reads, but 
needs to be correctly populated. Turning it on on
 systems with filters already defined would result in 
those filters to be not read.
 
+
+delay.sends.enabled
+Optional boolean. Defaults to false. Whether to 
support or not the delay send with JMAP protocol. 
 
 
 


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



[james-project] branch master updated: JAMES-3921 Fix Lucene indexing issues (#1621)

2023-07-03 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
 new 3a80597887 JAMES-3921 Fix Lucene indexing issues (#1621)
3a80597887 is described below

commit 3a80597887d64c30bfa1ab1ce527959b6841f63e
Author: Benoit TELLIER 
AuthorDate: Mon Jul 3 08:23:02 2023 +0200

JAMES-3921 Fix Lucene indexing issues (#1621)
---
 .../lucene/search/LuceneMessageSearchIndex.java| 24 ++
 .../LuceneMailboxMessageSearchIndexTest.java   | 24 +-
 2 files changed, 25 insertions(+), 23 deletions(-)

diff --git 
a/mailbox/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndex.java
 
b/mailbox/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndex.java
index c71e17ce5e..141c6d06ee 100644
--- 
a/mailbox/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndex.java
+++ 
b/mailbox/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndex.java
@@ -22,7 +22,6 @@ import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
-import java.io.StringReader;
 import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.Calendar;
@@ -79,11 +78,9 @@ import org.apache.james.mime4j.dom.address.Address;
 import org.apache.james.mime4j.dom.address.AddressList;
 import org.apache.james.mime4j.dom.address.Group;
 import org.apache.james.mime4j.dom.address.MailboxList;
-import org.apache.james.mime4j.dom.datetime.DateTime;
 import org.apache.james.mime4j.dom.field.DateTimeField;
 import org.apache.james.mime4j.field.address.AddressFormatter;
 import org.apache.james.mime4j.field.address.LenientAddressParser;
-import org.apache.james.mime4j.field.datetime.parser.DateTimeParser;
 import org.apache.james.mime4j.message.SimpleContentHandler;
 import org.apache.james.mime4j.parser.MimeStreamParser;
 import org.apache.james.mime4j.stream.BodyDescriptor;
@@ -116,8 +113,6 @@ import org.apache.lucene.search.TopDocs;
 import org.apache.lucene.search.WildcardQuery;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.Version;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import com.github.fge.lambdas.Throwing;
 import com.google.common.base.Preconditions;
@@ -135,7 +130,6 @@ public class LuceneMessageSearchIndex extends 
ListeningMessageSearchIndex {
 
 }
 
-private static final Logger LOGGER = 
LoggerFactory.getLogger(LuceneMessageSearchIndex.class);
 private static final Date MAX_DATE;
 private static final Date MIN_DATE;
 public static final org.apache.james.events.Group GROUP = new 
LuceneMessageSearchIndexGroup();
@@ -628,22 +622,8 @@ public class LuceneMessageSearchIndex extends 
ListeningMessageSearchIndex {
 doc.add(new Field(PREFIX_HEADER_FIELD + headerName, 
headerValue, Store.NO, Index.ANALYZED));
 
 if (f instanceof DateTimeField) {
-// We need to make sure we convert it to GMT
-try (StringReader reader = new 
StringReader(f.getBody())) {
-DateTime dateTime = new 
DateTimeParser(reader).parseAll();
-Calendar cal = getGMT();
-cal.set(dateTime.getYear(), dateTime.getMonth() - 
1, dateTime.getDay(), dateTime.getHour(), dateTime.getMinute(), 
dateTime.getSecond());
-sentDate = cal.getTime();
-
-} catch 
(org.apache.james.mime4j.field.datetime.parser.ParseException e) {
-LOGGER.debug("Unable to parse Date header for 
proper indexing", e);
-// This should never happen anyway fallback to the 
already parsed field
-sentDate = ((DateTimeField) f).getDate();
-}
-if (sentDate == null) {
-sentDate = membership.getInternalDate();
-}
-
+DateTimeField dateTimeField = (DateTimeField) f;
+sentDate = dateTimeField.getDate();
 }
 String field = null;
 if ("To".equalsIgnoreCase(headerName)) {
diff --git 
a/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java
 
b/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java
index 9508ffeba0..1a7e7fd338 100644
--- 
a/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java
+++ 
b/mailbox/lucene/src/test/java/org/apache/james/m

[james-project] branch master updated: JAMES-3922: Enforce non-null Property contract and add missing null-check in Prope (#1619)

2023-06-30 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
 new 3ba7c42399 JAMES-3922: Enforce non-null Property contract and add 
missing null-check in Prope (#1619)
3ba7c42399 is described below

commit 3ba7c423991b0d47a8cc38cb902bca14a38b36c1
Author: Wojtek 
AuthorDate: Fri Jun 30 04:22:40 2023 -0400

JAMES-3922: Enforce non-null Property contract and add missing null-check 
in Prope (#1619)
---
 .../james/mailbox/store/mail/model/Property.java   | 10 ++
 .../mailbox/store/mail/model/impl/PropertyBuilder.java |  8 ++--
 .../store/mail/model/impl/PropertyBuilderTest.java | 18 ++
 3 files changed, 30 insertions(+), 6 deletions(-)

diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/Property.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/Property.java
index 2e0e7a3ce1..350a17ef7d 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/Property.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/Property.java
@@ -22,6 +22,8 @@ import java.util.Objects;
 
 import com.google.common.base.MoreObjects;
 
+import reactor.util.annotation.NonNull;
+
 /**
  * Values a namespaced property.
  * 
@@ -51,11 +53,11 @@ public class Property {
  * @param localName not null
  * @param value not null
  */
-public Property(String namespace, String localName, String value) {
+public Property(@NonNull String namespace, @NonNull String localName, 
@NonNull String value) {
 super();
-this.namespace = namespace;
-this.localName = localName;
-this.value = value;
+this.namespace = Objects.requireNonNull(namespace);
+this.localName = Objects.requireNonNull(localName);
+this.value = Objects.requireNonNull(value);
 }
 
 public Property(Property property) {
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/PropertyBuilder.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/PropertyBuilder.java
index 74f5409822..4356add478 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/PropertyBuilder.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/PropertyBuilder.java
@@ -111,7 +111,9 @@ public class PropertyBuilder {
 properties.removeIf(property -> property.isNamed(namespace, 
localName));
 if (values != null) {
 for (String value:values) {
-properties.add(new Property(namespace, localName, value));
+if (value != null) {
+properties.add(new Property(namespace, localName, value));
+}
 }
 }
 }
@@ -126,7 +128,9 @@ public class PropertyBuilder {
 private void setProperties(String namespace, Map 
valuesByLocalName) {
 properties.removeIf(property -> property.isInSpace(namespace));
 for (Map.Entry 
valueByLocalName:valuesByLocalName.entrySet()) {
-properties.add(new Property(namespace, 
valueByLocalName.getKey().toLowerCase(Locale.US), valueByLocalName.getValue()));
+if (valueByLocalName.getValue() != null) {
+properties.add(new Property(namespace, 
valueByLocalName.getKey().toLowerCase(Locale.US), valueByLocalName.getValue()));
+}
 }
 }
 
diff --git 
a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/PropertyBuilderTest.java
 
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/PropertyBuilderTest.java
index 1e10873a07..20054f7b68 100644
--- 
a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/PropertyBuilderTest.java
+++ 
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/PropertyBuilderTest.java
@@ -26,12 +26,30 @@ import static org.assertj.core.api.Assertions.assertThat;
 import org.apache.james.mailbox.store.mail.model.Property;
 import org.junit.jupiter.api.Test;
 
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
 class PropertyBuilderTest {
 @Test
 void emptyPropertyBuilderShouldCreateEmptyProperties() {
 assertThat(new PropertyBuilder().toProperties()).isEmpty();
 }
 
+@Test
+void nullValuePropertyBuilderShouldCreateEmptyProperties() {
+List listOfNulls = Arrays.asList(null, null, null);
+Map  mapWithNullValues = Collections.singletonMap("k1", 
null);
+
+PropertyBuilder builder = new PropertyBuilder();
+builder.setContentLanguage(listOfNulls);
+builder.setContentTypeParameters(mapWithNullValues);
+builder

[james-mime4j] branch master updated: MIME4J-325 DateTimeParser should throw ParseException if value can't be parsed (#88)

2023-06-30 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-mime4j.git


The following commit(s) were added to refs/heads/master by this push:
 new 0ef21683 MIME4J-325 DateTimeParser should throw ParseException if 
value can't be parsed (#88)
0ef21683 is described below

commit 0ef216839687e1b0b027f2cff75912f4432747a1
Author: Wojtek 
AuthorDate: Fri Jun 30 02:08:28 2023 -0400

MIME4J-325 DateTimeParser should throw ParseException if value can't be 
parsed (#88)
---
 .../james/mime4j/field/datetime/DateTimeParser.jj| 20 ++--
 .../james/mime4j/field/datetime/DateTimeTest.java|  5 +
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git 
a/dom/src/main/javacc/org/apache/james/mime4j/field/datetime/DateTimeParser.jj 
b/dom/src/main/javacc/org/apache/james/mime4j/field/datetime/DateTimeParser.jj
index 8582f6e9..f67cf312 100644
--- 
a/dom/src/main/javacc/org/apache/james/mime4j/field/datetime/DateTimeParser.jj
+++ 
b/dom/src/main/javacc/org/apache/james/mime4j/field/datetime/DateTimeParser.jj
@@ -72,6 +72,22 @@ public class DateTimeParser {
}
 }
 
+public DateTime parseAll() throws ParseException {
+   try {
+   return doParseAll();
+   } catch (TokenMgrError e) {
+   throw new ParseException(e);
+   }
+}
+
+public DateTime parseLine() throws ParseException {
+   try {
+   return doParseLine();
+   } catch (TokenMgrError e) {
+   throw new ParseException(e);
+   }
+}
+
 private static int parseDigits(Token token) {
 return Integer.parseInt(token.image, 10);
 }
@@ -152,14 +168,14 @@ public class DateTimeParser {
 
 PARSER_END(DateTimeParser)
 
-DateTime parseLine() :
+private DateTime doParseLine() :
 {DateTime dt;}
 {
dt=date_time() ["\r"] "\n"
{ return dt; }
 }
 
-DateTime parseAll() :
+private DateTime doParseAll() :
 {DateTime dt;}
 {
dt=date_time() 
diff --git 
a/dom/src/test/java/org/apache/james/mime4j/field/datetime/DateTimeTest.java 
b/dom/src/test/java/org/apache/james/mime4j/field/datetime/DateTimeTest.java
index 02510bae..542021f0 100644
--- a/dom/src/test/java/org/apache/james/mime4j/field/datetime/DateTimeTest.java
+++ b/dom/src/test/java/org/apache/james/mime4j/field/datetime/DateTimeTest.java
@@ -101,6 +101,11 @@ public class DateTimeTest {
 });
 }
 
+@Test(expected=ParseException.class)
+public void testParseInvalidDateTime() throws Exception {
+new DateTimeParser(new StringReader("Thu, 29 Jan   
\u008Crodkowoeuropejski czas stand.")).parseAll();
+}
+
 private void ensureAllEqual(String[] dateStrings) throws ParseException {
 for (int i = 0; i < dateStrings.length - 1; i++) {
 long date1 = new DateTimeParser(new 
StringReader(dateStrings[i])).parseAll().getDate().getTime();


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



[james-project] branch master updated: JAMES-3867 Allow per IMAP server package specification (#1613)

2023-06-28 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
 new 827a69efb6 JAMES-3867 Allow per IMAP server package specification 
(#1613)
827a69efb6 is described below

commit 827a69efb660a586e8c7bb44620573174586f669
Author: Benoit TELLIER 
AuthorDate: Wed Jun 28 16:18:45 2023 +0200

JAMES-3867 Allow per IMAP server package specification (#1613)
---
 .../sample-configuration/imapserver.xml|  4 +-
 .../custom-imap/src/main/resources/imapserver.xml  |  6 +-
 .../main/java/org/apache/james/imap/ImapSuite.java | 48 +
 .../imap/decode/parser/ImapParserFactory.java  |  7 ++
 .../james/modules/protocols/IMAPServerModule.java  | 78 --
 .../james/imapserver/netty/IMAPServerFactory.java  | 25 +++
 upgrade-instructions.md| 17 -
 7 files changed, 130 insertions(+), 55 deletions(-)

diff --git a/examples/custom-imap/sample-configuration/imapserver.xml 
b/examples/custom-imap/sample-configuration/imapserver.xml
index 1156e5b3c8..910586 100644
--- a/examples/custom-imap/sample-configuration/imapserver.xml
+++ b/examples/custom-imap/sample-configuration/imapserver.xml
@@ -33,7 +33,7 @@ under the License.
 0
 false
 false
+
org.apache.james.modules.protocols.DefaultImapPackage
+
org.apache.james.examples.imap.PingImapPackages
 
-
org.apache.james.modules.protocols.DefaultImapPackage
-
org.apache.james.examples.imap.PingImapPackages
 
\ No newline at end of file
diff --git a/examples/custom-imap/src/main/resources/imapserver.xml 
b/examples/custom-imap/src/main/resources/imapserver.xml
index 8971ea8d03..9f5ec0e98b 100644
--- a/examples/custom-imap/src/main/resources/imapserver.xml
+++ b/examples/custom-imap/src/main/resources/imapserver.xml
@@ -36,6 +36,8 @@ under the License.
 pong.response=customImapParameter
 prop.b=anotherValue
 false
+
org.apache.james.modules.protocols.DefaultImapPackage
+
org.apache.james.examples.imap.PingImapPackages
 
 
 imapservers
@@ -53,7 +55,7 @@ under the License.
 pong.response=bad
 prop.b=baad
 false
+
org.apache.james.modules.protocols.DefaultImapPackage
+
org.apache.james.examples.imap.PingImapPackages
 
-
org.apache.james.modules.protocols.DefaultImapPackage
-
org.apache.james.examples.imap.PingImapPackages
 
\ No newline at end of file
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/ImapSuite.java 
b/protocols/imap/src/main/java/org/apache/james/imap/ImapSuite.java
new file mode 100644
index 00..8048be6a1d
--- /dev/null
+++ b/protocols/imap/src/main/java/org/apache/james/imap/ImapSuite.java
@@ -0,0 +1,48 @@
+/
+ * 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.imap;
+
+import org.apache.james.imap.api.process.ImapProcessor;
+import org.apache.james.imap.decode.ImapDecoder;
+import org.apache.james.imap.encode.ImapEncoder;
+
+public class ImapSuite {
+private final ImapDecoder decoder;
+private final ImapEncoder encoder;
+private final ImapProcessor processor;
+
+public ImapSuite(ImapDecoder decoder, ImapEncoder encoder, ImapProcessor 
processor) {
+this.decoder = decoder;
+this.encoder = encoder;
+this.processor = processor;
+}
+
+public ImapDecoder getDecoder() {
+return decoder;
+}
+
+public ImapEncoder getEncoder() {
+return encoder;
+}
+
+public ImapProcessor getProcessor() {
+return processor;
+}
+}
diff --git 
a/protocols/imap/src/main/java/o

[james-project] branch 3.8.x updated: JAMES-3919 RabbitMQMailQueue: clean up cassandra projection when we c… (#1609) (#1615)

2023-06-28 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch 3.8.x
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/3.8.x by this push:
 new 295f757b81 JAMES-3919 RabbitMQMailQueue: clean up cassandra projection 
when we c… (#1609) (#1615)
295f757b81 is described below

commit 295f757b811abf49d4c7a4c7109ea9b50c62a3b0
Author: Benoit TELLIER 
AuthorDate: Wed Jun 28 15:59:59 2023 +0200

JAMES-3919 RabbitMQMailQueue: clean up cassandra projection when we c… 
(#1609) (#1615)
---
 .../backends/rabbitmq/RabbitMQManagementAPI.java   |  3 ++
 .../org/apache/james/queue/rabbitmq/Dequeuer.java  |  2 +-
 .../org/apache/james/queue/rabbitmq/Enqueuer.java  | 13 -
 .../james/queue/rabbitmq/RabbitMQMailQueue.java|  4 +--
 .../queue/rabbitmq/view/api/FakeMailQueueView.java |  4 +--
 .../queue/rabbitmq/view/api/MailQueueView.java |  3 +-
 .../view/cassandra/CassandraMailQueueView.java | 11 ---
 .../queue/rabbitmq/RabbitMQMailQueueTest.java  | 34 --
 8 files changed, 46 insertions(+), 28 deletions(-)

diff --git 
a/backends-common/rabbitmq/src/main/java/org/apache/james/backends/rabbitmq/RabbitMQManagementAPI.java
 
b/backends-common/rabbitmq/src/main/java/org/apache/james/backends/rabbitmq/RabbitMQManagementAPI.java
index 9b7dc78089..390d09137c 100644
--- 
a/backends-common/rabbitmq/src/main/java/org/apache/james/backends/rabbitmq/RabbitMQManagementAPI.java
+++ 
b/backends-common/rabbitmq/src/main/java/org/apache/james/backends/rabbitmq/RabbitMQManagementAPI.java
@@ -454,6 +454,9 @@ public interface RabbitMQManagementAPI {
 @RequestLine(value = "DELETE /api/queues/{vhost}/{name}", decodeSlash = 
false)
 void deleteQueue(@Param("vhost") String vhost, @Param("name") String name);
 
+@RequestLine(value = "DELETE /api/queues/{vhost}/{name}/contents", 
decodeSlash = false)
+void purgeQueue(@Param("vhost") String vhost, @Param("name") String name);
+
 @RequestLine(value = "GET /api/exchanges/{vhost}/{name}/bindings/source", 
decodeSlash = false)
 List listBindings(@Param("vhost") String vhost, 
@Param("name") String name);
 
diff --git 
a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Dequeuer.java
 
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Dequeuer.java
index f9440c03fa..98d2d28b6d 100644
--- 
a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Dequeuer.java
+++ 
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Dequeuer.java
@@ -141,7 +141,7 @@ class Dequeuer {
 case SUCCESS:
 dequeueMetric.increment();
 response.ack();
-
mailQueueView.delete(DeleteCondition.withEnqueueId(mailWithEnqueueId.getEnqueueId(),
 mailWithEnqueueId.getBlobIds()));
+
Mono.from(mailQueueView.delete(DeleteCondition.withEnqueueId(mailWithEnqueueId.getEnqueueId(),
 mailWithEnqueueId.getBlobIds(.block();
 break;
 case RETRY:
 response.nack(REQUEUE);
diff --git 
a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Enqueuer.java
 
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Enqueuer.java
index aacb1e06b6..658de9ba43 100644
--- 
a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Enqueuer.java
+++ 
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Enqueuer.java
@@ -25,6 +25,7 @@ import static 
org.apache.james.queue.api.MailQueue.ENQUEUED_METRIC_NAME_PREFIX;
 
 import java.time.Clock;
 import java.time.Duration;
+import java.util.function.Function;
 
 import javax.mail.MessagingException;
 import javax.mail.internet.MimeMessage;
@@ -35,6 +36,7 @@ import org.apache.james.metrics.api.Metric;
 import org.apache.james.metrics.api.MetricFactory;
 import org.apache.james.queue.api.MailQueue;
 import org.apache.james.queue.rabbitmq.view.RabbitMQMailQueueConfiguration;
+import org.apache.james.queue.rabbitmq.view.api.DeleteCondition;
 import org.apache.james.queue.rabbitmq.view.api.MailQueueView;
 import 
org.apache.james.queue.rabbitmq.view.cassandra.CassandraMailQueueBrowser;
 import org.apache.mailet.Mail;
@@ -82,11 +84,20 @@ class Enqueuer {
 return Flux.mergeDelayError(2,
 mailQueueView.storeMail(enqueuedItem),
 publishReferenceToRabbit(mailReference))
-.then();
+.then()
+.onErrorResume(cleanupMailQueueView(enqueueId, 
mailReference));
 }).sneakyThrow())
 .thenEmpty(Mono.fromRunnable(enqueueMetric::increment));
 }
 
+private Function> cleanupMa

[james-project] branch 3.8.x updated: JAMES-3918 Force deletion of user mailboxes (#1608) (#1611)

2023-06-28 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch 3.8.x
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/3.8.x by this push:
 new df07cd2ea6 JAMES-3918 Force deletion of user mailboxes (#1608) (#1611)
df07cd2ea6 is described below

commit df07cd2ea68e3b4f49917dad20f5e3abe8a2f26d
Author: Benoit TELLIER 
AuthorDate: Wed Jun 28 15:59:09 2023 +0200

JAMES-3918 Force deletion of user mailboxes (#1608) (#1611)
---
 .../docs/modules/ROOT/pages/operate/webadmin.adoc  |  9 +++--
 .../james/webadmin/routes/UserMailboxesRoutes.java | 23 +++
 .../webadmin/service/UserMailboxesService.java | 37 ++
 .../webadmin/routes/UserMailboxesRoutesTest.java   | 44 --
 src/site/markdown/server/manage-webadmin.md| 11 +++---
 5 files changed, 87 insertions(+), 37 deletions(-)

diff --git 
a/server/apps/distributed-app/docs/modules/ROOT/pages/operate/webadmin.adoc 
b/server/apps/distributed-app/docs/modules/ROOT/pages/operate/webadmin.adoc
index 2449073d27..04c05b3db7 100644
--- a/server/apps/distributed-app/docs/modules/ROOT/pages/operate/webadmin.adoc
+++ b/server/apps/distributed-app/docs/modules/ROOT/pages/operate/webadmin.adoc
@@ -1610,7 +1610,7 @@ Response codes:
 
 * 204: The mailbox now exists on the server
 * 400: Invalid mailbox name
-* 404: The user name does not exist
+* 404: The user name does not exist. Note that this check can be bypassed by 
specifying the `force` query parameter.
 
 To create nested mailboxes, for instance a work mailbox inside the INBOX
 mailbox, people should use the . separator. The sample query is:
@@ -1632,7 +1632,7 @@ Response codes:
 
 * 204: The mailbox now does not exist on the server
 * 400: Invalid mailbox name
-* 404: The user name does not exist
+* 404: The user name does not exist. Note that this check can be bypassed by 
specifying the `force` query parameter.
 
 === Testing existence of a mailbox
 
@@ -1666,7 +1666,8 @@ Resource name `usernameToBeUsed` should be an existing 
user
 Response codes:
 
 * 200: The mailboxes list was successfully retrieved
-* 404: The user name does not exist
+* 404: The user name does not exist, the mailbox does not exist. Note that 
this check can be bypassed by specifying the `force` query parameter.
+
 
 === Deleting user mailboxes
 
@@ -1679,7 +1680,7 @@ Resource name `usernameToBeUsed` should be an existing 
user
 Response codes:
 
 * 204: The user do not have mailboxes anymore
-* 404: The user name does not exist
+* 404: The user name does not exist. Note that this check can be bypassed by 
specifying the `force` query parameter.
 
 === Exporting user mailboxes
 
diff --git 
a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/UserMailboxesRoutes.java
 
b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/UserMailboxesRoutes.java
index 365c8e80d0..30c813fe1a 100644
--- 
a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/UserMailboxesRoutes.java
+++ 
b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/UserMailboxesRoutes.java
@@ -73,6 +73,13 @@ public class UserMailboxesRoutes implements Routes {
 return Username.of(request.params(USER_NAME));
 }
 
+private static UserMailboxesService.Options getOptions(Request request) {
+if (request.queryParams().contains("force")) {
+return UserMailboxesService.Options.Force;
+}
+return UserMailboxesService.Options.Check;
+}
+
 public static final String MAILBOX_NAME = ":mailboxName";
 public static final String MAILBOXES = "mailboxes";
 private static final String USER_NAME = ":userName";
@@ -134,7 +141,7 @@ public class UserMailboxesRoutes implements Routes {
 service.get(USER_MAILBOXES_BASE, (request, response) -> {
 response.status(HttpStatus.OK_200);
 try {
-return 
userMailboxesService.listMailboxes(getUsernameParam(request));
+return 
userMailboxesService.listMailboxes(getUsernameParam(request), 
getOptions(request));
 } catch (IllegalStateException e) {
 LOGGER.info("Invalid get on user mailboxes", e);
 throw ErrorResponder.builder()
@@ -157,7 +164,7 @@ public class UserMailboxesRoutes implements Routes {
 public void defineDeleteUserMailbox() {
 service.delete(SPECIFIC_MAILBOX, (request, response) -> {
 try {
-userMailboxesService.deleteMailbox(getUsernameParam(request), 
new MailboxName(request.params(MAILBOX_NAME)));
+userMailboxesService.deleteMailbox(getUsernameParam(request), 
new MailboxName(request.params(MAILBOX_NAME)), getOptions(request));
 return R

[james-project] branch 3.8.x updated: Add simple null-check in JPAMailboxMessage #JAMES-3915 (#1601)

2023-06-27 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch 3.8.x
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/3.8.x by this push:
 new 2e962ed2fe Add simple null-check in JPAMailboxMessage #JAMES-3915 
(#1601)
2e962ed2fe is described below

commit 2e962ed2fec6f2dd3149116a75ae223c23fbd51e
Author: Benoit TELLIER 
AuthorDate: Tue Jun 27 22:56:56 2023 +0200

Add simple null-check in JPAMailboxMessage #JAMES-3915 (#1601)

Co-authored-by: Wojtek 
---
 .../mailbox/jpa/mail/model/openjpa/JPAMailboxMessage.java |  7 +--
 .../mailbox/jpa/mail/model/openjpa/JPAMailboxMessageTest.java | 11 +++
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git 
a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/JPAMailboxMessage.java
 
b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/JPAMailboxMessage.java
index 2083b6a237..9ad9be12ad 100644
--- 
a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/JPAMailboxMessage.java
+++ 
b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/JPAMailboxMessage.java
@@ -48,7 +48,7 @@ import com.google.common.annotations.VisibleForTesting;
 @Table(name = "JAMES_MAIL")
 public class JPAMailboxMessage extends AbstractJPAMailboxMessage {
 
-private static final byte[] EMPTY_BODY = new byte[] {};
+private static final byte[] EMPTY_ARRAY = new byte[] {};
 
 /** The value for the body field. Lazy loaded */
 /** We use a max length to represent 1gb data. Thats prolly overkill, but 
who knows */
@@ -106,13 +106,16 @@ public class JPAMailboxMessage extends 
AbstractJPAMailboxMessage {
 @Override
 public InputStream getBodyContent() throws IOException {
 if (body == null) {
-return new ByteArrayInputStream(EMPTY_BODY);
+return new ByteArrayInputStream(EMPTY_ARRAY);
 }
 return new ByteArrayInputStream(body);
 }
 
 @Override
 public InputStream getHeaderContent() throws IOException {
+if (header == null) {
+return new ByteArrayInputStream(EMPTY_ARRAY);
+}
 return new ByteArrayInputStream(header);
 }
 
diff --git 
a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/model/openjpa/JPAMailboxMessageTest.java
 
b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/model/openjpa/JPAMailboxMessageTest.java
index be0f6c561c..31d59a411c 100644
--- 
a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/model/openjpa/JPAMailboxMessageTest.java
+++ 
b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/model/openjpa/JPAMailboxMessageTest.java
@@ -27,6 +27,7 @@ import org.junit.jupiter.api.Test;
 
 class JPAMailboxMessageTest {
 
+private static final byte[] EMPTY = new byte[] {};
 /**
  * Even though there should never be a null body, it does happen. See 
JAMES-2384
  */
@@ -42,4 +43,14 @@ class JPAMailboxMessageTest {
 
 }
 
+@Test
+void getAnyMessagePartThatIsNullShouldYieldEmptyArray() throws Exception {
+
+// Prepare the message
+JPAMailboxMessage message = new JPAMailboxMessage(null, null);
+
assertThat(IOUtils.toByteArray(message.getHeaderContent())).containsExactly(EMPTY);
+
assertThat(IOUtils.toByteArray(message.getBodyContent())).containsExactly(EMPTY);
+
assertThat(IOUtils.toByteArray(message.getFullContent())).containsExactly(EMPTY);
+}
+
 }


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



[james-project] branch master updated: JAMES-3680 Warn when plain is not allowed (#1610)

2023-06-27 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
 new 849b8e2d20 JAMES-3680 Warn when plain is not allowed (#1610)
849b8e2d20 is described below

commit 849b8e2d207e6496fcd7a6efccc18abd5fb8c9c2
Author: Benoit TELLIER 
AuthorDate: Tue Jun 27 11:01:10 2023 +0200

JAMES-3680 Warn when plain is not allowed (#1610)
---
 .../java/org/apache/james/imap/processor/AuthenticateProcessor.java   | 1 +
 .../src/main/java/org/apache/james/imap/processor/LoginProcessor.java | 4 
 2 files changed, 5 insertions(+)

diff --git 
a/protocols/imap/src/main/java/org/apache/james/imap/processor/AuthenticateProcessor.java
 
b/protocols/imap/src/main/java/org/apache/james/imap/processor/AuthenticateProcessor.java
index fde4363f8b..40de07069c 100644
--- 
a/protocols/imap/src/main/java/org/apache/james/imap/processor/AuthenticateProcessor.java
+++ 
b/protocols/imap/src/main/java/org/apache/james/imap/processor/AuthenticateProcessor.java
@@ -85,6 +85,7 @@ public class AuthenticateProcessor extends 
AbstractAuthProcessor 
implements CapabilityImplementingProcessor {
 private static final List LOGINDISABLED_CAPS = 
ImmutableList.of(Capability.of("LOGINDISABLED"));
+private static final Logger LOGGER = 
LoggerFactory.getLogger(LoginProcessor.class);
 
 @Inject
 public LoginProcessor(MailboxManager mailboxManager, StatusResponseFactory 
factory, MetricFactory metricFactory) {
@@ -50,6 +53,7 @@ public class LoginProcessor extends 
AbstractAuthProcessor implemen
 protected void processRequest(LoginRequest request, ImapSession session, 
Responder responder) {
 // check if the login is allowed with LOGIN command. See IMAP-304
 if (session.isPlainAuthDisallowed()) {
+LOGGER.warn("Login attempt over clear channel rejected");
 no(request, responder, HumanReadableText.DISABLED_LOGIN);
 } else {
 doAuth(noDelegation(request.getUserid(), request.getPassword()),


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



[james-project] branch master updated: [SITE] Guest post for fail2ban setup (#1599)

2023-06-26 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
 new d0d2e9f972 [SITE] Guest post for fail2ban setup (#1599)
d0d2e9f972 is described below

commit d0d2e9f97229bbabdcd9cf50c3417f9e4ff45313
Author: Benoit TELLIER 
AuthorDate: Tue Jun 27 07:16:10 2023 +0200

[SITE] Guest post for fail2ban setup (#1599)
---
 src/homepage/_posts/2023-06-20-fail2ban.markdown | 347 +++
 1 file changed, 347 insertions(+)

diff --git a/src/homepage/_posts/2023-06-20-fail2ban.markdown 
b/src/homepage/_posts/2023-06-20-fail2ban.markdown
new file mode 100644
index 00..90e63e1563
--- /dev/null
+++ b/src/homepage/_posts/2023-06-20-fail2ban.markdown
@@ -0,0 +1,347 @@
+---
+layout: post
+title:  "Guest post: James and fail2ban"
+date:   2023-05-17  01:16:30 +0200
+categories: james update
+---
+
+Credits: Paul Gunter
+
+[Original][Original] version.
+
+# Repel brute force attacks with Linux firewall (iptables) and fail2ban
+
+## Introduction
+
+Servers on the Internet are constantly under attack. Mail servers are also 
attacked to gain control of
+a server that can be used to send bulk spam emails. This often leads to these 
servers ending up on
+various black lists and can no longer be used as mail servers. A safe basic 
configuration of James is
+required at this point.
+
+Nevertheless, attacks can mean that the server can practically no longer be 
operated. These are often
+DoS or DDoS attacks (Denial-of-Service or Distributed Denial-of-Service), 
which smaller servers
+in particular are difficult to defend against. However, basic protection via 
the firewall is relatively
+easy to reach.
+
+But even after that, attacks can be seen, especially those that try to spy out 
access data. These
+attacks can be detected by monitoring the log files. So the attack patterns 
are known and can be
+repelled with fail2ban.
+
+All examples refer to a Linux operating system, Windows is not covered. The 
examples are shown
+using Ubuntu and can be transferred to other Linux variants. “iptables” is 
used as the firewall front
+end.
+
+## Setting
+
+The following assumes a small mail server on which only an SSH service can be 
accessed from
+outside in addition to Apache James. In the example, the SSH service uses the 
standard port 22,
+James uses the standard ports 25 (smtp), 110 (pop3) and/or 143 (imap).
+
+The examples refer to Apache James 3.8.0 (Spring App).
+
+The operating system is Ubuntu 22.04.
+
+The configuration should be carried out beforehand on a test system and not 
during operation. One
+thing to note about James is that changes to log4j2's configuration usually 
take effect immediately.
+
+## (D)DoS - Attacks
+
+An attempt is made to load the server with so many requests that it no longer 
works. In the case of
+DDos, this is carried out in parallel by a large number of servers, which also 
means a corresponding
+amount of effort. A firewall can at least be used to ward off simple attacks.
+
+Rules are defined for the open ports and ping, which minimize the number of 
accesses. It must be
+ensured that the number of accesses is not restricted to such an extent that 
regular accesses are also
+affected.
+
+A normal check per ping usually has one access per second, so that 60 accesses 
per minute and IP
+address are normal. 
+
+The firewall rule can be (increase hitcount by one access so that there is no
+crash during regular operation):
+
+```
+sudo iptables -A INPUT -p icmp -m recent --set --name DDOS-PING
+sudo iptables -A INPUT -p icmp -m recent --update --seconds 5 --hitcount 6 
--name DDOS-PING -j DROP
+```
+
+A permanent ping query with one server is possible, if the same server tries 
to work in parallel, it is
+over after a total of 5 attempts.
+
+Similarly, this can be set for other open ports:
+
+```
+sudo iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m recent --set 
--name DDOS-SSH
+sudo iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m recent 
--update --seconds 60 --hitcount 6 --name DDOS-SSH -j DROP
+sudo iptables -A INPUT -p tcp --dport 25 -m state --state NEW -m recent --set 
--name DDOS-SMTP
+sudo iptables -A INPUT -p tcp --dport 25 -m state --state NEW -m recent 
--update --seconds 60 --hitcount 4 --name DDOS-SMTP -j DROP
+sudo iptables -A INPUT -p tcp --dport 110 -m state --state NEW -m recent --set 
--name DDOS-POP
+sudo iptables -A INPUT -p tcp --dport 110 -m state --state NEW -m recent 
--update --seconds 60 --hitcount 4 --name DDOS-POP -j DROP
+sudo iptables -A INPUT -p tcp --dport 143 -m state --state NEW -m recent --set 
--name DDOS-IMAP
+sudo iptables -A INPUT -p tcp --dport 143 -m state --state NEW -m recent 
--update --seconds 60 --hitcount 4 --name DDOS-IMAP -j DROP
+```
+There are many examples on the Internet how a firewall can

[james-project] branch master updated: JAMES-3918 Force deletion of user mailboxes (#1608)

2023-06-26 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
 new c3150d0990 JAMES-3918 Force deletion of user mailboxes (#1608)
c3150d0990 is described below

commit c3150d09903a2acaa6c152c84552992708842f07
Author: Benoit TELLIER 
AuthorDate: Tue Jun 27 07:08:52 2023 +0200

JAMES-3918 Force deletion of user mailboxes (#1608)
---
 .../docs/modules/ROOT/pages/operate/webadmin.adoc  |  9 +++--
 .../james/webadmin/routes/UserMailboxesRoutes.java | 23 +++
 .../webadmin/service/UserMailboxesService.java | 37 ++
 .../webadmin/routes/UserMailboxesRoutesTest.java   | 44 --
 src/site/markdown/server/manage-webadmin.md| 11 +++---
 5 files changed, 87 insertions(+), 37 deletions(-)

diff --git 
a/server/apps/distributed-app/docs/modules/ROOT/pages/operate/webadmin.adoc 
b/server/apps/distributed-app/docs/modules/ROOT/pages/operate/webadmin.adoc
index 703169ee12..46c5d00439 100644
--- a/server/apps/distributed-app/docs/modules/ROOT/pages/operate/webadmin.adoc
+++ b/server/apps/distributed-app/docs/modules/ROOT/pages/operate/webadmin.adoc
@@ -1691,7 +1691,7 @@ Response codes:
 
 * 204: The mailbox now exists on the server
 * 400: Invalid mailbox name
-* 404: The user name does not exist
+* 404: The user name does not exist. Note that this check can be bypassed by 
specifying the `force` query parameter.
 
 To create nested mailboxes, for instance a work mailbox inside the INBOX
 mailbox, people should use the . separator. The sample query is:
@@ -1713,7 +1713,7 @@ Response codes:
 
 * 204: The mailbox now does not exist on the server
 * 400: Invalid mailbox name
-* 404: The user name does not exist
+* 404: The user name does not exist. Note that this check can be bypassed by 
specifying the `force` query parameter.
 
 === Testing existence of a mailbox
 
@@ -1747,7 +1747,8 @@ Resource name `usernameToBeUsed` should be an existing 
user
 Response codes:
 
 * 200: The mailboxes list was successfully retrieved
-* 404: The user name does not exist
+* 404: The user name does not exist, the mailbox does not exist. Note that 
this check can be bypassed by specifying the `force` query parameter.
+
 
 === Deleting user mailboxes
 
@@ -1760,7 +1761,7 @@ Resource name `usernameToBeUsed` should be an existing 
user
 Response codes:
 
 * 204: The user do not have mailboxes anymore
-* 404: The user name does not exist
+* 404: The user name does not exist. Note that this check can be bypassed by 
specifying the `force` query parameter.
 
 === Exporting user mailboxes
 
diff --git 
a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/UserMailboxesRoutes.java
 
b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/UserMailboxesRoutes.java
index 365c8e80d0..30c813fe1a 100644
--- 
a/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/UserMailboxesRoutes.java
+++ 
b/server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/UserMailboxesRoutes.java
@@ -73,6 +73,13 @@ public class UserMailboxesRoutes implements Routes {
 return Username.of(request.params(USER_NAME));
 }
 
+private static UserMailboxesService.Options getOptions(Request request) {
+if (request.queryParams().contains("force")) {
+return UserMailboxesService.Options.Force;
+}
+return UserMailboxesService.Options.Check;
+}
+
 public static final String MAILBOX_NAME = ":mailboxName";
 public static final String MAILBOXES = "mailboxes";
 private static final String USER_NAME = ":userName";
@@ -134,7 +141,7 @@ public class UserMailboxesRoutes implements Routes {
 service.get(USER_MAILBOXES_BASE, (request, response) -> {
 response.status(HttpStatus.OK_200);
 try {
-return 
userMailboxesService.listMailboxes(getUsernameParam(request));
+return 
userMailboxesService.listMailboxes(getUsernameParam(request), 
getOptions(request));
 } catch (IllegalStateException e) {
 LOGGER.info("Invalid get on user mailboxes", e);
 throw ErrorResponder.builder()
@@ -157,7 +164,7 @@ public class UserMailboxesRoutes implements Routes {
 public void defineDeleteUserMailbox() {
 service.delete(SPECIFIC_MAILBOX, (request, response) -> {
 try {
-userMailboxesService.deleteMailbox(getUsernameParam(request), 
new MailboxName(request.params(MAILBOX_NAME)));
+userMailboxesService.deleteMailbox(getUsernameParam(request), 
new MailboxName(request.params(MAILBOX_NAME)), getOptions(request));
 return R

<    1   2   3   4   5   6   7   8   9   10   >