Skip to content

Commit

Permalink
Merge branch 'main' into update/minor_major
Browse files Browse the repository at this point in the history
  • Loading branch information
mpro7 authored Nov 9, 2023
2 parents 73d52f0 + b093357 commit dc8cd47
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 268 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ trait FusekiTestContainer extends GenericContainer[FusekiTestContainer] {
.map(_.map(line => line.replace("@REPOSITORY@", repositoryName)).mkString("\n"))
request = HttpRequest
.newBuilder()
.uri(baseUrl.withPath("/$/datasets").toJavaURI)
.uri(baseUrl.path("/$/datasets").toJavaURI)
.POST(BodyPublishers.ofString(fusekiConfig))
.header("Content-Type", "text/turtle; charset=utf-8")
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ object SipiTestContainer {
def portAndHost: ZIO[SipiTestContainer, Nothing, (Int, String)] = port <*> host

def resolveUrl(path: http.Path): URIO[SipiTestContainer, URL] =
ZIO.serviceWith[SipiTestContainer](_.sipiBaseUrl.withPath(path))
ZIO.serviceWith[SipiTestContainer](_.sipiBaseUrl.path(path))

def copyFileToImageFolderInContainer(prefix: String, filename: String): ZIO[SipiTestContainer, Throwable, Unit] =
ZIO.serviceWithZIO[SipiTestContainer](_.copyFileToImageFolderInContainer(prefix, filename))
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ object Dependencies {
// found/added by the plugin but deleted anyway
val commonsLang3 = "org.apache.commons" % "commons-lang3" % "3.13.0"

val tapirVersion = "1.7.6"
val tapirVersion = "1.8.4"

val tapir = Seq(
"com.softwaremill.sttp.tapir" %% "tapir-pekko-http-server" % tapirVersion,
Expand Down
2 changes: 1 addition & 1 deletion webapi/scripts/healthcheck.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# Fetch health route status json
json=$(curl -sS --max-time 10 'http://localhost:3339/health')
json=$(curl -sS --max-time 10 'http://localhost:3333/health')
if [ $? -ne 0 ]; then
echo "Health route is not responding"
exit 1
Expand Down
3 changes: 2 additions & 1 deletion webapi/src/main/scala/org/knora/webapi/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package org.knora.webapi
import zio._

import org.knora.webapi.core._
import org.knora.webapi.slice.infrastructure.MetricsServer
import org.knora.webapi.util.Logger

object Main extends ZIOApp {
Expand All @@ -30,5 +31,5 @@ object Main extends ZIOApp {
* Entrypoint of our Application
*/
override def run: ZIO[Environment with ZIOAppArgs with Scope, Any, Any] =
AppServer.make *> InstrumentationServer.make
AppServer.make *> MetricsServer.make

Check warning on line 34 in webapi/src/main/scala/org/knora/webapi/Main.scala

View check run for this annotation

Codecov / codecov/patch

webapi/src/main/scala/org/knora/webapi/Main.scala#L34

Added line #L34 was not covered by tests
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import org.knora.webapi.core.MessageHandler
import org.knora.webapi.core.MessageRelay
import org.knora.webapi.messages.IriConversions._
import org.knora.webapi.messages._
import org.knora.webapi.messages.admin.responder.projectsmessages.ProjectGetRequestADM
import org.knora.webapi.messages.admin.responder.projectsmessages.ProjectGetResponseADM
import org.knora.webapi.messages.admin.responder.projectsmessages.ProjectIdentifierADM._
import org.knora.webapi.messages.admin.responder.usersmessages.UserADM
import org.knora.webapi.messages.store.triplestoremessages.SmartIriLiteralV2
Expand All @@ -38,6 +36,7 @@ import org.knora.webapi.responders.IriService
import org.knora.webapi.responders.Responder
import org.knora.webapi.responders.v2.ontology.CardinalityHandler
import org.knora.webapi.responders.v2.ontology.OntologyHelpers
import org.knora.webapi.slice.admin.domain.service.KnoraProjectRepo
import org.knora.webapi.slice.ontology.domain.service.CardinalityService
import org.knora.webapi.slice.ontology.domain.service.OntologyRepo
import org.knora.webapi.slice.ontology.repo.service.OntologyCache
Expand Down Expand Up @@ -71,10 +70,10 @@ final case class OntologyResponderV2Live(
cardinalityHandler: CardinalityHandler,
cardinalityService: CardinalityService,
iriService: IriService,
messageRelay: MessageRelay,
ontologyCache: OntologyCache,
ontologyHelpers: OntologyHelpers,
ontologyRepo: OntologyRepo,
projectRepo: KnoraProjectRepo,
triplestoreService: TriplestoreService,
implicit val stringFormatter: StringFormatter
) extends OntologyResponderV2
Expand Down Expand Up @@ -526,14 +525,6 @@ final case class OntologyResponderV2Live(
ZIO.fail(ForbiddenException(msg))
}

// Get project info for the shortcode.
projectInfo <-
IriIdentifier
.fromString(projectIri.toString)
.toZIO
.mapError(e => BadRequestException(e.getMessage))
.flatMap(id => messageRelay.ask[ProjectGetResponseADM](ProjectGetRequestADM(identifier = id)))

// Check that the ontology name is valid.
validOntologyName <-
ZIO
Expand All @@ -543,10 +534,12 @@ final case class OntologyResponderV2Live(
)

// Make the internal ontology IRI.
projectId <- IriIdentifier.fromString(projectIri.toString).toZIO.mapError(e => BadRequestException(e.getMessage))
project <- projectRepo.findById(projectId).someOrFail(BadRequestException(s"Project not found: $projectIri"))

Check warning on line 538 in webapi/src/main/scala/org/knora/webapi/responders/v2/OntologyResponderV2.scala

View check run for this annotation

Codecov / codecov/patch

webapi/src/main/scala/org/knora/webapi/responders/v2/OntologyResponderV2.scala#L537-L538

Added lines #L537 - L538 were not covered by tests
internalOntologyIri = stringFormatter.makeProjectSpecificInternalOntologyIri(
validOntologyName,
createOntologyRequest.isShared,
projectInfo.project.shortcode
project.shortcode.value

Check warning on line 542 in webapi/src/main/scala/org/knora/webapi/responders/v2/OntologyResponderV2.scala

View check run for this annotation

Codecov / codecov/patch

webapi/src/main/scala/org/knora/webapi/responders/v2/OntologyResponderV2.scala#L542

Added line #L542 was not covered by tests
)

// Do the remaining pre-update checks and the update while holding a global ontology cache lock.
Expand Down Expand Up @@ -2957,30 +2950,32 @@ final case class OntologyResponderV2Live(

object OntologyResponderV2Live {
val layer: URLayer[
StringFormatter
with TriplestoreService
with OntologyRepo
with OntologyHelpers
with OntologyCache
with CardinalityService
AppConfig
with CardinalityHandler
with MessageRelay
with CardinalityService
with IriService
with AppConfig,
with KnoraProjectRepo
with MessageRelay
with OntologyCache
with OntologyHelpers
with OntologyRepo
with StringFormatter
with TriplestoreService,
OntologyResponderV2
] = ZLayer.fromZIO {
for {
config <- ZIO.service[AppConfig]
iriS <- ZIO.service[IriService]
mr <- ZIO.service[MessageRelay]
ch <- ZIO.service[CardinalityHandler]
cs <- ZIO.service[CardinalityService]
oc <- ZIO.service[OntologyCache]
oh <- ZIO.service[OntologyHelpers]
or <- ZIO.service[OntologyRepo]
ts <- ZIO.service[TriplestoreService]
sf <- ZIO.service[StringFormatter]
handler <- mr.subscribe(OntologyResponderV2Live(config, ch, cs, iriS, mr, oc, oh, or, ts, sf))
} yield handler
ac <- ZIO.service[AppConfig]
ch <- ZIO.service[CardinalityHandler]
cs <- ZIO.service[CardinalityService]
is <- ZIO.service[IriService]
kr <- ZIO.service[KnoraProjectRepo]
oc <- ZIO.service[OntologyCache]
oh <- ZIO.service[OntologyHelpers]
or <- ZIO.service[OntologyRepo]
sf <- ZIO.service[StringFormatter]
ts <- ZIO.service[TriplestoreService]
responder = OntologyResponderV2Live(ac, ch, cs, is, oc, oh, or, kr, ts, sf)
_ <- MessageRelay.subscribe(responder)
} yield responder

Check warning on line 2979 in webapi/src/main/scala/org/knora/webapi/responders/v2/OntologyResponderV2.scala

View check run for this annotation

Codecov / codecov/patch

webapi/src/main/scala/org/knora/webapi/responders/v2/OntologyResponderV2.scala#L2967-L2979

Added lines #L2967 - L2979 were not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ final case class DspIngestClientLive(
importUrl <- ZIO.fromEither(URL.decode(s"${projectsPath(shortcode)}/import"))
token <- jwtService.createJwtForDspIngest()
request = Request
.post(Body.fromFile(fileToImport.toFile), importUrl)
.post(importUrl, Body.fromFile(fileToImport.toFile))
.addHeaders(
Headers(
Header.Authorization.Bearer(token.jwtString),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ final case class ProjectImportServiceLive(
def acquire(fusekiUrl: URL, httpClient: HttpClient) =
ZIO.attempt(RDFConnectionFuseki.service(fusekiUrl.encode).httpClient(httpClient).build())
def release(connection: RDFConnection) = ZIO.attempt(connection.close()).logError.ignore
ZIO.acquireRelease(acquire(fusekiBaseUrl.withPath(s"/${config.fuseki.repositoryName}"), httpClient))(release)
ZIO.acquireRelease(acquire(fusekiBaseUrl.path(s"/${config.fuseki.repositoryName}"), httpClient))(release)

Check warning on line 63 in webapi/src/main/scala/org/knora/webapi/slice/admin/domain/service/ProjectImportService.scala

View check run for this annotation

Codecov / codecov/patch

webapi/src/main/scala/org/knora/webapi/slice/admin/domain/service/ProjectImportService.scala#L63

Added line #L63 was not covered by tests
}

override def importTrigFile(file: Path): Task[Unit] = ZIO.scoped {
Expand Down Expand Up @@ -126,5 +126,5 @@ final case class ProjectImportServiceLive(
}

object ProjectImportServiceLive {
val layer = ZLayer.fromFunction(ProjectImportServiceLive.apply _)
val layer = ZLayer.derive[ProjectImportServiceLive]
}
Loading

0 comments on commit dc8cd47

Please sign in to comment.