Skip to content

Commit

Permalink
Update to Jena 5.2 and Json-LD 1.1 (#5280)
Browse files Browse the repository at this point in the history
* Update to Jena 5.2 and Json-LD 1.1

---------

Co-authored-by: Simon Dumas <simon.dumas@frontiersin.org>
  • Loading branch information
imsdu and Simon Dumas authored Feb 18, 2025
1 parent 8bdd20b commit 3cb4d34
Show file tree
Hide file tree
Showing 128 changed files with 627 additions and 653 deletions.
17 changes: 10 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ val distageVersion = "1.2.16"
val doobieVersion = "1.0.0-RC7"
val fs2Version = "3.11.0"
val fs2AwsVersion = "6.2.0"
val glassFishJakartaVersion = "2.0.1"
val handleBarsVersion = "4.4.0"
val hikariVersion = "6.2.1"
val jenaVersion = "4.10.0"
val jsonldjavaVersion = "0.13.6"
val jenaVersion = "5.2.0"
val kamonVersion = "2.7.5"
val kanelaAgentVersion = "1.0.18"
val kindProjectorVersion = "0.13.3"
Expand All @@ -52,7 +52,8 @@ val postgresJdbcVersion = "42.7.5"
val pureconfigVersion = "0.17.8"
val scalaTestVersion = "3.2.19"
val scalaXmlVersion = "2.3.0"
val topBraidVersion = "1.4.3"
val titaniumJsonLdVersion = "1.5.0"
val topBraidVersion = "1.4.4"
val testContainersVersion = "1.20.4"
val testContainersScalaVersion = "0.41.8"

Expand Down Expand Up @@ -96,9 +97,9 @@ lazy val fs2ReactiveStreams = "co.fs2" %% "fs2-
lazy val fs2io = "co.fs2" %% "fs2-io" % fs2Version
lazy val fs2Aws = "io.laserdisc" %% "fs2-aws-core" % fs2AwsVersion
lazy val fs2AwsS3 = "io.laserdisc" %% "fs2-aws-s3" % fs2AwsVersion
lazy val glassFishJakarta = "org.glassfish" % "jakarta.json" % glassFishJakartaVersion
lazy val handleBars = "com.github.jknack" % "handlebars" % handleBarsVersion
lazy val jenaArq = "org.apache.jena" % "jena-arq" % jenaVersion exclude ("com.apicatalog", "titanium-json-ld")
lazy val jsonldjava = "com.github.jsonld-java" % "jsonld-java" % jsonldjavaVersion
lazy val jenaArq = "org.apache.jena" % "jena-arq" % jenaVersion
lazy val kamonAkkaHttp = "io.kamon" %% "kamon-akka-http" % kamonVersion
lazy val kamonCore = "io.kamon" %% "kamon-core" % kamonVersion
lazy val kanelaAgent = "io.kamon" % "kanela-agent" % kanelaAgentVersion
Expand All @@ -114,7 +115,8 @@ lazy val pureconfigCats = "com.github.pureconfig" %% "pure
lazy val scalaReflect = "org.scala-lang" % "scala-reflect" % scalaCompilerVersion
lazy val scalaTest = "org.scalatest" %% "scalatest" % scalaTestVersion
lazy val scalaXml = "org.scala-lang.modules" %% "scala-xml" % scalaXmlVersion
lazy val topBraidShacl = "org.topbraid" % "shacl" % topBraidVersion exclude ("com.apicatalog", "titanium-json-ld")
lazy val titaniumJsonLd = "com.apicatalog" % "titanium-json-ld" % titaniumJsonLdVersion
lazy val topBraidShacl = "org.topbraid" % "shacl" % topBraidVersion
lazy val testContainers = "org.testcontainers" % "testcontainers" % testContainersVersion
lazy val testContainersScala = "com.dimafeng" %% "testcontainers-scala-munit" % testContainersScalaVersion
lazy val testContainersScalaLocalStack = "com.dimafeng" %% "testcontainers-scala-localstack-v2" % testContainersScalaVersion
Expand Down Expand Up @@ -291,10 +293,11 @@ lazy val rdf = project
circeParser,
circeGeneric,
circeGenericExtras,
glassFishJakarta,
jenaArq,
jsonldjava,
magnolia,
scalaReflect,
titaniumJsonLd,
topBraidShacl,
logback % Test
),
Expand Down
17 changes: 0 additions & 17 deletions delta/app/src/main/resources/app.conf
Original file line number Diff line number Diff line change
Expand Up @@ -116,23 +116,6 @@ app {
resolve-base = "http://localhost:8081"
}

