Add RDAP support for deleted nameservers and filtering by registrar

This CL adds the functionality for nameserver searches. Future CLs will handle domains and entities.

Deleted items can only be seen by admins, and by registrars viewing their own deleted items.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=170106014
This commit is contained in:
mountford 2017-09-26 14:07:42 -07:00 committed by Ben McIlwain
parent 0c8b5bc8bf
commit c13c2f403a
11 changed files with 870 additions and 153 deletions

View file

@ -17,6 +17,7 @@ package google.registry.rdap;
import static google.registry.model.EppResourceUtils.loadByForeignKey;
import static google.registry.request.Action.Method.GET;
import static google.registry.request.Action.Method.HEAD;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import com.google.common.collect.ImmutableMap;
import google.registry.model.host.HostResource;
@ -59,8 +60,12 @@ public class RdapNameserverAction extends RdapActionBase {
pathSearchString = canonicalizeName(pathSearchString);
// The RDAP syntax is /rdap/nameserver/ns1.mydomain.com.
validateDomainName(pathSearchString);
HostResource hostResource = loadByForeignKey(HostResource.class, pathSearchString, now);
if (hostResource == null) {
// If there are no undeleted nameservers with the given name, the foreign key should point to
// the most recently deleted one.
HostResource hostResource =
loadByForeignKey(
HostResource.class, pathSearchString, shouldIncludeDeleted() ? START_OF_TIME : now);
if ((hostResource == null) || !shouldBeVisible(hostResource, now)) {
throw new NotFoundException(pathSearchString + " not found");
}
return rdapJsonFormatter.makeRdapJsonForHost(