Exemplo n.º 1
0
  /**
   * Add domainRedirection information
   *
   * @param domainName
   * @param redirectUrl
   * @throws ManagementException
   */
  public void addDomainRedirection(final String domainName, final String redirectUrl)
      throws ManagementException {

    Connection connection = jdbcUtils.getConnection();
    PreparedStatement stmt = null;
    ResultSet resultsIsNull = null;
    try {
      String sql = WhoisUtil.ISNULL_DOMAIN_REDIRECT;
      stmt = connection.prepareStatement(sql);
      stmt.setString(1, domainName);
      stmt.setString(2, redirectUrl);
      resultsIsNull = stmt.executeQuery();

      //			TODO : Whatever return result is true or false, still execute next code
      if (resultsIsNull.next()) throw new ManagementException("Already exists in the data ");

      sql =
          WhoisUtil.INSERT_DOMAIN_REDIRECTION
              + "'"
              + domainName
              + "'"
              + ","
              + "'"
              + redirectUrl
              + "')";

      stmt = connection.prepareStatement(sql);
      stmt.execute();
    } catch (SQLException e) {
      e.printStackTrace();
      throw new ManagementException(e);
    } finally {
      JdbcUtils.free(null, null, connection);
    }
  }
Exemplo n.º 2
0
  /**
   * Update domainRedirection information
   *
   * @param domainName
   * @param id
   * @param redirectUrl
   * @throws ManagementException
   */
  public void updateDomainRedirection(String domainName, int id, String redirectUrl)
      throws ManagementException {
    Connection connection = jdbcUtils.getConnection();
    PreparedStatement stmt = null;
    ResultSet resultsIsNull = null;
    try {
      String sql = WhoisUtil.ISNULL_DOMAIN_REDIRECT;
      stmt = connection.prepareStatement(sql);
      stmt.setString(1, domainName);
      stmt.setString(2, redirectUrl);
      resultsIsNull = stmt.executeQuery();

      if (resultsIsNull.next()) throw new ManagementException("Already exists in the data ");

      sql =
          WhoisUtil.UPDATE_DOMAIN_REDIRECTION
              + "'"
              + domainName
              + "'"
              + WhoisUtil.UPDATE_REDIRECTION1
              + "'"
              + redirectUrl
              + "'"
              + WhoisUtil.UPDATE_REDIRECTION2
              + id;

      stmt = connection.prepareStatement(sql);
      stmt.execute();
    } catch (SQLException e) {
      e.printStackTrace();
      throw new ManagementException(e);
    } finally {
      JdbcUtils.free(null, null, connection);
    }
  }
Exemplo n.º 3
0
  /**
   * Update ipRedirection information
   *
   * @param startHighAddr
   * @param endHighAddr
   * @param startLowAddr
   * @param endLowAddr
   * @param id
   * @param redirectUrl
   * @throws ManagementException
   */
  public void updateIPRedirection(
      long startHighAddr,
      long endHighAddr,
      long startLowAddr,
      long endLowAddr,
      int id,
      String redirectUrl)
      throws ManagementException {
    Connection connection = jdbcUtils.getConnection();
    PreparedStatement stmt = null;
    ResultSet resultsIsNull = null;
    try {
      String sql = WhoisUtil.ISNULL_IP_REDIRECT;
      stmt = connection.prepareStatement(sql);
      stmt.setLong(1, startHighAddr);
      stmt.setLong(2, endHighAddr);
      stmt.setLong(3, startLowAddr);
      stmt.setLong(4, endLowAddr);
      stmt.setString(5, redirectUrl);

      resultsIsNull = stmt.executeQuery();
      if (resultsIsNull.next()) throw new ManagementException("Already exists in the data ");

      sql =
          WhoisUtil.UPDATE_IP_REDIRECTION1
              + startHighAddr
              + WhoisUtil.UPDATE_IP_REDIRECTION2
              + endHighAddr
              + WhoisUtil.UPDATE_IP_REDIRECTION3
              + startLowAddr
              + WhoisUtil.UPDATE_IP_REDIRECTION4
              + endLowAddr
              + WhoisUtil.UPDATE_REDIRECTION1
              + "'"
              + redirectUrl
              + "'"
              + WhoisUtil.UPDATE_REDIRECTION2
              + id;

      stmt = connection.prepareStatement(sql);
      stmt.execute();
    } catch (SQLException e) {
      e.printStackTrace();
      throw new ManagementException(e);
    } finally {
      JdbcUtils.free(null, null, connection);
    }
  }
Exemplo n.º 4
0
  /**
   * Add autunmRedirection information
   *
   * @param startNumber
   * @param endNumber
   * @param redirectUrl
   * @throws ManagementException
   */
  public void addAutnumRedirection(String startNumber, String endNumber, String redirectUrl)
      throws ManagementException {
    Connection connection = jdbcUtils.getConnection();
    PreparedStatement stmt = null;
    ResultSet resultsIsNull = null;
    try {
      String sql = WhoisUtil.ISNULL_AUTNUM_REDIRECT;
      stmt = connection.prepareStatement(sql);
      stmt.setInt(1, Integer.parseInt(startNumber));
      stmt.setInt(2, Integer.parseInt(endNumber));
      stmt.setString(3, redirectUrl);
      resultsIsNull = stmt.executeQuery();

      if (resultsIsNull.next()) {
        throw new ManagementException("Already exists in the data ");
      }

      sql =
          WhoisUtil.INSERT_AUTNUM_REDIRECTION
              + Integer.parseInt(startNumber)
              + ","
              + Integer.parseInt(endNumber)
              + ","
              + "'"
              + redirectUrl
              + "')";

      stmt = connection.prepareStatement(sql);
      stmt.execute();

    } catch (SQLException e) {
      e.printStackTrace();
      throw new ManagementException(e);
    } finally {
      JdbcUtils.free(null, null, connection);
    }
  }