-
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.
Remove dependency on rdf from storage (#4131)
* Remove dependency on rdf from storage * don't compile with java 1.8 * no, it's the other ones which shouldn't use 1.8 * don't trigger storage build if rdf/kernel change * reduce storage scoverage threshold
- Loading branch information
1 parent
3e128a4
commit 4186060
Showing
13 changed files
with
146 additions
and
61 deletions.
There are no files selected for viewing
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
9 changes: 9 additions & 0 deletions
9
storage/src/main/scala/ch/epfl/bluebrain/nexus/storage/MediaTypes.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,9 @@ | ||
package ch.epfl.bluebrain.nexus.storage | ||
|
||
import akka.http.scaladsl.model.MediaType | ||
import akka.http.scaladsl.model.HttpCharsets.`UTF-8` | ||
|
||
object MediaTypes { | ||
final val `application/ld+json`: MediaType.WithFixedCharset = | ||
MediaType.applicationWithFixedCharset("ld+json", `UTF-8`, "jsonld") | ||
} |
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
25 changes: 25 additions & 0 deletions
25
storage/src/main/scala/ch/epfl/bluebrain/nexus/storage/UriUtils.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,25 @@ | ||
package ch.epfl.bluebrain.nexus.storage | ||
|
||
import akka.http.scaladsl.model.Uri | ||
|
||
object UriUtils { | ||
|
||
/** | ||
* Adds a segment to the end of the Uri | ||
*/ | ||
def addPath(uri: Uri, segment: String): Uri = { | ||
if (segment.trim.isEmpty) uri | ||
else { | ||
val segmentStartsWithSlash = segment.startsWith("/") | ||
val uriEndsWithSlash = uri.path.endsWithSlash | ||
if (uriEndsWithSlash && segmentStartsWithSlash) | ||
uri.copy(path = uri.path + segment.drop(1)) | ||
else if (uriEndsWithSlash) | ||
uri.copy(path = uri.path + segment) | ||
else if (segmentStartsWithSlash) | ||
uri.copy(path = uri.path / segment.drop(1)) | ||
else | ||
uri.copy(path = uri.path / segment) | ||
} | ||
} | ||
} |
7 changes: 3 additions & 4 deletions
7
storage/src/main/scala/ch/epfl/bluebrain/nexus/storage/config/Contexts.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 |
---|---|---|
@@ -1,13 +1,12 @@ | ||
package ch.epfl.bluebrain.nexus.storage.config | ||
|
||
import ch.epfl.bluebrain.nexus.delta.rdf.IriOrBNode.Iri | ||
import ch.epfl.bluebrain.nexus.delta.rdf.implicits._ | ||
import akka.http.scaladsl.model.Uri | ||
|
||
object Contexts { | ||
|
||
private val base = "https://bluebrain.github.io/nexus/contexts/" | ||
|
||
val errorCtxIri: Iri = iri"${base}error.json" | ||
val resourceCtxIri: Iri = iri"${base}resource.json" | ||
val errorCtxIri: Uri = s"${base}error.json" | ||
val resourceCtxIri: Uri = s"${base}resource.json" | ||
|
||
} |
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
40 changes: 40 additions & 0 deletions
40
storage/src/main/scala/ch/epfl/bluebrain/nexus/storage/jsonld/JsonLdContext.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,40 @@ | ||
package ch.epfl.bluebrain.nexus.storage.jsonld | ||
|
||
import akka.http.scaladsl.model.Uri | ||
import io.circe.Json | ||
|
||
object JsonLdContext { | ||
|
||
object keywords { | ||
val context = "@context" | ||
} | ||
|
||
/** | ||
* Adds a context Iri to an existing @context, or creates an @context with the Iri as a value. | ||
*/ | ||
def addContext(json: Json, contextIri: Uri): Json = { | ||
val jUriString = Json.fromString(contextIri.toString) | ||
|
||
json.asObject match { | ||
case Some(obj) => | ||
val updated = obj(keywords.context) match { | ||
case None => obj.add(keywords.context, jUriString) | ||
case Some(ctxValue) => | ||
(ctxValue.asObject, ctxValue.asArray, ctxValue.asString) match { | ||
case (Some(co), _, _) if co.isEmpty => obj.add(keywords.context, jUriString) | ||
case (_, Some(ca), _) if ca.isEmpty => obj.add(keywords.context, jUriString) | ||
case (_, _, Some(cs)) if cs.isEmpty => obj.add(keywords.context, jUriString) | ||
case (Some(co), _, _) if !co.values.exists(_ == jUriString) => | ||
obj.add(keywords.context, Json.arr(ctxValue, jUriString)) | ||
case (_, Some(ca), _) if !ca.contains(jUriString) => | ||
obj.add(keywords.context, Json.fromValues(ca :+ jUriString)) | ||
case (_, _, Some(cs)) if cs != contextIri.toString => | ||
obj.add(keywords.context, Json.arr(ctxValue, jUriString)) | ||
case _ => obj | ||
} | ||
} | ||
Json.fromJsonObject(updated) | ||
case None => json | ||
} | ||
} | ||
} |
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
Oops, something went wrong.