예제 #1
0
  public String execute() throws Exception {

    HttpSession session = request.getSession(false);
    WebUser user = RequestUtils.getWebUser(session);

    if (!isPropertyEmpty(dForm.getSelectedDashboardId())) {
      // assign a selected dashboard
      session.setAttribute(
          Constants.SELECTED_DASHBOARD_ID, new Integer(dForm.getSelectedDashboardId()));
    }
    if (!isPropertyEmpty(dForm.getDefaultDashboard())) {
      String currentDefaultDashboardId = user.getPreference(Constants.DEFAULT_DASHBOARD_ID, null);
      String submittedDefaultDashboardId = dForm.getDefaultDashboard();

      // Compare the incoming default dashboard id with the one we had in
      // our user preferences
      // If they aren't equal it means the user is changing it, so update
      if (!submittedDefaultDashboardId.equals(currentDefaultDashboardId)) {
        user.setPreference(Constants.DEFAULT_DASHBOARD_ID, dForm.getDefaultDashboard());
        session.setAttribute(
            Constants.SELECTED_DASHBOARD_ID, new Integer(dForm.getDefaultDashboard()));
        authzBoss.setUserPrefs(
            user.getSessionId(), user.getSubject().getId(), user.getPreferences());
      }
    }
    return SUCCESS;
  }
예제 #2
0
  public void execute(TilesRequestContext tilesContext, AttributeContext attributeContext) {

    try {
      this.request = getServletRequest();
      HttpSession session = request.getSession();
      WebUser user = RequestUtils.getWebUser(session);
      DashboardConfig dashConfig =
          dashboardManager.findDashboard(
              (Integer) session.getAttribute(Constants.SELECTED_DASHBOARD_ID), user, authzBoss);

      ConfigResponse dashPrefs = dashConfig.getConfig();

      String token;
      long ts = System.currentTimeMillis();

      try {
        token = RequestUtils.getStringParameter(request, "token");
        if (token != null) {
          // token should be alpha-numeric
          if (!token.matches("^[\\w-]*$")) {
            log.warn("Token cleared by xss filter: " + token);
            token = null;
          }
        }
      } catch (ParameterNotFoundException e) {
        token = null;
      }

      String resKey = PropertiesFormNG.RESOURCES;
      String numKey = PropertiesFormNG.NUM_TO_SHOW;
      String titleKey = PropertiesFormNG.TITLE;

      if (token != null) {
        resKey += token;
        numKey += token;
        titleKey += token;
      }

      log.debug("Availability summary loaded in " + (System.currentTimeMillis() - ts) + " ms");
      // request.setAttribute("titleDescription", dashPrefs.getValue(titleKey, ""));

    } catch (Exception ex) {
      // TODO add handling for exception
    }
  }