mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 00:17:20 +02:00
Add better RDE logging for when contact resources don't exist
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=192706560
This commit is contained in:
parent
613b19799a
commit
078e9cbe53
1 changed files with 30 additions and 4 deletions
|
@ -14,7 +14,9 @@
|
||||||
|
|
||||||
package google.registry.rde;
|
package google.registry.rde;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
|
import static google.registry.util.FormattingLogger.getLoggerForCallerClass;
|
||||||
|
|
||||||
import com.google.common.base.Ascii;
|
import com.google.common.base.Ascii;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
|
@ -29,6 +31,7 @@ import google.registry.model.eppcommon.StatusValue;
|
||||||
import google.registry.model.rde.RdeMode;
|
import google.registry.model.rde.RdeMode;
|
||||||
import google.registry.model.transfer.TransferData;
|
import google.registry.model.transfer.TransferData;
|
||||||
import google.registry.model.transfer.TransferStatus;
|
import google.registry.model.transfer.TransferStatus;
|
||||||
|
import google.registry.util.FormattingLogger;
|
||||||
import google.registry.util.Idn;
|
import google.registry.util.Idn;
|
||||||
import google.registry.xjc.domain.XjcDomainContactAttrType;
|
import google.registry.xjc.domain.XjcDomainContactAttrType;
|
||||||
import google.registry.xjc.domain.XjcDomainContactType;
|
import google.registry.xjc.domain.XjcDomainContactType;
|
||||||
|
@ -48,6 +51,8 @@ import org.joda.time.DateTime;
|
||||||
/** Utility class that turns {@link DomainResource} as {@link XjcRdeDomainElement}. */
|
/** Utility class that turns {@link DomainResource} as {@link XjcRdeDomainElement}. */
|
||||||
final class DomainResourceToXjcConverter {
|
final class DomainResourceToXjcConverter {
|
||||||
|
|
||||||
|
private static final FormattingLogger logger = getLoggerForCallerClass();
|
||||||
|
|
||||||
/** Converts {@link DomainResource} to {@link XjcRdeDomainElement}. */
|
/** Converts {@link DomainResource} to {@link XjcRdeDomainElement}. */
|
||||||
static XjcRdeDomainElement convert(DomainResource domain, RdeMode mode) {
|
static XjcRdeDomainElement convert(DomainResource domain, RdeMode mode) {
|
||||||
return new XjcRdeDomainElement(convertDomain(domain, mode));
|
return new XjcRdeDomainElement(convertDomain(domain, mode));
|
||||||
|
@ -151,6 +156,8 @@ final class DomainResourceToXjcConverter {
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case FULL:
|
case FULL:
|
||||||
|
String domainName = model.getFullyQualifiedDomainName();
|
||||||
|
|
||||||
// o Zero or more OPTIONAL <rgpStatus> element to represent
|
// o Zero or more OPTIONAL <rgpStatus> element to represent
|
||||||
// "pendingDelete" sub-statuses, including "redemptionPeriod",
|
// "pendingDelete" sub-statuses, including "redemptionPeriod",
|
||||||
// "pendingRestore", and "pendingDelete", that a domain name can be
|
// "pendingRestore", and "pendingDelete", that a domain name can be
|
||||||
|
@ -164,15 +171,23 @@ final class DomainResourceToXjcConverter {
|
||||||
// the human or organizational social information object associated
|
// the human or organizational social information object associated
|
||||||
// as the holder of the domain name object.
|
// as the holder of the domain name object.
|
||||||
Key<ContactResource> registrant = model.getRegistrant();
|
Key<ContactResource> registrant = model.getRegistrant();
|
||||||
if (registrant != null) {
|
if (registrant == null) {
|
||||||
bean.setRegistrant(ofy().load().key(registrant).now().getContactId());
|
logger.warningfmt("Domain %s has no registrant contact.", domainName);
|
||||||
|
} else {
|
||||||
|
ContactResource registrantContact = ofy().load().key(registrant).now();
|
||||||
|
checkState(
|
||||||
|
registrantContact != null,
|
||||||
|
"Registrant contact %s on domain %s does not exist",
|
||||||
|
registrant,
|
||||||
|
domainName);
|
||||||
|
bean.setRegistrant(registrantContact.getContactId());
|
||||||
}
|
}
|
||||||
|
|
||||||
// o Zero or more OPTIONAL <contact> elements that contain identifiers
|
// o Zero or more OPTIONAL <contact> elements that contain identifiers
|
||||||
// for the human or organizational social information objects
|
// for the human or organizational social information objects
|
||||||
// associated with the domain name object.
|
// associated with the domain name object.
|
||||||
for (DesignatedContact contact : model.getContacts()) {
|
for (DesignatedContact contact : model.getContacts()) {
|
||||||
bean.getContacts().add(convertDesignatedContact(contact));
|
bean.getContacts().add(convertDesignatedContact(contact, domainName));
|
||||||
}
|
}
|
||||||
|
|
||||||
// o An OPTIONAL <secDNS> element that contains the public key
|
// o An OPTIONAL <secDNS> element that contains the public key
|
||||||
|
@ -291,9 +306,20 @@ final class DomainResourceToXjcConverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Converts {@link DesignatedContact} to {@link XjcDomainContactType}. */
|
/** Converts {@link DesignatedContact} to {@link XjcDomainContactType}. */
|
||||||
private static XjcDomainContactType convertDesignatedContact(DesignatedContact model) {
|
private static XjcDomainContactType convertDesignatedContact(
|
||||||
|
DesignatedContact model, String domainName) {
|
||||||
XjcDomainContactType bean = new XjcDomainContactType();
|
XjcDomainContactType bean = new XjcDomainContactType();
|
||||||
|
checkState(
|
||||||
|
model.getContactKey() != null,
|
||||||
|
"Contact key for type %s is null on domain %s",
|
||||||
|
model.getType(),
|
||||||
|
domainName);
|
||||||
ContactResource contact = ofy().load().key(model.getContactKey()).now();
|
ContactResource contact = ofy().load().key(model.getContactKey()).now();
|
||||||
|
checkState(
|
||||||
|
contact != null,
|
||||||
|
"Contact %s on domain %s does not exist",
|
||||||
|
model.getContactKey(),
|
||||||
|
domainName);
|
||||||
bean.setType(XjcDomainContactAttrType.fromValue(Ascii.toLowerCase(model.getType().toString())));
|
bean.setType(XjcDomainContactAttrType.fromValue(Ascii.toLowerCase(model.getType().toString())));
|
||||||
bean.setValue(contact.getContactId());
|
bean.setValue(contact.getContactId());
|
||||||
return bean;
|
return bean;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue