From a3112df84fb2b1368baa3914c17a47c7723e7dfa Mon Sep 17 00:00:00 2001 From: Mike Bryant Date: Wed, 28 Aug 2024 14:14:53 +0100 Subject: [PATCH] Rollback 2.9 for logback SMTP mailer issues Revert "Update to Play 2.9.5 and Scala 2.13" Revert "Add in temp fix for updating subproject assets." Revert "Update version to (arbitrary) 3.0.0" Revert "Tweak dependencies for mailing, particularly SMTP log appender" More undoing of 2.9 changes --- .travis.yml | 2 +- build.sbt | 66 +- conf/logback-play-dev.xml | 5 +- hungary-items.json | 801 ------------------ modules/admin/app/client/json/package.scala | 60 +- .../admin/app/controllers/admin/Data.scala | 2 +- .../controllers/units/DocumentaryUnits.scala | 2 - .../app/controllers/users/UserProfiles.scala | 2 +- modules/admin/app/models/OaiPmhIdentity.scala | 2 +- modules/admin/app/models/UrlSetConfig.scala | 1 - .../datasets/SqlImportDatasetService.scala | 20 +- .../app/services/ingest/XmlFormatter.scala | 5 +- .../admin/common/accessPointForm.scala.html | 2 +- .../admin/search/inlineItemList.scala.html | 2 +- .../views/admin/userProfile/search.scala.html | 2 +- modules/admin/conf/users.routes | 2 +- .../views/admin/FormSerializationSpec.scala | 2 +- .../api/app/controllers/api/v1/ApiV1.scala | 16 +- .../api/app/views/api/oaipmh/docs.scala.html | 2 + modules/api/app/views/api/v1/docs.scala.html | 4 +- .../services/data/DataServiceError.scala | 3 +- .../services/data/WebServiceHelpers.scala | 10 +- .../src/main/scala/utils/CsvHelpers.scala | 7 +- .../src/main/scala/utils/EnumUtils.scala | 6 +- .../main/scala/utils/binders/package.scala | 4 +- .../data/streams/ByteStringResizerSpec.scala | 4 +- .../controllers/base/CoreActionBuilders.scala | 5 +- .../scala/controllers/generic/Search.scala | 2 +- .../main/scala/forms/mappings/package.scala | 2 +- .../core/src/main/scala/forms/package.scala | 26 - .../src/main/scala/models/Annotation.scala | 8 +- .../main/scala/models/AuthoritativeSet.scala | 4 +- .../core/src/main/scala/models/Concept.scala | 4 +- .../core/src/main/scala/models/Group.scala | 4 +- .../main/scala/models/HistoricalAgent.scala | 4 +- modules/core/src/main/scala/models/Link.scala | 6 +- .../src/main/scala/models/UserProfile.scala | 4 +- .../src/main/scala/models/Vocabulary.scala | 2 +- .../services/accounts/SqlAccountManager.scala | 6 +- .../scala/services/search/SearchQuery.scala | 2 +- .../main/scala/services/search/package.scala | 4 +- .../cookies/SessionPreferencesSpec.scala | 2 +- modules/guides/app/models/Guide.scala | 2 +- modules/guides/app/models/GuidePage.scala | 2 +- .../app/controllers/base/SearchVC.scala | 2 +- .../app/controllers/portal/Feedback.scala | 3 +- .../controllers/portal/account/Accounts.scala | 4 +- .../portal/base/PortalController.scala | 9 +- modules/portal/app/forms/AccountForms.scala | 6 +- modules/portal/app/models/CypherQuery.scala | 2 +- modules/portal/app/models/Feedback.scala | 2 +- modules/portal/app/models/SignupData.scala | 1 + .../feedback/SqlFeedbackService.scala | 6 +- .../geocoding/AwsGeocodingService.scala | 2 +- .../redirects/SqlMovedPageLookup.scala | 6 +- .../search/AkkaStreamsIndexMediator.scala | 4 +- .../search/CmdlineIndexMediator.scala | 4 +- .../search/SearchToolsIndexMediator.scala | 4 +- .../storage/S3CompatibleFileStorage.scala | 8 +- modules/portal/app/views/Helpers.scala | 1 + .../app/views/activity/timeline.scala.html | 2 +- .../app/views/common/listSorting.scala.html | 2 +- .../views/common/search/facetList.scala.html | 8 +- .../common/search/inlineItemList.scala.html | 2 +- .../views/common/search/searchForm.scala.html | 2 +- .../common/search/selectedFacets.scala.html | 2 +- .../userProfile/browseUsersList.scala.html | 4 +- .../test/utils/DateFacetUtilsSpec.scala | 2 +- .../search/solr/SolrQueryBuilder.scala | 6 +- .../ehri/project/xml/XQueryTransformer.scala | 6 +- project/build.properties | 2 +- project/plugins.sbt | 12 +- test/helpers/TestConfiguration.scala | 4 +- test/integration/admin/CypherQuerySpec.scala | 3 +- test/integration/admin/EntityViewsSpec.scala | 2 +- test/integration/admin/IndexingSpec.scala | 5 +- test/integration/admin/IngestSpec.scala | 5 +- test/integration/admin/SearchSpec.scala | 5 +- test/integration/api/v1/ApiV1Spec.scala | 4 +- test/integration/portal/AccountsSpec.scala | 5 +- test/integration/portal/AnnotationsSpec.scala | 4 +- test/integration/portal/PortalSpec.scala | 2 +- test/services/MailerSpec.scala | 2 +- .../accounts/MockAccountManager.scala | 8 +- test/services/data/WsDataServiceSpec.scala | 2 +- version.sbt | 2 +- 86 files changed, 232 insertions(+), 1058 deletions(-) delete mode 100644 hungary-items.json diff --git a/.travis.yml b/.travis.yml index 9b9d064aac..a00e1fa806 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: scala scala: - - 2.13.14 + - 2.12.12 jdk: openjdk8 diff --git a/build.sbt b/build.sbt index 9bd56442f8..ea418f44d4 100644 --- a/build.sbt +++ b/build.sbt @@ -17,19 +17,13 @@ logBuffered := false logLevel := Level.Info ThisBuild / organization := "eu.ehri-project" -val projectScalaVersion = "2.13.14" +val projectScalaVersion = "2.12.12" 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, @@ -48,10 +42,7 @@ val backendDependencies = Seq( "org.apache.jena" % "jena-iri" % "3.9.0", // Ontology - "eu.ehri-project" % "ehri-definitions" % backendVersion, - - // JavaX Mail for logback SMTP appender - "javax.mail" % "javax.mail-api" % "1.5.6", + "eu.ehri-project" % "ehri-definitions" % backendVersion ) val coreDependencies = backendDependencies ++ Seq( @@ -61,9 +52,6 @@ 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, @@ -94,8 +82,8 @@ val coreDependencies = backendDependencies ++ Seq( "org.jsoup" % "jsoup" % "1.11.3", // Mailer... - "com.typesafe.play" %% "play-mailer" % "9.0.0", - "com.typesafe.play" %% "play-mailer-guice" % "9.0.0", + "com.typesafe.play" %% "play-mailer" % "8.0.1", + "com.typesafe.play" %% "play-mailer-guice" % "8.0.1", // Time formatting library "org.ocpsoft.prettytime" % "prettytime" % "3.2.7.Final", @@ -105,6 +93,10 @@ 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)", @@ -137,8 +129,9 @@ val testDependencies = Seq( "com.typesafe.akka" %% "akka-stream-testkit" % akkaVersion % Test ) -val additionalResolvers = Resolver.sonatypeOssRepos("releases") ++ Seq( +val additionalResolvers = Seq( Resolver.mavenLocal, + Resolver.sonatypeRepo("releases"), // EHRI repositories "EHRI Releases" at "https://dev.ehri-project.eu/artifactory/libs-release-local", @@ -146,7 +139,8 @@ val additionalResolvers = Resolver.sonatypeOssRepos("releases") ++ Seq( val validateMessages = TaskKey[Unit]("validate-messages", "Validate messages") -val commonSettings = Seq( +lazy val commonSettings = Seq( + ThisBuild / scalaVersion := projectScalaVersion, // Increase the JVM heap to avoid running @@ -164,20 +158,26 @@ val commonSettings = Seq( "-encoding", "UTF-8", "-Ywarn-unused:imports", "-unchecked", - "-deprecation", - "-Wconf:cat=unused-imports&site=.*views.html.*:s", // Silence import warnings in Play html files + "-deprecation" ), resolvers ++= additionalResolvers, - publish / skip := true, + skip in publish := true, // Disable documentation generation - Compile / doc / sources := Seq.empty, - Compile/ packageDoc / publishArtifact := false + sources in (Compile, doc) := Seq.empty, + + publishArtifact in (Compile, packageDoc) := false ) 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, @@ -193,7 +193,7 @@ val webAppSettings = Seq( import java.io.FileInputStream import java.text.MessageFormat import java.util.Properties - import scala.jdk.CollectionConverters._ + import scala.collection.JavaConverters._ val properties: Properties = new Properties() val fis = new FileInputStream(messageFile) try { @@ -271,12 +271,12 @@ val resourceSettings = Seq( (Compile / PlayKeys.playExternalizedResources) += file("modules/xquery/src/main/resources/xtra.xqm") -> "xtra.xqm", // Filter out excluded resources from packaging - Universal / mappings := (Universal / mappings).value.filterNot { case (f, s) => + mappings in Universal := (mappings in Universal).value.filterNot { case (f, s) => excludedResources contains f.getName }, // Filter out excluded resources from jar generation (even though not used) - Compile / packageBin / mappings := (Compile / packageBin / mappings).value.filterNot { case (f, s) => + mappings in (Compile, packageBin) := (mappings in (Compile, packageBin)).value.filterNot { case (f, s) => excludedResources contains f.getName }, ) @@ -346,10 +346,10 @@ lazy val xslt = Project(appName + "-xslt", file("modules/xslt")) .settings(commonSettings: _*) .settings(libraryDependencies ++= Seq( "javax.inject" % "javax.inject" % "1", - "org.slf4j" % "slf4j-api" % "2.0.13", + "org.slf4j" % "slf4j-api" % "1.7.32", // We need JSON here... - "com.typesafe.play" %% "play-json" % "2.10.0", + "com.typesafe.play" %% "play-json" % "2.8.1", // Saxon for XSLT transformation "net.sf.saxon" % "Saxon-HE" % "10.2", @@ -363,14 +363,14 @@ lazy val xquery = Project(appName + "-xquery", file("modules/xquery")) .settings(resolvers += "BaseX repository" at "https://files.basex.org/maven/") .settings(libraryDependencies ++= Seq( "javax.inject" % "javax.inject" % "1", - "org.slf4j" % "slf4j-api" % "2.0.13", - "ch.qos.logback" % "logback-classic" % "1.5.6", + "org.slf4j" % "slf4j-api" % "1.7.32", + "ch.qos.logback" % "logback-classic" % "1.2.5", // EAD transformation... "org.basex" % "basex" % "8.5", // Command line parsing - "com.github.scopt" %% "scopt" % "4.1.0", + "com.github.scopt" %% "scopt" % "4.0.1", specs2 % Test, )) @@ -439,10 +439,10 @@ lazy val main = Project(appName, file(".")) .settings(libraryDependencies ++= coreDependencies ++ testDependencies) .settings(commonSettings ++ webAppSettings ++ resourceSettings) .settings( - publish / skip := false, + skip in publish := false, // Tell sbt that we only want a tgz, not a zip - makeDeploymentSettings(Universal, Universal / packageBin, "tgz"), + makeDeploymentSettings(Universal, packageBin in Universal, "tgz"), // Remove top-level directory from package zip topLevelDirectory := None, diff --git a/conf/logback-play-dev.xml b/conf/logback-play-dev.xml index 4e271d83fc..0996eefbbd 100644 --- a/conf/logback-play-dev.xml +++ b/conf/logback-play-dev.xml @@ -3,6 +3,8 @@ --> + + ${application.home}/logs/application.log @@ -21,7 +23,7 @@ - %highlight(%-5level) %logger{15} - %message%n%xException{5} + %coloredLevel %logger{15} - %message%n%xException{5} @@ -49,7 +51,6 @@ - diff --git a/hungary-items.json b/hungary-items.json deleted file mode 100644 index fd61dc1a96..0000000000 --- a/hungary-items.json +++ /dev/null @@ -1,801 +0,0 @@ -{ - "data" : { - "Country" : { - "repositories" : { - "items" : [ { - "id" : "hu-006596", - "itemCount" : 1, - "documentaryUnits" : { - "items" : [ { - "id" : "hu-006596-01" - } ] - } - }, { - "id" : "hu-006595", - "itemCount" : 1, - "documentaryUnits" : { - "items" : [ { - "id" : "hu-006595-01" - } ] - } - }, { - "id" : "hu-006589", - "itemCount" : 3, - "documentaryUnits" : { - "items" : [ { - "id" : "hu-006589-003" - }, { - "id" : "hu-006589-002" - }, { - "id" : "hu-006589-001" - } ] - } - }, { - "id" : "hu-006082", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-006081", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-006080", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-006075", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-006079", - "itemCount" : 1, - "documentaryUnits" : { - "items" : [ { - "id" : "hu-006079-v_83" - } ] - } - }, { - "id" : "hu-006078", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-006077", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-006074", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-00212", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-006072", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-006071", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-006070", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-006083", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-006067", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-006066", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-006065", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-006068", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-006062", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-006061", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-006060", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-006059", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-006064", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-006063", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-006057", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-006058", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-006056", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-006049", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-006048", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-006050", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-006053", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-006051", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-006054", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-006052", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-006055", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-002761", - "itemCount" : 3, - "documentaryUnits" : { - "items" : [ { - "id" : "hu-002761-xxiv_10" - }, { - "id" : "hu-002761-v_183" - }, { - "id" : "hu-002761-iv_454" - } ] - } - }, { - "id" : "hu-002736", - "itemCount" : 6, - "documentaryUnits" : { - "items" : [ { - "id" : "hu-002736-személyes_gyűjtemények_1848_1956" - }, { - "id" : "hu-002736-visszaemlékezések_gyűjteménye_1945_2010" - }, { - "id" : "hu-002736-koncentrációs_táborokkal_kapcsolatos_gyűjtemény" - }, { - "id" : "hu-002736-áldozati_nevekkel_kapcsolatos_gyűjtemény" - }, { - "id" : "hu-002736-aprónyomtatványok_gyűjteménye" - }, { - "id" : "hu-002736-munkaszolgálatos_gyűjtemény_1939_1945" - } ] - } - }, { - "id" : "hu-002770", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-002750", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-002762", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-002767", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-002737", - "itemCount" : 29, - "documentaryUnits" : { - "items" : [ { - "id" : "hu-002737-hu_hja_ix" - }, { - "id" : "hu-002737-hu_hja_xiii" - }, { - "id" : "hu-002737-hu_hja_xxiv" - }, { - "id" : "hu-002737-hu_hja_xx" - }, { - "id" : "hu-002737-hu_hja_xvi_a" - }, { - "id" : "hu-002737-hu_hja_ii" - }, { - "id" : "hu-002737-hu_hja_xii" - }, { - "id" : "hu-002737-hu_hja_xvi_b" - }, { - "id" : "hu-002737-hu_hja_xviii" - }, { - "id" : "hu-002737-mol_xxxiii_4_a" - }, { - "id" : "hu-002737-hu_hja_xix" - }, { - "id" : "hu-002737-hu_hja_pih_i_m" - }, { - "id" : "hu-002737-hu_hja_xx-c-hu_hja_xx_c_4" - }, { - "id" : "hu-002737-hu_hja_xxiv_a" - }, { - "id" : "hu-002737-hu_hja_xx-c-hu_hja_xx_c_5" - }, { - "id" : "hu-002737-hu_hja_xx-c-hu_hja_xx_c_1" - }, { - "id" : "hu-002737-hu_hja_xx-c-hu_hja_xx_c_3" - }, { - "id" : "hu-002737-hu_hja_xx-xx_g" - }, { - "id" : "hu-002737-hu_hja_xx-f-hu_hja_xx_f_2" - }, { - "id" : "hu-002737-hu_hja_xx-c-hu_hja_xx_c_6" - }, { - "id" : "hu-002737-hu_hja_pih_i_k" - }, { - "id" : "hu-002737-hu_hja_xx-d-hu_hja_xx_d_1" - }, { - "id" : "hu-002737-hu_hja_xx-xx_i" - }, { - "id" : "hu-002737-hu_hja_xx-xx_j" - }, { - "id" : "hu-002737-hu_hja_xv_b" - }, { - "id" : "hu-002737-hu_hja_xx-xx_p" - }, { - "id" : "hu-002737-hu_hja_xx-m_1" - }, { - "id" : "hu-002737-hu_hja_xx-xx_l" - }, { - "id" : "hu-002737-hu_hja_xxiv_c" - } ] - } - }, { - "id" : "hu-002733", - "itemCount" : 9, - "documentaryUnits" : { - "items" : [ { - "id" : "hu-002733-hu_bfl_vi" - }, { - "id" : "hu-002733-hu_bfl_iv_1411" - }, { - "id" : "hu-002733-hu_bfl_xvii_2" - }, { - "id" : "hu-002733-hu_bfl_vii" - }, { - "id" : "hu-002733-hu_bfl_iv_1470_83" - }, { - "id" : "hu-002733-hu_bfl_iv_1419" - }, { - "id" : "hu-002733-hu_bfl_iv_1402_1429" - }, { - "id" : "hu-002733-hu_bfl_xxv_1_a" - }, { - "id" : "hu-002733-bfl_vii_5_e" - } ] - } - }, { - "id" : "hu-002766", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-002774", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-002756", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-002748", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-002771", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-002743", - "itemCount" : 15, - "documentaryUnits" : { - "items" : [ { - "id" : "hu-002743-iv_421_449" - }, { - "id" : "hu-002743-v_73" - }, { - "id" : "hu-002743-iv_902" - }, { - "id" : "hu-002743-iv_410" - }, { - "id" : "hu-002743-iv_415" - }, { - "id" : "hu-002743-iv_403" - }, { - "id" : "hu-002743-iv_401" - }, { - "id" : "hu-002743-xiv_2" - }, { - "id" : "hu-002743-vii_1" - }, { - "id" : "hu-002743-xvii_401" - }, { - "id" : "hu-002743-xxv_1" - }, { - "id" : "hu-002743-v_276" - }, { - "id" : "hu-002743-vi_101" - }, { - "id" : "hu-002743-vi_3" - }, { - "id" : "hu-002743-iv_b_408" - } ] - } - }, { - "id" : "hu-002752", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-002768", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-002742", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-002759", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-002773", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-002732", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-002745", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-002755", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-002749", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-002735", - "itemCount" : 1, - "documentaryUnits" : { - "items" : [ { - "id" : "hu-002735-hu_ábtl_39_018" - } ] - } - }, { - "id" : "hu-002753", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-002747", - "itemCount" : 7, - "documentaryUnits" : { - "items" : [ { - "id" : "hu-002747-v_173" - }, { - "id" : "hu-002747-v_73" - }, { - "id" : "hu-002747-iv_411" - }, { - "id" : "hu-002747-iv_410" - }, { - "id" : "hu-002747-iv_409" - }, { - "id" : "hu-002747-vi_102" - }, { - "id" : "hu-002747-iv_404" - } ] - } - }, { - "id" : "hu-004862", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-002758", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-002763", - "itemCount" : 2, - "documentaryUnits" : { - "items" : [ { - "id" : "hu-002763-iv_1404" - }, { - "id" : "hu-002763-iv_409" - } ] - } - }, { - "id" : "hu-002764", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-002751", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-002765", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-002760", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-002769", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-002734", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-004861", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-002739", - "itemCount" : 83, - "documentaryUnits" : { - "items" : [ { - "id" : "hu-002739-mnl_ol_p_1351" - }, { - "id" : "hu-002739-mnl_ol_k_750" - }, { - "id" : "hu-002739-mnl_ol_k_494" - }, { - "id" : "hu-002739-mnl_ol_k_519" - }, { - "id" : "hu-002739-mnl_ol_k_523" - }, { - "id" : "hu-002739-mnl_ol_k494" - }, { - "id" : "hu-002739-mnl_ol_k_492" - }, { - "id" : "hu-002739-mnl_ol_k_70" - }, { - "id" : "hu-002739-mnl_ol_xx_4" - }, { - "id" : "hu-002739-mnl_ol_k_101" - }, { - "id" : "hu-002739-mnl_ol_k_119" - }, { - "id" : "hu-002739-mnl_ol_k_109" - }, { - "id" : "hu-002739-mnl_ol_k_107" - }, { - "id" : "hu-002739-mnl_ol_k_589" - }, { - "id" : "hu-002739-mnl_ol_k_28" - }, { - "id" : "hu-002739-mnl_ol_xxxiii_9" - }, { - "id" : "hu-002739-mnl_ol_k_66" - }, { - "id" : "hu-002739-mnl_ol_k_71" - }, { - "id" : "hu-002739-mnl_ol_k_165" - }, { - "id" : "hu-002739-mnl_ol_k_81" - }, { - "id" : "hu-002739-mnl_ol_k_85" - }, { - "id" : "hu-002739-mnl_ol_p_2066" - }, { - "id" : "hu-002739-mnl_ol_xix_l_beg" - }, { - "id" : "hu-002739-mnl_ol_p_2210" - }, { - "id" : "hu-002739-mnl_ol_k_99" - }, { - "id" : "hu-002739-mnl_ol_k_105" - }, { - "id" : "hu-002739-mnl_ol_k_7" - }, { - "id" : "hu-002739-mnl_ol_k_83" - }, { - "id" : "hu-002739-mnl_ol_k_84" - }, { - "id" : "hu-002739-mnl_ol_k_448" - }, { - "id" : "hu-002739-mnl_ol_k_648" - }, { - "id" : "hu-002739-mnl_ol_k_638" - }, { - "id" : "hu-002739-mnl_ol_k_643" - }, { - "id" : "hu-002739-mnl_ol_xix_a_5" - }, { - "id" : "hu-002739-mnl_ol_x_1320" - }, { - "id" : "hu-002739-mnl_ol_xix_20_l_o" - }, { - "id" : "hu-002739-mnl_ol_k_615" - }, { - "id" : "hu-002739-mnl_ol_k_273" - }, { - "id" : "hu-002739-mnl_ol_k_613" - }, { - "id" : "hu-002739-mnl_ol_k_428" - }, { - "id" : "hu-002739-mnl_ol_k_675" - }, { - "id" : "hu-002739-mnl_ol_z_936" - }, { - "id" : "hu-002739-mnl_ol_k_36" - }, { - "id" : "hu-002739-mnl_ol_k_37" - }, { - "id" : "hu-002739-mnl_ol_k_245" - }, { - "id" : "hu-002739-mnl_ol_k_38" - }, { - "id" : "hu-002739-mnl_ol_k_39" - }, { - "id" : "hu-002739-mnl_ol_k_429" - }, { - "id" : "hu-002739-mnl_ol_k_490" - }, { - "id" : "hu-002739-mnl_ol_k_491" - }, { - "id" : "hu-002739-mnl_ol_k_266" - }, { - "id" : "hu-002739-mnl_ol_k_469" - }, { - "id" : "hu-002739-mnl_ol_k_148" - }, { - "id" : "hu-002739-mnl_ol_k_149" - }, { - "id" : "hu-002739-mnl_ol_k_150" - }, { - "id" : "hu-002739-mnl_ol_k_254" - }, { - "id" : "hu-002739-mnl_ol_k_69" - }, { - "id" : "hu-002739-mnl_ol_k_707" - }, { - "id" : "hu-002739-mnl_ol_k_577_579" - }, { - "id" : "hu-002739-mnl_ol_k_800" - }, { - "id" : "hu-002739-mnl_ol_k_775" - }, { - "id" : "hu-002739-mnl_ol_k_63_64" - }, { - "id" : "hu-002739-mnl_ol_k_59_61" - }, { - "id" : "hu-002739-mnl_ol_k_239" - }, { - "id" : "hu-002739-mnl_ol_k_184" - }, { - "id" : "hu-002739-mnl_ol_k_654" - }, { - "id" : "hu-002739-mnl_ol_k_280" - }, { - "id" : "hu-002739-mnl_ol_k_256" - }, { - "id" : "hu-002739-mnl_ol_k_58" - }, { - "id" : "hu-002739-mnl_ol_k_79" - }, { - "id" : "hu-002739-mnl_ol_k_2" - }, { - "id" : "hu-002739-mnl_ol_k_588" - }, { - "id" : "hu-002739-mnl_ol_k_774" - }, { - "id" : "hu-002739-mnl_ol_k_34" - }, { - "id" : "hu-002739-mnl_ol_k_466" - }, { - "id" : "hu-002739-mnl_ol_k_29" - }, { - "id" : "hu-002739-mnl_ol_k_26" - }, { - "id" : "hu-002739-mnl_ol_k_27" - }, { - "id" : "hu-002739-mnl_ol_k_35" - }, { - "id" : "hu-002739-mnl_ol_k_498" - }, { - "id" : "hu-002739-mnl_ol_k_612" - }, { - "id" : "hu-002739-mnl_ol_k_178" - }, { - "id" : "hu-002739-mnl_ol_k_269" - } ] - } - }, { - "id" : "hu-002772", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-002741", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - }, { - "id" : "hu-002738", - "itemCount" : 1, - "documentaryUnits" : { - "items" : [ { - "id" : "hu-002738-i_31" - } ] - } - }, { - "id" : "hu-002754", - "itemCount" : 0, - "documentaryUnits" : { - "items" : [ ] - } - } ] - } - } - } -} \ No newline at end of file diff --git a/modules/admin/app/client/json/package.scala b/modules/admin/app/client/json/package.scala index ad189e6d23..83ebb4185e 100644 --- a/modules/admin/app/client/json/package.scala +++ b/modules/admin/app/client/json/package.scala @@ -1,10 +1,10 @@ package client import models.json._ -import models._ +import models.{Entity, EntityType, _} import play.api.Logger import play.api.libs.functional.syntax._ -import play.api.libs.json._ +import play.api.libs.json.{JsObject, KeyPathNode, _} import utils.EnumUtils package object json { @@ -68,7 +68,7 @@ package object json { } implicit object permissionGrantJson extends ClientWriteable[PermissionGrant] { - private implicit val permissionGrantFormat: OFormat[models.PermissionGrantF] = Json.format[PermissionGrantF] + private implicit val permissionGrantFormat = Json.format[PermissionGrantF] implicit val clientFormat: Format[PermissionGrant] = ( JsPath.format(permissionGrantFormat) and (__ \ "accessor").lazyFormatNullable[Accessor](accessorJson.clientFormat) and @@ -84,7 +84,7 @@ package object json { } implicit object linkJson extends ClientWriteable[Link] { - private implicit val linkFormat: OFormat[models.LinkF] = Json.format[LinkF] + private implicit val linkFormat = Json.format[LinkF] val clientFormat: Format[Link] = ( JsPath.format[LinkF](linkFormat) and (__ \ "targets").formatSeqOrEmpty(anyModelJson.clientFormat) and @@ -111,7 +111,7 @@ package object json { } implicit object versionJson extends ClientWriteable[Version] { - private implicit val fFormat: OFormat[models.VersionF] = Json.format[VersionF] + private implicit val fFormat = Json.format[VersionF] implicit val clientFormat: Format[Version] = ( JsPath.format[VersionF](fFormat) and (__ \ "event").lazyFormatNullable(systemEventJson.clientFormat) and @@ -130,7 +130,7 @@ package object json { } implicit object systemEventJson extends ClientWriteable[SystemEvent] { - private implicit val fFormat: OFormat[models.SystemEventF] = Json.format[SystemEventF] + private implicit val fFormat = Json.format[SystemEventF] implicit val clientFormat: Format[SystemEvent] = ( JsPath.format[SystemEventF](fFormat) and @@ -182,42 +182,42 @@ package object json { } implicit object documentaryUnitDescriptionJson extends ClientWriteable[DocumentaryUnitDescriptionF] { - 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] + 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] val clientFormat: Format[DocumentaryUnitDescriptionF] = Json.format[DocumentaryUnitDescriptionF] } implicit object historicalAgentDescriptionJson extends ClientWriteable[HistoricalAgentDescriptionF] { - 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] + 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] val clientFormat: Format[HistoricalAgentDescriptionF] = Json.format[HistoricalAgentDescriptionF] } implicit object repositoryDescriptionJson extends ClientWriteable[RepositoryDescriptionF] { - 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] + 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] val clientFormat: Format[RepositoryDescriptionF] = Json.format[RepositoryDescriptionF] } implicit object conceptDescriptionJson extends ClientWriteable[ConceptDescriptionF] { - private implicit val accessPointFormat: Format[models.AccessPoint] = accessPointJson.clientFormat + private implicit val accessPointFormat = accessPointJson.clientFormat lazy val clientFormat: Format[ConceptDescriptionF] = Json.format[ConceptDescriptionF] } implicit object historicalAgentJson extends ClientWriteable[HistoricalAgent] { - private implicit val haDescFmt: Format[models.HistoricalAgentDescriptionF] = historicalAgentDescriptionJson.clientFormat + private implicit val haDescFmt = historicalAgentDescriptionJson.clientFormat private val fFormat = Json.format[HistoricalAgentF] val clientFormat: Format[HistoricalAgent] = ( @@ -230,7 +230,7 @@ package object json { } implicit object repositoryJson extends ClientWriteable[Repository] { - private implicit val repoDescFmt: Format[models.RepositoryDescriptionF] = repositoryDescriptionJson.clientFormat + private implicit val repoDescFmt = repositoryDescriptionJson.clientFormat private val fFormat = Json.format[RepositoryF] val clientFormat: Format[Repository] = ( @@ -243,7 +243,7 @@ package object json { } implicit object documentaryUnitJson extends ClientWriteable[DocumentaryUnit] { - private implicit val docDescFmt: Format[models.DocumentaryUnitDescriptionF] = documentaryUnitDescriptionJson.clientFormat + private implicit val docDescFmt = documentaryUnitDescriptionJson.clientFormat private val fFormat = Json.format[DocumentaryUnitF] lazy val clientFormat: Format[DocumentaryUnit] = ( JsPath.format(fFormat) and @@ -256,7 +256,7 @@ package object json { } implicit object virtualUnitJson extends ClientWriteable[VirtualUnit] { - private implicit val vuDescFmt: Format[models.DocumentaryUnitDescriptionF] = documentaryUnitDescriptionJson.clientFormat + private implicit val vuDescFmt = documentaryUnitDescriptionJson.clientFormat private val fFormat = Json.format[VirtualUnitF] lazy val clientFormat: Format[VirtualUnit] = ( @@ -297,7 +297,7 @@ package object json { implicit object conceptJson extends ClientWriteable[Concept] { - private implicit val fdFormat: Format[models.ConceptDescriptionF] = conceptDescriptionJson.clientFormat + private implicit val fdFormat = conceptDescriptionJson.clientFormat implicit val fFormat: Format[ConceptF] = Json.format[ConceptF] val clientFormat: Format[Concept] = ( JsPath.format[ConceptF](fFormat) and diff --git a/modules/admin/app/controllers/admin/Data.scala b/modules/admin/app/controllers/admin/Data.scala index 87b269d31d..58ba20dd04 100644 --- a/modules/admin/app/controllers/admin/Data.scala +++ b/modules/admin/app/controllers/admin/Data.scala @@ -17,7 +17,7 @@ case class Data @Inject()( implicit val rd: Readable[Model] = Model.Converter - private def passThroughHeaders(headers: Map[String, scala.collection.Seq[String]], + private def passThroughHeaders(headers: Map[String, 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) diff --git a/modules/admin/app/controllers/units/DocumentaryUnits.scala b/modules/admin/app/controllers/units/DocumentaryUnits.scala index fe5cde7ead..7672ac0a16 100644 --- a/modules/admin/app/controllers/units/DocumentaryUnits.scala +++ b/modules/admin/app/controllers/units/DocumentaryUnits.scala @@ -149,9 +149,7 @@ 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)) diff --git a/modules/admin/app/controllers/users/UserProfiles.scala b/modules/admin/app/controllers/users/UserProfiles.scala index 575b90d85a..b90aba6de2 100644 --- a/modules/admin/app/controllers/users/UserProfiles.scala +++ b/modules/admin/app/controllers/users/UserProfiles.scala @@ -211,7 +211,7 @@ case class UserProfiles @Inject()( Ok(views.html.admin.userProfile.list(request.page, request.params)) } - def exportInfo: 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) diff --git a/modules/admin/app/models/OaiPmhIdentity.scala b/modules/admin/app/models/OaiPmhIdentity.scala index 00775f2ceb..3de2f5326e 100644 --- a/modules/admin/app/models/OaiPmhIdentity.scala +++ b/modules/admin/app/models/OaiPmhIdentity.scala @@ -15,7 +15,7 @@ object OaiPmhIdentity { val Day = Value("YYYY-MM-DD") val Second = Value("YYYY-MM-DDThh:mm:ssZ") - implicit val _format: Format[models.OaiPmhIdentity.Granularity.Value] = EnumUtils.enumFormat(Granularity) + implicit val _format = EnumUtils.enumFormat(Granularity) } implicit val _format: Format[OaiPmhIdentity] = Json.format[OaiPmhIdentity] diff --git a/modules/admin/app/models/UrlSetConfig.scala b/modules/admin/app/models/UrlSetConfig.scala index f5013b4d35..e54fdd8675 100644 --- a/modules/admin/app/models/UrlSetConfig.scala +++ b/modules/admin/app/models/UrlSetConfig.scala @@ -2,7 +2,6 @@ package models import akka.http.scaladsl.model.HttpMethods - case class UrlNameMap(url: String, name: String) case class UrlSetConfig( diff --git a/modules/admin/app/services/datasets/SqlImportDatasetService.scala b/modules/admin/app/services/datasets/SqlImportDatasetService.scala index 6ba2cf61c8..8ba346899a 100644 --- a/modules/admin/app/services/datasets/SqlImportDatasetService.scala +++ b/modules/admin/app/services/datasets/SqlImportDatasetService.scala @@ -97,16 +97,16 @@ case class SqlImportDatasetService @Inject()(db: Database, actorSystem: ActorSys db.withTransaction { implicit conn => val inserts = info.map { item => Seq[NamedParameter]( - 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("nest") -> item.nest, - Symbol("sync") -> item.sync, - Symbol("status") -> item.status, - Symbol("comments") -> item.notes + 'repo_id -> repoId, + 'id -> item.id, + 'name -> item.name, + 'type -> item.src, + 'content_type -> item.contentType, + 'item_id -> item.fonds.filter(_.trim.nonEmpty), + 'nest -> item.nest, + 'sync -> item.sync, + 'status -> item.status, + 'comments -> item.notes ) } val q = """INSERT INTO import_dataset (repo_id, id, name, type, content_type, item_id, sync, status, comments) diff --git a/modules/admin/app/services/ingest/XmlFormatter.scala b/modules/admin/app/services/ingest/XmlFormatter.scala index 0e22e042b4..0666fe2cfd 100644 --- a/modules/admin/app/services/ingest/XmlFormatter.scala +++ b/modules/admin/app/services/ingest/XmlFormatter.scala @@ -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)) @@ -79,6 +79,9 @@ 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) } diff --git a/modules/admin/app/views/admin/common/accessPointForm.scala.html b/modules/admin/app/views/admin/common/accessPointForm.scala.html index 988a67ea90..bb782db81f 100644 --- a/modules/admin/app/views/admin/common/accessPointForm.scala.html +++ b/modules/admin/app/views/admin/common/accessPointForm.scala.html @@ -27,7 +27,7 @@ }, labels: { - @AccessPointF.AccessPointType.values.toSeq.map { apt => @apt: "@Messages("accessPoint.type." + apt)", + @AccessPointF.AccessPointType.values.map { apt => @apt: "@Messages("accessPoint.type." + apt)", } } } diff --git a/modules/admin/app/views/admin/search/inlineItemList.scala.html b/modules/admin/app/views/admin/search/inlineItemList.scala.html index b918064feb..b230800b5e 100644 --- a/modules/admin/app/views/admin/search/inlineItemList.scala.html +++ b/modules/admin/app/views/admin/search/inlineItemList.scala.html @@ -33,7 +33,7 @@
@views.html.admin.helpers.linkTo(child)
@if(result.page.hasMore) { @Messages("activity.fetchMore") diff --git a/modules/admin/app/views/admin/userProfile/search.scala.html b/modules/admin/app/views/admin/userProfile/search.scala.html index f15a4f3ce8..2a8fa9946a 100644 --- a/modules/admin/app/views/admin/userProfile/search.scala.html +++ b/modules/admin/app/views/admin/userProfile/search.scala.html @@ -13,7 +13,7 @@ } @views.html.admin.common.sidebarAction(user.isAdmin) { - + @Messages("userProfile.export") diff --git a/modules/admin/conf/users.routes b/modules/admin/conf/users.routes index 5c4f7f694e..235bdd8e2a 100644 --- a/modules/admin/conf/users.routes +++ b/modules/admin/conf/users.routes @@ -2,7 +2,7 @@ GET / @controllers.users.UserProfiles.search(params: services.search.SearchParams ?= services.search.SearchParams.empty, paging: utils.PageParams ?= utils.PageParams.empty) GET /list @controllers.users.UserProfiles.list(paging: utils.PageParams ?= utils.PageParams.empty) -GET /export @controllers.users.UserProfiles.exportInfo() +GET /export @controllers.users.UserProfiles.export() GET /create @controllers.users.UserProfiles.createUser() POST /create @controllers.users.UserProfiles.createUserPost() GET /syncDb @controllers.users.UserProfiles.syncFromDbPost() diff --git a/modules/admin/test/views/admin/FormSerializationSpec.scala b/modules/admin/test/views/admin/FormSerializationSpec.scala index fc085afb86..b350445c99 100644 --- a/modules/admin/test/views/admin/FormSerializationSpec.scala +++ b/modules/admin/test/views/admin/FormSerializationSpec.scala @@ -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.jdk.CollectionConverters._ + import scala.collection.JavaConverters._ elements.asScala.map(e => e.attr("name") -> e.attr("value")).toMap } diff --git a/modules/api/app/controllers/api/v1/ApiV1.scala b/modules/api/app/controllers/api/v1/ApiV1.scala index f81e231915..92b1e19bef 100644 --- a/modules/api/app/controllers/api/v1/ApiV1.scala +++ b/modules/api/app/controllers/api/v1/ApiV1.scala @@ -2,8 +2,9 @@ package controllers.api.v1 import akka.stream.Materializer import auth.handler.AuthHandler +import views.AppConfig import controllers.AppComponents -import controllers.base.{CoreActionBuilders, SearchRelated, SearchVC} +import controllers.base.{ControllerHelpers, CoreActionBuilders, SearchRelated, SearchVC} import controllers.generic.Search import lifecycle.ItemLifecycle import models._ @@ -25,7 +26,7 @@ import services.redirects.MovedPageLookup import services.search.SearchConstants._ import services.search._ import utils.{DateFacetUtils, FieldFilter, Page, PageParams} -import views.{AppConfig, Helpers} +import views.Helpers import java.time.ZonedDateTime import javax.inject.{Inject, Singleton} @@ -60,6 +61,7 @@ case class ApiV1 @Inject()( mat: Materializer, dfu: DateFacetUtils ) extends CoreActionBuilders + with ControllerHelpers with Search with SearchVC with SearchRelated { @@ -184,11 +186,11 @@ case class ApiV1 @Inject()( JsObject(js.fields.filter { case (k, v) => keys.contains(k) }) def filterType(js: JsObject, filter: FieldFilter): JsObject = - (for { - tp <- js.value.get("type") if tp == JsString(filter.et.toString) - attrs <- js.value.get("attributes").flatMap(_.asOpt[JsObject]) - } yield JsObject(js.value.toMap.updated("attributes", filterObject(attrs, filter.fields)).toSeq)) - .getOrElse(js) + (for { + tp <- js.value.get("type") if tp == JsString(filter.et.toString) + attrs <- js.value.get("attributes").flatMap(_.asOpt[JsObject]) + } yield JsObject(js.value.updated("attributes", filterObject(attrs, filter.fields)).toSeq)) + .getOrElse(js) fields.foldLeft(js.as[JsObject])(filterType) } diff --git a/modules/api/app/views/api/oaipmh/docs.scala.html b/modules/api/app/views/api/oaipmh/docs.scala.html index 84db3d0c08..72e914a08e 100644 --- a/modules/api/app/views/api/oaipmh/docs.scala.html +++ b/modules/api/app/views/api/oaipmh/docs.scala.html @@ -1,5 +1,7 @@ @()(implicit userOpt: Option[UserProfile] = None, req: RequestHeader, conf: AppConfig, messages: Messages, prefs: SessionPrefs, flash: Flash) +@import play.api.libs.json.Json + @views.html.api.layout.apiDocLayout(Messages("api.oaipmh.header")) {
diff --git a/modules/api/app/views/api/v1/docs.scala.html b/modules/api/app/views/api/v1/docs.scala.html index 73c0ea5e1e..d4a96d0ae0 100644 --- a/modules/api/app/views/api/v1/docs.scala.html +++ b/modules/api/app/views/api/v1/docs.scala.html @@ -33,7 +33,7 @@ @@ -42,7 +42,7 @@ diff --git a/modules/backend/src/main/scala/services/data/DataServiceError.scala b/modules/backend/src/main/scala/services/data/DataServiceError.scala index 95ce88e30d..885b4cb7d4 100644 --- a/modules/backend/src/main/scala/services/data/DataServiceError.scala +++ b/modules/backend/src/main/scala/services/data/DataServiceError.scala @@ -3,7 +3,6 @@ package services.data import play.api.libs.functional.syntax._ import play.api.libs.json._ import play.api.mvc.RequestHeader -import scala.collection import java.time.ZonedDateTime @@ -81,7 +80,7 @@ case class ItemNotFound( case class CriticalError(error: String) extends RuntimeException(error) with DataServiceError case class BadJson( - error: collection.Seq[(JsPath, collection.Seq[JsonValidationError])], + error: Seq[(JsPath,Seq[JsonValidationError])], url: Option[String] = None, data: Option[String] = None ) extends RuntimeException(error.toString) with DataServiceError { diff --git a/modules/backend/src/main/scala/services/data/WebServiceHelpers.scala b/modules/backend/src/main/scala/services/data/WebServiceHelpers.scala index e066d1ef05..33e7833638 100644 --- a/modules/backend/src/main/scala/services/data/WebServiceHelpers.scala +++ b/modules/backend/src/main/scala/services/data/WebServiceHelpers.scala @@ -277,10 +277,7 @@ trait WebServiceHelpers { private[data] def parsePage[T](response: WSResponse, context: Option[String])(implicit rd: Reads[T]): Page[T] = { checkError(response).json.validate(Reads.seq(rd)).fold( invalid => throw BadJson( - invalid, - url = context, - data = Some(Json.prettyPrint(response.json)) - ), + invalid, url = context, data = Some(Json.prettyPrint(response.json))), items => parsePagination(response, context) match { case Some((offset, limit, total)) => Page( items = items, @@ -296,10 +293,7 @@ trait WebServiceHelpers { private[data] def jsonReadToRestError[T](json: JsValue, reader: Reads[T], context: Option[String] = None): T = { json.validate(reader).fold( invalid => throw BadJson( - invalid, - url = context, - data = Some(Json.prettyPrint(json)) - ), + invalid, url = context, data = Some(Json.prettyPrint(json))), valid => valid ) } diff --git a/modules/backend/src/main/scala/utils/CsvHelpers.scala b/modules/backend/src/main/scala/utils/CsvHelpers.scala index c968bbbfea..ac2595106e 100644 --- a/modules/backend/src/main/scala/utils/CsvHelpers.scala +++ b/modules/backend/src/main/scala/utils/CsvHelpers.scala @@ -6,8 +6,11 @@ import akka.stream.scaladsl.Source trait CsvHelpers { def writeCsv(headers: Seq[String], data: Seq[Array[String]], sep: Char = ','): Source[String, NotUsed] = { - val s: Seq[Seq[String]] = headers +: data.map(_.toSeq) - val src: Source[Seq[String], NotUsed] = Source.apply(s.toList) + + val s: Seq[scala.collection.immutable.Iterable[String]] = (headers +: data.map(_.toSeq)) + .map(_.to[scala.collection.immutable.Iterable]) + + val src: Source[scala.collection.immutable.Iterable[String], NotUsed] = Source.apply(s.toList) val csvFormat = CsvFormatting.format(delimiter = sep) src.via(csvFormat).map(_.utf8String) } diff --git a/modules/backend/src/main/scala/utils/EnumUtils.scala b/modules/backend/src/main/scala/utils/EnumUtils.scala index 0e4ca6ade5..724133142d 100644 --- a/modules/backend/src/main/scala/utils/EnumUtils.scala +++ b/modules/backend/src/main/scala/utils/EnumUtils.scala @@ -24,7 +24,7 @@ object EnumUtils { def enumWrites[E <: Enumeration]: Writes[E#Value] = Writes[E#Value](v => JsString(v.toString)) - def enumFormat[E <: Enumeration](`enum`: E): Format[E#Value] = Format(enumReads(enum), enumWrites) + def enumFormat[E <: Enumeration](enum: E): Format[E#Value] = Format(enumReads(enum), enumWrites) /** * Constructs a simple mapping for a text field (mapped as `scala.Enumeration`) @@ -36,7 +36,7 @@ object EnumUtils { * * @param enum the Enumeration#Value */ - def enumMapping[E <: Enumeration](`enum`: E): Mapping[E#Value] = Forms.of(enumFormBinder(enum)) + def enumMapping[E <: Enumeration](enum: E): Mapping[E#Value] = Forms.of(enumFormBinder(enum)) /** * Default formatter for `scala.Enumeration` @@ -44,7 +44,7 @@ object EnumUtils { */ private def enumFormBinder[E <: Enumeration](e: E): Formatter[E#Value] = new Formatter[E#Value] { def bind(key: String, data: Map[String, String]): Either[Seq[FormError], E#Value] = { - play.api.data.format.Formats.stringFormat.bind(key, data).flatMap { s => + play.api.data.format.Formats.stringFormat.bind(key, data).right.flatMap { s => scala.util.control.Exception.allCatch[E#Value] .either(e.withName(s)) .left.map(e => Seq(FormError(key, "errors.invalidValue", Nil))) diff --git a/modules/backend/src/main/scala/utils/binders/package.scala b/modules/backend/src/main/scala/utils/binders/package.scala index 7eb59b3c1b..b2c755e2f5 100644 --- a/modules/backend/src/main/scala/utils/binders/package.scala +++ b/modules/backend/src/main/scala/utils/binders/package.scala @@ -17,7 +17,7 @@ import scala.annotation.tailrec */ package object binders { - def bindableEnum[E <: Enumeration](`enum`: E): PathBindable[E#Value] = new PathBindable[E#Value] { + def bindableEnum[E <: Enumeration](enum: E): PathBindable[E#Value] = new PathBindable[E#Value] { def bind(key: String, value: String): Either[String, enum.Value] = enum.values.find(_.toString.toLowerCase == value.toLowerCase) match { case Some(v) => Right(v) @@ -27,7 +27,7 @@ package object binders { def unbind(key: String, value: E#Value): String = value.toString.toLowerCase } - def queryStringBinder[E <: Enumeration](`enum`: E)(implicit stringBinder: QueryStringBindable[String]): QueryStringBindable[E#Value] = + def queryStringBinder[E <: Enumeration](enum: E)(implicit stringBinder: QueryStringBindable[String]): QueryStringBindable[E#Value] = new QueryStringBindable[E#Value] { override def bind(key: String, params: Map[String, Seq[String]]): Option[Either[String, E#Value]] = for (v <- stringBinder.bind(key, params)) yield v match { diff --git a/modules/backend/src/test/scala/services/data/streams/ByteStringResizerSpec.scala b/modules/backend/src/test/scala/services/data/streams/ByteStringResizerSpec.scala index 41ac02ff73..d5abc28b3f 100644 --- a/modules/backend/src/test/scala/services/data/streams/ByteStringResizerSpec.scala +++ b/modules/backend/src/test/scala/services/data/streams/ByteStringResizerSpec.scala @@ -11,8 +11,8 @@ import scala.concurrent.duration._ class ByteStringResizerSpec extends PlaySpecification { - private implicit val as: akka.actor.ActorSystem = ActorSystem.create("testing") - private implicit val mat: akka.stream.Materializer = Materializer(as) + private implicit val as = ActorSystem.create("testing") + private implicit val mat = Materializer(as) def count(size: Int, bytes: ByteString*): Int = Await.result( Source.apply(bytes.toList) diff --git a/modules/core/src/main/scala/controllers/base/CoreActionBuilders.scala b/modules/core/src/main/scala/controllers/base/CoreActionBuilders.scala index c735dadfab..4777834493 100644 --- a/modules/core/src/main/scala/controllers/base/CoreActionBuilders.scala +++ b/modules/core/src/main/scala/controllers/base/CoreActionBuilders.scala @@ -14,13 +14,14 @@ import services.datamodel.EntityTypeMetadataService import java.time.ZonedDateTime import scala.concurrent.Future.{successful => immediate} import scala.concurrent.{ExecutionContext, Future} +import scala.language.higherKinds /** * Trait containing Action wrappers to handle different * types of site management and request authentication concerns */ -trait CoreActionBuilders extends BaseController with controllers.base.ControllerHelpers { +trait CoreActionBuilders extends BaseController with ControllerHelpers { /** * Inheriting controllers need to be provided/injected with @@ -85,7 +86,7 @@ trait CoreActionBuilders extends BaseController with controllers.base.Controller * Indicates that the current controller is secured, which, * if set to false, overrides staffOnly and verifiedOnly. */ - protected lazy val secured: Boolean = conf.configuration.getOptional[Boolean]("ehri.secured").getOrElse(true) + protected lazy val secured: Boolean = config.getOptional[Boolean]("ehri.secured").getOrElse(true) /** * Abstract response methods that should be implemented by inheritors. diff --git a/modules/core/src/main/scala/controllers/generic/Search.scala b/modules/core/src/main/scala/controllers/generic/Search.scala index 970ee2f1c7..c5e47d1b5f 100644 --- a/modules/core/src/main/scala/controllers/generic/Search.scala +++ b/modules/core/src/main/scala/controllers/generic/Search.scala @@ -77,7 +77,7 @@ trait Search extends CoreActionBuilders { appliedFacets = appliedFacets, facetClasses = facetClasses, user = userOpt, - lang = request.transientLang() + lang = request.lang ) } diff --git a/modules/core/src/main/scala/forms/mappings/package.scala b/modules/core/src/main/scala/forms/mappings/package.scala index 138369914a..3cc0674ac8 100644 --- a/modules/core/src/main/scala/forms/mappings/package.scala +++ b/modules/core/src/main/scala/forms/mappings/package.scala @@ -19,7 +19,7 @@ package object mappings { */ val entityForm: Mapping[Entity] = Forms.of(new Formatter[Entity] { def bind(key: String, data: Map[String, String]): Either[Seq[FormError], Entity] = { - play.api.data.format.Formats.stringFormat.bind(key, data).flatMap { s => + play.api.data.format.Formats.stringFormat.bind(key, data).right.flatMap { s => scala.util.control.Exception.allCatch[Entity] .either(Json.parse(s).as[Entity](Entity.entityReads)) .left.map(e => Seq(FormError(key, "error.jsonObj", Nil))) diff --git a/modules/core/src/main/scala/forms/package.scala b/modules/core/src/main/scala/forms/package.scala index 238a6398be..bd006f87be 100644 --- a/modules/core/src/main/scala/forms/package.scala +++ b/modules/core/src/main/scala/forms/package.scala @@ -1,4 +1,3 @@ -import models.Entity import play.api.data.Form import play.api.data.Forms.{nonEmptyText, seq, single} @@ -20,31 +19,6 @@ package object forms { case _: MalformedURLException => false } - import play.api.data.format.Formatter - import play.api.data.{FormError, Forms, Mapping} - import play.api.libs.json.Json - - /** - * Constructs a simple mapping for a text field (mapped as `JsObject`) - * - * For example: - * {{{ - * Form("randomData" -> jsonObj(Status)) - * }}} - */ - val entityForm: Mapping[Entity] = Forms.of(new Formatter[Entity] { - def bind(key: String, data: Map[String, String]): Either[Seq[FormError], Entity] = { - play.api.data.format.Formats.stringFormat.bind(key, data).flatMap { s => - scala.util.control.Exception.allCatch[Entity] - .either(Json.parse(s).as[Entity](Entity.entityReads)) - .left.map(e => Seq(FormError(key, "error.jsonObj", Nil))) - } - } - - def unbind(key: String, value: Entity): Map[String, String] = - Map(key -> Json.stringify(Json.toJson(value)(Entity.entityWrites))) - }) - /** * Form for a set of user or group identifiers that can * access a given resource. diff --git a/modules/core/src/main/scala/models/Annotation.scala b/modules/core/src/main/scala/models/Annotation.scala index 4e2b8c5a91..3a7944bdd1 100644 --- a/modules/core/src/main/scala/models/Annotation.scala +++ b/modules/core/src/main/scala/models/Annotation.scala @@ -62,10 +62,10 @@ object Annotation { import Ontology._ import EnumUtils.enumMapping - private implicit val anyModelReads: Reads[models.Model] = Model.Converter.restReads - private implicit val userProfileMetaReads: Reads[models.UserProfile] = UserProfile.UserProfileResource.restReads - private lazy implicit val systemEventReads: Reads[models.SystemEvent] = SystemEvent.SystemEventResource.restReads - private implicit val accessorReads: Reads[models.Accessor] = Accessor.Converter.restReads + private implicit val anyModelReads = Model.Converter.restReads + private implicit val userProfileMetaReads = UserProfile.UserProfileResource.restReads + private lazy implicit val systemEventReads = SystemEvent.SystemEventResource.restReads + private implicit val accessorReads = Accessor.Converter.restReads implicit val metaReads: Reads[Annotation] = ( __.read[AnnotationF] and diff --git a/modules/core/src/main/scala/models/AuthoritativeSet.scala b/modules/core/src/main/scala/models/AuthoritativeSet.scala index f37632c510..896c391791 100644 --- a/modules/core/src/main/scala/models/AuthoritativeSet.scala +++ b/modules/core/src/main/scala/models/AuthoritativeSet.scala @@ -50,8 +50,8 @@ object AuthoritativeSet { import Entity._ import eu.ehri.project.definitions.Ontology._ - private implicit val systemEventReads: Reads[models.SystemEvent] = SystemEvent.SystemEventResource.restReads - private implicit val accessorReads: Reads[models.Accessor] = Accessor.Converter.restReads + private implicit val systemEventReads = SystemEvent.SystemEventResource.restReads + private implicit val accessorReads = Accessor.Converter.restReads implicit val metaReads: Reads[AuthoritativeSet] = ( __.read[AuthoritativeSetF] and diff --git a/modules/core/src/main/scala/models/Concept.scala b/modules/core/src/main/scala/models/Concept.scala index 6faf06896d..cd83f673e3 100644 --- a/modules/core/src/main/scala/models/Concept.scala +++ b/modules/core/src/main/scala/models/Concept.scala @@ -89,8 +89,8 @@ object Concept { import Entity._ import ConceptF._ - private implicit val systemEventReads: Reads[models.SystemEvent] = SystemEvent.SystemEventResource.restReads - private implicit val vocabularyReads: Reads[models.Vocabulary] = Vocabulary.VocabularyResource.restReads + private implicit val systemEventReads = SystemEvent.SystemEventResource.restReads + private implicit val vocabularyReads = Vocabulary.VocabularyResource.restReads implicit val metaReads: Reads[Concept] = ( __.read[ConceptF] and diff --git a/modules/core/src/main/scala/models/Group.scala b/modules/core/src/main/scala/models/Group.scala index abac183d78..8b4c81ac92 100644 --- a/modules/core/src/main/scala/models/Group.scala +++ b/modules/core/src/main/scala/models/Group.scala @@ -44,7 +44,7 @@ object Group { import Entity._ import Ontology._ - private lazy implicit val systemEventReads: Reads[SystemEvent] = SystemEvent.SystemEventResource.restReads + private lazy implicit val systemEventReads = SystemEvent.SystemEventResource.restReads implicit val metaReads: Reads[Group] = ( __.read[GroupF] and @@ -60,7 +60,7 @@ object Group { val restReads: Reads[Group] = metaReads } - val form: Form[GroupF] = Form( + val form = Form( mapping( ISA -> ignored(EntityType.Group), ID -> optional(text), diff --git a/modules/core/src/main/scala/models/HistoricalAgent.scala b/modules/core/src/main/scala/models/HistoricalAgent.scala index 4fbffd3d2a..76db2ca950 100644 --- a/modules/core/src/main/scala/models/HistoricalAgent.scala +++ b/modules/core/src/main/scala/models/HistoricalAgent.scala @@ -59,8 +59,8 @@ object HistoricalAgent { import Ontology._ import utils.EnumUtils.enumMapping - private implicit val systemEventReads: Reads[models.SystemEvent] = SystemEvent.SystemEventResource.restReads - private implicit val authoritativeSetReads: Reads[models.AuthoritativeSet] = AuthoritativeSet.AuthoritativeSetResource.restReads + private implicit val systemEventReads = SystemEvent.SystemEventResource.restReads + private implicit val authoritativeSetReads = AuthoritativeSet.AuthoritativeSetResource.restReads implicit val metaReads: Reads[HistoricalAgent] = ( __.read[HistoricalAgentF] and diff --git a/modules/core/src/main/scala/models/Link.scala b/modules/core/src/main/scala/models/Link.scala index d9454c5e12..bb84697e88 100644 --- a/modules/core/src/main/scala/models/Link.scala +++ b/modules/core/src/main/scala/models/Link.scala @@ -84,9 +84,9 @@ object Link { import play.api.libs.functional.syntax._ import EnumUtils.enumMapping - private implicit val userProfileMetaReads: Reads[models.UserProfile] = models.UserProfile.UserProfileResource.restReads - private implicit val accessPointReads: Reads[models.AccessPoint] = models.AccessPoint.Converter.restReads - private implicit val systemEventReads: Reads[models.SystemEvent] = SystemEvent.SystemEventResource.restReads + private implicit val userProfileMetaReads = models.UserProfile.UserProfileResource.restReads + private implicit val accessPointReads = models.AccessPoint.Converter.restReads + private implicit val systemEventReads = SystemEvent.SystemEventResource.restReads implicit val metaReads: Reads[Link] = ( __.read[LinkF] and diff --git a/modules/core/src/main/scala/models/UserProfile.scala b/modules/core/src/main/scala/models/UserProfile.scala index e85af11977..21aba8c947 100644 --- a/modules/core/src/main/scala/models/UserProfile.scala +++ b/modules/core/src/main/scala/models/UserProfile.scala @@ -86,8 +86,8 @@ object UserProfile { import Ontology._ import UserProfileF._ - private implicit val groupReads: Reads[models.Group] = Group.GroupResource.restReads - private implicit val systemEventReads: Reads[models.SystemEvent] = SystemEvent.SystemEventResource.restReads + private implicit val groupReads = Group.GroupResource.restReads + private implicit val systemEventReads = SystemEvent.SystemEventResource.restReads implicit val metaReads: Reads[UserProfile] = ( __.read[UserProfileF] and diff --git a/modules/core/src/main/scala/models/Vocabulary.scala b/modules/core/src/main/scala/models/Vocabulary.scala index 5ad818ca87..9a795fe119 100644 --- a/modules/core/src/main/scala/models/Vocabulary.scala +++ b/modules/core/src/main/scala/models/Vocabulary.scala @@ -53,7 +53,7 @@ object Vocabulary { import Ontology._ import VocabularyF._ - private implicit val systemEventReads: Reads[models.SystemEvent] = SystemEvent.SystemEventResource.restReads + private implicit val systemEventReads = SystemEvent.SystemEventResource.restReads implicit val metaReads: Reads[Vocabulary] = ( __.read[VocabularyF] and diff --git a/modules/core/src/main/scala/services/accounts/SqlAccountManager.scala b/modules/core/src/main/scala/services/accounts/SqlAccountManager.scala index fc322315b5..97270cfbf4 100644 --- a/modules/core/src/main/scala/services/accounts/SqlAccountManager.scala +++ b/modules/core/src/main/scala/services/accounts/SqlAccountManager.scala @@ -203,8 +203,10 @@ case class SqlAccountManager @Inject()(db: Database, actorSystem: ActorSystem) e object SqlAccountManager { import anorm.{Column, ParameterMetaData, ToStatement, TypeDoesNotMatch} - implicit def pwToStatement: ToStatement[HashedPassword] = - (s: java.sql.PreparedStatement, index: Int, aValue: HashedPassword) => s.setString(index, aValue.s) + implicit def pwToStatement: ToStatement[HashedPassword] = new ToStatement[HashedPassword] { + def set(s: java.sql.PreparedStatement, index: Int, aValue: HashedPassword): Unit = + s.setString(index, aValue.s) + } implicit object HashedPasswordParameterMetaData extends ParameterMetaData[HashedPassword] { val sqlType: String = ParameterMetaData.StringParameterMetaData.sqlType diff --git a/modules/core/src/main/scala/services/search/SearchQuery.scala b/modules/core/src/main/scala/services/search/SearchQuery.scala index d38fd54263..cb8daccd4c 100644 --- a/modules/core/src/main/scala/services/search/SearchQuery.scala +++ b/modules/core/src/main/scala/services/search/SearchQuery.scala @@ -17,5 +17,5 @@ case class SearchQuery( extraParams: Map[String, Any] = Map.empty, mode: SearchMode.Value = SearchMode.DefaultAll, user: Option[UserProfile] = None, - lang: Option[Lang] = None, + lang: Lang = Lang.defaultLang ) diff --git a/modules/core/src/main/scala/services/search/package.scala b/modules/core/src/main/scala/services/search/package.scala index 5aff3877ab..ba49998caf 100644 --- a/modules/core/src/main/scala/services/search/package.scala +++ b/modules/core/src/main/scala/services/search/package.scala @@ -60,7 +60,7 @@ package object search { def pathWithFacet(fc: FacetClass[_], f: String, path: String, qs: Map[String, Seq[String]]): String = utils.http.joinPath(path, if (qs.contains(fc.param)) { qs.collect { - case (q, values) if q == fc.param => q -> (values :+ f).distinct.sorted + case (q, values) if q == fc.param => q -> values.union(Seq(f)).distinct.sorted case pair => pair } } else qs.updated(fc.param, Seq(f))) @@ -77,7 +77,7 @@ package object search { def pathWithGenericFacet(fc: FacetClass[_], f: String, path: String, qs: Map[String, Seq[String]]): String = utils.http.joinPath(path, if (qs.contains(SearchParams.FACET)) { qs.collect { - case (k, values) if k == SearchParams.FACET => k -> (values :+ s"${fc.param}:$f").distinct.sorted + case (k, values) if k == SearchParams.FACET => k -> values.union(Seq(s"${fc.param}:$f")).distinct.sorted case pair => pair } } else qs.updated(SearchParams.FACET, Seq(s"${fc.param}:$f"))) diff --git a/modules/core/src/test/scala/cookies/SessionPreferencesSpec.scala b/modules/core/src/test/scala/cookies/SessionPreferencesSpec.scala index 6014c63299..d6a6b0007e 100644 --- a/modules/core/src/test/scala/cookies/SessionPreferencesSpec.scala +++ b/modules/core/src/test/scala/cookies/SessionPreferencesSpec.scala @@ -27,7 +27,7 @@ class PrefTestController @Inject()(val controllerComponents: ControllerComponent // which needs a dummy secret. case class FakeApp() extends WithApplication( new GuiceApplicationBuilder().configure( - Map("smtp.host" -> "localhost", "play.http.secret.key" -> "foobar".*(6))).build()) + Map("smtp.host" -> "localhost", "play.http.secret.key" -> "foobar")).build()) trait PrefTest extends SessionPreferences[TestPrefs] { this: BaseController => diff --git a/modules/guides/app/models/Guide.scala b/modules/guides/app/models/Guide.scala index 5166c88fa9..440b510b03 100644 --- a/modules/guides/app/models/Guide.scala +++ b/modules/guides/app/models/Guide.scala @@ -38,7 +38,7 @@ object Guide { val DEFAULT_PAGE = "default_page" val CSS = "css" - implicit val form: Form[models.Guide] = Form( + implicit val form = Form( mapping( OBJECTID -> ignored(Option.empty[Long]), NAME -> nonEmptyText, diff --git a/modules/guides/app/models/GuidePage.scala b/modules/guides/app/models/GuidePage.scala index 08532658c5..b308b24b52 100644 --- a/modules/guides/app/models/GuidePage.scala +++ b/modules/guides/app/models/GuidePage.scala @@ -58,7 +58,7 @@ object GuidePage { val Nowhere = Value("nowhere") } - implicit val form: Form[models.GuidePage] = Form( + implicit val form = Form( mapping( OBJECTID -> ignored(Option.empty[Long]), LAYOUT -> enumMapping(Layout), diff --git a/modules/portal/app/controllers/base/SearchVC.scala b/modules/portal/app/controllers/base/SearchVC.scala index 0e7dd5d958..d6741b1124 100644 --- a/modules/portal/app/controllers/base/SearchVC.scala +++ b/modules/portal/app/controllers/base/SearchVC.scala @@ -54,7 +54,7 @@ trait SearchVC { logger.debug(s"Elements: ${seq.length}, distinct: ${seq.distinct.length}") - conf.configuration.getOptional[Int]("search.vc.maxDescendants").map { vcLimit => + config.getOptional[Int]("search.vc.maxDescendants").map { vcLimit => if (seq.length > vcLimit) { logger.error(s"Truncating clauses on child item search for $id: items ${seq.length}") seq.distinct.take(vcLimit) diff --git a/modules/portal/app/controllers/portal/Feedback.scala b/modules/portal/app/controllers/portal/Feedback.scala index 039ff100ab..86b71d6a3e 100644 --- a/modules/portal/app/controllers/portal/Feedback.scala +++ b/modules/portal/app/controllers/portal/Feedback.scala @@ -39,8 +39,7 @@ case class Feedback @Inject()( TIMESTAMP -> nonEmptyText, BLANK_CHECK -> text.verifying(s => s.isEmpty) )(CheckFeedbackData.apply)(CheckFeedbackData.unapply) - .verifying(blankFieldIsBlank) - .verifying(formSubmissionTime(appComponents.config)) + .verifying(blankFieldIsBlank).verifying(formSubmissionTime(appComponents.config)) ) private def getCopyMail(feedbackType: Option[models.Feedback.Type.Value]): Seq[String] = { diff --git a/modules/portal/app/controllers/portal/account/Accounts.scala b/modules/portal/app/controllers/portal/account/Accounts.scala index c173202555..fa384c4448 100644 --- a/modules/portal/app/controllers/portal/account/Accounts.scala +++ b/modules/portal/app/controllers/portal/account/Accounts.scala @@ -757,7 +757,7 @@ case class Accounts @Inject()( } } - private def sendResetEmail(name: String, emailAddress: String, uuid: UUID)(implicit request: RequestHeader): String = { + private def sendResetEmail(name: String, emailAddress: String, uuid: UUID)(implicit request: RequestHeader): Unit = { val email = Email( subject = "EHRI Password Reset", to = Seq(emailAddress), @@ -767,7 +767,7 @@ case class Accounts @Inject()( mailer.send(email) } - private def sendValidationEmail(name: String, emailAddress: String, uuid: UUID)(implicit request: RequestHeader): String = { + private def sendValidationEmail(name: String, emailAddress: String, uuid: UUID)(implicit request: RequestHeader): Unit = { val email = Email( subject = "Please confirm your EHRI Account Email", from = s"EHRI Email Validation <${config.get[String]("ehri.portal.emails.help")}>", diff --git a/modules/portal/app/controllers/portal/base/PortalController.scala b/modules/portal/app/controllers/portal/base/PortalController.scala index 9beb86a4ef..3df6a3e2af 100644 --- a/modules/portal/app/controllers/portal/base/PortalController.scala +++ b/modules/portal/app/controllers/portal/base/PortalController.scala @@ -2,7 +2,8 @@ package controllers.portal.base import akka.http.scaladsl.model.Uri import auth.handler.AuthHandler -import controllers.base.CoreActionBuilders +import views.AppConfig +import controllers.base.{ControllerHelpers, CoreActionBuilders} import controllers.{AppComponents, renderError} import cookies.{SessionPreferences, SessionPrefs} import lifecycle.ItemLifecycle @@ -16,7 +17,6 @@ import services.data.{DataServiceBuilder, DataUser} import services.datamodel.EntityTypeMetadataService import services.search.{SearchEngine, SearchItemResolver} import utils._ -import views.AppConfig import views.html.MarkdownRenderer import views.html.errors.{gone, itemNotFound, maintenance, pageNotFound} @@ -29,6 +29,7 @@ import scala.concurrent.duration.Duration trait PortalController extends CoreActionBuilders + with ControllerHelpers with SessionPreferences[SessionPrefs] { // Abstract controller components, injected into super classes @@ -74,7 +75,7 @@ trait PortalController /** * Activity event types that we think the user would care about. */ - val activityEventTypes: Seq[EventType.Value] = List( + val activityEventTypes = List( EventType.deletion, EventType.creation, EventType.modification, @@ -220,7 +221,7 @@ trait PortalController protected def renderItem(entityType: EntityType.Value, id: String, format: Option[String], supportedFormats: Seq[String], asFile: Boolean = false)( implicit apiUser: DataUser, request: RequestHeader): Future[Result] = { val fmt: String = format.filter(supportedFormats.contains).getOrElse(supportedFormats.head) - val params = request.queryString.view.filterKeys(_ == "lang").toMap + val params = request.queryString.filterKeys(_ == "lang") // since rendering EAD can take a long time, override the default timeout val timeout: Option[Duration] = config.getOptional[Duration]("ehri.backend.streamingTimeout") userDataApi.stream(s"classes/$entityType/$id/$fmt", params = params, diff --git a/modules/portal/app/forms/AccountForms.scala b/modules/portal/app/forms/AccountForms.scala index 6140cb1876..87f660e060 100644 --- a/modules/portal/app/forms/AccountForms.scala +++ b/modules/portal/app/forms/AccountForms.scala @@ -71,8 +71,8 @@ case class AccountForms @Inject() (config: Configuration, conf: AppConfig, oAuth BLANK_CHECK -> text, // honeypot AGREE_TERMS -> checked("signup.agreeTerms") )(SignupData.apply)(SignupData.unapply) - .verifying(formSubmissionTime(config)) - .verifying(blankFieldIsBlank) - .verifying("signup.badPasswords", s => s.password == s.confirm) + .verifying(formSubmissionTime(config)) + .verifying(blankFieldIsBlank) + .verifying("signup.badPasswords", s => s.password == s.confirm) ) } diff --git a/modules/portal/app/models/CypherQuery.scala b/modules/portal/app/models/CypherQuery.scala index 41e52019e3..3b509ecc75 100644 --- a/modules/portal/app/models/CypherQuery.scala +++ b/modules/portal/app/models/CypherQuery.scala @@ -46,7 +46,7 @@ object CypherQuery { } } - implicit val form: Form[models.CypherQuery] = Form( + implicit val form = Form( mapping( "objectId" -> ignored(Option.empty[String]), ID -> optional(text), diff --git a/modules/portal/app/models/Feedback.scala b/modules/portal/app/models/Feedback.scala index f22d85422c..afeb0d12bb 100644 --- a/modules/portal/app/models/Feedback.scala +++ b/modules/portal/app/models/Feedback.scala @@ -36,7 +36,7 @@ object Feedback { val Data = Value("data") } - implicit val form: Form[models.Feedback] = Form( + implicit val form = Form( mapping( "objectId" -> ignored(Option.empty[String]), ID -> optional(text), diff --git a/modules/portal/app/models/SignupData.scala b/modules/portal/app/models/SignupData.scala index da93f46696..82f00b3974 100644 --- a/modules/portal/app/models/SignupData.scala +++ b/modules/portal/app/models/SignupData.scala @@ -1,6 +1,7 @@ package models import forms.{HoneyPotForm, TimeCheckForm} +import forms.TimeCheckForm /** * Manage signup data. diff --git a/modules/portal/app/services/feedback/SqlFeedbackService.scala b/modules/portal/app/services/feedback/SqlFeedbackService.scala index ee08b71f87..2873263b51 100644 --- a/modules/portal/app/services/feedback/SqlFeedbackService.scala +++ b/modules/portal/app/services/feedback/SqlFeedbackService.scala @@ -36,7 +36,7 @@ case class SqlFeedbackService @Inject ()(db: Database, actorSystem: ActorSystem) } } - private implicit def modeEnumToStatement: ToStatement[Option[play.api.Mode]] = new ToStatement[Option[play.api.Mode]] { + private implicit def modeEnumToStatement = new ToStatement[Option[play.api.Mode]] { def set(s: java.sql.PreparedStatement, index: Int, value: Option[play.api.Mode]): Unit = s.setObject(index, value.map(_.toString).orNull) } @@ -52,7 +52,7 @@ case class SqlFeedbackService @Inject ()(db: Database, actorSystem: ActorSystem) } } - private implicit def typeEnumToStatement: ToStatement[Option[models.Feedback.Type.Value]] = new ToStatement[Option[Feedback.Type.Value]] { + private implicit def typeEnumToStatement = new ToStatement[Option[Feedback.Type.Value]] { def set(s: java.sql.PreparedStatement, index: Int, value: Option[Feedback.Type.Value]): Unit = s.setObject(index, value.map(_.toString).orNull) } @@ -74,7 +74,7 @@ case class SqlFeedbackService @Inject ()(db: Database, actorSystem: ActorSystem) } } - private implicit def contextToStatement: ToStatement[Option[models.FeedbackContext]] = new ToStatement[Option[FeedbackContext]] { + private implicit def contextToStatement = new ToStatement[Option[FeedbackContext]] { def set(s: java.sql.PreparedStatement, index: Int, value: Option[FeedbackContext]): Unit = s.setObject(index, value.map(v => Json.stringify(Json.toJson(v))).orNull) } diff --git a/modules/portal/app/services/geocoding/AwsGeocodingService.scala b/modules/portal/app/services/geocoding/AwsGeocodingService.scala index de1122d76f..8e2852a8ca 100644 --- a/modules/portal/app/services/geocoding/AwsGeocodingService.scala +++ b/modules/portal/app/services/geocoding/AwsGeocodingService.scala @@ -8,7 +8,7 @@ import software.amazon.awssdk.services.location.LocationClient import software.amazon.awssdk.services.location.model.SearchPlaceIndexForTextRequest import javax.inject.Inject -import scala.jdk.CollectionConverters._ +import scala.collection.JavaConverters._ import scala.concurrent.{ExecutionContext, Future} diff --git a/modules/portal/app/services/redirects/SqlMovedPageLookup.scala b/modules/portal/app/services/redirects/SqlMovedPageLookup.scala index 026969b9ad..d40af7ca2e 100644 --- a/modules/portal/app/services/redirects/SqlMovedPageLookup.scala +++ b/modules/portal/app/services/redirects/SqlMovedPageLookup.scala @@ -36,9 +36,9 @@ case class SqlMovedPageLookup @Inject ()(db: Database)(implicit actorSystem: Act db.withConnection { implicit conn => val inserts = moved.map { case (from, to) => Seq[NamedParameter]( - Symbol("hash") -> DigestUtils.sha1Hex(from), - Symbol("original") -> from, - Symbol("path") -> to + 'hash -> DigestUtils.sha1Hex(from), + 'original -> from, + 'path -> to ) } val q = """INSERT INTO moved_pages(original_path_sha1, original_path, new_path) diff --git a/modules/portal/app/services/search/AkkaStreamsIndexMediator.scala b/modules/portal/app/services/search/AkkaStreamsIndexMediator.scala index 25f9b2d37a..fa495a2990 100644 --- a/modules/portal/app/services/search/AkkaStreamsIndexMediator.scala +++ b/modules/portal/app/services/search/AkkaStreamsIndexMediator.scala @@ -45,7 +45,7 @@ case class AkkaStreamsIndexMediatorHandle( override def withChannel(actorRef: ActorRef, formatter: String => String, filter: Int => Boolean = _ % 100 == 0): AkkaStreamsIndexMediatorHandle = copy(chan = Some(actorRef), processFunc = formatter, progressFilter = filter) - import scala.jdk.CollectionConverters._ + import scala.collection.JavaConverters._ import scala.concurrent.duration._ private val logger = Logger(classOf[AkkaStreamsIndexMediator]) @@ -124,7 +124,7 @@ case class AkkaStreamsIndexMediatorHandle( private def setCommonHeaders(reqs: List[HttpRequest]): List[(HttpRequest, Uri)] = reqs.map { r => val headers = Seq(RawHeader(STREAM_HEADER_NAME, "true"), RawHeader(AUTH_HEADER_NAME, "admin")) ++ dataAuth.toSeq - val req = r.withHeaders(headers) + val req = r.withHeaders(headers: _*) req -> r.uri } diff --git a/modules/portal/app/services/search/CmdlineIndexMediator.scala b/modules/portal/app/services/search/CmdlineIndexMediator.scala index 1009f9f57a..5e83558fe1 100644 --- a/modules/portal/app/services/search/CmdlineIndexMediator.scala +++ b/modules/portal/app/services/search/CmdlineIndexMediator.scala @@ -44,7 +44,7 @@ case class CmdlineIndexMediatorHandle( def out(s: => String): Unit = report() - def err(s: => String): Unit = { + def err(s: => String) { errBuffer.add(s) // This is a hack. All progress goes to stdout but we only // want to buffer that which contains the format: @@ -53,7 +53,7 @@ case class CmdlineIndexMediatorHandle( else chan.foreach(_ ! processFunc(s)) } - import scala.jdk.CollectionConverters._ + import scala.collection.JavaConverters._ def lastMessages: List[String] = errBuffer.asScala.toList private def report(): Unit = { diff --git a/modules/portal/app/services/search/SearchToolsIndexMediator.scala b/modules/portal/app/services/search/SearchToolsIndexMediator.scala index 226194b10b..d15fb3ff39 100644 --- a/modules/portal/app/services/search/SearchToolsIndexMediator.scala +++ b/modules/portal/app/services/search/SearchToolsIndexMediator.scala @@ -15,7 +15,7 @@ import services.data.Constants import java.util.Properties import javax.inject.Inject -import scala.jdk.CollectionConverters._ +import scala.collection.JavaConverters._ import scala.concurrent.{ExecutionContext, Future} case class SearchToolsIndexMediator @Inject()( @@ -98,7 +98,7 @@ case class SearchToolsIndexMediatorHandle( override def indexChildren(entityType: EntityType.Value, id: String): Future[Unit] = Future { logger.debug(s"Index children: $entityType|$id") - indexHelper(entityType.toString + "|" + id).run() + indexHelper(entityType + "|" + id).run() } override def indexTypes(entityTypes: Seq[EntityType.Value]): Future[Unit] = Future { diff --git a/modules/portal/app/services/storage/S3CompatibleFileStorage.scala b/modules/portal/app/services/storage/S3CompatibleFileStorage.scala index 702f4b385a..e84331e86f 100644 --- a/modules/portal/app/services/storage/S3CompatibleFileStorage.scala +++ b/modules/portal/app/services/storage/S3CompatibleFileStorage.scala @@ -20,7 +20,7 @@ import software.amazon.awssdk.services.s3.presigner.S3Presigner import software.amazon.awssdk.services.s3.presigner.model.{GetObjectPresignRequest, PutObjectPresignRequest} import java.net.URI -import scala.jdk.CollectionConverters._ +import scala.collection.JavaConverters._ import scala.concurrent.duration.{FiniteDuration, _} import scala.concurrent.{ExecutionContext, Future} @@ -121,7 +121,7 @@ case class S3CompatibleFileStorage( Option(meta.contentType), Option(meta.versionId) ) - Some((fm, meta.metadata.asScala.toSeq.toMap)) + Some((fm, meta.metadata.asScala.toMap)) } catch { case _: SdkException => None } @@ -265,7 +265,7 @@ case class S3CompatibleFileStorage( val lvr = afterVersion.fold(rb2)(id => rb2.versionIdMarker(id)).build() val r = client.listObjectVersions(lvr) - FileList(r.versions().asScala.toSeq.map { f => + FileList(r.versions().asScala.map { f => FileMeta( name, f.key, @@ -302,7 +302,7 @@ case class S3CompatibleFileStorage( val lor = prefix.fold(rb2)(p => rb2.prefix(p)).build() val resp = client.listObjects(lor) - FileList(resp.contents().asScala.toSeq.map { f => + FileList(resp.contents().asScala.map { f => FileMeta( name, f.key, diff --git a/modules/portal/app/views/Helpers.scala b/modules/portal/app/views/Helpers.scala index 14acd34c97..05f051bbe3 100644 --- a/modules/portal/app/views/Helpers.scala +++ b/modules/portal/app/views/Helpers.scala @@ -2,6 +2,7 @@ package views import java.net.{MalformedURLException, URL} import models.{Annotation, Description, Entity, EntityType, FieldMetadata, Model, PermissionType, UserProfile} +import org.apache.commons.codec.digest.DigestUtils import org.apache.commons.lang3.StringUtils import org.jsoup.Jsoup import org.jsoup.safety.Whitelist diff --git a/modules/portal/app/views/activity/timeline.scala.html b/modules/portal/app/views/activity/timeline.scala.html index 4afac90016..2fcc5b7b0f 100644 --- a/modules/portal/app/views/activity/timeline.scala.html +++ b/modules/portal/app/views/activity/timeline.scala.html @@ -10,7 +10,7 @@ @if(page.more) { + href="@utils.http.joinPath(req.path, req.queryString.filterKeys(_ != "modal").updated(OFFSET_PARAM, Seq((page.offset + page.limit).toString)))"> @Messages("activity.fetchMore") diff --git a/modules/portal/app/views/common/listSorting.scala.html b/modules/portal/app/views/common/listSorting.scala.html index 576417513d..92073098fd 100644 --- a/modules/portal/app/views/common/listSorting.scala.html +++ b/modules/portal/app/views/common/listSorting.scala.html @@ -10,7 +10,7 @@
  • @defining((Messages(i18nKey), Messages(i18nKey + ".title"))) { case (name, title) => @if(current.contains(sortKey)) { - + @name } else { diff --git a/modules/portal/app/views/common/search/facetList.scala.html b/modules/portal/app/views/common/search/facetList.scala.html index c4751dfe08..31ba606199 100644 --- a/modules/portal/app/views/common/search/facetList.scala.html +++ b/modules/portal/app/views/common/search/facetList.scala.html @@ -12,7 +12,7 @@ @facetItem(fc: FacetClass[Facet], f: Facet) = { @if(f.applied) {
  • - + @fc.pretty(f) (@f.count) @Messages("search.facets.remove") @@ -21,7 +21,7 @@
  • } else {
  • - + @fc.pretty(f) (@f.count) @@ -61,14 +61,14 @@
  • @if(f.applied) { - + @fc.pretty(f) (@f.count) @Messages("search.facets.remove") } else { - + @fc.pretty(f) (@f.count) diff --git a/modules/portal/app/views/common/search/inlineItemList.scala.html b/modules/portal/app/views/common/search/inlineItemList.scala.html index 00cf18770b..6ee040c4c1 100644 --- a/modules/portal/app/views/common/search/inlineItemList.scala.html +++ b/modules/portal/app/views/common/search/inlineItemList.scala.html @@ -34,7 +34,7 @@
    @views.html.helpers.linkTo(child)
    @if(result.page.hasMore) { @Messages("activity.fetchMore") diff --git a/modules/portal/app/views/common/search/searchForm.scala.html b/modules/portal/app/views/common/search/searchForm.scala.html index ec91dbce16..e22619d14d 100644 --- a/modules/portal/app/views/common/search/searchForm.scala.html +++ b/modules/portal/app/views/common/search/searchForm.scala.html @@ -22,7 +22,7 @@ @if(result.page.hasMore) { @Messages("activity.fetchMore") diff --git a/modules/portal/app/views/common/search/selectedFacets.scala.html b/modules/portal/app/views/common/search/selectedFacets.scala.html index 29a349c61b..4479b5ab76 100644 --- a/modules/portal/app/views/common/search/selectedFacets.scala.html +++ b/modules/portal/app/views/common/search/selectedFacets.scala.html @@ -8,7 +8,7 @@ diff --git a/modules/portal/app/views/userProfile/browseUsersList.scala.html b/modules/portal/app/views/userProfile/browseUsersList.scala.html index c94c097df1..41a19c62b8 100644 --- a/modules/portal/app/views/userProfile/browseUsersList.scala.html +++ b/modules/portal/app/views/userProfile/browseUsersList.scala.html @@ -43,8 +43,8 @@

    @if(result.page.hasMore) { + href="@utils.http.joinPath(req.path, req.queryString.filterKeys(_ != "modal") + .updated(PAGE_PARAM, Seq((result.page.page + 1).toString)))"> @Messages("activity.fetchMore") diff --git a/modules/portal/test/utils/DateFacetUtilsSpec.scala b/modules/portal/test/utils/DateFacetUtilsSpec.scala index 5841f99264..3cd8af57a2 100644 --- a/modules/portal/test/utils/DateFacetUtilsSpec.scala +++ b/modules/portal/test/utils/DateFacetUtilsSpec.scala @@ -7,8 +7,8 @@ import services.search.{End, Start, Val} class DateFacetUtilsSpec extends PlaySpecification with play.api.i18n.I18nSupport with LangImplicits { import utils.DateFacetUtils._ + implicit val messagesApi: MessagesApi = new DefaultMessagesApi() private implicit val lang: Lang = Lang("en") - override implicit val messagesApi: DefaultMessagesApi = new DefaultMessagesApi() val dateFacetUtils = DateFacetUtils() diff --git a/modules/solr/src/main/scala/eu/ehri/project/search/solr/SolrQueryBuilder.scala b/modules/solr/src/main/scala/eu/ehri/project/search/solr/SolrQueryBuilder.scala index d6d7a302d0..aac31bd80f 100644 --- a/modules/solr/src/main/scala/eu/ehri/project/search/solr/SolrQueryBuilder.scala +++ b/modules/solr/src/main/scala/eu/ehri/project/search/solr/SolrQueryBuilder.scala @@ -140,7 +140,7 @@ private[solr] object SolrQueryBuilder { filters.map { case (key, value) => val filter = value match { // Have to quote strings - case _: String => key + ":\"" + value + "\"" + case s: String => key + ":\"" + s + "\"" // not value means the key is a query! case () => key case _ => s"$key:$value" @@ -149,7 +149,7 @@ private[solr] object SolrQueryBuilder { } } - def groupParams(lang: Option[Lang]): Seq[(String, String)] = { + def groupParams(lang: Lang): Seq[(String, String)] = { // Group results by item id (as opposed to description id). Facet counts // are also set to reflect grouping as opposed to the number of individual // items. @@ -157,7 +157,7 @@ private[solr] object SolrQueryBuilder { "group" -> true.toString, "group.field" -> ITEM_ID, "group.sort" -> "query({!v=$gsf}, 0.1) desc", - "gsf" -> s"$LANGUAGE_CODE:${lang.getOrElse(Lang.defaultLang).locale.getISO3Language}", + "gsf" -> s"$LANGUAGE_CODE:${lang.locale.getISO3Language}", "group.facet" -> true.toString, "group.ngroups" -> true.toString, "group.cache.percent" -> 0.toString, diff --git a/modules/xquery/src/main/scala/eu/ehri/project/xml/XQueryTransformer.scala b/modules/xquery/src/main/scala/eu/ehri/project/xml/XQueryTransformer.scala index 17c918946c..bdb3ffa6bc 100644 --- a/modules/xquery/src/main/scala/eu/ehri/project/xml/XQueryTransformer.scala +++ b/modules/xquery/src/main/scala/eu/ehri/project/xml/XQueryTransformer.scala @@ -6,7 +6,7 @@ import org.slf4j.{Logger, LoggerFactory} import scopt.OParser import java.io.{File, FileNotFoundException} -import scala.io.{BufferedSource, Source} +import scala.io.Source /** * Command-line interface to the BaseXXQueryTransformer @@ -56,7 +56,7 @@ object XQueryTransformer { .text("Additional namespaces in prefix1=url1,prefix2=url2 format."), opt[Unit]("print-script") .action((_, opt) => { - println(using[BufferedSource, String](Source.fromResource("transform.xqy"))(_.mkString)) + println(using(Source.fromResource("transform.xqy"))(_.mkString)) System.exit(1) opt }) @@ -66,7 +66,7 @@ object XQueryTransformer { |use with the -s|script option.""".stripMargin), opt[Unit]("print-functions") .action((_, opt) => { - println(using[BufferedSource, String](Source.fromResource("xtra.xqm"))(_.mkString)) + println(using(Source.fromResource("xtra.xqm"))(_.mkString)) System.exit(1) opt }) diff --git a/project/build.properties b/project/build.properties index 195fc1af09..0f9d811b6b 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1,2 +1,2 @@ -sbt.version=1.10.1 +sbt.version=1.4.9 logLevel := Level.Info diff --git a/project/plugins.sbt b/project/plugins.sbt index 4e2fa18f58..446caf07b7 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,21 +1,13 @@ // Comment to get more information during initialization -//logLevel := Level.Warn +logLevel := Level.Warn // The Typesafe repository resolvers += "Typesafe repository" at "https://repo.typesafe.com/typesafe/releases/" -resolvers += Resolver.bintrayRepo("givers", "maven") - -// Prevent library dependency errors with scala-xml 1.3.0 to 2.2.0, which in -// fact should be compatible -ThisBuild / libraryDependencySchemes ++= Seq( - "org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always -) - //resolvers += "Typesafe Snapshots" at "http://repo.typesafe.com/typesafe/snapshots/" // Use the Play sbt plugin for Play projects -addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.9.5") +addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.20") addSbtPlugin("io.github.irundaia" % "sbt-sassify" % "1.5.2") diff --git a/test/helpers/TestConfiguration.scala b/test/helpers/TestConfiguration.scala index 509ca4f291..babd8e98a6 100644 --- a/test/helpers/TestConfiguration.scala +++ b/test/helpers/TestConfiguration.scala @@ -250,11 +250,11 @@ trait TestConfiguration { protected abstract class WithSqlFile(val resource: String)(implicit appLoader: play.api.ApplicationLoader) extends WithApplicationLoader(appLoader) { override def around[T: AsResult](t: => T): Result = - Helpers.running(app)(withDatabaseFixture(resource)(implicit db => AsResult.effectively(t))) + running(app)(withDatabaseFixture(resource)(implicit db => AsResult.effectively(t))) } protected def formData(html: String): Map[String, Seq[String]] = { - import scala.jdk.CollectionConverters._ + import scala.collection.JavaConverters._ val doc = Jsoup.parse(html) val inputData = doc.select("input,textarea").asScala .foldLeft(Map.empty[String,Seq[String]]) { case (acc, elem) => diff --git a/test/integration/admin/CypherQuerySpec.scala b/test/integration/admin/CypherQuerySpec.scala index d5af88b18f..b55b7a47f6 100644 --- a/test/integration/admin/CypherQuerySpec.scala +++ b/test/integration/admin/CypherQuerySpec.scala @@ -82,7 +82,8 @@ class CypherQuerySpec extends IntegrationTestRunner { } // CSV - val q2 = FakeRequest("GET", controllers.cypher.routes.CypherQueries.executeQuery(fakeKey.toString).url + "?format=csv") + val q2 = FakeRequest("GET", controllers.cypher.routes.CypherQueries + .executeQuery(fakeKey.toString) + "?format=csv") .withUser(privilegedUser) .call() status(q2) must equalTo(OK) diff --git a/test/integration/admin/EntityViewsSpec.scala b/test/integration/admin/EntityViewsSpec.scala index 10084cffbc..11b73fe273 100644 --- a/test/integration/admin/EntityViewsSpec.scala +++ b/test/integration/admin/EntityViewsSpec.scala @@ -266,7 +266,7 @@ class EntityViewsSpec extends IntegrationTestRunner { } "allow exporting users" in new ITestApp { - val csv = FakeRequest(controllers.users.routes.UserProfiles.exportInfo()) + val csv = FakeRequest(controllers.users.routes.UserProfiles.export()) .withUser(privilegedUser).call() status(csv) must equalTo(OK) header(HeaderNames.CONTENT_DISPOSITION, csv) must beSome.which { s => diff --git a/test/integration/admin/IndexingSpec.scala b/test/integration/admin/IndexingSpec.scala index de2dfa979c..01ce19c2f4 100644 --- a/test/integration/admin/IndexingSpec.scala +++ b/test/integration/admin/IndexingSpec.scala @@ -25,7 +25,8 @@ class IndexingSpec extends SearchTestRunner { TextMessage.Strict(Json.prettyPrint(Json.toJson(obj))) "Indexing views" should { - "index items correctly" in new ITestServer(app = appBuilder.build()) { + val port = 9902 + "index items correctly" in new ITestServer(app = appBuilder.build(), port = port) { val mediator = app.injector.instanceOf[SearchIndexMediator] val engine = app.injector.instanceOf[SearchEngine] @@ -38,7 +39,7 @@ class IndexingSpec extends SearchTestRunner { // Now initiate a full re-index request... val headers = collection.immutable.Seq(RawHeader(AUTH_TEST_HEADER_NAME, testAuthToken(privilegedUser.id))) - val wsUrl = s"ws://127.0.0.1:${this.port}${controllers.admin.routes.Indexing.indexer()}" + val wsUrl = s"ws://127.0.0.1:$port${controllers.admin.routes.Indexing.indexer()}" val src = Source.single(jsonMessage(IndexTypes(IndexTypes.all))) // NB: using the technique mentioned for "half-closed" websockets here to get output diff --git a/test/integration/admin/IngestSpec.scala b/test/integration/admin/IngestSpec.scala index c5b23f1476..d146cbe577 100644 --- a/test/integration/admin/IngestSpec.scala +++ b/test/integration/admin/IngestSpec.scala @@ -35,7 +35,8 @@ class IngestSpec extends IntegrationTestRunner with FakeMultipartUpload { "Ingest views" should { - "perform ead-sync and monitor progress correctly" in new ITestServer(app = appBuilder.configure(getConfig).build()) { + val port = 9902 + "perform ead-sync and monitor progress correctly" in new ITestServer(app = appBuilder.configure(getConfig).build(), port = port) { val damStorage = app.injector.instanceOf(BindingKey(classOf[FileStorage], Some(QualifierInstance(Names.named("dam"))))) val result = FakeRequest(controllers.admin.routes.Ingest @@ -57,7 +58,7 @@ class IngestSpec extends IntegrationTestRunner with FakeMultipartUpload { val relativeUrl = loc.get val jobId = relativeUrl.split("=")(1) - val wsUrl = s"ws://127.0.0.1:${this.port}${controllers.admin.routes.Tasks.taskMonitorWS(jobId)}" + val wsUrl = s"ws://127.0.0.1:$port${controllers.admin.routes.Tasks.taskMonitorWS(jobId)}" val headers = collection.immutable.Seq(RawHeader(AUTH_TEST_HEADER_NAME, testAuthToken(privilegedUser.id))) val outFlow: Flow[Message, Message, (Future[Seq[Message]], Promise[Option[Message]])] = diff --git a/test/integration/admin/SearchSpec.scala b/test/integration/admin/SearchSpec.scala index 2aa23dbd92..530b216a44 100644 --- a/test/integration/admin/SearchSpec.scala +++ b/test/integration/admin/SearchSpec.scala @@ -47,12 +47,13 @@ class SearchSpec extends IntegrationTestRunner { } "Search index mediator" should { + val port = 9902 "perform indexing correctly via Websocket endpoint" in new ITestServer( - app = appBuilder.configure(getConfig).build()) { + app = appBuilder.configure(getConfig).build(), port = port) { val cmd = List(EntityType.DocumentaryUnit) val data = IndexTypes(cmd) - val wsUrl = s"ws://127.0.0.1:${this.port}${controllers.admin.routes.Indexing.indexer().url}" + val wsUrl = s"ws://127.0.0.1:$port${controllers.admin.routes.Indexing.indexer().url}" val headers = collection.immutable.Seq(RawHeader(AUTH_TEST_HEADER_NAME, testAuthToken(privilegedUser.id))) // Ensure the buffer of index events is empty. diff --git a/test/integration/api/v1/ApiV1Spec.scala b/test/integration/api/v1/ApiV1Spec.scala index cfa413af3d..2205c2b44c 100644 --- a/test/integration/api/v1/ApiV1Spec.scala +++ b/test/integration/api/v1/ApiV1Spec.scala @@ -26,7 +26,7 @@ class ApiV1Spec extends IntegrationTestRunner { } catch { case se: ValidationException => println(se.getMessage) - import scala.jdk.CollectionConverters._ + import scala.collection.JavaConverters._ se.getCausingExceptions.asScala.foreach { e => println(" - " + e.getMessage) } @@ -130,7 +130,7 @@ class ApiV1Spec extends IntegrationTestRunner { } "include context when search in items" in new ITestApp { - val search = FakeRequest(GET, apiRoutes.searchIn("r1").url + "?limit=1&page=2").call() + val search = FakeRequest(GET, apiRoutes.searchIn("r1") + "?limit=1&page=2").call() status(search) must_== OK validateJson(contentAsJson(search)) contentAsJson(search) \ "included" \ 0 \ "id" must_== JsDefined(JsString("r1")) diff --git a/test/integration/portal/AccountsSpec.scala b/test/integration/portal/AccountsSpec.scala index 0d990c8668..a05e4e2fb8 100644 --- a/test/integration/portal/AccountsSpec.scala +++ b/test/integration/portal/AccountsSpec.scala @@ -8,7 +8,6 @@ import forms.TimeCheckForm._ import helpers.IntegrationTestRunner import mockdata.{unprivilegedUser, unverifiedUser} import models.{Account, SignupData} -import play.api.Application import play.api.cache.SyncCacheApi import play.api.i18n.MessagesApi import play.api.test.{FakeRequest, Injecting, WithApplication} @@ -22,7 +21,7 @@ class AccountsSpec extends IntegrationTestRunner { private val accountRoutes = controllers.portal.account.routes.Accounts - private implicit def cache(implicit app: Application): SyncCacheApi = app.injector.instanceOf[SyncCacheApi] + private implicit def cache(implicit app: play.api.Application) = app.injector.instanceOf[SyncCacheApi] "Account views" should { "redirect to index page on log out" in new ITestApp { @@ -170,7 +169,7 @@ class AccountsSpec extends IntegrationTestRunner { } "error with bad session state" in new WithApplication with Injecting { - private implicit val messagesApi: play.api.i18n.MessagesApi = inject[MessagesApi] + private implicit val messagesApi = inject[MessagesApi] val singleUseKey = "useOnce" cache.set(singleUseKey, "jdjjjr") val login = FakeRequest( diff --git a/test/integration/portal/AnnotationsSpec.scala b/test/integration/portal/AnnotationsSpec.scala index 44937c40bb..1a0a85018a 100644 --- a/test/integration/portal/AnnotationsSpec.scala +++ b/test/integration/portal/AnnotationsSpec.scala @@ -121,8 +121,8 @@ class AnnotationsSpec extends IntegrationTestRunner { contentAsString(doc) must not contain testBody // Get a id via faff method and promote the item... - implicit val apiUser: DataUser = DataUser(Some(privilegedUser.id)) - await(dataApi.annotations[Annotation]("c4")).headOption must beSome.which { aid => + implicit val apiUser = DataUser(Some(privilegedUser.id)) + val aid = await(dataApi.annotations[Annotation]("c4")).headOption must beSome.which { aid => await(dataApi.promote[Annotation](aid.id)) // Ensure the unprivileged user CAN now see the annotation... diff --git a/test/integration/portal/PortalSpec.scala b/test/integration/portal/PortalSpec.scala index 417fb08b5e..535f5d6f7f 100644 --- a/test/integration/portal/PortalSpec.scala +++ b/test/integration/portal/PortalSpec.scala @@ -183,7 +183,7 @@ class PortalSpec extends IntegrationTestRunner { val is = bytes.iterator.asInputStream val zis = new ZipInputStream(is) try { - LazyList + Stream .continually(zis.getNextEntry) .takeWhile(_ != null) .toList diff --git a/test/services/MailerSpec.scala b/test/services/MailerSpec.scala index c218241d51..1a885971f3 100644 --- a/test/services/MailerSpec.scala +++ b/test/services/MailerSpec.scala @@ -16,7 +16,7 @@ class MailerSpec extends PlaySpecification { "SMTP mailer" should { "send mails" in new WithApplication(app) { - val mailer = this.app.injector.instanceOf[MailerClient] + val mailer = app.injector.instanceOf[MailerClient] val email = Email( "Test Email", "Test FROM ", diff --git a/test/services/accounts/MockAccountManager.scala b/test/services/accounts/MockAccountManager.scala index af8f962616..09df383d86 100644 --- a/test/services/accounts/MockAccountManager.scala +++ b/test/services/accounts/MockAccountManager.scala @@ -31,7 +31,7 @@ case class MockAccountManager @Inject()(executionContext: ExecutionContext) exte } def findAll: Future[Seq[OAuth2Association]] = - immediate(mockdata.oauth2AssociationFixtures.toSeq) + immediate(mockdata.oauth2AssociationFixtures) def findByProviderInfo(providerUserId: String, provider: String): Future[Option[OAuth2Association]] = immediate(mockdata.oauth2AssociationFixtures.find { @@ -39,7 +39,7 @@ case class MockAccountManager @Inject()(executionContext: ExecutionContext) exte }) def findForAccount(id: String): Future[Seq[OAuth2Association]] = - immediate(mockdata.oauth2AssociationFixtures.filter(_.id == id).toSeq) + immediate(mockdata.oauth2AssociationFixtures.filter(_.id == id)) } override def openId: OpenIdAssociationManager = new OpenIdAssociationManager { @@ -54,7 +54,7 @@ case class MockAccountManager @Inject()(executionContext: ExecutionContext) exte def findByUrl(url: String): Future[Option[OpenIDAssociation]] = immediate(mockdata.openIdAssociationFixtures.find(_.url == url)) - def findAll: Future[Seq[OpenIDAssociation]] = immediate(mockdata.openIdAssociationFixtures.toSeq) + def findAll: Future[Seq[OpenIDAssociation]] = immediate(mockdata.openIdAssociationFixtures) } override def get(id: String): Future[Account] = @@ -67,7 +67,7 @@ case class MockAccountManager @Inject()(executionContext: ExecutionContext) exte immediate(mockdata.accountFixtures.values.find(_.email.toLowerCase == email.toLowerCase)) override def findAllById(ids: Seq[String]): Future[Seq[Account]] = - immediate(mockdata.accountFixtures.filter(kv => ids.contains(kv._1)).values.toSeq) + immediate(mockdata.accountFixtures.filterKeys(id => ids.contains(id)).values.toSeq) override def authenticateById(id: String, pw: String, verifiedOnly: Boolean = false): Future[Option[Account]] = immediate { for { diff --git a/test/services/data/WsDataServiceSpec.scala b/test/services/data/WsDataServiceSpec.scala index 9b9afd5ed5..74e8b9eeaa 100644 --- a/test/services/data/WsDataServiceSpec.scala +++ b/test/services/data/WsDataServiceSpec.scala @@ -191,7 +191,7 @@ class WsDataServiceSpec extends IntegrationTestRunner { await(testBackend.create[UserProfile,UserProfileF](user)) failure("Expected a validation error!") } catch { - case e: services.data.ValidationError => + case e: ValidationError => case _: Throwable => failure("Expected a validation error!") } } diff --git a/version.sbt b/version.sbt index 00eeea30e1..062abea5df 100644 --- a/version.sbt +++ b/version.sbt @@ -1,2 +1,2 @@ // the SNAPSHOT here is basically here as a hack to ensure subprojects update their asset dependencies -ThisBuild / version := "3.0.0-SNAPSHOT" +ThisBuild / version := "2.0.1-SNAPSHOT"