# Json-LD Api configuration
json-ld-api {
# Set the Jena parser to perform extra checks:
# * URIs - whether IRs confirm to all the rules of the URI scheme
# * Literals: whether the lexical form conforms to the rules for the datatype.
# * Triples and quads: check slots have a valid kind of RDF term (parsers usually make this a syntax error anyway).
extra-checks: true
# Set the Jena parser to strict mode
# This mode do the extra-checks described above and reject relative iris/uris
strict: false
# Define the error handler for the Jena parser
# * strict: Both errors and warnings will raise exceptions
# * default: Errors will raise exceptions and warning will result in logs
# * no-warning: Erros will raise exceptions and warning will result in logs
error-handling: "strict"
}

jws {
# JWS configuration to sign and verify JWS payloads.
# Those are used for delegation operations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import cats.effect.IO
import cats.syntax.all._
import ch.epfl.bluebrain.nexus.delta.kernel.cache.CacheConfig
import ch.epfl.bluebrain.nexus.delta.kernel.config.Configs
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.api.JsonLdApiConfig
import ch.epfl.bluebrain.nexus.delta.sdk.acls.AclsConfig
import ch.epfl.bluebrain.nexus.delta.sdk.fusion.FusionConfig
import ch.epfl.bluebrain.nexus.delta.sdk.jws.JWSConfig
Expand Down Expand Up @@ -35,7 +34,6 @@ final case class AppConfig(
description: DescriptionConfig,
http: HttpConfig,
database: DatabaseConfig,
jsonLdApi: JsonLdApiConfig,
identities: CacheConfig,
permissions: PermissionsConfig,
realms: RealmsConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import ch.epfl.bluebrain.nexus.delta.kernel.dependency.ComponentDescription.Plug
import ch.epfl.bluebrain.nexus.delta.kernel.utils.{ClasspathResourceLoader, IOFuture, UUIDF}
import ch.epfl.bluebrain.nexus.delta.provisioning.ProvisioningCoordinator
import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary.contexts
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.api.{JsonLdApi, JsonLdJavaApi}
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.{ContextValue, RemoteContextResolution}
import ch.epfl.bluebrain.nexus.delta.rdf.utils.JsonKeyOrdering
import ch.epfl.bluebrain.nexus.delta.routes.ErrorRoutes
Expand Down Expand Up @@ -121,10 +120,6 @@ class DeltaModule(appCfg: AppConfig, config: Config)(implicit classLoader: Class
.merge(otherCtxResolutions.toSeq: _*)
}

make[JsonLdApi].fromValue {
new JsonLdJavaApi(appCfg.jsonLdApi)
}

make[Clock[IO]].from(implicitly[Clock[IO]])
make[UUIDF].from(UUIDF.random)
make[JsonKeyOrdering].from(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import ch.epfl.bluebrain.nexus.delta.Main.pluginsMaxPriority
import ch.epfl.bluebrain.nexus.delta.config.AppConfig
import ch.epfl.bluebrain.nexus.delta.kernel.utils.{ClasspathResourceLoader, UUIDF}
import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary.contexts
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.api.JsonLdApi
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.{ContextValue, RemoteContextResolution}
import ch.epfl.bluebrain.nexus.delta.rdf.utils.JsonKeyOrdering
import ch.epfl.bluebrain.nexus.delta.routes.ResolversRoutes
Expand Down Expand Up @@ -39,7 +38,6 @@ object ResolversModule extends ModuleDef {
resolverContextResolution: ResolverContextResolution,
config: AppConfig,
xas: Transactors,
api: JsonLdApi,
clock: Clock[IO],
uuidF: UUIDF
) =>
Expand All @@ -50,7 +48,7 @@ object ResolversModule extends ModuleDef {
config.resolvers.eventLog,
xas,
clock
)(api, uuidF)
)(uuidF)
}

make[MultiResolution].from {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import cats.effect.{Clock, IO}
import ch.epfl.bluebrain.nexus.delta.Main.pluginsMinPriority
import ch.epfl.bluebrain.nexus.delta.config.AppConfig
import ch.epfl.bluebrain.nexus.delta.kernel.utils.UUIDF
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.api.JsonLdApi
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.RemoteContextResolution
import ch.epfl.bluebrain.nexus.delta.rdf.shacl.ValidateShacl
import ch.epfl.bluebrain.nexus.delta.rdf.utils.JsonKeyOrdering
Expand Down Expand Up @@ -64,17 +63,13 @@ object ResourcesModule extends ModuleDef {
resourceLog: ResourceLog,
fetchContext: FetchContext,
resolverContextResolution: ResolverContextResolution,
api: JsonLdApi,
uuidF: UUIDF
) =>
ResourcesImpl(
resourceLog,
fetchContext,
resolverContextResolution
)(
api,
uuidF
)
)(uuidF)
}

