Search in sources :

Example 31 with RedirectMediaResource

use of org.olat.core.gui.media.RedirectMediaResource in project OpenOLAT by OpenOLAT.

the class OpenMeetingsRecordingController method event.

@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (source == downloadLink) {
        try {
            String url = openMeetingsManager.getRecordingURL(recording);
            MediaResource downloadUrl = new RedirectMediaResource(url);
            ureq.getDispatchResult().setResultingMediaResource(downloadUrl);
        } catch (OpenMeetingsException e) {
            logError("", e);
        }
    }
}
Also used : RedirectMediaResource(org.olat.core.gui.media.RedirectMediaResource) OpenMeetingsException(org.olat.modules.openmeetings.manager.OpenMeetingsException) MediaResource(org.olat.core.gui.media.MediaResource) RedirectMediaResource(org.olat.core.gui.media.RedirectMediaResource)

Example 32 with RedirectMediaResource

use of org.olat.core.gui.media.RedirectMediaResource in project OpenOLAT by OpenOLAT.

the class GoToMeetingController method doConfirm.

private void doConfirm(UserRequest ureq) {
    if (registrant != null) {
        String confirmUrl = registrant.getConfirmUrl();
        if (confirmUrl != null) {
            RedirectMediaResource redirect = new RedirectMediaResource(confirmUrl);
            ureq.getDispatchResult().setResultingMediaResource(redirect);
        }
    }
    updateButtons();
}
Also used : RedirectMediaResource(org.olat.core.gui.media.RedirectMediaResource)

Example 33 with RedirectMediaResource

use of org.olat.core.gui.media.RedirectMediaResource in project OpenOLAT by OpenOLAT.

the class GoToMeetingController method doStart.

private void doStart(UserRequest ureq) {
    if (registrant == null) {
        GoToError error = new GoToError();
        registrant = meetingMgr.registerTraining(meeting, getIdentity(), error);
    }
    GoToError error = new GoToError();
    String startUrl = meetingMgr.startTraining(meeting, error);
    if (startUrl != null) {
        RedirectMediaResource redirect = new RedirectMediaResource(startUrl);
        ureq.getDispatchResult().setResultingMediaResource(redirect);
    } else if (error.getError() == GoToErrors.TrainingInSession) {
        String joinUrl = registrant.getJoinUrl();
        RedirectMediaResource redirect = new RedirectMediaResource(joinUrl);
        ureq.getDispatchResult().setResultingMediaResource(redirect);
    }
}
Also used : GoToError(org.olat.modules.gotomeeting.model.GoToError) RedirectMediaResource(org.olat.core.gui.media.RedirectMediaResource)

Example 34 with RedirectMediaResource

use of org.olat.core.gui.media.RedirectMediaResource in project OpenOLAT by OpenOLAT.

the class HtmlStaticPageComponent method getAsyncMediaResource.

/**
 * @see org.olat.core.gui.media.AsyncMediaResponsible#getAsyncMediaResource(org.olat.core.gui.UserRequest)
 */
public MediaResource getAsyncMediaResource(UserRequest ureq) {
    // is the path to the desired resource (put together by the webbrowser by
    // combining latesturl and relative link)
    String moduleURI = ureq.getModuleURI();
    MediaResource mr = null;
    if (moduleURI != null) {
        // 1. check for an olat command (special link to indicate a command)
        if (moduleURI.startsWith(OLAT_CMD_PREFIX)) {
            String cmdAndSub = moduleURI.substring(OLAT_CMD_PREFIX.length());
            int slpos = cmdAndSub.indexOf('/');
            if (slpos != -1) {
                String cmd = cmdAndSub.substring(0, slpos);
                String subcmd = cmdAndSub.substring(slpos + 1);
                OlatCmdEvent aev = new OlatCmdEvent(cmd, subcmd);
                fireEvent(ureq, aev);
                // Mediaresourse)
                if (aev.isAccepted())
                    return null;
            }
        // else ignore (syntax error in command
        }
        // make sure moduleURI does not contain ".." or such (hack attempt)
        // -> ok, userrequest class asserts this.
        VFSItem sourceItem = rootContainer.resolve(moduleURI);
        // return 404 if the requested file does not exist
        if (sourceItem == null || (sourceItem instanceof VFSContainer)) {
            return new NotFoundMediaResource();
        }
        // we know the file exists.
        boolean checkRegular = true;
        // check for special case: render the follwing link in a new (server) window and all following clicks as well
        if ((ureq.getParameter("olatsite") != null) || ((moduleURI.endsWith(".html") || moduleURI.endsWith(".htm")) && (ureq.getParameter("olatraw") != null))) {
            log.debug("moduleURI=" + moduleURI);
            ExternalSiteEvent ese = new ExternalSiteEvent(moduleURI);
            fireEvent(ureq, ese);
            if (ese.isAccepted()) {
                mr = ese.getResultingMediaResource();
                log.debug("ExternalSiteEvent is accepted");
                checkRegular = false;
            } else {
                // it is a html page with olatraw parameter => redirect to mapper
                Mapper mapper = new HtmlStaticMapper(rootContainer);
                // NOTE: do not deregister this mapper, since it could be used a lot later (since it is opened in a new browser window)
                // Register mapper as cacheable
                String mapperID = VFSManager.getRealPath(rootContainer);
                if (mapperID == null) {
                    // Can't cache mapper, no cacheable context available
                    amapPath = CoreSpringFactory.getImpl(MapperService.class).register(ureq.getUserSession(), mapper);
                } else {
                    // Add classname to the file path to remove conflicts with other
                    // usages of the same file path
                    mapperID = this.getClass().getSimpleName() + ":" + mapperID;
                    amapPath = CoreSpringFactory.getImpl(MapperService.class).register(ureq.getUserSession(), mapperID, mapper);
                }
                String path = amapPath.getUrl() + "/" + moduleURI;
                ese.setResultingMediaResource(new RedirectMediaResource(path));
                if (log.isDebug())
                    log.debug("RedirectMediaResource=" + path);
                ese.accept();
                mr = ese.getResultingMediaResource();
                checkRegular = false;
            }
        }
        if (checkRegular) {
            // mediaresource (raw inputstream)
            if ((moduleURI.endsWith(".html") || moduleURI.endsWith(".htm")) && (ureq.getParameter("olatraw") == null)) {
                // we remember what to render inline later and return null to indicate
                // inline rendering
                currentURI = moduleURI;
                getFileContent((VFSLeaf) sourceItem);
                fireEvent(ureq, new NewInlineUriEvent(currentURI));
            } else {
                // it is indeed an image or such -> serve it
                mr = new VFSMediaResource((VFSLeaf) sourceItem);
            }
        }
    }
    // -> do a normal inline rendering (reload)
    return mr;
}
Also used : NotFoundMediaResource(org.olat.core.gui.media.NotFoundMediaResource) VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem) Mapper(org.olat.core.dispatcher.mapper.Mapper) RedirectMediaResource(org.olat.core.gui.media.RedirectMediaResource) MediaResource(org.olat.core.gui.media.MediaResource) RedirectMediaResource(org.olat.core.gui.media.RedirectMediaResource) NotFoundMediaResource(org.olat.core.gui.media.NotFoundMediaResource) VFSMediaResource(org.olat.core.util.vfs.VFSMediaResource) VFSMediaResource(org.olat.core.util.vfs.VFSMediaResource)

