Exemplo n.º 1
0
  @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;
  }