A repository may wish to record audit events for external processes, such as:
- Workflow steps that happen before material are ingested into the repository
- External processing, such as verifying checksums, performing format migrations, etc.
- Synchronizing with external preservation repository
These can be added to an external triplestore to facilitate querying and processing with audit events from the repository. These can also be added to the repository to allow preservation of the events.
Adding Events to an External Triplestore
Events that happen outside of the repository can be added directly to an external triplestore. The triples used to describe them should be the same as internal events, except they should have rdf:type audit:ExternalEvent:
Code Block |
---|
language | xml |
---|
title | event1.ttl |
---|
|
@prefix audit: <http://fedora.info/definitions/v4/audit#> .
@prefix premis: <http://www.loc.gov/premis/rdf/v1#> .
@prefix prov: <http://www.w3.org/ns/prov#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
<event1> a prov:InstantaneousEvent, premis:Event, audit:ExternalEvent ;
premis:hasEventRelatedAgent "jquser"^^xsd:string, "ImageMagick 6.8.8-9"^^xsd:string, "thumbnail-generator.example.edu"^^xsd:string ;
premis:hasEventType audit:derivativeCreation ;
premis:hasEventRelatedObject <http://localhost:8080/rest/55/59/ec/05/5559ec05-6ab1-4d61-905a-a5f3da360b23> ;
premis:hasEventDateTime "2012-04-30T20:40:40"^^xsd:dateTime . |
Posting them to a triplestore will be basically the same for different triplestores, with only the triplestore URL changing:
Code Block |
---|
language | bash |
---|
title | fuseki_post.sh |
---|
|
curl -X POST -H "Content-Type: text/turtle" --data-binary @event1.ttl http://localhost:3030/test/data |
Code Block |
---|
language | bash |
---|
title | sesame_post.sh |
---|
|
curl -X POST -H "Content-Type: text/turtle" --data-binary @event1.ttl http://localhost:8081/openrdf-sesame/repositories/test/statements |
Adding with SPARQL Update
The SPARQL Update command to insert event triples will be similar to:
Code Block |
---|
language | xml |
---|
title | event2.sparql |
---|
|
prefix audit: <http://fedora.info/definitions/v4/audit#>
prefix premis: <http://www.loc.gov/premis/rdf/v1#>
prefix premisEvent: <http://id.loc.gov/vocabulary/preservation/eventType/>
prefix prov: <http://www.w3.org/ns/prov#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
insert data {
<http://example.org/event2> rdf:type prov:InstantaneousEvent .
<http://example.org/event2> rdf:type premis:Event .
<http://example.org/event2> rdf:type audit:ExternalEvent .
<http://example.org/event2> premis:hasEventRelatedAgent "jquser"^^xsd:string .
<http://example.org/event2> premis:hasEventRelatedAgent "rsync 2.6.9"^^xsd:string .
<http://example.org/event2> premis:hasEventRelatedAgent "backup-repository.example.edu"^^xsd:string .
<http://example.org/event2> premis:hasEventType premisEvent:rep .
<http://example.org/event2> premis:hasEventRelatedObject <http://localhost:8080/fcrepo/rest/55/59/ec/05/5559ec05-6ab1-4d61-905a-a5f3da360b23> .
<http://example.org/event2> premis:hasEventDateTime "2012-04-30T20:40:40"^^xsd:dateTime .
} |
The command to execute the SPARQL Update vary somewhat more depending on the triplestore used, since some triplestores require form-encoding of SPARQL Update commands and others accept them directly:
Code Block |
---|
language | bash |
---|
title | fuseki_sparql.sh |
---|
|
curl -X POST -H "Content-Type: application/sparql-update" -d @event2.sparql http://localhost:3030/test/update |
Code Block |
---|
language | bash |
---|
title | sesame_sparql.sh |
---|
|
curl -X POST -H "Accept-Encoding: identity" -H "Accept: */*" -H "Content-Type: application/x-www-form-urlencoded" -d update=`cat event2.sparql` http://localhost:8081/openrdf-sesame/repositories/test/statements |
Adding Events to the Repository
External audit events can be added to an LDP Container as a repository resource. When using Internal Audit Events, the audit container will be created automatically. Otherwise, a container for audit events can be created in the usual way:
Code Block |
---|
|
curl -X POST -H "Slug: audit" http://localhost:8080/fcrepo/rest/ |
For each event, post the RDF for the event to the audit container:
Code Block |
---|
|
curl -X POST --data-binary @audit_event.ttl -H "Content-type: text/turtle" http://localhost:8080/fcrepo/rest/audit/ |
Code Block |
---|
language | xml |
---|
title | audit_event.ttl |
---|
|
@prefix audit: <http://fedora.info/definitions/v4/audit#> .
@prefix premis: <http://www.loc.gov/premis/rdf/v1#> .
@prefix prov: <http://www.w3.org/ns/prov#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
<> a prov:InstantaneousEvent, premis:Event, audit:ExternalEvent ;
premis:hasEventRelatedAgent "jquser"^^xsd:string,
"ImageMagick 6.8.8-9"^^xsd:string,
"thumbnail-generator.example.edu"^^xsd:string ;
premis:hasEventType audit:derivativeCreation ;
premis:hasEventRelatedObject <http://localhost:8080/fcrepo/rest/some-existing-resource> ;
premis:hasEventDateTime "2012-04-30T20:40:40"^^xsd:dateTime . |
The events generated by creating these nodes can be suppressed by Configuring a JMS Event Filter to suppress events about audit:ExternalEvent nodes
.