diff --git a/core/src/main/java/google/registry/batch/DeleteProberDataAction.java b/core/src/main/java/google/registry/batch/DeleteProberDataAction.java index 07804924f..d5fabeb3c 100644 --- a/core/src/main/java/google/registry/batch/DeleteProberDataAction.java +++ b/core/src/main/java/google/registry/batch/DeleteProberDataAction.java @@ -21,7 +21,7 @@ import static google.registry.batch.BatchModule.PARAM_DRY_RUN; import static google.registry.config.RegistryEnvironment.PRODUCTION; import static google.registry.dns.DnsUtils.requestDomainDnsRefresh; 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.request.Action.Method.POST; import static google.registry.request.RequestParameters.PARAM_TLDS; diff --git a/core/src/main/java/google/registry/cron/TldFanoutAction.java b/core/src/main/java/google/registry/cron/TldFanoutAction.java index 709e76663..73733b955 100644 --- a/core/src/main/java/google/registry/cron/TldFanoutAction.java +++ b/core/src/main/java/google/registry/cron/TldFanoutAction.java @@ -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.QUEUE_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.TEST; +import static google.registry.model.tld.Tlds.getTldsOfType; import com.google.cloud.tasks.v2.Task; import com.google.common.collect.ArrayListMultimap; diff --git a/core/src/main/java/google/registry/dns/DnsUtils.java b/core/src/main/java/google/registry/dns/DnsUtils.java index 9652798e1..eb6793856 100644 --- a/core/src/main/java/google/registry/dns/DnsUtils.java +++ b/core/src/main/java/google/registry/dns/DnsUtils.java @@ -20,8 +20,8 @@ import static google.registry.persistence.transaction.TransactionManagerFactory. import com.google.common.collect.ImmutableList; import com.google.common.net.InternetDomainName; import google.registry.model.common.DnsRefreshRequest; -import google.registry.model.tld.Registries; import google.registry.model.tld.Tld; +import google.registry.model.tld.Tlds; import java.util.Collection; import java.util.Optional; import org.joda.time.DateTime; @@ -38,7 +38,7 @@ public final class DnsUtils { 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 // 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().insert( @@ -114,7 +114,7 @@ public final class DnsUtils { } public static long getDnsAPlusAAAATtlForHost(String host, Duration dnsDefaultATtl) { - Optional tldName = Registries.findTldForName(InternetDomainName.from(host)); + Optional tldName = Tlds.findTldForName(InternetDomainName.from(host)); Duration dnsAPlusAaaaTtl = dnsDefaultATtl; if (tldName.isPresent()) { Tld tld = Tld.get(tldName.get().toString()); diff --git a/core/src/main/java/google/registry/dns/writer/clouddns/CloudDnsWriter.java b/core/src/main/java/google/registry/dns/writer/clouddns/CloudDnsWriter.java index b449359de..4d2aa8a5c 100644 --- a/core/src/main/java/google/registry/dns/writer/clouddns/CloudDnsWriter.java +++ b/core/src/main/java/google/registry/dns/writer/clouddns/CloudDnsWriter.java @@ -40,8 +40,8 @@ import google.registry.dns.writer.DnsWriterZone; import google.registry.model.domain.Domain; import google.registry.model.domain.secdns.DomainDsData; import google.registry.model.host.Host; -import google.registry.model.tld.Registries; import google.registry.model.tld.Tld; +import google.registry.model.tld.Tlds; import google.registry.util.Clock; import google.registry.util.Concurrent; import google.registry.util.Retrier; @@ -248,7 +248,7 @@ public class CloudDnsWriter extends BaseDnsWriter { public void publishHost(String hostName) { // Get the superordinate domain name of the host. InternetDomainName host = InternetDomainName.from(hostName); - Optional tld = Registries.findTldForName(host); + Optional tld = Tlds.findTldForName(host); // Host not managed by our registry, no need to update DNS. if (!tld.isPresent()) { diff --git a/core/src/main/java/google/registry/dns/writer/dnsupdate/DnsUpdateWriter.java b/core/src/main/java/google/registry/dns/writer/dnsupdate/DnsUpdateWriter.java index e02f9142c..9337dd8b2 100644 --- a/core/src/main/java/google/registry/dns/writer/dnsupdate/DnsUpdateWriter.java +++ b/core/src/main/java/google/registry/dns/writer/dnsupdate/DnsUpdateWriter.java @@ -31,8 +31,8 @@ import google.registry.dns.writer.DnsWriterZone; import google.registry.model.domain.Domain; import google.registry.model.domain.secdns.DomainDsData; import google.registry.model.host.Host; -import google.registry.model.tld.Registries; import google.registry.model.tld.Tld; +import google.registry.model.tld.Tlds; import google.registry.util.Clock; import java.io.IOException; import java.net.Inet4Address; @@ -154,7 +154,7 @@ public class DnsUpdateWriter extends BaseDnsWriter { // Get the superordinate domain name of the host. InternetDomainName host = InternetDomainName.from(hostName); ImmutableList hostParts = host.parts(); - Optional tld = Registries.findTldForName(host); + Optional tld = Tlds.findTldForName(host); // host not managed by our registry, no need to update DNS. if (!tld.isPresent()) { diff --git a/core/src/main/java/google/registry/export/ExportDomainListsAction.java b/core/src/main/java/google/registry/export/ExportDomainListsAction.java index 7d669261f..dca294617 100644 --- a/core/src/main/java/google/registry/export/ExportDomainListsAction.java +++ b/core/src/main/java/google/registry/export/ExportDomainListsAction.java @@ -15,7 +15,7 @@ package google.registry.export; 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.request.Action.Method.POST; import static java.nio.charset.StandardCharsets.UTF_8; diff --git a/core/src/main/java/google/registry/flows/domain/DomainFlowUtils.java b/core/src/main/java/google/registry/flows/domain/DomainFlowUtils.java index 71dfc302b..1a1e7c486 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainFlowUtils.java +++ b/core/src/main/java/google/registry/flows/domain/DomainFlowUtils.java @@ -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.union; 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.PREDELEGATION; 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.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.FULLY_BLOCKED; import static google.registry.model.tld.label.ReservationType.NAME_COLLISION; diff --git a/core/src/main/java/google/registry/flows/host/HostFlowUtils.java b/core/src/main/java/google/registry/flows/host/HostFlowUtils.java index 6ae5ba50e..f38eb252b 100644 --- a/core/src/main/java/google/registry/flows/host/HostFlowUtils.java +++ b/core/src/main/java/google/registry/flows/host/HostFlowUtils.java @@ -16,7 +16,7 @@ package google.registry.flows.host; import static google.registry.model.EppResourceUtils.isActive; 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 java.util.stream.Collectors.joining; diff --git a/core/src/main/java/google/registry/model/registrar/Registrar.java b/core/src/main/java/google/registry/model/registrar/Registrar.java index 5a55f0144..e7ec521c1 100644 --- a/core/src/main/java/google/registry/model/registrar/Registrar.java +++ b/core/src/main/java/google/registry/model/registrar/Registrar.java @@ -26,7 +26,7 @@ import static com.google.common.collect.Sets.immutableEnumSet; import static com.google.common.io.BaseEncoding.base64; import static google.registry.config.RegistryConfig.getDefaultRegistrarWhoisServer; 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.util.CollectionUtils.nullToEmptyImmutableCopy; import static google.registry.util.CollectionUtils.nullToEmptyImmutableSortedCopy; diff --git a/core/src/main/java/google/registry/model/tld/Registries.java b/core/src/main/java/google/registry/model/tld/Tlds.java similarity index 95% rename from core/src/main/java/google/registry/model/tld/Registries.java rename to core/src/main/java/google/registry/model/tld/Tlds.java index 8d40a87fb..4aea66fdc 100644 --- a/core/src/main/java/google/registry/model/tld/Registries.java +++ b/core/src/main/java/google/registry/model/tld/Tlds.java @@ -40,15 +40,15 @@ import java.util.stream.Stream; import javax.persistence.EntityManager; /** 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> cache = createFreshCache(); /** - * Returns a newly-created Supplier of a registries to types map. + * Returns a newly-created Supplier of a TLDs to types map. * *

The supplier's get() method enters a transactionless context briefly to avoid enrolling the * query inside an unrelated client-affecting transaction. @@ -84,7 +84,7 @@ public final class Registries { 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 getTldEntitiesOfType(TldType type) { return Tld.get(filterValues(cache.get(), equalTo(type)).keySet()); } diff --git a/core/src/main/java/google/registry/model/tld/label/BaseDomainLabelList.java b/core/src/main/java/google/registry/model/tld/label/BaseDomainLabelList.java index c8af606aa..97dcd1547 100644 --- a/core/src/main/java/google/registry/model/tld/label/BaseDomainLabelList.java +++ b/core/src/main/java/google/registry/model/tld/label/BaseDomainLabelList.java @@ -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.Strings.isNullOrEmpty; 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.ImmutableList; diff --git a/core/src/main/java/google/registry/monitoring/whitebox/EppMetric.java b/core/src/main/java/google/registry/monitoring/whitebox/EppMetric.java index cdcd0551c..2b6c3db60 100644 --- a/core/src/main/java/google/registry/monitoring/whitebox/EppMetric.java +++ b/core/src/main/java/google/registry/monitoring/whitebox/EppMetric.java @@ -20,7 +20,7 @@ import com.google.auto.value.AutoValue; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; 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 java.util.Optional; import org.joda.time.DateTime; @@ -104,7 +104,7 @@ public abstract class EppMetric { String tld = Iterables.getOnlyElement(tlds); // Only record TLDs that actually exist, otherwise we can blow up cardinality by recording // 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; default: setTld("_various"); diff --git a/core/src/main/java/google/registry/rde/PendingDepositChecker.java b/core/src/main/java/google/registry/rde/PendingDepositChecker.java index 3ac8849fa..406bc4746 100644 --- a/core/src/main/java/google/registry/rde/PendingDepositChecker.java +++ b/core/src/main/java/google/registry/rde/PendingDepositChecker.java @@ -23,9 +23,9 @@ import google.registry.config.RegistryConfig.Config; import google.registry.model.common.Cursor; import google.registry.model.common.Cursor.CursorType; import google.registry.model.rde.RdeMode; -import google.registry.model.tld.Registries; import google.registry.model.tld.Tld; import google.registry.model.tld.Tld.TldType; +import google.registry.model.tld.Tlds; import google.registry.util.Clock; import java.util.Optional; import javax.inject.Inject; @@ -83,7 +83,7 @@ public final class PendingDepositChecker { ImmutableSetMultimap.Builder builder = new ImmutableSetMultimap.Builder<>(); DateTime now = clock.nowUtc(); - for (String tldStr : Registries.getTldsOfType(TldType.REAL)) { + for (String tldStr : Tlds.getTldsOfType(TldType.REAL)) { Tld tld = Tld.get(tldStr); if (!tld.getEscrowEnabled()) { continue; diff --git a/core/src/main/java/google/registry/reporting/icann/IcannHttpReporter.java b/core/src/main/java/google/registry/reporting/icann/IcannHttpReporter.java index 701624f6c..b1b97b9cb 100644 --- a/core/src/main/java/google/registry/reporting/icann/IcannHttpReporter.java +++ b/core/src/main/java/google/registry/reporting/icann/IcannHttpReporter.java @@ -16,7 +16,7 @@ package google.registry.reporting.icann; import static com.google.common.base.Preconditions.checkArgument; 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 com.google.api.client.http.ByteArrayContent; diff --git a/core/src/main/java/google/registry/reporting/icann/IcannReportingUploadAction.java b/core/src/main/java/google/registry/reporting/icann/IcannReportingUploadAction.java index 614a2f01c..1c73cf64f 100644 --- a/core/src/main/java/google/registry/reporting/icann/IcannReportingUploadAction.java +++ b/core/src/main/java/google/registry/reporting/icann/IcannReportingUploadAction.java @@ -29,9 +29,9 @@ import google.registry.config.RegistryConfig.Config; import google.registry.gcs.GcsUtils; import google.registry.model.common.Cursor; 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.TldType; +import google.registry.model.tld.Tlds; import google.registry.persistence.VKey; import google.registry.request.Action; 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. */ private ImmutableMap loadCursors() { - ImmutableSet registries = Registries.getTldEntitiesOfType(TldType.REAL); + ImmutableSet registries = Tlds.getTldEntitiesOfType(TldType.REAL); ImmutableMap, Tld> activityKeyMap = loadKeyMap(registries, CursorType.ICANN_UPLOAD_ACTIVITY); diff --git a/core/src/main/java/google/registry/request/RequestModule.java b/core/src/main/java/google/registry/request/RequestModule.java index ceb915c63..175ff845e 100644 --- a/core/src/main/java/google/registry/request/RequestModule.java +++ b/core/src/main/java/google/registry/request/RequestModule.java @@ -17,8 +17,8 @@ package google.registry.request; 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.CLOUD_TASKS_RETRY_HEADER; -import static google.registry.model.tld.Registries.assertTldExists; -import static google.registry.model.tld.Registries.assertTldsExist; +import static google.registry.model.tld.Tlds.assertTldExists; +import static google.registry.model.tld.Tlds.assertTldsExist; import static google.registry.request.RequestParameters.extractOptionalHeader; import static google.registry.request.RequestParameters.extractRequiredParameter; import static google.registry.request.RequestParameters.extractSetOfParameters; diff --git a/core/src/main/java/google/registry/tools/CountDomainsCommand.java b/core/src/main/java/google/registry/tools/CountDomainsCommand.java index 0b5ff65a1..880449c70 100644 --- a/core/src/main/java/google/registry/tools/CountDomainsCommand.java +++ b/core/src/main/java/google/registry/tools/CountDomainsCommand.java @@ -14,7 +14,7 @@ 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.TransactionManagerFactory.tm; diff --git a/core/src/main/java/google/registry/tools/CreateAnchorTenantCommand.java b/core/src/main/java/google/registry/tools/CreateAnchorTenantCommand.java index 9e2ef5b35..72ae9ba86 100644 --- a/core/src/main/java/google/registry/tools/CreateAnchorTenantCommand.java +++ b/core/src/main/java/google/registry/tools/CreateAnchorTenantCommand.java @@ -16,7 +16,7 @@ package google.registry.tools; import static com.google.common.base.Preconditions.checkArgument; 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.util.StringGenerator.DEFAULT_PASSWORD_LENGTH; import static org.joda.time.DateTimeZone.UTC; diff --git a/core/src/main/java/google/registry/tools/CreateOrUpdateTldCommand.java b/core/src/main/java/google/registry/tools/CreateOrUpdateTldCommand.java index d6b9ca477..ecce2e6cc 100644 --- a/core/src/main/java/google/registry/tools/CreateOrUpdateTldCommand.java +++ b/core/src/main/java/google/registry/tools/CreateOrUpdateTldCommand.java @@ -28,10 +28,10 @@ import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.Sets; import google.registry.model.pricing.StaticPremiumListPricingEngine; -import google.registry.model.tld.Registries; import google.registry.model.tld.Tld; import google.registry.model.tld.Tld.TldState; 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.PremiumListDao; import google.registry.tldconfig.idn.IdnTableEnum; @@ -459,8 +459,8 @@ abstract class CreateOrUpdateTldCommand extends MutatingCommand { } finally { // Manually reset the cache here so that subsequent commands (e.g. in SetupOteCommand) see // the latest version of the data. - // TODO(b/24903801): change all those places to use uncached code paths to get Registries. - Registries.resetCache(); + // TODO(b/24903801): change all those places to use uncached code paths to get TLDs. + Tlds.resetCache(); } } diff --git a/core/src/main/java/google/registry/tools/CreatePremiumListCommand.java b/core/src/main/java/google/registry/tools/CreatePremiumListCommand.java index 02b906b63..84c742ea9 100644 --- a/core/src/main/java/google/registry/tools/CreatePremiumListCommand.java +++ b/core/src/main/java/google/registry/tools/CreatePremiumListCommand.java @@ -15,7 +15,7 @@ package google.registry.tools; 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 java.nio.charset.StandardCharsets.UTF_8; diff --git a/core/src/main/java/google/registry/tools/CreateReservedListCommand.java b/core/src/main/java/google/registry/tools/CreateReservedListCommand.java index 5079aa09f..e25bf2c25 100644 --- a/core/src/main/java/google/registry/tools/CreateReservedListCommand.java +++ b/core/src/main/java/google/registry/tools/CreateReservedListCommand.java @@ -15,7 +15,7 @@ package google.registry.tools; 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 java.nio.charset.StandardCharsets.UTF_8; import static org.joda.time.DateTimeZone.UTC; diff --git a/core/src/main/java/google/registry/tools/CreateTldCommand.java b/core/src/main/java/google/registry/tools/CreateTldCommand.java index 56e6b8b2f..46e92fd29 100644 --- a/core/src/main/java/google/registry/tools/CreateTldCommand.java +++ b/core/src/main/java/google/registry/tools/CreateTldCommand.java @@ -16,7 +16,7 @@ package google.registry.tools; import static com.google.common.base.Preconditions.checkArgument; 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.DateTimeUtils.START_OF_TIME; diff --git a/core/src/main/java/google/registry/tools/EppToolCommand.java b/core/src/main/java/google/registry/tools/EppToolCommand.java index 88ecfbc3e..a7ca8dcd3 100644 --- a/core/src/main/java/google/registry/tools/EppToolCommand.java +++ b/core/src/main/java/google/registry/tools/EppToolCommand.java @@ -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.collect.Maps.filterValues; 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.util.DomainNameUtils.canonicalizeHostname; import static google.registry.util.PreconditionsUtils.checkArgumentPresent; diff --git a/core/src/main/java/google/registry/tools/GenerateDnsReportCommand.java b/core/src/main/java/google/registry/tools/GenerateDnsReportCommand.java index 262ef4b37..8bed1eaeb 100644 --- a/core/src/main/java/google/registry/tools/GenerateDnsReportCommand.java +++ b/core/src/main/java/google/registry/tools/GenerateDnsReportCommand.java @@ -16,7 +16,7 @@ package google.registry.tools; import static com.google.common.collect.ImmutableList.toImmutableList; 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.util.DateTimeUtils.isBeforeOrAt; import static java.nio.charset.StandardCharsets.US_ASCII; diff --git a/core/src/main/java/google/registry/tools/GenerateEscrowDepositCommand.java b/core/src/main/java/google/registry/tools/GenerateEscrowDepositCommand.java index b62f34b46..320a78920 100644 --- a/core/src/main/java/google/registry/tools/GenerateEscrowDepositCommand.java +++ b/core/src/main/java/google/registry/tools/GenerateEscrowDepositCommand.java @@ -14,7 +14,7 @@ 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_LENIENT; import static google.registry.rde.RdeModule.PARAM_MANUAL; diff --git a/core/src/main/java/google/registry/tools/GenerateZoneFilesCommand.java b/core/src/main/java/google/registry/tools/GenerateZoneFilesCommand.java index 908ff783d..b08ca56f4 100644 --- a/core/src/main/java/google/registry/tools/GenerateZoneFilesCommand.java +++ b/core/src/main/java/google/registry/tools/GenerateZoneFilesCommand.java @@ -14,7 +14,7 @@ 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.Duration.standardMinutes; diff --git a/core/src/main/java/google/registry/tools/GetTldCommand.java b/core/src/main/java/google/registry/tools/GetTldCommand.java index 6a8c979d7..fa8fa0b49 100644 --- a/core/src/main/java/google/registry/tools/GetTldCommand.java +++ b/core/src/main/java/google/registry/tools/GetTldCommand.java @@ -14,7 +14,7 @@ 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.Parameters; diff --git a/core/src/main/java/google/registry/tools/ListCursorsCommand.java b/core/src/main/java/google/registry/tools/ListCursorsCommand.java index 15e2e81e0..a34e1c84a 100644 --- a/core/src/main/java/google/registry/tools/ListCursorsCommand.java +++ b/core/src/main/java/google/registry/tools/ListCursorsCommand.java @@ -23,9 +23,9 @@ import com.google.common.base.Strings; import com.google.common.collect.ImmutableMap; import google.registry.model.common.Cursor; 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.TldType; +import google.registry.model.tld.Tlds; import google.registry.persistence.VKey; import java.util.Map; import java.util.Optional; @@ -53,7 +53,7 @@ final class ListCursorsCommand implements Command { public void run() { Map> cursorKeys = cursorType.isScoped() - ? Registries.getTlds().stream() + ? Tlds.getTlds().stream() .map(Tld::get) .filter(r -> r.getTldType() == filterTldType) .filter(r -> !filterEscrowEnabled || r.getEscrowEnabled()) diff --git a/core/src/main/java/google/registry/tools/ListDomainsCommand.java b/core/src/main/java/google/registry/tools/ListDomainsCommand.java index 44752aec4..b73298178 100644 --- a/core/src/main/java/google/registry/tools/ListDomainsCommand.java +++ b/core/src/main/java/google/registry/tools/ListDomainsCommand.java @@ -15,7 +15,7 @@ package google.registry.tools; 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 com.beust.jcommander.Parameter; diff --git a/core/src/main/java/google/registry/tools/LoadTestCommand.java b/core/src/main/java/google/registry/tools/LoadTestCommand.java index f47379c04..192f23879 100644 --- a/core/src/main/java/google/registry/tools/LoadTestCommand.java +++ b/core/src/main/java/google/registry/tools/LoadTestCommand.java @@ -20,7 +20,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.net.MediaType; import google.registry.loadtest.LoadTestAction; import google.registry.model.registrar.Registrar; -import google.registry.model.tld.Registries; +import google.registry.model.tld.Tlds; /** Command to initiate 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. - if (!Registries.getTlds().contains(tld)) { + if (!Tlds.getTlds().contains(tld)) { System.err.printf("No such TLD: %s\n", tld); return false; } diff --git a/core/src/main/java/google/registry/tools/UpdateTldCommand.java b/core/src/main/java/google/registry/tools/UpdateTldCommand.java index 4c2137a57..72f4970f5 100644 --- a/core/src/main/java/google/registry/tools/UpdateTldCommand.java +++ b/core/src/main/java/google/registry/tools/UpdateTldCommand.java @@ -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.intersection; 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 com.beust.jcommander.Parameter; diff --git a/core/src/main/java/google/registry/tools/server/ListDomainsAction.java b/core/src/main/java/google/registry/tools/server/ListDomainsAction.java index 83748b365..a74eaba67 100644 --- a/core/src/main/java/google/registry/tools/server/ListDomainsAction.java +++ b/core/src/main/java/google/registry/tools/server/ListDomainsAction.java @@ -16,7 +16,7 @@ package google.registry.tools.server; import static com.google.common.base.Preconditions.checkArgument; 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.request.Action.Method.GET; import static google.registry.request.Action.Method.POST; diff --git a/core/src/main/java/google/registry/tools/server/ListTldsAction.java b/core/src/main/java/google/registry/tools/server/ListTldsAction.java index 2a9cddd63..2dfb29f80 100644 --- a/core/src/main/java/google/registry/tools/server/ListTldsAction.java +++ b/core/src/main/java/google/registry/tools/server/ListTldsAction.java @@ -15,7 +15,7 @@ package google.registry.tools.server; 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.POST; diff --git a/core/src/main/java/google/registry/tools/server/RefreshDnsForAllDomainsAction.java b/core/src/main/java/google/registry/tools/server/RefreshDnsForAllDomainsAction.java index 295945eb0..d4720028d 100644 --- a/core/src/main/java/google/registry/tools/server/RefreshDnsForAllDomainsAction.java +++ b/core/src/main/java/google/registry/tools/server/RefreshDnsForAllDomainsAction.java @@ -16,7 +16,7 @@ package google.registry.tools.server; import static com.google.common.base.Preconditions.checkArgument; 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.request.RequestParameters.PARAM_TLDS; diff --git a/core/src/main/java/google/registry/whois/DomainOrHostLookupCommand.java b/core/src/main/java/google/registry/whois/DomainOrHostLookupCommand.java index fb3ae14cf..fa540c7ee 100644 --- a/core/src/main/java/google/registry/whois/DomainOrHostLookupCommand.java +++ b/core/src/main/java/google/registry/whois/DomainOrHostLookupCommand.java @@ -15,8 +15,8 @@ package google.registry.whois; import static com.google.common.base.Preconditions.checkNotNull; -import static google.registry.model.tld.Registries.findTldForName; -import static google.registry.model.tld.Registries.getTlds; +import static google.registry.model.tld.Tlds.findTldForName; +import static google.registry.model.tld.Tlds.getTlds; import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND; import com.google.common.annotations.VisibleForTesting; diff --git a/core/src/main/java/google/registry/whois/NameserverLookupByIpCommand.java b/core/src/main/java/google/registry/whois/NameserverLookupByIpCommand.java index 06b210db4..dc50b5bc3 100644 --- a/core/src/main/java/google/registry/whois/NameserverLookupByIpCommand.java +++ b/core/src/main/java/google/registry/whois/NameserverLookupByIpCommand.java @@ -25,7 +25,7 @@ import com.google.common.collect.Streams; import com.google.common.net.InetAddresses; import com.google.common.net.InternetDomainName; import google.registry.model.host.Host; -import google.registry.model.tld.Registries; +import google.registry.model.tld.Tlds; import java.net.InetAddress; import org.joda.time.DateTime; @@ -72,8 +72,7 @@ final class NameserverLookupByIpCommand implements WhoisCommand { Streams.stream(hostsFromDb) .filter( host -> - Registries.findTldForName(InternetDomainName.from(host.getHostName())) - .isPresent()) + Tlds.findTldForName(InternetDomainName.from(host.getHostName())).isPresent()) .collect(toImmutableList()); if (hosts.isEmpty()) { throw new WhoisException(now, SC_NOT_FOUND, "No nameservers found."); diff --git a/core/src/main/java/google/registry/whois/WhoisReader.java b/core/src/main/java/google/registry/whois/WhoisReader.java index 095a9d72f..89cbf9f6a 100644 --- a/core/src/main/java/google/registry/whois/WhoisReader.java +++ b/core/src/main/java/google/registry/whois/WhoisReader.java @@ -16,7 +16,7 @@ package google.registry.whois; import static com.google.common.base.Preconditions.checkNotNull; 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 javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST; diff --git a/core/src/test/java/google/registry/model/registrar/RegistrarTest.java b/core/src/test/java/google/registry/model/registrar/RegistrarTest.java index 03c0f6f5b..79b0f905d 100644 --- a/core/src/test/java/google/registry/model/registrar/RegistrarTest.java +++ b/core/src/test/java/google/registry/model/registrar/RegistrarTest.java @@ -42,9 +42,9 @@ import google.registry.config.RegistryConfig; import google.registry.model.EntityTestCase; import google.registry.model.registrar.Registrar.State; 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.TldType; +import google.registry.model.tld.Tlds; import google.registry.util.CidrAddressBlock; import google.registry.util.SerializeUtils; 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 // to a higher value and reset the cache. RegistryConfig.CONFIG_SETTINGS.get().caching.singletonCacheRefreshSeconds = 600; - Registries.resetCache(); + Tlds.resetCache(); // Make sure the TLD we want to create doesn't exist yet. // 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. persistResource(newTld("newtld", "NEWTLD")); // 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 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 // TLDs - assertThat(Registries.getTlds()).doesNotContain("newtld"); + assertThat(Tlds.getTlds()).doesNotContain("newtld"); } finally { RegistryConfig.CONFIG_SETTINGS.get().caching.singletonCacheRefreshSeconds = origSingletonCacheRefreshSeconds; - Registries.resetCache(); + Tlds.resetCache(); } } diff --git a/core/src/test/java/google/registry/model/tld/RegistriesTest.java b/core/src/test/java/google/registry/model/tld/TldsTest.java similarity index 67% rename from core/src/test/java/google/registry/model/tld/RegistriesTest.java rename to core/src/test/java/google/registry/model/tld/TldsTest.java index 7ca166c82..fe5ecebf2 100644 --- a/core/src/test/java/google/registry/model/tld/RegistriesTest.java +++ b/core/src/test/java/google/registry/model/tld/TldsTest.java @@ -28,8 +28,8 @@ import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationT import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -/** Unit tests for {@link Registries}. */ -class RegistriesTest { +/** Unit tests for {@link Tlds}. */ +class TldsTest { @RegisterExtension final JpaIntegrationTestExtension jpa = @@ -42,51 +42,51 @@ class RegistriesTest { @Test void testGetTlds() { initTestTlds(); - assertThat(Registries.getTlds()).containsExactly("foo", "a.b.c"); + assertThat(Tlds.getTlds()).containsExactly("foo", "a.b.c"); } @Test void test_getTldEntities() { initTestTlds(); 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")); - assertThat(Registries.getTldEntitiesOfType(TldType.TEST)).containsExactly(Tld.get("testtld")); + assertThat(Tlds.getTldEntitiesOfType(TldType.TEST)).containsExactly(Tld.get("testtld")); } @Test void testGetTlds_withNoRegistriesPersisted_returnsEmptySet() { - assertThat(Registries.getTlds()).isEmpty(); + assertThat(Tlds.getTlds()).isEmpty(); } @Test void testAssertTldExists_doesExist() { initTestTlds(); - Registries.assertTldExists("foo"); - Registries.assertTldExists("a.b.c"); + Tlds.assertTldExists("foo"); + Tlds.assertTldExists("a.b.c"); } @Test void testAssertTldExists_doesntExist() { initTestTlds(); - assertThrows(IllegalArgumentException.class, () -> Registries.assertTldExists("baz")); + assertThrows(IllegalArgumentException.class, () -> Tlds.assertTldExists("baz")); } @Test void testFindTldForName() { initTestTlds(); - assertThat(Registries.findTldForName(InternetDomainName.from("example.foo")).get().toString()) + assertThat(Tlds.findTldForName(InternetDomainName.from("example.foo")).get().toString()) .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"); // 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. - assertThat(Registries.findTldForName(InternetDomainName.from("foo"))).isEmpty(); + assertThat(Tlds.findTldForName(InternetDomainName.from("foo"))).isEmpty(); // The name must match the entire tld. - assertThat(Registries.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.a.b"))).isEmpty(); + assertThat(Tlds.findTldForName(InternetDomainName.from("x.y.b.c"))).isEmpty(); // Substring tld matches aren't considered. - assertThat(Registries.findTldForName(InternetDomainName.from("example.barfoo"))).isEmpty(); + assertThat(Tlds.findTldForName(InternetDomainName.from("example.barfoo"))).isEmpty(); } } diff --git a/core/src/test/java/google/registry/whois/WhoisActionTest.java b/core/src/test/java/google/registry/whois/WhoisActionTest.java index b2dabca6a..760d4c2c8 100644 --- a/core/src/test/java/google/registry/whois/WhoisActionTest.java +++ b/core/src/test/java/google/registry/whois/WhoisActionTest.java @@ -19,7 +19,7 @@ import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.EppResourceUtils.loadByForeignKeyCached; import static google.registry.model.registrar.Registrar.State.ACTIVE; 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.loadRegistrar; import static google.registry.testing.DatabaseHelper.persistActiveDomain; diff --git a/util/src/main/java/google/registry/util/DomainNameUtils.java b/util/src/main/java/google/registry/util/DomainNameUtils.java index d9b0538fa..aa7beb8dd 100644 --- a/util/src/main/java/google/registry/util/DomainNameUtils.java +++ b/util/src/main/java/google/registry/util/DomainNameUtils.java @@ -58,8 +58,8 @@ public final class DomainNameUtils { *

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 * input will be under a TLD this registry controls, then it is preferable to use {@link - * google.registry.model.tld.Registries#findTldForName(InternetDomainName) - * Registries#findTldForName}, which will work on hostnames in addition to domains. + * google.registry.model.tld.Tlds#findTldForName(InternetDomainName) Registries#findTldForName}, + * which will work on hostnames in addition to domains. * * @param domainName must be a punycode SLD (not a host or unicode) * @throws IllegalArgumentException if there is no TLD