*/
protected void onMessage(final ODistributedRequest iRequest) {
OScenarioThreadLocal.INSTANCE.set(OScenarioThreadLocal.RUN_MODE.RUNNING_DISTRIBUTED);
try {
final OAbstractRemoteTask task = iRequest.getTask();
if (ODistributedServerLog.isDebugEnabled())
ODistributedServerLog.debug(this, manager.getLocalNodeName(), iRequest.getSenderNodeName(), DIRECTION.OUT,
"received request: %s", iRequest);
// EXECUTE IT LOCALLY
final Serializable responsePayload;
OUser origin = null;
try {
if (task.isRequiredOpenDatabase())
initDatabaseInstance();
ODatabaseRecordThreadLocal.INSTANCE.set(database);
task.setNodeSource(iRequest.getSenderNodeName());
// keep original user in database, check the username passed in request and set new user in DB, after document saved, reset
// to original user
if (database != null) {
origin = database.getUser();