Search in sources :

Example 11 with HistoryPoint

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

the class BaseFullWebappController method updateBusinessPath.

private void updateBusinessPath(UserRequest ureq, DTab tab) {
    // dtabToBusinessPath is null if the controller is disposed
    if (tab == null || dtabToBusinessPath == null)
        return;
    try {
        String businessPath = tab.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 = tab.getController().getWindowControlForDebug().getBusinessControl().getEntries();
                dtabToBusinessPath.put(tab, new HistoryPointImpl(ureq.getUuid(), businessPath, entries));
                return;
            }
        }
        dtabToBusinessPath.put(tab, point);
    } catch (Exception e) {
        logError("", e);
    }
}
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)

Example 12 with HistoryPoint

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

the class UserSession method addToHistory.

public void addToHistory(UserRequest ureq, BusinessControl businessControl) {
    List<ContextEntry> entries = businessControl.getEntries();
    String businessPath = businessControl.getAsString();
    if (StringHelper.containsNonWhitespace(businessPath)) {
        String uuid = ureq.getUuid();
        if (!history.isEmpty()) {
            // consolidate
            synchronized (history) {
                for (Iterator<HistoryPoint> it = history.iterator(); it.hasNext(); ) {
                    HistoryPoint p = it.next();
                    if (uuid.equals(p.getUuid())) {
                        it.remove();
                    }
                }
            }
        }
        // System.out.println(ureq.getUuid() + " Add business path: " + businessPath);
        history.push(new HistoryPointImpl(ureq.getUuid(), businessPath, entries));
        if (history.size() > 20) {
            history.remove(0);
        }
    }
}
Also used : HistoryPointImpl(org.olat.core.id.context.HistoryPointImpl) ContextEntry(org.olat.core.id.context.ContextEntry) HistoryPoint(org.olat.core.id.context.HistoryPoint)

Example 13 with HistoryPoint

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

the class ResumeSessionController method isResumeInteractionRequired.

private Redirect isResumeInteractionRequired(UserRequest ureq) {
    UserSession usess = ureq.getUserSession();
    Redirect option;
    if (isREST(ureq)) {
        String url = getRESTRedirectURL(ureq);
        option = new Redirect(url);
    } else if (!historyModule.isResumeEnabled()) {
        String url = toUrl(getLandingBC(ureq));
        option = new Redirect(url);
    } else if (usess.getRoles().isGuestOnly()) {
        String url = toUrl(getLandingBC(ureq));
        option = new Redirect(url);
    } else {
        Preferences prefs = usess.getGuiPreferences();
        String resumePrefs = (String) prefs.get(WindowManager.class, "resume-prefs");
        if (!StringHelper.containsNonWhitespace(resumePrefs)) {
            resumePrefs = historyModule.getResumeDefaultSetting();
        }
        if ("none".equals(resumePrefs)) {
            String url = toUrl(getLandingBC(ureq));
            option = new Redirect(url);
        } else if ("auto".equals(resumePrefs)) {
            HistoryPoint historyEntry = HistoryManager.getInstance().readHistoryPoint(ureq.getIdentity());
            if (historyEntry != null && StringHelper.containsNonWhitespace(historyEntry.getBusinessPath())) {
                List<ContextEntry> cloneCes = BusinessControlFactory.getInstance().cloneContextEntries(historyEntry.getEntries());
                String bc = BusinessControlFactory.getInstance().getAsRestPart(cloneCes, true);
                option = new Redirect(bc);
            } else {
                String url = toUrl(getLandingBC(ureq));
                option = new Redirect(url);
            }
        } else if ("ondemand".equals(resumePrefs)) {
            HistoryPoint historyEntry = historyManager.readHistoryPoint(ureq.getIdentity());
            if (historyEntry != null && StringHelper.containsNonWhitespace(historyEntry.getBusinessPath())) {
                List<ContextEntry> cloneCes = BusinessControlFactory.getInstance().cloneContextEntries(historyEntry.getEntries());
                String url = BusinessControlFactory.getInstance().getAsRestPart(cloneCes, true);
                String landingPage = getLandingBC(ureq);
                option = new Redirect(url, landingPage);
            } else {
                String url = toUrl(getLandingBC(ureq));
                option = new Redirect(url);
            }
        } else {
            String url = toUrl(getLandingBC(ureq));
            option = new Redirect(url);
        }
    }
    return option;
}
Also used : UserSession(org.olat.core.util.UserSession) ArrayList(java.util.ArrayList) List(java.util.List) Preferences(org.olat.core.util.prefs.Preferences) HistoryPoint(org.olat.core.id.context.HistoryPoint) ContextEntry(org.olat.core.id.context.ContextEntry) WindowManager(org.olat.core.gui.WindowManager)

