}
@Override
public synchronized void update(DiffReader diff) throws ModelRuntimeException {
if(this.isLocked()) {
throw new ModelRuntimeException("Model is locked, cannot perform an update.");
}
// do not auto-commit
assertModel();
try {
this.connection.begin();
try {
try {
// remove
Iterator<? extends Statement> it = diff.getRemoved().iterator();
while(it.hasNext()) {
org.openrdf.model.Statement s = ConversionUtil.toOpenRDF(it.next(),
this.valueFactory);
this.connection.remove(s, this.openRdfContext);
}
// add
it = diff.getAdded().iterator();
while(it.hasNext()) {
org.openrdf.model.Statement s = ConversionUtil.toOpenRDF(it.next(),
this.valueFactory);
this.connection.add(s, this.openRdfContext);
}
this.connection.commit();
} catch(RepositoryException x) {
this.logger.warn("Could not commit, rolling back.", x);
this.connection.rollback();
}
} finally {
this.connection.commit();
}
} catch(RepositoryException x) {
throw new ModelRuntimeException(x);
}
}