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:48 UTC

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

JAMES-2214 Rename ambiguous and misleading MailboxRightsException

MailboxRightsException leads to think it concerns mailbox rights, but was raised when having rights on a delegated mailbox


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

Branch: refs/heads/master
Commit: 1e8d057c9bcd3906d5e018baaef83b7681b9ec38
Parents: fe0522a
Author: benwa <bt...@linagora.com>
Authored: Mon Nov 13 13:00:21 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Wed Nov 15 18:04:09 2017 +0700

----------------------------------------------------------------------
 .../exceptions/MailboxNotOwnedException.java    | 29 ++++++++++++++++++++
 .../jmap/methods/MailboxRightsException.java    | 29 --------------------
 .../methods/SetMessagesCreationProcessor.java   |  7 +++--
 .../SetMessagesCreationProcessorTest.java       |  3 +-
 4 files changed, 35 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/1e8d057c/server/protocols/jmap/src/main/java/org/apache/james/jmap/exceptions/MailboxNotOwnedException.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/exceptions/MailboxNotOwnedException.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/exceptions/MailboxNotOwnedException.java
new file mode 100644
index 0000000..714305a
--- /dev/null
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/exceptions/MailboxNotOwnedException.java
@@ -0,0 +1,29 @@
+/****************************************************************
+ * 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 MailboxNotOwnedException extends MailboxException {
+
+    public MailboxNotOwnedException() {
+        super();
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e8d057c/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/MailboxRightsException.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/MailboxRightsException.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/MailboxRightsException.java
deleted file mode 100644
index f47e7d0..0000000
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/MailboxRightsException.java
+++ /dev/null
@@ -1,29 +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 MailboxRightsException extends MailboxException {
-
-    public MailboxRightsException() {
-        super();
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e8d057c/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 a91a65c..71e3a11 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.MailboxNotOwnedException;
 import org.apache.james.jmap.methods.ValueWithId.CreationMessageEntry;
 import org.apache.james.jmap.methods.ValueWithId.MessageWithId;
 import org.apache.james.jmap.model.CreationMessage;
@@ -155,7 +156,7 @@ public class SetMessagesCreationProcessor implements SetMessagesProcessor {
                         .description(e.getMessage())
                         .build());
 
-        } catch (MailboxRightsException e) {
+        } catch (MailboxNotOwnedException e) {
             LOG.error("Appending message in an unknown mailbox", e);
             responseBuilder.notCreated(create.getCreationId(), 
                     SetError.builder()
@@ -215,9 +216,9 @@ public class SetMessagesCreationProcessor implements SetMessagesProcessor {
         attachmentChecker.assertAttachmentsExist(entry, session);
     }
 
-    @VisibleForTesting void validateIsUserOwnerOfMailboxes(CreationMessageEntry entry, MailboxSession session) throws MailboxRightsException {
+    @VisibleForTesting void validateIsUserOwnerOfMailboxes(CreationMessageEntry entry, MailboxSession session) throws MailboxNotOwnedException {
         if (containsMailboxNotOwn(entry.getValue().getMailboxIds(), session)) {
-            throw new MailboxRightsException();
+            throw new MailboxNotOwnedException();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/1e8d057c/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMessagesCreationProcessorTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMessagesCreationProcessorTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMessagesCreationProcessorTest.java
index a0df1b4..8a55816 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMessagesCreationProcessorTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMessagesCreationProcessorTest.java
@@ -35,6 +35,7 @@ import java.util.stream.Stream;
 
 import javax.mail.Flags;
 
+import org.apache.james.jmap.exceptions.MailboxNotOwnedException;
 import org.apache.james.jmap.methods.ValueWithId.CreationMessageEntry;
 import org.apache.james.jmap.model.CreationMessage;
 import org.apache.james.jmap.model.CreationMessage.DraftEmailer;
@@ -357,7 +358,7 @@ public class SetMessagesCreationProcessorTest {
         CreationMessageEntry entry = new CreationMessageEntry(creationMessageId, creationMessageBuilder.mailboxId(mailboxId.serialize()).build());
 
         assertThatThrownBy(() -> sut.validateIsUserOwnerOfMailboxes(entry, session))
-            .isInstanceOf(MailboxRightsException.class);
+            .isInstanceOf(MailboxNotOwnedException.class);
     }
 
     @Test


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