Remove unused and misused methods from EppResourceUtils and DomainBase.

The methods in DomainBase were the only callers for the methods in
EppResourceUtils, so I first inlined them. Then I realized that there
were no callers for loadReferencedContacts() anywhere. For loadNameservers(),
all but one invocation actually wanted to load the foreign keys, and was
repeating that work, so I replaced it with loadNameserverFullyQualifiedHostNames().
The last invocation, in the Rdap code, was incorrectly assuming this was an async
load when in fact it blocks, so I replaced it with a real async load.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=122433897
This commit is contained in:
Corey Goldfeder 2016-05-16 10:38:26 -07:00 committed by Justine Tunney
parent 9a2afc7a9b
commit d9875ea302
8 changed files with 31 additions and 60 deletions

View file

@ -19,12 +19,15 @@ import static com.google.common.base.Strings.isNullOrEmpty;
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;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.util.CollectionUtils.nullToEmpty;
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 com.google.common.base.Function;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet;
@ -37,7 +40,6 @@ import com.googlecode.objectify.annotation.OnLoad;
import com.googlecode.objectify.condition.IfNull;
import google.registry.model.EppResource;
import google.registry.model.EppResourceUtils;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.launch.LaunchNotice;
import google.registry.model.domain.secdns.DelegationSignerData;
@ -161,9 +163,16 @@ public abstract class DomainBase extends EppResource {
return builder.build();
}
/** Loads and returns all linked nameservers. */
public ImmutableSet<HostResource> loadNameservers() {
return EppResourceUtils.loadReferencedNameservers(getNameservers());
/** Loads and returns the fully qualified host names of all linked nameservers. */
public ImmutableSet<String> loadNameserverFullyQualifiedHostNames() {
return FluentIterable.from(ofy().load().refs(getNameservers()).values())
.transform(
new Function<HostResource, String>() {
@Override
public String apply(HostResource host) {
return host.getFullyQualifiedHostName();
}})
.toSet();
}
public Ref<ContactResource> getRegistrant() {
@ -192,11 +201,6 @@ public abstract class DomainBase extends EppResource {
return contactsBuilder.build();
}
/** Loads and returns all referenced contacts from this domain or application. */
public ImmutableSet<ContactResource> loadReferencedContacts() {
return EppResourceUtils.loadReferencedContacts(getReferencedContacts());
}
public String getTld() {
return tld;
}