Example 14 with HistoryPoint

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

the class ShareLinkController method event.

@Override
protected void event(UserRequest ureq, Component source, Event event) {
    UserSession usess = ureq.getUserSession();
    if (source == shareLinkVC && "setLandingPage".equals(event.getCommand()) && usess != null && usess.isAuthenticated()) {
        HistoryPoint p = usess.getLastHistoryPoint();
        if (p != null && StringHelper.containsNonWhitespace(p.getBusinessPath())) {
            List<ContextEntry> ces = p.getEntries();
            String landingPage = BusinessControlFactory.getInstance().getAsURIString(ces, true);
            int start = landingPage.indexOf("/url/");
            if (start != -1) {
                // start with / after /url
                landingPage = landingPage.substring(start + 4);
            }
            // update user prefs
            Preferences prefs = usess.getGuiPreferences();
            prefs.put(WindowManager.class, "landing-page", landingPage);
            prefs.save();
            getWindowControl().getWindowBackOffice().sendCommandTo(new JSCommand("showInfoBox(\"" + translate("info.header") + "\",\"" + translate("landingpage.set.message") + "\");"));
        }
    }
}
Also used : UserSession(org.olat.core.util.UserSession) JSCommand(org.olat.core.gui.control.winmgr.JSCommand) Preferences(org.olat.core.util.prefs.Preferences) HistoryPoint(org.olat.core.id.context.HistoryPoint) ContextEntry(org.olat.core.id.context.ContextEntry) HistoryPoint(org.olat.core.id.context.HistoryPoint)

Example 15 with HistoryPoint

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

the class ResumeSessionController method isResumeInteractionRequired.

private Redirect isResumeInteractionRequired(UserRequest ureq) {
    UserSession usess = ureq.getUserSession();
    Redirect option;
    if (isREST(ureq)) {
        String url = getRESTRedirectURL(ureq);
        option = new Redirect(url);
    } else if (!historyModule.isResumeEnabled()) {
        String url = toUrl(getLandingBC(ureq));
        option = new Redirect(url);
    } else if (usess.getRoles().isGuestOnly()) {
        String url = toUrl(getLandingBC(ureq));
        option = new Redirect(url);
    } else {
        Preferences prefs = usess.getGuiPreferences();
        String resumePrefs = (String) prefs.get(WindowManager.class, "resume-prefs");
        if (!StringHelper.containsNonWhitespace(resumePrefs)) {
            resumePrefs = historyModule.getResumeDefaultSetting();
        }
        if ("none".equals(resumePrefs)) {
            String url = toUrl(getLandingBC(ureq));
            option = new Redirect(url);
        } else if ("auto".equals(resumePrefs)) {
            HistoryPoint historyEntry = HistoryManager.getInstance().readHistoryPoint(ureq.getIdentity());
            if (historyEntry != null && StringHelper.containsNonWhitespace(historyEntry.getBusinessPath())) {
                List<ContextEntry> cloneCes = BusinessControlFactory.getInstance().cloneContextEntries(historyEntry.getEntries());
                String bc = BusinessControlFactory.getInstance().getAsRestPart(cloneCes, true);
                option = new Redirect(bc);
            } else {
                String url = toUrl(getLandingBC(ureq));
                option = new Redirect(url);
            }
        } else if ("ondemand".equals(resumePrefs)) {
            HistoryPoint historyEntry = historyManager.readHistoryPoint(ureq.getIdentity());
            if (historyEntry != null && StringHelper.containsNonWhitespace(historyEntry.getBusinessPath())) {
                List<ContextEntry> cloneCes = BusinessControlFactory.getInstance().cloneContextEntries(historyEntry.getEntries());
                String url = BusinessControlFactory.getInstance().getAsRestPart(cloneCes, true);
                String landingPage = getLandingBC(ureq);
                option = new Redirect(url, landingPage);
            } else {
                String url = toUrl(getLandingBC(ureq));
                option = new Redirect(url);
            }
        } else {
            String url = toUrl(getLandingBC(ureq));
            option = new Redirect(url);
        }
    }
    return option;
}
Also used : UserSession(org.olat.core.util.UserSession) ArrayList(java.util.ArrayList) List(java.util.List) Preferences(org.olat.core.util.prefs.Preferences) HistoryPoint(org.olat.core.id.context.HistoryPoint) ContextEntry(org.olat.core.id.context.ContextEntry) WindowManager(org.olat.core.gui.WindowManager)

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