Search in sources :

Example 11 with ChiefController

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

the class ShibbolethDispatcher method showMessage.

/**
 * @param ureq
 * @param exceptionLogMessage will be recorded into the log file
 * @param cause
 * @param userMessage gets shown to the user
 * @param supportEmail if any available, else null
 */
private void showMessage(UserRequest ureq, String exceptionLogMessage, Throwable cause, String userMessage, String supportEmail) {
    ChiefController msgcc = MessageWindowController.createMessageChiefController(ureq, new OLATRuntimeException(exceptionLogMessage, cause), userMessage, supportEmail);
    msgcc.getWindow().dispatchRequest(ureq, true);
}
Also used : OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) ChiefController(org.olat.core.gui.control.ChiefController)

Example 12 with ChiefController

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

the class QTI21AssessmentMainLayoutController method setAsFullscreen.

public void setAsFullscreen(UserRequest ureq) {
    ChiefController cc = getWindowControl().getWindowBackOffice().getChiefController();
    if (cc != null) {
        thebaseChief = cc;
        thebaseChief.getScreenMode().setMode(Mode.full);
    } else {
        Windows.getWindows(ureq).setFullScreen(Boolean.TRUE);
    }
    fullScreen = true;
}
Also used : ChiefController(org.olat.core.gui.control.ChiefController)

Example 13 with ChiefController

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

the class LTIRunController method openBasicLTIContent.

private void openBasicLTIContent(UserRequest ureq) {
    // container is "run", "runFullscreen" or "runPopup" depending in configuration
    doBasicLTI(ureq, run);
    if (display == LTIDisplayOptions.fullscreen) {
        ChiefController cc = getWindowControl().getWindowBackOffice().getChiefController();
        if (cc != null) {
            thebaseChief = cc;
            thebaseChief.getScreenMode().setMode(Mode.full);
        }
        fullScreen = true;
        getWindowControl().pushToMainArea(run);
    } else {
        mainPanel.setContent(run);
    }
}
Also used : ChiefController(org.olat.core.gui.control.ChiefController)

Example 14 with ChiefController

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

the class AuthenticatedDispatcher method execute.

/**
 * Main method called by OpenOLATServlet. This processess all requests for
 * authenticated users.
 *
 * @param request
 * @param response
 * @param uriPrefix
 */
