mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 16:37:13 +02:00
Registrant of a domain can never be null
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=122630609
This commit is contained in:
parent
68b75461db
commit
d2a66e9d1f
14 changed files with 43 additions and 396 deletions
|
@ -14,8 +14,7 @@
|
|||
|
||||
package google.registry.model.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static com.google.common.base.Strings.isNullOrEmpty;
|
||||
import static com.google.common.base.Strings.emptyToNull;
|
||||
import static com.google.common.collect.Sets.difference;
|
||||
import static com.google.common.collect.Sets.union;
|
||||
import static google.registry.model.domain.DesignatedContact.Type.REGISTRANT;
|
||||
|
@ -25,6 +24,7 @@ import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
|
|||
import static google.registry.util.CollectionUtils.nullToEmptyImmutableSortedCopy;
|
||||
import static google.registry.util.CollectionUtils.union;
|
||||
import static google.registry.util.DomainNameUtils.getTldFromSld;
|
||||
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
|
@ -176,11 +176,7 @@ public abstract class DomainBase extends EppResource {
|
|||
}
|
||||
|
||||
public Ref<ContactResource> getRegistrant() {
|
||||
return registrant == null ? null : registrant.getLinked();
|
||||
}
|
||||
|
||||
public ContactResource loadRegistrant() {
|
||||
return getRegistrant().get();
|
||||
return registrant.getLinked();
|
||||
}
|
||||
|
||||
public ImmutableSet<DesignatedContact> getContacts() {
|
||||
|
@ -238,12 +234,11 @@ public abstract class DomainBase extends EppResource {
|
|||
@Override
|
||||
public T build() {
|
||||
T instance = getInstance();
|
||||
checkState(
|
||||
!isNullOrEmpty(instance.fullyQualifiedDomainName), "Missing fullyQualifiedDomainName");
|
||||
checkArgumentNotNull(
|
||||
emptyToNull(instance.fullyQualifiedDomainName), "Missing fullyQualifiedDomainName");
|
||||
checkArgumentNotNull(instance.registrant, "Missing registrant");
|
||||
instance.tld = getTldFromSld(instance.fullyQualifiedDomainName);
|
||||
instance.allContacts = instance.registrant == null
|
||||
? instance.contacts
|
||||
: union(
|
||||
instance.allContacts = union(
|
||||
instance.getContacts(),
|
||||
DesignatedContact.create(REGISTRANT, instance.registrant.getLinked()));
|
||||
return super.build();
|
||||
|
|
|
@ -30,7 +30,6 @@ import com.google.common.collect.Ordering;
|
|||
import com.google.common.net.InetAddresses;
|
||||
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
|
||||
import google.registry.model.EppResource;
|
||||
import google.registry.model.contact.ContactPhoneNumber;
|
||||
|
@ -54,12 +53,8 @@ import java.net.Inet4Address;
|
|||
import java.net.Inet6Address;
|
||||
import java.net.InetAddress;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
@ -400,16 +395,9 @@ public class RdapJsonFormatter {
|
|||
Map<Key<HostResource>, HostResource> loadedHosts =
|
||||
ofy().load().refs(domainResource.getNameservers());
|
||||
// And the registrant and other contacts.
|
||||
List<DesignatedContact> allContacts = new ArrayList<>();
|
||||
if (domainResource.getRegistrant() != null) {
|
||||
allContacts.add(DesignatedContact.create(Type.REGISTRANT, domainResource.getRegistrant()));
|
||||
}
|
||||
allContacts.addAll(domainResource.getContacts());
|
||||
Set<Ref<ContactResource>> contactRefs = new LinkedHashSet<>();
|
||||
for (DesignatedContact designatedContact : allContacts) {
|
||||
contactRefs.add(designatedContact.getContactRef());
|
||||
}
|
||||
Map<Key<ContactResource>, ContactResource> loadedContacts = ofy().load().refs(contactRefs);
|
||||
Map<Key<ContactResource>, ContactResource> loadedContacts =
|
||||
ofy().load().refs(domainResource.getReferencedContacts());
|
||||
|
||||
// Now, assemble the results, using the loaded objects as needed.
|
||||
ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>();
|
||||
builder.put("objectClassName", "domain");
|
||||
|
@ -438,8 +426,9 @@ public class RdapJsonFormatter {
|
|||
}
|
||||
// Contacts
|
||||
ImmutableList.Builder<Object> entitiesBuilder = new ImmutableList.Builder<>();
|
||||
for (DesignatedContact designatedContact
|
||||
: DESIGNATED_CONTACT_ORDERING.immutableSortedCopy(allContacts)) {
|
||||
for (DesignatedContact designatedContact : FluentIterable.from(domainResource.getContacts())
|
||||
.append(DesignatedContact.create(Type.REGISTRANT, domainResource.getRegistrant()))
|
||||
.toSortedList(DESIGNATED_CONTACT_ORDERING)) {
|
||||
ContactResource loadedContact =
|
||||
loadedContacts.get(designatedContact.getContactRef().key());
|
||||
entitiesBuilder.add(makeRdapJsonForContact(
|
||||
|
|
|
@ -146,7 +146,7 @@ final class AllocateDomainCommand extends MutatingEppToolCommand {
|
|||
"name", application.getFullyQualifiedDomainName(),
|
||||
"period", period.getValue(),
|
||||
"nameservers", application.loadNameserverFullyQualifiedHostNames(),
|
||||
"registrant", application.loadRegistrant().getForeignKey(),
|
||||
"registrant", application.getRegistrant().get().getForeignKey(),
|
||||
"contacts", contactsMapBuilder.build(),
|
||||
"authInfo", application.getAuthInfo().getPw().getValue(),
|
||||
"smdId", application.getEncodedSignedMarks().isEmpty()
|
||||
|
|
|
@ -104,7 +104,7 @@ final class AuctionStatusCommand implements RemoteApiCommand, GtechCommand {
|
|||
new Function<DomainApplication, String>() {
|
||||
@Override
|
||||
public String apply(DomainApplication app) {
|
||||
ContactResource registrant = checkNotNull(app.loadRegistrant());
|
||||
ContactResource registrant = checkNotNull(app.getRegistrant().get());
|
||||
Object[] keysAndValues = new Object[] {
|
||||
"Domain", app.getFullyQualifiedDomainName(),
|
||||
"Type", app.getEncodedSignedMarks().isEmpty() ? "Landrush" : "Sunrise",
|
||||
|
|
|
@ -177,7 +177,7 @@ final class GenerateApplicationsReportCommand implements RemoteApiCommand, Gtech
|
|||
domainApplication.getEncodedSignedMarks().isEmpty() ? "landrush" : "sunrise",
|
||||
domainApplication.getApplicationStatus(),
|
||||
domainApplication.getCurrentSponsorClientId(),
|
||||
domainApplication.loadRegistrant().getEmailAddress(),
|
||||
domainApplication.getRegistrant().get().getEmailAddress(),
|
||||
validityMessage);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ final class GenerateAuctionDataCommand implements RemoteApiCommand, GtechCommand
|
|||
+ "Can't process contending applications for %s because some applications "
|
||||
+ "are not yet validated.", domainName);
|
||||
|
||||
ContactResource registrant = checkNotNull(domainApplication.loadRegistrant());
|
||||
ContactResource registrant = checkNotNull(domainApplication.getRegistrant().get());
|
||||
result.add(emitApplication(domainApplication, registrant));
|
||||
|
||||
// Ensure the registrant's email address is unique across the contending applications.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue