public boolean isResourceConfigured(
      HttpServletRequest request, ServletContext ctx, boolean setError)
      throws ServletException, AppdefEntityNotFoundException, SessionNotFoundException,
          SessionTimeoutException, PermissionException, EncodingException, RemoteException {
    final String CONFIG_ATTR = "IsResourceUnconfigured";

    Boolean configured = (Boolean) request.getAttribute(CONFIG_ATTR);
    if (configured != null) return !configured.booleanValue();

    if (entityId.isGroup()) return true;

    int sessionId = RequestUtils.getSessionId(request).intValue();

    if (this instanceof ApplicationInventoryHelper) return true;

    ProductBoss productBoss = Bootstrap.getBean(ProductBoss.class);

    String context = request.getContextPath();
    try {
      productBoss.getMergedConfigResponse(
          sessionId, ProductPlugin.TYPE_MEASUREMENT, entityId, true);
    } catch (ConfigFetchException e) {
      if (setError) {
        ActionMessage error =
            new ActionMessage(
                CFG_ERR_RES,
                new String[] {
                  context, String.valueOf(entityId.getType()), String.valueOf(entityId.getID())
                });
        RequestUtils.setError(request, error, ActionMessages.GLOBAL_MESSAGE);
      }
      request.setAttribute(CONFIG_ATTR, Boolean.TRUE);
      return false;
    }

    // only check where the config is invalid
    String validationError =
        productBoss.getConfigResponse(sessionId, entityId).getValidationError();

    if (validationError == null) {
      request.setAttribute(CONFIG_ATTR, Boolean.FALSE);
      return true;
    }
    if (setError) {
      ActionMessage error =
          new ActionMessage(
              CFG_INVALID_RES,
              new String[] {
                StringUtil.replace(validationError, "\n", "<br>&nbsp;&nbsp;" + "&nbsp;&nbsp;"),
                context,
                String.valueOf(entityId.getType()),
                String.valueOf(entityId.getID())
              });
      RequestUtils.setError(request, error, ActionMessages.GLOBAL_MESSAGE);
    }
    request.setAttribute(CONFIG_ATTR, Boolean.TRUE);
    return false;
  }
示例#2
0
  @SkipValidation
  public String list() throws Exception {
    setHeaderResources();
    Integer sessionId = RequestUtils.getSessionId(getServletRequest());
    PageControl pc = RequestUtils.getPageControl(getServletRequest());

    if (log.isTraceEnabled()) {
      log.trace("getting all subjects");
    }
    PageList<AuthzSubjectValue> users = authzBoss.getAllSubjects(sessionId, null, pc);
    getServletRequest().setAttribute(Constants.ALL_USERS_ATTR, users);
    ActionContext.getContext().put(Constants.ALL_USERS_ATTR, users);

    return "listUsers";
  }
  public String execute() throws Exception {

    log.debug("entering RemoveEscalationActionNG");
    Integer escId = RequestUtils.getIntParameter(request, "esc");

    Integer sessionId = RequestUtils.getSessionId(request);

    try {
      eventsBoss.deleteEscalationById(sessionId.intValue(), escId);
    } catch (Exception e) {
      addActionError(getText("admin.config.error.escalation.CannotDelete"));
    }

    return SUCCESS;
  }
示例#4
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;
  }
