From f018c83f2699098bc546a8022743a06c7fe47a93 Mon Sep 17 00:00:00 2001 From: HoussemNasri Date: Mon, 9 Dec 2024 17:39:39 +0100 Subject: [PATCH] [ISSUE-1254] Move PublicAssetTotalSizeLimit constant to API --- .../linagora/tmail/james/jmap/PublicAssetTotalSizeLimit.scala | 2 ++ .../james/jmap/publicAsset/PublicAssetServiceContract.scala | 2 +- .../jmap/publicAsset/CassandraPublicAssetRepositoryTest.java | 3 +-- .../jmap/publicAsset/CassandraPublicAssetServiceTest.java | 3 +-- .../linagora/tmail/james/jmap/JMAPExtensionConfiguration.scala | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tmail-backend/jmap/extensions-api/src/main/scala/com/linagora/tmail/james/jmap/PublicAssetTotalSizeLimit.scala b/tmail-backend/jmap/extensions-api/src/main/scala/com/linagora/tmail/james/jmap/PublicAssetTotalSizeLimit.scala index b7e189a5fc..5a2c9f6b5b 100644 --- a/tmail-backend/jmap/extensions-api/src/main/scala/com/linagora/tmail/james/jmap/PublicAssetTotalSizeLimit.scala +++ b/tmail-backend/jmap/extensions-api/src/main/scala/com/linagora/tmail/james/jmap/PublicAssetTotalSizeLimit.scala @@ -7,6 +7,8 @@ import org.apache.james.util.Size import scala.util.{Failure, Success, Try} object PublicAssetTotalSizeLimit { + val DEFAULT: PublicAssetTotalSizeLimit = PublicAssetTotalSizeLimit.of(Size.of(20L, Size.Unit.M)).get + def of(size: Size): Try[PublicAssetTotalSizeLimit] = refined.refineV[UnsignedIntConstraint](size.asBytes()) match { case Right(value) => Success(PublicAssetTotalSizeLimit(value)) case Left(error) => Failure(new NumberFormatException(error)) diff --git a/tmail-backend/jmap/extensions-api/src/test/scala/com/linagora/tmail/james/jmap/publicAsset/PublicAssetServiceContract.scala b/tmail-backend/jmap/extensions-api/src/test/scala/com/linagora/tmail/james/jmap/publicAsset/PublicAssetServiceContract.scala index bde3e2c9ce..a4d92cedc1 100644 --- a/tmail-backend/jmap/extensions-api/src/test/scala/com/linagora/tmail/james/jmap/publicAsset/PublicAssetServiceContract.scala +++ b/tmail-backend/jmap/extensions-api/src/test/scala/com/linagora/tmail/james/jmap/publicAsset/PublicAssetServiceContract.scala @@ -30,7 +30,7 @@ object PublicAssetServiceContract { val identityRepository: IdentityRepository = mock(classOf[IdentityRepository]) - val PUBLIC_ASSET_TOTAL_SIZE_LIMIT_IN_CONFIGURED: Long = PublicAssetTotalSizeLimit.of(org.apache.james.util.Size.of(20L, org.apache.james.util.Size.Unit.M)).get.asLong() + val PUBLIC_ASSET_TOTAL_SIZE_LIMIT_IN_CONFIGURED: Long = PublicAssetTotalSizeLimit.DEFAULT.asLong() val CLOCK = new UpdatableTickingClock(Instant.now()) } diff --git a/tmail-backend/jmap/extensions-cassandra/src/test/java/com/linagora/tmail/james/jmap/publicAsset/CassandraPublicAssetRepositoryTest.java b/tmail-backend/jmap/extensions-cassandra/src/test/java/com/linagora/tmail/james/jmap/publicAsset/CassandraPublicAssetRepositoryTest.java index daa577c305..07c8e09f19 100644 --- a/tmail-backend/jmap/extensions-cassandra/src/test/java/com/linagora/tmail/james/jmap/publicAsset/CassandraPublicAssetRepositoryTest.java +++ b/tmail-backend/jmap/extensions-cassandra/src/test/java/com/linagora/tmail/james/jmap/publicAsset/CassandraPublicAssetRepositoryTest.java @@ -19,8 +19,7 @@ class CassandraPublicAssetRepositoryTest implements PublicAssetRepositoryContrac @BeforeEach void setup(CassandraCluster cassandra) { - PublicAssetTotalSizeLimit publicAssetTotalSizeLimit = - PublicAssetTotalSizeLimit.of(Size.of(20L, Size.Unit.M)).get(); + PublicAssetTotalSizeLimit publicAssetTotalSizeLimit = PublicAssetTotalSizeLimit.DEFAULT(); publicAssetRepository = new CassandraPublicAssetRepository( new CassandraPublicAssetDAO(cassandra.getConf(), blobIdFactory()), new DeDuplicationBlobStore(new MemoryBlobStoreDAO(), BucketName.DEFAULT, blobIdFactory()), diff --git a/tmail-backend/jmap/extensions-cassandra/src/test/java/com/linagora/tmail/james/jmap/publicAsset/CassandraPublicAssetServiceTest.java b/tmail-backend/jmap/extensions-cassandra/src/test/java/com/linagora/tmail/james/jmap/publicAsset/CassandraPublicAssetServiceTest.java index a32c7f90dc..66d7c3aa72 100644 --- a/tmail-backend/jmap/extensions-cassandra/src/test/java/com/linagora/tmail/james/jmap/publicAsset/CassandraPublicAssetServiceTest.java +++ b/tmail-backend/jmap/extensions-cassandra/src/test/java/com/linagora/tmail/james/jmap/publicAsset/CassandraPublicAssetServiceTest.java @@ -22,8 +22,7 @@ class CassandraPublicAssetServiceTest implements PublicAssetServiceContract { @BeforeEach void setup(CassandraCluster cassandra) { - PublicAssetTotalSizeLimit publicAssetTotalSizeLimit = - PublicAssetTotalSizeLimit.of(Size.of(20L, Size.Unit.M)).get(); + PublicAssetTotalSizeLimit publicAssetTotalSizeLimit = PublicAssetTotalSizeLimit.DEFAULT(); publicAssetRepository = new CassandraPublicAssetRepository( new CassandraPublicAssetDAO(cassandra.getConf(), blobIdFactory()), new DeDuplicationBlobStore(new MemoryBlobStoreDAO(), BucketName.DEFAULT, blobIdFactory()), diff --git a/tmail-backend/jmap/extensions/src/main/scala/com/linagora/tmail/james/jmap/JMAPExtensionConfiguration.scala b/tmail-backend/jmap/extensions/src/main/scala/com/linagora/tmail/james/jmap/JMAPExtensionConfiguration.scala index 6b039ddce4..76fc9e2c5c 100644 --- a/tmail-backend/jmap/extensions/src/main/scala/com/linagora/tmail/james/jmap/JMAPExtensionConfiguration.scala +++ b/tmail-backend/jmap/extensions/src/main/scala/com/linagora/tmail/james/jmap/JMAPExtensionConfiguration.scala @@ -18,7 +18,7 @@ import scala.util.{Failure, Success, Try} object JMAPExtensionConfiguration { val PUBLIC_ASSET_TOTAL_SIZE_LIMIT_PROPERTY: String = "public.asset.total.size" - val PUBLIC_ASSET_TOTAL_SIZE_LIMIT_DEFAULT: PublicAssetTotalSizeLimit = PublicAssetTotalSizeLimit.of(Size.of(20L, Size.Unit.M)).get + val PUBLIC_ASSET_TOTAL_SIZE_LIMIT_DEFAULT: PublicAssetTotalSizeLimit = PublicAssetTotalSizeLimit.DEFAULT val TICKET_IP_VALIDATION_PROPERTY: String = "authentication.strategy.rfc8621.tickets.ip.validation.enabled" val TICKET_IP_VALIDATION_ENABLED: TicketIpValidationEnable = TicketIpValidationEnable(true) val CALENDAR_EVENT_REPLY_SUPPORTED_LANGUAGES_PROPERTY: String = "calendarEvent.reply.supportedLanguages"