You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by rc...@apache.org on 2021/11/26 04:34:58 UTC

[james-project] 02/03: JAMES-3534 SetError forbidden should not always require Properties

This is an automated email from the ASF dual-hosted git repository.

rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 106f528535348c8f8cef7ac2e0c76109600c32b1
Author: Quan Tran <hq...@linagora.com>
AuthorDate: Tue Nov 23 09:31:01 2021 +0700

    JAMES-3534 SetError forbidden should not always require Properties
---
 .../james/jmap/rfc8621/contract/IdentitySetContract.scala | 15 +++------------
 .../main/scala/org/apache/james/jmap/core/SetError.scala  |  4 ++--
 .../james/jmap/method/IdentitySetDeletePerformer.scala    |  2 +-
 .../james/jmap/method/MailboxSetCreatePerformer.scala     |  2 +-
 4 files changed, 7 insertions(+), 16 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/IdentitySetContract.scala b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/IdentitySetContract.scala
index 154b081..f628c06 100644
--- a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/IdentitySetContract.scala
+++ b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/IdentitySetContract.scala
@@ -1298,17 +1298,11 @@ trait IdentitySetContract {
            |				"notDestroyed": {
            |					"$serverIdentitiesId1": {
            |						"type": "forbidden",
-           |						"description": "User do not have permission to delete IdentityId($serverIdentitiesId1)",
-           |						"properties": [
-           |							"id"
-           |						]
+           |						"description": "User do not have permission to delete IdentityId($serverIdentitiesId1)"
            |					},
            |					"$defaultServerSetIdentity": {
            |						"type": "forbidden",
-           |						"description": "User do not have permission to delete IdentityId($defaultServerSetIdentity)",
-           |						"properties": [
-           |							"id"
-           |						]
+           |						"description": "User do not have permission to delete IdentityId($defaultServerSetIdentity)"
            |					}
            |				}
            |			},
@@ -1470,10 +1464,7 @@ trait IdentitySetContract {
            |				"notDestroyed": {
            |					"$defaultServerSetIdentity": {
            |						"type": "forbidden",
-           |						"description": "User do not have permission to delete IdentityId($defaultServerSetIdentity)",
-           |						"properties": [
-           |							"id"
-           |						]
+           |						"description": "User do not have permission to delete IdentityId($defaultServerSetIdentity)"
            |					}
            |				}
            |			},
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/SetError.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/SetError.scala
index 0379b73..8b99e76 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/SetError.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/SetError.scala
@@ -54,8 +54,8 @@ object SetError {
   def invalidPatch(description: SetErrorDescription): SetError =
     SetError(invalidPatchValue, description, None)
 
-  def forbidden(description: SetErrorDescription, properties: Properties): SetError =
-    SetError(forbiddenValue, description, Some(properties))
+  def forbidden(description: SetErrorDescription, properties: Option[Properties] = None): SetError =
+    SetError(forbiddenValue, description, properties)
 
   def stateMismatch(description: SetErrorDescription, properties: Properties): SetError =
     SetError(stateMismatchValue, description, Some(properties))
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/IdentitySetDeletePerformer.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/IdentitySetDeletePerformer.scala
index 72eac97..6233785 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/IdentitySetDeletePerformer.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/IdentitySetDeletePerformer.scala
@@ -35,7 +35,7 @@ object IdentitySetDeletePerformer {
   case class IdentityDeletionSuccess(identityId: IdentityId) extends IdentityDeletionResult
   case class IdentityDeletionFailure(identityId: UnparsedIdentityId, exception: Throwable) extends IdentityDeletionResult {
     def asIdentitySetError: SetError = exception match {
-      case e: IdentityForbiddenDeleteException => SetError.forbidden(SetErrorDescription(e.getMessage), Properties("id"))
+      case e: IdentityForbiddenDeleteException => SetError.forbidden(SetErrorDescription(e.getMessage))
       case e: IllegalArgumentException => SetError.invalidArguments(SetErrorDescription(s"${identityId.id} is not a IdentityId: ${e.getMessage}"))
       case _ => SetError.serverFail(SetErrorDescription(exception.getMessage))
     }
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxSetCreatePerformer.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxSetCreatePerformer.scala
index 87a25f7..e411128 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxSetCreatePerformer.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxSetCreatePerformer.scala
@@ -49,7 +49,7 @@ object MailboxSetCreatePerformer {
       case e: MailboxExistsException => SetError.invalidArguments(SetErrorDescription(e.getMessage), Some(Properties("name")))
       case e: MailboxNameException => SetError.invalidArguments(SetErrorDescription(e.getMessage), Some(Properties("name")))
       case e: MailboxCreationParseException => e.setError
-      case _: InsufficientRightsException => SetError.forbidden(SetErrorDescription("Insufficient rights"), Properties("parentId"))
+      case _: InsufficientRightsException => SetError.forbidden(SetErrorDescription("Insufficient rights"), Some(Properties("parentId")))
       case _ => SetError.serverFail(SetErrorDescription(exception.getMessage))
     }
   }

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