public Object execute(final OServer iServer, ODistributedServerManager iManager, final ODatabaseDocumentTx database)
throws Exception {
ODistributedServerLog.debug(this, iManager.getLocalNodeName(), getNodeSource(), DIRECTION.IN, "updating record %s/%s v.%s",
database.getName(), rid.toString(), version.toString());
ORecord loadedRecord = rid.getRecord();
if (loadedRecord == null)
throw new ORecordNotFoundException("Record " + rid + " was not found on update");
if (loadedRecord instanceof ODocument) {
// APPLY CHANGES FIELD BY FIELD TO MARK DIRTY FIELDS FOR INDEXES/HOOKS
final ODocument newDocument = new ODocument().fromStream(content);
((ODocument) loadedRecord).merge(newDocument, false, false);
} else
ORecordInternal.fill(loadedRecord, rid, version, content, true);
loadedRecord = database.save(loadedRecord);
ODistributedServerLog.debug(this, iManager.getLocalNodeName(), getNodeSource(), DIRECTION.IN, "+-> updated record %s/%s v.%s",
database.getName(), rid.toString(), loadedRecord.getRecordVersion().toString());
return loadedRecord.getRecordVersion();
}