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 2022/11/22 07:11:56 UTC
[james-project] 11/12: JAMES-3858 JPA does not support MessageId
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 a8398ab68382f9bbc5835ff1d76851c5928632a8
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Fri Nov 18 22:31:51 2022 +0700
JAMES-3858 JPA does not support MessageId
-> Avoid advertising the capability
---
.../cassandra/CassandraObjectIdTest.java | 36 ++++++++++++++
.../james/mpt/imapmailbox/suite/ObjectId.java | 55 ++++++++++++++++++++++
.../org/apache/james/imap/scripts/Capability.test | 4 --
.../scripts/{Capability.test => ObjectId.test} | 8 ++--
.../imapmailbox/inmemory/InMemoryObjectIdTest.java | 43 +++++++++++++++++
.../lucenesearch/LuceneObjectIdTest.java | 49 +++++++++++++++++++
.../rabbitmq/RabbitMQObjectIdeTest.java | 36 ++++++++++++++
.../james/imap/processor/CapabilityProcessor.java | 4 ++
8 files changed, 226 insertions(+), 9 deletions(-)
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraObjectIdTest.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraObjectIdTest.java
new file mode 100644
index 0000000000..33eef7d0a5
--- /dev/null
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraObjectIdTest.java
@@ -0,0 +1,36 @@
+/****************************************************************
+ * 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.mpt.imapmailbox.cassandra;
+
+import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.cassandra.host.CassandraHostSystemExtension;
+import org.apache.james.mpt.imapmailbox.suite.ObjectId;
+import org.apache.james.mpt.imapmailbox.suite.SelectedState;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+public class CassandraObjectIdTest extends ObjectId {
+ @RegisterExtension
+ static CassandraHostSystemExtension hostSystemExtension = new CassandraHostSystemExtension();
+
+ @Override
+ protected ImapHostSystem createImapHostSystem() {
+ return hostSystemExtension.getImapHostSystem();
+ }
+}
diff --git a/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/imapmailbox/suite/ObjectId.java b/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/imapmailbox/suite/ObjectId.java
new file mode 100644
index 0000000000..03257ba2f0
--- /dev/null
+++ b/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/imapmailbox/suite/ObjectId.java
@@ -0,0 +1,55 @@
+/****************************************************************
+ * 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.mpt.imapmailbox.suite;
+
+import java.util.Locale;
+
+import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.ImapTestConstants;
+import org.apache.james.mpt.imapmailbox.suite.base.BasicImapCommands;
+import org.apache.james.mpt.script.SimpleScriptedTestProtocol;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+public abstract class ObjectId implements ImapTestConstants {
+
+ protected abstract ImapHostSystem createImapHostSystem();
+
+ private ImapHostSystem system;
+ private SimpleScriptedTestProtocol simpleScriptedTestProtocol;
+
+ @BeforeEach
+ public void setUp() throws Exception {
+ system = createImapHostSystem();
+ simpleScriptedTestProtocol = new SimpleScriptedTestProtocol("/org/apache/james/imap/scripts/", system)
+ .withUser(USER, PASSWORD)
+ .withLocale(Locale.US);
+ BasicImapCommands.welcome(simpleScriptedTestProtocol);
+ BasicImapCommands.authenticate(simpleScriptedTestProtocol);
+ BasicImapCommands.prepareMailbox(simpleScriptedTestProtocol);
+ }
+
+ @Test
+ public void testObjectId() throws Exception {
+ simpleScriptedTestProtocol
+ .withLocale(Locale.US)
+ .run("ObjectId");
+ }
+}
diff --git a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/Capability.test b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/Capability.test
index 4de49006df..16f7c4f9d7 100644
--- a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/Capability.test
+++ b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/Capability.test
@@ -20,9 +20,5 @@ C: abcd CAPABILITY
S: \* CAPABILITY .+
S: abcd OK CAPABILITY completed.
-C: defg CAPABILITY
-S: \* CAPABILITY .*OBJECTID.*
-S: defg OK CAPABILITY completed.
-
C: hijk CAPABILITY extra stuff
S: hijk BAD CAPABILITY failed. Illegal arguments.
diff --git a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/Capability.test b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/ObjectId.test
similarity index 89%
copy from mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/Capability.test
copy to mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/ObjectId.test
index 4de49006df..59bd418052 100644
--- a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/Capability.test
+++ b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/ObjectId.test
@@ -16,13 +16,11 @@
# specific language governing permissions and limitations #
# under the License. #
################################################################
-C: abcd CAPABILITY
-S: \* CAPABILITY .+
-S: abcd OK CAPABILITY completed.
C: defg CAPABILITY
S: \* CAPABILITY .*OBJECTID.*
S: defg OK CAPABILITY completed.
-C: hijk CAPABILITY extra stuff
-S: hijk BAD CAPABILITY failed. Illegal arguments.
+C: 22 fetch 1 (emailid threadid)
+S: \* 1 FETCH \(EMAILID \(.*\) THREADID \(.*\)\)
+S: 22 OK FETCH completed.
diff --git a/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/InMemoryObjectIdTest.java b/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/InMemoryObjectIdTest.java
new file mode 100644
index 0000000000..7a7777a80d
--- /dev/null
+++ b/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/InMemoryObjectIdTest.java
@@ -0,0 +1,43 @@
+/****************************************************************
+ * 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.mpt.imapmailbox.inmemory;
+
+import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.inmemory.host.InMemoryHostSystem;
+import org.apache.james.mpt.imapmailbox.suite.ObjectId;
+import org.apache.james.mpt.imapmailbox.suite.SelectedState;
+import org.junit.jupiter.api.BeforeEach;
+
+public class InMemoryObjectIdTest extends ObjectId {
+ private ImapHostSystem system;
+
+ @Override
+ @BeforeEach
+ public void setUp() throws Exception {
+ system = new InMemoryHostSystem();
+ system.beforeTest();
+ super.setUp();
+ }
+
+ @Override
+ protected ImapHostSystem createImapHostSystem() {
+ return system;
+ }
+}
diff --git a/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/LuceneObjectIdTest.java b/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/LuceneObjectIdTest.java
new file mode 100644
index 0000000000..368c159790
--- /dev/null
+++ b/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/LuceneObjectIdTest.java
@@ -0,0 +1,49 @@
+/****************************************************************
+ * 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.mpt.imapmailbox.lucenesearch;
+
+import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.lucenesearch.host.LuceneSearchHostSystem;
+import org.apache.james.mpt.imapmailbox.suite.ObjectId;
+import org.apache.james.mpt.imapmailbox.suite.SelectedState;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+
+public class LuceneObjectIdTest extends ObjectId {
+ private ImapHostSystem system;
+
+ @Override
+ @BeforeEach
+ public void setUp() throws Exception {
+ system = new LuceneSearchHostSystem();
+ system.beforeTest();
+ super.setUp();
+ }
+
+ @Override
+ protected ImapHostSystem createImapHostSystem() {
+ return system;
+ }
+
+ @AfterEach
+ public void tearDown() throws Exception {
+ system.afterTest();
+ }
+}
diff --git a/mpt/impl/imap-mailbox/rabbitmq/src/test/java/org/apache/james/mpt/imapmailbox/rabbitmq/RabbitMQObjectIdeTest.java b/mpt/impl/imap-mailbox/rabbitmq/src/test/java/org/apache/james/mpt/imapmailbox/rabbitmq/RabbitMQObjectIdeTest.java
new file mode 100644
index 0000000000..86f3955bef
--- /dev/null
+++ b/mpt/impl/imap-mailbox/rabbitmq/src/test/java/org/apache/james/mpt/imapmailbox/rabbitmq/RabbitMQObjectIdeTest.java
@@ -0,0 +1,36 @@
+/****************************************************************
+ * 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.mpt.imapmailbox.rabbitmq;
+
+import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.rabbitmq.host.RabbitMQEventBusHostSystemExtension;
+import org.apache.james.mpt.imapmailbox.suite.ObjectId;
+import org.apache.james.mpt.imapmailbox.suite.SelectedState;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+public class RabbitMQObjectIdeTest extends ObjectId {
+ @RegisterExtension
+ static RabbitMQEventBusHostSystemExtension hostSystemExtension = new RabbitMQEventBusHostSystemExtension();
+
+ @Override
+ protected ImapHostSystem createImapHostSystem() {
+ return hostSystemExtension.getHostSystem();
+ }
+}
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/CapabilityProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/CapabilityProcessor.java
index 890e1746b8..25211a9042 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/CapabilityProcessor.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/CapabilityProcessor.java
@@ -25,6 +25,7 @@ import static org.apache.james.imap.api.ImapConstants.SUPPORTS_I18NLEVEL_1;
import static org.apache.james.imap.api.ImapConstants.SUPPORTS_LITERAL_PLUS;
import static org.apache.james.imap.api.ImapConstants.SUPPORTS_OBJECTID;
import static org.apache.james.imap.api.ImapConstants.SUPPORTS_RFC3348;
+import static org.apache.james.mailbox.MailboxManager.MessageCapabilities.UniqueID;
import java.util.ArrayList;
import java.util.HashSet;
@@ -71,6 +72,9 @@ public class CapabilityProcessor extends AbstractMailboxProcessor<CapabilityRequ
if (shouldDisableCondstore(imapConfiguration)) {
disabledCaps.add(SUPPORTS_CONDSTORE);
}
+ if (!getMailboxManager().getSupportedMessageCapabilities().contains(UniqueID)) {
+ disabledCaps.add(SUPPORTS_OBJECTID);
+ }
}
private boolean shouldDisableCondstore(ImapConfiguration imapConfiguration) {
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org