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/11 15:58:20 UTC

[james-project] 01/03: [CLEAN_CODE] JMAP - remove duplicate method `toProperties`

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 5efc1a28938e200de0d554021973e4c3269e7ffe
Author: Tung Van TRAN <vt...@linagora.com>
AuthorDate: Mon Nov 7 12:56:56 2022 +0700

    [CLEAN_CODE] JMAP - remove duplicate method `toProperties`
---
 .../org/apache/james/jmap/core/PushSubscriptionSet.scala      |  7 +------
 .../scala/org/apache/james/jmap/mail/EmailSubmissionSet.scala | 11 ++---------
 .../main/scala/org/apache/james/jmap/mail/MailboxSet.scala    |  7 +------
 3 files changed, 4 insertions(+), 21 deletions(-)

diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/PushSubscriptionSet.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/PushSubscriptionSet.scala
index cef464d713..d34a1add56 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/PushSubscriptionSet.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/PushSubscriptionSet.scala
@@ -31,6 +31,7 @@ import eu.timepit.refined.types.string.NonEmptyString
 import org.apache.james.jmap.api.change.TypeStateFactory
 import org.apache.james.jmap.api.model.{PushSubscriptionExpiredTime, PushSubscriptionId, TypeName, VerificationCode}
 import org.apache.james.jmap.core.Id.Id
+import org.apache.james.jmap.core.Properties.toProperties
 import org.apache.james.jmap.core.SetError.SetErrorDescription
 import org.apache.james.jmap.mail.{InvalidPropertyException, InvalidUpdateException, PatchUpdateValidationException, UnsupportedPropertyUpdatedException}
 import org.apache.james.jmap.method.WithoutAccountId
@@ -191,12 +192,6 @@ object PushSubscriptionCreation {
           Some(toProperties(specifiedServerSetProperties.toSet)))))
       case _ => scala.Right(jsObject)
     }
-
-  private def toProperties(strings: Set[String]): Properties = Properties(strings
-    .flatMap(string => {
-      val refinedValue: Either[String, NonEmptyString] = refineV[NonEmpty](string)
-      refinedValue.fold(_ => None,  Some(_))
-    }))
 }
 
 case class PushSubscriptionCreationParseException(setError: SetError) extends Exception
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/EmailSubmissionSet.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/EmailSubmissionSet.scala
index 3313ab367f..ef41558c7e 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/EmailSubmissionSet.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/mail/EmailSubmissionSet.scala
@@ -23,13 +23,12 @@ import java.util.UUID
 
 import cats.implicits._
 import eu.timepit.refined.auto.autoUnwrap
-import eu.timepit.refined.collection.NonEmpty
 import eu.timepit.refined.refineV
-import eu.timepit.refined.types.string.NonEmptyString
 import org.apache.james.core.MailAddress
 import org.apache.james.jmap.core.Id.{Id, IdConstraint}
+import org.apache.james.jmap.core.Properties.toProperties
 import org.apache.james.jmap.core.SetError.SetErrorDescription
-import org.apache.james.jmap.core.{AccountId, Id, Properties, SetError, UuidState}
+import org.apache.james.jmap.core.{AccountId, Id, SetError, UuidState}
 import org.apache.james.jmap.method.{EmailSubmissionCreationParseException, WithAccountId}
 import org.apache.james.mailbox.model.MessageId
 import play.api.libs.json.JsObject
@@ -138,12 +137,6 @@ object EmailSubmissionCreationRequest {
           Some(toProperties(unknownProperties.toSet)))))
       case _ => scala.Right(jsObject)
     }
-
-  private def toProperties(strings: Set[String]): Properties = Properties(strings
-    .flatMap(string => {
-      val refinedValue: Either[String, NonEmptyString] = refineV[NonEmpty](string)
-      refinedValue.fold(_ => None,  Some(_))
-    }))
 }
 
 case class EmailSubmissionCreationRequest(emailId: MessageId,
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 359c2c0585..a6e2afdffc 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
@@ -27,6 +27,7 @@ import eu.timepit.refined.types.string.NonEmptyString
 import org.apache.james.core.Username
 import org.apache.james.jmap.core.CapabilityIdentifier.CapabilityIdentifier
 import org.apache.james.jmap.core.Id.Id
+import org.apache.james.jmap.core.Properties.toProperties
 import org.apache.james.jmap.core.SetError.{SetErrorDescription, SetErrorType}
 import org.apache.james.jmap.core.{AccountId, CapabilityIdentifier, Properties, SetError, UuidState}
 import org.apache.james.jmap.json.MailboxSerializer
@@ -65,12 +66,6 @@ object MailboxCreationRequest {
           Some(toProperties(specifiedServerSetProperties.toSet)))))
       case _ => scala.Right(jsObject)
     }
-
-  private def toProperties(strings: Set[String]): Properties = Properties(strings
-    .flatMap(string => {
-      val refinedValue: Either[String, NonEmptyString] = refineV[NonEmpty](string)
-      refinedValue.fold(_ => None,  Some(_))
-    }))
 }
 
 case class MailboxCreationRequest(name: MailboxName,


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