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 2020/11/20 02:18:07 UTC

[james-project] 01/18: JAMES-3440 Configuration option to enable EmailQuery view

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 3d231c2c240a0ff44e8bb7385a84f693fe78f4a3
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Mon Nov 16 13:13:58 2020 +0700

    JAMES-3440 Configuration option to enable EmailQuery view
    
    File: jmap.properties
    Default value: false (as we can not assume admins would have provisioned the view correctly, we
    should let them a grace period to migrate their data).
---
 .../destination/conf/jmap.properties               |  4 ++++
 .../destination/conf/jmap.properties               |  4 ++++
 .../destination/conf/jmap.properties               |  4 ++++
 .../cassandra/destination/conf/jmap.properties     |  4 ++++
 .../guice/memory/destination/conf/jmap.properties  |  4 ++++
 .../servers/pages/distributed/configure/jmap.adoc  |  5 ++++
 .../org/apache/james/jmap/draft/JMAPModule.java    |  1 +
 .../org/apache/james/jmap/JMAPConfiguration.java   | 28 ++++++++++++++++++++--
 .../apache/james/jmap/JMAPConfigurationTest.java   |  9 ++++---
 src/site/xdoc/server/config-jmap.xml               |  5 ++++
 10 files changed, 63 insertions(+), 5 deletions(-)

diff --git a/dockerfiles/run/guice/cassandra-ldap/destination/conf/jmap.properties b/dockerfiles/run/guice/cassandra-ldap/destination/conf/jmap.properties
index 53bc403..1980cfa 100644
--- a/dockerfiles/run/guice/cassandra-ldap/destination/conf/jmap.properties
+++ b/dockerfiles/run/guice/cassandra-ldap/destination/conf/jmap.properties
@@ -12,3 +12,7 @@ tls.secret=james72laBalle
 # which should be a PEM format file.
 #
 jwt.publickeypem.url=file://conf/jwt_publickey
+
+# Should simple Email/query be resolved against a Cassandra projection, or should we resolve them against ElasticSearch?
+# This enables a higher resilience, but the projection needs to be correctly populated. False by default.
+# view.email.query.enabled=true
diff --git a/dockerfiles/run/guice/cassandra-rabbitmq-ldap/destination/conf/jmap.properties b/dockerfiles/run/guice/cassandra-rabbitmq-ldap/destination/conf/jmap.properties
index 53bc403..1980cfa 100644
--- a/dockerfiles/run/guice/cassandra-rabbitmq-ldap/destination/conf/jmap.properties
+++ b/dockerfiles/run/guice/cassandra-rabbitmq-ldap/destination/conf/jmap.properties
@@ -12,3 +12,7 @@ tls.secret=james72laBalle
 # which should be a PEM format file.
 #
 jwt.publickeypem.url=file://conf/jwt_publickey
+
+# Should simple Email/query be resolved against a Cassandra projection, or should we resolve them against ElasticSearch?
+# This enables a higher resilience, but the projection needs to be correctly populated. False by default.
+# view.email.query.enabled=true
diff --git a/dockerfiles/run/guice/cassandra-rabbitmq/destination/conf/jmap.properties b/dockerfiles/run/guice/cassandra-rabbitmq/destination/conf/jmap.properties
index 53bc403..1980cfa 100644
--- a/dockerfiles/run/guice/cassandra-rabbitmq/destination/conf/jmap.properties
+++ b/dockerfiles/run/guice/cassandra-rabbitmq/destination/conf/jmap.properties
@@ -12,3 +12,7 @@ tls.secret=james72laBalle
 # which should be a PEM format file.
 #
 jwt.publickeypem.url=file://conf/jwt_publickey
+
+# Should simple Email/query be resolved against a Cassandra projection, or should we resolve them against ElasticSearch?
+# This enables a higher resilience, but the projection needs to be correctly populated. False by default.
+# view.email.query.enabled=true
diff --git a/dockerfiles/run/guice/cassandra/destination/conf/jmap.properties b/dockerfiles/run/guice/cassandra/destination/conf/jmap.properties
index 53bc403..71d28c6 100644
--- a/dockerfiles/run/guice/cassandra/destination/conf/jmap.properties
+++ b/dockerfiles/run/guice/cassandra/destination/conf/jmap.properties
@@ -12,3 +12,7 @@ tls.secret=james72laBalle
 # which should be a PEM format file.
 #
 jwt.publickeypem.url=file://conf/jwt_publickey
