Skip to content

Commit

Permalink
feat(dsp): cache dspace jsonld context document (#4048)
Browse files Browse the repository at this point in the history
* feat(dsp): cache dspace jsonld context document

* pr remark
  • Loading branch information
ndr-brt authored Mar 27, 2024
1 parent ab5e7f5 commit e5e7651
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.stream.Stream;

import static java.lang.String.format;
import static org.eclipse.edc.spi.CoreConstants.EDC_NAMESPACE;
Expand Down Expand Up @@ -89,9 +90,13 @@ public JsonLd createJsonLdService(ServiceExtensionContext context) {
}
service.registerNamespace(EDC_PREFIX, EDC_NAMESPACE);

getResourceUri("document" + File.separator + "odrl.jsonld")
.onSuccess(uri -> service.registerCachedDocument("http://www.w3.org/ns/odrl.jsonld", uri))
.onFailure(failure -> monitor.warning("Failed to register cached json-ld document: " + failure.getFailureDetail()));
Stream.of(
new JsonLdContext("odrl.jsonld", "http://www.w3.org/ns/odrl.jsonld"),
new JsonLdContext("dspace.jsonld", "https://w3id.org/dspace/2024/1/context.json")
).forEach(jsonLdContext -> getResourceUri("document" + File.separator + jsonLdContext.fileName())
.onSuccess(uri -> service.registerCachedDocument(jsonLdContext.url(), uri))
.onFailure(failure -> monitor.warning("Failed to register cached json-ld document: " + failure.getFailureDetail()))
);

registerCachedDocumentsFromConfig(context, service);

Expand Down Expand Up @@ -126,5 +131,6 @@ private Result<URI> getResourceUri(String name) {
}
}

record JsonLdContext(String fileName, String url) { }

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"@context": {
"odrl": "http://www.w3.org/ns/odrl/2/",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"cred": "https://www.w3.org/2018/credentials#",
"sec": "https://w3id.org/security#",
"foaf": "http://xmlns.com/foaf/0.1/",
"cc": "http://creativecommons.org/ns#",
"dct": "http://purl.org/dc/terms/",
"dcat": "http://www.w3.org/ns/dcat#",
"dspace": "https://w3id.org/dspace/2024/1/",

"dct:title": { "@language": "en" },
"dct:creator": { "@type": "@id" },
"dct:description": { "@container": "@set" },
"dct:issued": { "@type": "xsd:dateTime" },
"dct:modified": { "@type": "xsd:dateTime" },

"dcat:byteSize": { "@type": "xsd:decimal" },
"dcat:distribution": { "@container": "@set" },
"dcat:theme": { "@type": "@id" },
"dcat:conformsTo": { "@type": "@id" },
"dcat:dataset": { "@container": "@set" },
"dcat:endpointURL": { "@type": "xsd:anyURI" },
"dcat:endpointDescription": { "@type": "xsd:anyURI" },
"dcat:keyword": { "@container": "@set" },
"dcat:servesDataset": {"@container": "@set" },
"dcat:service": { "@container": "@set" },
"dcat:accessService": { "@container": "@set" },

"dspace:agreementId": { "@type": "@id" },
"dspace:dataset": { "@type": "@id" },
"dspace:transportType": { "@type": "@id" },
"dspace:state": { "@type": "@id" },
"dspace:providerId": { "@type": "@id" },
"dspace:consumerId": { "@type": "@id" },
"dspace:participantId": { "@type": "@id" },
"dspace:reason": { "@container": "@set" },
"dspace:catalog": { "@container": "@set" },
"dspace:filter": { "@container": "@set" },
"dspace:timestamp": { "@type": "xsd:dateTime" },
"dspace:callbackAddress": { "@type": "xsd:anyURI" },
"dspace:endpointProperties": { "@container": "@set" },

"foaf:homepage": { "@type": "xsd:anyURI" },

"odrl:hasPolicy": { "@container": "@set" },
"odrl:permission": { "@container": "@set" },
"odrl:prohibition": { "@container": "@set" },
"odrl:obligation": { "@container": "@set" },
"odrl:duty": { "@container": "@set" },
"odrl:constraint": { "@container": "@set" },
"odrl:action": { "@type": "@id" },
"odrl:target": { "@type": "@id" },
"odrl:leftOperand": { "@type": "@id" },
"odrl:operator": { "@type": "@id" },
"odrl:rightOperandReference": { "@type": "@id" },
"odrl:profile": { "@container": "@set" }
"odrl:assigner": { "@type": "@id" },
"odrl:assignee": { "@type": "@id" }
}
}

0 comments on commit e5e7651

Please sign in to comment.