Example #1
0
  private void manipulateChannelPerms(String modeName, Long uid, Long cid, String roleLabel) {
    WriteMode mode = ModeFactory.getWriteMode("Org_queries", modeName);
    Map<String, Object> params = new HashMap<String, Object>();
    params.put(USER_ID_KEY, uid);
    params.put("cid", cid);
    params.put("role_label", roleLabel);

    mode.executeUpdate(params);
  }
 private void markFailed(Long sessionId, Long failedStateId) {
   WriteMode update =
       ModeFactory.getWriteMode(
           TaskConstants.MODE_NAME, TaskConstants.TASK_QUERY_KSCLEANUP_MARK_SESSION_FAILED);
   Map params = new HashMap();
   params.put("session_id", sessionId);
   params.put("failed_state_id", failedStateId);
   update.executeUpdate(params);
 }
  /**
   * This method inserts a record into the rhnServerPackage mapping table to associate a given
   * Server with a particular Package. The web code doesn't actually create any of these records,
   * but this will be needed by the backend code.
   *
   * @param srvr Server to associate with the packages
   * @param p The package
   */
  public static void associateSystemToPackage(Server srvr, Package p) {
    try {
      WriteMode m = ModeFactory.getWriteMode("test_queries", "insert_into_rhnServerPackageSimple");
      Map params = new HashMap();
      params.put("server_id", srvr.getId());
      params.put("name_id", p.getPackageName().getId());
      params.put("evr_id", p.getPackageEvr().getId());

      m.executeUpdate(params);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  /**
   * This method inserts a record into the rhnServerPackage mapping table to associate a given
   * Server with a particular Package. The web code doesn't actually create any of these records,
   * but this will be needed by the backend code.
   *
   * @param srvr Server to associate with the packages
   * @param pn The package name to associate
   * @param pe The package evr (version and release).
   */
  public static void associateSystemToPackage(Server srvr, PackageName pn, PackageEvr pe) {
    try {
      WriteMode m = ModeFactory.getWriteMode("test_queries", "insert_into_rhnServerPackage");
      Map params = new HashMap();
      params.put("server_id", srvr.getId());
      params.put("pn_id", pn.getId());
      params.put("p_epoch", pe.getEpoch());
      params.put("p_version", pe.getVersion());
      params.put("p_release", pe.getRelease());

      m.executeUpdate(params);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  /**
   * This method inserts a record into the rhnServerPackage mapping table to associate a given
   * Server with a particular Package. The web code doesn't actually create any of these records,
   * but this will be needed by the backend code.
   *
   * @param srvr Server to associate with the packages
   * @param p The package
   */
  public static void associateSystemToPackageWithArch(Server srvr, Package p) {
    try {
      WriteMode m =
          ModeFactory.getWriteMode("test_queries", "insert_into_rhnServerPackage_with_arch");

      Map<String, Long> params = new HashMap<String, Long>(4);
      params.put("server_id", srvr.getId());
      params.put("pn_id", p.getPackageName().getId());
      params.put("evr_id", p.getPackageEvr().getId());
      params.put("arch_id", p.getPackageArch().getId());

      m.executeUpdate(params);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  /**
   * Add a kickstart package with the given name to the given channel.
   *
   * @param packageName
   * @param channel
   * @throws Exception
   */
  public static void addKickstartPackageToChannel(String packageName, Channel channel)
      throws Exception {
    PackageCapability kickstartCapability = findOrCreateKickstartCapability();
    com.redhat.rhn.domain.rhnpackage.Package kickstartPkg =
        PackageManagerTest.addPackageToChannel(packageName, channel);

    WriteMode m = ModeFactory.getWriteMode("test_queries", "insert_into_rhnPackageProvides");
    Map params = new HashMap();
    params.put("pkg_id", kickstartPkg.getId());
    params.put("capability_id", kickstartCapability.getId());
    params.put("sense_id", "8");
    m.executeUpdate(params);

    // Repeast for another sense:
    params.put("sense_id", "268435464");
    m.executeUpdate(params);
  }