// Check to make sure up2date is 2.9.0
  protected ValidatorError validateUp2dateVersion() {
    Server hostServer = getHostServer();
    List packages = PackageManager.systemPackageList(hostServer.getId(), null);
    if (packages != null) {
      log.debug("    packages.size() : " + packages.size());
    }
    // PackageListItem
    Iterator i = packages.iterator();
    String up2dateepoch = null;
    String up2dateversion = null;
    String up2daterelease = null;

    while (i.hasNext()) {
      PackageListItem pli = (PackageListItem) i.next();
      if (pli.getName().equals("yum-rhn-plugin")) {
        // found yum-rhn-plugin - returning
        return null;
      }
      if (pli.getName().equals("zypp-plugin-spacewalk")) {
        // found zypp-plugin-spacewalk - returning
        return null;
      }

      if (pli.getName().equals("up2date")) {
        log.debug("    found up2date ...");
        up2dateepoch = pli.getEpoch();
        up2dateversion = pli.getVersion();
        up2daterelease = pli.getRelease();

        log.debug("    e: " + up2dateepoch + " v: " + up2dateversion + " r : " + up2daterelease);
      }
    }

    if (up2dateepoch == null && up2dateversion == null && up2daterelease == null) {
      Object[] args = new Object[2];
      args[0] = hostServer.getId();
      args[1] = hostServer.getName();
      return new ValidatorError("kickstart.schedule.noup2date", args);
    }

    up2dateepoch = up2dateepoch == null ? "0" : up2dateepoch;
    up2dateversion = up2dateversion == null ? "0" : up2dateversion;
    up2daterelease = up2daterelease == null ? "0" : up2daterelease;

    int comp =
        PackageManager.verCmp(
            up2dateepoch, up2dateversion, up2daterelease, "0", UP2DATE_VERSION, "0");
    log.debug("    Got back comp from verCmp: " + comp);
    if (comp < 0) {
      Long packageId =
          PackageManager.getServerNeededUpdatePackageByName(hostServer.getId(), "up2date");
      if (packageId == null) {
        Object[] args = new Object[2];
        args[0] = UP2DATE_VERSION;
        args[1] = up2dateversion;
        return new ValidatorError("kickstart.schedule.noup2dateinchannel", args);
      }
      Package p = PackageFactory.lookupByIdAndUser(packageId, this.user);

      Map evrmap = new HashMap();
      evrmap.put("name_id", p.getPackageName().getId());
      evrmap.put("evr_id", p.getPackageEvr().getId());
      evrmap.put("arch_id", p.getPackageArch().getId());
      packagesToInstall.add(evrmap);
    } else {
      return null;
    }

    return null;
  }
  /** {@inheritDoc} */
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm formIn,
      HttpServletRequest request,
      HttpServletResponse response) {

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

    // If this is an easy one and we have the pid
    if (request.getParameter("pid") != null) {
      long pid = requestContext.getRequiredParam("pid");
      Package pkg = PackageFactory.lookupByIdAndUser(pid, user);

      // show permission error if pid is invalid like we did before
      if (pkg == null) {
        throw new PermissionException("Invalid pid");
      }

      if (pkg instanceof Patch) {
        request.setAttribute("type", "patch");
        request.setAttribute(PACKAGE_NAME, pkg.getPackageName().getName());
        request.setAttribute(
            "readme_url", DownloadManager.getPatchReadmeDownloadPath((Patch) pkg, user));
      } else if (pkg instanceof PatchSet) {
        request.setAttribute("type", "patchset");
        request.setAttribute(PACKAGE_NAME, pkg.getNameEvra());
        request.setAttribute(
            "readme_url", DownloadManager.getPatchSetReadmeDownloadPath((PatchSet) pkg, user));
      } else {
        request.setAttribute("type", "rpm");
        request.setAttribute(PACKAGE_NAME, pkg.getFilename());
        if (!pkg.getPackageKeys().isEmpty()) {
          request.setAttribute(PACKAGE_KEY, pkg.getPackageKeys().iterator().next().getKey());
        }
        boolean isDebug = pkg.getPackageName().getName().contains("debuginfo");

        request.setAttribute("isDebuginfo", isDebug);
        if (!isDebug) {
          Package debugPkg = PackageManager.findDebugInfo(user, pkg);
          String ftpUrl = PackageManager.generateFtpDebugPath(pkg);
          if (debugPkg != null) {
            request.setAttribute(
                "debugUrl", DownloadManager.getPackageDownloadPath(debugPkg, user));
          } else if (ftpUrl != null) {
            request.setAttribute("debugUrl", ftpUrl);
            request.setAttribute("debugFtp", true);
          }
        }
      }

      if (DownloadManager.isFileAvailable(pkg.getPath())) {
        request.setAttribute("url", DownloadManager.getPackageDownloadPath(pkg, user));
      }

      List<PackageSource> src = PackageFactory.lookupPackageSources(pkg);

      if (!src.isEmpty() && DownloadManager.isFileAvailable(src.get(0).getPath())) {
        request.setAttribute(
            "srpm_url", DownloadManager.getPackageSourceDownloadPath(pkg, src.get(0), user));
        request.setAttribute("srpm_path", src.get(0).getFile());
      }

      request.setAttribute("pack", pkg);
      // description can be null.
      if (pkg.getDescription() != null) {
        request.setAttribute("description", pkg.getDescription().replace("\n", "<BR>\n"));
      } else {
        request.setAttribute("description", pkg.getDescription());
      }
      request.setAttribute("packArches", PackageFactory.findPackagesWithDifferentArch(pkg));
      request.setAttribute("pid", pid);

      return mapping.findForward("default");
    } else { // we have to guess
      PackageListItem item = PackageListItem.parse(request.getParameter("id_combo"));
      Package pkg;
      long nameId = item.getIdOne();
      long evrId = item.getIdTwo();
      long archId = 0;
      if (item.getIdThree() != null) {
        archId = item.getIdThree();
      }

      Long cid = requestContext.getParamAsLong("cid");
      Long sid = requestContext.getParamAsLong("sid");
      if (cid != null) {
        pkg = PackageManager.guestimatePackageByChannel(cid, nameId, evrId, user.getOrg());

      } else if (sid != null) {
        pkg = PackageManager.guestimatePackageBySystem(sid, nameId, evrId, archId, user.getOrg());

      } else {
        throw new BadParameterException("pid, cid, or sid");
      }

      // show permission error if pid is invalid like we did before
      if (pkg == null) {
        throw new NoSuchPackageException();
      }

      Map params = new HashMap();
      params.put("pid", pkg.getId());
      return getStrutsDelegate().forwardParams(mapping.findForward("package"), params);
    }
  }