make[ResolverContextResolution].from {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package ch.epfl.bluebrain.nexus.delta.wiring
import cats.effect.{Clock, IO}
import ch.epfl.bluebrain.nexus.delta.Main.pluginsMinPriority
import ch.epfl.bluebrain.nexus.delta.kernel.utils.UUIDF
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.api.JsonLdApi
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.RemoteContextResolution
import ch.epfl.bluebrain.nexus.delta.rdf.utils.JsonKeyOrdering
import ch.epfl.bluebrain.nexus.delta.routes.ResourcesTrialRoutes
Expand All @@ -29,7 +28,6 @@ object ResourcesTrialModule extends ModuleDef {
validate: ValidateResource,
fetchContext: FetchContext,
contextResolution: ResolverContextResolution,
api: JsonLdApi,
clock: Clock[IO],
uuidF: UUIDF
) =>
Expand All @@ -39,7 +37,7 @@ object ResourcesTrialModule extends ModuleDef {
fetchContext,
contextResolution,
clock
)(api, uuidF)
)(uuidF)
}

make[ResourcesTrialRoutes].from {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import ch.epfl.bluebrain.nexus.delta.Main.pluginsMaxPriority
import ch.epfl.bluebrain.nexus.delta.config.AppConfig
import ch.epfl.bluebrain.nexus.delta.kernel.utils.{ClasspathResourceLoader, UUIDF}
import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary.contexts
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.api.JsonLdApi
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.{ContextValue, RemoteContextResolution}
import ch.epfl.bluebrain.nexus.delta.rdf.shacl.ValidateShacl
import ch.epfl.bluebrain.nexus.delta.rdf.utils.JsonKeyOrdering
Expand Down Expand Up @@ -43,7 +42,7 @@ object SchemasModule extends ModuleDef {

make[ValidateShacl].fromEffect { (rcr: RemoteContextResolution @Id("aggregate")) => ValidateShacl(rcr) }

make[ValidateSchema].from { (validateShacl: ValidateShacl, api: JsonLdApi) => ValidateSchema(validateShacl)(api) }
make[ValidateSchema].from { (validateShacl: ValidateShacl) => ValidateSchema(validateShacl) }

make[SchemaDefinition].from { (validateSchema: ValidateSchema, clock: Clock[IO]) =>
Schemas.definition(validateSchema, clock)
Expand All @@ -62,7 +61,6 @@ object SchemasModule extends ModuleDef {
schemaLog: SchemaLog,
fetchContext: FetchContext,
schemaImports: SchemaImports,
api: JsonLdApi,
resolverContextResolution: ResolverContextResolution,
uuidF: UUIDF
) =>
Expand All @@ -71,7 +69,7 @@ object SchemasModule extends ModuleDef {
fetchContext,
schemaImports,
resolverContextResolution
)(api, uuidF)
)(uuidF)
}

make[SchemaImports].from {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
"result": {
"@type": "sh:ValidationResult",
"focusNode": "nxv:MyShape",
"result:Path": {
"@id": "node:Kind"
"sh:resultPath": {
"@id": "sh:nodeKind"
},
"resultMessage": "Not a value from the sh:in enumeration",
"resultSeverity": "sh:Violation",
"sourceConstraintComponent": "sh:InConstraintComponent",
"sourceShape": {
},
"value": "nxv:42"
"sh:value": 42
},
"targetedNodes": 412
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import ch.epfl.bluebrain.nexus.delta.plugins.storage.FileSelf.ParsingError
import ch.epfl.bluebrain.nexus.delta.plugins.storage.files.Files
import ch.epfl.bluebrain.nexus.delta.plugins.storage.files.model.{FileId, FileRejection}
import ch.epfl.bluebrain.nexus.delta.rdf.implicits._
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.api.{JsonLdApi, JsonLdJavaApi}
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.api.{JsonLdApi, TitaniumJsonLdApi}
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.RemoteContextResolution
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.encoder.JsonLdEncoder
import ch.epfl.bluebrain.nexus.delta.rdf.utils.JsonKeyOrdering
Expand Down Expand Up @@ -96,7 +96,7 @@ object ArchiveDownload {
): ArchiveDownload =
new ArchiveDownload {

implicit private val api: JsonLdApi = JsonLdJavaApi.lenient
implicit private val api: JsonLdApi = TitaniumJsonLdApi.lenient
private val printer = Printer.spaces2.copy(dropNullValues = true)
private val sourcePrinter = Printer.spaces2.copy(dropNullValues = false)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import ch.epfl.bluebrain.nexus.delta.plugins.archive.model.contexts
import ch.epfl.bluebrain.nexus.delta.plugins.archive.routes.ArchiveRoutes
import ch.epfl.bluebrain.nexus.delta.plugins.storage.FileSelf
import ch.epfl.bluebrain.nexus.delta.plugins.storage.files.Files
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.api.JsonLdApi
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.{ContextValue, RemoteContextResolution}
import ch.epfl.bluebrain.nexus.delta.rdf.utils.JsonKeyOrdering
import ch.epfl.bluebrain.nexus.delta.sdk._
Expand Down Expand Up @@ -51,16 +50,11 @@ object ArchivePluginModule extends ModuleDef {
archiveDownload: ArchiveDownload,
cfg: ArchivePluginConfig,
xas: Transactors,
api: JsonLdApi,
uuidF: UUIDF,
rcr: RemoteContextResolution @Id("aggregate"),
clock: Clock[IO]
) =>
Archives(fetchContext, archiveDownload, cfg, xas, clock)(
api,
uuidF,
rcr
)
Archives(fetchContext, archiveDownload, cfg, xas, clock)(uuidF, rcr)
}

make[ArchiveRoutes].from {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package ch.epfl.bluebrain.nexus.delta.plugins.archive

import cats.effect.{Clock, IO}
import ch.epfl.bluebrain.nexus.delta.kernel.AkkaSource
import ch.epfl.bluebrain.nexus.delta.kernel.kamon.KamonMetricComponent
import ch.epfl.bluebrain.nexus.delta.kernel.syntax._
import ch.epfl.bluebrain.nexus.delta.kernel.utils.UUIDF
import ch.epfl.bluebrain.nexus.delta.plugins.archive.Archives.{entityType, expandIri, ArchiveLog}
import ch.epfl.bluebrain.nexus.delta.plugins.archive.model.ArchiveRejection._
import ch.epfl.bluebrain.nexus.delta.plugins.archive.model._
import ch.epfl.bluebrain.nexus.delta.rdf.IriOrBNode.Iri
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.api.JsonLdApi
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.RemoteContextResolution
import ch.epfl.bluebrain.nexus.delta.kernel.AkkaSource
import ch.epfl.bluebrain.nexus.delta.sdk.identities.model.Caller
import ch.epfl.bluebrain.nexus.delta.sdk.jsonld.ExpandIri
import ch.epfl.bluebrain.nexus.delta.sdk.jsonld.JsonLdSourceProcessor.JsonLdSourceDecoder
Expand Down Expand Up @@ -184,7 +183,7 @@ object Archives {
cfg: ArchivePluginConfig,
xas: Transactors,
clock: Clock[IO]
)(implicit api: JsonLdApi, uuidF: UUIDF, rcr: RemoteContextResolution): Archives = new Archives(
)(implicit uuidF: UUIDF, rcr: RemoteContextResolution): Archives = new Archives(
EphemeralLog(
definition(clock),
cfg.ephemeral,
Expand All @@ -204,7 +203,7 @@ object Archives {
onUniqueViolation = (id: Iri, c: CreateArchive) => ResourceAlreadyExists(id, c.project)
)

private[archive] def sourceDecoder(implicit api: JsonLdApi, uuidF: UUIDF): JsonLdSourceDecoder[ArchiveValue] =
private[archive] def sourceDecoder(implicit uuidF: UUIDF): JsonLdSourceDecoder[ArchiveValue] =
new JsonLdSourceDecoder[ArchiveValue](contexts.archives, uuidF)

private[archive] def evaluate(clock: Clock[IO])(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import ch.epfl.bluebrain.nexus.delta.plugins.archive.model.ArchiveReference.{Fil
import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.AbsolutePath
import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary.nxv
import ch.epfl.bluebrain.nexus.delta.rdf.implicits._
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.api.{JsonLdApi, JsonLdJavaApi}
import ch.epfl.bluebrain.nexus.delta.sdk.jsonld.JsonLdRejection.{DecodingFailed, InvalidJsonLdFormat, UnexpectedId}
import ch.epfl.bluebrain.nexus.delta.sdk.model.ResourceRepresentation.{AnnotatedSourceJson, CompactedJsonLd, Dot, ExpandedJsonLd, NTriples, SourceJson}
import ch.epfl.bluebrain.nexus.delta.sdk.projects.model.{ApiMappings, ProjectContext}
Expand All @@ -20,8 +19,7 @@ import java.nio.file.Paths

class ArchivesDecodingSpec extends CatsEffectSpec with RemoteContextResolutionFixture {

implicit private val uuidF: UUIDF = UUIDF.random
implicit private val api: JsonLdApi = JsonLdJavaApi.strict
implicit private val uuidF: UUIDF = UUIDF.random

private val context = ProjectContext.unsafe(ApiMappings.empty, nxv.base, nxv.base, enforceSchema = false)

Expand Down Expand Up @@ -203,15 +201,15 @@ class ArchivesDecodingSpec extends CatsEffectSpec with RemoteContextResolutionFi

"fail" when {

"it can't be parse as json-ld" in {
"it can't be parsed as json-ld" ignore {

val list = List(
// the resourceId is not an absolute iri
json"""{
"resources": [
{
"@type": "File",
"resourceId": "invalid iri"
"resourceId": "schema:invalid iri"
}
]
}""",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ package ch.epfl.bluebrain.nexus.delta.plugins.archive
import akka.stream.scaladsl.Source
import cats.data.NonEmptySet
import cats.effect.IO
import ch.epfl.bluebrain.nexus.delta.kernel.AkkaSource
import ch.epfl.bluebrain.nexus.delta.kernel.utils.UUIDF
import ch.epfl.bluebrain.nexus.delta.plugins.archive.model.ArchiveReference.{FileReference, ResourceReference}
import ch.epfl.bluebrain.nexus.delta.plugins.archive.model.ArchiveRejection.ArchiveNotFound
import ch.epfl.bluebrain.nexus.delta.plugins.archive.model.{Archive, ArchiveValue}
import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary.{nxv, schema}
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.api.{JsonLdApi, JsonLdJavaApi}
import ch.epfl.bluebrain.nexus.delta.kernel.AkkaSource
import ch.epfl.bluebrain.nexus.delta.sdk.generators.ProjectGen
import ch.epfl.bluebrain.nexus.delta.sdk.identities.model.Caller
import ch.epfl.bluebrain.nexus.delta.sdk.implicits._
Expand All @@ -35,8 +34,6 @@ class ArchivesSpec extends CatsEffectSpec with DoobieScalaTestFixture with Remot
private val uuid = UUID.randomUUID()
implicit private val uuidF: UUIDF = UUIDF.random

implicit private val api: JsonLdApi = JsonLdJavaApi.strict

private val usersRealm: Label = Label.unsafe("users")
private val bob: Subject = User("bob", usersRealm)
implicit private val caller: Caller = Caller.unsafe(bob)
Expand Down
Loading

0 comments on commit 3cb4d34

Please sign in to comment.