示例#5
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
    }
  }
  /**
   * Return the array of Integer ids for the given <code>notificationType</code> contained in the
   * alert definition notification actions.
   *
   * <p>This method also sets the alert definition object on the form and places it in the request.
   * It also puts the resource id and resource type in the request.
   *
   * @param addForm the form being prepared
   * @param notificationType the type of notification
   * @return the array of ids for already existing notifications based on the notificationType, or a
   *     zero-length array if there are not yet any notifications of this type
   * @throws ServletException
   * @throws RemoteException
   * @throws PermissionException
   * @throws SessionTimeoutException
   * @throws SessionNotFoundException
   * @throws EncodingException
   * @throws InvalidActionDataException
   */
  public Integer[] getNotificationIds(
      HttpServletRequest request,
      AddNotificationsFormNG addForm,
      AppdefEntityID aeid,
      int notificationType)
      throws ServletException, SessionNotFoundException, SessionTimeoutException,
          PermissionException, RemoteException, EncodingException, InvalidActionDataException {
    Integer[] ids = new Integer[0];

    Integer sessionId = RequestUtils.getSessionId(request);

    Integer alertDefId = addForm.getAd();
    log.debug("(1) alertDefId=" + alertDefId);
    if (alertDefId == null) throw new ParameterNotFoundException("alert definition id not found");

    log.debug("(2) alertDefId=" + alertDefId);
    AlertDefinitionValue alertDef =
        (AlertDefinitionValue) request.getAttribute(Constants.ALERT_DEFS_ATTR);
    if (alertDef == null) {
      alertDef = eventsBoss.getAlertDefinition(sessionId.intValue(), alertDefId);
    }
    request.setAttribute(Constants.ALERT_DEFINITION_ATTR, alertDef);

    ActionValue[] actions = alertDef.getActions();
    for (int i = 0; i < actions.length; ++i) {
      if (actions[i].classnameHasBeenSet()
          && !(actions[i].getClassname().equals(null) || actions[i].getClassname().equals(""))) {
        EmailActionConfig emailCfg = new EmailActionConfig();
        ConfigResponse configResponse = ConfigResponse.decode(actions[i].getConfig());

        try {
          emailCfg.init(configResponse);
        } catch (InvalidActionDataException e) {
          // Not an EmailAction
          log.debug("Action is " + actions[i].getClassname());
          continue;
        }

        if (emailCfg.getType() == notificationType) {
          ids = new Integer[emailCfg.getUsers().size()];
          ids = (Integer[]) emailCfg.getUsers().toArray(ids);
          break;
        }
      }
    }

    if (aeid instanceof AppdefEntityTypeID) {
      addForm.setAetid(aeid.getAppdefKey());
      request.setAttribute(Constants.APPDEF_RES_TYPE_ID, aeid.getAppdefKey());
    } else {
      addForm.setRid(aeid.getId());
      addForm.setType(new Integer(aeid.getType()));
      request.setAttribute(Constants.ENTITY_ID_PARAM, aeid.getAppdefKey());
    }

    return ids;
  }
示例#7
0
  public String create() throws Exception {

    setHeaderResources();

    if (!validatePasswordNoSpaces(user.getNewPassword())) {
      addFieldError("newPassword", getText("admin.user.changePassword.NoSpaces"));
      return INPUT;
    }
    String checkResult = checkSubmit(user);
    if (checkResult != null) {
      return checkResult;
    }

    String userName = user.getName();
    // add both a subject and a principal as normal
    log.trace("creating subject [" + userName + "]");

    Integer sessionId = RequestUtils.getSessionId(getServletRequest());

    AuthzSubject checkUser = authzBoss.findSubjectByName(sessionId, userName);

    if (checkUser != null) {
      log.error("User name '" + userName + "' already exists");
      String msg = getText("exception.user.alreadyExists");
      this.addFieldError("name", msg);
      return INPUT;
    }

    authzBoss.createSubject(
        sessionId,
        user.getName(),
        "yes".equals(user.getEnableLogin()),
        HQConstants.ApplicationName,
        user.getDepartment(),
        user.getEmailAddress(),
        user.getFirstName(),
        user.getLastName(),
        user.getPhoneNumber(),
        user.getSmsAddress(),
        user.isHtmlEmail());

    log.trace("adding user [" + userName + "]");
    authBoss.addUser(sessionId.intValue(), userName, user.getNewPassword());

    log.trace("finding subject [" + userName + "]");
    AuthzSubject newUser = authzBoss.findSubjectByName(sessionId, userName);

    getServletRequest().setAttribute(Constants.USER_PARAM, newUser.getId());
    ActionContext.getContext().put(Constants.USER_PARAM, newUser.getId());

    userId = newUser.getId().toString();

    return "showCreated";
  }
示例#8
0
  @RequestMapping(value = "/login", method = RequestMethod.GET)
  public ModelAndView login(
      HttpServletRequest request, HttpServletResponse response, HttpSession session) {
    final boolean debug = log.isDebugEnabled();

    ModelAndView result = new ModelAndView();

    // ...first check for an authentication object, if one exists we are already logged in...
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();

    if (authentication != null
        && !(authentication instanceof AnonymousAuthenticationToken)
        && authentication.isAuthenticated()) {
      try {
        if (debug) log.debug("User has already been authenticated.  Redirecting to dashboard.");

        // Redirect to Dashboard.action for struts2 support
        response.sendRedirect("Dashboard.action");

        return result;
      } catch (IOException e) {
        log.warn(
            "Could not perform the redirect for an authenticated user, displaying login page instead");
      }
    }

    // ...we're dealing with an unauthenticated user, we're going to show the login form...
    AuthzSubject guestUser = authzSubjectManager.getSubjectById(AuthzConstants.guestId);

    // ...before we return, check for an error message...
    boolean loginError = request.getParameter("authfailed") != null;

    if (loginError) {
      if (session != null) {
        AuthenticationException ex =
            (AuthenticationException)
                session.getAttribute(
                    AbstractAuthenticationProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY);

        if (ex != null) {
          result.addObject("errorMessage", RequestUtils.message(request, ex.getMessage()));
        }
      }
    }

    result.addObject("guestUsername", (guestUser != null) ? guestUser.getName() : "guest");
    result.addObject("guestEnabled", (guestUser != null && guestUser.getActive()));

    // ...set a response header so we can identify the login page explicitly...
    response.setHeader("hq-requires-auth", "1");

    return result;
  }
