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;
}
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()));
}
}
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);
}
}
}
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);
}
}
}
}
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;
}
}
Aggregations