[jira] [Created] (JAMES-2646) Aliases: listSources Cassandra version: DAO

2019-01-16 Thread Rene Cordier (JIRA)
Rene Cordier created JAMES-2646:
---

 Summary: Aliases: listSources Cassandra version: DAO
 Key: JAMES-2646
 URL: https://issues.apache.org/jira/browse/JAMES-2646
 Project: James Server
  Issue Type: New Feature
  Components: cassandra, RRT
Reporter: Rene Cordier


Implement a CassandraMappingsSourcesDAO in `server/data/data-cassandra` `rrt 
package`
We should be able to:
* add a mapping to source association
* remove a mapping to source association
* list sources associated to a mapping

You will represent the data as:
* Primary Key: (mappingType: text, mappingValue: text (mail address))
* Column: source: text mail address
* Create the interface for defining table names
* Register the new module in the RRT Cassandra module
* Implement your DAO and related -unit- test

Finally, you will plug your DAO in CassandraRecipientRewriteTable - only 
add+remove - migration is needed for safely delegating `listSources` to your 
DAO. Add a small test to demonstrate CassandraRecipientRewriteTable is updating 
your DAO.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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



[jira] [Updated] (JAMES-2645) CassandraRecipientRewriteTable: refactoring to be using a DAO

2019-01-16 Thread Rene Cordier (JIRA)


 [ 
https://issues.apache.org/jira/browse/JAMES-2645?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Rene Cordier updated JAMES-2645:

Component/s: cassandra

> CassandraRecipientRewriteTable: refactoring to be using a DAO
> -
>
> Key: JAMES-2645
> URL: https://issues.apache.org/jira/browse/JAMES-2645
> Project: James Server
>  Issue Type: New Feature
>  Components: cassandra
>Reporter: Rene Cordier
>Priority: Major
>
> Write a simple CassandraRecipientRewriteTableDAO with the current Cassandra 
> query logic currently defined in CassandraRecipientRewriteTable. (it is 
> mostly extraction)
> Add simple tests for your DAO.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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



[jira] [Closed] (JAMES-2641) Replace MailboxDispatcher & Delegating listener by the new event bus

2019-01-16 Thread Tellier Benoit (JIRA)


 [ 
https://issues.apache.org/jira/browse/JAMES-2641?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Tellier Benoit closed JAMES-2641.
-

> Replace MailboxDispatcher & Delegating listener by the new event bus
> 
>
> Key: JAMES-2641
> URL: https://issues.apache.org/jira/browse/JAMES-2641
> Project: James Server
>  Issue Type: Improvement
>Reporter: Trần Tiến Đức
>Priority: Major
> Fix For: 3.3.0
>
>
> You will make James use APIs defined in new EventBus instead than the 
> previous one.
> You will remove:
>  - `MailboxListenerSupport API`
>  - `MailboxEventDispatcher` class
>  - `DelegatingMailboxListener` & sub classes
> Rather than calling Mailbox Support, call the EventBus
> Note that:
>  - EventBus initialization should never be done in the MailboxManager (a 
> ready to use EventBus should be passed to it).
> This can be done in 2 steps:
>  - Keeping the MailboxManager as a proxy
>  - Then in a second PR directly calling the EventBus
> **edited**
> improvement: `MailboxEventDisplatcher` exposes some convenience methods for 
> easily creating events. We need, as part of `EventFactory` to propose 
> builders for Mailbox events.
> Note that as part of this effort, we need to get rid of the 
> MailboxEventDispatcher whose last responsibility is "not firing noop events". 
> We need to move the `isNoop()` method to the Event API in order to be able to 
> filter our noop event without having knowledge of the event details. 
> Filtering noop should then be a responsibility of the EventBus (and as a 
> temporary step of the DelegatingMailboxListener). In order to filter noop in 
> an agnostic way, we need to add a `isnoop()` method in the event bus.
> Once these 2 preliminary steps are done we can:
>  - Remove the `MailboxEventDispatcher` (event emition can then directly be 
> done on top of the delegatingListener/EventBus=
>  - Replace the DelegatingListener by the EventBus.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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



[jira] [Closed] (JAMES-2642) Alias integration tests

2019-01-16 Thread Tellier Benoit (JIRA)


 [ 
https://issues.apache.org/jira/browse/JAMES-2642?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Tellier Benoit closed JAMES-2642.
-

> Alias integration tests
> ---
>
> Key: JAMES-2642
> URL: https://issues.apache.org/jira/browse/JAMES-2642
> Project: James Server
>  Issue Type: New Feature
>  Components: integrationTests
>Reporter: Rene Cordier
>Priority: Major
> Fix For: 3.3.0
>
>
> In /server/mailet/integration-testing write integration tests for the alias 
> feature
> *Basic*
> {code:java}
> Given b...@domain.tld with a bob-al...@domain.tld alias
> When al...@domain.tld sends a mail to bob-al...@domain.tld
> Then b...@domain.tld receives it{code}
> *Forward compatibility*
> Forwards are handled for users with alias
> {code:java}
> Given b...@domain.tld with a bob-al...@domain.tld alias
> And b...@domain.tld is forwarding emails to ce...@domain.tld
> When al...@domain.tld sends a mail to bob-al...@domain.tld
> Then ced...@domain.tld receives it{code}
> I can forward an email to a user with an alias
> {code:java}
> Given b...@domain.tld with a bob-al...@domain.tld alias
> And al...@domain.tld is forwarding emails to bob-al...@domain.tld
> When ced...@domain.tld is sending an email to al...@domain.tld
> Then b...@domain.tld receives it{code}
> *Group compatibility*
> A user can register in a group via his alias
> {code:java}
> Given b...@domain.tld with a bob-al...@domain.tld alias
> And a group gr...@domain.tld with bob-al...@domain.tld as a member
> When al...@domain.tld is sending an email to gr...@domain.tld
> Then b...@domain.tld receives it{code}
> A group can have an alias
> {code:java}
> Given a group gr...@domain.tld with b...@domain.tld as a member
> And I create a group-al...@domain.tld for gr...@domain.tld
> When al...@domain.tld is sending an email to group-al...@domain.tld
> Then b...@domain.tld receives it{code}
> *Cascading aliases*
> {code:java}
> Given b...@domain.tld with a bob-ali...@domain.tld alias
> And bob-ali...@domain.tld with a bob-ali...@domain.tld alias
> When al...@domain.tld is sending an email to bob-ali...@domain.tld
> Then b...@domain.tld receives the mail{code}
>  
> *Corner cases*
> Several users can have the same alias.
> {code:java}
> Alice create al...@domain.tld
> Bob create al...@domain.tld
> When Cedric sends a mail to al...@domain.com
> Then Alice and Bob receives it{code}
> +Note+: we can not prevent bob and alice from having the same alias easily



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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



[jira] [Resolved] (JAMES-2642) Alias integration tests

2019-01-16 Thread Tellier Benoit (JIRA)


 [ 
https://issues.apache.org/jira/browse/JAMES-2642?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Tellier Benoit resolved JAMES-2642.
---
   Resolution: Fixed
Fix Version/s: 3.3.0

https://github.com/linagora/james-project/pull/2105 Contributed these tests

> Alias integration tests
> ---
>
> Key: JAMES-2642
> URL: https://issues.apache.org/jira/browse/JAMES-2642
> Project: James Server
>  Issue Type: New Feature
>  Components: integrationTests
>Reporter: Rene Cordier
>Priority: Major
> Fix For: 3.3.0
>
>
> In /server/mailet/integration-testing write integration tests for the alias 
> feature
> *Basic*
> {code:java}
> Given b...@domain.tld with a bob-al...@domain.tld alias
> When al...@domain.tld sends a mail to bob-al...@domain.tld
> Then b...@domain.tld receives it{code}
> *Forward compatibility*
> Forwards are handled for users with alias
> {code:java}
> Given b...@domain.tld with a bob-al...@domain.tld alias
> And b...@domain.tld is forwarding emails to ce...@domain.tld
> When al...@domain.tld sends a mail to bob-al...@domain.tld
> Then ced...@domain.tld receives it{code}
> I can forward an email to a user with an alias
> {code:java}
> Given b...@domain.tld with a bob-al...@domain.tld alias
> And al...@domain.tld is forwarding emails to bob-al...@domain.tld
> When ced...@domain.tld is sending an email to al...@domain.tld
> Then b...@domain.tld receives it{code}
> *Group compatibility*
> A user can register in a group via his alias
> {code:java}
> Given b...@domain.tld with a bob-al...@domain.tld alias
> And a group gr...@domain.tld with bob-al...@domain.tld as a member
> When al...@domain.tld is sending an email to gr...@domain.tld
> Then b...@domain.tld receives it{code}
> A group can have an alias
> {code:java}
> Given a group gr...@domain.tld with b...@domain.tld as a member
> And I create a group-al...@domain.tld for gr...@domain.tld
> When al...@domain.tld is sending an email to group-al...@domain.tld
> Then b...@domain.tld receives it{code}
> *Cascading aliases*
> {code:java}
> Given b...@domain.tld with a bob-ali...@domain.tld alias
> And bob-ali...@domain.tld with a bob-ali...@domain.tld alias
> When al...@domain.tld is sending an email to bob-ali...@domain.tld
> Then b...@domain.tld receives the mail{code}
>  
> *Corner cases*
> Several users can have the same alias.
> {code:java}
> Alice create al...@domain.tld
> Bob create al...@domain.tld
> When Cedric sends a mail to al...@domain.com
> Then Alice and Bob receives it{code}
> +Note+: we can not prevent bob and alice from having the same alias easily



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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



[jira] [Resolved] (JAMES-2641) Replace MailboxDispatcher & Delegating listener by the new event bus

2019-01-16 Thread Tellier Benoit (JIRA)


 [ 
https://issues.apache.org/jira/browse/JAMES-2641?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Tellier Benoit resolved JAMES-2641.
---
   Resolution: Fixed
Fix Version/s: 3.3.0

https://github.com/linagora/james-project/pull/2095 solved this

> Replace MailboxDispatcher & Delegating listener by the new event bus
> 
>
> Key: JAMES-2641
> URL: https://issues.apache.org/jira/browse/JAMES-2641
> Project: James Server
>  Issue Type: Improvement
>Reporter: Trần Tiến Đức
>Priority: Major
> Fix For: 3.3.0
>
>
> You will make James use APIs defined in new EventBus instead than the 
> previous one.
> You will remove:
>  - `MailboxListenerSupport API`
>  - `MailboxEventDispatcher` class
>  - `DelegatingMailboxListener` & sub classes
> Rather than calling Mailbox Support, call the EventBus
> Note that:
>  - EventBus initialization should never be done in the MailboxManager (a 
> ready to use EventBus should be passed to it).
> This can be done in 2 steps:
>  - Keeping the MailboxManager as a proxy
>  - Then in a second PR directly calling the EventBus
> **edited**
> improvement: `MailboxEventDisplatcher` exposes some convenience methods for 
> easily creating events. We need, as part of `EventFactory` to propose 
> builders for Mailbox events.
> Note that as part of this effort, we need to get rid of the 
> MailboxEventDispatcher whose last responsibility is "not firing noop events". 
> We need to move the `isNoop()` method to the Event API in order to be able to 
> filter our noop event without having knowledge of the event details. 
> Filtering noop should then be a responsibility of the EventBus (and as a 
> temporary step of the DelegatingMailboxListener). In order to filter noop in 
> an agnostic way, we need to add a `isnoop()` method in the event bus.
> Once these 2 preliminary steps are done we can:
>  - Remove the `MailboxEventDispatcher` (event emition can then directly be 
> done on top of the delegatingListener/EventBus=
>  - Replace the DelegatingListener by the EventBus.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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



[10/27] james-project git commit: JAMES-2641 DefaultImapProcessorFactory have many unused fields/methods

2019-01-16 Thread btellier
JAMES-2641 DefaultImapProcessorFactory have many unused fields/methods

Only 2 static methods are used


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

Branch: refs/heads/master
Commit: 9e34f173c6aca3f03c1e9e8aaa2fd46fb884c1e7
Parents: d35e8a6
Author: Benoit Tellier 
Authored: Thu Jan 10 15:27:40 2019 +0700
Committer: Benoit Tellier 
Committed: Thu Jan 17 10:23:41 2019 +0700

--
 .../main/DefaultImapProcessorFactory.java   | 69 ++--
 1 file changed, 4 insertions(+), 65 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/9e34f173/protocols/imap/src/main/java/org/apache/james/imap/processor/main/DefaultImapProcessorFactory.java
--
diff --git 
a/protocols/imap/src/main/java/org/apache/james/imap/processor/main/DefaultImapProcessorFactory.java
 
b/protocols/imap/src/main/java/org/apache/james/imap/processor/main/DefaultImapProcessorFactory.java
index 3af2b8e..ff6d78f 100644
--- 
a/protocols/imap/src/main/java/org/apache/james/imap/processor/main/DefaultImapProcessorFactory.java
+++ 
b/protocols/imap/src/main/java/org/apache/james/imap/processor/main/DefaultImapProcessorFactory.java
@@ -32,9 +32,6 @@ import org.apache.james.mailbox.quota.QuotaManager;
 import org.apache.james.mailbox.quota.QuotaRootResolver;
 import org.apache.james.metrics.api.MetricFactory;
 
-/**
- * 
- */
 public class DefaultImapProcessorFactory {
 
 public static ImapProcessor createDefaultProcessor(MailboxManager 
mailboxManager, SubscriptionManager subscriptionManager, QuotaManager 
quotaManager, QuotaRootResolver quotaRootResolver,
@@ -44,72 +41,14 @@ public class DefaultImapProcessorFactory {
 
 public static ImapProcessor createXListSupportingProcessor(MailboxManager 
mailboxManager, SubscriptionManager subscriptionManager,
 MailboxTyper mailboxTyper, QuotaManager quotaManager, 
QuotaRootResolver quotaRootResolver, MetricFactory metricFactory) {
+
 final StatusResponseFactory statusResponseFactory = new 
UnpooledStatusResponseFactory();
 final UnknownRequestProcessor unknownRequestImapProcessor = new 
UnknownRequestProcessor(statusResponseFactory);
-final ImapProcessor imap4rev1Chain = 
DefaultProcessorChain.createDefaultChain(unknownRequestImapProcessor, 
mailboxManager, subscriptionManager, statusResponseFactory, mailboxTyper, 
quotaManager, quotaRootResolver, metricFactory);
-return new ImapResponseMessageProcessor(imap4rev1Chain);
-}
-
-private MailboxManager mailboxManager;
-private SubscriptionManager subscriptionManager;
-private MailboxTyper mailboxTyper;
-private QuotaManager quotaManager;
-private QuotaRootResolver quotaRootResolver;
-private MetricFactory metricFactory;
-
-public final void setMailboxManager(MailboxManager mailboxManager) {
-this.mailboxManager = mailboxManager;
-}
-
-public final void setSubscriptionManager(SubscriptionManager 
subscriptionManager) {
-this.subscriptionManager = subscriptionManager;
-}
-
-public void setMailboxTyper(MailboxTyper mailboxTyper) {
-this.mailboxTyper = mailboxTyper;
-}
-
-public void setQuotaManager(QuotaManager quotaManager) {
-this.quotaManager = quotaManager;
-}
-
-public void setQuotaRootResolver(QuotaRootResolver quotaRootResolver) {
-this.quotaRootResolver = quotaRootResolver;
-}
 
-public final MailboxManager getMailboxManager() {
-return mailboxManager;
-}
-
-public final SubscriptionManager getSubscriptionManager() {
-return subscriptionManager;
-}
-
-public MailboxTyper getMailboxTyper() {
-return mailboxTyper;
-}
-
-public QuotaManager getQuotaManager() {
-return quotaManager;
-}
+final ImapProcessor imap4rev1Chain = 
DefaultProcessorChain.createDefaultChain(unknownRequestImapProcessor,
+mailboxManager, subscriptionManager, statusResponseFactory, 
mailboxTyper, quotaManager, quotaRootResolver, metricFactory);
 
-public QuotaRootResolver getQuotaRootResolver() {
-return quotaRootResolver;
-}
-
-public MetricFactory getMetricFactory() {
-return metricFactory;
-}
-
-public void setMetricFactory(MetricFactory metricFactory) {
-this.metricFactory = metricFactory;
-}
-
-/**
- * Create the {@link ImapProcessor}
- */
-public ImapProcessor buildImapProcessor() {
-return createDefaultProcessor(mailboxManager, subscriptionManager, 
quotaManager, quotaRootResolver, metricFactory);
+   

[07/27] james-project git commit: JAMES-2641 EventBus caller should block to await dispatching to be done

2019-01-16 Thread btellier
JAMES-2641 EventBus caller should block to await dispatching to be done


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

Branch: refs/heads/master
Commit: 24fe28f024c2989cd7ce5584359a5b93c537872b
Parents: 4c14a75
Author: Benoit Tellier 
Authored: Thu Jan 10 16:29:53 2019 +0700
Committer: Benoit Tellier 
Committed: Thu Jan 17 10:23:41 2019 +0700

--
 .../QuotaThresholdListenersTestSystem.java  |  2 +-
 .../mailbox/store/StoreMailboxManager.java  | 12 ++-
 .../mailbox/store/StoreMessageIdManager.java| 36 +---
 .../mailbox/store/StoreMessageManager.java  | 93 +++-
 .../james/mailbox/store/StoreRightManager.java  |  6 +-
 .../quota/ListeningCurrentQuotaUpdater.java |  6 +-
 6 files changed, 91 insertions(+), 64 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/24fe28f0/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdListenersTestSystem.java
--
diff --git 
a/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdListenersTestSystem.java
 
b/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdListenersTestSystem.java
index c399025..ae4e936 100644
--- 
a/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdListenersTestSystem.java
+++ 
b/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdListenersTestSystem.java
@@ -53,6 +53,6 @@ class QuotaThresholdListenersTestSystem {
 }
 
 void event(Event event) {
-eventBus.dispatch(event, NO_KEYS);
+eventBus.dispatch(event, NO_KEYS).block();
 }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/24fe28f0/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
--
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
index df08dee..7e46527 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
@@ -348,7 +348,8 @@ public class StoreMailboxManager implements MailboxManager {
 .mailboxSession(mailboxSession)
 .mailbox(m)
 .build(),
-new 
MailboxIdRegistrationKey(m.getMailboxId()));
+new MailboxIdRegistrationKey(m.getMailboxId()))
+.block();
 } catch (MailboxExistsException e) {
 LOGGER.info("{} mailbox was created concurrently", 
m.generateAssociatedPath());
 }
@@ -400,7 +401,8 @@ public class StoreMailboxManager implements MailboxManager {
 .quotaCount(QuotaCount.count(messageCount))
 .quotaSize(QuotaSize.size(totalSize))
 .build(),
-new MailboxIdRegistrationKey(mailbox.getMailboxId()));
+new MailboxIdRegistrationKey(mailbox.getMailboxId()))
+.block();
 return m;
 });
 
@@ -446,7 +448,8 @@ public class StoreMailboxManager implements MailboxManager {
 .oldPath(from)
 .newPath(to)
 .build(),
-new MailboxIdRegistrationKey(mailbox.getMailboxId()));
+new MailboxIdRegistrationKey(mailbox.getMailboxId()))
+.block();
 
 // rename submailboxes
 MailboxPath children = new MailboxPath(from.getNamespace(), 
from.getUser(), from.getName() + getDelimiter() + "%");
@@ -465,7 +468,8 @@ public class StoreMailboxManager implements MailboxManager {
 .oldPath(fromPath)
 .newPath(sub.generateAssociatedPath())
 .build(),
-new MailboxIdRegistrationKey(sub.getMailboxId()));
+new MailboxIdRegistrationKey(sub.getMailboxId()))
+.block();
 
 LOGGER.debug("Rename mailbox sub-mailbox {} to {}", 
subOriginalName, subNewName);
 }


[22/27] james-project git commit: JAMES-2641 Add a missing import after rebase

2019-01-16 Thread btellier
JAMES-2641 Add a missing import after rebase


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

Branch: refs/heads/master
Commit: 9fd0b6a4b37d09e86183ee2a4babe607fb96579c
Parents: 5a1d9d7
Author: Benoit Tellier 
Authored: Thu Jan 17 10:25:04 2019 +0700
Committer: Benoit Tellier 
Committed: Thu Jan 17 13:49:09 2019 +0700

--
 .../java/org/apache/james/mailbox/events/ErrorHandlingContract.java | 1 +
 1 file changed, 1 insertion(+)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/9fd0b6a4/mailbox/api/src/test/java/org/apache/james/mailbox/events/ErrorHandlingContract.java
--
diff --git 
a/mailbox/api/src/test/java/org/apache/james/mailbox/events/ErrorHandlingContract.java
 
b/mailbox/api/src/test/java/org/apache/james/mailbox/events/ErrorHandlingContract.java
index 0b5055b..f4c0768 100644
--- 
a/mailbox/api/src/test/java/org/apache/james/mailbox/events/ErrorHandlingContract.java
+++ 
b/mailbox/api/src/test/java/org/apache/james/mailbox/events/ErrorHandlingContract.java
@@ -29,6 +29,7 @@ import static org.mockito.Mockito.spy;
 import java.time.Instant;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.james.mailbox.Event;
 import org.apache.james.mailbox.MailboxListener;


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



[15/27] james-project git commit: JAMES-2641 MailboxManager should no more implement MailboxListener support

2019-01-16 Thread btellier
JAMES-2641 MailboxManager should no more implement MailboxListener support

It should rather expose proxy method for the event bus.

Note that these proxy method can be temporarily implemented on top of the 
Delegating Listener


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

Branch: refs/heads/master
Commit: c82c13844e7ee19ee06a8d8a57cd8c70ed437e6a
Parents: 7e0fdc6
Author: Benoit Tellier 
Authored: Thu Jan 10 10:53:15 2019 +0700
Committer: Benoit Tellier 
Committed: Thu Jan 17 10:23:41 2019 +0700

--
 .../apache/james/mailbox/MailboxManager.java|  10 +-
 .../james/mailbox/MailboxManagerStressTest.java |  17 ++-
 .../james/mailbox/MailboxManagerTest.java   |  20 +--
 .../CassandraMessageIdManagerTestSystem.java|   2 +-
 ...ticSearchQuotaSearchTestSystemExtension.java |   4 +-
 .../mailbox/store/StoreMailboxManager.java  |  62 +---
 .../james/imap/processor/IdleProcessor.java | 144 ---
 .../processor/base/SelectedMailboxImpl.java |  30 ++--
 .../processor/base/SelectedMailboxImplTest.java |   4 +-
 .../org/apache/james/utils/JmapGuiceProbe.java  |   4 +-
 .../event/PropagateLookupRightListenerTest.java |   2 +-
 .../ElasticSearchQuotaSearchExtension.java  |   4 +-
 12 files changed, 146 insertions(+), 157 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/c82c1384/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
--
diff --git 
a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java 
b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
index 1aedc86..be6c107 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
@@ -23,6 +23,8 @@ import java.util.EnumSet;
 import java.util.List;
 import java.util.Optional;
 
+import org.apache.james.mailbox.events.Group;
+import org.apache.james.mailbox.events.Registration;
 import org.apache.james.mailbox.exception.BadCredentialsException;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.MailboxExistsException;
@@ -68,7 +70,7 @@ import org.apache.james.mailbox.model.search.MailboxQuery;
  * 
  */
 
-public interface MailboxManager extends RequestAware, MailboxListenerSupport, 
RightManager, MailboxAnnotationManager {
+public interface MailboxManager extends RequestAware, RightManager, 
MailboxAnnotationManager {
 
 int MAX_MAILBOX_NAME_LENGTH = 200;
 
@@ -344,4 +346,10 @@ public interface MailboxManager extends RequestAware, 
MailboxListenerSupport, Ri
 List list(MailboxSession session) throws MailboxException;
 
 boolean hasChildren(MailboxPath mailboxPath, MailboxSession session) 
throws MailboxException;
+
+Registration register(MailboxListener listener, MailboxId registrationKey);
+
+Registration register(MailboxListener listener, Group group);
+
+Registration register(MailboxListener.GroupMailboxListener 
groupMailboxListener);
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/c82c1384/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressTest.java
--
diff --git 
a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressTest.java
 
b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressTest.java
index 41819a9..ce1f83c 100644
--- 
a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressTest.java
+++ 
b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressTest.java
@@ -22,7 +22,6 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import java.nio.charset.StandardCharsets;
 import java.util.Collection;
-import java.util.Optional;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentLinkedDeque;
 import java.util.concurrent.CountDownLatch;
@@ -59,15 +58,15 @@ public abstract class MailboxManagerStressTest {
 public void testStressTest() throws InterruptedException, MailboxException 
{
 ThreadFactory threadFactory = 
NamedThreadFactory.withClassName(getClass());
 
-final CountDownLatch latch = new CountDownLatch(APPEND_OPERATIONS);
-final ExecutorService pool = 
Executors.newFixedThreadPool(APPEND_OPERATIONS / 20, threadFactory);
-final Collection uList = new ConcurrentLinkedDeque<>();
-final String username = "username";
+CountDownLatch latch = new 

[24/27] james-project git commit: MAILBOX-377 remove unused method in EventBus ErrorHandling contract

2019-01-16 Thread btellier
MAILBOX-377 remove unused method in EventBus ErrorHandling contract


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

Branch: refs/heads/master
Commit: 7cc4a1989895572be30cad7c8b1c5f3399d59258
Parents: 8d66bb1
Author: Benoit Tellier 
Authored: Tue Jan 15 10:38:03 2019 +0700
Committer: Benoit Tellier 
Committed: Thu Jan 17 13:49:09 2019 +0700

--
 .../james/mailbox/events/ErrorHandlingContract.java | 12 +---
 1 file changed, 1 insertion(+), 11 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/7cc4a198/mailbox/api/src/test/java/org/apache/james/mailbox/events/ErrorHandlingContract.java
--
diff --git 
a/mailbox/api/src/test/java/org/apache/james/mailbox/events/ErrorHandlingContract.java
 
b/mailbox/api/src/test/java/org/apache/james/mailbox/events/ErrorHandlingContract.java
index 39d7729..0b5055b 100644
--- 
a/mailbox/api/src/test/java/org/apache/james/mailbox/events/ErrorHandlingContract.java
+++ 
b/mailbox/api/src/test/java/org/apache/james/mailbox/events/ErrorHandlingContract.java
@@ -29,7 +29,6 @@ import static org.mockito.Mockito.spy;
 import java.time.Instant;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.concurrent.TimeUnit;
 
 import org.apache.james.mailbox.Event;
 import org.apache.james.mailbox.MailboxListener;
@@ -37,13 +36,10 @@ import org.apache.james.mailbox.util.EventCollector;
 import org.assertj.core.api.SoftAssertions;
 import org.junit.jupiter.api.Test;
 
-import com.google.common.base.Stopwatch;
-
 interface ErrorHandlingContract extends EventBusContract {
 
 class ThrowingListener implements MailboxListener {
-
-private List timeElapsed;
+private final List timeElapsed;
 
 private ThrowingListener() {
 timeElapsed = new ArrayList<>();
@@ -64,12 +60,6 @@ interface ErrorHandlingContract extends EventBusContract {
 return new ThrowingListener();
 }
 
-default long recordTimeRun(Runnable operation) {
-Stopwatch stopwatch = Stopwatch.createStarted();
-operation.run();
-return stopwatch.elapsed(TimeUnit.MILLISECONDS);
-}
-
 @Test
 default void listenerShouldReceiveWhenFailsLessThanMaxRetries() {
 EventCollector eventCollector = eventCollector();


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



[21/27] james-project git commit: JAMES-2641 DefaultEventBus should not bind specific listeners

2019-01-16 Thread btellier
JAMES-2641 DefaultEventBus should not bind specific listeners


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

Branch: refs/heads/master
Commit: 897a206ab68a0c7e35c84c76c465d822a70c3a6e
Parents: 7cc4a19
Author: Benoit Tellier 
Authored: Tue Jan 15 10:46:38 2019 +0700
Committer: Benoit Tellier 
Committed: Thu Jan 17 13:49:09 2019 +0700

--
 .../james/modules/mailbox/DefaultEventModule.java   | 16 +---
 1 file changed, 5 insertions(+), 11 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/897a206a/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/DefaultEventModule.java
--
diff --git 
a/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/DefaultEventModule.java
 
b/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/DefaultEventModule.java
index 79d2dab..83056d1 100644
--- 
a/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/DefaultEventModule.java
+++ 
b/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/DefaultEventModule.java
@@ -30,8 +30,6 @@ import org.apache.james.mailbox.events.EventBus;
 import org.apache.james.mailbox.events.InVMEventBus;
 import org.apache.james.mailbox.events.delivery.EventDelivery;
 import org.apache.james.mailbox.events.delivery.InVmEventDelivery;
-import org.apache.james.mailbox.store.event.MailboxAnnotationListener;
-import org.apache.james.mailbox.store.quota.ListeningCurrentQuotaUpdater;
 import org.apache.james.server.core.configuration.ConfigurationProvider;
 import org.apache.james.utils.ConfigurationPerformer;
 
@@ -44,22 +42,18 @@ import com.google.inject.multibindings.Multibinder;
 public class DefaultEventModule extends AbstractModule {
 @Override
 protected void configure() {
-
 Multibinder.newSetBinder(binder(), 
ConfigurationPerformer.class).addBinding().to(ListenerRegistrationPerformer.class);
 
-bind(ListeningCurrentQuotaUpdater.class).in(Scopes.SINGLETON);
-bind(MailboxAnnotationListener.class).in(Scopes.SINGLETON);
-
 bind(MailboxListenerFactory.class).in(Scopes.SINGLETON);
 bind(MailboxListenersLoaderImpl.class).in(Scopes.SINGLETON);
-
bind(MailboxListenersLoader.class).to(MailboxListenersLoaderImpl.class);
-Multibinder.newSetBinder(binder(), 
MailboxListener.GroupMailboxListener.class);
-
 bind(InVmEventDelivery.class).in(Scopes.SINGLETON);
-bind(EventDelivery.class).to(InVmEventDelivery.class);
-
 bind(InVMEventBus.class).in(Scopes.SINGLETON);
+
+
bind(MailboxListenersLoader.class).to(MailboxListenersLoaderImpl.class);
+bind(EventDelivery.class).to(InVmEventDelivery.class);
 bind(EventBus.class).to(InVMEventBus.class);
+
+Multibinder.newSetBinder(binder(), 
MailboxListener.GroupMailboxListener.class);
 }
 
 @Singleton


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



[27/27] james-project git commit: JAMES-2642 Refactor and cleanup code for alias, group and forward integration tests

2019-01-16 Thread btellier
JAMES-2642 Refactor and cleanup code for alias, group and forward integration 
tests


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

Branch: refs/heads/master
Commit: 21cde6d28b4b81dc9b01ccb45e2579ad4bb30e7e
Parents: 1819ae1
Author: Rene Cordier 
Authored: Wed Jan 16 16:27:46 2019 +0700
Committer: Benoit Tellier 
Committed: Thu Jan 17 13:49:10 2019 +0700

--
 .../james/cli/probe/impl/JmxDataProbe.java  | 66 --
 .../org/apache/james/utils/DataProbeImpl.java   | 36 --
 .../java/org/apache/james/probe/DataProbe.java  | 12 
 .../RecipientRewriteTableManagementMBean.java   | 72 
 .../lib/RecipientRewriteTableManagement.java| 36 --
 .../RecipientRewriteTableIntegrationTest.java   | 18 -
 .../transport/mailets/AliasMappingTest.java | 46 +
 .../transport/mailets/GroupMappingTest.java |  5 +-
 .../WebAdminServerIntegrationTest.java  | 43 
 9 files changed, 82 insertions(+), 252 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/21cde6d2/server/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxDataProbe.java
--
diff --git 
a/server/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxDataProbe.java
 
b/server/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxDataProbe.java
index cb50af9..6006916 100644
--- 
a/server/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxDataProbe.java
+++ 
b/server/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxDataProbe.java
@@ -237,70 +237,4 @@ public class JmxDataProbe implements DataProbe, JmxProbe {
 virtualUserTableProxy.addDomainMapping(aliasDomain, 
deliveryDomain);
 }
 }
-
-@Override
-public void addForwardMapping(String user, String domain, String address) 
throws Exception {
-try (Closeable closeable =
-MDCBuilder.create()
-.addContext(MDCBuilder.PROTOCOL, JMX)
-.addContext(MDCBuilder.ACTION, "addForwardMapping")
-.build()) {
-   virtualUserTableProxy.addForwardMapping(user, domain, address);
-}
-}
-
-@Override
-public void removeForwardMapping(String user, String domain, String 
address) throws Exception {
-try (Closeable closeable =
-MDCBuilder.create()
-.addContext(MDCBuilder.PROTOCOL, JMX)
-.addContext(MDCBuilder.ACTION, "removeForwardMapping")
-.build()) {
-   virtualUserTableProxy.removeForwardMapping(user, domain, address);
-}
-}
-
-@Override
-public void addGroupMapping(String toUser, String toDomain, String 
fromAddress) throws Exception {
-try (Closeable closeable =
- MDCBuilder.create()
- .addContext(MDCBuilder.PROTOCOL, JMX)
- .addContext(MDCBuilder.ACTION, "removeForwardMapping")
- .build()) {
-virtualUserTableProxy.addGroupMapping(toUser, toDomain, 
fromAddress);
-}
-}
-
-@Override
-public void removeGroupMapping(String toUser, String toDomain, String 
fromAddress) throws Exception {
-try (Closeable closeable =
- MDCBuilder.create()
- .addContext(MDCBuilder.PROTOCOL, JMX)
- .addContext(MDCBuilder.ACTION, "removeForwardMapping")
- .build()) {
-virtualUserTableProxy.removeGroupMapping(toUser, toDomain, 
fromAddress);
-}
-}
-
-@Override
-public void addAliasMapping(String fromAlias, String fromDomain, String 
toAddress) throws Exception {
-try (Closeable closeable =
- MDCBuilder.create()
- .addContext(MDCBuilder.PROTOCOL, JMX)
- .addContext(MDCBuilder.ACTION, "addAliasMapping")
- .build()) {
-virtualUserTableProxy.addAliasMapping(fromAlias, fromDomain, 
toAddress);
-}
-}
-
-@Override
-public void removeAliasMapping(String fromAlias, String fromDomain, String 
toAddress) throws Exception {
-try (Closeable closeable =
- MDCBuilder.create()
- .addContext(MDCBuilder.PROTOCOL, JMX)
- .addContext(MDCBuilder.ACTION, "removeAliasMapping")
- .build()) {
-virtualUserTableProxy.removeAliasMapping(fromAlias, fromDomain, 
toAddress);
-}
-}
 }
\ 

[05/27] james-project git commit: JAMES-2641 IMAP components should use the EventBus directly

2019-01-16 Thread btellier
JAMES-2641 IMAP components should use the EventBus directly

This enables the MailboxManager to no more be an EventBus proxy


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

Branch: refs/heads/master
Commit: f398e3fa82285aa1949e9368017d94981d3d7804
Parents: 7a37651
Author: Benoit Tellier 
Authored: Thu Jan 10 15:46:11 2019 +0700
Committer: Benoit Tellier 
Committed: Thu Jan 17 10:23:41 2019 +0700

--
 .../apache/james/mailbox/MailboxManager.java|  3 ---
 .../mailbox/store/StoreMailboxManager.java  |  7 --
 .../cassandra/host/CassandraHostSystem.java |  2 +-
 .../host/ElasticSearchHostSystem.java   |  1 +
 .../inmemory/host/InMemoryHostSystem.java   |  2 +-
 .../mpt/imapmailbox/jpa/host/JPAHostSystem.java |  3 ++-
 .../host/LuceneSearchHostSystem.java|  1 +
 .../maildir/host/MaildirHostSystem.java |  3 ++-
 .../processor/AbstractSelectionProcessor.java   |  8 ---
 .../imap/processor/DefaultProcessorChain.java   | 20 ++--
 .../james/imap/processor/ExamineProcessor.java  |  7 +++---
 .../james/imap/processor/IdleProcessor.java |  9 ---
 .../james/imap/processor/SelectProcessor.java   |  7 +++---
 .../processor/base/SelectedMailboxImpl.java |  6 +++--
 .../main/DefaultImapProcessorFactory.java   | 18 +++---
 .../base/MailboxEventAnalyserTest.java  |  6 -
 .../processor/base/SelectedMailboxImplTest.java | 25 +---
 .../modules/protocols/IMAPServerModule.java |  7 +++---
 .../META-INF/spring/imapserver-context.xml  | 11 +
 19 files changed, 85 insertions(+), 61 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/f398e3fa/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
--
diff --git 
a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java 
b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
index e2d7cda..3af341c 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
@@ -23,7 +23,6 @@ import java.util.EnumSet;
 import java.util.List;
 import java.util.Optional;
 
-import org.apache.james.mailbox.events.Registration;
 import org.apache.james.mailbox.exception.BadCredentialsException;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.MailboxExistsException;
@@ -345,6 +344,4 @@ public interface MailboxManager extends RequestAware, 
RightManager, MailboxAnnot
 List list(MailboxSession session) throws MailboxException;
 
 boolean hasChildren(MailboxPath mailboxPath, MailboxSession session) 
throws MailboxException;
-
-Registration register(MailboxListener listener, MailboxId registrationKey);
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/f398e3fa/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
--
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
index fdf2ffb..df08dee 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
@@ -32,7 +32,6 @@ import javax.inject.Inject;
 import org.apache.james.core.quota.QuotaCount;
 import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.MailboxAnnotationManager;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxPathLocker;
 import org.apache.james.mailbox.MailboxPathLocker.LockAwareExecution;
@@ -41,7 +40,6 @@ import org.apache.james.mailbox.MessageManager;
 import org.apache.james.mailbox.StandardMailboxMetaDataComparator;
 import org.apache.james.mailbox.events.EventBus;
 import org.apache.james.mailbox.events.MailboxIdRegistrationKey;
-import org.apache.james.mailbox.events.Registration;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.MailboxExistsException;
 import org.apache.james.mailbox.exception.MailboxNotFoundException;
@@ -722,9 +720,4 @@ public class StoreMailboxManager implements MailboxManager {
 Mailbox mailbox = mapper.findMailboxByPath(mailboxPath);
 return mapper.hasChildren(mailbox, 

[14/27] james-project git commit: JAMES-2641 SetMessagesMethodTest should be using EventCollector

2019-01-16 Thread btellier
JAMES-2641 SetMessagesMethodTest should be using EventCollector

Rather than implementing its own


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

Branch: refs/heads/master
Commit: 7e0fdc6a6822098b04312e6e8190370b6b1ce6b7
Parents: 0a3b38a
Author: Benoit Tellier 
Authored: Thu Jan 10 10:50:06 2019 +0700
Committer: Benoit Tellier 
Committed: Thu Jan 17 10:23:41 2019 +0700

--
 .../jmap-integration-testing-common/pom.xml   |  6 ++
 .../integration/SetMessagesMethodTest.java| 18 --
 .../memory-jmap-integration-testing/pom.xml   |  6 ++
 .../rabbitmq-jmap-integration-testing/pom.xml |  6 ++
 4 files changed, 22 insertions(+), 14 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/7e0fdc6a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml
--
diff --git 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml
 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml
index d414034..8c52940 100644
--- 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml
+++ 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml
@@ -35,6 +35,12 @@
 
 
 ${james.groupId}
+apache-james-mailbox-api
+test-jar
+test
+
+
+${james.groupId}
 apache-james-mailbox-spamassassin
 test
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/7e0fdc6a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
--
diff --git 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
index 0dfd667..c8028bf 100644
--- 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
+++ 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
@@ -96,6 +96,7 @@ import org.apache.james.mailbox.model.SerializableQuotaValue;
 import org.apache.james.mailbox.probe.ACLProbe;
 import org.apache.james.mailbox.probe.MailboxProbe;
 import org.apache.james.mailbox.probe.QuotaProbe;
+import org.apache.james.mailbox.util.EventCollector;
 import org.apache.james.modules.ACLProbeImpl;
 import org.apache.james.modules.MailboxProbeImpl;
 import org.apache.james.modules.QuotaProbesImpl;
@@ -123,7 +124,6 @@ import org.junit.experimental.categories.Category;
 
 import com.google.common.base.Strings;
 import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
 import com.google.common.io.ByteStreams;
 
 import io.restassured.RestAssured;
@@ -2307,18 +2307,8 @@ public abstract class SetMessagesMethodTest {
 "  ]" +
 "]";
 
-List events = Lists.newArrayList();
-jmapServer.getProbe(JmapGuiceProbe.class).addMailboxListener(new 
MailboxListener() {
-@Override
-public ListenerType getType() {
-return ListenerType.ONCE;
-}
-
-@Override
-public void event(Event event) {
-events.add(event);
-}
-});
+EventCollector eventCollector = new EventCollector();
+
jmapServer.getProbe(JmapGuiceProbe.class).addMailboxListener(eventCollector);
 
 String messageId = with()
 .header("Authorization", accessToken.serialize())
@@ -2332,7 +2322,7 @@ public abstract class SetMessagesMethodTest {
 
 
 
-calmlyAwait.atMost(5, TimeUnit.SECONDS).until(() -> events.stream()
+calmlyAwait.atMost(5, TimeUnit.SECONDS).until(() -> 
eventCollector.getEvents().stream()
 .anyMatch(event -> isAddedToOutboxEvent(messageId, event, 
outboxId)));
 }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/7e0fdc6a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml
--
diff --git 

[17/27] james-project git commit: JAMES-2641 Remove now useless ListenerType

2019-01-16 Thread btellier
JAMES-2641 Remove now useless ListenerType


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

Branch: refs/heads/master
Commit: f063b4862d78436fb0473ee72c17c4a443e946c1
Parents: 90f18c4
Author: Benoit Tellier 
Authored: Thu Jan 10 14:58:06 2019 +0700
Committer: Benoit Tellier 
Committed: Thu Jan 17 10:23:41 2019 +0700

--
 .../org/apache/james/mailbox/MailboxListener.java|  8 
 .../james/mailbox/MailboxManagerStressTest.java  | 15 ---
 .../james/mailbox/events/ErrorHandlingContract.java  |  5 -
 .../james/mailbox/events/EventBusTestFixture.java|  5 -
 .../apache/james/mailbox/util/EventCollector.java| 15 ---
 .../caching/CacheInvalidatingMailboxListener.java|  4 
 .../cassandra/MailboxOperationLoggingListener.java   |  5 -
 .../quota/CassandraCurrentQuotaManager.java  |  6 --
 .../ElasticSearchListeningMessageSearchIndex.java|  5 -
 .../mailbox/jpa/quota/JpaCurrentQuotaManager.java|  6 --
 .../lucene/search/LuceneMessageSearchIndex.java  |  5 -
 .../inmemory/quota/InMemoryCurrentQuotaManager.java  |  6 --
 .../listeners/QuotaThresholdCrossingListener.java|  5 -
 .../events/ElasticSearchQuotaMailboxListener.java|  5 -
 .../mailbox/spamassassin/SpamAssassinListener.java   |  5 -
 .../store/event/MailboxAnnotationListener.java   |  5 -
 .../store/quota/ListeningCurrentQuotaUpdater.java|  5 -
 .../store/quota/StoreCurrentQuotaManager.java|  3 ---
 .../mailbox/store/search/LazyMessageSearchIndex.java |  5 -
 .../apache/james/imap/processor/IdleProcessor.java   |  5 -
 .../imap/processor/base/SelectedMailboxImpl.java |  5 -
 .../james/modules/mailbox/NoopMailboxListener.java   |  5 -
 .../jmap/event/PropagateLookupRightListener.java |  5 -
 .../jmap/event/PropagateLookupRightListenerTest.java |  5 -
 24 files changed, 4 insertions(+), 139 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/f063b486/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
--
diff --git 
a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java 
b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
index 253347c..fd79dd9 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
@@ -53,19 +53,11 @@ public interface MailboxListener {
 Group getGroup();
 }
 
-enum ListenerType {
-ONCE,
-EACH_NODE,
-MAILBOX
-}
-
 enum ExecutionMode {
 SYNCHRONOUS,
 ASYNCHRONOUS
 }
 
-ListenerType getType();
-
 default ExecutionMode getExecutionMode() {
 return ExecutionMode.SYNCHRONOUS;
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/f063b486/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressTest.java
--
diff --git 
a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressTest.java
 
b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressTest.java
index ce1f83c..d769815 100644
--- 
a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressTest.java
+++ 
b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressTest.java
@@ -66,18 +66,11 @@ public abstract class MailboxManagerStressTest {
 mailboxManager.startProcessingRequest(session);
 MailboxPath path = MailboxPath.forUser(username, "INBOX");
 MailboxId mailboxId = mailboxManager.createMailbox(path, 
session).get();
-mailboxManager.register(new MailboxListener() {
-@Override
-public ListenerType getType() {
-return ListenerType.MAILBOX;
-}
-
-@Override
-public void event(Event event) {
-MessageUid u = ((Added) event).getUids().iterator().next();
+mailboxManager.register(
+event -> {
+MessageUid u = ((MailboxListener.Added) 
event).getUids().iterator().next();
 uList.add(u);
-}
-}, mailboxId);
+}, mailboxId);
 mailboxManager.endProcessingRequest(session);
 mailboxManager.logout(session, false);
 


[26/27] james-project git commit: JAMES-2642 add a few more alias mapping integration tests

2019-01-16 Thread btellier
JAMES-2642 add a few more alias mapping integration tests


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

Branch: refs/heads/master
Commit: 1819ae1cbdf2b91e1a74ee4bbd7d2cba6a13240f
Parents: a0793f5
Author: Rene Cordier 
Authored: Wed Jan 16 15:06:30 2019 +0700
Committer: Benoit Tellier 
Committed: Thu Jan 17 13:49:10 2019 +0700

--
 .../transport/mailets/AliasMappingTest.java | 56 
 1 file changed, 56 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/1819ae1c/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/AliasMappingTest.java
--
diff --git 
a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/AliasMappingTest.java
 
b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/AliasMappingTest.java
index 45f4a2f..e400712 100644
--- 
a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/AliasMappingTest.java
+++ 
b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/AliasMappingTest.java
@@ -136,6 +136,7 @@ public class AliasMappingTest {
 
 
jamesServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE,
 BOB_ADDRESS, "INBOX");
 
jamesServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE,
 ALICE_ADDRESS, "INBOX");
+
jamesServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE,
 CEDRIC_ADDRESS, "INBOX");
 
 WebAdminGuiceProbe webAdminGuiceProbe = 
jamesServer.getProbe(WebAdminGuiceProbe.class);
 webAdminGuiceProbe.await();
@@ -285,4 +286,59 @@ public class AliasMappingTest {
 }
 
 
+@Test
+public void messageShouldRedirectFromAliasContainingSlash() throws 
Exception {
+String aliasWithSlash = "bob/alias@" + DOMAIN;
+String aliasWithEncodedSlash = "bob%2Falias@" + DOMAIN;
+webAdminApi.put(AliasRoutes.ROOT_PATH + "/" + BOB_ADDRESS + 
"/sources/" + aliasWithEncodedSlash);
+
+messageSender.connect(LOCALHOST_IP, 
jamesServer.getProbe(SmtpGuiceProbe.class).getSmtpPort())
+.sendMessage(FakeMail.builder()
+.mimeMessage(message)
+.sender(ALICE_ADDRESS)
+.recipient(aliasWithSlash));
+
+imapMessageReader.connect(LOCALHOST_IP, 
jamesServer.getProbe(ImapGuiceProbe.class).getImapPort())
+.login(BOB_ADDRESS, PASSWORD)
+.select(IMAPMessageReader.INBOX)
+.awaitMessage(awaitAtMostOneMinute);
+}
+
+@Test
+public void messageShouldRedirectToUserContainingSlash() throws Exception {
+String userWithSlash = "bob/a@" + DOMAIN;
+dataProbe.addUser(userWithSlash, PASSWORD);
+String userWithEncodedSlash = "bob%2Fa@" + DOMAIN;
+webAdminApi.put(AliasRoutes.ROOT_PATH + "/" + userWithEncodedSlash + 
"/sources/" + BOB_ALIAS);
+
+messageSender.connect(LOCALHOST_IP, 
jamesServer.getProbe(SmtpGuiceProbe.class).getSmtpPort())
+.sendMessage(FakeMail.builder()
+.mimeMessage(message)
+.sender(ALICE_ADDRESS)
+.recipient(BOB_ALIAS));
+
+imapMessageReader.connect(LOCALHOST_IP, 
jamesServer.getProbe(ImapGuiceProbe.class).getImapPort())
+.login(userWithSlash, PASSWORD)
+.select(IMAPMessageReader.INBOX)
+.awaitMessage(awaitAtMostOneMinute);
+}
+
+@Test
+public void messageShouldRedirectToUserWhenEncodingAt() throws Exception {
+String userWithEncodedAt = "bob%40" + DOMAIN;
+String aliasWithEncodedAt = "bob-alias%40" + DOMAIN;
+webAdminApi.put(AliasRoutes.ROOT_PATH + "/" + userWithEncodedAt + 
"/sources/" + aliasWithEncodedAt);
+
+messageSender.connect(LOCALHOST_IP, 
jamesServer.getProbe(SmtpGuiceProbe.class).getSmtpPort())
+.sendMessage(FakeMail.builder()
+.mimeMessage(message)
+.sender(ALICE_ADDRESS)
+.recipient(BOB_ALIAS));
+
+imapMessageReader.connect(LOCALHOST_IP, 
jamesServer.getProbe(ImapGuiceProbe.class).getImapPort())
+.login(BOB_ADDRESS, PASSWORD)
+.select(IMAPMessageReader.INBOX)
+.awaitMessage(awaitAtMostOneMinute);
+}
+
 }


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



[18/27] james-project git commit: MAILBOX-377 Slightly improve InVMEventDelivery

2019-01-16 Thread btellier
MAILBOX-377 Slightly improve InVMEventDelivery


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

Branch: refs/heads/master
Commit: 3f8b8f6a57fdcf15bdeb5a17056147212602fe22
Parents: 897a206
Author: Benoit Tellier 
Authored: Tue Jan 15 11:00:00 2019 +0700
Committer: Benoit Tellier 
Committed: Thu Jan 17 13:49:09 2019 +0700

--
 .../events/delivery/InVmEventDelivery.java  | 26 
 1 file changed, 10 insertions(+), 16 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/3f8b8f6a/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/InVmEventDelivery.java
--
diff --git 
a/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/InVmEventDelivery.java
 
b/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/InVmEventDelivery.java
index 63edafb..c59a8b8 100644
--- 
a/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/InVmEventDelivery.java
+++ 
b/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/InVmEventDelivery.java
@@ -21,6 +21,7 @@ package org.apache.james.mailbox.events.delivery;
 
 import java.time.Duration;
 import java.util.Collection;
+import java.util.stream.Stream;
 
 import javax.inject.Inject;
 
@@ -31,12 +32,11 @@ import org.apache.james.metrics.api.TimeMetric;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.github.steveash.guavate.Guavate;
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.ImmutableList;
 
 import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
+import reactor.core.publisher.MonoProcessor;
 import reactor.core.scheduler.Schedulers;
 
 public class InVmEventDelivery implements EventDelivery {
@@ -56,27 +56,21 @@ public class InVmEventDelivery implements EventDelivery {
 
 @Override
 public ExecutionStages deliver(Collection 
mailboxListeners, Event event) {
-Mono synchronousListeners = doDeliver(
-filterByExecutionMode(mailboxListeners, 
MailboxListener.ExecutionMode.SYNCHRONOUS), event)
-.cache();
-Mono asyncListener = doDeliver(
-filterByExecutionMode(mailboxListeners, 
MailboxListener.ExecutionMode.ASYNCHRONOUS), event)
-.cache();
-
-synchronousListeners.subscribe();
-asyncListener.subscribe();
+Mono synchronousListeners = 
doDeliver(filterByExecutionMode(mailboxListeners, 
MailboxListener.ExecutionMode.SYNCHRONOUS), event)
+.subscribeWith(MonoProcessor.create());
+Mono asyncListener = 
doDeliver(filterByExecutionMode(mailboxListeners, 
MailboxListener.ExecutionMode.ASYNCHRONOUS), event)
+.subscribeWith(MonoProcessor.create());
 
 return new ExecutionStages(synchronousListeners, asyncListener);
 }
 
-private ImmutableList 
filterByExecutionMode(Collection mailboxListeners, 
MailboxListener.ExecutionMode executionMode) {
+private Stream 
filterByExecutionMode(Collection mailboxListeners, 
MailboxListener.ExecutionMode executionMode) {
 return mailboxListeners.stream()
-.filter(listener -> listener.getExecutionMode() == executionMode)
-.collect(Guavate.toImmutableList());
+.filter(listener -> listener.getExecutionMode() == executionMode);
 }
 
-private Mono doDeliver(Collection mailboxListeners, 
Event event) {
-return Flux.fromIterable(mailboxListeners)
+private Mono doDeliver(Stream mailboxListeners, 
Event event) {
+return Flux.fromStream(mailboxListeners)
 .flatMap(mailboxListener -> deliveryWithRetries(event, 
mailboxListener))
 .then()
 .subscribeOn(Schedulers.elastic());


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



[25/27] james-project git commit: JAMES-2642 Add basic alias mapping integration tests

2019-01-16 Thread btellier
JAMES-2642 Add basic alias mapping integration tests


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

Branch: refs/heads/master
Commit: a0793f5bbcf321c69541d78144e231503250dbcc
Parents: 3a00fa2
Author: Rene Cordier 
Authored: Wed Jan 16 11:54:29 2019 +0700
Committer: Benoit Tellier 
Committed: Thu Jan 17 13:49:10 2019 +0700

--
 .../transport/mailets/AliasMappingTest.java | 288 +++
 1 file changed, 288 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/a0793f5b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/AliasMappingTest.java
--
diff --git 
a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/AliasMappingTest.java
 
b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/AliasMappingTest.java
new file mode 100644
index 000..45f4a2f
--- /dev/null
+++ 
b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/AliasMappingTest.java
@@ -0,0 +1,288 @@
+/
+ * 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.transport.mailets;
+
+import static io.restassured.RestAssured.given;
+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.awaitAtMostOneMinute;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import javax.mail.internet.MimeMessage;
+
+import org.apache.james.core.builder.MimeMessageBuilder;
+import org.apache.james.jmap.mailet.VacationMailet;
+import org.apache.james.jmap.mailet.filter.JMAPFiltering;
+import org.apache.james.mailbox.model.MailboxConstants;
+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.mailets.configuration.ProcessorConfiguration;
+import org.apache.james.mailrepository.api.MailRepositoryUrl;
+import org.apache.james.modules.MailboxProbeImpl;
+import org.apache.james.modules.protocols.ImapGuiceProbe;
+import org.apache.james.modules.protocols.SmtpGuiceProbe;
+import org.apache.james.probe.DataProbe;
+import org.apache.james.transport.matchers.All;
+import org.apache.james.transport.matchers.IsSenderInRRTLoop;
+import org.apache.james.transport.matchers.RecipientIsLocal;
+import org.apache.james.utils.DataProbeImpl;
+import org.apache.james.utils.IMAPMessageReader;
+import org.apache.james.utils.SMTPMessageSender;
+import org.apache.james.utils.WebAdminGuiceProbe;
+import org.apache.james.webadmin.WebAdminUtils;
+import org.apache.james.webadmin.routes.AliasRoutes;
+import org.apache.mailet.base.test.FakeMail;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+
+import io.restassured.specification.RequestSpecification;
+
+public class AliasMappingTest {
+private static final String DOMAIN = "domain.tld";
+
+private static final String BOB_USER = "bob";
+private static final String ALICE_USER = "alice";
+private static final String 

[19/27] james-project git commit: JAMES-2641 Allow specifying group of registered listeners

2019-01-16 Thread btellier
JAMES-2641 Allow specifying group of registered listeners

This allow duplicate listeners to be registered, a feature used by over-quota 
mailing
to specify several thresholds.


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

Branch: refs/heads/master
Commit: 8d66bb110a21a7a473dc3fcea84fb5a5399499b3
Parents: 24fe28f
Author: Benoit Tellier 
Authored: Mon Jan 14 10:44:20 2019 +0700
Committer: Benoit Tellier 
Committed: Thu Jan 17 13:49:09 2019 +0700

--
 .../apache/james/mailbox/MailboxListener.java   |  2 +-
 .../apache/james/mailbox/events/EventBus.java   |  2 +-
 .../james/mailbox/events/GenericGroup.java  | 45 
 .../org/apache/james/mailbox/events/Group.java  |  4 +-
 .../apache/james/mailbox/events/GroupTest.java  |  7 +++
 .../james/mailbox/util/EventCollector.java  |  2 +-
 .../CacheInvalidatingMailboxListener.java   |  2 +-
 .../MailboxOperationLoggingListener.java|  2 +-
 ...lasticSearchListeningMessageSearchIndex.java |  2 +-
 .../lucene/search/LuceneMessageSearchIndex.java |  2 +-
 .../QuotaThresholdCrossingListener.java |  2 +-
 .../ElasticSearchQuotaMailboxListener.java  |  2 +-
 .../spamassassin/SpamAssassinListener.java  |  2 +-
 .../store/event/MailboxAnnotationListener.java  |  2 +-
 .../quota/ListeningCurrentQuotaUpdater.java |  2 +-
 .../store/search/LazyMessageSearchIndex.java|  2 +-
 .../modules/mailbox/CassandraQuotaModule.java   |  2 +-
 .../modules/mailbox/ListenerConfiguration.java  | 13 --
 .../modules/mailbox/MailboxListenerFactory.java |  6 +--
 .../modules/mailbox/MailboxListenersLoader.java |  6 ++-
 .../mailbox/MailboxListenersLoaderImpl.java | 29 ++---
 .../modules/mailbox/NoopMailboxListener.java|  2 +-
 .../mailbox/ListenerConfigurationTest.java  | 25 ++-
 .../mailbox/MailboxListenersLoaderImplTest.java | 39 -
 .../src/test/resources/listeners.xml|  2 +
 .../src/test/resources/listeners.xml|  2 +
 .../src/test/resources/listeners.xml|  2 +
 .../event/PropagateLookupRightListener.java |  2 +-
 28 files changed, 176 insertions(+), 36 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/8d66bb11/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
--
diff --git 
a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java 
b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
index fd79dd9..d845154 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
@@ -50,7 +50,7 @@ import com.google.common.collect.ImmutableMap;
 public interface MailboxListener {
 
 interface GroupMailboxListener extends MailboxListener {
-Group getGroup();
+Group getDefaultGroup();
 }
 
 enum ExecutionMode {

http://git-wip-us.apache.org/repos/asf/james-project/blob/8d66bb11/mailbox/api/src/main/java/org/apache/james/mailbox/events/EventBus.java
--
diff --git 
a/mailbox/api/src/main/java/org/apache/james/mailbox/events/EventBus.java 
b/mailbox/api/src/main/java/org/apache/james/mailbox/events/EventBus.java
index 70275cc..6b25f1b 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/events/EventBus.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/events/EventBus.java
@@ -40,6 +40,6 @@ public interface EventBus {
 }
 
 default Registration register(MailboxListener.GroupMailboxListener 
groupMailboxListener) {
-return register(groupMailboxListener, groupMailboxListener.getGroup());
+return register(groupMailboxListener, 
groupMailboxListener.getDefaultGroup());
 }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/8d66bb11/mailbox/api/src/main/java/org/apache/james/mailbox/events/GenericGroup.java
--
diff --git 
a/mailbox/api/src/main/java/org/apache/james/mailbox/events/GenericGroup.java 
b/mailbox/api/src/main/java/org/apache/james/mailbox/events/GenericGroup.java
new file mode 100644
index 000..ed36568
--- /dev/null
+++ 
b/mailbox/api/src/main/java/org/apache/james/mailbox/events/GenericGroup.java
@@ -0,0 +1,45 @@
+/
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *

[06/27] james-project git commit: JAMES-2641 Introduce GroupMailboxListener

2019-01-16 Thread btellier
JAMES-2641 Introduce GroupMailboxListener

That is mailboxListener carrying their default execution group around.


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

Branch: refs/heads/master
Commit: 0a3b38abea5ee8b030a6973ec812ee4fe5c1790c
Parents: 8cf25c7
Author: Benoit Tellier 
Authored: Thu Jan 10 10:49:06 2019 +0700
Committer: Benoit Tellier 
Committed: Thu Jan 17 10:23:41 2019 +0700

--
 .../java/org/apache/james/mailbox/MailboxListener.java   |  5 +
 .../org/apache/james/mailbox/util/EventCollector.java| 11 ++-
 .../caching/CacheInvalidatingMailboxListener.java| 10 +-
 .../cassandra/MailboxOperationLoggingListener.java   | 11 ++-
 .../events/ElasticSearchListeningMessageSearchIndex.java |  8 
 .../mailbox/lucene/search/LuceneMessageSearchIndex.java  |  8 
 .../listeners/QuotaThresholdCrossingListener.java| 11 ++-
 .../events/ElasticSearchQuotaMailboxListener.java| 10 +-
 .../james/mailbox/spamassassin/SpamAssassinListener.java |  8 
 .../james/mailbox/store/event/SpamEventListener.java |  2 +-
 .../store/quota/ListeningCurrentQuotaUpdater.java| 10 +-
 .../mailbox/store/search/LazyMessageSearchIndex.java |  8 
 .../store/search/ListeningMessageSearchIndex.java|  2 +-
 .../james/modules/mailbox/NoopMailboxListener.java   | 11 ++-
 .../james/jmap/event/PropagateLookupRightListener.java   | 11 ++-
 15 files changed, 116 insertions(+), 10 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/0a3b38ab/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
--
diff --git 
a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java 
b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
index 7eb3709..253347c 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
@@ -30,6 +30,7 @@ import org.apache.james.core.User;
 import org.apache.james.core.quota.QuotaCount;
 import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.acl.ACLDiff;
+import org.apache.james.mailbox.events.Group;
 import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.MessageMetaData;
@@ -48,6 +49,10 @@ import com.google.common.collect.ImmutableMap;
  */
 public interface MailboxListener {
 
+interface GroupMailboxListener extends MailboxListener {
+Group getGroup();
+}
+
 enum ListenerType {
 ONCE,
 EACH_NODE,

http://git-wip-us.apache.org/repos/asf/james-project/blob/0a3b38ab/mailbox/api/src/test/java/org/apache/james/mailbox/util/EventCollector.java
--
diff --git 
a/mailbox/api/src/test/java/org/apache/james/mailbox/util/EventCollector.java 
b/mailbox/api/src/test/java/org/apache/james/mailbox/util/EventCollector.java
index 7152cf3..7b8cffa 100644
--- 
a/mailbox/api/src/test/java/org/apache/james/mailbox/util/EventCollector.java
+++ 
b/mailbox/api/src/test/java/org/apache/james/mailbox/util/EventCollector.java
@@ -24,8 +24,12 @@ import java.util.List;
 
 import org.apache.james.mailbox.Event;
 import org.apache.james.mailbox.MailboxListener;
+import org.apache.james.mailbox.events.Group;
 
-public class EventCollector implements MailboxListener {
+public class EventCollector implements MailboxListener.GroupMailboxListener {
+private static class EventCollectorGroup extends Group {}
+
+private static final Group GROUP = new EventCollectorGroup();
 
 private final List events = new ArrayList<>();
 
@@ -40,6 +44,11 @@ public class EventCollector implements MailboxListener {
 }
 
 @Override
+public Group getGroup() {
+return GROUP;
+}
+
+@Override
 public ListenerType getType() {
 return listenerType;
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/0a3b38ab/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CacheInvalidatingMailboxListener.java
--
diff --git 
a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CacheInvalidatingMailboxListener.java
 
b/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CacheInvalidatingMailboxListener.java
index fdbf311..02b436b 100644
--- 

[02/27] james-project git commit: JAMES-2641 Delete DefaultDelegatingMailboxListenerTest

2019-01-16 Thread btellier
JAMES-2641 Delete DefaultDelegatingMailboxListenerTest


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

Branch: refs/heads/master
Commit: 0947b1b300b731139212c0a821fa44520adfff5c
Parents: 1f390f4
Author: Benoit Tellier 
Authored: Thu Jan 10 10:05:52 2019 +0700
Committer: Benoit Tellier 
Committed: Thu Jan 17 10:23:40 2019 +0700

--
 .../DefaultDelegatingMailboxListenerTest.java   | 196 ---
 1 file changed, 196 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/0947b1b3/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/DefaultDelegatingMailboxListenerTest.java
--
diff --git 
a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/DefaultDelegatingMailboxListenerTest.java
 
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/DefaultDelegatingMailboxListenerTest.java
deleted file mode 100644
index 9490f63..000
--- 
a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/DefaultDelegatingMailboxListenerTest.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/
- * 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.mailbox.store.event;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.apache.james.core.User;
-import org.apache.james.core.quota.QuotaCount;
-import org.apache.james.core.quota.QuotaSize;
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
-import org.apache.james.mailbox.MailboxSession;
-import org.apache.james.mailbox.MailboxSessionUtil;
-import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.model.MailboxId;
-import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.model.QuotaRoot;
-import org.apache.james.mailbox.model.TestId;
-import org.apache.james.mailbox.util.EventCollector;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.google.common.collect.ImmutableSortedMap;
-
-public class DefaultDelegatingMailboxListenerTest {
-
-private static final MailboxPath MAILBOX_PATH = new 
MailboxPath("namespace", "user", "name");
-private static final MailboxPath OTHER_MAILBOX_PATH = new 
MailboxPath("namespace", "other", "name");
-private static final MailboxId MAILBOX_ID = TestId.of(100);
-private static final MailboxId OTHER_MAILBOX_ID = TestId.of(42);
-
-private DefaultDelegatingMailboxListener defaultDelegatingMailboxListener;
-private EventCollector mailboxEventCollector;
-private EventCollector eachNodeEventCollector;
-private EventCollector onceEventCollector;
-
-@Before
-public void setUp() throws Exception {
-mailboxEventCollector = new 
EventCollector(MailboxListener.ListenerType.MAILBOX);
-eachNodeEventCollector = new 
EventCollector(MailboxListener.ListenerType.EACH_NODE);
-onceEventCollector = new 
EventCollector(MailboxListener.ListenerType.ONCE);
-defaultDelegatingMailboxListener = new 
DefaultDelegatingMailboxListener();
-defaultDelegatingMailboxListener.addListener(MAILBOX_ID, 
mailboxEventCollector, null);
-defaultDelegatingMailboxListener.addGlobalListener(onceEventCollector, 
null);
-

[09/27] james-project git commit: JAMES-2641 Remove MailboxListenerRegistry

2019-01-16 Thread btellier
JAMES-2641 Remove MailboxListenerRegistry


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

Branch: refs/heads/master
Commit: 90f18c4b9377cbe41cf76012bd2c9d7463f619a8
Parents: 89f168d
Author: Benoit Tellier 
Authored: Thu Jan 10 14:30:16 2019 +0700
Committer: Benoit Tellier 
Committed: Thu Jan 17 10:23:41 2019 +0700

--
 .../store/event/MailboxListenerRegistry.java|  71 --
 .../event/MailboxListenerRegistryTest.java  | 142 ---
 .../modules/mailbox/DefaultEventModule.java |   2 -
 .../modules/mailbox/MailboxListenerFactory.java |   6 +-
 .../modules/mailbox/MailboxListenersLoader.java |   5 +-
 .../mailbox/MailboxListenersLoaderImpl.java |  19 ++-
 .../modules/mailbox/NoopMailboxListener.java|   2 +-
 .../mailbox/MailboxListenersLoaderImplTest.java |  15 +-
 8 files changed, 22 insertions(+), 240 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/90f18c4b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxListenerRegistry.java
--
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxListenerRegistry.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxListenerRegistry.java
deleted file mode 100644
index 83461e6..000
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxListenerRegistry.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/
- * 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.mailbox.store.event;
-
-import java.util.List;
-import java.util.concurrent.ConcurrentLinkedQueue;
-
-import org.apache.james.mailbox.MailboxListener;
-import org.apache.james.mailbox.model.MailboxId;
-
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Multimap;
-import com.google.common.collect.Multimaps;
-
-public class MailboxListenerRegistry {
-
-private final Multimap listeners;
-private final ConcurrentLinkedQueue globalListeners;
-
-public MailboxListenerRegistry() {
-this.globalListeners = new ConcurrentLinkedQueue<>();
-this.listeners = Multimaps.synchronizedMultimap(HashMultimap.create());
-}
-
-public void addListener(MailboxId mailboxId, MailboxListener listener) {
-listeners.put(mailboxId, listener);
-}
-
-public void addGlobalListener(MailboxListener listener) {
-globalListeners.add(listener);
-}
-
-public void removeListener(MailboxId mailboxId, MailboxListener listener) {
-listeners.remove(mailboxId, listener);
-}
-
-public void removeGlobalListener(MailboxListener listener) {
-globalListeners.remove(listener);
-}
-
-public List getLocalMailboxListeners(MailboxId mailboxId) 
{
-return ImmutableList.copyOf(listeners.get(mailboxId));
-}
-
-public List getGlobalListeners() {
-return ImmutableList.copyOf(globalListeners);
-}
-
-public void deleteRegistryFor(MailboxId mailboxId) {
-listeners.removeAll(mailboxId);
-}
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/90f18c4b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MailboxListenerRegistryTest.java
--
diff --git 

[12/27] james-project git commit: JAMES-2641 Drop Delegating mailbox listener and rather use the EventBus

2019-01-16 Thread btellier
http://git-wip-us.apache.org/repos/asf/james-project/blob/89f168de/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxManagerAttachmentTest.java
--
diff --git 
a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxManagerAttachmentTest.java
 
b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxManagerAttachmentTest.java
index 668cfbe..2cc6bae 100644
--- 
a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxManagerAttachmentTest.java
+++ 
b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxManagerAttachmentTest.java
@@ -28,6 +28,8 @@ import java.io.InputStream;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.acl.GroupMembershipResolver;
 import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
+import org.apache.james.mailbox.events.InVMEventBus;
+import org.apache.james.mailbox.events.delivery.InVmEventDelivery;
 import org.apache.james.mailbox.inmemory.InMemoryMailboxManager;
 import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
 import org.apache.james.mailbox.inmemory.InMemoryMessageId;
@@ -40,13 +42,13 @@ import org.apache.james.mailbox.store.NoMailboxPathLocker;
 import org.apache.james.mailbox.store.SessionProvider;
 import org.apache.james.mailbox.store.StoreMailboxAnnotationManager;
 import org.apache.james.mailbox.store.StoreRightManager;
-import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
 import org.apache.james.mailbox.store.extractor.DefaultTextExtractor;
 import org.apache.james.mailbox.store.mail.AttachmentMapperFactory;
 import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
 import org.apache.james.mailbox.store.quota.QuotaComponents;
 import org.apache.james.mailbox.store.search.MessageSearchIndex;
 import org.apache.james.mailbox.store.search.SimpleMessageSearchIndex;
+import org.apache.james.metrics.api.NoopMetricFactory;
 import org.junit.Before;
 
 public class InMemoryMailboxManagerAttachmentTest extends 
AbstractMailboxManagerAttachmentTest {
@@ -62,11 +64,11 @@ public class InMemoryMailboxManagerAttachmentTest extends 
AbstractMailboxManager
 mailboxSessionMapperFactory = new 
InMemoryMailboxSessionMapperFactory();
 Authenticator noAuthenticator = null;
 Authorizator noAuthorizator = null;
-DefaultDelegatingMailboxListener delegatingListener = new 
DefaultDelegatingMailboxListener();
+InVMEventBus eventBus = new InVMEventBus(new InVmEventDelivery(new 
NoopMetricFactory()));
 MessageId.Factory messageIdFactory = new InMemoryMessageId.Factory();
 GroupMembershipResolver groupMembershipResolver = null;
 UnionMailboxACLResolver aclResolver = new UnionMailboxACLResolver();
-StoreRightManager storeRightManager = new 
StoreRightManager(mailboxSessionMapperFactory, aclResolver, 
groupMembershipResolver, delegatingListener);
+StoreRightManager storeRightManager = new 
StoreRightManager(mailboxSessionMapperFactory, aclResolver, 
groupMembershipResolver, eventBus);
 
 SessionProvider sessionProvider = new SessionProvider(noAuthenticator, 
noAuthorizator);
 QuotaComponents quotaComponents = 
QuotaComponents.disabled(sessionProvider, mailboxSessionMapperFactory);
@@ -74,12 +76,12 @@ public class InMemoryMailboxManagerAttachmentTest extends 
AbstractMailboxManager
 
 StoreMailboxAnnotationManager annotationManager = new 
StoreMailboxAnnotationManager(mailboxSessionMapperFactory, storeRightManager);
 mailboxManager = new 
InMemoryMailboxManager(mailboxSessionMapperFactory, sessionProvider, new 
NoMailboxPathLocker(),
-new MessageParser(), messageIdFactory, delegatingListener, 
annotationManager, storeRightManager, quotaComponents, index);
+new MessageParser(), messageIdFactory, eventBus, 
annotationManager, storeRightManager, quotaComponents, index);
 MessageParser failingMessageParser = mock(MessageParser.class);
 when(failingMessageParser.retrieveAttachments(any(InputStream.class)))
 .thenThrow(new RuntimeException("Message parser set to fail"));
 parseFailingMailboxManager = new 
InMemoryMailboxManager(mailboxSessionMapperFactory, sessionProvider, new 
NoMailboxPathLocker(),
-failingMessageParser, messageIdFactory, delegatingListener, 
annotationManager, storeRightManager, quotaComponents, index);
+failingMessageParser, messageIdFactory, eventBus, 
annotationManager, storeRightManager, quotaComponents, index);
 super.setUp();
 }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/89f168de/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java

[23/27] james-project git commit: JAMES-2642 alias webadmin integration test

2019-01-16 Thread btellier
JAMES-2642 alias webadmin integration test


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

Branch: refs/heads/master
Commit: 3a00fa2adeb956ede1daf3fbad393d8b62170cb9
Parents: 9fd0b6a
Author: Rene Cordier 
Authored: Tue Jan 15 10:36:05 2019 +0700
Committer: Benoit Tellier 
Committed: Thu Jan 17 13:49:09 2019 +0700

--
 .../james/cli/probe/impl/JmxDataProbe.java  | 22 
 .../org/apache/james/utils/DataProbeImpl.java   | 12 +++
 .../java/org/apache/james/probe/DataProbe.java  |  4 +++
 .../RecipientRewriteTableManagementMBean.java   | 36 
 .../lib/RecipientRewriteTableManagement.java| 12 +++
 .../WebAdminServerIntegrationTest.java  | 16 +
 6 files changed, 96 insertions(+), 6 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/3a00fa2a/server/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxDataProbe.java
--
diff --git 
a/server/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxDataProbe.java
 
b/server/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxDataProbe.java
index fae65ac..cb50af9 100644
--- 
a/server/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxDataProbe.java
+++ 
b/server/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxDataProbe.java
@@ -281,4 +281,26 @@ public class JmxDataProbe implements DataProbe, JmxProbe {
 virtualUserTableProxy.removeGroupMapping(toUser, toDomain, 
fromAddress);
 }
 }
+
+@Override
+public void addAliasMapping(String fromAlias, String fromDomain, String 
toAddress) throws Exception {
+try (Closeable closeable =
+ MDCBuilder.create()
+ .addContext(MDCBuilder.PROTOCOL, JMX)
+ .addContext(MDCBuilder.ACTION, "addAliasMapping")
+ .build()) {
+virtualUserTableProxy.addAliasMapping(fromAlias, fromDomain, 
toAddress);
+}
+}
+
+@Override
+public void removeAliasMapping(String fromAlias, String fromDomain, String 
toAddress) throws Exception {
+try (Closeable closeable =
+ MDCBuilder.create()
+ .addContext(MDCBuilder.PROTOCOL, JMX)
+ .addContext(MDCBuilder.ACTION, "removeAliasMapping")
+ .build()) {
+virtualUserTableProxy.removeAliasMapping(fromAlias, fromDomain, 
toAddress);
+}
+}
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/3a00fa2a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/DataProbeImpl.java
--
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/DataProbeImpl.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/DataProbeImpl.java
index 314ec07..e56c8b5 100644
--- 
a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/DataProbeImpl.java
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/DataProbeImpl.java
@@ -168,4 +168,16 @@ public class DataProbeImpl implements GuiceProbe, 
DataProbe {
 MappingSource source = MappingSource.fromUser(toUser, toDomain);
 recipientRewriteTable.removeGroupMapping(source, fromAddress);
 }
+
+@Override
+public void addAliasMapping(String fromAlias, String fromDomain, String 
toAddress) throws Exception {
+MappingSource source = MappingSource.fromUser(fromAlias, fromDomain);
+recipientRewriteTable.addAliasMapping(source, toAddress);
+}
+
+@Override
+public void removeAliasMapping(String fromAlias, String fromDomain, String 
toAddress) throws Exception {
+MappingSource source = MappingSource.fromUser(fromAlias, fromDomain);
+recipientRewriteTable.removeAliasMapping(source, toAddress);
+}
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/3a00fa2a/server/data/data-api/src/main/java/org/apache/james/probe/DataProbe.java
--
diff --git 
a/server/data/data-api/src/main/java/org/apache/james/probe/DataProbe.java 
b/server/data/data-api/src/main/java/org/apache/james/probe/DataProbe.java
index 6832fcd..cdaf8fc 100644
--- a/server/data/data-api/src/main/java/org/apache/james/probe/DataProbe.java
+++ b/server/data/data-api/src/main/java/org/apache/james/probe/DataProbe.java
@@ -92,4 

[11/27] james-project git commit: JAMES-2641 Drop Delegating mailbox listener and rather use the EventBus

2019-01-16 Thread btellier
http://git-wip-us.apache.org/repos/asf/james-project/blob/89f168de/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerSideEffectTest.java
--
diff --git 
a/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerSideEffectTest.java
 
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerSideEffectTest.java
index 0ea9730..50ffb55 100644
--- 
a/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerSideEffectTest.java
+++ 
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerSideEffectTest.java
@@ -39,6 +39,9 @@ import org.apache.james.mailbox.MessageManager;
 import org.apache.james.mailbox.MessageManager.FlagsUpdateMode;
 import org.apache.james.mailbox.MessageMoveEvent;
 import org.apache.james.mailbox.MessageUid;
+import org.apache.james.mailbox.events.EventBus;
+import org.apache.james.mailbox.events.InVMEventBus;
+import org.apache.james.mailbox.events.delivery.InVmEventDelivery;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.OverQuotaException;
 import org.apache.james.mailbox.fixture.MailboxFixture;
@@ -50,10 +53,9 @@ import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.model.UpdatedFlags;
 import org.apache.james.mailbox.quota.QuotaManager;
-import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
-import org.apache.james.mailbox.store.event.DelegatingMailboxListener;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 import org.apache.james.mailbox.util.EventCollector;
+import org.apache.james.metrics.api.NoopMetricFactory;
 import org.assertj.core.api.AbstractListAssert;
 import org.assertj.core.api.ObjectAssert;
 import org.junit.Rule;
@@ -72,7 +74,6 @@ public abstract class AbstractMessageIdManagerSideEffectTest {
 private static final MessageUid messageUid2 = MessageUid.of(113);
 
 private static final Flags FLAGS = new Flags();
-private static final MailboxSession SESSION = 
MailboxSessionUtil.create("any");
 
 @Rule
 public ExpectedException expectedException = ExpectedException.none();
@@ -85,17 +86,17 @@ public abstract class 
AbstractMessageIdManagerSideEffectTest {
 private QuotaManager quotaManager;
 private MessageIdManagerTestSystem testingData;
 private EventCollector eventCollector;
-private DefaultDelegatingMailboxListener delegatingMailboxListener;
+private EventBus eventBus;
 
-protected abstract MessageIdManagerTestSystem 
createTestSystem(QuotaManager quotaManager, DelegatingMailboxListener 
delegatingMailboxListener) throws Exception;
+protected abstract MessageIdManagerTestSystem 
createTestSystem(QuotaManager quotaManager, EventBus eventBus) throws Exception;
 
 public void setUp() throws Exception {
-delegatingMailboxListener = new DefaultDelegatingMailboxListener();
+eventBus = new InVMEventBus(new InVmEventDelivery(new 
NoopMetricFactory()));
 eventCollector = new EventCollector();
 quotaManager = mock(QuotaManager.class);
 
 session = MailboxSessionUtil.create(ALICE);
-testingData = createTestSystem(quotaManager, 
delegatingMailboxListener);
+testingData = createTestSystem(quotaManager, eventBus);
 messageIdManager = testingData.getMessageIdManager();
 
 mailbox1 = testingData.createMailbox(MailboxFixture.INBOX_ALICE, 
session);
@@ -111,7 +112,7 @@ public abstract class 
AbstractMessageIdManagerSideEffectTest {
 MessageResult messageResult = 
messageIdManager.getMessages(ImmutableList.of(messageId), 
FetchGroupImpl.MINIMAL, session).get(0);
 MessageMetaData simpleMessageMetaData = 
messageResult.messageMetaData();
 
-delegatingMailboxListener.addGlobalListener(eventCollector, SESSION);
+eventBus.register(eventCollector);
 messageIdManager.delete(messageId, 
ImmutableList.of(mailbox1.getMailboxId()), session);
 
 assertThat(eventCollector.getEvents())
@@ -136,7 +137,7 @@ public abstract class 
AbstractMessageIdManagerSideEffectTest {
 MessageResult messageResult2 = 
messageIdManager.getMessages(ImmutableList.of(messageId2), 
FetchGroupImpl.MINIMAL, session).get(0);
 MessageMetaData simpleMessageMetaData2 = 
messageResult2.messageMetaData();
 
-delegatingMailboxListener.addGlobalListener(eventCollector, SESSION);
+eventBus.register(eventCollector);
 messageIdManager.delete(ImmutableList.of(messageId1, messageId2), 
session);
 
 AbstractListAssert, 
MailboxListener.Expunged, ObjectAssert> events =
@@ -155,7 +156,7 @@ public abstract class 
AbstractMessageIdManagerSideEffectTest {
 givenUnlimitedQuota();
 MessageId messageId = testingData.persist(mailbox2.getMailboxId(), 

[20/27] james-project git commit: JAMES-2641 Harden MailboxManagerTest for events and do some fix

2019-01-16 Thread btellier
JAMES-2641 Harden MailboxManagerTest for events and do some fix

We need to also ensure the right dispatch key is being used...


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

Branch: refs/heads/master
Commit: 5a1d9d7b4ab55175c435afb5711c4bb8ee6f3294
Parents: 3f8b8f6
Author: Benoit Tellier 
Authored: Tue Jan 15 17:35:51 2019 +0700
Committer: Benoit Tellier 
Committed: Thu Jan 17 13:49:09 2019 +0700

--
 .../james/mailbox/MailboxManagerTest.java   | 85 ++--
 .../mailbox/store/StoreMessageManager.java  | 22 ++---
 2 files changed, 90 insertions(+), 17 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/5a1d9d7b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
--
diff --git 
a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java 
b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
index 57c1b34..8a3d351 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
@@ -36,10 +36,12 @@ import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.MailboxManager.MailboxCapabilities;
 import org.apache.james.mailbox.MessageManager.AppendCommand;
 import org.apache.james.mailbox.events.EventBus;
+import org.apache.james.mailbox.events.MailboxIdRegistrationKey;
 import org.apache.james.mailbox.exception.AnnotationException;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.TooLongMailboxNameException;
 import org.apache.james.mailbox.mock.DataProvisioner;
+import org.apache.james.mailbox.model.ComposedMessageId;
 import org.apache.james.mailbox.model.MailboxACL;
 import org.apache.james.mailbox.model.MailboxAnnotation;
 import org.apache.james.mailbox.model.MailboxAnnotationKey;
@@ -385,7 +387,7 @@ public abstract class MailboxManagerTest {
 @Test
 void deleteMailboxShouldFireMailboxDeletionEvent() throws Exception {
 
assumeTrue(mailboxManager.hasCapability(MailboxCapabilities.Quota));
-retrieveEventBus(mailboxManager).register(listener);
+retrieveEventBus(mailboxManager).register(listener, new 
MailboxIdRegistrationKey(inboxId));
 
 mailboxManager.deleteMailbox(inbox, session);
 
@@ -441,7 +443,7 @@ public abstract class MailboxManagerTest {
 
 @Test
 void addingMessageShouldFireAddedEvent() throws Exception {
-retrieveEventBus(mailboxManager).register(listener);
+retrieveEventBus(mailboxManager).register(listener, new 
MailboxIdRegistrationKey(inboxId));
 inboxManager.appendMessage(MessageManager.AppendCommand.builder()
 .build(message), session);
 
@@ -459,7 +461,7 @@ public abstract class MailboxManagerTest {
 
inboxManager.appendMessage(MessageManager.AppendCommand.builder().build(message),
 session);
 inboxManager.setFlags(new Flags(Flags.Flag.DELETED), 
MessageManager.FlagsUpdateMode.ADD, MessageRange.all(), session);
 
-retrieveEventBus(mailboxManager).register(listener);
+retrieveEventBus(mailboxManager).register(listener, new 
MailboxIdRegistrationKey(inboxId));
 inboxManager.expunge(MessageRange.all(), session);
 
 assertThat(listener.getEvents())
@@ -475,7 +477,7 @@ public abstract class MailboxManagerTest {
 void setFlagsShouldFireFlagsUpdatedEvent() throws Exception {
 
inboxManager.appendMessage(MessageManager.AppendCommand.builder().build(message),
 session);
 
-retrieveEventBus(mailboxManager).register(listener);
+retrieveEventBus(mailboxManager).register(listener, new 
MailboxIdRegistrationKey(inboxId));
 inboxManager.setFlags(new Flags(Flags.Flag.FLAGGED), 
MessageManager.FlagsUpdateMode.ADD, MessageRange.all(), session);
 
 assertThat(listener.getEvents())
@@ -493,7 +495,7 @@ public abstract class MailboxManagerTest {
 Optional targetMailboxId = 
mailboxManager.createMailbox(newPath, session);
 inboxManager.appendMessage(AppendCommand.builder().build(message), 
session);
 
-retrieveEventBus(mailboxManager).register(listener);
+retrieveEventBus(mailboxManager).register(listener, new 
MailboxIdRegistrationKey(targetMailboxId.get()));
 mailboxManager.moveMessages(MessageRange.all(), inbox, newPath, 
session);
 
 

[01/27] james-project git commit: JAMES-2641 MessageMoves should return impactedMailboxIds

2019-01-16 Thread btellier
Repository: james-project
Updated Branches:
  refs/heads/master 1f390f4f3 -> 21cde6d28


JAMES-2641 MessageMoves should return impactedMailboxIds

This is needed to get the registration keys to dispatch related events


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

Branch: refs/heads/master
Commit: 8cf25c79fef04218938368d6cedd5798746a7421
Parents: 0947b1b
Author: Benoit Tellier 
Authored: Thu Jan 10 11:18:15 2019 +0700
Committer: Benoit Tellier 
Committed: Thu Jan 17 10:23:40 2019 +0700

--
 .../java/org/apache/james/mailbox/model/MessageMoves.java | 7 +++
 1 file changed, 7 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/8cf25c79/mailbox/api/src/main/java/org/apache/james/mailbox/model/MessageMoves.java
--
diff --git 
a/mailbox/api/src/main/java/org/apache/james/mailbox/model/MessageMoves.java 
b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MessageMoves.java
index b4ef7ea..a6a9d19 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/model/MessageMoves.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MessageMoves.java
@@ -22,6 +22,7 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.Objects;
 import java.util.Set;
+import java.util.stream.Stream;
 
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Sets;
@@ -94,6 +95,12 @@ public class MessageMoves {
 return targetMailboxIds;
 }
 
+public Stream impactedMailboxIds() {
+return Stream.concat(
+addedMailboxIds().stream(),
+removedMailboxIds().stream());
+}
+
 @Override
 public final boolean equals(Object o) {
 if (o instanceof MessageMoves) {


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



[04/27] james-project git commit: JAMES-2641 DefaultProcessorChain should not use final variable/parameters

2019-01-16 Thread btellier
JAMES-2641 DefaultProcessorChain should not use final variable/parameters


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

Branch: refs/heads/master
Commit: 352f92a72affb0f03ae2f91be54e6d3f0fd13c8b
Parents: 9e34f17
Author: Benoit Tellier 
Authored: Thu Jan 10 15:29:39 2019 +0700
Committer: Benoit Tellier 
Committed: Thu Jan 17 10:23:41 2019 +0700

--
 .../imap/processor/DefaultProcessorChain.java   | 88 ++--
 1 file changed, 44 insertions(+), 44 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/352f92a7/protocols/imap/src/main/java/org/apache/james/imap/processor/DefaultProcessorChain.java
--
diff --git 
a/protocols/imap/src/main/java/org/apache/james/imap/processor/DefaultProcessorChain.java
 
b/protocols/imap/src/main/java/org/apache/james/imap/processor/DefaultProcessorChain.java
index 93946ae..201dbec 100644
--- 
a/protocols/imap/src/main/java/org/apache/james/imap/processor/DefaultProcessorChain.java
+++ 
b/protocols/imap/src/main/java/org/apache/james/imap/processor/DefaultProcessorChain.java
@@ -35,80 +35,80 @@ import org.apache.james.metrics.api.MetricFactory;
 public class DefaultProcessorChain {
 
 public static ImapProcessor createDefaultChain(ImapProcessor 
chainEndProcessor,
-  final MailboxManager mailboxManager, SubscriptionManager 
subscriptionManager,
-  final StatusResponseFactory statusResponseFactory, 
MailboxTyper mailboxTyper, QuotaManager quotaManager,
-  final QuotaRootResolver quotaRootResolver,
+  MailboxManager mailboxManager, SubscriptionManager 
subscriptionManager,
+  StatusResponseFactory statusResponseFactory, MailboxTyper 
mailboxTyper, QuotaManager quotaManager,
+  QuotaRootResolver quotaRootResolver,
   MetricFactory metricFactory) {
-final SystemMessageProcessor systemProcessor = new 
SystemMessageProcessor(chainEndProcessor, mailboxManager);
-final LogoutProcessor logoutProcessor = new 
LogoutProcessor(systemProcessor, mailboxManager, statusResponseFactory, 
metricFactory);
+SystemMessageProcessor systemProcessor = new 
SystemMessageProcessor(chainEndProcessor, mailboxManager);
+LogoutProcessor logoutProcessor = new LogoutProcessor(systemProcessor, 
mailboxManager, statusResponseFactory, metricFactory);
 
-final CapabilityProcessor capabilityProcessor = new 
CapabilityProcessor(logoutProcessor, mailboxManager, statusResponseFactory, 
metricFactory);
-final CheckProcessor checkProcessor = new 
CheckProcessor(capabilityProcessor, mailboxManager, statusResponseFactory, 
metricFactory);
-final LoginProcessor loginProcessor = new 
LoginProcessor(checkProcessor, mailboxManager, statusResponseFactory, 
metricFactory);
+CapabilityProcessor capabilityProcessor = new 
CapabilityProcessor(logoutProcessor, mailboxManager, statusResponseFactory, 
metricFactory);
+CheckProcessor checkProcessor = new 
CheckProcessor(capabilityProcessor, mailboxManager, statusResponseFactory, 
metricFactory);
+LoginProcessor loginProcessor = new LoginProcessor(checkProcessor, 
mailboxManager, statusResponseFactory, metricFactory);
 // so it can announce the LOGINDISABLED if needed
 capabilityProcessor.addProcessor(loginProcessor);
 
-final RenameProcessor renameProcessor = new 
RenameProcessor(loginProcessor, mailboxManager, statusResponseFactory, 
metricFactory);
-final DeleteProcessor deleteProcessor = new 
DeleteProcessor(renameProcessor, mailboxManager, statusResponseFactory, 
metricFactory);
-final CreateProcessor createProcessor = new 
CreateProcessor(deleteProcessor, mailboxManager, statusResponseFactory, 
metricFactory);
-final CloseProcessor closeProcessor = new 
CloseProcessor(createProcessor, mailboxManager, statusResponseFactory, 
metricFactory);
-final UnsubscribeProcessor unsubscribeProcessor = new 
UnsubscribeProcessor(closeProcessor, mailboxManager, subscriptionManager, 
statusResponseFactory, metricFactory);
-final SubscribeProcessor subscribeProcessor;
+RenameProcessor renameProcessor = new RenameProcessor(loginProcessor, 
mailboxManager, statusResponseFactory, metricFactory);
+DeleteProcessor deleteProcessor = new DeleteProcessor(renameProcessor, 
mailboxManager, statusResponseFactory, metricFactory);
+CreateProcessor createProcessor = new CreateProcessor(deleteProcessor, 
mailboxManager, statusResponseFactory, 

[16/27] james-project git commit: JAMES-2641 MailboxManager should not expose group registration

2019-01-16 Thread btellier
JAMES-2641 MailboxManager should not expose group registration


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

Branch: refs/heads/master
Commit: d35e8a64590ba14fd88af33f9667556fb4952849
Parents: f063b48
Author: Benoit Tellier 
Authored: Thu Jan 10 15:21:10 2019 +0700
Committer: Benoit Tellier 
Committed: Thu Jan 17 10:23:41 2019 +0700

--
 .../apache/james/mailbox/MailboxManager.java|  2 --
 .../james/mailbox/MailboxManagerTest.java   | 29 +++-
 .../cassandra/CassandraMailboxManagerTest.java  | 11 ++--
 .../CassandraMessageIdManagerTestSystem.java|  2 +-
 .../mailbox/jpa/JPAMailboxManagerTest.java  | 10 +--
 .../DomainUserMaildirMailboxManagerTest.java| 11 ++--
 .../FullUserMaildirMailboxManagerTest.java  | 12 ++--
 .../inmemory/MemoryMailboxManagerProvider.java  |  4 +--
 .../inmemory/MemoryMailboxManagerTest.java  | 12 +---
 ...ticSearchQuotaSearchTestSystemExtension.java |  2 +-
 .../org/apache/james/utils/JmapGuiceProbe.java  |  7 +++--
 .../event/PropagateLookupRightListenerTest.java |  2 +-
 .../ElasticSearchQuotaSearchExtension.java  |  2 +-
 13 files changed, 66 insertions(+), 40 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/d35e8a64/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
--
diff --git 
a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java 
b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
index 3b5f36c..e2d7cda 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
@@ -347,6 +347,4 @@ public interface MailboxManager extends RequestAware, 
RightManager, MailboxAnnot
 boolean hasChildren(MailboxPath mailboxPath, MailboxSession session) 
throws MailboxException;
 
 Registration register(MailboxListener listener, MailboxId registrationKey);
-
-Registration register(MailboxListener.GroupMailboxListener 
groupMailboxListener);
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/d35e8a64/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
--
diff --git 
a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java 
b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
index 0172ac7..57c1b34 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
@@ -35,6 +35,7 @@ import org.apache.james.core.quota.QuotaCount;
 import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.MailboxManager.MailboxCapabilities;
 import org.apache.james.mailbox.MessageManager.AppendCommand;
+import org.apache.james.mailbox.events.EventBus;
 import org.apache.james.mailbox.exception.AnnotationException;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.TooLongMailboxNameException;
@@ -74,16 +75,18 @@ import com.google.common.collect.ImmutableSet;
  * implement the test methods.
  * 
  */
-public abstract class MailboxManagerTest {
+public abstract class MailboxManagerTest {
 public static final String USER_1 = "USER_1";
 public static final String USER_2 = "USER_2";
 private static final int DEFAULT_MAXIMUM_LIMIT = 256;
 
-private MailboxManager mailboxManager;
+private T mailboxManager;
 private MailboxSession session;
 private Message.Builder message;
 
-protected abstract MailboxManager provideMailboxManager() throws 
MailboxException;
+protected abstract T provideMailboxManager();
+
+protected abstract EventBus retrieveEventBus(T mailboxManager);
 
 @BeforeEach
 void setUp() throws Exception {
@@ -382,7 +385,7 @@ public abstract class MailboxManagerTest {
 @Test
 void deleteMailboxShouldFireMailboxDeletionEvent() throws Exception {
 
assumeTrue(mailboxManager.hasCapability(MailboxCapabilities.Quota));
-mailboxManager.register(listener);
+retrieveEventBus(mailboxManager).register(listener);
 
 mailboxManager.deleteMailbox(inbox, session);
 
@@ -400,7 +403,7 @@ public abstract class MailboxManagerTest {
 @Test
 void createMailboxShouldFireMailboxAddedEvent() throws Exception {
 
assumeTrue(mailboxManager.hasCapability(MailboxCapabilities.Quota));

[03/27] james-project git commit: JAMES-2641 Re-order fields of AbstractSelectionProcessor

2019-01-16 Thread btellier
JAMES-2641 Re-order fields of AbstractSelectionProcessor


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

Branch: refs/heads/master
Commit: 7a37651ec27bad6be3328f5ed567a57ead4939cb
Parents: 352f92a
Author: Benoit Tellier 
Authored: Thu Jan 10 15:38:28 2019 +0700
Committer: Benoit Tellier 
Committed: Thu Jan 17 10:23:41 2019 +0700

--
 .../apache/james/imap/processor/AbstractSelectionProcessor.java | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/7a37651e/protocols/imap/src/main/java/org/apache/james/imap/processor/AbstractSelectionProcessor.java
--
diff --git 
a/protocols/imap/src/main/java/org/apache/james/imap/processor/AbstractSelectionProcessor.java
 
b/protocols/imap/src/main/java/org/apache/james/imap/processor/AbstractSelectionProcessor.java
index 5d817b5..1172979 100644
--- 
a/protocols/imap/src/main/java/org/apache/james/imap/processor/AbstractSelectionProcessor.java
+++ 
b/protocols/imap/src/main/java/org/apache/james/imap/processor/AbstractSelectionProcessor.java
@@ -61,11 +61,10 @@ import com.google.common.collect.ImmutableList;
 
 abstract class AbstractSelectionProcessor extends AbstractMailboxProcessor implements 
PermitEnableCapabilityProcessor {
 private static final Logger LOGGER = 
LoggerFactory.getLogger(AbstractSelectionProcessor.class);
+private static final List CAPS = 
ImmutableList.of(ImapConstants.SUPPORTS_QRESYNC, 
ImapConstants.SUPPORTS_CONDSTORE);
 
-final StatusResponseFactory statusResponseFactory;
-
+private final StatusResponseFactory statusResponseFactory;
 private final boolean openReadOnly;
-private static final List CAPS = 
ImmutableList.of(ImapConstants.SUPPORTS_QRESYNC, 
ImapConstants.SUPPORTS_CONDSTORE);
 
 
 public AbstractSelectionProcessor(Class acceptableClass, ImapProcessor 
next, MailboxManager mailboxManager, StatusResponseFactory 
statusResponseFactory, boolean openReadOnly,


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



[08/27] james-project git commit: JAMES-2641 IMAP components should use the EventBus directly

2019-01-16 Thread btellier
JAMES-2641 IMAP components should use the EventBus directly

This enables the MailboxManager to no more be an EventBus proxy


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

Branch: refs/heads/master
Commit: 4c14a757d46267827932474f17870aea50745971
Parents: f398e3f
Author: Benoit Tellier 
Authored: Thu Jan 10 15:57:25 2019 +0700
Committer: Benoit Tellier 
Committed: Thu Jan 17 10:23:41 2019 +0700

--
 .../james/mailbox/MailboxManagerStressTest.java   | 13 -
 .../cassandra/CassandraMailboxManagerStressTest.java  | 12 
 .../mailbox/jpa/JpaMailboxManagerStressTest.java  | 14 +-
 .../DomainUserMaildirMailboxManagerStressTest.java| 11 ---
 .../FullUserMaildirMailboxManagerStressTest.java  | 12 
 .../maildir/UserMaildirMailboxManagerStressTest.java  | 12 
 .../inmemory/MemoryMailboxManagerStressTest.java  | 12 
 7 files changed, 57 insertions(+), 29 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/4c14a757/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressTest.java
--
diff --git 
a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressTest.java
 
b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressTest.java
index d769815..12dcce1 100644
--- 
a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressTest.java
+++ 
b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressTest.java
@@ -31,6 +31,8 @@ import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 
+import org.apache.james.mailbox.events.EventBus;
+import org.apache.james.mailbox.events.MailboxIdRegistrationKey;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.ComposedMessageId;
 import org.apache.james.mailbox.model.MailboxId;
@@ -41,14 +43,15 @@ import org.junit.Test;
 
 import com.google.common.collect.ImmutableSet;
 
-public abstract class MailboxManagerStressTest {
+public abstract class MailboxManagerStressTest {
 
 private static final int APPEND_OPERATIONS = 200;
 
-private MailboxManager mailboxManager;
+private T mailboxManager;
 
-protected abstract MailboxManager provideManager() throws MailboxException;
+protected abstract T provideManager() throws MailboxException;
 
+protected abstract EventBus retrieveEventBus(T mailboxManager);
 
 public void setUp() throws Exception {
 this.mailboxManager = provideManager();
@@ -66,11 +69,11 @@ public abstract class MailboxManagerStressTest {
 mailboxManager.startProcessingRequest(session);
 MailboxPath path = MailboxPath.forUser(username, "INBOX");
 MailboxId mailboxId = mailboxManager.createMailbox(path, 
session).get();
-mailboxManager.register(
+retrieveEventBus(mailboxManager).register(
 event -> {
 MessageUid u = ((MailboxListener.Added) 
event).getUids().iterator().next();
 uList.add(u);
-}, mailboxId);
+}, new MailboxIdRegistrationKey(mailboxId));
 mailboxManager.endProcessingRequest(session);
 mailboxManager.logout(session, false);
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/4c14a757/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerStressTest.java
--
diff --git 
a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerStressTest.java
 
b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerStressTest.java
index 75b7b3c..94d3092 100644
--- 
a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerStressTest.java
+++ 
b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerStressTest.java
@@ -21,16 +21,16 @@ package org.apache.james.mailbox.cassandra;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
 import org.apache.james.backends.cassandra.DockerCassandraRule;
-import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxManagerStressTest;
 import org.apache.james.mailbox.cassandra.mail.MailboxAggregateModule;
+import org.apache.james.mailbox.events.EventBus;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
 import 

[13/27] james-project git commit: JAMES-2641 Drop Delegating mailbox listener and rather use the EventBus

2019-01-16 Thread btellier
JAMES-2641 Drop Delegating mailbox listener and rather use the EventBus


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

Branch: refs/heads/master
Commit: 89f168de14d819e7c877a1907c1215d151e71feb
Parents: c82c138
Author: Benoit Tellier 
Authored: Thu Jan 10 14:16:30 2019 +0700
Committer: Benoit Tellier 
Committed: Thu Jan 17 10:23:41 2019 +0700

--
 .../james/mailbox/MailboxListenerSupport.java   |  82 
 .../apache/james/mailbox/MailboxManager.java|   3 -
 .../apache/james/mailbox/events/EventBus.java   |   4 +
 .../CacheInvalidatingMailboxListener.java   |   9 +-
 mailbox/cassandra/pom.xml   |   5 +
 .../cassandra/CassandraMailboxManager.java  |   8 +-
 .../cassandra/CassandraMessageManager.java  |  14 +--
 .../CassandraCombinationManagerTest.java|   9 +-
 .../CassandraCombinationManagerTestSystem.java  |   8 +-
 .../CassandraMailboxManagerProvider.java|  22 ++--
 ...CassandraMessageIdManagerSideEffectTest.java |   6 +-
 .../CassandraMessageIdManagerStorageTest.java   |   9 +-
 .../CassandraMessageIdManagerTestSystem.java|  14 +--
 .../cassandra/CassandraTestSystemFixture.java   |  20 +--
 .../CassandraMailboxManagerAttachmentTest.java  |  12 +-
 mailbox/elasticsearch/pom.xml   |   5 +
 .../ElasticSearchIntegrationTest.java   |  15 +--
 .../james/mailbox/events/InVMEventBus.java  |   9 +-
 mailbox/jpa/pom.xml |   5 +
 .../james/mailbox/jpa/JPAMailboxManager.java|   6 +-
 .../james/mailbox/jpa/JPAMessageManager.java|   6 +-
 .../jpa/openjpa/OpenJPAMailboxManager.java  |   8 +-
 .../jpa/openjpa/OpenJPAMessageManager.java  |   6 +-
 .../resources/META-INF/spring/mailbox-jpa.xml   |   2 +-
 .../mailbox/jpa/JpaMailboxManagerProvider.java  |  11 +-
 mailbox/lucene/pom.xml  |   5 +
 .../search/LuceneMessageSearchIndexTest.java|  15 +--
 mailbox/maildir/pom.xml |   5 +
 .../META-INF/spring/mailbox-maildir.xml |   2 +-
 .../maildir/MaildirMailboxManagerProvider.java  |  11 +-
 .../inmemory/InMemoryMailboxManager.java|   8 +-
 .../inmemory/InMemoryMessageManager.java|   6 +-
 .../META-INF/spring/mailbox-memory.xml  |   2 +-
 .../InMemoryMailboxManagerAttachmentTest.java   |  12 +-
 .../manager/InMemoryIntegrationResources.java   |  36 +++---
 .../InMemoryMessageIdManagerSideEffectTest.java |  10 +-
 mailbox/plugin/quota-mailing/pom.xml|   5 +
 .../QuotaThresholdListenersTestSystem.java  |  26 ++--
 .../search/SimpleMessageSearchIndexTest.java|   4 +-
 mailbox/spring/pom.xml  |   4 +
 .../mailbox/spring/MailboxInitializer.java  |  20 ++-
 .../resources/META-INF/spring/event-system.xml  |   6 +-
 .../main/resources/META-INF/spring/quota.xml|   2 +-
 .../META-INF/spring/spring-mailbox.xml  |   4 +-
 .../mailbox/store/StoreMailboxManager.java  |  76 ---
 .../mailbox/store/StoreMessageIdManager.java|  36 +++---
 .../mailbox/store/StoreMessageManager.java  |  52 
 .../james/mailbox/store/StoreRightManager.java  |  19 +--
 .../event/DefaultDelegatingMailboxListener.java | 126 ---
 .../store/event/DelegatingMailboxListener.java  |  27 
 .../store/event/MailboxAnnotationListener.java  |  14 ++-
 .../quota/ListeningCurrentQuotaUpdater.java |  24 ++--
 .../AbstractMessageIdManagerSideEffectTest.java |  49 
 .../store/MessageIdManagerTestSystem.java   |   6 +-
 .../mailbox/store/StoreMailboxManagerTest.java  |  10 +-
 .../mailbox/store/StoreRightManagerTest.java|   6 +-
 .../quota/ListeningCurrentQuotaUpdaterTest.java |  11 +-
 mpt/impl/imap-mailbox/cassandra/pom.xml |   5 +
 .../cassandra/host/CassandraHostSystem.java |  15 ++-
 mpt/impl/imap-mailbox/elasticsearch/pom.xml |   5 +
 .../host/ElasticSearchHostSystem.java   |  13 +-
 mpt/impl/imap-mailbox/jpa/pom.xml   |   5 +
 .../mpt/imapmailbox/jpa/host/JPAHostSystem.java |  17 +--
 mpt/impl/imap-mailbox/lucenesearch/pom.xml  |   4 +
 .../host/LuceneSearchHostSystem.java|  15 +--
 mpt/impl/imap-mailbox/maildir/pom.xml   |   5 +
 .../maildir/host/MaildirHostSystem.java |  16 ++-
 .../app/spring/JamesSpringContextTest.java  |  14 +--
 .../modules/mailbox/CassandraMailboxModule.java |   2 +-
 .../mailbox/ElasticSearchMailboxModule.java |   2 +-
 .../ElasticSearchQuotaSearcherModule.java   |   2 +-
 .../james/modules/mailbox/JPAMailboxModule.java |   2 +-
 .../james/modules/mailbox/JpaQuotaModule.java   |   2 +-
 

[jira] [Commented] (JAMES-2645) CassandraRecipientRewriteTable: refactoring to be using a DAO

2019-01-16 Thread Rene Cordier (JIRA)


[ 
https://issues.apache.org/jira/browse/JAMES-2645?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16744685#comment-16744685
 ] 

Rene Cordier commented on JAMES-2645:
-

PR : https://github.com/linagora/james-project/pull/2108

> CassandraRecipientRewriteTable: refactoring to be using a DAO
> -
>
> Key: JAMES-2645
> URL: https://issues.apache.org/jira/browse/JAMES-2645
> Project: James Server
>  Issue Type: New Feature
>Reporter: Rene Cordier
>Priority: Major
>
> Write a simple CassandraRecipientRewriteTableDAO with the current Cassandra 
> query logic currently defined in CassandraRecipientRewriteTable. (it is 
> mostly extraction)
> Add simple tests for your DAO.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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



[jira] [Created] (JAMES-2645) CassandraRecipientRewriteTable: refactoring to be using a DAO

2019-01-16 Thread Rene Cordier (JIRA)
Rene Cordier created JAMES-2645:
---

 Summary: CassandraRecipientRewriteTable: refactoring to be using a 
DAO
 Key: JAMES-2645
 URL: https://issues.apache.org/jira/browse/JAMES-2645
 Project: James Server
  Issue Type: New Feature
Reporter: Rene Cordier


Write a simple CassandraRecipientRewriteTableDAO with the current Cassandra 
query logic currently defined in CassandraRecipientRewriteTable. (it is mostly 
extraction)

Add simple tests for your DAO.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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



[jira] [Created] (JAMES-2644) Saving a malformed mail attribute Content-Type cause exception throwing

2019-01-16 Thread Gautier DI FOLCO (JIRA)
Gautier DI FOLCO created JAMES-2644:
---

 Summary: Saving a malformed mail attribute Content-Type cause 
exception throwing
 Key: JAMES-2644
 URL: https://issues.apache.org/jira/browse/JAMES-2644
 Project: James Server
  Issue Type: Bug
Reporter: Gautier DI FOLCO


When a mail with a malformed Content-Type attribute cause exception throwing:

 
{code:java}
Exception calling MailAttributesToMimeHeaders: In Content-Type string 
, expected '/', got ; 
javax.mail.internet.ParseException: In Content-Type string 
, expected '/', got ;
  at javax.mail.internet.ContentType.(ContentType.java:104)
  at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1508)
  at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1172)
  at javax.mail.internet.MimeMultipart.updateHeaders(MimeMultipart.java:522)
  at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1531)
  at javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:2271)
  at javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:2231)
  at 
org.apache.james.server.core.MimeMessageCopyOnWriteProxy.saveChanges(MimeMessageCopyOnWriteProxy.java:513)
  at 
org.apache.james.transport.mailets.MailAttributesToMimeHeaders.service(MailAttributesToMimeHeaders.java:70)
  at 
org.apache.james.mailetcontainer.impl.camel.CamelProcessor.process(CamelProcessor.java:81)
  at 
org.apache.james.mailetcontainer.impl.camel.CamelMailetProcessor$MailetContainerRouteBuilder.handleMailet(CamelMailetProcessor.java:178)
  at 
org.apache.james.mailetcontainer.impl.camel.CamelMailetProcessor$MailetContainerRouteBuilder.lambda$configure$0(CamelMailetProcessor.java:155)
  at 
org.apache.camel.processor.DelegateSyncProcessor.process(DelegateSyncProcessor.java:63)
  ...
  at 
org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:168)
  at 
org.apache.james.mailetcontainer.impl.camel.CamelMailetProcessor.service(CamelMailetProcessor.java:68)
  at 
org.apache.james.mailetcontainer.lib.AbstractStateCompositeProcessor.service(AbstractStateCompositeProcessor.java:84)
  at 
org.apache.james.mailetcontainer.impl.JamesMailSpooler.lambda$run$0(JamesMailSpooler.java:163)
  at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
  at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
  at java.lang.Thread.run(Thread.java:748)
{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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



[jira] [Commented] (MAILBOX-372) EventBus error handling

2019-01-16 Thread Tellier Benoit (JIRA)


[ 
https://issues.apache.org/jira/browse/MAILBOX-372?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16743887#comment-16743887
 ] 

Tellier Benoit commented on MAILBOX-372:


https://github.com/linagora/james-project/pull/2097 added retry backoff for the 
RabbitMQ event bus

> EventBus error handling
> ---
>
> Key: MAILBOX-372
> URL: https://issues.apache.org/jira/browse/MAILBOX-372
> Project: James Mailbox
>  Issue Type: New Feature
>Reporter: Trần Tiến Đức
>Priority: Major
>
> MailboxListener should get retried upon exceptions.
> Write EventBusContract test to demonstrate MailboxListener get retired. => 
> over contract that could be optional contract
> Implement this retry logic in the InVmDelivery + RabbitMQ eventbus with a 
> hardcoded maxRetry constant + exponential backoff.
>  
> Then try it with RabbitMQEventBus
>  
> A timeout on listener execution is more related to at least once/at most once 
> delivery concerns of the RabbitMQEventBus
>  The event bus should retry upon exceptions, with a max retry + exponential 
> backoff. That maxRetries ensures bugs do not trigger infinite loops.
>  We need a dead letter equivalent for audit/rescheduling purposes.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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



[2/3] james-project git commit: MAILBOX-372 RetryBackoff POJO

2019-01-16 Thread btellier
MAILBOX-372 RetryBackoff POJO


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

Branch: refs/heads/master
Commit: 2c60acb3cba479d1c2d5df67937cc29cee51add4
Parents: 4cdfef0
Author: tran tien duc 
Authored: Tue Jan 15 14:54:18 2019 +0700
Committer: tran tien duc 
Committed: Wed Jan 16 14:07:50 2019 +0700

--
 .../james/mailbox/events/RetryBackoff.java  | 110 +++
 1 file changed, 110 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/2c60acb3/mailbox/api/src/main/java/org/apache/james/mailbox/events/RetryBackoff.java
--
diff --git 
a/mailbox/api/src/main/java/org/apache/james/mailbox/events/RetryBackoff.java 
b/mailbox/api/src/main/java/org/apache/james/mailbox/events/RetryBackoff.java
new file mode 100644
index 000..2fa15ad
--- /dev/null
+++ 
b/mailbox/api/src/main/java/org/apache/james/mailbox/events/RetryBackoff.java
@@ -0,0 +1,110 @@
+/
+ * 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.mailbox.events;
+
+import java.time.Duration;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Preconditions;
+
+class RetryBackoff {
+
+@FunctionalInterface
+interface RequireMaxRetries {
+RequireFirstBackoff maxRetries(int maxRetries);
+}
+
+@FunctionalInterface
+interface RequireFirstBackoff {
+RequireJitterFactor firstBackoff(Duration firstBackoff);
+}
+
+@FunctionalInterface
+interface RequireJitterFactor {
+ReadyToBuild jitterFactor(double jitterFactor);
+}
+
+static class ReadyToBuild {
+private final int maxRetries;
+private final Duration firstBackoff;
+private final double jitterFactor;
+
+private ReadyToBuild(int maxRetries, Duration firstBackoff, double 
jitterFactor) {
+this.maxRetries = maxRetries;
+this.firstBackoff = firstBackoff;
+this.jitterFactor = jitterFactor;
+}
+
+RetryBackoff build() {
+return new RetryBackoff(maxRetries, firstBackoff, jitterFactor);
+}
+}
+
+static RequireMaxRetries builder() {
+return maxRetries -> firstBackoff -> jitterFactor -> new 
ReadyToBuild(maxRetries, firstBackoff, jitterFactor);
+}
+
+static RetryBackoff defaultRetryBackoff() {
+return builder()
+.maxRetries(DEFAULT_MAX_RETRIES)
+.firstBackoff(DEFAULT_FIRST_BACKOFF)
+.jitterFactor(DEFAULT_JITTER_FACTOR)
+.build();
+}
+
+private static final double DEFAULT_JITTER_FACTOR = 0.5;
+private static final int DEFAULT_MAX_RETRIES = 3;
+private static final Duration DEFAULT_FIRST_BACKOFF = 
Duration.ofMillis(100);
+
+private final int maxRetries;
+private final Duration firstBackoff;
+private final double jitterFactor;
+
+RetryBackoff(int maxRetries, Duration firstBackoff, double jitterFactor) {
+Preconditions.checkArgument(!firstBackoff.isNegative() && 
!firstBackoff.isZero(), "firstBackoff has to be strictly positive");
+Preconditions.checkArgument(maxRetries > 0, "maxRetries has to be 
strictly positive");
+Preconditions.checkArgument(jitterFactor > 0, "jitterFactor has to be 
strictly positive");
+
+this.maxRetries = maxRetries;
+this.firstBackoff = firstBackoff;
+this.jitterFactor = jitterFactor;
+}
+
+public int 

[3/3] james-project git commit: MAILBOX-372 handle retrying for event group consumers

2019-01-16 Thread btellier
MAILBOX-372 handle retrying for event group consumers


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

Branch: refs/heads/master
Commit: 1f390f4f3f69db1c073b5e018b25cdf52acb3647
Parents: bd656cf
Author: tran tien duc 
Authored: Tue Jan 15 14:58:45 2019 +0700
Committer: tran tien duc 
Committed: Wed Jan 16 14:21:28 2019 +0700

--
 .../james/mailbox/events/RetryBackoff.java  | 110 ---
 .../events/RetryBackoffConfiguration.java   | 125 +
 .../mailbox/events/ErrorHandlingContract.java   |  45 --
 .../mailbox/events/EventBusTestFixture.java |   4 +-
 .../events/RetryBackoffConfigurationTest.java   | 140 +++
 .../mailbox/events/GroupConsumerRetry.java  | 133 ++
 .../james/mailbox/events/GroupRegistration.java |  62 +---
 .../events/GroupRegistrationHandler.java|   5 +-
 .../james/mailbox/events/RabbitMQEventBus.java  |   8 +-
 .../mailbox/events/WaitDelayGenerator.java  |  18 ++-
 .../mailbox/events/RabbitMQEventBusTest.java|  26 +++-
 .../mailbox/events/WaitDelayGeneratorTest.java  |  49 ++-
 12 files changed, 565 insertions(+), 160 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/1f390f4f/mailbox/api/src/main/java/org/apache/james/mailbox/events/RetryBackoff.java
--
diff --git 
a/mailbox/api/src/main/java/org/apache/james/mailbox/events/RetryBackoff.java 
b/mailbox/api/src/main/java/org/apache/james/mailbox/events/RetryBackoff.java
deleted file mode 100644
index 2fa15ad..000
--- 
a/mailbox/api/src/main/java/org/apache/james/mailbox/events/RetryBackoff.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/
- * 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.mailbox.events;
-
-import java.time.Duration;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
-
-class RetryBackoff {
-
-@FunctionalInterface
-interface RequireMaxRetries {
-RequireFirstBackoff maxRetries(int maxRetries);
-}
-
-@FunctionalInterface
-interface RequireFirstBackoff {
-RequireJitterFactor firstBackoff(Duration firstBackoff);
-}
-
-@FunctionalInterface
-interface RequireJitterFactor {
-ReadyToBuild jitterFactor(double jitterFactor);
-}
-
-static class ReadyToBuild {
-private final int maxRetries;
-private final Duration firstBackoff;
-private final double jitterFactor;
-
-private ReadyToBuild(int maxRetries, Duration firstBackoff, double 
jitterFactor) {
-this.maxRetries = maxRetries;
-this.firstBackoff = firstBackoff;
-this.jitterFactor = jitterFactor;
-}
-
-RetryBackoff build() {
-return new RetryBackoff(maxRetries, firstBackoff, jitterFactor);
-}
-}
-
-static RequireMaxRetries builder() {
-return maxRetries -> firstBackoff -> jitterFactor -> new 
ReadyToBuild(maxRetries, firstBackoff, jitterFactor);
-}
-
-static RetryBackoff defaultRetryBackoff() {
-return builder()
-.maxRetries(DEFAULT_MAX_RETRIES)
-.firstBackoff(DEFAULT_FIRST_BACKOFF)
-.jitterFactor(DEFAULT_JITTER_FACTOR)
-.build();
-}
-
-private static final double DEFAULT_JITTER_FACTOR = 0.5;
-private static final int DEFAULT_MAX_RETRIES = 3;
-private static final Duration 

[1/3] james-project git commit: MAILBOX-372 generating wait delay in WaitDelayGenerator

2019-01-16 Thread btellier
Repository: james-project
Updated Branches:
  refs/heads/master 4cdfef08a -> 1f390f4f3


MAILBOX-372 generating wait delay in WaitDelayGenerator


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

Branch: refs/heads/master
Commit: bd656cf888086b4bfb6caae401746287f2e8eedc
Parents: 2c60acb
Author: tran tien duc 
Authored: Tue Jan 15 14:56:03 2019 +0700
Committer: tran tien duc 
Committed: Wed Jan 16 14:07:50 2019 +0700

--
 .../mailbox/events/WaitDelayGenerator.java  | 71 
 .../mailbox/events/WaitDelayGeneratorTest.java  | 58 
 2 files changed, 129 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/james-project/blob/bd656cf8/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/WaitDelayGenerator.java
--
diff --git 
a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/WaitDelayGenerator.java
 
b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/WaitDelayGenerator.java
new file mode 100644
index 000..fdcf9cc
--- /dev/null
+++ 
b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/WaitDelayGenerator.java
@@ -0,0 +1,71 @@
+/
+ * 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.mailbox.events;
+
+import java.security.SecureRandom;
+import java.time.Duration;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+
+import reactor.core.publisher.Mono;
+
+class WaitDelayGenerator {
+
+static WaitDelayGenerator of(RetryBackoff retryBackoff) {
+return new WaitDelayGenerator(retryBackoff);
+}
+
+private static int randomBetween(int lowest, int highest) {
+Preconditions.checkArgument(lowest <= highest, "lowest always has to 
be less than or equals highest");
+return SECURE_RANDOM.nextInt(highest - lowest) + lowest;
+}
+
+private static final SecureRandom SECURE_RANDOM = new SecureRandom();
+
+private final RetryBackoff retryBackoff;
+
+private WaitDelayGenerator(RetryBackoff retryBackoff) {
+this.retryBackoff = retryBackoff;
+}
+
+Mono delayIfHaveTo(int retryCount) {
+Mono countRetryMono = Mono.just(retryCount);
+if (retryCount < 1) {
+return countRetryMono;
+}
+
+return countRetryMono
+.filter(count -> count <= retryBackoff.getMaxRetries())
+.delayElement(generateDelay(retryCount));
+}
+
+@VisibleForTesting
+Duration generateDelay(int retryCount) {
+if (retryCount < 1) {
+return Duration.ZERO;
+}
+int exponentialFactor = Double.valueOf(Math.pow(2, retryCount - 
1)).intValue();
+int minDelay = exponentialFactor * (int) 
retryBackoff.getFirstBackoff().toMillis();
+int maxDelay = Double.valueOf(minDelay + minDelay * 
retryBackoff.getJitterFactor()).intValue();
+
+return Duration.ofMillis(randomBetween(minDelay, maxDelay));
+}
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/bd656cf8/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/WaitDelayGeneratorTest.java
--
diff --git 
a/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/WaitDelayGeneratorTest.java
 

[jira] [Created] (JAMES-2643) Optimize listing mapping by destination on top of JPA

2019-01-16 Thread Tellier Benoit (JIRA)
Tellier Benoit created JAMES-2643:
-

 Summary: Optimize listing mapping by destination on top of JPA
 Key: JAMES-2643
 URL: https://issues.apache.org/jira/browse/JAMES-2643
 Project: James Server
  Issue Type: Improvement
  Components: data, jpa
Reporter: Tellier Benoit


In `JPARecipientRewriteTable` implement the listSources method defined in 
JAMES-2596 : map it to an SQL query

Tests should still pass.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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



[jira] [Commented] (JAMES-2642) Alias integration tests

2019-01-16 Thread Rene Cordier (JIRA)


[ 
https://issues.apache.org/jira/browse/JAMES-2642?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16743732#comment-16743732
 ] 

Rene Cordier commented on JAMES-2642:
-

PR : https://github.com/linagora/james-project/pull/2105

> Alias integration tests
> ---
>
> Key: JAMES-2642
> URL: https://issues.apache.org/jira/browse/JAMES-2642
> Project: James Server
>  Issue Type: New Feature
>  Components: integrationTests
>Reporter: Rene Cordier
>Priority: Major
>
> In /server/mailet/integration-testing write integration tests for the alias 
> feature
> *Basic*
> {code:java}
> Given b...@domain.tld with a bob-al...@domain.tld alias
> When al...@domain.tld sends a mail to bob-al...@domain.tld
> Then b...@domain.tld receives it{code}
> *Forward compatibility*
> Forwards are handled for users with alias
> {code:java}
> Given b...@domain.tld with a bob-al...@domain.tld alias
> And b...@domain.tld is forwarding emails to ce...@domain.tld
> When al...@domain.tld sends a mail to bob-al...@domain.tld
> Then ced...@domain.tld receives it{code}
> I can forward an email to a user with an alias
> {code:java}
> Given b...@domain.tld with a bob-al...@domain.tld alias
> And al...@domain.tld is forwarding emails to bob-al...@domain.tld
> When ced...@domain.tld is sending an email to al...@domain.tld
> Then b...@domain.tld receives it{code}
> *Group compatibility*
> A user can register in a group via his alias
> {code:java}
> Given b...@domain.tld with a bob-al...@domain.tld alias
> And a group gr...@domain.tld with bob-al...@domain.tld as a member
> When al...@domain.tld is sending an email to gr...@domain.tld
> Then b...@domain.tld receives it{code}
> A group can have an alias
> {code:java}
> Given a group gr...@domain.tld with b...@domain.tld as a member
> And I create a group-al...@domain.tld for gr...@domain.tld
> When al...@domain.tld is sending an email to group-al...@domain.tld
> Then b...@domain.tld receives it{code}
> *Cascading aliases*
> {code:java}
> Given b...@domain.tld with a bob-ali...@domain.tld alias
> And bob-ali...@domain.tld with a bob-ali...@domain.tld alias
> When al...@domain.tld is sending an email to bob-ali...@domain.tld
> Then b...@domain.tld receives the mail{code}
>  
> *Corner cases*
> Several users can have the same alias.
> {code:java}
> Alice create al...@domain.tld
> Bob create al...@domain.tld
> When Cedric sends a mail to al...@domain.com
> Then Alice and Bob receives it{code}
> +Note+: we can not prevent bob and alice from having the same alias easily



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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