You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ad...@apache.org on 2017/11/15 11:15:57 UTC

[16/19] james-project git commit: JAMES-2214 Rename ambiguous and misleading MailboxNotImplementedException

JAMES-2214 Rename ambiguous and misleading MailboxNotImplementedException

  MailboxNotImplementedException and the "Not yet implemented" message is misleading.

  JMAP spec does not support, whatever version you take, saving messages in other mailboxes than Outbox or Draft.

  The error message name should explain that the given mailboxes were invalid. Moreover, the error message should explain which state was not met by the provided mailboxes.


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/8ad6ba63
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/8ad6ba63
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/8ad6ba63

Branch: refs/heads/master
Commit: 8ad6ba63c84042619395ec8e10cfc09583740784
Parents: 1e8d057
Author: benwa <bt...@linagora.com>
Authored: Mon Nov 13 13:08:14 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Wed Nov 15 18:05:45 2017 +0700

----------------------------------------------------------------------
 .../integration/SetMessagesMethodTest.java      |  8 +++---
 .../InvalidMailboxForCreationException.java     | 30 ++++++++++++++++++++
 .../methods/MailboxNotImplementedException.java | 30 --------------------
 .../methods/SetMessagesCreationProcessor.java   |  9 +++---
 4 files changed, 39 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/8ad6ba63/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
index 13e1da4..97fbf15 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
@@ -1439,11 +1439,11 @@ public abstract class SetMessagesMethodTest {
             .body(ARGUMENTS + ".notCreated", hasKey(messageCreationId))
             .body(ARGUMENTS + ".notCreated[\"" + messageCreationId + "\"].type", equalTo("invalidProperties"))
             .body(ARGUMENTS + ".notCreated[\"" + messageCreationId + "\"].properties", contains("mailboxIds"))
-            .body(ARGUMENTS + ".notCreated[\"" + messageCreationId + "\"].description", equalTo("Not yet implemented"));
+            .body(ARGUMENTS + ".notCreated[\"" + messageCreationId + "\"].description", equalTo("Message creation is only supported in mailboxes with role Draft and Outbox"));
     }
 
     @Test
-    public void setMessagesShouldBeCompatibleWithIsDraftProperty() {
+    public void setMessageShouldAllowDraftCreationWhenUsingIsDraftProperty() {
         String messageCreationId = "creationId1337";
         String fromAddress = USERNAME;
         String requestBody = "[" +
@@ -1511,7 +1511,7 @@ public abstract class SetMessagesMethodTest {
             .body(ARGUMENTS + ".notCreated", hasKey(messageCreationId))
             .body(ARGUMENTS + ".notCreated[\"" + messageCreationId + "\"].type", equalTo("invalidProperties"))
             .body(ARGUMENTS + ".notCreated[\"" + messageCreationId + "\"].properties", contains("mailboxIds"))
-            .body(ARGUMENTS + ".notCreated[\"" + messageCreationId + "\"].description", equalTo("Not yet implemented"));
+            .body(ARGUMENTS + ".notCreated[\"" + messageCreationId + "\"].description", equalTo("Message creation is only supported in mailboxes with role Draft and Outbox"));
     }
 
     @Test
@@ -2645,7 +2645,7 @@ public abstract class SetMessagesMethodTest {
             .statusCode(200)
             .body(ARGUMENTS + ".notCreated", hasKey(messageCreationId))
             .body(notCreatedMessage + ".type", equalTo("invalidProperties"))
-            .body(notCreatedMessage + ".description", equalTo("Not yet implemented"))
+            .body(notCreatedMessage + ".description", equalTo("Message creation is only supported in mailboxes with role Draft and Outbox"))
             .body(ARGUMENTS + ".created", aMapWithSize(0));
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/8ad6ba63/server/protocols/jmap/src/main/java/org/apache/james/jmap/exceptions/InvalidMailboxForCreationException.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/exceptions/InvalidMailboxForCreationException.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/exceptions/InvalidMailboxForCreationException.java
new file mode 100644
index 0000000..bd1ea0b
--- /dev/null
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/exceptions/InvalidMailboxForCreationException.java
@@ -0,0 +1,30 @@
+/****************************************************************
+ * 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.jmap.exceptions;
+
+import org.apache.james.mailbox.exception.MailboxException;
+
+public class InvalidMailboxForCreationException extends MailboxException {
+
+    public InvalidMailboxForCreationException(String message) {
+        super(message);
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/8ad6ba63/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/MailboxNotImplementedException.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/MailboxNotImplementedException.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/MailboxNotImplementedException.java
deleted file mode 100644
index a7da6d4..0000000
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/MailboxNotImplementedException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/****************************************************************
- * 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.jmap.methods;
-
-import org.apache.james.mailbox.exception.MailboxException;
-
-public class MailboxNotImplementedException extends MailboxException {
-
-    public MailboxNotImplementedException(String message) {
-        super(message);
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/8ad6ba63/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesCreationProcessor.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesCreationProcessor.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesCreationProcessor.java
index 71e3a11..4b0e38b 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesCreationProcessor.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesCreationProcessor.java
@@ -31,6 +31,7 @@ import javax.mail.MessagingException;
 
 import org.apache.james.jmap.exceptions.AttachmentsNotFoundException;
 import org.apache.james.jmap.exceptions.InvalidDraftKeywordsException;
+import org.apache.james.jmap.exceptions.InvalidMailboxForCreationException;
 import org.apache.james.jmap.exceptions.MailboxNotOwnedException;
 import org.apache.james.jmap.methods.ValueWithId.CreationMessageEntry;
 import org.apache.james.jmap.methods.ValueWithId.MessageWithId;
@@ -137,12 +138,12 @@ public class SetMessagesCreationProcessor implements SetMessagesProcessor {
                         .description("Attachment not found")
                         .build());
             
-        } catch (MailboxNotImplementedException e) {
+        } catch (InvalidMailboxForCreationException e) {
             responseBuilder.notCreated(create.getCreationId(), 
                     SetError.builder()
                         .type("invalidProperties")
                         .properties(MessageProperty.mailboxIds)
-                        .description("Not yet implemented")
+                        .description("Message creation is only supported in mailboxes with role Draft and Outbox")
                         .build());
 
         } catch (MailboxInvalidMessageCreationException e) {
@@ -175,13 +176,13 @@ public class SetMessagesCreationProcessor implements SetMessagesProcessor {
         }
     }
     
-    private void performCreate(CreationMessageEntry entry, Builder responseBuilder, MailboxSession session) throws MailboxException, MailboxNotImplementedException, MessagingException, AttachmentsNotFoundException {
+    private void performCreate(CreationMessageEntry entry, Builder responseBuilder, MailboxSession session) throws MailboxException, InvalidMailboxForCreationException, MessagingException, AttachmentsNotFoundException {
         if (isAppendToMailboxWithRole(Role.DRAFTS, entry.getValue(), session)) {
             saveDraft(entry, responseBuilder, session);
         } else if (isAppendToMailboxWithRole(Role.OUTBOX, entry.getValue(), session)) {
             sendMailViaOutbox(entry, responseBuilder, session);
         } else {
-            throw new MailboxNotImplementedException("The only implemented feature is sending via outbox and draft saving");
+            throw new InvalidMailboxForCreationException("The only implemented feature is sending via outbox and draft saving");
         }
     }
 


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