mirror of
https://github.com/google/nomulus.git
synced 2025-05-15 00:47:11 +02:00
RDAP: Allow domain and nameserver queries with no initial string under certain circumstances
Up to now, our search wildcard rules have been that there must be an initial string of at least two characters. If a wildcard is present after that, it can optionally be followed by a suffix specifying the TLD (for domains) or domain (for nameservers). So domain queries can look like: example.tld ex* ex*.tld and nameserver queries can look like: ns1.example.tld ns*.example.tld ns* But you can't do a domain query for *.tld, nor a nameserver query for *.example.tld. It would be nice to support such queries, and the presence of a valid TLD or domain makes them relatively efficient. This CL relaxes the restrictions to allow wildcards with no initial string if the suffix is present. For nameservers, the suffix must be a valid domain in the system, to avoid having to loop through all nameservers. A side effect of the changes is to fix a shortcoming in the logic which caused wildcard nameserver searches to fail if the specified domain suffix referred to an external domain. Entity searches are not affected, since they do not support suffixes. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=159856563
This commit is contained in:
parent
4b2e587480
commit
5a31be12ba
9 changed files with 278 additions and 94 deletions
|
@ -37,6 +37,7 @@ import google.registry.request.Action;
|
|||
import google.registry.request.HttpException;
|
||||
import google.registry.request.HttpException.BadRequestException;
|
||||
import google.registry.request.HttpException.NotFoundException;
|
||||
import google.registry.request.HttpException.UnprocessableEntityException;
|
||||
import google.registry.request.RequestMethod;
|
||||
import google.registry.request.RequestPath;
|
||||
import google.registry.request.Response;
|
||||
|
@ -170,8 +171,9 @@ public abstract class RdapActionBase implements Runnable {
|
|||
* @param clazz the type of resource to be queried
|
||||
* @param filterField the database field of interest
|
||||
* @param partialStringQuery the details of the search string; if there is no wildcard, an
|
||||
* equality query is used; if there is a wildcard, a range query is used instead; there
|
||||
* should not be a search suffix
|
||||
* equality query is used; if there is a wildcard, a range query is used instead; the
|
||||
* initial string should not be empty, and any search suffix will be ignored, so the caller
|
||||
* must filter the results if a suffix is specified
|
||||
* @param resultSetMaxSize the maximum number of results to return
|
||||
* @return the results of the query
|
||||
*/
|
||||
|
@ -180,6 +182,13 @@ public abstract class RdapActionBase implements Runnable {
|
|||
String filterField,
|
||||
RdapSearchPattern partialStringQuery,
|
||||
int resultSetMaxSize) {
|
||||
if (partialStringQuery.getInitialString().length()
|
||||
< RdapSearchPattern.MIN_INITIAL_STRING_LENGTH) {
|
||||
throw new UnprocessableEntityException(
|
||||
String.format(
|
||||
"Initial search string must be at least %d characters",
|
||||
RdapSearchPattern.MIN_INITIAL_STRING_LENGTH));
|
||||
}
|
||||
if (!partialStringQuery.getHasWildcard()) {
|
||||
return ofy().load()
|
||||
.type(clazz)
|
||||
|
@ -187,7 +196,7 @@ public abstract class RdapActionBase implements Runnable {
|
|||
.filter("deletionTime", END_OF_TIME)
|
||||
.limit(resultSetMaxSize);
|
||||
} else {
|
||||
checkArgument(partialStringQuery.getSuffix() == null, "Unexpected search string suffix");
|
||||
// Ignore the suffix; the caller will need to filter on the suffix, if any.
|
||||
return ofy().load()
|
||||
.type(clazz)
|
||||
.filter(filterField + " >=", partialStringQuery.getInitialString())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue