use of org.olat.core.util.SignOnOffEvent in project OpenOLAT by OpenOLAT.
the class UserSessionManager method internSignOffAndClear.
private void internSignOffAndClear(UserSession usess) {
boolean isDebug = log.isDebug();
if (isDebug)
log.debug("signOffAndClear() START");
signOffAndClearWithout(usess);
// handle safely
try {
if (usess.isAuthenticated()) {
SessionInfo sessionInfo = usess.getSessionInfo();
IdentityEnvironment identityEnvironment = usess.getIdentityEnvironment();
Identity identity = identityEnvironment.getIdentity();
log.audit("Logged off: " + sessionInfo);
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(new SignOnOffEvent(identity, false), ORES_USERSESSION);
if (isDebug)
log.debug("signOffAndClear() deregistering usersession from eventbus, id=" + sessionInfo);
// fxdiff FXOLAT-231: event on GUI Preferences extern changes
OLATResourceable ores = OresHelper.createOLATResourceableInstance(Preferences.class, identity.getKey());
CoordinatorManager.getInstance().getCoordinator().getEventBus().deregisterFor(usess, ores);
}
} catch (Exception e) {
log.error("exception in signOffAndClear: while sending signonoffevent!", e);
}
// clear all instance variables, set authenticated to false
usess.init();
if (isDebug)
log.debug("signOffAndClear() END");
}
use of org.olat.core.util.SignOnOffEvent in project OpenOLAT by OpenOLAT.
the class UserSessionManager method event.
/**
* only for SignOffEvents
* - Usersession keeps book about usernames
* - WindowManager responsible to dispose controller chain
* @see org.olat.core.util.event.GenericEventListener#event(org.olat.core.gui.control.Event)
*/
@Override
public void event(Event event) {
if (event instanceof SignOnOffEvent) {
SignOnOffEvent se = (SignOnOffEvent) event;
processSignOnOffEvent(se);
}
}
use of org.olat.core.util.SignOnOffEvent in project OpenOLAT by OpenOLAT.
the class ClusterLocker method event.
/**
* receives all sign on / sign off events so it can release locks of users
* which have or are logged off
*
* @see org.olat.core.util.event.GenericEventListener#event(org.olat.core.gui.control.Event)
*/
@Override
public void event(Event event) {
SignOnOffEvent se = (SignOnOffEvent) event;
if (!se.isSignOn() && se.isEventOnThisNode()) {
// it is a "logout" event - we are only interested in logout events
// and it is from our VM => only release all locks from within one VM
Long identKey = se.getIdentityKey();
// since the lock is reentrant, a lock could be freed while a session still is in a locked workflow (2x lock and then once freed)
try {
clusterLockManager.releaseAllLocksFor(identKey);
DBFactory.getInstance().commit();
} catch (DBRuntimeException dbEx) {
log.warn("releaseAllLocksFor failed, close session and try it again for identName=" + identKey);
// TODO: 2010-04-23 Transactions [eglis]: OLAT-4318: this rollback has possibly unwanted
// side effects, as it rolls back any changes with this transaction during this
// event handling. Nicer would be to be done in the outmost-possible place, e.g. dofire()
DBFactory.getInstance().rollbackAndCloseSession();
// try again with new db-session
log.info("try again to release all locks for identName=" + identKey);
clusterLockManager.releaseAllLocksFor(identKey);
log.info("Done, released all locks for identName=" + identKey);
}
}
}
use of org.olat.core.util.SignOnOffEvent in project OpenOLAT by OpenOLAT.
the class LockTest method testSaveEvent.
@Test
public void testSaveEvent() {
Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("lock-save-event-");
dbInstance.closeSession();
log.info("Created identity=" + identity);
// The group has no creation date -> commit will fail
GroupImpl entry = new GroupImpl();
entry.setName("bar");
try {
dbInstance.saveObject(entry);
dbInstance.commit();
fail("Should generate an error");
} catch (DBRuntimeException dre) {
log.info("DB connection is in error-state");
}
// DB transaction must be in error state for this test
try {
Locker locker = clusterCoordinator.getLocker();
assertTrue(locker instanceof ClusterLocker);
log.info("ClusterLocker created");
Event event = new SignOnOffEvent(identity, false);
log.info("START locker.event(event)");
((ClusterLocker) locker).event(event);
log.info("DONE locker.event(event)");
} catch (Exception ex) {
log.error("", ex);
fail("BLOCKER : ClusterLocker.event is not error-safe, db exception could happen and de-register event-listener");
}
}
use of org.olat.core.util.SignOnOffEvent in project openolat by klemens.
the class UserSessionManager method event.
/**
* only for SignOffEvents
* - Usersession keeps book about usernames
* - WindowManager responsible to dispose controller chain
* @see org.olat.core.util.event.GenericEventListener#event(org.olat.core.gui.control.Event)
*/
@Override
public void event(Event event) {
if (event instanceof SignOnOffEvent) {
SignOnOffEvent se = (SignOnOffEvent) event;
processSignOnOffEvent(se);
}
}
Aggregations