From e2528875b2d35e8cf2123b00e46a8cbbd1216469 Mon Sep 17 00:00:00 2001 From: mcilwain Date: Fri, 25 Jan 2019 10:53:10 -0800 Subject: [PATCH] Merge DomainResource into DomainBase This eliminates the use of Objectify polymorphism for EPP resources entirely (yay!), which makes the Registry 3.0 database migration easier. It is unfortunate that the naming parallelism of EppResources is lost between ContactResource, HostResource, and DomainResource, but the actual type as far as Datastore was concerned was DomainBase all along, and it would be a much more substantial data migration to allow us to continue using the class name DomainResource now that we're no longer using Objectify polymorphism. This simply isn't worth it. This also removes the polymorphic Datastore indexes (which will no longer function as of this change). The non-polymorphic replacement indexes were added in [] ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=230930546 --- .../batch/DeleteProberDataAction.java | 9 +- .../ExpandRecurringBillingEventsAction.java | 4 +- .../batch/RefreshDnsOnHostRenameAction.java | 8 +- .../google/registry/dns/RefreshDnsAction.java | 4 +- .../dns/writer/clouddns/CloudDnsWriter.java | 14 +- .../dns/writer/dnsupdate/DnsUpdateWriter.java | 16 +- .../default/WEB-INF/datastore-indexes.xml | 40 -- .../export/ExportDomainListsAction.java | 8 +- .../google/registry/flows/CheckApiAction.java | 4 +- java/google/registry/flows/EppController.java | 2 +- java/google/registry/flows/FlowReporter.java | 8 +- .../custom/DomainCreateFlowCustomLogic.java | 8 +- .../custom/DomainDeleteFlowCustomLogic.java | 14 +- .../custom/DomainInfoFlowCustomLogic.java | 12 +- .../custom/DomainRenewFlowCustomLogic.java | 20 +- .../custom/DomainUpdateFlowCustomLogic.java | 14 +- .../flows/domain/DomainCheckFlow.java | 4 +- .../flows/domain/DomainCreateFlow.java | 14 +- .../flows/domain/DomainDeleteFlow.java | 16 +- .../flows/domain/DomainFlowUtils.java | 17 +- .../registry/flows/domain/DomainInfoFlow.java | 8 +- .../flows/domain/DomainRenewFlow.java | 10 +- .../domain/DomainRestoreRequestFlow.java | 14 +- .../domain/DomainTransferApproveFlow.java | 14 +- .../domain/DomainTransferCancelFlow.java | 8 +- .../flows/domain/DomainTransferQueryFlow.java | 6 +- .../domain/DomainTransferRejectFlow.java | 8 +- .../domain/DomainTransferRequestFlow.java | 16 +- .../flows/domain/DomainTransferUtils.java | 8 +- .../flows/domain/DomainUpdateFlow.java | 20 +- .../registry/flows/host/HostCreateFlow.java | 4 +- .../registry/flows/host/HostFlowUtils.java | 16 +- .../registry/flows/host/HostInfoFlow.java | 4 +- .../registry/flows/host/HostUpdateFlow.java | 10 +- .../inputs/EppResourceBaseReader.java | 2 +- .../inputs/EppResourceEntityReader.java | 2 +- .../mapreduce/inputs/EppResourceInputs.java | 13 +- java/google/registry/model/EntityClasses.java | 2 - .../registry/model/ResourceTransferUtils.java | 8 +- .../model/contact/ContactResource.java | 2 +- .../registry/model/domain/DomainBase.java | 444 +++++++++++++++++- .../registry/model/domain/DomainCommand.java | 16 +- .../registry/model/domain/DomainResource.java | 436 ----------------- .../registry/model/domain/GracePeriod.java | 2 +- .../registry/model/eppcommon/StatusValue.java | 6 +- .../registry/model/eppinput/EppInput.java | 4 +- .../registry/model/host/HostResource.java | 10 +- .../registry/model/index/ForeignKeyIndex.java | 8 +- java/google/registry/model/package-info.java | 15 +- .../registry/rdap/RdapDomainAction.java | 10 +- .../registry/rdap/RdapDomainSearchAction.java | 46 +- .../registry/rdap/RdapJsonFormatter.java | 40 +- .../rdap/RdapNameserverSearchAction.java | 12 +- ...ter.java => DomainBaseToXjcConverter.java} | 20 +- .../rde/HostResourceToXjcConverter.java | 6 +- java/google/registry/rde/RdeMarshaller.java | 10 +- .../google/registry/rde/RdeStagingMapper.java | 18 +- .../rde/imports/RdeDomainImportAction.java | 10 +- .../registry/rde/imports/RdeDomainInput.java | 4 +- .../rde/imports/RdeHostLinkAction.java | 16 +- .../registry/rde/imports/RdeImportUtils.java | 4 +- ...ter.java => XjcToDomainBaseConverter.java} | 22 +- .../reporting/icann/sql/total_domains.sql | 3 +- .../reporting/icann/sql/total_nameservers.sql | 3 +- java/google/registry/tmch/LordnTaskUtils.java | 12 +- .../registry/tools/CommandUtilities.java | 4 +- .../registry/tools/CountDomainsCommand.java | 4 +- .../registry/tools/DeleteTldCommand.java | 4 +- .../tools/GenerateDnsReportCommand.java | 8 +- .../registry/tools/GenerateLordnCommand.java | 4 +- .../registry/tools/GetDomainCommand.java | 4 +- .../registry/tools/LockDomainCommand.java | 8 +- .../registry/tools/RenewDomainCommand.java | 8 +- .../tools/UniformRapidSuspensionCommand.java | 10 +- .../registry/tools/UnlockDomainCommand.java | 8 +- .../registry/tools/UnrenewDomainCommand.java | 12 +- .../registry/tools/UpdateDomainCommand.java | 22 +- .../tools/server/GenerateZoneFilesAction.java | 12 +- .../tools/server/ListDomainsAction.java | 10 +- .../server/RefreshDnsForAllDomainsAction.java | 8 +- .../registry/whois/DomainLookupCommand.java | 4 +- .../registry/whois/DomainWhoisResponse.java | 6 +- .../DeleteContactsAndHostsActionTest.java | 32 +- .../batch/DeleteProberDataActionTest.java | 46 +- ...xpandRecurringBillingEventsActionTest.java | 8 +- .../RefreshDnsOnHostRenameActionTest.java | 20 +- .../batch/ResaveEntityActionTest.java | 14 +- .../dns/PublishDnsUpdatesActionTest.java | 6 +- .../registry/dns/RefreshDnsActionTest.java | 4 +- .../writer/clouddns/CloudDnsWriterTest.java | 8 +- .../writer/dnsupdate/DnsUpdateWriterTest.java | 26 +- .../registry/flows/EppCommitLogsTest.java | 12 +- .../flows/EppLifecycleDomainTest.java | 14 +- .../registry/flows/EppLifecycleHostTest.java | 14 +- .../google/registry/flows/EppTestCase.java | 10 +- .../registry/flows/FlowReporterTest.java | 16 +- .../flows/contact/ContactDeleteFlowTest.java | 6 +- .../flows/contact/ContactInfoFlowTest.java | 4 +- .../flows/domain/DomainCheckFlowTest.java | 4 +- .../domain/DomainClaimsCheckFlowTest.java | 4 +- .../flows/domain/DomainCreateFlowTest.java | 20 +- .../flows/domain/DomainDeleteFlowTest.java | 42 +- .../flows/domain/DomainInfoFlowTest.java | 12 +- .../flows/domain/DomainRenewFlowTest.java | 16 +- .../domain/DomainRestoreRequestFlowTest.java | 16 +- .../domain/DomainTransferApproveFlowTest.java | 10 +- .../domain/DomainTransferCancelFlowTest.java | 6 +- .../domain/DomainTransferFlowTestCase.java | 10 +- .../domain/DomainTransferQueryFlowTest.java | 6 +- .../domain/DomainTransferRejectFlowTest.java | 6 +- .../domain/DomainTransferRequestFlowTest.java | 18 +- .../flows/domain/DomainUpdateFlowTest.java | 52 +- .../flows/host/HostCreateFlowTest.java | 14 +- .../flows/host/HostDeleteFlowTest.java | 22 +- .../registry/flows/host/HostInfoFlowTest.java | 10 +- .../flows/host/HostUpdateFlowTest.java | 110 ++--- .../registry/flows/poll/PollAckFlowTest.java | 8 +- .../flows/poll/PollRequestFlowTest.java | 8 +- .../inputs/ChildEntityInputTest.java | 22 +- .../inputs/EppResourceInputsTest.java | 63 +-- .../model/billing/BillingEventTest.java | 4 +- .../registry/model/common/CursorTest.java | 4 +- ...nResourceTest.java => DomainBaseTest.java} | 78 +-- .../registry/model/eppinput/EppInputTest.java | 4 +- .../registry/model/host/HostResourceTest.java | 8 +- .../google/registry/model/ofy/OfyTest.java | 3 +- .../model/reporting/HistoryEntryTest.java | 4 +- .../google/registry/model/testdata/schema.txt | 22 +- .../registry/rdap/RdapDomainActionTest.java | 10 +- .../rdap/RdapDomainSearchActionTest.java | 30 +- .../registry/rdap/RdapEntityActionTest.java | 4 +- .../registry/rdap/RdapJsonFormatterTest.java | 32 +- .../rdap/RdapNameserverSearchActionTest.java | 8 +- ...java => DomainBaseToXjcConverterTest.java} | 24 +- .../rde/HostResourceToXjcConverterTest.java | 6 +- .../google/registry/rde/RdeFixtures.java | 6 +- .../registry/rde/RdeStagingActionTest.java | 24 +- .../google/registry/rde/RdeTestSuite.java | 2 +- .../imports/RdeDomainImportActionTest.java | 52 +- .../rde/imports/RdeHostLinkActionTest.java | 14 +- .../rde/imports/RdeImportUtilsTest.java | 20 +- ...java => XjcToDomainBaseConverterTest.java} | 88 ++-- .../icann/testdata/total_domains_test.sql | 3 +- .../icann/testdata/total_nameservers_test.sql | 3 +- javatests/google/registry/server/Fixture.java | 6 +- .../testing/AbstractDomainBaseSubject.java | 3 +- .../registry/testing/DatastoreHelper.java | 62 +-- ...rceSubject.java => DomainBaseSubject.java} | 26 +- .../testing/FullFieldsTestEntityHelper.java | 6 +- .../registry/testing/HostResourceSubject.java | 4 +- .../registry/tmch/LordnTaskUtilsTest.java | 20 +- .../registry/tmch/NordnUploadActionTest.java | 8 +- .../registry/tools/EppLifecycleToolsTest.java | 6 +- .../tools/GenerateDnsReportCommandTest.java | 10 +- .../registry/tools/GetDomainCommandTest.java | 4 +- .../tools/GetHistoryEntriesCommandTest.java | 4 +- .../registry/tools/LockDomainCommandTest.java | 6 +- .../UniformRapidSuspensionCommandTest.java | 6 +- .../tools/UnlockDomainCommandTest.java | 6 +- .../tools/UnrenewDomainCommandTest.java | 16 +- .../tools/UpdateDomainCommandTest.java | 14 +- .../server/GenerateZoneFilesActionTest.java | 20 +- .../ResaveAllHistoryEntriesActionTest.java | 4 +- .../whois/DomainWhoisResponseTest.java | 14 +- .../registry/whois/WhoisActionTest.java | 34 +- .../registry/whois/WhoisHttpActionTest.java | 16 +- 166 files changed, 1525 insertions(+), 1666 deletions(-) delete mode 100644 java/google/registry/model/domain/DomainResource.java rename java/google/registry/rde/{DomainResourceToXjcConverter.java => DomainBaseToXjcConverter.java} (95%) rename java/google/registry/rde/imports/{XjcToDomainResourceConverter.java => XjcToDomainBaseConverter.java} (94%) rename javatests/google/registry/model/domain/{DomainResourceTest.java => DomainBaseTest.java} (90%) rename javatests/google/registry/rde/{DomainResourceToXjcConverterTest.java => DomainBaseToXjcConverterTest.java} (95%) rename javatests/google/registry/rde/imports/{XjcToDomainResourceConverterTest.java => XjcToDomainBaseConverterTest.java} (86%) rename javatests/google/registry/testing/{DomainResourceSubject.java => DomainBaseSubject.java} (66%) diff --git a/java/google/registry/batch/DeleteProberDataAction.java b/java/google/registry/batch/DeleteProberDataAction.java index 051eeffd8..f35b10b67 100644 --- a/java/google/registry/batch/DeleteProberDataAction.java +++ b/java/google/registry/batch/DeleteProberDataAction.java @@ -42,7 +42,6 @@ import google.registry.mapreduce.MapreduceRunner; import google.registry.mapreduce.inputs.EppResourceInputs; import google.registry.model.EppResourceUtils; import google.registry.model.domain.DomainBase; -import google.registry.model.domain.DomainResource; import google.registry.model.index.EppResourceIndex; import google.registry.model.index.ForeignKeyIndex; import google.registry.model.registry.Registry; @@ -58,7 +57,7 @@ import org.joda.time.DateTime; import org.joda.time.Duration; /** - * Deletes all prober DomainResources and their subordinate history entries, poll messages, and + * Deletes all prober DomainBases and their subordinate history entries, poll messages, and * billing events, along with their ForeignKeyDomainIndex and EppResourceIndex entities. * *

See: https://www.youtube.com/watch?v=xuuv0syoHnM @@ -166,7 +165,7 @@ public class DeleteProberDataAction implements Runnable { } private void deleteDomain(final Key domainKey) { - final DomainResource domain = (DomainResource) ofy().load().key(domainKey).now(); + final DomainBase domain = ofy().load().key(domainKey).now(); DateTime now = DateTime.now(UTC); @@ -245,9 +244,9 @@ public class DeleteProberDataAction implements Runnable { getContext().incrementCounter("total entities hard-deleted", entitiesDeleted); } - private void softDeleteDomain(final DomainResource domain) { + private void softDeleteDomain(final DomainBase domain) { ofy().transactNew(() -> { - DomainResource deletedDomain = domain + DomainBase deletedDomain = domain .asBuilder() .setDeletionTime(ofy().getTransactionTime()) .setStatusValues(null) diff --git a/java/google/registry/batch/ExpandRecurringBillingEventsAction.java b/java/google/registry/batch/ExpandRecurringBillingEventsAction.java index 304c45acd..9eee1f9f5 100644 --- a/java/google/registry/batch/ExpandRecurringBillingEventsAction.java +++ b/java/google/registry/batch/ExpandRecurringBillingEventsAction.java @@ -47,7 +47,7 @@ import google.registry.model.billing.BillingEvent.Flag; import google.registry.model.billing.BillingEvent.OneTime; import google.registry.model.billing.BillingEvent.Recurring; import google.registry.model.common.Cursor; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.Period; import google.registry.model.registry.Registry; import google.registry.model.reporting.DomainTransactionRecord; @@ -110,7 +110,7 @@ public class ExpandRecurringBillingEventsAction implements Runnable { ImmutableList.of( new NullInput<>(), createChildEntityInput( - ImmutableSet.of(DomainResource.class), ImmutableSet.of(Recurring.class)))) + ImmutableSet.of(DomainBase.class), ImmutableSet.of(Recurring.class)))) .sendLinkToMapreduceConsole(response); } diff --git a/java/google/registry/batch/RefreshDnsOnHostRenameAction.java b/java/google/registry/batch/RefreshDnsOnHostRenameAction.java index 59f3b92f6..ed5995f89 100644 --- a/java/google/registry/batch/RefreshDnsOnHostRenameAction.java +++ b/java/google/registry/batch/RefreshDnsOnHostRenameAction.java @@ -49,7 +49,7 @@ import google.registry.batch.AsyncTaskMetrics.OperationResult; import google.registry.dns.DnsQueue; import google.registry.mapreduce.MapreduceRunner; import google.registry.mapreduce.inputs.NullInput; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.host.HostResource; import google.registry.model.server.Lock; import google.registry.request.Action; @@ -166,7 +166,7 @@ public class RefreshDnsOnHostRenameAction implements Runnable { new RefreshDnsOnHostRenameMapper(refreshRequests, retrier), new RefreshDnsOnHostRenameReducer(refreshRequests, lock.get(), retrier), // Add an extra NullInput so that the reducer always fires exactly once. - ImmutableList.of(new NullInput<>(), createEntityInput(DomainResource.class))) + ImmutableList.of(new NullInput<>(), createEntityInput(DomainBase.class))) .sendLinkToMapreduceConsole(response); } catch (Throwable t) { logRespondAndUnlock( @@ -182,7 +182,7 @@ public class RefreshDnsOnHostRenameAction implements Runnable { /** Map over domains and refresh the DNS of those that reference the renamed hosts. */ public static class RefreshDnsOnHostRenameMapper - extends Mapper { + extends Mapper { private static final long serialVersionUID = -5261698524424335531L; private static final DnsQueue dnsQueue = DnsQueue.create(); @@ -197,7 +197,7 @@ public class RefreshDnsOnHostRenameAction implements Runnable { } @Override - public final void map(@Nullable final DomainResource domain) { + public final void map(@Nullable final DomainBase domain) { if (domain == null) { // Emit a single value so that the reducer always runs. The key and value don't matter. emit(true, true); diff --git a/java/google/registry/dns/RefreshDnsAction.java b/java/google/registry/dns/RefreshDnsAction.java index 57410761d..7d6fd11c8 100644 --- a/java/google/registry/dns/RefreshDnsAction.java +++ b/java/google/registry/dns/RefreshDnsAction.java @@ -20,7 +20,7 @@ import google.registry.dns.DnsConstants.TargetType; import google.registry.model.EppResource; import google.registry.model.EppResource.ForeignKeyedEppResource; import google.registry.model.annotations.ExternalMessagingName; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.host.HostResource; import google.registry.request.Action; import google.registry.request.HttpException.BadRequestException; @@ -51,7 +51,7 @@ public final class RefreshDnsAction implements Runnable { } switch (type) { case DOMAIN: - loadAndVerifyExistence(DomainResource.class, domainOrHostName); + loadAndVerifyExistence(DomainBase.class, domainOrHostName); dnsQueue.addDomainRefreshTask(domainOrHostName); break; case HOST: diff --git a/java/google/registry/dns/writer/clouddns/CloudDnsWriter.java b/java/google/registry/dns/writer/clouddns/CloudDnsWriter.java index 152921277..cc77b6d4e 100644 --- a/java/google/registry/dns/writer/clouddns/CloudDnsWriter.java +++ b/java/google/registry/dns/writer/clouddns/CloudDnsWriter.java @@ -36,7 +36,7 @@ import google.registry.config.RegistryConfig.Config; import google.registry.dns.writer.BaseDnsWriter; import google.registry.dns.writer.DnsWriter; import google.registry.dns.writer.DnsWriterZone; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.host.HostResource; import google.registry.model.registry.Registries; @@ -121,13 +121,13 @@ public class CloudDnsWriter extends BaseDnsWriter { String absoluteDomainName = getAbsoluteHostName(domainName); // Load the target domain. Note that it can be absent if this domain was just deleted. - Optional domainResource = - loadByForeignKey(DomainResource.class, domainName, clock.nowUtc()); + Optional domainBase = + loadByForeignKey(DomainBase.class, domainName, clock.nowUtc()); // Return early if no DNS records should be published. // desiredRecordsBuilder is populated with an empty set to indicate that all existing records // should be deleted. - if (!domainResource.isPresent() || !domainResource.get().shouldPublishToDns()) { + if (!domainBase.isPresent() || !domainBase.get().shouldPublishToDns()) { desiredRecords.put(absoluteDomainName, ImmutableSet.of()); return; } @@ -135,7 +135,7 @@ public class CloudDnsWriter extends BaseDnsWriter { ImmutableSet.Builder domainRecords = new ImmutableSet.Builder<>(); // Construct DS records (if any). - Set dsData = domainResource.get().getDsData(); + Set dsData = domainBase.get().getDsData(); if (!dsData.isEmpty()) { HashSet dsRrData = new HashSet<>(); for (DelegationSignerData ds : dsData) { @@ -154,8 +154,8 @@ public class CloudDnsWriter extends BaseDnsWriter { } // Construct NS records (if any). - Set nameserverData = domainResource.get().loadNameserverFullyQualifiedHostNames(); - Set subordinateHosts = domainResource.get().getSubordinateHosts(); + Set nameserverData = domainBase.get().loadNameserverFullyQualifiedHostNames(); + Set subordinateHosts = domainBase.get().getSubordinateHosts(); if (!nameserverData.isEmpty()) { HashSet nsRrData = new HashSet<>(); for (String hostName : nameserverData) { diff --git a/java/google/registry/dns/writer/dnsupdate/DnsUpdateWriter.java b/java/google/registry/dns/writer/dnsupdate/DnsUpdateWriter.java index 4baecb065..dc885cbe4 100644 --- a/java/google/registry/dns/writer/dnsupdate/DnsUpdateWriter.java +++ b/java/google/registry/dns/writer/dnsupdate/DnsUpdateWriter.java @@ -27,7 +27,7 @@ import com.google.common.net.InternetDomainName; import google.registry.config.RegistryConfig.Config; import google.registry.dns.writer.BaseDnsWriter; import google.registry.dns.writer.DnsWriterZone; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.host.HostResource; import google.registry.model.registry.Registries; @@ -127,12 +127,12 @@ public class DnsUpdateWriter extends BaseDnsWriter { * this domain refresh request */ private void publishDomain(String domainName, String requestingHostName) { - Optional domainOptional = - loadByForeignKey(DomainResource.class, domainName, clock.nowUtc()); + Optional domainOptional = + loadByForeignKey(DomainBase.class, domainName, clock.nowUtc()); update.delete(toAbsoluteName(domainName), Type.ANY); // If the domain is now deleted, then don't update DNS for it. if (domainOptional.isPresent()) { - DomainResource domain = domainOptional.get(); + DomainBase domain = domainOptional.get(); // As long as the domain exists, orphan glues should be cleaned. deleteSubordinateHostAddressSet(domain, requestingHostName, update); if (domain.shouldPublishToDns()) { @@ -184,7 +184,7 @@ public class DnsUpdateWriter extends BaseDnsWriter { } } - private RRset makeDelegationSignerSet(DomainResource domain) { + private RRset makeDelegationSignerSet(DomainBase domain) { RRset signerSet = new RRset(); for (DelegationSignerData signerData : domain.getDsData()) { DSRecord dsRecord = @@ -202,7 +202,7 @@ public class DnsUpdateWriter extends BaseDnsWriter { } private void deleteSubordinateHostAddressSet( - DomainResource domain, String additionalHost, Update update) { + DomainBase domain, String additionalHost, Update update) { for (String hostName : union( domain.getSubordinateHosts(), @@ -213,7 +213,7 @@ public class DnsUpdateWriter extends BaseDnsWriter { } } - private void addInBailiwickNameServerSet(DomainResource domain, Update update) { + private void addInBailiwickNameServerSet(DomainBase domain, Update update) { for (String hostName : intersection( domain.loadNameserverFullyQualifiedHostNames(), domain.getSubordinateHosts())) { @@ -224,7 +224,7 @@ public class DnsUpdateWriter extends BaseDnsWriter { } } - private RRset makeNameServerSet(DomainResource domain) { + private RRset makeNameServerSet(DomainBase domain) { RRset nameServerSet = new RRset(); for (String hostName : domain.loadNameserverFullyQualifiedHostNames()) { NSRecord record = diff --git a/java/google/registry/env/common/default/WEB-INF/datastore-indexes.xml b/java/google/registry/env/common/default/WEB-INF/datastore-indexes.xml index dffd81d01..236f50c7f 100644 --- a/java/google/registry/env/common/default/WEB-INF/datastore-indexes.xml +++ b/java/google/registry/env/common/default/WEB-INF/datastore-indexes.xml @@ -6,21 +6,11 @@ - - - - - - - - - - @@ -31,11 +21,6 @@ - - - - - @@ -62,11 +47,6 @@ - - - - - @@ -95,31 +75,11 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/java/google/registry/export/ExportDomainListsAction.java b/java/google/registry/export/ExportDomainListsAction.java index 474d772a6..0b8d3e70a 100644 --- a/java/google/registry/export/ExportDomainListsAction.java +++ b/java/google/registry/export/ExportDomainListsAction.java @@ -38,7 +38,7 @@ import com.google.common.net.MediaType; import google.registry.config.RegistryConfig.Config; import google.registry.gcs.GcsUtils; import google.registry.mapreduce.MapreduceRunner; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.registry.Registry; import google.registry.model.registry.Registry.TldType; import google.registry.request.Action; @@ -88,11 +88,11 @@ public class ExportDomainListsAction implements Runnable { .runMapreduce( new ExportDomainListsMapper(DateTime.now(UTC), realTlds), new ExportDomainListsReducer(gcsBucket, gcsBufferSize), - ImmutableList.of(createEntityInput(DomainResource.class))) + ImmutableList.of(createEntityInput(DomainBase.class))) .sendLinkToMapreduceConsole(response); } - static class ExportDomainListsMapper extends Mapper { + static class ExportDomainListsMapper extends Mapper { private static final long serialVersionUID = -7312206212434039854L; @@ -105,7 +105,7 @@ public class ExportDomainListsAction implements Runnable { } @Override - public void map(DomainResource domain) { + public void map(DomainBase domain) { if (realTlds.contains(domain.getTld()) && isActive(domain, exportTime)) { emit(domain.getTld(), domain.getFullyQualifiedDomainName()); getContext().incrementCounter(String.format("domains in tld %s", domain.getTld())); diff --git a/java/google/registry/flows/CheckApiAction.java b/java/google/registry/flows/CheckApiAction.java index 1b513fe76..5e5e540bd 100644 --- a/java/google/registry/flows/CheckApiAction.java +++ b/java/google/registry/flows/CheckApiAction.java @@ -44,7 +44,7 @@ import dagger.Module; import dagger.Provides; import google.registry.flows.domain.DomainFlowUtils.BadCommandForRegistryPhaseException; import google.registry.flows.domain.DomainFlowUtils.InvalidIdnDomainLabelException; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.index.ForeignKeyIndex; import google.registry.model.registry.Registry; import google.registry.model.registry.label.ReservationType; @@ -157,7 +157,7 @@ public class CheckApiAction implements Runnable { } private boolean checkExists(String domainString, DateTime now) { - return !ForeignKeyIndex.loadCached(DomainResource.class, ImmutableList.of(domainString), now) + return !ForeignKeyIndex.loadCached(DomainBase.class, ImmutableList.of(domainString), now) .isEmpty(); } diff --git a/java/google/registry/flows/EppController.java b/java/google/registry/flows/EppController.java index 44f2ae054..7de8bf6e3 100644 --- a/java/google/registry/flows/EppController.java +++ b/java/google/registry/flows/EppController.java @@ -95,7 +95,7 @@ public final class EppController { e.getResult(), Trid.create(null, serverTridProvider.createServerTrid())); } if (!eppInput.getTargetIds().isEmpty()) { - if (eppInput.isDomainResourceType()) { + if (eppInput.isDomainType()) { eppMetricBuilder.setTlds(extractTlds(eppInput.getTargetIds())); } } diff --git a/java/google/registry/flows/FlowReporter.java b/java/google/registry/flows/FlowReporter.java index c59dea773..7c15e45d4 100644 --- a/java/google/registry/flows/FlowReporter.java +++ b/java/google/registry/flows/FlowReporter.java @@ -70,12 +70,8 @@ public class FlowReporter { .put("flowClassName", flowClass.getSimpleName()) .put("targetId", singleTargetId) .put("targetIds", targetIds) - .put( - "tld", - eppInput.isDomainResourceType() ? extractTld(singleTargetId).orElse("") : "") - .put( - "tlds", - eppInput.isDomainResourceType() ? extractTlds(targetIds).asList() : EMPTY_LIST) + .put("tld", eppInput.isDomainType() ? extractTld(singleTargetId).orElse("") : "") + .put("tlds", eppInput.isDomainType() ? extractTlds(targetIds).asList() : EMPTY_LIST) .put("icannActivityReportField", extractActivityReportField(flowClass)) .build())); } diff --git a/java/google/registry/flows/custom/DomainCreateFlowCustomLogic.java b/java/google/registry/flows/custom/DomainCreateFlowCustomLogic.java index 0c2d10d34..3675b63ae 100644 --- a/java/google/registry/flows/custom/DomainCreateFlowCustomLogic.java +++ b/java/google/registry/flows/custom/DomainCreateFlowCustomLogic.java @@ -22,7 +22,7 @@ import google.registry.flows.FlowMetadata; import google.registry.flows.SessionMetadata; import google.registry.flows.domain.DomainCreateFlow; import google.registry.model.ImmutableObject; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.eppinput.EppInput; import google.registry.model.eppoutput.EppResponse.ResponseData; import google.registry.model.eppoutput.EppResponse.ResponseExtension; @@ -125,10 +125,10 @@ public class DomainCreateFlowCustomLogic extends BaseFlowCustomLogic { public abstract static class BeforeSaveParameters extends ImmutableObject { /** - * The new {@link DomainResource} entity that is going to be persisted at the end of the + * The new {@link DomainBase} entity that is going to be persisted at the end of the * transaction. */ - public abstract DomainResource newDomain(); + public abstract DomainBase newDomain(); /** * The new {@link HistoryEntry} entity for the domain's creation that is going to be persisted @@ -162,7 +162,7 @@ public class DomainCreateFlowCustomLogic extends BaseFlowCustomLogic { @AutoValue.Builder public abstract static class Builder { - public abstract Builder setNewDomain(DomainResource newDomain); + public abstract Builder setNewDomain(DomainBase newDomain); public abstract Builder setHistoryEntry(HistoryEntry historyEntry); diff --git a/java/google/registry/flows/custom/DomainDeleteFlowCustomLogic.java b/java/google/registry/flows/custom/DomainDeleteFlowCustomLogic.java index b43418cf6..70a1b73a6 100644 --- a/java/google/registry/flows/custom/DomainDeleteFlowCustomLogic.java +++ b/java/google/registry/flows/custom/DomainDeleteFlowCustomLogic.java @@ -21,7 +21,7 @@ import google.registry.flows.FlowMetadata; import google.registry.flows.SessionMetadata; import google.registry.flows.domain.DomainDeleteFlow; import google.registry.model.ImmutableObject; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.eppinput.EppInput; import google.registry.model.eppoutput.EppResponse.ResponseExtension; import google.registry.model.eppoutput.Result; @@ -83,7 +83,7 @@ public class DomainDeleteFlowCustomLogic extends BaseFlowCustomLogic { @AutoValue public abstract static class AfterValidationParameters extends ImmutableObject { - public abstract DomainResource existingDomain(); + public abstract DomainBase existingDomain(); public static Builder newBuilder() { return new AutoValue_DomainDeleteFlowCustomLogic_AfterValidationParameters.Builder(); @@ -93,7 +93,7 @@ public class DomainDeleteFlowCustomLogic extends BaseFlowCustomLogic { @AutoValue.Builder public abstract static class Builder { - public abstract Builder setExistingDomain(DomainResource existingDomain); + public abstract Builder setExistingDomain(DomainBase existingDomain); public abstract AfterValidationParameters build(); } @@ -109,9 +109,9 @@ public class DomainDeleteFlowCustomLogic extends BaseFlowCustomLogic { @AutoValue public abstract static class BeforeSaveParameters extends ImmutableObject { - public abstract DomainResource existingDomain(); + public abstract DomainBase existingDomain(); - public abstract DomainResource newDomain(); + public abstract DomainBase newDomain(); public abstract HistoryEntry historyEntry(); @@ -125,9 +125,9 @@ public class DomainDeleteFlowCustomLogic extends BaseFlowCustomLogic { @AutoValue.Builder public abstract static class Builder { - public abstract Builder setExistingDomain(DomainResource existingDomain); + public abstract Builder setExistingDomain(DomainBase existingDomain); - public abstract Builder setNewDomain(DomainResource newDomain); + public abstract Builder setNewDomain(DomainBase newDomain); public abstract Builder setHistoryEntry(HistoryEntry historyEntry); diff --git a/java/google/registry/flows/custom/DomainInfoFlowCustomLogic.java b/java/google/registry/flows/custom/DomainInfoFlowCustomLogic.java index fba46ed37..3b19fd2ea 100644 --- a/java/google/registry/flows/custom/DomainInfoFlowCustomLogic.java +++ b/java/google/registry/flows/custom/DomainInfoFlowCustomLogic.java @@ -21,8 +21,8 @@ import google.registry.flows.FlowMetadata; import google.registry.flows.SessionMetadata; import google.registry.flows.domain.DomainInfoFlow; import google.registry.model.ImmutableObject; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.DomainInfoData; -import google.registry.model.domain.DomainResource; import google.registry.model.eppinput.EppInput; import google.registry.model.eppoutput.EppResponse.ResponseExtension; @@ -53,7 +53,7 @@ public class DomainInfoFlowCustomLogic extends BaseFlowCustomLogic { /** * A hook that runs before the response is returned. * - *

This takes the {@link DomainResource} and {@link ResponseExtension}s as input and returns + *

This takes the {@link DomainBase} and {@link ResponseExtension}s as input and returns * them, potentially with modifications. */ @SuppressWarnings("unused") @@ -69,7 +69,7 @@ public class DomainInfoFlowCustomLogic extends BaseFlowCustomLogic { @AutoValue public abstract static class AfterValidationParameters extends ImmutableObject { - public abstract DomainResource domain(); + public abstract DomainBase domain(); public static Builder newBuilder() { return new AutoValue_DomainInfoFlowCustomLogic_AfterValidationParameters.Builder(); @@ -79,7 +79,7 @@ public class DomainInfoFlowCustomLogic extends BaseFlowCustomLogic { @AutoValue.Builder public abstract static class Builder { - public abstract Builder setDomain(DomainResource domain); + public abstract Builder setDomain(DomainBase domain); public abstract AfterValidationParameters build(); } @@ -89,7 +89,7 @@ public class DomainInfoFlowCustomLogic extends BaseFlowCustomLogic { @AutoValue public abstract static class BeforeResponseParameters extends ImmutableObject { - public abstract DomainResource domain(); + public abstract DomainBase domain(); public abstract DomainInfoData resData(); @@ -103,7 +103,7 @@ public class DomainInfoFlowCustomLogic extends BaseFlowCustomLogic { @AutoValue.Builder public abstract static class Builder { - public abstract Builder setDomain(DomainResource domain); + public abstract Builder setDomain(DomainBase domain); public abstract Builder setResData(DomainInfoData resData); diff --git a/java/google/registry/flows/custom/DomainRenewFlowCustomLogic.java b/java/google/registry/flows/custom/DomainRenewFlowCustomLogic.java index 89497f6a6..adf6b1275 100644 --- a/java/google/registry/flows/custom/DomainRenewFlowCustomLogic.java +++ b/java/google/registry/flows/custom/DomainRenewFlowCustomLogic.java @@ -21,7 +21,7 @@ import google.registry.flows.FlowMetadata; import google.registry.flows.SessionMetadata; import google.registry.flows.domain.DomainRenewFlow; import google.registry.model.ImmutableObject; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.eppinput.EppInput; import google.registry.model.eppoutput.EppResponse.ResponseData; import google.registry.model.eppoutput.EppResponse.ResponseExtension; @@ -68,7 +68,7 @@ public class DomainRenewFlowCustomLogic extends BaseFlowCustomLogic { /** * A hook that runs before the response is returned. * - *

This takes the {@link DomainResource} and {@link ResponseExtension}s as input and returns + *

This takes the {@link DomainBase} and {@link ResponseExtension}s as input and returns * them, potentially with modifications. */ @SuppressWarnings("unused") @@ -84,7 +84,7 @@ public class DomainRenewFlowCustomLogic extends BaseFlowCustomLogic { @AutoValue public abstract static class AfterValidationParameters extends ImmutableObject { - public abstract DomainResource existingDomain(); + public abstract DomainBase existingDomain(); public abstract int years(); @@ -98,7 +98,7 @@ public class DomainRenewFlowCustomLogic extends BaseFlowCustomLogic { @AutoValue.Builder public abstract static class Builder { - public abstract Builder setExistingDomain(DomainResource existingDomain); + public abstract Builder setExistingDomain(DomainBase existingDomain); public abstract Builder setYears(int years); @@ -118,9 +118,9 @@ public class DomainRenewFlowCustomLogic extends BaseFlowCustomLogic { @AutoValue public abstract static class BeforeSaveParameters extends ImmutableObject { - public abstract DomainResource existingDomain(); + public abstract DomainBase existingDomain(); - public abstract DomainResource newDomain(); + public abstract DomainBase newDomain(); public abstract HistoryEntry historyEntry(); @@ -138,9 +138,9 @@ public class DomainRenewFlowCustomLogic extends BaseFlowCustomLogic { @AutoValue.Builder public abstract static class Builder { - public abstract Builder setExistingDomain(DomainResource existingDomain); + public abstract Builder setExistingDomain(DomainBase existingDomain); - public abstract Builder setNewDomain(DomainResource newDomain); + public abstract Builder setNewDomain(DomainBase newDomain); public abstract Builder setHistoryEntry(HistoryEntry historyEntry); @@ -158,7 +158,7 @@ public class DomainRenewFlowCustomLogic extends BaseFlowCustomLogic { @AutoValue public abstract static class BeforeResponseParameters extends ImmutableObject { - public abstract DomainResource domain(); + public abstract DomainBase domain(); public abstract ResponseData resData(); @@ -172,7 +172,7 @@ public class DomainRenewFlowCustomLogic extends BaseFlowCustomLogic { @AutoValue.Builder public abstract static class Builder { - public abstract BeforeResponseParameters.Builder setDomain(DomainResource domain); + public abstract BeforeResponseParameters.Builder setDomain(DomainBase domain); public abstract BeforeResponseParameters.Builder setResData(ResponseData resData); diff --git a/java/google/registry/flows/custom/DomainUpdateFlowCustomLogic.java b/java/google/registry/flows/custom/DomainUpdateFlowCustomLogic.java index 09425d834..92f07b91a 100644 --- a/java/google/registry/flows/custom/DomainUpdateFlowCustomLogic.java +++ b/java/google/registry/flows/custom/DomainUpdateFlowCustomLogic.java @@ -20,7 +20,7 @@ import google.registry.flows.FlowMetadata; import google.registry.flows.SessionMetadata; import google.registry.flows.domain.DomainUpdateFlow; import google.registry.model.ImmutableObject; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.eppinput.EppInput; import google.registry.model.reporting.HistoryEntry; @@ -65,7 +65,7 @@ public class DomainUpdateFlowCustomLogic extends BaseFlowCustomLogic { @AutoValue public abstract static class AfterValidationParameters extends ImmutableObject { - public abstract DomainResource existingDomain(); + public abstract DomainBase existingDomain(); public static Builder newBuilder() { return new AutoValue_DomainUpdateFlowCustomLogic_AfterValidationParameters.Builder(); @@ -75,7 +75,7 @@ public class DomainUpdateFlowCustomLogic extends BaseFlowCustomLogic { @AutoValue.Builder public abstract static class Builder { - public abstract Builder setExistingDomain(DomainResource existingDomain); + public abstract Builder setExistingDomain(DomainBase existingDomain); public abstract AfterValidationParameters build(); } @@ -91,9 +91,9 @@ public class DomainUpdateFlowCustomLogic extends BaseFlowCustomLogic { @AutoValue public abstract static class BeforeSaveParameters extends ImmutableObject { - public abstract DomainResource existingDomain(); + public abstract DomainBase existingDomain(); - public abstract DomainResource newDomain(); + public abstract DomainBase newDomain(); public abstract HistoryEntry historyEntry(); @@ -107,9 +107,9 @@ public class DomainUpdateFlowCustomLogic extends BaseFlowCustomLogic { @AutoValue.Builder public abstract static class Builder { - public abstract Builder setExistingDomain(DomainResource existingDomain); + public abstract Builder setExistingDomain(DomainBase existingDomain); - public abstract Builder setNewDomain(DomainResource newDomain); + public abstract Builder setNewDomain(DomainBase newDomain); public abstract Builder setHistoryEntry(HistoryEntry historyEntry); diff --git a/java/google/registry/flows/domain/DomainCheckFlow.java b/java/google/registry/flows/domain/DomainCheckFlow.java index 2735c4249..ce53e27e6 100644 --- a/java/google/registry/flows/domain/DomainCheckFlow.java +++ b/java/google/registry/flows/domain/DomainCheckFlow.java @@ -42,8 +42,8 @@ import google.registry.flows.custom.DomainCheckFlowCustomLogic; import google.registry.flows.custom.DomainCheckFlowCustomLogic.BeforeResponseParameters; import google.registry.flows.custom.DomainCheckFlowCustomLogic.BeforeResponseReturnData; import google.registry.flows.domain.token.AllocationTokenFlowUtils; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.DomainCommand.Check; -import google.registry.model.domain.DomainResource; import google.registry.model.domain.fee.FeeCheckCommandExtension; import google.registry.model.domain.fee.FeeCheckCommandExtensionItem; import google.registry.model.domain.fee.FeeCheckResponseExtensionItem; @@ -141,7 +141,7 @@ public final class DomainCheckFlow implements Flow { // TODO: Use as of date from fee extension v0.12 instead of now, if specified. .setAsOfDate(now) .build()); - Set existingIds = checkResourcesExist(DomainResource.class, targetIds, now); + Set existingIds = checkResourcesExist(DomainBase.class, targetIds, now); Optional allocationTokenExtension = eppInput.getSingleExtension(AllocationTokenExtension.class); ImmutableMap tokenCheckResults = diff --git a/java/google/registry/flows/domain/DomainCreateFlow.java b/java/google/registry/flows/domain/DomainCreateFlow.java index f830a5f1b..c65ce8275 100644 --- a/java/google/registry/flows/domain/DomainCreateFlow.java +++ b/java/google/registry/flows/domain/DomainCreateFlow.java @@ -76,9 +76,9 @@ import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent.Flag; import google.registry.model.billing.BillingEvent.Reason; import google.registry.model.billing.BillingEvent.Recurring; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.DomainCommand; import google.registry.model.domain.DomainCommand.Create; -import google.registry.model.domain.DomainResource; import google.registry.model.domain.GracePeriod; import google.registry.model.domain.Period; import google.registry.model.domain.fee.FeeCreateCommandExtension; @@ -221,7 +221,7 @@ public class DomainCreateFlow implements TransactionalFlow { verifyUnitIsYears(period); int years = period.getValue(); validateRegistrationPeriod(years); - verifyResourceDoesNotExist(DomainResource.class, targetId, now); + verifyResourceDoesNotExist(DomainBase.class, targetId, now); // Validate that this is actually a legal domain name on a TLD that the registrar has access to. InternetDomainName domainName = validateDomainName(command.getFullyQualifiedDomainName()); String domainLabel = domainName.parts().get(0); @@ -334,8 +334,8 @@ public class DomainCreateFlow implements TransactionalFlow { createNameCollisionOneTimePollMessage(targetId, historyEntry, clientId, now)); } - DomainResource newDomain = - new DomainResource.Builder() + DomainBase newDomain = + new DomainBase.Builder() .setCreationClientId(clientId) .setPersistedCurrentSponsorClientId(clientId) .setRepoId(repoId) @@ -477,7 +477,7 @@ public class DomainCreateFlow implements TransactionalFlow { .setType(HistoryEntry.Type.DOMAIN_CREATE) .setPeriod(period) .setModificationTime(now) - .setParent(Key.create(DomainResource.class, repoId)) + .setParent(Key.create(DomainBase.class, repoId)) .build(); } @@ -573,12 +573,12 @@ public class DomainCreateFlow implements TransactionalFlow { } private void enqueueTasks( - DomainResource newDomain, boolean hasSignedMarks, boolean hasClaimsNotice) { + DomainBase newDomain, boolean hasSignedMarks, boolean hasClaimsNotice) { if (newDomain.shouldPublishToDns()) { dnsQueue.addDomainRefreshTask(newDomain.getFullyQualifiedDomainName()); } if (hasClaimsNotice || hasSignedMarks) { - LordnTaskUtils.enqueueDomainResourceTask(newDomain); + LordnTaskUtils.enqueueDomainBaseTask(newDomain); } } diff --git a/java/google/registry/flows/domain/DomainDeleteFlow.java b/java/google/registry/flows/domain/DomainDeleteFlow.java index e4cb34687..c4dbd007b 100644 --- a/java/google/registry/flows/domain/DomainDeleteFlow.java +++ b/java/google/registry/flows/domain/DomainDeleteFlow.java @@ -61,8 +61,8 @@ import google.registry.flows.custom.DomainDeleteFlowCustomLogic.BeforeSaveParame import google.registry.flows.custom.EntityChanges; import google.registry.model.ImmutableObject; import google.registry.model.billing.BillingEvent; -import google.registry.model.domain.DomainResource; -import google.registry.model.domain.DomainResource.Builder; +import google.registry.model.domain.DomainBase; +import google.registry.model.domain.DomainBase.Builder; import google.registry.model.domain.GracePeriod; import google.registry.model.domain.fee.BaseFee.FeeType; import google.registry.model.domain.fee.Credit; @@ -143,7 +143,7 @@ public final class DomainDeleteFlow implements TransactionalFlow { validateClientIsLoggedIn(clientId); DateTime now = ofy().getTransactionTime(); // Loads the target resource if it exists - DomainResource existingDomain = loadAndVerifyExistence(DomainResource.class, targetId, now); + DomainBase existingDomain = loadAndVerifyExistence(DomainBase.class, targetId, now); Registry registry = Registry.get(existingDomain.getTld()); verifyDeleteAllowed(existingDomain, registry, now); flowCustomLogic.afterValidation( @@ -204,7 +204,7 @@ public final class DomainDeleteFlow implements TransactionalFlow { // message are produced (since we are ending the autorenew recurrences at "now" below). For // now at least this is working as intended. } - DomainResource newDomain = builder.build(); + DomainBase newDomain = builder.build(); updateForeignKeyIndexDeletionTime(newDomain); handlePendingTransferOnDelete(existingDomain, newDomain, now, historyEntry); // Close the autorenew billing event and poll message. This may delete the poll message. @@ -245,7 +245,7 @@ public final class DomainDeleteFlow implements TransactionalFlow { .build(); } - private void verifyDeleteAllowed(DomainResource existingDomain, Registry registry, DateTime now) + private void verifyDeleteAllowed(DomainBase existingDomain, Registry registry, DateTime now) throws EppException { verifyNoDisallowedStatuses(existingDomain, DISALLOWED_STATUSES); verifyOptionalAuthInfo(authInfo, existingDomain); @@ -260,7 +260,7 @@ public final class DomainDeleteFlow implements TransactionalFlow { } private HistoryEntry buildHistoryEntry( - DomainResource existingResource, + DomainBase existingResource, Registry registry, DateTime now, Duration durationUntilDelete, @@ -298,7 +298,7 @@ public final class DomainDeleteFlow implements TransactionalFlow { } private OneTime createDeletePollMessage( - DomainResource existingResource, HistoryEntry historyEntry, DateTime deletionTime) { + DomainBase existingResource, HistoryEntry historyEntry, DateTime deletionTime) { return new PollMessage.OneTime.Builder() .setClientId(existingResource.getCurrentSponsorClientId()) .setEventTime(deletionTime) @@ -312,7 +312,7 @@ public final class DomainDeleteFlow implements TransactionalFlow { @Nullable private ImmutableList getResponseExtensions( - DomainResource existingDomain, DateTime now) { + DomainBase existingDomain, DateTime now) { FeeTransformResponseExtension.Builder feeResponseBuilder = getDeleteResponseBuilder(); if (feeResponseBuilder == null) { return ImmutableList.of(); diff --git a/java/google/registry/flows/domain/DomainFlowUtils.java b/java/google/registry/flows/domain/DomainFlowUtils.java index 8a44689af..33c1a5c5b 100644 --- a/java/google/registry/flows/domain/DomainFlowUtils.java +++ b/java/google/registry/flows/domain/DomainFlowUtils.java @@ -22,7 +22,7 @@ import static com.google.common.collect.Iterables.any; 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.DomainResource.MAX_REGISTRATION_YEARS; +import static google.registry.model.domain.DomainBase.MAX_REGISTRATION_YEARS; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.registry.Registries.findTldForName; import static google.registry.model.registry.Registries.getTlds; @@ -77,7 +77,6 @@ import google.registry.model.domain.DomainCommand.Create; import google.registry.model.domain.DomainCommand.CreateOrUpdate; import google.registry.model.domain.DomainCommand.InvalidReferencesException; import google.registry.model.domain.DomainCommand.Update; -import google.registry.model.domain.DomainResource; import google.registry.model.domain.ForeignKeyedDesignatedContact; import google.registry.model.domain.Period; import google.registry.model.domain.fee.BaseFee.FeeType; @@ -504,7 +503,7 @@ public class DomainFlowUtils { * Fills in a builder with the data needed for an autorenew billing event for this domain. This * does not copy over the id of the current autorenew billing event. */ - public static BillingEvent.Recurring.Builder newAutorenewBillingEvent(DomainResource domain) { + public static BillingEvent.Recurring.Builder newAutorenewBillingEvent(DomainBase domain) { return new BillingEvent.Recurring.Builder() .setReason(Reason.RENEW) .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) @@ -517,7 +516,7 @@ public class DomainFlowUtils { * Fills in a builder with the data needed for an autorenew poll message for this domain. This * does not copy over the id of the current autorenew poll message. */ - public static PollMessage.Autorenew.Builder newAutorenewPollMessage(DomainResource domain) { + public static PollMessage.Autorenew.Builder newAutorenewPollMessage(DomainBase domain) { return new PollMessage.Autorenew.Builder() .setTargetId(domain.getFullyQualifiedDomainName()) .setClientId(domain.getCurrentSponsorClientId()) @@ -533,7 +532,7 @@ public class DomainFlowUtils { * time earlier than its event time (i.e. if it's being ended before it was ever triggered). */ @SuppressWarnings("unchecked") - public static void updateAutorenewRecurrenceEndTime(DomainResource domain, DateTime newEndTime) { + public static void updateAutorenewRecurrenceEndTime(DomainBase domain, DateTime newEndTime) { Optional autorenewPollMessage = Optional.ofNullable(ofy().load().key(domain.getAutorenewPollMessage()).now()); @@ -787,7 +786,7 @@ public class DomainFlowUtils { /** * Check whether a new expiration time (via a renew) does not extend beyond a maximum number of - * years (e.g. {@link DomainResource#MAX_REGISTRATION_YEARS}) from "now". + * years (e.g. {@link DomainBase#MAX_REGISTRATION_YEARS}) from "now". * * @throws ExceedsMaxRegistrationYearsException if the new registration period is too long */ @@ -800,7 +799,7 @@ public class DomainFlowUtils { /** * Check that a new registration period (via a create) does not extend beyond a maximum number of - * years (e.g. {@link DomainResource#MAX_REGISTRATION_YEARS}). + * years (e.g. {@link DomainBase#MAX_REGISTRATION_YEARS}). * * @throws ExceedsMaxRegistrationYearsException if the new registration period is too long */ @@ -1019,7 +1018,7 @@ public class DomainFlowUtils { * the most recent HistoryEntry that fits the above criteria, with negated reportAmounts. */ static ImmutableSet createCancelingRecords( - DomainResource domainResource, + DomainBase domainBase, final DateTime now, Duration maxSearchPeriod, final ImmutableSet cancelableFields) { @@ -1028,7 +1027,7 @@ public class DomainFlowUtils { ofy() .load() .type(HistoryEntry.class) - .ancestor(domainResource) + .ancestor(domainBase) .filter("modificationTime >=", now.minus(maxSearchPeriod)) .order("modificationTime") .list(); diff --git a/java/google/registry/flows/domain/DomainInfoFlow.java b/java/google/registry/flows/domain/DomainInfoFlow.java index 03357280a..a87b23dbb 100644 --- a/java/google/registry/flows/domain/DomainInfoFlow.java +++ b/java/google/registry/flows/domain/DomainInfoFlow.java @@ -37,10 +37,10 @@ import google.registry.flows.custom.DomainInfoFlowCustomLogic; import google.registry.flows.custom.DomainInfoFlowCustomLogic.AfterValidationParameters; import google.registry.flows.custom.DomainInfoFlowCustomLogic.BeforeResponseParameters; import google.registry.flows.custom.DomainInfoFlowCustomLogic.BeforeResponseReturnData; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.DomainCommand.Info; import google.registry.model.domain.DomainCommand.Info.HostsRequest; import google.registry.model.domain.DomainInfoData; -import google.registry.model.domain.DomainResource; import google.registry.model.domain.fee06.FeeInfoCommandExtensionV06; import google.registry.model.domain.fee06.FeeInfoResponseExtensionV06; import google.registry.model.domain.rgp.GracePeriodStatus; @@ -95,8 +95,8 @@ public final class DomainInfoFlow implements Flow { extensionManager.validate(); validateClientIsLoggedIn(clientId); DateTime now = clock.nowUtc(); - DomainResource domain = verifyExistence( - DomainResource.class, targetId, loadByForeignKey(DomainResource.class, targetId, now)); + DomainBase domain = verifyExistence( + DomainBase.class, targetId, loadByForeignKey(DomainBase.class, targetId, now)); verifyOptionalAuthInfo(authInfo, domain); flowCustomLogic.afterValidation( AfterValidationParameters.newBuilder().setDomain(domain).build()); @@ -145,7 +145,7 @@ public final class DomainInfoFlow implements Flow { } private ImmutableList getDomainResponseExtensions( - DomainResource domain, DateTime now) throws EppException { + DomainBase domain, DateTime now) throws EppException { ImmutableList.Builder extensions = new ImmutableList.Builder<>(); addSecDnsExtensionIfPresent(extensions, domain.getDsData()); ImmutableSet gracePeriodStatuses = domain.getGracePeriodStatuses(); diff --git a/java/google/registry/flows/domain/DomainRenewFlow.java b/java/google/registry/flows/domain/DomainRenewFlow.java index 3a122a49c..37049b072 100644 --- a/java/google/registry/flows/domain/DomainRenewFlow.java +++ b/java/google/registry/flows/domain/DomainRenewFlow.java @@ -51,9 +51,9 @@ import google.registry.flows.custom.EntityChanges; import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent.OneTime; import google.registry.model.billing.BillingEvent.Reason; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.DomainCommand.Renew; import google.registry.model.domain.DomainRenewData; -import google.registry.model.domain.DomainResource; import google.registry.model.domain.GracePeriod; import google.registry.model.domain.Period; import google.registry.model.domain.fee.BaseFee.FeeType; @@ -139,7 +139,7 @@ public final class DomainRenewFlow implements TransactionalFlow { DateTime now = ofy().getTransactionTime(); Renew command = (Renew) resourceCommand; // Loads the target resource if it exists - DomainResource existingDomain = loadAndVerifyExistence(DomainResource.class, targetId, now); + DomainBase existingDomain = loadAndVerifyExistence(DomainBase.class, targetId, now); verifyRenewAllowed(authInfo, existingDomain, command); int years = command.getPeriod().getValue(); DateTime newExpirationTime = @@ -174,7 +174,7 @@ public final class DomainRenewFlow implements TransactionalFlow { .build(); // End the old autorenew billing event and poll message now. This may delete the poll message. updateAutorenewRecurrenceEndTime(existingDomain, now); - DomainResource newDomain = + DomainBase newDomain = existingDomain .asBuilder() .setLastEppUpdateTime(now) @@ -220,7 +220,7 @@ public final class DomainRenewFlow implements TransactionalFlow { } private HistoryEntry buildHistoryEntry( - DomainResource existingDomain, DateTime now, Period period, Duration renewGracePeriod) { + DomainBase existingDomain, DateTime now, Period period, Duration renewGracePeriod) { return historyBuilder .setType(HistoryEntry.Type.DOMAIN_RENEW) .setPeriod(period) @@ -238,7 +238,7 @@ public final class DomainRenewFlow implements TransactionalFlow { private void verifyRenewAllowed( Optional authInfo, - DomainResource existingDomain, + DomainBase existingDomain, Renew command) throws EppException { verifyOptionalAuthInfo(authInfo, existingDomain); verifyNoDisallowedStatuses(existingDomain, RENEW_DISALLOWED_STATUSES); diff --git a/java/google/registry/flows/domain/DomainRestoreRequestFlow.java b/java/google/registry/flows/domain/DomainRestoreRequestFlow.java index 02abe2a5f..197e550e0 100644 --- a/java/google/registry/flows/domain/DomainRestoreRequestFlow.java +++ b/java/google/registry/flows/domain/DomainRestoreRequestFlow.java @@ -48,8 +48,8 @@ import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent.OneTime; import google.registry.model.billing.BillingEvent.OneTime.Builder; import google.registry.model.billing.BillingEvent.Reason; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.DomainCommand.Update; -import google.registry.model.domain.DomainResource; import google.registry.model.domain.fee.BaseFee.FeeType; import google.registry.model.domain.fee.Fee; import google.registry.model.domain.fee.FeeTransformResponseExtension; @@ -134,7 +134,7 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow { verifyRegistrarIsActive(clientId); Update command = (Update) resourceCommand; DateTime now = ofy().getTransactionTime(); - DomainResource existingDomain = loadAndVerifyExistence(DomainResource.class, targetId, now); + DomainBase existingDomain = loadAndVerifyExistence(DomainBase.class, targetId, now); FeesAndCredits feesAndCredits = pricingLogic.getRestorePrice(Registry.get(existingDomain.getTld()), targetId, now); Optional feeUpdate = @@ -160,7 +160,7 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow { .setAutorenewEndTime(END_OF_TIME) .setParent(historyEntry) .build(); - DomainResource newDomain = + DomainBase newDomain = performRestore( existingDomain, newExpirationTime, autorenewEvent, autorenewPollMessage, now, clientId); updateForeignKeyIndexDeletionTime(newDomain); @@ -175,7 +175,7 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow { .build(); } - private HistoryEntry buildHistoryEntry(DomainResource existingDomain, DateTime now) { + private HistoryEntry buildHistoryEntry(DomainBase existingDomain, DateTime now) { return historyBuilder .setType(HistoryEntry.Type.DOMAIN_RESTORE) .setModificationTime(now) @@ -189,7 +189,7 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow { private void verifyRestoreAllowed( Update command, - DomainResource existingDomain, + DomainBase existingDomain, Optional feeUpdate, FeesAndCredits feesAndCredits, DateTime now) throws EppException { @@ -223,8 +223,8 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow { return ImmutableSet.of(restoreEvent, renewEvent); } - private static DomainResource performRestore( - DomainResource existingDomain, + private static DomainBase performRestore( + DomainBase existingDomain, DateTime newExpirationTime, BillingEvent.Recurring autorenewEvent, PollMessage.Autorenew autorenewPollMessage, diff --git a/java/google/registry/flows/domain/DomainTransferApproveFlow.java b/java/google/registry/flows/domain/DomainTransferApproveFlow.java index 555063b06..713cce753 100644 --- a/java/google/registry/flows/domain/DomainTransferApproveFlow.java +++ b/java/google/registry/flows/domain/DomainTransferApproveFlow.java @@ -26,7 +26,7 @@ import static google.registry.flows.domain.DomainFlowUtils.updateAutorenewRecurr import static google.registry.flows.domain.DomainTransferUtils.createGainingTransferPollMessage; import static google.registry.flows.domain.DomainTransferUtils.createTransferResponse; import static google.registry.model.ResourceTransferUtils.approvePendingTransfer; -import static google.registry.model.domain.DomainResource.extendRegistrationWithCap; +import static google.registry.model.domain.DomainBase.extendRegistrationWithCap; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.reporting.DomainTransactionRecord.TransactionReportField.TRANSFER_SUCCESSFUL; import static google.registry.pricing.PricingEngineProxy.getDomainRenewCost; @@ -46,7 +46,7 @@ import google.registry.model.ImmutableObject; import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent.Flag; import google.registry.model.billing.BillingEvent.Reason; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.GracePeriod; import google.registry.model.domain.metadata.MetadataExtension; import google.registry.model.domain.rgp.GracePeriodStatus; @@ -95,7 +95,7 @@ public final class DomainTransferApproveFlow implements TransactionalFlow { /** *

The logic in this flow, which handles client approvals, very closely parallels the logic in - * {@link DomainResource#cloneProjectedAtTime} which handles implicit server approvals. + * {@link DomainBase#cloneProjectedAtTime} which handles implicit server approvals. */ @Override public final EppResponse run() throws EppException { @@ -103,7 +103,7 @@ public final class DomainTransferApproveFlow implements TransactionalFlow { extensionManager.validate(); validateClientIsLoggedIn(clientId); DateTime now = ofy().getTransactionTime(); - DomainResource existingDomain = loadAndVerifyExistence(DomainResource.class, targetId, now); + DomainBase existingDomain = loadAndVerifyExistence(DomainBase.class, targetId, now); verifyOptionalAuthInfo(authInfo, existingDomain); verifyHasPendingTransfer(existingDomain); verifyResourceOwnership(clientId, existingDomain); @@ -173,9 +173,9 @@ public final class DomainTransferApproveFlow implements TransactionalFlow { .setParent(historyEntry) .build(); // Construct the post-transfer domain. - DomainResource partiallyApprovedDomain = + DomainBase partiallyApprovedDomain = approvePendingTransfer(existingDomain, TransferStatus.CLIENT_APPROVED, now); - DomainResource newDomain = + DomainBase newDomain = partiallyApprovedDomain .asBuilder() // Update the transferredRegistrationExpirationTime here since approvePendingTransfer() @@ -223,7 +223,7 @@ public final class DomainTransferApproveFlow implements TransactionalFlow { } private HistoryEntry buildHistoryEntry( - DomainResource existingDomain, Registry registry, DateTime now, String gainingClientId) { + DomainBase existingDomain, Registry registry, DateTime now, String gainingClientId) { ImmutableSet cancelingRecords = createCancelingRecords( existingDomain, diff --git a/java/google/registry/flows/domain/DomainTransferCancelFlow.java b/java/google/registry/flows/domain/DomainTransferCancelFlow.java index 123236e98..7251180cb 100644 --- a/java/google/registry/flows/domain/DomainTransferCancelFlow.java +++ b/java/google/registry/flows/domain/DomainTransferCancelFlow.java @@ -39,7 +39,7 @@ import google.registry.flows.FlowModule.TargetId; import google.registry.flows.TransactionalFlow; import google.registry.flows.annotations.ReportingSpec; import google.registry.model.ImmutableObject; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.metadata.MetadataExtension; import google.registry.model.eppcommon.AuthInfo; import google.registry.model.eppoutput.EppResponse; @@ -88,7 +88,7 @@ public final class DomainTransferCancelFlow implements TransactionalFlow { extensionManager.validate(); validateClientIsLoggedIn(clientId); DateTime now = ofy().getTransactionTime(); - DomainResource existingDomain = loadAndVerifyExistence(DomainResource.class, targetId, now); + DomainBase existingDomain = loadAndVerifyExistence(DomainBase.class, targetId, now); verifyOptionalAuthInfo(authInfo, existingDomain); verifyHasPendingTransfer(existingDomain); verifyTransferInitiator(clientId, existingDomain); @@ -97,7 +97,7 @@ public final class DomainTransferCancelFlow implements TransactionalFlow { } Registry registry = Registry.get(existingDomain.getTld()); HistoryEntry historyEntry = buildHistoryEntry(existingDomain, registry, now); - DomainResource newDomain = + DomainBase newDomain = denyPendingTransfer(existingDomain, TransferStatus.CLIENT_CANCELLED, now, clientId); ofy().save().entities( newDomain, @@ -116,7 +116,7 @@ public final class DomainTransferCancelFlow implements TransactionalFlow { } private HistoryEntry buildHistoryEntry( - DomainResource existingDomain, Registry registry, DateTime now) { + DomainBase existingDomain, Registry registry, DateTime now) { ImmutableSet cancelingRecords = createCancelingRecords( existingDomain, diff --git a/java/google/registry/flows/domain/DomainTransferQueryFlow.java b/java/google/registry/flows/domain/DomainTransferQueryFlow.java index 2e16e40d3..6ce16eda3 100644 --- a/java/google/registry/flows/domain/DomainTransferQueryFlow.java +++ b/java/google/registry/flows/domain/DomainTransferQueryFlow.java @@ -18,7 +18,7 @@ import static google.registry.flows.FlowUtils.validateClientIsLoggedIn; import static google.registry.flows.ResourceFlowUtils.loadAndVerifyExistence; import static google.registry.flows.ResourceFlowUtils.verifyOptionalAuthInfo; import static google.registry.flows.domain.DomainTransferUtils.createTransferResponse; -import static google.registry.model.domain.DomainResource.extendRegistrationWithCap; +import static google.registry.model.domain.DomainBase.extendRegistrationWithCap; import google.registry.flows.EppException; import google.registry.flows.ExtensionManager; @@ -28,7 +28,7 @@ import google.registry.flows.FlowModule.TargetId; import google.registry.flows.annotations.ReportingSpec; import google.registry.flows.exceptions.NoTransferHistoryToQueryException; import google.registry.flows.exceptions.NotAuthorizedToViewTransferException; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.eppcommon.AuthInfo; import google.registry.model.eppoutput.EppResponse; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; @@ -70,7 +70,7 @@ public final class DomainTransferQueryFlow implements Flow { extensionManager.validate(); // There are no legal extensions for this flow. validateClientIsLoggedIn(clientId); DateTime now = clock.nowUtc(); - DomainResource domain = loadAndVerifyExistence(DomainResource.class, targetId, now); + DomainBase domain = loadAndVerifyExistence(DomainBase.class, targetId, now); verifyOptionalAuthInfo(authInfo, domain); // Most of the fields on the transfer response are required, so there's no way to return valid // XML if the object has never been transferred (and hence the fields aren't populated). diff --git a/java/google/registry/flows/domain/DomainTransferRejectFlow.java b/java/google/registry/flows/domain/DomainTransferRejectFlow.java index 3408605fc..4b01ab1b9 100644 --- a/java/google/registry/flows/domain/DomainTransferRejectFlow.java +++ b/java/google/registry/flows/domain/DomainTransferRejectFlow.java @@ -41,7 +41,7 @@ import google.registry.flows.FlowModule.TargetId; import google.registry.flows.TransactionalFlow; import google.registry.flows.annotations.ReportingSpec; import google.registry.model.ImmutableObject; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.metadata.MetadataExtension; import google.registry.model.eppcommon.AuthInfo; import google.registry.model.eppoutput.EppResponse; @@ -90,7 +90,7 @@ public final class DomainTransferRejectFlow implements TransactionalFlow { extensionManager.validate(); validateClientIsLoggedIn(clientId); DateTime now = ofy().getTransactionTime(); - DomainResource existingDomain = loadAndVerifyExistence(DomainResource.class, targetId, now); + DomainBase existingDomain = loadAndVerifyExistence(DomainBase.class, targetId, now); Registry registry = Registry.get(existingDomain.getTld()); HistoryEntry historyEntry = buildHistoryEntry(existingDomain, registry, now); verifyOptionalAuthInfo(authInfo, existingDomain); @@ -99,7 +99,7 @@ public final class DomainTransferRejectFlow implements TransactionalFlow { if (!isSuperuser) { checkAllowedAccessToTld(clientId, existingDomain.getTld()); } - DomainResource newDomain = + DomainBase newDomain = denyPendingTransfer(existingDomain, TransferStatus.CLIENT_REJECTED, now, clientId); ofy().save().entities( newDomain, @@ -118,7 +118,7 @@ public final class DomainTransferRejectFlow implements TransactionalFlow { } private HistoryEntry buildHistoryEntry( - DomainResource existingDomain, Registry registry, DateTime now) { + DomainBase existingDomain, Registry registry, DateTime now) { ImmutableSet cancelingRecords = createCancelingRecords( existingDomain, diff --git a/java/google/registry/flows/domain/DomainTransferRequestFlow.java b/java/google/registry/flows/domain/DomainTransferRequestFlow.java index 7799a08c7..721c9fa17 100644 --- a/java/google/registry/flows/domain/DomainTransferRequestFlow.java +++ b/java/google/registry/flows/domain/DomainTransferRequestFlow.java @@ -29,7 +29,7 @@ import static google.registry.flows.domain.DomainTransferUtils.createLosingTrans import static google.registry.flows.domain.DomainTransferUtils.createPendingTransferData; import static google.registry.flows.domain.DomainTransferUtils.createTransferResponse; import static google.registry.flows.domain.DomainTransferUtils.createTransferServerApproveEntities; -import static google.registry.model.domain.DomainResource.extendRegistrationWithCap; +import static google.registry.model.domain.DomainBase.extendRegistrationWithCap; import static google.registry.model.eppoutput.Result.Code.SUCCESS_WITH_ACTION_PENDING; import static google.registry.model.ofy.ObjectifyService.ofy; @@ -49,8 +49,8 @@ import google.registry.flows.exceptions.InvalidTransferPeriodValueException; import google.registry.flows.exceptions.ObjectAlreadySponsoredException; import google.registry.flows.exceptions.TransferPeriodMustBeOneYearException; import google.registry.flows.exceptions.TransferPeriodZeroAndFeeTransferExtensionException; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.DomainCommand.Transfer; -import google.registry.model.domain.DomainResource; import google.registry.model.domain.Period; import google.registry.model.domain.fee.FeeTransferCommandExtension; import google.registry.model.domain.fee.FeeTransformResponseExtension; @@ -143,7 +143,7 @@ public final class DomainTransferRequestFlow implements TransactionalFlow { validateClientIsLoggedIn(gainingClientId); verifyRegistrarIsActive(gainingClientId); DateTime now = ofy().getTransactionTime(); - DomainResource existingDomain = loadAndVerifyExistence(DomainResource.class, targetId, now); + DomainBase existingDomain = loadAndVerifyExistence(DomainBase.class, targetId, now); Optional superuserExtension = eppInput.getSingleExtension(DomainTransferRequestSuperuserExtension.class); Period period = @@ -182,7 +182,7 @@ public final class DomainTransferRequestFlow implements TransactionalFlow { // See b/19430703#comment17 and https://www.icann.org/news/advisory-2002-06-06-en for the // policy documentation for transfers subsuming autorenews within the autorenew grace period. int extraYears = period.getValue(); - DomainResource domainAtTransferTime = + DomainBase domainAtTransferTime = existingDomain.cloneProjectedAtTime(automaticTransferTime); if (!domainAtTransferTime.getGracePeriodsOfType(GracePeriodStatus.AUTO_RENEW).isEmpty()) { extraYears = 0; @@ -225,7 +225,7 @@ public final class DomainTransferRequestFlow implements TransactionalFlow { // cloneProjectedAtTime() will replace these old autorenew entities with the server approve ones // that we've created in this flow and stored in pendingTransferData. updateAutorenewRecurrenceEndTime(existingDomain, automaticTransferTime); - DomainResource newDomain = + DomainBase newDomain = existingDomain .asBuilder() .setTransferData(pendingTransferData) @@ -248,7 +248,7 @@ public final class DomainTransferRequestFlow implements TransactionalFlow { } private void verifyTransferAllowed( - DomainResource existingDomain, + DomainBase existingDomain, Period period, DateTime now, Optional superuserExtension) @@ -310,7 +310,7 @@ public final class DomainTransferRequestFlow implements TransactionalFlow { } private HistoryEntry buildHistoryEntry( - DomainResource existingDomain, Registry registry, DateTime now, Period period) { + DomainBase existingDomain, Registry registry, DateTime now, Period period) { return historyBuilder .setType(HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST) .setOtherClientId(existingDomain.getCurrentSponsorClientId()) @@ -329,7 +329,7 @@ public final class DomainTransferRequestFlow implements TransactionalFlow { } private DomainTransferResponse createResponse( - Period period, DomainResource existingDomain, DomainResource newDomain, DateTime now) { + Period period, DomainBase existingDomain, DomainBase newDomain, DateTime now) { // If the registration were approved this instant, this is what the new expiration would be, // because we cap at 10 years from the moment of approval. This is different than the server // approval new expiration time, which is capped at 10 years from the server approve time. diff --git a/java/google/registry/flows/domain/DomainTransferUtils.java b/java/google/registry/flows/domain/DomainTransferUtils.java index fe24d01cf..49bab34c4 100644 --- a/java/google/registry/flows/domain/DomainTransferUtils.java +++ b/java/google/registry/flows/domain/DomainTransferUtils.java @@ -24,7 +24,7 @@ import com.googlecode.objectify.Key; import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent.Flag; import google.registry.model.billing.BillingEvent.Reason; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.GracePeriod; import google.registry.model.domain.Period; import google.registry.model.domain.rgp.GracePeriodStatus; @@ -106,7 +106,7 @@ public final class DomainTransferUtils { DateTime automaticTransferTime, DateTime serverApproveNewExpirationTime, HistoryEntry historyEntry, - DomainResource existingDomain, + DomainBase existingDomain, Trid trid, String gainingClientId, Optional transferCost, @@ -258,9 +258,9 @@ public final class DomainTransferUtils { DateTime automaticTransferTime, HistoryEntry historyEntry, String targetId, - DomainResource existingDomain, + DomainBase existingDomain, Optional transferCost) { - DomainResource domainAtTransferTime = + DomainBase domainAtTransferTime = existingDomain.cloneProjectedAtTime(automaticTransferTime); GracePeriod autorenewGracePeriod = getOnlyElement( diff --git a/java/google/registry/flows/domain/DomainUpdateFlow.java b/java/google/registry/flows/domain/DomainUpdateFlow.java index 5aa32a6de..f22d676ed 100644 --- a/java/google/registry/flows/domain/DomainUpdateFlow.java +++ b/java/google/registry/flows/domain/DomainUpdateFlow.java @@ -62,10 +62,10 @@ import google.registry.flows.domain.DomainFlowUtils.MissingRegistrantException; import google.registry.model.ImmutableObject; import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent.Reason; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.DomainCommand.Update; import google.registry.model.domain.DomainCommand.Update.AddRemove; import google.registry.model.domain.DomainCommand.Update.Change; -import google.registry.model.domain.DomainResource; import google.registry.model.domain.fee.FeeUpdateCommandExtension; import google.registry.model.domain.metadata.MetadataExtension; import google.registry.model.domain.secdns.SecDnsUpdateExtension; @@ -162,12 +162,12 @@ public final class DomainUpdateFlow implements TransactionalFlow { validateClientIsLoggedIn(clientId); DateTime now = ofy().getTransactionTime(); Update command = cloneAndLinkReferences((Update) resourceCommand, now); - DomainResource existingDomain = loadAndVerifyExistence(DomainResource.class, targetId, now); + DomainBase existingDomain = loadAndVerifyExistence(DomainBase.class, targetId, now); verifyUpdateAllowed(command, existingDomain, now); flowCustomLogic.afterValidation( AfterValidationParameters.newBuilder().setExistingDomain(existingDomain).build()); HistoryEntry historyEntry = buildHistoryEntry(existingDomain, now); - DomainResource newDomain = performUpdate(command, existingDomain, now); + DomainBase newDomain = performUpdate(command, existingDomain, now); validateNewState(newDomain); dnsQueue.addDomainRefreshTask(targetId); ImmutableSet.Builder entitiesToSave = new ImmutableSet.Builder<>(); @@ -189,7 +189,7 @@ public final class DomainUpdateFlow implements TransactionalFlow { } /** Fail if the object doesn't exist or was deleted. */ - private void verifyUpdateAllowed(Update command, DomainResource existingDomain, DateTime now) + private void verifyUpdateAllowed(Update command, DomainBase existingDomain, DateTime now) throws EppException { verifyOptionalAuthInfo(authInfo, existingDomain); AddRemove add = command.getInnerAdd(); @@ -225,7 +225,7 @@ public final class DomainUpdateFlow implements TransactionalFlow { domainName, nullToEmpty(add.getNameserverFullyQualifiedHostNames())); } - private HistoryEntry buildHistoryEntry(DomainResource existingDomain, DateTime now) { + private HistoryEntry buildHistoryEntry(DomainBase existingDomain, DateTime now) { return historyBuilder .setType(HistoryEntry.Type.DOMAIN_UPDATE) .setModificationTime(now) @@ -233,7 +233,7 @@ public final class DomainUpdateFlow implements TransactionalFlow { .build(); } - private DomainResource performUpdate(Update command, DomainResource domain, DateTime now) + private DomainBase performUpdate(Update command, DomainBase domain, DateTime now) throws EppException { AddRemove add = command.getInnerAdd(); AddRemove remove = command.getInnerRemove(); @@ -244,7 +244,7 @@ public final class DomainUpdateFlow implements TransactionalFlow { validateRegistrantIsntBeingRemoved(change); Optional secDnsUpdate = eppInput.getSingleExtension(SecDnsUpdateExtension.class); - DomainResource.Builder domainBuilder = + DomainBase.Builder domainBuilder = domain .asBuilder() // Handle the secDNS extension. @@ -276,7 +276,7 @@ public final class DomainUpdateFlow implements TransactionalFlow { } } - private void validateNewState(DomainResource newDomain) throws EppException { + private void validateNewState(DomainBase newDomain) throws EppException { validateNoDuplicateContacts(newDomain.getContacts()); validateRequiredContactsPresent(newDomain.getRegistrant(), newDomain.getContacts()); validateDsData(newDomain.getDsData()); @@ -288,8 +288,8 @@ public final class DomainUpdateFlow implements TransactionalFlow { /** Some status updates cost money. Bill only once no matter how many of them are changed. */ private Optional createBillingEventForStatusUpdates( - DomainResource existingDomain, - DomainResource newDomain, + DomainBase existingDomain, + DomainBase newDomain, HistoryEntry historyEntry, DateTime now) { Optional metadataExtension = diff --git a/java/google/registry/flows/host/HostCreateFlow.java b/java/google/registry/flows/host/HostCreateFlow.java index 63aa8c0a0..504addb2e 100644 --- a/java/google/registry/flows/host/HostCreateFlow.java +++ b/java/google/registry/flows/host/HostCreateFlow.java @@ -38,7 +38,7 @@ import google.registry.flows.FlowModule.TargetId; import google.registry.flows.TransactionalFlow; import google.registry.flows.annotations.ReportingSpec; import google.registry.model.ImmutableObject; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.metadata.MetadataExtension; import google.registry.model.eppinput.ResourceCommand; import google.registry.model.eppoutput.CreateData.HostCreateData; @@ -106,7 +106,7 @@ public final class HostCreateFlow implements TransactionalFlow { // The superordinate domain of the host object if creating an in-bailiwick host, or null if // creating an external host. This is looked up before we actually create the Host object so // we can detect error conditions earlier. - Optional superordinateDomain = + Optional superordinateDomain = lookupSuperordinateDomain(validateHostName(targetId), now); verifySuperordinateDomainNotInPendingDelete(superordinateDomain.orElse(null)); verifySuperordinateDomainOwnership(clientId, superordinateDomain.orElse(null)); diff --git a/java/google/registry/flows/host/HostFlowUtils.java b/java/google/registry/flows/host/HostFlowUtils.java index 704eaa397..9ffd7a146 100644 --- a/java/google/registry/flows/host/HostFlowUtils.java +++ b/java/google/registry/flows/host/HostFlowUtils.java @@ -29,7 +29,7 @@ import google.registry.flows.EppException.ParameterValuePolicyErrorException; import google.registry.flows.EppException.ParameterValueRangeErrorException; import google.registry.flows.EppException.ParameterValueSyntaxErrorException; import google.registry.flows.EppException.StatusProhibitsOperationException; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.eppcommon.StatusValue; import google.registry.util.Idn; import java.util.Optional; @@ -77,8 +77,8 @@ public class HostFlowUtils { } } - /** Return the {@link DomainResource} this host is subordinate to, or null for external hosts. */ - public static Optional lookupSuperordinateDomain( + /** Return the {@link DomainBase} this host is subordinate to, or null for external hosts. */ + public static Optional lookupSuperordinateDomain( InternetDomainName hostName, DateTime now) throws EppException { Optional tld = findTldForName(hostName); if (!tld.isPresent()) { @@ -90,8 +90,8 @@ public class HostFlowUtils { hostName.parts().stream() .skip(hostName.parts().size() - (tld.get().parts().size() + 1)) .collect(joining(".")); - Optional superordinateDomain = - loadByForeignKey(DomainResource.class, domainName, now); + Optional superordinateDomain = + loadByForeignKey(DomainBase.class, domainName, now); if (!superordinateDomain.isPresent() || !isActive(superordinateDomain.get(), now)) { throw new SuperordinateDomainDoesNotExistException(domainName); } @@ -101,13 +101,13 @@ public class HostFlowUtils { /** Superordinate domain for this hostname does not exist. */ static class SuperordinateDomainDoesNotExistException extends ObjectDoesNotExistException { public SuperordinateDomainDoesNotExistException(String domainName) { - super(DomainResource.class, domainName); + super(DomainBase.class, domainName); } } /** Ensure that the superordinate domain is sponsored by the provided clientId. */ static void verifySuperordinateDomainOwnership( - String clientId, DomainResource superordinateDomain) throws EppException { + String clientId, DomainBase superordinateDomain) throws EppException { if (superordinateDomain != null && !clientId.equals(superordinateDomain.getCurrentSponsorClientId())) { throw new HostDomainNotOwnedException(); @@ -122,7 +122,7 @@ public class HostFlowUtils { } /** Ensure that the superordinate domain is not in pending delete. */ - static void verifySuperordinateDomainNotInPendingDelete(DomainResource superordinateDomain) + static void verifySuperordinateDomainNotInPendingDelete(DomainBase superordinateDomain) throws EppException { if ((superordinateDomain != null) && superordinateDomain.getStatusValues().contains(StatusValue.PENDING_DELETE)) { diff --git a/java/google/registry/flows/host/HostInfoFlow.java b/java/google/registry/flows/host/HostInfoFlow.java index 6750f0fca..692eceb24 100644 --- a/java/google/registry/flows/host/HostInfoFlow.java +++ b/java/google/registry/flows/host/HostInfoFlow.java @@ -28,7 +28,7 @@ import google.registry.flows.Flow; import google.registry.flows.FlowModule.ClientId; import google.registry.flows.FlowModule.TargetId; import google.registry.flows.annotations.ReportingSpec; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppoutput.EppResponse; import google.registry.model.host.HostInfoData; @@ -77,7 +77,7 @@ public final class HostInfoFlow implements Flow { // the client id, last transfer time, and pending transfer status need to be read off of it. If // there is no superordinate domain, the host's own values for these fields will be correct. if (host.isSubordinate()) { - DomainResource superordinateDomain = + DomainBase superordinateDomain = ofy().load().key(host.getSuperordinateDomain()).now().cloneProjectedAtTime(now); hostInfoDataBuilder .setCurrentSponsorClientId(superordinateDomain.getCurrentSponsorClientId()) diff --git a/java/google/registry/flows/host/HostUpdateFlow.java b/java/google/registry/flows/host/HostUpdateFlow.java index 82c96ea6f..72a4493ec 100644 --- a/java/google/registry/flows/host/HostUpdateFlow.java +++ b/java/google/registry/flows/host/HostUpdateFlow.java @@ -47,7 +47,7 @@ import google.registry.flows.annotations.ReportingSpec; import google.registry.flows.exceptions.ResourceHasClientUpdateProhibitedException; import google.registry.model.EppResource; import google.registry.model.ImmutableObject; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.metadata.MetadataExtension; import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppinput.ResourceCommand; @@ -135,11 +135,11 @@ public final class HostUpdateFlow implements TransactionalFlow { boolean isHostRename = suppliedNewHostName != null; String oldHostName = targetId; String newHostName = firstNonNull(suppliedNewHostName, oldHostName); - DomainResource oldSuperordinateDomain = existingHost.isSubordinate() + DomainBase oldSuperordinateDomain = existingHost.isSubordinate() ? ofy().load().key(existingHost.getSuperordinateDomain()).now().cloneProjectedAtTime(now) : null; // Note that lookupSuperordinateDomain calls cloneProjectedAtTime on the domain for us. - Optional newSuperordinateDomain = + Optional newSuperordinateDomain = lookupSuperordinateDomain(validateHostName(newHostName), now); verifySuperordinateDomainNotInPendingDelete(newSuperordinateDomain.orElse(null)); EppResource owningResource = firstNonNull(oldSuperordinateDomain, existingHost); @@ -152,7 +152,7 @@ public final class HostUpdateFlow implements TransactionalFlow { AddRemove remove = command.getInnerRemove(); checkSameValuesNotAddedAndRemoved(add.getStatusValues(), remove.getStatusValues()); checkSameValuesNotAddedAndRemoved(add.getInetAddresses(), remove.getInetAddresses()); - Key newSuperordinateDomainKey = + Key newSuperordinateDomainKey = newSuperordinateDomain.map(Key::create).orElse(null); // If the superordinateDomain field is changing, set the lastSuperordinateChange to now. DateTime lastSuperordinateChange = @@ -209,7 +209,7 @@ public final class HostUpdateFlow implements TransactionalFlow { private void verifyUpdateAllowed( Update command, HostResource existingHost, - DomainResource newSuperordinateDomain, + DomainBase newSuperordinateDomain, EppResource owningResource, boolean isHostRename) throws EppException { diff --git a/java/google/registry/mapreduce/inputs/EppResourceBaseReader.java b/java/google/registry/mapreduce/inputs/EppResourceBaseReader.java index ab4a7e35a..768142c42 100644 --- a/java/google/registry/mapreduce/inputs/EppResourceBaseReader.java +++ b/java/google/registry/mapreduce/inputs/EppResourceBaseReader.java @@ -40,7 +40,7 @@ abstract class EppResourceBaseReader extends RetryingInputReaderThis can be empty, or any of {"ContactResource", "HostResource", "DomainBase"}. It will - * never contain "EppResource" or "DomainResource" since these aren't actual kinds in Datastore. + * never contain "EppResource" since this isn't an actual kind in Datastore. */ private final ImmutableSet filterKinds; diff --git a/java/google/registry/mapreduce/inputs/EppResourceEntityReader.java b/java/google/registry/mapreduce/inputs/EppResourceEntityReader.java index dda110c50..6e9639fad 100644 --- a/java/google/registry/mapreduce/inputs/EppResourceEntityReader.java +++ b/java/google/registry/mapreduce/inputs/EppResourceEntityReader.java @@ -67,7 +67,7 @@ class EppResourceEntityReader extends EppResourceBaseRead logger.atSevere().log("EppResourceIndex key %s points at a missing resource", key); continue; } - // Postfilter to distinguish polymorphic types (e.g. DomainBase and DomainResource). + // Postfilter to distinguish polymorphic types (e.g. EppResources). for (Class resourceClass : resourceClasses) { if (resourceClass.isAssignableFrom(resource.getClass())) { @SuppressWarnings("unchecked") diff --git a/java/google/registry/mapreduce/inputs/EppResourceInputs.java b/java/google/registry/mapreduce/inputs/EppResourceInputs.java index 6d7ca772e..37ec23713 100644 --- a/java/google/registry/mapreduce/inputs/EppResourceInputs.java +++ b/java/google/registry/mapreduce/inputs/EppResourceInputs.java @@ -16,12 +16,10 @@ package google.registry.mapreduce.inputs; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.collect.Lists.asList; -import static google.registry.util.TypeUtils.hasAnnotation; import com.google.appengine.tools.mapreduce.Input; import com.google.common.collect.ImmutableSet; import com.googlecode.objectify.Key; -import com.googlecode.objectify.annotation.EntitySubclass; import google.registry.model.EppResource; import google.registry.model.ImmutableObject; import google.registry.model.index.EppResourceIndex; @@ -84,13 +82,8 @@ public final class EppResourceInputs { */ @SafeVarargs public static Input> createKeyInput( - Class resourceClass, - Class... moreResourceClasses) { - ImmutableSet> resourceClasses = - ImmutableSet.copyOf(asList(resourceClass, moreResourceClasses)); - checkArgument( - resourceClasses.stream().noneMatch(hasAnnotation(EntitySubclass.class)), - "Mapping over keys requires a non-polymorphic Entity"); - return new EppResourceKeyInput<>(resourceClasses); + Class resourceClass, Class... moreResourceClasses) { + return new EppResourceKeyInput<>( + ImmutableSet.copyOf(asList(resourceClass, moreResourceClasses))); } } diff --git a/java/google/registry/model/EntityClasses.java b/java/google/registry/model/EntityClasses.java index e617fc856..e8787e5eb 100644 --- a/java/google/registry/model/EntityClasses.java +++ b/java/google/registry/model/EntityClasses.java @@ -21,7 +21,6 @@ import google.registry.model.common.EntityGroupRoot; import google.registry.model.common.GaeUserIdConverter; import google.registry.model.contact.ContactResource; import google.registry.model.domain.DomainBase; -import google.registry.model.domain.DomainResource; import google.registry.model.domain.token.AllocationToken; import google.registry.model.host.HostResource; import google.registry.model.index.EppResourceIndex; @@ -73,7 +72,6 @@ public final class EntityClasses { ContactResource.class, Cursor.class, DomainBase.class, - DomainResource.class, EntityGroupRoot.class, EppResourceIndex.class, EppResourceIndexBucket.class, diff --git a/java/google/registry/model/ResourceTransferUtils.java b/java/google/registry/model/ResourceTransferUtils.java index 338fe3129..017e57aa2 100644 --- a/java/google/registry/model/ResourceTransferUtils.java +++ b/java/google/registry/model/ResourceTransferUtils.java @@ -17,7 +17,7 @@ package google.registry.model; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; -import static google.registry.model.domain.DomainResource.extendRegistrationWithCap; +import static google.registry.model.domain.DomainBase.extendRegistrationWithCap; import static google.registry.model.ofy.ObjectifyService.ofy; import com.google.common.collect.ImmutableList; @@ -28,7 +28,7 @@ import google.registry.model.EppResource.BuilderWithTransferData; import google.registry.model.EppResource.ForeignKeyedEppResource; import google.registry.model.EppResource.ResourceWithTransferData; import google.registry.model.contact.ContactResource; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.Trid; import google.registry.model.index.ForeignKeyIndex; @@ -64,7 +64,7 @@ public final class ResourceTransferUtils { if (eppResource instanceof ContactResource) { builder = new ContactTransferResponse.Builder().setContactId(eppResource.getForeignKey()); } else { - DomainResource domain = (DomainResource) eppResource; + DomainBase domain = (DomainBase) eppResource; builder = new DomainTransferResponse.Builder() .setFullyQualifiedDomainName(eppResource.getForeignKey()) @@ -102,7 +102,7 @@ public final class ResourceTransferUtils { } private static void assertIsContactOrDomain(EppResource eppResource) { - checkState(eppResource instanceof ContactResource || eppResource instanceof DomainResource); + checkState(eppResource instanceof ContactResource || eppResource instanceof DomainBase); } /** Update the relevant {@link ForeignKeyIndex} to cache the new deletion time. */ diff --git a/java/google/registry/model/contact/ContactResource.java b/java/google/registry/model/contact/ContactResource.java index 12583b8db..9c09f165f 100644 --- a/java/google/registry/model/contact/ContactResource.java +++ b/java/google/registry/model/contact/ContactResource.java @@ -193,7 +193,7 @@ public class ContactResource extends EppResource implements /** A builder for constructing {@link ContactResource}, since it is immutable. */ public static class Builder extends EppResource.Builder - implements BuilderWithTransferData{ + implements BuilderWithTransferData { public Builder() {} diff --git a/java/google/registry/model/domain/DomainBase.java b/java/google/registry/model/domain/DomainBase.java index e144ea90a..00921d29d 100644 --- a/java/google/registry/model/domain/DomainBase.java +++ b/java/google/registry/model/domain/DomainBase.java @@ -19,13 +19,19 @@ import static com.google.common.base.Strings.emptyToNull; import static com.google.common.collect.ImmutableSet.toImmutableSet; import static com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet; 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.EppResourceUtils.projectResourceOntoBuilderAtTime; +import static google.registry.model.EppResourceUtils.setAutomaticTransferSuccessProperties; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.util.CollectionUtils.forceEmptyToNull; 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.DateTimeUtils.earliestOf; +import static google.registry.util.DateTimeUtils.isBeforeOrAt; +import static google.registry.util.DateTimeUtils.leapSafeAddYears; import static google.registry.util.DomainNameUtils.canonicalizeDomainName; import static google.registry.util.DomainNameUtils.getTldFromDomainName; import static google.registry.util.PreconditionsUtils.checkArgumentNotNull; @@ -40,22 +46,58 @@ import com.googlecode.objectify.annotation.IgnoreSave; import com.googlecode.objectify.annotation.Index; import com.googlecode.objectify.condition.IfNull; import google.registry.model.EppResource; +import google.registry.model.EppResource.ForeignKeyedEppResource; +import google.registry.model.EppResource.ResourceWithTransferData; +import google.registry.model.annotations.ExternalMessagingName; import google.registry.model.annotations.ReportedOn; +import google.registry.model.billing.BillingEvent; import google.registry.model.contact.ContactResource; import google.registry.model.domain.DesignatedContact.Type; import google.registry.model.domain.launch.LaunchNotice; +import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.domain.secdns.DelegationSignerData; +import google.registry.model.eppcommon.StatusValue; import google.registry.model.host.HostResource; +import google.registry.model.poll.PollMessage; +import google.registry.model.registry.Registry; +import google.registry.model.transfer.TransferData; +import google.registry.model.transfer.TransferStatus; +import google.registry.util.CollectionUtils; +import java.util.HashSet; import java.util.Objects; +import java.util.Optional; import java.util.Set; import java.util.function.Predicate; +import javax.annotation.Nullable; +import org.joda.time.DateTime; +import org.joda.time.Interval; -/** Base class for {@link DomainResource}. */ -// TODO(b/121028829): Squash DomainResource into this. +/** + * A persistable domain resource including mutable and non-mutable fields. + * + *

For historical reasons, the name of this entity is "DomainBase". Ideally it would be + * "DomainResource" for linguistic parallelism with the other {@link EppResource} entity classes, + * but that would necessitate a complex data migration which isn't worth it. + * + * @see RFC 5731 + */ @ReportedOn @Entity -public abstract class DomainBase extends EppResource { +@ExternalMessagingName("domain") +public class DomainBase extends EppResource + implements ForeignKeyedEppResource, ResourceWithTransferData { + /** The max number of years that a domain can be registered for, as set by ICANN policy. */ + public static final int MAX_REGISTRATION_YEARS = 10; + + /** Status values which prohibit DNS information from being published. */ + private static final ImmutableSet DNS_PUBLISHING_PROHIBITED_STATUSES = + ImmutableSet.of( + StatusValue.CLIENT_HOLD, + StatusValue.INACTIVE, + StatusValue.PENDING_DELETE, + StatusValue.SERVER_HOLD); + /** * Fully qualified domain name (puny-coded), which serves as the foreign key for this domain. * @@ -109,6 +151,105 @@ public abstract class DomainBase extends EppResource { @IgnoreSave(IfNull.class) String idnTableName; + /** Fully qualified host names of this domain's active subordinate hosts. */ + Set subordinateHosts; + + /** When this domain's registration will expire. */ + DateTime registrationExpirationTime; + + /** + * The poll message associated with this domain being deleted. + * + *

This field should be null if the domain is not in pending delete. If it is, the field should + * refer to a {@link PollMessage} timed to when the domain is fully deleted. If the domain is + * restored, the message should be deleted. + */ + Key deletePollMessage; + + /** + * The recurring billing event associated with this domain's autorenewals. + * + *

The recurrence should be open ended unless the domain is in pending delete or fully deleted, + * in which case it should be closed at the time the delete was requested. Whenever the domain's + * {@link #registrationExpirationTime} is changed the recurrence should be closed, a new one + * should be created, and this field should be updated to point to the new one. + */ + Key autorenewBillingEvent; + + /** + * The recurring poll message associated with this domain's autorenewals. + * + *

The recurrence should be open ended unless the domain is in pending delete or fully deleted, + * in which case it should be closed at the time the delete was requested. Whenever the domain's + * {@link #registrationExpirationTime} is changed the recurrence should be closed, a new one + * should be created, and this field should be updated to point to the new one. + */ + Key autorenewPollMessage; + + /** The unexpired grace periods for this domain (some of which may not be active yet). */ + Set gracePeriods; + + /** + * The id of the signed mark that was used to create this domain in sunrise. + * + *

Will only be populated for domains created in sunrise. + */ + @IgnoreSave(IfNull.class) + String smdId; + + /** Data about any pending or past transfers on this domain. */ + TransferData transferData; + + /** + * The time that this resource was last transferred. + * + *

Can be null if the resource has never been transferred. + */ + DateTime lastTransferTime; + + public ImmutableSet getSubordinateHosts() { + return nullToEmptyImmutableCopy(subordinateHosts); + } + + public DateTime getRegistrationExpirationTime() { + return registrationExpirationTime; + } + + public Key getDeletePollMessage() { + return deletePollMessage; + } + + public Key getAutorenewBillingEvent() { + return autorenewBillingEvent; + } + + public Key getAutorenewPollMessage() { + return autorenewPollMessage; + } + + public ImmutableSet getGracePeriods() { + return nullToEmptyImmutableCopy(gracePeriods); + } + + public String getSmdId() { + return smdId; + } + + @Override + public final TransferData getTransferData() { + return Optional.ofNullable(transferData).orElse(TransferData.EMPTY); + } + + @Override + public DateTime getLastTransferTime() { + return lastTransferTime; + } + + @Override + public String getForeignKey() { + return fullyQualifiedDomainName; + } + public String getFullyQualifiedDomainName() { return fullyQualifiedDomainName; } @@ -133,6 +274,174 @@ public abstract class DomainBase extends EppResource { return getPersistedCurrentSponsorClientId(); } + /** Returns true if DNS information should be published for the given domain. */ + public boolean shouldPublishToDns() { + return intersection(getStatusValues(), DNS_PUBLISHING_PROHIBITED_STATUSES).isEmpty(); + } + + /** + * Returns the Registry Grace Period Statuses for this domain. + * + *

This collects all statuses from the domain's {@link GracePeriod} entries and also adds the + * PENDING_DELETE status if needed. + */ + public ImmutableSet getGracePeriodStatuses() { + Set gracePeriodStatuses = new HashSet<>(); + for (GracePeriod gracePeriod : getGracePeriods()) { + gracePeriodStatuses.add(gracePeriod.getType()); + } + if (getStatusValues().contains(StatusValue.PENDING_DELETE) + && !gracePeriodStatuses.contains(GracePeriodStatus.REDEMPTION)) { + gracePeriodStatuses.add(GracePeriodStatus.PENDING_DELETE); + } + return ImmutableSet.copyOf(gracePeriodStatuses); + } + + /** Returns the subset of grace periods having the specified type. */ + public ImmutableSet getGracePeriodsOfType(GracePeriodStatus gracePeriodType) { + ImmutableSet.Builder builder = new ImmutableSet.Builder<>(); + for (GracePeriod gracePeriod : getGracePeriods()) { + if (gracePeriod.getType() == gracePeriodType) { + builder.add(gracePeriod); + } + } + return builder.build(); + } + + /** + * The logic in this method, which handles implicit server approval of transfers, very closely + * parallels the logic in {@code DomainTransferApproveFlow} which handles explicit client + * approvals. + */ + @Override + public DomainBase cloneProjectedAtTime(final DateTime now) { + + TransferData transferData = getTransferData(); + DateTime transferExpirationTime = transferData.getPendingTransferExpirationTime(); + + // If there's a pending transfer that has expired, handle it. + if (TransferStatus.PENDING.equals(transferData.getTransferStatus()) + && isBeforeOrAt(transferExpirationTime, now)) { + // Project until just before the transfer time. This will handle the case of an autorenew + // before the transfer was even requested or during the request period. + // If the transfer time is precisely the moment that the domain expires, there will not be an + // autorenew billing event (since we end the recurrence at transfer time and recurrences are + // exclusive of their ending), and we can just proceed with the transfer. + DomainBase domainAtTransferTime = + cloneProjectedAtTime(transferExpirationTime.minusMillis(1)); + // If we are within an autorenew grace period, the transfer will subsume the autorenew. There + // will already be a cancellation written in advance by the transfer request flow, so we don't + // need to worry about billing, but we do need to cancel out the expiration time increase. + // The transfer period saved in the transfer data will be one year, unless the superuser + // extension set the transfer period to zero. + int extraYears = transferData.getTransferPeriod().getValue(); + if (domainAtTransferTime.getGracePeriodStatuses().contains(GracePeriodStatus.AUTO_RENEW)) { + extraYears = 0; + } + // Set the expiration, autorenew events, and grace period for the transfer. (Transfer ends + // all other graces). + Builder builder = domainAtTransferTime.asBuilder() + // Extend the registration by the correct number of years from the expiration time that + // was current on the domain right before the transfer, capped at 10 years from the + // moment of the transfer. + .setRegistrationExpirationTime(extendRegistrationWithCap( + transferExpirationTime, + domainAtTransferTime.getRegistrationExpirationTime(), + extraYears)) + // Set the speculatively-written new autorenew events as the domain's autorenew events. + .setAutorenewBillingEvent(transferData.getServerApproveAutorenewEvent()) + .setAutorenewPollMessage(transferData.getServerApproveAutorenewPollMessage()); + if (transferData.getTransferPeriod().getValue() == 1) { + // Set the grace period using a key to the prescheduled transfer billing event. Not using + // GracePeriod.forBillingEvent() here in order to avoid the actual Datastore fetch. + builder.setGracePeriods( + ImmutableSet.of( + GracePeriod.create( + GracePeriodStatus.TRANSFER, + transferExpirationTime.plus( + Registry.get(getTld()).getTransferGracePeriodLength()), + transferData.getGainingClientId(), + transferData.getServerApproveBillingEvent()))); + } else { + // There won't be a billing event, so we don't need a grace period + builder.setGracePeriods(ImmutableSet.of()); + } + // Set all remaining transfer properties. + setAutomaticTransferSuccessProperties(builder, transferData); + builder + .setLastEppUpdateTime(transferExpirationTime) + .setLastEppUpdateClientId(transferData.getGainingClientId()); + // Finish projecting to now. + return builder.build().cloneProjectedAtTime(now); + } + + Optional newLastEppUpdateTime = Optional.empty(); + + // There is no transfer. Do any necessary autorenews. + + Builder builder = asBuilder(); + if (isBeforeOrAt(registrationExpirationTime, now)) { + // Autorenew by the number of years between the old expiration time and now. + DateTime lastAutorenewTime = leapSafeAddYears( + registrationExpirationTime, + new Interval(registrationExpirationTime, now).toPeriod().getYears()); + DateTime newExpirationTime = lastAutorenewTime.plusYears(1); + builder + .setRegistrationExpirationTime(newExpirationTime) + .addGracePeriod( + GracePeriod.createForRecurring( + GracePeriodStatus.AUTO_RENEW, + lastAutorenewTime.plus(Registry.get(getTld()).getAutoRenewGracePeriodLength()), + getCurrentSponsorClientId(), + autorenewBillingEvent)); + newLastEppUpdateTime = Optional.of(lastAutorenewTime); + } + + // Remove any grace periods that have expired. + DomainBase almostBuilt = builder.build(); + builder = almostBuilt.asBuilder(); + for (GracePeriod gracePeriod : almostBuilt.getGracePeriods()) { + if (isBeforeOrAt(gracePeriod.getExpirationTime(), now)) { + builder.removeGracePeriod(gracePeriod); + if (!newLastEppUpdateTime.isPresent() + || isBeforeOrAt(newLastEppUpdateTime.get(), gracePeriod.getExpirationTime())) { + newLastEppUpdateTime = Optional.of(gracePeriod.getExpirationTime()); + } + } + } + + // It is possible that the lastEppUpdateClientId is different from current sponsor client + // id, so we have to do the comparison instead of having one variable just storing the most + // recent time. + if (newLastEppUpdateTime.isPresent()) { + if (getLastEppUpdateTime() == null + || newLastEppUpdateTime.get().isAfter(getLastEppUpdateTime())) { + builder + .setLastEppUpdateTime(newLastEppUpdateTime.get()) + .setLastEppUpdateClientId(getCurrentSponsorClientId()); + } + } + + // Handle common properties like setting or unsetting linked status. This also handles the + // general case of pending transfers for other resource types, but since we've always handled + // a pending transfer by this point that's a no-op for domains. + projectResourceOntoBuilderAtTime(almostBuilt, builder, now); + return builder.build(); + } + + /** Return what the expiration time would be if the given number of years were added to it. */ + public static DateTime extendRegistrationWithCap( + DateTime now, + DateTime currentExpirationTime, + @Nullable Integer extendedRegistrationYears) { + // We must cap registration at the max years (aka 10), even if that truncates the last year. + return earliestOf( + leapSafeAddYears( + currentExpirationTime, + Optional.ofNullable(extendedRegistrationYears).orElse(0)), + leapSafeAddYears(now, MAX_REGISTRATION_YEARS)); + } + /** Loads and returns the fully qualified host names of all linked nameservers. */ public ImmutableSortedSet loadNameserverFullyQualifiedHostNames() { return ofy() @@ -185,21 +494,34 @@ public abstract class DomainBase extends EppResource { /** An override of {@link EppResource#asBuilder} with tighter typing. */ @Override - public abstract Builder asBuilder(); + public Builder asBuilder() { + return new Builder(clone(this)); + } /** A builder for constructing {@link DomainBase}, since it is immutable. */ - public abstract static class Builder> - extends EppResource.Builder { + public static class Builder extends EppResource.Builder + implements BuilderWithTransferData { - protected Builder() {} + public Builder() {} - protected Builder(T instance) { + Builder(DomainBase instance) { super(instance); } @Override - public T build() { - T instance = getInstance(); + public DomainBase build() { + DomainBase instance = getInstance(); + // If TransferData is totally empty, set it to null. + if (TransferData.EMPTY.equals(getInstance().transferData)) { + setTransferData(null); + } + // A DomainBase has status INACTIVE if there are no nameservers. + if (getInstance().getNameservers().isEmpty()) { + addStatusValue(StatusValue.INACTIVE); + } else { // There are nameservers, so make sure INACTIVE isn't there. + removeStatusValue(StatusValue.INACTIVE); + } + checkArgumentNotNull( emptyToNull(instance.fullyQualifiedDomainName), "Missing fullyQualifiedDomainName"); checkArgument(instance.allContacts.stream().anyMatch(IS_REGISTRANT), "Missing registrant"); @@ -207,7 +529,7 @@ public abstract class DomainBase extends EppResource { return super.build(); } - public B setFullyQualifiedDomainName(String fullyQualifiedDomainName) { + public Builder setFullyQualifiedDomainName(String fullyQualifiedDomainName) { checkArgument( fullyQualifiedDomainName.equals(canonicalizeDomainName(fullyQualifiedDomainName)), "Domain name must be in puny-coded, lower-case form"); @@ -215,12 +537,12 @@ public abstract class DomainBase extends EppResource { return thisCastToDerived(); } - public B setDsData(ImmutableSet dsData) { + public Builder setDsData(ImmutableSet dsData) { getInstance().dsData = dsData; return thisCastToDerived(); } - public B setRegistrant(Key registrant) { + public Builder setRegistrant(Key registrant) { // Replace the registrant contact inside allContacts. getInstance().allContacts = union( getInstance().getContacts(), @@ -228,44 +550,44 @@ public abstract class DomainBase extends EppResource { return thisCastToDerived(); } - public B setAuthInfo(DomainAuthInfo authInfo) { + public Builder setAuthInfo(DomainAuthInfo authInfo) { getInstance().authInfo = authInfo; return thisCastToDerived(); } - public B setNameservers(Key nameserver) { + public Builder setNameservers(Key nameserver) { getInstance().nsHosts = ImmutableSet.of(nameserver); return thisCastToDerived(); } - public B setNameservers(ImmutableSet> nameservers) { + public Builder setNameservers(ImmutableSet> nameservers) { getInstance().nsHosts = forceEmptyToNull(nameservers); return thisCastToDerived(); } - public B addNameserver(Key nameserver) { + public Builder addNameserver(Key nameserver) { return addNameservers(ImmutableSet.of(nameserver)); } - public B addNameservers(ImmutableSet> nameservers) { + public Builder addNameservers(ImmutableSet> nameservers) { return setNameservers( ImmutableSet.copyOf(union(getInstance().getNameservers(), nameservers))); } - public B removeNameserver(Key nameserver) { + public Builder removeNameserver(Key nameserver) { return removeNameservers(ImmutableSet.of(nameserver)); } - public B removeNameservers(ImmutableSet> nameservers) { + public Builder removeNameservers(ImmutableSet> nameservers) { return setNameservers( ImmutableSet.copyOf(difference(getInstance().getNameservers(), nameservers))); } - public B setContacts(DesignatedContact contact) { + public Builder setContacts(DesignatedContact contact) { return setContacts(ImmutableSet.of(contact)); } - public B setContacts(ImmutableSet contacts) { + public Builder setContacts(ImmutableSet contacts) { checkArgument(contacts.stream().noneMatch(IS_REGISTRANT), "Registrant cannot be a contact"); // Replace the non-registrant contacts inside allContacts. getInstance().allContacts = @@ -276,22 +598,92 @@ public abstract class DomainBase extends EppResource { return thisCastToDerived(); } - public B addContacts(ImmutableSet contacts) { + public Builder addContacts(ImmutableSet contacts) { return setContacts(ImmutableSet.copyOf(union(getInstance().getContacts(), contacts))); } - public B removeContacts(ImmutableSet contacts) { + public Builder removeContacts(ImmutableSet contacts) { return setContacts(ImmutableSet.copyOf(difference(getInstance().getContacts(), contacts))); } - public B setLaunchNotice(LaunchNotice launchNotice) { + public Builder setLaunchNotice(LaunchNotice launchNotice) { getInstance().launchNotice = launchNotice; return thisCastToDerived(); } - public B setIdnTableName(String idnTableName) { + public Builder setIdnTableName(String idnTableName) { getInstance().idnTableName = idnTableName; return thisCastToDerived(); } + + public Builder setSubordinateHosts(ImmutableSet subordinateHosts) { + getInstance().subordinateHosts = subordinateHosts; + return thisCastToDerived(); + } + + public Builder addSubordinateHost(String hostToAdd) { + return setSubordinateHosts(ImmutableSet.copyOf( + union(getInstance().getSubordinateHosts(), hostToAdd))); + } + + public Builder removeSubordinateHost(String hostToRemove) { + return setSubordinateHosts(ImmutableSet.copyOf( + CollectionUtils.difference(getInstance().getSubordinateHosts(), hostToRemove))); + } + + public Builder setRegistrationExpirationTime(DateTime registrationExpirationTime) { + getInstance().registrationExpirationTime = registrationExpirationTime; + return this; + } + + public Builder setDeletePollMessage(Key deletePollMessage) { + getInstance().deletePollMessage = deletePollMessage; + return this; + } + + public Builder setAutorenewBillingEvent( + Key autorenewBillingEvent) { + getInstance().autorenewBillingEvent = autorenewBillingEvent; + return this; + } + + public Builder setAutorenewPollMessage( + Key autorenewPollMessage) { + getInstance().autorenewPollMessage = autorenewPollMessage; + return this; + } + + public Builder setSmdId(String smdId) { + getInstance().smdId = smdId; + return this; + } + + public Builder setGracePeriods(ImmutableSet gracePeriods) { + getInstance().gracePeriods = gracePeriods; + return this; + } + + public Builder addGracePeriod(GracePeriod gracePeriod) { + getInstance().gracePeriods = union(getInstance().getGracePeriods(), gracePeriod); + return this; + } + + public Builder removeGracePeriod(GracePeriod gracePeriod) { + getInstance().gracePeriods = CollectionUtils + .difference(getInstance().getGracePeriods(), gracePeriod); + return this; + } + + @Override + public Builder setTransferData(TransferData transferData) { + getInstance().transferData = transferData; + return thisCastToDerived(); + } + + @Override + public Builder setLastTransferTime(DateTime lastTransferTime) { + getInstance().lastTransferTime = lastTransferTime; + return thisCastToDerived(); + } } } diff --git a/java/google/registry/model/domain/DomainCommand.java b/java/google/registry/model/domain/DomainCommand.java index 47632377d..dd9764196 100644 --- a/java/google/registry/model/domain/DomainCommand.java +++ b/java/google/registry/model/domain/DomainCommand.java @@ -54,7 +54,7 @@ import javax.xml.bind.annotation.XmlValue; import org.joda.time.DateTime; import org.joda.time.LocalDate; -/** A collection of {@link DomainResource} commands. */ +/** A collection of {@link DomainBase} commands. */ public class DomainCommand { /** The default validity period (if not specified) is 1 year for all operations. */ @@ -72,7 +72,7 @@ public class DomainCommand { /** The fields on "chgType" from {@link "http://tools.ietf.org/html/rfc5731"}. */ @XmlTransient - public static class DomainCreateOrChange> + public static class DomainCreateOrChange extends ImmutableObject implements ResourceCreateOrChange { /** The contactId of the registrant who registered this domain. */ @@ -112,7 +112,7 @@ public class DomainCommand { "foreignKeyedDesignatedContacts", "authInfo"}) public static class Create - extends DomainCreateOrChange> + extends DomainCreateOrChange implements CreateOrUpdate { /** Fully qualified domain name, which serves as a unique identifier for this domain. */ @@ -259,11 +259,11 @@ public class DomainCommand { } } - /** A check request for {@link DomainResource}. */ + /** A check request for {@link DomainBase}. */ @XmlRootElement public static class Check extends ResourceCheck {} - /** A renew command for a {@link DomainResource}. */ + /** A renew command for a {@link DomainBase}. */ @XmlRootElement public static class Renew extends AbstractSingleResourceCommand { @XmlElement(name = "curExpDate") @@ -281,7 +281,7 @@ public class DomainCommand { } } - /** A transfer operation for a {@link DomainResource}. */ + /** A transfer operation for a {@link DomainBase}. */ @XmlRootElement public static class Transfer extends AbstractSingleResourceCommand { /** The period to extend this domain's registration upon completion of the transfer. */ @@ -304,7 +304,7 @@ public class DomainCommand { @XmlRootElement @XmlType(propOrder = {"targetId", "innerAdd", "innerRemove", "innerChange"}) public static class Update - extends ResourceUpdate, Update.Change> + extends ResourceUpdate implements CreateOrUpdate { @XmlElement(name = "chg") @@ -384,7 +384,7 @@ public class DomainCommand { /** The inner change type on a domain update command. */ @XmlType(propOrder = {"registrantContactId", "authInfo"}) - public static class Change extends DomainCreateOrChange> { + public static class Change extends DomainCreateOrChange { /** Creates a copy of this {@link Change} with hard links to hosts and contacts. */ Change cloneAndLinkReferences(DateTime now) throws InvalidReferencesException { Change clone = clone(this); diff --git a/java/google/registry/model/domain/DomainResource.java b/java/google/registry/model/domain/DomainResource.java deleted file mode 100644 index 054ff70e9..000000000 --- a/java/google/registry/model/domain/DomainResource.java +++ /dev/null @@ -1,436 +0,0 @@ -// Copyright 2017 The Nomulus Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - package google.registry.model.domain; - -import static com.google.common.collect.Sets.intersection; -import static google.registry.model.EppResourceUtils.projectResourceOntoBuilderAtTime; -import static google.registry.model.EppResourceUtils.setAutomaticTransferSuccessProperties; -import static google.registry.util.CollectionUtils.difference; -import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy; -import static google.registry.util.CollectionUtils.union; -import static google.registry.util.DateTimeUtils.earliestOf; -import static google.registry.util.DateTimeUtils.isBeforeOrAt; -import static google.registry.util.DateTimeUtils.leapSafeAddYears; - -import com.google.common.collect.ImmutableSet; -import com.googlecode.objectify.Key; -import com.googlecode.objectify.annotation.EntitySubclass; -import com.googlecode.objectify.annotation.IgnoreSave; -import com.googlecode.objectify.condition.IfNull; -import google.registry.model.EppResource.ForeignKeyedEppResource; -import google.registry.model.EppResource.ResourceWithTransferData; -import google.registry.model.annotations.ExternalMessagingName; -import google.registry.model.billing.BillingEvent; -import google.registry.model.domain.rgp.GracePeriodStatus; -import google.registry.model.eppcommon.StatusValue; -import google.registry.model.poll.PollMessage; -import google.registry.model.registry.Registry; -import google.registry.model.transfer.TransferData; -import google.registry.model.transfer.TransferStatus; -import java.util.HashSet; -import java.util.Optional; -import java.util.Set; -import javax.annotation.Nullable; -import org.joda.time.DateTime; -import org.joda.time.Interval; - -/** - * A persistable domain resource including mutable and non-mutable fields. - * - * @see RFC 5731 - */ -@EntitySubclass(index = true) -@ExternalMessagingName("domain") -public class DomainResource extends DomainBase - implements ForeignKeyedEppResource, ResourceWithTransferData { - - /** The max number of years that a domain can be registered for, as set by ICANN policy. */ - public static final int MAX_REGISTRATION_YEARS = 10; - - /** Status values which prohibit DNS information from being published. */ - private static final ImmutableSet DNS_PUBLISHING_PROHIBITED_STATUSES = - ImmutableSet.of( - StatusValue.CLIENT_HOLD, - StatusValue.INACTIVE, - StatusValue.PENDING_DELETE, - StatusValue.SERVER_HOLD); - - /** Fully qualified host names of this domain's active subordinate hosts. */ - Set subordinateHosts; - - /** When this domain's registration will expire. */ - DateTime registrationExpirationTime; - - /** - * The poll message associated with this domain being deleted. - * - *

This field should be null if the domain is not in pending delete. If it is, the field should - * refer to a {@link PollMessage} timed to when the domain is fully deleted. If the domain is - * restored, the message should be deleted. - */ - Key deletePollMessage; - - /** - * The recurring billing event associated with this domain's autorenewals. - * - *

The recurrence should be open ended unless the domain is in pending delete or fully deleted, - * in which case it should be closed at the time the delete was requested. Whenever the domain's - * {@link #registrationExpirationTime} is changed the recurrence should be closed, a new one - * should be created, and this field should be updated to point to the new one. - */ - Key autorenewBillingEvent; - - /** - * The recurring poll message associated with this domain's autorenewals. - * - *

The recurrence should be open ended unless the domain is in pending delete or fully deleted, - * in which case it should be closed at the time the delete was requested. Whenever the domain's - * {@link #registrationExpirationTime} is changed the recurrence should be closed, a new one - * should be created, and this field should be updated to point to the new one. - */ - Key autorenewPollMessage; - - /** The unexpired grace periods for this domain (some of which may not be active yet). */ - Set gracePeriods; - - /** - * The id of the signed mark that was used to create this domain in sunrise. - * - *

Will only be populated for domains created in sunrise. - */ - @IgnoreSave(IfNull.class) - String smdId; - - /** Data about any pending or past transfers on this domain. */ - TransferData transferData; - - /** - * The time that this resource was last transferred. - * - *

Can be null if the resource has never been transferred. - */ - DateTime lastTransferTime; - - public ImmutableSet getSubordinateHosts() { - return nullToEmptyImmutableCopy(subordinateHosts); - } - - public DateTime getRegistrationExpirationTime() { - return registrationExpirationTime; - } - - public Key getDeletePollMessage() { - return deletePollMessage; - } - - public Key getAutorenewBillingEvent() { - return autorenewBillingEvent; - } - - public Key getAutorenewPollMessage() { - return autorenewPollMessage; - } - - public ImmutableSet getGracePeriods() { - return nullToEmptyImmutableCopy(gracePeriods); - } - - public String getSmdId() { - return smdId; - } - - @Override - public final TransferData getTransferData() { - return Optional.ofNullable(transferData).orElse(TransferData.EMPTY); - } - - @Override - public DateTime getLastTransferTime() { - return lastTransferTime; - } - - @Override - public String getForeignKey() { - return fullyQualifiedDomainName; - } - - /** Returns true if DNS information should be published for the given domain. */ - public boolean shouldPublishToDns() { - return intersection(getStatusValues(), DNS_PUBLISHING_PROHIBITED_STATUSES).isEmpty(); - } - - /** - * Returns the Registry Grace Period Statuses for this domain. - * - *

This collects all statuses from the domain's {@link GracePeriod} entries and also adds the - * PENDING_DELETE status if needed. - */ - public ImmutableSet getGracePeriodStatuses() { - Set gracePeriodStatuses = new HashSet<>(); - for (GracePeriod gracePeriod : getGracePeriods()) { - gracePeriodStatuses.add(gracePeriod.getType()); - } - if (getStatusValues().contains(StatusValue.PENDING_DELETE) - && !gracePeriodStatuses.contains(GracePeriodStatus.REDEMPTION)) { - gracePeriodStatuses.add(GracePeriodStatus.PENDING_DELETE); - } - return ImmutableSet.copyOf(gracePeriodStatuses); - } - - /** Returns the subset of grace periods having the specified type. */ - public ImmutableSet getGracePeriodsOfType(GracePeriodStatus gracePeriodType) { - ImmutableSet.Builder builder = new ImmutableSet.Builder<>(); - for (GracePeriod gracePeriod : getGracePeriods()) { - if (gracePeriod.getType() == gracePeriodType) { - builder.add(gracePeriod); - } - } - return builder.build(); - } - - /** - * The logic in this method, which handles implicit server approval of transfers, very closely - * parallels the logic in {@code DomainTransferApproveFlow} which handles explicit client - * approvals. - */ - @Override - public DomainResource cloneProjectedAtTime(final DateTime now) { - - TransferData transferData = getTransferData(); - DateTime transferExpirationTime = transferData.getPendingTransferExpirationTime(); - - // If there's a pending transfer that has expired, handle it. - if (TransferStatus.PENDING.equals(transferData.getTransferStatus()) - && isBeforeOrAt(transferExpirationTime, now)) { - // Project until just before the transfer time. This will handle the case of an autorenew - // before the transfer was even requested or during the request period. - // If the transfer time is precisely the moment that the domain expires, there will not be an - // autorenew billing event (since we end the recurrence at transfer time and recurrences are - // exclusive of their ending), and we can just proceed with the transfer. - DomainResource domainAtTransferTime = - cloneProjectedAtTime(transferExpirationTime.minusMillis(1)); - // If we are within an autorenew grace period, the transfer will subsume the autorenew. There - // will already be a cancellation written in advance by the transfer request flow, so we don't - // need to worry about billing, but we do need to cancel out the expiration time increase. - // The transfer period saved in the transfer data will be one year, unless the superuser - // extension set the transfer period to zero. - int extraYears = transferData.getTransferPeriod().getValue(); - if (domainAtTransferTime.getGracePeriodStatuses().contains(GracePeriodStatus.AUTO_RENEW)) { - extraYears = 0; - } - // Set the expiration, autorenew events, and grace period for the transfer. (Transfer ends - // all other graces). - Builder builder = domainAtTransferTime.asBuilder() - // Extend the registration by the correct number of years from the expiration time that - // was current on the domain right before the transfer, capped at 10 years from the - // moment of the transfer. - .setRegistrationExpirationTime(extendRegistrationWithCap( - transferExpirationTime, - domainAtTransferTime.getRegistrationExpirationTime(), - extraYears)) - // Set the speculatively-written new autorenew events as the domain's autorenew events. - .setAutorenewBillingEvent(transferData.getServerApproveAutorenewEvent()) - .setAutorenewPollMessage(transferData.getServerApproveAutorenewPollMessage()); - if (transferData.getTransferPeriod().getValue() == 1) { - // Set the grace period using a key to the prescheduled transfer billing event. Not using - // GracePeriod.forBillingEvent() here in order to avoid the actual Datastore fetch. - builder.setGracePeriods( - ImmutableSet.of( - GracePeriod.create( - GracePeriodStatus.TRANSFER, - transferExpirationTime.plus( - Registry.get(getTld()).getTransferGracePeriodLength()), - transferData.getGainingClientId(), - transferData.getServerApproveBillingEvent()))); - } else { - // There won't be a billing event, so we don't need a grace period - builder.setGracePeriods(ImmutableSet.of()); - } - // Set all remaining transfer properties. - setAutomaticTransferSuccessProperties(builder, transferData); - builder - .setLastEppUpdateTime(transferExpirationTime) - .setLastEppUpdateClientId(transferData.getGainingClientId()); - // Finish projecting to now. - return builder.build().cloneProjectedAtTime(now); - } - - Optional newLastEppUpdateTime = Optional.empty(); - - // There is no transfer. Do any necessary autorenews. - - Builder builder = asBuilder(); - if (isBeforeOrAt(registrationExpirationTime, now)) { - // Autorenew by the number of years between the old expiration time and now. - DateTime lastAutorenewTime = leapSafeAddYears( - registrationExpirationTime, - new Interval(registrationExpirationTime, now).toPeriod().getYears()); - DateTime newExpirationTime = lastAutorenewTime.plusYears(1); - builder - .setRegistrationExpirationTime(newExpirationTime) - .addGracePeriod( - GracePeriod.createForRecurring( - GracePeriodStatus.AUTO_RENEW, - lastAutorenewTime.plus(Registry.get(getTld()).getAutoRenewGracePeriodLength()), - getCurrentSponsorClientId(), - autorenewBillingEvent)); - newLastEppUpdateTime = Optional.of(lastAutorenewTime); - } - - // Remove any grace periods that have expired. - DomainResource almostBuilt = builder.build(); - builder = almostBuilt.asBuilder(); - for (GracePeriod gracePeriod : almostBuilt.getGracePeriods()) { - if (isBeforeOrAt(gracePeriod.getExpirationTime(), now)) { - builder.removeGracePeriod(gracePeriod); - if (!newLastEppUpdateTime.isPresent() - || isBeforeOrAt(newLastEppUpdateTime.get(), gracePeriod.getExpirationTime())) { - newLastEppUpdateTime = Optional.of(gracePeriod.getExpirationTime()); - } - } - } - - // It is possible that the lastEppUpdateClientId is different from current sponsor client - // id, so we have to do the comparison instead of having one variable just storing the most - // recent time. - if (newLastEppUpdateTime.isPresent()) { - if (getLastEppUpdateTime() == null - || newLastEppUpdateTime.get().isAfter(getLastEppUpdateTime())) { - builder - .setLastEppUpdateTime(newLastEppUpdateTime.get()) - .setLastEppUpdateClientId(getCurrentSponsorClientId()); - } - } - - // Handle common properties like setting or unsetting linked status. This also handles the - // general case of pending transfers for other resource types, but since we've always handled - // a pending transfer by this point that's a no-op for domains. - projectResourceOntoBuilderAtTime(almostBuilt, builder, now); - return builder.build(); - } - - /** Return what the expiration time would be if the given number of years were added to it. */ - public static DateTime extendRegistrationWithCap( - DateTime now, - DateTime currentExpirationTime, - @Nullable Integer extendedRegistrationYears) { - // We must cap registration at the max years (aka 10), even if that truncates the last year. - return earliestOf( - leapSafeAddYears( - currentExpirationTime, - Optional.ofNullable(extendedRegistrationYears).orElse(0)), - leapSafeAddYears(now, MAX_REGISTRATION_YEARS)); - } - - @Override - public Builder asBuilder() { - return new Builder(clone(this)); - } - - /** A builder for constructing {@link DomainResource}, since it is immutable. */ - public static class Builder extends DomainBase.Builder - implements BuilderWithTransferData { - - public Builder() {} - - private Builder(DomainResource instance) { - super(instance); - } - - @Override - public DomainResource build() { - // If TransferData is totally empty, set it to null. - if (TransferData.EMPTY.equals(getInstance().transferData)) { - setTransferData(null); - } - // A DomainResource has status INACTIVE if there are no nameservers. - if (getInstance().getNameservers().isEmpty()) { - addStatusValue(StatusValue.INACTIVE); - } else { // There are nameservers, so make sure INACTIVE isn't there. - removeStatusValue(StatusValue.INACTIVE); - } - // This must be called after we add or remove INACTIVE, since that affects whether we get OK. - return super.build(); - } - - public Builder setSubordinateHosts(ImmutableSet subordinateHosts) { - getInstance().subordinateHosts = subordinateHosts; - return thisCastToDerived(); - } - - public Builder addSubordinateHost(String hostToAdd) { - return setSubordinateHosts(ImmutableSet.copyOf( - union(getInstance().getSubordinateHosts(), hostToAdd))); - } - - public Builder removeSubordinateHost(String hostToRemove) { - return setSubordinateHosts(ImmutableSet.copyOf( - difference(getInstance().getSubordinateHosts(), hostToRemove))); - } - - public Builder setRegistrationExpirationTime(DateTime registrationExpirationTime) { - getInstance().registrationExpirationTime = registrationExpirationTime; - return this; - } - - public Builder setDeletePollMessage(Key deletePollMessage) { - getInstance().deletePollMessage = deletePollMessage; - return this; - } - - public Builder setAutorenewBillingEvent(Key autorenewBillingEvent) { - getInstance().autorenewBillingEvent = autorenewBillingEvent; - return this; - } - - public Builder setAutorenewPollMessage(Key autorenewPollMessage) { - getInstance().autorenewPollMessage = autorenewPollMessage; - return this; - } - - public Builder setSmdId(String smdId) { - getInstance().smdId = smdId; - return this; - } - - public Builder setGracePeriods(ImmutableSet gracePeriods) { - getInstance().gracePeriods = gracePeriods; - return this; - } - - public Builder addGracePeriod(GracePeriod gracePeriod) { - getInstance().gracePeriods = union(getInstance().getGracePeriods(), gracePeriod); - return this; - } - - public Builder removeGracePeriod(GracePeriod gracePeriod) { - getInstance().gracePeriods = difference(getInstance().getGracePeriods(), gracePeriod); - return this; - } - - @Override - public Builder setTransferData(TransferData transferData) { - getInstance().transferData = transferData; - return thisCastToDerived(); - } - - @Override - public Builder setLastTransferTime(DateTime lastTransferTime) { - getInstance().lastTransferTime = lastTransferTime; - return thisCastToDerived(); - } - } -} - diff --git a/java/google/registry/model/domain/GracePeriod.java b/java/google/registry/model/domain/GracePeriod.java index 03d5102bd..27cd16d08 100644 --- a/java/google/registry/model/domain/GracePeriod.java +++ b/java/google/registry/model/domain/GracePeriod.java @@ -28,7 +28,7 @@ import org.joda.time.DateTime; /** * A domain grace period with an expiration time. * - *

When a grace period expires, it is lazily removed from the {@link DomainResource} the next + *

When a grace period expires, it is lazily removed from the {@link DomainBase} the next * time the resource is loaded from Datastore. */ @Embed diff --git a/java/google/registry/model/eppcommon/StatusValue.java b/java/google/registry/model/eppcommon/StatusValue.java index 6f0677aa8..e6584694f 100644 --- a/java/google/registry/model/eppcommon/StatusValue.java +++ b/java/google/registry/model/eppcommon/StatusValue.java @@ -21,7 +21,7 @@ import static com.google.common.base.Strings.nullToEmpty; import com.google.common.collect.ImmutableSet; import google.registry.model.EppResource; import google.registry.model.contact.ContactResource; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.host.HostResource; import google.registry.model.translators.EnumToAttributeAdapter.EppEnum; import google.registry.model.translators.StatusValueAdapter; @@ -127,9 +127,9 @@ public enum StatusValue implements EppEnum { /** Enum to help clearly list which resource types a status value is allowed to be present on. */ private enum AllowedOn { - ALL(ContactResource.class, DomainResource.class, HostResource.class), + ALL(ContactResource.class, DomainBase.class, HostResource.class), NONE, - DOMAINS(DomainResource.class); + DOMAINS(DomainBase.class); private final ImmutableSet> classes; diff --git a/java/google/registry/model/eppinput/EppInput.java b/java/google/registry/model/eppinput/EppInput.java index 8f46d0854..6992e7cbc 100644 --- a/java/google/registry/model/eppinput/EppInput.java +++ b/java/google/registry/model/eppinput/EppInput.java @@ -110,8 +110,8 @@ public class EppInput extends ImmutableObject { return Optional.empty(); } - /** Returns whether this EppInput represents a command that operates on domain resources. */ - public boolean isDomainResourceType() { + /** Returns whether this EppInput represents a command that operates on domains. */ + public boolean isDomainType() { return getResourceType().orElse("").equals("domain"); } diff --git a/java/google/registry/model/host/HostResource.java b/java/google/registry/model/host/HostResource.java index 0ea9696c8..8e8d79ced 100644 --- a/java/google/registry/model/host/HostResource.java +++ b/java/google/registry/model/host/HostResource.java @@ -31,7 +31,7 @@ import google.registry.model.EppResource; import google.registry.model.EppResource.ForeignKeyedEppResource; import google.registry.model.annotations.ExternalMessagingName; import google.registry.model.annotations.ReportedOn; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.transfer.TransferData; import java.net.InetAddress; import java.util.Optional; @@ -70,7 +70,7 @@ public class HostResource extends EppResource implements ForeignKeyedEppResource @Index @IgnoreSave(IfNull.class) @DoNotHydrate - Key superordinateDomain; + Key superordinateDomain; /** * The time that this resource was last transferred. @@ -92,7 +92,7 @@ public class HostResource extends EppResource implements ForeignKeyedEppResource return fullyQualifiedHostName; } - public Key getSuperordinateDomain() { + public Key getSuperordinateDomain() { return superordinateDomain; } @@ -137,7 +137,7 @@ public class HostResource extends EppResource implements ForeignKeyedEppResource * the {@link #superordinateDomain} field. Passing it as a parameter allows the caller to * control the degree of consistency used to load it. */ - public DateTime computeLastTransferTime(@Nullable DomainResource superordinateDomain) { + public DateTime computeLastTransferTime(@Nullable DomainBase superordinateDomain) { if (!isSubordinate()) { checkArgument(superordinateDomain == null); return getLastTransferTime(); @@ -195,7 +195,7 @@ public class HostResource extends EppResource implements ForeignKeyedEppResource difference(getInstance().getInetAddresses(), inetAddresses))); } - public Builder setSuperordinateDomain(Key superordinateDomain) { + public Builder setSuperordinateDomain(Key superordinateDomain) { getInstance().superordinateDomain = superordinateDomain; return this; } diff --git a/java/google/registry/model/index/ForeignKeyIndex.java b/java/google/registry/model/index/ForeignKeyIndex.java index 710146eda..b98bc77c9 100644 --- a/java/google/registry/model/index/ForeignKeyIndex.java +++ b/java/google/registry/model/index/ForeignKeyIndex.java @@ -40,7 +40,7 @@ import google.registry.model.BackupGroupRoot; import google.registry.model.EppResource; import google.registry.model.annotations.ReportedOn; import google.registry.model.contact.ContactResource; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.host.HostResource; import google.registry.util.NonFinalForTesting; import java.util.Map; @@ -62,10 +62,10 @@ public abstract class ForeignKeyIndex extends BackupGroup @Entity public static class ForeignKeyContactIndex extends ForeignKeyIndex {} - /** The {@link ForeignKeyIndex} type for {@link DomainResource} entities. */ + /** The {@link ForeignKeyIndex} type for {@link DomainBase} entities. */ @ReportedOn @Entity - public static class ForeignKeyDomainIndex extends ForeignKeyIndex {} + public static class ForeignKeyDomainIndex extends ForeignKeyIndex {} /** The {@link ForeignKeyIndex} type for {@link HostResource} entities. */ @ReportedOn @@ -77,7 +77,7 @@ public abstract class ForeignKeyIndex extends BackupGroup RESOURCE_CLASS_TO_FKI_CLASS = ImmutableMap.of( ContactResource.class, ForeignKeyContactIndex.class, - DomainResource.class, ForeignKeyDomainIndex.class, + DomainBase.class, ForeignKeyDomainIndex.class, HostResource.class, ForeignKeyHostIndex.class); @Id diff --git a/java/google/registry/model/package-info.java b/java/google/registry/model/package-info.java index e3b1cbef8..47d864b88 100644 --- a/java/google/registry/model/package-info.java +++ b/java/google/registry/model/package-info.java @@ -32,12 +32,15 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; * This package defines all entities which are managed via EPP XML and persisted to the Datastore * via Objectify. * - *

All first class entities are represented as a "Resource" class - {@link DomainResource}, - * {@link HostResource}, {@link ContactResource}, and {@link RegistrarResource}. Resource objects - * are written in a single shared entity group per TLD. All commands that operate on those entities - * are grouped in a "Command" class- {@link DomainCommand}, {@link HostCommand}, - * {@link ContactCommand}. The Resource does double duty as both the persisted representation and as - * the XML-marshallable object returned in respond to Info commands. + *

All first class entities are represented as a resource class - {@link + * google.registry.model.domain.DomainBase}, {@link google.registry.model.host.HostResource}, {@link + * google.registry.model.contact.ContactResource}, and {@link + * google.registry.model.registrar.Registrar}. Resource objects are written in a single shared + * entity group per TLD. All commands that operate on those entities are grouped in a "Command" + * class- {@link google.registry.model.domain.DomainCommand}, {@link + * google.registry.model.host.HostCommand}, {@link google.registry.model.contact.ContactCommand}. + * The Resource does double duty as both the persisted representation and as the XML-marshallable + * object returned in respond to Info commands. * *

Command classes are never persisted, and the Objectify annotations on the Create and Update * classes are purely for the benefit of the derived Resource classes that inherit from them. diff --git a/java/google/registry/rdap/RdapDomainAction.java b/java/google/registry/rdap/RdapDomainAction.java index 01e6bee38..a84a25c3e 100644 --- a/java/google/registry/rdap/RdapDomainAction.java +++ b/java/google/registry/rdap/RdapDomainAction.java @@ -22,7 +22,7 @@ import static google.registry.util.DateTimeUtils.START_OF_TIME; import com.google.common.collect.ImmutableMap; import google.registry.flows.EppException; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.rdap.RdapJsonFormatter.OutputDataType; import google.registry.rdap.RdapMetrics.EndpointType; import google.registry.request.Action; @@ -75,14 +75,14 @@ public class RdapDomainAction extends RdapActionBase { pathSearchString, getHumanReadableObjectTypeName(), e.getMessage())); } // The query string is not used; the RDAP syntax is /rdap/domain/mydomain.com. - Optional domainResource = + Optional domainBase = loadByForeignKey( - DomainResource.class, pathSearchString, shouldIncludeDeleted() ? START_OF_TIME : now); - if (!shouldBeVisible(domainResource, now)) { + DomainBase.class, pathSearchString, shouldIncludeDeleted() ? START_OF_TIME : now); + if (!shouldBeVisible(domainBase, now)) { throw new NotFoundException(pathSearchString + " not found"); } return rdapJsonFormatter.makeRdapJsonForDomain( - domainResource.get(), + domainBase.get(), true, fullServletPath, rdapWhoisServer, diff --git a/java/google/registry/rdap/RdapDomainSearchAction.java b/java/google/registry/rdap/RdapDomainSearchAction.java index 7d82df32a..09a226ea4 100644 --- a/java/google/registry/rdap/RdapDomainSearchAction.java +++ b/java/google/registry/rdap/RdapDomainSearchAction.java @@ -31,7 +31,7 @@ import com.google.common.net.InetAddresses; import com.google.common.primitives.Booleans; import com.googlecode.objectify.Key; import com.googlecode.objectify.cmd.Query; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.host.HostResource; import google.registry.rdap.RdapJsonFormatter.BoilerplateType; import google.registry.rdap.RdapJsonFormatter.OutputDataType; @@ -216,11 +216,11 @@ public class RdapDomainSearchAction extends RdapSearchActionBase { */ private RdapSearchResults searchByDomainNameWithoutWildcard( final RdapSearchPattern partialStringQuery, final DateTime now) { - Optional domainResource = - loadByForeignKey(DomainResource.class, partialStringQuery.getInitialString(), now); + Optional domainBase = + loadByForeignKey(DomainBase.class, partialStringQuery.getInitialString(), now); return makeSearchResults( - shouldBeVisible(domainResource, now) - ? ImmutableList.of(domainResource.get()) + shouldBeVisible(domainBase, now) + ? ImmutableList.of(domainBase.get()) : ImmutableList.of(), now); } @@ -238,10 +238,10 @@ public class RdapDomainSearchAction extends RdapSearchActionBase { // domains directly, rather than the foreign keys, because then we have an index on TLD if we // need it. int querySizeLimit = RESULT_SET_SIZE_SCALING_FACTOR * rdapResultSetMaxSize; - Query query = + Query query = ofy() .load() - .type(DomainResource.class) + .type(DomainBase.class) .filter("fullyQualifiedDomainName <", partialStringQuery.getNextInitialString()) .filter("fullyQualifiedDomainName >=", partialStringQuery.getInitialString()); if (cursorString.isPresent()) { @@ -262,10 +262,10 @@ public class RdapDomainSearchAction extends RdapSearchActionBase { // searchByDomainNameWithInitialString, unable to perform an inequality query on deletion time. // Don't use queryItems, because it doesn't handle pending deletes. int querySizeLimit = RESULT_SET_SIZE_SCALING_FACTOR * rdapResultSetMaxSize; - Query query = + Query query = ofy() .load() - .type(DomainResource.class) + .type(DomainBase.class) .filter("tld", tld); if (cursorString.isPresent()) { query = query.filter("fullyQualifiedDomainName >", cursorString.get()); @@ -368,9 +368,9 @@ public class RdapDomainSearchAction extends RdapSearchActionBase { // The suffix must be a domain that we manage. That way, we can look up the domain and search // through the subordinate hosts. This is more efficient, and lets us permit wildcard searches // with no initial string. - DomainResource domainResource = + DomainBase domainBase = loadByForeignKey( - DomainResource.class, + DomainBase.class, partialStringQuery.getSuffix(), shouldIncludeDeleted() ? START_OF_TIME : now) .orElseThrow( @@ -380,7 +380,7 @@ public class RdapDomainSearchAction extends RdapSearchActionBase { + "must be a domain defined in the system")); Optional desiredRegistrar = getDesiredRegistrar(); ImmutableList.Builder> builder = new ImmutableList.Builder<>(); - for (String fqhn : ImmutableSortedSet.copyOf(domainResource.getSubordinateHosts())) { + for (String fqhn : ImmutableSortedSet.copyOf(domainBase.getSubordinateHosts())) { // We can't just check that the host name starts with the initial query string, because // then the query ns.exam*.example.com would match against nameserver ns.example.com. if (partialStringQuery.matches(fqhn)) { @@ -451,17 +451,17 @@ public class RdapDomainSearchAction extends RdapSearchActionBase { // We must break the query up into chunks, because the in operator is limited to 30 subqueries. // Since it is possible for the same domain to show up more than once in our result list (if // we do a wildcard nameserver search that returns multiple nameservers used by the same - // domain), we must create a set of resulting {@link DomainResource} objects. Use a sorted set, + // domain), we must create a set of resulting {@link DomainBase} objects. Use a sorted set, // and fetch all domains, to make sure that we can return the first domains in alphabetical // order. - ImmutableSortedSet.Builder domainSetBuilder = + ImmutableSortedSet.Builder domainSetBuilder = ImmutableSortedSet.orderedBy( - Comparator.comparing(DomainResource::getFullyQualifiedDomainName)); + Comparator.comparing(DomainBase::getFullyQualifiedDomainName)); int numHostKeysSearched = 0; for (List> chunk : Iterables.partition(hostKeys, 30)) { numHostKeysSearched += chunk.size(); - Query query = ofy().load() - .type(DomainResource.class) + Query query = ofy().load() + .type(DomainBase.class) .filter("nsHosts in", chunk); if (!shouldIncludeDeleted()) { query = query.filter("deletionTime >", now); @@ -470,7 +470,7 @@ public class RdapDomainSearchAction extends RdapSearchActionBase { } else if (cursorString.isPresent()) { query = query.filter("fullyQualifiedDomainName >", cursorString.get()); } - Stream stream = + Stream stream = Streams.stream(query).filter(domain -> isAuthorized(domain, now)); if (cursorString.isPresent()) { stream = @@ -479,7 +479,7 @@ public class RdapDomainSearchAction extends RdapSearchActionBase { } stream.forEach(domainSetBuilder::add); } - List domains = domainSetBuilder.build().asList(); + List domains = domainSetBuilder.build().asList(); metricInformationBuilder.setNumHostsRetrieved(numHostKeysSearched); if (domains.size() > rdapResultSetMaxSize) { return makeSearchResults( @@ -502,14 +502,14 @@ public class RdapDomainSearchAction extends RdapSearchActionBase { } /** Output JSON for a list of domains, with no incompleteness warnings. */ - private RdapSearchResults makeSearchResults(List domains, DateTime now) { + private RdapSearchResults makeSearchResults(List domains, DateTime now) { return makeSearchResults( domains, IncompletenessWarningType.COMPLETE, Optional.of((long) domains.size()), now); } /** Output JSON from data in an {@link RdapResultSet} object. */ private RdapSearchResults makeSearchResults( - RdapResultSet resultSet, DateTime now) { + RdapResultSet resultSet, DateTime now) { return makeSearchResults( resultSet.resources(), resultSet.incompletenessWarningType(), @@ -525,7 +525,7 @@ public class RdapDomainSearchAction extends RdapSearchActionBase { * maximum number of nameservers in the first stage query. */ private RdapSearchResults makeSearchResults( - List domains, + List domains, IncompletenessWarningType incompletenessWarningType, Optional numDomainsRetrieved, DateTime now) { @@ -535,7 +535,7 @@ public class RdapDomainSearchAction extends RdapSearchActionBase { RdapAuthorization authorization = getAuthorization(); List> jsonList = new ArrayList<>(); Optional newCursor = Optional.empty(); - for (DomainResource domain : domains) { + for (DomainBase domain : domains) { newCursor = Optional.of(domain.getFullyQualifiedDomainName()); jsonList.add( rdapJsonFormatter.makeRdapJsonForDomain( diff --git a/java/google/registry/rdap/RdapJsonFormatter.java b/java/google/registry/rdap/RdapJsonFormatter.java index d64dfaf5b..b72f22245 100644 --- a/java/google/registry/rdap/RdapJsonFormatter.java +++ b/java/google/registry/rdap/RdapJsonFormatter.java @@ -39,7 +39,7 @@ import google.registry.model.contact.ContactResource; import google.registry.model.contact.PostalInfo; import google.registry.model.domain.DesignatedContact; import google.registry.model.domain.DesignatedContact.Type; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.eppcommon.Address; import google.registry.model.eppcommon.StatusValue; import google.registry.model.host.HostResource; @@ -455,9 +455,9 @@ public class RdapJsonFormatter { } /** - * Creates a JSON object for a {@link DomainResource}. + * Creates a JSON object for a {@link DomainBase}. * - * @param domainResource the domain resource object from which the JSON object should be created + * @param domainBase the domain resource object from which the JSON object should be created * @param isTopLevel if true, the top-level boilerplate will be added * @param linkBase the URL base to be used when creating links * @param whoisServer the fully-qualified domain name of the WHOIS server to be listed in the @@ -468,7 +468,7 @@ public class RdapJsonFormatter { * registrar owning the domain, no contact information is included */ ImmutableMap makeRdapJsonForDomain( - DomainResource domainResource, + DomainBase domainBase, boolean isTopLevel, @Nullable String linkBase, @Nullable String whoisServer, @@ -478,22 +478,22 @@ public class RdapJsonFormatter { // Start with the domain-level information. ImmutableMap.Builder jsonBuilder = new ImmutableMap.Builder<>(); jsonBuilder.put("objectClassName", "domain"); - jsonBuilder.put("handle", domainResource.getRepoId()); - jsonBuilder.put("ldhName", domainResource.getFullyQualifiedDomainName()); + jsonBuilder.put("handle", domainBase.getRepoId()); + jsonBuilder.put("ldhName", domainBase.getFullyQualifiedDomainName()); // Only include the unicodeName field if there are unicode characters. - if (hasUnicodeComponents(domainResource.getFullyQualifiedDomainName())) { - jsonBuilder.put("unicodeName", Idn.toUnicode(domainResource.getFullyQualifiedDomainName())); + if (hasUnicodeComponents(domainBase.getFullyQualifiedDomainName())) { + jsonBuilder.put("unicodeName", Idn.toUnicode(domainBase.getFullyQualifiedDomainName())); } jsonBuilder.put( "status", makeStatusValueList( - domainResource.getStatusValues(), + domainBase.getStatusValues(), false, // isRedacted - domainResource.getDeletionTime().isBefore(now))); + domainBase.getDeletionTime().isBefore(now))); jsonBuilder.put("links", ImmutableList.of( - makeLink("domain", domainResource.getFullyQualifiedDomainName(), linkBase))); + makeLink("domain", domainBase.getFullyQualifiedDomainName(), linkBase))); boolean displayContacts = - authorization.isAuthorizedForClientId(domainResource.getCurrentSponsorClientId()); + authorization.isAuthorizedForClientId(domainBase.getCurrentSponsorClientId()); // If we are outputting all data (not just summary data), also add information about hosts, // contacts and events (history entries). If we are outputting summary data, instead add a // remark indicating that fact. @@ -504,26 +504,26 @@ public class RdapJsonFormatter { remarks = displayContacts ? ImmutableList.of() : ImmutableList.of(RdapIcannStandardInformation.DOMAIN_CONTACTS_HIDDEN_DATA_REMARK); - ImmutableList events = makeEvents(domainResource, now); + ImmutableList events = makeEvents(domainBase, now); if (!events.isEmpty()) { jsonBuilder.put("events", events); } // Kick off the database loads of the nameservers that we will need, so it can load // asynchronously while we load and process the contacts. Map, HostResource> loadedHosts = - ofy().load().keys(domainResource.getNameservers()); + ofy().load().keys(domainBase.getNameservers()); // Load the registrant and other contacts and add them to the data. ImmutableList> entities; if (!displayContacts) { entities = ImmutableList.of(); } else { Map, ContactResource> loadedContacts = - ofy().load().keys(domainResource.getReferencedContacts()); + ofy().load().keys(domainBase.getReferencedContacts()); entities = Streams.concat( - domainResource.getContacts().stream(), + domainBase.getContacts().stream(), Stream.of( - DesignatedContact.create(Type.REGISTRANT, domainResource.getRegistrant()))) + DesignatedContact.create(Type.REGISTRANT, domainBase.getRegistrant()))) .sorted(DESIGNATED_CONTACT_ORDERING) .map( designatedContact -> @@ -540,7 +540,7 @@ public class RdapJsonFormatter { } entities = addRegistrarEntity( - entities, domainResource.getCurrentSponsorClientId(), linkBase, whoisServer, now); + entities, domainBase.getCurrentSponsorClientId(), linkBase, whoisServer, now); if (!entities.isEmpty()) { jsonBuilder.put("entities", entities); } @@ -1022,8 +1022,8 @@ public class RdapJsonFormatter { eventsBuilder.add(makeEvent( eventAction, historyEntry.getClientId(), historyEntry.getModificationTime())); } - if (resource instanceof DomainResource) { - DateTime expirationTime = ((DomainResource) resource).getRegistrationExpirationTime(); + if (resource instanceof DomainBase) { + DateTime expirationTime = ((DomainBase) resource).getRegistrationExpirationTime(); if (expirationTime != null) { eventsBuilder.add(makeEvent(RdapEventAction.EXPIRATION, null, expirationTime)); } diff --git a/java/google/registry/rdap/RdapNameserverSearchAction.java b/java/google/registry/rdap/RdapNameserverSearchAction.java index 624c31b85..91c8af0b8 100644 --- a/java/google/registry/rdap/RdapNameserverSearchAction.java +++ b/java/google/registry/rdap/RdapNameserverSearchAction.java @@ -25,7 +25,7 @@ import com.google.common.collect.Iterables; import com.google.common.net.InetAddresses; import com.google.common.primitives.Booleans; import com.googlecode.objectify.cmd.Query; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.host.HostResource; import google.registry.rdap.RdapJsonFormatter.BoilerplateType; import google.registry.rdap.RdapJsonFormatter.OutputDataType; @@ -204,9 +204,9 @@ public class RdapNameserverSearchAction extends RdapSearchActionBase { /** Searches for nameservers by name using the superordinate domain as a suffix. */ private RdapSearchResults searchByNameUsingSuperordinateDomain( final RdapSearchPattern partialStringQuery, final DateTime now) { - Optional domainResource = - loadByForeignKey(DomainResource.class, partialStringQuery.getSuffix(), now); - if (!domainResource.isPresent()) { + Optional domainBase = + loadByForeignKey(DomainBase.class, partialStringQuery.getSuffix(), now); + if (!domainBase.isPresent()) { // Don't allow wildcards with suffixes which are not domains we manage. That would risk a // table scan in many easily foreseeable cases. The user might ask for ns*.zombo.com, // forcing us to query for all hosts beginning with ns, then filter for those ending in @@ -216,7 +216,7 @@ public class RdapNameserverSearchAction extends RdapSearchActionBase { "A suffix after a wildcard in a nameserver lookup must be an in-bailiwick domain"); } List hostList = new ArrayList<>(); - for (String fqhn : ImmutableSortedSet.copyOf(domainResource.get().getSubordinateHosts())) { + for (String fqhn : ImmutableSortedSet.copyOf(domainBase.get().getSubordinateHosts())) { if (cursorString.isPresent() && (fqhn.compareTo(cursorString.get()) <= 0)) { continue; } @@ -235,7 +235,7 @@ public class RdapNameserverSearchAction extends RdapSearchActionBase { return makeSearchResults( hostList, IncompletenessWarningType.COMPLETE, - domainResource.get().getSubordinateHosts().size(), + domainBase.get().getSubordinateHosts().size(), CursorType.NAME, now); } diff --git a/java/google/registry/rde/DomainResourceToXjcConverter.java b/java/google/registry/rde/DomainBaseToXjcConverter.java similarity index 95% rename from java/google/registry/rde/DomainResourceToXjcConverter.java rename to java/google/registry/rde/DomainBaseToXjcConverter.java index 37b079c87..4af3c0c31 100644 --- a/java/google/registry/rde/DomainResourceToXjcConverter.java +++ b/java/google/registry/rde/DomainBaseToXjcConverter.java @@ -24,7 +24,7 @@ import com.google.common.flogger.FluentLogger; import com.googlecode.objectify.Key; import google.registry.model.contact.ContactResource; import google.registry.model.domain.DesignatedContact; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.eppcommon.StatusValue; @@ -47,18 +47,18 @@ import google.registry.xjc.secdns.XjcSecdnsDsDataType; import google.registry.xjc.secdns.XjcSecdnsDsOrKeyType; import org.joda.time.DateTime; -/** Utility class that turns {@link DomainResource} as {@link XjcRdeDomainElement}. */ -final class DomainResourceToXjcConverter { +/** Utility class that turns {@link DomainBase} as {@link XjcRdeDomainElement}. */ +final class DomainBaseToXjcConverter { private static final FluentLogger logger = FluentLogger.forEnclosingClass(); - /** Converts {@link DomainResource} to {@link XjcRdeDomainElement}. */ - static XjcRdeDomainElement convert(DomainResource domain, RdeMode mode) { + /** Converts {@link DomainBase} to {@link XjcRdeDomainElement}. */ + static XjcRdeDomainElement convert(DomainBase domain, RdeMode mode) { return new XjcRdeDomainElement(convertDomain(domain, mode)); } - /** Converts {@link DomainResource} to {@link XjcRdeDomain}. */ - static XjcRdeDomain convertDomain(DomainResource model, RdeMode mode) { + /** Converts {@link DomainBase} to {@link XjcRdeDomain}. */ + static XjcRdeDomain convertDomain(DomainBase model, RdeMode mode) { XjcRdeDomain bean = new XjcRdeDomain(); // o A element that contains the fully qualified name of the @@ -236,7 +236,7 @@ final class DomainResourceToXjcConverter { // * An OPTIONAL element that contains the end of the // domain name object's validity period (expiry date) if the // transfer caused or causes a change in the validity period. - if (model.getTransferData() != TransferData.EMPTY) { + if (!model.getTransferData().equals(TransferData.EMPTY)) { // Temporary check to make sure that there really was a transfer. A bug caused spurious // empty transfer records to get generated for deleted domains. // TODO(b/33289763): remove the hasGainingAndLosingRegistrars check in February 2017 @@ -254,7 +254,7 @@ final class DomainResourceToXjcConverter { return bean; } - private static boolean hasGainingAndLosingRegistrars(DomainResource model) { + private static boolean hasGainingAndLosingRegistrars(DomainBase model) { return !Strings.isNullOrEmpty(model.getTransferData().getGainingClientId()) && !Strings.isNullOrEmpty(model.getTransferData().getLosingClientId()); @@ -324,5 +324,5 @@ final class DomainResourceToXjcConverter { return bean; } - private DomainResourceToXjcConverter() {} + private DomainBaseToXjcConverter() {} } diff --git a/java/google/registry/rde/HostResourceToXjcConverter.java b/java/google/registry/rde/HostResourceToXjcConverter.java index b699d246f..ce929f8c4 100644 --- a/java/google/registry/rde/HostResourceToXjcConverter.java +++ b/java/google/registry/rde/HostResourceToXjcConverter.java @@ -18,7 +18,7 @@ import static com.google.common.base.Preconditions.checkArgument; import com.google.common.net.InetAddresses; import com.googlecode.objectify.Key; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.eppcommon.StatusValue; import google.registry.model.host.HostResource; import google.registry.xjc.host.XjcHostAddrType; @@ -36,7 +36,7 @@ final class HostResourceToXjcConverter { /** Converts a subordinate {@link HostResource} to {@link XjcRdeHostElement}. */ static XjcRdeHostElement convertSubordinate( - HostResource host, DomainResource superordinateDomain) { + HostResource host, DomainBase superordinateDomain) { checkArgument(Key.create(superordinateDomain).equals(host.getSuperordinateDomain())); return new XjcRdeHostElement(convertSubordinateHost(host, superordinateDomain)); } @@ -48,7 +48,7 @@ final class HostResourceToXjcConverter { } /** Converts {@link HostResource} to {@link XjcRdeHost}. */ - static XjcRdeHost convertSubordinateHost(HostResource model, DomainResource superordinateDomain) { + static XjcRdeHost convertSubordinateHost(HostResource model, DomainBase superordinateDomain) { XjcRdeHost bean = convertHostCommon( model, superordinateDomain.getCurrentSponsorClientId(), diff --git a/java/google/registry/rde/RdeMarshaller.java b/java/google/registry/rde/RdeMarshaller.java index 5a6866b06..7a92cf772 100644 --- a/java/google/registry/rde/RdeMarshaller.java +++ b/java/google/registry/rde/RdeMarshaller.java @@ -21,7 +21,7 @@ import com.google.common.flogger.FluentLogger; import com.googlecode.objectify.Key; import google.registry.model.ImmutableObject; import google.registry.model.contact.ContactResource; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.host.HostResource; import google.registry.model.rde.RdeMode; import google.registry.model.registrar.Registrar; @@ -123,15 +123,15 @@ public final class RdeMarshaller implements Serializable { ContactResourceToXjcConverter.convert(contact)); } - /** Turns {@link DomainResource} object into an XML fragment. */ - public DepositFragment marshalDomain(DomainResource domain, RdeMode mode) { + /** Turns {@link DomainBase} object into an XML fragment. */ + public DepositFragment marshalDomain(DomainBase domain, RdeMode mode) { return marshalResource(RdeResourceType.DOMAIN, domain, - DomainResourceToXjcConverter.convert(domain, mode)); + DomainBaseToXjcConverter.convert(domain, mode)); } /** Turns {@link HostResource} object into an XML fragment. */ public DepositFragment marshalSubordinateHost( - HostResource host, DomainResource superordinateDomain) { + HostResource host, DomainBase superordinateDomain) { return marshalResource(RdeResourceType.HOST, host, HostResourceToXjcConverter.convertSubordinate(host, superordinateDomain)); } diff --git a/java/google/registry/rde/RdeStagingMapper.java b/java/google/registry/rde/RdeStagingMapper.java index 09e347b7a..5c3f8da67 100644 --- a/java/google/registry/rde/RdeStagingMapper.java +++ b/java/google/registry/rde/RdeStagingMapper.java @@ -28,7 +28,7 @@ import com.google.common.collect.Maps; import com.googlecode.objectify.Result; import google.registry.model.EppResource; import google.registry.model.contact.ContactResource; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.host.HostResource; import google.registry.model.rde.RdeMode; import google.registry.model.registrar.Registrar; @@ -75,7 +75,7 @@ public final class RdeStagingMapper extends Mapper tlds; - if (resource instanceof DomainResource) { - String tld = ((DomainResource) resource).getTld(); + if (resource instanceof DomainBase) { + String tld = ((DomainBase) resource).getTld(); if (!pendings.containsKey(tld)) { - getContext().incrementCounter("DomainResource of an unneeded TLD skipped"); + getContext().incrementCounter("DomainBase of an unneeded TLD skipped"); return; } - getContext().incrementCounter("DomainResource instances"); + getContext().incrementCounter("DomainBase instances"); tlds = ImmutableSet.of(tld); } else { - getContext().incrementCounter("non-DomainResource instances"); + getContext().incrementCounter("non-DomainBase instances"); // Contacts and hosts get emitted on all TLDs, even if domains don't reference them. tlds = pendings.keySet(); } @@ -175,8 +175,8 @@ public final class RdeStagingMapper extends MapperIf a mapShards parameter has been specified, up to that many readers will be created * so that each map shard has one reader. If a mapShards parameter has not been specified, a diff --git a/java/google/registry/rde/imports/RdeHostLinkAction.java b/java/google/registry/rde/imports/RdeHostLinkAction.java index a47f5ab67..0e349f816 100644 --- a/java/google/registry/rde/imports/RdeHostLinkAction.java +++ b/java/google/registry/rde/imports/RdeHostLinkAction.java @@ -30,7 +30,7 @@ import google.registry.config.RegistryConfig.Config; import google.registry.flows.host.HostFlowUtils; import google.registry.mapreduce.MapreduceRunner; import google.registry.model.EppResource; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.eppcommon.StatusValue; import google.registry.model.host.HostResource; import google.registry.request.Action; @@ -49,7 +49,7 @@ import org.joda.time.DateTime; * *

This mapreduce is run as the last step of the process of importing escrow files. For each host * in the escrow file, the corresponding {@link HostResource} record in Datastore is linked to its - * superordinate {@link DomainResource} only if it is an in-zone host. This is necessary because all + * superordinate {@link DomainBase} only if it is an in-zone host. This is necessary because all * hosts must exist before domains can be imported, due to references in host objects, and domains * must exist before hosts can be linked to their superordinate domains. * @@ -110,7 +110,7 @@ public class RdeHostLinkAction implements Runnable { final InternetDomainName hostName = InternetDomainName.from(xjcHost.getName()); HostLinkResult hostLinkResult = ofy().transact(() -> { - Optional superordinateDomain = + Optional superordinateDomain = lookupSuperordinateDomain(hostName, ofy().getTransactionTime()); // if suporordinateDomain is absent, this is an out of zone host and can't be linked. // absent is only returned for out of zone hosts, and an exception is thrown for in @@ -121,7 +121,7 @@ public class RdeHostLinkAction implements Runnable { if (superordinateDomain.get().getStatusValues().contains(StatusValue.PENDING_DELETE)) { return HostLinkResult.SUPERORDINATE_DOMAIN_IN_PENDING_DELETE; } - Key superordinateDomainKey = Key.create(superordinateDomain.get()); + Key superordinateDomainKey = Key.create(superordinateDomain.get()); // link host to superordinate domain and set time of last superordinate change to // the time of the import HostResource host = @@ -172,7 +172,7 @@ public class RdeHostLinkAction implements Runnable { } /** - * Return the {@link DomainResource} this host is subordinate to, or absent for out of zone + * Return the {@link DomainBase} this host is subordinate to, or absent for out of zone * hosts. * *

We use this instead of {@link HostFlowUtils#lookupSuperordinateDomain} because we don't @@ -181,7 +181,7 @@ public class RdeHostLinkAction implements Runnable { * * @throws IllegalStateException for hosts without superordinate domains */ - private static Optional lookupSuperordinateDomain( + private static Optional lookupSuperordinateDomain( InternetDomainName hostName, DateTime now) { Optional tld = findTldForName(hostName); // out of zone hosts cannot be linked @@ -195,8 +195,8 @@ public class RdeHostLinkAction implements Runnable { .stream() .skip(hostName.parts().size() - (tld.get().parts().size() + 1)) .collect(joining(".")); - Optional superordinateDomain = - loadByForeignKey(DomainResource.class, domainName, now); + Optional superordinateDomain = + loadByForeignKey(DomainBase.class, domainName, now); // Hosts can't be linked if domains import hasn't been run checkState( superordinateDomain.isPresent(), diff --git a/java/google/registry/rde/imports/RdeImportUtils.java b/java/google/registry/rde/imports/RdeImportUtils.java index f34815ed0..a33046de2 100644 --- a/java/google/registry/rde/imports/RdeImportUtils.java +++ b/java/google/registry/rde/imports/RdeImportUtils.java @@ -38,7 +38,7 @@ import google.registry.model.EppResource.ForeignKeyedEppResource; import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent.Flag; import google.registry.model.billing.BillingEvent.Reason; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.eppcommon.Trid; import google.registry.model.index.EppResourceIndex; import google.registry.model.index.ForeignKeyIndex; @@ -223,7 +223,7 @@ public class RdeImportUtils { .setBySuperuser(true) .setReason("RDE Import") .setRequestedByRegistrar(false) - .setParent(Key.create(null, DomainResource.class, domain.getRoid())) + .setParent(Key.create(null, DomainBase.class, domain.getRoid())) .build(); } diff --git a/java/google/registry/rde/imports/XjcToDomainResourceConverter.java b/java/google/registry/rde/imports/XjcToDomainBaseConverter.java similarity index 94% rename from java/google/registry/rde/imports/XjcToDomainResourceConverter.java rename to java/google/registry/rde/imports/XjcToDomainBaseConverter.java index e8dd07969..6ab586a1b 100644 --- a/java/google/registry/rde/imports/XjcToDomainResourceConverter.java +++ b/java/google/registry/rde/imports/XjcToDomainBaseConverter.java @@ -29,7 +29,7 @@ import google.registry.model.billing.BillingEvent; import google.registry.model.contact.ContactResource; import google.registry.model.domain.DesignatedContact; import google.registry.model.domain.DomainAuthInfo; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.GracePeriod; import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.domain.secdns.DelegationSignerData; @@ -55,8 +55,8 @@ import google.registry.xjc.secdns.XjcSecdnsDsDataType; import java.util.function.Function; import org.joda.time.DateTime; -/** Utility class that converts an {@link XjcRdeDomainElement} into a {@link DomainResource}. */ -final class XjcToDomainResourceConverter extends XjcToEppResourceConverter { +/** Utility class that converts an {@link XjcRdeDomainElement} into a {@link DomainBase}. */ +final class XjcToDomainBaseConverter extends XjcToEppResourceConverter { private static final XmlToEnumMapper TRANSFER_STATUS_MAPPER = XmlToEnumMapper.create(TransferStatus.values()); @@ -131,16 +131,16 @@ final class XjcToDomainResourceConverter extends XjcToEppResourceConverter { } } - /** Converts {@link XjcRdeDomain} to {@link DomainResource}. */ - static DomainResource convertDomain( + /** Converts {@link XjcRdeDomain} to {@link DomainBase}. */ + static DomainBase convertDomain( XjcRdeDomain domain, BillingEvent.Recurring autoRenewBillingEvent, PollMessage.Autorenew autoRenewPollMessage, StringGenerator stringGenerator) { GracePeriodConverter gracePeriodConverter = new GracePeriodConverter(domain, Key.create(autoRenewBillingEvent)); - DomainResource.Builder builder = - new DomainResource.Builder() + DomainBase.Builder builder = + new DomainBase.Builder() .setFullyQualifiedDomainName(canonicalizeDomainName(domain.getName())) .setRepoId(domain.getRoid()) .setIdnTableName(domain.getIdnTableId()) @@ -157,7 +157,7 @@ final class XjcToDomainResourceConverter extends XjcToEppResourceConverter { domain .getStatuses() .stream() - .map(XjcToDomainResourceConverter::convertStatusType) + .map(XjcToDomainBaseConverter::convertStatusType) .collect(toImmutableSet())) .setNameservers(convertNameservers(domain.getNs())) .setGracePeriods( @@ -170,7 +170,7 @@ final class XjcToDomainResourceConverter extends XjcToEppResourceConverter { domain .getContacts() .stream() - .map(XjcToDomainResourceConverter::convertContactType) + .map(XjcToDomainBaseConverter::convertContactType) .collect(toImmutableSet())) .setDsData( domain.getSecDNS() == null @@ -179,7 +179,7 @@ final class XjcToDomainResourceConverter extends XjcToEppResourceConverter { .getSecDNS() .getDsDatas() .stream() - .map(XjcToDomainResourceConverter::convertSecdnsDsDataType) + .map(XjcToDomainBaseConverter::convertSecdnsDsDataType) .collect(toImmutableSet())) .setTransferData(convertDomainTransferData(domain.getTrnData())) // authInfo pw must be a token between 6 and 16 characters in length @@ -251,5 +251,5 @@ final class XjcToDomainResourceConverter extends XjcToEppResourceConverter { return DesignatedContact.create(type, key); } - private XjcToDomainResourceConverter() {} + private XjcToDomainBaseConverter() {} } diff --git a/java/google/registry/reporting/icann/sql/total_domains.sql b/java/google/registry/reporting/icann/sql/total_domains.sql index 46a6523b5..f08b60f29 100644 --- a/java/google/registry/reporting/icann/sql/total_domains.sql +++ b/java/google/registry/reporting/icann/sql/total_domains.sql @@ -32,7 +32,6 @@ JOIN ON currentSponsorClientId = registrar_table.__key__.name WHERE - domain_table._d = 'DomainResource' - AND (registrar_table.type = 'REAL' OR registrar_table.type = 'INTERNAL') + registrar_table.type = 'REAL' OR registrar_table.type = 'INTERNAL' GROUP BY tld, registrarName ORDER BY tld, registrarName diff --git a/java/google/registry/reporting/icann/sql/total_nameservers.sql b/java/google/registry/reporting/icann/sql/total_nameservers.sql index f2163d9f0..bab51b056 100644 --- a/java/google/registry/reporting/icann/sql/total_nameservers.sql +++ b/java/google/registry/reporting/icann/sql/total_nameservers.sql @@ -44,8 +44,7 @@ JOIN ( FROM `%PROJECT_ID%.%DATASTORE_EXPORT_DATA_SET%.%DOMAINBASE_TABLE%`, UNNEST(nsHosts) AS hosts - WHERE _d = 'DomainResource' - AND creationTime <= TIMESTAMP("%LATEST_REPORT_TIME%") + WHERE creationTime <= TIMESTAMP("%LATEST_REPORT_TIME%") AND deletionTime > TIMESTAMP("%LATEST_REPORT_TIME%") ) AS domain_table ON host_table.__key__.name = domain_table.referencedHostName diff --git a/java/google/registry/tmch/LordnTaskUtils.java b/java/google/registry/tmch/LordnTaskUtils.java index 63c475ac9..855a73b3e 100644 --- a/java/google/registry/tmch/LordnTaskUtils.java +++ b/java/google/registry/tmch/LordnTaskUtils.java @@ -21,14 +21,14 @@ import static google.registry.model.ofy.ObjectifyService.ofy; import com.google.appengine.api.taskqueue.TaskOptions; import com.google.appengine.api.taskqueue.TaskOptions.Method; import com.google.common.base.Joiner; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.registrar.Registrar; import java.util.Optional; import org.joda.time.DateTime; /** * Helper methods for creating tasks containing CSV line data in the lordn-sunrise and lordn-claims - * queues based on DomainResource changes. + * queues based on DomainBase changes. * *

Note that, per the * TMCH RFC, while the application-datetime data is optional (which we never send because there @@ -46,9 +46,9 @@ public final class LordnTaskUtils { /** * Enqueues a task in the LORDN queue representing a line of CSV for LORDN export. */ - public static void enqueueDomainResourceTask(DomainResource domain) { + public static void enqueueDomainBaseTask(DomainBase domain) { ofy().assertInTransaction(); - // This method needs to use ofy transactionTime as the DomainResource's creationTime because + // This method needs to use ofy transactionTime as the DomainBase's creationTime because // CreationTime isn't yet populated when this method is called during the resource flow. String tld = domain.getTld(); if (domain.getLaunchNotice() == null) { @@ -65,7 +65,7 @@ public final class LordnTaskUtils { } /** Returns the corresponding CSV LORDN line for a sunrise domain. */ - public static String getCsvLineForSunriseDomain(DomainResource domain, DateTime transactionTime) { + public static String getCsvLineForSunriseDomain(DomainBase domain, DateTime transactionTime) { return Joiner.on(',') .join( domain.getRepoId(), @@ -76,7 +76,7 @@ public final class LordnTaskUtils { } /** Returns the corresponding CSV LORDN line for a claims domain. */ - public static String getCsvLineForClaimsDomain(DomainResource domain, DateTime transactionTime) { + public static String getCsvLineForClaimsDomain(DomainBase domain, DateTime transactionTime) { return Joiner.on(',') .join( domain.getRepoId(), diff --git a/java/google/registry/tools/CommandUtilities.java b/java/google/registry/tools/CommandUtilities.java index 7ba9823fe..808680401 100644 --- a/java/google/registry/tools/CommandUtilities.java +++ b/java/google/registry/tools/CommandUtilities.java @@ -21,7 +21,7 @@ import com.google.common.base.Strings; import com.googlecode.objectify.Key; import google.registry.model.EppResource; import google.registry.model.contact.ContactResource; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.host.HostResource; import google.registry.model.index.ForeignKeyIndex; import org.joda.time.DateTime; @@ -33,7 +33,7 @@ class CommandUtilities { public enum ResourceType { CONTACT(ContactResource.class), HOST(HostResource.class), - DOMAIN(DomainResource.class); + DOMAIN(DomainBase.class); private Class clazz; diff --git a/java/google/registry/tools/CountDomainsCommand.java b/java/google/registry/tools/CountDomainsCommand.java index 75ead28bc..38e104e14 100644 --- a/java/google/registry/tools/CountDomainsCommand.java +++ b/java/google/registry/tools/CountDomainsCommand.java @@ -20,7 +20,7 @@ import static google.registry.model.registry.Registries.assertTldsExist; import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; import com.google.common.collect.Iterators; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.util.Clock; import java.util.List; import javax.inject.Inject; @@ -46,7 +46,7 @@ final class CountDomainsCommand implements CommandWithRemoteApi { return Iterators.size( ofy() .load() - .type(DomainResource.class) + .type(DomainBase.class) .filter("tld", tld) .filter("deletionTime >", now) .chunkAll() diff --git a/java/google/registry/tools/DeleteTldCommand.java b/java/google/registry/tools/DeleteTldCommand.java index be11882e5..4859f2e4d 100644 --- a/java/google/registry/tools/DeleteTldCommand.java +++ b/java/google/registry/tools/DeleteTldCommand.java @@ -19,7 +19,7 @@ import static google.registry.model.ofy.ObjectifyService.ofy; import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.registrar.Registrar; import google.registry.model.registry.Registry; import google.registry.model.registry.Registry.TldType; @@ -62,7 +62,7 @@ final class DeleteTldCommand extends ConfirmingCommand implements CommandWithRem } int count = ofy().load() - .type(DomainResource.class) + .type(DomainBase.class) .filter("tld", tld) .limit(1) .count(); diff --git a/java/google/registry/tools/GenerateDnsReportCommand.java b/java/google/registry/tools/GenerateDnsReportCommand.java index b0a3ad58e..8f13ff65c 100644 --- a/java/google/registry/tools/GenerateDnsReportCommand.java +++ b/java/google/registry/tools/GenerateDnsReportCommand.java @@ -25,7 +25,7 @@ import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.host.HostResource; import google.registry.tools.params.PathParameter; import google.registry.util.Clock; @@ -71,8 +71,8 @@ final class GenerateDnsReportCommand implements CommandWithRemoteApi { String generate() { result.append("[\n"); - Iterable domains = ofy().load().type(DomainResource.class).filter("tld", tld); - for (DomainResource domain : domains) { + Iterable domains = ofy().load().type(DomainBase.class).filter("tld", tld); + for (DomainBase domain : domains) { // Skip deleted domains and domains that don't get published to DNS. if (isBeforeOrAt(domain.getDeletionTime(), now) || !domain.shouldPublishToDns()) { continue; @@ -93,7 +93,7 @@ final class GenerateDnsReportCommand implements CommandWithRemoteApi { return result.append("\n]\n").toString(); } - private void write(DomainResource domain) { + private void write(DomainBase domain) { ImmutableList nameservers = ImmutableList.sortedCopyOf(domain.loadNameserverFullyQualifiedHostNames()); ImmutableList> dsData = diff --git a/java/google/registry/tools/GenerateLordnCommand.java b/java/google/registry/tools/GenerateLordnCommand.java index 81815f117..ec8bbbfcb 100644 --- a/java/google/registry/tools/GenerateLordnCommand.java +++ b/java/google/registry/tools/GenerateLordnCommand.java @@ -21,7 +21,7 @@ import static org.joda.time.DateTimeZone.UTC; import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; import com.google.common.collect.ImmutableList; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.tmch.LordnTaskUtils; import google.registry.tools.params.PathParameter; import java.io.IOException; @@ -58,7 +58,7 @@ final class GenerateLordnCommand implements CommandWithRemoteApi { DateTime now = DateTime.now(UTC); ImmutableList.Builder claimsCsv = new ImmutableList.Builder<>(); ImmutableList.Builder sunriseCsv = new ImmutableList.Builder<>(); - for (DomainResource domain : ofy().load().type(DomainResource.class).filter("tld", tld)) { + for (DomainBase domain : ofy().load().type(DomainBase.class).filter("tld", tld)) { String status = " "; if (domain.getLaunchNotice() == null && domain.getSmdId() != null) { sunriseCsv.add(LordnTaskUtils.getCsvLineForSunriseDomain(domain, domain.getCreationTime())); diff --git a/java/google/registry/tools/GetDomainCommand.java b/java/google/registry/tools/GetDomainCommand.java index 4119c2dba..5802c6dda 100644 --- a/java/google/registry/tools/GetDomainCommand.java +++ b/java/google/registry/tools/GetDomainCommand.java @@ -18,7 +18,7 @@ import static google.registry.model.EppResourceUtils.loadByForeignKey; import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import java.util.List; /** Command to show a domain resource. */ @@ -34,7 +34,7 @@ final class GetDomainCommand extends GetEppResourceCommand { public void runAndPrint() { for (String domainName : mainParameters) { printResource( - "Domain", domainName, loadByForeignKey(DomainResource.class, domainName, readTimestamp)); + "Domain", domainName, loadByForeignKey(DomainBase.class, domainName, readTimestamp)); } } } diff --git a/java/google/registry/tools/LockDomainCommand.java b/java/google/registry/tools/LockDomainCommand.java index a03b8f1a1..35c03b505 100644 --- a/java/google/registry/tools/LockDomainCommand.java +++ b/java/google/registry/tools/LockDomainCommand.java @@ -25,7 +25,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import com.google.common.flogger.FluentLogger; import com.google.template.soy.data.SoyMapData; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.eppcommon.StatusValue; import google.registry.tools.soy.DomainUpdateSoyInfo; import java.util.Optional; @@ -46,10 +46,10 @@ public class LockDomainCommand extends LockOrUnlockDomainCommand { // Project all domains as of the same time so that argument order doesn't affect behavior. DateTime now = DateTime.now(UTC); for (String domain : getDomains()) { - Optional domainResource = loadByForeignKey(DomainResource.class, domain, now); - checkArgumentPresent(domainResource, "Domain '%s' does not exist or is deleted", domain); + Optional domainBase = loadByForeignKey(DomainBase.class, domain, now); + checkArgumentPresent(domainBase, "Domain '%s' does not exist or is deleted", domain); ImmutableSet statusesToAdd = - Sets.difference(REGISTRY_LOCK_STATUSES, domainResource.get().getStatusValues()) + Sets.difference(REGISTRY_LOCK_STATUSES, domainBase.get().getStatusValues()) .immutableCopy(); if (statusesToAdd.isEmpty()) { logger.atInfo().log("Domain '%s' is already locked and needs no updates.", domain); diff --git a/java/google/registry/tools/RenewDomainCommand.java b/java/google/registry/tools/RenewDomainCommand.java index 5dd3ef786..0ddcc9f61 100644 --- a/java/google/registry/tools/RenewDomainCommand.java +++ b/java/google/registry/tools/RenewDomainCommand.java @@ -23,7 +23,7 @@ import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; import com.google.common.base.Joiner; import com.google.template.soy.data.SoyMapData; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.tools.soy.RenewDomainSoyInfo; import google.registry.util.Clock; import java.util.List; @@ -57,11 +57,11 @@ final class RenewDomainCommand extends MutatingEppToolCommand { checkArgument(period < 10, "Cannot renew domains for 10 or more years"); DateTime now = clock.nowUtc(); for (String domainName : mainParameters) { - Optional domainOptional = - loadByForeignKey(DomainResource.class, domainName, now); + Optional domainOptional = + loadByForeignKey(DomainBase.class, domainName, now); checkArgumentPresent(domainOptional, "Domain '%s' does not exist or is deleted", domainName); setSoyTemplate(RenewDomainSoyInfo.getInstance(), RenewDomainSoyInfo.RENEWDOMAIN); - DomainResource domain = domainOptional.get(); + DomainBase domain = domainOptional.get(); addSoyRecord( domain.getCurrentSponsorClientId(), new SoyMapData( diff --git a/java/google/registry/tools/UniformRapidSuspensionCommand.java b/java/google/registry/tools/UniformRapidSuspensionCommand.java index 4a63d6434..9c22488a1 100644 --- a/java/google/registry/tools/UniformRapidSuspensionCommand.java +++ b/java/google/registry/tools/UniformRapidSuspensionCommand.java @@ -30,7 +30,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedSet; import com.google.template.soy.data.SoyMapData; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.eppcommon.StatusValue; import google.registry.model.host.HostResource; @@ -121,7 +121,7 @@ final class UniformRapidSuspensionCommand extends MutatingEppToolCommand { } catch (ClassCastException | ParseException e) { throw new IllegalArgumentException("Invalid --dsdata JSON", e); } - Optional domain = loadByForeignKey(DomainResource.class, domainName, now); + Optional domain = loadByForeignKey(DomainBase.class, domainName, now); checkArgumentPresent(domain, "Domain '%s' does not exist or is deleted", domainName); Set missingHosts = difference(newHostsSet, checkResourcesExist(HostResource.class, newHosts, now)); @@ -146,7 +146,7 @@ final class UniformRapidSuspensionCommand extends MutatingEppToolCommand { "reason", (undo ? "Undo " : "") + "Uniform Rapid Suspension")); } - private ImmutableSortedSet getExistingNameservers(DomainResource domain) { + private ImmutableSortedSet getExistingNameservers(DomainBase domain) { ImmutableSortedSet.Builder nameservers = ImmutableSortedSet.naturalOrder(); for (HostResource host : ofy().load().keys(domain.getNameservers()).values()) { nameservers.add(host.getForeignKey()); @@ -154,7 +154,7 @@ final class UniformRapidSuspensionCommand extends MutatingEppToolCommand { return nameservers.build(); } - private ImmutableSortedSet getExistingLocks(DomainResource domain) { + private ImmutableSortedSet getExistingLocks(DomainBase domain) { ImmutableSortedSet.Builder locks = ImmutableSortedSet.naturalOrder(); for (StatusValue lock : domain.getStatusValues()) { if (URS_LOCKS.contains(lock.getXmlName())) { @@ -164,7 +164,7 @@ final class UniformRapidSuspensionCommand extends MutatingEppToolCommand { return locks.build(); } - private ImmutableSortedSet getExistingDsData(DomainResource domain) { + private ImmutableSortedSet getExistingDsData(DomainBase domain) { ImmutableSortedSet.Builder dsDataJsons = ImmutableSortedSet.naturalOrder(); HexBinaryAdapter hexBinaryAdapter = new HexBinaryAdapter(); for (DelegationSignerData dsData : domain.getDsData()) { diff --git a/java/google/registry/tools/UnlockDomainCommand.java b/java/google/registry/tools/UnlockDomainCommand.java index 4c6a48821..fa21c7090 100644 --- a/java/google/registry/tools/UnlockDomainCommand.java +++ b/java/google/registry/tools/UnlockDomainCommand.java @@ -25,7 +25,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import com.google.common.flogger.FluentLogger; import com.google.template.soy.data.SoyMapData; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.eppcommon.StatusValue; import google.registry.tools.soy.DomainUpdateSoyInfo; import java.util.Optional; @@ -46,10 +46,10 @@ public class UnlockDomainCommand extends LockOrUnlockDomainCommand { // Project all domains as of the same time so that argument order doesn't affect behavior. DateTime now = DateTime.now(UTC); for (String domain : getDomains()) { - Optional domainResource = loadByForeignKey(DomainResource.class, domain, now); - checkArgumentPresent(domainResource, "Domain '%s' does not exist or is deleted", domain); + Optional domainBase = loadByForeignKey(DomainBase.class, domain, now); + checkArgumentPresent(domainBase, "Domain '%s' does not exist or is deleted", domain); ImmutableSet statusesToRemove = - Sets.intersection(domainResource.get().getStatusValues(), REGISTRY_LOCK_STATUSES) + Sets.intersection(domainBase.get().getStatusValues(), REGISTRY_LOCK_STATUSES) .immutableCopy(); if (statusesToRemove.isEmpty()) { logger.atInfo().log("Domain '%s' is already unlocked and needs no updates.", domain); diff --git a/java/google/registry/tools/UnrenewDomainCommand.java b/java/google/registry/tools/UnrenewDomainCommand.java index 6f8e2d0e2..0e962f5eb 100644 --- a/java/google/registry/tools/UnrenewDomainCommand.java +++ b/java/google/registry/tools/UnrenewDomainCommand.java @@ -32,7 +32,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import com.googlecode.objectify.Key; import google.registry.model.billing.BillingEvent; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.Period; import google.registry.model.domain.Period.Unit; import google.registry.model.eppcommon.StatusValue; @@ -91,7 +91,7 @@ class UnrenewDomainCommand extends ConfirmingCommand implements CommandWithRemot domainsNonexistentBuilder.add(domainName); continue; } - Optional domain = loadByForeignKey(DomainResource.class, domainName, now); + Optional domain = loadByForeignKey(DomainBase.class, domainName, now); if (!domain.isPresent() || domain.get().getStatusValues().contains(StatusValue.PENDING_DELETE)) { domainsDeletingBuilder.add(domainName); @@ -151,8 +151,8 @@ class UnrenewDomainCommand extends ConfirmingCommand implements CommandWithRemot private void unrenewDomain(String domainName) { ofy().assertInTransaction(); DateTime now = ofy().getTransactionTime(); - Optional domainOptional = - loadByForeignKey(DomainResource.class, domainName, now); + Optional domainOptional = + loadByForeignKey(DomainBase.class, domainName, now); // Transactional sanity checks on the off chance that something changed between init() running // and here. checkState( @@ -160,7 +160,7 @@ class UnrenewDomainCommand extends ConfirmingCommand implements CommandWithRemot && !domainOptional.get().getStatusValues().contains(StatusValue.PENDING_DELETE), "Domain %s was deleted or is pending deletion", domainName); - DomainResource domain = domainOptional.get(); + DomainBase domain = domainOptional.get(); checkState( Sets.intersection(domain.getStatusValues(), DISALLOWED_STATUSES).isEmpty(), "Domain %s has prohibited status values", @@ -206,7 +206,7 @@ class UnrenewDomainCommand extends ConfirmingCommand implements CommandWithRemot .build(); // End the old autorenew billing event and poll message now. updateAutorenewRecurrenceEndTime(domain, now); - DomainResource newDomain = + DomainBase newDomain = domain .asBuilder() .setRegistrationExpirationTime(newExpirationTime) diff --git a/java/google/registry/tools/UpdateDomainCommand.java b/java/google/registry/tools/UpdateDomainCommand.java index 4e7d03431..8f2e55ae9 100644 --- a/java/google/registry/tools/UpdateDomainCommand.java +++ b/java/google/registry/tools/UpdateDomainCommand.java @@ -30,7 +30,7 @@ import com.google.common.collect.Sets; import com.google.common.flogger.FluentLogger; import com.google.template.soy.data.SoyMapData; import google.registry.model.domain.DesignatedContact; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.eppcommon.StatusValue; import google.registry.tools.params.NameserversParameter; import google.registry.tools.soy.DomainUpdateSoyInfo; @@ -173,18 +173,18 @@ final class UpdateDomainCommand extends CreateOrUpdateDomainCommand { if (!nameservers.isEmpty() || !admins.isEmpty() || !techs.isEmpty() || !statuses.isEmpty()) { DateTime now = DateTime.now(UTC); - Optional domainOptional = - loadByForeignKey(DomainResource.class, domain, now); + Optional domainOptional = + loadByForeignKey(DomainBase.class, domain, now); checkArgumentPresent(domainOptional, "Domain '%s' does not exist or is deleted", domain); - DomainResource domainResource = domainOptional.get(); + DomainBase domainBase = domainOptional.get(); checkArgument( - !domainResource.getStatusValues().contains(SERVER_UPDATE_PROHIBITED), + !domainBase.getStatusValues().contains(SERVER_UPDATE_PROHIBITED), "The domain '%s' has status SERVER_UPDATE_PROHIBITED. Verify that you are allowed " + "to make updates, and if so, use the domain_unlock command to enable updates.", domain); if (!nameservers.isEmpty()) { ImmutableSortedSet existingNameservers = - domainResource.loadNameserverFullyQualifiedHostNames(); + domainBase.loadNameserverFullyQualifiedHostNames(); populateAddRemoveLists( ImmutableSet.copyOf(nameservers), existingNameservers, @@ -201,9 +201,9 @@ final class UpdateDomainCommand extends CreateOrUpdateDomainCommand { } if (!admins.isEmpty() || !techs.isEmpty()) { ImmutableSet existingAdmins = - getContactsOfType(domainResource, DesignatedContact.Type.ADMIN); + getContactsOfType(domainBase, DesignatedContact.Type.ADMIN); ImmutableSet existingTechs = - getContactsOfType(domainResource, DesignatedContact.Type.TECH); + getContactsOfType(domainBase, DesignatedContact.Type.TECH); if (!admins.isEmpty()) { populateAddRemoveLists( @@ -222,7 +222,7 @@ final class UpdateDomainCommand extends CreateOrUpdateDomainCommand { } if (!statuses.isEmpty()) { Set currentStatusValues = new HashSet<>(); - for (StatusValue statusValue : domainResource.getStatusValues()) { + for (StatusValue statusValue : domainBase.getStatusValues()) { currentStatusValues.add(statusValue.getXmlName()); } populateAddRemoveLists( @@ -290,8 +290,8 @@ final class UpdateDomainCommand extends CreateOrUpdateDomainCommand { } ImmutableSet getContactsOfType( - DomainResource domainResource, final DesignatedContact.Type contactType) { - return domainResource + DomainBase domainBase, final DesignatedContact.Type contactType) { + return domainBase .getContacts() .stream() .filter(contact -> contact.getType().equals(contactType)) diff --git a/java/google/registry/tools/server/GenerateZoneFilesAction.java b/java/google/registry/tools/server/GenerateZoneFilesAction.java index b6a273ec8..8eb95f742 100644 --- a/java/google/registry/tools/server/GenerateZoneFilesAction.java +++ b/java/google/registry/tools/server/GenerateZoneFilesAction.java @@ -38,7 +38,7 @@ import google.registry.gcs.GcsUtils; import google.registry.mapreduce.MapreduceRunner; import google.registry.mapreduce.inputs.NullInput; import google.registry.model.EppResource; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.host.HostResource; import google.registry.request.Action; @@ -140,7 +140,7 @@ public class GenerateZoneFilesAction implements Runnable, JsonActionRunner.JsonA new GenerateBindFileMapper( tlds, exportTime, dnsDefaultATtl, dnsDefaultNsTtl, dnsDefaultDsTtl), new GenerateBindFileReducer(bucket, exportTime, gcsBufferSize), - ImmutableList.of(new NullInput<>(), createEntityInput(DomainResource.class))) + ImmutableList.of(new NullInput<>(), createEntityInput(DomainBase.class))) .getLinkToMapreduceConsole(); ImmutableList filenames = tlds.stream() @@ -185,7 +185,7 @@ public class GenerateZoneFilesAction implements Runnable, JsonActionRunner.JsonA emit(tld, null); } } else { - mapDomain((DomainResource) resource); + mapDomain((DomainBase) resource); } } @@ -194,7 +194,7 @@ public class GenerateZoneFilesAction implements Runnable, JsonActionRunner.JsonA // be emitted in the final file, which is incorrect. Rather, to match the actual DNS glue // records, we only want to emit host information for in-bailiwick hosts in the specified // TLD(s), meaning those that act as nameservers for their respective superordinate domains. - private void mapDomain(DomainResource domain) { + private void mapDomain(DomainBase domain) { // Domains never change their tld, so we can check if it's from the wrong tld right away. if (tlds.contains(domain.getTld())) { domain = loadAtPointInTime(domain, exportTime).now(); @@ -210,7 +210,7 @@ public class GenerateZoneFilesAction implements Runnable, JsonActionRunner.JsonA } } - private void emitForSubordinateHosts(DomainResource domain) { + private void emitForSubordinateHosts(DomainBase domain) { ImmutableSet subordinateHosts = domain.getSubordinateHosts(); if (!subordinateHosts.isEmpty()) { for (HostResource unprojectedHost : ofy().load().keys(domain.getNameservers()).values()) { @@ -276,7 +276,7 @@ public class GenerateZoneFilesAction implements Runnable, JsonActionRunner.JsonA * } */ private static String domainStanza( - DomainResource domain, + DomainBase domain, DateTime exportTime, Duration dnsDefaultNsTtl, Duration dnsDefaultDsTtl) { diff --git a/java/google/registry/tools/server/ListDomainsAction.java b/java/google/registry/tools/server/ListDomainsAction.java index 495ce82c0..0b5f60656 100644 --- a/java/google/registry/tools/server/ListDomainsAction.java +++ b/java/google/registry/tools/server/ListDomainsAction.java @@ -29,7 +29,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import google.registry.model.EppResource; import google.registry.model.EppResourceUtils; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.request.Action; import google.registry.request.Parameter; import google.registry.request.auth.Auth; @@ -45,7 +45,7 @@ import org.joda.time.DateTime; path = ListDomainsAction.PATH, method = {GET, POST}, auth = Auth.AUTH_INTERNAL_OR_ADMIN) -public final class ListDomainsAction extends ListObjectsAction { +public final class ListDomainsAction extends ListObjectsAction { /** An App Engine limitation on how many subqueries can be used in a single query. */ @VisibleForTesting @NonFinalForTesting static int maxNumSubqueries = 30; @@ -71,16 +71,16 @@ public final class ListDomainsAction extends ListObjectsAction { } @Override - public ImmutableSet loadObjects() { + public ImmutableSet loadObjects() { checkArgument(!tlds.isEmpty(), "Must specify TLDs to query"); assertTldsExist(tlds); DateTime now = clock.nowUtc(); - ImmutableList.Builder domainsBuilder = new ImmutableList.Builder<>(); + ImmutableList.Builder domainsBuilder = new ImmutableList.Builder<>(); for (List tldsBatch : Lists.partition(tlds.asList(), maxNumSubqueries)) { domainsBuilder.addAll( ofy() .load() - .type(DomainResource.class) + .type(DomainBase.class) .filter("tld in", tldsBatch) // Get the N most recently created domains (requires ordering in descending order). .order("-creationTime") diff --git a/java/google/registry/tools/server/RefreshDnsForAllDomainsAction.java b/java/google/registry/tools/server/RefreshDnsForAllDomainsAction.java index e48ffeeb1..796a23a94 100644 --- a/java/google/registry/tools/server/RefreshDnsForAllDomainsAction.java +++ b/java/google/registry/tools/server/RefreshDnsForAllDomainsAction.java @@ -26,7 +26,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.flogger.FluentLogger; import google.registry.dns.DnsQueue; import google.registry.mapreduce.MapreduceRunner; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.request.Action; import google.registry.request.Parameter; import google.registry.request.Response; @@ -69,13 +69,13 @@ public class RefreshDnsForAllDomainsAction implements Runnable { .setDefaultMapShards(10) .runMapOnly( new RefreshDnsForAllDomainsActionMapper(tlds), - ImmutableList.of(createEntityInput(DomainResource.class))) + ImmutableList.of(createEntityInput(DomainBase.class))) .sendLinkToMapreduceConsole(response); } /** Mapper to refresh DNS for all active domain resources. */ public static class RefreshDnsForAllDomainsActionMapper - extends Mapper { + extends Mapper { private static final long serialVersionUID = 1455544013508953083L; @@ -88,7 +88,7 @@ public class RefreshDnsForAllDomainsAction implements Runnable { } @Override - public void map(final DomainResource domain) { + public void map(final DomainBase domain) { String domainName = domain.getFullyQualifiedDomainName(); if (tlds.contains(domain.getTld())) { if (isActive(domain, DateTime.now(DateTimeZone.UTC))) { diff --git a/java/google/registry/whois/DomainLookupCommand.java b/java/google/registry/whois/DomainLookupCommand.java index a7b769dab..3aafb405b 100644 --- a/java/google/registry/whois/DomainLookupCommand.java +++ b/java/google/registry/whois/DomainLookupCommand.java @@ -17,7 +17,7 @@ package google.registry.whois; import static google.registry.model.EppResourceUtils.loadByForeignKeyCached; import com.google.common.net.InternetDomainName; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import java.util.Optional; import org.joda.time.DateTime; @@ -33,7 +33,7 @@ public class DomainLookupCommand extends DomainOrHostLookupCommand { @Override protected Optional getResponse(InternetDomainName domainName, DateTime now) { - return loadByForeignKeyCached(DomainResource.class, domainName.toString(), now) + return loadByForeignKeyCached(DomainBase.class, domainName.toString(), now) .map(domain -> new DomainWhoisResponse(domain, fullOutput, now)); } } diff --git a/java/google/registry/whois/DomainWhoisResponse.java b/java/google/registry/whois/DomainWhoisResponse.java index b290fab52..a0b4663fd 100644 --- a/java/google/registry/whois/DomainWhoisResponse.java +++ b/java/google/registry/whois/DomainWhoisResponse.java @@ -29,7 +29,7 @@ import google.registry.model.contact.ContactResource; import google.registry.model.contact.PostalInfo; import google.registry.model.domain.DesignatedContact; import google.registry.model.domain.DesignatedContact.Type; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.GracePeriod; import google.registry.model.eppcommon.StatusValue; import google.registry.model.registrar.Registrar; @@ -54,13 +54,13 @@ final class DomainWhoisResponse extends WhoisResponseImpl { "For more information on Whois status codes, please visit https://icann.org/epp\r\n"; /** Domain which was the target of this WHOIS command. */ - private final DomainResource domain; + private final DomainBase domain; /** Whether the full WHOIS output is to be displayed. */ private final boolean fullOutput; /** Creates new WHOIS domain response on the given domain. */ - DomainWhoisResponse(DomainResource domain, boolean fullOutput, DateTime timestamp) { + DomainWhoisResponse(DomainBase domain, boolean fullOutput, DateTime timestamp) { super(timestamp); this.domain = checkNotNull(domain, "domain"); this.fullOutput = fullOutput; diff --git a/javatests/google/registry/batch/DeleteContactsAndHostsActionTest.java b/javatests/google/registry/batch/DeleteContactsAndHostsActionTest.java index 7ecf70680..3d0904f69 100644 --- a/javatests/google/registry/batch/DeleteContactsAndHostsActionTest.java +++ b/javatests/google/registry/batch/DeleteContactsAndHostsActionTest.java @@ -37,7 +37,7 @@ import static google.registry.testing.DatastoreHelper.getOnlyHistoryEntryOfType; import static google.registry.testing.DatastoreHelper.getOnlyPollMessageForHistoryEntry; import static google.registry.testing.DatastoreHelper.getPollMessages; import static google.registry.testing.DatastoreHelper.newContactResource; -import static google.registry.testing.DatastoreHelper.newDomainResource; +import static google.registry.testing.DatastoreHelper.newDomainBase; import static google.registry.testing.DatastoreHelper.newHostResource; import static google.registry.testing.DatastoreHelper.persistActiveContact; import static google.registry.testing.DatastoreHelper.persistActiveHost; @@ -75,7 +75,7 @@ import google.registry.model.contact.ContactAddress; import google.registry.model.contact.ContactPhoneNumber; import google.registry.model.contact.ContactResource; import google.registry.model.contact.PostalInfo; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.Trid; import google.registry.model.eppoutput.EppResponse.ResponseData; @@ -96,7 +96,6 @@ import google.registry.testing.FakeClock; import google.registry.testing.FakeResponse; import google.registry.testing.FakeSleeper; import google.registry.testing.InjectRule; -import google.registry.testing.MockitoJUnitRule; import google.registry.testing.TaskQueueHelper.TaskMatcher; import google.registry.testing.mapreduce.MapreduceTestCase; import google.registry.util.AppEngineServiceUtils; @@ -120,7 +119,6 @@ public class DeleteContactsAndHostsActionTest extends MapreduceTestCase { @Rule public final InjectRule inject = new InjectRule(); - @Rule public final MockitoJUnitRule mocks = MockitoJUnitRule.create(); private AsyncTaskEnqueuer enqueuer; private final FakeClock clock = new FakeClock(DateTime.parse("2015-01-15T11:22:33Z")); @@ -181,7 +179,7 @@ public class DeleteContactsAndHostsActionTest @Test public void testSuccess_contact_referencedByActiveDomain_doesNotGetDeleted() throws Exception { ContactResource contact = persistContactPendingDelete("blah8221"); - persistResource(newDomainResource("example.tld", contact)); + persistResource(newDomainBase("example.tld", contact)); DateTime timeEnqueued = clock.nowUtc(); enqueuer.enqueueAsyncDelete( contact, @@ -197,8 +195,8 @@ public class DeleteContactsAndHostsActionTest .doesNotHaveStatusValue(PENDING_DELETE) .and() .hasDeletionTime(END_OF_TIME); - DomainResource domainReloaded = - loadByForeignKey(DomainResource.class, "example.tld", clock.nowUtc()).get(); + DomainBase domainReloaded = + loadByForeignKey(DomainBase.class, "example.tld", clock.nowUtc()).get(); assertThat(domainReloaded.getReferencedContacts()).contains(Key.create(contactUpdated)); HistoryEntry historyEntry = getOnlyHistoryEntryOfType(contactUpdated, HistoryEntry.Type.CONTACT_DELETE_FAILURE); @@ -237,7 +235,7 @@ public class DeleteContactsAndHostsActionTest @Test public void test_mapreduceHasWorkToDo_lockIsAcquired() { ContactResource contact = persistContactPendingDelete("blah8221"); - persistResource(newDomainResource("example.tld", contact)); + persistResource(newDomainBase("example.tld", contact)); DateTime timeEnqueued = clock.nowUtc(); enqueuer.enqueueAsyncDelete( contact, @@ -380,7 +378,7 @@ public class DeleteContactsAndHostsActionTest public void testSuccess_contact_referencedByDeletedDomain_getsDeleted() throws Exception { ContactResource contactUsed = persistContactPendingDelete("blah1234"); persistResource( - newDomainResource("example.tld", contactUsed) + newDomainBase("example.tld", contactUsed) .asBuilder() .setDeletionTime(clock.nowUtc().minusDays(3)) .build()); @@ -614,8 +612,8 @@ public class DeleteContactsAndHostsActionTest .doesNotHaveStatusValue(PENDING_DELETE) .and() .hasDeletionTime(END_OF_TIME); - DomainResource domain = - loadByForeignKey(DomainResource.class, "example.tld", clock.nowUtc()).get(); + DomainBase domain = + loadByForeignKey(DomainBase.class, "example.tld", clock.nowUtc()).get(); assertThat(domain.getNameservers()).contains(Key.create(hostAfter)); HistoryEntry historyEntry = getOnlyHistoryEntryOfType(hostAfter, HOST_DELETE_FAILURE); assertPollMessageFor( @@ -684,7 +682,7 @@ public class DeleteContactsAndHostsActionTest public void testSuccess_host_referencedByDeletedDomain_getsDeleted() throws Exception { HostResource host = persistHostPendingDelete("ns1.example.tld"); persistResource( - newDomainResource("example.tld") + newDomainBase("example.tld") .asBuilder() .setNameservers(ImmutableSet.of(Key.create(host))) .setDeletionTime(clock.nowUtc().minusDays(5)) @@ -722,9 +720,9 @@ public class DeleteContactsAndHostsActionTest @Test public void testSuccess_subordinateHost_getsDeleted() throws Exception { - DomainResource domain = + DomainBase domain = persistResource( - newDomainResource("example.tld") + newDomainBase("example.tld") .asBuilder() .setSubordinateHosts(ImmutableSet.of("ns2.example.tld")) .build()); @@ -745,7 +743,7 @@ public class DeleteContactsAndHostsActionTest assertThat(loadByForeignKey(HostResource.class, "ns2.example.tld", clock.nowUtc())).isEmpty(); assertNoBillingEvents(); assertThat( - loadByForeignKey(DomainResource.class, "example.tld", clock.nowUtc()) + loadByForeignKey(DomainBase.class, "example.tld", clock.nowUtc()) .get() .getSubordinateHosts()) .isEmpty(); @@ -940,10 +938,10 @@ public class DeleteContactsAndHostsActionTest newHostResource(hostName).asBuilder().addStatusValue(PENDING_DELETE).build()); } - private static DomainResource persistUsedDomain( + private static DomainBase persistUsedDomain( String domainName, ContactResource contact, HostResource host) { return persistResource( - newDomainResource(domainName, contact) + newDomainBase(domainName, contact) .asBuilder() .setNameservers(ImmutableSet.of(Key.create(host))) .build()); diff --git a/javatests/google/registry/batch/DeleteProberDataActionTest.java b/javatests/google/registry/batch/DeleteProberDataActionTest.java index a255819f6..e35744d23 100644 --- a/javatests/google/registry/batch/DeleteProberDataActionTest.java +++ b/javatests/google/registry/batch/DeleteProberDataActionTest.java @@ -19,7 +19,7 @@ import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.EppResourceUtils.loadByForeignKey; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; -import static google.registry.testing.DatastoreHelper.newDomainResource; +import static google.registry.testing.DatastoreHelper.newDomainBase; import static google.registry.testing.DatastoreHelper.persistActiveDomain; import static google.registry.testing.DatastoreHelper.persistActiveHost; import static google.registry.testing.DatastoreHelper.persistDeletedDomain; @@ -38,7 +38,7 @@ import google.registry.config.RegistryEnvironment; import google.registry.model.ImmutableObject; import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent.Reason; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.index.EppResourceIndex; import google.registry.model.index.ForeignKeyIndex; import google.registry.model.poll.PollMessage; @@ -163,9 +163,9 @@ public class DeleteProberDataActionTest extends MapreduceTestCase fkiNic = - ForeignKeyIndex.load(DomainResource.class, "nic.ib-any.test", START_OF_TIME); + DomainBase nic = persistActiveDomain("nic.ib-any.test"); + ForeignKeyIndex fkiNic = + ForeignKeyIndex.load(DomainBase.class, "nic.ib-any.test", START_OF_TIME); Set ibEntities = persistLotsOfDomains("ib-any.test"); runMapreduce(); assertDeleted(ibEntities); @@ -184,14 +184,14 @@ public class DeleteProberDataActionTest extends MapreduceTestCase domain = - loadByForeignKey(DomainResource.class, "blah.ib-any.test", DateTime.now(UTC)); + Optional domain = + loadByForeignKey(DomainBase.class, "blah.ib-any.test", DateTime.now(UTC)); assertThat(domain).isPresent(); assertThat(domain.get().getDeletionTime()).isEqualTo(END_OF_TIME); } @Test public void testDryRun_doesntSoftDeleteData() throws Exception { - DomainResource domain = persistResource( - newDomainResource("blah.ib-any.test") + DomainBase domain = persistResource( + newDomainBase("blah.ib-any.test") .asBuilder() .setCreationTimeForTest(DateTime.now(UTC).minusYears(1)) .build()); @@ -243,11 +243,11 @@ public class DeleteProberDataActionTest extends MapreduceTestCase persistDomainAndDescendants(String fqdn) { - DomainResource domain = persistDeletedDomain(fqdn, DELETION_TIME); + DomainBase domain = persistDeletedDomain(fqdn, DELETION_TIME); HistoryEntry historyEntry = persistSimpleResource( new HistoryEntry.Builder() .setParent(domain) @@ -298,8 +298,8 @@ public class DeleteProberDataActionTest extends MapreduceTestCase fki = - ForeignKeyIndex.load(DomainResource.class, fqdn, START_OF_TIME); + ForeignKeyIndex fki = + ForeignKeyIndex.load(DomainBase.class, fqdn, START_OF_TIME); EppResourceIndex eppIndex = ofy().load().entity(EppResourceIndex.create(Key.create(domain))).now(); return ImmutableSet.of( diff --git a/javatests/google/registry/batch/ExpandRecurringBillingEventsActionTest.java b/javatests/google/registry/batch/ExpandRecurringBillingEventsActionTest.java index 713eae04a..7362fb5b9 100644 --- a/javatests/google/registry/batch/ExpandRecurringBillingEventsActionTest.java +++ b/javatests/google/registry/batch/ExpandRecurringBillingEventsActionTest.java @@ -42,7 +42,7 @@ import google.registry.model.billing.BillingEvent.Flag; import google.registry.model.billing.BillingEvent.OneTime; import google.registry.model.billing.BillingEvent.Reason; import google.registry.model.common.Cursor; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.Period; import google.registry.model.ofy.Ofy; import google.registry.model.registry.Registry; @@ -74,7 +74,7 @@ public class ExpandRecurringBillingEventsActionTest private final DateTime beginningOfTest = DateTime.parse("2000-10-02T00:00:00Z"); private final FakeClock clock = new FakeClock(beginningOfTest); - DomainResource domain; + DomainBase domain; HistoryEntry historyEntry; BillingEvent.Recurring recurring; @@ -118,7 +118,7 @@ public class ExpandRecurringBillingEventsActionTest } void assertHistoryEntryMatches( - DomainResource domain, HistoryEntry actual, String clientId, DateTime billingTime) { + DomainBase domain, HistoryEntry actual, String clientId, DateTime billingTime) { assertThat(actual.getBySuperuser()).isFalse(); assertThat(actual.getClientId()).isEqualTo(clientId); assertThat(actual.getParent()).isEqualTo(Key.create(domain)); @@ -168,7 +168,7 @@ public class ExpandRecurringBillingEventsActionTest @Test public void testSuccess_expandSingleEvent_deletedDomain() throws Exception { DateTime deletionTime = DateTime.parse("2000-08-01T00:00:00Z"); - DomainResource deletedDomain = persistDeletedDomain("deleted.tld", deletionTime); + DomainBase deletedDomain = persistDeletedDomain("deleted.tld", deletionTime); historyEntry = persistResource(new HistoryEntry.Builder().setParent(deletedDomain).build()); recurring = persistResource(new BillingEvent.Recurring.Builder() .setParent(historyEntry) diff --git a/javatests/google/registry/batch/RefreshDnsOnHostRenameActionTest.java b/javatests/google/registry/batch/RefreshDnsOnHostRenameActionTest.java index 5458aa5d2..53df05881 100644 --- a/javatests/google/registry/batch/RefreshDnsOnHostRenameActionTest.java +++ b/javatests/google/registry/batch/RefreshDnsOnHostRenameActionTest.java @@ -23,7 +23,7 @@ import static google.registry.batch.AsyncTaskEnqueuer.QUEUE_ASYNC_HOST_RENAME; import static google.registry.batch.AsyncTaskMetrics.OperationType.DNS_REFRESH; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; -import static google.registry.testing.DatastoreHelper.newDomainResource; +import static google.registry.testing.DatastoreHelper.newDomainBase; import static google.registry.testing.DatastoreHelper.newHostResource; import static google.registry.testing.DatastoreHelper.persistActiveHost; import static google.registry.testing.DatastoreHelper.persistDeletedHost; @@ -53,7 +53,6 @@ import google.registry.testing.FakeClock; import google.registry.testing.FakeResponse; import google.registry.testing.FakeSleeper; import google.registry.testing.InjectRule; -import google.registry.testing.MockitoJUnitRule; import google.registry.testing.TaskQueueHelper.TaskMatcher; import google.registry.testing.mapreduce.MapreduceTestCase; import google.registry.util.AppEngineServiceUtils; @@ -77,7 +76,6 @@ public class RefreshDnsOnHostRenameActionTest extends MapreduceTestCase { @Rule public final InjectRule inject = new InjectRule(); - @Rule public final MockitoJUnitRule mocks = MockitoJUnitRule.create(); private AsyncTaskEnqueuer enqueuer; private final FakeClock clock = new FakeClock(DateTime.parse("2015-01-15T11:22:33Z")); @@ -135,9 +133,9 @@ public class RefreshDnsOnHostRenameActionTest @Test public void testSuccess_dnsUpdateEnqueued() throws Exception { HostResource host = persistActiveHost("ns1.example.tld"); - persistResource(newDomainResource("example.tld", host)); - persistResource(newDomainResource("otherexample.tld", host)); - persistResource(newDomainResource("untouched.tld", persistActiveHost("ns2.example.tld"))); + persistResource(newDomainBase("example.tld", host)); + persistResource(newDomainBase("otherexample.tld", host)); + persistResource(newDomainBase("untouched.tld", persistActiveHost("ns2.example.tld"))); DateTime timeEnqueued = clock.nowUtc(); enqueuer.enqueueAsyncDnsRefresh(host, timeEnqueued); runMapreduce(); @@ -154,9 +152,9 @@ public class RefreshDnsOnHostRenameActionTest HostResource host1 = persistActiveHost("ns1.example.tld"); HostResource host2 = persistActiveHost("ns2.example.tld"); HostResource host3 = persistActiveHost("ns3.example.tld"); - persistResource(newDomainResource("example1.tld", host1)); - persistResource(newDomainResource("example2.tld", host2)); - persistResource(newDomainResource("example3.tld", host3)); + persistResource(newDomainBase("example1.tld", host1)); + persistResource(newDomainBase("example2.tld", host2)); + persistResource(newDomainBase("example3.tld", host3)); DateTime timeEnqueued = clock.nowUtc(); DateTime laterTimeEnqueued = timeEnqueued.plus(standardSeconds(10)); enqueuer.enqueueAsyncDnsRefresh(host1, timeEnqueued); @@ -176,7 +174,7 @@ public class RefreshDnsOnHostRenameActionTest @Test public void testSuccess_deletedHost_doesntTriggerDnsRefresh() throws Exception { HostResource host = persistDeletedHost("ns11.fakesss.tld", clock.nowUtc().minusDays(4)); - persistResource(newDomainResource("example1.tld", host)); + persistResource(newDomainBase("example1.tld", host)); DateTime timeEnqueued = clock.nowUtc(); enqueuer.enqueueAsyncDnsRefresh(host, timeEnqueued); runMapreduce(); @@ -192,7 +190,7 @@ public class RefreshDnsOnHostRenameActionTest public void testSuccess_noDnsTasksForDeletedDomain() throws Exception { HostResource renamedHost = persistActiveHost("ns1.example.tld"); persistResource( - newDomainResource("example.tld", renamedHost) + newDomainBase("example.tld", renamedHost) .asBuilder() .setDeletionTime(START_OF_TIME) .build()); diff --git a/javatests/google/registry/batch/ResaveEntityActionTest.java b/javatests/google/registry/batch/ResaveEntityActionTest.java index 2328ceee1..f154c2d8b 100644 --- a/javatests/google/registry/batch/ResaveEntityActionTest.java +++ b/javatests/google/registry/batch/ResaveEntityActionTest.java @@ -24,7 +24,7 @@ import static google.registry.batch.AsyncTaskEnqueuer.QUEUE_ASYNC_DELETE; import static google.registry.batch.AsyncTaskEnqueuer.QUEUE_ASYNC_HOST_RENAME; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; -import static google.registry.testing.DatastoreHelper.newDomainResource; +import static google.registry.testing.DatastoreHelper.newDomainBase; import static google.registry.testing.DatastoreHelper.persistActiveContact; import static google.registry.testing.DatastoreHelper.persistDomainWithDependentResources; import static google.registry.testing.DatastoreHelper.persistDomainWithPendingTransfer; @@ -39,7 +39,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedSet; import com.googlecode.objectify.Key; import google.registry.model.ImmutableObject; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.GracePeriod; import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.eppcommon.StatusValue; @@ -106,7 +106,7 @@ public class ResaveEntityActionTest extends ShardableTestCase { @Test public void test_domainPendingTransfer_isResavedAndTransferCompleted() { - DomainResource domain = + DomainBase domain = persistDomainWithPendingTransfer( persistDomainWithDependentResources( "domain", @@ -122,16 +122,16 @@ public class ResaveEntityActionTest extends ShardableTestCase { clock.advanceOneMilli(); assertThat(domain.getCurrentSponsorClientId()).isEqualTo("TheRegistrar"); runAction(Key.create(domain), DateTime.parse("2016-02-06T10:00:01Z"), ImmutableSortedSet.of()); - DomainResource resavedDomain = ofy().load().entity(domain).now(); + DomainBase resavedDomain = ofy().load().entity(domain).now(); assertThat(resavedDomain.getCurrentSponsorClientId()).isEqualTo("NewRegistrar"); verify(response).setPayload("Entity re-saved."); } @Test public void test_domainPendingDeletion_isResavedAndReenqueued() { - DomainResource domain = + DomainBase domain = persistResource( - newDomainResource("domain.tld") + newDomainBase("domain.tld") .asBuilder() .setDeletionTime(clock.nowUtc().plusDays(35)) .setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE)) @@ -147,7 +147,7 @@ public class ResaveEntityActionTest extends ShardableTestCase { assertThat(domain.getGracePeriods()).isNotEmpty(); runAction(Key.create(domain), requestedTime, ImmutableSortedSet.of(requestedTime.plusDays(5))); - DomainResource resavedDomain = ofy().load().entity(domain).now(); + DomainBase resavedDomain = ofy().load().entity(domain).now(); assertThat(resavedDomain.getGracePeriods()).isEmpty(); assertTasksEnqueued( diff --git a/javatests/google/registry/dns/PublishDnsUpdatesActionTest.java b/javatests/google/registry/dns/PublishDnsUpdatesActionTest.java index 0de352653..e9c9d2b49 100644 --- a/javatests/google/registry/dns/PublishDnsUpdatesActionTest.java +++ b/javatests/google/registry/dns/PublishDnsUpdatesActionTest.java @@ -33,7 +33,7 @@ import google.registry.dns.DnsMetrics.ActionStatus; import google.registry.dns.DnsMetrics.CommitStatus; import google.registry.dns.DnsMetrics.PublishStatus; import google.registry.dns.writer.DnsWriter; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.ofy.Ofy; import google.registry.model.registry.Registry; import google.registry.request.HttpException.ServiceUnavailableException; @@ -78,10 +78,10 @@ public class PublishDnsUpdatesActionTest { .asBuilder() .setDnsWriters(ImmutableSet.of("correctWriter")) .build()); - DomainResource domain1 = persistActiveDomain("example.xn--q9jyb4c"); + DomainBase domain1 = persistActiveDomain("example.xn--q9jyb4c"); persistActiveSubordinateHost("ns1.example.xn--q9jyb4c", domain1); persistActiveSubordinateHost("ns2.example.xn--q9jyb4c", domain1); - DomainResource domain2 = persistActiveDomain("example2.xn--q9jyb4c"); + DomainBase domain2 = persistActiveDomain("example2.xn--q9jyb4c"); persistActiveSubordinateHost("ns1.example.xn--q9jyb4c", domain2); clock.advanceOneMilli(); } diff --git a/javatests/google/registry/dns/RefreshDnsActionTest.java b/javatests/google/registry/dns/RefreshDnsActionTest.java index 3d882ffb6..e26329ae0 100644 --- a/javatests/google/registry/dns/RefreshDnsActionTest.java +++ b/javatests/google/registry/dns/RefreshDnsActionTest.java @@ -25,7 +25,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import google.registry.dns.DnsConstants.TargetType; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.request.HttpException.BadRequestException; import google.registry.request.HttpException.NotFoundException; import google.registry.testing.AppEngineRule; @@ -64,7 +64,7 @@ public class RefreshDnsActionTest { @Test public void testSuccess_host() { - DomainResource domain = persistActiveDomain("example.xn--q9jyb4c"); + DomainBase domain = persistActiveDomain("example.xn--q9jyb4c"); persistActiveSubordinateHost("ns1.example.xn--q9jyb4c", domain); run(TargetType.HOST, "ns1.example.xn--q9jyb4c"); verify(dnsQueue).addHostRefreshTask("ns1.example.xn--q9jyb4c"); diff --git a/javatests/google/registry/dns/writer/clouddns/CloudDnsWriterTest.java b/javatests/google/registry/dns/writer/clouddns/CloudDnsWriterTest.java index 5f15eccb1..76f269057 100644 --- a/javatests/google/registry/dns/writer/clouddns/CloudDnsWriterTest.java +++ b/javatests/google/registry/dns/writer/clouddns/CloudDnsWriterTest.java @@ -18,7 +18,7 @@ import static com.google.common.collect.ImmutableList.toImmutableList; import static com.google.common.io.BaseEncoding.base16; import static com.google.common.truth.Truth.assertThat; import static google.registry.testing.DatastoreHelper.createTld; -import static google.registry.testing.DatastoreHelper.newDomainResource; +import static google.registry.testing.DatastoreHelper.newDomainBase; import static google.registry.testing.DatastoreHelper.newHostResource; import static google.registry.testing.DatastoreHelper.persistResource; import static org.mockito.Matchers.anyString; @@ -40,7 +40,7 @@ import com.google.common.net.InetAddresses; import com.google.common.util.concurrent.RateLimiter; import com.googlecode.objectify.Key; import google.registry.dns.writer.clouddns.CloudDnsWriter.ZoneStateException; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.eppcommon.StatusValue; import google.registry.model.host.HostResource; @@ -281,7 +281,7 @@ public class CloudDnsWriterTest { } /** Returns a domain to be persisted in Datastore. */ - private static DomainResource fakeDomain( + private static DomainBase fakeDomain( String domainName, ImmutableSet nameservers, int numDsRecords) { ImmutableSet.Builder dsDataBuilder = new ImmutableSet.Builder<>(); @@ -294,7 +294,7 @@ public class CloudDnsWriterTest { hostResourceRefBuilder.add(Key.create(nameserver)); } - return newDomainResource(domainName) + return newDomainBase(domainName) .asBuilder() .setNameservers(hostResourceRefBuilder.build()) .setDsData(dsDataBuilder.build()) diff --git a/javatests/google/registry/dns/writer/dnsupdate/DnsUpdateWriterTest.java b/javatests/google/registry/dns/writer/dnsupdate/DnsUpdateWriterTest.java index 641b7a3ce..db04d8cc6 100644 --- a/javatests/google/registry/dns/writer/dnsupdate/DnsUpdateWriterTest.java +++ b/javatests/google/registry/dns/writer/dnsupdate/DnsUpdateWriterTest.java @@ -18,7 +18,7 @@ import static com.google.common.io.BaseEncoding.base16; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assert_; import static google.registry.testing.DatastoreHelper.createTld; -import static google.registry.testing.DatastoreHelper.newDomainResource; +import static google.registry.testing.DatastoreHelper.newDomainBase; import static google.registry.testing.DatastoreHelper.newHostResource; import static google.registry.testing.DatastoreHelper.persistActiveDomain; import static google.registry.testing.DatastoreHelper.persistActiveHost; @@ -37,7 +37,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.net.InetAddresses; import com.googlecode.objectify.Key; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.eppcommon.StatusValue; import google.registry.model.host.HostResource; @@ -102,7 +102,7 @@ public class DnsUpdateWriterTest { public void testPublishDomainCreate_publishesNameServers() throws Exception { HostResource host1 = persistActiveHost("ns1.example.tld"); HostResource host2 = persistActiveHost("ns2.example.tld"); - DomainResource domain = + DomainBase domain = persistActiveDomain("example.tld") .asBuilder() .setNameservers(ImmutableSet.of(Key.create(host1), Key.create(host2))) @@ -123,7 +123,7 @@ public class DnsUpdateWriterTest { @Test public void testPublishAtomic_noCommit() { HostResource host1 = persistActiveHost("ns.example1.tld"); - DomainResource domain1 = + DomainBase domain1 = persistActiveDomain("example1.tld") .asBuilder() .setNameservers(ImmutableSet.of(Key.create(host1))) @@ -131,7 +131,7 @@ public class DnsUpdateWriterTest { persistResource(domain1); HostResource host2 = persistActiveHost("ns.example2.tld"); - DomainResource domain2 = + DomainBase domain2 = persistActiveDomain("example2.tld") .asBuilder() .setNameservers(ImmutableSet.of(Key.create(host2))) @@ -147,7 +147,7 @@ public class DnsUpdateWriterTest { @Test public void testPublishAtomic_oneUpdate() throws Exception { HostResource host1 = persistActiveHost("ns.example1.tld"); - DomainResource domain1 = + DomainBase domain1 = persistActiveDomain("example1.tld") .asBuilder() .setNameservers(ImmutableSet.of(Key.create(host1))) @@ -155,7 +155,7 @@ public class DnsUpdateWriterTest { persistResource(domain1); HostResource host2 = persistActiveHost("ns.example2.tld"); - DomainResource domain2 = + DomainBase domain2 = persistActiveDomain("example2.tld") .asBuilder() .setNameservers(ImmutableSet.of(Key.create(host2))) @@ -178,7 +178,7 @@ public class DnsUpdateWriterTest { @Test public void testPublishDomainCreate_publishesDelegationSigner() throws Exception { - DomainResource domain = + DomainBase domain = persistActiveDomain("example.tld") .asBuilder() .setNameservers(ImmutableSet.of(Key.create(persistActiveHost("ns1.example.tld")))) @@ -202,7 +202,7 @@ public class DnsUpdateWriterTest { @Test public void testPublishDomainWhenNotActive_removesDnsRecords() throws Exception { - DomainResource domain = + DomainBase domain = persistActiveDomain("example.tld") .asBuilder() .addStatusValue(StatusValue.SERVER_HOLD) @@ -247,7 +247,7 @@ public class DnsUpdateWriterTest { InetAddresses.forString("fd0e:a5c8:6dfb:6a5e:0:0:0:1"))) .build()); persistResource( - newDomainResource("example.tld") + newDomainBase("example.tld") .asBuilder() .addSubordinateHost("ns1.example.tld") .addNameserver(Key.create(host)) @@ -319,7 +319,7 @@ public class DnsUpdateWriterTest { .build()); persistResource( - newDomainResource("example.tld") + newDomainBase("example.tld") .asBuilder() .addSubordinateHost("ns1.example.tld") .addNameservers( @@ -354,7 +354,7 @@ public class DnsUpdateWriterTest { .build()); persistResource( - newDomainResource("example.tld") + newDomainBase("example.tld") .asBuilder() .addSubordinateHost("ns1.example.tld") .addSubordinateHost("foo.example.tld") @@ -378,7 +378,7 @@ public class DnsUpdateWriterTest { @Test public void testPublishDomainFails_whenDnsUpdateReturnsError() throws Exception { - DomainResource domain = + DomainBase domain = persistActiveDomain("example.tld") .asBuilder() .setNameservers(ImmutableSet.of(Key.create(persistActiveHost("ns1.example.tld")))) diff --git a/javatests/google/registry/flows/EppCommitLogsTest.java b/javatests/google/registry/flows/EppCommitLogsTest.java index 0ed3dddd0..e6e920abc 100644 --- a/javatests/google/registry/flows/EppCommitLogsTest.java +++ b/javatests/google/registry/flows/EppCommitLogsTest.java @@ -27,7 +27,7 @@ import static org.joda.time.Duration.standardDays; import com.google.common.collect.ImmutableMap; import com.googlecode.objectify.Key; import google.registry.flows.EppTestComponent.FakesAndMocksModule; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.ofy.Ofy; import google.registry.monitoring.whitebox.EppMetric; import google.registry.testing.AppEngineRule; @@ -104,8 +104,8 @@ public class EppCommitLogsTest extends ShardableTestCase { eppLoader = new EppLoader(this, "domain_create.xml", ImmutableMap.of("DOMAIN", "example.tld")); runFlow(); ofy().clearSessionCache(); - Key key = Key.create(ofy().load().type(DomainResource.class).first().now()); - DomainResource domainAfterCreate = ofy().load().key(key).now(); + Key key = Key.create(ofy().load().type(DomainBase.class).first().now()); + DomainBase domainAfterCreate = ofy().load().key(key).now(); assertThat(domainAfterCreate.getFullyQualifiedDomainName()).isEqualTo("example.tld"); clock.advanceBy(standardDays(2)); @@ -114,7 +114,7 @@ public class EppCommitLogsTest extends ShardableTestCase { runFlow(); ofy().clearSessionCache(); - DomainResource domainAfterFirstUpdate = ofy().load().key(key).now(); + DomainBase domainAfterFirstUpdate = ofy().load().key(key).now(); assertThat(domainAfterCreate).isNotEqualTo(domainAfterFirstUpdate); clock.advanceOneMilli(); // same day as first update @@ -122,7 +122,7 @@ public class EppCommitLogsTest extends ShardableTestCase { eppLoader = new EppLoader(this, "domain_update_dsdata_rem.xml"); runFlow(); ofy().clearSessionCache(); - DomainResource domainAfterSecondUpdate = ofy().load().key(key).now(); + DomainBase domainAfterSecondUpdate = ofy().load().key(key).now(); clock.advanceBy(standardDays(2)); DateTime timeAtDelete = clock.nowUtc(); // before 'add' grace period ends @@ -133,7 +133,7 @@ public class EppCommitLogsTest extends ShardableTestCase { assertThat(domainAfterFirstUpdate).isNotEqualTo(domainAfterSecondUpdate); // Point-in-time can only rewind an object from the current version, not roll forward. - DomainResource latest = ofy().load().key(key).now(); + DomainBase latest = ofy().load().key(key).now(); // Creation time has millisecond granularity due to isActive() check. ofy().clearSessionCache(); diff --git a/javatests/google/registry/flows/EppLifecycleDomainTest.java b/javatests/google/registry/flows/EppLifecycleDomainTest.java index 129509842..ebe456fe5 100644 --- a/javatests/google/registry/flows/EppLifecycleDomainTest.java +++ b/javatests/google/registry/flows/EppLifecycleDomainTest.java @@ -38,7 +38,7 @@ import com.google.re2j.Pattern; import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent.OneTime; import google.registry.model.billing.BillingEvent.Reason; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.registry.Registry; import google.registry.model.registry.Registry.TldState; import google.registry.model.reporting.HistoryEntry.Type; @@ -110,8 +110,8 @@ public class EppLifecycleDomainTest extends EppTestCase { "CRDATE", "2000-06-01T00:02:00.0Z", "EXDATE", "2002-06-01T00:02:00.0Z")); - DomainResource domain = - loadByForeignKey(DomainResource.class, "example.tld", createTime.plusHours(1)).get(); + DomainBase domain = + loadByForeignKey(DomainBase.class, "example.tld", createTime.plusHours(1)).get(); // Delete domain example.tld within the add grace period. DateTime deleteTime = createTime.plusDays(1); @@ -186,9 +186,9 @@ public class EppLifecycleDomainTest extends EppTestCase { ImmutableMap.of( "CODE", "2303", "MSG", "The domain with given ID (example.tld) doesn't exist.")); - DomainResource domain = + DomainBase domain = loadByForeignKey( - DomainResource.class, "example.tld", DateTime.parse("2000-08-01T00:02:00Z")) + DomainBase.class, "example.tld", DateTime.parse("2000-08-01T00:02:00Z")) .get(); // Verify that the autorenew was ended and that the one-time billing event is not canceled. assertBillingEventsForResource( @@ -221,9 +221,9 @@ public class EppLifecycleDomainTest extends EppTestCase { .atTime(createTime) .hasResponse("domain_create_response_eap_fee.xml"); - DomainResource domain = + DomainBase domain = loadByForeignKey( - DomainResource.class, "example.tld", DateTime.parse("2000-06-01T00:03:00Z")) + DomainBase.class, "example.tld", DateTime.parse("2000-06-01T00:03:00Z")) .get(); // Delete domain example.tld within the add grade period. diff --git a/javatests/google/registry/flows/EppLifecycleHostTest.java b/javatests/google/registry/flows/EppLifecycleHostTest.java index 334213ca1..4af18ffdb 100644 --- a/javatests/google/registry/flows/EppLifecycleHostTest.java +++ b/javatests/google/registry/flows/EppLifecycleHostTest.java @@ -25,7 +25,7 @@ import static google.registry.testing.HostResourceSubject.assertAboutHosts; import com.google.common.collect.ImmutableMap; import com.googlecode.objectify.Key; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.host.HostResource; import google.registry.testing.AppEngineRule; import org.joda.time.DateTime; @@ -219,8 +219,8 @@ public class EppLifecycleHostTest extends EppTestCase { HostResource exampleBarFooTldHost = loadByForeignKey(HostResource.class, "ns1.example.bar.foo.tld", timeAfterCreates).get(); - DomainResource exampleBarFooTldDomain = - loadByForeignKey(DomainResource.class, "example.bar.foo.tld", timeAfterCreates).get(); + DomainBase exampleBarFooTldDomain = + loadByForeignKey(DomainBase.class, "example.bar.foo.tld", timeAfterCreates).get(); assertAboutHosts() .that(exampleBarFooTldHost) .hasSuperordinateDomain(Key.create(exampleBarFooTldDomain)); @@ -229,8 +229,8 @@ public class EppLifecycleHostTest extends EppTestCase { HostResource exampleFooTldHost = loadByForeignKey(HostResource.class, "ns1.example.foo.tld", timeAfterCreates).get(); - DomainResource exampleFooTldDomain = - loadByForeignKey(DomainResource.class, "example.foo.tld", timeAfterCreates).get(); + DomainBase exampleFooTldDomain = + loadByForeignKey(DomainBase.class, "example.foo.tld", timeAfterCreates).get(); assertAboutHosts() .that(exampleFooTldHost) .hasSuperordinateDomain(Key.create(exampleFooTldDomain)); @@ -238,8 +238,8 @@ public class EppLifecycleHostTest extends EppTestCase { HostResource exampleTldHost = loadByForeignKey(HostResource.class, "ns1.example.tld", timeAfterCreates).get(); - DomainResource exampleTldDomain = - loadByForeignKey(DomainResource.class, "example.tld", timeAfterCreates).get(); + DomainBase exampleTldDomain = + loadByForeignKey(DomainBase.class, "example.tld", timeAfterCreates).get(); assertAboutHosts().that(exampleTldHost).hasSuperordinateDomain(Key.create(exampleTldDomain)); assertThat(exampleTldDomain.getSubordinateHosts()).containsExactly("ns1.example.tld"); diff --git a/javatests/google/registry/flows/EppTestCase.java b/javatests/google/registry/flows/EppTestCase.java index fdd95d154..5b77d133a 100644 --- a/javatests/google/registry/flows/EppTestCase.java +++ b/javatests/google/registry/flows/EppTestCase.java @@ -34,7 +34,7 @@ import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent.Flag; import google.registry.model.billing.BillingEvent.OneTime; import google.registry.model.billing.BillingEvent.Reason; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.eppcommon.EppXmlTransformer; import google.registry.model.ofy.Ofy; import google.registry.model.registry.Registry; @@ -276,7 +276,7 @@ public class EppTestCase extends ShardableTestCase { /** Makes a one-time billing event corresponding to the given domain's creation. */ protected static BillingEvent.OneTime makeOneTimeCreateBillingEvent( - DomainResource domain, DateTime createTime) { + DomainBase domain, DateTime createTime) { return new BillingEvent.OneTime.Builder() .setReason(Reason.CREATE) .setTargetId(domain.getFullyQualifiedDomainName()) @@ -291,14 +291,14 @@ public class EppTestCase extends ShardableTestCase { /** Makes a recurring billing event corresponding to the given domain's creation. */ protected static BillingEvent.Recurring makeRecurringCreateBillingEvent( - DomainResource domain, DateTime eventTime, DateTime endTime) { + DomainBase domain, DateTime eventTime, DateTime endTime) { return makeRecurringCreateBillingEvent( domain, getOnlyHistoryEntryOfType(domain, Type.DOMAIN_CREATE), eventTime, endTime); } /** Makes a recurring billing event corresponding to the given history entry. */ protected static BillingEvent.Recurring makeRecurringCreateBillingEvent( - DomainResource domain, HistoryEntry historyEntry, DateTime eventTime, DateTime endTime) { + DomainBase domain, HistoryEntry historyEntry, DateTime eventTime, DateTime endTime) { return new BillingEvent.Recurring.Builder() .setReason(Reason.RENEW) .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) @@ -312,7 +312,7 @@ public class EppTestCase extends ShardableTestCase { /** Makes a cancellation billing event cancelling out the given domain create billing event. */ protected static BillingEvent.Cancellation makeCancellationBillingEventFor( - DomainResource domain, + DomainBase domain, OneTime billingEventToCancel, DateTime createTime, DateTime deleteTime) { diff --git a/javatests/google/registry/flows/FlowReporterTest.java b/javatests/google/registry/flows/FlowReporterTest.java index 9def9d6c7..e1127fa01 100644 --- a/javatests/google/registry/flows/FlowReporterTest.java +++ b/javatests/google/registry/flows/FlowReporterTest.java @@ -76,7 +76,7 @@ public class FlowReporterTest extends ShardableTestCase { @Test public void testRecordToLogs_metadata_basic() throws Exception { - when(flowReporter.eppInput.isDomainResourceType()).thenReturn(true); + when(flowReporter.eppInput.isDomainType()).thenReturn(true); when(flowReporter.eppInput.getResourceType()).thenReturn(Optional.of("domain")); flowReporter.recordToLogs(); assertThat(parseJsonMap(findFirstLogMessageByPrefix(handler, "FLOW-LOG-SIGNATURE-METADATA: "))) @@ -114,7 +114,7 @@ public class FlowReporterTest extends ShardableTestCase { @Test public void testRecordToLogs_metadata_notResourceFlow_noResourceTypeOrTld() throws Exception { - when(flowReporter.eppInput.isDomainResourceType()).thenReturn(false); + when(flowReporter.eppInput.isDomainType()).thenReturn(false); when(flowReporter.eppInput.getResourceType()).thenReturn(Optional.empty()); flowReporter.recordToLogs(); Map json = @@ -127,7 +127,7 @@ public class FlowReporterTest extends ShardableTestCase { @Test public void testRecordToLogs_metadata_notDomainFlow_noTld() throws Exception { - when(flowReporter.eppInput.isDomainResourceType()).thenReturn(false); + when(flowReporter.eppInput.isDomainType()).thenReturn(false); when(flowReporter.eppInput.getResourceType()).thenReturn(Optional.of("contact")); flowReporter.recordToLogs(); Map json = @@ -139,7 +139,7 @@ public class FlowReporterTest extends ShardableTestCase { @Test public void testRecordToLogs_metadata_multipartDomainName_multipartTld() throws Exception { - when(flowReporter.eppInput.isDomainResourceType()).thenReturn(true); + when(flowReporter.eppInput.isDomainType()).thenReturn(true); when(flowReporter.eppInput.getResourceType()).thenReturn(Optional.of("domain")); when(flowReporter.eppInput.getSingleTargetId()).thenReturn(Optional.of("target.co.uk")); when(flowReporter.eppInput.getTargetIds()).thenReturn(ImmutableList.of("target.co.uk")); @@ -154,7 +154,7 @@ public class FlowReporterTest extends ShardableTestCase { @Test public void testRecordToLogs_metadata_multipleTargetIds_uniqueTldSet() throws Exception { - when(flowReporter.eppInput.isDomainResourceType()).thenReturn(true); + when(flowReporter.eppInput.isDomainType()).thenReturn(true); when(flowReporter.eppInput.getSingleTargetId()).thenReturn(Optional.empty()); when(flowReporter.eppInput.getTargetIds()) .thenReturn(ImmutableList.of("target.co.uk", "foo.uk", "bar.uk", "baz.com")); @@ -170,7 +170,7 @@ public class FlowReporterTest extends ShardableTestCase { @Test public void testRecordToLogs_metadata_uppercaseDomainName_lowercaseTld() throws Exception { - when(flowReporter.eppInput.isDomainResourceType()).thenReturn(true); + when(flowReporter.eppInput.isDomainType()).thenReturn(true); when(flowReporter.eppInput.getSingleTargetId()).thenReturn(Optional.of("TARGET.FOO")); when(flowReporter.eppInput.getTargetIds()).thenReturn(ImmutableList.of("TARGET.FOO")); flowReporter.recordToLogs(); @@ -184,7 +184,7 @@ public class FlowReporterTest extends ShardableTestCase { @Test public void testRecordToLogs_metadata_invalidDomainName_stillGuessesTld() throws Exception { - when(flowReporter.eppInput.isDomainResourceType()).thenReturn(true); + when(flowReporter.eppInput.isDomainType()).thenReturn(true); when(flowReporter.eppInput.getSingleTargetId()).thenReturn(Optional.of("")); when(flowReporter.eppInput.getTargetIds()).thenReturn(ImmutableList.of("")); flowReporter.recordToLogs(); @@ -198,7 +198,7 @@ public class FlowReporterTest extends ShardableTestCase { @Test public void testRecordToLogs_metadata_domainWithoutPeriod_noTld() throws Exception { - when(flowReporter.eppInput.isDomainResourceType()).thenReturn(true); + when(flowReporter.eppInput.isDomainType()).thenReturn(true); when(flowReporter.eppInput.getSingleTargetId()).thenReturn(Optional.of("target,foo")); when(flowReporter.eppInput.getTargetIds()).thenReturn(ImmutableList.of("target,foo")); flowReporter.recordToLogs(); diff --git a/javatests/google/registry/flows/contact/ContactDeleteFlowTest.java b/javatests/google/registry/flows/contact/ContactDeleteFlowTest.java index 0e6c12e0b..04b6e8292 100644 --- a/javatests/google/registry/flows/contact/ContactDeleteFlowTest.java +++ b/javatests/google/registry/flows/contact/ContactDeleteFlowTest.java @@ -19,7 +19,7 @@ import static google.registry.testing.ContactResourceSubject.assertAboutContacts import static google.registry.testing.DatastoreHelper.assertNoBillingEvents; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.newContactResource; -import static google.registry.testing.DatastoreHelper.newDomainResource; +import static google.registry.testing.DatastoreHelper.newDomainBase; import static google.registry.testing.DatastoreHelper.persistActiveContact; import static google.registry.testing.DatastoreHelper.persistDeletedContact; import static google.registry.testing.DatastoreHelper.persistResource; @@ -166,7 +166,7 @@ public class ContactDeleteFlowTest public void testFailure_failfastWhenLinkedToDomain() throws Exception { createTld("tld"); persistResource( - newDomainResource("example.tld", persistActiveContact(getUniqueIdFromCommand()))); + newDomainBase("example.tld", persistActiveContact(getUniqueIdFromCommand()))); EppException thrown = assertThrows(ResourceToDeleteIsReferencedException.class, this::runFlow); assertAboutEppExceptions().that(thrown).marshalsToXml(); } @@ -175,7 +175,7 @@ public class ContactDeleteFlowTest public void testFailure_failfastWhenLinkedToApplication() throws Exception { createTld("tld"); persistResource( - newDomainResource("example.tld", persistActiveContact(getUniqueIdFromCommand()))); + newDomainBase("example.tld", persistActiveContact(getUniqueIdFromCommand()))); EppException thrown = assertThrows(ResourceToDeleteIsReferencedException.class, this::runFlow); assertAboutEppExceptions().that(thrown).marshalsToXml(); } diff --git a/javatests/google/registry/flows/contact/ContactInfoFlowTest.java b/javatests/google/registry/flows/contact/ContactInfoFlowTest.java index ccd972f3f..4d7e253cd 100644 --- a/javatests/google/registry/flows/contact/ContactInfoFlowTest.java +++ b/javatests/google/registry/flows/contact/ContactInfoFlowTest.java @@ -18,7 +18,7 @@ import static com.google.common.truth.Truth.assertThat; import static google.registry.model.EppResourceUtils.isDeleted; import static google.registry.testing.DatastoreHelper.assertNoBillingEvents; import static google.registry.testing.DatastoreHelper.createTld; -import static google.registry.testing.DatastoreHelper.newDomainResource; +import static google.registry.testing.DatastoreHelper.newDomainBase; import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions; import static google.registry.testing.JUnitBackports.assertThrows; @@ -110,7 +110,7 @@ public class ContactInfoFlowTest extends ResourceFlowTestCase { + extends ResourceCheckFlowTestCase { public DomainCheckFlowTest() { setEppInput("domain_check_one_tld.xml"); diff --git a/javatests/google/registry/flows/domain/DomainClaimsCheckFlowTest.java b/javatests/google/registry/flows/domain/DomainClaimsCheckFlowTest.java index 54b30fcb3..77b3b1f7d 100644 --- a/javatests/google/registry/flows/domain/DomainClaimsCheckFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainClaimsCheckFlowTest.java @@ -33,7 +33,7 @@ import google.registry.flows.domain.DomainFlowUtils.ClaimsPeriodEndedException; import google.registry.flows.domain.DomainFlowUtils.NotAuthorizedForTldException; import google.registry.flows.domain.DomainFlowUtils.TldDoesNotExistException; import google.registry.flows.exceptions.TooManyResourceChecksException; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.registry.Registry; import google.registry.model.registry.Registry.TldState; import org.junit.Before; @@ -41,7 +41,7 @@ import org.junit.Test; /** Unit tests for {@link DomainClaimsCheckFlow}. */ public class DomainClaimsCheckFlowTest - extends ResourceFlowTestCase { + extends ResourceFlowTestCase { public DomainClaimsCheckFlowTest() { setEppInput("domain_check_claims.xml"); diff --git a/javatests/google/registry/flows/domain/DomainCreateFlowTest.java b/javatests/google/registry/flows/domain/DomainCreateFlowTest.java index 820134d6b..e816cf8e2 100644 --- a/javatests/google/registry/flows/domain/DomainCreateFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainCreateFlowTest.java @@ -46,7 +46,7 @@ import static google.registry.testing.DatastoreHelper.persistActiveHost; import static google.registry.testing.DatastoreHelper.persistDeletedDomain; import static google.registry.testing.DatastoreHelper.persistReservedList; import static google.registry.testing.DatastoreHelper.persistResource; -import static google.registry.testing.DomainResourceSubject.assertAboutDomains; +import static google.registry.testing.DomainBaseSubject.assertAboutDomains; import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions; import static google.registry.testing.JUnitBackports.assertThrows; import static google.registry.testing.TaskQueueHelper.assertDnsTasksEnqueued; @@ -136,7 +136,7 @@ import google.registry.flows.exceptions.ResourceAlreadyExistsException; import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent.Flag; import google.registry.model.billing.BillingEvent.Reason; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.GracePeriod; import google.registry.model.domain.launch.LaunchNotice; import google.registry.model.domain.rgp.GracePeriodStatus; @@ -162,7 +162,7 @@ import org.junit.Before; import org.junit.Test; /** Unit tests for {@link DomainCreateFlow}. */ -public class DomainCreateFlowTest extends ResourceFlowTestCase { +public class DomainCreateFlowTest extends ResourceFlowTestCase { private static final String CLAIMS_KEY = "2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001"; @@ -212,7 +212,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase expectedBillingFlags) throws Exception { - DomainResource domain = reloadResourceByForeignKey(); + DomainBase domain = reloadResourceByForeignKey(); // Calculate the total cost. Money cost = @@ -1090,7 +1090,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase { +public class DomainDeleteFlowTest extends ResourceFlowTestCase { - private DomainResource domain; + private DomainBase domain; private HistoryEntry earlierHistoryEntry; private static final DateTime TIME_BEFORE_FLOW = DateTime.parse("2000-06-06T22:00:00.0Z"); @@ -148,7 +148,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase { +public class DomainInfoFlowTest extends ResourceFlowTestCase { private ContactResource registrant; private ContactResource contact; private HostResource host1; private HostResource host2; private HostResource host3; - private DomainResource domain; + private DomainBase domain; @Before public void setup() { @@ -84,7 +84,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase { +public class DomainRenewFlowTest extends ResourceFlowTestCase { private static final ImmutableMap FEE_06_MAP = ImmutableMap.of("FEE_VERSION", "0.6", "FEE_NS", "fee"); @@ -94,7 +94,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase { + extends ResourceFlowTestCase { private static final ImmutableMap FEE_06_MAP = ImmutableMap.of("FEE_VERSION", "0.6", "FEE_NS", "fee"); @@ -92,7 +92,7 @@ public class DomainRestoreRequestFlowTest } void persistPendingDeleteDomain() throws Exception { - DomainResource domain = newDomainResource(getUniqueIdFromCommand()); + DomainBase domain = newDomainBase(getUniqueIdFromCommand()); HistoryEntry historyEntry = persistResource( new HistoryEntry.Builder() @@ -136,7 +136,7 @@ public class DomainRestoreRequestFlowTest // Double check that we see a poll message in the future for when the delete happens. assertThat(getPollMessages("TheRegistrar", clock.nowUtc().plusMonths(1))).hasSize(1); runFlowAssertResponse(loadFile("generic_success_response.xml")); - DomainResource domain = reloadResourceByForeignKey(); + DomainBase domain = reloadResourceByForeignKey(); HistoryEntry historyEntryDomainRestore = getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_RESTORE); assertThat(ofy().load().key(domain.getAutorenewBillingEvent()).now().getEventTime()) @@ -474,7 +474,7 @@ public class DomainRestoreRequestFlowTest @Test public void testFailure_notInRedemptionPeriod() throws Exception { persistResource( - newDomainResource(getUniqueIdFromCommand()) + newDomainBase(getUniqueIdFromCommand()) .asBuilder() .setDeletionTime(clock.nowUtc().plusDays(4)) .setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE)) @@ -611,7 +611,7 @@ public class DomainRestoreRequestFlowTest public void testIcannTransactionReportField_getsStored() throws Exception { persistPendingDeleteDomain(); runFlow(); - DomainResource domain = reloadResourceByForeignKey(); + DomainBase domain = reloadResourceByForeignKey(); HistoryEntry historyEntryDomainRestore = getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_RESTORE); assertThat(historyEntryDomainRestore.getDomainTransactionRecords()) diff --git a/javatests/google/registry/flows/domain/DomainTransferApproveFlowTest.java b/javatests/google/registry/flows/domain/DomainTransferApproveFlowTest.java index 9f200e732..ba27c8dec 100644 --- a/javatests/google/registry/flows/domain/DomainTransferApproveFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainTransferApproveFlowTest.java @@ -30,7 +30,7 @@ import static google.registry.testing.DatastoreHelper.getOnlyPollMessage; import static google.registry.testing.DatastoreHelper.getPollMessages; import static google.registry.testing.DatastoreHelper.loadRegistrar; import static google.registry.testing.DatastoreHelper.persistResource; -import static google.registry.testing.DomainResourceSubject.assertAboutDomains; +import static google.registry.testing.DomainBaseSubject.assertAboutDomains; import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions; import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries; import static google.registry.testing.JUnitBackports.assertThrows; @@ -55,7 +55,7 @@ import google.registry.model.billing.BillingEvent.Reason; import google.registry.model.billing.BillingEvent.Recurring; import google.registry.model.contact.ContactAuthInfo; import google.registry.model.domain.DomainAuthInfo; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.GracePeriod; import google.registry.model.domain.Period; import google.registry.model.domain.Period.Unit; @@ -81,7 +81,7 @@ import org.junit.Test; /** Unit tests for {@link DomainTransferApproveFlow}. */ public class DomainTransferApproveFlowTest - extends DomainTransferFlowTestCase { + extends DomainTransferFlowTestCase { @Before public void setUp() { @@ -108,7 +108,7 @@ public class DomainTransferApproveFlowTest clock.advanceOneMilli(); } - private void assertTransferApproved(DomainResource domain, TransferData oldTransferData) { + private void assertTransferApproved(DomainBase domain, TransferData oldTransferData) { assertAboutDomains() .that(domain) .hasCurrentSponsorClientId("NewRegistrar") @@ -633,7 +633,7 @@ public class DomainTransferApproveFlowTest @Test public void testSuccess_superuserExtension_transferPeriodZero_autorenewGraceActive() throws Exception { - DomainResource domain = reloadResourceByForeignKey(); + DomainBase domain = reloadResourceByForeignKey(); Key existingAutorenewEvent = domain.getAutorenewBillingEvent(); // Set domain to have auto-renewed just before the transfer request, so that it will have an // active autorenew grace period spanning the entire transfer window. diff --git a/javatests/google/registry/flows/domain/DomainTransferCancelFlowTest.java b/javatests/google/registry/flows/domain/DomainTransferCancelFlowTest.java index 3c7aa3f22..a172cd110 100644 --- a/javatests/google/registry/flows/domain/DomainTransferCancelFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainTransferCancelFlowTest.java @@ -27,7 +27,7 @@ import static google.registry.testing.DatastoreHelper.getOnlyHistoryEntryOfType; import static google.registry.testing.DatastoreHelper.getPollMessages; import static google.registry.testing.DatastoreHelper.loadRegistrar; import static google.registry.testing.DatastoreHelper.persistResource; -import static google.registry.testing.DomainResourceSubject.assertAboutDomains; +import static google.registry.testing.DomainBaseSubject.assertAboutDomains; import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions; import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries; import static google.registry.testing.JUnitBackports.assertThrows; @@ -43,7 +43,7 @@ import google.registry.flows.exceptions.NotPendingTransferException; import google.registry.flows.exceptions.NotTransferInitiatorException; import google.registry.model.contact.ContactAuthInfo; import google.registry.model.domain.DomainAuthInfo; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.GracePeriod; import google.registry.model.eppcommon.AuthInfo.PasswordAuth; import google.registry.model.poll.PollMessage; @@ -60,7 +60,7 @@ import org.junit.Test; /** Unit tests for {@link DomainTransferCancelFlow}. */ public class DomainTransferCancelFlowTest - extends DomainTransferFlowTestCase { + extends DomainTransferFlowTestCase { @Before public void setUp() { diff --git a/javatests/google/registry/flows/domain/DomainTransferFlowTestCase.java b/javatests/google/registry/flows/domain/DomainTransferFlowTestCase.java index 19cac9c2a..410512504 100644 --- a/javatests/google/registry/flows/domain/DomainTransferFlowTestCase.java +++ b/javatests/google/registry/flows/domain/DomainTransferFlowTestCase.java @@ -24,7 +24,7 @@ import static google.registry.testing.DatastoreHelper.persistActiveContact; import static google.registry.testing.DatastoreHelper.persistDomainWithDependentResources; import static google.registry.testing.DatastoreHelper.persistDomainWithPendingTransfer; import static google.registry.testing.DatastoreHelper.persistResource; -import static google.registry.testing.DomainResourceSubject.assertAboutDomains; +import static google.registry.testing.DomainBaseSubject.assertAboutDomains; import static google.registry.util.DateTimeUtils.END_OF_TIME; import com.google.common.base.Ascii; @@ -37,7 +37,7 @@ import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent.Flag; import google.registry.model.billing.BillingEvent.Reason; import google.registry.model.contact.ContactResource; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.eppcommon.StatusValue; import google.registry.model.host.HostResource; import google.registry.model.registry.Registry; @@ -72,7 +72,7 @@ public class DomainTransferFlowTestCase REGISTRATION_EXPIRATION_TIME.plusYears(EXTENDED_REGISTRATION_YEARS); protected ContactResource contact; - protected DomainResource domain; + protected DomainBase domain; protected HostResource subordinateHost; protected HistoryEntry historyEntryDomainCreate; @@ -89,7 +89,7 @@ public class DomainTransferFlowTestCase AppEngineRule.makeRegistrar1().asBuilder().setClientId("ClientZ").build()); } - static DomainResource persistWithPendingTransfer(DomainResource domain) { + static DomainBase persistWithPendingTransfer(DomainBase domain) { return persistDomainWithPendingTransfer( domain, TRANSFER_REQUEST_TIME, @@ -165,7 +165,7 @@ public class DomainTransferFlowTestCase } protected void assertTransferFailed( - DomainResource domain, TransferStatus status, TransferData oldTransferData) { + DomainBase domain, TransferStatus status, TransferData oldTransferData) { assertAboutDomains().that(domain) .doesNotHaveStatusValue(StatusValue.PENDING_TRANSFER).and() .hasCurrentSponsorClientId("TheRegistrar"); diff --git a/javatests/google/registry/flows/domain/DomainTransferQueryFlowTest.java b/javatests/google/registry/flows/domain/DomainTransferQueryFlowTest.java index e7434d093..634e5c98f 100644 --- a/javatests/google/registry/flows/domain/DomainTransferQueryFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainTransferQueryFlowTest.java @@ -19,7 +19,7 @@ import static google.registry.testing.DatastoreHelper.assertBillingEvents; import static google.registry.testing.DatastoreHelper.deleteResource; import static google.registry.testing.DatastoreHelper.getPollMessages; import static google.registry.testing.DatastoreHelper.persistResource; -import static google.registry.testing.DomainResourceSubject.assertAboutDomains; +import static google.registry.testing.DomainBaseSubject.assertAboutDomains; import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions; import static google.registry.testing.JUnitBackports.assertThrows; @@ -30,7 +30,7 @@ import google.registry.flows.exceptions.NoTransferHistoryToQueryException; import google.registry.flows.exceptions.NotAuthorizedToViewTransferException; import google.registry.model.contact.ContactAuthInfo; import google.registry.model.domain.DomainAuthInfo; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.eppcommon.AuthInfo.PasswordAuth; import google.registry.model.reporting.HistoryEntry; import google.registry.model.transfer.TransferStatus; @@ -39,7 +39,7 @@ import org.junit.Test; /** Unit tests for {@link DomainTransferQueryFlow}. */ public class DomainTransferQueryFlowTest - extends DomainTransferFlowTestCase { + extends DomainTransferFlowTestCase { @Before public void setUp() { diff --git a/javatests/google/registry/flows/domain/DomainTransferRejectFlowTest.java b/javatests/google/registry/flows/domain/DomainTransferRejectFlowTest.java index a616ff696..f3b18d6da 100644 --- a/javatests/google/registry/flows/domain/DomainTransferRejectFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainTransferRejectFlowTest.java @@ -29,7 +29,7 @@ import static google.registry.testing.DatastoreHelper.getOnlyPollMessage; import static google.registry.testing.DatastoreHelper.getPollMessages; import static google.registry.testing.DatastoreHelper.loadRegistrar; import static google.registry.testing.DatastoreHelper.persistResource; -import static google.registry.testing.DomainResourceSubject.assertAboutDomains; +import static google.registry.testing.DomainBaseSubject.assertAboutDomains; import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions; import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries; import static google.registry.testing.JUnitBackports.assertThrows; @@ -44,7 +44,7 @@ import google.registry.flows.domain.DomainFlowUtils.NotAuthorizedForTldException import google.registry.flows.exceptions.NotPendingTransferException; import google.registry.model.contact.ContactAuthInfo; import google.registry.model.domain.DomainAuthInfo; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.GracePeriod; import google.registry.model.eppcommon.AuthInfo.PasswordAuth; import google.registry.model.eppcommon.Trid; @@ -63,7 +63,7 @@ import org.junit.Test; /** Unit tests for {@link DomainTransferRejectFlow}. */ public class DomainTransferRejectFlowTest - extends DomainTransferFlowTestCase { + extends DomainTransferFlowTestCase { @Before public void setUp() { diff --git a/javatests/google/registry/flows/domain/DomainTransferRequestFlowTest.java b/javatests/google/registry/flows/domain/DomainTransferRequestFlowTest.java index 367635dd5..590333c1f 100644 --- a/javatests/google/registry/flows/domain/DomainTransferRequestFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainTransferRequestFlowTest.java @@ -36,7 +36,7 @@ import static google.registry.testing.DatastoreHelper.getPollMessages; import static google.registry.testing.DatastoreHelper.loadRegistrar; import static google.registry.testing.DatastoreHelper.persistActiveContact; import static google.registry.testing.DatastoreHelper.persistResource; -import static google.registry.testing.DomainResourceSubject.assertAboutDomains; +import static google.registry.testing.DomainBaseSubject.assertAboutDomains; import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions; import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries; import static google.registry.testing.HostResourceSubject.assertAboutHosts; @@ -80,7 +80,7 @@ import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent.Reason; import google.registry.model.contact.ContactAuthInfo; import google.registry.model.domain.DomainAuthInfo; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.GracePeriod; import google.registry.model.domain.Period; import google.registry.model.domain.Period.Unit; @@ -110,7 +110,7 @@ import org.junit.Test; /** Unit tests for {@link DomainTransferRequestFlow}. */ public class DomainTransferRequestFlowTest - extends DomainTransferFlowTestCase { + extends DomainTransferFlowTestCase { private static final ImmutableMap BASE_FEE_MAP = new ImmutableMap.Builder() @@ -144,7 +144,7 @@ public class DomainTransferRequestFlowTest } private void assertTransferRequested( - DomainResource domain, + DomainBase domain, DateTime automaticTransferTime, Period expectedPeriod, DateTime expectedExpirationTime) @@ -184,7 +184,7 @@ public class DomainTransferRequestFlowTest } private void assertTransferApproved( - DomainResource domain, DateTime automaticTransferTime, Period expectedPeriod) + DomainBase domain, DateTime automaticTransferTime, Period expectedPeriod) throws Exception { assertAboutDomains() .that(domain) @@ -309,7 +309,7 @@ public class DomainTransferRequestFlowTest assertThat(domain.getGracePeriods()).containsExactlyElementsIn(originalGracePeriods); // If we fast forward AUTOMATIC_TRANSFER_DAYS, the transfer should have cleared out all other // grace periods, but expect a transfer grace period (if there was a transfer billing event). - DomainResource domainAfterAutomaticTransfer = domain.cloneProjectedAtTime(implicitTransferTime); + DomainBase domainAfterAutomaticTransfer = domain.cloneProjectedAtTime(implicitTransferTime); if (expectTransferBillingEvent) { assertGracePeriods( domainAfterAutomaticTransfer.getGracePeriods(), @@ -417,7 +417,7 @@ public class DomainTransferRequestFlowTest DateTime expectedExpirationTime, DateTime implicitTransferTime, Period expectedPeriod) throws Exception { Registry registry = Registry.get(domain.getTld()); - DomainResource domainAfterAutomaticTransfer = domain.cloneProjectedAtTime(implicitTransferTime); + DomainBase domainAfterAutomaticTransfer = domain.cloneProjectedAtTime(implicitTransferTime); assertTransferApproved(domainAfterAutomaticTransfer, implicitTransferTime, expectedPeriod); assertAboutDomains() .that(domainAfterAutomaticTransfer) @@ -434,7 +434,7 @@ public class DomainTransferRequestFlowTest .getEventTime()) .isEqualTo(expectedExpirationTime); // And after the expected grace time, the grace period should be gone. - DomainResource afterGracePeriod = + DomainBase afterGracePeriod = domain.cloneProjectedAtTime( clock .nowUtc() @@ -573,7 +573,7 @@ public class DomainTransferRequestFlowTest if (expectedAutomaticTransferLength.equals(Duration.ZERO)) { // The transfer is going to happen immediately. To observe the domain in the pending transfer // state, grab it directly from the database. - domain = Iterables.getOnlyElement(ofy().load().type(DomainResource.class).list()); + domain = Iterables.getOnlyElement(ofy().load().type(DomainBase.class).list()); assertThat(domain.getFullyQualifiedDomainName()).isEqualTo("example.tld"); } else { // Transfer should have been requested. diff --git a/javatests/google/registry/flows/domain/DomainUpdateFlowTest.java b/javatests/google/registry/flows/domain/DomainUpdateFlowTest.java index 40ec7b95f..be502585c 100644 --- a/javatests/google/registry/flows/domain/DomainUpdateFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainUpdateFlowTest.java @@ -25,7 +25,7 @@ import static google.registry.testing.DatastoreHelper.assertNoBillingEvents; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.getOnlyHistoryEntryOfType; import static google.registry.testing.DatastoreHelper.loadRegistrar; -import static google.registry.testing.DatastoreHelper.newDomainResource; +import static google.registry.testing.DatastoreHelper.newDomainBase; import static google.registry.testing.DatastoreHelper.persistActiveContact; import static google.registry.testing.DatastoreHelper.persistActiveDomain; import static google.registry.testing.DatastoreHelper.persistActiveHost; @@ -33,7 +33,7 @@ import static google.registry.testing.DatastoreHelper.persistActiveSubordinateHo import static google.registry.testing.DatastoreHelper.persistDeletedDomain; import static google.registry.testing.DatastoreHelper.persistReservedList; import static google.registry.testing.DatastoreHelper.persistResource; -import static google.registry.testing.DomainResourceSubject.assertAboutDomains; +import static google.registry.testing.DomainBaseSubject.assertAboutDomains; import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions; import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries; import static google.registry.testing.JUnitBackports.assertThrows; @@ -83,7 +83,7 @@ import google.registry.model.billing.BillingEvent.Reason; import google.registry.model.contact.ContactResource; import google.registry.model.domain.DesignatedContact; import google.registry.model.domain.DesignatedContact.Type; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.eppcommon.StatusValue; import google.registry.model.host.HostResource; @@ -94,7 +94,7 @@ import org.junit.Before; import org.junit.Test; /** Unit tests for {@link DomainUpdateFlow}. */ -public class DomainUpdateFlowTest extends ResourceFlowTestCase { +public class DomainUpdateFlowTest extends ResourceFlowTestCase { private static final DelegationSignerData SOME_DSDATA = DelegationSignerData.create(1, 2, 3, new byte[] {0, 1, 2}); @@ -120,12 +120,12 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase sh8013Key = Key.create(sh8013); persistResource( - newDomainResource(getUniqueIdFromCommand()) + newDomainBase(getUniqueIdFromCommand()) .asBuilder() .setRegistrant(sh8013Key) .setContacts( @@ -409,11 +409,11 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCaseThe transfer is from "TheRegistrar" to "NewRegistrar". */ - private DomainResource createDomainWithServerApprovedTransfer(String domainName) { + private DomainBase createDomainWithServerApprovedTransfer(String domainName) { DateTime now = clock.nowUtc(); DateTime requestTime = now.minusDays(1).minus(Registry.DEFAULT_AUTOMATIC_TRANSFER_LENGTH); DateTime transferExpirationTime = now.minusDays(1); - return newDomainResource(domainName) + return newDomainBase(domainName) .asBuilder() .setPersistedCurrentSponsorClientId("TheRegistrar") .addStatusValue(StatusValue.PENDING_TRANSFER) @@ -192,7 +192,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase192.0.2.22", "1080:0:0:0:8:800:200C:417A"); createTld("tld"); - DomainResource example = persistActiveDomain("example.tld"); - DomainResource foo = + DomainBase example = persistActiveDomain("example.tld"); + DomainBase foo = persistResource( - newDomainResource("foo.tld") + newDomainBase("foo.tld") .asBuilder() .setSubordinateHosts(ImmutableSet.of(oldHostName())) .build()); @@ -336,13 +336,13 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase1080:0:0:0:8:800:200C:417A"); createTld("foo"); createTld("tld"); - DomainResource fooDomain = + DomainBase fooDomain = persistResource( - newDomainResource("example.foo") + newDomainBase("example.foo") .asBuilder() .setSubordinateHosts(ImmutableSet.of(oldHostName())) .build()); - DomainResource tldDomain = persistActiveDomain("example.tld"); + DomainBase tldDomain = persistActiveDomain("example.tld"); persistActiveSubordinateHost(oldHostName(), fooDomain); assertThat(fooDomain.getSubordinateHosts()).containsExactly("ns1.example.foo"); assertThat(tldDomain.getSubordinateHosts()).isEmpty(); @@ -357,10 +357,10 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase1080:0:0:0:8:800:200C:417A"); createTld("foo"); - DomainResource domain = + DomainBase domain = persistResource( - newDomainResource("example.foo") + newDomainBase("example.foo") .asBuilder() .setSubordinateHosts(ImmutableSet.of(oldHostName())) .build()); @@ -402,7 +402,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase192.0.2.22", null); createTld("tld"); - DomainResource domain = persistActiveDomain("example.tld"); + DomainBase domain = persistActiveDomain("example.tld"); persistActiveHost(oldHostName()); assertThat(domain.getSubordinateHosts()).isEmpty(); assertThrows(CannotRenameExternalHostException.class, this::runFlow); @@ -425,7 +425,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase192.0.2.22", null); createTld("tld"); - DomainResource domain = persistActiveDomain("example.tld"); + DomainBase domain = persistActiveDomain("example.tld"); persistActiveHost(oldHostName()); assertThat(domain.getSubordinateHosts()).isEmpty(); HostResource renamedHost = doSuccessfulTestAsSuperuser(); @@ -501,12 +501,12 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase1080:0:0:0:8:800:200C:417A"); createTld("tld"); DateTime lastTransferTime = clock.nowUtc().minusDays(5); - DomainResource foo = - newDomainResource("foo.tld").asBuilder().setLastTransferTime(lastTransferTime).build(); + DomainBase foo = + newDomainBase("foo.tld").asBuilder().setLastTransferTime(lastTransferTime).build(); // Set the new domain to have a last transfer time that is different than the last transfer // time on the host in question. persistResource( - newDomainResource("example.tld") + newDomainBase("example.tld") .asBuilder() .setLastTransferTime(clock.nowUtc().minusDays(10)) .build()); @@ -535,15 +535,15 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase192.0.2.22", "1080:0:0:0:8:800:200C:417A"); createTld("tld"); - DomainResource domain = - newDomainResource("foo.tld") + DomainBase domain = + newDomainBase("foo.tld") .asBuilder() .setLastTransferTime(clock.nowUtc().minusDays(5)) .build(); // Set the new domain to have a last transfer time that is different than the last transfer // time on the host in question. persistResource( - newDomainResource("example.tld") + newDomainBase("example.tld") .asBuilder() .setLastTransferTime(clock.nowUtc().minusDays(10)) .build()); @@ -574,13 +574,13 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase192.0.2.22", "1080:0:0:0:8:800:200C:417A"); createTld("tld"); - DomainResource foo = - newDomainResource("foo.tld") + DomainBase foo = + newDomainBase("foo.tld") .asBuilder() .setLastTransferTime(clock.nowUtc().minusDays(5)) .build(); // Set the new domain to have a null last transfer time. - persistResource(newDomainResource("example.tld").asBuilder().setLastTransferTime(null).build()); + persistResource(newDomainBase("example.tld").asBuilder().setLastTransferTime(null).build()); DateTime lastTransferTime = clock.nowUtc().minusDays(20); persistResource( @@ -609,9 +609,9 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase192.0.2.22", "1080:0:0:0:8:800:200C:417A"); createTld("tld"); - DomainResource foo = newDomainResource("foo.tld").asBuilder().setLastTransferTime(null).build(); + DomainBase foo = newDomainBase("foo.tld").asBuilder().setLastTransferTime(null).build(); // Set the new domain to have a null last transfer time. - persistResource(newDomainResource("example.tld").asBuilder().setLastTransferTime(null).build()); + persistResource(newDomainBase("example.tld").asBuilder().setLastTransferTime(null).build()); DateTime lastTransferTime = clock.nowUtc().minusDays(20); persistResource( @@ -639,13 +639,13 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase192.0.2.22", "1080:0:0:0:8:800:200C:417A"); createTld("tld"); - DomainResource foo = - newDomainResource("foo.tld") + DomainBase foo = + newDomainBase("foo.tld") .asBuilder() .setLastTransferTime(clock.nowUtc().minusDays(5)) .build(); // Set the new domain to have a null last transfer time. - persistResource(newDomainResource("example.tld").asBuilder().setLastTransferTime(null).build()); + persistResource(newDomainBase("example.tld").asBuilder().setLastTransferTime(null).build()); persistResource( newHostResource(oldHostName()) .asBuilder() @@ -671,7 +671,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase1080:0:0:0:8:800:200C:417A"); createTld("foo"); - DomainResource domain = persistActiveDomain("example.foo"); + DomainBase domain = persistActiveDomain("example.foo"); persistResource( newHostResource(oldHostName()) .asBuilder() @@ -707,7 +707,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase1080:0:0:0:8:800:200C:417A"); createTld("foo"); - DomainResource domain = persistActiveDomain("example.foo"); + DomainBase domain = persistActiveDomain("example.foo"); DateTime lastTransferTime = clock.nowUtc().minusDays(12); persistResource( newHostResource(oldHostName()) @@ -743,7 +743,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase1080:0:0:0:8:800:200C:417A"); createTld("foo"); - DomainResource domain = persistActiveDomain("example.foo"); + DomainBase domain = persistActiveDomain("example.foo"); persistResource( newHostResource(oldHostName()) .asBuilder() @@ -774,7 +774,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase192.0.2.22", null); createTld("tld"); persistResource( - newDomainResource("example.tld") + newDomainBase("example.tld") .asBuilder() .setLastTransferTime(domainTransferTime) .build()); @@ -826,9 +826,9 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase192.0.2.22", "1080:0:0:0:8:800:200C:417A"); createTld("tld"); - DomainResource domain = + DomainBase domain = persistResource( - newDomainResource("example.tld") + newDomainBase("example.tld") .asBuilder() .setSubordinateHosts(ImmutableSet.of(oldHostName())) .setDeletionTime(clock.nowUtc().plusDays(35)) @@ -1095,9 +1095,9 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase { /** This is the message id being sent in the ACK request. */ private static final long MESSAGE_ID = 3; - private DomainResource domain; + private DomainBase domain; private ContactResource contact; @Before @@ -54,7 +54,7 @@ public class PollAckFlowTest extends FlowTestCase { clock.advanceOneMilli(); contact = persistActiveContact("jd1234"); clock.advanceOneMilli(); - domain = persistResource(newDomainResource("test.example", contact)); + domain = persistResource(newDomainBase("test.example", contact)); clock.advanceOneMilli(); } diff --git a/javatests/google/registry/flows/poll/PollRequestFlowTest.java b/javatests/google/registry/flows/poll/PollRequestFlowTest.java index bad4886ad..15e6cb597 100644 --- a/javatests/google/registry/flows/poll/PollRequestFlowTest.java +++ b/javatests/google/registry/flows/poll/PollRequestFlowTest.java @@ -16,7 +16,7 @@ package google.registry.flows.poll; import static google.registry.testing.DatastoreHelper.createHistoryEntryForEppResource; import static google.registry.testing.DatastoreHelper.createTld; -import static google.registry.testing.DatastoreHelper.newDomainResource; +import static google.registry.testing.DatastoreHelper.newDomainBase; import static google.registry.testing.DatastoreHelper.persistActiveContact; import static google.registry.testing.DatastoreHelper.persistActiveHost; import static google.registry.testing.DatastoreHelper.persistResource; @@ -28,7 +28,7 @@ import google.registry.flows.EppException; import google.registry.flows.FlowTestCase; import google.registry.flows.poll.PollRequestFlow.UnexpectedMessageIdException; import google.registry.model.contact.ContactResource; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.eppcommon.Trid; import google.registry.model.host.HostResource; import google.registry.model.poll.PendingActionNotificationResponse.DomainPendingActionNotificationResponse; @@ -44,7 +44,7 @@ import org.junit.Test; /** Unit tests for {@link PollRequestFlow}. */ public class PollRequestFlowTest extends FlowTestCase { - private DomainResource domain; + private DomainBase domain; private ContactResource contact; private HostResource host; @@ -55,7 +55,7 @@ public class PollRequestFlowTest extends FlowTestCase { clock.setTo(DateTime.parse("2011-01-02T01:01:01Z")); createTld("example"); contact = persistActiveContact("jd1234"); - domain = persistResource(newDomainResource("test.example", contact)); + domain = persistResource(newDomainBase("test.example", contact)); host = persistActiveHost("ns1.test.example"); } diff --git a/javatests/google/registry/mapreduce/inputs/ChildEntityInputTest.java b/javatests/google/registry/mapreduce/inputs/ChildEntityInputTest.java index c32199eb1..874e00bef 100644 --- a/javatests/google/registry/mapreduce/inputs/ChildEntityInputTest.java +++ b/javatests/google/registry/mapreduce/inputs/ChildEntityInputTest.java @@ -20,7 +20,7 @@ import static google.registry.mapreduce.inputs.EppResourceInputs.createChildEnti import static google.registry.model.index.EppResourceIndexBucket.getBucketKey; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.newContactResource; -import static google.registry.testing.DatastoreHelper.newDomainResource; +import static google.registry.testing.DatastoreHelper.newDomainBase; import static google.registry.testing.DatastoreHelper.persistEppResourceInFirstBucket; import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.DatastoreHelper.persistSimpleResource; @@ -36,7 +36,7 @@ import google.registry.model.ImmutableObject; import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent.Reason; import google.registry.model.contact.ContactResource; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.index.EppResourceIndex; import google.registry.model.reporting.HistoryEntry; import google.registry.testing.AppEngineRule; @@ -63,8 +63,8 @@ public class ChildEntityInputTest { @Rule public final AppEngineRule appEngine = AppEngineRule.builder().withDatastore().build(); - DomainResource domainA; - DomainResource domainB; + DomainBase domainA; + DomainBase domainB; HistoryEntry domainHistoryEntryA; HistoryEntry domainHistoryEntryB; HistoryEntry contactHistoryEntry; @@ -76,7 +76,7 @@ public class ChildEntityInputTest { private void setupResources() { createTld("tld"); ContactResource contact = persistEppResourceInFirstBucket(newContactResource("contact1234")); - domainA = persistEppResourceInFirstBucket(newDomainResource("a.tld", contact)); + domainA = persistEppResourceInFirstBucket(newDomainBase("a.tld", contact)); domainHistoryEntryA = persistResource( new HistoryEntry.Builder() .setParent(domainA) @@ -110,8 +110,8 @@ public class ChildEntityInputTest { .build()); } - private void setupSecondDomainResources() { - domainB = persistEppResourceInFirstBucket(newDomainResource("b.tld")); + private void setupSecondDomainBases() { + domainB = persistEppResourceInFirstBucket(newDomainBase("b.tld")); domainHistoryEntryB = persistResource( new HistoryEntry.Builder() .setParent(domainB) @@ -155,7 +155,7 @@ public class ChildEntityInputTest { @Test public void testSuccess_childEntityReader_multipleParentsAndChildren() throws Exception { setupResources(); - setupSecondDomainResources(); + setupSecondDomainBases(); Set seen = new HashSet<>(); InputReader reader = EppResourceInputs.createChildEntityInput( ImmutableSet.of(EppResource.class), @@ -262,7 +262,7 @@ public class ChildEntityInputTest { @Test public void testSuccess_childEntityReader_readerCountMatchesBucketCount() throws Exception { assertThat(EppResourceInputs.createChildEntityInput( - ImmutableSet.>of(DomainResource.class), + ImmutableSet.>of(DomainBase.class), ImmutableSet.>of( BillingEvent.OneTime.class)).createReaders()).hasSize(3); } @@ -272,7 +272,7 @@ public class ChildEntityInputTest { createTld("tld"); Set historyEntries = new HashSet<>(); for (int i = 1; i <= 3; i++) { - DomainResource domain = persistSimpleResource(newDomainResource(i + ".tld")); + DomainBase domain = persistSimpleResource(newDomainBase(i + ".tld")); historyEntries.add(persistResource( new HistoryEntry.Builder() .setParent(domain) @@ -283,7 +283,7 @@ public class ChildEntityInputTest { } Set seen = new HashSet<>(); for (InputReader reader : EppResourceInputs.createChildEntityInput( - ImmutableSet.>of(DomainResource.class), + ImmutableSet.>of(DomainBase.class), ImmutableSet.>of(HistoryEntry.class)).createReaders()) { reader.beginShard(); reader.beginSlice(); diff --git a/javatests/google/registry/mapreduce/inputs/EppResourceInputsTest.java b/javatests/google/registry/mapreduce/inputs/EppResourceInputsTest.java index 7077a414c..0f53d282a 100644 --- a/javatests/google/registry/mapreduce/inputs/EppResourceInputsTest.java +++ b/javatests/google/registry/mapreduce/inputs/EppResourceInputsTest.java @@ -21,7 +21,7 @@ import static google.registry.mapreduce.inputs.EppResourceInputs.createKeyInput; import static google.registry.model.index.EppResourceIndexBucket.getBucketKey; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.newContactResource; -import static google.registry.testing.DatastoreHelper.newDomainResource; +import static google.registry.testing.DatastoreHelper.newDomainBase; import static google.registry.testing.DatastoreHelper.newHostResource; import static google.registry.testing.DatastoreHelper.persistActiveContact; import static google.registry.testing.DatastoreHelper.persistEppResourceInFirstBucket; @@ -34,7 +34,6 @@ import com.googlecode.objectify.Key; import google.registry.model.EppResource; import google.registry.model.contact.ContactResource; import google.registry.model.domain.DomainBase; -import google.registry.model.domain.DomainResource; import google.registry.model.host.HostResource; import google.registry.model.index.EppResourceIndex; import google.registry.testing.AppEngineRule; @@ -72,14 +71,7 @@ public class EppResourceInputsTest { @Test public void testSuccess_keyInputType_polymorphicBaseType() { - createKeyInput(DomainBase.class); - } - - @Test - public void testFailure_keyInputType_polymorphicSubclass() { - IllegalArgumentException thrown = - assertThrows(IllegalArgumentException.class, () -> createKeyInput(DomainResource.class)); - assertThat(thrown).hasMessageThat().contains("non-polymorphic"); + createKeyInput(EppResource.class); } @Test @@ -91,19 +83,12 @@ public class EppResourceInputsTest { assertThat(thrown).hasMessageThat().contains("inheritance"); } - @Test - public void testSuccess_entityInputTypesMayBePolymorphic() { - // Both polymorphic and not should work. - createEntityInput(DomainBase.class); - createEntityInput(DomainResource.class); - } - @Test public void testFailure_entityInputType_noInheritanceBetweenTypes_eppResource() { IllegalArgumentException thrown = assertThrows( IllegalArgumentException.class, - () -> createEntityInput(EppResource.class, DomainResource.class)); + () -> createEntityInput(EppResource.class, DomainBase.class)); assertThat(thrown).hasMessageThat().contains("inheritance"); } @@ -112,7 +97,7 @@ public class EppResourceInputsTest { IllegalArgumentException thrown = assertThrows( IllegalArgumentException.class, - () -> createEntityInput(DomainBase.class, DomainResource.class)); + () -> createEntityInput(EppResource.class, ContactResource.class)); assertThat(thrown).hasMessageThat().contains("inheritance"); } @@ -125,9 +110,9 @@ public class EppResourceInputsTest { @Test public void testKeyInput_oneReaderPerBucket() throws Exception { createTld("tld"); - Set> domains = new HashSet<>(); + Set> domains = new HashSet<>(); for (int i = 1; i <= 3; i++) { - Key key = Key.create(newDomainResource(i + ".tld")); + Key key = Key.create(newDomainBase(i + ".tld")); domains.add(key); persistResource(EppResourceIndex.create(getBucketKey(i), key)); } @@ -148,21 +133,21 @@ public class EppResourceInputsTest { @Test public void testEntityInput_oneReaderPerBucket() throws Exception { createTld("tld"); - Set domains = new HashSet<>(); + Set domains = new HashSet<>(); for (int i = 1; i <= 3; i++) { // Persist the domain as a simple resource so that it doesn't automatically get an ERI. - DomainResource domain = persistSimpleResource(newDomainResource(i + ".tld")); + DomainBase domain = persistSimpleResource(newDomainBase(i + ".tld")); domains.add(domain); persistResource(EppResourceIndex.create(getBucketKey(i), Key.create(domain))); } - Set seen = new HashSet<>(); - for (InputReader reader - : createEntityInput(DomainResource.class).createReaders()) { + Set seen = new HashSet<>(); + for (InputReader reader + : createEntityInput(DomainBase.class).createReaders()) { reader.beginShard(); reader.beginSlice(); seen.add(reader.next()); try { - DomainResource domain = reader.next(); + DomainBase domain = reader.next(); assert_().fail("Unexpected element: " + domain); } catch (NoSuchElementException expected) { } @@ -173,8 +158,8 @@ public class EppResourceInputsTest { @Test public void testSuccess_keyReader_survivesAcrossSerialization() throws Exception { createTld("tld"); - DomainResource domainA = persistEppResourceInFirstBucket(newDomainResource("a.tld")); - DomainResource domainB = persistEppResourceInFirstBucket(newDomainResource("b.tld")); + DomainBase domainA = persistEppResourceInFirstBucket(newDomainBase("a.tld")); + DomainBase domainB = persistEppResourceInFirstBucket(newDomainBase("b.tld")); // Should be ignored. We'll know if it isn't because the progress counts will be off. persistActiveContact("contact"); Set> seen = new HashSet<>(); @@ -197,20 +182,20 @@ public class EppResourceInputsTest { @Test public void testSuccess_entityReader_survivesAcrossSerialization() throws Exception { createTld("tld"); - DomainResource domainA = persistEppResourceInFirstBucket(newDomainResource("a.tld")); - DomainResource domainB = persistEppResourceInFirstBucket(newDomainResource("b.tld")); + DomainBase domainA = persistEppResourceInFirstBucket(newDomainBase("a.tld")); + DomainBase domainB = persistEppResourceInFirstBucket(newDomainBase("b.tld")); // Should be ignored. We'll know if it isn't because the progress counts will be off. persistActiveContact("contact"); - Set seen = new HashSet<>(); - InputReader reader = - createEntityInput(DomainResource.class).createReaders().get(0); + Set seen = new HashSet<>(); + InputReader reader = + createEntityInput(DomainBase.class).createReaders().get(0); reader.beginShard(); reader.beginSlice(); assertThat(reader.getProgress()).isWithin(EPSILON).of(0); seen.add(reader.next()); assertThat(reader.getProgress()).isWithin(EPSILON).of(0.5); reader.endSlice(); - InputReader deserializedReader = serializeAndDeserialize(reader); + InputReader deserializedReader = serializeAndDeserialize(reader); deserializedReader.beginSlice(); assertThat(deserializedReader.getProgress()).isWithin(EPSILON).of(0.5); seen.add(deserializedReader.next()); @@ -224,13 +209,13 @@ public class EppResourceInputsTest { @Test public void testSuccess_entityReader_filtersOnMultipleTypes() throws Exception { createTld("tld"); - DomainResource domain = persistEppResourceInFirstBucket(newDomainResource("a.tld")); + DomainBase domain = persistEppResourceInFirstBucket(newDomainBase("a.tld")); HostResource host = persistEppResourceInFirstBucket(newHostResource("ns1.example.com")); persistEppResourceInFirstBucket(newContactResource("contact")); Set seen = new HashSet<>(); InputReader reader = EppResourceInputs.createEntityInput( - DomainResource.class, HostResource.class).createReaders().get(0); + DomainBase.class, HostResource.class).createReaders().get(0); reader.beginShard(); reader.beginSlice(); assertThat(reader.getProgress()).isWithin(EPSILON).of(0); @@ -247,8 +232,8 @@ public class EppResourceInputsTest { createTld("tld"); ContactResource contact = persistEppResourceInFirstBucket(newContactResource("contact")); // Specify the contact since persistActiveDomain{Application} creates a hidden one. - DomainResource domain1 = persistEppResourceInFirstBucket(newDomainResource("a.tld", contact)); - DomainResource domain2 = persistEppResourceInFirstBucket(newDomainResource("b.tld", contact)); + DomainBase domain1 = persistEppResourceInFirstBucket(newDomainBase("a.tld", contact)); + DomainBase domain2 = persistEppResourceInFirstBucket(newDomainBase("b.tld", contact)); HostResource host = persistEppResourceInFirstBucket(newHostResource("ns1.example.com")); Set seen = new HashSet<>(); InputReader reader = createEntityInput(EppResource.class).createReaders().get(0); diff --git a/javatests/google/registry/model/billing/BillingEventTest.java b/javatests/google/registry/model/billing/BillingEventTest.java index b2ff19426..d56eed22d 100644 --- a/javatests/google/registry/model/billing/BillingEventTest.java +++ b/javatests/google/registry/model/billing/BillingEventTest.java @@ -29,7 +29,7 @@ import com.googlecode.objectify.Key; import google.registry.model.EntityTestCase; import google.registry.model.billing.BillingEvent.Flag; import google.registry.model.billing.BillingEvent.Reason; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.GracePeriod; import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.reporting.HistoryEntry; @@ -44,7 +44,7 @@ public class BillingEventTest extends EntityTestCase { HistoryEntry historyEntry; HistoryEntry historyEntry2; - DomainResource domain; + DomainBase domain; BillingEvent.OneTime oneTime; BillingEvent.OneTime oneTimeSynthetic; BillingEvent.Recurring recurring; diff --git a/javatests/google/registry/model/common/CursorTest.java b/javatests/google/registry/model/common/CursorTest.java index 68a74a71b..2a87f8c7d 100644 --- a/javatests/google/registry/model/common/CursorTest.java +++ b/javatests/google/registry/model/common/CursorTest.java @@ -25,7 +25,7 @@ import static google.registry.testing.JUnitBackports.assertThrows; import static google.registry.util.DateTimeUtils.START_OF_TIME; import google.registry.model.EntityTestCase; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.registry.Registry; import org.joda.time.DateTime; import org.junit.Test; @@ -70,7 +70,7 @@ public class CursorTest extends EntityTestCase { createTld("tld"); clock.advanceOneMilli(); final DateTime time = DateTime.parse("2012-07-12T03:30:00.000Z"); - final DomainResource domain = persistActiveDomain("notaregistry.tld"); + final DomainBase domain = persistActiveDomain("notaregistry.tld"); IllegalArgumentException thrown = assertThrows( IllegalArgumentException.class, diff --git a/javatests/google/registry/model/domain/DomainResourceTest.java b/javatests/google/registry/model/domain/DomainBaseTest.java similarity index 90% rename from javatests/google/registry/model/domain/DomainResourceTest.java rename to javatests/google/registry/model/domain/DomainBaseTest.java index c24311320..8be180275 100644 --- a/javatests/google/registry/model/domain/DomainResourceTest.java +++ b/javatests/google/registry/model/domain/DomainBaseTest.java @@ -21,10 +21,10 @@ import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.EppResourceUtils.loadByForeignKey; import static google.registry.testing.DatastoreHelper.cloneAndSetAutoTimestamps; import static google.registry.testing.DatastoreHelper.createTld; -import static google.registry.testing.DatastoreHelper.newDomainResource; +import static google.registry.testing.DatastoreHelper.newDomainBase; import static google.registry.testing.DatastoreHelper.newHostResource; import static google.registry.testing.DatastoreHelper.persistResource; -import static google.registry.testing.DomainResourceSubject.assertAboutDomains; +import static google.registry.testing.DomainBaseSubject.assertAboutDomains; import static google.registry.testing.JUnitBackports.assertThrows; import static google.registry.util.DateTimeUtils.START_OF_TIME; import static org.joda.money.CurrencyUnit.USD; @@ -58,15 +58,15 @@ import org.joda.time.DateTime; import org.junit.Before; import org.junit.Test; -/** Unit tests for {@link DomainResource}. */ -public class DomainResourceTest extends EntityTestCase { +/** Unit tests for {@link DomainBase}. */ +public class DomainBaseTest extends EntityTestCase { - DomainResource domain; + DomainBase domain; @Before public void setUp() { createTld("com"); - Key domainKey = Key.create(null, DomainResource.class, "4-COM"); + Key domainKey = Key.create(null, DomainBase.class, "4-COM"); Key hostKey = Key.create(persistResource( new HostResource.Builder() .setFullyQualifiedHostName("ns1.example.com") @@ -97,7 +97,7 @@ public class DomainResourceTest extends EntityTestCase { domain = persistResource( cloneAndSetAutoTimestamps( - new DomainResource.Builder() + new DomainBase.Builder() .setFullyQualifiedDomainName("example.com") .setRepoId("4-COM") .setCreationClientId("a registrar") @@ -150,7 +150,7 @@ public class DomainResourceTest extends EntityTestCase { @Test public void testPersistence() { - assertThat(loadByForeignKey(DomainResource.class, domain.getForeignKey(), clock.nowUtc())) + assertThat(loadByForeignKey(DomainBase.class, domain.getForeignKey(), clock.nowUtc())) .hasValue(domain); } @@ -168,17 +168,17 @@ public class DomainResourceTest extends EntityTestCase { @Test public void testEmptyStringsBecomeNull() { - assertThat(newDomainResource("example.com").asBuilder() + assertThat(newDomainBase("example.com").asBuilder() .setPersistedCurrentSponsorClientId(null) .build() .getCurrentSponsorClientId()) .isNull(); - assertThat(newDomainResource("example.com").asBuilder() + assertThat(newDomainBase("example.com").asBuilder() .setPersistedCurrentSponsorClientId("") .build() .getCurrentSponsorClientId()) .isNull(); - assertThat(newDomainResource("example.com").asBuilder() + assertThat(newDomainBase("example.com").asBuilder() .setPersistedCurrentSponsorClientId(" ") .build() .getCurrentSponsorClientId()) @@ -188,33 +188,33 @@ public class DomainResourceTest extends EntityTestCase { @Test public void testEmptySetsAndArraysBecomeNull() { assertThat( - newDomainResource("example.com") + newDomainBase("example.com") .asBuilder() .setNameservers(ImmutableSet.of()) .build() .nsHosts) .isNull(); assertThat( - newDomainResource("example.com") + newDomainBase("example.com") .asBuilder() .setNameservers(ImmutableSet.of()) .build() .nsHosts) .isNull(); - assertThat(newDomainResource("example.com").asBuilder() + assertThat(newDomainBase("example.com").asBuilder() .setNameservers(ImmutableSet.of(Key.create(newHostResource("foo.example.tld")))) .build().nsHosts) .isNotNull(); // This behavior should also hold true for ImmutableObjects nested in collections. - assertThat(newDomainResource("example.com").asBuilder() + assertThat(newDomainBase("example.com").asBuilder() .setDsData(ImmutableSet.of(DelegationSignerData.create(1, 1, 1, null))) .build().getDsData().asList().get(0).getDigest()) .isNull(); - assertThat(newDomainResource("example.com").asBuilder() + assertThat(newDomainBase("example.com").asBuilder() .setDsData(ImmutableSet.of(DelegationSignerData.create(1, 1, 1, new byte[]{}))) .build().getDsData().asList().get(0).getDigest()) .isNull(); - assertThat(newDomainResource("example.com").asBuilder() + assertThat(newDomainBase("example.com").asBuilder() .setDsData(ImmutableSet.of(DelegationSignerData.create(1, 1, 1, new byte[]{1}))) .build().getDsData().asList().get(0).getDigest()) .isNotNull(); @@ -222,9 +222,9 @@ public class DomainResourceTest extends EntityTestCase { @Test public void testEmptyTransferDataBecomesNull() { - DomainResource withNull = - newDomainResource("example.com").asBuilder().setTransferData(null).build(); - DomainResource withEmpty = withNull.asBuilder().setTransferData(TransferData.EMPTY).build(); + DomainBase withNull = + newDomainBase("example.com").asBuilder().setTransferData(null).build(); + DomainBase withEmpty = withNull.asBuilder().setTransferData(TransferData.EMPTY).build(); assertThat(withNull).isEqualTo(withEmpty); assertThat(withEmpty.transferData).isNull(); } @@ -236,12 +236,12 @@ public class DomainResourceTest extends EntityTestCase { StatusValue[] statuses = {StatusValue.OK}; // OK is implicit if there's no other statuses but there are nameservers. assertAboutDomains() - .that(newDomainResource("example.com").asBuilder().setNameservers(nameservers).build()) + .that(newDomainBase("example.com").asBuilder().setNameservers(nameservers).build()) .hasExactlyStatusValues(statuses); StatusValue[] statuses1 = {StatusValue.CLIENT_HOLD}; // If there are other status values, OK should be suppressed. (Domains can't be LINKED.) assertAboutDomains() - .that(newDomainResource("example.com").asBuilder() + .that(newDomainBase("example.com").asBuilder() .setNameservers(nameservers) .setStatusValues(ImmutableSet.of(StatusValue.CLIENT_HOLD)) .build()) @@ -249,7 +249,7 @@ public class DomainResourceTest extends EntityTestCase { StatusValue[] statuses2 = {StatusValue.CLIENT_HOLD}; // When OK is suppressed, it should be removed even if it was originally there. assertAboutDomains() - .that(newDomainResource("example.com").asBuilder() + .that(newDomainBase("example.com").asBuilder() .setNameservers(nameservers) .setStatusValues(ImmutableSet.of(StatusValue.OK, StatusValue.CLIENT_HOLD)) .build()) @@ -257,19 +257,19 @@ public class DomainResourceTest extends EntityTestCase { StatusValue[] statuses3 = {StatusValue.INACTIVE}; // If there are no nameservers, INACTIVE should be added, which suppresses OK. assertAboutDomains() - .that(newDomainResource("example.com").asBuilder().build()) + .that(newDomainBase("example.com").asBuilder().build()) .hasExactlyStatusValues(statuses3); StatusValue[] statuses4 = {StatusValue.CLIENT_HOLD, StatusValue.INACTIVE}; // If there are no nameservers but there are status values, INACTIVE should still be added. assertAboutDomains() - .that(newDomainResource("example.com").asBuilder() + .that(newDomainBase("example.com").asBuilder() .setStatusValues(ImmutableSet.of(StatusValue.CLIENT_HOLD)) .build()) .hasExactlyStatusValues(statuses4); StatusValue[] statuses5 = {StatusValue.CLIENT_HOLD}; // If there are nameservers, INACTIVE should be removed even if it was originally there. assertAboutDomains() - .that(newDomainResource("example.com").asBuilder() + .that(newDomainBase("example.com").asBuilder() .setNameservers(nameservers) .setStatusValues(ImmutableSet.of(StatusValue.INACTIVE, StatusValue.CLIENT_HOLD)) .build()) @@ -277,7 +277,7 @@ public class DomainResourceTest extends EntityTestCase { } private void assertTransferred( - DomainResource domain, + DomainBase domain, DateTime newExpirationTime, Key newAutorenewEvent) { assertThat(domain.getTransferData().getTransferStatus()) @@ -323,7 +323,7 @@ public class DomainResourceTest extends EntityTestCase { GracePeriod.create( GracePeriodStatus.ADD, clock.nowUtc().plusDays(100), "foo", null)) .build(); - DomainResource afterTransfer = domain.cloneProjectedAtTime(clock.nowUtc().plusDays(1)); + DomainBase afterTransfer = domain.cloneProjectedAtTime(clock.nowUtc().plusDays(1)); DateTime newExpirationTime = oldExpirationTime.plusYears(1); Key serverApproveAutorenewEvent = domain.getTransferData().getServerApproveAutorenewEvent(); @@ -335,7 +335,7 @@ public class DomainResourceTest extends EntityTestCase { "winner", Key.create(transferBillingEvent))); // If we project after the grace period expires all should be the same except the grace period. - DomainResource afterGracePeriod = domain.cloneProjectedAtTime( + DomainBase afterGracePeriod = domain.cloneProjectedAtTime( clock.nowUtc().plusDays(2).plus(Registry.get("com").getTransferGracePeriodLength())); assertTransferred(afterGracePeriod, newExpirationTime, serverApproveAutorenewEvent); assertThat(afterGracePeriod.getGracePeriods()).isEmpty(); @@ -381,13 +381,13 @@ public class DomainResourceTest extends EntityTestCase { DateTime transferSuccessDateTime = now.plusDays(5); setupPendingTransferDomain(autorenewDateTime, transferRequestDateTime, transferSuccessDateTime); - DomainResource beforeAutoRenew = domain.cloneProjectedAtTime(autorenewDateTime.minusDays(1)); + DomainBase beforeAutoRenew = domain.cloneProjectedAtTime(autorenewDateTime.minusDays(1)); assertThat(beforeAutoRenew.getLastEppUpdateTime()).isEqualTo(transferRequestDateTime); assertThat(beforeAutoRenew.getLastEppUpdateClientId()).isEqualTo("gaining"); // If autorenew happens before transfer succeeds(before transfer grace period starts as well), // lastEppUpdateClientId should still be the current sponsor client id - DomainResource afterAutoRenew = domain.cloneProjectedAtTime(autorenewDateTime.plusDays(1)); + DomainBase afterAutoRenew = domain.cloneProjectedAtTime(autorenewDateTime.plusDays(1)); assertThat(afterAutoRenew.getLastEppUpdateTime()).isEqualTo(autorenewDateTime); assertThat(afterAutoRenew.getLastEppUpdateClientId()).isEqualTo("losing"); } @@ -400,11 +400,11 @@ public class DomainResourceTest extends EntityTestCase { DateTime transferSuccessDateTime = now.plusDays(5); setupPendingTransferDomain(autorenewDateTime, transferRequestDateTime, transferSuccessDateTime); - DomainResource beforeAutoRenew = domain.cloneProjectedAtTime(autorenewDateTime.minusDays(1)); + DomainBase beforeAutoRenew = domain.cloneProjectedAtTime(autorenewDateTime.minusDays(1)); assertThat(beforeAutoRenew.getLastEppUpdateTime()).isEqualTo(transferRequestDateTime); assertThat(beforeAutoRenew.getLastEppUpdateClientId()).isEqualTo("gaining"); - DomainResource afterTransferSuccess = + DomainBase afterTransferSuccess = domain.cloneProjectedAtTime(transferSuccessDateTime.plusDays(1)); assertThat(afterTransferSuccess.getLastEppUpdateTime()).isEqualTo(transferSuccessDateTime); assertThat(afterTransferSuccess.getLastEppUpdateClientId()).isEqualTo("gaining"); @@ -428,11 +428,11 @@ public class DomainResourceTest extends EntityTestCase { DateTime autorenewDateTime = now.plusDays(3); setupUnmodifiedDomain(autorenewDateTime); - DomainResource beforeAutoRenew = domain.cloneProjectedAtTime(autorenewDateTime.minusDays(1)); + DomainBase beforeAutoRenew = domain.cloneProjectedAtTime(autorenewDateTime.minusDays(1)); assertThat(beforeAutoRenew.getLastEppUpdateTime()).isEqualTo(null); assertThat(beforeAutoRenew.getLastEppUpdateClientId()).isEqualTo(null); - DomainResource afterAutoRenew = domain.cloneProjectedAtTime(autorenewDateTime.plusDays(1)); + DomainBase afterAutoRenew = domain.cloneProjectedAtTime(autorenewDateTime.plusDays(1)); assertThat(afterAutoRenew.getLastEppUpdateTime()).isEqualTo(autorenewDateTime); assertThat(afterAutoRenew.getLastEppUpdateClientId()).isEqualTo("losing"); } @@ -472,7 +472,7 @@ public class DomainResourceTest extends EntityTestCase { @Test public void testRenewalsHappenAtExpiration() { - DomainResource renewed = + DomainBase renewed = domain.cloneProjectedAtTime(domain.getRegistrationExpirationTime()); assertThat(renewed.getRegistrationExpirationTime()) .isEqualTo(domain.getRegistrationExpirationTime().plusYears(1)); @@ -484,7 +484,7 @@ public class DomainResourceTest extends EntityTestCase { @Test public void testTldGetsSet() { createTld("tld"); - domain = newDomainResource("foo.tld"); + domain = newDomainBase("foo.tld"); assertThat(domain.getTld()).isEqualTo("tld"); } @@ -493,7 +493,7 @@ public class DomainResourceTest extends EntityTestCase { domain = domain.asBuilder() .setRegistrationExpirationTime(DateTime.parse("2004-02-29T22:00:00.0Z")) .build(); - DomainResource renewed = + DomainBase renewed = domain.cloneProjectedAtTime(domain.getRegistrationExpirationTime().plusYears(4)); assertThat(renewed.getRegistrationExpirationTime().getDayOfMonth()).isEqualTo(28); } @@ -517,7 +517,7 @@ public class DomainResourceTest extends EntityTestCase { .put(oldExpirationTime.plusYears(2).plusMillis(1), Money.of(USD, 5)) .build()) .build()); - DomainResource renewedThreeTimes = + DomainBase renewedThreeTimes = domain.cloneProjectedAtTime(oldExpirationTime.plusYears(2)); assertThat(renewedThreeTimes.getRegistrationExpirationTime()) .isEqualTo(oldExpirationTime.plusYears(3)); diff --git a/javatests/google/registry/model/eppinput/EppInputTest.java b/javatests/google/registry/model/eppinput/EppInputTest.java index 4c9e0071a..b636cf9ee 100644 --- a/javatests/google/registry/model/eppinput/EppInputTest.java +++ b/javatests/google/registry/model/eppinput/EppInputTest.java @@ -21,7 +21,7 @@ import static google.registry.testing.JUnitBackports.assertThrows; import static google.registry.testing.TestDataHelper.loadBytes; import google.registry.model.contact.ContactResourceTest; -import google.registry.model.domain.DomainResourceTest; +import google.registry.model.domain.DomainBaseTest; import google.registry.model.eppinput.EppInput.InnerCommand; import google.registry.model.eppinput.EppInput.Login; import google.registry.xml.XmlException; @@ -47,7 +47,7 @@ public class EppInputTest { @Test public void testUnmarshalling_domainCheck() throws Exception { EppInput input = - unmarshal(EppInput.class, loadBytes(DomainResourceTest.class, "domain_check.xml").read()); + unmarshal(EppInput.class, loadBytes(DomainBaseTest.class, "domain_check.xml").read()); assertThat(input.getCommandWrapper().getClTrid()).hasValue("ABC-12345"); assertThat(input.getCommandType()).isEqualTo("check"); assertThat(input.getResourceType()).hasValue("domain"); diff --git a/javatests/google/registry/model/host/HostResourceTest.java b/javatests/google/registry/model/host/HostResourceTest.java index 01ade68f4..3fb67033b 100644 --- a/javatests/google/registry/model/host/HostResourceTest.java +++ b/javatests/google/registry/model/host/HostResourceTest.java @@ -19,7 +19,7 @@ import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.EppResourceUtils.loadByForeignKey; import static google.registry.testing.DatastoreHelper.cloneAndSetAutoTimestamps; import static google.registry.testing.DatastoreHelper.createTld; -import static google.registry.testing.DatastoreHelper.newDomainResource; +import static google.registry.testing.DatastoreHelper.newDomainBase; import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.HostResourceSubject.assertAboutHosts; import static google.registry.testing.JUnitBackports.assertThrows; @@ -29,7 +29,7 @@ import com.google.common.net.InetAddresses; import com.googlecode.objectify.Key; import google.registry.model.EntityTestCase; import google.registry.model.billing.BillingEvent; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.Trid; import google.registry.model.transfer.TransferData; @@ -45,7 +45,7 @@ public class HostResourceTest extends EntityTestCase { final DateTime day2 = day3.minusDays(1); final DateTime day1 = day2.minusDays(1); - DomainResource domain; + DomainBase domain; HostResource host; @Before @@ -54,7 +54,7 @@ public class HostResourceTest extends EntityTestCase { // Set up a new persisted registrar entity. domain = persistResource( - newDomainResource("example.com") + newDomainBase("example.com") .asBuilder() .setRepoId("1-COM") .setTransferData( diff --git a/javatests/google/registry/model/ofy/OfyTest.java b/javatests/google/registry/model/ofy/OfyTest.java index ced4d285d..7cb2d4b97 100644 --- a/javatests/google/registry/model/ofy/OfyTest.java +++ b/javatests/google/registry/model/ofy/OfyTest.java @@ -44,7 +44,6 @@ import com.googlecode.objectify.annotation.Parent; import google.registry.model.ImmutableObject; import google.registry.model.contact.ContactResource; import google.registry.model.domain.DomainBase; -import google.registry.model.domain.DomainResource; import google.registry.model.eppcommon.Trid; import google.registry.model.reporting.HistoryEntry; import google.registry.testing.AppEngineRule; @@ -362,7 +361,7 @@ public class OfyTest { @Test public void test_getBaseEntityClassFromEntityOrKey_subclassEntity() { - DomainResource domain = DatastoreHelper.newDomainResource("test.tld"); + DomainBase domain = DatastoreHelper.newDomainBase("test.tld"); assertThat(getBaseEntityClassFromEntityOrKey(domain)).isEqualTo(DomainBase.class); assertThat(getBaseEntityClassFromEntityOrKey(Key.create(domain))) .isEqualTo(DomainBase.class); diff --git a/javatests/google/registry/model/reporting/HistoryEntryTest.java b/javatests/google/registry/model/reporting/HistoryEntryTest.java index 5b04f3dbf..6313bc5f4 100644 --- a/javatests/google/registry/model/reporting/HistoryEntryTest.java +++ b/javatests/google/registry/model/reporting/HistoryEntryTest.java @@ -17,7 +17,7 @@ package google.registry.model.reporting; import static com.google.common.truth.Truth.assertThat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; -import static google.registry.testing.DatastoreHelper.newDomainResource; +import static google.registry.testing.DatastoreHelper.newDomainBase; import static google.registry.testing.DatastoreHelper.persistResource; import static java.nio.charset.StandardCharsets.UTF_8; @@ -47,7 +47,7 @@ public class HistoryEntryTest extends EntityTestCase { // Set up a new persisted HistoryEntry entity. historyEntry = new HistoryEntry.Builder() - .setParent(newDomainResource("foo.foobar")) + .setParent(newDomainBase("foo.foobar")) .setType(HistoryEntry.Type.DOMAIN_CREATE) .setPeriod(Period.create(1, Period.Unit.YEARS)) .setXmlBytes("".getBytes(UTF_8)) diff --git a/javatests/google/registry/model/testdata/schema.txt b/javatests/google/registry/model/testdata/schema.txt index 49685b089..fb6342cf4 100644 --- a/javatests/google/registry/model/testdata/schema.txt +++ b/javatests/google/registry/model/testdata/schema.txt @@ -161,26 +161,6 @@ class google.registry.model.domain.DomainAuthInfo { google.registry.model.eppcommon.AuthInfo$PasswordAuth pw; } class google.registry.model.domain.DomainBase { - @Id java.lang.String repoId; - com.google.common.collect.ImmutableSortedMap> revisions; - google.registry.model.CreateAutoTimestamp creationTime; - google.registry.model.UpdateAutoTimestamp updateTimestamp; - google.registry.model.domain.DomainAuthInfo authInfo; - google.registry.model.domain.launch.LaunchNotice launchNotice; - java.lang.String creationClientId; - java.lang.String currentSponsorClientId; - java.lang.String fullyQualifiedDomainName; - java.lang.String idnTableName; - java.lang.String lastEppUpdateClientId; - java.lang.String tld; - java.util.Set> nsHosts; - java.util.Set allContacts; - java.util.Set dsData; - java.util.Set status; - org.joda.time.DateTime deletionTime; - org.joda.time.DateTime lastEppUpdateTime; -} -class google.registry.model.domain.DomainResource { @Id java.lang.String repoId; com.google.common.collect.ImmutableSortedMap> revisions; com.googlecode.objectify.Key autorenewBillingEvent; @@ -288,7 +268,7 @@ class google.registry.model.eppcommon.Trid { class google.registry.model.host.HostResource { @Id java.lang.String repoId; com.google.common.collect.ImmutableSortedMap> revisions; - com.googlecode.objectify.Key superordinateDomain; + com.googlecode.objectify.Key superordinateDomain; google.registry.model.CreateAutoTimestamp creationTime; google.registry.model.UpdateAutoTimestamp updateTimestamp; java.lang.String creationClientId; diff --git a/javatests/google/registry/rdap/RdapDomainActionTest.java b/javatests/google/registry/rdap/RdapDomainActionTest.java index 65acf8ffe..99d43c55a 100644 --- a/javatests/google/registry/rdap/RdapDomainActionTest.java +++ b/javatests/google/registry/rdap/RdapDomainActionTest.java @@ -20,7 +20,7 @@ import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.DatastoreHelper.persistSimpleResources; import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistContactResource; import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistHostResource; -import static google.registry.testing.FullFieldsTestEntityHelper.makeDomainResource; +import static google.registry.testing.FullFieldsTestEntityHelper.makeDomainBase; import static google.registry.testing.FullFieldsTestEntityHelper.makeHistoryEntry; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarContacts; @@ -95,13 +95,13 @@ public class RdapDomainActionTest extends RdapActionBaseTestCase", Registrar.State.ACTIVE)); persistSimpleResources(makeRegistrarContacts(registrar)); domainCatLol = persistResource( - makeDomainResource( + makeDomainBase( "cat.lol", contact1 = makeAndPersistContactResource( "5372808-ERL", @@ -192,7 +192,7 @@ public class RdapDomainSearchActionTest extends RdapSearchActionTestCase> hostKeys = hostKeysBuilder.build(); // Create all the domains at once, then persist them in parallel, for increased efficiency. - ImmutableList.Builder domainsBuilder = new ImmutableList.Builder<>(); + ImmutableList.Builder domainsBuilder = new ImmutableList.Builder<>(); for (int i = numActiveDomains * numTotalDomainsPerActiveDomain; i >= 1; i--) { String domainName = String.format("domain%d.lol", i); - DomainResource.Builder builder = - makeDomainResource( + DomainBase.Builder builder = + makeDomainBase( domainName, contact1, contact2, contact3, null, null, registrar) .asBuilder() .setNameservers(hostKeys) diff --git a/javatests/google/registry/rdap/RdapEntityActionTest.java b/javatests/google/registry/rdap/RdapEntityActionTest.java index 44835b21b..3089c851e 100644 --- a/javatests/google/registry/rdap/RdapEntityActionTest.java +++ b/javatests/google/registry/rdap/RdapEntityActionTest.java @@ -20,7 +20,7 @@ import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.DatastoreHelper.persistSimpleResources; import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistContactResource; import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistDeletedContactResource; -import static google.registry.testing.FullFieldsTestEntityHelper.makeDomainResource; +import static google.registry.testing.FullFieldsTestEntityHelper.makeDomainBase; import static google.registry.testing.FullFieldsTestEntityHelper.makeHostResource; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarContacts; @@ -94,7 +94,7 @@ public class RdapEntityActionTest extends RdapActionBaseTestCaseThis tests the mapping between {@link DomainResource} and {@link XjcRdeDomain} as well as + *

This tests the mapping between {@link DomainBase} and {@link XjcRdeDomain} as well as * some exceptional conditions. */ @RunWith(JUnit4.class) -public class DomainResourceToXjcConverterTest { +public class DomainBaseToXjcConverterTest { @Rule public final AppEngineRule appEngine = AppEngineRule.builder() @@ -101,7 +101,7 @@ public class DomainResourceToXjcConverterTest { @Test public void testConvertThick() { XjcRdeDomain bean = - DomainResourceToXjcConverter.convertDomain(makeDomainResource(clock), RdeMode.FULL); + DomainBaseToXjcConverter.convertDomain(makeDomainBase(clock), RdeMode.FULL); assertThat(bean.getClID()).isEqualTo("GetTheeBack"); @@ -184,7 +184,7 @@ public class DomainResourceToXjcConverterTest { @Test public void testConvertThin() { XjcRdeDomain bean = - DomainResourceToXjcConverter.convertDomain(makeDomainResource(clock), RdeMode.THIN); + DomainBaseToXjcConverter.convertDomain(makeDomainBase(clock), RdeMode.THIN); assertThat(bean.getRegistrant()).isNull(); assertThat(bean.getContacts()).isEmpty(); assertThat(bean.getSecDNS()).isNull(); @@ -193,14 +193,14 @@ public class DomainResourceToXjcConverterTest { @Test public void testMarshalThick() throws Exception { XjcRdeDomain bean = - DomainResourceToXjcConverter.convertDomain(makeDomainResource(clock), RdeMode.FULL); + DomainBaseToXjcConverter.convertDomain(makeDomainBase(clock), RdeMode.FULL); wrapDeposit(bean).marshal(new ByteArrayOutputStream(), UTF_8); } @Test public void testMarshalThin() throws Exception { XjcRdeDomain bean = - DomainResourceToXjcConverter.convertDomain(makeDomainResource(clock), RdeMode.THIN); + DomainBaseToXjcConverter.convertDomain(makeDomainBase(clock), RdeMode.THIN); wrapDeposit(bean).marshal(new ByteArrayOutputStream(), UTF_8); } @@ -221,9 +221,9 @@ public class DomainResourceToXjcConverterTest { return deposit; } - static DomainResource makeDomainResource(FakeClock clock) { - DomainResource domain = - newDomainResource("example.xn--q9jyb4c").asBuilder().setRepoId("2-Q9JYB4C").build(); + static DomainBase makeDomainBase(FakeClock clock) { + DomainBase domain = + newDomainBase("example.xn--q9jyb4c").asBuilder().setRepoId("2-Q9JYB4C").build(); HistoryEntry historyEntry = persistResource(new HistoryEntry.Builder().setParent(domain).build()); BillingEvent.OneTime billingEvent = persistResource( diff --git a/javatests/google/registry/rde/HostResourceToXjcConverterTest.java b/javatests/google/registry/rde/HostResourceToXjcConverterTest.java index f45d23b0c..f1d1ed51e 100644 --- a/javatests/google/registry/rde/HostResourceToXjcConverterTest.java +++ b/javatests/google/registry/rde/HostResourceToXjcConverterTest.java @@ -16,7 +16,7 @@ package google.registry.rde; import static com.google.common.truth.Truth.assertThat; import static google.registry.testing.DatastoreHelper.createTld; -import static google.registry.testing.DatastoreHelper.newDomainResource; +import static google.registry.testing.DatastoreHelper.newDomainBase; import static google.registry.testing.JUnitBackports.assertThrows; import static google.registry.xjc.XjcXmlTransformer.marshalStrict; import static java.nio.charset.StandardCharsets.UTF_8; @@ -24,7 +24,7 @@ import static java.nio.charset.StandardCharsets.UTF_8; import com.google.common.collect.ImmutableSet; import com.google.common.net.InetAddresses; import com.googlecode.objectify.Key; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.eppcommon.StatusValue; import google.registry.model.host.HostResource; import google.registry.testing.AppEngineRule; @@ -61,7 +61,7 @@ public class HostResourceToXjcConverterTest { @Test public void testConvertSubordinateHost() { - DomainResource domain = newDomainResource("love.foobar").asBuilder() + DomainBase domain = newDomainBase("love.foobar").asBuilder() .setPersistedCurrentSponsorClientId("LeisureDog") .setLastTransferTime(DateTime.parse("2010-01-01T00:00:00Z")) .addStatusValue(StatusValue.PENDING_TRANSFER) diff --git a/javatests/google/registry/rde/RdeFixtures.java b/javatests/google/registry/rde/RdeFixtures.java index 3eb79d95a..486d88b65 100644 --- a/javatests/google/registry/rde/RdeFixtures.java +++ b/javatests/google/registry/rde/RdeFixtures.java @@ -36,7 +36,7 @@ import google.registry.model.contact.ContactResource; import google.registry.model.contact.PostalInfo; import google.registry.model.domain.DesignatedContact; import google.registry.model.domain.DomainAuthInfo; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.GracePeriod; import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.domain.secdns.DelegationSignerData; @@ -57,8 +57,8 @@ import org.joda.time.DateTime; /** Utility class for creating {@code EppResource} entities that'll successfully marshal. */ final class RdeFixtures { - static DomainResource makeDomainResource(FakeClock clock, String tld) { - DomainResource domain = new DomainResource.Builder() + static DomainBase makeDomainBase(FakeClock clock, String tld) { + DomainBase domain = new DomainBase.Builder() .setFullyQualifiedDomainName("example." + tld) .setRepoId(generateNewDomainRoid(tld)) .setRegistrant(Key.create( diff --git a/javatests/google/registry/rde/RdeStagingActionTest.java b/javatests/google/registry/rde/RdeStagingActionTest.java index 4e045ff00..e7cb3d8e5 100644 --- a/javatests/google/registry/rde/RdeStagingActionTest.java +++ b/javatests/google/registry/rde/RdeStagingActionTest.java @@ -20,7 +20,7 @@ import static google.registry.model.common.Cursor.CursorType.BRDA; import static google.registry.model.common.Cursor.CursorType.RDE_STAGING; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.rde.RdeFixtures.makeContactResource; -import static google.registry.rde.RdeFixtures.makeDomainResource; +import static google.registry.rde.RdeFixtures.makeDomainBase; import static google.registry.rde.RdeFixtures.makeHostResource; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.persistResource; @@ -322,7 +322,7 @@ public class RdeStagingActionTest extends MapreduceTestCase { public void testMapReduce_bunchOfResources_headerHasCorrectCounts() throws Exception { clock.setTo(DateTime.parse("1999-12-31TZ")); createTldWithEscrowEnabled("lol"); - makeDomainResource(clock, "lol"); + makeDomainBase(clock, "lol"); clock.setTo(DateTime.parse("2000-01-01TZ")); action.run(); @@ -417,7 +417,7 @@ public class RdeStagingActionTest extends MapreduceTestCase { public void testMapReduce_sameDayRdeDeposit_advancesCursorToTomorrow() throws Exception { clock.setTo(DateTime.parse("1999-12-31TZ")); createTldWithEscrowEnabled("lol"); - makeDomainResource(clock, "lol"); + makeDomainBase(clock, "lol"); setCursor(Registry.get("lol"), RDE_STAGING, DateTime.parse("2000-01-01TZ")); setCursor(Registry.get("lol"), BRDA, DateTime.parse("2000-01-04TZ")); clock.setTo(DateTime.parse("2000-01-01TZ")); // Saturday @@ -438,7 +438,7 @@ public class RdeStagingActionTest extends MapreduceTestCase { public void testMapReduce_onBrdaDay_advancesBothCursors() throws Exception { clock.setTo(DateTime.parse("1999-12-31TZ")); createTldWithEscrowEnabled("lol"); - makeDomainResource(clock, "lol"); + makeDomainBase(clock, "lol"); setCursor(Registry.get("lol"), RDE_STAGING, DateTime.parse("2000-01-04TZ")); setCursor(Registry.get("lol"), BRDA, DateTime.parse("2000-01-04TZ")); clock.setTo(DateTime.parse("2000-01-04TZ")); // Tuesday @@ -459,7 +459,7 @@ public class RdeStagingActionTest extends MapreduceTestCase { public void testMapReduce_onBrdaDay_enqueuesBothTasks() throws Exception { clock.setTo(DateTime.parse("1999-12-31TZ")); createTldWithEscrowEnabled("lol"); - makeDomainResource(clock, "lol"); + makeDomainBase(clock, "lol"); setCursor(Registry.get("lol"), RDE_STAGING, DateTime.parse("2000-01-04TZ")); setCursor(Registry.get("lol"), BRDA, DateTime.parse("2000-01-04TZ")); clock.setTo(DateTime.parse("2000-01-04TZ")); // Tuesday @@ -515,7 +515,7 @@ public class RdeStagingActionTest extends MapreduceTestCase { public void testMapReduce_idnTables_goInDeposit() throws Exception { clock.setTo(DateTime.parse("1999-12-31TZ")); createTldWithEscrowEnabled("fop"); - makeDomainResource(clock, "fop"); + makeDomainBase(clock, "fop"); clock.setTo(DateTime.parse("2000-01-01TZ")); action.run(); @@ -541,7 +541,7 @@ public class RdeStagingActionTest extends MapreduceTestCase { public void testMapReduce_withDomain_producesExpectedXml() throws Exception { clock.setTo(DateTime.parse("1999-12-31TZ")); createTldWithEscrowEnabled("lol"); - makeDomainResource(clock, "lol"); + makeDomainBase(clock, "lol"); clock.setTo(DateTime.parse("2000-01-01TZ")); action.run(); @@ -558,7 +558,7 @@ public class RdeStagingActionTest extends MapreduceTestCase { public void testMapReduce_withDomain_producesCorrectLengthFile() throws Exception { clock.setTo(DateTime.parse("1999-12-31TZ")); createTldWithEscrowEnabled("lol"); - makeDomainResource(clock, "lol"); + makeDomainBase(clock, "lol"); clock.setTo(DateTime.parse("2000-01-01TZ")); action.run(); @@ -573,7 +573,7 @@ public class RdeStagingActionTest extends MapreduceTestCase { public void testMapReduce_withDomain_producesReportXml() throws Exception { clock.setTo(DateTime.parse("1999-12-31TZ")); createTldWithEscrowEnabled("lol"); - makeDomainResource(clock, "lol"); + makeDomainBase(clock, "lol"); clock.setTo(DateTime.parse("2000-01-01TZ")); action.run(); @@ -590,9 +590,9 @@ public class RdeStagingActionTest extends MapreduceTestCase { public void testMapReduce_twoDomainsDifferentTlds_isolatesDomains() throws Exception { clock.setTo(DateTime.parse("1999-12-31TZ")); createTldWithEscrowEnabled("boggle"); - makeDomainResource(clock, "boggle"); + makeDomainBase(clock, "boggle"); createTldWithEscrowEnabled("lol"); - makeDomainResource(clock, "lol"); + makeDomainBase(clock, "lol"); clock.setTo(DateTime.parse("2000-01-01TZ")); action.run(); @@ -746,7 +746,7 @@ public class RdeStagingActionTest extends MapreduceTestCase { clock.setTo(DateTime.parse("1999-12-31TZ")); for (String tld : tlds) { createTldWithEscrowEnabled(tld); - makeDomainResource(clock, tld); + makeDomainBase(clock, tld); setCursor(Registry.get(tld), RDE_STAGING, DateTime.parse("1999-01-01TZ")); setCursor(Registry.get(tld), BRDA, DateTime.parse("2001-01-01TZ")); } diff --git a/javatests/google/registry/rde/RdeTestSuite.java b/javatests/google/registry/rde/RdeTestSuite.java index 94bfd762d..f2f386cde 100644 --- a/javatests/google/registry/rde/RdeTestSuite.java +++ b/javatests/google/registry/rde/RdeTestSuite.java @@ -21,7 +21,7 @@ import org.junit.runners.Suite.SuiteClasses; /** Convenience class to run all RDE tests inside IDE with one keystroke. */ @RunWith(Suite.class) @SuiteClasses({ - DomainResourceToXjcConverterTest.class, + DomainBaseToXjcConverterTest.class, GhostrydeGpgIntegrationTest.class, GhostrydeTest.class, HostResourceToXjcConverterTest.class, diff --git a/javatests/google/registry/rde/imports/RdeDomainImportActionTest.java b/javatests/google/registry/rde/imports/RdeDomainImportActionTest.java index acdfa80e8..4ad9d8a56 100644 --- a/javatests/google/registry/rde/imports/RdeDomainImportActionTest.java +++ b/javatests/google/registry/rde/imports/RdeDomainImportActionTest.java @@ -19,7 +19,7 @@ import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.getHistoryEntries; import static google.registry.testing.DatastoreHelper.getPollMessages; -import static google.registry.testing.DatastoreHelper.newDomainResource; +import static google.registry.testing.DatastoreHelper.newDomainBase; import static google.registry.testing.DatastoreHelper.persistActiveContact; import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.DatastoreHelper.persistSimpleResource; @@ -40,7 +40,7 @@ import google.registry.config.RegistryConfig.ConfigModule; import google.registry.gcs.GcsUtils; import google.registry.mapreduce.MapreduceRunner; import google.registry.model.billing.BillingEvent; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.eppcommon.Trid; import google.registry.model.poll.PollMessage; @@ -108,7 +108,7 @@ public class RdeDomainImportActionTest extends MapreduceTestCase domains = ofy().load().type(DomainResource.class).list(); + List domains = ofy().load().type(DomainBase.class).list(); assertThat(domains).hasSize(1); checkDomain(domains.get(0)); } @@ -117,8 +117,8 @@ public class RdeDomainImportActionTest extends MapreduceTestCase domains = ofy().load().type(DomainResource.class).list(); - DomainResource domain = domains.get(0); + List domains = ofy().load().type(DomainBase.class).list(); + DomainBase domain = domains.get(0); // verify history entry List historyEntries = getHistoryEntries(domain); assertThat(historyEntries).hasSize(1); @@ -130,9 +130,9 @@ public class RdeDomainImportActionTest extends MapreduceTestCase domains = ofy().load().type(DomainResource.class).list(); + List domains = ofy().load().type(DomainBase.class).list(); assertThat(domains.size()).isEqualTo(1); - DomainResource domain = domains.get(0); + DomainBase domain = domains.get(0); // verify history entry List historyEntries = getHistoryEntries(domain); assertThat(historyEntries).hasSize(1); @@ -165,13 +165,13 @@ public class RdeDomainImportActionTest extends MapreduceTestCase domains = ofy().load().type(DomainResource.class).list(); + List domains = ofy().load().type(DomainBase.class).list(); assertThat(domains).hasSize(1); checkDomain(domains.get(0)); // implicit server approval happens at 2015-01-08T22:00:00.0Z DateTime serverApprovalTime = DateTime.parse("2015-01-08T22:00:00.0Z"); // Domain should be assigned to RegistrarX before server approval - DomainResource beforeApproval = + DomainBase beforeApproval = domains.get(0).cloneProjectedAtTime(serverApprovalTime.minus(Seconds.ONE)); assertThat(beforeApproval.getCurrentSponsorClientId()).isEqualTo("RegistrarX"); assertThat(loadAutorenewBillingEventForDomain(beforeApproval).getClientId()) @@ -199,7 +199,7 @@ public class RdeDomainImportActionTest extends MapreduceTestCase domains = ofy().load().type(DomainResource.class).list(); + List domains = ofy().load().type(DomainBase.class).list(); assertThat(domains).hasSize(1); checkDomain(domains.get(0)); // Domain should be assigned to RegistrarX before server approval - DomainResource beforeApproval = + DomainBase beforeApproval = domains.get(0).cloneProjectedAtTime(serverApprovalTime.minus(Seconds.ONE)); assertThat(beforeApproval.getCurrentSponsorClientId()).isEqualTo("RegistrarX"); assertThat(loadAutorenewBillingEventForDomain(beforeApproval).getClientId()) @@ -244,7 +244,7 @@ public class RdeDomainImportActionTest extends MapreduceTestCase domains = ofy().load().type(DomainResource.class).list(); + List domains = ofy().load().type(DomainBase.class).list(); assertThat(domains).hasSize(1); checkDomain(domains.get(0)); checkTransferRequestPollMessage( @@ -289,7 +289,7 @@ public class RdeDomainImportActionTest extends MapreduceTestCase .asBuilder() .setRepoId("Hns1_example1_test-TEST") .build()); - DomainResource superordinateDomain = persistActiveDomain("example1.test"); - Key superOrdinateDomainKey = Key.create(superordinateDomain); + DomainBase superordinateDomain = persistActiveDomain("example1.test"); + Key superOrdinateDomainKey = Key.create(superordinateDomain); pushToGcs(DEPOSIT_1_HOST); // set transaction time to slightly after resource save clock.advanceOneMilli(); @@ -111,7 +111,7 @@ public class RdeHostLinkActionTest extends MapreduceTestCase assertThat(hosts.get(0).getLastSuperordinateChange()) .isEqualTo(DateTime.parse("2016-05-07T14:55:38.001Z")); // verify that domain is linked to host - List domains = ofy().load().type(DomainResource.class).list(); + List domains = ofy().load().type(DomainBase.class).list(); assertThat(domains).hasSize(1); assertThat(domains.get(0).getSubordinateHosts()).containsExactly("ns1.example1.test"); } @@ -126,7 +126,7 @@ public class RdeHostLinkActionTest extends MapreduceTestCase .asBuilder() .setRepoId("wrong-repoid") .build()); - DomainResource superordinateDomain = persistActiveDomain("example1.test"); + DomainBase superordinateDomain = persistActiveDomain("example1.test"); ForeignKeyDomainIndex.create(superordinateDomain, END_OF_TIME); pushToGcs(DEPOSIT_1_HOST); // set transaction time to slightly after resource save @@ -146,7 +146,7 @@ public class RdeHostLinkActionTest extends MapreduceTestCase .setRepoId("Hns1_example1_test-TEST") .build()); persistResource( - newDomainResource("example1.test") + newDomainBase("example1.test") .asBuilder() .setStatusValues(ImmutableSet.of(PENDING_DELETE)) .build()); diff --git a/javatests/google/registry/rde/imports/RdeImportUtilsTest.java b/javatests/google/registry/rde/imports/RdeImportUtilsTest.java index 063164b06..fef256106 100644 --- a/javatests/google/registry/rde/imports/RdeImportUtilsTest.java +++ b/javatests/google/registry/rde/imports/RdeImportUtilsTest.java @@ -41,7 +41,7 @@ import google.registry.model.EppResource.ForeignKeyedEppResource; import google.registry.model.contact.ContactResource; import google.registry.model.domain.DesignatedContact; import google.registry.model.domain.DesignatedContact.Type; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.eppcommon.StatusValue; import google.registry.model.host.HostResource; import google.registry.model.index.EppResourceIndex; @@ -174,10 +174,10 @@ public class RdeImportUtilsTest extends ShardableTestCase { @Test public void testImportNewDomain() { - final DomainResource newDomain = buildNewDomain(); + final DomainBase newDomain = buildNewDomain(); importResourceInTransaction(newDomain); - DomainResource saved = getDomain("Dexample1-TEST"); + DomainBase saved = getDomain("Dexample1-TEST"); assertThat(saved.getFullyQualifiedDomainName()) .isEqualTo(newDomain.getFullyQualifiedDomainName()); assertThat(saved.getStatusValues()).isEqualTo(newDomain.getStatusValues()); @@ -192,15 +192,15 @@ public class RdeImportUtilsTest extends ShardableTestCase { @Test public void testImportExistingDomain() { - DomainResource newDomain = buildNewDomain(); + DomainBase newDomain = buildNewDomain(); persistResource(newDomain); - final DomainResource updatedDomain = + final DomainBase updatedDomain = newDomain .asBuilder() .setFullyQualifiedDomainName("1" + newDomain.getFullyQualifiedDomainName()) .build(); assertThrows(ResourceExistsException.class, () -> importResourceInTransaction(updatedDomain)); - DomainResource saved = getDomain("Dexample1-TEST"); + DomainBase saved = getDomain("Dexample1-TEST"); assertThat(saved.getFullyQualifiedDomainName()) .isEqualTo(newDomain.getFullyQualifiedDomainName()); assertThat(saved.getStatusValues()).isEqualTo(newDomain.getStatusValues()); @@ -235,10 +235,10 @@ public class RdeImportUtilsTest extends ShardableTestCase { .build(); } - private DomainResource buildNewDomain() { + private DomainBase buildNewDomain() { ContactResource registrant = persistActiveContact("jd1234"); ContactResource admin = persistActiveContact("sh8013"); - return new DomainResource.Builder() + return new DomainBase.Builder() .setFullyQualifiedDomainName("example1.example") .setRepoId("Dexample1-TEST") .setStatusValues(ImmutableSet.of(StatusValue.OK)) @@ -317,8 +317,8 @@ public class RdeImportUtilsTest extends ShardableTestCase { } /** Gets the domain with the specified ROID */ - private static DomainResource getDomain(String repoId) { - final Key key = Key.create(DomainResource.class, repoId); + private static DomainBase getDomain(String repoId) { + final Key key = Key.create(DomainBase.class, repoId); return ofy().transact(() -> ofy().load().key(key).now()); } diff --git a/javatests/google/registry/rde/imports/XjcToDomainResourceConverterTest.java b/javatests/google/registry/rde/imports/XjcToDomainBaseConverterTest.java similarity index 86% rename from javatests/google/registry/rde/imports/XjcToDomainResourceConverterTest.java rename to javatests/google/registry/rde/imports/XjcToDomainBaseConverterTest.java index 6a26f39dc..55a78dd6b 100644 --- a/javatests/google/registry/rde/imports/XjcToDomainResourceConverterTest.java +++ b/javatests/google/registry/rde/imports/XjcToDomainBaseConverterTest.java @@ -39,7 +39,7 @@ import google.registry.model.billing.BillingEvent.Flag; import google.registry.model.billing.BillingEvent.Reason; import google.registry.model.contact.ContactResource; import google.registry.model.domain.DesignatedContact; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.GracePeriod; import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.domain.secdns.DelegationSignerData; @@ -68,9 +68,9 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -/** Tests for {@link XjcToDomainResourceConverter} */ +/** Tests for {@link XjcToDomainBaseConverter} */ @RunWith(JUnit4.class) -public class XjcToDomainResourceConverterTest { +public class XjcToDomainBaseConverterTest { //List of packages to initialize JAXBContext private static final String JAXB_CONTEXT_PACKAGES = Joiner.on(":").join(asList( @@ -102,7 +102,7 @@ public class XjcToDomainResourceConverterTest { } @Test - public void testConvertDomainResource() { + public void testConvertDomainBase() { final ContactResource jd1234 = persistActiveContact("jd1234"); final ContactResource sh8013 = persistActiveContact("sh8013"); ImmutableSet expectedContacts = @@ -110,10 +110,10 @@ public class XjcToDomainResourceConverterTest { DesignatedContact.create(DesignatedContact.Type.ADMIN, Key.create(sh8013)), DesignatedContact.create(DesignatedContact.Type.TECH, Key.create(sh8013))); final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment.xml"); - DomainResource domain = convertDomainInTransaction(xjcDomain); + DomainBase domain = convertDomainInTransaction(xjcDomain); assertThat(domain.getFullyQualifiedDomainName()).isEqualTo("example1.example"); assertThat(domain.getRepoId()).isEqualTo("Dexample1-TEST"); - // A DomainResource has status INACTIVE if there are no nameservers. + // A DomainBase has status INACTIVE if there are no nameservers. assertThat(domain.getStatusValues()).isEqualTo(ImmutableSet.of(StatusValue.INACTIVE)); assertThat(domain.getRegistrant().getName()).isEqualTo(jd1234.getRepoId()); assertThat(domain.getContacts()).isEqualTo(expectedContacts); @@ -133,20 +133,20 @@ public class XjcToDomainResourceConverterTest { /** Verifies that uppercase domain names are converted to lowercase */ @Test - public void testConvertDomainResourceUpperCase() { + public void testConvertDomainBaseUpperCase() { persistActiveContact("jd1234"); persistActiveContact("sh8013"); final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment_ucase.xml"); - DomainResource domain = convertDomainInTransaction(xjcDomain); + DomainBase domain = convertDomainInTransaction(xjcDomain); assertThat(domain.getFullyQualifiedDomainName()).isEqualTo("example1.example"); } @Test - public void testConvertDomainResourceAddPeriod() { + public void testConvertDomainBaseAddPeriod() { persistActiveContact("jd1234"); persistActiveContact("sh8013"); final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment_addPeriod.xml"); - DomainResource domain = convertDomainInTransaction(xjcDomain); + DomainBase domain = convertDomainInTransaction(xjcDomain); assertThat(domain.getGracePeriods()).hasSize(1); GracePeriod gracePeriod = domain.getGracePeriods().asList().get(0); assertThat(gracePeriod.getType()).isEqualTo(GracePeriodStatus.ADD); @@ -155,11 +155,11 @@ public class XjcToDomainResourceConverterTest { } @Test - public void testConvertDomainResourceAutoRenewPeriod() { + public void testConvertDomainBaseAutoRenewPeriod() { persistActiveContact("jd1234"); persistActiveContact("sh8013"); final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment_autoRenewPeriod.xml"); - DomainResource domain = convertDomainInTransaction(xjcDomain); + DomainBase domain = convertDomainInTransaction(xjcDomain); assertThat(domain.getGracePeriods()).hasSize(1); GracePeriod gracePeriod = domain.getGracePeriods().asList().get(0); assertThat(gracePeriod.getType()).isEqualTo(GracePeriodStatus.AUTO_RENEW); @@ -168,11 +168,11 @@ public class XjcToDomainResourceConverterTest { } @Test - public void testConvertDomainResourceRedemptionPeriod() { + public void testConvertDomainBaseRedemptionPeriod() { persistActiveContact("jd1234"); persistActiveContact("sh8013"); final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment_redemptionPeriod.xml"); - DomainResource domain = convertDomainInTransaction(xjcDomain); + DomainBase domain = convertDomainInTransaction(xjcDomain); assertThat(domain.getGracePeriods()).hasSize(1); GracePeriod gracePeriod = domain.getGracePeriods().asList().get(0); assertThat(gracePeriod.getType()).isEqualTo(GracePeriodStatus.REDEMPTION); @@ -181,11 +181,11 @@ public class XjcToDomainResourceConverterTest { } @Test - public void testConvertDomainResourceRenewPeriod() { + public void testConvertDomainBaseRenewPeriod() { persistActiveContact("jd1234"); persistActiveContact("sh8013"); final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment_renewPeriod.xml"); - DomainResource domain = convertDomainInTransaction(xjcDomain); + DomainBase domain = convertDomainInTransaction(xjcDomain); assertThat(domain.getGracePeriods()).hasSize(1); GracePeriod gracePeriod = domain.getGracePeriods().asList().get(0); assertThat(gracePeriod.getType()).isEqualTo(GracePeriodStatus.RENEW); @@ -194,11 +194,11 @@ public class XjcToDomainResourceConverterTest { } @Test - public void testConvertDomainResourcePendingDeletePeriod() { + public void testConvertDomainBasePendingDeletePeriod() { persistActiveContact("jd1234"); persistActiveContact("sh8013"); final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment_pendingDeletePeriod.xml"); - DomainResource domain = convertDomainInTransaction(xjcDomain); + DomainBase domain = convertDomainInTransaction(xjcDomain); assertThat(domain.getGracePeriods()).hasSize(1); GracePeriod gracePeriod = domain.getGracePeriods().asList().get(0); assertThat(gracePeriod.getType()).isEqualTo(GracePeriodStatus.PENDING_DELETE); @@ -207,7 +207,7 @@ public class XjcToDomainResourceConverterTest { } @Test - public void testConvertDomainResourcePendingRestorePeriodUnsupported() { + public void testConvertDomainBasePendingRestorePeriodUnsupported() { persistActiveContact("jd1234"); persistActiveContact("sh8013"); final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment_pendingRestorePeriod.xml"); @@ -219,11 +219,11 @@ public class XjcToDomainResourceConverterTest { } @Test - public void testConvertDomainResourceTransferPeriod() { + public void testConvertDomainBaseTransferPeriod() { persistActiveContact("jd1234"); persistActiveContact("sh8013"); final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment_transferPeriod.xml"); - DomainResource domain = convertDomainInTransaction(xjcDomain); + DomainBase domain = convertDomainInTransaction(xjcDomain); assertThat(domain.getGracePeriods()).hasSize(1); GracePeriod gracePeriod = domain.getGracePeriods().asList().get(0); assertThat(gracePeriod.getType()).isEqualTo(GracePeriodStatus.TRANSFER); @@ -241,27 +241,27 @@ public class XjcToDomainResourceConverterTest { } @Test - public void testConvertDomainResourceEppUpdateRegistrar() { + public void testConvertDomainBaseEppUpdateRegistrar() { persistActiveContact("jd1234"); persistActiveContact("sh8013"); final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment_up_rr.xml"); - DomainResource domain = convertDomainInTransaction(xjcDomain); + DomainBase domain = convertDomainInTransaction(xjcDomain); assertThat(domain.getLastEppUpdateClientId()).isEqualTo("RegistrarX"); } @Test - public void testConvertDomainResourceWithHostObjs() { + public void testConvertDomainBaseWithHostObjs() { persistActiveContact("jd1234"); persistActiveContact("sh8013"); HostResource host1 = persistActiveHost("ns1.example.net"); HostResource host2 = persistActiveHost("ns2.example.net"); final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment_host_objs.xml"); - DomainResource domain = convertDomainInTransaction(xjcDomain); + DomainBase domain = convertDomainInTransaction(xjcDomain); assertThat(domain.getNameservers()).containsExactly(Key.create(host1), Key.create(host2)); } @Test - public void testConvertDomainResourceWithHostAttrs() { + public void testConvertDomainBaseWithHostAttrs() { persistActiveContact("jd1234"); persistActiveContact("sh8013"); persistActiveHost("ns1.example.net"); @@ -273,7 +273,7 @@ public class XjcToDomainResourceConverterTest { } @Test - public void testConvertDomainResourceHostNotFound() { + public void testConvertDomainBaseHostNotFound() { persistActiveContact("jd1234"); persistActiveContact("sh8013"); persistActiveHost("ns1.example.net"); @@ -286,7 +286,7 @@ public class XjcToDomainResourceConverterTest { } @Test - public void testConvertDomainResourceRegistrantNotFound() { + public void testConvertDomainBaseRegistrantNotFound() { persistActiveContact("sh8013"); final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment.xml"); IllegalStateException thrown = @@ -295,7 +295,7 @@ public class XjcToDomainResourceConverterTest { } @Test - public void testConvertDomainResourceRegistrantMissing() { + public void testConvertDomainBaseRegistrantMissing() { persistActiveContact("jd1234"); persistActiveContact("sh8013"); final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment_registrant_missing.xml"); @@ -307,7 +307,7 @@ public class XjcToDomainResourceConverterTest { } @Test - public void testConvertDomainResourceAdminNotFound() { + public void testConvertDomainBaseAdminNotFound() { persistActiveContact("jd1234"); final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment.xml"); IllegalStateException thrown = @@ -316,24 +316,24 @@ public class XjcToDomainResourceConverterTest { } @Test - public void testConvertDomainResourceSecDnsData() { + public void testConvertDomainBaseSecDnsData() { persistActiveContact("jd1234"); persistActiveContact("sh8013"); final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment_secdns.xml"); - DomainResource domain = convertDomainInTransaction(xjcDomain); + DomainBase domain = convertDomainInTransaction(xjcDomain); byte[] digest = base16().decode("5FA1FA1C2F70AA483FE178B765D82B272072B4E4167902C5B7F97D46C8899F44"); assertThat(domain.getDsData()).containsExactly(DelegationSignerData.create(4609, 8, 2, digest)); } @Test - public void testConvertDomainResourceHistoryEntry() throws Exception { + public void testConvertDomainBaseHistoryEntry() throws Exception { persistActiveContact("jd1234"); persistActiveContact("sh8013"); final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment.xml"); // First import in a transaction, then verify in another transaction. // Ancestor queries don't work within the same transaction. - DomainResource domain = persistResource(convertDomainInTransaction(xjcDomain)); + DomainBase domain = persistResource(convertDomainInTransaction(xjcDomain)); List historyEntries = getHistoryEntries(domain); assertThat(historyEntries).hasSize(1); HistoryEntry entry = historyEntries.get(0); @@ -352,13 +352,13 @@ public class XjcToDomainResourceConverterTest { } @Test - public void testConvertDomainResourceAutoRenewBillingEvent() { + public void testConvertDomainBaseAutoRenewBillingEvent() { persistActiveContact("jd1234"); persistActiveContact("sh8013"); final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment.xml"); // First import in a transaction, then verify in another transaction. // Ancestor queries don't work within the same transaction. - DomainResource domain = persistResource(convertDomainInTransaction(xjcDomain)); + DomainBase domain = persistResource(convertDomainInTransaction(xjcDomain)); BillingEvent.Recurring autoRenewEvent = ofy().load().key(domain.getAutorenewBillingEvent()).now(); assertThat(autoRenewEvent.getReason()).isEqualTo(Reason.RENEW); @@ -370,13 +370,13 @@ public class XjcToDomainResourceConverterTest { } @Test - public void testConvertDomainResourceAutoRenewPollMessage() { + public void testConvertDomainBaseAutoRenewPollMessage() { persistActiveContact("jd1234"); persistActiveContact("sh8013"); final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment.xml"); // First import in a transaction, then verify in another transaction. // Ancestor queries don't work within the same transaction. - DomainResource domain = persistResource(convertDomainInTransaction(xjcDomain)); + DomainBase domain = persistResource(convertDomainInTransaction(xjcDomain)); PollMessage pollMessage = ofy().load().key(domain.getAutorenewPollMessage()).now(); assertThat(pollMessage).isInstanceOf(PollMessage.Autorenew.class); assertThat(((PollMessage.Autorenew) pollMessage).getTargetId()).isEqualTo(xjcDomain.getRoid()); @@ -386,11 +386,11 @@ public class XjcToDomainResourceConverterTest { } @Test - public void testConvertDomainResourcePendingTransfer() { + public void testConvertDomainBasePendingTransfer() { persistActiveContact("jd1234"); persistActiveContact("sh8013"); final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment_pending_transfer.xml"); - DomainResource domain = persistResource(convertDomainInTransaction(xjcDomain)); + DomainBase domain = persistResource(convertDomainInTransaction(xjcDomain)); assertThat(domain.getTransferData()).isNotNull(); assertThat(domain.getTransferData().getTransferStatus()).isEqualTo(TransferStatus.PENDING); assertThat(domain.getTransferData().getGainingClientId()).isEqualTo("RegistrarY"); @@ -402,18 +402,18 @@ public class XjcToDomainResourceConverterTest { } @Test - public void testConvertDomainResourcePendingTransferRegistrationCap() { + public void testConvertDomainBasePendingTransferRegistrationCap() { persistActiveContact("jd1234"); persistActiveContact("sh8013"); final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment_pending_transfer_registration_cap.xml"); - DomainResource domain = persistResource(convertDomainInTransaction(xjcDomain)); + DomainBase domain = persistResource(convertDomainInTransaction(xjcDomain)); assertThat(domain.getTransferData()).isNotNull(); // This test will be imcomplete until b/36405140 is fixed to store exDate on TransferData, since // without that there's no way to actually test the capping of the projected registration here. } - private DomainResource convertDomainInTransaction(final XjcRdeDomain xjcDomain) { + private DomainBase convertDomainInTransaction(final XjcRdeDomain xjcDomain) { return ofy() .transact( () -> { @@ -423,7 +423,7 @@ public class XjcToDomainResourceConverterTest { PollMessage.Autorenew autorenewPollMessage = createAutoRenewPollMessageForDomainImport(xjcDomain, historyEntry); ofy().save().entities(historyEntry, autorenewBillingEvent, autorenewPollMessage); - return XjcToDomainResourceConverter.convertDomain( + return XjcToDomainBaseConverter.convertDomain( xjcDomain, autorenewBillingEvent, autorenewPollMessage, stringGenerator); }); } diff --git a/javatests/google/registry/reporting/icann/testdata/total_domains_test.sql b/javatests/google/registry/reporting/icann/testdata/total_domains_test.sql index af516f0bf..8c82118c6 100644 --- a/javatests/google/registry/reporting/icann/testdata/total_domains_test.sql +++ b/javatests/google/registry/reporting/icann/testdata/total_domains_test.sql @@ -32,7 +32,6 @@ JOIN ON currentSponsorClientId = registrar_table.__key__.name WHERE - domain_table._d = 'DomainResource' - AND (registrar_table.type = 'REAL' OR registrar_table.type = 'INTERNAL') + registrar_table.type = 'REAL' OR registrar_table.type = 'INTERNAL' GROUP BY tld, registrarName ORDER BY tld, registrarName diff --git a/javatests/google/registry/reporting/icann/testdata/total_nameservers_test.sql b/javatests/google/registry/reporting/icann/testdata/total_nameservers_test.sql index c263df3a7..a81ecbd56 100644 --- a/javatests/google/registry/reporting/icann/testdata/total_nameservers_test.sql +++ b/javatests/google/registry/reporting/icann/testdata/total_nameservers_test.sql @@ -44,8 +44,7 @@ JOIN ( FROM `domain-registry-alpha.latest_datastore_export.DomainBase`, UNNEST(nsHosts) AS hosts - WHERE _d = 'DomainResource' - AND creationTime <= TIMESTAMP("2017-09-30 23:59:59.999") + WHERE creationTime <= TIMESTAMP("2017-09-30 23:59:59.999") AND deletionTime > TIMESTAMP("2017-09-30 23:59:59.999") ) AS domain_table ON host_table.__key__.name = domain_table.referencedHostName diff --git a/javatests/google/registry/server/Fixture.java b/javatests/google/registry/server/Fixture.java index 938ea1347..8840697bf 100644 --- a/javatests/google/registry/server/Fixture.java +++ b/javatests/google/registry/server/Fixture.java @@ -20,7 +20,7 @@ import static google.registry.model.domain.DesignatedContact.Type.TECH; import static google.registry.testing.DatastoreHelper.createTlds; import static google.registry.testing.DatastoreHelper.loadRegistrar; import static google.registry.testing.DatastoreHelper.newContactResource; -import static google.registry.testing.DatastoreHelper.newDomainResource; +import static google.registry.testing.DatastoreHelper.newDomainBase; import static google.registry.testing.DatastoreHelper.persistActiveHost; import static google.registry.testing.DatastoreHelper.persistPremiumList; import static google.registry.testing.DatastoreHelper.persistResource; @@ -124,7 +124,7 @@ public enum Fixture { .build()); persistResource( - newDomainResource("love.xn--q9jyb4c", justine).asBuilder() + newDomainBase("love.xn--q9jyb4c", justine).asBuilder() .setContacts(ImmutableSet.of( DesignatedContact.create(ADMIN, Key.create(robert)), DesignatedContact.create(BILLING, Key.create(google)), @@ -135,7 +135,7 @@ public enum Fixture { .build()); persistResource( - newDomainResource("moogle.example", justine).asBuilder() + newDomainBase("moogle.example", justine).asBuilder() .setContacts(ImmutableSet.of( DesignatedContact.create(ADMIN, Key.create(robert)), DesignatedContact.create(BILLING, Key.create(google)), diff --git a/javatests/google/registry/testing/AbstractDomainBaseSubject.java b/javatests/google/registry/testing/AbstractDomainBaseSubject.java index f4a1784de..cb60890a3 100644 --- a/javatests/google/registry/testing/AbstractDomainBaseSubject.java +++ b/javatests/google/registry/testing/AbstractDomainBaseSubject.java @@ -17,14 +17,13 @@ package google.registry.testing; import com.google.common.collect.ImmutableSet; import com.google.common.truth.FailureMetadata; import google.registry.model.domain.DomainBase; -import google.registry.model.domain.DomainResource; import google.registry.model.domain.launch.LaunchNotice; import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.eppcommon.AuthInfo; import google.registry.testing.TruthChainer.And; import java.util.Set; -/** Truth subject for asserting things about {@link DomainResource} instances. */ +/** Truth subject for asserting things about {@link DomainBase} instances. */ public abstract class AbstractDomainBaseSubject > extends AbstractEppResourceSubject { diff --git a/javatests/google/registry/testing/DatastoreHelper.java b/javatests/google/registry/testing/DatastoreHelper.java index a908dfe30..1e634ec61 100644 --- a/javatests/google/registry/testing/DatastoreHelper.java +++ b/javatests/google/registry/testing/DatastoreHelper.java @@ -67,7 +67,7 @@ import google.registry.model.contact.ContactResource; import google.registry.model.domain.DesignatedContact; import google.registry.model.domain.DesignatedContact.Type; import google.registry.model.domain.DomainAuthInfo; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.GracePeriod; import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.eppcommon.AuthInfo.PasswordAuth; @@ -125,27 +125,27 @@ public class DatastoreHelper { .build(); } - public static DomainResource newDomainResource(String domainName) { + public static DomainBase newDomainBase(String domainName) { String repoId = generateNewDomainRoid(getTldFromDomainName(domainName)); - return newDomainResource(domainName, repoId, persistActiveContact("contact1234")); + return newDomainBase(domainName, repoId, persistActiveContact("contact1234")); } - public static DomainResource newDomainResource(String domainName, ContactResource contact) { - return newDomainResource( + public static DomainBase newDomainBase(String domainName, ContactResource contact) { + return newDomainBase( domainName, generateNewDomainRoid(getTldFromDomainName(domainName)), contact); } - public static DomainResource newDomainResource(String domainName, HostResource host) { - return newDomainResource(domainName) + public static DomainBase newDomainBase(String domainName, HostResource host) { + return newDomainBase(domainName) .asBuilder() .setNameservers(ImmutableSet.of(Key.create(host))) .build(); } - public static DomainResource newDomainResource( + public static DomainBase newDomainBase( String domainName, String repoId, ContactResource contact) { Key contactKey = Key.create(contact); - return new DomainResource.Builder() + return new DomainBase.Builder() .setRepoId(repoId) .setFullyQualifiedDomainName(domainName) .setCreationClientId("TheRegistrar") @@ -233,7 +233,7 @@ public class DatastoreHelper { } public static HostResource persistActiveSubordinateHost( - String hostName, DomainResource superordinateDomain) { + String hostName, DomainBase superordinateDomain) { checkNotNull(superordinateDomain); return persistResource( newHostResource(hostName) @@ -250,19 +250,19 @@ public class DatastoreHelper { newHostResource(hostName).asBuilder().setDeletionTime(deletionTime).build()); } - public static DomainResource persistActiveDomain(String domainName) { - return persistResource(newDomainResource(domainName)); + public static DomainBase persistActiveDomain(String domainName) { + return persistResource(newDomainBase(domainName)); } - public static DomainResource persistActiveDomain(String domainName, DateTime creationTime) { + public static DomainBase persistActiveDomain(String domainName, DateTime creationTime) { return persistResource( - newDomainResource(domainName).asBuilder().setCreationTimeForTest(creationTime).build()); + newDomainBase(domainName).asBuilder().setCreationTimeForTest(creationTime).build()); } - public static DomainResource persistActiveDomain( + public static DomainBase persistActiveDomain( String domainName, DateTime creationTime, DateTime expirationTime) { return persistResource( - newDomainResource(domainName) + newDomainBase(domainName) .asBuilder() .setCreationTimeForTest(creationTime) .setRegistrationExpirationTime(expirationTime) @@ -270,26 +270,26 @@ public class DatastoreHelper { } /** Persists a domain resource with the given domain name deleted at the specified time. */ - public static DomainResource persistDeletedDomain(String domainName, DateTime deletionTime) { - return persistDomainAsDeleted(newDomainResource(domainName), deletionTime); + public static DomainBase persistDeletedDomain(String domainName, DateTime deletionTime) { + return persistDomainAsDeleted(newDomainBase(domainName), deletionTime); } /** * Returns a persisted domain that is the passed-in domain modified to be deleted at the specified * time. */ - public static DomainResource persistDomainAsDeleted( - DomainResource domain, DateTime deletionTime) { + public static DomainBase persistDomainAsDeleted( + DomainBase domain, DateTime deletionTime) { return persistResource(domain.asBuilder().setDeletionTime(deletionTime).build()); } /** Persists a domain and enqueues a LORDN task of the appropriate type for it. */ - public static DomainResource persistDomainAndEnqueueLordn(final DomainResource domain) { - final DomainResource persistedDomain = persistResource(domain); - // Calls {@link LordnTaskUtils#enqueueDomainResourceTask} wrapped in an ofy transaction so that + public static DomainBase persistDomainAndEnqueueLordn(final DomainBase domain) { + final DomainBase persistedDomain = persistResource(domain); + // Calls {@link LordnTaskUtils#enqueueDomainBaseTask} wrapped in an ofy transaction so that // the // transaction time is set correctly. - ofy().transactNew(() -> LordnTaskUtils.enqueueDomainResourceTask(persistedDomain)); + ofy().transactNew(() -> LordnTaskUtils.enqueueDomainBaseTask(persistedDomain)); return persistedDomain; } @@ -414,7 +414,7 @@ public class DatastoreHelper { } public static BillingEvent.OneTime createBillingEventForTransfer( - DomainResource domain, + DomainBase domain, HistoryEntry historyEntry, DateTime costLookupTime, DateTime eventTime) { @@ -473,7 +473,7 @@ public class DatastoreHelper { .build()); } - public static DomainResource persistDomainWithDependentResources( + public static DomainBase persistDomainWithDependentResources( String label, String tld, ContactResource contact, @@ -481,8 +481,8 @@ public class DatastoreHelper { DateTime creationTime, DateTime expirationTime) { String domainName = String.format("%s.%s", label, tld); - DomainResource domain = - new DomainResource.Builder() + DomainBase domain = + new DomainBase.Builder() .setRepoId(generateNewDomainRoid(tld)) .setFullyQualifiedDomainName(domainName) .setPersistedCurrentSponsorClientId("TheRegistrar") @@ -533,8 +533,8 @@ public class DatastoreHelper { .build()); } - public static DomainResource persistDomainWithPendingTransfer( - DomainResource domain, + public static DomainBase persistDomainWithPendingTransfer( + DomainBase domain, DateTime requestTime, DateTime expirationTime, DateTime extendedRegistrationExpirationTime, @@ -978,7 +978,7 @@ public class DatastoreHelper { } else if (resource instanceof HostResource) { return resource.getRepoId() != null ? HistoryEntry.Type.HOST_CREATE : HistoryEntry.Type.HOST_UPDATE; - } else if (resource instanceof DomainResource) { + } else if (resource instanceof DomainBase) { return resource.getRepoId() != null ? HistoryEntry.Type.DOMAIN_CREATE : HistoryEntry.Type.DOMAIN_UPDATE; } else { diff --git a/javatests/google/registry/testing/DomainResourceSubject.java b/javatests/google/registry/testing/DomainBaseSubject.java similarity index 66% rename from javatests/google/registry/testing/DomainResourceSubject.java rename to javatests/google/registry/testing/DomainBaseSubject.java index 26164d19c..28f234aa4 100644 --- a/javatests/google/registry/testing/DomainResourceSubject.java +++ b/javatests/google/registry/testing/DomainBaseSubject.java @@ -19,16 +19,16 @@ import static com.google.common.truth.Truth.assertAbout; import com.google.common.truth.FailureMetadata; import com.google.common.truth.SimpleSubjectBuilder; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.testing.TruthChainer.And; import java.util.Objects; import org.joda.time.DateTime; -/** Truth subject for asserting things about {@link DomainResource} instances. */ -public final class DomainResourceSubject - extends AbstractDomainBaseSubject { +/** Truth subject for asserting things about {@link DomainBase} instances. */ +public final class DomainBaseSubject + extends AbstractDomainBaseSubject { - public And hasRegistrationExpirationTime(DateTime expiration) { + public And hasRegistrationExpirationTime(DateTime expiration) { if (!Objects.equals(actual().getRegistrationExpirationTime(), expiration)) { failWithBadResults( "has registrationExpirationTime", @@ -38,43 +38,43 @@ public final class DomainResourceSubject return andChainer(); } - public And hasLastTransferTime(DateTime lastTransferTime) { + public And hasLastTransferTime(DateTime lastTransferTime) { return hasValue( lastTransferTime, actual().getLastTransferTime(), "has lastTransferTime"); } - public And hasLastTransferTimeNotEqualTo(DateTime lastTransferTime) { + public And hasLastTransferTimeNotEqualTo(DateTime lastTransferTime) { return doesNotHaveValue( lastTransferTime, actual().getLastTransferTime(), "lastTransferTime"); } - public And hasDeletePollMessage() { + public And hasDeletePollMessage() { if (actual().getDeletePollMessage() == null) { fail("has a delete poll message"); } return andChainer(); } - public And hasNoDeletePollMessage() { + public And hasNoDeletePollMessage() { if (actual().getDeletePollMessage() != null) { fail("has no delete poll message"); } return andChainer(); } - public And hasSmdId(String smdId) { + public And hasSmdId(String smdId) { return hasValue(smdId, actual().getSmdId(), "has smdId"); } - public DomainResourceSubject(FailureMetadata failureMetadata, DomainResource subject) { + public DomainBaseSubject(FailureMetadata failureMetadata, DomainBase subject) { super(failureMetadata, checkNotNull(subject)); } - public static SimpleSubjectBuilder assertAboutDomains() { - return assertAbout(DomainResourceSubject::new); + public static SimpleSubjectBuilder assertAboutDomains() { + return assertAbout(DomainBaseSubject::new); } } diff --git a/javatests/google/registry/testing/FullFieldsTestEntityHelper.java b/javatests/google/registry/testing/FullFieldsTestEntityHelper.java index 7a75a0a05..e4b7e4b78 100644 --- a/javatests/google/registry/testing/FullFieldsTestEntityHelper.java +++ b/javatests/google/registry/testing/FullFieldsTestEntityHelper.java @@ -30,7 +30,7 @@ import google.registry.model.contact.ContactPhoneNumber; import google.registry.model.contact.ContactResource; import google.registry.model.contact.PostalInfo; import google.registry.model.domain.DesignatedContact; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.Period; import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.eppcommon.StatusValue; @@ -332,7 +332,7 @@ public final class FullFieldsTestEntityHelper { return contactResource; } - public static DomainResource makeDomainResource( + public static DomainBase makeDomainBase( String domain, @Nullable ContactResource registrant, @Nullable ContactResource admin, @@ -340,7 +340,7 @@ public final class FullFieldsTestEntityHelper { @Nullable HostResource ns1, @Nullable HostResource ns2, Registrar registrar) { - DomainResource.Builder builder = new DomainResource.Builder() + DomainBase.Builder builder = new DomainBase.Builder() .setFullyQualifiedDomainName(Idn.toASCII(domain)) .setRepoId(generateNewDomainRoid(getTldFromDomainName(Idn.toASCII(domain)))) .setLastEppUpdateTime(DateTime.parse("2009-05-29T20:13:00Z")) diff --git a/javatests/google/registry/testing/HostResourceSubject.java b/javatests/google/registry/testing/HostResourceSubject.java index ba22718e5..525f41530 100644 --- a/javatests/google/registry/testing/HostResourceSubject.java +++ b/javatests/google/registry/testing/HostResourceSubject.java @@ -20,7 +20,7 @@ import static com.google.common.truth.Truth.assertAbout; import com.google.common.truth.FailureMetadata; import com.google.common.truth.SimpleSubjectBuilder; import com.googlecode.objectify.Key; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.host.HostResource; import google.registry.testing.TruthChainer.And; import org.joda.time.DateTime; @@ -58,7 +58,7 @@ public final class HostResourceSubject "has lastSuperordinateChange"); } - public And hasSuperordinateDomain(Key superordinateDomain) { + public And hasSuperordinateDomain(Key superordinateDomain) { return hasValue( superordinateDomain, actual().getSuperordinateDomain(), diff --git a/javatests/google/registry/tmch/LordnTaskUtilsTest.java b/javatests/google/registry/tmch/LordnTaskUtilsTest.java index 400130890..167c6e7bf 100644 --- a/javatests/google/registry/tmch/LordnTaskUtilsTest.java +++ b/javatests/google/registry/tmch/LordnTaskUtilsTest.java @@ -24,7 +24,7 @@ import static google.registry.testing.JUnitBackports.assertThrows; import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued; import com.googlecode.objectify.Key; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.launch.LaunchNotice; import google.registry.model.ofy.Ofy; import google.registry.model.registrar.Registrar.Type; @@ -60,8 +60,8 @@ public class LordnTaskUtilsTest { inject.setStaticField(Ofy.class, "clock", clock); } - private DomainResource.Builder newDomainBuilder() { - return new DomainResource.Builder() + private DomainBase.Builder newDomainBuilder() { + return new DomainBase.Builder() .setFullyQualifiedDomainName("fleece.example") .setRegistrant(Key.create(persistActiveContact("jd1234"))) .setSmdId("smdzzzz") @@ -69,7 +69,7 @@ public class LordnTaskUtilsTest { } @Test - public void test_enqueueDomainResourceTask_sunrise() { + public void test_enqueueDomainBaseTask_sunrise() { persistDomainAndEnqueueLordn(newDomainBuilder().setRepoId("A-EXAMPLE").build()); String expectedPayload = "A-EXAMPLE,fleece.example,smdzzzz,1,2010-05-01T10:11:12.000Z"; @@ -78,8 +78,8 @@ public class LordnTaskUtilsTest { } @Test - public void test_enqueueDomainResourceTask_claims() { - DomainResource domain = + public void test_enqueueDomainBaseTask_claims() { + DomainBase domain = newDomainBuilder() .setRepoId("11-EXAMPLE") .setLaunchNotice( @@ -113,8 +113,8 @@ public class LordnTaskUtilsTest { } @Test - public void test_enqueueDomainResourceTask_throwsExceptionOnInvalidRegistrar() { - DomainResource domain = + public void test_enqueueDomainBaseTask_throwsExceptionOnInvalidRegistrar() { + DomainBase domain = newDomainBuilder() .setRepoId("9000-EXAMPLE") .setCreationClientId("nonexistentRegistrar") @@ -127,9 +127,9 @@ public class LordnTaskUtilsTest { } @Test - public void test_enqueueDomainResourceTask_throwsNpeOnNullDomain() { + public void test_enqueueDomainBaseTask_throwsNpeOnNullDomain() { assertThrows( NullPointerException.class, - () -> ofy().transactNew(() -> LordnTaskUtils.enqueueDomainResourceTask(null))); + () -> ofy().transactNew(() -> LordnTaskUtils.enqueueDomainBaseTask(null))); } } diff --git a/javatests/google/registry/tmch/NordnUploadActionTest.java b/javatests/google/registry/tmch/NordnUploadActionTest.java index 529ed2d33..dfd7bbe6f 100644 --- a/javatests/google/registry/tmch/NordnUploadActionTest.java +++ b/javatests/google/registry/tmch/NordnUploadActionTest.java @@ -22,7 +22,7 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.loadRegistrar; -import static google.registry.testing.DatastoreHelper.newDomainResource; +import static google.registry.testing.DatastoreHelper.newDomainBase; import static google.registry.testing.DatastoreHelper.persistDomainAndEnqueueLordn; import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.JUnitBackports.assertThrows; @@ -49,7 +49,7 @@ import com.google.appengine.api.urlfetch.URLFetchService; import com.google.apphosting.api.DeadlineExceededException; import com.google.common.base.VerifyException; import com.google.common.collect.ImmutableList; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.launch.LaunchNotice; import google.registry.model.ofy.Ofy; import google.registry.model.registry.Registry; @@ -271,7 +271,7 @@ public class NordnUploadActionTest { } private void persistClaimsModeDomain() { - DomainResource domain = newDomainResource("claims-landrush1.tld"); + DomainBase domain = newDomainBase("claims-landrush1.tld"); persistDomainAndEnqueueLordn( domain .asBuilder() @@ -283,7 +283,7 @@ public class NordnUploadActionTest { private void persistSunriseModeDomain() { action.phase = "sunrise"; - DomainResource domain = newDomainResource("sunrise1.tld"); + DomainBase domain = newDomainBase("sunrise1.tld"); persistDomainAndEnqueueLordn(domain.asBuilder().setSmdId("my-smdid").build()); } diff --git a/javatests/google/registry/tools/EppLifecycleToolsTest.java b/javatests/google/registry/tools/EppLifecycleToolsTest.java index c17e62a19..896bc5336 100644 --- a/javatests/google/registry/tools/EppLifecycleToolsTest.java +++ b/javatests/google/registry/tools/EppLifecycleToolsTest.java @@ -25,7 +25,7 @@ import com.google.common.collect.ImmutableMap; import google.registry.flows.EppTestCase; import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent.Reason; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.reporting.HistoryEntry.Type; import google.registry.testing.AppEngineRule; import google.registry.util.Clock; @@ -139,9 +139,9 @@ public class EppLifecycleToolsTest extends EppTestCase { // Assert about billing events. DateTime createTime = DateTime.parse("2000-06-01T00:02:00Z"); - DomainResource domain = + DomainBase domain = loadByForeignKey( - DomainResource.class, "example.tld", DateTime.parse("2003-06-02T00:02:00Z")) + DomainBase.class, "example.tld", DateTime.parse("2003-06-02T00:02:00Z")) .get(); BillingEvent.OneTime renewBillingEvent = new BillingEvent.OneTime.Builder() diff --git a/javatests/google/registry/tools/GenerateDnsReportCommandTest.java b/javatests/google/registry/tools/GenerateDnsReportCommandTest.java index 0e28ca725..e042d87dc 100644 --- a/javatests/google/registry/tools/GenerateDnsReportCommandTest.java +++ b/javatests/google/registry/tools/GenerateDnsReportCommandTest.java @@ -17,7 +17,7 @@ package google.registry.tools; import static com.google.common.io.BaseEncoding.base16; import static com.google.common.truth.Truth.assertThat; import static google.registry.testing.DatastoreHelper.createTlds; -import static google.registry.testing.DatastoreHelper.newDomainResource; +import static google.registry.testing.DatastoreHelper.newDomainBase; import static google.registry.testing.DatastoreHelper.newHostResource; import static google.registry.testing.DatastoreHelper.persistActiveDomain; import static google.registry.testing.DatastoreHelper.persistActiveHost; @@ -32,7 +32,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.net.InetAddresses; import com.googlecode.objectify.Key; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.eppcommon.StatusValue; import google.registry.model.host.HostResource; @@ -70,7 +70,7 @@ public class GenerateDnsReportCommandTest extends CommandTestCase DOMAIN1_OUTPUT = ImmutableMap.of( "domain", "example.xn--q9jyb4c", @@ -130,13 +130,13 @@ public class GenerateDnsReportCommandTest extends CommandTestCase { @Test public void testSuccess_domainDeletedInFuture() throws Exception { - persistResource(newDomainResource("example.tld").asBuilder() + persistResource(newDomainBase("example.tld").asBuilder() .setDeletionTime(now.plusDays(1)).build()); runCommand("example.tld", "--read_timestamp=" + now.plusMonths(1)); assertInStdout("Domain 'example.tld' does not exist or is deleted"); diff --git a/javatests/google/registry/tools/GetHistoryEntriesCommandTest.java b/javatests/google/registry/tools/GetHistoryEntriesCommandTest.java index fc17977a1..d002ba916 100644 --- a/javatests/google/registry/tools/GetHistoryEntriesCommandTest.java +++ b/javatests/google/registry/tools/GetHistoryEntriesCommandTest.java @@ -19,7 +19,7 @@ import static google.registry.testing.DatastoreHelper.persistActiveDomain; import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.FullFieldsTestEntityHelper.makeHistoryEntry; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.domain.Period; import google.registry.model.reporting.HistoryEntry; import google.registry.testing.FakeClock; @@ -32,7 +32,7 @@ public class GetHistoryEntriesCommandTest extends CommandTestCase> nameservers = ImmutableSet.of(Key.create(host1), Key.create(host2)); persistResource( - newDomainResource("example.tld").asBuilder().setNameservers(nameservers).build()); + newDomainBase("example.tld").asBuilder().setNameservers(nameservers).build()); runCommandForced( "--client=NewRegistrar", "--nameservers=ns2.zdns.google,ns3.zdns.google", "example.tld"); eppVerifier.verifySent("domain_update_set_nameservers.xml"); @@ -192,7 +192,7 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase techResourceKey2 = Key.create(techContact2); persistResource( - newDomainResource("example.tld") + newDomainBase("example.tld") .asBuilder() .setContacts( ImmutableSet.of( @@ -215,7 +215,7 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase> nameservers = ImmutableSet.of(Key.create(host)); persistResource( - newDomainResource("example.tld") + newDomainBase("example.tld") .asBuilder() .setStatusValues( ImmutableSet.of( @@ -259,7 +259,7 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase> nameservers = ImmutableSet.of(Key.create(host)); persistResource( - newDomainResource("example.tld") + newDomainBase("example.tld") .asBuilder() .setStatusValues(ImmutableSet.of(SERVER_UPDATE_PROHIBITED)) .setNameservers(nameservers) diff --git a/javatests/google/registry/tools/server/GenerateZoneFilesActionTest.java b/javatests/google/registry/tools/server/GenerateZoneFilesActionTest.java index 6c60151c6..cce1b4687 100644 --- a/javatests/google/registry/tools/server/GenerateZoneFilesActionTest.java +++ b/javatests/google/registry/tools/server/GenerateZoneFilesActionTest.java @@ -17,7 +17,7 @@ package google.registry.tools.server; import static com.google.appengine.tools.cloudstorage.GcsServiceFactory.createGcsService; import static com.google.common.truth.Truth.assertThat; import static google.registry.testing.DatastoreHelper.createTlds; -import static google.registry.testing.DatastoreHelper.newDomainResource; +import static google.registry.testing.DatastoreHelper.newDomainBase; import static google.registry.testing.DatastoreHelper.newHostResource; import static google.registry.testing.DatastoreHelper.persistActiveContact; import static google.registry.testing.DatastoreHelper.persistActiveDomain; @@ -72,43 +72,43 @@ public class GenerateZoneFilesActionTest extends MapreduceTestCase adminResourceKey = Key.create(adminContact); Key techResourceKey = Key.create(techContact); - domainResource = persistResource(new DomainResource.Builder() + domainBase = persistResource(new DomainBase.Builder() .setFullyQualifiedDomainName("example.tld") .setRepoId("3-TLD") .setLastEppUpdateTime(DateTime.parse("2009-05-29T20:13:00Z")) @@ -256,7 +256,7 @@ public class DomainWhoisResponseTest { @Test public void getPlainTextOutputTest() { DomainWhoisResponse domainWhoisResponse = - new DomainWhoisResponse(domainResource, false, clock.nowUtc()); + new DomainWhoisResponse(domainBase, false, clock.nowUtc()); assertThat( domainWhoisResponse.getResponse( false, @@ -268,7 +268,7 @@ public class DomainWhoisResponseTest { public void getPlainTextOutputTest_registrarAbuseInfoMissing() { persistResource(abuseContact.asBuilder().setVisibleInDomainWhoisAsAbuse(false).build()); DomainWhoisResponse domainWhoisResponse = - new DomainWhoisResponse(domainResource, false, clock.nowUtc()); + new DomainWhoisResponse(domainBase, false, clock.nowUtc()); assertThat(domainWhoisResponse.getResponse(false, "Footer")) .isEqualTo( WhoisResponseResults.create( @@ -278,7 +278,7 @@ public class DomainWhoisResponseTest { @Test public void getPlainTextOutputTest_fullOutput() { DomainWhoisResponse domainWhoisResponse = - new DomainWhoisResponse(domainResource, true, clock.nowUtc()); + new DomainWhoisResponse(domainBase, true, clock.nowUtc()); assertThat( domainWhoisResponse.getResponse( false, @@ -290,7 +290,7 @@ public class DomainWhoisResponseTest { public void addImplicitOkStatusTest() { DomainWhoisResponse domainWhoisResponse = new DomainWhoisResponse( - domainResource.asBuilder().setStatusValues(null).build(), false, clock.nowUtc()); + domainBase.asBuilder().setStatusValues(null).build(), false, clock.nowUtc()); assertThat( domainWhoisResponse .getResponse( diff --git a/javatests/google/registry/whois/WhoisActionTest.java b/javatests/google/registry/whois/WhoisActionTest.java index de2acf352..007634d86 100644 --- a/javatests/google/registry/whois/WhoisActionTest.java +++ b/javatests/google/registry/whois/WhoisActionTest.java @@ -26,7 +26,7 @@ import static google.registry.testing.DatastoreHelper.persistActiveDomain; import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.DatastoreHelper.persistSimpleResources; import static google.registry.testing.FullFieldsTestEntityHelper.makeContactResource; -import static google.registry.testing.FullFieldsTestEntityHelper.makeDomainResource; +import static google.registry.testing.FullFieldsTestEntityHelper.makeDomainBase; import static google.registry.testing.FullFieldsTestEntityHelper.makeHostResource; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarContacts; @@ -45,7 +45,7 @@ import com.google.appengine.api.datastore.DatastoreTimeoutException; import com.google.common.collect.ImmutableSet; import com.google.common.net.InetAddresses; import google.registry.model.contact.ContactResource; -import google.registry.model.domain.DomainResource; +import google.registry.model.domain.DomainBase; import google.registry.model.eppcommon.Trid; import google.registry.model.host.HostResource; import google.registry.model.ofy.Ofy; @@ -118,8 +118,8 @@ public class WhoisActionTest { assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_no_command.txt")); } - private DomainResource makeDomainResourceWithRegistrar(Registrar registrar) { - return makeDomainResource( + private DomainBase makeDomainBaseWithRegistrar(Registrar registrar) { + return makeDomainBase( "cat.lol", persistResource(makeContactResource("5372808-ERL", "Goblin Market", "lol@cat.lol")), persistResource(makeContactResource("5372808-IRL", "Santa Claus", "BOFH@cat.lol")), @@ -133,7 +133,7 @@ public class WhoisActionTest { public void testRun_domainQuery_works() { Registrar registrar = persistResource(makeRegistrar("evilregistrar", "Yes Virginia", ACTIVE)); - persistResource(makeDomainResourceWithRegistrar(registrar)); + persistResource(makeDomainBaseWithRegistrar(registrar)); persistSimpleResources(makeRegistrarContacts(registrar)); newWhoisAction("domain cat.lol\r\n").run(); assertThat(response.getStatus()).isEqualTo(200); @@ -144,11 +144,11 @@ public class WhoisActionTest { public void testRun_domainQuery_usesCache() { Registrar registrar = persistResource(makeRegistrar("evilregistrar", "Yes Virginia", ACTIVE)); - persistResource(makeDomainResourceWithRegistrar(registrar)); + persistResource(makeDomainBaseWithRegistrar(registrar)); persistSimpleResources(makeRegistrarContacts(registrar)); // Populate the cache for both the domain and contact. - DomainResource domain = - loadByForeignKeyCached(DomainResource.class, "cat.lol", clock.nowUtc()).get(); + DomainBase domain = + loadByForeignKeyCached(DomainBase.class, "cat.lol", clock.nowUtc()).get(); ContactResource contact = loadByForeignKeyCached(ContactResource.class, "5372808-ERL", clock.nowUtc()).get(); // Make a change to the domain and contact that won't be seen because the cache will be hit. @@ -172,7 +172,7 @@ public class WhoisActionTest { public void testRun_domainAfterTransfer_hasUpdatedEppTimeAndClientId() { Registrar registrar = persistResource(makeRegistrar("TheRegistrar", "Yes Virginia", ACTIVE)); persistResource( - makeDomainResourceWithRegistrar(registrar) + makeDomainBaseWithRegistrar(registrar) .asBuilder() .setTransferData( new TransferData.Builder() @@ -197,7 +197,7 @@ public class WhoisActionTest { public void testRun_idnDomain_works() { Registrar registrar = persistResource(makeRegistrar( "evilregistrar", "Yes Virginia", ACTIVE)); - persistResource(makeDomainResource( + persistResource(makeDomainBase( "cat.みんな", persistResource(makeContactResource("5372808-ERL", "(◕‿◕)", "lol@cat.みんな")), persistResource(makeContactResource("5372808-IRL", "Santa Claus", "BOFH@cat.みんな")), @@ -215,7 +215,7 @@ public class WhoisActionTest { public void testRun_punycodeDomain_works() { Registrar registrar = persistResource(makeRegistrar( "evilregistrar", "Yes Virginia", ACTIVE)); - persistResource(makeDomainResource( + persistResource(makeDomainBase( "cat.みんな", persistResource(makeContactResource("5372808-ERL", "(◕‿◕)", "lol@cat.みんな")), persistResource(makeContactResource("5372808-IRL", "Santa Claus", "BOFH@cat.みんな")), @@ -239,7 +239,7 @@ public class WhoisActionTest { @Test public void testRun_domainNotFound_usesCache() { // Populate the cache with the nonexistence of this domain. - assertThat(loadByForeignKeyCached(DomainResource.class, "cat.lol", clock.nowUtc())).isEmpty(); + assertThat(loadByForeignKeyCached(DomainBase.class, "cat.lol", clock.nowUtc())).isEmpty(); // Add a new valid cat.lol domain that won't be found because the cache will be hit instead. persistActiveDomain("cat.lol"); newWhoisAction("domain cat.lol\r\n").run(); @@ -254,7 +254,7 @@ public class WhoisActionTest { persistResource(Registry.get("lol").asBuilder().setTldType(Registry.TldType.TEST).build()); Registrar registrar = persistResource(makeRegistrar( "evilregistrar", "Yes Virginia", ACTIVE)); - persistResource(makeDomainResource( + persistResource(makeDomainBase( "cat.lol", persistResource(makeContactResource("5372808-ERL", "Goblin Market", "lol@cat.lol")), persistResource(makeContactResource("5372808-IRL", "Santa Claus", "BOFH@cat.lol")), @@ -271,7 +271,7 @@ public class WhoisActionTest { @Test public void testRun_domainFlaggedAsDeletedInDatastore_isConsideredNotFound() { Registrar registrar; - persistResource(makeDomainResource("cat.lol", + persistResource(makeDomainBase("cat.lol", persistResource( makeContactResource("5372808-ERL", "Peter Murphy", "lol@cat.lol")), persistResource( @@ -296,7 +296,7 @@ public class WhoisActionTest { @Test public void testRun_domainDeletedThenRecreated_isFound() { Registrar registrar; - DomainResource domain1 = persistResource(makeDomainResource("cat.lol", + DomainBase domain1 = persistResource(makeDomainBase("cat.lol", persistResource( makeContactResource("5372808-ERL", "Peter Murphy", "lol@cat.lol")), persistResource( @@ -309,7 +309,7 @@ public class WhoisActionTest { makeRegistrar("example", "Example Registrar", ACTIVE))).asBuilder() .setCreationTimeForTest(clock.nowUtc().minusDays(2)) .setDeletionTime(clock.nowUtc().minusDays(1)).build()); - DomainResource domain2 = persistResource(makeDomainResource("cat.lol", + DomainBase domain2 = persistResource(makeDomainBase("cat.lol", persistResource( makeContactResource( "5372809-ERL", "Mrs. Alice Crypto", "alice@example.lol")), @@ -522,7 +522,7 @@ public class WhoisActionTest { public void testRun_multilevelDomain_isNotConsideredAHostname() { Registrar registrar = persistResource(makeRegistrar("example", "Example Registrar", ACTIVE)); - persistResource(makeDomainResource("cat.1.test", + persistResource(makeDomainBase("cat.1.test", persistResource(makeContactResource("5372808-ERL", "(◕‿◕)", "lol@cat.1.test")), persistResource(makeContactResource("5372808-IRL", "Santa Claus", "BOFH@cat.1.test")), persistResource(makeContactResource("5372808-TRL", "The Raven", "bog@cat.1.test")), diff --git a/javatests/google/registry/whois/WhoisHttpActionTest.java b/javatests/google/registry/whois/WhoisHttpActionTest.java index eede4f0d9..c6ed75c00 100644 --- a/javatests/google/registry/whois/WhoisHttpActionTest.java +++ b/javatests/google/registry/whois/WhoisHttpActionTest.java @@ -21,7 +21,7 @@ import static google.registry.testing.DatastoreHelper.loadRegistrar; import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.DatastoreHelper.persistSimpleResources; import static google.registry.testing.FullFieldsTestEntityHelper.makeContactResource; -import static google.registry.testing.FullFieldsTestEntityHelper.makeDomainResource; +import static google.registry.testing.FullFieldsTestEntityHelper.makeDomainBase; import static google.registry.testing.FullFieldsTestEntityHelper.makeHostResource; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarContacts; @@ -122,7 +122,7 @@ public class WhoisHttpActionTest { persistResource(Registry.get("lol").asBuilder().setTldType(Registry.TldType.TEST).build()); Registrar registrar = persistResource(makeRegistrar( "evilregistrar", "Yes Virginia", Registrar.State.ACTIVE)); - persistResource(makeDomainResource( + persistResource(makeDomainBase( "cat.lol", persistResource(makeContactResource("5372808-ERL", "Goblin Market", "lol@cat.lol")), persistResource(makeContactResource("5372808-IRL", "Santa Claus", "BOFH@cat.lol")), @@ -141,7 +141,7 @@ public class WhoisHttpActionTest { public void testRun_domainQueryIdn_works() { Registrar registrar = persistResource(makeRegistrar( "evilregistrar", "Yes Virginia", Registrar.State.ACTIVE)); - persistResource(makeDomainResource( + persistResource(makeDomainBase( "cat.みんな", persistResource(makeContactResource("5372808-ERL", "(◕‿◕)", "lol@cat.みんな")), persistResource(makeContactResource("5372808-IRL", "Santa Claus", "BOFH@cat.みんな")), @@ -167,7 +167,7 @@ public class WhoisHttpActionTest { .setOrg("Galactic\r\nEmpire") .build()) .build()); - persistResource(makeDomainResource( + persistResource(makeDomainBase( "cat.みんな", trl, trl, trl, @@ -180,7 +180,7 @@ public class WhoisHttpActionTest { @Test public void testRun_domainOnly_works() { - persistResource(makeDomainResource( + persistResource(makeDomainBase( "cat.みんな", persistResource(makeContactResource("5372808-ERL", "(◕‿◕)", "lol@cat.みんな")), persistResource(makeContactResource("5372808-IRL", "Operator", "BOFH@cat.みんな")), @@ -204,7 +204,7 @@ public class WhoisHttpActionTest { public void testRun_domainQueryPunycode_works() { Registrar registrar = persistResource(makeRegistrar( "evilregistrar", "Yes Virginia", Registrar.State.ACTIVE)); - persistResource(makeDomainResource( + persistResource(makeDomainBase( "cat.みんな", persistResource(makeContactResource("5372808-ERL", "(◕‿◕)", "lol@cat.みんな")), persistResource(makeContactResource("5372808-IRL", "Santa Claus", "BOFH@cat.みんな")), @@ -269,7 +269,7 @@ public class WhoisHttpActionTest { @Test public void testRun_uppercaseDomain_ignoresCasing() { - persistResource(makeDomainResource( + persistResource(makeDomainBase( "cat.lol", persistResource(makeContactResource("5372808-ERL", "Peter Murphy", "lol@cat.lol")), persistResource(makeContactResource("5372808-IRL", "Operator", "BOFH@cat.lol")), @@ -283,7 +283,7 @@ public class WhoisHttpActionTest { @Test public void testRun_hairyPath_getsDecoded() { - persistResource(makeDomainResource( + persistResource(makeDomainBase( "cat.lol", persistResource(makeContactResource("5372808-ERL", "Peter Murphy", "lol@cat.lol")), persistResource(makeContactResource("5372808-IRL", "Operator", "BOFH@cat.lol")),