Ejemplo n.º 1
0
 /**
  * Method to overload if the controller wants to be an origin for workflows. Child classes should
  * customize this to participate in workflows.
  *
  * @param request The request to get the session to store the returnPath into.
  * @param mapping The ActionMapping to get the input forward from.
  * @param params A Map of request parameters to add to the return path.
  */
 protected void setReturnPath(
     HttpServletRequest request, ActionMapping mapping, Map<String, Object> params)
     throws Exception {
   String returnPath = ActionUtils.findReturnPath(mapping, params);
   if (log.isTraceEnabled()) {
     log.trace("setting return path: " + returnPath);
   }
   SessionUtils.setReturnPath(request.getSession(), returnPath);
 }
  @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);
  }
Ejemplo n.º 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;
  }
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    HttpSession session = request.getSession();

    AddApplicationServicesForm addForm = (AddApplicationServicesForm) form;
    AppdefEntityID aeid = new AppdefEntityID(addForm.getType().intValue(), addForm.getRid());

    HashMap<String, Object> forwardParams = new HashMap<String, Object>(2);
    forwardParams.put(Constants.ENTITY_ID_PARAM, aeid.getAppdefKey());
    forwardParams.put(Constants.ACCORDION_PARAM, "3");

    ActionForward forward = checkSubmit(request, mapping, form, forwardParams);
    if (forward != null) {
      BaseValidatorForm spiderForm = (BaseValidatorForm) form;

      if (spiderForm.isCancelClicked()
          || spiderForm.isResetClicked()
          || forward.getName().equalsIgnoreCase(Constants.RESET_URL)) {
        log.trace("removing pending service list");
        SessionUtils.removeList(session, Constants.PENDING_APPSVCS_SES_ATTR);
      } else if (spiderForm.isAddClicked()) {
        log.trace(
            "adding to pending service list " + Arrays.asList(addForm.getAvailableServices()));
        SessionUtils.addToList(
            session, Constants.PENDING_APPSVCS_SES_ATTR, addForm.getAvailableServices());
      } else if (spiderForm.isRemoveClicked()) {
        log.trace("removing from pending service list");
        SessionUtils.removeFromList(
            session, Constants.PENDING_APPSVCS_SES_ATTR, addForm.getPendingServices());
      }
      return forward;
    }

    Integer sessionId = RequestUtils.getSessionId(request);

    log.trace("getting pending service list");
    List<String> uiPendings =
        SessionUtils.getListAsListStr(session, Constants.PENDING_APPSVCS_SES_ATTR);
    List<AppdefEntityID> svcList = new ArrayList<AppdefEntityID>();

    for (int pRcs = 0; pRcs < uiPendings.size(); pRcs++) {
      log.debug("uiPendings = " + uiPendings.get(pRcs));
      StringTokenizer tok = new StringTokenizer(uiPendings.get(pRcs), " ");
      svcList.add(new AppdefEntityID(tok.nextToken()));
    }
    // when we call boss.setApplicationServices(...) our map must
    // be populated with all of the existing services (and whether
    // or not they're entry points) as well as our new ones

    // first, get the existing ones
    PageControl nullPc = new PageControl(-1, -1);
    List<AppdefResourceValue> existingServices =
        appdefBoss.findServiceInventoryByApplication(sessionId.intValue(), aeid.getId(), nullPc);
    DependencyTree tree = appdefBoss.getAppDependencyTree(sessionId.intValue(), aeid.getId());
    for (AppdefResourceValue service : existingServices) {

      log.debug("service =" + service.getClass().getName());

      tree.findAppService(service);
      svcList.add(service.getEntityId());
    }

    // second, get the new ones

    // set all added services to be entry points, if they're not to be
    // entry points and are instead part of a dependency chain,
    // setting up the dependencies is a separate activity

    log.trace("adding servicess " + svcList + " for application [" + aeid.getID() + "]");
    appdefBoss.setApplicationServices(sessionId.intValue(), aeid.getId(), svcList);
    log.trace("removing pending service list");
    SessionUtils.removeList(session, Constants.PENDING_APPSVCS_SES_ATTR);

    RequestUtils.setConfirmation(request, "resource.application.inventory.confirm.AddedServices");
    return returnSuccess(request, mapping, forwardParams);
  }