+
+# Should simple Email/query be resolved against a Cassandra projection, or should we resolve them against ElasticSearch?
+# This enables a higher resilience, but the projection needs to be correctly populated. False by default.
+# view.email.query.enabled=true
\ No newline at end of file
diff --git a/dockerfiles/run/guice/memory/destination/conf/jmap.properties b/dockerfiles/run/guice/memory/destination/conf/jmap.properties
index 53bc403..1980cfa 100644
--- a/dockerfiles/run/guice/memory/destination/conf/jmap.properties
+++ b/dockerfiles/run/guice/memory/destination/conf/jmap.properties
@@ -12,3 +12,7 @@ tls.secret=james72laBalle
 # which should be a PEM format file.
 #
 jwt.publickeypem.url=file://conf/jwt_publickey
+
+# Should simple Email/query be resolved against a Cassandra projection, or should we resolve them against ElasticSearch?
+# This enables a higher resilience, but the projection needs to be correctly populated. False by default.
+# view.email.query.enabled=true
diff --git a/docs/modules/servers/pages/distributed/configure/jmap.adoc b/docs/modules/servers/pages/distributed/configure/jmap.adoc
index f2b55d0..5ab56a9 100644
--- a/docs/modules/servers/pages/distributed/configure/jmap.adoc
+++ b/docs/modules/servers/pages/distributed/configure/jmap.adoc
@@ -37,6 +37,11 @@ This should not be the same keystore than the ones used by TLS based protocols.
 | Optional. Configuration max size Upload in new JMAP-RFC-8621.
 | Default value: 30M. Supported units are B (bytes) K (KB) M (MB) G (GB).
 
