Skip to content

Commit

Permalink
Update to Play 2.9.1 and Scala 2.13
Browse files Browse the repository at this point in the history
Fix lots of deprecation warnings, but still various warnings about
templates, using of symbols etc ignored for the time being.
  • Loading branch information
mikesname committed Mar 6, 2024
1 parent 53bd388 commit f0a781d
Show file tree
Hide file tree
Showing 78 changed files with 198 additions and 198 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: scala
scala:
- 2.12.12
- 2.13.3

jdk:
openjdk8
Expand Down
30 changes: 14 additions & 16 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@ logBuffered := false
logLevel := Level.Info
ThisBuild / organization := "eu.ehri-project"

val projectScalaVersion = "2.12.12"
val projectScalaVersion = "2.13.13"
val appName = "docview"

val backendVersion = "0.15.1"
val dataConverterVersion = "1.1.15"
val alpakkaVersion = "3.0.4"

// This prevents a library version incompatibility error between
// scala-xml 1.3.0 and 2.2.0 (which are in fact binary compatible.)
ThisBuild / libraryDependencySchemes ++= Seq(
"org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always
)

val backendDependencies = Seq(
// Play stuff
ws,
Expand Down Expand Up @@ -52,6 +58,9 @@ val coreDependencies = backendDependencies ++ Seq(
filters,
openId,

// Force Scala XML version
"org.scala-lang.modules" %% "scala-xml" % "2.2.0",

// Force Akka HTTP version
"com.typesafe.akka" %% "akka-http" % akkaHttpVersion,
"com.typesafe.akka" %% "akka-http-xml" % akkaHttpVersion,
Expand Down Expand Up @@ -93,10 +102,6 @@ val coreDependencies = backendDependencies ++ Seq(
)

val portalDependencies = Seq(
// Library for the silencer compiler plugin, only needed
// at compile time.
"com.github.ghik" %% "silencer-lib" % "1.3.1" % Compile,

// Helper for making thumbnails...
"net.coobird" % "thumbnailator" % "[0.4, 0.5)",

Expand Down Expand Up @@ -139,8 +144,7 @@ val additionalResolvers = Seq(

val validateMessages = TaskKey[Unit]("validate-messages", "Validate messages")

lazy val commonSettings = Seq(

val commonSettings = Seq(
ThisBuild / scalaVersion := projectScalaVersion,

// Increase the JVM heap to avoid running
Expand All @@ -158,7 +162,7 @@ lazy val commonSettings = Seq(
"-encoding", "UTF-8",
"-Ywarn-unused:imports",
"-unchecked",
"-deprecation"
"-deprecation",
),

resolvers ++= additionalResolvers,
Expand All @@ -172,12 +176,6 @@ lazy val commonSettings = Seq(
)

val webAppSettings = Seq(
// Add silencer plugin...
addCompilerPlugin("com.github.ghik" %% "silencer-plugin" % "1.3.1"),

// ... and silence all warnings on autogenerated files
scalacOptions += "-P:silencer:pathFilters=target/.*",

// Allow SBT to tell Scaladoc where to find external
// api docs if dependencies provide that metadata
autoAPIMappings := true,
Expand Down Expand Up @@ -349,7 +347,7 @@ lazy val xslt = Project(appName + "-xslt", file("modules/xslt"))
"org.slf4j" % "slf4j-api" % "1.7.32",

// We need JSON here...
"com.typesafe.play" %% "play-json" % "2.8.1",
"com.typesafe.play" %% "play-json" % "2.10.0",

// Saxon for XSLT transformation
"net.sf.saxon" % "Saxon-HE" % "10.2",
Expand All @@ -370,7 +368,7 @@ lazy val xquery = Project(appName + "-xquery", file("modules/xquery"))
"org.basex" % "basex" % "8.5",

// Command line parsing
"com.github.scopt" %% "scopt" % "4.0.1",
"com.github.scopt" %% "scopt" % "4.1.0",

specs2 % Test,
))
Expand Down
5 changes: 2 additions & 3 deletions conf/logback-play-dev.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
-->
<configuration>

<conversionRule conversionWord="coloredLevel" converterClass="play.api.libs.logback.ColoredLevel" />

<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>${application.home}/logs/application.log</file>
<encoder>
Expand All @@ -23,7 +21,7 @@
</filter>

<encoder>
<pattern>%coloredLevel %logger{15} - %message%n%xException{5}</pattern>
<pattern>%highlight(%-5level) %logger{15} - %message%n%xException{5}</pattern>
</encoder>
</appender>

Expand Down Expand Up @@ -51,6 +49,7 @@
<!-- Turn down the default level of some classes that log with each
application restart -->
<logger name="com.zaxxer.hikari" level="ERROR" />
<logger name="play.api.http.HttpErrorHandlerExceptions" level="WARN" />
<logger name="play.api.db.HikariCPConnectionPool" level="WARN" />
<logger name="play.api.libs.concurrent.ActorSystemProvider" level="ERROR" />

Expand Down
60 changes: 30 additions & 30 deletions modules/admin/app/client/json/package.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package client

import models.json._
import models.{Entity, EntityType, _}
import models._
import play.api.Logger
import play.api.libs.functional.syntax._
import play.api.libs.json.{JsObject, KeyPathNode, _}
import play.api.libs.json._
import utils.EnumUtils

package object json {
Expand Down Expand Up @@ -68,7 +68,7 @@ package object json {
}

implicit object permissionGrantJson extends ClientWriteable[PermissionGrant] {
private implicit val permissionGrantFormat = Json.format[PermissionGrantF]
private implicit val permissionGrantFormat: OFormat[models.PermissionGrantF] = Json.format[PermissionGrantF]
implicit val clientFormat: Format[PermissionGrant] = (
JsPath.format(permissionGrantFormat) and
(__ \ "accessor").lazyFormatNullable[Accessor](accessorJson.clientFormat) and
Expand All @@ -84,7 +84,7 @@ package object json {
}

implicit object linkJson extends ClientWriteable[Link] {
private implicit val linkFormat = Json.format[LinkF]
private implicit val linkFormat: OFormat[models.LinkF] = Json.format[LinkF]
val clientFormat: Format[Link] = (
JsPath.format[LinkF](linkFormat) and
(__ \ "targets").formatSeqOrEmpty(anyModelJson.clientFormat) and
Expand All @@ -111,7 +111,7 @@ package object json {
}

implicit object versionJson extends ClientWriteable[Version] {
private implicit val fFormat = Json.format[VersionF]
private implicit val fFormat: OFormat[models.VersionF] = Json.format[VersionF]
implicit val clientFormat: Format[Version] = (
JsPath.format[VersionF](fFormat) and
(__ \ "event").lazyFormatNullable(systemEventJson.clientFormat) and
Expand All @@ -130,7 +130,7 @@ package object json {
}

implicit object systemEventJson extends ClientWriteable[SystemEvent] {
private implicit val fFormat = Json.format[SystemEventF]
private implicit val fFormat: OFormat[models.SystemEventF] = Json.format[SystemEventF]

implicit val clientFormat: Format[SystemEvent] = (
JsPath.format[SystemEventF](fFormat) and
Expand Down Expand Up @@ -182,42 +182,42 @@ package object json {
}

implicit object documentaryUnitDescriptionJson extends ClientWriteable[DocumentaryUnitDescriptionF] {
private implicit val accessPointFormat = accessPointJson.clientFormat
private implicit val datePeriodFormat = datePeriodJson.clientFormat
private implicit val isadGIdentityFormat = Json.format[IsadGIdentity]
private implicit val isadGContextFormat = Json.format[IsadGContext]
private implicit val isadGContentFormat = Json.format[IsadGContent]
private implicit val isadGConditionsFormat = Json.format[IsadGConditions]
private implicit val isadGMaterialsFormat = Json.format[IsadGMaterials]
private implicit val isadGControlFormat = Json.format[IsadGControl]
private implicit val accessPointFormat: Format[models.AccessPoint] = accessPointJson.clientFormat
private implicit val datePeriodFormat: Format[models.DatePeriodF] = datePeriodJson.clientFormat
private implicit val isadGIdentityFormat: OFormat[models.IsadGIdentity] = Json.format[IsadGIdentity]
private implicit val isadGContextFormat: OFormat[models.IsadGContext] = Json.format[IsadGContext]
private implicit val isadGContentFormat: OFormat[models.IsadGContent] = Json.format[IsadGContent]
private implicit val isadGConditionsFormat: OFormat[models.IsadGConditions] = Json.format[IsadGConditions]
private implicit val isadGMaterialsFormat: OFormat[models.IsadGMaterials] = Json.format[IsadGMaterials]
private implicit val isadGControlFormat: OFormat[models.IsadGControl] = Json.format[IsadGControl]
val clientFormat: Format[DocumentaryUnitDescriptionF] = Json.format[DocumentaryUnitDescriptionF]
}

implicit object historicalAgentDescriptionJson extends ClientWriteable[HistoricalAgentDescriptionF] {
private implicit val accessPointFormat = accessPointJson.clientFormat
private implicit val datePeriodFormat = datePeriodJson.clientFormat
private implicit val isaarDetailsFormat = Json.format[IsaarDetail]
private implicit val isaarControlFormat = Json.format[IsaarControl]
private implicit val accessPointFormat: Format[models.AccessPoint] = accessPointJson.clientFormat
private implicit val datePeriodFormat: Format[models.DatePeriodF] = datePeriodJson.clientFormat
private implicit val isaarDetailsFormat: OFormat[models.IsaarDetail] = Json.format[IsaarDetail]
private implicit val isaarControlFormat: OFormat[models.IsaarControl] = Json.format[IsaarControl]
val clientFormat: Format[HistoricalAgentDescriptionF] = Json.format[HistoricalAgentDescriptionF]
}

implicit object repositoryDescriptionJson extends ClientWriteable[RepositoryDescriptionF] {
private implicit val addressFormat = addressJson.clientFormat
private implicit val accessPointFormat = accessPointJson.clientFormat
private implicit val isdiahDetailsFormat = Json.format[IsdiahDetails]
private implicit val isdiahAccessFormat = Json.format[IsdiahAccess]
private implicit val isdiahServicesFormat = Json.format[IsdiahServices]
private implicit val isdiahControlFormat = Json.format[IsdiahControl]
private implicit val addressFormat: Writes[models.AddressF] = addressJson.clientFormat
private implicit val accessPointFormat: Format[models.AccessPoint] = accessPointJson.clientFormat
private implicit val isdiahDetailsFormat: OFormat[models.IsdiahDetails] = Json.format[IsdiahDetails]
private implicit val isdiahAccessFormat: OFormat[models.IsdiahAccess] = Json.format[IsdiahAccess]
private implicit val isdiahServicesFormat: OFormat[models.IsdiahServices] = Json.format[IsdiahServices]
private implicit val isdiahControlFormat: OFormat[models.IsdiahControl] = Json.format[IsdiahControl]
val clientFormat: Format[RepositoryDescriptionF] = Json.format[RepositoryDescriptionF]
}

implicit object conceptDescriptionJson extends ClientWriteable[ConceptDescriptionF] {
private implicit val accessPointFormat = accessPointJson.clientFormat
private implicit val accessPointFormat: Format[models.AccessPoint] = accessPointJson.clientFormat
lazy val clientFormat: Format[ConceptDescriptionF] = Json.format[ConceptDescriptionF]
}

implicit object historicalAgentJson extends ClientWriteable[HistoricalAgent] {
private implicit val haDescFmt = historicalAgentDescriptionJson.clientFormat
private implicit val haDescFmt: Format[models.HistoricalAgentDescriptionF] = historicalAgentDescriptionJson.clientFormat
private val fFormat = Json.format[HistoricalAgentF]

val clientFormat: Format[HistoricalAgent] = (
Expand All @@ -230,7 +230,7 @@ package object json {
}

implicit object repositoryJson extends ClientWriteable[Repository] {
private implicit val repoDescFmt = repositoryDescriptionJson.clientFormat
private implicit val repoDescFmt: Format[models.RepositoryDescriptionF] = repositoryDescriptionJson.clientFormat
private val fFormat = Json.format[RepositoryF]

val clientFormat: Format[Repository] = (
Expand All @@ -243,7 +243,7 @@ package object json {
}

implicit object documentaryUnitJson extends ClientWriteable[DocumentaryUnit] {
private implicit val docDescFmt = documentaryUnitDescriptionJson.clientFormat
private implicit val docDescFmt: Format[models.DocumentaryUnitDescriptionF] = documentaryUnitDescriptionJson.clientFormat
private val fFormat = Json.format[DocumentaryUnitF]
lazy val clientFormat: Format[DocumentaryUnit] = (
JsPath.format(fFormat) and
Expand All @@ -256,7 +256,7 @@ package object json {
}

implicit object virtualUnitJson extends ClientWriteable[VirtualUnit] {
private implicit val vuDescFmt = documentaryUnitDescriptionJson.clientFormat
private implicit val vuDescFmt: Format[models.DocumentaryUnitDescriptionF] = documentaryUnitDescriptionJson.clientFormat
private val fFormat = Json.format[VirtualUnitF]

lazy val clientFormat: Format[VirtualUnit] = (
Expand Down Expand Up @@ -297,7 +297,7 @@ package object json {

implicit object conceptJson extends ClientWriteable[Concept] {

private implicit val fdFormat = conceptDescriptionJson.clientFormat
private implicit val fdFormat: Format[models.ConceptDescriptionF] = conceptDescriptionJson.clientFormat
implicit val fFormat: Format[ConceptF] = Json.format[ConceptF]
val clientFormat: Format[Concept] = (
JsPath.format[ConceptF](fFormat) and
Expand Down
2 changes: 1 addition & 1 deletion modules/admin/app/controllers/admin/Data.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ case class Data @Inject()(

implicit val rd: Readable[Model] = Model.Converter

private def passThroughHeaders(headers: Map[String, Seq[String]],
private def passThroughHeaders(headers: Map[String, scala.collection.Seq[String]],
filter: Seq[String] = Seq.empty): Seq[(String, String)] = {
headers.filter(kv => if (filter.isEmpty) true else filter.contains(kv._1)).flatMap { case (k, seq) =>
seq.map(s => k -> s)
Expand Down
2 changes: 2 additions & 0 deletions modules/admin/app/controllers/units/DocumentaryUnits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ case class DocumentaryUnits @Inject()(
for (fileHandles <- importLogs.getHandles(id)) yield {
val eventHandles: Map[String, Seq[(String, java.net.URI)]] = fileHandles
.groupBy(_.eventId)
.view
.mapValues(_.map(f => (f.key, damStorage.uri(f.key, duration = 2.hours, versionId = f.versionId))))
.toMap

Ok(views.html.admin.documentaryUnit.eventList(
request.item, request.page, request.params, eventHandles))
Expand Down
2 changes: 1 addition & 1 deletion modules/admin/app/controllers/users/UserProfiles.scala
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ case class UserProfiles @Inject()(
Ok(views.html.admin.userProfile.list(request.page, request.params))
}

def export: Action[AnyContent] = AdminAction.async { implicit request =>
def `export`: Action[AnyContent] = AdminAction.async { implicit request =>
for {
accounts <- accounts.findAll(PageParams.empty.withoutLimit)
users <- userDataApi.list[UserProfile](PageParams.empty.withoutLimit)
Expand Down
2 changes: 1 addition & 1 deletion modules/admin/app/models/OaiPmhIdentity.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ object OaiPmhIdentity {
val Day = Value("YYYY-MM-DD")
val Second = Value("YYYY-MM-DDThh:mm:ssZ")

implicit val _format = EnumUtils.enumFormat(Granularity)
implicit val _format: Format[models.OaiPmhIdentity.Granularity.Value] = EnumUtils.enumFormat(Granularity)
}

implicit val _format: Format[OaiPmhIdentity] = Json.format[OaiPmhIdentity]
Expand Down
1 change: 1 addition & 0 deletions modules/admin/app/models/UrlSetConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package models

import akka.http.scaladsl.model.HttpMethods


case class UrlNameMap(url: String, name: String)

case class UrlSetConfig(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ case class SqlImportDatasetService @Inject()(db: Database, actorSystem: ActorSys
db.withTransaction { implicit conn =>
val inserts = info.map { item =>
Seq[NamedParameter](
'repo_id -> repoId,
'id -> item.id,
'name -> item.name,
'type -> item.src,
'content_type -> item.contentType,
'item_id -> item.fonds.filter(_.trim.nonEmpty),
'sync -> item.sync,
'status -> item.status,
'comments -> item.notes
Symbol("repo_id") -> repoId,
Symbol("id") -> item.id,
Symbol("name") -> item.name,
Symbol("type") -> item.src,
Symbol("content_type") -> item.contentType,
Symbol("item_id") -> item.fonds.filter(_.trim.nonEmpty),
Symbol("sync") -> item.sync,
Symbol("status") -> item.status,
Symbol("comments") -> item.notes
)
}
val q = """INSERT INTO import_dataset (repo_id, id, name, type, content_type, item_id, sync, status, comments)
Expand Down
5 changes: 1 addition & 4 deletions modules/admin/app/services/ingest/XmlFormatter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import akka.stream.alpakka.xml.{Characters, EndElement, ParseEvent, StartElement
import akka.stream.scaladsl.Flow
import akka.stream.stage.{GraphStage, GraphStageLogic, InHandler, OutHandler}
import akka.stream.{Attributes, FlowShape, Inlet, Outlet}
import javax.xml.stream.events.EndDocument


object XmlFormatter {
def format(indent: Int = 4): Flow[ParseEvent, ParseEvent, NotUsed] = Flow.fromGraph(XmlFormatter(indent))
Expand Down Expand Up @@ -79,9 +79,6 @@ protected[ingest] case class XmlFormatter(indent: Int) extends GraphStage[FlowSh
state = SeenData
push(out, e)

case e: EndDocument =>
emitMultiple(out, List(Characters("\n"), e))

case e =>
push(out, e)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

},
labels: {
@AccessPointF.AccessPointType.values.map { apt => @apt: "@Messages("accessPoint.type." + apt)",
@AccessPointF.AccessPointType.values.toSeq.map { apt => @apt: "@Messages("accessPoint.type." + apt)",
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ <h5>@views.html.admin.helpers.linkTo(child)</h5>
@if(result.page.hasMore) {
<a class="inline-load-more btn-progress"
data-limit="@result.page.limit" data-page="@(result.page.page + 1)"
href="@utils.http.joinPath(req.path, req.queryString.filterKeys(_ != "modal")
href="@utils.http.joinPath(req.path, req.queryString.view.filterKeys(_ != "modal").toMap
.updated(PAGE_PARAM, Seq((result.page.page + 1).toString)))">
<span class="load-prompt">@Messages("activity.fetchMore")</span>
<span class="loading-indicator spinner-grow spinner-grow-sm" role="status" aria-hidden="true"></span>
Expand Down
2 changes: 1 addition & 1 deletion modules/admin/test/views/admin/FormSerializationSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class FormSerializationSpec extends PlaySpecification with ResourceUtils {

def formData(html: Html): Map[String,String] = {
val elements: java.util.ArrayList[Element] = Jsoup.parse(html.body).select("input")
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
elements.asScala.map(e => e.attr("name") -> e.attr("value")).toMap
}

Expand Down
Loading

0 comments on commit f0a781d

Please sign in to comment.