mirror of
https://github.com/google/nomulus.git
synced 2025-05-12 22:38:16 +02:00
RDAP: Add "last update of RDAP database" event
The ICANN operational profile says: 1.4.12. An entity object within an RDAP response MUST contain an events member with the following events: o An event of eventAction type registration. o An event of eventAction type last changed. The event of eventAction type last changed MUST be omitted if the Contact Object (as defined in RFC5733) has not been updated since it was created. o An event of eventAction type last update of RDAP database. It has similar wording for domains and hosts. The registration and last changed events are already being generated. This CL adds a "last update of RDAP database" event for all three object types. It's very redundant, and I have warned ICANN that "last update" doesn't mean what they might expect in the context of an eventually consistent database, but there we are. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=130279688
This commit is contained in:
parent
82ab624b36
commit
19da9a1531
30 changed files with 302 additions and 67 deletions
|
@ -106,7 +106,7 @@ public class RdapJsonFormatter {
|
|||
PENDING_TRANSFER("pending transfer"),
|
||||
PENDING_UPDATE("pending update"),
|
||||
PENDING_DELETE("pending delete"),
|
||||
|
||||
|
||||
// Additional status values defined in
|
||||
// https://tools.ietf.org/html/draft-ietf-regext-epp-rdap-status-mapping-01.
|
||||
ADD_PERIOD("add period"),
|
||||
|
@ -201,7 +201,8 @@ public class RdapJsonFormatter {
|
|||
REINSTANTIATION("reinstantiation"),
|
||||
TRANSFER("transfer"),
|
||||
LOCKED("locked"),
|
||||
UNLOCKED("unlocked");
|
||||
UNLOCKED("unlocked"),
|
||||
LAST_UPDATE_OF_RDAP_DATABASE("last update of RDAP database");
|
||||
|
||||
/** Value as it appears in RDAP messages. */
|
||||
private final String rfc7483String;
|
||||
|
@ -412,7 +413,8 @@ public class RdapJsonFormatter {
|
|||
DomainResource domainResource,
|
||||
boolean isTopLevel,
|
||||
@Nullable String linkBase,
|
||||
@Nullable String whoisServer) {
|
||||
@Nullable String whoisServer,
|
||||
DateTime now) {
|
||||
// Kick off the database loads of the nameservers that we will need.
|
||||
Map<Key<HostResource>, HostResource> loadedHosts =
|
||||
ofy().load().refs(domainResource.getNameservers());
|
||||
|
@ -432,7 +434,7 @@ public class RdapJsonFormatter {
|
|||
builder.put("status", makeStatusValueList(domainResource.getStatusValues()));
|
||||
builder.put("links", ImmutableList.of(
|
||||
makeLink("domain", domainResource.getFullyQualifiedDomainName(), linkBase)));
|
||||
ImmutableList<Object> events = makeEvents(domainResource);
|
||||
ImmutableList<Object> events = makeEvents(domainResource, now);
|
||||
if (!events.isEmpty()) {
|
||||
builder.put("events", events);
|
||||
}
|
||||
|
@ -440,7 +442,7 @@ public class RdapJsonFormatter {
|
|||
ImmutableList.Builder<Object> nsBuilder = new ImmutableList.Builder<>();
|
||||
for (HostResource hostResource
|
||||
: HOST_RESOURCE_ORDERING.immutableSortedCopy(loadedHosts.values())) {
|
||||
nsBuilder.add(makeRdapJsonForHost(hostResource, false, linkBase, null));
|
||||
nsBuilder.add(makeRdapJsonForHost(hostResource, false, linkBase, null, now));
|
||||
}
|
||||
ImmutableList<Object> ns = nsBuilder.build();
|
||||
if (!ns.isEmpty()) {
|
||||
|
@ -454,7 +456,7 @@ public class RdapJsonFormatter {
|
|||
ContactResource loadedContact =
|
||||
loadedContacts.get(designatedContact.getContactRef().key());
|
||||
entitiesBuilder.add(makeRdapJsonForContact(
|
||||
loadedContact, false, Optional.of(designatedContact.getType()), linkBase, null));
|
||||
loadedContact, false, Optional.of(designatedContact.getType()), linkBase, null, now));
|
||||
}
|
||||
ImmutableList<Object> entities = entitiesBuilder.build();
|
||||
if (!entities.isEmpty()) {
|
||||
|
@ -481,7 +483,8 @@ public class RdapJsonFormatter {
|
|||
HostResource hostResource,
|
||||
boolean isTopLevel,
|
||||
@Nullable String linkBase,
|
||||
@Nullable String whoisServer) {
|
||||
@Nullable String whoisServer,
|
||||
DateTime now) {
|
||||
ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>();
|
||||
builder.put("objectClassName", "nameserver");
|
||||
builder.put("handle", hostResource.getRepoId());
|
||||
|
@ -493,7 +496,7 @@ public class RdapJsonFormatter {
|
|||
builder.put("status", makeStatusValueList(hostResource.getStatusValues()));
|
||||
builder.put("links", ImmutableList.of(
|
||||
makeLink("nameserver", hostResource.getFullyQualifiedHostName(), linkBase)));
|
||||
ImmutableList<Object> events = makeEvents(hostResource);
|
||||
ImmutableList<Object> events = makeEvents(hostResource, now);
|
||||
if (!events.isEmpty()) {
|
||||
builder.put("events", events);
|
||||
}
|
||||
|
@ -546,7 +549,8 @@ public class RdapJsonFormatter {
|
|||
boolean isTopLevel,
|
||||
Optional<DesignatedContact.Type> contactType,
|
||||
@Nullable String linkBase,
|
||||
@Nullable String whoisServer) {
|
||||
@Nullable String whoisServer,
|
||||
DateTime now) {
|
||||
ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>();
|
||||
builder.put("objectClassName", "entity");
|
||||
builder.put("handle", contactResource.getRepoId());
|
||||
|
@ -588,7 +592,7 @@ public class RdapJsonFormatter {
|
|||
vcardBuilder.add(ImmutableList.of("email", ImmutableMap.of(), "text", emailAddress));
|
||||
}
|
||||
builder.put("vcardArray", ImmutableList.of("vcard", vcardBuilder.build()));
|
||||
ImmutableList<Object> events = makeEvents(contactResource);
|
||||
ImmutableList<Object> events = makeEvents(contactResource, now);
|
||||
if (!events.isEmpty()) {
|
||||
builder.put("events", events);
|
||||
}
|
||||
|
@ -613,7 +617,8 @@ public class RdapJsonFormatter {
|
|||
Registrar registrar,
|
||||
boolean isTopLevel,
|
||||
@Nullable String linkBase,
|
||||
@Nullable String whoisServer) {
|
||||
@Nullable String whoisServer,
|
||||
DateTime now) {
|
||||
ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>();
|
||||
builder.put("objectClassName", "entity");
|
||||
builder.put("handle", registrar.getClientIdentifier());
|
||||
|
@ -656,7 +661,7 @@ public class RdapJsonFormatter {
|
|||
vcardBuilder.add(ImmutableList.of("email", ImmutableMap.of(), "text", emailAddress));
|
||||
}
|
||||
builder.put("vcardArray", ImmutableList.of("vcard", vcardBuilder.build()));
|
||||
ImmutableList<Object> events = makeEvents(registrar);
|
||||
ImmutableList<Object> events = makeEvents(registrar, now);
|
||||
if (!events.isEmpty()) {
|
||||
builder.put("events", events);
|
||||
}
|
||||
|
@ -763,7 +768,7 @@ public class RdapJsonFormatter {
|
|||
/**
|
||||
* Creates an event list for a domain, host or contact resource.
|
||||
*/
|
||||
private static ImmutableList<Object> makeEvents(EppResource resource) {
|
||||
private static ImmutableList<Object> makeEvents(EppResource resource, DateTime now) {
|
||||
ImmutableList.Builder<Object> eventsBuilder = new ImmutableList.Builder<>();
|
||||
for (HistoryEntry historyEntry : ofy().load()
|
||||
.type(HistoryEntry.class)
|
||||
|
@ -789,13 +794,14 @@ public class RdapJsonFormatter {
|
|||
eventsBuilder.add(makeEvent(
|
||||
RdapEventAction.LAST_CHANGED, null, resource.getLastEppUpdateTime()));
|
||||
}
|
||||
eventsBuilder.add(makeEvent(RdapEventAction.LAST_UPDATE_OF_RDAP_DATABASE, null, now));
|
||||
return eventsBuilder.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an event list for a {@link Registrar}.
|
||||
*/
|
||||
private static ImmutableList<Object> makeEvents(Registrar registrar) {
|
||||
private static ImmutableList<Object> makeEvents(Registrar registrar, DateTime now) {
|
||||
ImmutableList.Builder<Object> eventsBuilder = new ImmutableList.Builder<>();
|
||||
eventsBuilder.add(makeEvent(
|
||||
RdapEventAction.REGISTRATION,
|
||||
|
@ -806,6 +812,7 @@ public class RdapJsonFormatter {
|
|||
eventsBuilder.add(makeEvent(
|
||||
RdapEventAction.LAST_CHANGED, null, registrar.getLastUpdateTime()));
|
||||
}
|
||||
eventsBuilder.add(makeEvent(RdapEventAction.LAST_UPDATE_OF_RDAP_DATABASE, null, now));
|
||||
return eventsBuilder.build();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue