mirror of
https://github.com/google/nomulus.git
synced 2025-05-22 04:09:46 +02:00
Remove some fields from WHOIS output
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=191445626
This commit is contained in:
parent
377fe5f573
commit
839e4aa682
9 changed files with 34 additions and 161 deletions
|
@ -26,8 +26,6 @@ import com.googlecode.objectify.Key;
|
|||
import google.registry.model.contact.ContactPhoneNumber;
|
||||
import google.registry.model.contact.ContactResource;
|
||||
import google.registry.model.contact.PostalInfo;
|
||||
import google.registry.model.domain.DesignatedContact;
|
||||
import google.registry.model.domain.DesignatedContact.Type;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.GracePeriod;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
|
@ -101,9 +99,6 @@ final class DomainWhoisResponse extends WhoisResponseImpl {
|
|||
abuseContact.map(RegistrarContact::getPhoneNumber).orElse(null))
|
||||
.emitStatusValues(domain.getStatusValues(), domain.getGracePeriods())
|
||||
.emitContact("Registrant", domain.getRegistrant(), preferUnicode)
|
||||
.emitContact("Admin", getContactReference(Type.ADMIN), preferUnicode)
|
||||
.emitContact("Tech", getContactReference(Type.TECH), preferUnicode)
|
||||
.emitContact("Billing", getContactReference(Type.BILLING), preferUnicode)
|
||||
.emitSet(
|
||||
"Name Server",
|
||||
domain.loadNameserverFullyQualifiedHostNames(),
|
||||
|
@ -118,14 +113,6 @@ final class DomainWhoisResponse extends WhoisResponseImpl {
|
|||
return WhoisResponseResults.create(plaintext, 1);
|
||||
}
|
||||
|
||||
/** Returns the contact of the given type, or null if it does not exist. */
|
||||
@Nullable
|
||||
private Key<ContactResource> getContactReference(final Type type) {
|
||||
Optional<DesignatedContact> contactOfType =
|
||||
domain.getContacts().stream().filter(d -> d.getType() == type).findFirst();
|
||||
return contactOfType.map(DesignatedContact::getContactKey).orElse(null);
|
||||
}
|
||||
|
||||
/** Output emitter with logic for domains. */
|
||||
class DomainEmitter extends Emitter<DomainEmitter> {
|
||||
DomainEmitter emitPhone(
|
||||
|
@ -140,9 +127,7 @@ final class DomainWhoisResponse extends WhoisResponseImpl {
|
|||
|
||||
/** Emit the contact entry of the given type. */
|
||||
DomainEmitter emitContact(
|
||||
String contactType,
|
||||
@Nullable Key<ContactResource> contact,
|
||||
boolean preferUnicode) {
|
||||
String contactType, @Nullable Key<ContactResource> contact, boolean preferUnicode) {
|
||||
if (contact == null) {
|
||||
return this;
|
||||
}
|
||||
|
@ -151,24 +136,21 @@ final class DomainWhoisResponse extends WhoisResponseImpl {
|
|||
// someone's attention.
|
||||
ContactResource contactResource = ofy().load().key(contact).now();
|
||||
if (contactResource == null) {
|
||||
logger.severefmt("(BUG) Broken reference found from domain %s to contact %s",
|
||||
logger.severefmt(
|
||||
"(BUG) Broken reference found from domain %s to contact %s",
|
||||
domain.getFullyQualifiedDomainName(), contact);
|
||||
return this;
|
||||
}
|
||||
// ICANN Consistent Labeling & Display policy requires that this be the ROID.
|
||||
emitField(ImmutableList.of("Registry", contactType, "ID"), contactResource.getRepoId());
|
||||
PostalInfo postalInfo = chooseByUnicodePreference(
|
||||
preferUnicode,
|
||||
contactResource.getLocalizedPostalInfo(),
|
||||
contactResource.getInternationalizedPostalInfo());
|
||||
PostalInfo postalInfo =
|
||||
chooseByUnicodePreference(
|
||||
preferUnicode,
|
||||
contactResource.getLocalizedPostalInfo(),
|
||||
contactResource.getInternationalizedPostalInfo());
|
||||
if (postalInfo != null) {
|
||||
emitFieldIfDefined(ImmutableList.of(contactType, "Name"), postalInfo.getName());
|
||||
emitFieldIfDefined(ImmutableList.of(contactType, "Organization"), postalInfo.getOrg());
|
||||
emitAddress(contactType, postalInfo.getAddress());
|
||||
emitRegistrantAddress(contactType, postalInfo.getAddress());
|
||||
}
|
||||
return emitPhone(contactType, "Phone", contactResource.getVoiceNumber())
|
||||
.emitPhone(contactType, "Fax", contactResource.getFaxNumber())
|
||||
.emitField(ImmutableList.of(contactType, "Email"), contactResource.getEmailAddress());
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Emits status values and grace periods as a set, in the AWIP format. */
|
||||
|
|
|
@ -48,7 +48,7 @@ class RegistrarWhoisResponse extends WhoisResponseImpl {
|
|||
String plaintext =
|
||||
new RegistrarEmitter()
|
||||
.emitField("Registrar", registrar.getRegistrarName())
|
||||
.emitAddress(
|
||||
.emitRegistrarAddress(
|
||||
null,
|
||||
chooseByUnicodePreference(
|
||||
preferUnicode,
|
||||
|
|
|
@ -135,8 +135,8 @@ abstract class WhoisResponseImpl implements WhoisResponse {
|
|||
return emitField(Joiner.on(' ').join(nameParts), value);
|
||||
}
|
||||
|
||||
/** Emit a contact address. */
|
||||
E emitAddress(@Nullable String prefix, @Nullable Address address) {
|
||||
/** Emit registrar address. */
|
||||
E emitRegistrarAddress(@Nullable String prefix, @Nullable Address address) {
|
||||
prefix = isNullOrEmpty(prefix) ? "" : prefix + " ";
|
||||
if (address != null) {
|
||||
emitList(prefix + "Street", address.getStreet());
|
||||
|
@ -148,6 +148,16 @@ abstract class WhoisResponseImpl implements WhoisResponse {
|
|||
return thisCastToDerived();
|
||||
}
|
||||
|
||||
/** Emit registrant address. */
|
||||
E emitRegistrantAddress(@Nullable String prefix, @Nullable Address address) {
|
||||
prefix = isNullOrEmpty(prefix) ? "" : prefix + " ";
|
||||
if (address != null) {
|
||||
emitField(prefix + "State/Province", address.getState());
|
||||
emitField(prefix + "Country", address.getCountryCode());
|
||||
}
|
||||
return thisCastToDerived();
|
||||
}
|
||||
|
||||
/** Emit Whois Inaccuracy Complaint Form link. Only used for domain queries. */
|
||||
E emitWicfLink() {
|
||||
emitField(ICANN_REPORTING_URL_FIELD, ICANN_REPORTING_URL);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue