You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2021/02/02 08:17:53 UTC

[james-project] 04/04: JAMES-3444 Perform JMAP TransportChecks only when JMAP is enabled

This is an automated email from the ASF dual-hosted git repository.

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

commit 6b4fca05402880a69c1c39e72afaa3d32ad36550
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Fri Jan 29 23:52:27 2021 +0700

    JAMES-3444 Perform JMAP TransportChecks only when JMAP is enabled
    
    On gitter with one of our users:
    
    https://github.com/devnewton reported:
    
    {code:java}
    Hello, I try to setup Apache James + Cassandra + LDAP following the documentation and Dockerfile configuration sample.
    
    James crash at startup because of missing something related to JMAP: Missing org.apache.james.jmap.mailet.filter.JMAPFiltering in mailets configuration (mailetcontainer -> processors -> transport).
    
    I tried to disable this protocol using enabled=false in conf/jmap.properties but it has no effect.
    {code}
    
    The short term solution for him is to had the missing mailet.
    
    But does it even make sense, when JMAP is disabled, to require
    people to configure JMAP mailets?
    
    Maybe we should relax the checks and only perform them only when
    JMAP is enabled. This should result in an easier to use mail server.
---
 .../modules/server/CamelMailetContainerModule.java |  9 ++++++
 .../org/apache/james/jmap/draft/JMAPModule.java    | 37 +++++++++++++++-------
 2 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/server/container/guice/mailet/src/main/java/org/apache/james/modules/server/CamelMailetContainerModule.java b/server/container/guice/mailet/src/main/java/org/apache/james/modules/server/CamelMailetContainerModule.java
index 0364045..4706a65 100644
--- a/server/container/guice/mailet/src/main/java/org/apache/james/modules/server/CamelMailetContainerModule.java
+++ b/server/container/guice/mailet/src/main/java/org/apache/james/modules/server/CamelMailetContainerModule.java
@@ -241,6 +241,15 @@ public class CamelMailetContainerModule extends AbstractModule {
 
     @FunctionalInterface
     public interface ProcessorsCheck {
+        static ProcessorsCheck noCheck() {
+            return new ProcessorsCheck() {
+                @Override
+                public void check(Multimap<String, MatcherMailetPair> processors) {
+
+                }
+            };
+        }
+
         void check(Multimap<String, MatcherMailetPair> processors) throws ConfigurationException;
 
         class Or implements ProcessorsCheck {
diff --git a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/draft/JMAPModule.java b/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/draft/JMAPModule.java
index 9c5b19c..7185537 100644
--- a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/draft/JMAPModule.java
+++ b/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/draft/JMAPModule.java
@@ -52,6 +52,7 @@ import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxManager.SearchCapabilities;
 import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.modules.server.CamelMailetContainerModule;
+import org.apache.james.modules.server.CamelMailetContainerModule.ProcessorsCheck;
 import org.apache.james.queue.api.MailQueueItemDecoratorFactory;
 import org.apache.james.server.core.configuration.FileConfigurationProvider;
 import org.apache.james.transport.matchers.All;
@@ -86,23 +87,23 @@ public class JMAPModule extends AbstractModule {
                 throw new RuntimeException(e);
             }
         };
-    public static final CamelMailetContainerModule.ProcessorsCheck VACATION_MAILET_CHECK =
-        CamelMailetContainerModule.ProcessorsCheck.Or.of(
-            new CamelMailetContainerModule.ProcessorsCheck.Impl(
+    public static final ProcessorsCheck VACATION_MAILET_CHECK =
+        ProcessorsCheck.Or.of(
+            new ProcessorsCheck.Impl(
                 Mail.TRANSPORT,
                 RecipientIsLocal.class,
                 VacationMailet.class),
-            new CamelMailetContainerModule.ProcessorsCheck.Impl(
+            new ProcessorsCheck.Impl(
                 Mail.LOCAL_DELIVERY,
                 All.class,
                 VacationMailet.class));
-    public static final CamelMailetContainerModule.ProcessorsCheck FILTERING_MAILET_CHECK =
-        CamelMailetContainerModule.ProcessorsCheck.Or.of(
-        new CamelMailetContainerModule.ProcessorsCheck.Impl(
+    public static final ProcessorsCheck FILTERING_MAILET_CHECK =
+        ProcessorsCheck.Or.of(
+        new ProcessorsCheck.Impl(
             Mail.TRANSPORT,
             RecipientIsLocal.class,
             JMAPFiltering.class),
-        new CamelMailetContainerModule.ProcessorsCheck.Impl(
+        new ProcessorsCheck.Impl(
             Mail.LOCAL_DELIVERY,
             All.class,
             JMAPFiltering.class));
@@ -123,10 +124,6 @@ public class JMAPModule extends AbstractModule {
         bind(HtmlTextExtractor.class).to(JsoupHtmlTextExtractor.class);
         Multibinder.newSetBinder(binder(), StartUpCheck.class).addBinding().to(RequiredCapabilitiesStartUpCheck.class);
 
-        Multibinder<CamelMailetContainerModule.ProcessorsCheck> transportProcessorChecks = Multibinder.newSetBinder(binder(), CamelMailetContainerModule.ProcessorsCheck.class);
-        transportProcessorChecks.addBinding().toInstance(VACATION_MAILET_CHECK);
-        transportProcessorChecks.addBinding().toInstance(FILTERING_MAILET_CHECK);
-
         bind(MailQueueItemDecoratorFactory.class).to(PostDequeueDecoratorFactory.class).in(Scopes.SINGLETON);
 
         Multibinder.newSetBinder(binder(), MailboxListener.GroupMailboxListener.class).addBinding().to(PropagateLookupRightListener.class);
@@ -145,6 +142,22 @@ public class JMAPModule extends AbstractModule {
     }
 
     @ProvidesIntoSet
+    ProcessorsCheck vacationMailetCheck(JMAPConfiguration configuration) {
+        if (configuration.isEnabled()) {
+            return VACATION_MAILET_CHECK;
+        }
+        return ProcessorsCheck.noCheck();
+    }
+
+    @ProvidesIntoSet
+    ProcessorsCheck filteringMailetCheck(JMAPConfiguration configuration) {
+        if (configuration.isEnabled()) {
+            return FILTERING_MAILET_CHECK;
+        }
+        return ProcessorsCheck.noCheck();
+    }
+
+    @ProvidesIntoSet
     Capability coreCapability(JmapRfc8621Configuration configuration) {
         return DefaultCapabilities.coreCapability(configuration.maxUploadSize());
     }


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