-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wire initial remote context / resolver context resolution for schemas…
… to work
- Loading branch information
1 parent
1b734cd
commit b36db37
Showing
5 changed files
with
101 additions
and
8 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
ship/src/main/scala/ch/epfl/bluebrain/nexus/ship/ContextWiring.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package ch.epfl.bluebrain.nexus.ship | ||
|
||
import cats.effect.{Clock, IO} | ||
import ch.epfl.bluebrain.nexus.delta.kernel.utils.ClasspathResourceLoader | ||
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.sdk.acls.AclCheck | ||
import ch.epfl.bluebrain.nexus.delta.sdk.projects.FetchContext | ||
import ch.epfl.bluebrain.nexus.delta.sdk.resolvers.ResolverContextResolution | ||
import ch.epfl.bluebrain.nexus.delta.sdk.resources.FetchResource | ||
import ch.epfl.bluebrain.nexus.delta.sdk.resources.Resources.ResourceLog | ||
import ch.epfl.bluebrain.nexus.delta.sourcing.Transactors | ||
import ch.epfl.bluebrain.nexus.delta.sourcing.config.EventLogConfig | ||
import ch.epfl.bluebrain.nexus.ship.acls.AclWiring | ||
import ch.epfl.bluebrain.nexus.ship.resolvers.ResolverWiring | ||
|
||
object ContextWiring { | ||
|
||
implicit private val loader: ClasspathResourceLoader = ClasspathResourceLoader.withContext(getClass) | ||
|
||
def remoteContextResolution: IO[RemoteContextResolution] = | ||
for { | ||
shaclCtx <- ContextValue.fromFile("contexts/shacl.json") | ||
schemasMetaCtx <- ContextValue.fromFile("contexts/schemas-metadata.json") | ||
} yield RemoteContextResolution.fixed( | ||
contexts.shacl -> shaclCtx, | ||
contexts.schemasMetadata -> schemasMetaCtx | ||
) | ||
|
||
def resolverContextResolution( | ||
resourceLog: Clock[IO] => IO[ResourceLog], | ||
fetchContext: FetchContext, | ||
config: EventLogConfig, | ||
xas: Transactors | ||
)(implicit jsonLdApi: JsonLdApi): Clock[IO] => IO[ResolverContextResolution] = { clock => | ||
val aclCheck = AclCheck(AclWiring.acls(config, clock, xas)) | ||
val resolvers = ResolverWiring.resolvers(fetchContext, config, clock, xas) | ||
|
||
for { | ||
fetchResource <- resourceLog(clock).map(FetchResource(_)) | ||
rcr <- remoteContextResolution | ||
} yield ResolverContextResolution(aclCheck, resolvers, rcr, fetchResource) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters