Skip to content
Permalink
Browse files
fix(version): fix displayed versions (#2026)
* fix(version): fix displayed versions

* added missing name + formatting fix

* fix
  • Loading branch information
mpro7 committed Mar 24, 2022
1 parent 4bd5b2f commit 566285c227a59f2a6efc93ded171ab548efde3a2
Showing with 17 additions and 40 deletions.
  1. +12 −36 webapi/src/main/scala/org/knora/webapi/routing/VersionRoute.scala
  2. +5 −4 webapi/src/test/scala/org/knora/webapi/it/VersionRouteITSpec.scala
@@ -15,15 +15,6 @@ import spray.json.{JsObject, JsString}

import scala.concurrent.duration._

case class VersionCheckResult(
name: String,
webapi: String,
scala: String,
akkaHttp: String,
sipi: String,
fuseki: String
)

/**
* Provides version check logic
*/
@@ -32,39 +23,24 @@ trait VersionCheck {

override implicit val timeout: Timeout = 1.second

protected def createResponse(result: VersionCheckResult): HttpResponse =
protected def createResponse(): HttpResponse = {
val sipiVersion: String = BuildInfo.sipi.split(":").apply(1)
val fusekiVersion: String = BuildInfo.fuseki.split(":").apply(1)

HttpResponse(
status = StatusCodes.OK,
entity = HttpEntity(
ContentTypes.`application/json`,
JsObject(
"name" -> JsString(result.name),
"webapi" -> JsString(result.webapi),
"scala" -> JsString(result.scala),
"akkaHttp" -> JsString(result.akkaHttp),
"sipi" -> JsString(result.sipi),
"fuseki" -> JsString(result.fuseki)
).compactPrint
"name" -> JsString("version"),
"webapi" -> JsString(BuildInfo.version),
"scala" -> JsString(BuildInfo.scalaVersion),
"akkaHttp" -> JsString(BuildInfo.akkaHttp),
"sipi" -> JsString(sipiVersion),
"fuseki" -> JsString(fusekiVersion)
).prettyPrint
)
)

protected def getVersion: VersionCheckResult = {
var sipiVersion = BuildInfo.sipi
val sipiIndex = sipiVersion.indexOf(':')
sipiVersion = if (sipiIndex > 0) sipiVersion.substring(sipiIndex + 1) else sipiVersion

var fusekiVersion = BuildInfo.fuseki
val fusekiIndex = fusekiVersion.indexOf(':')
fusekiVersion = if (fusekiIndex > 0) fusekiVersion.substring(fusekiIndex + 1) else fusekiVersion

VersionCheckResult(
name = "version",
webapi = BuildInfo.version,
scala = BuildInfo.version,
akkaHttp = BuildInfo.akkaHttp,
sipi = sipiVersion,
fuseki = fusekiVersion
)
}
}

@@ -79,7 +55,7 @@ class VersionRoute(routeData: KnoraRouteData) extends KnoraRoute(routeData) with
override def makeRoute(featureFactoryConfig: FeatureFactoryConfig): Route =
path("version") {
get { requestContext =>
requestContext.complete(createResponse(getVersion))
requestContext.complete(createResponse())
}
}
}
@@ -17,10 +17,11 @@ import scala.concurrent.duration._
import scala.languageFeature.postfixOps

object VersionRouteITSpec {
val config: Config = ConfigFactory.parseString("""
|akka.loglevel = "DEBUG"
|akka.stdout-loglevel = "DEBUG"
""".stripMargin)
val config: Config = ConfigFactory.parseString(
"""
|akka.loglevel = "DEBUG"
|akka.stdout-loglevel = "DEBUG"
""".stripMargin)
}

/**

0 comments on commit 566285c

Please sign in to comment.