Search in sources :

Example 1 with Disposable

use of org.olat.core.gui.control.Disposable in project OpenOLAT by OpenOLAT.

the class FormLayoutContainer method dispose.

/**
 * Dispose all child elements from this container
 *
 * @see org.olat.core.gui.control.Disposable#dispose()
 */
@Override
public void dispose() {
    // cleanup temporary files)
    for (FormItem formItem : getFormItems()) {
        if (formItem instanceof Disposable) {
            Disposable disposableFormItem = (Disposable) formItem;
            disposableFormItem.dispose();
        }
    }
}
Also used : Disposable(org.olat.core.gui.control.Disposable) FormItem(org.olat.core.gui.components.form.flexible.FormItem)

Example 2 with Disposable

use of org.olat.core.gui.control.Disposable in project openolat by klemens.

the class FormLayoutContainer method dispose.

/**
 * Dispose all child elements from this container
 *
 * @see org.olat.core.gui.control.Disposable#dispose()
 */
@Override
public void dispose() {
    // cleanup temporary files)
    for (FormItem formItem : getFormItems()) {
        if (formItem instanceof Disposable) {
            Disposable disposableFormItem = (Disposable) formItem;
            disposableFormItem.dispose();
        }
    }
}
Also used : Disposable(org.olat.core.gui.control.Disposable) FormItem(org.olat.core.gui.components.form.flexible.FormItem)

Example 3 with Disposable

use of org.olat.core.gui.control.Disposable in project OpenOLAT by OpenOLAT.

the class UserSessionManager method signOffAndClearWithout.

/**
 * called from signOffAndClear()
 * called from event -> MUEvent
 * the real work to do during sign off but without sending the multiuserevent
 * this is used in case the user logs in to node1 and was logged in on node2 =>
 * node2 catches the sign on event and invalidates the user on node2 "silently", e.g.
 * without firing an event.
 */
private void signOffAndClearWithout(final UserSession usess) {
    boolean isDebug = log.isDebug();
    if (isDebug)
        log.debug("signOffAndClearWithout() START");
    final IdentityEnvironment identityEnvironment = usess.getIdentityEnvironment();
    final SessionInfo sessionInfo = usess.getSessionInfo();
    final Identity ident = identityEnvironment.getIdentity();
    if (isDebug)
        log.debug("UserSession:::logging off: " + sessionInfo);
    if (usess.isAuthenticated() && usess.getLastHistoryPoint() != null && !usess.getRoles().isGuestOnly()) {
        historyManager.persistHistoryPoint(ident, usess.getLastHistoryPoint());
    }
    /**
     * use not RunnableWithException, as exceptionHandlng is inside the run
     */
    Runnable run = new Runnable() {

        @Override
        public void run() {
            Object obj = null;
            try {
                // do logging
                if (ident != null) {
                    ThreadLocalUserActivityLogger.log(OlatLoggingAction.OLAT_LOGOUT, UserSession.class, CoreLoggingResourceable.wrap(ident));
                }
                // notify all variables in the store (the values) about the disposal
                // if
                // Disposable
                List<Object> storeList = usess.getStoreValues();
                for (Iterator<Object> it_storevals = storeList.iterator(); it_storevals.hasNext(); ) {
                    obj = it_storevals.next();
                    if (obj instanceof Disposable) {
                        // synchronous, since triggered by tomcat session timeout or user
                        // click and
                        // asynchronous, if kicked out by administrator.
                        // we assume synchronous
                        // !!!!
                        // As a reminder, this .dispose() calls dispose on
                        // DefaultController which is synchronized.
                        // (Windows/WindowManagerImpl/WindowBackOfficeImpl/BaseChiefController/../
                        // dispose()
                        // !!!! was important for bug OLAT-3390
                        ((Disposable) obj).dispose();
                    }
                }
            } catch (Exception e) {
                String objtostr = "n/a";
                try {
                    objtostr = obj.toString();
                } catch (Exception ee) {
                // ignore
                }
                log.error("exception in signOffAndClear: while disposing object:" + objtostr, e);
            }
        }
    };
    ThreadLocalUserActivityLoggerInstaller.runWithUserActivityLogger(run, UserActivityLoggerImpl.newLoggerForValueUnbound(usess));
    if (authUserSessions.remove(usess)) {
        // remove only from identityEnvironment if found in sessions.
        // see also SIDEEFFECT!! line in signOn(..)
        Identity previousSignedOn = identityEnvironment.getIdentity();
        if (previousSignedOn != null && previousSignedOn.getKey() != null) {
            if (isDebug)
                log.debug("signOffAndClearWithout() removing from userNameToIdentity: " + previousSignedOn.getName().toLowerCase());
            userNameToIdentity.remove(previousSignedOn.getKey());
            userSessionCache.remove(previousSignedOn.getKey());
        }
    } else if (isDebug) {
        log.info("UserSession already removed! for [" + ident + "]");
    }
    // update logged in users counters
    if (sessionInfo != null) {
        if (sessionInfo.isREST()) {
            sessionCountRest.decrementAndGet();
        } else if (sessionInfo.isWebDAV()) {
            sessionCountDav.decrementAndGet();
        } else {
            sessionCountWeb.decrementAndGet();
        }
    }
    if (isDebug)
        log.debug("signOffAndClearWithout() END");
}
Also used : Disposable(org.olat.core.gui.control.Disposable) SessionInfo(org.olat.core.util.SessionInfo) Identity(org.olat.core.id.Identity) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) AssertException(org.olat.core.logging.AssertException)