Example 35 with RedirectMediaResource

use of org.olat.core.gui.media.RedirectMediaResource in project openolat by klemens.

the class UserPrefsResetForm method formOK.

@Override
protected void formOK(UserRequest ureq) {
    if (resetElements.isAtLeastSelected(1)) {
        // Log out user first if logged in
        boolean logout = false;
        Set<UserSession> sessions = sessionManager.getAuthenticatedUserSessions();
        for (UserSession session : sessions) {
            Identity ident = session.getIdentity();
            if (ident != null && tobeChangedIdentity.equalsByPersistableKey(ident)) {
                sessionManager.signOffAndClear(session);
                logout = true;
                break;
            }
        }
        // Delete gui prefs
        if (resetElements.isSelected(0)) {
            PropertyManager pm = PropertyManager.getInstance();
            pm.deleteProperties(tobeChangedIdentity, null, null, null, "v2guipreferences");
        }
        // Reset preferences
        if (resetElements.isSelected(1)) {
            UserManager um = UserManager.getInstance();
            User user = um.loadUserByKey(tobeChangedIdentity.getUser().getKey());
            org.olat.core.id.Preferences preferences = user.getPreferences();
            preferences.setFontsize(null);
            preferences.setNotificationInterval(null);
            preferences.setPresenceMessagesPublic(false);
            preferences.setReceiveRealMail(null);
            um.updateUser(user);
            PropertyManager pm = PropertyManager.getInstance();
            pm.deleteProperties(tobeChangedIdentity, null, null, null, "charset");
        }
        // Reset history
        if (resetElements.isSelected(2)) {
            HistoryManager.getInstance().deleteHistory(tobeChangedIdentity);
        }
        // reset form buttons
        resetElements.uncheckAll();
        if (logout) {
            // if logout, need a redirect to the login page
            String lang = i18nModule.getLocaleKey(ureq.getLocale());
            ureq.getDispatchResult().setResultingMediaResource(new RedirectMediaResource(WebappHelper.getServletContextPath() + "/dmz/?lang=" + lang + "&logout=true"));
        }
    }
}
Also used : User(org.olat.core.id.User) PropertyManager(org.olat.properties.PropertyManager) UserSession(org.olat.core.util.UserSession) RedirectMediaResource(org.olat.core.gui.media.RedirectMediaResource) Identity(org.olat.core.id.Identity)

Aggregations

RedirectMediaResource (org.olat.core.gui.media.RedirectMediaResource)48 MediaResource (org.olat.core.gui.media.MediaResource)16 Identity (org.olat.core.id.Identity)8 URL (java.net.URL)6 UserRequest (org.olat.core.gui.UserRequest)6 Window (org.olat.core.gui.components.Window)6 UserSession (org.olat.core.util.UserSession)6 IOException (java.io.IOException)4 HttpSession (javax.servlet.http.HttpSession)4 ChiefController (org.olat.core.gui.control.ChiefController)4 WindowBackOffice (org.olat.core.gui.control.WindowBackOffice)4 StringOutput (org.olat.core.gui.render.StringOutput)4 URLBuilder (org.olat.core.gui.render.URLBuilder)4 AssertException (org.olat.core.logging.AssertException)4 UserRequestImpl (org.olat.core.gui.UserRequestImpl)3 GoToError (org.olat.modules.gotomeeting.model.GoToError)3 OpenMeetingsException (org.olat.modules.openmeetings.manager.OpenMeetingsException)3 ArrayList (java.util.ArrayList)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2