james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [04/15] james-project git commit: MAILBOX-317 Solve Spring related issues.
Date Fri, 03 Nov 2017 02:33:21 GMT
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 <btellier@linagora.com>
Authored: Thu Nov 2 12:51:38 2017 +0700
Committer: benwa <btellier@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


Mime
View raw message