use of org.olat.core.id.context.HistoryPoint in project OpenOLAT by OpenOLAT.
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);
}
}
}
}
use of org.olat.core.id.context.HistoryPoint in project OpenOLAT by OpenOLAT.
the class ResumeController method formOK.
@Override
protected void formOK(UserRequest ureq) {
savePreferences(ureq, "auto");
fireEvent(ureq, Event.DONE_EVENT);
HistoryPoint historyEntry = historyManager.readHistoryPoint(ureq.getIdentity());
if (historyEntry != null && StringHelper.containsNonWhitespace(historyEntry.getBusinessPath())) {
List<ContextEntry> cloneCes = BusinessControlFactory.getInstance().cloneContextEntries(historyEntry.getEntries());
BusinessControl bc = BusinessControlFactory.getInstance().createFromContextEntries(cloneCes);
WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, getWindowControl());
try {
// make the resume secure. If something fail, don't generate a red screen
NewControllerFactory.getInstance().launch(ureq, bwControl);
} catch (Exception e) {
logError("Error while resumging", e);
}
}
}
use of org.olat.core.id.context.HistoryPoint in project OpenOLAT by OpenOLAT.
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;
}
use of org.olat.core.id.context.HistoryPoint in project OpenOLAT by OpenOLAT.
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);
}
}
}
use of org.olat.core.id.context.HistoryPoint in project openolat by klemens.
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") + "\");"));
}
}
}
Aggregations