|
| 1 | +# Json-Ld Scopes |
| 2 | + |
| 3 | +## Decision |
| 4 | + |
| 5 | +Implement Json-Ld scopes, which are runtime visibility boundaries that enable Json-Ld contexts to be specified for |
| 6 | +different processing contexts. For example, Json-Ld processing for Dataspace Protocol messages and identity-trust |
| 7 | +protocol messages will utilize different Json-Ld contexts. It must be possible to individually specify these contexts. |
| 8 | + |
| 9 | +## Rationale |
| 10 | + |
| 11 | +Currently, Json-Ld processing is handled by `JerseyJsonLdInterceptor` and `JsonLdRemoteMessageSerializerImpl` that are |
| 12 | +registered for each ingess/egress context. On egress, during compaction, `JerseyJsonLdInterceptor` |
| 13 | +and `JsonLdRemoteMessageSerializerImpl` delegate to `TitaniumJsonLd`, which synthesizes a Json-Ld context based on |
| 14 | +namespaces registered using `JsonLd.registerNamespace(String prefix, String contextIri)`. This results in `@context` |
| 15 | +structures containing extraneous information. For example, a registered `DCAT` namespace will be included in the context |
| 16 | +synthesized for identity and trust endpoints, which is never referenced in messages. |
| 17 | + |
| 18 | +Json-Ld scopes will provide a mechanism to avoid extraneous context items by making it possible to limit registration to |
| 19 | +an endpoint context. |
| 20 | + |
| 21 | +## Approach |
| 22 | + |
| 23 | +### Namespace Registration |
| 24 | + |
| 25 | +The `JsonLd` interface will be extended with an overloaded method containing a `scope` parameter: |
| 26 | + |
| 27 | +``` |
| 28 | +void registerNamespace(String prefix, String contextIri, String scope) |
| 29 | +``` |
| 30 | + |
| 31 | +The scope parameter will identify a Web Context Alias set in the `JerseyWebService`. A `*` value is treated as a |
| 32 | +wildcard to indicate all web context aliases. |
| 33 | + |
| 34 | +The existing `registerNamespace(String prefix, String contextIri)` method will be treated as a `*` wildcard |
| 35 | +registration. This will maintain backward compatibility. |
| 36 | + |
| 37 | +Existing registrations will be ported according to the following table: |
| 38 | + |
| 39 | +| Namespace | Web Context Alias | |
| 40 | +|---------------|---------------------------| |
| 41 | +| EDC_NAMESPACE | * | |
| 42 | +| DCAT_SCHEMA | DSP | |
| 43 | +| ODRL_SCHEMA | DSP, MANAGEMENT_API, IATP | |
| 44 | +| DSPACE_SCHEMA | DSP | |
| 45 | + |
| 46 | +### Context Registration |
| 47 | + |
| 48 | +The `JsonLd` interface will be extended to support registration of context references. For example: |
| 49 | + |
| 50 | +```json |
| 51 | +{ |
| 52 | + "@context": [ |
| 53 | + "https://example.org/context/v1" |
| 54 | + ] |
| 55 | +} |
| 56 | +``` |
| 57 | + |
| 58 | +The following methods will be added to `JsonLd`: |
| 59 | + |
| 60 | +``` |
| 61 | + void registerContext(String contextIri) |
| 62 | + |
| 63 | + void registerContext(String contextIri, String scope) |
| 64 | +``` |
| 65 | + |
| 66 | +The first method variant will register a context reference using the `*` wildcard scope. On compaction, the `JsonLd` |
| 67 | +service will insert references to registered contexts in the synthesized `@context`structure. |
| 68 | + |
| 69 | +### Json-Ld Compaction |
| 70 | + |
| 71 | +Json-Ld compaction will be performed in an egress scope that corresponds to the `JerseyWebService` context alias. |
| 72 | +The `JsonLd` interface will be extended with an overloaded method containing a `scope` parameter: |
| 73 | + |
| 74 | +``` |
| 75 | +Result<JsonObject> compact(JsonObject json, String scope); |
| 76 | +``` |
| 77 | + |
| 78 | +The existing `Json.ld.compact(JsonObject json)` method will be treated as a `*` wildcard. |
| 79 | + |
| 80 | +Constructors for `JerseyJsonLdInterceptor` and `JsonLdRemoteMessageSerializerImpl` will be updated to include a `scope` |
| 81 | +parameter that will be used for compaction operations. |
| 82 | + |
0 commit comments