Skip to content

Commit

Permalink
[ISSUE-1254] Move PublicAssetTotalSizeLimit constant to API
Browse files Browse the repository at this point in the history
  • Loading branch information
HoussemNasri committed Dec 10, 2024
1 parent ff4fcf4 commit f018c83
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit f018c83

Please sign in to comment.