Example 4 with Disposable

use of org.olat.core.gui.control.Disposable in project openolat by klemens.

the class UserSessionManager method signOffAndClearWithout.

/**
 * called from signOffAndClear()
 * called from event -> MUEvent
 * the real work to do during sign off but without sending the multiuserevent
 * this is used in case the user logs in to node1 and was logged in on node2 =>
 * node2 catches the sign on event and invalidates the user on node2 "silently", e.g.
 * without firing an event.
 */
private void signOffAndClearWithout(final UserSession usess) {
    boolean isDebug = log.isDebug();
    if (isDebug)
        log.debug("signOffAndClearWithout() START");
    final IdentityEnvironment identityEnvironment = usess.getIdentityEnvironment();
    final SessionInfo sessionInfo = usess.getSessionInfo();
    final Identity ident = identityEnvironment.getIdentity();
    if (isDebug)
        log.debug("UserSession:::logging off: " + sessionInfo);
    if (usess.isAuthenticated() && usess.getLastHistoryPoint() != null && !usess.getRoles().isGuestOnly()) {
        historyManager.persistHistoryPoint(ident, usess.getLastHistoryPoint());
    }
    /**
     * use not RunnableWithException, as exceptionHandlng is inside the run
     */
    Runnable run = new Runnable() {

        @Override
        public void run() {
            Object obj = null;
            try {
                // do logging
                if (ident != null) {
                    ThreadLocalUserActivityLogger.log(OlatLoggingAction.OLAT_LOGOUT, UserSession.class, CoreLoggingResourceable.wrap(ident));
                }
                // notify all variables in the store (the values) about the disposal
                // if
                // Disposable
                List<Object> storeList = usess.getStoreValues();
                for (Iterator<Object> it_storevals = storeList.iterator(); it_storevals.hasNext(); ) {
                    obj = it_storevals.next();
                    if (obj instanceof Disposable) {
                        // synchronous, since triggered by tomcat session timeout or user
                        // click and
                        // asynchronous, if kicked out by administrator.
                        // we assume synchronous
                        // !!!!
                        // As a reminder, this .dispose() calls dispose on
                        // DefaultController which is synchronized.
                        // (Windows/WindowManagerImpl/WindowBackOfficeImpl/BaseChiefController/../
                        // dispose()
                        // !!!! was important for bug OLAT-3390
                        ((Disposable) obj).dispose();
                    }
                }
            } catch (Exception e) {
                String objtostr = "n/a";
                try {
                    objtostr = obj.toString();
                } catch (Exception ee) {
                // ignore
                }
                log.error("exception in signOffAndClear: while disposing object:" + objtostr, e);
            }
        }
    };
    ThreadLocalUserActivityLoggerInstaller.runWithUserActivityLogger(run, UserActivityLoggerImpl.newLoggerForValueUnbound(usess));
    if (authUserSessions.remove(usess)) {
        // remove only from identityEnvironment if found in sessions.
        // see also SIDEEFFECT!! line in signOn(..)
        Identity previousSignedOn = identityEnvironment.getIdentity();
        if (previousSignedOn != null && previousSignedOn.getKey() != null) {
            if (isDebug)
                log.debug("signOffAndClearWithout() removing from userNameToIdentity: " + previousSignedOn.getName().toLowerCase());
            userNameToIdentity.remove(previousSignedOn.getKey());
            userSessionCache.remove(previousSignedOn.getKey());
        }
    } else if (isDebug) {
        log.info("UserSession already removed! for [" + ident + "]");
    }
    // update logged in users counters
    if (sessionInfo != null) {
        if (sessionInfo.isREST()) {
            sessionCountRest.decrementAndGet();
        } else if (sessionInfo.isWebDAV()) {
            sessionCountDav.decrementAndGet();
        } else {
            sessionCountWeb.decrementAndGet();
        }
    }
    if (isDebug)
        log.debug("signOffAndClearWithout() END");
}
Also used : Disposable(org.olat.core.gui.control.Disposable) SessionInfo(org.olat.core.util.SessionInfo) Identity(org.olat.core.id.Identity) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) AssertException(org.olat.core.logging.AssertException)

Aggregations

Disposable (org.olat.core.gui.control.Disposable)4 FormItem (org.olat.core.gui.components.form.flexible.FormItem)2 Identity (org.olat.core.id.Identity)2 IdentityEnvironment (org.olat.core.id.IdentityEnvironment)2 AssertException (org.olat.core.logging.AssertException)2 SessionInfo (org.olat.core.util.SessionInfo)2