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 bt...@apache.org on 2020/08/14 09:07:40 UTC

[james-project] 12/13: JAMES-3354: mailbox set: parentId handling

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 73710fab20d69b5602dd0028b2c79fda46cbf79b
Author: duc91 <vd...@linagora.com>
AuthorDate: Fri Aug 14 11:26:22 2020 +0700

    JAMES-3354: mailbox set: parentId handling
---
 .../apache/james/jmap/rfc8621/contract/MailboxSetMethodContract.scala | 4 ++--
 .../src/main/scala/org/apache/james/jmap/mail/MailboxSet.scala        | 2 ++
 .../main/scala/org/apache/james/jmap/method/MailboxSetMethod.scala    | 4 +---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxSetMethodContract.scala b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxSetMethodContract.scala
index 5f86a34..d248288 100644
--- a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxSetMethodContract.scala
+++ b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxSetMethodContract.scala
@@ -609,7 +609,7 @@ trait MailboxSetMethodContract {
   }
 
   @Test
-  def mailboxSetShouldNotCreateMailboxWhenMailboxItShared(server: GuiceJamesServer): Unit = {
+  def mailboxSetShouldNotCreateChildMailboxWhenSharedParentMailbox(server: GuiceJamesServer): Unit = {
     val path = MailboxPath.forUser(ANDRE, "mailbox")
     val mailboxId: MailboxId = server.getProbe(classOf[MailboxProbeImpl]).createMailbox(path)
 
@@ -660,7 +660,7 @@ trait MailboxSetMethodContract {
          |      "newState": "000001",
          |      "notCreated": {
          |        "C42": {
-         |          "type": "invalidArguments",
+         |          "type": "forbidden",
          |          "description": "Insufficient rights",
          |          "properties":{"value":["parentId"]}
          |        }
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/MailboxSet.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/MailboxSet.scala
index bd9983a..a55a8a3 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/MailboxSet.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/MailboxSet.scala
@@ -59,9 +59,11 @@ case class MailboxSetResponse(accountId: AccountId,
 object MailboxSetError {
   val invalidArgumentValue: SetErrorType = "invalidArguments"
   val serverFailValue: SetErrorType = "serverFail"
+  val forbiddenValue: SetErrorType = "forbidden"
 
   def invalidArgument(description: Option[SetErrorDescription], properties: Option[Properties]) = MailboxSetError(invalidArgumentValue, description, properties)
   def serverFail(description: Option[SetErrorDescription], properties: Option[Properties]) = MailboxSetError(serverFailValue, description, properties)
+  def forbidden(description: Option[SetErrorDescription], properties: Option[Properties]) = MailboxSetError(forbiddenValue, description, properties)
 }
 
 case class MailboxSetError(`type`: SetErrorType, description: Option[SetErrorDescription], properties: Option[Properties])
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxSetMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxSetMethod.scala
index 1bee2f9..c2fcd51 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxSetMethod.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxSetMethod.scala
@@ -49,7 +49,7 @@ case class CreationFailure(mailboxCreationId: MailboxCreationId, exception: Exce
     case e: MailboxNotFoundException => MailboxSetError.invalidArgument(Some(SetErrorDescription(e.getMessage)), Some(Properties(List("parentId"))))
     case e: MailboxExistsException => MailboxSetError.invalidArgument(Some(SetErrorDescription(e.getMessage)), Some(Properties(List("name"))))
     case e: MailboxNameException => MailboxSetError.invalidArgument(Some(SetErrorDescription(e.getMessage)), Some(Properties(List("name"))))
-    case _: InsufficientRightsException => MailboxSetError.invalidArgument(Some(SetErrorDescription("Insufficient rights")), Some(Properties(List("parentId"))))
+    case _: InsufficientRightsException => MailboxSetError.forbidden(Some(SetErrorDescription("Insufficient rights")), Some(Properties(List("parentId"))))
     case _ => MailboxSetError.serverFail(Some(SetErrorDescription(exception.getMessage)), None)
   }
 }
@@ -60,7 +60,6 @@ case class CreationResults(created: Seq[CreationResult]) {
       case success: CreationSuccess => Some(success.mailboxCreationId, success.mailboxId)
       case _ => None
     })
-    .toSet
     .toMap
 
   def retrieveErrors: Map[MailboxCreationId, MailboxSetError] = created
@@ -68,7 +67,6 @@ case class CreationResults(created: Seq[CreationResult]) {
       case failure: CreationFailure => Some(failure.mailboxCreationId, failure.asMailboxSetError)
       case _ => None
     })
-    .toSet
     .toMap
 }
 


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