Fedora JSON-LD addons
- Compacton filter: Compacts all json-ld responses from the repository with respect to a given context.
- Deserialization filter: Accepts compacted (or uncompacted) JSON-LD, validates it, and persists it to the repository. Uses cached or pre-loaded contexts where possible.
- JSON Merge Patch filter: Accepts compacted JSON-LD and performs an RFC7386 merge patch against the persisted resource, in compact form.
Configuration
Logging
System properties or environment variables that start with LOG
can be used to adjust logging levels, with the form LOG.logger.name=LEVEL
, e.g. LOG.org.dataconservancy=DEBUG
-
You may define an environment variable for a logger of your choice (e.g.
org.dataconservancy.jsonld
). Underscores may be used in place of periodsexport LOG_ORG_DATACONSERVANCY_JSONLD=DEBUG
-
You may define a system property that does the same
-Dlog.org.dataconservancy.jsonld=DEBUG
Static Loaded Contexts
Context URIs can be mapped to a files to pre-load contexts so that they can be used/cached without requiring resolution on the internet. As many contexts as desired can be loaded using the following pattern for a given arbitrary context name NAME
. Define system properties or environment varlables as follows:
-
Define environment variables
COMPACTION_PRELOAD_URI_NAME
andCOMPACTION_PRELOAD_FILE_NAME
export COMPACTION_PRELOAD_URI_MY_CONTEXT_1=http://example.org/context.jsonld export COMPACTION_PRELOAD_FILE_MY_CONTEXT_1=/path/to/file
-
Define system properties
compaction.preload.uri.NAME
andcompaction.preload.file.NAME
-Dcompaction.preload.uri.my.context.1=http://example.org/context.jsonld -Dcompaction.preload.file.my.context.1=/path/to/file
Compaction
A context can be provided such that json-ld responses are compacted with respect to the given context by default. Use one of the following three methods:
-
Define an environment variable
COMPACTION_URI
export COMPACTION_URI=http://example.org/context.jsonld
-
Define a system property
compaction.uri
-Dcompaction.uri=http://example.org/context.jsonld
Strict JSON-LD
When deserializing json-ld, normally unknown JSON attributes are ignored. This can be problematic if json-ld from users is known/assumed/required to be in a compact form such that every attribute is presumed to have a definition. In this scenario, an undefined attribute is an error. Strict jsonld processing will throw a bad request error (400) if user-submitted jsonld contaiins any content that isn't defined in a context.
-
Define an environment variable
JSONLD_STRICT
export JSONLD_STRICT=true
-
Define a system property
jsonld.strict
-Djsonld.strict=true
Minimal JSON-LD
When returning json-ld in compact form, when this is set the server will omit any properties that aren't mapped to anything in the context.
-
Define an environment variable
JSONLD_CONTEXT_MINIMAL
export JSONLD_CONTEXT_MINIMAL=true
-
Define a system property
jsonld.context.minimal
-Djsonld.context.minimal=true
Persisted contexts
This will cause the original jsonld context URI to be persisted in the repository, so that subsequent requests are compacted with respect to this context upon retrieval.
-
Define an environment variable
JSONLD_CONTEXT_PERSIST
export JSONLD_CONTEXT_PERSIST=true
-
Define a system property
jsonld.context.persist
-Djsonld.context.persist=true