@Override public boolean isInterceptionRequired(UserRequest ureq) { UserSession usess = ureq.getUserSession(); boolean interception = false; if (isREST(ureq)) { // do nothing } else if (!historyModule.isResumeEnabled()) { String bc = getLandingBC(ureq); launch(ureq, bc); } else if (usess.getRoles().isGuestOnly()) { String bc = getLandingBC(ureq); launch(ureq, bc); } 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 bc = getLandingBC(ureq); launch(ureq, bc); } 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()); BusinessControl bc = BusinessControlFactory.getInstance().createFromContextEntries(cloneCes); launch(ureq, bc); } else { String bc = getLandingBC(ureq); launch(ureq, bc); } } else if ("ondemand".equals(resumePrefs)) { HistoryPoint historyEntry = historyManager.readHistoryPoint(ureq.getIdentity()); if (historyEntry != null && StringHelper.containsNonWhitespace(historyEntry.getBusinessPath())) { interception = true; String bc = getLandingBC(ureq); if (StringHelper.containsNonWhitespace(bc)) { noButton.setVisible(false); } else { landingButton.setVisible(false); } } else { String bc = getLandingBC(ureq); launch(ureq, bc); } } } return interception; }
@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); } } }