Search in sources :

Example 6 with HistoryPoint

use of org.olat.core.id.context.HistoryPoint in project openolat by klemens.

the class ValidatingVisitor method handleBusinessPath.

public Command handleBusinessPath(UserRequest ureq) {
    HistoryPoint p = ureq.getUserSession().getLastHistoryPoint();
    if (p != null && StringHelper.containsNonWhitespace(p.getBusinessPath())) {
        StringBuilder sb = new StringBuilder();
        List<ContextEntry> ces = p.getEntries();
        String url = BusinessControlFactory.getInstance().getAsURIString(ces, true);
        sb.append("try { o_info.businessPath='").append(url).append("';");
        // Add analytics code
        if (analyticsSPI != null) {
            String serverUri = Settings.getServerContextPathURI();
            if (url != null && url.startsWith(serverUri)) {
                analyticsSPI.analyticsCountPageJavaScript(sb, getTitle(), url.substring(serverUri.length()));
            }
        }
        sb.append(" } catch(e) { }");
        return new JSCommand(sb.toString());
    }
    return null;
}
Also used : JSCommand(org.olat.core.gui.control.winmgr.JSCommand) HistoryPoint(org.olat.core.id.context.HistoryPoint) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 7 with HistoryPoint

use of org.olat.core.id.context.HistoryPoint in project openolat by klemens.

the class AjaxController method appendBusinessPathInfos.

private void appendBusinessPathInfos(UserRequest ureq, Writer writer) throws IOException {
    ChiefController ctrl = wboImpl.getChiefController();
    String documentTitle = ctrl == null ? "" : ctrl.getWindow().getTitle();
    writer.append(",\"documentTitle\":").append(JSONObject.quote(documentTitle));
    StringBuilder bc = new StringBuilder(128);
    HistoryPoint p = ureq.getUserSession().getLastHistoryPoint();
    if (p != null && StringHelper.containsNonWhitespace(p.getBusinessPath())) {
        List<ContextEntry> ces = p.getEntries();
        String uriPrefix = wboImpl.getWindow().getUriPrefix();
        bc.append(uriPrefix).append(BusinessControlFactory.getInstance().getAsRestPart(ces, true));
        writer.append(",\"businessPath\":").append(JSONObject.quote(bc.toString()));
        writer.append(",\"historyPointId\":").append(JSONObject.quote(p.getUuid()));
    }
}
Also used : ChiefController(org.olat.core.gui.control.ChiefController) HistoryPoint(org.olat.core.id.context.HistoryPoint) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 8 with HistoryPoint

use of org.olat.core.id.context.HistoryPoint in project openolat by klemens.

the class AuthenticatedDispatcher method processBusinessPath.

private void processBusinessPath(String businessPath, UserRequest ureq, UserSession usess) {
    ChiefController chiefController = Windows.getWindows(usess).getChiefController();
    if (chiefController == null) {
        if (usess.isAuthenticated()) {
            AuthHelper.createAuthHome(ureq).getWindow();
            chiefController = Windows.getWindows(usess).getChiefController();
        } else {
            redirectToDefaultDispatcher(ureq.getHttpReq(), ureq.getHttpResp());
            return;
        }
    }
    WindowBackOffice windowBackOffice = chiefController.getWindow().getWindowBackOffice();
    if (chiefController.isLoginInterceptionInProgress()) {
        Window w = windowBackOffice.getWindow();
        // renderOnly
        w.dispatchRequest(ureq, true);
    } else {
        String wSettings = (String) usess.removeEntryFromNonClearedStore(WINDOW_SETTINGS);
        if (wSettings != null) {
            WindowSettings settings = WindowSettings.parse(wSettings);
            windowBackOffice.setWindowSettings(settings);
        }
        try {
            BusinessControl bc = null;
            String historyPointId = ureq.getHttpReq().getParameter("historyPointId");
            if (StringHelper.containsNonWhitespace(historyPointId)) {
                HistoryPoint point = ureq.getUserSession().getHistoryPoint(historyPointId);
                bc = BusinessControlFactory.getInstance().createFromContextEntries(point.getEntries());
            }
            if (bc == null) {
                bc = BusinessControlFactory.getInstance().createFromString(businessPath);
            }
            WindowControl wControl = windowBackOffice.getChiefController().getWindowControl();
            WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, wControl);
            NewControllerFactory.getInstance().launch(ureq, bwControl);
            // render the window
            Window w = windowBackOffice.getWindow();
            // renderOnly
            w.dispatchRequest(ureq, true);
        } catch (Exception e) {
            // try to render something
            try {
                Window w = windowBackOffice.getWindow();
                // renderOnly
                w.dispatchRequest(ureq, true);
            } catch (Exception e1) {
                redirectToDefaultDispatcher(ureq.getHttpReq(), ureq.getHttpResp());
            }
            log.error("", e);
        }
    }
}
Also used : Window(org.olat.core.gui.components.Window) BusinessControl(org.olat.core.id.context.BusinessControl) WindowBackOffice(org.olat.core.gui.control.WindowBackOffice) ChiefController(org.olat.core.gui.control.ChiefController) WindowControl(org.olat.core.gui.control.WindowControl) HistoryPoint(org.olat.core.id.context.HistoryPoint) IOException(java.io.IOException) InvalidRequestParameterException(org.olat.core.gui.components.form.flexible.impl.InvalidRequestParameterException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) WindowSettings(org.olat.core.gui.WindowSettings)

