james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [02/15] james-project git commit: MAILBOX-317 Rework CassandraMailboxManager constructor
Date Fri, 03 Nov 2017 02:33:19 GMT
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 <btellier@linagora.com>
Authored: Thu Nov 2 09:00:01 2017 +0700
Committer: benwa <btellier@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


Mime
View raw message