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);
}
}
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);
}
}
}
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;
}
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") + "\");"));
}
}
}
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;
}
Aggregations