diff --git a/.sdkmanrc b/.sdkmanrc new file mode 100644 index 00000000..169ca95f --- /dev/null +++ b/.sdkmanrc @@ -0,0 +1,2 @@ +java=11-open +sbt=1.10.2 \ No newline at end of file diff --git a/build.sbt b/build.sbt index c16fc9cf..f96ea9d0 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ import ReleaseTransformations._ name := """nio""" organization := "fr.maif" -scalaVersion := "2.13.10" +scalaVersion := "2.13.11" lazy val root = (project in file(".")) .aggregate( diff --git a/nio-provider/app/actor/EventActor.scala b/nio-provider/app/actor/EventActor.scala index 20df601e..c26cc4b2 100644 --- a/nio-provider/app/actor/EventActor.scala +++ b/nio-provider/app/actor/EventActor.scala @@ -1,6 +1,6 @@ package actor -import akka.actor.{Actor, ActorRef, Props} +import org.apache.pekko.actor.{Actor, ActorRef, Props} import models.NioEvent import play.api.libs.json.Json import utils.NioLogger diff --git a/nio-provider/app/actor/KafkaActor.scala b/nio-provider/app/actor/KafkaActor.scala index 4a114e7a..12853175 100644 --- a/nio-provider/app/actor/KafkaActor.scala +++ b/nio-provider/app/actor/KafkaActor.scala @@ -1,9 +1,9 @@ package actor -import akka.NotUsed -import akka.actor.{Actor, Props} -import akka.stream.Materializer -import akka.stream.scaladsl.Source +import org.apache.pekko.NotUsed +import org.apache.pekko.actor.{Actor, Props} +import org.apache.pekko.stream.Materializer +import org.apache.pekko.stream.scaladsl.Source import models.NioEvent import utils.NioLogger diff --git a/nio-provider/app/controllers/HomeController.scala b/nio-provider/app/controllers/HomeController.scala index c236389d..5c6de53b 100644 --- a/nio-provider/app/controllers/HomeController.scala +++ b/nio-provider/app/controllers/HomeController.scala @@ -1,6 +1,6 @@ package controllers -import akka.actor.ActorSystem +import org.apache.pekko.actor.ActorSystem import auth.AuthActionWithEmail import configuration.Env import messaging.KafkaMessageBroker diff --git a/nio-provider/app/controllers/UserDataController.scala b/nio-provider/app/controllers/UserDataController.scala index 2de1aace..f8c416ff 100644 --- a/nio-provider/app/controllers/UserDataController.scala +++ b/nio-provider/app/controllers/UserDataController.scala @@ -3,10 +3,10 @@ package controllers import java.io.FileInputStream import actor.EventActor -import akka.actor.ActorSystem -import akka.stream.Materializer -import akka.stream.scaladsl.{Source, StreamConverters} -import akka.util.ByteString +import org.apache.pekko.actor.ActorSystem +import org.apache.pekko.stream.Materializer +import org.apache.pekko.stream.scaladsl.{Source, StreamConverters} +import org.apache.pekko.util.ByteString import auth.AuthActionWithEmail import configuration.Env import play.api.libs.streams.ActorFlow diff --git a/nio-provider/app/filters/OtoroshiFilter.scala b/nio-provider/app/filters/OtoroshiFilter.scala index 0b145805..a92abd95 100644 --- a/nio-provider/app/filters/OtoroshiFilter.scala +++ b/nio-provider/app/filters/OtoroshiFilter.scala @@ -1,6 +1,6 @@ package filters -import akka.stream.Materializer +import org.apache.pekko.stream.Materializer import auth.AuthInfo import com.auth0.jwt._ import com.auth0.jwt.algorithms.Algorithm diff --git a/nio-provider/app/loader/NioLoader.scala b/nio-provider/app/loader/NioLoader.scala index 67f4fa2a..e9da8683 100644 --- a/nio-provider/app/loader/NioLoader.scala +++ b/nio-provider/app/loader/NioLoader.scala @@ -1,7 +1,7 @@ package loader import actor.{EventActor, KafkaActor} -import akka.actor.{ActorRef, ActorSystem} +import org.apache.pekko.actor.{ActorRef, ActorSystem} import auth._ import com.softwaremill.macwire.wire import configuration._ diff --git a/nio-provider/app/loader/Starter.scala b/nio-provider/app/loader/Starter.scala index f8de531f..9893502e 100644 --- a/nio-provider/app/loader/Starter.scala +++ b/nio-provider/app/loader/Starter.scala @@ -1,7 +1,7 @@ package loader import actor.KafkaActor -import akka.actor.ActorSystem +import org.apache.pekko.actor.ActorSystem import messaging.KafkaMessageBroker class Starter(kafkaMessageBroker: KafkaMessageBroker, diff --git a/nio-provider/app/messaging/Kafka.scala b/nio-provider/app/messaging/Kafka.scala index 2edae741..dcebcdd8 100644 --- a/nio-provider/app/messaging/Kafka.scala +++ b/nio-provider/app/messaging/Kafka.scala @@ -2,7 +2,7 @@ package messaging import java.io.File -import akka.actor.ActorSystem +import org.apache.pekko.actor.ActorSystem import configuration.KafkaConfig import org.apache.kafka.clients.CommonClientConfigs import org.apache.kafka.common.config.internals.BrokerSecurityConfigs @@ -13,7 +13,7 @@ import org.apache.kafka.common.serialization.{ object KafkaSettings { - import akka.kafka.{ConsumerSettings, ProducerSettings} + import org.apache.pekko.kafka.{ConsumerSettings, ProducerSettings} import org.apache.kafka.clients.consumer.ConsumerConfig import org.apache.kafka.common.config.SslConfigs import org.apache.kafka.common.serialization.ByteArrayDeserializer diff --git a/nio-provider/app/messaging/KafkaMessageBroker.scala b/nio-provider/app/messaging/KafkaMessageBroker.scala index f3d51f15..d6e7e5f8 100644 --- a/nio-provider/app/messaging/KafkaMessageBroker.scala +++ b/nio-provider/app/messaging/KafkaMessageBroker.scala @@ -1,11 +1,11 @@ package messaging -import akka.NotUsed -import akka.actor.ActorSystem -import akka.kafka.Subscriptions -import akka.kafka.scaladsl.Consumer -import akka.stream.Materializer -import akka.stream.scaladsl.{Flow, Sink, Source} +import org.apache.pekko.NotUsed +import org.apache.pekko.actor.ActorSystem +import org.apache.pekko.kafka.Subscriptions +import org.apache.pekko.kafka.scaladsl.Consumer +import org.apache.pekko.stream.Materializer +import org.apache.pekko.stream.scaladsl.{Flow, Sink, Source} import configuration.{Env, KafkaConfig} import models.NioEvent import utils.NioLogger diff --git a/nio-provider/app/models/UserExtractTask.scala b/nio-provider/app/models/UserExtractTask.scala index 058ed333..917a6a79 100644 --- a/nio-provider/app/models/UserExtractTask.scala +++ b/nio-provider/app/models/UserExtractTask.scala @@ -1,6 +1,6 @@ package models -import org.joda.time.{DateTime, DateTimeZone} +import java.time.{LocalDateTime, Clock} import play.api.libs.functional.syntax.{unlift, _} import play.api.libs.json.Reads._ import play.api.libs.json.Writes._ @@ -15,16 +15,16 @@ case class UserExtractTask( orgKey: String, userId: String, email: String, - startedAt: DateTime, - uploadStartedAt: Option[DateTime], - endedAt: Option[DateTime] + startedAt: LocalDateTime, + uploadStartedAt: Option[LocalDateTime], + endedAt: Option[LocalDateTime] ) { def asJson(): JsValue = UserExtractTask.userExtractTaskWrites.writes(this) } object UserExtractTask { - implicit val dateFormats: Format[DateTime] = DateUtils.utcDateTimeFormats + implicit val dateFormats: Format[LocalDateTime] = DateUtils.utcDateTimeFormats implicit val userExtractTaskReads: Reads[UserExtractTask] = ( (__ \ "_id").readNullable[String].map { maybeId => @@ -34,11 +34,11 @@ object UserExtractTask { (__ \ "orgKey").read[String] and (__ \ "userId").read[String] and (__ \ "email").read[String] and - (__ \ "startedAt").readNullable[DateTime].map { maybeStartedAt => - maybeStartedAt.getOrElse(DateTime.now(DateTimeZone.UTC)) + (__ \ "startedAt").readNullable[LocalDateTime].map { maybeStartedAt => + maybeStartedAt.getOrElse(LocalDateTime.now(Clock.systemUTC)) } and - (__ \ "uploadStartedAt").readNullable[DateTime] and - (__ \ "endedAt").readNullable[DateTime] + (__ \ "uploadStartedAt").readNullable[LocalDateTime] and + (__ \ "endedAt").readNullable[LocalDateTime] )(UserExtractTask.apply _) implicit val userExtractTaskWrites: Writes[UserExtractTask] = ( @@ -47,9 +47,9 @@ object UserExtractTask { (JsPath \ "orgKey").write[String] and (JsPath \ "userId").write[String] and (JsPath \ "email").write[String] and - (JsPath \ "startedAt").write[DateTime] and - (JsPath \ "uploadStartedAt").writeNullable[DateTime] and - (JsPath \ "endedAt").writeNullable[DateTime] + (JsPath \ "startedAt").write[LocalDateTime] and + (JsPath \ "uploadStartedAt").writeNullable[LocalDateTime] and + (JsPath \ "endedAt").writeNullable[LocalDateTime] )(unlift(UserExtractTask.unapply)) implicit val userExtractTaskOWrites: OWrites[UserExtractTask] = ( @@ -58,9 +58,9 @@ object UserExtractTask { (JsPath \ "orgKey").write[String] and (JsPath \ "userId").write[String] and (JsPath \ "email").write[String] and - (JsPath \ "startedAt").write[DateTime] and - (JsPath \ "uploadStartedAt").writeNullable[DateTime] and - (JsPath \ "endedAt").writeNullable[DateTime] + (JsPath \ "startedAt").write[LocalDateTime] and + (JsPath \ "uploadStartedAt").writeNullable[LocalDateTime] and + (JsPath \ "endedAt").writeNullable[LocalDateTime] )(unlift(UserExtractTask.unapply)) implicit val format: Format[UserExtractTask] = diff --git a/nio-provider/app/models/events.scala b/nio-provider/app/models/events.scala index 0ce9061d..6e4078a4 100644 --- a/nio-provider/app/models/events.scala +++ b/nio-provider/app/models/events.scala @@ -1,6 +1,6 @@ package models -import org.joda.time.{DateTime, DateTimeZone} +import java.time.{LocalDateTime, Clock} import utils.NioLogger import play.api.libs.json._ import utils.DateUtils @@ -47,7 +47,7 @@ object NioEvent { trait NioEvent { val id: Long - val date: DateTime + val date: LocalDateTime val tenant: String def tYpe: EventType.Value @@ -70,7 +70,7 @@ case class UserExtractTaskAsked( author: String, metadata: Option[Seq[(String, String)]] = None, id: Long, - date: DateTime = DateTime.now(DateTimeZone.UTC), + date: LocalDateTime = LocalDateTime.now(Clock.systemUTC), payload: UserExtractTask ) extends NioEvent { override def tYpe: EventType.Value = EventType.UserExtractTaskAsked @@ -82,7 +82,7 @@ case class UserExtractTaskAsked( "tenant" -> tenant, "author" -> author, "metadata" -> buildMetadata(metadata), - "date" -> date.toString(DateUtils.utcDateFormatter), + "date" -> date.format(DateUtils.utcDateFormatter), "id" -> id, "payload" -> payload.asJson() ) @@ -94,7 +94,7 @@ case class UserExtractTaskCompleted( author: String, metadata: Option[Seq[(String, String)]] = None, id: Long, - date: DateTime = DateTime.now(DateTimeZone.UTC), + date: LocalDateTime = LocalDateTime.now(Clock.systemUTC), payload: UserExtractTask ) extends NioEvent { override def tYpe: EventType.Value = EventType.UserExtractTaskCompleted @@ -106,7 +106,7 @@ case class UserExtractTaskCompleted( "tenant" -> tenant, "author" -> author, "metadata" -> buildMetadata(metadata), - "date" -> date.toString(DateUtils.utcDateFormatter), + "date" -> date.format(DateUtils.utcDateFormatter), "id" -> id, "payload" -> payload.asJson() ) diff --git a/nio-provider/app/service/NioService.scala b/nio-provider/app/service/NioService.scala index 0105c660..705beac3 100644 --- a/nio-provider/app/service/NioService.scala +++ b/nio-provider/app/service/NioService.scala @@ -1,8 +1,8 @@ package service -import akka.http.scaladsl.model.HttpMethods -import akka.stream.scaladsl.Source -import akka.util.ByteString +import org.apache.pekko.http.scaladsl.model.HttpMethods +import org.apache.pekko.stream.scaladsl.Source +import org.apache.pekko.util.ByteString import configuration.{Env, NioConfig} import play.api.libs.json.JsValue import play.api.libs.ws.WSClient diff --git a/nio-provider/app/utils/DateUtils.scala b/nio-provider/app/utils/DateUtils.scala index 9f0424b6..a75b5b68 100644 --- a/nio-provider/app/utils/DateUtils.scala +++ b/nio-provider/app/utils/DateUtils.scala @@ -1,18 +1,19 @@ package utils -import org.joda.time.DateTime +import java.time.LocalDateTime import org.joda.time.format.DateTimeFormat import play.api.libs.json._ +import java.time.format.DateTimeFormatter import scala.util.{Failure, Success, Try} object DateUtils { - val utcDateFormatter = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss'Z'") + val utcDateFormatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME //forPattern("yyyy-MM-dd'T'HH:mm:ss'Z'") - val utcDateTimeReads = new Reads[DateTime] { + val utcDateTimeReads = new Reads[LocalDateTime] { def reads(json: JsValue) = json match { case JsString(s) => - Try(DateTime.parse(s, utcDateFormatter)) match { + Try(LocalDateTime.parse(s, utcDateFormatter)) match { case Success(d) => JsSuccess(d) case Failure(f) => JsSuccess(null) } @@ -20,11 +21,11 @@ object DateUtils { } } - val utcDateTimeWrites = new Writes[DateTime] { - override def writes(o: DateTime): JsValue = - JsString(o.toString(DateUtils.utcDateFormatter)) + val utcDateTimeWrites = new Writes[LocalDateTime] { + override def writes(o: LocalDateTime): JsValue = + JsString(o.format(DateUtils.utcDateFormatter)) } - val utcDateTimeFormats: Format[DateTime] = + val utcDateTimeFormats: Format[LocalDateTime] = Format(utcDateTimeReads, utcDateTimeWrites) } diff --git a/nio-provider/build.sbt b/nio-provider/build.sbt index 8d6fc681..6997a0ea 100644 --- a/nio-provider/build.sbt +++ b/nio-provider/build.sbt @@ -9,17 +9,21 @@ lazy val `nio-provider` = (project in file(".")) .enablePlugins(NoPublish) .disablePlugins(BintrayPlugin) -scalaVersion := "2.13.10" +scalaVersion := "2.13.14" resolvers ++= Seq( Resolver.jcenterRepo, "Maven central" at "https://repo1.maven.org/maven2/" ) +dependencyOverrides ++= Seq( + "com.github.luben" % "zstd-jni" % "1.5.6-4" +) + libraryDependencies ++= Seq( ws, "com.typesafe.play" %% "play-json-joda" % playJsonJodaVersion, - "com.typesafe.akka" %% "akka-stream-kafka" % akkaStreamKafka, + "org.apache.pekko" %% "pekko-connectors-kafka" % pekkoKafka, "de.svenkubiak" % "jBCrypt" % "0.4.1", // ISC/BSD "com.auth0" % "java-jwt" % javaJwt, // MIT license "com.github.pureconfig" %% "pureconfig" % pureConfig, // Apache 2.0 diff --git a/nio-server/app/auth/auth.scala b/nio-server/app/auth/auth.scala index d7c76a49..90796943 100644 --- a/nio-server/app/auth/auth.scala +++ b/nio-server/app/auth/auth.scala @@ -1,6 +1,6 @@ package auth -import akka.http.scaladsl.util.FastFuture +import org.apache.pekko.http.scaladsl.util.FastFuture import configuration.Env import db.ExtractionTaskMongoDataStore import utils.NioLogger diff --git a/nio-server/app/controllers/ApiKeyController.scala b/nio-server/app/controllers/ApiKeyController.scala index 373d5455..03a8a3bf 100644 --- a/nio-server/app/controllers/ApiKeyController.scala +++ b/nio-server/app/controllers/ApiKeyController.scala @@ -1,6 +1,6 @@ package controllers -import akka.http.scaladsl.util.FastFuture +import org.apache.pekko.http.scaladsl.util.FastFuture import auth.SecuredAuthContext import controllers.ErrorManager.{AppErrorManagerResult, ErrorManagerResult} import db.ApiKeyMongoDataStore diff --git a/nio-server/app/controllers/Auth0Controller.scala b/nio-server/app/controllers/Auth0Controller.scala index fd65ec90..ffa10c6d 100644 --- a/nio-server/app/controllers/Auth0Controller.scala +++ b/nio-server/app/controllers/Auth0Controller.scala @@ -4,7 +4,7 @@ import java.math.BigInteger import java.security.SecureRandom import java.util.UUID.randomUUID -import akka.http.scaladsl.util.FastFuture +import org.apache.pekko.http.scaladsl.util.FastFuture import configuration.{Auth0Config, Env} import controllers.ErrorManager.AppErrorManagerResult import org.apache.commons.lang3.StringUtils diff --git a/nio-server/app/controllers/ConsentController.scala b/nio-server/app/controllers/ConsentController.scala index 936f9e00..21e4b526 100644 --- a/nio-server/app/controllers/ConsentController.scala +++ b/nio-server/app/controllers/ConsentController.scala @@ -1,11 +1,11 @@ package controllers -import akka.NotUsed -import akka.actor.ActorSystem -import akka.http.scaladsl.util.FastFuture -import akka.stream.{FlowShape, Materializer} -import akka.stream.scaladsl.{Flow, Framing, GraphDSL, Merge, Partition, Sink, Source} -import akka.util.ByteString +import org.apache.pekko.NotUsed +import org.apache.pekko.actor.ActorSystem +import org.apache.pekko.http.scaladsl.util.FastFuture +import org.apache.pekko.stream.{FlowShape, Materializer} +import org.apache.pekko.stream.scaladsl.{Flow, Framing, GraphDSL, Merge, Partition, Sink, Source} +import org.apache.pekko.util.ByteString import auth.{AuthAction, SecuredAuthContext} import controllers.ErrorManager.{AppErrorManagerResult, ErrorManagerResult, ErrorWithStatusManagerResult} import db.{ConsentFactMongoDataStore, LastConsentFactMongoDataStore, OrganisationMongoDataStore, UserMongoDataStore} @@ -449,7 +449,7 @@ class ConsentController( def downloadBulked(tenant: String) = AuthAction { implicit req => NioLogger.info(s"Downloading consents (using bulked reads) from tenant $tenant") - import reactivemongo.akkastream.cursorProducer + import reactivemongo.pekkostream.cursorProducer val src = Source .futureSource { diff --git a/nio-server/app/controllers/DeletionController.scala b/nio-server/app/controllers/DeletionController.scala index f8046fdc..4c6bc632 100644 --- a/nio-server/app/controllers/DeletionController.scala +++ b/nio-server/app/controllers/DeletionController.scala @@ -1,6 +1,6 @@ package controllers -import akka.actor.ActorSystem +import org.apache.pekko.actor.ActorSystem import auth.{AuthAction, SecuredAction, SecuredAuthContext} import db.{ConsentFactMongoDataStore, DeletionTaskMongoDataStore, OrganisationMongoDataStore, UserMongoDataStore} import messaging.KafkaMessageBroker diff --git a/nio-server/app/controllers/ExtractionController.scala b/nio-server/app/controllers/ExtractionController.scala index b182e498..0d8e6b99 100644 --- a/nio-server/app/controllers/ExtractionController.scala +++ b/nio-server/app/controllers/ExtractionController.scala @@ -3,10 +3,10 @@ package controllers import java.io.ByteArrayInputStream import java.util -import akka.actor.ActorSystem -import akka.stream.Materializer -import akka.stream.scaladsl.{Flow, Source} -import akka.util.ByteString +import org.apache.pekko.actor.ActorSystem +import org.apache.pekko.stream.Materializer +import org.apache.pekko.stream.scaladsl.{Flow, Source} +import org.apache.pekko.util.ByteString import auth._ import com.amazonaws.services.s3.model.{ CompleteMultipartUploadRequest, diff --git a/nio-server/app/controllers/HomeController.scala b/nio-server/app/controllers/HomeController.scala index 64b762c4..c3cd01f3 100644 --- a/nio-server/app/controllers/HomeController.scala +++ b/nio-server/app/controllers/HomeController.scala @@ -2,8 +2,8 @@ package controllers import java.nio.file.Files -import akka.actor.ActorSystem -import akka.http.scaladsl.util.FastFuture +import org.apache.pekko.actor.ActorSystem +import org.apache.pekko.http.scaladsl.util.FastFuture import auth.AuthContextWithEmail import configuration.Env import controllers.ErrorManager.ErrorManagerResult diff --git a/nio-server/app/controllers/MetricsController.scala b/nio-server/app/controllers/MetricsController.scala index 0b9bf8ad..7b3fa30f 100644 --- a/nio-server/app/controllers/MetricsController.scala +++ b/nio-server/app/controllers/MetricsController.scala @@ -1,6 +1,6 @@ package controllers -import akka.actor.ActorSystem +import org.apache.pekko.actor.ActorSystem import auth.{AuthAction, SecuredAction, SecuredAuthContext} import com.fasterxml.jackson.databind.ObjectMapper import configuration.Env diff --git a/nio-server/app/controllers/NioAccountController.scala b/nio-server/app/controllers/NioAccountController.scala index 2887d9fa..a70c313a 100644 --- a/nio-server/app/controllers/NioAccountController.scala +++ b/nio-server/app/controllers/NioAccountController.scala @@ -1,6 +1,6 @@ package controllers -import akka.http.scaladsl.util.FastFuture +import org.apache.pekko.http.scaladsl.util.FastFuture import auth.SecuredAuthContext import controllers.ErrorManager.{AppErrorManagerResult, ErrorManagerResult} import db.NioAccountMongoDataStore diff --git a/nio-server/app/controllers/NioAuthenticateController.scala b/nio-server/app/controllers/NioAuthenticateController.scala index c6e85182..57814dd6 100644 --- a/nio-server/app/controllers/NioAuthenticateController.scala +++ b/nio-server/app/controllers/NioAuthenticateController.scala @@ -1,7 +1,7 @@ package controllers -import akka.actor.ActorSystem -import akka.http.scaladsl.util.FastFuture +import org.apache.pekko.actor.ActorSystem +import org.apache.pekko.http.scaladsl.util.FastFuture import com.auth0.jwt.JWT import com.auth0.jwt.algorithms.Algorithm import configuration.{DefaultFilterConfig, Env} diff --git a/nio-server/app/controllers/OrganisationController.scala b/nio-server/app/controllers/OrganisationController.scala index 16307923..40f12d31 100644 --- a/nio-server/app/controllers/OrganisationController.scala +++ b/nio-server/app/controllers/OrganisationController.scala @@ -1,8 +1,8 @@ package controllers -import akka.actor.ActorSystem -import akka.stream.Materializer -import akka.util.ByteString +import org.apache.pekko.actor.ActorSystem +import org.apache.pekko.stream.Materializer +import org.apache.pekko.util.ByteString import auth.{AuthAction, SecuredAction, SecuredAuthContext} import db._ import models._ diff --git a/nio-server/app/controllers/OrganisationOfferController.scala b/nio-server/app/controllers/OrganisationOfferController.scala index bac265c3..5aab6dbe 100644 --- a/nio-server/app/controllers/OrganisationOfferController.scala +++ b/nio-server/app/controllers/OrganisationOfferController.scala @@ -1,11 +1,11 @@ package controllers -import akka.NotUsed -import akka.actor.ActorSystem -import akka.http.scaladsl.util.FastFuture -import akka.stream.Materializer -import akka.stream.scaladsl.{Flow, Framing, Sink, Source} -import akka.util.ByteString +import org.apache.pekko.NotUsed +import org.apache.pekko.actor.ActorSystem +import org.apache.pekko.http.scaladsl.util.FastFuture +import org.apache.pekko.stream.Materializer +import org.apache.pekko.stream.scaladsl.{Flow, Framing, Sink, Source} +import org.apache.pekko.util.ByteString import auth.{AuthInfo, SecuredAuthContext} import configuration.Env import controllers.ErrorManager.{AppErrorManagerResult, ErrorManagerResult, ErrorWithStatusManagerResult} @@ -13,7 +13,8 @@ import db.OrganisationMongoDataStore import libs.xmlorjson.XmlOrJson import messaging.KafkaMessageBroker import models._ -import org.joda.time.DateTime + +import java.time.{Clock, LocalDateTime} import utils.NioLogger import play.api.http.HttpEntity import play.api.libs.json.Reads._ @@ -22,8 +23,9 @@ import play.api.libs.streams.Accumulator import play.api.mvc.{ActionBuilder, AnyContent, ControllerComponents} import reactivemongo.api.bson.BSONObjectID import service.{ConsentManagerService, OfferManagerService} -import scala.collection.Seq +import java.time.format.DateTimeFormatter +import scala.collection.Seq import scala.concurrent.{ExecutionContext, Future} import scala.util.{Failure, Success} @@ -205,14 +207,14 @@ class OrganisationOfferController( ) ) ) - val date = DateTime.parse(value.date) + val date = LocalDateTime.parse(value.date, DateTimeFormatter.ISO_LOCAL_DATE_TIME) offers.filter(off => off.key != offerKey) ++ Seq(offer.copy(lastUpdate = date)) } } cf.copy( _id = BSONObjectID.generate().stringify, - lastUpdateSystem = DateTime.now(), + lastUpdateSystem = LocalDateTime.now(Clock.systemUTC()), userId = value.id, doneBy = DoneBy(authInfo.sub, "admin"), offers = Some(consentOffers) diff --git a/nio-server/app/controllers/UserController.scala b/nio-server/app/controllers/UserController.scala index 5dd4f932..eb208033 100644 --- a/nio-server/app/controllers/UserController.scala +++ b/nio-server/app/controllers/UserController.scala @@ -1,8 +1,8 @@ package controllers -import akka.actor.ActorSystem -import akka.stream.Materializer -import akka.util.ByteString +import org.apache.pekko.actor.ActorSystem +import org.apache.pekko.stream.Materializer +import org.apache.pekko.util.ByteString import auth.{AuthAction, SecuredAction, SecuredAuthContext} import db.UserMongoDataStore import models.PagedUsers diff --git a/nio-server/app/controllers/UserExtractController.scala b/nio-server/app/controllers/UserExtractController.scala index f792d818..64dcf1da 100644 --- a/nio-server/app/controllers/UserExtractController.scala +++ b/nio-server/app/controllers/UserExtractController.scala @@ -2,11 +2,10 @@ package controllers import java.io.FileInputStream import java.util.Base64 - -import akka.actor.ActorSystem -import akka.stream.IOResult -import akka.stream.scaladsl.{Source, StreamConverters} -import akka.util.ByteString +import org.apache.pekko.actor.ActorSystem +import org.apache.pekko.stream.IOResult +import org.apache.pekko.stream.scaladsl.{Source, StreamConverters} +import org.apache.pekko.util.ByteString import auth.{AuthAction, SecuredAction, SecuredAuthContext} import com.auth0.jwt.JWT import com.auth0.jwt.algorithms.Algorithm @@ -15,7 +14,8 @@ import controllers.ErrorManager.{AppErrorManagerResult, ErrorManagerResult} import db.{OrganisationMongoDataStore, UserExtractTaskDataStore} import messaging.KafkaMessageBroker import models._ -import org.joda.time.{DateTime, DateTimeZone} + +import java.time.{Clock, LocalDateTime} import utils.NioLogger import play.api.http.HttpEntity import play.api.libs.Files @@ -149,7 +149,7 @@ class UserExtractController( .notFound() ) case Some(extractTask) => - val startUploadAt = DateTime.now(DateTimeZone.UTC) + val startUploadAt = LocalDateTime.now(Clock.systemUTC) val future: Future[Either[AppErrors, String]] = for { downloadedFileUrl <- Future { @@ -159,7 +159,7 @@ class UserExtractController( _ <- mailService.sendDownloadedFile(extractTask.email, downloadedFileUrl.toString) taskUpdateEndedDate: UserExtractTask <- Future { extractTask.copy( - endedAt = Some(DateTime.now(DateTimeZone.UTC)), + endedAt = Some(LocalDateTime.now(Clock.systemUTC)), uploadStartedAt = Some(startUploadAt) ) } diff --git a/nio-server/app/db/CatchupLockMongoDatastore.scala b/nio-server/app/db/CatchupLockMongoDatastore.scala index 3744ada8..d60a35a6 100644 --- a/nio-server/app/db/CatchupLockMongoDatastore.scala +++ b/nio-server/app/db/CatchupLockMongoDatastore.scala @@ -1,7 +1,8 @@ package db -import akka.http.scaladsl.util.FastFuture -import org.joda.time.DateTime +import org.apache.pekko.http.scaladsl.util.FastFuture + +import java.time.{Clock, Instant, LocalDateTime, ZoneId} import utils.NioLogger import play.api.libs.json._ import play.modules.reactivemongo.ReactiveMongoApi @@ -11,7 +12,7 @@ import reactivemongo.api.bson.collection.BSONCollection import scala.concurrent.{ExecutionContext, Future} import scala.util.Try -import scala.collection.{immutable, Seq} +import scala.collection.{Seq, immutable} class CatchupLockMongoDatastore(val reactiveMongoApi: ReactiveMongoApi)(implicit val ec: ExecutionContext) extends DataStoreUtils { @@ -74,7 +75,7 @@ class CatchupLockMongoDatastore(val reactiveMongoApi: ReactiveMongoApi)(implicit ) } -case class CatchupLock(tenant: String, expireAt: DateTime = DateTime.now) +case class CatchupLock(tenant: String, expireAt: LocalDateTime = LocalDateTime.now) object CatchupLock { implicit val catchupLockFormats: Format[CatchupLock] = @@ -97,11 +98,15 @@ object CatchupLock { ) } - implicit val jodaDateFormat = new Format[org.joda.time.DateTime] { - override def reads(d: JsValue): JsResult[DateTime] = - JsSuccess(new DateTime(d.as[JsObject].\("$date").as[JsNumber].value.toLong)) + implicit val jodaDateFormat = new Format[LocalDateTime] { + override def reads(d: JsValue): JsResult[LocalDateTime] = + JsSuccess(Instant + .ofEpochMilli(d.as[JsObject].\("$date").as[JsNumber].value.toLong) + .atZone(ZoneId.systemDefault()) + .toLocalDateTime + ) - override def writes(d: DateTime): JsValue = - JsObject(Seq("$date" -> JsNumber(d.getMillis))) + override def writes(d: LocalDateTime): JsValue = + JsObject(Seq("$date" -> JsNumber(d.atZone(ZoneId.systemDefault()).toInstant.toEpochMilli))) } } diff --git a/nio-server/app/db/ExtractionTaskMongoDataStore.scala b/nio-server/app/db/ExtractionTaskMongoDataStore.scala index 630adf83..ae47ca0d 100644 --- a/nio-server/app/db/ExtractionTaskMongoDataStore.scala +++ b/nio-server/app/db/ExtractionTaskMongoDataStore.scala @@ -1,12 +1,12 @@ package db -import akka.stream.Materializer -import akka.stream.scaladsl.Source +import org.apache.pekko.stream.Materializer +import org.apache.pekko.stream.scaladsl.Source import cats.implicits.toShow import models.ExtractionTask import play.api.libs.json._ import play.modules.reactivemongo.ReactiveMongoApi -import reactivemongo.akkastream.{cursorProducer, State} +import reactivemongo.pekkostream.{cursorProducer, State} import reactivemongo.api.indexes.{Index, IndexType} import scala.concurrent.{ExecutionContext, Future} diff --git a/nio-server/app/db/LastConsentFactMongoDataStore.scala b/nio-server/app/db/LastConsentFactMongoDataStore.scala index b3106305..1cd68cf6 100644 --- a/nio-server/app/db/LastConsentFactMongoDataStore.scala +++ b/nio-server/app/db/LastConsentFactMongoDataStore.scala @@ -1,16 +1,16 @@ package db -import akka.http.scaladsl.util.FastFuture -import akka.stream._ -import akka.stream.scaladsl.{Sink, Source} -import akka.util.ByteString +import org.apache.pekko.http.scaladsl.util.FastFuture +import org.apache.pekko.stream._ +import org.apache.pekko.stream.scaladsl.{Sink, Source} +import org.apache.pekko.util.ByteString import controllers.AppErrorWithStatus import models._ import utils.NioLogger import play.api.libs.json.{JsValue, Json, OFormat} import play.api.mvc.Results.NotFound import play.modules.reactivemongo.ReactiveMongoApi -import reactivemongo.akkastream.cursorProducer +import reactivemongo.pekkostream.cursorProducer import reactivemongo.api.{Cursor, ReadPreference} import reactivemongo.api.bson.collection.BSONCollection import reactivemongo.api.indexes.{Index, IndexType} @@ -26,7 +26,7 @@ class LastConsentFactMongoDataStore(val mongoApi: ReactiveMongoApi)(implicit val import reactivemongo.api.bson._ import reactivemongo.play.json.compat._ - import reactivemongo.akkastream._ + import reactivemongo.pekkostream._ import lax._ import bson2json._ import json2bson._ @@ -165,7 +165,7 @@ class LastConsentFactMongoDataStore(val mongoApi: ReactiveMongoApi)(implicit val def streamAll(tenant: String, pageSize: Int, parallelisation: Int)(implicit m: Materializer - ): Source[JsValue, akka.NotUsed] = + ): Source[JsValue, org.apache.pekko.NotUsed] = Source .future(storedCollection(tenant)) .mapAsync(1)(coll => coll.count().map(c => (coll, c))) @@ -199,7 +199,7 @@ class LastConsentFactMongoDataStore(val mongoApi: ReactiveMongoApi)(implicit val def streamAllBSON(tenant: String, pageSize: Int, parallelisation: Int)(implicit m: Materializer - ): Source[ByteString, akka.NotUsed] = + ): Source[ByteString, org.apache.pekko.NotUsed] = Source .future(storedBSONCollection(tenant)) .mapAsync(1)(coll => coll.count().map(c => (coll, c))) diff --git a/nio-server/app/db/MongoDataStore.scala b/nio-server/app/db/MongoDataStore.scala index 5817f97e..fa88f168 100644 --- a/nio-server/app/db/MongoDataStore.scala +++ b/nio-server/app/db/MongoDataStore.scala @@ -1,8 +1,8 @@ package db -import akka.http.scaladsl.util.FastFuture -import akka.stream.Materializer -import akka.stream.scaladsl.Source +import org.apache.pekko.http.scaladsl.util.FastFuture +import org.apache.pekko.stream.Materializer +import org.apache.pekko.stream.scaladsl.Source import play.api.libs.json._ import play.modules.reactivemongo.ReactiveMongoApi import reactivemongo.api.indexes.Index @@ -26,7 +26,7 @@ trait MongoDataStore[T] { import Request.ImprovedRequest import reactivemongo.api.bson._ import reactivemongo.play.json.compat._ - import reactivemongo.akkastream._ + import reactivemongo.pekkostream._ import bson2json._ import json2bson._ diff --git a/nio-server/app/db/MongoOpsDataStore.scala b/nio-server/app/db/MongoOpsDataStore.scala index 5a0bc535..1615f3d5 100644 --- a/nio-server/app/db/MongoOpsDataStore.scala +++ b/nio-server/app/db/MongoOpsDataStore.scala @@ -1,7 +1,7 @@ package db -import akka.stream.Materializer -import akka.stream.scaladsl.Source +import org.apache.pekko.stream.Materializer +import org.apache.pekko.stream.scaladsl.Source import reactivemongo.api.{Cursor, ReadPreference} import reactivemongo.api.bson.collection.BSONCollection @@ -15,7 +15,7 @@ object MongoOpsDataStore { import play.api.libs.json._ import reactivemongo.api.bson._ import reactivemongo.play.json.compat._ - import reactivemongo.akkastream._ + import reactivemongo.pekkostream._ def insertOne[T](objToInsert: T)(implicit oformat: OFormat[T]): Future[Boolean] = { import json2bson._ diff --git a/nio-server/app/db/OrganisationMongoDataStore.scala b/nio-server/app/db/OrganisationMongoDataStore.scala index a2cb159c..6dda2527 100644 --- a/nio-server/app/db/OrganisationMongoDataStore.scala +++ b/nio-server/app/db/OrganisationMongoDataStore.scala @@ -1,13 +1,13 @@ package db -import akka.http.scaladsl.util.FastFuture -import akka.stream.Materializer +import org.apache.pekko.http.scaladsl.util.FastFuture +import org.apache.pekko.stream.Materializer import controllers.AppErrorWithStatus import models._ import utils.NioLogger import play.api.libs.json._ import play.modules.reactivemongo.ReactiveMongoApi -import reactivemongo.akkastream.cursorProducer +import reactivemongo.pekkostream.cursorProducer import reactivemongo.api.indexes.{Index, IndexType} import utils.Result.{AppErrors, ErrorMessage} @@ -19,7 +19,7 @@ class OrganisationMongoDataStore(val mongoApi: ReactiveMongoApi)(implicit val ex import reactivemongo.api.bson._ import reactivemongo.play.json.compat._ - import reactivemongo.akkastream._ + import reactivemongo.pekkostream._ import lax._ import bson2json._ import json2bson._ diff --git a/nio-server/app/db/TenantMongoDataStore.scala b/nio-server/app/db/TenantMongoDataStore.scala index d7b5a11f..6d7fb6aa 100644 --- a/nio-server/app/db/TenantMongoDataStore.scala +++ b/nio-server/app/db/TenantMongoDataStore.scala @@ -15,7 +15,7 @@ class TenantMongoDataStore(val reactiveMongoApi: ReactiveMongoApi)(implicit val import reactivemongo.api.bson._ import reactivemongo.play.json.compat._ - import reactivemongo.akkastream._ + import reactivemongo.pekkostream._ import lax._ import bson2json._ import json2bson._ diff --git a/nio-server/app/db/UserMongoDataStore.scala b/nio-server/app/db/UserMongoDataStore.scala index ec0f007d..bd7dc3ef 100644 --- a/nio-server/app/db/UserMongoDataStore.scala +++ b/nio-server/app/db/UserMongoDataStore.scala @@ -1,7 +1,7 @@ package db -import akka.stream.Materializer -import akka.stream.scaladsl.Source +import org.apache.pekko.stream.Materializer +import org.apache.pekko.stream.scaladsl.Source import models._ import play.api.libs.json.{JsValue, Json, OFormat} import play.modules.reactivemongo.ReactiveMongoApi @@ -15,7 +15,7 @@ class UserMongoDataStore(val mongoApi: ReactiveMongoApi)(implicit val executionC import reactivemongo.api.bson._ import reactivemongo.play.json.compat._ - import reactivemongo.akkastream._ + import reactivemongo.pekkostream._ import lax._ import bson2json._ import json2bson._ diff --git a/nio-server/app/filters/Auth0Filter.scala b/nio-server/app/filters/Auth0Filter.scala index 20cbfd7e..5b188110 100644 --- a/nio-server/app/filters/Auth0Filter.scala +++ b/nio-server/app/filters/Auth0Filter.scala @@ -2,7 +2,7 @@ package filters import java.util.Base64 -import akka.stream.Materializer +import org.apache.pekko.stream.Materializer import auth.AuthInfo import com.auth0.jwt.JWT import com.auth0.jwt.algorithms.Algorithm diff --git a/nio-server/app/filters/NioDefaultFilter.scala b/nio-server/app/filters/NioDefaultFilter.scala index 71468e82..757f1ef0 100644 --- a/nio-server/app/filters/NioDefaultFilter.scala +++ b/nio-server/app/filters/NioDefaultFilter.scala @@ -2,7 +2,7 @@ package filters import java.util.Base64 -import akka.stream.Materializer +import org.apache.pekko.stream.Materializer import auth.AuthInfo import com.auth0.jwt.JWT import com.auth0.jwt.algorithms.Algorithm diff --git a/nio-server/app/filters/OtoroshiFilter.scala b/nio-server/app/filters/OtoroshiFilter.scala index 0384109d..1651133a 100644 --- a/nio-server/app/filters/OtoroshiFilter.scala +++ b/nio-server/app/filters/OtoroshiFilter.scala @@ -1,6 +1,6 @@ package filters -import akka.stream.Materializer +import org.apache.pekko.stream.Materializer import auth.AuthInfo import com.auth0.jwt._ import com.auth0.jwt.algorithms.Algorithm diff --git a/nio-server/app/libs/xml/XmlParser.scala b/nio-server/app/libs/xml/XmlParser.scala index 876912e2..16ea25ce 100644 --- a/nio-server/app/libs/xml/XmlParser.scala +++ b/nio-server/app/libs/xml/XmlParser.scala @@ -1,17 +1,15 @@ package libs.xml -import java.util.concurrent.atomic.{AtomicInteger, AtomicReference} - import cats.data.Validated import libs.xml.syntax.XmlResult -import org.joda.time.DateTime -import org.joda.time.format.DateTimeFormatter -import utils.DateUtils -import utils.Result.{AppErrors, ErrorMessage} +import utils.Result.AppErrors +import java.time.LocalDateTime +import java.time.format.DateTimeFormatter +import java.util.concurrent.atomic.AtomicInteger +import scala.collection.Seq import scala.util.Try import scala.xml.{Elem, NodeSeq} -import scala.collection.Seq object syntax { import cats.implicits._ @@ -101,16 +99,16 @@ object implicits { .map(_.valid) .getOrElse(buildError(path).invalid) - implicit def defaultReadDateTime: XMLRead[DateTime] = - readDateTime(DateUtils.utcDateFormatter) + implicit def defaultReadDateTime: XMLRead[LocalDateTime] = + readDateTime(DateTimeFormatter.ISO_LOCAL_DATE_TIME) - def readDateTime(dateTimeFormatter: DateTimeFormatter): XMLRead[DateTime] = + def readDateTime(dateTimeFormatter: DateTimeFormatter): XMLRead[LocalDateTime] = (xml: NodeSeq, path: Option[String]) => Try(xml.head.text) .map(_.valid) .getOrElse(buildError(path).invalid) .andThen { t => - Try(dateTimeFormatter.parseDateTime(t)) + Try(LocalDateTime.parse(t, dateTimeFormatter)) .map(_.valid) .getOrElse(AppErrors.error(s"parse.error${toPath(path)}").invalid) } diff --git a/nio-server/app/loader/NioLoader.scala b/nio-server/app/loader/NioLoader.scala index e6c4b3bd..08663489 100644 --- a/nio-server/app/loader/NioLoader.scala +++ b/nio-server/app/loader/NioLoader.scala @@ -2,8 +2,8 @@ package loader import java.security.SecureRandom -import akka.actor.ActorSystem -import akka.http.scaladsl.util.FastFuture +import org.apache.pekko.actor.ActorSystem +import org.apache.pekko.http.scaladsl.util.FastFuture import auth._ import com.softwaremill.macwire.wire import configuration._ diff --git a/nio-server/app/loader/Starter.scala b/nio-server/app/loader/Starter.scala index 01918e7d..0e785193 100644 --- a/nio-server/app/loader/Starter.scala +++ b/nio-server/app/loader/Starter.scala @@ -2,10 +2,10 @@ package loader import java.util.concurrent.TimeUnit -import akka.actor.ActorSystem -import akka.http.scaladsl.util.FastFuture -import akka.japi.Option.Some -import akka.stream.Materializer +import org.apache.pekko.actor.ActorSystem +import org.apache.pekko.http.scaladsl.util.FastFuture +import org.apache.pekko.japi.Option.Some +import org.apache.pekko.stream.Materializer import configuration.Env import db.{UserExtractTaskDataStore, _} import models.{NioAccount, Tenant} diff --git a/nio-server/app/messaging/Kafka.scala b/nio-server/app/messaging/Kafka.scala index 450d67c6..2f900aa4 100644 --- a/nio-server/app/messaging/Kafka.scala +++ b/nio-server/app/messaging/Kafka.scala @@ -2,7 +2,7 @@ package messaging import java.io.File -import akka.actor.ActorSystem +import org.apache.pekko.actor.ActorSystem import configuration.KafkaConfig import org.apache.kafka.clients.CommonClientConfigs import org.apache.kafka.common.config.internals.BrokerSecurityConfigs @@ -13,7 +13,7 @@ import org.apache.kafka.common.serialization.{ object KafkaSettings { - import akka.kafka.{ConsumerSettings, ProducerSettings} + import org.apache.pekko.kafka.{ConsumerSettings, ProducerSettings} import org.apache.kafka.clients.consumer.ConsumerConfig import org.apache.kafka.common.config.SslConfigs import org.apache.kafka.common.serialization.ByteArrayDeserializer diff --git a/nio-server/app/messaging/KafkaMessageBroker.scala b/nio-server/app/messaging/KafkaMessageBroker.scala index e02b7de8..a721ccce 100644 --- a/nio-server/app/messaging/KafkaMessageBroker.scala +++ b/nio-server/app/messaging/KafkaMessageBroker.scala @@ -2,14 +2,14 @@ package messaging import java.io.Closeable import java.security.MessageDigest -import akka.actor.ActorSystem -import akka.kafka.ConsumerMessage.CommittableOffsetBatch -import akka.kafka.{CommitterSettings, ConsumerMessage, ProducerSettings, Subscriptions} -import akka.kafka.scaladsl.{Committer, Consumer} -import akka.stream.Materializer -import akka.stream.scaladsl.Keep.both -import akka.stream.scaladsl.{Flow, Source} -import akka.{Done, NotUsed} +import org.apache.pekko.actor.ActorSystem +import org.apache.pekko.kafka.ConsumerMessage.CommittableOffsetBatch +import org.apache.pekko.kafka.{CommitterSettings, ConsumerMessage, ProducerSettings, Subscriptions} +import org.apache.pekko.kafka.scaladsl.{Committer, Consumer} +import org.apache.pekko.stream.Materializer +import org.apache.pekko.stream.scaladsl.Keep.both +import org.apache.pekko.stream.scaladsl.{Flow, Source} +import org.apache.pekko.{Done, NotUsed} import configuration.{Env, KafkaConfig} import models.{Digest, NioEvent, SecuredEvent} import org.apache.kafka.clients.producer.{Callback, KafkaProducer, Producer, ProducerRecord, RecordMetadata} diff --git a/nio-server/app/models/Account.scala b/nio-server/app/models/Account.scala index 0784f520..df0523a6 100644 --- a/nio-server/app/models/Account.scala +++ b/nio-server/app/models/Account.scala @@ -7,7 +7,7 @@ import libs.xml.XMLRead import libs.xml.XmlUtil.XmlCleaner import libs.xml.implicits._ import libs.xml.syntax._ -import org.joda.time.{DateTime, DateTimeZone} +import java.time.{LocalDateTime, Clock} import play.api.libs.functional.syntax.{unlift, _} import play.api.libs.json.Reads._ import play.api.libs.json.{JsValue, _} @@ -61,7 +61,7 @@ object OrganisationUser { case class Account( accountId: String, - lastUpdate: DateTime = DateTime.now(DateTimeZone.UTC), + lastUpdate: LocalDateTime = LocalDateTime.now(Clock.systemUTC), organisationsUsers: Seq[OrganisationUser] ) extends ModelTransformAs { override def asXml(): Elem = @@ -69,7 +69,7 @@ case class Account( {accountId} - {lastUpdate.toString(DateUtils.utcDateFormatter)} + {lastUpdate.format(DateUtils.utcDateFormatter)} {organisationsUsers.map(_.asXml())} @@ -84,14 +84,14 @@ object Account extends ReadableEntity[Account] { implicit val read: Reads[Account] = ( (__ \ "accountId").read[String] and (__ \ "lastUpdate") - .readWithDefault[DateTime](DateTime.now(DateTimeZone.UTC))(DateUtils.utcDateTimeReads) and + .readWithDefault[LocalDateTime](LocalDateTime.now(Clock.systemUTC))(DateUtils.utcDateTimeReads) and (__ \ "organisationsUsers").read[Seq[OrganisationUser]] )(Account.apply _) implicit val write: OWrites[Account] = ( (JsPath \ "accountId").write[String] and (JsPath \ "lastUpdate") - .write[DateTime](DateUtils.utcDateTimeWrites) and + .write[LocalDateTime](DateUtils.utcDateTimeWrites) and (JsPath \ "organisationsUsers").write[Seq[OrganisationUser]] )(unlift(Account.unapply)) diff --git a/nio-server/app/models/ConsentFact.scala b/nio-server/app/models/ConsentFact.scala index 2f9747c7..7c1ac523 100644 --- a/nio-server/app/models/ConsentFact.scala +++ b/nio-server/app/models/ConsentFact.scala @@ -7,7 +7,6 @@ import libs.xml.XMLRead import libs.xml.XmlUtil.XmlCleaner import libs.xml.implicits._ import libs.xml.syntax._ -import org.joda.time.{DateTime, DateTimeZone} import play.api.libs.functional.syntax.{unlift, _} import play.api.libs.json.Reads._ import play.api.libs.json._ @@ -17,6 +16,8 @@ import utils.Result.AppErrors import utils.Result.AppErrors._ import utils.json.JsResultOps +import java.time.format.DateTimeFormatter +import java.time.{Clock, LocalDateTime} import scala.xml.{Elem, NodeSeq} import scala.collection.Seq @@ -112,7 +113,7 @@ case class ConsentOffer( key: String, label: String, version: Int, - lastUpdate: DateTime = DateTime.now(DateTimeZone.UTC), + lastUpdate: LocalDateTime = LocalDateTime.now(Clock.systemUTC()), groups: Seq[ConsentGroup] ) extends ModelTransformAs { override def asXml(): Elem = @@ -126,7 +127,7 @@ case class ConsentOffer( {version} - {lastUpdate.toString(DateUtils.utcDateFormatter)} + {lastUpdate.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)} {groups.map(_.asXml())} @@ -141,7 +142,7 @@ object ConsentOffer extends ReadableEntity[ConsentOffer] { (__ \ "key").read[String] and (__ \ "label").read[String] and (__ \ "version").read[Int] and - (__ \ "lastUpdate").readWithDefault[DateTime](DateTime.now(DateTimeZone.UTC))(DateUtils.utcDateTimeReads) and + (__ \ "lastUpdate").readWithDefault[LocalDateTime](LocalDateTime.now(Clock.systemUTC()))(DateUtils.utcDateTimeReads) and (__ \ "groups").read[Seq[ConsentGroup]] )(ConsentOffer.apply _) @@ -149,7 +150,7 @@ object ConsentOffer extends ReadableEntity[ConsentOffer] { (__ \ "key").write[String] and (__ \ "label").write[String] and (__ \ "version").write[Int] and - (__ \ "lastUpdate").write[DateTime](DateUtils.utcDateTimeWrites) and + (__ \ "lastUpdate").write[LocalDateTime](DateUtils.utcDateTimeWrites) and (__ \ "groups").write[Seq[ConsentGroup]] )(unlift(ConsentOffer.unapply)) @@ -157,7 +158,7 @@ object ConsentOffer extends ReadableEntity[ConsentOffer] { (__ \ "key").write[String] and (__ \ "label").write[String] and (__ \ "version").write[Int] and - (__ \ "lastUpdate").write[DateTime](DateUtils.utcDateTimeWrites) and + (__ \ "lastUpdate").write[LocalDateTime](DateUtils.utcDateTimeWrites) and (__ \ "groups").write[Seq[ConsentGroup]] )(unlift(ConsentOffer.unapply)) @@ -171,7 +172,7 @@ object ConsentOffer extends ReadableEntity[ConsentOffer] { (node \ "key").validate[String](Some(s"${path.convert()}key")), (node \ "label").validate[String](Some(s"${path.convert()}label")), (node \ "version").validate[Int](Some(s"${path.convert()}version")), - (node \ "lastUpdate").validate[DateTime](Some(s"${path.convert()}lastUpdate")), + (node \ "lastUpdate").validate[LocalDateTime](Some(s"${path.convert()}lastUpdate")), (node \ "groups").validate[Seq[ConsentGroup]](Some(s"${path.convert()}groups")) ).mapN((key, label, version, lastUpdate, groups) => ConsentOffer(key, label, version, lastUpdate, groups)) @@ -245,7 +246,7 @@ object PartialConsentGroup { ).mapN((key, label, consents) => PartialConsentGroup(key, label, consents)) } -case class PartialConsentOffer(key: String, label: Option[String], lastUpdate: Option[DateTime], version: Option[Int], groups: Option[Seq[PartialConsentGroup]]) +case class PartialConsentOffer(key: String, label: Option[String], lastUpdate: Option[LocalDateTime], version: Option[Int], groups: Option[Seq[PartialConsentGroup]]) object PartialConsentOffer { def merge(partialOffers: Seq[PartialConsentOffer], existingOffers: Option[Seq[ConsentOffer]]): Option[Seq[ConsentOffer]] = { @@ -268,7 +269,7 @@ object PartialConsentOffer { key = po.key, label = po.label.getOrElse(""), version = po.version.getOrElse(0), - lastUpdate = po.lastUpdate.getOrElse(DateTime.now(DateTimeZone.UTC)), + lastUpdate = po.lastUpdate.getOrElse(LocalDateTime.now(Clock.systemUTC)), groups = po.groups.toList.flatten.map(pg => ConsentGroup( key = pg.key, label = pg.label.getOrElse(""), @@ -290,7 +291,7 @@ object PartialConsentOffer { ( (node \ "key").validate[String](Some(s"${path.convert()}key")), (node \ "label").validateNullable[String](Some(s"${path.convert()}label")), - (node \ "lastUpdate").validateNullable[DateTime](Some(s"${path.convert()}lastUpdate")), + (node \ "lastUpdate").validateNullable[LocalDateTime](Some(s"${path.convert()}lastUpdate")), (node \ "version").validateNullable[Int](Some(s"${path.convert()}version")), (node \ "groups").validateNullable[Seq[PartialConsentGroup]](Some(s"${path.convert()}consents")) ).mapN((key, label, lastUpdate, version, groups) => PartialConsentOffer(key, label, lastUpdate, version, groups)) @@ -300,7 +301,7 @@ case class PartialConsentFact( userId: Option[String] = None, doneBy: Option[DoneBy] = None, version: Option[Int] = None, - lastUpdate: Option[DateTime] = None, + lastUpdate: Option[LocalDateTime] = None, groups: Option[Seq[PartialConsentGroup]] = None, offers: Option[Seq[PartialConsentOffer]] = None, orgKey: Option[String] = None, @@ -313,7 +314,7 @@ case class PartialConsentFact( doneBy = doneBy.getOrElse(lastConsentFact.doneBy), version = version.getOrElse(currentVersion.num), lastUpdate = lastUpdate.getOrElse(lastConsentFact.lastUpdate), - lastUpdateSystem = DateTime.now(DateTimeZone.UTC), + lastUpdateSystem = LocalDateTime.now(Clock.systemUTC), groups = groups.map(g => PartialConsentGroup.merge(g, lastConsentFact.groups)).getOrElse(lastConsentFact.groups), offers = offers.map(o => PartialConsentOffer.merge(o, lastConsentFact.offers)).getOrElse(lastConsentFact.offers), orgKey = orgKey.orElse(lastConsentFact.orgKey), @@ -339,7 +340,7 @@ object PartialConsentFact extends ReadableEntity[PartialConsentFact] { (node \ "userId").validateNullable[String](Some(s"${path.convert()}userId")), (node \ "doneBy").validateNullable[DoneBy](Some(s"${path.convert()}doneBy")), (node \ "version").validateNullable[Int](Some(s"${path.convert()}version")), - (node \ "lastUpdate").validateNullable[DateTime](Some(s"${path.convert()}lastUpdate")), + (node \ "lastUpdate").validateNullable[LocalDateTime](Some(s"${path.convert()}lastUpdate")), (node \ "groups").validateNullable[Seq[PartialConsentGroup]](Some(s"${path.convert()}consents")), (node \ "offers").validateNullable[Seq[PartialConsentOffer]](Some(s"${path.convert()}offers")), (node \ "orgKey").validateNullable[String](Some(s"${path.convert()}orgKey")), @@ -373,8 +374,8 @@ case class ConsentFact( version: Int, groups: Seq[ConsentGroup], offers: Option[Seq[ConsentOffer]] = None, - lastUpdate: DateTime = DateTime.now(DateTimeZone.UTC), - lastUpdateSystem: DateTime = DateTime.now(DateTimeZone.UTC), + lastUpdate: LocalDateTime = LocalDateTime.now(Clock.systemUTC), + lastUpdateSystem: LocalDateTime = LocalDateTime.now(Clock.systemUTC), orgKey: Option[String] = None, metaData: Option[Map[String, String]] = None, sendToKafka: Option[Boolean] = None @@ -422,7 +423,7 @@ case class ConsentFact( } } - {lastUpdate.toString(DateUtils.utcDateFormatter)} + {lastUpdate.format(DateUtils.utcDateFormatter)} {orgKey.getOrElse("")} @@ -444,7 +445,7 @@ object ConsentFact extends ReadableEntity[ConsentFact] { version: Int, groups: Seq[ConsentGroup], offers: Option[Seq[ConsentOffer]] = None, - lastUpdate: DateTime = DateTime.now(DateTimeZone.UTC), + lastUpdate: LocalDateTime = LocalDateTime.now(Clock.systemUTC), orgKey: Option[String] = None, metaData: Option[Map[String, String]] = None, sendToKafka: Option[Boolean] = None @@ -468,8 +469,8 @@ object ConsentFact extends ReadableEntity[ConsentFact] { version: Int, groups: Seq[ConsentGroup], offers: Option[Seq[ConsentOffer]] = None, - lastUpdate: DateTime = DateTime.now(DateTimeZone.UTC), - lastUpdateSystem: DateTime = DateTime.now(DateTimeZone.UTC), + lastUpdate: LocalDateTime = LocalDateTime.now(Clock.systemUTC), + lastUpdateSystem: LocalDateTime = LocalDateTime.now(Clock.systemUTC), orgKey: Option[String] = None, metaData: Option[Map[String, String]] = None ) = @@ -492,7 +493,7 @@ object ConsentFact extends ReadableEntity[ConsentFact] { (__ \ "version").read[Int] and (__ \ "groups").read[Seq[ConsentGroup]] and (__ \ "offers").readNullable[Seq[ConsentOffer]] and - (__ \ "lastUpdate").readWithDefault[DateTime](DateTime.now(DateTimeZone.UTC))(DateUtils.utcDateTimeReads) and + (__ \ "lastUpdate").readWithDefault[LocalDateTime](LocalDateTime.now(Clock.systemUTC))(DateUtils.utcDateTimeReads) and (__ \ "orgKey").readNullable[String] and (__ \ "metaData").readNullable[Map[String, String]] and (__ \ "sendToKafka").readNullable[Boolean] @@ -505,8 +506,8 @@ object ConsentFact extends ReadableEntity[ConsentFact] { (__ \ "version").read[Int] and (__ \ "groups").read[Seq[ConsentGroup]] and (__ \ "offers").readNullable[Seq[ConsentOffer]] and - (__ \ "lastUpdate").read[DateTime](DateUtils.utcDateTimeReads) and - (__ \ "lastUpdateSystem").read[DateTime](DateUtils.utcDateTimeReads) and + (__ \ "lastUpdate").read[LocalDateTime](DateUtils.utcDateTimeReads) and + (__ \ "lastUpdateSystem").read[LocalDateTime](DateUtils.utcDateTimeReads) and (__ \ "orgKey").readNullable[String] and (__ \ "metaData").readNullable[Map[String, String]] )(ConsentFact.newWithoutKafkaFlag _) @@ -519,9 +520,9 @@ object ConsentFact extends ReadableEntity[ConsentFact] { (JsPath \ "groups").write[Seq[ConsentGroup]] and (JsPath \ "offers").writeNullable[Seq[ConsentOffer]] and (JsPath \ "lastUpdate") - .write[DateTime](DateUtils.utcDateTimeWrites) and + .write[LocalDateTime](DateUtils.utcDateTimeWrites) and (JsPath \ "lastUpdateSystem") - .write[DateTime](DateUtils.utcDateTimeWrites) and + .write[LocalDateTime](DateUtils.utcDateTimeWrites) and (JsPath \ "orgKey").writeNullable[String] and (JsPath \ "metaData").writeNullable[Map[String, String]] and (JsPath \ "sendToKafka").writeNullable[Boolean] @@ -535,10 +536,10 @@ object ConsentFact extends ReadableEntity[ConsentFact] { (JsPath \ "groups").write[Seq[ConsentGroup]] and (JsPath \ "offers").writeNullable[Seq[ConsentOffer]] and (JsPath \ "lastUpdate") - .write[DateTime](DateUtils.utcDateTimeWrites) and + .write[LocalDateTime](DateUtils.utcDateTimeWrites) and (JsPath \ "lastUpdateSystem") - .writeNullable[DateTime](DateUtils.utcDateTimeWrites) - .contramap((_: DateTime) => None) and + .writeNullable[LocalDateTime](DateUtils.utcDateTimeWrites) + .contramap((_: LocalDateTime ) => None) and (JsPath \ "orgKey").writeNullable[String] and (JsPath \ "metaData").writeNullable[Map[String, String]] and (JsPath \ "sendToKafka").writeNullable[Boolean] @@ -552,9 +553,9 @@ object ConsentFact extends ReadableEntity[ConsentFact] { (JsPath \ "groups").write[Seq[ConsentGroup]] and (JsPath \ "offers").writeNullable[Seq[ConsentOffer]] and (JsPath \ "lastUpdate") - .write[DateTime](DateUtils.utcDateTimeWrites) and + .write[LocalDateTime](DateUtils.utcDateTimeWrites) and (JsPath \ "lastUpdateSystem") - .write[DateTime](DateUtils.utcDateTimeWrites) and + .write[LocalDateTime](DateUtils.utcDateTimeWrites) and (JsPath \ "orgKey").writeNullable[String] and (JsPath \ "metaData").writeNullable[Map[String, String]] and (JsPath \ "sendToKafka").writeNullable[Boolean] @@ -573,7 +574,7 @@ object ConsentFact extends ReadableEntity[ConsentFact] { version = orgVerNum, groups = groups, offers = offers, - lastUpdate = DateTime.now(DateTimeZone.UTC), + lastUpdate = LocalDateTime.now(Clock.systemUTC), lastUpdateSystem = null, orgKey = Some(orgKey) ) @@ -585,7 +586,7 @@ object ConsentFact extends ReadableEntity[ConsentFact] { (node \ "userId").validate[String](Some(s"${path.convert()}userId")), (node \ "doneBy").validate[DoneBy](Some(s"${path.convert()}doneBy")), (node \ "lastUpdate") - .validateNullable[DateTime](DateTime.now(DateTimeZone.UTC), Some(s"${path.convert()}lastUpdate")), + .validateNullable[LocalDateTime](LocalDateTime.now(Clock.systemUTC), Some(s"${path.convert()}lastUpdate")), (node \ "orgKey").validateNullable[String](Some(s"${path.convert()}orgKey")), (node \ "version").validate[Int](Some(s"${path.convert()}version")), (node \ "groups").validate[Seq[ConsentGroup]](Some(s"${path.convert()}groups")), diff --git a/nio-server/app/models/DeletionTask.scala b/nio-server/app/models/DeletionTask.scala index 3e3613d0..b5e6803c 100644 --- a/nio-server/app/models/DeletionTask.scala +++ b/nio-server/app/models/DeletionTask.scala @@ -1,7 +1,7 @@ package models import models.DeletionTaskStatus.DeletionTaskStatus -import org.joda.time.{DateTime, DateTimeZone} +import java.time.{LocalDateTime, Clock} import play.api.libs.json._ import reactivemongo.api.bson.BSONObjectID import utils.DateUtils @@ -47,11 +47,11 @@ case class DeletionTask( _id: String, orgKey: String, userId: String, - startedAt: DateTime, + startedAt: LocalDateTime, appIds: Set[String], states: Set[AppDeletionState], status: DeletionTaskStatus, - lastUpdate: DateTime + lastUpdate: LocalDateTime ) extends ModelTransformAs { def copyWithAppDone(appId: String) = { @@ -67,21 +67,21 @@ case class DeletionTask( "id" -> _id, "orgKey" -> orgKey, "userId" -> userId, - "startedAt" -> startedAt.toString(DateUtils.utcDateFormatter), + "startedAt" -> startedAt.format(DateUtils.utcDateFormatter), "appIds" -> appIds, "states" -> states.map(_.asJson()), "status" -> status.toString, - "lastUpdate" -> startedAt.toString(DateUtils.utcDateFormatter) + "lastUpdate" -> startedAt.format(DateUtils.utcDateFormatter) ) def asXml() = {orgKey} {userId} - {startedAt.toString(DateUtils.utcDateFormatter)} + {startedAt.format(DateUtils.utcDateFormatter)} {appIds.map(appId => appId)} {states.map(_.asXml())} {status.toString} - {lastUpdate.toString(DateUtils.utcDateFormatter)} + {lastUpdate.format(DateUtils.utcDateFormatter)} .clean() } @@ -91,7 +91,7 @@ object DeletionTask { implicit val deletionTaskFormats = Json.format[DeletionTask] def newTask(orgKey: String, userId: String, appIds: Set[String]) = { - val now = DateTime.now(DateTimeZone.UTC) + val now = LocalDateTime.now(Clock.systemUTC) DeletionTask( BSONObjectID.generate().stringify, orgKey, diff --git a/nio-server/app/models/ExtractionTask.scala b/nio-server/app/models/ExtractionTask.scala index c5687129..7c421261 100644 --- a/nio-server/app/models/ExtractionTask.scala +++ b/nio-server/app/models/ExtractionTask.scala @@ -11,7 +11,7 @@ import libs.xml.implicits._ import libs.xml.syntax._ import messaging.KafkaMessageBroker import models.ExtractionTaskStatus.ExtractionTaskStatus -import org.joda.time.{DateTime, DateTimeZone} +import java.time.{LocalDateTime, Clock} import play.api.libs.json.Reads._ import play.api.libs.json._ import reactivemongo.api.bson.BSONObjectID @@ -136,11 +136,11 @@ case class ExtractionTask( _id: String, orgKey: String, userId: String, - startedAt: DateTime, + startedAt: LocalDateTime, appIds: Set[String], states: Set[AppState], status: ExtractionTaskStatus, - lastUpdate: DateTime, + lastUpdate: LocalDateTime, done: Int = 0 ) extends ModelTransformAs { @@ -149,12 +149,12 @@ case class ExtractionTask( "id" -> _id, "orgKey" -> orgKey, "userId" -> userId, - "startedAt" -> startedAt.toString(DateUtils.utcDateFormatter), + "startedAt" -> startedAt.format(DateUtils.utcDateFormatter), "appIds" -> appIds, "states" -> states.map(_.asJson()), "status" -> status.toString, "progress" -> progress, - "lastUpdate" -> lastUpdate.toString(DateUtils.utcDateFormatter), + "lastUpdate" -> lastUpdate.format(DateUtils.utcDateFormatter), "done" -> done ) @@ -162,12 +162,12 @@ case class ExtractionTask( {_id} {orgKey} {userId} - {startedAt.toString(DateUtils.utcDateFormatter)} + {startedAt.format(DateUtils.utcDateFormatter)} {appIds.map(appId => {appId})} {states.map(_.asXml())} {status} {progress} - {lastUpdate.toString(DateUtils.utcDateFormatter)} + {lastUpdate.format(DateUtils.utcDateFormatter)} {done} .clean() @@ -197,7 +197,7 @@ case class ExtractionTask( val newAppState = appState.copy(files = appExtractedFiles.files, totalBytes = sizeOfAllFiles) UploadTracker.addApp(this._id, appId) - copy(states = states.filterNot(_.appId == appId) + newAppState, lastUpdate = DateTime.now(DateTimeZone.UTC)) + copy(states = states.filterNot(_.appId == appId) + newAppState, lastUpdate = LocalDateTime.now(Clock.systemUTC)) } def copyWithFileUploadHandled(appId: String, appState: AppState) = { @@ -210,7 +210,7 @@ case class ExtractionTask( status = if (allWillBeDone) ExtractionTaskStatus.Done else ExtractionTaskStatus.Running, - lastUpdate = DateTime.now(DateTimeZone.UTC) + lastUpdate = LocalDateTime.now(Clock.systemUTC) ) } @@ -257,7 +257,7 @@ object ExtractionTask { implicit val fmt = Json.format[ExtractionTask] def newFrom(orgKey: String, userId: String, appIds: Set[String]) = { - val now = DateTime.now(DateTimeZone.UTC) + val now = LocalDateTime.now(Clock.systemUTC) ExtractionTask( _id = BSONObjectID.generate().stringify, orgKey = orgKey, diff --git a/nio-server/app/models/Organisation.scala b/nio-server/app/models/Organisation.scala index 97e5f95d..87403d4e 100644 --- a/nio-server/app/models/Organisation.scala +++ b/nio-server/app/models/Organisation.scala @@ -9,7 +9,7 @@ import libs.xml.XMLRead import libs.xml.XmlUtil.XmlCleaner import libs.xml.implicits._ import libs.xml.syntax._ -import org.joda.time.{DateTime, DateTimeZone} +import java.time.{LocalDateTime, Clock} import play.api.libs.functional.syntax.{unlift, _} import play.api.libs.json.Reads._ import play.api.libs.json._ @@ -25,9 +25,9 @@ case class VersionInfo( num: Int = 1, latest: Boolean = false, neverReleased: Option[Boolean] = Some(true), - lastUpdate: DateTime = DateTime.now(DateTimeZone.UTC) + lastUpdate: LocalDateTime = LocalDateTime.now(Clock.systemUTC) ) { - def copyUpdated = copy(lastUpdate = DateTime.now(DateTimeZone.UTC)) + def copyUpdated = copy(lastUpdate = LocalDateTime.now(Clock.systemUTC)) } object VersionInfo { @@ -37,7 +37,7 @@ object VersionInfo { "status" -> versionInfo.status, "num" -> versionInfo.num, "latest" -> versionInfo.latest, - "lastUpdate" -> versionInfo.lastUpdate.toString(DateUtils.utcDateFormatter) + "lastUpdate" -> versionInfo.lastUpdate.format(DateUtils.utcDateFormatter) ) } implicit val utcDateTimeFormats = DateUtils.utcDateTimeFormats @@ -50,7 +50,7 @@ object VersionInfo { (node \ "num").validate[Int](Some(s"${path.convert()}num")), (node \ "latest").validate[Boolean](Some(s"${path.convert()}latest")), (node \ "lastUpdate") - .validateNullable[DateTime](DateTime.now(DateTimeZone.UTC), Some(s"${path.convert()}lastUpdate")) + .validateNullable[LocalDateTime](LocalDateTime.now(Clock.systemUTC), Some(s"${path.convert()}lastUpdate")) ).mapN { (status, num, latest, lastUpdate) => VersionInfo(status = status, num = num, latest = latest, lastUpdate = lastUpdate) } @@ -85,7 +85,7 @@ case class Organisation( {version.latest} - {version.lastUpdate.toString(DateUtils.utcDateFormatter)} + {version.lastUpdate.format(DateUtils.utcDateFormatter)} @@ -286,7 +286,7 @@ case class Organisations(organisations: Seq[Organisation]) extends ModelTransfor object Organisations {} -case class VersionInfoLight(status: String, num: Int, lastUpdate: DateTime) +case class VersionInfoLight(status: String, num: Int, lastUpdate: LocalDateTime) case class OrganisationLight(key: String, label: String, version: VersionInfoLight) { def asXml() = @@ -304,7 +304,7 @@ case class OrganisationLight(key: String, label: String, version: VersionInfoLig {version.num} - {version.lastUpdate.toString(DateUtils.utcDateFormatter)} + {version.lastUpdate.format(DateUtils.utcDateFormatter)} .clean() @@ -316,7 +316,7 @@ case class OrganisationLight(key: String, label: String, version: VersionInfoLig "version" -> Json.obj( "status" -> version.status, "num" -> version.num, - "lastUpdate" -> version.lastUpdate.toString(DateUtils.utcDateFormatter) + "lastUpdate" -> version.lastUpdate.format(DateUtils.utcDateFormatter) ) ) } diff --git a/nio-server/app/models/UserExtractTask.scala b/nio-server/app/models/UserExtractTask.scala index 93ff596c..f218941d 100644 --- a/nio-server/app/models/UserExtractTask.scala +++ b/nio-server/app/models/UserExtractTask.scala @@ -6,7 +6,7 @@ import libs.xml.XMLRead import libs.xml.XmlUtil.XmlCleaner import libs.xml.implicits._ import libs.xml.syntax._ -import org.joda.time.{DateTime, DateTimeZone} +import java.time.{LocalDateTime, Clock} import play.api.libs.functional.syntax.{unlift, _} import play.api.libs.json.Reads._ import play.api.libs.json.Writes._ @@ -14,19 +14,20 @@ import play.api.libs.json._ import reactivemongo.api.bson.BSONObjectID import utils.Result.AppErrors import utils.{DateUtils, Result} -import scala.collection.Seq +import java.time.{Clock, LocalDateTime} +import scala.collection.Seq import scala.xml.{Elem, NodeSeq} case class UserExtractTask( - _id: String, - tenant: String, - orgKey: String, - userId: String, - email: String, - startedAt: DateTime, - uploadStartedAt: Option[DateTime], - endedAt: Option[DateTime] + _id: String, + tenant: String, + orgKey: String, + userId: String, + email: String, + startedAt: LocalDateTime, + uploadStartedAt: Option[LocalDateTime], + endedAt: Option[LocalDateTime] ) extends ModelTransformAs { override def asXml(): Elem = @@ -42,16 +43,16 @@ case class UserExtractTask( {email} - {startedAt.toString(DateUtils.utcDateFormatter)} + {startedAt.format(DateUtils.utcDateFormatter)} { uploadStartedAt.map(date => - {date.toString(DateUtils.utcDateFormatter)} + {date.format(DateUtils.utcDateFormatter)} ) } { endedAt.map(date => - {date.toString(DateUtils.utcDateFormatter)} + {date.format(DateUtils.utcDateFormatter)} ) } .clean() @@ -70,7 +71,7 @@ object UserExtractTask extends ReadableEntity[UserExtractTask] { orgKey = orgKey, userId = userId, email = email, - startedAt = DateTime.now(DateTimeZone.UTC), + startedAt = LocalDateTime.now(Clock.systemUTC), uploadStartedAt = None, endedAt = None ) @@ -83,11 +84,11 @@ object UserExtractTask extends ReadableEntity[UserExtractTask] { (__ \ "orgKey").read[String] and (__ \ "userId").read[String] and (__ \ "email").read[String] and - (__ \ "startedAt").readNullable[DateTime].map { maybeStartedAt => - maybeStartedAt.getOrElse(DateTime.now(DateTimeZone.UTC)) + (__ \ "startedAt").readNullable[LocalDateTime].map { maybeStartedAt => + maybeStartedAt.getOrElse(LocalDateTime.now(Clock.systemUTC)) } and - (__ \ "uploadStartedAt").readNullable[DateTime] and - (__ \ "endedAt").readNullable[DateTime] + (__ \ "uploadStartedAt").readNullable[LocalDateTime] and + (__ \ "endedAt").readNullable[LocalDateTime] )(UserExtractTask.apply _) implicit val userExtractTaskWrites: Writes[UserExtractTask] = ( @@ -96,9 +97,9 @@ object UserExtractTask extends ReadableEntity[UserExtractTask] { (JsPath \ "orgKey").write[String] and (JsPath \ "userId").write[String] and (JsPath \ "email").write[String] and - (JsPath \ "startedAt").write[DateTime] and - (JsPath \ "uploadStartedAt").writeNullable[DateTime] and - (JsPath \ "endedAt").writeNullable[DateTime] + (JsPath \ "startedAt").write[LocalDateTime] and + (JsPath \ "uploadStartedAt").writeNullable[LocalDateTime] and + (JsPath \ "endedAt").writeNullable[LocalDateTime] )(unlift(UserExtractTask.unapply)) implicit val userExtractTaskOWrites: OWrites[UserExtractTask] = ( @@ -107,9 +108,9 @@ object UserExtractTask extends ReadableEntity[UserExtractTask] { (JsPath \ "orgKey").write[String] and (JsPath \ "userId").write[String] and (JsPath \ "email").write[String] and - (JsPath \ "startedAt").write[DateTime] and - (JsPath \ "uploadStartedAt").writeNullable[DateTime] and - (JsPath \ "endedAt").writeNullable[DateTime] + (JsPath \ "startedAt").write[LocalDateTime] and + (JsPath \ "uploadStartedAt").writeNullable[LocalDateTime] and + (JsPath \ "endedAt").writeNullable[LocalDateTime] )(unlift(UserExtractTask.unapply)) implicit val format = Format(userExtractTaskReads, userExtractTaskWrites) @@ -124,9 +125,9 @@ object UserExtractTask extends ReadableEntity[UserExtractTask] { (node \ "userId").validate[String](Some(s"${path.convert()}userId")), (node \ "email").validate[String](Some(s"${path.convert()}email")), (node \ "startedAt") - .validateNullable[DateTime](DateTime.now(DateTimeZone.UTC), Some(s"${path.convert()}startedAt")), - (node \ "uploadStartedAt").validateNullable[DateTime](Some(s"${path.convert()}uploadStartedAt")), - (node \ "endedAt").validateNullable[DateTime](Some(s"${path.convert()}endedAt")) + .validateNullable[LocalDateTime](LocalDateTime.now(Clock.systemUTC), Some(s"${path.convert()}startedAt")), + (node \ "uploadStartedAt").validateNullable[LocalDateTime](Some(s"${path.convert()}uploadStartedAt")), + (node \ "endedAt").validateNullable[LocalDateTime](Some(s"${path.convert()}endedAt")) ).mapN((_id, tenant, orgKey, userId, email, startedAt, uploadStartedAt, endedAt) => UserExtractTask( _id = _id, diff --git a/nio-server/app/models/events.scala b/nio-server/app/models/events.scala index 73d47f4c..68398f7c 100644 --- a/nio-server/app/models/events.scala +++ b/nio-server/app/models/events.scala @@ -1,10 +1,13 @@ package models import models.OrganisationUser.{read, write} -import org.joda.time.{DateTime, DateTimeZone} +import java.time.{LocalDateTime, Clock} + +import java.time.{Clock, LocalDateTime} import utils.NioLogger import play.api.libs.json._ import utils.{DateUtils, IdGenerator} + import scala.collection.Seq object EventType extends Enumeration { @@ -118,7 +121,7 @@ object NioEvent { trait NioEvent { val id: Long - val date: DateTime + val date: LocalDateTime val tenant: String def `type`: EventType.Value @@ -156,12 +159,12 @@ object CleanUpMetadata { import CleanUpMetadata.CleanMetadata case class TenantCreated( - tenant: String, - author: String = "tenant-admin", - metadata: Option[Seq[(String, String)]] = None, - date: DateTime = DateTime.now(DateTimeZone.UTC), - id: Long = NioEvent.gen.nextId(), - payload: Tenant + tenant: String, + author: String = "tenant-admin", + metadata: Option[Seq[(String, String)]] = None, + date: LocalDateTime = LocalDateTime.now(Clock.systemUTC), + id: Long = NioEvent.gen.nextId(), + payload: Tenant ) extends NioEvent { def shardId = payload.key @@ -174,7 +177,7 @@ case class TenantCreated( "tenant" -> payload.key, "author" -> author, "metadata" -> buildMetadata(metadata), - "date" -> date.toString(DateUtils.utcDateFormatter), + "date" -> date.format(DateUtils.utcDateFormatter), "id" -> id, "payload" -> payload.asJson() ) @@ -185,7 +188,7 @@ case class TenantDeleted( tenant: String, author: String = "tenant-admin", metadata: Option[Seq[(String, String)]] = None, - date: DateTime = DateTime.now(DateTimeZone.UTC), + date: LocalDateTime = LocalDateTime.now(Clock.systemUTC), id: Long = NioEvent.gen.nextId(), payload: Tenant ) extends NioEvent { @@ -200,7 +203,7 @@ case class TenantDeleted( "tenant" -> payload.key, "author" -> author, "metadata" -> buildMetadata(metadata), - "date" -> date.toString(DateUtils.utcDateFormatter), + "date" -> date.format(DateUtils.utcDateFormatter), "id" -> id, "payload" -> payload.asJson() ) @@ -211,7 +214,7 @@ case class OrganisationCreated( tenant: String, author: String, metadata: Option[Seq[(String, String)]] = None, - date: DateTime = DateTime.now(DateTimeZone.UTC), + date: LocalDateTime = LocalDateTime.now(Clock.systemUTC), id: Long = NioEvent.gen.nextId(), payload: Organisation ) extends NioEvent { @@ -226,7 +229,7 @@ case class OrganisationCreated( "tenant" -> tenant, "author" -> author, "metadata" -> buildMetadata(metadata), - "date" -> date.toString(DateUtils.utcDateFormatter), + "date" -> date.format(DateUtils.utcDateFormatter), "id" -> id, "payload" -> payload.asJson() ) @@ -237,7 +240,7 @@ case class OrganisationUpdated( tenant: String, author: String, metadata: Option[Seq[(String, String)]] = None, - date: DateTime = DateTime.now(DateTimeZone.UTC), + date: LocalDateTime = LocalDateTime.now(Clock.systemUTC), id: Long = NioEvent.gen.nextId(), payload: Organisation, oldValue: Organisation @@ -253,7 +256,7 @@ case class OrganisationUpdated( "tenant" -> tenant, "author" -> author, "metadata" -> buildMetadata(metadata), - "date" -> date.toString(DateUtils.utcDateFormatter), + "date" -> date.format(DateUtils.utcDateFormatter), "id" -> id, "payload" -> payload.asJson(), "oldValue" -> oldValue.asJson() @@ -265,7 +268,7 @@ case class OrganisationReleased( tenant: String, author: String, metadata: Option[Seq[(String, String)]] = None, - date: DateTime = DateTime.now(DateTimeZone.UTC), + date: LocalDateTime = LocalDateTime.now(Clock.systemUTC), id: Long = NioEvent.gen.nextId(), payload: Organisation ) extends NioEvent { @@ -280,7 +283,7 @@ case class OrganisationReleased( "tenant" -> tenant, "author" -> author, "metadata" -> buildMetadata(metadata), - "date" -> date.toString(DateUtils.utcDateFormatter), + "date" -> date.format(DateUtils.utcDateFormatter), "id" -> id, "payload" -> payload.asJson() ) @@ -291,7 +294,7 @@ case class OrganisationDeleted( tenant: String, author: String, metadata: Option[Seq[(String, String)]] = None, - date: DateTime = DateTime.now(DateTimeZone.UTC), + date: LocalDateTime = LocalDateTime.now(Clock.systemUTC), id: Long = NioEvent.gen.nextId(), payload: Organisation ) extends NioEvent { @@ -306,7 +309,7 @@ case class OrganisationDeleted( "tenant" -> tenant, "author" -> author, "metadata" -> buildMetadata(metadata), - "date" -> date.toString(DateUtils.utcDateFormatter), + "date" -> date.format(DateUtils.utcDateFormatter), "id" -> id, "payload" -> payload.asJson() ) @@ -317,7 +320,7 @@ case class ConsentFactCreated( tenant: String, author: String, metadata: Option[Seq[(String, String)]] = None, - date: DateTime = DateTime.now(DateTimeZone.UTC), + date: LocalDateTime = LocalDateTime.now(Clock.systemUTC), id: Long = NioEvent.gen.nextId(), payload: ConsentFact, command: JsValue @@ -333,7 +336,7 @@ case class ConsentFactCreated( "tenant" -> tenant, "author" -> author, "metadata" -> buildMetadata(metadata), - "date" -> date.toString(DateUtils.utcDateFormatter), + "date" -> date.format(DateUtils.utcDateFormatter), "id" -> id, "payload" -> payload.asJson(), "command" -> command @@ -345,7 +348,7 @@ case class ConsentFactUpdated( tenant: String, author: String, metadata: Option[Seq[(String, String)]] = None, - date: DateTime = DateTime.now(DateTimeZone.UTC), + date: LocalDateTime = LocalDateTime.now(Clock.systemUTC), id: Long = NioEvent.gen.nextId(), payload: ConsentFact, oldValue: ConsentFact, @@ -362,7 +365,7 @@ case class ConsentFactUpdated( "tenant" -> tenant, "author" -> author, "metadata" -> buildMetadata(metadata), - "date" -> date.toString(DateUtils.utcDateFormatter), + "date" -> date.format(DateUtils.utcDateFormatter), "id" -> id, "payload" -> payload.asJson(), "oldValue" -> oldValue.asJson(), @@ -376,7 +379,7 @@ case class AccountDeleted( author: String, metadata: Option[Seq[(String, String)]] = None, id: Long = NioEvent.gen.nextId(), - date: DateTime = DateTime.now(DateTimeZone.UTC), + date: LocalDateTime = LocalDateTime.now(Clock.systemUTC), payload: Account ) extends NioEvent { def shardId = payload.accountId @@ -391,7 +394,7 @@ case class AccountDeleted( "author" -> author, "metadata" -> buildMetadata(metadata), "account" -> payload.accountId, - "date" -> date.toString(DateUtils.utcDateFormatter), + "date" -> date.format(DateUtils.utcDateFormatter), "id" -> id, "payload" -> payload.asJson() ) @@ -403,7 +406,7 @@ case class AccountCreated( author: String, metadata: Option[Seq[(String, String)]] = None, id: Long = NioEvent.gen.nextId(), - date: DateTime = DateTime.now(DateTimeZone.UTC), + date: LocalDateTime = LocalDateTime.now(Clock.systemUTC), payload: Account ) extends NioEvent { def shardId = payload.accountId @@ -418,7 +421,7 @@ case class AccountCreated( "author" -> author, "metadata" -> buildMetadata(metadata), "account" -> payload.accountId, - "date" -> date.toString(DateUtils.utcDateFormatter), + "date" -> date.format(DateUtils.utcDateFormatter), "id" -> id, "payload" -> payload.asJson() ) @@ -430,7 +433,7 @@ case class AccountUpdated( author: String, metadata: Option[Seq[(String, String)]] = None, id: Long = NioEvent.gen.nextId(), - date: DateTime = DateTime.now(DateTimeZone.UTC), + date: LocalDateTime = LocalDateTime.now(Clock.systemUTC), payload: Account, oldValue: Account ) extends NioEvent { @@ -446,7 +449,7 @@ case class AccountUpdated( "author" -> author, "metadata" -> buildMetadata(metadata), "account" -> payload.accountId, - "date" -> date.toString(DateUtils.utcDateFormatter), + "date" -> date.format(DateUtils.utcDateFormatter), "id" -> id, "payload" -> payload.asJson(), "oldValue" -> oldValue.asJson() @@ -456,7 +459,7 @@ case class AccountUpdated( case class SecuredEvent( id: Long = NioEvent.gen.nextId(), - date: DateTime = DateTime.now(DateTimeZone.UTC), + date: LocalDateTime = LocalDateTime.now(Clock.systemUTC), payload: Digest ) extends NioEvent { def `type` = EventType.SecuredEvent @@ -466,7 +469,7 @@ case class SecuredEvent( .obj( "type" -> `type`, "tenant" -> tenant, - "date" -> date.toString(DateUtils.utcDateFormatter), + "date" -> date.format(DateUtils.utcDateFormatter), "id" -> id, "payload" -> payload.digest ) @@ -482,7 +485,7 @@ case class DeletionStarted( author: String, metadata: Option[Seq[(String, String)]] = None, id: Long = NioEvent.gen.nextId(), - date: DateTime = DateTime.now(DateTimeZone.UTC), + date: LocalDateTime = LocalDateTime.now(Clock.systemUTC), payload: DeletionTaskInfoPerApp ) extends NioEvent { def shardId = payload.userId @@ -496,7 +499,7 @@ case class DeletionStarted( "tenant" -> tenant, "author" -> author, "metadata" -> buildMetadata(metadata), - "date" -> date.toString(DateUtils.utcDateFormatter), + "date" -> date.format(DateUtils.utcDateFormatter), "id" -> id, "payload" -> payload.asJson() ) @@ -508,7 +511,7 @@ case class DeletionAppDone( author: String, metadata: Option[Seq[(String, String)]] = None, id: Long = NioEvent.gen.nextId(), - date: DateTime = DateTime.now(DateTimeZone.UTC), + date: LocalDateTime = LocalDateTime.now(Clock.systemUTC), payload: AppDone ) extends NioEvent { def shardId = payload.userId @@ -522,7 +525,7 @@ case class DeletionAppDone( "tenant" -> tenant, "author" -> author, "metadata" -> buildMetadata(metadata), - "date" -> date.toString(DateUtils.utcDateFormatter), + "date" -> date.format(DateUtils.utcDateFormatter), "id" -> id, "payload" -> payload.asJson() ) @@ -534,7 +537,7 @@ case class DeletionFinished( author: String, metadata: Option[Seq[(String, String)]] = None, id: Long = NioEvent.gen.nextId(), - date: DateTime = DateTime.now(DateTimeZone.UTC), + date: LocalDateTime = LocalDateTime.now(Clock.systemUTC), payload: DeletionTask ) extends NioEvent { def shardId = payload.userId @@ -548,7 +551,7 @@ case class DeletionFinished( "tenant" -> tenant, "author" -> author, "metadata" -> buildMetadata(metadata), - "date" -> date.toString(DateUtils.utcDateFormatter), + "date" -> date.format(DateUtils.utcDateFormatter), "id" -> id, "payload" -> payload.asJson() ) @@ -560,7 +563,7 @@ case class UserExtractTaskAsked( author: String, metadata: Option[Seq[(String, String)]] = None, id: Long = NioEvent.gen.nextId(), - date: DateTime = DateTime.now(DateTimeZone.UTC), + date: LocalDateTime = LocalDateTime.now(Clock.systemUTC), payload: UserExtractTask ) extends NioEvent { override def `type`: EventType.Value = EventType.UserExtractTaskAsked @@ -572,7 +575,7 @@ case class UserExtractTaskAsked( "tenant" -> tenant, "author" -> author, "metadata" -> buildMetadata(metadata), - "date" -> date.toString(DateUtils.utcDateFormatter), + "date" -> date.format(DateUtils.utcDateFormatter), "id" -> id, "payload" -> payload.asJson() ) @@ -585,7 +588,7 @@ case class UserExtractTaskCompleted( author: String, metadata: Option[Seq[(String, String)]] = None, id: Long = NioEvent.gen.nextId(), - date: DateTime = DateTime.now(DateTimeZone.UTC), + date: LocalDateTime = LocalDateTime.now(Clock.systemUTC), payload: UserExtractTask ) extends NioEvent { override def `type`: EventType.Value = EventType.UserExtractTaskCompleted @@ -597,7 +600,7 @@ case class UserExtractTaskCompleted( "tenant" -> tenant, "author" -> author, "metadata" -> buildMetadata(metadata), - "date" -> date.toString(DateUtils.utcDateFormatter), + "date" -> date.format(DateUtils.utcDateFormatter), "id" -> id, "payload" -> payload.asJson() ) @@ -611,7 +614,7 @@ case class ExtractionStarted( author: String, metadata: Option[Seq[(String, String)]] = None, id: Long = NioEvent.gen.nextId(), - date: DateTime = DateTime.now(DateTimeZone.UTC), + date: LocalDateTime = LocalDateTime.now(Clock.systemUTC), payload: ExtractionTaskInfoPerApp ) extends NioEvent { def shardId = payload.userId @@ -625,7 +628,7 @@ case class ExtractionStarted( "tenant" -> tenant, "author" -> author, "metadata" -> buildMetadata(metadata), - "date" -> date.toString(DateUtils.utcDateFormatter), + "date" -> date.format(DateUtils.utcDateFormatter), "id" -> id, "payload" -> payload.asJson() ) @@ -637,7 +640,7 @@ case class ExtractionAppDone( author: String, metadata: Option[Seq[(String, String)]] = None, id: Long = NioEvent.gen.nextId(), - date: DateTime = DateTime.now(DateTimeZone.UTC), + date: LocalDateTime = LocalDateTime.now(Clock.systemUTC), payload: AppDone ) extends NioEvent { def shardId = payload.userId @@ -651,7 +654,7 @@ case class ExtractionAppDone( "tenant" -> tenant, "author" -> author, "metadata" -> buildMetadata(metadata), - "date" -> date.toString(DateUtils.utcDateFormatter), + "date" -> date.format(DateUtils.utcDateFormatter), "id" -> id, "payload" -> payload.asJson() ) @@ -663,7 +666,7 @@ case class ExtractionAppFilesMetadataReceived( author: String, metadata: Option[Seq[(String, String)]] = None, id: Long = NioEvent.gen.nextId(), - date: DateTime = DateTime.now(DateTimeZone.UTC), + date: LocalDateTime = LocalDateTime.now(Clock.systemUTC), payload: AppFilesMetadata ) extends NioEvent { def shardId = payload.userId @@ -677,7 +680,7 @@ case class ExtractionAppFilesMetadataReceived( "tenant" -> tenant, "author" -> author, "metadata" -> buildMetadata(metadata), - "date" -> date.toString(DateUtils.utcDateFormatter), + "date" -> date.format(DateUtils.utcDateFormatter), "id" -> id, "payload" -> payload.asJson() ) @@ -689,7 +692,7 @@ case class ExtractionFinished( author: String, metadata: Option[Seq[(String, String)]] = None, id: Long = NioEvent.gen.nextId(), - date: DateTime = DateTime.now(DateTimeZone.UTC), + date: LocalDateTime = LocalDateTime.now(Clock.systemUTC), payload: ExtractionTask ) extends NioEvent { def shardId = payload.userId @@ -703,7 +706,7 @@ case class ExtractionFinished( "tenant" -> tenant, "author" -> author, "metadata" -> buildMetadata(metadata), - "date" -> date.toString(DateUtils.utcDateFormatter), + "date" -> date.format(DateUtils.utcDateFormatter), "id" -> id, "payload" -> payload.asJson() ) diff --git a/nio-server/app/s3/S3.scala b/nio-server/app/s3/S3.scala index 21c2a669..2829e283 100644 --- a/nio-server/app/s3/S3.scala +++ b/nio-server/app/s3/S3.scala @@ -1,10 +1,9 @@ package s3 -import java.util - -import akka.actor.ActorSystem -import akka.stream.Materializer -import akka.stream.scaladsl.Source +import java.{time, util} +import org.apache.pekko.actor.ActorSystem +import org.apache.pekko.stream.Materializer +import org.apache.pekko.stream.scaladsl.Source import com.amazonaws.ClientConfiguration import com.amazonaws.auth.{AWSStaticCredentialsProvider, BasicAWSCredentials} import com.amazonaws.client.builder.AwsClientBuilder @@ -13,9 +12,9 @@ import com.amazonaws.services.s3.model._ import com.amazonaws.services.s3.model.lifecycle.{LifecycleAndOperator, LifecycleFilter, LifecycleTagPredicate} import db.{ExtractionTaskMongoDataStore, TenantMongoDataStore} import models.{ExtractionTask, ExtractionTaskStatus} -import org.joda.time.{DateTime, DateTimeZone, Days} import utils.NioLogger +import java.time.{Clock, LocalDateTime} import scala.jdk.CollectionConverters._ import scala.concurrent.duration._ import scala.concurrent.{ExecutionContext, Future} @@ -96,9 +95,9 @@ class S3(val conf: S3Configuration, val system: ActorSystem, val tenantStore: Te _.runForeach { taskJson => try { val task = ExtractionTask.fmt.reads(taskJson).get - val days = Days - .daysBetween(DateTime.now(DateTimeZone.UTC), task.lastUpdate) - .getDays + val days = time.Duration + .between(LocalDateTime.now(Clock.systemUTC), task.lastUpdate) + .toDays if (days >= conf.expirationInDays) { val keys = task.states.flatMap { state => state.files.map { f => diff --git a/nio-server/app/s3/S3FileDataStore.scala b/nio-server/app/s3/S3FileDataStore.scala index 5e514c71..093fd310 100644 --- a/nio-server/app/s3/S3FileDataStore.scala +++ b/nio-server/app/s3/S3FileDataStore.scala @@ -1,8 +1,8 @@ package s3 -import akka.actor.ActorSystem -import akka.stream.alpakka.s3.scaladsl.S3 -import akka.stream.alpakka.s3.{AccessStyle, MemoryBufferType, S3Attributes, S3Ext, S3Settings} +import org.apache.pekko.actor.ActorSystem +import org.apache.pekko.stream.connectors.s3.scaladsl.S3 +import org.apache.pekko.stream.connectors.s3.{AccessStyle, MemoryBufferType, S3Attributes, S3Ext, S3Settings} import software.amazon.awssdk.auth.credentials.{AwsBasicCredentials, StaticCredentialsProvider} import software.amazon.awssdk.regions.Region import software.amazon.awssdk.regions.providers.AwsRegionProvider diff --git a/nio-server/app/service/AccessibleOfferManagerService.scala b/nio-server/app/service/AccessibleOfferManagerService.scala index 92c5ff0c..0bcc1a75 100644 --- a/nio-server/app/service/AccessibleOfferManagerService.scala +++ b/nio-server/app/service/AccessibleOfferManagerService.scala @@ -2,7 +2,7 @@ package service import java.util.regex.Pattern -import akka.http.scaladsl.util.FastFuture +import org.apache.pekko.http.scaladsl.util.FastFuture import controllers.AppErrorWithStatus import db.OrganisationMongoDataStore import models.{Offer, Organisation} diff --git a/nio-server/app/service/CatchupNioEventService.scala b/nio-server/app/service/CatchupNioEventService.scala index 5a1e19b5..910cf549 100644 --- a/nio-server/app/service/CatchupNioEventService.scala +++ b/nio-server/app/service/CatchupNioEventService.scala @@ -1,11 +1,11 @@ package service -import akka.NotUsed -import akka.actor.ActorSystem -import akka.kafka.ProducerMessage -import akka.kafka.scaladsl.Producer -import akka.stream.scaladsl.{Broadcast, Flow, GraphDSL, Merge, RunnableGraph, Sink, Source} -import akka.stream.{ClosedShape, Materializer} +import org.apache.pekko.NotUsed +import org.apache.pekko.actor.ActorSystem +import org.apache.pekko.kafka.ProducerMessage +import org.apache.pekko.kafka.scaladsl.Producer +import org.apache.pekko.stream.scaladsl.{Broadcast, Flow, GraphDSL, Merge, RunnableGraph, Sink, Source} +import org.apache.pekko.stream.{ClosedShape, Materializer} import configuration.Env import db.{CatchupLockMongoDatastore, ConsentFactMongoDataStore, LastConsentFactMongoDataStore, TenantMongoDataStore} import messaging.KafkaMessageBroker @@ -13,7 +13,7 @@ import models.{ConsentFact, ConsentFactCreated, ConsentFactUpdated} import org.apache.kafka.clients.producer.ProducerRecord import utils.NioLogger import play.api.libs.json.Json -import reactivemongo.akkastream.State +import reactivemongo.pekkostream.State import scala.concurrent.{ExecutionContext, Future} diff --git a/nio-server/app/service/MailService.scala b/nio-server/app/service/MailService.scala index 400c151a..cdae93a6 100644 --- a/nio-server/app/service/MailService.scala +++ b/nio-server/app/service/MailService.scala @@ -1,7 +1,7 @@ package service -import akka.http.scaladsl.model._ -import akka.http.scaladsl.util.FastFuture +import org.apache.pekko.http.scaladsl.model._ +import org.apache.pekko.http.scaladsl.util.FastFuture import configuration.{Env, MailGunConfig} import utils.NioLogger import play.api.libs.ws.{WSClient, _} diff --git a/nio-server/app/service/OfferManagerService.scala b/nio-server/app/service/OfferManagerService.scala index c0f62f52..fb1c3c8d 100644 --- a/nio-server/app/service/OfferManagerService.scala +++ b/nio-server/app/service/OfferManagerService.scala @@ -1,6 +1,6 @@ package service -import akka.http.scaladsl.util.FastFuture +import org.apache.pekko.http.scaladsl.util.FastFuture import controllers.AppErrorWithStatus import db.{LastConsentFactMongoDataStore, OrganisationMongoDataStore} import models.{Offer, Organisation} diff --git a/nio-server/app/service/ServiceUtils.scala b/nio-server/app/service/ServiceUtils.scala index 4e39ebb0..de511e8d 100644 --- a/nio-server/app/service/ServiceUtils.scala +++ b/nio-server/app/service/ServiceUtils.scala @@ -1,6 +1,6 @@ package service -import akka.http.scaladsl.util.FastFuture +import org.apache.pekko.http.scaladsl.util.FastFuture import controllers.AppErrorWithStatus import play.api.mvc.Results._ import utils.Result.{AppErrors, ErrorMessage} diff --git a/nio-server/app/utils/DateUtils.scala b/nio-server/app/utils/DateUtils.scala index b68aa662..9e0b00ce 100644 --- a/nio-server/app/utils/DateUtils.scala +++ b/nio-server/app/utils/DateUtils.scala @@ -1,30 +1,30 @@ package utils +import java.time.LocalDateTime import play.api.libs.json._ -import org.joda.time.DateTime -import org.joda.time.format.DateTimeFormat +import java.time.format.DateTimeFormatter import scala.util.{Failure, Success, Try} object DateUtils { - val utcDateFormatter = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss'Z'") + val utcDateFormatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME //forPattern("yyyy-MM-dd'T'HH:mm:ss'Z'") - val utcDateTimeReads = new Reads[DateTime] { + val utcDateTimeReads = new Reads[LocalDateTime] { def reads(json: JsValue) = json match { case JsString(s) => - Try(DateTime.parse(s, utcDateFormatter)) match { - case Success(d) => JsSuccess(d.withMillisOfSecond(0)) + Try(LocalDateTime.parse(s, utcDateFormatter)) match { + case Success(d) => JsSuccess(d.withNano(0)) case Failure(f) => JsSuccess(null) } case _ => JsError("error.expected.date") } } - val utcDateTimeWrites = new Writes[DateTime] { - override def writes(o: DateTime): JsValue = - JsString(o.toString(DateUtils.utcDateFormatter)) + val utcDateTimeWrites = new Writes[LocalDateTime] { + override def writes(o: LocalDateTime): JsValue = + JsString(o.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)) } - val utcDateTimeFormats: Format[DateTime] = + val utcDateTimeFormats: Format[LocalDateTime] = Format(utcDateTimeReads, utcDateTimeWrites) } diff --git a/nio-server/app/utils/S3Manager.scala b/nio-server/app/utils/S3Manager.scala index 1760319a..8247b321 100644 --- a/nio-server/app/utils/S3Manager.scala +++ b/nio-server/app/utils/S3Manager.scala @@ -5,11 +5,11 @@ import java.nio.file.Files import java.util import java.util.Base64 -import akka.NotUsed -import akka.actor.ActorSystem -import akka.stream.{IOResult, Materializer} -import akka.stream.scaladsl.{Flow, Source, StreamConverters} -import akka.util.ByteString +import org.apache.pekko.NotUsed +import org.apache.pekko.actor.ActorSystem +import org.apache.pekko.stream.{IOResult, Materializer} +import org.apache.pekko.stream.scaladsl.{Flow, Source, StreamConverters} +import org.apache.pekko.util.ByteString import com.amazonaws.ClientConfiguration import com.amazonaws.auth.{AWSStaticCredentialsProvider, BasicAWSCredentials} import com.amazonaws.client.builder.AwsClientBuilder diff --git a/nio-server/app/utils/SecureEvent.scala b/nio-server/app/utils/SecureEvent.scala index 51be04f0..a643254c 100644 --- a/nio-server/app/utils/SecureEvent.scala +++ b/nio-server/app/utils/SecureEvent.scala @@ -1,8 +1,8 @@ package utils -import akka.actor.ActorSystem -import akka.stream.Materializer -import akka.stream.scaladsl.{RestartSource, Sink} +import org.apache.pekko.actor.ActorSystem +import org.apache.pekko.stream.Materializer +import org.apache.pekko.stream.scaladsl.{RestartSource, Sink} import configuration.Env import messaging.KafkaMessageBroker diff --git a/nio-server/build.sbt b/nio-server/build.sbt index c85bfff0..4b156fe8 100644 --- a/nio-server/build.sbt +++ b/nio-server/build.sbt @@ -9,21 +9,28 @@ lazy val `nio-server` = (project in file(".")) .enablePlugins(NoPublish) .disablePlugins(BintrayPlugin) -scalaVersion := "2.13.10" +scalaVersion := "2.13.14" resolvers ++= Seq( Resolver.jcenterRepo, "Maven central" at "https://repo1.maven.org/maven2/" ) +dependencyOverrides ++= Seq( + "com.github.luben" % "zstd-jni" % "1.5.6-4", + "org.scala-lang.modules" %% "scala-xml" % "2.2.0" +) + libraryDependencies ++= Seq( ws, - "com.typesafe.akka" %% "akka-http" % "10.1.15", - "com.typesafe.akka" %% "akka-http-xml" % "10.1.15", - "com.typesafe.play" %% "play-json-joda" % playJsonJodaVersion, - "org.reactivemongo" %% "play2-reactivemongo" % s"$reactiveMongoVersion-play28", - "org.reactivemongo" %% "reactivemongo-akkastream" % reactiveMongoVersion, - "com.typesafe.akka" %% "akka-stream-kafka" % akkaStreamKafka, + "org.apache.pekko" %% "pekko-http" % "1.1.0", + "org.apache.pekko" %% "pekko-http-xml" % "1.1.0", + "com.typesafe.play" %% "play-json-joda" % playJsonJodaVersion, + "org.reactivemongo" %% "reactivemongo" % s"$reactiveMongoVersion-pekko.RC13", + "org.reactivemongo" %% "play2-reactivemongo" % s"$reactiveMongoVersion-play30.RC13", + "org.reactivemongo" %% "reactivemongo-pekkostream" % s"$reactiveMongoVersion-RC13", + "org.apache.pekko" %% "pekko-connectors-kafka" % pekkoKafka, + "org.apache.commons" % "commons-lang3" % "3.11", "de.svenkubiak" % "jBCrypt" % "0.4.1", // ISC/BSD "com.auth0" % "java-jwt" % javaJwt, // MIT license @@ -38,7 +45,7 @@ libraryDependencies ++= Seq( "io.dropwizard.metrics" % "metrics-jvm" % metricsVersion, // Apache 2.0 // S3 client for akka-stream - "com.lightbend.akka" %% "akka-stream-alpakka-s3" % alpakkaS3Version, + "org.apache.pekko" %% "pekko-connectors-s3" % pekkoS3Version, "org.scalatestplus.play" %% "scalatestplus-play" % scalatestPlay % Test ) diff --git a/nio-server/test/controllers/ConsentControllerSpec.scala b/nio-server/test/controllers/ConsentControllerSpec.scala index cb2693f1..d5f39c0b 100644 --- a/nio-server/test/controllers/ConsentControllerSpec.scala +++ b/nio-server/test/controllers/ConsentControllerSpec.scala @@ -1,8 +1,8 @@ package controllers -import akka.japi.Option +import org.apache.pekko.japi.Option import models._ -import org.joda.time.{DateTime, DateTimeZone} +import java.time.{LocalDateTime, Clock} import utils.NioLogger import play.api.libs.json.{JsArray, JsObject, JsValue, Json} import play.api.libs.ws.WSResponse @@ -621,7 +621,7 @@ class ConsentControllerSpec extends TestUtils { ) ) ), - lastUpdate = DateTime.now(DateTimeZone.UTC) + lastUpdate = LocalDateTime.now(Clock.systemUTC) ) val consentFactasXml = consentFact.asXml() @@ -645,7 +645,7 @@ class ConsentControllerSpec extends TestUtils { } "force lastUpdate date" in { - val tomorrow: DateTime = DateTime.now(DateTimeZone.UTC).plusDays(1) + val tomorrow: LocalDateTime = LocalDateTime.now(Clock.systemUTC).plusDays(1) val consentFact = ConsentFact( _id = "cf", @@ -682,7 +682,7 @@ class ConsentControllerSpec extends TestUtils { val json: JsValue = resp.json - (json \ "lastUpdate").as[String] mustBe tomorrow.toString(DateUtils.utcDateFormatter) + (json \ "lastUpdate").as[String] mustBe tomorrow.format(DateUtils.utcDateFormatter) val respGet = getJson(s"/$tenant/organisations/$organisationKey/users/$userId4") @@ -691,7 +691,7 @@ class ConsentControllerSpec extends TestUtils { val jsonGet: JsValue = respGet.json - (jsonGet \ "lastUpdate").as[String] mustBe tomorrow.toString(DateUtils.utcDateFormatter) + (jsonGet \ "lastUpdate").as[String] mustBe tomorrow.format(DateUtils.utcDateFormatter) } "not force update date" in { @@ -734,7 +734,7 @@ class ConsentControllerSpec extends TestUtils { } "force lastUpdate date xml" in { - val yesterday: DateTime = DateTime.now(DateTimeZone.UTC).minusDays(1) + val yesterday: DateTime = LocalDateTime.now(Clock.systemUTC).minusDays(1) val userId6 = "userId6Xml" @@ -773,7 +773,7 @@ class ConsentControllerSpec extends TestUtils { val xml = resp.xml - (xml \ "lastUpdate").head.text mustBe yesterday.toString(DateUtils.utcDateFormatter) + (xml \ "lastUpdate").head.text mustBe yesterday.format(DateUtils.utcDateFormatter) val respGet = getXml(s"/$tenant/organisations/$organisationKey/users/$userId6") @@ -782,7 +782,7 @@ class ConsentControllerSpec extends TestUtils { val xmlGet = respGet.xml - (xmlGet \ "lastUpdate").head.text mustBe yesterday.toString(DateUtils.utcDateFormatter) + (xmlGet \ "lastUpdate").head.text mustBe yesterday.format(DateUtils.utcDateFormatter) } @@ -1032,7 +1032,7 @@ class ConsentControllerSpec extends TestUtils { patchedOffers.value.length mustBe 2 (patchedOffers \ 0 \ "key").as[String] mustBe "offer1" - (patchedOffers \ 0 \ "lastUpdate").as[DateTime](DateUtils.utcDateTimeFormats) mustBe updatedDate + (patchedOffers \ 0 \ "lastUpdate").as[LocalDateTime](DateUtils.utcDateTimeFormats) mustBe updatedDate } @@ -1264,7 +1264,7 @@ class ConsentControllerSpec extends TestUtils { ConsentGroup("a", "a", Seq(Consent("a", "a", false))), ConsentGroup("b", "b", Seq(Consent("b", "b", false))) ), - lastUpdate = DateTime.now(DateTimeZone.UTC), + lastUpdate = LocalDateTime.now(Clock.systemUTC), metaData = Some(Map("mdKey1" -> "mdVal1", "tata" -> "val2")) ) @@ -1325,7 +1325,7 @@ class ConsentControllerSpec extends TestUtils { } "last update date must be >= last update date in db" should { - val lastUpdate = DateTime.now(DateTimeZone.UTC) + val lastUpdate = LocalDateTime.now(Clock.systemUTC) val userIdDate = "userIdWithLastUpdateDate" val consentFact = ConsentFact( @@ -1401,9 +1401,9 @@ class ConsentControllerSpec extends TestUtils { } "last update offer date must be >= last update offer date in db" should { - val today = DateTime.now(DateTimeZone.UTC) - val yesterday = DateTime.now(DateTimeZone.UTC).minusDays(1) - val tommorrow = DateTime.now(DateTimeZone.UTC).plusDays(1) + val today = LocalDateTime.now(Clock.systemUTC) + val yesterday = LocalDateTime.now(Clock.systemUTC).minusDays(1) + val tommorrow = LocalDateTime.now(Clock.systemUTC).plusDays(1) val userIdDate = "userIdWithLastUpdateDate" val consentFact = ConsentFact( @@ -1502,8 +1502,8 @@ class ConsentControllerSpec extends TestUtils { } "put just offer2 with user has 1 & 2" should { - val today = DateTime.now(DateTimeZone.UTC) - val yesterday = DateTime.now(DateTimeZone.UTC).minusDays(1) + val today = LocalDateTime.now(Clock.systemUTC) + val yesterday = LocalDateTime.now(Clock.systemUTC).minusDays(1) val consentOffer1: ConsentOffer = offerToConsentOffer(offer1).copy(lastUpdate = yesterday) val consentOffer2: ConsentOffer = offerToConsentOffer(offer2).copy(lastUpdate = yesterday) @@ -1601,8 +1601,8 @@ class ConsentControllerSpec extends TestUtils { } "put no offers with user has 1 & 2" should { - val today = DateTime.now(DateTimeZone.UTC) - val yesterday = DateTime.now(DateTimeZone.UTC).minusDays(1) + val today = LocalDateTime.now(Clock.systemUTC) + val yesterday = LocalDateTime.now(Clock.systemUTC).minusDays(1) val consentOffer1: ConsentOffer = offerToConsentOffer(offer1).copy(lastUpdate = yesterday) val consentOffer2: ConsentOffer = offerToConsentOffer(offer2).copy(lastUpdate = yesterday) diff --git a/nio-server/test/controllers/EventControllerSpec.scala b/nio-server/test/controllers/EventControllerSpec.scala index 0dcfa7de..e8026788 100644 --- a/nio-server/test/controllers/EventControllerSpec.scala +++ b/nio-server/test/controllers/EventControllerSpec.scala @@ -2,8 +2,8 @@ package controllers import java.util.concurrent.atomic.AtomicBoolean -import akka.actor.ActorSystem -import akka.stream.{ActorMaterializer, Materializer} +import org.apache.pekko.actor.ActorSystem +import org.apache.pekko.stream.{ActorMaterializer, Materializer} import play.api.libs.json.Json import play.api.libs.ws.WSResponse import play.api.test.Helpers._ diff --git a/nio-server/test/controllers/ExtractionControllerSpec.scala b/nio-server/test/controllers/ExtractionControllerSpec.scala index a338c6af..1daa56a3 100644 --- a/nio-server/test/controllers/ExtractionControllerSpec.scala +++ b/nio-server/test/controllers/ExtractionControllerSpec.scala @@ -9,7 +9,7 @@ import java.nio.charset.StandardCharsets import java.nio.file.Files import java.util.concurrent.TimeUnit -import akka.stream.scaladsl.FileIO +import org.apache.pekko.stream.scaladsl.FileIO import com.amazonaws.services.s3.AmazonS3 import play.api.libs.ws.SourceBody import s3.{S3, S3Configuration} diff --git a/nio-server/test/controllers/OrganisationControllerSpec.scala b/nio-server/test/controllers/OrganisationControllerSpec.scala index 4da3bff7..424ce106 100644 --- a/nio-server/test/controllers/OrganisationControllerSpec.scala +++ b/nio-server/test/controllers/OrganisationControllerSpec.scala @@ -1,7 +1,7 @@ package controllers import models._ -import org.joda.time.{DateTime, DateTimeZone} +import java.time.{LocalDateTime, Clock} import utils.NioLogger import play.api.libs.json.{JsArray, JsValue, Json} import play.api.libs.ws.WSResponse @@ -78,7 +78,7 @@ class OrganisationControllerSpec extends TestUtils { ) "create new organisation" in { - val beforeNewOrgCreation = DateTime.now(DateTimeZone.UTC).minusSeconds(1) + val beforeNewOrgCreation = LocalDateTime.now(Clock.systemUTC).minusSeconds(1) val path: String = s"/$tenant/organisations" val createResponse = postJson(path, org1AsJson) @@ -104,7 +104,7 @@ class OrganisationControllerSpec extends TestUtils { (value \ "version" \ "neverReleased").asOpt[Boolean] mustBe None (value \ "version" \ "lastUpdate").asOpt[String].map { s => val lastUpdate = DateTime.parse(s) - lastUpdate.isAfter(beforeNewOrgCreation) && lastUpdate.isBefore(DateTime.now(DateTimeZone.UTC).plusSeconds(1)) + lastUpdate.isAfter(beforeNewOrgCreation) && lastUpdate.isBefore(LocalDateTime.now(Clock.systemUTC).plusSeconds(1)) } mustBe Some(true) val groups = (value \ "groups").as[JsArray] @@ -135,7 +135,7 @@ class OrganisationControllerSpec extends TestUtils { (organisations \ 1 \ "version" \ "num").as[Int] mustBe 1 (organisations \ 1 \ "version" \ "lastUpdate").asOpt[String].map { s => val lastUpdate = DateTime.parse(s) - lastUpdate.isAfter(beforeNewOrgCreation) && lastUpdate.isBefore(DateTime.now(DateTimeZone.UTC).plusSeconds(1)) + lastUpdate.isAfter(beforeNewOrgCreation) && lastUpdate.isBefore(LocalDateTime.now(Clock.systemUTC).plusSeconds(1)) } mustBe Some(true) } @@ -187,7 +187,7 @@ class OrganisationControllerSpec extends TestUtils { (value \ "version" \ "num").as[Int] mustBe org1.version.num (value \ "version" \ "lastUpdate").asOpt[String].map { s => val lastUpdate = DateTime.parse(s) - lastUpdate.isBefore(DateTime.now(DateTimeZone.UTC).plusSeconds(1)) + lastUpdate.isBefore(LocalDateTime.now(Clock.systemUTC).plusSeconds(1)) } mustBe Some(true) } diff --git a/nio-server/test/controllers/UserExtractControllerSpec.scala b/nio-server/test/controllers/UserExtractControllerSpec.scala index ef8a9883..03cfeb20 100644 --- a/nio-server/test/controllers/UserExtractControllerSpec.scala +++ b/nio-server/test/controllers/UserExtractControllerSpec.scala @@ -5,9 +5,9 @@ import java.nio.charset.StandardCharsets import java.nio.file.Files import java.util.concurrent.TimeUnit -import akka.NotUsed -import akka.http.scaladsl.model.Multipart.BodyPart -import akka.stream.scaladsl.{FileIO, Source} +import org.apache.pekko.NotUsed +import org.apache.pekko.http.scaladsl.model.Multipart.BodyPart +import org.apache.pekko.stream.scaladsl.{FileIO, Source} import models.{Organisation, Permission, PermissionGroup, UserExtract} import org.apache.http.entity.ContentType import org.apache.http.entity.mime.MultipartEntityBuilder diff --git a/nio-server/test/db/OrganisationMongoDataStoreSpec.scala b/nio-server/test/db/OrganisationMongoDataStoreSpec.scala index 6dda4428..04be23ce 100644 --- a/nio-server/test/db/OrganisationMongoDataStoreSpec.scala +++ b/nio-server/test/db/OrganisationMongoDataStoreSpec.scala @@ -3,7 +3,7 @@ package db import java.util.concurrent.TimeUnit import models.{Organisation, Permission, PermissionGroup, VersionInfo} -import org.joda.time.{DateTime, DateTimeZone} +import java.time.{LocalDateTime, Clock} import utils.{DateUtils, TestUtils} import scala.concurrent.Await @@ -31,16 +31,16 @@ class OrganisationMongoDataStoreSpec extends TestUtils { val org2Key = "org2Draft" val beforeInsert = - DateTime.now(DateTimeZone.UTC).toString(DateUtils.utcDateFormatter) + LocalDateTime.now(Clock.systemUTC).format(DateUtils.utcDateFormatter) Await.result( for { _ <- ds.insert(tenant, org1) draft1 <- ds.findDraftByKey(tenant, org1Key) - afterInsert = DateTime + afterInsert = LocalDateTime .now(DateTimeZone.UTC) - .toString(DateUtils.utcDateFormatter) + .format(DateUtils.utcDateFormatter) _ = Thread.sleep(1000) diff --git a/nio-server/test/models/ConsentFactSpec.scala b/nio-server/test/models/ConsentFactSpec.scala index 65767f08..b24ab4a2 100644 --- a/nio-server/test/models/ConsentFactSpec.scala +++ b/nio-server/test/models/ConsentFactSpec.scala @@ -1,6 +1,6 @@ package models -import org.joda.time.{DateTime, DateTimeZone} +import java.time.{LocalDateTime, Clock} import org.scalatest.wordspec.AnyWordSpecLike import org.scalatest.matchers.must.Matchers import org.scalatestplus.play.PlaySpec @@ -21,7 +21,7 @@ class ConsentFactSpec extends PlaySpec with AnyWordSpecLike with Matchers { ConsentGroup("a", "a", Seq(Consent("a", "a", false))), ConsentGroup("b", "b", Seq(Consent("b", "b", false))) ), - lastUpdate = DateTime.now(DateTimeZone.UTC), + lastUpdate = LocalDateTime.now(Clock.systemUTC), metaData = Some(Map(mdKey1 -> mdVal1, "tata" -> "val2")) ) diff --git a/nio-server/test/models/ModelValidationSpec.scala b/nio-server/test/models/ModelValidationSpec.scala index d6fae4b8..18069bff 100644 --- a/nio-server/test/models/ModelValidationSpec.scala +++ b/nio-server/test/models/ModelValidationSpec.scala @@ -1,6 +1,6 @@ package models -import org.joda.time.{DateTime, DateTimeZone} +import java.time.{LocalDateTime, Clock} import org.scalatest.matchers.must.Matchers import org.scalatest.wordspec.AnyWordSpecLike import play.api.libs.json.JsValue @@ -11,7 +11,7 @@ import scala.xml.Elem class ModelValidationSpec extends AnyWordSpecLike with Matchers { - val now: DateTime = DateTime.now(DateTimeZone.UTC) + val now: DateTime = LocalDateTime.now(Clock.systemUTC) "Validation ConsentFact" should { val consentFact: ConsentFact = ConsentFact( @@ -148,7 +148,7 @@ class ModelValidationSpec extends AnyWordSpecLike with Matchers { ) } - {consentFact.lastUpdate.toString(DateUtils.utcDateFormatter)} + {consentFact.lastUpdate.format(DateUtils.utcDateFormatter)} {consentFact.orgKey.getOrElse("")} { if (consentFact.metaData.isDefined) @@ -188,7 +188,7 @@ class ModelValidationSpec extends AnyWordSpecLike with Matchers { consentFact.groups(1).consents(1).label must be("group 2 consent 2") consentFact.groups(1).consents(1).checked must be(false) - consentFact.lastUpdate.toString(DateUtils.utcDateFormatter) must be(now.toString(DateUtils.utcDateFormatter)) + consentFact.lastUpdate.format(DateUtils.utcDateFormatter) must be(now.format(DateUtils.utcDateFormatter)) consentFact.orgKey.get must be("orgKey") @@ -247,7 +247,7 @@ class ModelValidationSpec extends AnyWordSpecLike with Matchers { def invalidAccount(account: Account): Elem = {account.accountId} - {account.lastUpdate.toString(DateUtils.utcDateFormatter)} + {account.lastUpdate.format(DateUtils.utcDateFormatter)} { account.organisationsUsers.map(ou => @@ -371,7 +371,7 @@ class ModelValidationSpec extends AnyWordSpecLike with Matchers { {organisation.version.status} {organisation.version.num} {organisation.version.latest} - {organisation.version.lastUpdate.toString(DateUtils.utcDateFormatter)} + {organisation.version.lastUpdate.format(DateUtils.utcDateFormatter)} { organisation.groups.map(group => @@ -396,7 +396,7 @@ class ModelValidationSpec extends AnyWordSpecLike with Matchers { organisation.version.num must be(2) organisation.version.latest must be(true) organisation.version.lastUpdate - .toString(DateUtils.utcDateFormatter) must be(now.toString(DateUtils.utcDateFormatter)) + .format(DateUtils.utcDateFormatter) must be(now.format(DateUtils.utcDateFormatter)) organisation.groups.size must be(2) organisation.groups.head.key must be("group1") diff --git a/nio-server/test/utils/TestUtils.scala b/nio-server/test/utils/TestUtils.scala index ba66b3a2..e44d20e6 100644 --- a/nio-server/test/utils/TestUtils.scala +++ b/nio-server/test/utils/TestUtils.scala @@ -4,12 +4,12 @@ import java.io.File import java.util.UUID import java.util.concurrent.TimeUnit import java.{lang, util} -import akka.actor.ActorSystem -import akka.http.scaladsl.model.HttpEntity -import akka.kafka.scaladsl.Consumer -import akka.kafka.{ConsumerSettings, Subscriptions} -import akka.stream.{ActorMaterializer, Materializer} -import akka.stream.scaladsl.Sink +import org.apache.pekko.actor.ActorSystem +import org.apache.pekko.http.scaladsl.model.HttpEntity +import org.apache.pekko.kafka.scaladsl.Consumer +import org.apache.pekko.kafka.{ConsumerSettings, Subscriptions} +import org.apache.pekko.stream.{ActorMaterializer, Materializer} +import org.apache.pekko.stream.scaladsl.Sink import com.amazonaws.services.s3.model.PutObjectResult import com.typesafe.config.{Config, ConfigFactory} import filters.AuthInfoMock diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 7b127ef6..8bdbefdd 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -1,13 +1,13 @@ object Dependencies { val playJsonJodaVersion = "2.9.1" - val reactiveMongoVersion = "1.0.1" - val akkaStreamKafka = "2.0.5" + val reactiveMongoVersion = "1.1.0" + val pekkoKafka = "1.1.0" val pureConfig = "0.14.0" val scalaticVersion = "3.2.0" val catsVersion = "2.2.0" val macwireVersion = "2.3.7" val metricsVersion = "4.0.2" - val alpakkaS3Version = "2.0.2" + val pekkoS3Version = "1.0.2" val scalatestPlay = "5.1.0" val javaJwt = "3.11.0" } diff --git a/project/build.properties b/project/build.properties index 875272df..3829f19f 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.8.2 \ No newline at end of file +sbt.version=1.10.2 \ No newline at end of file diff --git a/project/plugins.sbt b/project/plugins.sbt index b121b1cc..800c8450 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,5 +1,5 @@ // The Play plugin -addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.19") +addSbtPlugin("org.playframework" % "sbt-plugin" % "3.0.0") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2") // Apache 2.0