Skip to content

Commit

Permalink
Fix for URLS with spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
hohonuuli committed Oct 30, 2024
1 parent 528b6d3 commit 291e831
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 16 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ThisBuild / licenses := Seq("Apache-2.0" -> url("http://www.apache.org/l
ThisBuild / organization := "org.mbari"
ThisBuild / organizationName := "Monterey Bay Aquarium Research Institute"
ThisBuild / resolvers ++= Seq(Resolver.githubPackages("mbari-org", "maven"))
ThisBuild / scalaVersion := "3.5.0"
ThisBuild / scalaVersion := "3.5.2"
ThisBuild / usePipelining := true
// ThisBuild / scalaVersion := "3.4.2"
// ThisBuild / scalaVersion := "3.3.1" // Fails. See https://github.com/lampepfl/dotty/issues/17069#issuecomment-1763053572
Expand Down
3 changes: 2 additions & 1 deletion oni/src/main/scala/org/mbari/oni/domain/Media.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ object Media:

def from(media: MediaEntity): Media =
val conceptName = Try(media.getConceptMetadata.getConcept.getName).toOption
val escapedUrl = media.getUrl.replace(" ", "%20")
Media(
URI.create(media.getUrl).toURL,
URI.create(escapedUrl).toURL,
Option(media.getCaption),
Option(media.getCredit),
resolveMimeType(media.getType, media.getUrl),
Expand Down
4 changes: 3 additions & 1 deletion oni/src/main/scala/org/mbari/oni/jdbc/ConceptRow.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@ case class ConceptRow(
lazy val lastUpdate: Instant = Seq(conceptTimestamp, conceptNameTimestamp)
.maxBy(i => i.toEpochMilli)

case class CName(name: String, nameType: String)

case class CName(name: String, nameType: String):
val isPrimary: Boolean = nameType.equalsIgnoreCase(ConceptNameTypes.PRIMARY.getType)
6 changes: 3 additions & 3 deletions oni/src/main/scala/org/mbari/oni/jdbc/MutableConcept.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ class MutableConcept:

def primaryName: Option[String] =
names
.find(n => n.nameType.equals("primary"))
.find(n => n.isPrimary)
.map(_.name)

def alternativeNames: Seq[String] =
names
.filter(n => !n.nameType.equals("primary"))
.filter(n => !n.isPrimary)
.map(_.name)

def copyUp(): MutableConcept = copyUp(Nil)
Expand All @@ -42,7 +42,7 @@ class MutableConcept:
def toImmutable: Concept =
// println(s"${this.id} - ${this.names}")
val primaryName = names
.find(_.nameType.equalsIgnoreCase("primary"))
.find(_.isPrimary)
.getOrElse(names.head)
val alternativeNames = names.filter(!_.eq(primaryName))
Concept(
Expand Down
10 changes: 10 additions & 0 deletions oni/src/test/scala/org/mbari/oni/domain/MediaSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

package org.mbari.oni.domain

import org.mbari.oni.jpa.entities.MediaEntity

class MediaSuite extends munit.FunSuite {

test("resolveMimeType (image)") {
Expand All @@ -25,6 +27,14 @@ class MediaSuite extends munit.FunSuite {
assertEquals(b, "video/mp4")
}

test("media URL with space") {
val mediaEntity = new MediaEntity()
mediaEntity.setUrl("http://foo.com/bar bax.jpg")
mediaEntity.setType("image/jpg")
val media = Media.from(mediaEntity)
assertEquals(media.url.toString, "http://foo.com/bar%20bax.jpg")
}



}
16 changes: 8 additions & 8 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ object Dependencies {
lazy val caffeine = "com.github.ben-manes.caffeine" % "caffeine" % caffeineVersion
lazy val caffeineJCache = "com.github.ben-manes.caffeine" % "jcache" % caffeineVersion

val circeVersion = "0.14.9"
val circeVersion = "0.14.10"
lazy val circeCore = "io.circe" %% "circe-core" % circeVersion
lazy val circeGeneric = "io.circe" %% "circe-generic" % circeVersion
lazy val circeParser = "io.circe" %% "circe-parser" % circeVersion
Expand All @@ -21,19 +21,19 @@ object Dependencies {
lazy val helidonEncodingDeflate = "io.helidon.http.encoding" % "helidon-http-encoding-deflate" % helidonVersion
lazy val helidonEncodingGzip = "io.helidon.http.encoding" % "helidon-http-encoding-gzip" % helidonVersion

val hibernateVersion = "6.6.0.Final"
val hibernateVersion = "6.6.1.Final"
lazy val hibernateCore = "org.hibernate.orm" % "hibernate-core" % hibernateVersion
lazy val hibernateJCache = "org.hibernate" % "hibernate-jcache" % hibernateVersion
lazy val hibernateEnvers = "org.hibernate.orm" % "hibernate-envers" % hibernateVersion
lazy val hibernateHikari = "org.hibernate.orm" % "hibernate-hikaricp" % hibernateVersion

lazy val hikariCp = "com.zaxxer" % "HikariCP" % "5.1.0"
lazy val hikariCp = "com.zaxxer" % "HikariCP" % "6.0.0"
lazy val jansi = "org.fusesource.jansi" % "jansi" % "2.4.1"
lazy val jaspyt = "org.jasypt" % "jasypt" % "1.9.3"
lazy val junit = "junit" % "junit" % "4.13.2"
lazy val logback = "ch.qos.logback" % "logback-classic" % "1.5.7"
lazy val logback = "ch.qos.logback" % "logback-classic" % "1.5.12"
lazy val mssqlserver = "com.microsoft.sqlserver" % "mssql-jdbc" % "12.8.1.jre11"
lazy val munit = "org.scalameta" %% "munit" % "1.0.1"
lazy val munit = "org.scalameta" %% "munit" % "1.0.2"
lazy val oracle = "com.oracle.ojdbc" % "ojdbc8" % "19.3.0.0"
lazy val postgresql = "org.postgresql" % "postgresql" % "42.7.4"
// lazy val scilube = "org.mbari.scilube" %% "scilube" % "3.0.1"
Expand All @@ -42,17 +42,17 @@ object Dependencies {
lazy val slf4jJulBridge = "org.slf4j" % "jul-to-slf4j" % slf4jVersion
lazy val slf4jSystem = "org.slf4j" % "slf4j-jdk-platform-logging" % slf4jVersion

private val tapirVersion = "1.11.1"
private val tapirVersion = "1.11.7"
lazy val tapirCirce = "com.softwaremill.sttp.tapir" %% "tapir-json-circe" % tapirVersion
lazy val tapirHelidon = "com.softwaremill.sttp.tapir" %% "tapir-nima-server" % tapirVersion
lazy val tapirPrometheus = "com.softwaremill.sttp.tapir" %% "tapir-prometheus-metrics" % tapirVersion
lazy val tapirServerStub = "com.softwaremill.sttp.tapir" %% "tapir-sttp-stub-server" % tapirVersion
lazy val tapirSwagger = "com.softwaremill.sttp.tapir" %% "tapir-swagger-ui-bundle" % tapirVersion
lazy val tapirVertex = "com.softwaremill.sttp.tapir" %% "tapir-vertx-server" % tapirVersion

lazy val tapirSttpCirce = "com.softwaremill.sttp.client3" %% "circe" % "3.9.8"
lazy val tapirSttpCirce = "com.softwaremill.sttp.client3" %% "circe" % "3.10.1"

val testcontainersVersion = "1.20.1"
val testcontainersVersion = "1.20.3"
lazy val testcontainersCore = "org.testcontainers" % "testcontainers" % testcontainersVersion
lazy val testcontainersJdbc = "org.testcontainers" % "jdbc" % testcontainersVersion
lazy val testcontainersSqlserver = "org.testcontainers" % "mssqlserver" % testcontainersVersion
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.10.1
sbt.version=1.10.4
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
addSbtPlugin("com.codecommit" % "sbt-github-packages" % "0.5.3")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.4")
addSbtPlugin("com.github.sbt" % "sbt-git" % "2.0.1")
addSbtPlugin("com.github.sbt" % "sbt-git" % "2.1.0")
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.10.4")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.10.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")

0 comments on commit 291e831

Please sign in to comment.