diff --git a/tmail-backend/jmap/extensions/pom.xml b/tmail-backend/jmap/extensions/pom.xml
index cd433af0a4..02858a0854 100644
--- a/tmail-backend/jmap/extensions/pom.xml
+++ b/tmail-backend/jmap/extensions/pom.xml
@@ -144,6 +144,25 @@
jmap-extensions-api
1.0.0-SNAPSHOT
+
+ ${project.groupId}
+ jmap-extensions-api
+ 1.0.0-SNAPSHOT
+ test-jar
+ test
+
+
+ ${project.groupId}
+ jmap-extensions-configuration
+ 1.0.0-SNAPSHOT
+
+
+ ${project.groupId}
+ jmap-extensions-configuration
+ 1.0.0-SNAPSHOT
+ test-jar
+ test
+
diff --git a/tmail-backend/jmap/extensions/src/main/scala/com/linagora/tmail/james/jmap/json/CalendarEventReplySerializer.scala b/tmail-backend/jmap/extensions/src/main/scala/com/linagora/tmail/james/jmap/json/CalendarEventReplySerializer.scala
index 8f346cd686..633471420f 100644
--- a/tmail-backend/jmap/extensions/src/main/scala/com/linagora/tmail/james/jmap/json/CalendarEventReplySerializer.scala
+++ b/tmail-backend/jmap/extensions/src/main/scala/com/linagora/tmail/james/jmap/json/CalendarEventReplySerializer.scala
@@ -1,7 +1,8 @@
package com.linagora.tmail.james.jmap.json
+import com.linagora.tmail.james.jmap.LanguageLocation
import com.linagora.tmail.james.jmap.model.CalendarEventParse.UnparsedBlobId
-import com.linagora.tmail.james.jmap.model.{CalendarEventNotDone, CalendarEventNotFound, CalendarEventReplyAcceptedResponse, CalendarEventReplyMaybeResponse, CalendarEventReplyRejectedResponse, CalendarEventReplyRequest, CalendarEventReplyResponse, LanguageLocation}
+import com.linagora.tmail.james.jmap.model.{CalendarEventNotDone, CalendarEventNotFound, CalendarEventReplyAcceptedResponse, CalendarEventReplyMaybeResponse, CalendarEventReplyRejectedResponse, CalendarEventReplyRequest, CalendarEventReplyResponse}
import org.apache.james.jmap.core.SetError
import org.apache.james.jmap.json.mapWrites
import org.apache.james.jmap.mail.{BlobId, BlobIds}
diff --git a/tmail-backend/jmap/extensions/src/main/scala/com/linagora/tmail/james/jmap/method/CalendarEventReplyPerformer.scala b/tmail-backend/jmap/extensions/src/main/scala/com/linagora/tmail/james/jmap/method/CalendarEventReplyPerformer.scala
index 0ae3a6014a..def819372f 100644
--- a/tmail-backend/jmap/extensions/src/main/scala/com/linagora/tmail/james/jmap/method/CalendarEventReplyPerformer.scala
+++ b/tmail-backend/jmap/extensions/src/main/scala/com/linagora/tmail/james/jmap/method/CalendarEventReplyPerformer.scala
@@ -106,7 +106,7 @@ class CalendarEventReplyPerformer @Inject()(blobCalendarResolver: BlobCalendarRe
})
private def getLanguageLocale(request: CalendarEventReplyRequest): Locale =
- request.language.map(_.language).getOrElse(CalendarEventReplySupportedLanguage.LANGUAGE_DEFAULT)
+ request.language.map(_.language).getOrElse(JMAPExtensionConfiguration.CALENDAR_LANGUAGE_DEFAULT)
}
class BlobCalendarResolver @Inject()(blobResolvers: BlobResolvers) {
@@ -128,14 +128,10 @@ class BlobCalendarResolver @Inject()(blobResolvers: BlobResolvers) {
}
}
-object CalendarEventReplySupportedLanguage {
- val LANGUAGE_DEFAULT: Locale = Locale.ENGLISH
-}
-
class CalendarEventReplySupportedLanguage @Inject()(jmapExtensionConfiguration: JMAPExtensionConfiguration) {
private val supportedLanguages: Set[Locale] = jmapExtensionConfiguration.calendarEventReplySupportedLanguagesConfig.supportedLanguages match {
- case supportedLanguages if supportedLanguages.isEmpty => Set(CalendarEventReplySupportedLanguage.LANGUAGE_DEFAULT)
+ case supportedLanguages if supportedLanguages.isEmpty => JMAPExtensionConfiguration.CALENDAR_SUPPORTED_LANGUAGES_DEFAULT
case supportedLanguages => supportedLanguages
}
diff --git a/tmail-backend/jmap/extensions/src/main/scala/com/linagora/tmail/james/jmap/model/CalendarEventReply.scala b/tmail-backend/jmap/extensions/src/main/scala/com/linagora/tmail/james/jmap/model/CalendarEventReply.scala
index 6f1aeb8d71..ef6f1e7b98 100644
--- a/tmail-backend/jmap/extensions/src/main/scala/com/linagora/tmail/james/jmap/model/CalendarEventReply.scala
+++ b/tmail-backend/jmap/extensions/src/main/scala/com/linagora/tmail/james/jmap/model/CalendarEventReply.scala
@@ -1,7 +1,6 @@
package com.linagora.tmail.james.jmap.model
-import java.util.Locale
-
+import com.linagora.tmail.james.jmap.LanguageLocation
import com.linagora.tmail.james.jmap.method.CalendarEventReplyPerformer.LOGGER
import com.linagora.tmail.james.jmap.model.CalendarEventParse.UnparsedBlobId
import com.linagora.tmail.james.jmap.model.CalendarEventReplyRequest.MAXIMUM_NUMBER_OF_BLOB_IDS
@@ -11,23 +10,6 @@ import org.apache.james.jmap.mail.{BlobId, BlobIds, RequestTooLargeException}
import org.apache.james.jmap.method.WithAccountId
import org.apache.james.mailbox.MailboxSession
-import scala.util.Try
-
-object LanguageLocation {
- def fromString(languageCode: String): Try[LanguageLocation] = detectLocale(languageCode).map(LanguageLocation.apply)
-
- def detectLocale(languageCode: String): Try[Locale] =
- if (Locale.getISOLanguages.contains(languageCode)) {
- Try(Locale.forLanguageTag(languageCode))
- } else {
- throw new IllegalArgumentException("The language must be a valid ISO language code")
- }
-}
-
-case class LanguageLocation(language: Locale) {
- def value: String = language.toLanguageTag
-}
-
object CalendarEventReplyRequest {
val MAXIMUM_NUMBER_OF_BLOB_IDS: Int = 16
}
diff --git a/tmail-backend/jmap/extensions/src/test/scala/com/linagora/tmail/james/jmap/json/CalendarEventReplySerializerTest.scala b/tmail-backend/jmap/extensions/src/test/scala/com/linagora/tmail/james/jmap/json/CalendarEventReplySerializerTest.scala
index 5cb4ea083a..b46f4b953c 100644
--- a/tmail-backend/jmap/extensions/src/test/scala/com/linagora/tmail/james/jmap/json/CalendarEventReplySerializerTest.scala
+++ b/tmail-backend/jmap/extensions/src/test/scala/com/linagora/tmail/james/jmap/json/CalendarEventReplySerializerTest.scala
@@ -1,7 +1,8 @@
package com.linagora.tmail.james.jmap.json
+import com.linagora.tmail.james.jmap.LanguageLocation
import com.linagora.tmail.james.jmap.json.{CalendarEventReplySerializer => testee}
-import com.linagora.tmail.james.jmap.model.{CalendarEventNotDone, CalendarEventNotFound, CalendarEventReplyAcceptedResponse, CalendarEventReplyRequest, LanguageLocation}
+import com.linagora.tmail.james.jmap.model.{CalendarEventNotDone, CalendarEventNotFound, CalendarEventReplyAcceptedResponse, CalendarEventReplyRequest}
import eu.timepit.refined.auto._
import org.apache.james.core.Username
import org.apache.james.jmap.core.SetError.SetErrorDescription
diff --git a/tmail-backend/jmap/jmap-extensions-configuration/pom.xml b/tmail-backend/jmap/jmap-extensions-configuration/pom.xml
new file mode 100644
index 0000000000..33a4eb0797
--- /dev/null
+++ b/tmail-backend/jmap/jmap-extensions-configuration/pom.xml
@@ -0,0 +1,43 @@
+
+
+ 4.0.0
+
+ com.linagora.tmail
+ tmail-backend
+ 1.0.0-SNAPSHOT
+ ../../pom.xml
+
+
+ jmap-extensions-configuration
+ Twake Mail :: JMAP :: Extensions :: Configuration
+
+
+
+ ${james.groupId}
+ james-server-jmap-rfc-8621
+
+
+ ${james.groupId}
+ james-server-data-jmap
+
+
+ ${james.groupId}
+ james-server-guice-configuration
+
+
+
+
+
+ net.alchim31.maven
+ scala-maven-plugin
+
+
+ io.github.evis
+ scalafix-maven-plugin_2.13
+
+ ${project.parent.parent.basedir}/.scalafix.conf
+
+
+
+
+
\ No newline at end of file
diff --git a/tmail-backend/jmap/extensions/src/main/scala/com/linagora/tmail/james/jmap/JMAPExtensionConfiguration.scala b/tmail-backend/jmap/jmap-extensions-configuration/src/main/java/com/linagora/tmail/james/jmap/JMAPExtensionConfiguration.scala
similarity index 89%
rename from tmail-backend/jmap/extensions/src/main/scala/com/linagora/tmail/james/jmap/JMAPExtensionConfiguration.scala
rename to tmail-backend/jmap/jmap-extensions-configuration/src/main/java/com/linagora/tmail/james/jmap/JMAPExtensionConfiguration.scala
index ad19572ae6..304269fcca 100644
--- a/tmail-backend/jmap/extensions/src/main/scala/com/linagora/tmail/james/jmap/JMAPExtensionConfiguration.scala
+++ b/tmail-backend/jmap/jmap-extensions-configuration/src/main/java/com/linagora/tmail/james/jmap/JMAPExtensionConfiguration.scala
@@ -6,8 +6,6 @@ import java.time.temporal.ChronoUnit
import java.util.Locale
import com.linagora.tmail.james.jmap.JMAPExtensionConfiguration.{CALENDAR_EVENT_REPLY_SUPPORTED_LANGUAGES_DEFAULT, PUBLIC_ASSET_TOTAL_SIZE_LIMIT_DEFAULT, TICKET_IP_VALIDATION_ENABLED}
-import com.linagora.tmail.james.jmap.method.CalendarEventReplySupportedLanguage.LANGUAGE_DEFAULT
-import com.linagora.tmail.james.jmap.model.LanguageLocation
import eu.timepit.refined
import org.apache.commons.configuration2.Configuration
import org.apache.james.core.MailAddress
@@ -22,8 +20,10 @@ object JMAPExtensionConfiguration {
val PUBLIC_ASSET_TOTAL_SIZE_LIMIT_DEFAULT: PublicAssetTotalSizeLimit = PublicAssetTotalSizeLimit.of(Size.of(20L, Size.Unit.M)).get
val TICKET_IP_VALIDATION_PROPERTY: String = "authentication.strategy.rfc8621.tickets.ip.validation.enabled"
val TICKET_IP_VALIDATION_ENABLED: TicketIpValidationEnable = TicketIpValidationEnable(true)
+ val CALENDAR_LANGUAGE_DEFAULT: Locale = Locale.ENGLISH
+ val CALENDAR_SUPPORTED_LANGUAGES_DEFAULT: Set[Locale] = Set(CALENDAR_LANGUAGE_DEFAULT)
val CALENDAR_EVENT_REPLY_SUPPORTED_LANGUAGES_PROPERTY: String = "calendarEvent.reply.supportedLanguages"
- val CALENDAR_EVENT_REPLY_SUPPORTED_LANGUAGES_DEFAULT: CalendarEventReplySupportedLanguagesConfig = CalendarEventReplySupportedLanguagesConfig(Set(LANGUAGE_DEFAULT))
+ val CALENDAR_EVENT_REPLY_SUPPORTED_LANGUAGES_DEFAULT: CalendarEventReplySupportedLanguagesConfig = CalendarEventReplySupportedLanguagesConfig(CALENDAR_SUPPORTED_LANGUAGES_DEFAULT)
val SUPPORT_MAIL_ADDRESS_PROPERTY: String = "support.mail.address"
@@ -84,6 +84,21 @@ case class JMAPExtensionConfiguration(publicAssetTotalSizeLimit: PublicAssetTota
}
}
+object LanguageLocation {
+ def fromString(languageCode: String): Try[LanguageLocation] = detectLocale(languageCode).map(LanguageLocation.apply)
+
+ def detectLocale(languageCode: String): Try[Locale] =
+ if (Locale.getISOLanguages.contains(languageCode)) {
+ Try(Locale.forLanguageTag(languageCode))
+ } else {
+ throw new IllegalArgumentException("The language must be a valid ISO language code")
+ }
+}
+
+case class LanguageLocation(language: Locale) {
+ def value: String = language.toLanguageTag
+}
+
case class PublicAssetTotalSizeLimit(value: UnsignedInt) {
def asLong(): Long = value.value
}