Example 9 with HistoryPoint

use of org.olat.core.id.context.HistoryPoint in project openolat by klemens.

the class BaseFullWebappController method event.

@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (source instanceof Link) {
        Link link = (Link) source;
        String mC = link.getCommand().substring(0, 1);
        if (mC.equals("t")) {
            // activate normal tab
            SiteInstance s = (SiteInstance) link.getUserObject();
            // fix the state of the last tab/site
            updateBusinessPath(ureq);
            HistoryPoint point = null;
            if (siteToBusinessPath.containsKey(s)) {
                point = siteToBusinessPath.get(s);
            }
            activateSite(s, ureq, null, true);
            if (point != null) {
                BusinessControlFactory.getInstance().addToHistory(ureq, point);
            }
            updateBusinessPath(ureq, s);
        } else if (mC.equals("a")) {
            // activate dyntab
            DTab dt = (DTab) link.getUserObject();
            // fix the state of the last tab/site
            updateBusinessPath(ureq);
            HistoryPoint point = null;
            if (dtabToBusinessPath.containsKey(dt)) {
                point = dtabToBusinessPath.get(dt);
            }
            doActivateDTab(dt);
            if (dt.getController() instanceof Activateable2) {
                ((Activateable2) dt.getController()).activate(ureq, null, new ReloadEvent());
            }
            if (point != null) {
                BusinessControlFactory.getInstance().addToHistory(ureq, point);
            }
        } else if (mC.equals("c")) {
            // close dyntab
            DTab dt = (DTab) link.getUserObject();
            requestCloseTab(ureq, dt);
        }
    } else if (source == getWindowControl().getWindowBackOffice().getWindow()) {
        if (event == Window.OLDTIMESTAMPCALL) {
            getLogger().info("RELOAD");
            HistoryPoint point = ureq.getUserSession().popLastHistoryEntry();
            if (point != null) {
                back(ureq, point);
            }
        }
    }
}
Also used : BornSiteInstance(org.olat.core.gui.control.navigation.BornSiteInstance) SiteInstance(org.olat.core.gui.control.navigation.SiteInstance) DTab(org.olat.core.gui.control.generic.dtabs.DTab) Activateable2(org.olat.core.gui.control.generic.dtabs.Activateable2) Link(org.olat.core.gui.components.link.Link) HistoryPoint(org.olat.core.id.context.HistoryPoint)

Example 10 with HistoryPoint

use of org.olat.core.id.context.HistoryPoint in project openolat by klemens.

the class BaseFullWebappController method updateBusinessPath.

private String updateBusinessPath(UserRequest ureq, SiteInstance site) {
    if (site == null)
        return null;
    try {
        String businessPath = siteToBornSite.get(site).getController().getWindowControlForDebug().getBusinessControl().getAsString();
        HistoryPoint point = ureq.getUserSession().getLastHistoryPoint();
        int index = businessPath.indexOf(':');
        if (index > 0 && point != null && point.getBusinessPath() != null) {
            String start = businessPath.substring(0, index);
            if (!point.getBusinessPath().startsWith(start)) {
                // if a controller has not set its business path, don't pollute the mapping
                List<ContextEntry> entries = siteToBornSite.get(site).getController().getWindowControlForDebug().getBusinessControl().getEntries();
                siteToBusinessPath.put(site, new HistoryPointImpl(ureq.getUuid(), businessPath, entries));
                return BusinessControlFactory.getInstance().getAsRestPart(entries, true);
            }
            List<ContextEntry> entries = siteToBornSite.get(site).getController().getWindowControlForDebug().getBusinessControl().getEntries();
            businessPath = BusinessControlFactory.getInstance().getAsRestPart(entries, true);
        }
        siteToBusinessPath.put(site, point);
        return businessPath;
    } catch (Exception e) {
        logError("", e);
        return null;
    }
}
Also used : HistoryPointImpl(org.olat.core.id.context.HistoryPointImpl) HistoryPoint(org.olat.core.id.context.HistoryPoint) HistoryPoint(org.olat.core.id.context.HistoryPoint) ContextEntry(org.olat.core.id.context.ContextEntry) AssertException(org.olat.core.logging.AssertException)

Aggregations

HistoryPoint (org.olat.core.id.context.HistoryPoint)22 ContextEntry (org.olat.core.id.context.ContextEntry)18 WindowControl (org.olat.core.gui.control.WindowControl)6 BusinessControl (org.olat.core.id.context.BusinessControl)6 HistoryPointImpl (org.olat.core.id.context.HistoryPointImpl)6 ChiefController (org.olat.core.gui.control.ChiefController)4 DTab (org.olat.core.gui.control.generic.dtabs.DTab)4 JSCommand (org.olat.core.gui.control.winmgr.JSCommand)4 AssertException (org.olat.core.logging.AssertException)4 UserSession (org.olat.core.util.UserSession)4 Preferences (org.olat.core.util.prefs.Preferences)4 IOException (java.io.IOException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 WindowManager (org.olat.core.gui.WindowManager)2 WindowSettings (org.olat.core.gui.WindowSettings)2 Window (org.olat.core.gui.components.Window)2 InvalidRequestParameterException (org.olat.core.gui.components.form.flexible.impl.InvalidRequestParameterException)2 Link (org.olat.core.gui.components.link.Link)2