You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2017/11/03 02:33:18 UTC
[01/15] james-project git commit: MAILBOX-317 Rework
InMemoryMailboxManager constructor
Repository: james-project
Updated Branches:
refs/heads/master 541dbc384 -> 99c181977
MAILBOX-317 Rework InMemoryMailboxManager constructor
Passing the event system should not be optional. And It should not be class concern to init the right system.
In the operation:
- Delete one constructor
- Implement logic in only one constructor (the other should only call it)
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/f879859b
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/f879859b
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/f879859b
Branch: refs/heads/master
Commit: f879859b2e77bcc5064850c25ba7551b9080529b
Parents: b3eb1b2
Author: benwa <bt...@linagora.com>
Authored: Thu Nov 2 09:13:19 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Fri Nov 3 09:32:31 2017 +0700
----------------------------------------------------------------------
.../elasticsearch/ElasticSearchIntegrationTest.java | 7 ++++---
.../lucene/search/LuceneMessageSearchIndexTest.java | 8 +++++---
.../james/mailbox/inmemory/InMemoryMailboxManager.java | 5 -----
.../mail/InMemoryMailboxManagerAttachmentTest.java | 11 ++++++++---
.../inmemory/manager/InMemoryIntegrationResources.java | 9 ++++++++-
.../store/search/SimpleMessageSearchIndexTest.java | 8 +++++---
.../imapmailbox/inmemory/host/InMemoryHostSystem.java | 8 +++++++-
.../apache/james/transport/matchers/IsOverQuotaTest.java | 11 ++++++++---
8 files changed, 45 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/f879859b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
index cf3a9cc..d91e755 100644
--- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
+++ b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
@@ -136,6 +136,8 @@ public class ElasticSearchIntegrationTest extends AbstractMessageSearchIndexTest
MailboxElasticSearchConstants.DEFAULT_MAILBOX_READ_ALIAS,
MailboxElasticSearchConstants.MESSAGE_TYPE),
new MessageToElasticSearchJson(textExtractor, ZoneId.of("Europe/Paris"), IndexAttachments.YES));
+ DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
storeMailboxManager = new InMemoryMailboxManager(
mapperFactory,
new FakeAuthenticator(),
@@ -143,10 +145,9 @@ public class ElasticSearchIntegrationTest extends AbstractMessageSearchIndexTest
new JVMMailboxPathLocker(),
new MessageParser(),
messageIdFactory,
+ mailboxEventDispatcher,
+ delegatingListener,
storeRightManager);
- DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
- MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
- storeMailboxManager.setDelegatingMailboxListener(delegatingListener);
messageIdManager = new StoreMessageIdManager(
storeMailboxManager,
http://git-wip-us.apache.org/repos/asf/james-project/blob/f879859b/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java
----------------------------------------------------------------------
diff --git a/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java b/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java
index c66bd57..2c6daaa 100644
--- a/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java
+++ b/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java
@@ -54,6 +54,9 @@ public class LuceneMessageSearchIndexTest extends AbstractMessageSearchIndexTest
UnionMailboxACLResolver aclResolver = new UnionMailboxACLResolver();
SimpleGroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
StoreRightManager storeRightManager = new StoreRightManager(mapperFactory, aclResolver, groupMembershipResolver);
+
+ DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
storeMailboxManager = new InMemoryMailboxManager(
mapperFactory,
new FakeAuthenticator(),
@@ -61,10 +64,9 @@ public class LuceneMessageSearchIndexTest extends AbstractMessageSearchIndexTest
new JVMMailboxPathLocker(),
new MessageParser(),
messageIdFactory,
+ mailboxEventDispatcher,
+ delegatingListener,
storeRightManager);
- DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
- MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
- storeMailboxManager.setDelegatingMailboxListener(delegatingListener);
messageIdManager = new StoreMessageIdManager(
storeMailboxManager,
http://git-wip-us.apache.org/repos/asf/james-project/blob/f879859b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManager.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManager.java b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManager.java
index 99dffd2..07f8f8a 100644
--- a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManager.java
+++ b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManager.java
@@ -51,11 +51,6 @@ public class InMemoryMailboxManager extends StoreMailboxManager {
delegatingMailboxListener, storeRightManager);
}
- public InMemoryMailboxManager(MailboxSessionMapperFactory mailboxSessionMapperFactory, Authenticator authenticator, Authorizator authorizator,
- MailboxPathLocker locker, MessageParser messageParser, MessageId.Factory messageIdFactory, StoreRightManager storeRightManager) {
- super(mailboxSessionMapperFactory, authenticator, authorizator, locker, messageParser, messageIdFactory, storeRightManager);
- }
-
public InMemoryMailboxManager(MailboxSessionMapperFactory mailboxSessionMapperFactory, Authenticator authenticator, Authorizator authorizator,
MessageParser messageParser, MessageId.Factory messageIdFactory,
int limitOfAnnotations, int limitAnnotationSize,
http://git-wip-us.apache.org/repos/asf/james-project/blob/f879859b/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 92bc78d..56ea10a 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
@@ -38,6 +38,8 @@ import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
import org.apache.james.mailbox.store.NoMailboxPathLocker;
import org.apache.james.mailbox.store.StoreRightManager;
+import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
+import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.AttachmentMapperFactory;
import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
import org.junit.Before;
@@ -58,14 +60,17 @@ public class InMemoryMailboxManagerAttachmentTest extends AbstractMailboxManager
GroupMembershipResolver groupMembershipResolver = null;
UnionMailboxACLResolver aclResolver = new UnionMailboxACLResolver();
StoreRightManager storeRightManager = new StoreRightManager(mailboxSessionMapperFactory, aclResolver, groupMembershipResolver);
- mailboxManager = new InMemoryMailboxManager(mailboxSessionMapperFactory, noAuthenticator, noAuthorizator, new NoMailboxPathLocker(),
- new MessageParser(), messageIdFactory, storeRightManager);
+
+ DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
+ mailboxManager = new InMemoryMailboxManager(mailboxSessionMapperFactory, noAuthenticator, noAuthorizator, new NoMailboxPathLocker(),
+ new MessageParser(), messageIdFactory, mailboxEventDispatcher, delegatingListener, storeRightManager);
mailboxManager.init();
MessageParser failingMessageParser = mock(MessageParser.class);
when(failingMessageParser.retrieveAttachments(any(InputStream.class)))
.thenThrow(new RuntimeException("Message parser set to fail"));
parseFailingMailboxManager = new InMemoryMailboxManager(mailboxSessionMapperFactory, noAuthenticator, noAuthorizator, new NoMailboxPathLocker(),
- failingMessageParser, messageIdFactory, storeRightManager);
+ failingMessageParser, messageIdFactory, mailboxEventDispatcher, delegatingListener, storeRightManager);
parseFailingMailboxManager.init();
super.setUp();
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f879859b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
index f560727..536751e 100644
--- a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
+++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
@@ -40,6 +40,8 @@ import org.apache.james.mailbox.store.NoMailboxPathLocker;
import org.apache.james.mailbox.store.StoreMailboxManager;
import org.apache.james.mailbox.store.StoreMessageIdManager;
import org.apache.james.mailbox.store.StoreRightManager;
+import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
+import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
import org.apache.james.mailbox.store.quota.CurrentQuotaCalculator;
import org.apache.james.mailbox.store.quota.DefaultQuotaRootResolver;
@@ -58,13 +60,18 @@ public class InMemoryIntegrationResources implements IntegrationResources<StoreM
fakeAuthenticator.addUser(ManagerTestResources.OTHER_USER, ManagerTestResources.OTHER_USER_PASS);
InMemoryMailboxSessionMapperFactory mailboxSessionMapperFactory = new InMemoryMailboxSessionMapperFactory();
StoreRightManager storeRightManager = new StoreRightManager(mailboxSessionMapperFactory, new UnionMailboxACLResolver(), groupMembershipResolver);
- final StoreMailboxManager manager = new InMemoryMailboxManager(
+
+ DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
+ StoreMailboxManager manager = new InMemoryMailboxManager(
mailboxSessionMapperFactory,
fakeAuthenticator,
FakeAuthorizator.defaultReject(),
new NoMailboxPathLocker(),
new MessageParser(),
new InMemoryMessageId.Factory(),
+ mailboxEventDispatcher,
+ delegatingListener,
storeRightManager);
manager.init();
return manager;
http://git-wip-us.apache.org/repos/asf/james-project/blob/f879859b/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java
----------------------------------------------------------------------
diff --git a/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java b/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java
index 31e35f0..e28f558 100644
--- a/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java
+++ b/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java
@@ -53,6 +53,9 @@ public class SimpleMessageSearchIndexTest extends AbstractMessageSearchIndexTest
UnionMailboxACLResolver aclResolver = new UnionMailboxACLResolver();
SimpleGroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
StoreRightManager storeRightManager = new StoreRightManager(mapperFactory, aclResolver, groupMembershipResolver);
+
+ DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
storeMailboxManager = new InMemoryMailboxManager(
mapperFactory,
new FakeAuthenticator(),
@@ -60,10 +63,9 @@ public class SimpleMessageSearchIndexTest extends AbstractMessageSearchIndexTest
new JVMMailboxPathLocker(),
new MessageParser(),
messageIdFactory,
+ mailboxEventDispatcher,
+ delegatingListener,
storeRightManager);
- DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
- MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(new DefaultDelegatingMailboxListener());
- storeMailboxManager.setDelegatingMailboxListener(delegatingListener);
messageIdManager = new StoreMessageIdManager(
storeMailboxManager,
http://git-wip-us.apache.org/repos/asf/james-project/blob/f879859b/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryHostSystem.java b/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryHostSystem.java
index 56451ee..0cac457 100644
--- a/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryHostSystem.java
+++ b/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryHostSystem.java
@@ -38,6 +38,8 @@ import org.apache.james.mailbox.quota.QuotaRootResolver;
import org.apache.james.mailbox.store.JVMMailboxPathLocker;
import org.apache.james.mailbox.store.StoreRightManager;
import org.apache.james.mailbox.store.StoreSubscriptionManager;
+import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
+import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
import org.apache.james.mailbox.store.quota.CurrentQuotaCalculator;
import org.apache.james.mailbox.store.quota.DefaultQuotaRootResolver;
@@ -72,8 +74,12 @@ public class InMemoryHostSystem extends JamesImapHostSystem {
InMemoryMailboxSessionMapperFactory mailboxSessionMapperFactory = new InMemoryMailboxSessionMapperFactory();
StoreRightManager storeRightManager = new StoreRightManager(mailboxSessionMapperFactory, aclResolver, groupMembershipResolver);
+
+ DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
mailboxManager = new InMemoryMailboxManager(mailboxSessionMapperFactory, authenticator, authorizator,
- new JVMMailboxPathLocker(), messageParser, new InMemoryMessageId.Factory(), storeRightManager);
+ new JVMMailboxPathLocker(), messageParser, new InMemoryMessageId.Factory(),
+ mailboxEventDispatcher, delegatingListener, storeRightManager);
QuotaRootResolver quotaRootResolver = new DefaultQuotaRootResolver(mailboxManager.getMapperFactory());
perUserMaxQuotaManager = new InMemoryPerUserMaxQuotaManager();
http://git-wip-us.apache.org/repos/asf/james-project/blob/f879859b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsOverQuotaTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsOverQuotaTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsOverQuotaTest.java
index ac46f78..c18771b 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsOverQuotaTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsOverQuotaTest.java
@@ -25,6 +25,7 @@ import static org.mockito.Mockito.when;
import java.util.Collection;
+import org.apache.james.core.MailAddress;
import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
import org.apache.james.mailbox.inmemory.InMemoryMailboxManager;
@@ -38,12 +39,13 @@ import org.apache.james.mailbox.store.FakeAuthenticator;
import org.apache.james.mailbox.store.FakeAuthorizator;
import org.apache.james.mailbox.store.NoMailboxPathLocker;
import org.apache.james.mailbox.store.StoreRightManager;
+import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
+import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
import org.apache.james.mailbox.store.quota.CurrentQuotaCalculator;
import org.apache.james.mailbox.store.quota.DefaultQuotaRootResolver;
import org.apache.james.mailbox.store.quota.StoreQuotaManager;
import org.apache.james.user.api.UsersRepository;
-import org.apache.james.core.MailAddress;
import org.apache.mailet.base.MailAddressFixture;
import org.apache.mailet.base.test.FakeMail;
import org.apache.mailet.base.test.FakeMatcherConfig;
@@ -61,10 +63,13 @@ public class IsOverQuotaTest {
public void setUp() throws Exception {
InMemoryMailboxSessionMapperFactory factory = new InMemoryMailboxSessionMapperFactory();
StoreRightManager storeRightManager = new StoreRightManager(factory, new UnionMailboxACLResolver(), new SimpleGroupMembershipResolver());
+
+ DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
mailboxManager = new InMemoryMailboxManager(factory, new FakeAuthenticator(), FakeAuthorizator.defaultReject(),
new NoMailboxPathLocker(), new MessageParser(),
- new InMemoryMessageId.Factory(),
- storeRightManager);
+ new InMemoryMessageId.Factory(), mailboxEventDispatcher,
+ delegatingListener, storeRightManager);
quotaRootResolver = new DefaultQuotaRootResolver(factory);
maxQuotaManager = new InMemoryPerUserMaxQuotaManager();
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[03/15] james-project git commit: Fix unused imports
Posted by bt...@apache.org.
Fix unused imports
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/4e1be59d
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/4e1be59d
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/4e1be59d
Branch: refs/heads/master
Commit: 4e1be59d26e91f32b6ea0b88b80f308dc7ef43e7
Parents: 541dbc3
Author: benwa <bt...@linagora.com>
Authored: Thu Nov 2 13:24:47 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Fri Nov 3 09:32:31 2017 +0700
----------------------------------------------------------------------
.../org/apache/james/mailbox/store/mail/model/FlagsFactoryTest.java | 1 -
1 file changed, 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/4e1be59d/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/FlagsFactoryTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/FlagsFactoryTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/FlagsFactoryTest.java
index 0f99ca1..8833037 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/FlagsFactoryTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/FlagsFactoryTest.java
@@ -19,7 +19,6 @@
package org.apache.james.mailbox.store.mail.model;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
import javax.mail.Flags;
import javax.mail.Flags.Flag;
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[06/15] james-project git commit: MAILBOX-317 Bonus: Avoid using a
null system session during required listener registration
Posted by bt...@apache.org.
MAILBOX-317 Bonus: Avoid using a null system session during required listener 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/b9be0917
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/b9be0917
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/b9be0917
Branch: refs/heads/master
Commit: b9be0917af11b2e20d8ada13a97902426b92e61b
Parents: ce3583a
Author: benwa <bt...@linagora.com>
Authored: Thu Nov 2 13:03:14 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Fri Nov 3 09:32:32 2017 +0700
----------------------------------------------------------------------
.../james/mailbox/store/StoreMailboxManager.java | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/b9be0917/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 c13248d..b4f6433 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
@@ -206,15 +206,15 @@ public class StoreMailboxManager implements MailboxManager {
*/
@PostConstruct
public void init() throws MailboxException {
+ if (idGenerator == null) {
+ idGenerator = new RandomMailboxSessionIdGenerator();
+ }
+ MailboxSession session = createSystemSession("storeMailboxManager");
if (index == null) {
index = new SimpleMessageSearchIndex(mailboxSessionMapperFactory, mailboxSessionMapperFactory, new DefaultTextExtractor());
}
if (index instanceof ListeningMessageSearchIndex) {
- this.addGlobalListener((MailboxListener) index, null);
- }
-
- if (idGenerator == null) {
- idGenerator = new RandomMailboxSessionIdGenerator();
+ this.addGlobalListener((MailboxListener) index, session);
}
if (quotaManager == null) {
quotaManager = new NoQuotaManager();
@@ -223,7 +223,7 @@ public class StoreMailboxManager implements MailboxManager {
quotaRootResolver = new DefaultQuotaRootResolver(mailboxSessionMapperFactory);
}
if (quotaUpdater != null && quotaUpdater instanceof MailboxListener) {
- this.addGlobalListener((MailboxListener) quotaUpdater, null);
+ this.addGlobalListener((MailboxListener) quotaUpdater, session);
}
if (copyBatcher == null) {
copyBatcher = new MessageBatcher(MessageBatcher.NO_BATCH_SIZE);
@@ -232,7 +232,6 @@ public class StoreMailboxManager implements MailboxManager {
moveBatcher = new MessageBatcher(MessageBatcher.NO_BATCH_SIZE);
}
if (hasCapability(MailboxCapabilities.Annotation)) {
- MailboxSession session = null;
this.addGlobalListener(new MailboxAnnotationListener(mailboxSessionMapperFactory), session);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[12/15] james-project git commit: MAILBOX-317 Add a
MailboxAnnotationManager
Posted by bt...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/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 dadc77c..c53da61 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
@@ -30,6 +30,7 @@ import java.util.stream.Stream;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
+import org.apache.james.mailbox.MailboxAnnotationManager;
import org.apache.james.mailbox.MailboxListener;
import org.apache.james.mailbox.MailboxManager;
import org.apache.james.mailbox.MailboxPathLocker;
@@ -40,7 +41,6 @@ import org.apache.james.mailbox.MailboxSessionIdGenerator;
import org.apache.james.mailbox.MessageManager;
import org.apache.james.mailbox.RequestAware;
import org.apache.james.mailbox.StandardMailboxMetaDataComparator;
-import org.apache.james.mailbox.exception.AnnotationException;
import org.apache.james.mailbox.exception.BadCredentialsException;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.exception.MailboxExistsException;
@@ -69,7 +69,6 @@ import org.apache.james.mailbox.store.event.DelegatingMailboxListener;
import org.apache.james.mailbox.store.event.MailboxAnnotationListener;
import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.extractor.DefaultTextExtractor;
-import org.apache.james.mailbox.store.mail.AnnotationMapper;
import org.apache.james.mailbox.store.mail.MailboxMapper;
import org.apache.james.mailbox.store.mail.model.Mailbox;
import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
@@ -108,6 +107,7 @@ public class StoreMailboxManager implements MailboxManager {
private final MailboxSessionMapperFactory mailboxSessionMapperFactory;
private final Authenticator authenticator;
+ private final MailboxAnnotationManager annotationManager;
private Authorizator authorizator;
@@ -135,23 +135,15 @@ public class StoreMailboxManager implements MailboxManager {
private final MessageParser messageParser;
private final Factory messageIdFactory;
- private final int limitOfAnnotations;
- private final int limitAnnotationSize;
private final ImmutableMailboxMessage.Factory immutableMailboxMessageFactory;
@Inject
- public StoreMailboxManager(MailboxSessionMapperFactory mailboxSessionMapperFactory, Authenticator authenticator, Authorizator authorizator,
- MailboxPathLocker locker, MessageParser messageParser, MessageId.Factory messageIdFactory, MailboxEventDispatcher mailboxEventDispatcher,
- DelegatingMailboxListener delegatingListener, StoreRightManager storeRightManager) {
- this(mailboxSessionMapperFactory, authenticator, authorizator, locker, messageParser, messageIdFactory,
- MailboxConstants.DEFAULT_LIMIT_ANNOTATIONS_ON_MAILBOX, MailboxConstants.DEFAULT_LIMIT_ANNOTATION_SIZE, mailboxEventDispatcher,
- delegatingListener, storeRightManager);
- }
-
public StoreMailboxManager(MailboxSessionMapperFactory mailboxSessionMapperFactory, Authenticator authenticator, Authorizator authorizator,
MailboxPathLocker locker, MessageParser messageParser,
- MessageId.Factory messageIdFactory, int limitOfAnnotations, int limitAnnotationSize, MailboxEventDispatcher mailboxEventDispatcher,
+ MessageId.Factory messageIdFactory, MailboxAnnotationManager annotationManager,
+ MailboxEventDispatcher mailboxEventDispatcher,
DelegatingMailboxListener delegatingListener, StoreRightManager storeRightManager) {
+ this.annotationManager = annotationManager;
Preconditions.checkNotNull(delegatingListener);
Preconditions.checkNotNull(mailboxEventDispatcher);
this.authenticator = authenticator;
@@ -160,15 +152,13 @@ public class StoreMailboxManager implements MailboxManager {
this.mailboxSessionMapperFactory = mailboxSessionMapperFactory;
this.messageParser = messageParser;
this.messageIdFactory = messageIdFactory;
- this.limitOfAnnotations = limitOfAnnotations;
- this.limitAnnotationSize = limitAnnotationSize;
this.delegatingListener = delegatingListener;
this.dispatcher = mailboxEventDispatcher;
this.immutableMailboxMessageFactory = new ImmutableMailboxMessage.Factory(this);
this.storeRightManager = storeRightManager;
}
- protected Factory getMessageIdFactory() {
+ public Factory getMessageIdFactory() {
return messageIdFactory;
}
@@ -819,50 +809,21 @@ public class StoreMailboxManager implements MailboxManager {
@Override
public List<MailboxAnnotation> getAllAnnotations(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
- final AnnotationMapper annotationMapper = mailboxSessionMapperFactory.getAnnotationMapper(session);
- final MailboxId mailboxId = getMailbox(mailboxPath, session).getId();
-
- return annotationMapper.execute(
- () -> annotationMapper.getAllAnnotations(mailboxId));
+ return annotationManager.getAllAnnotations(mailboxPath, session);
}
@Override
- public List<MailboxAnnotation> getAnnotationsByKeys(MailboxPath mailboxPath, MailboxSession session, final Set<MailboxAnnotationKey> keys)
+ public List<MailboxAnnotation> getAnnotationsByKeys(MailboxPath mailboxPath, MailboxSession session, Set<MailboxAnnotationKey> keys)
throws MailboxException {
- final AnnotationMapper annotationMapper = mailboxSessionMapperFactory.getAnnotationMapper(session);
- final MailboxId mailboxId = getMailbox(mailboxPath, session).getId();
-
- return annotationMapper.execute(
- () -> annotationMapper.getAnnotationsByKeys(mailboxId, keys));
+ return annotationManager.getAnnotationsByKeys(mailboxPath, session, keys);
}
@Override
- public void updateAnnotations(MailboxPath mailboxPath, MailboxSession session, final List<MailboxAnnotation> mailboxAnnotations)
+ public void updateAnnotations(MailboxPath mailboxPath, MailboxSession session, List<MailboxAnnotation> mailboxAnnotations)
throws MailboxException {
- final AnnotationMapper annotationMapper = mailboxSessionMapperFactory.getAnnotationMapper(session);
- final MailboxId mailboxId = getMailbox(mailboxPath, session).getId();
-
- annotationMapper.execute(Mapper.toTransaction(() -> {
- for (MailboxAnnotation annotation : mailboxAnnotations) {
- if (annotation.isNil()) {
- annotationMapper.deleteAnnotation(mailboxId, annotation.getKey());
- } else if (canInsertOrUpdate(mailboxId, annotation, annotationMapper)) {
- annotationMapper.insertAnnotation(mailboxId, annotation);
- }
- }
- }));
+ annotationManager.updateAnnotations(mailboxPath, session, mailboxAnnotations);
}
- private boolean canInsertOrUpdate(MailboxId mailboxId, MailboxAnnotation annotation, AnnotationMapper annotationMapper) throws AnnotationException {
- if (annotation.size() > limitAnnotationSize) {
- throw new AnnotationException("annotation too big.");
- }
- if (!annotationMapper.exist(mailboxId, annotation)
- && annotationMapper.countAnnotations(mailboxId) >= limitOfAnnotations) {
- throw new AnnotationException("too many annotations.");
- }
- return true;
- }
@Override
public boolean hasCapability(MailboxCapabilities capability) {
@@ -871,22 +832,14 @@ public class StoreMailboxManager implements MailboxManager {
@Override
public List<MailboxAnnotation> getAnnotationsByKeysWithOneDepth(MailboxPath mailboxPath, MailboxSession session,
- final Set<MailboxAnnotationKey> keys) throws MailboxException {
- final AnnotationMapper annotationMapper = mailboxSessionMapperFactory.getAnnotationMapper(session);
- final MailboxId mailboxId = getMailbox(mailboxPath, session).getId();
-
- return annotationMapper.execute(
- () -> annotationMapper.getAnnotationsByKeysWithOneDepth(mailboxId, keys));
+ Set<MailboxAnnotationKey> keys) throws MailboxException {
+ return annotationManager.getAnnotationsByKeysWithOneDepth(mailboxPath, session, keys);
}
@Override
public List<MailboxAnnotation> getAnnotationsByKeysWithAllDepth(MailboxPath mailboxPath, MailboxSession session,
- final Set<MailboxAnnotationKey> keys) throws MailboxException {
- final AnnotationMapper annotationMapper = mailboxSessionMapperFactory.getAnnotationMapper(session);
- final MailboxId mailboxId = getMailbox(mailboxPath, session).getId();
-
- return annotationMapper.execute(
- () -> annotationMapper.getAnnotationsByKeysWithAllDepth(mailboxId, keys));
+ Set<MailboxAnnotationKey> keys) throws MailboxException {
+ return annotationManager.getAnnotationsByKeysWithAllDepth(mailboxPath, session, keys);
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerAnnotationTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerAnnotationTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerAnnotationTest.java
index ccf2304..46d4a0d 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerAnnotationTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerAnnotationTest.java
@@ -32,21 +32,17 @@ import java.util.Collections;
import java.util.List;
import java.util.Set;
-import org.apache.james.mailbox.acl.GroupMembershipResolver;
-import org.apache.james.mailbox.acl.MailboxACLResolver;
+import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.mock.MockMailboxSession;
+import org.apache.james.mailbox.model.MailboxACL;
import org.apache.james.mailbox.model.MailboxAnnotation;
import org.apache.james.mailbox.model.MailboxAnnotationKey;
import org.apache.james.mailbox.model.MailboxId;
import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.model.MessageId;
-import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
-import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.AnnotationMapper;
import org.apache.james.mailbox.store.mail.MailboxMapper;
import org.apache.james.mailbox.store.mail.model.Mailbox;
-import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
import org.apache.james.mailbox.store.transaction.Mapper;
import org.junit.Before;
import org.junit.Test;
@@ -68,20 +64,15 @@ public class StoreMailboxManagerAnnotationTest {
private static final List<MailboxAnnotation> ANNOTATIONS_WITH_NIL_ENTRY = ImmutableList.of(PRIVATE_ANNOTATION, MailboxAnnotation.nil(SHARED_KEY));
@Mock private MailboxSessionMapperFactory mailboxSessionMapperFactory;
- @Mock private Authenticator authenticator;
- @Mock private Authorizator authorizator;
- @Mock private MailboxACLResolver aclResolver;
- @Mock private GroupMembershipResolver groupMembershipResolver;
+ @Mock private StoreRightManager storeRightManager;
@Mock private MailboxMapper mailboxMapper;
@Mock private AnnotationMapper annotationMapper;
@Mock private MailboxPath mailboxPath;
@Mock private Mailbox mailbox;
- @Mock private MessageParser messageParser;
@Mock private MailboxId mailboxId;
- @Mock private MessageId.Factory messageIdFactory;
private MockMailboxSession session;
- private StoreMailboxManager storeMailboxManager;
+ private StoreMailboxAnnotationManager annotationManager;
@SuppressWarnings("unchecked")
@@ -100,30 +91,23 @@ public class StoreMailboxManagerAnnotationTest {
Mapper.Transaction<?> transaction = (Mapper.Transaction<?>) invocationOnMock.getArguments()[0];
return transaction.run();
});
+ when(storeRightManager.hasRight(any(Mailbox.class), any(MailboxACL.Right.class), any(MailboxSession.class)))
+ .thenReturn(true);
- StoreRightManager storeRightManager = new StoreRightManager(mailboxSessionMapperFactory, aclResolver,
- groupMembershipResolver);
-
- DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
- MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
- storeMailboxManager = spy(new StoreMailboxManager(mailboxSessionMapperFactory, authenticator, authorizator,
- new JVMMailboxPathLocker(), messageParser, messageIdFactory,
- mailboxEventDispatcher,
- delegatingListener,
- storeRightManager));
- storeMailboxManager.init();
+ annotationManager = spy(new StoreMailboxAnnotationManager(mailboxSessionMapperFactory,
+ storeRightManager));
}
@Test(expected = MailboxException.class)
public void updateAnnotationsShouldThrowExceptionWhenDoesNotLookupMailbox() throws Exception {
doThrow(MailboxException.class).when(mailboxMapper).findMailboxByPath(eq(mailboxPath));
- storeMailboxManager.updateAnnotations(mailboxPath, session, ImmutableList.of(PRIVATE_ANNOTATION));
+ annotationManager.updateAnnotations(mailboxPath, session, ImmutableList.of(PRIVATE_ANNOTATION));
}
@Test
public void updateAnnotationsShouldCallAnnotationMapperToInsertAnnotation() throws Exception {
when(mailboxMapper.findMailboxByPath(eq(mailboxPath))).thenReturn(mailbox);
- storeMailboxManager.updateAnnotations(mailboxPath, session, ANNOTATIONS);
+ annotationManager.updateAnnotations(mailboxPath, session, ANNOTATIONS);
verify(annotationMapper, times(2)).insertAnnotation(eq(mailboxId), any(MailboxAnnotation.class));
}
@@ -131,7 +115,7 @@ public class StoreMailboxManagerAnnotationTest {
@Test
public void updateAnnotationsShouldCallAnnotationMapperToDeleteAnnotation() throws Exception {
when(mailboxMapper.findMailboxByPath(eq(mailboxPath))).thenReturn(mailbox);
- storeMailboxManager.updateAnnotations(mailboxPath, session, ANNOTATIONS_WITH_NIL_ENTRY);
+ annotationManager.updateAnnotations(mailboxPath, session, ANNOTATIONS_WITH_NIL_ENTRY);
verify(annotationMapper, times(1)).insertAnnotation(eq(mailboxId), eq(PRIVATE_ANNOTATION));
verify(annotationMapper, times(1)).deleteAnnotation(eq(mailboxId), eq(SHARED_KEY));
@@ -140,7 +124,7 @@ public class StoreMailboxManagerAnnotationTest {
@Test(expected = MailboxException.class)
public void getAllAnnotationsShouldThrowExceptionWhenDoesNotLookupMailbox() throws Exception {
doThrow(MailboxException.class).when(mailboxMapper).findMailboxByPath(eq(mailboxPath));
- storeMailboxManager.getAllAnnotations(mailboxPath, session);
+ annotationManager.getAllAnnotations(mailboxPath, session);
}
@Test
@@ -148,7 +132,7 @@ public class StoreMailboxManagerAnnotationTest {
when(mailboxMapper.findMailboxByPath(eq(mailboxPath))).thenReturn(mailbox);
when(annotationMapper.getAllAnnotations(eq(mailboxId))).thenReturn(Collections.<MailboxAnnotation> emptyList());
- assertThat(storeMailboxManager.getAllAnnotations(mailboxPath, session)).isEmpty();
+ assertThat(annotationManager.getAllAnnotations(mailboxPath, session)).isEmpty();
}
@Test
@@ -156,13 +140,13 @@ public class StoreMailboxManagerAnnotationTest {
when(mailboxMapper.findMailboxByPath(eq(mailboxPath))).thenReturn(mailbox);
when(annotationMapper.getAllAnnotations(eq(mailboxId))).thenReturn(ANNOTATIONS);
- assertThat(storeMailboxManager.getAllAnnotations(mailboxPath, session)).isEqualTo(ANNOTATIONS);
+ assertThat(annotationManager.getAllAnnotations(mailboxPath, session)).isEqualTo(ANNOTATIONS);
}
@Test(expected = MailboxException.class)
public void getAnnotationsByKeysShouldThrowExceptionWhenDoesNotLookupMailbox() throws Exception {
doThrow(MailboxException.class).when(mailboxMapper).findMailboxByPath(eq(mailboxPath));
- storeMailboxManager.getAnnotationsByKeys(mailboxPath, session, KEYS);
+ annotationManager.getAnnotationsByKeys(mailboxPath, session, KEYS);
}
@Test
@@ -170,6 +154,6 @@ public class StoreMailboxManagerAnnotationTest {
when(mailboxMapper.findMailboxByPath(eq(mailboxPath))).thenReturn(mailbox);
when(annotationMapper.getAnnotationsByKeys(eq(mailboxId), eq(KEYS))).thenReturn(ANNOTATIONS);
- assertThat(storeMailboxManager.getAnnotationsByKeys(mailboxPath, session, KEYS)).isEqualTo(ANNOTATIONS);
+ assertThat(annotationManager.getAnnotationsByKeys(mailboxPath, session, KEYS)).isEqualTo(ANNOTATIONS);
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java
index 846cfb0..33f9efd 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java
@@ -79,8 +79,10 @@ public class StoreMailboxManagerTest {
DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
+ StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mockedMapperFactory, storeRightManager);
storeMailboxManager = new StoreMailboxManager(mockedMapperFactory, authenticator, FakeAuthorizator.forUserAndAdmin(ADMIN, CURRENT_USER),
- new JVMMailboxPathLocker(), new MessageParser(), messageIdFactory, mailboxEventDispatcher, delegatingListener, storeRightManager);
+ new JVMMailboxPathLocker(), new MessageParser(), messageIdFactory,
+ annotationManager, mailboxEventDispatcher, delegatingListener, storeRightManager);
storeMailboxManager.init();
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mailbox/tool/pom.xml
----------------------------------------------------------------------
diff --git a/mailbox/tool/pom.xml b/mailbox/tool/pom.xml
index d6460fe..73550d8 100644
--- a/mailbox/tool/pom.xml
+++ b/mailbox/tool/pom.xml
@@ -48,10 +48,22 @@
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
+ <artifactId>apache-james-mailbox-api</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
<artifactId>apache-james-mailbox-memory</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
+ <artifactId>apache-james-mailbox-memory</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
<artifactId>apache-james-mailbox-store</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mailbox/tool/src/test/java/org/apache/james/mailbox/copier/MailboxCopierTest.java
----------------------------------------------------------------------
diff --git a/mailbox/tool/src/test/java/org/apache/james/mailbox/copier/MailboxCopierTest.java b/mailbox/tool/src/test/java/org/apache/james/mailbox/copier/MailboxCopierTest.java
index 27f5187..0bf9ec4 100644
--- a/mailbox/tool/src/test/java/org/apache/james/mailbox/copier/MailboxCopierTest.java
+++ b/mailbox/tool/src/test/java/org/apache/james/mailbox/copier/MailboxCopierTest.java
@@ -27,23 +27,13 @@ import org.apache.james.mailbox.MailboxManager;
import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.MessageManager;
import org.apache.james.mailbox.MessageManager.MetaData.FetchGroup;
-import org.apache.james.mailbox.acl.GroupMembershipResolver;
-import org.apache.james.mailbox.acl.MailboxACLResolver;
import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
-import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
import org.apache.james.mailbox.exception.BadCredentialsException;
import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
+import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
import org.apache.james.mailbox.mock.MockMailboxManager;
import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.store.Authorizator;
-import org.apache.james.mailbox.store.JVMMailboxPathLocker;
import org.apache.james.mailbox.store.StoreMailboxManager;
-import org.apache.james.mailbox.store.StoreRightManager;
-import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
-import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
-import org.apache.james.mailbox.store.mail.model.DefaultMessageId;
-import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
import org.junit.Before;
import org.junit.Test;
@@ -55,8 +45,6 @@ import org.junit.Test;
*
*/
public class MailboxCopierTest {
-
- public static final boolean AUTHENTIC = true;
/**
* The instance for the test mailboxCopier.
*/
@@ -155,26 +143,9 @@ public class MailboxCopierTest {
*
* @return a new InMemoryMailboxManager
*/
- private MailboxManager newInMemoryMailboxManager() {
- MailboxACLResolver aclResolver = new UnionMailboxACLResolver();
- GroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
- MessageParser messageParser = new MessageParser();
- InMemoryMailboxSessionMapperFactory mapperFactory = new InMemoryMailboxSessionMapperFactory();
- StoreRightManager storeRightManager = new StoreRightManager(mapperFactory, aclResolver, groupMembershipResolver);
-
- DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
- MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
- return new StoreMailboxManager(
- mapperFactory,
- (userid, passwd) -> AUTHENTIC,
- (userId, otherUserId) -> Authorizator.AuthorizationState.NOT_ADMIN,
- new JVMMailboxPathLocker(),
- messageParser,
- new DefaultMessageId.Factory(),
- mailboxEventDispatcher,
- delegatingListener,
- storeRightManager);
-
+ private MailboxManager newInMemoryMailboxManager() throws MailboxException {
+ return new InMemoryIntegrationResources()
+ .createMailboxManager(new SimpleGroupMembershipResolver());
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java
index ff17399..93fc95e 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java
@@ -52,6 +52,7 @@ import org.apache.james.mailbox.cassandra.quota.CassandraPerUserMaxQuotaManager;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.quota.QuotaRootResolver;
import org.apache.james.mailbox.store.JVMMailboxPathLocker;
+import org.apache.james.mailbox.store.StoreMailboxAnnotationManager;
import org.apache.james.mailbox.store.StoreRightManager;
import org.apache.james.mailbox.store.StoreSubscriptionManager;
import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
@@ -115,9 +116,11 @@ public class CassandraHostSystem extends JamesImapHostSystem {
DefaultDelegatingMailboxListener delegatingMailboxListener = new DefaultDelegatingMailboxListener();
MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingMailboxListener);
StoreRightManager storeRightManager = new StoreRightManager(mapperFactory, new UnionMailboxACLResolver(), new SimpleGroupMembershipResolver());
+
+ StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mapperFactory, storeRightManager);
mailboxManager = new CassandraMailboxManager(mapperFactory, authenticator, authorizator,
new JVMMailboxPathLocker(), new MessageParser(), messageIdFactory,
- mailboxEventDispatcher, delegatingMailboxListener, storeRightManager);
+ mailboxEventDispatcher, delegatingMailboxListener, annotationManager, storeRightManager);
QuotaRootResolver quotaRootResolver = new DefaultQuotaRootResolver(mapperFactory);
perUserMaxQuotaManager = new CassandraPerUserMaxQuotaManager(session);
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mpt/impl/imap-mailbox/elasticsearch/pom.xml
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/elasticsearch/pom.xml b/mpt/impl/imap-mailbox/elasticsearch/pom.xml
index 762f5a7..1add2e2 100644
--- a/mpt/impl/imap-mailbox/elasticsearch/pom.xml
+++ b/mpt/impl/imap-mailbox/elasticsearch/pom.xml
@@ -47,6 +47,11 @@
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
+ <artifactId>apache-james-mailbox-api</artifactId>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
<artifactId>apache-james-mailbox-elasticsearch</artifactId>
</dependency>
<dependency>
@@ -55,6 +60,11 @@
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
+ <artifactId>apache-james-mailbox-memory</artifactId>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
<artifactId>apache-james-mailbox-store</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java b/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
index 369492f..9b36b88 100644
--- a/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
+++ b/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
@@ -37,10 +37,7 @@ import org.apache.james.imap.encode.main.DefaultImapEncoderFactory;
import org.apache.james.imap.main.DefaultImapDecoderFactory;
import org.apache.james.imap.processor.main.DefaultImapProcessorFactory;
import org.apache.james.mailbox.MailboxManager;
-import org.apache.james.mailbox.acl.GroupMembershipResolver;
-import org.apache.james.mailbox.acl.MailboxACLResolver;
import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
-import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
import org.apache.james.mailbox.elasticsearch.IndexAttachments;
import org.apache.james.mailbox.elasticsearch.MailboxElasticSearchConstants;
import org.apache.james.mailbox.elasticsearch.MailboxMappingFactory;
@@ -53,14 +50,11 @@ import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.inmemory.InMemoryId;
import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
import org.apache.james.mailbox.inmemory.InMemoryMessageId;
-import org.apache.james.mailbox.store.JVMMailboxPathLocker;
+import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
+import org.apache.james.mailbox.mock.MockMailboxSession;
import org.apache.james.mailbox.store.StoreMailboxManager;
-import org.apache.james.mailbox.store.StoreRightManager;
import org.apache.james.mailbox.store.StoreSubscriptionManager;
-import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
-import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.extractor.DefaultTextExtractor;
-import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
import org.apache.james.mailbox.store.quota.DefaultQuotaRootResolver;
import org.apache.james.mailbox.store.quota.NoQuotaManager;
import org.apache.james.metrics.logger.DefaultMetricFactory;
@@ -69,8 +63,6 @@ import org.apache.james.mpt.api.ImapFeatures.Feature;
import org.apache.james.mpt.host.JamesImapHostSystem;
import org.elasticsearch.client.Client;
-import com.google.common.base.Throwables;
-
public class ElasticSearchHostSystem extends JamesImapHostSystem {
private static final ImapFeatures SUPPORTED_FEATURES = ImapFeatures.of(Feature.NAMESPACE_SUPPORT);
@@ -95,7 +87,7 @@ public class ElasticSearchHostSystem extends JamesImapHostSystem {
FileUtils.deleteDirectory(tempDirectory.toFile());
}
- private void initFields() {
+ private void initFields() throws MailboxException {
Client client = NodeMappingFactory.applyMapping(
new IndexCreationFactory()
.useIndex(MailboxElasticSearchConstants.DEFAULT_MAILBOX_INDEX)
@@ -120,26 +112,13 @@ public class ElasticSearchHostSystem extends JamesImapHostSystem {
MailboxElasticSearchConstants.DEFAULT_MAILBOX_READ_ALIAS, MailboxElasticSearchConstants.MESSAGE_TYPE),
new MessageToElasticSearchJson(new DefaultTextExtractor(), ZoneId.systemDefault(), IndexAttachments.YES));
- MailboxACLResolver aclResolver = new UnionMailboxACLResolver();
- GroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
- MessageParser messageParser = new MessageParser();
-
- StoreRightManager storeRightManager = new StoreRightManager(factory, aclResolver, groupMembershipResolver);
-
- DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
- MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
- mailboxManager = new StoreMailboxManager(factory, authenticator, authorizator, new JVMMailboxPathLocker(),
- messageParser, messageIdFactory, mailboxEventDispatcher, delegatingListener, storeRightManager);
- mailboxManager.setMessageSearchIndex(searchIndex);
-
- try {
- mailboxManager.init();
- } catch (MailboxException e) {
- throw Throwables.propagate(e);
- }
+ InMemoryIntegrationResources inMemoryIntegrationResources = new InMemoryIntegrationResources();
+ this.mailboxManager = inMemoryIntegrationResources.createMailboxManager(new SimpleGroupMembershipResolver());
+ this.mailboxManager.setMessageSearchIndex(searchIndex);
+ this.mailboxManager.removeGlobalListener(searchIndex, new MockMailboxSession("admin"));
final ImapProcessor defaultImapProcessorFactory =
- DefaultImapProcessorFactory.createDefaultProcessor(mailboxManager,
+ DefaultImapProcessorFactory.createDefaultProcessor(this.mailboxManager,
new StoreSubscriptionManager(factory),
new NoQuotaManager(),
new DefaultQuotaRootResolver(factory),
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mpt/impl/imap-mailbox/hbase/src/test/java/org/apache/james/mpt/imapmailbox/hbase/host/HBaseHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/hbase/src/test/java/org/apache/james/mpt/imapmailbox/hbase/host/HBaseHostSystem.java b/mpt/impl/imap-mailbox/hbase/src/test/java/org/apache/james/mpt/imapmailbox/hbase/host/HBaseHostSystem.java
index 1b0cacd..aa1c82b 100644
--- a/mpt/impl/imap-mailbox/hbase/src/test/java/org/apache/james/mpt/imapmailbox/hbase/host/HBaseHostSystem.java
+++ b/mpt/impl/imap-mailbox/hbase/src/test/java/org/apache/james/mpt/imapmailbox/hbase/host/HBaseHostSystem.java
@@ -42,6 +42,7 @@ import org.apache.james.mailbox.hbase.HBaseMailboxSessionMapperFactory;
import org.apache.james.mailbox.hbase.mail.HBaseModSeqProvider;
import org.apache.james.mailbox.hbase.mail.HBaseUidProvider;
import org.apache.james.mailbox.store.JVMMailboxPathLocker;
+import org.apache.james.mailbox.store.StoreMailboxAnnotationManager;
import org.apache.james.mailbox.store.StoreRightManager;
import org.apache.james.mailbox.store.StoreSubscriptionManager;
import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
@@ -109,9 +110,11 @@ public class HBaseHostSystem extends JamesImapHostSystem {
DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
StoreRightManager storeRightManager = new StoreRightManager(mapperFactory, aclResolver, groupMembershipResolver);
+ StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mapperFactory, storeRightManager);
mailboxManager = new HBaseMailboxManager(mapperFactory, authenticator, authorizator,
new JVMMailboxPathLocker(), messageParser,
- messageIdFactory, mailboxEventDispatcher, delegatingListener, storeRightManager);
+ messageIdFactory, mailboxEventDispatcher, delegatingListener,
+ annotationManager, storeRightManager);
mailboxManager.init();
SubscriptionManager subscriptionManager = new StoreSubscriptionManager(mapperFactory);
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mpt/impl/imap-mailbox/inmemory/pom.xml
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/inmemory/pom.xml b/mpt/impl/imap-mailbox/inmemory/pom.xml
index dfed496..996ca9e 100644
--- a/mpt/impl/imap-mailbox/inmemory/pom.xml
+++ b/mpt/impl/imap-mailbox/inmemory/pom.xml
@@ -33,8 +33,20 @@
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
+ <artifactId>apache-james-mailbox-api</artifactId>
+ <scope>test</scope>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>apache-james-mailbox-memory</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
<artifactId>apache-james-mailbox-memory</artifactId>
<scope>test</scope>
+ <type>test-jar</type>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryHostSystem.java b/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryHostSystem.java
index 0cac457..9f3f26e 100644
--- a/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryHostSystem.java
+++ b/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/host/InMemoryHostSystem.java
@@ -24,23 +24,15 @@ import org.apache.james.imap.encode.main.DefaultImapEncoderFactory;
import org.apache.james.imap.main.DefaultImapDecoderFactory;
import org.apache.james.imap.processor.main.DefaultImapProcessorFactory;
import org.apache.james.mailbox.MailboxManager;
-import org.apache.james.mailbox.acl.GroupMembershipResolver;
-import org.apache.james.mailbox.acl.MailboxACLResolver;
import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
-import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.inmemory.InMemoryMailboxManager;
-import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
-import org.apache.james.mailbox.inmemory.InMemoryMessageId;
+import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
import org.apache.james.mailbox.inmemory.quota.InMemoryCurrentQuotaManager;
import org.apache.james.mailbox.inmemory.quota.InMemoryPerUserMaxQuotaManager;
+import org.apache.james.mailbox.mock.MockMailboxSession;
import org.apache.james.mailbox.quota.QuotaRootResolver;
-import org.apache.james.mailbox.store.JVMMailboxPathLocker;
-import org.apache.james.mailbox.store.StoreRightManager;
+import org.apache.james.mailbox.store.StoreMailboxManager;
import org.apache.james.mailbox.store.StoreSubscriptionManager;
-import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
-import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
-import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
import org.apache.james.mailbox.store.quota.CurrentQuotaCalculator;
import org.apache.james.mailbox.store.quota.DefaultQuotaRootResolver;
import org.apache.james.mailbox.store.quota.ListeningCurrentQuotaUpdater;
@@ -58,7 +50,7 @@ public class InMemoryHostSystem extends JamesImapHostSystem {
Feature.QUOTA_SUPPORT,
Feature.ANNOTATION_SUPPORT);
- private InMemoryMailboxManager mailboxManager;
+ private StoreMailboxManager mailboxManager;
private InMemoryPerUserMaxQuotaManager perUserMaxQuotaManager;
public static JamesImapHostSystem build() throws Exception {
@@ -68,18 +60,8 @@ public class InMemoryHostSystem extends JamesImapHostSystem {
@Override
public void beforeTest() throws Exception {
super.beforeTest();
- MailboxACLResolver aclResolver = new UnionMailboxACLResolver();
- GroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
- MessageParser messageParser = new MessageParser();
-
- InMemoryMailboxSessionMapperFactory mailboxSessionMapperFactory = new InMemoryMailboxSessionMapperFactory();
- StoreRightManager storeRightManager = new StoreRightManager(mailboxSessionMapperFactory, aclResolver, groupMembershipResolver);
-
- DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
- MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
- mailboxManager = new InMemoryMailboxManager(mailboxSessionMapperFactory, authenticator, authorizator,
- new JVMMailboxPathLocker(), messageParser, new InMemoryMessageId.Factory(),
- mailboxEventDispatcher, delegatingListener, storeRightManager);
+ this.mailboxManager = new InMemoryIntegrationResources()
+ .createMailboxManager(new SimpleGroupMembershipResolver(), authenticator, authorizator);
QuotaRootResolver quotaRootResolver = new DefaultQuotaRootResolver(mailboxManager.getMapperFactory());
perUserMaxQuotaManager = new InMemoryPerUserMaxQuotaManager();
@@ -95,8 +77,7 @@ public class InMemoryHostSystem extends JamesImapHostSystem {
mailboxManager.setQuotaRootResolver(quotaRootResolver);
mailboxManager.setQuotaManager(quotaManager);
mailboxManager.setQuotaUpdater(quotaUpdater);
-
- mailboxManager.init();
+ mailboxManager.addGlobalListener(quotaUpdater, new MockMailboxSession("admin"));
final ImapProcessor defaultImapProcessorFactory = DefaultImapProcessorFactory.createDefaultProcessor(mailboxManager, new StoreSubscriptionManager(mailboxManager.getMapperFactory()), quotaManager, quotaRootResolver, new DefaultMetricFactory());
configure(new DefaultImapDecoderFactory().buildImapDecoder(),
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mpt/impl/imap-mailbox/jcr/src/test/java/org/apache/james/mpt/imapmailbox/jcr/host/JCRHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/jcr/src/test/java/org/apache/james/mpt/imapmailbox/jcr/host/JCRHostSystem.java b/mpt/impl/imap-mailbox/jcr/src/test/java/org/apache/james/mpt/imapmailbox/jcr/host/JCRHostSystem.java
index 01a286b..7702d20 100644
--- a/mpt/impl/imap-mailbox/jcr/src/test/java/org/apache/james/mpt/imapmailbox/jcr/host/JCRHostSystem.java
+++ b/mpt/impl/imap-mailbox/jcr/src/test/java/org/apache/james/mpt/imapmailbox/jcr/host/JCRHostSystem.java
@@ -42,6 +42,7 @@ import org.apache.james.mailbox.jcr.JCRUtils;
import org.apache.james.mailbox.jcr.mail.JCRModSeqProvider;
import org.apache.james.mailbox.jcr.mail.JCRUidProvider;
import org.apache.james.mailbox.store.JVMMailboxPathLocker;
+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.event.MailboxEventDispatcher;
@@ -97,8 +98,10 @@ public class JCRHostSystem extends JamesImapHostSystem {
StoreRightManager storeRightManager = new StoreRightManager(mf, aclResolver, groupMembershipResolver);
DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
+ StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mf, storeRightManager);
mailboxManager = new JCRMailboxManager(mf, authenticator, authorizator, new JVMMailboxPathLocker(), messageParser,
- new DefaultMessageId.Factory(), mailboxEventDispatcher, delegatingListener, storeRightManager);
+ new DefaultMessageId.Factory(), mailboxEventDispatcher, delegatingListener,
+ annotationManager, storeRightManager);
mailboxManager.init();
final ImapProcessor defaultImapProcessorFactory =
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mpt/impl/imap-mailbox/jpa/src/test/java/org/apache/james/mpt/imapmailbox/jpa/host/JPAHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/jpa/src/test/java/org/apache/james/mpt/imapmailbox/jpa/host/JPAHostSystem.java b/mpt/impl/imap-mailbox/jpa/src/test/java/org/apache/james/mpt/imapmailbox/jpa/host/JPAHostSystem.java
index 1dbfbab..f6468d2 100644
--- a/mpt/impl/imap-mailbox/jpa/src/test/java/org/apache/james/mpt/imapmailbox/jpa/host/JPAHostSystem.java
+++ b/mpt/impl/imap-mailbox/jpa/src/test/java/org/apache/james/mpt/imapmailbox/jpa/host/JPAHostSystem.java
@@ -45,9 +45,11 @@ import org.apache.james.mailbox.jpa.mail.JPAUidProvider;
import org.apache.james.mailbox.jpa.openjpa.OpenJPAMailboxManager;
import org.apache.james.mailbox.jpa.quota.JPAPerUserMaxQuotaManager;
import org.apache.james.mailbox.jpa.quota.JpaCurrentQuotaManager;
-import org.apache.james.mailbox.model.MailboxConstants;
import org.apache.james.mailbox.store.JVMMailboxPathLocker;
+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.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.model.DefaultMessageId;
import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
import org.apache.james.mailbox.store.quota.DefaultQuotaRootResolver;
@@ -95,11 +97,12 @@ public class JPAHostSystem extends JamesImapHostSystem {
MessageParser messageParser = new MessageParser();
StoreRightManager storeRightManager = new StoreRightManager(mapperFactory, aclResolver, groupMembershipResolver);
- boolean useStreaming = false;
- mailboxManager = new OpenJPAMailboxManager(mapperFactory, authenticator, authorizator, locker, useStreaming,
- messageParser, new DefaultMessageId.Factory(),
- MailboxConstants.DEFAULT_LIMIT_ANNOTATIONS_ON_MAILBOX,
- MailboxConstants.DEFAULT_LIMIT_ANNOTATION_SIZE, storeRightManager);
+ DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
+ StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mapperFactory, storeRightManager);
+ mailboxManager = new OpenJPAMailboxManager(mapperFactory, authenticator, authorizator,
+ messageParser, new DefaultMessageId.Factory(), delegatingListener,
+ mailboxEventDispatcher, annotationManager, storeRightManager);
DefaultQuotaRootResolver quotaRootResolver = new DefaultQuotaRootResolver(mapperFactory);
JpaCurrentQuotaManager currentQuotaManager = new JpaCurrentQuotaManager(entityManagerFactory);
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/host/LuceneSearchHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/host/LuceneSearchHostSystem.java b/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/host/LuceneSearchHostSystem.java
index 794a163..d9a21e2 100644
--- a/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/host/LuceneSearchHostSystem.java
+++ b/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/host/LuceneSearchHostSystem.java
@@ -48,10 +48,12 @@ import org.apache.james.mailbox.jpa.mail.JPAModSeqProvider;
import org.apache.james.mailbox.jpa.mail.JPAUidProvider;
import org.apache.james.mailbox.jpa.openjpa.OpenJPAMailboxManager;
import org.apache.james.mailbox.lucene.search.LuceneMessageSearchIndex;
-import org.apache.james.mailbox.model.MailboxConstants;
import org.apache.james.mailbox.model.MessageId;
import org.apache.james.mailbox.store.JVMMailboxPathLocker;
+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.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.model.DefaultMessageId;
import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
import org.apache.james.mailbox.store.quota.DefaultQuotaRootResolver;
@@ -118,12 +120,13 @@ public class LuceneSearchHostSystem extends JamesImapHostSystem {
MessageParser messageParser = new MessageParser();
StoreRightManager storeRightManager = new StoreRightManager(factory, aclResolver, groupMembershipResolver);
- boolean useStreaming = false;
- mailboxManager = new OpenJPAMailboxManager(factory, authenticator, authorizator, locker, useStreaming,
- messageParser, messageIdFactory,
- MailboxConstants.DEFAULT_LIMIT_ANNOTATIONS_ON_MAILBOX,
- MailboxConstants.DEFAULT_LIMIT_ANNOTATION_SIZE,
- storeRightManager);
+
+ DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
+ StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(factory, storeRightManager);
+ mailboxManager = new OpenJPAMailboxManager(factory, authenticator, authorizator,
+ messageParser, new DefaultMessageId.Factory(), delegatingListener,
+ mailboxEventDispatcher, annotationManager, storeRightManager);
LuceneMessageSearchIndex searchIndex = new LuceneMessageSearchIndex(factory, mailboxIdFactory, fsDirectory, messageIdFactory);
searchIndex.setEnableSuffixMatch(true);
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mpt/impl/imap-mailbox/maildir/src/test/java/org/apache/james/mpt/imapmailbox/maildir/host/MaildirHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/maildir/src/test/java/org/apache/james/mpt/imapmailbox/maildir/host/MaildirHostSystem.java b/mpt/impl/imap-mailbox/maildir/src/test/java/org/apache/james/mpt/imapmailbox/maildir/host/MaildirHostSystem.java
index 6f7799e..3730ee7 100644
--- a/mpt/impl/imap-mailbox/maildir/src/test/java/org/apache/james/mpt/imapmailbox/maildir/host/MaildirHostSystem.java
+++ b/mpt/impl/imap-mailbox/maildir/src/test/java/org/apache/james/mpt/imapmailbox/maildir/host/MaildirHostSystem.java
@@ -34,6 +34,7 @@ import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
import org.apache.james.mailbox.maildir.MaildirMailboxSessionMapperFactory;
import org.apache.james.mailbox.maildir.MaildirStore;
import org.apache.james.mailbox.store.JVMMailboxPathLocker;
+import org.apache.james.mailbox.store.StoreMailboxAnnotationManager;
import org.apache.james.mailbox.store.StoreMailboxManager;
import org.apache.james.mailbox.store.StoreRightManager;
import org.apache.james.mailbox.store.StoreSubscriptionManager;
@@ -75,9 +76,10 @@ public class MaildirHostSystem extends JamesImapHostSystem {
DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
StoreRightManager storeRightManager = new StoreRightManager(mailboxSessionMapperFactory, aclResolver, groupMembershipResolver);
+ StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mailboxSessionMapperFactory, storeRightManager);
mailboxManager = new StoreMailboxManager(mailboxSessionMapperFactory, authenticator, authorizator, locker,
- messageParser, new DefaultMessageId.Factory(), mailboxEventDispatcher,
- delegatingListener, storeRightManager);
+ messageParser, new DefaultMessageId.Factory(), annotationManager,
+ mailboxEventDispatcher, delegatingListener, storeRightManager);
mailboxManager.init();
final ImapProcessor defaultImapProcessorFactory =
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/server/container/mailbox-adapter/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/mailbox-adapter/pom.xml b/server/container/mailbox-adapter/pom.xml
index 08a39a8..1d17b85 100644
--- a/server/container/mailbox-adapter/pom.xml
+++ b/server/container/mailbox-adapter/pom.xml
@@ -39,6 +39,12 @@
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
+ <artifactId>apache-james-mailbox-api</artifactId>
+ <scope>test</scope>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
<artifactId>apache-james-mailbox-maildir</artifactId>
</dependency>
<dependency>
@@ -48,6 +54,12 @@
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
+ <artifactId>apache-james-mailbox-memory</artifactId>
+ <scope>test</scope>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
<artifactId>apache-james-mailbox-store</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/MailboxManagementTest.java
----------------------------------------------------------------------
diff --git a/server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/MailboxManagementTest.java b/server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/MailboxManagementTest.java
index 380a09f..7fc5e45 100644
--- a/server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/MailboxManagementTest.java
+++ b/server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/MailboxManagementTest.java
@@ -29,24 +29,16 @@ import java.util.Iterator;
import org.apache.commons.io.IOUtils;
import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
-import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
import org.apache.james.mailbox.exception.MailboxExistsException;
-import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
+import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
import org.apache.james.mailbox.model.MailboxConstants;
import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.model.MessageRange;
-import org.apache.james.mailbox.store.FakeAuthenticator;
-import org.apache.james.mailbox.store.FakeAuthorizator;
-import org.apache.james.mailbox.store.JVMMailboxPathLocker;
+import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
import org.apache.james.mailbox.store.StoreMailboxManager;
-import org.apache.james.mailbox.store.StoreRightManager;
-import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
-import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.MessageMapper;
-import org.apache.james.mailbox.store.mail.model.DefaultMessageId;
import org.apache.james.mailbox.store.mail.model.Mailbox;
import org.apache.james.mailbox.store.mail.model.MailboxMessage;
-import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
import org.junit.Before;
import org.junit.Test;
@@ -60,31 +52,15 @@ public class MailboxManagementTest {
public static final int LIMIT = 1;
private MailboxManagerManagement mailboxManagerManagement;
- private InMemoryMailboxSessionMapperFactory inMemoryMapperFactory;
+ private MailboxSessionMapperFactory mapperFactory;
private MailboxSession session;
@Before
public void setUp() throws Exception {
- inMemoryMapperFactory = new InMemoryMailboxSessionMapperFactory();
- StoreRightManager storeRightManager = new StoreRightManager(inMemoryMapperFactory,
- new UnionMailboxACLResolver(),
- new SimpleGroupMembershipResolver());
-
-
- DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
- MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
- StoreMailboxManager mailboxManager = new StoreMailboxManager(
- inMemoryMapperFactory,
- new FakeAuthenticator(),
- FakeAuthorizator.defaultReject(),
- new JVMMailboxPathLocker(),
- new MessageParser(),
- new DefaultMessageId.Factory(),
- mailboxEventDispatcher,
- delegatingListener,
- storeRightManager);
-
- mailboxManager.init();
+ StoreMailboxManager mailboxManager = new InMemoryIntegrationResources()
+ .createMailboxManager(new SimpleGroupMembershipResolver());
+ mapperFactory = mailboxManager.getMapperFactory();
+
mailboxManagerManagement = new MailboxManagerManagement();
mailboxManagerManagement.setMailboxManager(mailboxManager);
session = mailboxManager.createSystemSession("TEST");
@@ -92,46 +68,46 @@ public class MailboxManagementTest {
@Test
public void deleteMailboxesShouldDeleteMailboxes() throws Exception {
- inMemoryMapperFactory.createMailboxMapper(session).save(new SimpleMailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY));
+ mapperFactory.createMailboxMapper(session).save(new SimpleMailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY));
mailboxManagerManagement.deleteMailboxes(USER);
- assertThat(inMemoryMapperFactory.createMailboxMapper(session).list()).isEmpty();
+ assertThat(mapperFactory.createMailboxMapper(session).list()).isEmpty();
}
@Test
public void deleteMailboxesShouldDeleteInbox() throws Exception {
- inMemoryMapperFactory.createMailboxMapper(session).save(new SimpleMailbox(MailboxPath.forUser(USER, "INBOX"), UID_VALIDITY));
+ mapperFactory.createMailboxMapper(session).save(new SimpleMailbox(MailboxPath.forUser(USER, "INBOX"), UID_VALIDITY));
mailboxManagerManagement.deleteMailboxes(USER);
- assertThat(inMemoryMapperFactory.createMailboxMapper(session).list()).isEmpty();
+ assertThat(mapperFactory.createMailboxMapper(session).list()).isEmpty();
}
@Test
public void deleteMailboxesShouldDeleteMailboxesChildren() throws Exception {
- inMemoryMapperFactory.createMailboxMapper(session).save(new SimpleMailbox(MailboxPath.forUser(USER, "INBOX.test"), UID_VALIDITY));
+ mapperFactory.createMailboxMapper(session).save(new SimpleMailbox(MailboxPath.forUser(USER, "INBOX.test"), UID_VALIDITY));
mailboxManagerManagement.deleteMailboxes(USER);
- assertThat(inMemoryMapperFactory.createMailboxMapper(session).list()).isEmpty();
+ assertThat(mapperFactory.createMailboxMapper(session).list()).isEmpty();
}
@Test
public void deleteMailboxesShouldNotDeleteMailboxesBelongingToNotPrivateNamespace() throws Exception {
Mailbox mailbox = new SimpleMailbox(new MailboxPath("#top", USER, "name"), UID_VALIDITY);
- inMemoryMapperFactory.createMailboxMapper(session).save(mailbox);
+ mapperFactory.createMailboxMapper(session).save(mailbox);
mailboxManagerManagement.deleteMailboxes(USER);
- assertThat(inMemoryMapperFactory.createMailboxMapper(session).list()).containsExactly(mailbox);
+ assertThat(mapperFactory.createMailboxMapper(session).list()).containsExactly(mailbox);
}
@Test
public void deleteMailboxesShouldNotDeleteMailboxesBelongingToOtherUsers() throws Exception {
Mailbox mailbox = new SimpleMailbox(MailboxPath.forUser("userbis", "name"), UID_VALIDITY);
- inMemoryMapperFactory.createMailboxMapper(session).save(mailbox);
+ mapperFactory.createMailboxMapper(session).save(mailbox);
mailboxManagerManagement.deleteMailboxes(USER);
- assertThat(inMemoryMapperFactory.createMailboxMapper(session).list()).containsExactly(mailbox);
+ assertThat(mapperFactory.createMailboxMapper(session).list()).containsExactly(mailbox);
}
@Test
public void deleteMailboxesShouldDeleteMailboxesWithEmptyNames() throws Exception {
- inMemoryMapperFactory.createMailboxMapper(session).save(new SimpleMailbox(MailboxPath.forUser(USER, ""), UID_VALIDITY));
+ mapperFactory.createMailboxMapper(session).save(new SimpleMailbox(MailboxPath.forUser(USER, ""), UID_VALIDITY));
mailboxManagerManagement.deleteMailboxes(USER);
- assertThat(inMemoryMapperFactory.createMailboxMapper(session).list()).isEmpty();
+ assertThat(mapperFactory.createMailboxMapper(session).list()).isEmpty();
}
@Test(expected = NullPointerException.class)
@@ -146,25 +122,25 @@ public class MailboxManagementTest {
@Test
public void deleteMailboxesShouldDeleteMultipleMailboxes() throws Exception {
- inMemoryMapperFactory.createMailboxMapper(session).save(new SimpleMailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY));
- inMemoryMapperFactory.createMailboxMapper(session).save(new SimpleMailbox(MailboxPath.forUser(USER, "INBOX"), UID_VALIDITY));
- inMemoryMapperFactory.createMailboxMapper(session).save(new SimpleMailbox(MailboxPath.forUser(USER, "INBOX.test"), UID_VALIDITY));
+ mapperFactory.createMailboxMapper(session).save(new SimpleMailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY));
+ mapperFactory.createMailboxMapper(session).save(new SimpleMailbox(MailboxPath.forUser(USER, "INBOX"), UID_VALIDITY));
+ mapperFactory.createMailboxMapper(session).save(new SimpleMailbox(MailboxPath.forUser(USER, "INBOX.test"), UID_VALIDITY));
mailboxManagerManagement.deleteMailboxes(USER);
- assertThat(inMemoryMapperFactory.createMailboxMapper(session).list()).isEmpty();
+ assertThat(mapperFactory.createMailboxMapper(session).list()).isEmpty();
}
@Test
public void createMailboxShouldCreateAMailbox() throws Exception {
mailboxManagerManagement.createMailbox(MailboxConstants.USER_NAMESPACE, USER, "name");
- assertThat(inMemoryMapperFactory.createMailboxMapper(session).list()).hasSize(1);
- assertThat(inMemoryMapperFactory.createMailboxMapper(session).findMailboxByPath(MailboxPath.forUser(USER, "name"))).isNotNull();
+ assertThat(mapperFactory.createMailboxMapper(session).list()).hasSize(1);
+ assertThat(mapperFactory.createMailboxMapper(session).findMailboxByPath(MailboxPath.forUser(USER, "name"))).isNotNull();
}
@Test
public void createMailboxShouldThrowIfMailboxAlreadyExists() throws Exception {
MailboxPath path = MailboxPath.forUser(USER, "name");
Mailbox mailbox = new SimpleMailbox(path, UID_VALIDITY);
- inMemoryMapperFactory.createMailboxMapper(session).save(mailbox);
+ mapperFactory.createMailboxMapper(session).save(mailbox);
assertThatThrownBy(() -> mailboxManagerManagement.createMailbox(MailboxConstants.USER_NAMESPACE, USER, "name"))
.isInstanceOf(RuntimeException.class)
@@ -175,9 +151,9 @@ public class MailboxManagementTest {
public void createMailboxShouldNotCreateAdditionalMailboxesIfMailboxAlreadyExists() throws Exception {
MailboxPath path = MailboxPath.forUser(USER, "name");
Mailbox mailbox = new SimpleMailbox(path, UID_VALIDITY);
- inMemoryMapperFactory.createMailboxMapper(session).save(mailbox);
+ mapperFactory.createMailboxMapper(session).save(mailbox);
- assertThat(inMemoryMapperFactory.createMailboxMapper(session).list()).containsExactly(mailbox);
+ assertThat(mapperFactory.createMailboxMapper(session).list()).containsExactly(mailbox);
}
@Test(expected = NullPointerException.class)
@@ -218,12 +194,12 @@ public class MailboxManagementTest {
Mailbox mailbox4 = new SimpleMailbox(MailboxPath.forUser(USER, "name4"), UID_VALIDITY);
Mailbox mailbox5 = new SimpleMailbox(MailboxPath.forUser(USER, "INBOX"), UID_VALIDITY);
Mailbox mailbox6 = new SimpleMailbox(MailboxPath.forUser(USER, "INBOX.toto"), UID_VALIDITY);
- inMemoryMapperFactory.createMailboxMapper(session).save(mailbox1);
- inMemoryMapperFactory.createMailboxMapper(session).save(mailbox2);
- inMemoryMapperFactory.createMailboxMapper(session).save(mailbox3);
- inMemoryMapperFactory.createMailboxMapper(session).save(mailbox4);
- inMemoryMapperFactory.createMailboxMapper(session).save(mailbox5);
- inMemoryMapperFactory.createMailboxMapper(session).save(mailbox6);
+ mapperFactory.createMailboxMapper(session).save(mailbox1);
+ mapperFactory.createMailboxMapper(session).save(mailbox2);
+ mapperFactory.createMailboxMapper(session).save(mailbox3);
+ mapperFactory.createMailboxMapper(session).save(mailbox4);
+ mapperFactory.createMailboxMapper(session).save(mailbox5);
+ mapperFactory.createMailboxMapper(session).save(mailbox6);
assertThat(mailboxManagerManagement.listMailboxes(USER)).containsOnly("name2", "name4", "INBOX", "INBOX.toto");
}
@@ -239,45 +215,45 @@ public class MailboxManagementTest {
@Test
public void deleteMailboxShouldDeleteGivenMailbox() throws Exception {
- inMemoryMapperFactory.createMailboxMapper(session).save(new SimpleMailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY));
+ mapperFactory.createMailboxMapper(session).save(new SimpleMailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY));
mailboxManagerManagement.deleteMailbox(MailboxConstants.USER_NAMESPACE, USER, "name");
- assertThat(inMemoryMapperFactory.createMailboxMapper(session).list()).isEmpty();
+ assertThat(mapperFactory.createMailboxMapper(session).list()).isEmpty();
}
@Test
public void deleteMailboxShouldNotDeleteGivenMailboxIfWrongNamespace() throws Exception {
Mailbox mailbox = new SimpleMailbox(new MailboxPath("#top", USER, "name"), UID_VALIDITY);
- inMemoryMapperFactory.createMailboxMapper(session).save(mailbox);
+ mapperFactory.createMailboxMapper(session).save(mailbox);
mailboxManagerManagement.deleteMailbox(MailboxConstants.USER_NAMESPACE, USER, "name");
- assertThat(inMemoryMapperFactory.createMailboxMapper(session).list()).containsOnly(mailbox);
+ assertThat(mapperFactory.createMailboxMapper(session).list()).containsOnly(mailbox);
}
@Test
public void deleteMailboxShouldNotDeleteGivenMailboxIfWrongUser() throws Exception {
Mailbox mailbox = new SimpleMailbox(MailboxPath.forUser("userbis", "name"), UID_VALIDITY);
- inMemoryMapperFactory.createMailboxMapper(session).save(mailbox);
+ mapperFactory.createMailboxMapper(session).save(mailbox);
mailboxManagerManagement.deleteMailbox(MailboxConstants.USER_NAMESPACE, USER, "name");
- assertThat(inMemoryMapperFactory.createMailboxMapper(session).list()).containsOnly(mailbox);
+ assertThat(mapperFactory.createMailboxMapper(session).list()).containsOnly(mailbox);
}
@Test
public void deleteMailboxShouldNotDeleteGivenMailboxIfWrongName() throws Exception {
Mailbox mailbox = new SimpleMailbox(MailboxPath.forUser(USER, "wrong_name"), UID_VALIDITY);
- inMemoryMapperFactory.createMailboxMapper(session).save(mailbox);
+ mapperFactory.createMailboxMapper(session).save(mailbox);
mailboxManagerManagement.deleteMailbox(MailboxConstants.USER_NAMESPACE, USER, "name");
- assertThat(inMemoryMapperFactory.createMailboxMapper(session).list()).containsOnly(mailbox);
+ assertThat(mapperFactory.createMailboxMapper(session).list()).containsOnly(mailbox);
}
@Test
public void importEmlFileToMailboxShouldImportEmlFileToGivenMailbox() throws Exception {
Mailbox mailbox = new SimpleMailbox(MailboxPath.forUser(USER, "name"),
UID_VALIDITY);
- inMemoryMapperFactory.createMailboxMapper(session).save(mailbox);
+ mapperFactory.createMailboxMapper(session).save(mailbox);
String emlpath = ClassLoader.getSystemResource("eml/frnog.eml").getFile();
mailboxManagerManagement.importEmlFileToMailbox(MailboxConstants.USER_NAMESPACE, USER, "name", emlpath);
- assertThat(inMemoryMapperFactory.getMessageMapper(session).countMessagesInMailbox(mailbox)).isEqualTo(1);
- Iterator<MailboxMessage> iterator = inMemoryMapperFactory.getMessageMapper(session).findInMailbox(mailbox,
+ assertThat(mapperFactory.getMessageMapper(session).countMessagesInMailbox(mailbox)).isEqualTo(1);
+ Iterator<MailboxMessage> iterator = mapperFactory.getMessageMapper(session).findInMailbox(mailbox,
MessageRange.all(), MessageMapper.FetchType.Full, LIMIT);
MailboxMessage mailboxMessage = iterator.next();
@@ -289,12 +265,12 @@ public class MailboxManagementTest {
public void importEmlFileToMailboxShouldNotImportEmlFileWithWrongPathToGivenMailbox() throws Exception {
Mailbox mailbox = new SimpleMailbox(MailboxPath.forUser(USER, "name"),
UID_VALIDITY);
- inMemoryMapperFactory.createMailboxMapper(session).save(mailbox);
+ mapperFactory.createMailboxMapper(session).save(mailbox);
String emlpath = ClassLoader.getSystemResource("eml/frnog.eml").getFile();
mailboxManagerManagement.importEmlFileToMailbox(MailboxConstants.USER_NAMESPACE, USER, "name", "wrong_path" + emlpath);
- assertThat(inMemoryMapperFactory.getMessageMapper(session).countMessagesInMailbox(mailbox)).isEqualTo(0);
- Iterator<MailboxMessage> iterator = inMemoryMapperFactory.getMessageMapper(session).findInMailbox(mailbox,
+ assertThat(mapperFactory.getMessageMapper(session).countMessagesInMailbox(mailbox)).isEqualTo(0);
+ Iterator<MailboxMessage> iterator = mapperFactory.getMessageMapper(session).findInMailbox(mailbox,
MessageRange.all(), MessageMapper.FetchType.Full, LIMIT);
assertThat(iterator.hasNext()).isFalse();
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsOverQuotaTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsOverQuotaTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsOverQuotaTest.java
index c18771b..200ca0d 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsOverQuotaTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/matchers/IsOverQuotaTest.java
@@ -27,21 +27,12 @@ import java.util.Collection;
import org.apache.james.core.MailAddress;
import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
-import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
-import org.apache.james.mailbox.inmemory.InMemoryMailboxManager;
-import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
-import org.apache.james.mailbox.inmemory.InMemoryMessageId;
+import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
import org.apache.james.mailbox.inmemory.quota.InMemoryCurrentQuotaManager;
import org.apache.james.mailbox.inmemory.quota.InMemoryPerUserMaxQuotaManager;
import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.model.QuotaRoot;
-import org.apache.james.mailbox.store.FakeAuthenticator;
-import org.apache.james.mailbox.store.FakeAuthorizator;
-import org.apache.james.mailbox.store.NoMailboxPathLocker;
-import org.apache.james.mailbox.store.StoreRightManager;
-import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
-import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
-import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
+import org.apache.james.mailbox.store.StoreMailboxManager;
import org.apache.james.mailbox.store.quota.CurrentQuotaCalculator;
import org.apache.james.mailbox.store.quota.DefaultQuotaRootResolver;
import org.apache.james.mailbox.store.quota.StoreQuotaManager;
@@ -56,31 +47,23 @@ public class IsOverQuotaTest {
private IsOverQuota testee;
private InMemoryPerUserMaxQuotaManager maxQuotaManager;
private DefaultQuotaRootResolver quotaRootResolver;
- private InMemoryMailboxManager mailboxManager;
+ private StoreMailboxManager mailboxManager;
private UsersRepository usersRepository;
@Before
public void setUp() throws Exception {
- InMemoryMailboxSessionMapperFactory factory = new InMemoryMailboxSessionMapperFactory();
- StoreRightManager storeRightManager = new StoreRightManager(factory, new UnionMailboxACLResolver(), new SimpleGroupMembershipResolver());
+ mailboxManager = new InMemoryIntegrationResources().createMailboxManager(new SimpleGroupMembershipResolver());
- DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
- MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
- mailboxManager = new InMemoryMailboxManager(factory, new FakeAuthenticator(), FakeAuthorizator.defaultReject(),
- new NoMailboxPathLocker(), new MessageParser(),
- new InMemoryMessageId.Factory(), mailboxEventDispatcher,
- delegatingListener, storeRightManager);
-
- quotaRootResolver = new DefaultQuotaRootResolver(factory);
+ quotaRootResolver = new DefaultQuotaRootResolver(mailboxManager.getMapperFactory());
maxQuotaManager = new InMemoryPerUserMaxQuotaManager();
- InMemoryCurrentQuotaManager currentQuotaManager = new InMemoryCurrentQuotaManager(new CurrentQuotaCalculator(factory, quotaRootResolver), mailboxManager);
+ CurrentQuotaCalculator quotaCalculator = new CurrentQuotaCalculator(mailboxManager.getMapperFactory(), quotaRootResolver);
+ InMemoryCurrentQuotaManager currentQuotaManager = new InMemoryCurrentQuotaManager(quotaCalculator, mailboxManager);
StoreQuotaManager quotaManager = new StoreQuotaManager(currentQuotaManager, maxQuotaManager);
usersRepository = mock(UsersRepository.class);
testee = new IsOverQuota(quotaRootResolver, quotaManager, mailboxManager, usersRepository);
mailboxManager.setQuotaRootResolver(quotaRootResolver);
mailboxManager.setQuotaManager(quotaManager);
- mailboxManager.init();
testee.init(FakeMatcherConfig.builder().matcherName("IsOverQuota").build());
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/server/protocols/protocols-pop3/pom.xml
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-pop3/pom.xml b/server/protocols/protocols-pop3/pom.xml
index c0fd0a5..be675b2 100644
--- a/server/protocols/protocols-pop3/pom.xml
+++ b/server/protocols/protocols-pop3/pom.xml
@@ -39,11 +39,23 @@
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
+ <artifactId>apache-james-mailbox-api</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
<artifactId>apache-james-mailbox-memory</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
+ <artifactId>apache-james-mailbox-memory</artifactId>
+ <scope>test</scope>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
<artifactId>apache-james-mailbox-store</artifactId>
<scope>test</scope>
</dependency>
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/server/protocols/protocols-pop3/src/test/java/org/apache/james/pop3server/POP3ServerTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-pop3/src/test/java/org/apache/james/pop3server/POP3ServerTest.java b/server/protocols/protocols-pop3/src/test/java/org/apache/james/pop3server/POP3ServerTest.java
index a0ff351..361a5bf 100644
--- a/server/protocols/protocols-pop3/src/test/java/org/apache/james/pop3server/POP3ServerTest.java
+++ b/server/protocols/protocols-pop3/src/test/java/org/apache/james/pop3server/POP3ServerTest.java
@@ -42,21 +42,12 @@ import org.apache.james.filesystem.api.mock.MockFileSystem;
import org.apache.james.mailbox.MailboxManager;
import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.MessageManager;
-import org.apache.james.mailbox.acl.GroupMembershipResolver;
-import org.apache.james.mailbox.acl.MailboxACLResolver;
import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
-import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
+import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.store.Authorizator;
-import org.apache.james.mailbox.store.JVMMailboxPathLocker;
+import org.apache.james.mailbox.store.FakeAuthorizator;
import org.apache.james.mailbox.store.StoreMailboxManager;
-import org.apache.james.mailbox.store.StoreRightManager;
-import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
-import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
-import org.apache.james.mailbox.store.mail.model.DefaultMessageId;
-import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
import org.apache.james.pop3server.netty.POP3Server;
import org.apache.james.protocols.api.utils.ProtocolServerUtils;
import org.apache.james.protocols.lib.POP3BeforeSMTPHelper;
@@ -718,30 +709,17 @@ public class POP3ServerTest {
protected void setUpServiceManager() throws Exception {
protocolHandlerChain = new MockProtocolHandlerLoader();
protocolHandlerChain.put("usersrepository", UsersRepository.class, usersRepository);
-
- InMemoryMailboxSessionMapperFactory factory = new InMemoryMailboxSessionMapperFactory();
- MailboxACLResolver aclResolver = new UnionMailboxACLResolver();
- GroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
- MessageParser messageParser = new MessageParser();
- StoreRightManager storeRightManager = new StoreRightManager(factory, aclResolver, groupMembershipResolver);
-
- DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
- MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
- mailboxManager = new StoreMailboxManager(factory, (userid, passwd) -> {
- try {
- return usersRepository.test(userid, passwd.toString());
- } catch (UsersRepositoryException e) {
- e.printStackTrace();
- return false;
- }
- }, (userId, otherUserId) -> Authorizator.AuthorizationState.NOT_ADMIN,
- new JVMMailboxPathLocker(),
- messageParser,
- new DefaultMessageId.Factory(),
- mailboxEventDispatcher,
- delegatingListener,
- storeRightManager);
- mailboxManager.init();
+
+ mailboxManager = new InMemoryIntegrationResources()
+ .createMailboxManager(new SimpleGroupMembershipResolver(),
+ (userid, passwd) -> {
+ try {
+ return usersRepository.test(userid, passwd.toString());
+ } catch (UsersRepositoryException e) {
+ e.printStackTrace();
+ return false;
+ }
+ }, FakeAuthorizator.defaultReject());
protocolHandlerChain.put("mailboxmanager", MailboxManager.class, mailboxManager);
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[07/15] james-project git commit: MAILBOX-317 Rework
HBaseMailboxManager constructor
Posted by bt...@apache.org.
MAILBOX-317 Rework HBaseMailboxManager constructor
Passing the event system should not be optional. And It should not be class concern to init the right system.
In the operation:
- Delete one constructor
- Implement logic in only one constructor (the other should only call it)
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/3653aa9c
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/3653aa9c
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/3653aa9c
Branch: refs/heads/master
Commit: 3653aa9ca8910ac4eccdaebcfe2f81492e6b80ff
Parents: f879859
Author: benwa <bt...@linagora.com>
Authored: Thu Nov 2 09:19:47 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Fri Nov 3 09:32:32 2017 +0700
----------------------------------------------------------------------
.../james/mailbox/hbase/HBaseMailboxManager.java | 17 ++++++-----------
.../hbase/HBaseMailboxManagerStressTest.java | 11 +++++++++--
.../mailbox/hbase/HBaseMailboxManagerTest.java | 11 +++++++++--
.../imapmailbox/hbase/host/HBaseHostSystem.java | 10 ++++++++--
4 files changed, 32 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/3653aa9c/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMailboxManager.java
----------------------------------------------------------------------
diff --git a/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMailboxManager.java b/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMailboxManager.java
index be5d4d9..25e74b2 100644
--- a/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMailboxManager.java
+++ b/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMailboxManager.java
@@ -29,10 +29,11 @@ import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.model.MessageId;
import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
-import org.apache.james.mailbox.store.JVMMailboxPathLocker;
import org.apache.james.mailbox.store.StoreMailboxManager;
import org.apache.james.mailbox.store.StoreMessageManager;
import org.apache.james.mailbox.store.StoreRightManager;
+import org.apache.james.mailbox.store.event.DelegatingMailboxListener;
+import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.model.Mailbox;
import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
import org.apache.james.mailbox.store.transaction.Mapper;
@@ -49,17 +50,11 @@ public class HBaseMailboxManager extends StoreMailboxManager {
MailboxPathLocker locker,
MessageParser messageParser,
MessageId.Factory messageIdFactory,
+ MailboxEventDispatcher dispatcher,
+ DelegatingMailboxListener delegatingMailboxListener,
StoreRightManager storeRightManager) {
- super(mapperFactory, authenticator, authorizator, locker, messageParser, messageIdFactory, storeRightManager);
- }
-
- public HBaseMailboxManager(HBaseMailboxSessionMapperFactory mapperFactory,
- Authenticator authenticator,
- Authorizator authorizator,
- MessageParser messageParser,
- MessageId.Factory messageIdFactory,
- StoreRightManager storeRightManager) {
- super(mapperFactory, authenticator, authorizator, new JVMMailboxPathLocker(), messageParser, messageIdFactory, storeRightManager);
+ super(mapperFactory, authenticator, authorizator, locker, messageParser, messageIdFactory,
+ dispatcher, delegatingMailboxListener, storeRightManager);
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/3653aa9c/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerStressTest.java
----------------------------------------------------------------------
diff --git a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerStressTest.java b/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerStressTest.java
index 4fb2025..7a44866 100644
--- a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerStressTest.java
+++ b/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerStressTest.java
@@ -40,7 +40,10 @@ import org.apache.james.mailbox.hbase.mail.HBaseUidProvider;
import org.apache.james.mailbox.model.MessageId;
import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
+import org.apache.james.mailbox.store.JVMMailboxPathLocker;
import org.apache.james.mailbox.store.StoreRightManager;
+import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
+import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.model.DefaultMessageId;
import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
import org.junit.After;
@@ -66,13 +69,17 @@ public class HBaseMailboxManagerStressTest extends MailboxManagerStressTest {
Authenticator noAuthenticator = null;
Authorizator noAuthorizator = null;
+ DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
HBaseMailboxManager manager = new HBaseMailboxManager(mapperFactory,
noAuthenticator,
noAuthorizator,
+ new JVMMailboxPathLocker(),
new MessageParser(),
messageIdFactory,
- storeRightManager
- );
+ mailboxEventDispatcher,
+ delegatingListener,
+ storeRightManager);
try {
manager.init();
http://git-wip-us.apache.org/repos/asf/james-project/blob/3653aa9c/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerTest.java b/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerTest.java
index f6f8ad2..5d0cba7 100644
--- a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerTest.java
+++ b/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerTest.java
@@ -40,7 +40,10 @@ import org.apache.james.mailbox.hbase.mail.HBaseUidProvider;
import org.apache.james.mailbox.model.MessageId;
import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
+import org.apache.james.mailbox.store.JVMMailboxPathLocker;
import org.apache.james.mailbox.store.StoreRightManager;
+import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
+import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.model.DefaultMessageId;
import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
import org.junit.After;
@@ -66,13 +69,17 @@ public class HBaseMailboxManagerTest extends MailboxManagerTest {
Authenticator noAuthenticator = null;
Authorizator noAuthorizator = null;
+ DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
HBaseMailboxManager manager = new HBaseMailboxManager(mapperFactory,
noAuthenticator,
noAuthorizator,
+ new JVMMailboxPathLocker(),
new MessageParser(),
messageIdFactory,
- storeRightManager
- );
+ mailboxEventDispatcher,
+ delegatingListener,
+ storeRightManager);
try {
manager.init();
http://git-wip-us.apache.org/repos/asf/james-project/blob/3653aa9c/mpt/impl/imap-mailbox/hbase/src/test/java/org/apache/james/mpt/imapmailbox/hbase/host/HBaseHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/hbase/src/test/java/org/apache/james/mpt/imapmailbox/hbase/host/HBaseHostSystem.java b/mpt/impl/imap-mailbox/hbase/src/test/java/org/apache/james/mpt/imapmailbox/hbase/host/HBaseHostSystem.java
index 54b8ccc..1b0cacd 100644
--- a/mpt/impl/imap-mailbox/hbase/src/test/java/org/apache/james/mpt/imapmailbox/hbase/host/HBaseHostSystem.java
+++ b/mpt/impl/imap-mailbox/hbase/src/test/java/org/apache/james/mpt/imapmailbox/hbase/host/HBaseHostSystem.java
@@ -41,8 +41,11 @@ import org.apache.james.mailbox.hbase.HBaseMailboxManager;
import org.apache.james.mailbox.hbase.HBaseMailboxSessionMapperFactory;
import org.apache.james.mailbox.hbase.mail.HBaseModSeqProvider;
import org.apache.james.mailbox.hbase.mail.HBaseUidProvider;
+import org.apache.james.mailbox.store.JVMMailboxPathLocker;
import org.apache.james.mailbox.store.StoreRightManager;
import org.apache.james.mailbox.store.StoreSubscriptionManager;
+import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
+import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.model.DefaultMessageId;
import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
import org.apache.james.mailbox.store.quota.DefaultQuotaRootResolver;
@@ -103,9 +106,12 @@ public class HBaseHostSystem extends JamesImapHostSystem {
GroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
MessageParser messageParser = new MessageParser();
+ DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
StoreRightManager storeRightManager = new StoreRightManager(mapperFactory, aclResolver, groupMembershipResolver);
- mailboxManager = new HBaseMailboxManager(mapperFactory, authenticator, authorizator, messageParser,
- messageIdFactory, storeRightManager);
+ mailboxManager = new HBaseMailboxManager(mapperFactory, authenticator, authorizator,
+ new JVMMailboxPathLocker(), messageParser,
+ messageIdFactory, mailboxEventDispatcher, delegatingListener, storeRightManager);
mailboxManager.init();
SubscriptionManager subscriptionManager = new StoreSubscriptionManager(mapperFactory);
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[05/15] james-project git commit: MAILBOX-317 MailboxManager rights
API javadoc should reference RightManager
Posted by bt...@apache.org.
MAILBOX-317 MailboxManager rights API javadoc should reference RightManager
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/0930817c
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/0930817c
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/0930817c
Branch: refs/heads/master
Commit: 0930817cb1ceb561dd7223f2967b3af74119404c
Parents: afbed0f
Author: benwa <bt...@linagora.com>
Authored: Thu Nov 2 13:37:17 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Fri Nov 3 09:32:32 2017 +0700
----------------------------------------------------------------------
.../apache/james/mailbox/MailboxManager.java | 105 +------------------
.../mailbox/store/StoreMailboxManager.java | 5 +
.../base/MailboxEventAnalyserTest.java | 5 +
...ltMailboxesProvisioningFilterThreadTest.java | 5 +
4 files changed, 16 insertions(+), 104 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/0930817c/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 7a55280..67b122d 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
@@ -22,17 +22,11 @@ package org.apache.james.mailbox;
import java.util.EnumSet;
import java.util.List;
import java.util.Optional;
-import java.util.Set;
-import org.apache.james.mailbox.exception.AnnotationException;
import org.apache.james.mailbox.exception.BadCredentialsException;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.exception.MailboxExistsException;
import org.apache.james.mailbox.exception.MailboxNotFoundException;
-import org.apache.james.mailbox.exception.UnsupportedRightException;
-import org.apache.james.mailbox.model.MailboxACL;
-import org.apache.james.mailbox.model.MailboxAnnotation;
-import org.apache.james.mailbox.model.MailboxAnnotationKey;
import org.apache.james.mailbox.model.MailboxId;
import org.apache.james.mailbox.model.MailboxMetaData;
import org.apache.james.mailbox.model.MailboxPath;
@@ -74,7 +68,7 @@ import org.apache.james.mailbox.model.search.MailboxQuery;
* </p>
*/
-public interface MailboxManager extends RequestAware, MailboxListenerSupport {
+public interface MailboxManager extends RequestAware, MailboxListenerSupport, RightManager, MailboxAnnotationManager {
enum MailboxCapabilities {
Annotation,
@@ -337,78 +331,6 @@ public interface MailboxManager extends RequestAware, MailboxListenerSupport {
void logout(MailboxSession session, boolean force) throws MailboxException;
/**
- * Tells whether the given {@link MailboxSession}'s user has the given
- * {@link MailboxACL.MailboxACLRight} for this {@link MessageManager}'s mailbox.
- *
- * @param session MailboxSession of the user we want to check
- * @param right Right we want to check.
- * @param session Session of the user we want to check this right against.
- * @return true if the given {@link MailboxSession}'s user has the given
- * {@link MailboxACL.MailboxACLRight} for this {@link MessageManager}'s
- * mailbox; false otherwise.
- * @throws MailboxException
- */
- boolean hasRight(MailboxPath mailboxPath, MailboxACL.Right right, MailboxSession session) throws MailboxException;
-
- /**
- * Returns the rights applicable to the user who has sent the current
- * request on the mailbox designated by this mailboxPath.
- *
- * @param mailboxPath Path of the mailbox you want to get your rights on.
- * @param session The session used to determine the user we should retrieve the rights of.
- * @return the rights applicable to the user who has sent the request,
- * returns {@link MailboxACL#NO_RIGHTS} if
- * {@code session.getUser()} is null.
- * @throws UnsupportedRightException
- */
- MailboxACL.Rfc4314Rights myRights(MailboxPath mailboxPath, MailboxSession session) throws MailboxException;
-
- MailboxACL.Rfc4314Rights myRights(MailboxId mailboxId, MailboxSession session) throws MailboxException;
-
- /**
- * Computes a result suitable for the LISTRIGHTS IMAP command. The result is
- * computed for this mailbox and the given {@code identifier}.
- *
- * From RFC 4314 section 3.7:
- * The first element of the resulting array contains the (possibly empty)
- * set of rights the identifier will always be granted in the mailbox.
- * Following this are zero or more right sets the identifier can be granted
- * in the mailbox. Rights mentioned in the same set are tied together. The
- * server MUST either grant all tied rights to the identifier in the mailbox
- * or grant none.
- *
- * The same right MUST NOT be listed more than once in the LISTRIGHTS
- * command.
- *
- * @param mailboxPath Path of the mailbox you want to get the rights list.
- * @param identifier
- * the identifier from the LISTRIGHTS command.
- * @param session Right of the user performing the request.
- * @return result suitable for the LISTRIGHTS IMAP command
- * @throws UnsupportedRightException
- */
- MailboxACL.Rfc4314Rights[] listRigths(MailboxPath mailboxPath, MailboxACL.EntryKey identifier, MailboxSession session) throws MailboxException;
-
- /**
- * Update the Mailbox ACL of the designated mailbox. We can either ADD REPLACE or REMOVE entries.
- *
- * @param mailboxACLCommand Update to perform.
- * @throws UnsupportedRightException
- */
- void applyRightsCommand(MailboxPath mailboxPath, MailboxACL.ACLCommand mailboxACLCommand, MailboxSession session) throws MailboxException;
-
-
- /**
- * Reset the Mailbox ACL of the designated mailbox.
- *
- * @param mailboxACL New ACL value
- * @throws UnsupportedRightException
- */
- void setRights(MailboxPath mailboxPath, MailboxACL mailboxACL, MailboxSession session) throws MailboxException;
-
- void setRights(MailboxId mailboxId, MailboxACL mailboxACL, MailboxSession session) throws MailboxException;
-
- /**
* Return a unmodifiable {@link List} of {@link MailboxPath} objects
*
* @param session
@@ -417,30 +339,5 @@ public interface MailboxManager extends RequestAware, MailboxListenerSupport {
*/
List<MailboxPath> list(MailboxSession session) throws MailboxException;
- /**
- * See {@link MailboxAnnotationManager#getAllAnnotations(MailboxPath, MailboxSession)}
- */
- List<MailboxAnnotation> getAllAnnotations(MailboxPath mailboxPath, MailboxSession session) throws MailboxException;
-
- /**
- * See {@link MailboxAnnotationManager#getAnnotationsByKeys(MailboxPath, MailboxSession, Set)}
- */
- List<MailboxAnnotation> getAnnotationsByKeys(MailboxPath mailboxPath, MailboxSession session, Set<MailboxAnnotationKey> keys) throws MailboxException;
-
- /**
- * See {@link MailboxAnnotationManager#getAnnotationsByKeysWithOneDepth(MailboxPath, MailboxSession, Set)}
- */
- List<MailboxAnnotation> getAnnotationsByKeysWithOneDepth(MailboxPath mailboxPath, MailboxSession session, Set<MailboxAnnotationKey> keys) throws MailboxException;
-
- /**
- * See {@link MailboxAnnotationManager#getAnnotationsByKeysWithAllDepth(MailboxPath, MailboxSession, Set)}
- */
- List<MailboxAnnotation> getAnnotationsByKeysWithAllDepth(MailboxPath mailboxPath, MailboxSession session, Set<MailboxAnnotationKey> keys) throws MailboxException;
-
- /**
- * See {@link MailboxAnnotationManager#updateAnnotations(MailboxPath, MailboxSession, List)}
- */
- void updateAnnotations(MailboxPath mailboxPath, MailboxSession session, List<MailboxAnnotation> mailboxAnnotations) throws MailboxException, AnnotationException;
-
boolean hasChildren(MailboxPath mailboxPath, MailboxSession session) throws MailboxException;
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/0930817c/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 c53da61..3cd66b0 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
@@ -776,6 +776,11 @@ public class StoreMailboxManager implements MailboxManager {
}
@Override
+ public boolean hasRight(MailboxId mailboxId, Right right, MailboxSession session) throws MailboxException {
+ return storeRightManager.hasRight(mailboxId, right, session);
+ }
+
+ @Override
public Rfc4314Rights myRights(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
return storeRightManager.myRights(mailboxPath, session);
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/0930817c/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
index 091b5e2..45e670b 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
@@ -91,6 +91,11 @@ public class MailboxEventAnalyserTest {
private final MailboxManager mockManager = new MailboxManager() {
@Override
+ public boolean hasRight(MailboxId mailboxId, Right right, MailboxSession session) throws MailboxException {
+ return false;
+ }
+
+ @Override
public EnumSet<MailboxCapabilities> getSupportedMailboxCapabilities() {
return EnumSet.noneOf(MailboxCapabilities.class);
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/0930817c/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterThreadTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterThreadTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterThreadTest.java
index 06e9df3..69bfa0f 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterThreadTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterThreadTest.java
@@ -190,6 +190,11 @@ public class DefaultMailboxesProvisioningFilterThreadTest {
}
@Override
+ public boolean hasRight(MailboxId mailboxId, MailboxACL.Right right, MailboxSession session) throws MailboxException {
+ return false;
+ }
+
+ @Override
public boolean hasRight(MailboxPath mailboxPath, MailboxACL.Right right, MailboxSession session) throws MailboxException {
return false;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[11/15] james-project git commit: MAILBOX-317 Bonus: Avoid useless
mailboxId -> path -> mailboxId lookup
Posted by bt...@apache.org.
MAILBOX-317 Bonus: Avoid useless mailboxId -> path -> mailboxId lookup
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/d078c5e6
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/d078c5e6
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/d078c5e6
Branch: refs/heads/master
Commit: d078c5e6050fc905e43b639f414780e3292ac5df
Parents: 0930817
Author: benwa <bt...@linagora.com>
Authored: Thu Nov 2 09:58:42 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Fri Nov 3 09:32:32 2017 +0700
----------------------------------------------------------------------
.../java/org/apache/james/mailbox/store/StoreMailboxManager.java | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/d078c5e6/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 3cd66b0..8387ced 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
@@ -807,9 +807,7 @@ public class StoreMailboxManager implements MailboxManager {
@Override
public void setRights(MailboxId mailboxId, MailboxACL mailboxACL, MailboxSession session) throws MailboxException {
- MailboxMapper mapper = mailboxSessionMapperFactory.getMailboxMapper(session);
- Mailbox mailbox = mapper.findMailboxById(mailboxId);
- storeRightManager.setRights(mailbox.generateAssociatedPath(), mailboxACL, session);
+ storeRightManager.setRights(mailboxId, mailboxACL, session);
}
@Override
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[14/15] james-project git commit: MAILBOX-317 Reduce Cassandra logs
in tests
Posted by bt...@apache.org.
MAILBOX-317 Reduce Cassandra logs in 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/99c18197
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/99c18197
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/99c18197
Branch: refs/heads/master
Commit: 99c181977e4c4be19946e68bdd9e34b64de722db
Parents: c301e82
Author: Antoine Duprat <ad...@linagora.com>
Authored: Thu Nov 2 15:14:55 2017 +0100
Committer: benwa <bt...@linagora.com>
Committed: Fri Nov 3 09:32:33 2017 +0700
----------------------------------------------------------------------
backends-common/cassandra/src/test/resources/logback-test.xml | 4 ++++
mailbox/cassandra/src/test/resources/logback-test.xml | 4 ++++
mailbox/elasticsearch/src/test/resources/logback-test.xml | 4 ++++
.../guice/cassandra-guice/src/test/resources/logback-test.xml | 4 ++++
4 files changed, 16 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/99c18197/backends-common/cassandra/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/backends-common/cassandra/src/test/resources/logback-test.xml b/backends-common/cassandra/src/test/resources/logback-test.xml
index 7f9da84..ed489a2 100644
--- a/backends-common/cassandra/src/test/resources/logback-test.xml
+++ b/backends-common/cassandra/src/test/resources/logback-test.xml
@@ -21,4 +21,8 @@
<appender-ref ref="CONSOLE" />
</logger>
+ <logger name="org.apache.james.backends.cassandra.DockerCassandraRule" level="WARN" >
+ <appender-ref ref="CONSOLE" />
+ </logger>
+
</configuration>
http://git-wip-us.apache.org/repos/asf/james-project/blob/99c18197/mailbox/cassandra/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/resources/logback-test.xml b/mailbox/cassandra/src/test/resources/logback-test.xml
index f2c08d8..8785627 100644
--- a/mailbox/cassandra/src/test/resources/logback-test.xml
+++ b/mailbox/cassandra/src/test/resources/logback-test.xml
@@ -16,4 +16,8 @@
<appender-ref ref="CONSOLE" />
</root>
+ <logger name="org.apache.james.backends.cassandra.DockerCassandraRule" level="WARN" >
+ <appender-ref ref="CONSOLE" />
+ </logger>
+
</configuration>
http://git-wip-us.apache.org/repos/asf/james-project/blob/99c18197/mailbox/elasticsearch/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/test/resources/logback-test.xml b/mailbox/elasticsearch/src/test/resources/logback-test.xml
index 15e1365..0c52f6b 100644
--- a/mailbox/elasticsearch/src/test/resources/logback-test.xml
+++ b/mailbox/elasticsearch/src/test/resources/logback-test.xml
@@ -23,4 +23,8 @@
<logger name="com.datastax.driver.core.QueryLogger.SLOW" level="DEBUG" />
+ <logger name="org.apache.james.backends.cassandra.DockerCassandraRule" level="WARN" >
+ <appender-ref ref="CONSOLE" />
+ </logger>
+
</configuration>
http://git-wip-us.apache.org/repos/asf/james-project/blob/99c18197/server/container/guice/cassandra-guice/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/resources/logback-test.xml b/server/container/guice/cassandra-guice/src/test/resources/logback-test.xml
index f6f0c68..3cc9158 100644
--- a/server/container/guice/cassandra-guice/src/test/resources/logback-test.xml
+++ b/server/container/guice/cassandra-guice/src/test/resources/logback-test.xml
@@ -20,4 +20,8 @@
<logger name="com.datastax.driver.core.QueryLogger.SLOW" level="DEBUG" />
+ <logger name="org.apache.james.backends.cassandra.DockerCassandraRule" level="WARN" >
+ <appender-ref ref="CONSOLE" />
+ </logger>
+
</configuration>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[10/15] james-project git commit: MAILBOX-317 Bonus: Solve Intellij
warning about unneeded cast
Posted by bt...@apache.org.
MAILBOX-317 Bonus: Solve Intellij warning about unneeded cast
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/ce3583a9
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/ce3583a9
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/ce3583a9
Branch: refs/heads/master
Commit: ce3583a9dd96e3a1c1224accdbd4b5781d0d7d9f
Parents: d078c5e
Author: benwa <bt...@linagora.com>
Authored: Thu Nov 2 13:00:35 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Fri Nov 3 09:32:32 2017 +0700
----------------------------------------------------------------------
.../org/apache/james/mailbox/store/StoreMailboxManager.java | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/ce3583a9/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 8387ced..c13248d 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
@@ -39,7 +39,6 @@ import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.MailboxSession.SessionType;
import org.apache.james.mailbox.MailboxSessionIdGenerator;
import org.apache.james.mailbox.MessageManager;
-import org.apache.james.mailbox.RequestAware;
import org.apache.james.mailbox.StandardMailboxMetaDataComparator;
import org.apache.james.mailbox.exception.BadCredentialsException;
import org.apache.james.mailbox.exception.MailboxException;
@@ -143,9 +142,11 @@ public class StoreMailboxManager implements MailboxManager {
MessageId.Factory messageIdFactory, MailboxAnnotationManager annotationManager,
MailboxEventDispatcher mailboxEventDispatcher,
DelegatingMailboxListener delegatingListener, StoreRightManager storeRightManager) {
- this.annotationManager = annotationManager;
Preconditions.checkNotNull(delegatingListener);
Preconditions.checkNotNull(mailboxEventDispatcher);
+ Preconditions.checkNotNull(mailboxSessionMapperFactory);
+
+ this.annotationManager = annotationManager;
this.authenticator = authenticator;
this.authorizator = authorizator;
this.locker = locker;
@@ -732,9 +733,7 @@ public class StoreMailboxManager implements MailboxManager {
*/
@Override
public void endProcessingRequest(MailboxSession session) {
- if (mailboxSessionMapperFactory instanceof RequestAware) {
- ((RequestAware) mailboxSessionMapperFactory).endProcessingRequest(session);
- }
+ mailboxSessionMapperFactory.endProcessingRequest(session);
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[09/15] james-project git commit: MAILBOX-317 Limit the number of
constructor of StoreMailboxManager
Posted by bt...@apache.org.
MAILBOX-317 Limit the number of constructor of StoreMailboxManager
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/fb0c391b
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/fb0c391b
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/fb0c391b
Branch: refs/heads/master
Commit: fb0c391be061f6273d50962a3b298d46c5dfabcb
Parents: f5a2bbf
Author: benwa <bt...@linagora.com>
Authored: Thu Nov 2 09:36:33 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Fri Nov 3 09:32:32 2017 +0700
----------------------------------------------------------------------
.../james/mailbox/jpa/JPAMailboxManager.java | 11 ++++-
.../jpa/openjpa/OpenJPAMailboxManager.java | 18 +++++--
.../maildir/MaildirMailboxManagerProvider.java | 7 ++-
.../inmemory/InMemoryMailboxManager.java | 6 ++-
.../inmemory/MemoryMailboxManagerProvider.java | 7 ++-
.../mailbox/store/StoreMailboxManager.java | 50 ++------------------
.../StoreMailboxManagerAnnotationTest.java | 11 +++--
.../mailbox/store/StoreMailboxManagerTest.java | 7 ++-
.../james/mailbox/copier/MailboxCopierTest.java | 12 +++--
.../host/ElasticSearchHostSystem.java | 11 +++--
.../maildir/host/MaildirHostSystem.java | 7 ++-
.../adapter/mailbox/MailboxManagementTest.java | 7 +++
.../apache/james/pop3server/POP3ServerTest.java | 12 +++--
13 files changed, 96 insertions(+), 70 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/fb0c391b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxManager.java
----------------------------------------------------------------------
diff --git a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxManager.java b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxManager.java
index 2c61935..77dcc68 100644
--- a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxManager.java
+++ b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxManager.java
@@ -31,6 +31,8 @@ import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.StoreMailboxManager;
import org.apache.james.mailbox.store.StoreRightManager;
+import org.apache.james.mailbox.store.event.DelegatingMailboxListener;
+import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.model.Mailbox;
import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
import org.apache.james.mailbox.store.transaction.Mapper;
@@ -46,9 +48,11 @@ public abstract class JPAMailboxManager extends StoreMailboxManager {
MailboxPathLocker locker,
MessageParser messageParser,
MessageId.Factory messageIdFactory,
+ DelegatingMailboxListener delegatingMailboxListener,
+ MailboxEventDispatcher mailboxEventDispatcher,
StoreRightManager storeRightManager) {
super(mailboxSessionMapperFactory, authenticator, authorizator, locker,
- messageParser, messageIdFactory, storeRightManager);
+ messageParser, messageIdFactory, mailboxEventDispatcher, delegatingMailboxListener, storeRightManager);
}
public JPAMailboxManager(JPAMailboxSessionMapperFactory mailboxSessionMapperFactory,
@@ -57,11 +61,14 @@ public abstract class JPAMailboxManager extends StoreMailboxManager {
MailboxPathLocker locker,
MessageParser messageParser,
MessageId.Factory messageIdFactory,
+ DelegatingMailboxListener delegatingMailboxListener,
+ MailboxEventDispatcher mailboxEventDispatcher,
int limitAnnotation,
int limitAnnotationSize,
StoreRightManager storeRightManager) {
super(mailboxSessionMapperFactory, authenticator, authorizator, locker,
- messageParser, messageIdFactory, limitAnnotation, limitAnnotationSize, storeRightManager);
+ messageParser, messageIdFactory, limitAnnotation, limitAnnotationSize,
+ mailboxEventDispatcher, delegatingMailboxListener, storeRightManager);
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/fb0c391b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/openjpa/OpenJPAMailboxManager.java
----------------------------------------------------------------------
diff --git a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/openjpa/OpenJPAMailboxManager.java b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/openjpa/OpenJPAMailboxManager.java
index 52dc140..48339d1 100644
--- a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/openjpa/OpenJPAMailboxManager.java
+++ b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/openjpa/OpenJPAMailboxManager.java
@@ -36,6 +36,8 @@ import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.JVMMailboxPathLocker;
import org.apache.james.mailbox.store.StoreMessageManager;
import org.apache.james.mailbox.store.StoreRightManager;
+import org.apache.james.mailbox.store.event.DelegatingMailboxListener;
+import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.model.Mailbox;
import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
@@ -56,9 +58,11 @@ public class OpenJPAMailboxManager extends JPAMailboxManager {
MessageId.Factory messageIdFactory,
int annotationLimit,
int annotationLimitSize,
+ DelegatingMailboxListener delegatingMailboxListener,
+ MailboxEventDispatcher mailboxEventDispatcher,
StoreRightManager storeRightManager) {
super(mapperFactory, authenticator, authorizator, locker, messageParser,
- messageIdFactory, annotationLimit, annotationLimitSize, storeRightManager);
+ messageIdFactory, delegatingMailboxListener, mailboxEventDispatcher, annotationLimit, annotationLimitSize, storeRightManager);
if (useStreaming) {
feature = AdvancedFeature.Streaming;
} else {
@@ -73,9 +77,11 @@ public class OpenJPAMailboxManager extends JPAMailboxManager {
String encryptPass,
MessageParser messageParser,
MessageId.Factory messageIdFactory,
+ DelegatingMailboxListener delegatingMailboxListener,
+ MailboxEventDispatcher mailboxEventDispatcher,
StoreRightManager storeRightManager) {
super(mapperFactory, authenticator, authorizator, locker, messageParser,
- messageIdFactory, storeRightManager);
+ messageIdFactory, delegatingMailboxListener, mailboxEventDispatcher, storeRightManager);
if (encryptPass != null) {
EncryptDecryptHelper.init(encryptPass);
feature = AdvancedFeature.Encryption;
@@ -90,10 +96,12 @@ public class OpenJPAMailboxManager extends JPAMailboxManager {
Authorizator authorizator,
MessageParser messageParser,
MessageId.Factory messageIdFactory,
+ DelegatingMailboxListener delegatingMailboxListener,
+ MailboxEventDispatcher mailboxEventDispatcher,
StoreRightManager storeRightManager) {
this(mapperFactory, authenticator, authorizator, new JVMMailboxPathLocker(), false,
messageParser, messageIdFactory, MailboxConstants.DEFAULT_LIMIT_ANNOTATIONS_ON_MAILBOX,
- MailboxConstants.DEFAULT_LIMIT_ANNOTATION_SIZE, storeRightManager);
+ MailboxConstants.DEFAULT_LIMIT_ANNOTATION_SIZE, delegatingMailboxListener, mailboxEventDispatcher, storeRightManager);
}
public OpenJPAMailboxManager(JPAMailboxSessionMapperFactory mapperFactory,
@@ -103,9 +111,11 @@ public class OpenJPAMailboxManager extends JPAMailboxManager {
MessageId.Factory messageIdFactory,
int annotationLimit,
int annotationLimitSize,
+ DelegatingMailboxListener delegatingMailboxListener,
+ MailboxEventDispatcher mailboxEventDispatcher,
StoreRightManager storeRightManager) {
this(mapperFactory, authenticator, authorizator, new JVMMailboxPathLocker(), false,
- messageParser, messageIdFactory, annotationLimit, annotationLimitSize, storeRightManager);
+ messageParser, messageIdFactory, annotationLimit, annotationLimitSize, delegatingMailboxListener, mailboxEventDispatcher, storeRightManager);
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/fb0c391b/mailbox/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerProvider.java
----------------------------------------------------------------------
diff --git a/mailbox/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerProvider.java b/mailbox/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerProvider.java
index e36e020..88bcf7c 100644
--- a/mailbox/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerProvider.java
+++ b/mailbox/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerProvider.java
@@ -31,6 +31,8 @@ import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.JVMMailboxPathLocker;
import org.apache.james.mailbox.store.StoreMailboxManager;
import org.apache.james.mailbox.store.StoreRightManager;
+import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
+import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.model.DefaultMessageId;
import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
import org.junit.rules.TemporaryFolder;
@@ -47,8 +49,11 @@ public class MaildirMailboxManagerProvider {
Authenticator noAuthenticator = null;
Authorizator noAuthorizator = null;
+
+ DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
StoreMailboxManager manager = new StoreMailboxManager(mf, noAuthenticator, noAuthorizator, new JVMMailboxPathLocker(),
- messageParser, new DefaultMessageId.Factory(), storeRightManager);
+ messageParser, new DefaultMessageId.Factory(), mailboxEventDispatcher, delegatingListener, storeRightManager);
manager.init();
return manager;
http://git-wip-us.apache.org/repos/asf/james-project/blob/fb0c391b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManager.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManager.java b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManager.java
index 07f8f8a..884bc9b 100644
--- a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManager.java
+++ b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManager.java
@@ -30,6 +30,7 @@ import org.apache.james.mailbox.model.MailboxConstants;
import org.apache.james.mailbox.model.MessageId;
import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
+import org.apache.james.mailbox.store.JVMMailboxPathLocker;
import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
import org.apache.james.mailbox.store.StoreMailboxManager;
import org.apache.james.mailbox.store.StoreMessageManager;
@@ -54,8 +55,11 @@ public class InMemoryMailboxManager extends StoreMailboxManager {
public InMemoryMailboxManager(MailboxSessionMapperFactory mailboxSessionMapperFactory, Authenticator authenticator, Authorizator authorizator,
MessageParser messageParser, MessageId.Factory messageIdFactory,
int limitOfAnnotations, int limitAnnotationSize,
+ MailboxEventDispatcher dispatcher,
+ DelegatingMailboxListener delegatingMailboxListener,
StoreRightManager storeRightManager) {
- super(mailboxSessionMapperFactory, authenticator, authorizator, messageParser, messageIdFactory, limitOfAnnotations, limitAnnotationSize, storeRightManager);
+ super(mailboxSessionMapperFactory, authenticator, authorizator, new JVMMailboxPathLocker(), messageParser, messageIdFactory,
+ limitOfAnnotations, limitAnnotationSize, dispatcher, delegatingMailboxListener, storeRightManager);
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/fb0c391b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/MemoryMailboxManagerProvider.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/MemoryMailboxManagerProvider.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/MemoryMailboxManagerProvider.java
index 7438442..be1c2b9 100644
--- a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/MemoryMailboxManagerProvider.java
+++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/MemoryMailboxManagerProvider.java
@@ -29,6 +29,8 @@ import org.apache.james.mailbox.model.MessageId;
import org.apache.james.mailbox.store.FakeAuthenticator;
import org.apache.james.mailbox.store.FakeAuthorizator;
import org.apache.james.mailbox.store.StoreRightManager;
+import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
+import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
import com.google.common.base.Throwables;
@@ -45,8 +47,11 @@ public class MemoryMailboxManagerProvider {
InMemoryMailboxSessionMapperFactory mailboxSessionMapperFactory = new InMemoryMailboxSessionMapperFactory();
StoreRightManager storeRightManager = new StoreRightManager(mailboxSessionMapperFactory, aclResolver, groupMembershipResolver);
MessageId.Factory messageIdFactory = new InMemoryMessageId.Factory();
+ DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
InMemoryMailboxManager mailboxManager = new InMemoryMailboxManager(mailboxSessionMapperFactory, new FakeAuthenticator(), FakeAuthorizator.defaultReject(),
- messageParser, messageIdFactory, LIMIT_ANNOTATIONS, LIMIT_ANNOTATION_SIZE, storeRightManager);
+ messageParser, messageIdFactory, LIMIT_ANNOTATIONS, LIMIT_ANNOTATION_SIZE,
+ mailboxEventDispatcher, delegatingListener, storeRightManager);
try {
mailboxManager.init();
http://git-wip-us.apache.org/repos/asf/james-project/blob/fb0c391b/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 de7424b..dadc77c 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
@@ -65,7 +65,6 @@ import org.apache.james.mailbox.model.search.MailboxNameExpression;
import org.apache.james.mailbox.model.search.MailboxQuery;
import org.apache.james.mailbox.quota.QuotaManager;
import org.apache.james.mailbox.quota.QuotaRootResolver;
-import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
import org.apache.james.mailbox.store.event.DelegatingMailboxListener;
import org.apache.james.mailbox.store.event.MailboxAnnotationListener;
import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
@@ -88,6 +87,7 @@ import org.slf4j.LoggerFactory;
import com.github.fge.lambdas.Throwing;
import com.github.steveash.guavate.Guavate;
import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
@@ -103,9 +103,8 @@ public class StoreMailboxManager implements MailboxManager {
private static final Logger LOGGER = LoggerFactory.getLogger(StoreMailboxManager.class);
public static final char SQL_WILDCARD_CHAR = '%';
-
- private MailboxEventDispatcher dispatcher;
- private DelegatingMailboxListener delegatingListener;
+ private final MailboxEventDispatcher dispatcher;
+ private final DelegatingMailboxListener delegatingListener;
private final MailboxSessionMapperFactory mailboxSessionMapperFactory;
private final Authenticator authenticator;
@@ -136,11 +135,8 @@ public class StoreMailboxManager implements MailboxManager {
private final MessageParser messageParser;
private final Factory messageIdFactory;
-
private final int limitOfAnnotations;
-
private final int limitAnnotationSize;
-
private final ImmutableMailboxMessage.Factory immutableMailboxMessageFactory;
@Inject
@@ -153,28 +149,11 @@ public class StoreMailboxManager implements MailboxManager {
}
public StoreMailboxManager(MailboxSessionMapperFactory mailboxSessionMapperFactory, Authenticator authenticator, Authorizator authorizator,
- MailboxPathLocker locker, MessageParser messageParser, MessageId.Factory messageIdFactory, StoreRightManager storeRightManager) {
- this(mailboxSessionMapperFactory, authenticator, authorizator, locker, messageParser, messageIdFactory,
- MailboxConstants.DEFAULT_LIMIT_ANNOTATIONS_ON_MAILBOX, MailboxConstants.DEFAULT_LIMIT_ANNOTATION_SIZE, storeRightManager);
- }
-
- public StoreMailboxManager(MailboxSessionMapperFactory mailboxSessionMapperFactory, Authenticator authenticator, Authorizator authorizator,
- MessageParser messageParser, MessageId.Factory messageIdFactory, int limitOfAnnotations, int limitAnnotationSize, StoreRightManager storeRightManager) {
- this(mailboxSessionMapperFactory, authenticator, authorizator, new JVMMailboxPathLocker(), messageParser, messageIdFactory,
- limitOfAnnotations, limitAnnotationSize, storeRightManager);
- }
-
- public StoreMailboxManager(MailboxSessionMapperFactory mailboxSessionMapperFactory, Authenticator authenticator, Authorizator authorizator,
- MailboxPathLocker locker, MessageParser messageParser,
- MessageId.Factory messageIdFactory, int limitOfAnnotations, int limitAnnotationSize, StoreRightManager storeRightManager) {
- this(mailboxSessionMapperFactory, authenticator, authorizator, locker, messageParser, messageIdFactory,
- limitOfAnnotations, limitAnnotationSize, null, null, storeRightManager);
- }
-
- public StoreMailboxManager(MailboxSessionMapperFactory mailboxSessionMapperFactory, Authenticator authenticator, Authorizator authorizator,
MailboxPathLocker locker, MessageParser messageParser,
MessageId.Factory messageIdFactory, int limitOfAnnotations, int limitAnnotationSize, MailboxEventDispatcher mailboxEventDispatcher,
DelegatingMailboxListener delegatingListener, StoreRightManager storeRightManager) {
+ Preconditions.checkNotNull(delegatingListener);
+ Preconditions.checkNotNull(mailboxEventDispatcher);
this.authenticator = authenticator;
this.authorizator = authorizator;
this.locker = locker;
@@ -236,11 +215,6 @@ public class StoreMailboxManager implements MailboxManager {
*/
@PostConstruct
public void init() throws MailboxException {
-
- if (dispatcher == null) {
- dispatcher = new MailboxEventDispatcher(getDelegationListener());
- }
-
if (index == null) {
index = new SimpleMessageSearchIndex(mailboxSessionMapperFactory, mailboxSessionMapperFactory, new DefaultTextExtractor());
}
@@ -294,9 +268,6 @@ public class StoreMailboxManager implements MailboxManager {
* @return delegatingListener
*/
public DelegatingMailboxListener getDelegationListener() {
- if (delegatingListener == null) {
- delegatingListener = new DefaultDelegatingMailboxListener();
- }
return delegatingListener;
}
@@ -349,17 +320,6 @@ public class StoreMailboxManager implements MailboxManager {
}
/**
- * Set the {@link DelegatingMailboxListener} to use with this {@link MailboxManager} instance. If none is set here a {@link DefaultDelegatingMailboxListener} instance will
- * be created lazy
- *
- * @param delegatingListener
- */
- public void setDelegatingMailboxListener(DelegatingMailboxListener delegatingListener) {
- this.delegatingListener = delegatingListener;
- dispatcher = new MailboxEventDispatcher(getDelegationListener());
- }
-
- /**
* Set the {@link MessageSearchIndex} which should be used by this {@link MailboxManager}. If none is given this implementation will use a {@link SimpleMessageSearchIndex}
* by default
*
http://git-wip-us.apache.org/repos/asf/james-project/blob/fb0c391b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerAnnotationTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerAnnotationTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerAnnotationTest.java
index ffc4b94..ccf2304 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerAnnotationTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerAnnotationTest.java
@@ -38,10 +38,11 @@ import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.mock.MockMailboxSession;
import org.apache.james.mailbox.model.MailboxAnnotation;
import org.apache.james.mailbox.model.MailboxAnnotationKey;
-import org.apache.james.mailbox.model.MailboxConstants;
import org.apache.james.mailbox.model.MailboxId;
import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.model.MessageId;
+import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
+import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.AnnotationMapper;
import org.apache.james.mailbox.store.mail.MailboxMapper;
import org.apache.james.mailbox.store.mail.model.Mailbox;
@@ -103,10 +104,12 @@ public class StoreMailboxManagerAnnotationTest {
StoreRightManager storeRightManager = new StoreRightManager(mailboxSessionMapperFactory, aclResolver,
groupMembershipResolver);
+ DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
storeMailboxManager = spy(new StoreMailboxManager(mailboxSessionMapperFactory, authenticator, authorizator,
- messageParser, messageIdFactory,
- MailboxConstants.DEFAULT_LIMIT_ANNOTATIONS_ON_MAILBOX,
- MailboxConstants.DEFAULT_LIMIT_ANNOTATION_SIZE,
+ new JVMMailboxPathLocker(), messageParser, messageIdFactory,
+ mailboxEventDispatcher,
+ delegatingListener,
storeRightManager));
storeMailboxManager.init();
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/fb0c391b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java
index 8c9a76d..846cfb0 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java
@@ -42,6 +42,8 @@ import org.apache.james.mailbox.model.MessageId.Factory;
import org.apache.james.mailbox.model.TestId;
import org.apache.james.mailbox.model.search.MailboxQuery;
import org.apache.james.mailbox.model.search.PrefixedRegex;
+import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
+import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.MailboxMapper;
import org.apache.james.mailbox.store.mail.model.Mailbox;
import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
@@ -74,8 +76,11 @@ public class StoreMailboxManagerTest {
authenticator.addUser(CURRENT_USER, CURRENT_USER_PASSWORD);
authenticator.addUser(ADMIN, ADMIN_PASSWORD);
StoreRightManager storeRightManager = new StoreRightManager(mockedMapperFactory, new UnionMailboxACLResolver(), new SimpleGroupMembershipResolver());
+
+ DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
storeMailboxManager = new StoreMailboxManager(mockedMapperFactory, authenticator, FakeAuthorizator.forUserAndAdmin(ADMIN, CURRENT_USER),
- new JVMMailboxPathLocker(), new MessageParser(), messageIdFactory, storeRightManager);
+ new JVMMailboxPathLocker(), new MessageParser(), messageIdFactory, mailboxEventDispatcher, delegatingListener, storeRightManager);
storeMailboxManager.init();
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/fb0c391b/mailbox/tool/src/test/java/org/apache/james/mailbox/copier/MailboxCopierTest.java
----------------------------------------------------------------------
diff --git a/mailbox/tool/src/test/java/org/apache/james/mailbox/copier/MailboxCopierTest.java b/mailbox/tool/src/test/java/org/apache/james/mailbox/copier/MailboxCopierTest.java
index 89d9462..27f5187 100644
--- a/mailbox/tool/src/test/java/org/apache/james/mailbox/copier/MailboxCopierTest.java
+++ b/mailbox/tool/src/test/java/org/apache/james/mailbox/copier/MailboxCopierTest.java
@@ -35,11 +35,13 @@ import org.apache.james.mailbox.exception.BadCredentialsException;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
import org.apache.james.mailbox.mock.MockMailboxManager;
-import org.apache.james.mailbox.model.MailboxConstants;
import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.store.Authorizator;
+import org.apache.james.mailbox.store.JVMMailboxPathLocker;
import org.apache.james.mailbox.store.StoreMailboxManager;
import org.apache.james.mailbox.store.StoreRightManager;
+import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
+import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.model.DefaultMessageId;
import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
import org.junit.Before;
@@ -159,14 +161,18 @@ public class MailboxCopierTest {
MessageParser messageParser = new MessageParser();
InMemoryMailboxSessionMapperFactory mapperFactory = new InMemoryMailboxSessionMapperFactory();
StoreRightManager storeRightManager = new StoreRightManager(mapperFactory, aclResolver, groupMembershipResolver);
+
+ DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
return new StoreMailboxManager(
mapperFactory,
(userid, passwd) -> AUTHENTIC,
(userId, otherUserId) -> Authorizator.AuthorizationState.NOT_ADMIN,
+ new JVMMailboxPathLocker(),
messageParser,
new DefaultMessageId.Factory(),
- MailboxConstants.DEFAULT_LIMIT_ANNOTATIONS_ON_MAILBOX,
- MailboxConstants.DEFAULT_LIMIT_ANNOTATION_SIZE,
+ mailboxEventDispatcher,
+ delegatingListener,
storeRightManager);
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/fb0c391b/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java b/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
index 4d6d184..369492f 100644
--- a/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
+++ b/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
@@ -53,10 +53,12 @@ import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.inmemory.InMemoryId;
import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
import org.apache.james.mailbox.inmemory.InMemoryMessageId;
-import org.apache.james.mailbox.model.MailboxConstants;
+import org.apache.james.mailbox.store.JVMMailboxPathLocker;
import org.apache.james.mailbox.store.StoreMailboxManager;
import org.apache.james.mailbox.store.StoreRightManager;
import org.apache.james.mailbox.store.StoreSubscriptionManager;
+import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
+import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.extractor.DefaultTextExtractor;
import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
import org.apache.james.mailbox.store.quota.DefaultQuotaRootResolver;
@@ -124,9 +126,10 @@ public class ElasticSearchHostSystem extends JamesImapHostSystem {
StoreRightManager storeRightManager = new StoreRightManager(factory, aclResolver, groupMembershipResolver);
- mailboxManager = new StoreMailboxManager(factory, authenticator, authorizator, messageParser,
- messageIdFactory, MailboxConstants.DEFAULT_LIMIT_ANNOTATIONS_ON_MAILBOX,
- MailboxConstants.DEFAULT_LIMIT_ANNOTATION_SIZE, storeRightManager);
+ DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
+ mailboxManager = new StoreMailboxManager(factory, authenticator, authorizator, new JVMMailboxPathLocker(),
+ messageParser, messageIdFactory, mailboxEventDispatcher, delegatingListener, storeRightManager);
mailboxManager.setMessageSearchIndex(searchIndex);
try {
http://git-wip-us.apache.org/repos/asf/james-project/blob/fb0c391b/mpt/impl/imap-mailbox/maildir/src/test/java/org/apache/james/mpt/imapmailbox/maildir/host/MaildirHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/maildir/src/test/java/org/apache/james/mpt/imapmailbox/maildir/host/MaildirHostSystem.java b/mpt/impl/imap-mailbox/maildir/src/test/java/org/apache/james/mpt/imapmailbox/maildir/host/MaildirHostSystem.java
index f39ab06..6f7799e 100644
--- a/mpt/impl/imap-mailbox/maildir/src/test/java/org/apache/james/mpt/imapmailbox/maildir/host/MaildirHostSystem.java
+++ b/mpt/impl/imap-mailbox/maildir/src/test/java/org/apache/james/mpt/imapmailbox/maildir/host/MaildirHostSystem.java
@@ -37,6 +37,8 @@ import org.apache.james.mailbox.store.JVMMailboxPathLocker;
import org.apache.james.mailbox.store.StoreMailboxManager;
import org.apache.james.mailbox.store.StoreRightManager;
import org.apache.james.mailbox.store.StoreSubscriptionManager;
+import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
+import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.model.DefaultMessageId;
import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
import org.apache.james.mailbox.store.quota.DefaultQuotaRootResolver;
@@ -70,9 +72,12 @@ public class MaildirHostSystem extends JamesImapHostSystem {
GroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
MessageParser messageParser = new MessageParser();
+ DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
StoreRightManager storeRightManager = new StoreRightManager(mailboxSessionMapperFactory, aclResolver, groupMembershipResolver);
mailboxManager = new StoreMailboxManager(mailboxSessionMapperFactory, authenticator, authorizator, locker,
- messageParser, new DefaultMessageId.Factory(), storeRightManager);
+ messageParser, new DefaultMessageId.Factory(), mailboxEventDispatcher,
+ delegatingListener, storeRightManager);
mailboxManager.init();
final ImapProcessor defaultImapProcessorFactory =
http://git-wip-us.apache.org/repos/asf/james-project/blob/fb0c391b/server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/MailboxManagementTest.java
----------------------------------------------------------------------
diff --git a/server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/MailboxManagementTest.java b/server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/MailboxManagementTest.java
index bf80ffb..380a09f 100644
--- a/server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/MailboxManagementTest.java
+++ b/server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/MailboxManagementTest.java
@@ -40,6 +40,8 @@ import org.apache.james.mailbox.store.FakeAuthorizator;
import org.apache.james.mailbox.store.JVMMailboxPathLocker;
import org.apache.james.mailbox.store.StoreMailboxManager;
import org.apache.james.mailbox.store.StoreRightManager;
+import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
+import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.MessageMapper;
import org.apache.james.mailbox.store.mail.model.DefaultMessageId;
import org.apache.james.mailbox.store.mail.model.Mailbox;
@@ -68,6 +70,9 @@ public class MailboxManagementTest {
new UnionMailboxACLResolver(),
new SimpleGroupMembershipResolver());
+
+ DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
StoreMailboxManager mailboxManager = new StoreMailboxManager(
inMemoryMapperFactory,
new FakeAuthenticator(),
@@ -75,6 +80,8 @@ public class MailboxManagementTest {
new JVMMailboxPathLocker(),
new MessageParser(),
new DefaultMessageId.Factory(),
+ mailboxEventDispatcher,
+ delegatingListener,
storeRightManager);
mailboxManager.init();
http://git-wip-us.apache.org/repos/asf/james-project/blob/fb0c391b/server/protocols/protocols-pop3/src/test/java/org/apache/james/pop3server/POP3ServerTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-pop3/src/test/java/org/apache/james/pop3server/POP3ServerTest.java b/server/protocols/protocols-pop3/src/test/java/org/apache/james/pop3server/POP3ServerTest.java
index 1fc9a50..a0ff351 100644
--- a/server/protocols/protocols-pop3/src/test/java/org/apache/james/pop3server/POP3ServerTest.java
+++ b/server/protocols/protocols-pop3/src/test/java/org/apache/james/pop3server/POP3ServerTest.java
@@ -48,11 +48,13 @@ import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
-import org.apache.james.mailbox.model.MailboxConstants;
import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.store.Authorizator;
+import org.apache.james.mailbox.store.JVMMailboxPathLocker;
import org.apache.james.mailbox.store.StoreMailboxManager;
import org.apache.james.mailbox.store.StoreRightManager;
+import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
+import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.model.DefaultMessageId;
import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
import org.apache.james.pop3server.netty.POP3Server;
@@ -722,6 +724,9 @@ public class POP3ServerTest {
GroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
MessageParser messageParser = new MessageParser();
StoreRightManager storeRightManager = new StoreRightManager(factory, aclResolver, groupMembershipResolver);
+
+ DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
mailboxManager = new StoreMailboxManager(factory, (userid, passwd) -> {
try {
return usersRepository.test(userid, passwd.toString());
@@ -730,10 +735,11 @@ public class POP3ServerTest {
return false;
}
}, (userId, otherUserId) -> Authorizator.AuthorizationState.NOT_ADMIN,
+ new JVMMailboxPathLocker(),
messageParser,
new DefaultMessageId.Factory(),
- MailboxConstants.DEFAULT_LIMIT_ANNOTATIONS_ON_MAILBOX,
- MailboxConstants.DEFAULT_LIMIT_ANNOTATION_SIZE,
+ mailboxEventDispatcher,
+ delegatingListener,
storeRightManager);
mailboxManager.init();
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[02/15] james-project git commit: MAILBOX-317 Rework
CassandraMailboxManager constructor
Posted by bt...@apache.org.
MAILBOX-317 Rework CassandraMailboxManager constructor
Passing the event system should not be optional. And It should not be class concern to init the right system.
In the operation:
- Delete one constructor
- Implement logic in only one constructor (the other should only call it)
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/b3eb1b2a
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/b3eb1b2a
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/b3eb1b2a
Branch: refs/heads/master
Commit: b3eb1b2ad693f409a03525204a04c42fb70a1d16
Parents: 4e1be59
Author: benwa <bt...@linagora.com>
Authored: Thu Nov 2 09:00:01 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Fri Nov 3 09:32:31 2017 +0700
----------------------------------------------------------------------
.../cassandra/CassandraMailboxManager.java | 33 +++++++-------------
.../CassandraMailboxManagerProvider.java | 7 ++++-
.../cassandra/CassandraTestSystemFixture.java | 11 ++++++-
.../CassandraMailboxManagerAttachmentTest.java | 17 ++++++++--
.../cassandra/host/CassandraHostSystem.java | 12 ++++++-
5 files changed, 53 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/b3eb1b2a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxManager.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxManager.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxManager.java
index 448c9d9..2f68d6c 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxManager.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxManager.java
@@ -26,8 +26,6 @@ import javax.inject.Inject;
import org.apache.james.mailbox.MailboxManager;
import org.apache.james.mailbox.MailboxPathLocker;
import org.apache.james.mailbox.MailboxSession;
-import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
-import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.model.MailboxACL;
import org.apache.james.mailbox.model.MailboxConstants;
@@ -55,8 +53,9 @@ public class CassandraMailboxManager extends StoreMailboxManager {
@Inject
public CassandraMailboxManager(CassandraMailboxSessionMapperFactory mapperFactory, Authenticator authenticator, Authorizator authorizator,
MailboxPathLocker locker, MessageParser messageParser, MessageId.Factory messageIdFactory,
- MailboxEventDispatcher mailboxEventDispatcher, DelegatingMailboxListener delegatingMailboxListener) {
- super(mapperFactory,
+ MailboxEventDispatcher mailboxEventDispatcher, DelegatingMailboxListener delegatingMailboxListener,
+ StoreRightManager storeRightManager) {
+ this(mapperFactory,
authenticator,
authorizator,
locker,
@@ -66,34 +65,24 @@ public class CassandraMailboxManager extends StoreMailboxManager {
MailboxConstants.DEFAULT_LIMIT_ANNOTATION_SIZE,
mailboxEventDispatcher,
delegatingMailboxListener,
- new StoreRightManager(mapperFactory, new UnionMailboxACLResolver(), new SimpleGroupMembershipResolver()));
- this.locker = locker;
- this.mapperFactory = mapperFactory;
- }
-
- public CassandraMailboxManager(CassandraMailboxSessionMapperFactory mapperFactory, Authenticator authenticator, Authorizator authorizator,
- MailboxPathLocker locker, MessageParser messageParser, MessageId.Factory messageIdFactory) {
- super(mapperFactory,
- authenticator,
- authorizator,
- locker,
- messageParser,
- messageIdFactory,
- new StoreRightManager(mapperFactory, new UnionMailboxACLResolver(), new SimpleGroupMembershipResolver()));
- this.locker = locker;
- this.mapperFactory = mapperFactory;
+ storeRightManager);
}
public CassandraMailboxManager(CassandraMailboxSessionMapperFactory mapperFactory, Authenticator authenticator, Authorizator authorizator,
- MailboxPathLocker locker, MessageParser messageParser,
- MessageId.Factory messageIdFactory, int limitOfAnnotations, int limitAnnotationSize, StoreRightManager storeRightManager) {
+ MailboxPathLocker locker, MessageParser messageParser,
+ MessageId.Factory messageIdFactory, int limitOfAnnotations, int limitAnnotationSize,
+ MailboxEventDispatcher mailboxEventDispatcher, DelegatingMailboxListener delegatingMailboxListener,
+ StoreRightManager storeRightManager) {
super(mapperFactory,
authenticator,
authorizator,
+ locker,
messageParser,
messageIdFactory,
limitOfAnnotations,
limitAnnotationSize,
+ mailboxEventDispatcher,
+ delegatingMailboxListener,
storeRightManager);
this.locker = locker;
this.mapperFactory = mapperFactory;
http://git-wip-us.apache.org/repos/asf/james-project/blob/b3eb1b2a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerProvider.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerProvider.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerProvider.java
index bc23445..85d809f 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerProvider.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerProvider.java
@@ -30,6 +30,8 @@ import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.NoMailboxPathLocker;
import org.apache.james.mailbox.store.StoreRightManager;
+import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
+import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
import com.datastax.driver.core.Session;
@@ -54,8 +56,11 @@ public class CassandraMailboxManagerProvider {
Authenticator noAuthenticator = null;
Authorizator noAuthorizator = null;
+ DefaultDelegatingMailboxListener delegatingMailboxListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingMailboxListener);
+
CassandraMailboxManager manager = new CassandraMailboxManager(mapperFactory, noAuthenticator, noAuthorizator, new NoMailboxPathLocker(),
- messageParser, messageIdFactory, LIMIT_ANNOTATIONS, LIMIT_ANNOTATION_SIZE, storeRightManager);
+ messageParser, messageIdFactory, LIMIT_ANNOTATIONS, LIMIT_ANNOTATION_SIZE, mailboxEventDispatcher, delegatingMailboxListener, storeRightManager);
try {
manager.init();
} catch (MailboxException e) {
http://git-wip-us.apache.org/repos/asf/james-project/blob/b3eb1b2a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java
index 57e2f09..1dfe2bc 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java
@@ -22,6 +22,8 @@ package org.apache.james.mailbox.cassandra;
import static org.mockito.Mockito.mock;
import org.apache.james.backends.cassandra.CassandraCluster;
+import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
+import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
import org.apache.james.mailbox.cassandra.ids.CassandraMessageId;
import org.apache.james.mailbox.cassandra.quota.CassandraCurrentQuotaManager;
import org.apache.james.mailbox.cassandra.quota.CassandraPerUserMaxQuotaManager;
@@ -32,6 +34,8 @@ import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.NoMailboxPathLocker;
import org.apache.james.mailbox.store.StoreMessageIdManager;
+import org.apache.james.mailbox.store.StoreRightManager;
+import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
import org.apache.james.mailbox.store.quota.DefaultQuotaRootResolver;
@@ -51,8 +55,13 @@ public class CassandraTestSystemFixture {
}
public static CassandraMailboxManager createMailboxManager(CassandraMailboxSessionMapperFactory mapperFactory) throws Exception{
+ DefaultDelegatingMailboxListener delegatingMailboxListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingMailboxListener);
+ StoreRightManager storeRightManager = new StoreRightManager(mapperFactory, new UnionMailboxACLResolver(), new SimpleGroupMembershipResolver());
+
CassandraMailboxManager cassandraMailboxManager = new CassandraMailboxManager(mapperFactory, mock(Authenticator.class), mock(Authorizator.class),
- new NoMailboxPathLocker(), new MessageParser(), new CassandraMessageId.Factory());
+ new NoMailboxPathLocker(), new MessageParser(), new CassandraMessageId.Factory(),
+ mailboxEventDispatcher, delegatingMailboxListener, storeRightManager);
cassandraMailboxManager.init();
return cassandraMailboxManager;
http://git-wip-us.apache.org/repos/asf/james-project/blob/b3eb1b2a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxManagerAttachmentTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxManagerAttachmentTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxManagerAttachmentTest.java
index e19e594..6a3f5b0 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxManagerAttachmentTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxManagerAttachmentTest.java
@@ -26,6 +26,8 @@ import org.apache.james.backends.cassandra.CassandraCluster;
import org.apache.james.backends.cassandra.DockerCassandraRule;
import org.apache.james.backends.cassandra.init.CassandraModuleComposite;
import org.apache.james.mailbox.MailboxManager;
+import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
+import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
import org.apache.james.mailbox.cassandra.CassandraMailboxManager;
import org.apache.james.mailbox.cassandra.CassandraMailboxSessionMapperFactory;
import org.apache.james.mailbox.cassandra.TestCassandraMailboxSessionMapperFactory;
@@ -47,6 +49,9 @@ import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
import org.apache.james.mailbox.store.NoMailboxPathLocker;
+import org.apache.james.mailbox.store.StoreRightManager;
+import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
+import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.AttachmentMapperFactory;
import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
import org.junit.After;
@@ -99,12 +104,20 @@ public class CassandraMailboxManagerAttachmentTest extends AbstractMailboxManage
messageIdFactory);
Authenticator noAuthenticator = null;
Authorizator noAuthorizator = null;
- mailboxManager = new CassandraMailboxManager(mailboxSessionMapperFactory, noAuthenticator, noAuthorizator, new NoMailboxPathLocker(), new MessageParser(), messageIdFactory);
+ DefaultDelegatingMailboxListener delegatingMailboxListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingMailboxListener);
+ StoreRightManager storeRightManager = new StoreRightManager(mailboxSessionMapperFactory, new UnionMailboxACLResolver(), new SimpleGroupMembershipResolver());
+
+ mailboxManager = new CassandraMailboxManager(mailboxSessionMapperFactory,
+ noAuthenticator, noAuthorizator, new NoMailboxPathLocker(), new MessageParser(),
+ messageIdFactory, mailboxEventDispatcher, delegatingMailboxListener, storeRightManager);
mailboxManager.init();
MessageParser failingMessageParser = mock(MessageParser.class);
when(failingMessageParser.retrieveAttachments(any()))
.thenThrow(new RuntimeException("Message parser set to fail"));
- parseFailingMailboxManager = new CassandraMailboxManager(mailboxSessionMapperFactory, noAuthenticator, noAuthorizator, new NoMailboxPathLocker(), failingMessageParser, messageIdFactory);
+ parseFailingMailboxManager = new CassandraMailboxManager(mailboxSessionMapperFactory, noAuthenticator, noAuthorizator,
+ new NoMailboxPathLocker(), failingMessageParser, messageIdFactory,
+ mailboxEventDispatcher, delegatingMailboxListener, storeRightManager);
parseFailingMailboxManager.init();
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b3eb1b2a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java
index ca39444..ff17399 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java
@@ -26,6 +26,8 @@ import org.apache.james.imap.main.DefaultImapDecoderFactory;
import org.apache.james.imap.processor.main.DefaultImapProcessorFactory;
import org.apache.james.mailbox.MailboxManager;
import org.apache.james.mailbox.SubscriptionManager;
+import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
+import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
import org.apache.james.mailbox.cassandra.CassandraMailboxManager;
import org.apache.james.mailbox.cassandra.CassandraMailboxSessionMapperFactory;
import org.apache.james.mailbox.cassandra.TestCassandraMailboxSessionMapperFactory;
@@ -50,7 +52,10 @@ import org.apache.james.mailbox.cassandra.quota.CassandraPerUserMaxQuotaManager;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.quota.QuotaRootResolver;
import org.apache.james.mailbox.store.JVMMailboxPathLocker;
+import org.apache.james.mailbox.store.StoreRightManager;
import org.apache.james.mailbox.store.StoreSubscriptionManager;
+import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
+import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
import org.apache.james.mailbox.store.quota.DefaultQuotaRootResolver;
import org.apache.james.mailbox.store.quota.ListeningCurrentQuotaUpdater;
@@ -107,7 +112,12 @@ public class CassandraHostSystem extends JamesImapHostSystem {
cassandra.getTypesProvider(),
messageIdFactory);
- mailboxManager = new CassandraMailboxManager(mapperFactory, authenticator, authorizator, new JVMMailboxPathLocker(), new MessageParser(), messageIdFactory);
+ DefaultDelegatingMailboxListener delegatingMailboxListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingMailboxListener);
+ StoreRightManager storeRightManager = new StoreRightManager(mapperFactory, new UnionMailboxACLResolver(), new SimpleGroupMembershipResolver());
+ mailboxManager = new CassandraMailboxManager(mapperFactory, authenticator, authorizator,
+ new JVMMailboxPathLocker(), new MessageParser(), messageIdFactory,
+ mailboxEventDispatcher, delegatingMailboxListener, storeRightManager);
QuotaRootResolver quotaRootResolver = new DefaultQuotaRootResolver(mapperFactory);
perUserMaxQuotaManager = new CassandraPerUserMaxQuotaManager(session);
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[08/15] james-project git commit: MAILBOX-317 Rework
JcrMailboxManager constructor
Posted by bt...@apache.org.
MAILBOX-317 Rework JcrMailboxManager constructor
Passing the event system should not be optional. And It should not be class concern to init the right system.
In the operation:
- Delete one constructor
- Implement logic in only one constructor (the other should only call it)
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/f5a2bbfa
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/f5a2bbfa
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/f5a2bbfa
Branch: refs/heads/master
Commit: f5a2bbfaae134e0644f8753a5aabdc48a427c10c
Parents: 3653aa9
Author: benwa <bt...@linagora.com>
Authored: Thu Nov 2 09:22:14 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Fri Nov 3 09:32:32 2017 +0700
----------------------------------------------------------------------
.../james/mailbox/jcr/JCRMailboxManager.java | 17 ++++++-----------
.../mailbox/jcr/JCRMailboxManagerProvider.java | 7 ++++++-
.../mpt/imapmailbox/jcr/host/JCRHostSystem.java | 8 ++++++--
3 files changed, 18 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/f5a2bbfa/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMailboxManager.java
----------------------------------------------------------------------
diff --git a/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMailboxManager.java b/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMailboxManager.java
index fb13206..eca67e9 100644
--- a/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMailboxManager.java
+++ b/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMailboxManager.java
@@ -28,10 +28,11 @@ import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.model.MessageId;
import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
-import org.apache.james.mailbox.store.JVMMailboxPathLocker;
import org.apache.james.mailbox.store.StoreMailboxManager;
import org.apache.james.mailbox.store.StoreMessageManager;
import org.apache.james.mailbox.store.StoreRightManager;
+import org.apache.james.mailbox.store.event.DelegatingMailboxListener;
+import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.model.Mailbox;
import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
@@ -44,20 +45,14 @@ public class JCRMailboxManager extends StoreMailboxManager implements JCRImapCon
public JCRMailboxManager(JCRMailboxSessionMapperFactory mapperFactory,
Authenticator authenticator,
Authorizator authorizator,
- MessageParser messageParser,
- MessageId.Factory messageIdFactory,
- StoreRightManager storeRightManager) {
- this(mapperFactory, authenticator, authorizator, new JVMMailboxPathLocker(), messageParser, messageIdFactory, storeRightManager);
- }
-
- public JCRMailboxManager(JCRMailboxSessionMapperFactory mapperFactory,
- Authenticator authenticator,
- Authorizator authorizator,
MailboxPathLocker locker,
MessageParser messageParser,
MessageId.Factory messageIdFactory,
+ MailboxEventDispatcher mailboxEventDispatcher,
+ DelegatingMailboxListener delegatingMailboxListener,
StoreRightManager storeRightManager) {
- super(mapperFactory, authenticator, authorizator, locker, messageParser, messageIdFactory, storeRightManager);
+ super(mapperFactory, authenticator, authorizator, locker, messageParser, messageIdFactory,
+ mailboxEventDispatcher, delegatingMailboxListener, storeRightManager);
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/f5a2bbfa/mailbox/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRMailboxManagerProvider.java
----------------------------------------------------------------------
diff --git a/mailbox/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRMailboxManagerProvider.java b/mailbox/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRMailboxManagerProvider.java
index 09ed47a..ee76ed6 100644
--- a/mailbox/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRMailboxManagerProvider.java
+++ b/mailbox/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRMailboxManagerProvider.java
@@ -32,6 +32,8 @@ import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.JVMMailboxPathLocker;
import org.apache.james.mailbox.store.StoreRightManager;
+import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
+import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.model.DefaultMessageId;
import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
import org.xml.sax.InputSource;
@@ -66,8 +68,11 @@ public class JCRMailboxManagerProvider {
Authenticator noAuthenticator = null;
Authorizator noAuthorizator = null;
StoreRightManager storeRightManager = new StoreRightManager(mf, aclResolver, groupMembershipResolver);
+ DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
JCRMailboxManager manager = new JCRMailboxManager(mf, noAuthenticator, noAuthorizator, locker,
- messageParser, new DefaultMessageId.Factory(), storeRightManager);
+ messageParser, new DefaultMessageId.Factory(), mailboxEventDispatcher, delegatingListener,
+ storeRightManager);
try {
manager.init();
http://git-wip-us.apache.org/repos/asf/james-project/blob/f5a2bbfa/mpt/impl/imap-mailbox/jcr/src/test/java/org/apache/james/mpt/imapmailbox/jcr/host/JCRHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/jcr/src/test/java/org/apache/james/mpt/imapmailbox/jcr/host/JCRHostSystem.java b/mpt/impl/imap-mailbox/jcr/src/test/java/org/apache/james/mpt/imapmailbox/jcr/host/JCRHostSystem.java
index eb3f7d0..01a286b 100644
--- a/mpt/impl/imap-mailbox/jcr/src/test/java/org/apache/james/mpt/imapmailbox/jcr/host/JCRHostSystem.java
+++ b/mpt/impl/imap-mailbox/jcr/src/test/java/org/apache/james/mpt/imapmailbox/jcr/host/JCRHostSystem.java
@@ -43,6 +43,8 @@ import org.apache.james.mailbox.jcr.mail.JCRModSeqProvider;
import org.apache.james.mailbox.jcr.mail.JCRUidProvider;
import org.apache.james.mailbox.store.JVMMailboxPathLocker;
import org.apache.james.mailbox.store.StoreRightManager;
+import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
+import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.model.DefaultMessageId;
import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
import org.apache.james.mailbox.store.quota.DefaultQuotaRootResolver;
@@ -93,8 +95,10 @@ public class JCRHostSystem extends JamesImapHostSystem {
MessageParser messageParser = new MessageParser();
StoreRightManager storeRightManager = new StoreRightManager(mf, aclResolver, groupMembershipResolver);
- mailboxManager = new JCRMailboxManager(mf, authenticator, authorizator, messageParser,
- new DefaultMessageId.Factory(), storeRightManager);
+ DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
+ mailboxManager = new JCRMailboxManager(mf, authenticator, authorizator, new JVMMailboxPathLocker(), messageParser,
+ new DefaultMessageId.Factory(), mailboxEventDispatcher, delegatingListener, storeRightManager);
mailboxManager.init();
final ImapProcessor defaultImapProcessorFactory =
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[04/15] james-project git commit: MAILBOX-317 Solve Spring related
issues.
Posted by bt...@apache.org.
MAILBOX-317 Solve Spring related issues.
Over-customization in OpenJpaMailboxManager led Spring choosing the wrong constructor. Thus I propose a simplification of untested features.
(Enabling compression / encryption will require extending OpenJpaMailboxManager)
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/afbed0f2
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/afbed0f2
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/afbed0f2
Branch: refs/heads/master
Commit: afbed0f2ac65c99b10e2b610ff7ad988761fb389
Parents: 9e7abcb
Author: benwa <bt...@linagora.com>
Authored: Thu Nov 2 12:51:38 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Fri Nov 3 09:32:32 2017 +0700
----------------------------------------------------------------------
.../jpa/openjpa/OpenJPAMailboxManager.java | 54 +++-----------------
.../jpa/openjpa/OpenJPAMessageManager.java | 15 ------
.../resources/META-INF/spring/mailbox-jpa.xml | 6 ++-
.../META-INF/spring/mailbox-maildir.xml | 7 +--
.../META-INF/spring/mailbox-memory.xml | 5 +-
.../META-INF/spring/spring-mailbox.xml | 5 ++
6 files changed, 22 insertions(+), 70 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/afbed0f2/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/openjpa/OpenJPAMailboxManager.java
----------------------------------------------------------------------
diff --git a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/openjpa/OpenJPAMailboxManager.java b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/openjpa/OpenJPAMailboxManager.java
index 5c25eeb..5f7421d 100644
--- a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/openjpa/OpenJPAMailboxManager.java
+++ b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/openjpa/OpenJPAMailboxManager.java
@@ -22,12 +22,10 @@ package org.apache.james.mailbox.jpa.openjpa;
import javax.inject.Inject;
-import org.apache.james.mailbox.MailboxPathLocker;
import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.jpa.JPAMailboxManager;
import org.apache.james.mailbox.jpa.JPAMailboxSessionMapperFactory;
-import org.apache.james.mailbox.jpa.mail.model.openjpa.EncryptDecryptHelper;
import org.apache.james.mailbox.jpa.openjpa.OpenJPAMessageManager.AdvancedFeature;
import org.apache.james.mailbox.model.MessageId;
import org.apache.james.mailbox.store.Authenticator;
@@ -47,62 +45,22 @@ import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
*/
public class OpenJPAMailboxManager extends JPAMailboxManager {
- private final AdvancedFeature feature;
-
+ @Inject
public OpenJPAMailboxManager(JPAMailboxSessionMapperFactory mapperFactory,
Authenticator authenticator,
Authorizator authorizator,
- MailboxPathLocker locker,
- boolean useStreaming,
MessageParser messageParser,
MessageId.Factory messageIdFactory,
- StoreMailboxAnnotationManager annotationManager,
DelegatingMailboxListener delegatingMailboxListener,
MailboxEventDispatcher mailboxEventDispatcher,
- StoreRightManager storeRightManager) {
- super(mapperFactory, authenticator, authorizator, locker, messageParser,
- messageIdFactory, delegatingMailboxListener, mailboxEventDispatcher, annotationManager, storeRightManager);
- if (useStreaming) {
- feature = AdvancedFeature.Streaming;
- } else {
- feature = AdvancedFeature.None;
- }
- }
-
- public OpenJPAMailboxManager(JPAMailboxSessionMapperFactory mapperFactory,
- Authenticator authenticator,
- Authorizator authorizator,
- MailboxPathLocker locker,
- String encryptPass,
- MessageParser messageParser,
- MessageId.Factory messageIdFactory,
StoreMailboxAnnotationManager annotationManager,
- DelegatingMailboxListener delegatingMailboxListener,
- MailboxEventDispatcher mailboxEventDispatcher,
StoreRightManager storeRightManager) {
- super(mapperFactory, authenticator, authorizator, locker, messageParser,
+ super(mapperFactory, authenticator, authorizator, new JVMMailboxPathLocker(), messageParser,
messageIdFactory, delegatingMailboxListener, mailboxEventDispatcher, annotationManager, storeRightManager);
- if (encryptPass != null) {
- EncryptDecryptHelper.init(encryptPass);
- feature = AdvancedFeature.Encryption;
- } else {
- feature = AdvancedFeature.None;
- }
}
-
- @Inject
- public OpenJPAMailboxManager(JPAMailboxSessionMapperFactory mapperFactory,
- Authenticator authenticator,
- Authorizator authorizator,
- MessageParser messageParser,
- MessageId.Factory messageIdFactory,
- DelegatingMailboxListener delegatingMailboxListener,
- MailboxEventDispatcher mailboxEventDispatcher,
- StoreMailboxAnnotationManager annotationManager,
- StoreRightManager storeRightManager) {
- this(mapperFactory, authenticator, authorizator, new JVMMailboxPathLocker(), false,
- messageParser, messageIdFactory, annotationManager, delegatingMailboxListener, mailboxEventDispatcher,
- storeRightManager);
+
+ protected AdvancedFeature getAdvancedFeature() {
+ return AdvancedFeature.None;
}
@Override
@@ -112,7 +70,7 @@ public class OpenJPAMailboxManager extends JPAMailboxManager {
getEventDispatcher(),
getLocker(),
mailboxRow,
- feature,
+ getAdvancedFeature(),
getQuotaManager(),
getQuotaRootResolver(),
getMessageParser(),
http://git-wip-us.apache.org/repos/asf/james-project/blob/afbed0f2/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/openjpa/OpenJPAMessageManager.java
----------------------------------------------------------------------
diff --git a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/openjpa/OpenJPAMessageManager.java b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/openjpa/OpenJPAMessageManager.java
index e02ce9e..e82ee00 100644
--- a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/openjpa/OpenJPAMessageManager.java
+++ b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/openjpa/OpenJPAMessageManager.java
@@ -58,17 +58,6 @@ public class OpenJPAMessageManager extends JPAMessageManager {
Streaming,
Encryption
}
-
- public OpenJPAMessageManager(MailboxSessionMapperFactory mapperFactory,
- MessageSearchIndex index,MailboxEventDispatcher dispatcher,
- MailboxPathLocker locker, Mailbox mailbox,
- QuotaManager quotaManager, QuotaRootResolver quotaRootResolver, MessageParser messageParser,
- MessageId.Factory messageIdFactory, BatchSizes batchSizes,
- ImmutableMailboxMessage.Factory immutableMailboxMessageFactory,
- StoreRightManager storeRightManager) throws MailboxException {
- this(mapperFactory, index, dispatcher, locker, mailbox, AdvancedFeature.None,
- quotaManager, quotaRootResolver, messageParser, messageIdFactory, batchSizes, immutableMailboxMessageFactory, storeRightManager);
- }
public OpenJPAMessageManager(MailboxSessionMapperFactory mapperFactory,
MessageSearchIndex index, MailboxEventDispatcher dispatcher,
@@ -84,10 +73,6 @@ public class OpenJPAMessageManager extends JPAMessageManager {
@Override
protected MailboxMessage createMessage(Date internalDate, int size, int bodyStartOctet, SharedInputStream content, Flags flags, PropertyBuilder propertyBuilder, List<MessageAttachment> attachments) throws MailboxException {
- int headerEnd = bodyStartOctet -2;
- if (headerEnd < 0) {
- headerEnd = 0;
- }
switch (feature) {
case Streaming:
return new JPAStreamingMailboxMessage((JPAMailbox) getMailboxEntity(), internalDate, size, flags, content, bodyStartOctet, propertyBuilder);
http://git-wip-us.apache.org/repos/asf/james-project/blob/afbed0f2/mailbox/jpa/src/main/resources/META-INF/spring/mailbox-jpa.xml
----------------------------------------------------------------------
diff --git a/mailbox/jpa/src/main/resources/META-INF/spring/mailbox-jpa.xml b/mailbox/jpa/src/main/resources/META-INF/spring/mailbox-jpa.xml
index 86d3966..53d378c 100644
--- a/mailbox/jpa/src/main/resources/META-INF/spring/mailbox-jpa.xml
+++ b/mailbox/jpa/src/main/resources/META-INF/spring/mailbox-jpa.xml
@@ -38,11 +38,13 @@
<constructor-arg index="2" ref="authorizator"/>
<constructor-arg index="3" ref="messageParser"/>
<constructor-arg index="4" ref="messageIdFactory"/>
- <constructor-arg index="5" ref="storeRightManager" />
+ <constructor-arg index="5" ref="delegating-listener"/>
+ <constructor-arg index="6" ref="dispatcher"/>
+ <constructor-arg index="7" ref="storeMailboxAnnotationManager"/>
+ <constructor-arg index="8" ref="storeRightManager" />
<property name="quotaManager" ref="quotaManager"/>
<property name="quotaRootResolver" ref="quotaRootResolver"/>
<property name="quotaUpdater" ref="quotaUpdater"/>
- <property name="delegatingMailboxListener" ref="delegating-listener"/>
</bean>
<bean id ="jpa-subscriptionManager" class="org.apache.james.mailbox.jpa.JPASubscriptionManager">
http://git-wip-us.apache.org/repos/asf/james-project/blob/afbed0f2/mailbox/maildir/src/main/resources/META-INF/spring/mailbox-maildir.xml
----------------------------------------------------------------------
diff --git a/mailbox/maildir/src/main/resources/META-INF/spring/mailbox-maildir.xml b/mailbox/maildir/src/main/resources/META-INF/spring/mailbox-maildir.xml
index ebbdd03..ca75508 100644
--- a/mailbox/maildir/src/main/resources/META-INF/spring/mailbox-maildir.xml
+++ b/mailbox/maildir/src/main/resources/META-INF/spring/mailbox-maildir.xml
@@ -41,9 +41,10 @@
<constructor-arg index="3" ref="maildir-locker"/>
<constructor-arg index="4" ref="messageParser"/>
<constructor-arg index="5" ref="messageIdFactory" />
- <constructor-arg index="6" ref="dispatcher" />
- <constructor-arg index="7" ref="delegating-listener" />
- <constructor-arg index="8" ref="storeRightManager" />
+ <constructor-arg index="6" ref="storeMailboxAnnotationManager" />
+ <constructor-arg index="7" ref="dispatcher" />
+ <constructor-arg index="8" ref="delegating-listener" />
+ <constructor-arg index="9" ref="storeRightManager" />
<!-- <property name="messageSearchIndex" ref="lazyIndex"/> -->
<property name="quotaManager" ref="quotaManager"/>
<property name="quotaRootResolver" ref="quotaRootResolver"/>
http://git-wip-us.apache.org/repos/asf/james-project/blob/afbed0f2/mailbox/memory/src/main/resources/META-INF/spring/mailbox-memory.xml
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/main/resources/META-INF/spring/mailbox-memory.xml b/mailbox/memory/src/main/resources/META-INF/spring/mailbox-memory.xml
index 0e3d011..7857d0f 100644
--- a/mailbox/memory/src/main/resources/META-INF/spring/mailbox-memory.xml
+++ b/mailbox/memory/src/main/resources/META-INF/spring/mailbox-memory.xml
@@ -31,7 +31,7 @@
<!-- WARNING: Memory does not persist the mailbox. -->
<!-- Information will be lost after jvm restart. -->
- <bean id="memory-mailboxManager" class="org.apache.james.mailbox.store.StoreMailboxManager" init-method="init">
+ <bean id="memory-mailboxManager" class="org.apache.james.mailbox.inmemory.InMemoryMailboxManager" init-method="init">
<constructor-arg index="0" ref="memory-sessionMapperFactory"/>
<constructor-arg index="1" ref="authenticator"/>
<constructor-arg index="2" ref="authorizator"/>
@@ -40,7 +40,8 @@
<constructor-arg index="5" ref="messageIdFactory" />
<constructor-arg index="6" ref="dispatcher" />
<constructor-arg index="7" ref="delegating-listener" />
- <constructor-arg index="8" ref="storeRightManager" />
+ <constructor-arg index="8" ref="storeMailboxAnnotationManager" />
+ <constructor-arg index="9" ref="storeRightManager" />
<!-- <property name="messageSearchIndex" ref="lazyIndex"/> -->
<property name="quotaManager" ref="quotaManager"/>
<property name="quotaRootResolver" ref="quotaRootResolver"/>
http://git-wip-us.apache.org/repos/asf/james-project/blob/afbed0f2/mailbox/spring/src/main/resources/META-INF/spring/spring-mailbox.xml
----------------------------------------------------------------------
diff --git a/mailbox/spring/src/main/resources/META-INF/spring/spring-mailbox.xml b/mailbox/spring/src/main/resources/META-INF/spring/spring-mailbox.xml
index ca91f42..8caa3cb 100644
--- a/mailbox/spring/src/main/resources/META-INF/spring/spring-mailbox.xml
+++ b/mailbox/spring/src/main/resources/META-INF/spring/spring-mailbox.xml
@@ -60,6 +60,11 @@
-->
<bean id="messageParser" class="org.apache.james.mailbox.store.mail.model.impl.MessageParser"/>
+ <bean id="storeMailboxAnnotationManager" class="org.apache.james.mailbox.store.StoreMailboxAnnotationManager">
+ <constructor-arg index="0" ref="messageMapperFactory" />
+ <constructor-arg index="1" ref="storeRightManager" />
+ </bean>
+
<bean id="storeRightManager" class="org.apache.james.mailbox.store.StoreRightManager" >
<constructor-arg index="0" ref="messageMapperFactory" />
<constructor-arg index="1" ref="aclResolver" />
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[13/15] james-project git commit: MAILBOX-317 Add a
MailboxAnnotationManager
Posted by bt...@apache.org.
MAILBOX-317 Add a MailboxAnnotationManager
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/9e7abcbe
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/9e7abcbe
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/9e7abcbe
Branch: refs/heads/master
Commit: 9e7abcbef868a1efed3efbb555271d5647d69b5a
Parents: fb0c391
Author: benwa <bt...@linagora.com>
Authored: Thu Nov 2 11:05:33 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Fri Nov 3 09:32:32 2017 +0700
----------------------------------------------------------------------
.../james/mailbox/MailboxAnnotationManager.java | 100 +++++++++++++
.../apache/james/mailbox/MailboxManager.java | 45 +-----
.../cassandra/CassandraMailboxManager.java | 26 +---
.../CassandraMailboxManagerProvider.java | 6 +-
.../cassandra/CassandraTestSystemFixture.java | 4 +-
.../CassandraMailboxManagerAttachmentTest.java | 6 +-
mailbox/elasticsearch/pom.xml | 6 +
.../ElasticSearchIntegrationTest.java | 52 ++-----
.../mailbox/hbase/HBaseMailboxManager.java | 4 +-
.../hbase/HBaseMailboxManagerStressTest.java | 3 +
.../mailbox/hbase/HBaseMailboxManagerTest.java | 3 +
.../james/mailbox/jcr/JCRMailboxManager.java | 4 +-
.../mailbox/jcr/JCRMailboxManagerProvider.java | 4 +-
.../james/mailbox/jpa/JPAMailboxManager.java | 19 +--
.../jpa/openjpa/OpenJPAMailboxManager.java | 29 +---
.../mailbox/jpa/JpaMailboxManagerProvider.java | 12 +-
mailbox/lucene/pom.xml | 6 +
.../search/LuceneMessageSearchIndexTest.java | 53 ++-----
.../maildir/MaildirMailboxManagerProvider.java | 5 +-
.../inmemory/InMemoryMailboxManager.java | 19 +--
.../inmemory/MemoryMailboxManagerProvider.java | 9 +-
.../InMemoryMailboxManagerAttachmentTest.java | 6 +-
.../manager/InMemoryIntegrationResources.java | 28 ++++
mailbox/scanning-search/pom.xml | 12 ++
.../search/SimpleMessageSearchIndexTest.java | 52 ++-----
.../store/StoreMailboxAnnotationManager.java | 146 +++++++++++++++++++
.../mailbox/store/StoreMailboxManager.java | 77 ++--------
.../StoreMailboxManagerAnnotationTest.java | 48 ++----
.../mailbox/store/StoreMailboxManagerTest.java | 4 +-
mailbox/tool/pom.xml | 12 ++
.../james/mailbox/copier/MailboxCopierTest.java | 37 +----
.../cassandra/host/CassandraHostSystem.java | 5 +-
mpt/impl/imap-mailbox/elasticsearch/pom.xml | 10 ++
.../host/ElasticSearchHostSystem.java | 37 +----
.../imapmailbox/hbase/host/HBaseHostSystem.java | 5 +-
mpt/impl/imap-mailbox/inmemory/pom.xml | 12 ++
.../inmemory/host/InMemoryHostSystem.java | 33 +----
.../mpt/imapmailbox/jcr/host/JCRHostSystem.java | 5 +-
.../mpt/imapmailbox/jpa/host/JPAHostSystem.java | 15 +-
.../host/LuceneSearchHostSystem.java | 17 ++-
.../maildir/host/MaildirHostSystem.java | 6 +-
server/container/mailbox-adapter/pom.xml | 12 ++
.../adapter/mailbox/MailboxManagementTest.java | 120 ++++++---------
.../transport/matchers/IsOverQuotaTest.java | 31 +---
server/protocols/protocols-pop3/pom.xml | 12 ++
.../apache/james/pop3server/POP3ServerTest.java | 48 ++----
46 files changed, 631 insertions(+), 574 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxAnnotationManager.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxAnnotationManager.java b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxAnnotationManager.java
new file mode 100644
index 0000000..740f7ef
--- /dev/null
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxAnnotationManager.java
@@ -0,0 +1,100 @@
+/****************************************************************
+ * 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;
+
+import java.util.List;
+import java.util.Set;
+
+import org.apache.james.mailbox.exception.AnnotationException;
+import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.model.MailboxAnnotation;
+import org.apache.james.mailbox.model.MailboxAnnotationKey;
+import org.apache.james.mailbox.model.MailboxPath;
+
+/**
+ * <p>
+ * This class intends to manage mailbox annotations.
+ *
+ * Work will be delegated to it by {@link MailboxManager}
+ * </p>
+ */
+
+public interface MailboxAnnotationManager {
+
+ /**
+ * Return all mailbox's annotation as the {@link List} of {@link MailboxAnnotation} without order and
+ * do not contain any two annotations with the same key
+ *
+ * @param mailboxPath the current mailbox
+ * @param session the current session
+ * @return List<MailboxAnnotation>
+ * @throws MailboxException in case of selected mailbox does not exist
+ */
+ List<MailboxAnnotation> getAllAnnotations(MailboxPath mailboxPath, MailboxSession session) throws MailboxException;
+
+ /**
+ * Return all mailbox's annotation filter by the list of the keys without order and
+ * do not contain any two annotations with the same key
+ *
+ * @param mailboxPath the current mailbox
+ * @param session the current session
+ * @param keys list of the keys should be filter
+ * @return List<MailboxAnnotation>
+ * @throws MailboxException in case of selected mailbox does not exist
+ */
+ List<MailboxAnnotation> getAnnotationsByKeys(MailboxPath mailboxPath, MailboxSession session, Set<MailboxAnnotationKey> keys) throws MailboxException;
+
+ /**
+ * Return all mailbox's annotation by the list of the keys and its children entries without order and
+ * do not contain any two annotations with the same key
+ *
+ * @param mailboxPath the current mailbox
+ * @param session the current session
+ * @param keys list of the keys should be filter
+ * @return List<MailboxAnnotation>
+ * @throws MailboxException in case of selected mailbox does not exist
+ */
+ List<MailboxAnnotation> getAnnotationsByKeysWithOneDepth(MailboxPath mailboxPath, MailboxSession session, Set<MailboxAnnotationKey> keys) throws MailboxException;
+
+ /**
+ * Return all mailbox's annotation by the list of the keys and its below entries without order and
+ * do not contain any two annotations with the same key
+ *
+ * @param mailboxPath the current mailbox
+ * @param session the current session
+ * @param keys list of the keys should be filter
+ * @return List<MailboxAnnotation>
+ * @throws MailboxException in case of selected mailbox does not exist
+ */
+ List<MailboxAnnotation> getAnnotationsByKeysWithAllDepth(MailboxPath mailboxPath, MailboxSession session, Set<MailboxAnnotationKey> keys) throws MailboxException;
+
+ /**
+ * Update the mailbox's annotations. This method can:
+ * - Insert new annotation if it does not exist
+ * - Update the new value for existed annotation
+ * - Delete the existed annotation if its value is nil
+ *
+ * @param mailboxPath the current mailbox
+ * @param session the current session
+ * @param mailboxAnnotations the list of annotation should be insert/udpate/delete
+ * @throws MailboxException in case of selected mailbox does not exist
+ */
+ void updateAnnotations(MailboxPath mailboxPath, MailboxSession session, List<MailboxAnnotation> mailboxAnnotations) throws MailboxException, AnnotationException;
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/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 287c790..7a55280 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
@@ -418,62 +418,27 @@ public interface MailboxManager extends RequestAware, MailboxListenerSupport {
List<MailboxPath> list(MailboxSession session) throws MailboxException;
/**
- * Return all mailbox's annotation as the {@link List} of {@link MailboxAnnotation} without order and
- * do not contain any two annotations with the same key
- *
- * @param mailboxPath the current mailbox
- * @param session the current session
- * @return List<MailboxAnnotation>
- * @throws MailboxException in case of selected mailbox does not exist
+ * See {@link MailboxAnnotationManager#getAllAnnotations(MailboxPath, MailboxSession)}
*/
List<MailboxAnnotation> getAllAnnotations(MailboxPath mailboxPath, MailboxSession session) throws MailboxException;
/**
- * Return all mailbox's annotation filter by the list of the keys without order and
- * do not contain any two annotations with the same key
- *
- * @param mailboxPath the current mailbox
- * @param session the current session
- * @param keys list of the keys should be filter
- * @return List<MailboxAnnotation>
- * @throws MailboxException in case of selected mailbox does not exist
+ * See {@link MailboxAnnotationManager#getAnnotationsByKeys(MailboxPath, MailboxSession, Set)}
*/
List<MailboxAnnotation> getAnnotationsByKeys(MailboxPath mailboxPath, MailboxSession session, Set<MailboxAnnotationKey> keys) throws MailboxException;
/**
- * Return all mailbox's annotation by the list of the keys and its children entries without order and
- * do not contain any two annotations with the same key
- *
- * @param mailboxPath the current mailbox
- * @param session the current session
- * @param keys list of the keys should be filter
- * @return List<MailboxAnnotation>
- * @throws MailboxException in case of selected mailbox does not exist
+ * See {@link MailboxAnnotationManager#getAnnotationsByKeysWithOneDepth(MailboxPath, MailboxSession, Set)}
*/
List<MailboxAnnotation> getAnnotationsByKeysWithOneDepth(MailboxPath mailboxPath, MailboxSession session, Set<MailboxAnnotationKey> keys) throws MailboxException;
/**
- * Return all mailbox's annotation by the list of the keys and its below entries without order and
- * do not contain any two annotations with the same key
- *
- * @param mailboxPath the current mailbox
- * @param session the current session
- * @param keys list of the keys should be filter
- * @return List<MailboxAnnotation>
- * @throws MailboxException in case of selected mailbox does not exist
+ * See {@link MailboxAnnotationManager#getAnnotationsByKeysWithAllDepth(MailboxPath, MailboxSession, Set)}
*/
List<MailboxAnnotation> getAnnotationsByKeysWithAllDepth(MailboxPath mailboxPath, MailboxSession session, Set<MailboxAnnotationKey> keys) throws MailboxException;
/**
- * Update the mailbox's annotations. This method can:
- * - Insert new annotation if it does not exist
- * - Update the new value for existed annotation
- * - Delete the existed annotation if its value is nil
- *
- * @param mailboxPath the current mailbox
- * @param session the current session
- * @param mailboxAnnotations the list of annotation should be insert/udpate/delete
- * @throws MailboxException in case of selected mailbox does not exist
+ * See {@link MailboxAnnotationManager#updateAnnotations(MailboxPath, MailboxSession, List)}
*/
void updateAnnotations(MailboxPath mailboxPath, MailboxSession session, List<MailboxAnnotation> mailboxAnnotations) throws MailboxException, AnnotationException;
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxManager.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxManager.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxManager.java
index 2f68d6c..a6d6603 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxManager.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxManager.java
@@ -28,11 +28,11 @@ import org.apache.james.mailbox.MailboxPathLocker;
import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.model.MailboxACL;
-import org.apache.james.mailbox.model.MailboxConstants;
import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.model.MessageId;
import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
+import org.apache.james.mailbox.store.StoreMailboxAnnotationManager;
import org.apache.james.mailbox.store.StoreMailboxManager;
import org.apache.james.mailbox.store.StoreMessageManager;
import org.apache.james.mailbox.store.StoreRightManager;
@@ -52,35 +52,17 @@ public class CassandraMailboxManager extends StoreMailboxManager {
@Inject
public CassandraMailboxManager(CassandraMailboxSessionMapperFactory mapperFactory, Authenticator authenticator, Authorizator authorizator,
- MailboxPathLocker locker, MessageParser messageParser, MessageId.Factory messageIdFactory,
- MailboxEventDispatcher mailboxEventDispatcher, DelegatingMailboxListener delegatingMailboxListener,
- StoreRightManager storeRightManager) {
- this(mapperFactory,
- authenticator,
- authorizator,
- locker,
- messageParser,
- messageIdFactory,
- MailboxConstants.DEFAULT_LIMIT_ANNOTATIONS_ON_MAILBOX,
- MailboxConstants.DEFAULT_LIMIT_ANNOTATION_SIZE,
- mailboxEventDispatcher,
- delegatingMailboxListener,
- storeRightManager);
- }
-
- public CassandraMailboxManager(CassandraMailboxSessionMapperFactory mapperFactory, Authenticator authenticator, Authorizator authorizator,
MailboxPathLocker locker, MessageParser messageParser,
- MessageId.Factory messageIdFactory, int limitOfAnnotations, int limitAnnotationSize,
+ MessageId.Factory messageIdFactory,
MailboxEventDispatcher mailboxEventDispatcher, DelegatingMailboxListener delegatingMailboxListener,
- StoreRightManager storeRightManager) {
+ StoreMailboxAnnotationManager annotationManager, StoreRightManager storeRightManager) {
super(mapperFactory,
authenticator,
authorizator,
locker,
messageParser,
messageIdFactory,
- limitOfAnnotations,
- limitAnnotationSize,
+ annotationManager,
mailboxEventDispatcher,
delegatingMailboxListener,
storeRightManager);
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerProvider.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerProvider.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerProvider.java
index 85d809f..3fca347 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerProvider.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerProvider.java
@@ -29,6 +29,7 @@ import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.NoMailboxPathLocker;
+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.event.MailboxEventDispatcher;
@@ -58,9 +59,12 @@ public class CassandraMailboxManagerProvider {
Authorizator noAuthorizator = null;
DefaultDelegatingMailboxListener delegatingMailboxListener = new DefaultDelegatingMailboxListener();
MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingMailboxListener);
+ StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mapperFactory, storeRightManager,
+ LIMIT_ANNOTATIONS, LIMIT_ANNOTATION_SIZE);
CassandraMailboxManager manager = new CassandraMailboxManager(mapperFactory, noAuthenticator, noAuthorizator, new NoMailboxPathLocker(),
- messageParser, messageIdFactory, LIMIT_ANNOTATIONS, LIMIT_ANNOTATION_SIZE, mailboxEventDispatcher, delegatingMailboxListener, storeRightManager);
+ messageParser, messageIdFactory, mailboxEventDispatcher, delegatingMailboxListener,
+ annotationManager, storeRightManager);
try {
manager.init();
} catch (MailboxException e) {
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java
index 1dfe2bc..8a4d46e 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java
@@ -33,6 +33,7 @@ import org.apache.james.mailbox.quota.QuotaManager;
import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.NoMailboxPathLocker;
+import org.apache.james.mailbox.store.StoreMailboxAnnotationManager;
import org.apache.james.mailbox.store.StoreMessageIdManager;
import org.apache.james.mailbox.store.StoreRightManager;
import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
@@ -58,10 +59,11 @@ public class CassandraTestSystemFixture {
DefaultDelegatingMailboxListener delegatingMailboxListener = new DefaultDelegatingMailboxListener();
MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingMailboxListener);
StoreRightManager storeRightManager = new StoreRightManager(mapperFactory, new UnionMailboxACLResolver(), new SimpleGroupMembershipResolver());
+ StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mapperFactory, storeRightManager);
CassandraMailboxManager cassandraMailboxManager = new CassandraMailboxManager(mapperFactory, mock(Authenticator.class), mock(Authorizator.class),
new NoMailboxPathLocker(), new MessageParser(), new CassandraMessageId.Factory(),
- mailboxEventDispatcher, delegatingMailboxListener, storeRightManager);
+ mailboxEventDispatcher, delegatingMailboxListener, annotationManager, storeRightManager);
cassandraMailboxManager.init();
return cassandraMailboxManager;
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxManagerAttachmentTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxManagerAttachmentTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxManagerAttachmentTest.java
index 6a3f5b0..e5d416a 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxManagerAttachmentTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxManagerAttachmentTest.java
@@ -49,6 +49,7 @@ import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
import org.apache.james.mailbox.store.NoMailboxPathLocker;
+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.event.MailboxEventDispatcher;
@@ -107,17 +108,18 @@ public class CassandraMailboxManagerAttachmentTest extends AbstractMailboxManage
DefaultDelegatingMailboxListener delegatingMailboxListener = new DefaultDelegatingMailboxListener();
MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingMailboxListener);
StoreRightManager storeRightManager = new StoreRightManager(mailboxSessionMapperFactory, new UnionMailboxACLResolver(), new SimpleGroupMembershipResolver());
+ StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mailboxSessionMapperFactory, storeRightManager);
mailboxManager = new CassandraMailboxManager(mailboxSessionMapperFactory,
noAuthenticator, noAuthorizator, new NoMailboxPathLocker(), new MessageParser(),
- messageIdFactory, mailboxEventDispatcher, delegatingMailboxListener, storeRightManager);
+ messageIdFactory, mailboxEventDispatcher, delegatingMailboxListener, annotationManager, storeRightManager);
mailboxManager.init();
MessageParser failingMessageParser = mock(MessageParser.class);
when(failingMessageParser.retrieveAttachments(any()))
.thenThrow(new RuntimeException("Message parser set to fail"));
parseFailingMailboxManager = new CassandraMailboxManager(mailboxSessionMapperFactory, noAuthenticator, noAuthorizator,
new NoMailboxPathLocker(), failingMessageParser, messageIdFactory,
- mailboxEventDispatcher, delegatingMailboxListener, storeRightManager);
+ mailboxEventDispatcher, delegatingMailboxListener, annotationManager, storeRightManager);
parseFailingMailboxManager.init();
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mailbox/elasticsearch/pom.xml
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/pom.xml b/mailbox/elasticsearch/pom.xml
index 5ac7989..84156cb 100644
--- a/mailbox/elasticsearch/pom.xml
+++ b/mailbox/elasticsearch/pom.xml
@@ -59,6 +59,12 @@
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
+ <artifactId>apache-james-mailbox-memory</artifactId>
+ <scope>test</scope>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
<artifactId>apache-james-mailbox-store</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
index d91e755..405f76f 100644
--- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
+++ b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
@@ -36,31 +36,18 @@ import org.apache.james.backends.es.NodeMappingFactory;
import org.apache.james.backends.es.utils.TestingClientProvider;
import org.apache.james.mailbox.MessageManager;
import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
-import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
import org.apache.james.mailbox.elasticsearch.events.ElasticSearchListeningMessageSearchIndex;
import org.apache.james.mailbox.elasticsearch.json.MessageToElasticSearchJson;
import org.apache.james.mailbox.elasticsearch.query.CriterionConverter;
import org.apache.james.mailbox.elasticsearch.query.QueryConverter;
import org.apache.james.mailbox.elasticsearch.search.ElasticSearchSearcher;
import org.apache.james.mailbox.inmemory.InMemoryId;
-import org.apache.james.mailbox.inmemory.InMemoryMailboxManager;
-import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
-import org.apache.james.mailbox.inmemory.InMemoryMessageId;
+import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
import org.apache.james.mailbox.mock.MockMailboxSession;
import org.apache.james.mailbox.model.ComposedMessageId;
import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.model.SearchQuery;
-import org.apache.james.mailbox.store.FakeAuthenticator;
-import org.apache.james.mailbox.store.FakeAuthorizator;
-import org.apache.james.mailbox.store.JVMMailboxPathLocker;
-import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
import org.apache.james.mailbox.store.StoreMessageIdManager;
-import org.apache.james.mailbox.store.StoreRightManager;
-import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
-import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
-import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
-import org.apache.james.mailbox.store.quota.DefaultQuotaRootResolver;
-import org.apache.james.mailbox.store.quota.NoQuotaManager;
import org.apache.james.mailbox.store.search.AbstractMessageSearchIndexTest;
import org.apache.james.mailbox.tika.TikaConfiguration;
import org.apache.james.mailbox.tika.TikaContainer;
@@ -119,10 +106,12 @@ public class ElasticSearchIntegrationTest extends AbstractMessageSearchIndexTest
MailboxElasticSearchConstants.MESSAGE_TYPE,
MailboxMappingFactory.getMappingContent());
- MailboxSessionMapperFactory mapperFactory = new InMemoryMailboxSessionMapperFactory();
- InMemoryMessageId.Factory messageIdFactory = new InMemoryMessageId.Factory();
- StoreRightManager storeRightManager = new StoreRightManager(mapperFactory, new UnionMailboxACLResolver(), new SimpleGroupMembershipResolver());
- messageSearchIndex = new ElasticSearchListeningMessageSearchIndex(mapperFactory,
+ storeMailboxManager = new InMemoryIntegrationResources()
+ .createMailboxManager(new SimpleGroupMembershipResolver());
+
+
+ ElasticSearchListeningMessageSearchIndex elasticSearchListeningMessageSearchIndex = new ElasticSearchListeningMessageSearchIndex(
+ storeMailboxManager.getMapperFactory(),
new ElasticSearchIndexer(client,
new DeleteByQueryPerformer(client,
Executors.newSingleThreadExecutor(),
@@ -132,32 +121,21 @@ public class ElasticSearchIntegrationTest extends AbstractMessageSearchIndexTest
MailboxElasticSearchConstants.DEFAULT_MAILBOX_WRITE_ALIAS,
MailboxElasticSearchConstants.MESSAGE_TYPE),
new ElasticSearchSearcher(client, new QueryConverter(new CriterionConverter()), SEARCH_SIZE,
- new InMemoryId.Factory(), messageIdFactory,
+ new InMemoryId.Factory(), storeMailboxManager.getMessageIdFactory(),
MailboxElasticSearchConstants.DEFAULT_MAILBOX_READ_ALIAS,
MailboxElasticSearchConstants.MESSAGE_TYPE),
new MessageToElasticSearchJson(textExtractor, ZoneId.of("Europe/Paris"), IndexAttachments.YES));
- DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
- MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
- storeMailboxManager = new InMemoryMailboxManager(
- mapperFactory,
- new FakeAuthenticator(),
- FakeAuthorizator.defaultReject(),
- new JVMMailboxPathLocker(),
- new MessageParser(),
- messageIdFactory,
- mailboxEventDispatcher,
- delegatingListener,
- storeRightManager);
messageIdManager = new StoreMessageIdManager(
storeMailboxManager,
storeMailboxManager.getMapperFactory(),
- mailboxEventDispatcher,
- messageIdFactory,
- new NoQuotaManager(),
- new DefaultQuotaRootResolver(mapperFactory));
- storeMailboxManager.setMessageSearchIndex(messageSearchIndex);
- storeMailboxManager.init();
+ storeMailboxManager.getEventDispatcher(),
+ storeMailboxManager.getMessageIdFactory(),
+ storeMailboxManager.getQuotaManager(),
+ storeMailboxManager.getQuotaRootResolver());
+ storeMailboxManager.setMessageSearchIndex(elasticSearchListeningMessageSearchIndex);
+ storeMailboxManager.addGlobalListener(elasticSearchListeningMessageSearchIndex, new MockMailboxSession("admin"));
+ this.messageSearchIndex = elasticSearchListeningMessageSearchIndex;
}
@Test
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMailboxManager.java
----------------------------------------------------------------------
diff --git a/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMailboxManager.java b/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMailboxManager.java
index 25e74b2..5fe1378 100644
--- a/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMailboxManager.java
+++ b/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMailboxManager.java
@@ -29,6 +29,7 @@ import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.model.MessageId;
import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
+import org.apache.james.mailbox.store.StoreMailboxAnnotationManager;
import org.apache.james.mailbox.store.StoreMailboxManager;
import org.apache.james.mailbox.store.StoreMessageManager;
import org.apache.james.mailbox.store.StoreRightManager;
@@ -52,9 +53,10 @@ public class HBaseMailboxManager extends StoreMailboxManager {
MessageId.Factory messageIdFactory,
MailboxEventDispatcher dispatcher,
DelegatingMailboxListener delegatingMailboxListener,
+ StoreMailboxAnnotationManager annotationManager,
StoreRightManager storeRightManager) {
super(mapperFactory, authenticator, authorizator, locker, messageParser, messageIdFactory,
- dispatcher, delegatingMailboxListener, storeRightManager);
+ annotationManager, dispatcher, delegatingMailboxListener, storeRightManager);
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerStressTest.java
----------------------------------------------------------------------
diff --git a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerStressTest.java b/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerStressTest.java
index 7a44866..688894d 100644
--- a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerStressTest.java
+++ b/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerStressTest.java
@@ -41,6 +41,7 @@ import org.apache.james.mailbox.model.MessageId;
import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.JVMMailboxPathLocker;
+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.event.MailboxEventDispatcher;
@@ -71,6 +72,7 @@ public class HBaseMailboxManagerStressTest extends MailboxManagerStressTest {
Authorizator noAuthorizator = null;
DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
+ StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mapperFactory, storeRightManager);
HBaseMailboxManager manager = new HBaseMailboxManager(mapperFactory,
noAuthenticator,
noAuthorizator,
@@ -79,6 +81,7 @@ public class HBaseMailboxManagerStressTest extends MailboxManagerStressTest {
messageIdFactory,
mailboxEventDispatcher,
delegatingListener,
+ annotationManager,
storeRightManager);
try {
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerTest.java b/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerTest.java
index 5d0cba7..5794093 100644
--- a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerTest.java
+++ b/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerTest.java
@@ -41,6 +41,7 @@ import org.apache.james.mailbox.model.MessageId;
import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.JVMMailboxPathLocker;
+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.event.MailboxEventDispatcher;
@@ -71,6 +72,7 @@ public class HBaseMailboxManagerTest extends MailboxManagerTest {
Authorizator noAuthorizator = null;
DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
+ StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mapperFactory, storeRightManager);
HBaseMailboxManager manager = new HBaseMailboxManager(mapperFactory,
noAuthenticator,
noAuthorizator,
@@ -79,6 +81,7 @@ public class HBaseMailboxManagerTest extends MailboxManagerTest {
messageIdFactory,
mailboxEventDispatcher,
delegatingListener,
+ annotationManager,
storeRightManager);
try {
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMailboxManager.java
----------------------------------------------------------------------
diff --git a/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMailboxManager.java b/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMailboxManager.java
index eca67e9..9a1b935 100644
--- a/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMailboxManager.java
+++ b/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMailboxManager.java
@@ -28,6 +28,7 @@ import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.model.MessageId;
import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
+import org.apache.james.mailbox.store.StoreMailboxAnnotationManager;
import org.apache.james.mailbox.store.StoreMailboxManager;
import org.apache.james.mailbox.store.StoreMessageManager;
import org.apache.james.mailbox.store.StoreRightManager;
@@ -50,9 +51,10 @@ public class JCRMailboxManager extends StoreMailboxManager implements JCRImapCon
MessageId.Factory messageIdFactory,
MailboxEventDispatcher mailboxEventDispatcher,
DelegatingMailboxListener delegatingMailboxListener,
+ StoreMailboxAnnotationManager annotationManager,
StoreRightManager storeRightManager) {
super(mapperFactory, authenticator, authorizator, locker, messageParser, messageIdFactory,
- mailboxEventDispatcher, delegatingMailboxListener, storeRightManager);
+ annotationManager, mailboxEventDispatcher, delegatingMailboxListener, storeRightManager);
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mailbox/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRMailboxManagerProvider.java
----------------------------------------------------------------------
diff --git a/mailbox/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRMailboxManagerProvider.java b/mailbox/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRMailboxManagerProvider.java
index ee76ed6..40bc489 100644
--- a/mailbox/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRMailboxManagerProvider.java
+++ b/mailbox/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRMailboxManagerProvider.java
@@ -31,6 +31,7 @@ import org.apache.james.mailbox.jcr.mail.JCRUidProvider;
import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.JVMMailboxPathLocker;
+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.event.MailboxEventDispatcher;
@@ -68,11 +69,12 @@ public class JCRMailboxManagerProvider {
Authenticator noAuthenticator = null;
Authorizator noAuthorizator = null;
StoreRightManager storeRightManager = new StoreRightManager(mf, aclResolver, groupMembershipResolver);
+ StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mf, storeRightManager);
DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
JCRMailboxManager manager = new JCRMailboxManager(mf, noAuthenticator, noAuthorizator, locker,
messageParser, new DefaultMessageId.Factory(), mailboxEventDispatcher, delegatingListener,
- storeRightManager);
+ annotationManager, storeRightManager);
try {
manager.init();
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxManager.java
----------------------------------------------------------------------
diff --git a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxManager.java b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxManager.java
index 77dcc68..2943e01 100644
--- a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxManager.java
+++ b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxManager.java
@@ -29,6 +29,7 @@ import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.model.MessageId;
import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
+import org.apache.james.mailbox.store.StoreMailboxAnnotationManager;
import org.apache.james.mailbox.store.StoreMailboxManager;
import org.apache.james.mailbox.store.StoreRightManager;
import org.apache.james.mailbox.store.event.DelegatingMailboxListener;
@@ -41,19 +42,6 @@ import org.apache.james.mailbox.store.transaction.Mapper;
* JPA implementation of {@link StoreMailboxManager}
*/
public abstract class JPAMailboxManager extends StoreMailboxManager {
-
- public JPAMailboxManager(JPAMailboxSessionMapperFactory mailboxSessionMapperFactory,
- Authenticator authenticator,
- Authorizator authorizator,
- MailboxPathLocker locker,
- MessageParser messageParser,
- MessageId.Factory messageIdFactory,
- DelegatingMailboxListener delegatingMailboxListener,
- MailboxEventDispatcher mailboxEventDispatcher,
- StoreRightManager storeRightManager) {
- super(mailboxSessionMapperFactory, authenticator, authorizator, locker,
- messageParser, messageIdFactory, mailboxEventDispatcher, delegatingMailboxListener, storeRightManager);
- }
public JPAMailboxManager(JPAMailboxSessionMapperFactory mailboxSessionMapperFactory,
Authenticator authenticator,
@@ -63,11 +51,10 @@ public abstract class JPAMailboxManager extends StoreMailboxManager {
MessageId.Factory messageIdFactory,
DelegatingMailboxListener delegatingMailboxListener,
MailboxEventDispatcher mailboxEventDispatcher,
- int limitAnnotation,
- int limitAnnotationSize,
+ StoreMailboxAnnotationManager annotationManager,
StoreRightManager storeRightManager) {
super(mailboxSessionMapperFactory, authenticator, authorizator, locker,
- messageParser, messageIdFactory, limitAnnotation, limitAnnotationSize,
+ messageParser, messageIdFactory, annotationManager,
mailboxEventDispatcher, delegatingMailboxListener, storeRightManager);
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/openjpa/OpenJPAMailboxManager.java
----------------------------------------------------------------------
diff --git a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/openjpa/OpenJPAMailboxManager.java b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/openjpa/OpenJPAMailboxManager.java
index 48339d1..5c25eeb 100644
--- a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/openjpa/OpenJPAMailboxManager.java
+++ b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/openjpa/OpenJPAMailboxManager.java
@@ -29,11 +29,11 @@ import org.apache.james.mailbox.jpa.JPAMailboxManager;
import org.apache.james.mailbox.jpa.JPAMailboxSessionMapperFactory;
import org.apache.james.mailbox.jpa.mail.model.openjpa.EncryptDecryptHelper;
import org.apache.james.mailbox.jpa.openjpa.OpenJPAMessageManager.AdvancedFeature;
-import org.apache.james.mailbox.model.MailboxConstants;
import org.apache.james.mailbox.model.MessageId;
import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.JVMMailboxPathLocker;
+import org.apache.james.mailbox.store.StoreMailboxAnnotationManager;
import org.apache.james.mailbox.store.StoreMessageManager;
import org.apache.james.mailbox.store.StoreRightManager;
import org.apache.james.mailbox.store.event.DelegatingMailboxListener;
@@ -56,13 +56,12 @@ public class OpenJPAMailboxManager extends JPAMailboxManager {
boolean useStreaming,
MessageParser messageParser,
MessageId.Factory messageIdFactory,
- int annotationLimit,
- int annotationLimitSize,
+ StoreMailboxAnnotationManager annotationManager,
DelegatingMailboxListener delegatingMailboxListener,
MailboxEventDispatcher mailboxEventDispatcher,
StoreRightManager storeRightManager) {
super(mapperFactory, authenticator, authorizator, locker, messageParser,
- messageIdFactory, delegatingMailboxListener, mailboxEventDispatcher, annotationLimit, annotationLimitSize, storeRightManager);
+ messageIdFactory, delegatingMailboxListener, mailboxEventDispatcher, annotationManager, storeRightManager);
if (useStreaming) {
feature = AdvancedFeature.Streaming;
} else {
@@ -77,11 +76,12 @@ public class OpenJPAMailboxManager extends JPAMailboxManager {
String encryptPass,
MessageParser messageParser,
MessageId.Factory messageIdFactory,
+ StoreMailboxAnnotationManager annotationManager,
DelegatingMailboxListener delegatingMailboxListener,
MailboxEventDispatcher mailboxEventDispatcher,
StoreRightManager storeRightManager) {
super(mapperFactory, authenticator, authorizator, locker, messageParser,
- messageIdFactory, delegatingMailboxListener, mailboxEventDispatcher, storeRightManager);
+ messageIdFactory, delegatingMailboxListener, mailboxEventDispatcher, annotationManager, storeRightManager);
if (encryptPass != null) {
EncryptDecryptHelper.init(encryptPass);
feature = AdvancedFeature.Encryption;
@@ -98,24 +98,11 @@ public class OpenJPAMailboxManager extends JPAMailboxManager {
MessageId.Factory messageIdFactory,
DelegatingMailboxListener delegatingMailboxListener,
MailboxEventDispatcher mailboxEventDispatcher,
+ StoreMailboxAnnotationManager annotationManager,
StoreRightManager storeRightManager) {
this(mapperFactory, authenticator, authorizator, new JVMMailboxPathLocker(), false,
- messageParser, messageIdFactory, MailboxConstants.DEFAULT_LIMIT_ANNOTATIONS_ON_MAILBOX,
- MailboxConstants.DEFAULT_LIMIT_ANNOTATION_SIZE, delegatingMailboxListener, mailboxEventDispatcher, storeRightManager);
- }
-
- public OpenJPAMailboxManager(JPAMailboxSessionMapperFactory mapperFactory,
- Authenticator authenticator,
- Authorizator authorizator,
- MessageParser messageParser,
- MessageId.Factory messageIdFactory,
- int annotationLimit,
- int annotationLimitSize,
- DelegatingMailboxListener delegatingMailboxListener,
- MailboxEventDispatcher mailboxEventDispatcher,
- StoreRightManager storeRightManager) {
- this(mapperFactory, authenticator, authorizator, new JVMMailboxPathLocker(), false,
- messageParser, messageIdFactory, annotationLimit, annotationLimitSize, delegatingMailboxListener, mailboxEventDispatcher, storeRightManager);
+ messageParser, messageIdFactory, annotationManager, delegatingMailboxListener, mailboxEventDispatcher,
+ storeRightManager);
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/JpaMailboxManagerProvider.java
----------------------------------------------------------------------
diff --git a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/JpaMailboxManagerProvider.java b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/JpaMailboxManagerProvider.java
index a9a0180..8d1439c 100644
--- a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/JpaMailboxManagerProvider.java
+++ b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/JpaMailboxManagerProvider.java
@@ -33,7 +33,10 @@ import org.apache.james.mailbox.jpa.openjpa.OpenJPAMailboxManager;
import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.JVMMailboxPathLocker;
+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.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.model.DefaultMessageId;
import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
@@ -56,9 +59,14 @@ public class JpaMailboxManagerProvider {
Authenticator noAuthenticator = null;
Authorizator noAuthorizator = null;
StoreRightManager storeRightManager = new StoreRightManager(mf, aclResolver, groupMembershipResolver);
+ DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
+ StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mf, storeRightManager,
+ LIMIT_ANNOTATIONS, LIMIT_ANNOTATION_SIZE);
OpenJPAMailboxManager openJPAMailboxManager = new OpenJPAMailboxManager(mf, noAuthenticator, noAuthorizator,
- messageParser, new DefaultMessageId.Factory(), LIMIT_ANNOTATIONS,
- LIMIT_ANNOTATION_SIZE, storeRightManager);
+ messageParser, new DefaultMessageId.Factory(),
+ delegatingListener, mailboxEventDispatcher, annotationManager,
+ storeRightManager);
try {
openJPAMailboxManager.init();
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mailbox/lucene/pom.xml
----------------------------------------------------------------------
diff --git a/mailbox/lucene/pom.xml b/mailbox/lucene/pom.xml
index 0da2934..947d584 100644
--- a/mailbox/lucene/pom.xml
+++ b/mailbox/lucene/pom.xml
@@ -49,6 +49,12 @@
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
+ <artifactId>apache-james-mailbox-memory</artifactId>
+ <scope>test</scope>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
<artifactId>apache-james-mailbox-store</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java
----------------------------------------------------------------------
diff --git a/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java b/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java
index 2c6daaa..8d5683e 100644
--- a/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java
+++ b/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java
@@ -20,23 +20,11 @@
package org.apache.james.mailbox.lucene.search;
import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
-import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.inmemory.InMemoryId;
-import org.apache.james.mailbox.inmemory.InMemoryMailboxManager;
-import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
-import org.apache.james.mailbox.model.TestMessageId;
-import org.apache.james.mailbox.store.FakeAuthenticator;
-import org.apache.james.mailbox.store.FakeAuthorizator;
-import org.apache.james.mailbox.store.JVMMailboxPathLocker;
-import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
+import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
+import org.apache.james.mailbox.mock.MockMailboxSession;
import org.apache.james.mailbox.store.StoreMessageIdManager;
-import org.apache.james.mailbox.store.StoreRightManager;
-import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
-import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
-import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
-import org.apache.james.mailbox.store.quota.DefaultQuotaRootResolver;
-import org.apache.james.mailbox.store.quota.NoQuotaManager;
import org.apache.james.mailbox.store.search.AbstractMessageSearchIndexTest;
import org.apache.lucene.store.RAMDirectory;
import org.junit.Ignore;
@@ -49,35 +37,22 @@ public class LuceneMessageSearchIndexTest extends AbstractMessageSearchIndexTest
@Override
protected void initializeMailboxManager() throws Exception {
- TestMessageId.Factory messageIdFactory = new TestMessageId.Factory();
- MailboxSessionMapperFactory mapperFactory = new InMemoryMailboxSessionMapperFactory();
- UnionMailboxACLResolver aclResolver = new UnionMailboxACLResolver();
- SimpleGroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
- StoreRightManager storeRightManager = new StoreRightManager(mapperFactory, aclResolver, groupMembershipResolver);
-
- DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
- MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
- storeMailboxManager = new InMemoryMailboxManager(
- mapperFactory,
- new FakeAuthenticator(),
- FakeAuthorizator.defaultReject(),
- new JVMMailboxPathLocker(),
- new MessageParser(),
- messageIdFactory,
- mailboxEventDispatcher,
- delegatingListener,
- storeRightManager);
+ storeMailboxManager = new InMemoryIntegrationResources()
+ .createMailboxManager(new SimpleGroupMembershipResolver());
messageIdManager = new StoreMessageIdManager(
storeMailboxManager,
storeMailboxManager.getMapperFactory(),
- mailboxEventDispatcher,
- messageIdFactory,
- new NoQuotaManager(),
- new DefaultQuotaRootResolver(mapperFactory));
- messageSearchIndex = new LuceneMessageSearchIndex(mapperFactory, new InMemoryId.Factory(), new RAMDirectory(), messageIdFactory);
- storeMailboxManager.setMessageSearchIndex(messageSearchIndex);
- storeMailboxManager.init();
+ storeMailboxManager.getEventDispatcher(),
+ storeMailboxManager.getMessageIdFactory(),
+ storeMailboxManager.getQuotaManager(),
+ storeMailboxManager.getQuotaRootResolver());
+ LuceneMessageSearchIndex luceneMessageSearchIndex = new LuceneMessageSearchIndex(
+ storeMailboxManager.getMapperFactory(), new InMemoryId.Factory(), new RAMDirectory(),
+ storeMailboxManager.getMessageIdFactory());
+ storeMailboxManager.setMessageSearchIndex(luceneMessageSearchIndex);
+ storeMailboxManager.addGlobalListener(luceneMessageSearchIndex, new MockMailboxSession("admin"));
+ this.messageSearchIndex = luceneMessageSearchIndex;
}
/**
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mailbox/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerProvider.java
----------------------------------------------------------------------
diff --git a/mailbox/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerProvider.java b/mailbox/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerProvider.java
index 88bcf7c..4d10a6f 100644
--- a/mailbox/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerProvider.java
+++ b/mailbox/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerProvider.java
@@ -29,6 +29,7 @@ import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.JVMMailboxPathLocker;
+import org.apache.james.mailbox.store.StoreMailboxAnnotationManager;
import org.apache.james.mailbox.store.StoreMailboxManager;
import org.apache.james.mailbox.store.StoreRightManager;
import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
@@ -52,8 +53,10 @@ public class MaildirMailboxManagerProvider {
DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
+ StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mf, storeRightManager);
StoreMailboxManager manager = new StoreMailboxManager(mf, noAuthenticator, noAuthorizator, new JVMMailboxPathLocker(),
- messageParser, new DefaultMessageId.Factory(), mailboxEventDispatcher, delegatingListener, storeRightManager);
+ messageParser, new DefaultMessageId.Factory(), annotationManager,
+ mailboxEventDispatcher, delegatingListener, storeRightManager);
manager.init();
return manager;
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManager.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManager.java b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManager.java
index 884bc9b..f333035 100644
--- a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManager.java
+++ b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManager.java
@@ -26,12 +26,11 @@ import javax.inject.Inject;
import org.apache.james.mailbox.MailboxPathLocker;
import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.model.MailboxConstants;
import org.apache.james.mailbox.model.MessageId;
import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
-import org.apache.james.mailbox.store.JVMMailboxPathLocker;
import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
+import org.apache.james.mailbox.store.StoreMailboxAnnotationManager;
import org.apache.james.mailbox.store.StoreMailboxManager;
import org.apache.james.mailbox.store.StoreMessageManager;
import org.apache.james.mailbox.store.StoreRightManager;
@@ -46,20 +45,12 @@ public class InMemoryMailboxManager extends StoreMailboxManager {
@Inject
public InMemoryMailboxManager(MailboxSessionMapperFactory mailboxSessionMapperFactory, Authenticator authenticator, Authorizator authorizator,
MailboxPathLocker locker, MessageParser messageParser, MessageId.Factory messageIdFactory, MailboxEventDispatcher dispatcher,
- DelegatingMailboxListener delegatingMailboxListener, StoreRightManager storeRightManager) {
- super(mailboxSessionMapperFactory, authenticator, authorizator, locker, messageParser, messageIdFactory,
- MailboxConstants.DEFAULT_LIMIT_ANNOTATIONS_ON_MAILBOX, MailboxConstants.DEFAULT_LIMIT_ANNOTATION_SIZE, dispatcher,
- delegatingMailboxListener, storeRightManager);
- }
-
- public InMemoryMailboxManager(MailboxSessionMapperFactory mailboxSessionMapperFactory, Authenticator authenticator, Authorizator authorizator,
- MessageParser messageParser, MessageId.Factory messageIdFactory,
- int limitOfAnnotations, int limitAnnotationSize,
- MailboxEventDispatcher dispatcher,
DelegatingMailboxListener delegatingMailboxListener,
+ StoreMailboxAnnotationManager annotationManager,
StoreRightManager storeRightManager) {
- super(mailboxSessionMapperFactory, authenticator, authorizator, new JVMMailboxPathLocker(), messageParser, messageIdFactory,
- limitOfAnnotations, limitAnnotationSize, dispatcher, delegatingMailboxListener, storeRightManager);
+ super(mailboxSessionMapperFactory, authenticator, authorizator, locker, messageParser, messageIdFactory,
+ annotationManager, dispatcher,
+ delegatingMailboxListener, storeRightManager);
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/MemoryMailboxManagerProvider.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/MemoryMailboxManagerProvider.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/MemoryMailboxManagerProvider.java
index be1c2b9..5d290f6 100644
--- a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/MemoryMailboxManagerProvider.java
+++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/MemoryMailboxManagerProvider.java
@@ -28,6 +28,9 @@ import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.model.MessageId;
import org.apache.james.mailbox.store.FakeAuthenticator;
import org.apache.james.mailbox.store.FakeAuthorizator;
+import org.apache.james.mailbox.store.JVMMailboxPathLocker;
+import org.apache.james.mailbox.store.StoreAttachmentManager;
+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.event.MailboxEventDispatcher;
@@ -49,9 +52,11 @@ public class MemoryMailboxManagerProvider {
MessageId.Factory messageIdFactory = new InMemoryMessageId.Factory();
DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
+ StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mailboxSessionMapperFactory, storeRightManager,
+ LIMIT_ANNOTATIONS, LIMIT_ANNOTATION_SIZE);
InMemoryMailboxManager mailboxManager = new InMemoryMailboxManager(mailboxSessionMapperFactory, new FakeAuthenticator(), FakeAuthorizator.defaultReject(),
- messageParser, messageIdFactory, LIMIT_ANNOTATIONS, LIMIT_ANNOTATION_SIZE,
- mailboxEventDispatcher, delegatingListener, storeRightManager);
+ new JVMMailboxPathLocker(), messageParser, messageIdFactory, mailboxEventDispatcher, delegatingListener,
+ annotationManager, storeRightManager);
try {
mailboxManager.init();
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/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 56ea10a..0ba5857 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
@@ -37,6 +37,7 @@ import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
import org.apache.james.mailbox.store.NoMailboxPathLocker;
+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.event.MailboxEventDispatcher;
@@ -63,14 +64,15 @@ public class InMemoryMailboxManagerAttachmentTest extends AbstractMailboxManager
DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
+ StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mailboxSessionMapperFactory, storeRightManager);
mailboxManager = new InMemoryMailboxManager(mailboxSessionMapperFactory, noAuthenticator, noAuthorizator, new NoMailboxPathLocker(),
- new MessageParser(), messageIdFactory, mailboxEventDispatcher, delegatingListener, storeRightManager);
+ new MessageParser(), messageIdFactory, mailboxEventDispatcher, delegatingListener, annotationManager, storeRightManager);
mailboxManager.init();
MessageParser failingMessageParser = mock(MessageParser.class);
when(failingMessageParser.retrieveAttachments(any(InputStream.class)))
.thenThrow(new RuntimeException("Message parser set to fail"));
parseFailingMailboxManager = new InMemoryMailboxManager(mailboxSessionMapperFactory, noAuthenticator, noAuthorizator, new NoMailboxPathLocker(),
- failingMessageParser, messageIdFactory, mailboxEventDispatcher, delegatingListener, storeRightManager);
+ failingMessageParser, messageIdFactory, mailboxEventDispatcher, delegatingListener, annotationManager, storeRightManager);
parseFailingMailboxManager.init();
super.setUp();
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
index 536751e..3e84c32 100644
--- a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
+++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
@@ -34,9 +34,12 @@ import org.apache.james.mailbox.manager.ManagerTestResources;
import org.apache.james.mailbox.quota.MaxQuotaManager;
import org.apache.james.mailbox.quota.QuotaManager;
import org.apache.james.mailbox.quota.QuotaRootResolver;
+import org.apache.james.mailbox.store.Authenticator;
+import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.FakeAuthenticator;
import org.apache.james.mailbox.store.FakeAuthorizator;
import org.apache.james.mailbox.store.NoMailboxPathLocker;
+import org.apache.james.mailbox.store.StoreMailboxAnnotationManager;
import org.apache.james.mailbox.store.StoreMailboxManager;
import org.apache.james.mailbox.store.StoreMessageIdManager;
import org.apache.james.mailbox.store.StoreRightManager;
@@ -60,6 +63,7 @@ public class InMemoryIntegrationResources implements IntegrationResources<StoreM
fakeAuthenticator.addUser(ManagerTestResources.OTHER_USER, ManagerTestResources.OTHER_USER_PASS);
InMemoryMailboxSessionMapperFactory mailboxSessionMapperFactory = new InMemoryMailboxSessionMapperFactory();
StoreRightManager storeRightManager = new StoreRightManager(mailboxSessionMapperFactory, new UnionMailboxACLResolver(), groupMembershipResolver);
+ StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mailboxSessionMapperFactory, storeRightManager);
DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
@@ -72,6 +76,30 @@ public class InMemoryIntegrationResources implements IntegrationResources<StoreM
new InMemoryMessageId.Factory(),
mailboxEventDispatcher,
delegatingListener,
+ annotationManager,
+ storeRightManager);
+ manager.init();
+ return manager;
+ }
+
+ public StoreMailboxManager createMailboxManager(GroupMembershipResolver groupMembershipResolver,
+ Authenticator authenticator, Authorizator authorizator) throws MailboxException {
+ InMemoryMailboxSessionMapperFactory mailboxSessionMapperFactory = new InMemoryMailboxSessionMapperFactory();
+ StoreRightManager storeRightManager = new StoreRightManager(mailboxSessionMapperFactory, new UnionMailboxACLResolver(), groupMembershipResolver);
+ StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mailboxSessionMapperFactory, storeRightManager);
+
+ DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
+ StoreMailboxManager manager = new InMemoryMailboxManager(
+ mailboxSessionMapperFactory,
+ authenticator,
+ authorizator,
+ new NoMailboxPathLocker(),
+ new MessageParser(),
+ new InMemoryMessageId.Factory(),
+ mailboxEventDispatcher,
+ delegatingListener,
+ annotationManager,
storeRightManager);
manager.init();
return manager;
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mailbox/scanning-search/pom.xml
----------------------------------------------------------------------
diff --git a/mailbox/scanning-search/pom.xml b/mailbox/scanning-search/pom.xml
index e8d3acc..e188f87 100644
--- a/mailbox/scanning-search/pom.xml
+++ b/mailbox/scanning-search/pom.xml
@@ -38,11 +38,23 @@
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
+ <artifactId>apache-james-mailbox-api</artifactId>
+ <scope>test</scope>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
<artifactId>apache-james-mailbox-memory</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
+ <artifactId>apache-james-mailbox-memory</artifactId>
+ <scope>test</scope>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
<artifactId>apache-james-mailbox-store</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java
----------------------------------------------------------------------
diff --git a/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java b/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java
index e28f558..437e292 100644
--- a/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java
+++ b/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java
@@ -19,24 +19,10 @@
package org.apache.james.mailbox.store.search;
-
import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
-import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.inmemory.InMemoryMailboxManager;
-import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
-import org.apache.james.mailbox.inmemory.InMemoryMessageId;
-import org.apache.james.mailbox.store.FakeAuthenticator;
-import org.apache.james.mailbox.store.FakeAuthorizator;
-import org.apache.james.mailbox.store.JVMMailboxPathLocker;
-import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
+import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
import org.apache.james.mailbox.store.StoreMessageIdManager;
-import org.apache.james.mailbox.store.StoreRightManager;
-import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
-import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
-import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
-import org.apache.james.mailbox.store.quota.DefaultQuotaRootResolver;
-import org.apache.james.mailbox.store.quota.NoQuotaManager;
import org.junit.Ignore;
public class SimpleMessageSearchIndexTest extends AbstractMessageSearchIndexTest {
@@ -47,35 +33,23 @@ public class SimpleMessageSearchIndexTest extends AbstractMessageSearchIndexTest
@Override
protected void initializeMailboxManager() throws Exception {
- MailboxSessionMapperFactory mapperFactory = new InMemoryMailboxSessionMapperFactory();
- messageSearchIndex = new SimpleMessageSearchIndex(mapperFactory, mapperFactory, new PDFTextExtractor());
- InMemoryMessageId.Factory messageIdFactory = new InMemoryMessageId.Factory();
- UnionMailboxACLResolver aclResolver = new UnionMailboxACLResolver();
- SimpleGroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
- StoreRightManager storeRightManager = new StoreRightManager(mapperFactory, aclResolver, groupMembershipResolver);
-
- DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
- MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
- storeMailboxManager = new InMemoryMailboxManager(
- mapperFactory,
- new FakeAuthenticator(),
- FakeAuthorizator.defaultReject(),
- new JVMMailboxPathLocker(),
- new MessageParser(),
- messageIdFactory,
- mailboxEventDispatcher,
- delegatingListener,
- storeRightManager);
+ storeMailboxManager = new InMemoryIntegrationResources()
+ .createMailboxManager(new SimpleGroupMembershipResolver());
+
+ messageSearchIndex = new SimpleMessageSearchIndex(
+ storeMailboxManager.getMapperFactory(),
+ storeMailboxManager.getMapperFactory(),
+ new PDFTextExtractor());
messageIdManager = new StoreMessageIdManager(
storeMailboxManager,
storeMailboxManager.getMapperFactory(),
- mailboxEventDispatcher,
- messageIdFactory,
- new NoQuotaManager(),
- new DefaultQuotaRootResolver(mapperFactory));
+ storeMailboxManager.getEventDispatcher(),
+ storeMailboxManager.getMessageIdFactory(),
+ storeMailboxManager.getQuotaManager(),
+ storeMailboxManager.getQuotaRootResolver());
+
storeMailboxManager.setMessageSearchIndex(messageSearchIndex);
- storeMailboxManager.init();
}
/**
http://git-wip-us.apache.org/repos/asf/james-project/blob/9e7abcbe/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxAnnotationManager.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxAnnotationManager.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxAnnotationManager.java
new file mode 100644
index 0000000..69edea3
--- /dev/null
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxAnnotationManager.java
@@ -0,0 +1,146 @@
+/****************************************************************
+ * 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;
+
+import java.util.List;
+import java.util.Set;
+
+import javax.inject.Inject;
+
+import org.apache.james.mailbox.MailboxAnnotationManager;
+import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.exception.AnnotationException;
+import org.apache.james.mailbox.exception.InsufficientRightsException;
+import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.model.MailboxACL.Right;
+import org.apache.james.mailbox.model.MailboxAnnotation;
+import org.apache.james.mailbox.model.MailboxAnnotationKey;
+import org.apache.james.mailbox.model.MailboxConstants;
+import org.apache.james.mailbox.model.MailboxId;
+import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.mailbox.store.mail.AnnotationMapper;
+import org.apache.james.mailbox.store.mail.MailboxMapper;
+import org.apache.james.mailbox.store.mail.model.Mailbox;
+import org.apache.james.mailbox.store.transaction.Mapper;
+
+public class StoreMailboxAnnotationManager implements MailboxAnnotationManager {
+
+ private final MailboxSessionMapperFactory mailboxSessionMapperFactory;
+
+ private final StoreRightManager rightManager;
+ private final int limitOfAnnotations;
+ private final int limitAnnotationSize;
+
+ @Inject
+ public StoreMailboxAnnotationManager(MailboxSessionMapperFactory mailboxSessionMapperFactory,
+ StoreRightManager rightManager) {
+ this(mailboxSessionMapperFactory,
+ rightManager,
+ MailboxConstants.DEFAULT_LIMIT_ANNOTATIONS_ON_MAILBOX,
+ MailboxConstants.DEFAULT_LIMIT_ANNOTATION_SIZE);
+ }
+
+ public StoreMailboxAnnotationManager(MailboxSessionMapperFactory mailboxSessionMapperFactory,
+ StoreRightManager rightManager,
+ int limitOfAnnotations,
+ int limitAnnotationSize) {
+ this.mailboxSessionMapperFactory = mailboxSessionMapperFactory;
+ this.rightManager = rightManager;
+ this.limitOfAnnotations = limitOfAnnotations;
+ this.limitAnnotationSize = limitAnnotationSize;
+ }
+
+ public MailboxId checkThenGetMailboxId(MailboxPath path, MailboxSession session) throws MailboxException {
+ MailboxMapper mailboxMapper = mailboxSessionMapperFactory.getMailboxMapper(session);
+ Mailbox mailbox = mailboxMapper.findMailboxByPath(path);
+ if (!rightManager.hasRight(mailbox, Right.Read, session)) {
+ throw new InsufficientRightsException("Not enough rights on " + path);
+ }
+ return mailbox.getMailboxId();
+ }
+
+ @Override
+ public List<MailboxAnnotation> getAllAnnotations(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
+ AnnotationMapper annotationMapper = mailboxSessionMapperFactory.getAnnotationMapper(session);
+
+ MailboxId mailboxId = checkThenGetMailboxId(mailboxPath, session);
+
+ return annotationMapper.execute(
+ () -> annotationMapper.getAllAnnotations(mailboxId));
+ }
+
+ @Override
+ public List<MailboxAnnotation> getAnnotationsByKeys(MailboxPath mailboxPath, MailboxSession session, final Set<MailboxAnnotationKey> keys)
+ throws MailboxException {
+ AnnotationMapper annotationMapper = mailboxSessionMapperFactory.getAnnotationMapper(session);
+ MailboxId mailboxId = checkThenGetMailboxId(mailboxPath, session);
+
+ return annotationMapper.execute(
+ () -> annotationMapper.getAnnotationsByKeys(mailboxId, keys));
+ }
+
+ @Override
+ public void updateAnnotations(MailboxPath mailboxPath, MailboxSession session, List<MailboxAnnotation> mailboxAnnotations)
+ throws MailboxException {
+ AnnotationMapper annotationMapper = mailboxSessionMapperFactory.getAnnotationMapper(session);
+ MailboxId mailboxId = checkThenGetMailboxId(mailboxPath, session);
+
+ annotationMapper.execute(Mapper.toTransaction(() -> {
+ for (MailboxAnnotation annotation : mailboxAnnotations) {
+ if (annotation.isNil()) {
+ annotationMapper.deleteAnnotation(mailboxId, annotation.getKey());
+ } else if (canInsertOrUpdate(mailboxId, annotation, annotationMapper)) {
+ annotationMapper.insertAnnotation(mailboxId, annotation);
+ }
+ }
+ }));
+ }
+
+ private boolean canInsertOrUpdate(MailboxId mailboxId, MailboxAnnotation annotation, AnnotationMapper annotationMapper) throws AnnotationException {
+ if (annotation.size() > limitAnnotationSize) {
+ throw new AnnotationException("annotation too big.");
+ }
+ if (!annotationMapper.exist(mailboxId, annotation)
+ && annotationMapper.countAnnotations(mailboxId) >= limitOfAnnotations) {
+ throw new AnnotationException("too many annotations.");
+ }
+ return true;
+ }
+
+ @Override
+ public List<MailboxAnnotation> getAnnotationsByKeysWithOneDepth(MailboxPath mailboxPath, MailboxSession session,
+ Set<MailboxAnnotationKey> keys) throws MailboxException {
+ AnnotationMapper annotationMapper = mailboxSessionMapperFactory.getAnnotationMapper(session);
+ final MailboxId mailboxId = checkThenGetMailboxId(mailboxPath, session);
+
+ return annotationMapper.execute(
+ () -> annotationMapper.getAnnotationsByKeysWithOneDepth(mailboxId, keys));
+ }
+
+ @Override
+ public List<MailboxAnnotation> getAnnotationsByKeysWithAllDepth(MailboxPath mailboxPath, MailboxSession session,
+ Set<MailboxAnnotationKey> keys) throws MailboxException {
+ AnnotationMapper annotationMapper = mailboxSessionMapperFactory.getAnnotationMapper(session);
+ MailboxId mailboxId = checkThenGetMailboxId(mailboxPath, session);
+
+ return annotationMapper.execute(
+ () -> annotationMapper.getAnnotationsByKeysWithAllDepth(mailboxId, keys));
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[15/15] james-project git commit: MAILBOX-317 Bonus: Further simplify
InMemoryMailboxManager hierarchy
Posted by bt...@apache.org.
MAILBOX-317 Bonus: Further simplify InMemoryMailboxManager hierarchy
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/c301e821
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/c301e821
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/c301e821
Branch: refs/heads/master
Commit: c301e821060e544fbd753938cc62816ce3aff36a
Parents: b9be091
Author: benwa <bt...@linagora.com>
Authored: Thu Nov 2 13:32:53 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Fri Nov 3 09:32:33 2017 +0700
----------------------------------------------------------------------
.../james/mailbox/MailboxManagerStressTest.java | 4 +-
.../james/mailbox/MailboxManagerTest.java | 2 +-
.../inmemory/MemoryMailboxManagerProvider.java | 43 +++-----------------
.../MemoryMailboxManagerStressTest.java | 3 +-
.../inmemory/MemoryMailboxManagerTest.java | 3 +-
.../manager/InMemoryIntegrationResources.java | 28 ++++++++++++-
.../host/ElasticSearchHostSystem.java | 8 ++--
.../org/apache/james/JPAJamesServerMain.java | 4 +-
.../org/apache/james/modules/MailboxModule.java | 10 +++++
.../modules/mailbox/MemoryMailboxModule.java | 8 ----
10 files changed, 56 insertions(+), 57 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/c301e821/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 8b4e580..1ad56e0 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
@@ -46,10 +46,10 @@ public abstract class MailboxManagerStressTest {
private MailboxManager mailboxManager;
- protected abstract MailboxManager provideManager();
+ protected abstract MailboxManager provideManager() throws MailboxException;
- public void setUp() throws MailboxException, Exception {
+ public void setUp() throws Exception {
this.mailboxManager = provideManager();
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/c301e821/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 d4e722d..be94d90 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
@@ -84,7 +84,7 @@ public abstract class MailboxManagerTest {
private MailboxManager mailboxManager;
private MailboxSession session;
- protected abstract MailboxManager provideMailboxManager();
+ protected abstract MailboxManager provideMailboxManager() throws MailboxException;
public void setUp() throws Exception {
this.mailboxManager = new MockMailboxManager(provideMailboxManager()).getMockMailboxManager();
http://git-wip-us.apache.org/repos/asf/james-project/blob/c301e821/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/MemoryMailboxManagerProvider.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/MemoryMailboxManagerProvider.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/MemoryMailboxManagerProvider.java
index 5d290f6..c8eedd1 100644
--- a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/MemoryMailboxManagerProvider.java
+++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/MemoryMailboxManagerProvider.java
@@ -20,51 +20,18 @@
package org.apache.james.mailbox.inmemory;
import org.apache.james.mailbox.MailboxManager;
-import org.apache.james.mailbox.acl.GroupMembershipResolver;
-import org.apache.james.mailbox.acl.MailboxACLResolver;
import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
-import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.model.MessageId;
-import org.apache.james.mailbox.store.FakeAuthenticator;
-import org.apache.james.mailbox.store.FakeAuthorizator;
-import org.apache.james.mailbox.store.JVMMailboxPathLocker;
-import org.apache.james.mailbox.store.StoreAttachmentManager;
-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.event.MailboxEventDispatcher;
-import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
-
-import com.google.common.base.Throwables;
+import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
public class MemoryMailboxManagerProvider {
private static final int LIMIT_ANNOTATIONS = 3;
private static final int LIMIT_ANNOTATION_SIZE = 30;
- public static MailboxManager provideMailboxManager() {
- MailboxACLResolver aclResolver = new UnionMailboxACLResolver();
- GroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
- MessageParser messageParser = new MessageParser();
-
- InMemoryMailboxSessionMapperFactory mailboxSessionMapperFactory = new InMemoryMailboxSessionMapperFactory();
- StoreRightManager storeRightManager = new StoreRightManager(mailboxSessionMapperFactory, aclResolver, groupMembershipResolver);
- MessageId.Factory messageIdFactory = new InMemoryMessageId.Factory();
- DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
- MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
- StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mailboxSessionMapperFactory, storeRightManager,
- LIMIT_ANNOTATIONS, LIMIT_ANNOTATION_SIZE);
- InMemoryMailboxManager mailboxManager = new InMemoryMailboxManager(mailboxSessionMapperFactory, new FakeAuthenticator(), FakeAuthorizator.defaultReject(),
- new JVMMailboxPathLocker(), messageParser, messageIdFactory, mailboxEventDispatcher, delegatingListener,
- annotationManager, storeRightManager);
-
- try {
- mailboxManager.init();
- } catch (MailboxException e) {
- throw Throwables.propagate(e);
- }
-
- return mailboxManager;
+ public static MailboxManager provideMailboxManager() throws MailboxException {
+ return new InMemoryIntegrationResources()
+ .createMailboxManager(new SimpleGroupMembershipResolver(),
+ LIMIT_ANNOTATIONS, LIMIT_ANNOTATION_SIZE);
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/c301e821/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/MemoryMailboxManagerStressTest.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/MemoryMailboxManagerStressTest.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/MemoryMailboxManagerStressTest.java
index b8b03c1..9212e89 100644
--- a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/MemoryMailboxManagerStressTest.java
+++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/MemoryMailboxManagerStressTest.java
@@ -21,6 +21,7 @@ package org.apache.james.mailbox.inmemory;
import org.apache.james.mailbox.MailboxManager;
import org.apache.james.mailbox.MailboxManagerStressTest;
+import org.apache.james.mailbox.exception.MailboxException;
import org.junit.Before;
public class MemoryMailboxManagerStressTest extends MailboxManagerStressTest {
@@ -31,7 +32,7 @@ public class MemoryMailboxManagerStressTest extends MailboxManagerStressTest {
}
@Override
- protected MailboxManager provideManager() {
+ protected MailboxManager provideManager() throws MailboxException {
return MemoryMailboxManagerProvider.provideMailboxManager();
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/c301e821/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/MemoryMailboxManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/MemoryMailboxManagerTest.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/MemoryMailboxManagerTest.java
index c958a14..023c117 100644
--- a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/MemoryMailboxManagerTest.java
+++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/MemoryMailboxManagerTest.java
@@ -21,6 +21,7 @@ package org.apache.james.mailbox.inmemory;
import org.apache.james.mailbox.MailboxManager;
import org.apache.james.mailbox.MailboxManagerTest;
+import org.apache.james.mailbox.exception.MailboxException;
import org.junit.Before;
public class MemoryMailboxManagerTest extends MailboxManagerTest {
@@ -31,7 +32,7 @@ public class MemoryMailboxManagerTest extends MailboxManagerTest {
}
@Override
- protected MailboxManager provideMailboxManager() {
+ protected MailboxManager provideMailboxManager() throws MailboxException {
return MemoryMailboxManagerProvider.provideMailboxManager();
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/c301e821/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
index 3e84c32..5c6e4a6 100644
--- a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
+++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
@@ -19,6 +19,8 @@
package org.apache.james.mailbox.inmemory.manager;
+import java.util.function.BiFunction;
+
import org.apache.james.mailbox.MessageIdManager;
import org.apache.james.mailbox.acl.GroupMembershipResolver;
import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
@@ -38,6 +40,7 @@ import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.Authorizator;
import org.apache.james.mailbox.store.FakeAuthenticator;
import org.apache.james.mailbox.store.FakeAuthorizator;
+import org.apache.james.mailbox.store.JVMMailboxPathLocker;
import org.apache.james.mailbox.store.NoMailboxPathLocker;
import org.apache.james.mailbox.store.StoreMailboxAnnotationManager;
import org.apache.james.mailbox.store.StoreMailboxManager;
@@ -58,12 +61,33 @@ public class InMemoryIntegrationResources implements IntegrationResources<StoreM
@Override
public StoreMailboxManager createMailboxManager(GroupMembershipResolver groupMembershipResolver) throws MailboxException {
+ return createMailboxManager(groupMembershipResolver,
+ ((storeRightManager, inMemoryMailboxSessionMapperFactory) ->
+ new StoreMailboxAnnotationManager(
+ inMemoryMailboxSessionMapperFactory,
+ storeRightManager)));
+ }
+
+ public StoreMailboxManager createMailboxManager(GroupMembershipResolver groupMembershipResolver,
+ int limitAnnotationCount, int limitAnnotationSize) throws MailboxException {
+ return createMailboxManager(groupMembershipResolver,
+ ((storeRightManager, inMemoryMailboxSessionMapperFactory) ->
+ new StoreMailboxAnnotationManager(
+ inMemoryMailboxSessionMapperFactory,
+ storeRightManager,
+ limitAnnotationCount,
+ limitAnnotationSize)));
+ }
+
+ private StoreMailboxManager createMailboxManager(GroupMembershipResolver groupMembershipResolver,
+ BiFunction<StoreRightManager, InMemoryMailboxSessionMapperFactory, StoreMailboxAnnotationManager> annotationManagerBiFunction) throws MailboxException {
FakeAuthenticator fakeAuthenticator = new FakeAuthenticator();
fakeAuthenticator.addUser(ManagerTestResources.USER, ManagerTestResources.USER_PASS);
fakeAuthenticator.addUser(ManagerTestResources.OTHER_USER, ManagerTestResources.OTHER_USER_PASS);
InMemoryMailboxSessionMapperFactory mailboxSessionMapperFactory = new InMemoryMailboxSessionMapperFactory();
StoreRightManager storeRightManager = new StoreRightManager(mailboxSessionMapperFactory, new UnionMailboxACLResolver(), groupMembershipResolver);
- StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mailboxSessionMapperFactory, storeRightManager);
+ StoreMailboxAnnotationManager annotationManager = annotationManagerBiFunction
+ .apply(storeRightManager, mailboxSessionMapperFactory);
DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
@@ -71,7 +95,7 @@ public class InMemoryIntegrationResources implements IntegrationResources<StoreM
mailboxSessionMapperFactory,
fakeAuthenticator,
FakeAuthorizator.defaultReject(),
- new NoMailboxPathLocker(),
+ new JVMMailboxPathLocker(),
new MessageParser(),
new InMemoryMessageId.Factory(),
mailboxEventDispatcher,
http://git-wip-us.apache.org/repos/asf/james-project/blob/c301e821/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java b/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
index 9b36b88..a7f2c76 100644
--- a/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
+++ b/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
@@ -112,10 +112,12 @@ public class ElasticSearchHostSystem extends JamesImapHostSystem {
MailboxElasticSearchConstants.DEFAULT_MAILBOX_READ_ALIAS, MailboxElasticSearchConstants.MESSAGE_TYPE),
new MessageToElasticSearchJson(new DefaultTextExtractor(), ZoneId.systemDefault(), IndexAttachments.YES));
- InMemoryIntegrationResources inMemoryIntegrationResources = new InMemoryIntegrationResources();
- this.mailboxManager = inMemoryIntegrationResources.createMailboxManager(new SimpleGroupMembershipResolver());
+ this.mailboxManager = new InMemoryIntegrationResources()
+ .createMailboxManager(new SimpleGroupMembershipResolver(),
+ authenticator,
+ authorizator);
this.mailboxManager.setMessageSearchIndex(searchIndex);
- this.mailboxManager.removeGlobalListener(searchIndex, new MockMailboxSession("admin"));
+ this.mailboxManager.addGlobalListener(searchIndex, new MockMailboxSession("admin"));
final ImapProcessor defaultImapProcessorFactory =
DefaultImapProcessorFactory.createDefaultProcessor(this.mailboxManager,
http://git-wip-us.apache.org/repos/asf/james-project/blob/c301e821/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java b/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
index e4a63b2..783b1bd 100644
--- a/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
+++ b/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
@@ -22,6 +22,7 @@ package org.apache.james;
import org.apache.james.modules.MailboxModule;
import org.apache.james.modules.data.JPADataModule;
import org.apache.james.modules.data.SieveFileRepositoryModule;
+import org.apache.james.modules.mailbox.DefaultEventModule;
import org.apache.james.modules.mailbox.JPAMailboxModule;
import org.apache.james.modules.mailbox.LuceneSearchMailboxModule;
import org.apache.james.modules.protocols.IMAPServerModule;
@@ -70,7 +71,8 @@ public class JPAJamesServerMain {
new MailboxModule(),
new NoJwtModule(),
new RawPostDequeueDecoratorModule(),
- new SieveFileRepositoryModule());
+ new SieveFileRepositoryModule(),
+ new DefaultEventModule());
public static void main(String[] args) throws Exception {
GuiceJamesServer server = new GuiceJamesServer()
http://git-wip-us.apache.org/repos/asf/james-project/blob/c301e821/server/container/guice/mailbox/src/main/java/org/apache/james/modules/MailboxModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/mailbox/src/main/java/org/apache/james/modules/MailboxModule.java b/server/container/guice/mailbox/src/main/java/org/apache/james/modules/MailboxModule.java
index a91ada3..dc8bdc7 100644
--- a/server/container/guice/mailbox/src/main/java/org/apache/james/modules/MailboxModule.java
+++ b/server/container/guice/mailbox/src/main/java/org/apache/james/modules/MailboxModule.java
@@ -18,9 +18,14 @@
****************************************************************/
package org.apache.james.modules;
+import org.apache.james.mailbox.acl.GroupMembershipResolver;
+import org.apache.james.mailbox.acl.MailboxACLResolver;
+import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
+import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
import org.apache.james.utils.GuiceProbe;
import com.google.inject.AbstractModule;
+import com.google.inject.Scopes;
import com.google.inject.multibindings.Multibinder;
public class MailboxModule extends AbstractModule {
@@ -31,6 +36,11 @@ public class MailboxModule extends AbstractModule {
probeMultiBinder.addBinding().to(MailboxProbeImpl.class);
probeMultiBinder.addBinding().to(QuotaProbesImpl.class);
probeMultiBinder.addBinding().to(ACLProbeImpl.class);
+
+ bind(UnionMailboxACLResolver.class).in(Scopes.SINGLETON);
+ bind(MailboxACLResolver.class).to(UnionMailboxACLResolver.class);
+ bind(SimpleGroupMembershipResolver.class).in(Scopes.SINGLETON);
+ bind(GroupMembershipResolver.class).to(SimpleGroupMembershipResolver.class);
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/c301e821/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java
index 301190c..204dbf3 100644
--- a/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java
+++ b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java
@@ -29,10 +29,6 @@ import org.apache.james.mailbox.MailboxManager;
import org.apache.james.mailbox.MailboxPathLocker;
import org.apache.james.mailbox.MessageIdManager;
import org.apache.james.mailbox.SubscriptionManager;
-import org.apache.james.mailbox.acl.GroupMembershipResolver;
-import org.apache.james.mailbox.acl.MailboxACLResolver;
-import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
-import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.extractor.TextExtractor;
import org.apache.james.mailbox.inmemory.InMemoryId;
@@ -99,8 +95,6 @@ public class MemoryMailboxModule extends AbstractModule {
bind(Authorizator.class).to(UserRepositoryAuthorizator.class);
bind(MailboxManager.class).to(InMemoryMailboxManager.class);
bind(MessageIdManager.class).to(StoreMessageIdManager.class);
- bind(MailboxACLResolver.class).to(UnionMailboxACLResolver.class);
- bind(GroupMembershipResolver.class).to(SimpleGroupMembershipResolver.class);
bind(AttachmentManager.class).to(StoreAttachmentManager.class);
bind(MessageSearchIndex.class).to(SimpleMessageSearchIndex.class);
@@ -115,8 +109,6 @@ public class MemoryMailboxModule extends AbstractModule {
bind(UserRepositoryAuthenticator.class).in(Scopes.SINGLETON);
bind(UserRepositoryAuthorizator.class).in(Scopes.SINGLETON);
bind(InMemoryMailboxManager.class).in(Scopes.SINGLETON);
- bind(UnionMailboxACLResolver.class).in(Scopes.SINGLETON);
- bind(SimpleGroupMembershipResolver.class).in(Scopes.SINGLETON);
bind(InMemoryMessageId.Factory.class).in(Scopes.SINGLETON);
bind(StoreMessageIdManager.class).in(Scopes.SINGLETON);
bind(MailboxEventDispatcher.class).in(Scopes.SINGLETON);
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org