NICMx / rdap-sql-provider

Red Dog’s reference (SQL-based) data access implementation.
https://www.reddog.mx
Apache License 2.0
1 stars 1 forks source link

ip_address.iad_type value is ignored when the object is loaded from database #13

Open TheRedTrainer opened 7 years ago

TheRedTrainer commented 7 years ago

When a ip address is loaded from database (according to mx.nic.rdap.sql.objects.IpAddressDbObj.java class), all the data is setted with db values, except the internet address type as it is showed in the following method loadFromDatabase:

public void loadFromDatabase(ResultSet resultSet) throws SQLException { this.setId(resultSet.getLong("iad_id")); this.setNameserverId(resultSet.getLong("nse_id")); try { this.setAddress(InetAddress.getByName(resultSet.getString("iad_value"))); } catch (UnknownHostException e) { // The address is validate in the store process,so this exception // will never be throw. } if (this.getAddress() instanceof Inet4Address) { this.setType(4); } else if (this.getAddress() instanceof Inet6Address) { this.setType(6); }

}

Ip Address type attribute is setted in a validation of the instance of inet address, but the iad_type value from db is never accessed. It is necessary to obtain the ip address type from db and, if it is necessary, validate it with the instance of inet address, in order to confirm or throw an exception.

dhfelix commented 7 years ago

When the object IpAddress is loaded as a property of a nameserver object, it is not critical to load the column "iad_type" from the database.

The column "iad_type" is used when a partial search is requested (more specific, at the /nameservers/nsIp=XXX request), with this column is easier to search only information of that kind of IP version, and do not perform a full table scan. As our project RDAP does not store data in the database, the project do not have control if the iad_type and the value of the IP match when performing a search.

In conclusion, the column "iad_type" is useful as a filter when the user requests a search.

TheRedTrainer commented 7 years ago

Verified and agreed. However, talking about with @pcarana , it could be an enhancement to add comments related to that fact to the code, scripts and web site, in order to explain this behaviour that could be misunderstood by other developers. This issue will be closed and a new enhancement will be reported to explain the situation.