Example #1
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
    }
  }
  @Override
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    HttpSession session = request.getSession();

    WebUser user = SessionUtils.getWebUser(session);
    AuthzSubject guestUser = authzBoss.findSubjectByName(user.getSessionId(), "guest");
    DashboardConfig dashboardConfig = dashboardManager.getUserDashboard(guestUser, guestUser);

    String portletId = request.getParameter("pid");
    Portlet portlet = new Portlet(portletId);

    session.setAttribute("portlet", portlet);
    session.setAttribute(Constants.SELECTED_DASHBOARD_ID, dashboardConfig.getId());

    return super.execute(mapping, form, request, response);
  }
Example #3
0
  public String update() throws Exception {

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

    String forwardStr = SUCCESS;

    String token = (String) session.getAttribute("currentPortletToken");

    // For multi-portlet configurations
    String resKey = JsonLoadCriticalAlertsNG.RESOURCES_KEY;
    String countKey = PropertiesFormNG.ALERT_NUMBER;
    String priorityKey = PropertiesFormNG.PRIORITY;
    String timeKey = PropertiesFormNG.PAST;
    String selOrAllKey = PropertiesFormNG.SELECTED_OR_ALL;
    String titleKey = PropertiesFormNG.TITLE;

    if (token != null) {
      resKey += token;
      countKey += token;
      priorityKey += token;
      timeKey += token;
      selOrAllKey += token;
      titleKey += token;
    }
    DashboardConfig dashConfig =
        dashboardManager.findDashboard(
            (Integer) session.getAttribute(Constants.SELECTED_DASHBOARD_ID), user, authzBoss);
    ConfigResponse dashPrefs = dashConfig.getConfig();

    if (pForm.isRemoveClicked()) {
      DashboardUtils.removeResources(pForm.getIds(), resKey, dashPrefs);
      configurationProxy.setDashboardPreferences(session, user, dashPrefs);
      forwardStr = "review";
    }

    String forward = checkSubmit(pForm);

    if (forward != null) {
      return forward;
    }

    Integer numberOfAlerts = pForm.getNumberOfAlerts();
    String past = String.valueOf(pForm.getPast());
    String prioritity = pForm.getPriority();
    String selectedOrAll = pForm.getSelectedOrAll();

    dashPrefs.setValue(countKey, numberOfAlerts.toString());
    dashPrefs.setValue(timeKey, past);
    dashPrefs.setValue(priorityKey, prioritity);
    dashPrefs.setValue(selOrAllKey, selectedOrAll);
    dashPrefs.setValue(titleKey, pForm.getTitle());

    configurationProxy.setDashboardPreferences(session, user, dashPrefs);

    session.removeAttribute(Constants.USERS_SES_PORTAL);

    removeValueInSession("currentPortletKey");
    removeValueInSession("currentPortletToken");

    return forwardStr;
  }