Exemplo n.º 1
0
  /** {@inheritDoc} */
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm formIn,
      HttpServletRequest request,
      HttpServletResponse response) {

    RequestContext rc = new RequestContext(request);
    User user = rc.getLoggedInUser();

    Channel chan = ChannelManager.lookupByIdAndUser(rc.getRequiredParam(RequestContext.CID), user);

    try {
      ChannelManager.verifyChannelAdmin(user, chan.getId());
    } catch (InvalidChannelRoleException e) {
      addMessage(request, e.getMessage());
      return mapping.findForward("default");
    }

    ListRhnSetHelper helper =
        new ListRhnSetHelper(this, request, RhnSetDecl.ERRATA_TO_SYNC.createCustom(chan.getId()));

    helper.execute();
    if (helper.isDispatched()) {
      Map params = new HashMap();
      params.put(RequestContext.CID, chan.getId());
      return getStrutsDelegate().forwardParams(mapping.findForward("submit"), params);
    }

    request.setAttribute("channel_name", chan.getName());
    request.setAttribute(RequestContext.CID, chan.getId());
    return mapping.findForward("default");
  }
Exemplo n.º 2
0
  /** {@inheritDoc} */
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm formIn,
      HttpServletRequest request,
      HttpServletResponse response) {

    RequestContext requestContext = new RequestContext(request);
    User user = requestContext.getCurrentUser();
    Long sid = requestContext.getRequiredParam("sid");
    RhnSet set = getSetDecl(sid).get(user);

    ListRhnSetHelper help = new ListRhnSetHelper(this, request, getSetDecl(sid));
    help.setListName(LIST_NAME);
    String parentURL = request.getRequestURI() + "?sid=" + sid;
    help.setParentUrl(parentURL);

    help.execute();

    if (help.isDispatched()) {
      if (requestContext.wasDispatched("errata.jsp.apply")) {
        return applyErrata(mapping, formIn, request, response);
      }
    }

    String showButton = "true";
    // Show the "Apply Errata" button only when unapplied errata exist:
    if (!SystemManager.hasUnscheduledErrata(user, sid)) {
      showButton = "false";
    }

    Map params = new HashMap();
    Set keys = request.getParameterMap().keySet();
    for (Iterator i = keys.iterator(); i.hasNext(); ) {
      String key = (String) i.next();
      params.put(key, request.getParameter(key));
    }

    Server server = SystemManager.lookupByIdAndUser(sid, user);
    SdcHelper.ssmCheck(request, server.getId(), user);
    request.setAttribute("showApplyErrata", showButton);
    request.setAttribute("set", set);
    request.setAttribute("system", server);
    request.setAttribute("combo", getComboList(request));
    request.setAttribute(SELECTOR, request.getParameter(SELECTOR));

    return getStrutsDelegate()
        .forwardParams(mapping.findForward(RhnHelper.DEFAULT_FORWARD), params);
  }
Exemplo n.º 3
0
  protected ActionForward doExecute(
      HttpServletRequest request, ActionMapping mapping, DynaActionForm form) {
    String viewMode = form.getString(VIEW_MODE);
    String searchString = form.getString(SEARCH_STR).trim();

    ActionErrors errs = new ActionErrors();
    if (viewMode.equals(SystemSearchHelper.ID)
        || viewMode.equals(SystemSearchHelper.CPU_MHZ_LT)
        || viewMode.equals(SystemSearchHelper.CPU_MHZ_GT)
        || viewMode.equals(SystemSearchHelper.RAM_LT)
        || viewMode.equals(SystemSearchHelper.RAM_GT)
        || viewMode.equals(SystemSearchHelper.NUM_CPUS_LT)
        || viewMode.equals(SystemSearchHelper.NUM_CPUS_GT)
        || viewMode.equals(SystemSearchHelper.CHECKIN)
        || viewMode.equals(SystemSearchHelper.REGISTERED)) {
      String regEx = "(\\d)*";
      Pattern pattern = Pattern.compile(regEx);
      Matcher matcher = pattern.matcher(searchString);
      if (!matcher.matches()) {
        errs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("systemsearch.errors.numeric"));
      }
    }

    // TODO: Set up combined-form validator
    //              errs.add(RhnValidationHelper.validateDynaActionForm(this, daForm));
    addErrors(request, errs);

    ListRhnSetHelper helper = new ListRhnSetHelper(this, request, RhnSetDecl.SYSTEMS);
    helper.setWillClearSet(false);
    helper.setDataSetName(getDataSetName());
    helper.setListName(getListName());
    helper.execute();

    List results = (List) request.getAttribute(getDataSetName());
    log.debug(
        "SystemSearch results.size() = " + (results != null ? results.size() : "null results"));
    if ((results != null) && (results.size() == 1)) {
      SystemSearchResult s = (SystemSearchResult) results.get(0);
      return StrutsDelegate.getInstance()
          .forwardParam(mapping.findForward("single"), "sid", s.getId().toString());
    }
    return mapping.findForward(RhnHelper.DEFAULT_FORWARD);
  }
Exemplo n.º 4
0
  /** {@inheritDoc} */
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm formIn,
      HttpServletRequest request,
      HttpServletResponse response) {

    RequestContext context = new RequestContext(request);
    context.copyParamToAttributes("sid");
    Server server = context.lookupAndBindServer();

    ListRhnSetHelper helper =
        new ListRhnSetHelper(this, request, RhnSetDecl.setForSystemCrashes(server));
    helper.execute();
    if (helper.isDispatched()) {
      return handleSubmit(mapping, context, server);
    }

    SdcHelper.ssmCheck(request, server.getId(), context.getCurrentUser());

    return mapping.findForward(RhnHelper.DEFAULT_FORWARD);
  }