示例#9
0
 @SkipValidation
 public String cancel() throws Exception {
   setHeaderResources();
   clearErrorsAndMessages();
   AppdefEntityID appdefId = RequestUtils.getEntityId(request);
   if (appdefId != null) {
     internalEid = appdefId.getId() + ":" + appdefId.getType();
   }
   internalRid = appdefId.getId().toString();
   internalType = String.valueOf(appdefId.getType());
   return "cancel";
 }
示例#10
0
  public String save() throws Exception {
    request = getServletRequest();
    log.trace("performing resouce quick control action: " + qcForm.getResourceAction());

    try {

      int sessionId = RequestUtils.getSessionIdInt(request);

      // create the new action to schedule
      Integer localId = qcForm.getResourceId();
      Integer localType = qcForm.getResourceType();
      AppdefEntityID appdefId = new AppdefEntityID(localType.intValue(), localId);
      type = localType.toString();
      rid = localId.toString();
      internalEid = appdefId.toString();

      request.setAttribute(Constants.RESOURCE_PARAM, localId);
      request.setAttribute(Constants.RESOURCE_TYPE_ID_PARAM, type);

      String action = qcForm.getResourceAction();
      String args = qcForm.getArguments();

      if (AppdefEntityConstants.APPDEF_TYPE_GROUP == localType) {
        controlBoss.doGroupAction(sessionId, appdefId, action, args, null);
      } else {
        controlBoss.doAction(sessionId, appdefId, action, args);
      }

      // set confirmation message
      String ctrlStr = qcForm.getResourceAction();
      addActionMessage(
          getText("resource.server.QuickControl.Confirmation", new String[] {ctrlStr}));

      qcForm.reset();
      return SUCCESS;
    } catch (PluginException cpe) {
      log.trace("control not enabled", cpe);
      this.addActionError(getText("resource.common.error.ControlNotEnabled"));
      return "Failure";
    } catch (PermissionException pe) {
      this.addActionError(getText("resource.common.control.error.NewPermission"));
      return "Failure";
    }
  }
示例#11
0
  /**
   * Retrieve the id of the selected child resource type from the request. If no selection was made,
   * then return the default id if <code>selectDefaultSubtab</code> allows.
   *
   * @param childTypes the complete List of child resource types for this entity type
   * @param childCounts the Map of child resource counts keyed by resource type
   * @param defaultOverride whether or not to override <code>selectDefaultSubtab</code>
   */
  public Integer getSelectedChildId(
      HttpServletRequest request, List childTypes, Map childCounts, boolean defaultOverride) {
    AppdefEntityTypeID childTypeId = null;
    try {
      childTypeId = RequestUtils.getChildResourceTypeId(request);
    } catch (ParameterNotFoundException pnfe) {; // it's ok if the request param is not specified
    }

    if (defaultOverride && childTypeId == null) {
      // default to the first child type for which we
      // actually have some deployed childs
      return MonitorUtils.findDefaultChildResourceId(childTypes, childCounts);
    }

    if (childTypeId != null) {
      return childTypeId.getId();
    }

    return null;
  }