+| view.email.query.enabled
+| Optional boolean. Defaults to false.
+| Should simple Email/query be resolved against a Cassandra projection, or should we resolve them against ElasticSearch?
+This enables a higher resilience, but the projection needs to be correctly populated.
+
 |===
 
 == Wire tapping
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 934da8e..91cf4bf 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
@@ -139,6 +139,7 @@ public class JMAPModule extends AbstractModule {
             return JMAPConfiguration.builder()
                 .enabled(configuration.getBoolean("enabled", true))
                 .port(Port.of(configuration.getInt("jmap.port", DEFAULT_JMAP_PORT)))
+                .enableEmailQueryView(Optional.ofNullable(configuration.getBoolean("view.email.query.enabled", null)))
                 .build();
         } catch (FileNotFoundException e) {
             LOGGER.warn("Could not find JMAP configuration file. JMAP server will not be enabled.");
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPConfiguration.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPConfiguration.java
index cf2e61d..5b7c729 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPConfiguration.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPConfiguration.java
@@ -33,6 +33,7 @@ public class JMAPConfiguration {
 
     public static class Builder {
         private Optional<Boolean> enabled = Optional.empty();
+        private Optional<Boolean> emailQueryViewEnabled = Optional.empty();
         private Optional<Port> port = Optional.empty();
 
         private Builder() {
@@ -52,6 +53,23 @@ public class JMAPConfiguration {
             return enabled(false);
         }
 
+        public Builder enableEmailQueryView(boolean enabled) {
+            return enableEmailQueryView(Optional.of(enabled));
+        }
+
+        public Builder enableEmailQueryView(Optional<Boolean> enabled) {
+            this.emailQueryViewEnabled = enabled;
+            return this;
+        }
+
+        public Builder enableEmailQueryView() {
+            return enableEmailQueryView(true);
+        }
+
+        public Builder disableEmailQueryView() {
+            return enableEmailQueryView(false);
+        }
+
         public Builder port(Port port) {
             this.port = Optional.of(port);
             return this;
@@ -64,18 +82,20 @@ public class JMAPConfiguration {
 
         public JMAPConfiguration build() {
             Preconditions.checkState(enabled.isPresent(), "You should specify if JMAP server should be started");
-            return new JMAPConfiguration(enabled.get(), port);
+            return new JMAPConfiguration(enabled.get(), port, emailQueryViewEnabled.orElse(false));
         }
 
     }
 
     private final boolean enabled;
     private final Optional<Port> port;
+    private final boolean emailQueryViewEnabled;
 
     @VisibleForTesting
-    JMAPConfiguration(boolean enabled, Optional<Port> port) {
+    JMAPConfiguration(boolean enabled, Optional<Port> port, boolean emailQueryViewEnabled) {
         this.enabled = enabled;
         this.port = port;
+        this.emailQueryViewEnabled = emailQueryViewEnabled;
     }
 
     public boolean isEnabled() {
@@ -85,4 +105,8 @@ public class JMAPConfiguration {
     public Optional<Port> getPort() {
         return port;
     }
+
+    public boolean isEmailQueryViewEnabled() {
+        return emailQueryViewEnabled;
+    }
 }
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/JMAPConfigurationTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/JMAPConfigurationTest.java
index 68dbf75..011f774 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/JMAPConfigurationTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/JMAPConfigurationTest.java
@@ -41,22 +41,24 @@ class JMAPConfigurationTest {
 
     @Test
     void buildShouldWorkWhenRandomPort() {
-        JMAPConfiguration expectedJMAPConfiguration = new JMAPConfiguration(ENABLED, Optional.empty());
+        JMAPConfiguration expectedJMAPConfiguration = new JMAPConfiguration(ENABLED, Optional.empty(), ENABLED);
 
         JMAPConfiguration jmapConfiguration = JMAPConfiguration.builder()
             .enable()
             .randomPort()
+            .enableEmailQueryView()
             .build();
         assertThat(jmapConfiguration).isEqualToComparingFieldByField(expectedJMAPConfiguration);
     }
 
     @Test
     void buildShouldWorkWhenFixedPort() {
-        JMAPConfiguration expectedJMAPConfiguration = new JMAPConfiguration(ENABLED, Optional.of(Port.of(80)));
+        JMAPConfiguration expectedJMAPConfiguration = new JMAPConfiguration(ENABLED, Optional.of(Port.of(80)), ENABLED);
 
         JMAPConfiguration jmapConfiguration = JMAPConfiguration.builder()
             .enable()
             .port(Port.of(80))
+            .enableEmailQueryView()
             .build();
 
         assertThat(jmapConfiguration).isEqualToComparingFieldByField(expectedJMAPConfiguration);
@@ -64,10 +66,11 @@ class JMAPConfigurationTest {
 
     @Test
     void buildShouldWorkWhenDisabled() {
-        JMAPConfiguration expectedJMAPConfiguration = new JMAPConfiguration(DISABLED, Optional.empty());
+        JMAPConfiguration expectedJMAPConfiguration = new JMAPConfiguration(DISABLED, Optional.empty(), DISABLED);
 
         JMAPConfiguration jmapConfiguration = JMAPConfiguration.builder()
             .disable()
+            .disableEmailQueryView()
             .build();
         assertThat(jmapConfiguration).isEqualToComparingFieldByField(expectedJMAPConfiguration);
     }
diff --git a/src/site/xdoc/server/config-jmap.xml b/src/site/xdoc/server/config-jmap.xml
index ce649ac..ef03111 100644
--- a/src/site/xdoc/server/config-jmap.xml
+++ b/src/site/xdoc/server/config-jmap.xml
@@ -64,6 +64,11 @@
                     <dt><strong>upload.max.size</strong></dt>
                     <dd>Optional. Configuration max size Upload in new JMAP-RFC-8621.</dd>
                     <dd>Default value: 30M. Supported units are B (bytes) K (KB) M (MB) G (GB).</dd>
+
+                    <dt><strong>view.email.query.enabled</strong></dt>
+                    <dd>Optional boolean. Defaults to false.</dd>
+                    <dd>Should simple Email/query be resolved against a Cassandra projection, or should we resolve them against ElasticSearch?
+                        This enables a higher resilience, but the projection needs to be correctly populated.</dd>
                 </dl>
 
             </subsection>


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