Skip to content

Commit

Permalink
Audit module (Change Tracking) (#3879)
Browse files Browse the repository at this point in the history
* Added audit to startup listeners

* provide editor info in create and link resource controller

* Added example audit configuration

---------

Co-authored-by: Georgy Litvinov <[email protected]>
  • Loading branch information
litvinovg and litvinovg authored Dec 22, 2023
1 parent 6e7806a commit d13a84b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.dao.InsertException;
import edu.cornell.mannlib.vitro.webapp.dao.NewURIMakerVitro;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.N3EditUtils;
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames;
import edu.cornell.mannlib.vitro.webapp.rdfservice.ChangeSet;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
Expand Down Expand Up @@ -391,7 +392,7 @@ protected ResponseValues processRequest(VitroRequest vreq) {
}

// Finished processing confirmation, write the differences between the existing and updated model
writeChanges(vreq.getRDFService(), existingModel, updatedModel);
writeChanges(vreq.getRDFService(), existingModel, updatedModel, N3EditUtils.getEditorUri(vreq));
}

// Get any IDs that have not yet been processed from the form
Expand Down Expand Up @@ -1815,8 +1816,9 @@ protected boolean isResourceOfType(Resource resource, String typeUri) {
* @param rdfService
* @param existingModel
* @param updatedModel
* @param editroUri
*/
protected void writeChanges(RDFService rdfService, Model existingModel, Model updatedModel) {
protected void writeChanges(RDFService rdfService, Model existingModel, Model updatedModel, String editorUri) {
Model removeModel = existingModel.difference(updatedModel);
Model addModel = updatedModel.difference(existingModel);

Expand All @@ -1829,12 +1831,12 @@ protected void writeChanges(RDFService rdfService, Model existingModel, Model up

if (!addModel.isEmpty()) {
addStream = makeN3InputStream(addModel);
changeSet.addAddition(addStream, RDFService.ModelSerializationFormat.N3, ModelNames.ABOX_ASSERTIONS);
changeSet.addAddition(addStream, RDFService.ModelSerializationFormat.N3, ModelNames.ABOX_ASSERTIONS, editorUri);
}

if (!removeModel.isEmpty()) {
removeStream = makeN3InputStream(removeModel);
changeSet.addRemoval(removeStream, RDFService.ModelSerializationFormat.N3, ModelNames.ABOX_ASSERTIONS);
changeSet.addRemoval(removeStream, RDFService.ModelSerializationFormat.N3, ModelNames.ABOX_ASSERTIONS, editorUri);
}

try {
Expand Down
12 changes: 12 additions & 0 deletions home/src/main/resources/config/example.applicationSetup.n3
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,22 @@
:hasSearchIndexer :basicSearchIndexer ;
:hasImageProcessor :iioImageProcessor ;
:hasFileStorage :ptiFileStorage ;
# :hasAuditModule :tdbAuditModule ;
:hasContentTripleSource :tdbContentTripleSource ;
:hasConfigurationTripleSource :tdbConfigurationTripleSource ;
:hasTBoxReasonerModule :jfactTBoxReasonerModule .

# ----------------------------
#
# Audit module:
#

#:tdbAuditModule
# a <java:edu.cornell.mannlib.vitro.webapp.audit.TDBAuditModule> ,
# <java:edu.cornell.mannlib.vitro.webapp.audit.AuditModule> ;
# :hasTdbDirectory "tdbAuditModels" .


# ----------------------------
#
# Image processor module:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,6 @@ edu.cornell.mannlib.vitro.webapp.controller.individual.VIVOIndividualResponseBui

# This should be near the end, because it will issue a warning if the connection to the SearchEngine times out.
edu.cornell.mannlib.vitro.webapp.servlet.setup.SearchEngineSmokeTest

edu.cornell.mannlib.vitro.webapp.audit.AuditSetup

0 comments on commit d13a84b

Please sign in to comment.