示例#12
0
  // @SkipValidation
  // public String start() throws Exception {
  //
  // // log.trace("preparing new server control action");
  // // request=getServletRequest();
  // // int sessionId = RequestUtils.getSessionId(request).intValue();
  // //
  // // AppdefEntityID appdefId = RequestUtils.getEntityId(request);
  // //
  // // List<String> actions = controlBoss.getActions(sessionId, appdefId);
  // //
  // // Map options= new LinkedHashMap<String, String>();
  // // for (String action : actions) {
  // // String value = action;
  // // String label = StringUtil.capitalize(value);
  // // options.put(value,label);
  // // }
  // // cForm.setControlActions(options);
  // // cForm.setNumControlActions(new Integer(options.size()));
  // // if (cForm.getStartHour() == null) {
  // // Date date = new Date();
  // // Calendar calendar = GregorianCalendar.getInstance();
  // // calendar.setTime(date);
  // // int hours=calendar.get(Calendar.HOUR);
  // // cForm.setStartHour(hours+"");
  // // }
  // // if (cForm.getStartMin()==null) {
  // // DateTime dt = new DateTime();
  // // int minutes = dt.getMinuteOfHour();
  // // cForm.setStartMin(minutes+"");
  // // }
  // // if (cForm.getStartAmPm()==null) {
  // // Date date = new Date();
  // // Calendar calendar = GregorianCalendar.getInstance();
  // // calendar.setTime(date);
  // // int ampm=calendar.get(Calendar.AM_PM);
  // // if (ampm==0) {
  // // cForm.setStartAmPm("AM");
  // // } else {
  // // cForm.setStartAmPm("PM");
  // // }
  // // }
  // return "formNewActionLoad";
  // }
  public String save() throws Exception {

    log.trace("creating new action");
    try {
      request = getServletRequest();
      int sessionId = RequestUtils.getSessionId(request).intValue();
      AppdefEntityID appdefId = RequestUtils.getEntityId(request);
      request.setAttribute(Constants.RESOURCE_PARAM, appdefId.getId());
      request.setAttribute(Constants.RESOURCE_TYPE_ID_PARAM, new Integer(appdefId.getType()));
      boolean validationFailed = false;
      String des = this.cForm.getDescription();
      if (des != null && des.length() > 100) {
        this.addFieldError("description", getText("ng.errors.maxlength", new String[] {"100"}));

        validationFailed = true;
      }
      if (!(cForm.getStartTime().equals("1"))) {
        try {
          int tmph = Integer.parseInt(cForm.getStartHour());
          if (tmph < 0 || tmph > 12) {
            this.addFieldError(
                "startHour", getText("errors.range", new String[] {tmph + "", "1", "12"}));
            validationFailed = true;
          }
        } catch (NumberFormatException nfe) {
          this.addFieldError(
              "startHour",
              getText("errors.invalid.StartHour", new String[] {cForm.getStartHour() + ""}));
          validationFailed = true;
        }

        try {
          int tmpmin = Integer.parseInt(cForm.getStartMin());
          if (tmpmin > 59 || tmpmin < 0) {
            this.addFieldError(
                "startMin", getText("errors.range", new String[] {tmpmin + "", "0", "59"}));
            validationFailed = true;
          }
        } catch (NumberFormatException nfe) {
          this.addFieldError(
              "startMin",
              getText("errors.invalid.StartMin", new String[] {cForm.getStartMin() + ""}));
          validationFailed = true;
        }
      }

      String cAction = this.cForm.getControlAction();
      if (cAction != null && cAction.equals("")) {
        this.addFieldError(
            "controlAction",
            getText(
                "errors.required", new String[] {getText("dash.home.TableHeader.ControlAction")}));
        validationFailed = true;
      }
      // make sure that the ControlAction is valid.
      String action = cForm.getControlAction();
      List<String> validActions = controlBoss.getActions(sessionId, appdefId);
      if (!validActions.contains(action)) {
        this.addActionError(getText("resource.common.control.error.ControlActionNotValid"));
        validationFailed = true;
      }
      if (!(cForm.getStartTime().equals("1"))) {
        cForm.setStartTime(ScheduleFormNG.START_ON_DATE);

        if (cForm.getStartTime().equals(ScheduleFormNG.START_ON_DATE)
            && cForm.getRecurInterval().equals(ScheduleFormNG.RECUR_WEEKLY)) {
          Integer tmpNumWeeks = null;
          try {
            tmpNumWeeks = new Integer(Integer.parseInt(cForm.getNumWeeks()));
          } catch (NumberFormatException nfe) {
            this.addFieldError(
                "numWeeks",
                getText(
                    "resource.autodiscovery.ScheduleTab.error.numWeeks",
                    new String[] {cForm.getNumWeeks()}));
            validationFailed = true;
          }
          if (null == cForm.getRecurrenceDay() || cForm.getRecurrenceDay().length == 0) {
            this.addFieldError(
                "recurrenceDay", getText("resource.autodiscovery.ScheduleTab.error.recurrenceDay"));
            validationFailed = true;
          }
        }
        if (cForm.getStartTime().equals(ScheduleFormNG.START_ON_DATE)
            && cForm.getRecurInterval().equals(ScheduleFormNG.RECUR_DAILY)) {
          Integer tmpNumDays = null;
          try {
            tmpNumDays = new Integer(Integer.parseInt(cForm.getNumDays()));
          } catch (NumberFormatException nfe) {
            this.addFieldError(
                "numDays",
                getText(
                    "resource.autodiscovery.ScheduleTab.error.numDays",
                    new String[] {cForm.getNumDays()}));
            validationFailed = true;
          }
        }
        if (cForm.getStartTime().equals(ScheduleFormNG.START_ON_DATE)
            && cForm.getRecurInterval().equals(ScheduleFormNG.RECUR_MONTHLY)) {
          Integer tmpNumMonths = null;
          try {
            tmpNumMonths = new Integer(Integer.parseInt(cForm.getNumMonths()));
          } catch (NumberFormatException nfe) {
            this.addFieldError(
                "numMonths",
                getText(
                    "resource.autodiscovery.ScheduleTab.error.numDays",
                    new String[] {cForm.getNumMonths()}));
            validationFailed = true;
          }
        }

        LocalDate localDate =
            new LocalDate(cForm.getEndYear(), cForm.getEndMonth() + 1, cForm.getEndDay());
        Date endDate = new Date();
        if (cForm.getRecurInterval().equals("recurNever")
            && (cForm.getEndTime().equals("1") || cForm.getEndTime().equals(null))) {
          endDate = null;
        } else {
          endDate = java.sql.Date.valueOf(localDate + "");
        }
        if ((!(cForm.getRecurInterval().equals(ScheduleFormNG.RECUR_NEVER))
            && (cForm.getStartDate() != null && !(cForm.getEndTime().equals("1"))))) {
          Date tmpStartDate = cForm.getStartDate();
          Date tmpEndDate = endDate;
          if (tmpStartDate.after(tmpEndDate)) {
            this.addFieldError(
                "startMonth", getText("resource.common.monitor.error.FromEarlierThanTo"));
            validationFailed = true;
          }
        }
        Date d = new Date();
        GregorianCalendar cal = new GregorianCalendar();
        cal.set(Calendar.YEAR, Calendar.getInstance().get(Calendar.YEAR));
        cal.set(Calendar.MONTH, Calendar.getInstance().get(Calendar.MONTH));
        cal.set(Calendar.DAY_OF_MONTH, Calendar.getInstance().get(Calendar.DAY_OF_MONTH));
        cal.set(Calendar.HOUR_OF_DAY, Calendar.getInstance().get(Calendar.HOUR_OF_DAY));
        cal.set(Calendar.MINUTE, Calendar.getInstance().get(Calendar.MINUTE));
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        d = cal.getTime();
        Date startDate = cForm.getStartDate();
        if ((startDate != null) && (d.after(startDate))) {
          this.addFieldError("startYear", getText("resource.common.control.error.ScheduleInvalid"));
          validationFailed = true;
        }
      } else {
        cForm.setStartTime(ScheduleFormNG.START_NOW);
      }
      request.setAttribute("recurrenceDay", cForm.getRecurrenceDay());
      if (validationFailed) {
        return INPUT;
      }
      if (cForm.getStartTime().equals(ScheduleFormNG.START_NOW)) {
        if (runBackendSave) {
          controlBoss.doAction(sessionId, appdefId, action, (String) null);
        }
      } else {

        // create the new action to schedule

        if (runBackendSave) {
          controlBoss.doAction(sessionId, appdefId, action, covertToScheduleValue());
        }
      }

      // set confirmation message
      if (runBackendSave) {
        addActionMessage(getText("resource.common.scheduled.Confirmation"));
      }
      internalRid = appdefId.getId().toString();
      internalType = String.valueOf(appdefId.getType());
      internalEid = internalType + ":" + internalRid;
      return SUCCESS;
    } catch (PluginNotFoundException pnfe) {
      log.trace("no plugin available", pnfe);
      this.addActionError(getText("resource.common.control.PluginNotFound"));
      return INPUT;
    } catch (PluginException cpe) {
      log.trace("control not enabled", cpe);
      this.addActionError(getText("resource.common.error.ControlNotEnabled"));
      return INPUT;
    } catch (PermissionException pe) {
      this.addActionError(getText("resource.common.control.error.NewPermission"));
      return INPUT;
    } catch (SchedulerException se) {
      this.addActionError(getText("resource.common.control.error.ScheduleInvalid"));
      return INPUT;
    }
  }
  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);
  }