@Override
public void execute(HttpServletRequest request, HttpServletResponse response) {
    String uriPrefix = DispatcherModule.getLegacyUriPrefix(request);
    UserSession usess = CoreSpringFactory.getImpl(UserSessionManager.class).getUserSession(request);
    UserRequest ureq = null;
    try {
        // upon creation URL is checked for
        ureq = new UserRequestImpl(uriPrefix, request, response);
    } catch (NumberFormatException nfe) {
        // a 404 message must be shown -> e.g. robots correct their links.
        if (log.isDebug()) {
            log.debug("Bad Request " + request.getPathInfo());
        }
    }
    boolean auth = usess.isAuthenticated();
    if (!auth) {
        String guestAccess = ureq.getParameter(GUEST);
        if (guestAccess == null || !CoreSpringFactory.getImpl(LoginModule.class).isGuestLoginEnabled()) {
            String businessPath = extractBusinessPath(ureq, request, uriPrefix);
            if (businessPath != null) {
                usess.putEntryInNonClearedStore(AUTHDISPATCHER_BUSINESSPATH, businessPath);
            }
            redirectToDefaultDispatcher(request, response);
            return;
        } else if (guestAccess.equals(TRUE)) {
            // try to log in as anonymous
            // use the language from the lang parameter if available, otherwise use the system default locale
            String guestLang = ureq.getParameter("language");
            if (guestLang == null) {
                // support for legacy lang parameter
                guestLang = ureq.getParameter("lang");
            }
            Locale guestLoc;
            if (guestLang == null) {
                guestLoc = I18nModule.getDefaultLocale();
            } else {
                guestLoc = I18nManager.getInstance().getLocaleOrDefault(guestLang);
            }
            int loginStatus = AuthHelper.doAnonymousLogin(ureq, guestLoc);
            if (loginStatus != AuthHelper.LOGIN_OK) {
                if (loginStatus == AuthHelper.LOGIN_NOTAVAILABLE) {
                    DispatcherModule.redirectToServiceNotAvailable(response);
                }
                // error, redirect to login screen
                redirectToDefaultDispatcher(request, response);
                return;
            }
        // else now logged in as anonymous user, continue
        }
    }
    // authenticated!
    try {
        // kill session if not secured via SSL
        if (forceSecureAccessOnly && !request.isSecure()) {
            SessionInfo sessionInfo = usess.getSessionInfo();
            if (sessionInfo != null) {
                HttpSession session = sessionInfo.getSession();
                if (session != null) {
                    try {
                        session.invalidate();
                    } catch (IllegalStateException ise) {
                    // thrown when session already invalidated. fine. ignore.
                    }
                }
            }
            redirectToDefaultDispatcher(request, response);
            return;
        }
        SessionInfo sessionInfo = usess.getSessionInfo();
        if (sessionInfo == null) {
            redirectToDefaultDispatcher(request, response);
            return;
        }
        if (userBasedLogLevelManager != null) {
            userBasedLogLevelManager.activateUsernameBasedLogLevel(sessionInfo.getLogin());
        }
        sessionInfo.setLastClickTime();
        String businessPath = (String) usess.removeEntryFromNonClearedStore(AUTHDISPATCHER_BUSINESSPATH);
        if (businessPath != null) {
            processBusinessPath(businessPath, ureq, usess);
        } else if (ureq.isValidDispatchURI()) {
            // valid uri for dispatching (has timestamp, componentid and windowid)
            processValidDispatchURI(ureq, usess, request, response);
        } else {
            businessPath = extractBusinessPath(ureq, request, uriPrefix);
            if (businessPath == null) {
                processBusinessPath("", ureq, usess);
            } else {
                processBusinessPath(businessPath, ureq, usess);
            }
        }
    } catch (InvalidRequestParameterException e) {
        try {
            response.sendError(HttpServletResponse.SC_BAD_REQUEST);
        } catch (IOException e1) {
            log.error("An exception occured while handling the invalid request parameter exception...", e1);
        }
    } catch (Throwable th) {
        // Do not log as Warn or Error here, log as ERROR in MsgFactory => ExceptionWindowController throws an OLATRuntimeException
        log.debug("handleError in AuthenticatedDispatcher throwable=" + th);
        DispatcherModule.handleError();
        ChiefController msgcc = MsgFactory.createMessageChiefController(ureq, th);
        // the controller's window must be failsafe also
        msgcc.getWindow().dispatchRequest(ureq, true);
    // do not dispatch (render only), since this is a new Window created as
    // a result of another window's click.
    } finally {
        if (userBasedLogLevelManager != null) {
            userBasedLogLevelManager.deactivateUsernameBasedLogLevel();
        }
    }
}
Also used : Locale(java.util.Locale) HttpSession(javax.servlet.http.HttpSession) SessionInfo(org.olat.core.util.SessionInfo) LoginModule(org.olat.login.LoginModule) IOException(java.io.IOException) ChiefController(org.olat.core.gui.control.ChiefController) UserSessionManager(org.olat.core.util.session.UserSessionManager) InvalidRequestParameterException(org.olat.core.gui.components.form.flexible.impl.InvalidRequestParameterException) UserSession(org.olat.core.util.UserSession) UserRequest(org.olat.core.gui.UserRequest) UserRequestImpl(org.olat.core.gui.UserRequestImpl)

Example 15 with ChiefController

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

the class RESTDispatcher method getRedirectToURL.

private String getRedirectToURL(UserSession usess) {
    ChiefController cc = Windows.getWindows(usess).getChiefController();
    Window w = cc.getWindow();
    URLBuilder ubu = new URLBuilder(WebappHelper.getServletContextPath() + DispatcherModule.PATH_AUTHENTICATED, w.getInstanceId(), String.valueOf(w.getTimestamp()));
    StringOutput sout = new StringOutput(30);
    ubu.buildURI(sout, null, null);
    return sout.toString();
}
Also used : Window(org.olat.core.gui.components.Window) StringOutput(org.olat.core.gui.render.StringOutput) ChiefController(org.olat.core.gui.control.ChiefController) URLBuilder(org.olat.core.gui.render.URLBuilder)

Aggregations

ChiefController (org.olat.core.gui.control.ChiefController)58 UserRequest (org.olat.core.gui.UserRequest)10 UserRequestImpl (org.olat.core.gui.UserRequestImpl)10 IOException (java.io.IOException)8 Window (org.olat.core.gui.components.Window)8 InvalidRequestParameterException (org.olat.core.gui.components.form.flexible.impl.InvalidRequestParameterException)8 WindowControl (org.olat.core.gui.control.WindowControl)8 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)8 ArrayList (java.util.ArrayList)6 BaseFullWebappController (org.olat.core.commons.fullWebApp.BaseFullWebappController)6 StringOutput (org.olat.core.gui.render.StringOutput)6 URLBuilder (org.olat.core.gui.render.URLBuilder)6 AssertException (org.olat.core.logging.AssertException)6 UserSession (org.olat.core.util.UserSession)6 HttpSession (javax.servlet.http.HttpSession)4 BaseFullWebappControllerParts (org.olat.core.commons.fullWebApp.BaseFullWebappControllerParts)4 Windows (org.olat.core.gui.Windows)4 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)4 RedirectMediaResource (org.olat.core.gui.media.RedirectMediaResource)4 ContextEntry (org.olat.core.id.context.ContextEntry)4