Rename Registries to Tlds (#2042)

* Rename Registries to Tlds

* Change Tlds to TLDs in comments
This commit is contained in:
sarahcaseybot 2023-05-24 17:08:09 -04:00 committed by GitHub
parent 6b5d7f5b21
commit 2df1fbc418
41 changed files with 81 additions and 82 deletions

View file

@ -21,7 +21,7 @@ import static google.registry.batch.BatchModule.PARAM_DRY_RUN;
import static google.registry.config.RegistryEnvironment.PRODUCTION; import static google.registry.config.RegistryEnvironment.PRODUCTION;
import static google.registry.dns.DnsUtils.requestDomainDnsRefresh; import static google.registry.dns.DnsUtils.requestDomainDnsRefresh;
import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_DELETE; import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_DELETE;
import static google.registry.model.tld.Registries.getTldsOfType; import static google.registry.model.tld.Tlds.getTldsOfType;
import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
import static google.registry.request.Action.Method.POST; import static google.registry.request.Action.Method.POST;
import static google.registry.request.RequestParameters.PARAM_TLDS; import static google.registry.request.RequestParameters.PARAM_TLDS;

View file

@ -27,9 +27,9 @@ import static google.registry.cron.CronModule.FOR_EACH_TEST_TLD_PARAM;
import static google.registry.cron.CronModule.JITTER_SECONDS_PARAM; import static google.registry.cron.CronModule.JITTER_SECONDS_PARAM;
import static google.registry.cron.CronModule.QUEUE_PARAM; import static google.registry.cron.CronModule.QUEUE_PARAM;
import static google.registry.cron.CronModule.RUN_IN_EMPTY_PARAM; import static google.registry.cron.CronModule.RUN_IN_EMPTY_PARAM;
import static google.registry.model.tld.Registries.getTldsOfType;
import static google.registry.model.tld.Tld.TldType.REAL; import static google.registry.model.tld.Tld.TldType.REAL;
import static google.registry.model.tld.Tld.TldType.TEST; import static google.registry.model.tld.Tld.TldType.TEST;
import static google.registry.model.tld.Tlds.getTldsOfType;
import com.google.cloud.tasks.v2.Task; import com.google.cloud.tasks.v2.Task;
import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ArrayListMultimap;

View file

@ -20,8 +20,8 @@ import static google.registry.persistence.transaction.TransactionManagerFactory.
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.net.InternetDomainName; import com.google.common.net.InternetDomainName;
import google.registry.model.common.DnsRefreshRequest; import google.registry.model.common.DnsRefreshRequest;
import google.registry.model.tld.Registries;
import google.registry.model.tld.Tld; import google.registry.model.tld.Tld;
import google.registry.model.tld.Tlds;
import java.util.Collection; import java.util.Collection;
import java.util.Optional; import java.util.Optional;
import org.joda.time.DateTime; import org.joda.time.DateTime;
@ -38,7 +38,7 @@ public final class DnsUtils {
private static void requestDnsRefresh(String name, TargetType type, Duration delay) { private static void requestDnsRefresh(String name, TargetType type, Duration delay) {
// Throws an IllegalArgumentException if the name is not under a managed TLD -- we only update // Throws an IllegalArgumentException if the name is not under a managed TLD -- we only update
// DNS for names that are under our management. // DNS for names that are under our management.
String tld = Registries.findTldForNameOrThrow(InternetDomainName.from(name)).toString(); String tld = Tlds.findTldForNameOrThrow(InternetDomainName.from(name)).toString();
tm().transact( tm().transact(
() -> () ->
tm().insert( tm().insert(
@ -114,7 +114,7 @@ public final class DnsUtils {
} }
public static long getDnsAPlusAAAATtlForHost(String host, Duration dnsDefaultATtl) { public static long getDnsAPlusAAAATtlForHost(String host, Duration dnsDefaultATtl) {
Optional<InternetDomainName> tldName = Registries.findTldForName(InternetDomainName.from(host)); Optional<InternetDomainName> tldName = Tlds.findTldForName(InternetDomainName.from(host));
Duration dnsAPlusAaaaTtl = dnsDefaultATtl; Duration dnsAPlusAaaaTtl = dnsDefaultATtl;
if (tldName.isPresent()) { if (tldName.isPresent()) {
Tld tld = Tld.get(tldName.get().toString()); Tld tld = Tld.get(tldName.get().toString());

View file

@ -40,8 +40,8 @@ import google.registry.dns.writer.DnsWriterZone;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.secdns.DomainDsData; import google.registry.model.domain.secdns.DomainDsData;
import google.registry.model.host.Host; import google.registry.model.host.Host;
import google.registry.model.tld.Registries;
import google.registry.model.tld.Tld; import google.registry.model.tld.Tld;
import google.registry.model.tld.Tlds;
import google.registry.util.Clock; import google.registry.util.Clock;
import google.registry.util.Concurrent; import google.registry.util.Concurrent;
import google.registry.util.Retrier; import google.registry.util.Retrier;
@ -248,7 +248,7 @@ public class CloudDnsWriter extends BaseDnsWriter {
public void publishHost(String hostName) { public void publishHost(String hostName) {
// Get the superordinate domain name of the host. // Get the superordinate domain name of the host.
InternetDomainName host = InternetDomainName.from(hostName); InternetDomainName host = InternetDomainName.from(hostName);
Optional<InternetDomainName> tld = Registries.findTldForName(host); Optional<InternetDomainName> tld = Tlds.findTldForName(host);
// Host not managed by our registry, no need to update DNS. // Host not managed by our registry, no need to update DNS.
if (!tld.isPresent()) { if (!tld.isPresent()) {

View file

@ -31,8 +31,8 @@ import google.registry.dns.writer.DnsWriterZone;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.secdns.DomainDsData; import google.registry.model.domain.secdns.DomainDsData;
import google.registry.model.host.Host; import google.registry.model.host.Host;
import google.registry.model.tld.Registries;
import google.registry.model.tld.Tld; import google.registry.model.tld.Tld;
import google.registry.model.tld.Tlds;
import google.registry.util.Clock; import google.registry.util.Clock;
import java.io.IOException; import java.io.IOException;
import java.net.Inet4Address; import java.net.Inet4Address;
@ -154,7 +154,7 @@ public class DnsUpdateWriter extends BaseDnsWriter {
// Get the superordinate domain name of the host. // Get the superordinate domain name of the host.
InternetDomainName host = InternetDomainName.from(hostName); InternetDomainName host = InternetDomainName.from(hostName);
ImmutableList<String> hostParts = host.parts(); ImmutableList<String> hostParts = host.parts();
Optional<InternetDomainName> tld = Registries.findTldForName(host); Optional<InternetDomainName> tld = Tlds.findTldForName(host);
// host not managed by our registry, no need to update DNS. // host not managed by our registry, no need to update DNS.
if (!tld.isPresent()) { if (!tld.isPresent()) {

View file

@ -15,7 +15,7 @@
package google.registry.export; package google.registry.export;
import static com.google.common.base.Verify.verifyNotNull; import static com.google.common.base.Verify.verifyNotNull;
import static google.registry.model.tld.Registries.getTldsOfType; import static google.registry.model.tld.Tlds.getTldsOfType;
import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
import static google.registry.request.Action.Method.POST; import static google.registry.request.Action.Method.POST;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;

View file

@ -26,12 +26,12 @@ import static com.google.common.collect.Sets.difference;
import static com.google.common.collect.Sets.intersection; import static com.google.common.collect.Sets.intersection;
import static com.google.common.collect.Sets.union; import static com.google.common.collect.Sets.union;
import static google.registry.model.domain.Domain.MAX_REGISTRATION_YEARS; import static google.registry.model.domain.Domain.MAX_REGISTRATION_YEARS;
import static google.registry.model.tld.Registries.findTldForName;
import static google.registry.model.tld.Registries.getTlds;
import static google.registry.model.tld.Tld.TldState.GENERAL_AVAILABILITY; import static google.registry.model.tld.Tld.TldState.GENERAL_AVAILABILITY;
import static google.registry.model.tld.Tld.TldState.PREDELEGATION; import static google.registry.model.tld.Tld.TldState.PREDELEGATION;
import static google.registry.model.tld.Tld.TldState.QUIET_PERIOD; import static google.registry.model.tld.Tld.TldState.QUIET_PERIOD;
import static google.registry.model.tld.Tld.TldState.START_DATE_SUNRISE; import static google.registry.model.tld.Tld.TldState.START_DATE_SUNRISE;
import static google.registry.model.tld.Tlds.findTldForName;
import static google.registry.model.tld.Tlds.getTlds;
import static google.registry.model.tld.label.ReservationType.ALLOWED_IN_SUNRISE; import static google.registry.model.tld.label.ReservationType.ALLOWED_IN_SUNRISE;
import static google.registry.model.tld.label.ReservationType.FULLY_BLOCKED; import static google.registry.model.tld.label.ReservationType.FULLY_BLOCKED;
import static google.registry.model.tld.label.ReservationType.NAME_COLLISION; import static google.registry.model.tld.label.ReservationType.NAME_COLLISION;

View file

@ -16,7 +16,7 @@ package google.registry.flows.host;
import static google.registry.model.EppResourceUtils.isActive; import static google.registry.model.EppResourceUtils.isActive;
import static google.registry.model.EppResourceUtils.loadByForeignKey; import static google.registry.model.EppResourceUtils.loadByForeignKey;
import static google.registry.model.tld.Registries.findTldForName; import static google.registry.model.tld.Tlds.findTldForName;
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull; import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.joining;

View file

@ -26,7 +26,7 @@ import static com.google.common.collect.Sets.immutableEnumSet;
import static com.google.common.io.BaseEncoding.base64; import static com.google.common.io.BaseEncoding.base64;
import static google.registry.config.RegistryConfig.getDefaultRegistrarWhoisServer; import static google.registry.config.RegistryConfig.getDefaultRegistrarWhoisServer;
import static google.registry.model.CacheUtils.memoizeWithShortExpiration; import static google.registry.model.CacheUtils.memoizeWithShortExpiration;
import static google.registry.model.tld.Registries.assertTldsExist; import static google.registry.model.tld.Tlds.assertTldsExist;
import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy; import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
import static google.registry.util.CollectionUtils.nullToEmptyImmutableSortedCopy; import static google.registry.util.CollectionUtils.nullToEmptyImmutableSortedCopy;

View file

@ -40,15 +40,15 @@ import java.util.stream.Stream;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
/** Utilities for finding and listing {@link Tld} entities. */ /** Utilities for finding and listing {@link Tld} entities. */
public final class Registries { public final class Tlds {
private Registries() {} private Tlds() {}
/** Supplier of a cached registries map. */ /** Supplier of a cached TLDs map. */
private static Supplier<ImmutableMap<String, TldType>> cache = createFreshCache(); private static Supplier<ImmutableMap<String, TldType>> cache = createFreshCache();
/** /**
* Returns a newly-created Supplier of a registries to types map. * Returns a newly-created Supplier of a TLDs to types map.
* *
* <p>The supplier's get() method enters a transactionless context briefly to avoid enrolling the * <p>The supplier's get() method enters a transactionless context briefly to avoid enrolling the
* query inside an unrelated client-affecting transaction. * query inside an unrelated client-affecting transaction.
@ -84,7 +84,7 @@ public final class Registries {
return ImmutableSet.copyOf(filterValues(cache.get(), equalTo(type)).keySet()); return ImmutableSet.copyOf(filterValues(cache.get(), equalTo(type)).keySet());
} }
/** Returns the Registry entities themselves of the given type loaded fresh from the database. */ /** Returns the TLD entities themselves of the given type loaded fresh from the database. */
public static ImmutableSet<Tld> getTldEntitiesOfType(TldType type) { public static ImmutableSet<Tld> getTldEntitiesOfType(TldType type) {
return Tld.get(filterValues(cache.get(), equalTo(type)).keySet()); return Tld.get(filterValues(cache.get(), equalTo(type)).keySet());
} }

View file

@ -18,7 +18,7 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
import static com.google.common.base.Strings.isNullOrEmpty; import static com.google.common.base.Strings.isNullOrEmpty;
import static com.google.common.collect.ImmutableSet.toImmutableSet; import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static google.registry.model.tld.Registries.getTlds; import static google.registry.model.tld.Tlds.getTlds;
import com.google.common.collect.HashMultiset; import com.google.common.collect.HashMultiset;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;

View file

@ -20,7 +20,7 @@ import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import google.registry.model.eppoutput.Result.Code; import google.registry.model.eppoutput.Result.Code;
import google.registry.model.tld.Registries; import google.registry.model.tld.Tlds;
import google.registry.util.Clock; import google.registry.util.Clock;
import java.util.Optional; import java.util.Optional;
import org.joda.time.DateTime; import org.joda.time.DateTime;
@ -104,7 +104,7 @@ public abstract class EppMetric {
String tld = Iterables.getOnlyElement(tlds); String tld = Iterables.getOnlyElement(tlds);
// Only record TLDs that actually exist, otherwise we can blow up cardinality by recording // Only record TLDs that actually exist, otherwise we can blow up cardinality by recording
// an arbitrarily large number of strings. // an arbitrarily large number of strings.
setTld(Optional.ofNullable(Registries.getTlds().contains(tld) ? tld : "_invalid")); setTld(Optional.ofNullable(Tlds.getTlds().contains(tld) ? tld : "_invalid"));
break; break;
default: default:
setTld("_various"); setTld("_various");

View file

@ -23,9 +23,9 @@ import google.registry.config.RegistryConfig.Config;
import google.registry.model.common.Cursor; import google.registry.model.common.Cursor;
import google.registry.model.common.Cursor.CursorType; import google.registry.model.common.Cursor.CursorType;
import google.registry.model.rde.RdeMode; import google.registry.model.rde.RdeMode;
import google.registry.model.tld.Registries;
import google.registry.model.tld.Tld; import google.registry.model.tld.Tld;
import google.registry.model.tld.Tld.TldType; import google.registry.model.tld.Tld.TldType;
import google.registry.model.tld.Tlds;
import google.registry.util.Clock; import google.registry.util.Clock;
import java.util.Optional; import java.util.Optional;
import javax.inject.Inject; import javax.inject.Inject;
@ -83,7 +83,7 @@ public final class PendingDepositChecker {
ImmutableSetMultimap.Builder<String, PendingDeposit> builder = ImmutableSetMultimap.Builder<String, PendingDeposit> builder =
new ImmutableSetMultimap.Builder<>(); new ImmutableSetMultimap.Builder<>();
DateTime now = clock.nowUtc(); DateTime now = clock.nowUtc();
for (String tldStr : Registries.getTldsOfType(TldType.REAL)) { for (String tldStr : Tlds.getTldsOfType(TldType.REAL)) {
Tld tld = Tld.get(tldStr); Tld tld = Tld.get(tldStr);
if (!tld.getEscrowEnabled()) { if (!tld.getEscrowEnabled()) {
continue; continue;

View file

@ -16,7 +16,7 @@ package google.registry.reporting.icann;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.net.MediaType.CSV_UTF_8; import static com.google.common.net.MediaType.CSV_UTF_8;
import static google.registry.model.tld.Registries.assertTldExists; import static google.registry.model.tld.Tlds.assertTldExists;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.api.client.http.ByteArrayContent; import com.google.api.client.http.ByteArrayContent;

View file

@ -29,9 +29,9 @@ import google.registry.config.RegistryConfig.Config;
import google.registry.gcs.GcsUtils; import google.registry.gcs.GcsUtils;
import google.registry.model.common.Cursor; import google.registry.model.common.Cursor;
import google.registry.model.common.Cursor.CursorType; import google.registry.model.common.Cursor.CursorType;
import google.registry.model.tld.Registries;
import google.registry.model.tld.Tld; import google.registry.model.tld.Tld;
import google.registry.model.tld.Tld.TldType; import google.registry.model.tld.Tld.TldType;
import google.registry.model.tld.Tlds;
import google.registry.persistence.VKey; import google.registry.persistence.VKey;
import google.registry.request.Action; import google.registry.request.Action;
import google.registry.request.HttpException.ServiceUnavailableException; import google.registry.request.HttpException.ServiceUnavailableException;
@ -203,7 +203,7 @@ public final class IcannReportingUploadAction implements Runnable {
/** Returns a map of each cursor to the tld. */ /** Returns a map of each cursor to the tld. */
private ImmutableMap<Cursor, String> loadCursors() { private ImmutableMap<Cursor, String> loadCursors() {
ImmutableSet<Tld> registries = Registries.getTldEntitiesOfType(TldType.REAL); ImmutableSet<Tld> registries = Tlds.getTldEntitiesOfType(TldType.REAL);
ImmutableMap<VKey<? extends Cursor>, Tld> activityKeyMap = ImmutableMap<VKey<? extends Cursor>, Tld> activityKeyMap =
loadKeyMap(registries, CursorType.ICANN_UPLOAD_ACTIVITY); loadKeyMap(registries, CursorType.ICANN_UPLOAD_ACTIVITY);

View file

@ -17,8 +17,8 @@ package google.registry.request;
import static com.google.common.net.MediaType.JSON_UTF_8; import static com.google.common.net.MediaType.JSON_UTF_8;
import static google.registry.dns.PublishDnsUpdatesAction.APP_ENGINE_RETRY_HEADER; import static google.registry.dns.PublishDnsUpdatesAction.APP_ENGINE_RETRY_HEADER;
import static google.registry.dns.PublishDnsUpdatesAction.CLOUD_TASKS_RETRY_HEADER; import static google.registry.dns.PublishDnsUpdatesAction.CLOUD_TASKS_RETRY_HEADER;
import static google.registry.model.tld.Registries.assertTldExists; import static google.registry.model.tld.Tlds.assertTldExists;
import static google.registry.model.tld.Registries.assertTldsExist; import static google.registry.model.tld.Tlds.assertTldsExist;
import static google.registry.request.RequestParameters.extractOptionalHeader; import static google.registry.request.RequestParameters.extractOptionalHeader;
import static google.registry.request.RequestParameters.extractRequiredParameter; import static google.registry.request.RequestParameters.extractRequiredParameter;
import static google.registry.request.RequestParameters.extractSetOfParameters; import static google.registry.request.RequestParameters.extractSetOfParameters;

View file

@ -14,7 +14,7 @@
package google.registry.tools; package google.registry.tools;
import static google.registry.model.tld.Registries.assertTldsExist; import static google.registry.model.tld.Tlds.assertTldsExist;
import static google.registry.persistence.transaction.QueryComposer.Comparator; import static google.registry.persistence.transaction.QueryComposer.Comparator;
import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.persistence.transaction.TransactionManagerFactory.tm;

View file

@ -16,7 +16,7 @@ package google.registry.tools;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Strings.isNullOrEmpty; import static com.google.common.base.Strings.isNullOrEmpty;
import static google.registry.model.tld.Registries.findTldForNameOrThrow; import static google.registry.model.tld.Tlds.findTldForNameOrThrow;
import static google.registry.pricing.PricingEngineProxy.getDomainCreateCost; import static google.registry.pricing.PricingEngineProxy.getDomainCreateCost;
import static google.registry.util.StringGenerator.DEFAULT_PASSWORD_LENGTH; import static google.registry.util.StringGenerator.DEFAULT_PASSWORD_LENGTH;
import static org.joda.time.DateTimeZone.UTC; import static org.joda.time.DateTimeZone.UTC;

View file

@ -28,10 +28,10 @@ import com.google.common.collect.ImmutableSortedMap;
import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.ImmutableSortedSet;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import google.registry.model.pricing.StaticPremiumListPricingEngine; import google.registry.model.pricing.StaticPremiumListPricingEngine;
import google.registry.model.tld.Registries;
import google.registry.model.tld.Tld; import google.registry.model.tld.Tld;
import google.registry.model.tld.Tld.TldState; import google.registry.model.tld.Tld.TldState;
import google.registry.model.tld.Tld.TldType; import google.registry.model.tld.Tld.TldType;
import google.registry.model.tld.Tlds;
import google.registry.model.tld.label.PremiumList; import google.registry.model.tld.label.PremiumList;
import google.registry.model.tld.label.PremiumListDao; import google.registry.model.tld.label.PremiumListDao;
import google.registry.tldconfig.idn.IdnTableEnum; import google.registry.tldconfig.idn.IdnTableEnum;
@ -459,8 +459,8 @@ abstract class CreateOrUpdateTldCommand extends MutatingCommand {
} finally { } finally {
// Manually reset the cache here so that subsequent commands (e.g. in SetupOteCommand) see // Manually reset the cache here so that subsequent commands (e.g. in SetupOteCommand) see
// the latest version of the data. // the latest version of the data.
// TODO(b/24903801): change all those places to use uncached code paths to get Registries. // TODO(b/24903801): change all those places to use uncached code paths to get TLDs.
Registries.resetCache(); Tlds.resetCache();
} }
} }

View file

@ -15,7 +15,7 @@
package google.registry.tools; package google.registry.tools;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static google.registry.model.tld.Registries.assertTldExists; import static google.registry.model.tld.Tlds.assertTldExists;
import static google.registry.util.ListNamingUtils.convertFilePathToName; import static google.registry.util.ListNamingUtils.convertFilePathToName;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;

View file

@ -15,7 +15,7 @@
package google.registry.tools; package google.registry.tools;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static google.registry.model.tld.Registries.assertTldExists; import static google.registry.model.tld.Tlds.assertTldExists;
import static google.registry.util.ListNamingUtils.convertFilePathToName; import static google.registry.util.ListNamingUtils.convertFilePathToName;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
import static org.joda.time.DateTimeZone.UTC; import static org.joda.time.DateTimeZone.UTC;

View file

@ -16,7 +16,7 @@ package google.registry.tools;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
import static google.registry.model.tld.Registries.getTlds; import static google.registry.model.tld.Tlds.getTlds;
import static google.registry.util.CollectionUtils.nullToEmpty; import static google.registry.util.CollectionUtils.nullToEmpty;
import static google.registry.util.DateTimeUtils.START_OF_TIME; import static google.registry.util.DateTimeUtils.START_OF_TIME;

View file

@ -18,7 +18,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Strings.nullToEmpty; import static com.google.common.base.Strings.nullToEmpty;
import static com.google.common.collect.Maps.filterValues; import static com.google.common.collect.Maps.filterValues;
import static com.google.common.io.Resources.getResource; import static com.google.common.io.Resources.getResource;
import static google.registry.model.tld.Registries.findTldForNameOrThrow; import static google.registry.model.tld.Tlds.findTldForNameOrThrow;
import static google.registry.tools.CommandUtilities.addHeader; import static google.registry.tools.CommandUtilities.addHeader;
import static google.registry.util.DomainNameUtils.canonicalizeHostname; import static google.registry.util.DomainNameUtils.canonicalizeHostname;
import static google.registry.util.PreconditionsUtils.checkArgumentPresent; import static google.registry.util.PreconditionsUtils.checkArgumentPresent;

View file

@ -16,7 +16,7 @@ package google.registry.tools;
import static com.google.common.collect.ImmutableList.toImmutableList; import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.common.io.BaseEncoding.base16; import static com.google.common.io.BaseEncoding.base16;
import static google.registry.model.tld.Registries.assertTldExists; import static google.registry.model.tld.Tlds.assertTldExists;
import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
import static google.registry.util.DateTimeUtils.isBeforeOrAt; import static google.registry.util.DateTimeUtils.isBeforeOrAt;
import static java.nio.charset.StandardCharsets.US_ASCII; import static java.nio.charset.StandardCharsets.US_ASCII;

View file

@ -14,7 +14,7 @@
package google.registry.tools; package google.registry.tools;
import static google.registry.model.tld.Registries.assertTldsExist; import static google.registry.model.tld.Tlds.assertTldsExist;
import static google.registry.rde.RdeModule.PARAM_DIRECTORY; import static google.registry.rde.RdeModule.PARAM_DIRECTORY;
import static google.registry.rde.RdeModule.PARAM_LENIENT; import static google.registry.rde.RdeModule.PARAM_LENIENT;
import static google.registry.rde.RdeModule.PARAM_MANUAL; import static google.registry.rde.RdeModule.PARAM_MANUAL;

View file

@ -14,7 +14,7 @@
package google.registry.tools; package google.registry.tools;
import static google.registry.model.tld.Registries.assertTldsExist; import static google.registry.model.tld.Tlds.assertTldsExist;
import static org.joda.time.DateTimeZone.UTC; import static org.joda.time.DateTimeZone.UTC;
import static org.joda.time.Duration.standardMinutes; import static org.joda.time.Duration.standardMinutes;

View file

@ -14,7 +14,7 @@
package google.registry.tools; package google.registry.tools;
import static google.registry.model.tld.Registries.assertTldsExist; import static google.registry.model.tld.Tlds.assertTldsExist;
import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters; import com.beust.jcommander.Parameters;

View file

@ -23,9 +23,9 @@ import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import google.registry.model.common.Cursor; import google.registry.model.common.Cursor;
import google.registry.model.common.Cursor.CursorType; import google.registry.model.common.Cursor.CursorType;
import google.registry.model.tld.Registries;
import google.registry.model.tld.Tld; import google.registry.model.tld.Tld;
import google.registry.model.tld.Tld.TldType; import google.registry.model.tld.Tld.TldType;
import google.registry.model.tld.Tlds;
import google.registry.persistence.VKey; import google.registry.persistence.VKey;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
@ -53,7 +53,7 @@ final class ListCursorsCommand implements Command {
public void run() { public void run() {
Map<String, VKey<Cursor>> cursorKeys = Map<String, VKey<Cursor>> cursorKeys =
cursorType.isScoped() cursorType.isScoped()
? Registries.getTlds().stream() ? Tlds.getTlds().stream()
.map(Tld::get) .map(Tld::get)
.filter(r -> r.getTldType() == filterTldType) .filter(r -> r.getTldType() == filterTldType)
.filter(r -> !filterEscrowEnabled || r.getEscrowEnabled()) .filter(r -> !filterEscrowEnabled || r.getEscrowEnabled())

View file

@ -15,7 +15,7 @@
package google.registry.tools; package google.registry.tools;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static google.registry.model.tld.Registries.getTldsOfType; import static google.registry.model.tld.Tlds.getTldsOfType;
import static google.registry.util.CollectionUtils.isNullOrEmpty; import static google.registry.util.CollectionUtils.isNullOrEmpty;
import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameter;

View file

@ -20,7 +20,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.net.MediaType; import com.google.common.net.MediaType;
import google.registry.loadtest.LoadTestAction; import google.registry.loadtest.LoadTestAction;
import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar;
import google.registry.model.tld.Registries; import google.registry.model.tld.Tlds;
/** Command to initiate a load-test. */ /** Command to initiate a load-test. */
@Parameters(separators = " =", commandDescription = "Run a load test.") @Parameters(separators = " =", commandDescription = "Run a load test.")
@ -91,7 +91,7 @@ class LoadTestCommand extends ConfirmingCommand implements CommandWithConnection
} }
// Check validity of TLD and Client Id. // Check validity of TLD and Client Id.
if (!Registries.getTlds().contains(tld)) { if (!Tlds.getTlds().contains(tld)) {
System.err.printf("No such TLD: %s\n", tld); System.err.printf("No such TLD: %s\n", tld);
return false; return false;
} }

View file

@ -18,7 +18,7 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.collect.Sets.difference; import static com.google.common.collect.Sets.difference;
import static com.google.common.collect.Sets.intersection; import static com.google.common.collect.Sets.intersection;
import static com.google.common.collect.Sets.union; import static com.google.common.collect.Sets.union;
import static google.registry.model.tld.Registries.assertTldExists; import static google.registry.model.tld.Tlds.assertTldExists;
import static google.registry.util.CollectionUtils.nullToEmpty; import static google.registry.util.CollectionUtils.nullToEmpty;
import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameter;

View file

@ -16,7 +16,7 @@ package google.registry.tools.server;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.collect.ImmutableList.toImmutableList; import static com.google.common.collect.ImmutableList.toImmutableList;
import static google.registry.model.tld.Registries.assertTldsExist; import static google.registry.model.tld.Tlds.assertTldsExist;
import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
import static google.registry.request.Action.Method.GET; import static google.registry.request.Action.Method.GET;
import static google.registry.request.Action.Method.POST; import static google.registry.request.Action.Method.POST;

View file

@ -15,7 +15,7 @@
package google.registry.tools.server; package google.registry.tools.server;
import static com.google.common.collect.ImmutableSet.toImmutableSet; import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static google.registry.model.tld.Registries.getTlds; import static google.registry.model.tld.Tlds.getTlds;
import static google.registry.request.Action.Method.GET; import static google.registry.request.Action.Method.GET;
import static google.registry.request.Action.Method.POST; import static google.registry.request.Action.Method.POST;

View file

@ -16,7 +16,7 @@ package google.registry.tools.server;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static google.registry.dns.DnsUtils.requestDomainDnsRefresh; import static google.registry.dns.DnsUtils.requestDomainDnsRefresh;
import static google.registry.model.tld.Registries.assertTldsExist; import static google.registry.model.tld.Tlds.assertTldsExist;
import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
import static google.registry.request.RequestParameters.PARAM_TLDS; import static google.registry.request.RequestParameters.PARAM_TLDS;

View file

@ -15,8 +15,8 @@
package google.registry.whois; package google.registry.whois;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static google.registry.model.tld.Registries.findTldForName; import static google.registry.model.tld.Tlds.findTldForName;
import static google.registry.model.tld.Registries.getTlds; import static google.registry.model.tld.Tlds.getTlds;
import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND; import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;

View file

@ -25,7 +25,7 @@ import com.google.common.collect.Streams;
import com.google.common.net.InetAddresses; import com.google.common.net.InetAddresses;
import com.google.common.net.InternetDomainName; import com.google.common.net.InternetDomainName;
import google.registry.model.host.Host; import google.registry.model.host.Host;
import google.registry.model.tld.Registries; import google.registry.model.tld.Tlds;
import java.net.InetAddress; import java.net.InetAddress;
import org.joda.time.DateTime; import org.joda.time.DateTime;
@ -72,8 +72,7 @@ final class NameserverLookupByIpCommand implements WhoisCommand {
Streams.stream(hostsFromDb) Streams.stream(hostsFromDb)
.filter( .filter(
host -> host ->
Registries.findTldForName(InternetDomainName.from(host.getHostName())) Tlds.findTldForName(InternetDomainName.from(host.getHostName())).isPresent())
.isPresent())
.collect(toImmutableList()); .collect(toImmutableList());
if (hosts.isEmpty()) { if (hosts.isEmpty()) {
throw new WhoisException(now, SC_NOT_FOUND, "No nameservers found."); throw new WhoisException(now, SC_NOT_FOUND, "No nameservers found.");

View file

@ -16,7 +16,7 @@ package google.registry.whois;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Strings.isNullOrEmpty; import static com.google.common.base.Strings.isNullOrEmpty;
import static google.registry.model.tld.Registries.findTldForName; import static google.registry.model.tld.Tlds.findTldForName;
import static google.registry.util.DomainNameUtils.canonicalizeHostname; import static google.registry.util.DomainNameUtils.canonicalizeHostname;
import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST; import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;

View file

@ -42,9 +42,9 @@ import google.registry.config.RegistryConfig;
import google.registry.model.EntityTestCase; import google.registry.model.EntityTestCase;
import google.registry.model.registrar.Registrar.State; import google.registry.model.registrar.Registrar.State;
import google.registry.model.registrar.Registrar.Type; import google.registry.model.registrar.Registrar.Type;
import google.registry.model.tld.Registries;
import google.registry.model.tld.Tld; import google.registry.model.tld.Tld;
import google.registry.model.tld.Tld.TldType; import google.registry.model.tld.Tld.TldType;
import google.registry.model.tld.Tlds;
import google.registry.util.CidrAddressBlock; import google.registry.util.CidrAddressBlock;
import google.registry.util.SerializeUtils; import google.registry.util.SerializeUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -603,14 +603,14 @@ class RegistrarTest extends EntityTestCase {
// Cache duration in tests is 0. To make sure the data isn't in the cache we have to set it // Cache duration in tests is 0. To make sure the data isn't in the cache we have to set it
// to a higher value and reset the cache. // to a higher value and reset the cache.
RegistryConfig.CONFIG_SETTINGS.get().caching.singletonCacheRefreshSeconds = 600; RegistryConfig.CONFIG_SETTINGS.get().caching.singletonCacheRefreshSeconds = 600;
Registries.resetCache(); Tlds.resetCache();
// Make sure the TLD we want to create doesn't exist yet. // Make sure the TLD we want to create doesn't exist yet.
// This is also important because getTlds fills out the cache when used. // This is also important because getTlds fills out the cache when used.
assertThat(Registries.getTlds()).doesNotContain("newtld"); assertThat(Tlds.getTlds()).doesNotContain("newtld");
// We can't use createTld here because it fails when the cache is used. // We can't use createTld here because it fails when the cache is used.
persistResource(newTld("newtld", "NEWTLD")); persistResource(newTld("newtld", "NEWTLD"));
// Make sure we set up the cache correctly, so the newly created TLD isn't in the cache // Make sure we set up the cache correctly, so the newly created TLD isn't in the cache
assertThat(Registries.getTlds()).doesNotContain("newtld"); assertThat(Tlds.getTlds()).doesNotContain("newtld");
// Test that the uncached version works // Test that the uncached version works
assertThat( assertThat(
@ -633,11 +633,11 @@ class RegistrarTest extends EntityTestCase {
// Make sure the cache hasn't expired during the test and "newtld" is still not in the cached // Make sure the cache hasn't expired during the test and "newtld" is still not in the cached
// TLDs // TLDs
assertThat(Registries.getTlds()).doesNotContain("newtld"); assertThat(Tlds.getTlds()).doesNotContain("newtld");
} finally { } finally {
RegistryConfig.CONFIG_SETTINGS.get().caching.singletonCacheRefreshSeconds = RegistryConfig.CONFIG_SETTINGS.get().caching.singletonCacheRefreshSeconds =
origSingletonCacheRefreshSeconds; origSingletonCacheRefreshSeconds;
Registries.resetCache(); Tlds.resetCache();
} }
} }

View file

@ -28,8 +28,8 @@ import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationT
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.extension.RegisterExtension;
/** Unit tests for {@link Registries}. */ /** Unit tests for {@link Tlds}. */
class RegistriesTest { class TldsTest {
@RegisterExtension @RegisterExtension
final JpaIntegrationTestExtension jpa = final JpaIntegrationTestExtension jpa =
@ -42,51 +42,51 @@ class RegistriesTest {
@Test @Test
void testGetTlds() { void testGetTlds() {
initTestTlds(); initTestTlds();
assertThat(Registries.getTlds()).containsExactly("foo", "a.b.c"); assertThat(Tlds.getTlds()).containsExactly("foo", "a.b.c");
} }
@Test @Test
void test_getTldEntities() { void test_getTldEntities() {
initTestTlds(); initTestTlds();
persistResource(newTld("testtld", "TESTTLD").asBuilder().setTldType(TldType.TEST).build()); persistResource(newTld("testtld", "TESTTLD").asBuilder().setTldType(TldType.TEST).build());
assertThat(Registries.getTldEntitiesOfType(TldType.REAL)) assertThat(Tlds.getTldEntitiesOfType(TldType.REAL))
.containsExactly(Tld.get("foo"), Tld.get("a.b.c")); .containsExactly(Tld.get("foo"), Tld.get("a.b.c"));
assertThat(Registries.getTldEntitiesOfType(TldType.TEST)).containsExactly(Tld.get("testtld")); assertThat(Tlds.getTldEntitiesOfType(TldType.TEST)).containsExactly(Tld.get("testtld"));
} }
@Test @Test
void testGetTlds_withNoRegistriesPersisted_returnsEmptySet() { void testGetTlds_withNoRegistriesPersisted_returnsEmptySet() {
assertThat(Registries.getTlds()).isEmpty(); assertThat(Tlds.getTlds()).isEmpty();
} }
@Test @Test
void testAssertTldExists_doesExist() { void testAssertTldExists_doesExist() {
initTestTlds(); initTestTlds();
Registries.assertTldExists("foo"); Tlds.assertTldExists("foo");
Registries.assertTldExists("a.b.c"); Tlds.assertTldExists("a.b.c");
} }
@Test @Test
void testAssertTldExists_doesntExist() { void testAssertTldExists_doesntExist() {
initTestTlds(); initTestTlds();
assertThrows(IllegalArgumentException.class, () -> Registries.assertTldExists("baz")); assertThrows(IllegalArgumentException.class, () -> Tlds.assertTldExists("baz"));
} }
@Test @Test
void testFindTldForName() { void testFindTldForName() {
initTestTlds(); initTestTlds();
assertThat(Registries.findTldForName(InternetDomainName.from("example.foo")).get().toString()) assertThat(Tlds.findTldForName(InternetDomainName.from("example.foo")).get().toString())
.isEqualTo("foo"); .isEqualTo("foo");
assertThat(Registries.findTldForName(InternetDomainName.from("x.y.a.b.c")).get().toString()) assertThat(Tlds.findTldForName(InternetDomainName.from("x.y.a.b.c")).get().toString())
.isEqualTo("a.b.c"); .isEqualTo("a.b.c");
// We don't have an "example" tld. // We don't have an "example" tld.
assertThat(Registries.findTldForName(InternetDomainName.from("foo.example"))).isEmpty(); assertThat(Tlds.findTldForName(InternetDomainName.from("foo.example"))).isEmpty();
// A tld is not a match for itself. // A tld is not a match for itself.
assertThat(Registries.findTldForName(InternetDomainName.from("foo"))).isEmpty(); assertThat(Tlds.findTldForName(InternetDomainName.from("foo"))).isEmpty();
// The name must match the entire tld. // The name must match the entire tld.
assertThat(Registries.findTldForName(InternetDomainName.from("x.y.a.b"))).isEmpty(); assertThat(Tlds.findTldForName(InternetDomainName.from("x.y.a.b"))).isEmpty();
assertThat(Registries.findTldForName(InternetDomainName.from("x.y.b.c"))).isEmpty(); assertThat(Tlds.findTldForName(InternetDomainName.from("x.y.b.c"))).isEmpty();
// Substring tld matches aren't considered. // Substring tld matches aren't considered.
assertThat(Registries.findTldForName(InternetDomainName.from("example.barfoo"))).isEmpty(); assertThat(Tlds.findTldForName(InternetDomainName.from("example.barfoo"))).isEmpty();
} }
} }

View file

@ -19,7 +19,7 @@ import static com.google.common.truth.Truth8.assertThat;
import static google.registry.model.EppResourceUtils.loadByForeignKeyCached; import static google.registry.model.EppResourceUtils.loadByForeignKeyCached;
import static google.registry.model.registrar.Registrar.State.ACTIVE; import static google.registry.model.registrar.Registrar.State.ACTIVE;
import static google.registry.model.registrar.Registrar.Type.PDT; import static google.registry.model.registrar.Registrar.Type.PDT;
import static google.registry.model.tld.Registries.getTlds; import static google.registry.model.tld.Tlds.getTlds;
import static google.registry.testing.DatabaseHelper.createTlds; import static google.registry.testing.DatabaseHelper.createTlds;
import static google.registry.testing.DatabaseHelper.loadRegistrar; import static google.registry.testing.DatabaseHelper.loadRegistrar;
import static google.registry.testing.DatabaseHelper.persistActiveDomain; import static google.registry.testing.DatabaseHelper.persistActiveDomain;

View file

@ -58,8 +58,8 @@ public final class DomainNameUtils {
* <p>This function is compatible with multi-part tlds, e.g. {@code co.uk}. This function will * <p>This function is compatible with multi-part tlds, e.g. {@code co.uk}. This function will
* also work on domains for which the registry is not authoritative. If you are certain that the * also work on domains for which the registry is not authoritative. If you are certain that the
* input will be under a TLD this registry controls, then it is preferable to use {@link * input will be under a TLD this registry controls, then it is preferable to use {@link
* google.registry.model.tld.Registries#findTldForName(InternetDomainName) * google.registry.model.tld.Tlds#findTldForName(InternetDomainName) Registries#findTldForName},
* Registries#findTldForName}, which will work on hostnames in addition to domains. * which will work on hostnames in addition to domains.
* *
* @param domainName must be a punycode SLD (not a host or unicode) * @param domainName must be a punycode SLD (not a host or unicode)
* @throws IllegalArgumentException if there is no TLD * @throws IllegalArgumentException if there is no TLD