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
This commit is contained in:
mcilwain 2019-01-25 10:53:10 -08:00 committed by Ben McIlwain
parent 97c2049669
commit e2528875b2
166 changed files with 1525 additions and 1666 deletions

View file

@ -42,7 +42,6 @@ import google.registry.mapreduce.MapreduceRunner;
import google.registry.mapreduce.inputs.EppResourceInputs; import google.registry.mapreduce.inputs.EppResourceInputs;
import google.registry.model.EppResourceUtils; import google.registry.model.EppResourceUtils;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.DomainBase;
import google.registry.model.domain.DomainResource;
import google.registry.model.index.EppResourceIndex; import google.registry.model.index.EppResourceIndex;
import google.registry.model.index.ForeignKeyIndex; import google.registry.model.index.ForeignKeyIndex;
import google.registry.model.registry.Registry; import google.registry.model.registry.Registry;
@ -58,7 +57,7 @@ import org.joda.time.DateTime;
import org.joda.time.Duration; 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. * billing events, along with their ForeignKeyDomainIndex and EppResourceIndex entities.
* *
* <p>See: https://www.youtube.com/watch?v=xuuv0syoHnM * <p>See: https://www.youtube.com/watch?v=xuuv0syoHnM
@ -166,7 +165,7 @@ public class DeleteProberDataAction implements Runnable {
} }
private void deleteDomain(final Key<DomainBase> domainKey) { private void deleteDomain(final Key<DomainBase> domainKey) {
final DomainResource domain = (DomainResource) ofy().load().key(domainKey).now(); final DomainBase domain = ofy().load().key(domainKey).now();
DateTime now = DateTime.now(UTC); DateTime now = DateTime.now(UTC);
@ -245,9 +244,9 @@ public class DeleteProberDataAction implements Runnable {
getContext().incrementCounter("total entities hard-deleted", entitiesDeleted); getContext().incrementCounter("total entities hard-deleted", entitiesDeleted);
} }
private void softDeleteDomain(final DomainResource domain) { private void softDeleteDomain(final DomainBase domain) {
ofy().transactNew(() -> { ofy().transactNew(() -> {
DomainResource deletedDomain = domain DomainBase deletedDomain = domain
.asBuilder() .asBuilder()
.setDeletionTime(ofy().getTransactionTime()) .setDeletionTime(ofy().getTransactionTime())
.setStatusValues(null) .setStatusValues(null)

View file

@ -47,7 +47,7 @@ import google.registry.model.billing.BillingEvent.Flag;
import google.registry.model.billing.BillingEvent.OneTime; import google.registry.model.billing.BillingEvent.OneTime;
import google.registry.model.billing.BillingEvent.Recurring; import google.registry.model.billing.BillingEvent.Recurring;
import google.registry.model.common.Cursor; 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.domain.Period;
import google.registry.model.registry.Registry; import google.registry.model.registry.Registry;
import google.registry.model.reporting.DomainTransactionRecord; import google.registry.model.reporting.DomainTransactionRecord;
@ -110,7 +110,7 @@ public class ExpandRecurringBillingEventsAction implements Runnable {
ImmutableList.of( ImmutableList.of(
new NullInput<>(), new NullInput<>(),
createChildEntityInput( createChildEntityInput(
ImmutableSet.of(DomainResource.class), ImmutableSet.of(Recurring.class)))) ImmutableSet.of(DomainBase.class), ImmutableSet.of(Recurring.class))))
.sendLinkToMapreduceConsole(response); .sendLinkToMapreduceConsole(response);
} }

View file

@ -49,7 +49,7 @@ import google.registry.batch.AsyncTaskMetrics.OperationResult;
import google.registry.dns.DnsQueue; import google.registry.dns.DnsQueue;
import google.registry.mapreduce.MapreduceRunner; import google.registry.mapreduce.MapreduceRunner;
import google.registry.mapreduce.inputs.NullInput; 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.host.HostResource;
import google.registry.model.server.Lock; import google.registry.model.server.Lock;
import google.registry.request.Action; import google.registry.request.Action;
@ -166,7 +166,7 @@ public class RefreshDnsOnHostRenameAction implements Runnable {
new RefreshDnsOnHostRenameMapper(refreshRequests, retrier), new RefreshDnsOnHostRenameMapper(refreshRequests, retrier),
new RefreshDnsOnHostRenameReducer(refreshRequests, lock.get(), retrier), new RefreshDnsOnHostRenameReducer(refreshRequests, lock.get(), retrier),
// Add an extra NullInput so that the reducer always fires exactly once. // 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); .sendLinkToMapreduceConsole(response);
} catch (Throwable t) { } catch (Throwable t) {
logRespondAndUnlock( logRespondAndUnlock(
@ -182,7 +182,7 @@ public class RefreshDnsOnHostRenameAction implements Runnable {
/** Map over domains and refresh the DNS of those that reference the renamed hosts. */ /** Map over domains and refresh the DNS of those that reference the renamed hosts. */
public static class RefreshDnsOnHostRenameMapper public static class RefreshDnsOnHostRenameMapper
extends Mapper<DomainResource, Boolean, Boolean> { extends Mapper<DomainBase, Boolean, Boolean> {
private static final long serialVersionUID = -5261698524424335531L; private static final long serialVersionUID = -5261698524424335531L;
private static final DnsQueue dnsQueue = DnsQueue.create(); private static final DnsQueue dnsQueue = DnsQueue.create();
@ -197,7 +197,7 @@ public class RefreshDnsOnHostRenameAction implements Runnable {
} }
@Override @Override
public final void map(@Nullable final DomainResource domain) { public final void map(@Nullable final DomainBase domain) {
if (domain == null) { if (domain == null) {
// Emit a single value so that the reducer always runs. The key and value don't matter. // Emit a single value so that the reducer always runs. The key and value don't matter.
emit(true, true); emit(true, true);

View file

@ -20,7 +20,7 @@ import google.registry.dns.DnsConstants.TargetType;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.model.EppResource.ForeignKeyedEppResource; import google.registry.model.EppResource.ForeignKeyedEppResource;
import google.registry.model.annotations.ExternalMessagingName; 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.model.host.HostResource;
import google.registry.request.Action; import google.registry.request.Action;
import google.registry.request.HttpException.BadRequestException; import google.registry.request.HttpException.BadRequestException;
@ -51,7 +51,7 @@ public final class RefreshDnsAction implements Runnable {
} }
switch (type) { switch (type) {
case DOMAIN: case DOMAIN:
loadAndVerifyExistence(DomainResource.class, domainOrHostName); loadAndVerifyExistence(DomainBase.class, domainOrHostName);
dnsQueue.addDomainRefreshTask(domainOrHostName); dnsQueue.addDomainRefreshTask(domainOrHostName);
break; break;
case HOST: case HOST:

View file

@ -36,7 +36,7 @@ import google.registry.config.RegistryConfig.Config;
import google.registry.dns.writer.BaseDnsWriter; import google.registry.dns.writer.BaseDnsWriter;
import google.registry.dns.writer.DnsWriter; import google.registry.dns.writer.DnsWriter;
import google.registry.dns.writer.DnsWriterZone; 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.domain.secdns.DelegationSignerData;
import google.registry.model.host.HostResource; import google.registry.model.host.HostResource;
import google.registry.model.registry.Registries; import google.registry.model.registry.Registries;
@ -121,13 +121,13 @@ public class CloudDnsWriter extends BaseDnsWriter {
String absoluteDomainName = getAbsoluteHostName(domainName); String absoluteDomainName = getAbsoluteHostName(domainName);
// Load the target domain. Note that it can be absent if this domain was just deleted. // Load the target domain. Note that it can be absent if this domain was just deleted.
Optional<DomainResource> domainResource = Optional<DomainBase> domainBase =
loadByForeignKey(DomainResource.class, domainName, clock.nowUtc()); loadByForeignKey(DomainBase.class, domainName, clock.nowUtc());
// Return early if no DNS records should be published. // Return early if no DNS records should be published.
// desiredRecordsBuilder is populated with an empty set to indicate that all existing records // desiredRecordsBuilder is populated with an empty set to indicate that all existing records
// should be deleted. // should be deleted.
if (!domainResource.isPresent() || !domainResource.get().shouldPublishToDns()) { if (!domainBase.isPresent() || !domainBase.get().shouldPublishToDns()) {
desiredRecords.put(absoluteDomainName, ImmutableSet.of()); desiredRecords.put(absoluteDomainName, ImmutableSet.of());
return; return;
} }
@ -135,7 +135,7 @@ public class CloudDnsWriter extends BaseDnsWriter {
ImmutableSet.Builder<ResourceRecordSet> domainRecords = new ImmutableSet.Builder<>(); ImmutableSet.Builder<ResourceRecordSet> domainRecords = new ImmutableSet.Builder<>();
// Construct DS records (if any). // Construct DS records (if any).
Set<DelegationSignerData> dsData = domainResource.get().getDsData(); Set<DelegationSignerData> dsData = domainBase.get().getDsData();
if (!dsData.isEmpty()) { if (!dsData.isEmpty()) {
HashSet<String> dsRrData = new HashSet<>(); HashSet<String> dsRrData = new HashSet<>();
for (DelegationSignerData ds : dsData) { for (DelegationSignerData ds : dsData) {
@ -154,8 +154,8 @@ public class CloudDnsWriter extends BaseDnsWriter {
} }
// Construct NS records (if any). // Construct NS records (if any).
Set<String> nameserverData = domainResource.get().loadNameserverFullyQualifiedHostNames(); Set<String> nameserverData = domainBase.get().loadNameserverFullyQualifiedHostNames();
Set<String> subordinateHosts = domainResource.get().getSubordinateHosts(); Set<String> subordinateHosts = domainBase.get().getSubordinateHosts();
if (!nameserverData.isEmpty()) { if (!nameserverData.isEmpty()) {
HashSet<String> nsRrData = new HashSet<>(); HashSet<String> nsRrData = new HashSet<>();
for (String hostName : nameserverData) { for (String hostName : nameserverData) {

View file

@ -27,7 +27,7 @@ import com.google.common.net.InternetDomainName;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
import google.registry.dns.writer.BaseDnsWriter; import google.registry.dns.writer.BaseDnsWriter;
import google.registry.dns.writer.DnsWriterZone; 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.domain.secdns.DelegationSignerData;
import google.registry.model.host.HostResource; import google.registry.model.host.HostResource;
import google.registry.model.registry.Registries; import google.registry.model.registry.Registries;
@ -127,12 +127,12 @@ public class DnsUpdateWriter extends BaseDnsWriter {
* this domain refresh request * this domain refresh request
*/ */
private void publishDomain(String domainName, String requestingHostName) { private void publishDomain(String domainName, String requestingHostName) {
Optional<DomainResource> domainOptional = Optional<DomainBase> domainOptional =
loadByForeignKey(DomainResource.class, domainName, clock.nowUtc()); loadByForeignKey(DomainBase.class, domainName, clock.nowUtc());
update.delete(toAbsoluteName(domainName), Type.ANY); update.delete(toAbsoluteName(domainName), Type.ANY);
// If the domain is now deleted, then don't update DNS for it. // If the domain is now deleted, then don't update DNS for it.
if (domainOptional.isPresent()) { if (domainOptional.isPresent()) {
DomainResource domain = domainOptional.get(); DomainBase domain = domainOptional.get();
// As long as the domain exists, orphan glues should be cleaned. // As long as the domain exists, orphan glues should be cleaned.
deleteSubordinateHostAddressSet(domain, requestingHostName, update); deleteSubordinateHostAddressSet(domain, requestingHostName, update);
if (domain.shouldPublishToDns()) { 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(); RRset signerSet = new RRset();
for (DelegationSignerData signerData : domain.getDsData()) { for (DelegationSignerData signerData : domain.getDsData()) {
DSRecord dsRecord = DSRecord dsRecord =
@ -202,7 +202,7 @@ public class DnsUpdateWriter extends BaseDnsWriter {
} }
private void deleteSubordinateHostAddressSet( private void deleteSubordinateHostAddressSet(
DomainResource domain, String additionalHost, Update update) { DomainBase domain, String additionalHost, Update update) {
for (String hostName : for (String hostName :
union( union(
domain.getSubordinateHosts(), 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 : for (String hostName :
intersection( intersection(
domain.loadNameserverFullyQualifiedHostNames(), domain.getSubordinateHosts())) { 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(); RRset nameServerSet = new RRset();
for (String hostName : domain.loadNameserverFullyQualifiedHostNames()) { for (String hostName : domain.loadNameserverFullyQualifiedHostNames()) {
NSRecord record = NSRecord record =

View file

@ -6,21 +6,11 @@
<property name="searchName" direction="asc"/> <property name="searchName" direction="asc"/>
</datastore-index> </datastore-index>
<!-- For finding domain resources by registrar. --> <!-- For finding domain resources by registrar. -->
<datastore-index kind="DomainBase" ancestor="false" source="manual">
<property name="^i" direction="asc"/>
<property name="currentSponsorClientId" direction="asc"/>
<property name="deletionTime" direction="asc"/>
</datastore-index>
<datastore-index kind="DomainBase" ancestor="false" source="manual"> <datastore-index kind="DomainBase" ancestor="false" source="manual">
<property name="currentSponsorClientId" direction="asc"/> <property name="currentSponsorClientId" direction="asc"/>
<property name="deletionTime" direction="asc"/> <property name="deletionTime" direction="asc"/>
</datastore-index> </datastore-index>
<!-- For finding domain resources by TLD. --> <!-- For finding domain resources by TLD. -->
<datastore-index kind="DomainBase" ancestor="false" source="manual">
<property name="^i" direction="asc"/>
<property name="tld" direction="asc"/>
<property name="deletionTime" direction="asc"/>
</datastore-index>
<datastore-index kind="DomainBase" ancestor="false" source="manual"> <datastore-index kind="DomainBase" ancestor="false" source="manual">
<property name="tld" direction="asc"/> <property name="tld" direction="asc"/>
<property name="deletionTime" direction="asc"/> <property name="deletionTime" direction="asc"/>
@ -31,11 +21,6 @@
<property name="deletionTime" direction="asc"/> <property name="deletionTime" direction="asc"/>
</datastore-index> </datastore-index>
<!-- For finding the most recently created domain resources. --> <!-- For finding the most recently created domain resources. -->
<datastore-index kind="DomainBase" ancestor="false" source="manual">
<property name="^i" direction="asc"/>
<property name="tld" direction="asc"/>
<property name="creationTime" direction="desc"/>
</datastore-index>
<datastore-index kind="DomainBase" ancestor="false" source="manual"> <datastore-index kind="DomainBase" ancestor="false" source="manual">
<property name="tld" direction="asc"/> <property name="tld" direction="asc"/>
<property name="creationTime" direction="desc"/> <property name="creationTime" direction="desc"/>
@ -62,11 +47,6 @@
<property name="deletionTime" direction="asc"/> <property name="deletionTime" direction="asc"/>
</datastore-index> </datastore-index>
<!-- For RDAP searches by linked nameserver. --> <!-- For RDAP searches by linked nameserver. -->
<datastore-index kind="DomainBase" ancestor="false" source="manual">
<property name="^i" direction="asc"/>
<property name="nsHosts" direction="asc"/>
<property name="deletionTime" direction="asc"/>
</datastore-index>
<datastore-index kind="DomainBase" ancestor="false" source="manual"> <datastore-index kind="DomainBase" ancestor="false" source="manual">
<property name="nsHosts" direction="asc"/> <property name="nsHosts" direction="asc"/>
<property name="deletionTime" direction="asc"/> <property name="deletionTime" direction="asc"/>
@ -95,31 +75,11 @@
</datastore-index> </datastore-index>
<!-- For RDAP. --> <!-- For RDAP. -->
<datastore-index kind="DomainBase" ancestor="false" source="manual"> <datastore-index kind="DomainBase" ancestor="false" source="manual">
<property name="^i" direction="asc"/>
<property name="fullyQualifiedDomainName" direction="asc"/>
</datastore-index>
<datastore-index kind="DomainBase" ancestor="false" source="manual">
<property name="^i" direction="asc"/>
<property name="currentSponsorClientId" direction="asc"/> <property name="currentSponsorClientId" direction="asc"/>
<property name="fullyQualifiedDomainName" direction="asc"/> <property name="fullyQualifiedDomainName" direction="asc"/>
</datastore-index> </datastore-index>
<datastore-index kind="DomainBase" ancestor="false" source="manual"> <datastore-index kind="DomainBase" ancestor="false" source="manual">
<property name="currentSponsorClientId" direction="asc"/> <property name="currentSponsorClientId" direction="asc"/>
<property name="fullyQualifiedDomainName" direction="asc"/>
</datastore-index>
<datastore-index kind="DomainBase" ancestor="false" source="manual">
<property name="^i" direction="asc"/>
<property name="currentSponsorClientId" direction="asc"/>
<property name="tld" direction="asc"/>
<property name="fullyQualifiedDomainName" direction="asc"/>
</datastore-index>
<datastore-index kind="DomainBase" ancestor="false" source="manual">
<property name="currentSponsorClientId" direction="asc"/>
<property name="tld" direction="asc"/>
<property name="fullyQualifiedDomainName" direction="asc"/>
</datastore-index>
<datastore-index kind="DomainBase" ancestor="false" source="manual">
<property name="^i" direction="asc"/>
<property name="tld" direction="asc"/> <property name="tld" direction="asc"/>
<property name="fullyQualifiedDomainName" direction="asc"/> <property name="fullyQualifiedDomainName" direction="asc"/>
</datastore-index> </datastore-index>

View file

@ -38,7 +38,7 @@ import com.google.common.net.MediaType;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
import google.registry.gcs.GcsUtils; import google.registry.gcs.GcsUtils;
import google.registry.mapreduce.MapreduceRunner; 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;
import google.registry.model.registry.Registry.TldType; import google.registry.model.registry.Registry.TldType;
import google.registry.request.Action; import google.registry.request.Action;
@ -88,11 +88,11 @@ public class ExportDomainListsAction implements Runnable {
.runMapreduce( .runMapreduce(
new ExportDomainListsMapper(DateTime.now(UTC), realTlds), new ExportDomainListsMapper(DateTime.now(UTC), realTlds),
new ExportDomainListsReducer(gcsBucket, gcsBufferSize), new ExportDomainListsReducer(gcsBucket, gcsBufferSize),
ImmutableList.of(createEntityInput(DomainResource.class))) ImmutableList.of(createEntityInput(DomainBase.class)))
.sendLinkToMapreduceConsole(response); .sendLinkToMapreduceConsole(response);
} }
static class ExportDomainListsMapper extends Mapper<DomainResource, String, String> { static class ExportDomainListsMapper extends Mapper<DomainBase, String, String> {
private static final long serialVersionUID = -7312206212434039854L; private static final long serialVersionUID = -7312206212434039854L;
@ -105,7 +105,7 @@ public class ExportDomainListsAction implements Runnable {
} }
@Override @Override
public void map(DomainResource domain) { public void map(DomainBase domain) {
if (realTlds.contains(domain.getTld()) && isActive(domain, exportTime)) { if (realTlds.contains(domain.getTld()) && isActive(domain, exportTime)) {
emit(domain.getTld(), domain.getFullyQualifiedDomainName()); emit(domain.getTld(), domain.getFullyQualifiedDomainName());
getContext().incrementCounter(String.format("domains in tld %s", domain.getTld())); getContext().incrementCounter(String.format("domains in tld %s", domain.getTld()));

View file

@ -44,7 +44,7 @@ import dagger.Module;
import dagger.Provides; import dagger.Provides;
import google.registry.flows.domain.DomainFlowUtils.BadCommandForRegistryPhaseException; import google.registry.flows.domain.DomainFlowUtils.BadCommandForRegistryPhaseException;
import google.registry.flows.domain.DomainFlowUtils.InvalidIdnDomainLabelException; 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.index.ForeignKeyIndex;
import google.registry.model.registry.Registry; import google.registry.model.registry.Registry;
import google.registry.model.registry.label.ReservationType; import google.registry.model.registry.label.ReservationType;
@ -157,7 +157,7 @@ public class CheckApiAction implements Runnable {
} }
private boolean checkExists(String domainString, DateTime now) { 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(); .isEmpty();
} }

View file

@ -95,7 +95,7 @@ public final class EppController {
e.getResult(), Trid.create(null, serverTridProvider.createServerTrid())); e.getResult(), Trid.create(null, serverTridProvider.createServerTrid()));
} }
if (!eppInput.getTargetIds().isEmpty()) { if (!eppInput.getTargetIds().isEmpty()) {
if (eppInput.isDomainResourceType()) { if (eppInput.isDomainType()) {
eppMetricBuilder.setTlds(extractTlds(eppInput.getTargetIds())); eppMetricBuilder.setTlds(extractTlds(eppInput.getTargetIds()));
} }
} }

View file

@ -70,12 +70,8 @@ public class FlowReporter {
.put("flowClassName", flowClass.getSimpleName()) .put("flowClassName", flowClass.getSimpleName())
.put("targetId", singleTargetId) .put("targetId", singleTargetId)
.put("targetIds", targetIds) .put("targetIds", targetIds)
.put( .put("tld", eppInput.isDomainType() ? extractTld(singleTargetId).orElse("") : "")
"tld", .put("tlds", eppInput.isDomainType() ? extractTlds(targetIds).asList() : EMPTY_LIST)
eppInput.isDomainResourceType() ? extractTld(singleTargetId).orElse("") : "")
.put(
"tlds",
eppInput.isDomainResourceType() ? extractTlds(targetIds).asList() : EMPTY_LIST)
.put("icannActivityReportField", extractActivityReportField(flowClass)) .put("icannActivityReportField", extractActivityReportField(flowClass))
.build())); .build()));
} }

View file

@ -22,7 +22,7 @@ import google.registry.flows.FlowMetadata;
import google.registry.flows.SessionMetadata; import google.registry.flows.SessionMetadata;
import google.registry.flows.domain.DomainCreateFlow; import google.registry.flows.domain.DomainCreateFlow;
import google.registry.model.ImmutableObject; 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.eppinput.EppInput;
import google.registry.model.eppoutput.EppResponse.ResponseData; import google.registry.model.eppoutput.EppResponse.ResponseData;
import google.registry.model.eppoutput.EppResponse.ResponseExtension; import google.registry.model.eppoutput.EppResponse.ResponseExtension;
@ -125,10 +125,10 @@ public class DomainCreateFlowCustomLogic extends BaseFlowCustomLogic {
public abstract static class BeforeSaveParameters extends ImmutableObject { 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. * 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 * 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 @AutoValue.Builder
public abstract static class Builder { public abstract static class Builder {
public abstract Builder setNewDomain(DomainResource newDomain); public abstract Builder setNewDomain(DomainBase newDomain);
public abstract Builder setHistoryEntry(HistoryEntry historyEntry); public abstract Builder setHistoryEntry(HistoryEntry historyEntry);

View file

@ -21,7 +21,7 @@ import google.registry.flows.FlowMetadata;
import google.registry.flows.SessionMetadata; import google.registry.flows.SessionMetadata;
import google.registry.flows.domain.DomainDeleteFlow; import google.registry.flows.domain.DomainDeleteFlow;
import google.registry.model.ImmutableObject; 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.eppinput.EppInput;
import google.registry.model.eppoutput.EppResponse.ResponseExtension; import google.registry.model.eppoutput.EppResponse.ResponseExtension;
import google.registry.model.eppoutput.Result; import google.registry.model.eppoutput.Result;
@ -83,7 +83,7 @@ public class DomainDeleteFlowCustomLogic extends BaseFlowCustomLogic {
@AutoValue @AutoValue
public abstract static class AfterValidationParameters extends ImmutableObject { public abstract static class AfterValidationParameters extends ImmutableObject {
public abstract DomainResource existingDomain(); public abstract DomainBase existingDomain();
public static Builder newBuilder() { public static Builder newBuilder() {
return new AutoValue_DomainDeleteFlowCustomLogic_AfterValidationParameters.Builder(); return new AutoValue_DomainDeleteFlowCustomLogic_AfterValidationParameters.Builder();
@ -93,7 +93,7 @@ public class DomainDeleteFlowCustomLogic extends BaseFlowCustomLogic {
@AutoValue.Builder @AutoValue.Builder
public abstract static class Builder { public abstract static class Builder {
public abstract Builder setExistingDomain(DomainResource existingDomain); public abstract Builder setExistingDomain(DomainBase existingDomain);
public abstract AfterValidationParameters build(); public abstract AfterValidationParameters build();
} }
@ -109,9 +109,9 @@ public class DomainDeleteFlowCustomLogic extends BaseFlowCustomLogic {
@AutoValue @AutoValue
public abstract static class BeforeSaveParameters extends ImmutableObject { 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(); public abstract HistoryEntry historyEntry();
@ -125,9 +125,9 @@ public class DomainDeleteFlowCustomLogic extends BaseFlowCustomLogic {
@AutoValue.Builder @AutoValue.Builder
public abstract static class 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); public abstract Builder setHistoryEntry(HistoryEntry historyEntry);

View file

@ -21,8 +21,8 @@ import google.registry.flows.FlowMetadata;
import google.registry.flows.SessionMetadata; import google.registry.flows.SessionMetadata;
import google.registry.flows.domain.DomainInfoFlow; import google.registry.flows.domain.DomainInfoFlow;
import google.registry.model.ImmutableObject; import google.registry.model.ImmutableObject;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.DomainInfoData; import google.registry.model.domain.DomainInfoData;
import google.registry.model.domain.DomainResource;
import google.registry.model.eppinput.EppInput; import google.registry.model.eppinput.EppInput;
import google.registry.model.eppoutput.EppResponse.ResponseExtension; 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. * A hook that runs before the response is returned.
* *
* <p>This takes the {@link DomainResource} and {@link ResponseExtension}s as input and returns * <p>This takes the {@link DomainBase} and {@link ResponseExtension}s as input and returns
* them, potentially with modifications. * them, potentially with modifications.
*/ */
@SuppressWarnings("unused") @SuppressWarnings("unused")
@ -69,7 +69,7 @@ public class DomainInfoFlowCustomLogic extends BaseFlowCustomLogic {
@AutoValue @AutoValue
public abstract static class AfterValidationParameters extends ImmutableObject { public abstract static class AfterValidationParameters extends ImmutableObject {
public abstract DomainResource domain(); public abstract DomainBase domain();
public static Builder newBuilder() { public static Builder newBuilder() {
return new AutoValue_DomainInfoFlowCustomLogic_AfterValidationParameters.Builder(); return new AutoValue_DomainInfoFlowCustomLogic_AfterValidationParameters.Builder();
@ -79,7 +79,7 @@ public class DomainInfoFlowCustomLogic extends BaseFlowCustomLogic {
@AutoValue.Builder @AutoValue.Builder
public abstract static class Builder { public abstract static class Builder {
public abstract Builder setDomain(DomainResource domain); public abstract Builder setDomain(DomainBase domain);
public abstract AfterValidationParameters build(); public abstract AfterValidationParameters build();
} }
@ -89,7 +89,7 @@ public class DomainInfoFlowCustomLogic extends BaseFlowCustomLogic {
@AutoValue @AutoValue
public abstract static class BeforeResponseParameters extends ImmutableObject { public abstract static class BeforeResponseParameters extends ImmutableObject {
public abstract DomainResource domain(); public abstract DomainBase domain();
public abstract DomainInfoData resData(); public abstract DomainInfoData resData();
@ -103,7 +103,7 @@ public class DomainInfoFlowCustomLogic extends BaseFlowCustomLogic {
@AutoValue.Builder @AutoValue.Builder
public abstract static class Builder { public abstract static class Builder {
public abstract Builder setDomain(DomainResource domain); public abstract Builder setDomain(DomainBase domain);
public abstract Builder setResData(DomainInfoData resData); public abstract Builder setResData(DomainInfoData resData);

View file

@ -21,7 +21,7 @@ import google.registry.flows.FlowMetadata;
import google.registry.flows.SessionMetadata; import google.registry.flows.SessionMetadata;
import google.registry.flows.domain.DomainRenewFlow; import google.registry.flows.domain.DomainRenewFlow;
import google.registry.model.ImmutableObject; 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.eppinput.EppInput;
import google.registry.model.eppoutput.EppResponse.ResponseData; import google.registry.model.eppoutput.EppResponse.ResponseData;
import google.registry.model.eppoutput.EppResponse.ResponseExtension; 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. * A hook that runs before the response is returned.
* *
* <p>This takes the {@link DomainResource} and {@link ResponseExtension}s as input and returns * <p>This takes the {@link DomainBase} and {@link ResponseExtension}s as input and returns
* them, potentially with modifications. * them, potentially with modifications.
*/ */
@SuppressWarnings("unused") @SuppressWarnings("unused")
@ -84,7 +84,7 @@ public class DomainRenewFlowCustomLogic extends BaseFlowCustomLogic {
@AutoValue @AutoValue
public abstract static class AfterValidationParameters extends ImmutableObject { public abstract static class AfterValidationParameters extends ImmutableObject {
public abstract DomainResource existingDomain(); public abstract DomainBase existingDomain();
public abstract int years(); public abstract int years();
@ -98,7 +98,7 @@ public class DomainRenewFlowCustomLogic extends BaseFlowCustomLogic {
@AutoValue.Builder @AutoValue.Builder
public abstract static class Builder { public abstract static class Builder {
public abstract Builder setExistingDomain(DomainResource existingDomain); public abstract Builder setExistingDomain(DomainBase existingDomain);
public abstract Builder setYears(int years); public abstract Builder setYears(int years);
@ -118,9 +118,9 @@ public class DomainRenewFlowCustomLogic extends BaseFlowCustomLogic {
@AutoValue @AutoValue
public abstract static class BeforeSaveParameters extends ImmutableObject { 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(); public abstract HistoryEntry historyEntry();
@ -138,9 +138,9 @@ public class DomainRenewFlowCustomLogic extends BaseFlowCustomLogic {
@AutoValue.Builder @AutoValue.Builder
public abstract static class 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); public abstract Builder setHistoryEntry(HistoryEntry historyEntry);
@ -158,7 +158,7 @@ public class DomainRenewFlowCustomLogic extends BaseFlowCustomLogic {
@AutoValue @AutoValue
public abstract static class BeforeResponseParameters extends ImmutableObject { public abstract static class BeforeResponseParameters extends ImmutableObject {
public abstract DomainResource domain(); public abstract DomainBase domain();
public abstract ResponseData resData(); public abstract ResponseData resData();
@ -172,7 +172,7 @@ public class DomainRenewFlowCustomLogic extends BaseFlowCustomLogic {
@AutoValue.Builder @AutoValue.Builder
public abstract static class 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); public abstract BeforeResponseParameters.Builder setResData(ResponseData resData);

View file

@ -20,7 +20,7 @@ import google.registry.flows.FlowMetadata;
import google.registry.flows.SessionMetadata; import google.registry.flows.SessionMetadata;
import google.registry.flows.domain.DomainUpdateFlow; import google.registry.flows.domain.DomainUpdateFlow;
import google.registry.model.ImmutableObject; 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.eppinput.EppInput;
import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.HistoryEntry;
@ -65,7 +65,7 @@ public class DomainUpdateFlowCustomLogic extends BaseFlowCustomLogic {
@AutoValue @AutoValue
public abstract static class AfterValidationParameters extends ImmutableObject { public abstract static class AfterValidationParameters extends ImmutableObject {
public abstract DomainResource existingDomain(); public abstract DomainBase existingDomain();
public static Builder newBuilder() { public static Builder newBuilder() {
return new AutoValue_DomainUpdateFlowCustomLogic_AfterValidationParameters.Builder(); return new AutoValue_DomainUpdateFlowCustomLogic_AfterValidationParameters.Builder();
@ -75,7 +75,7 @@ public class DomainUpdateFlowCustomLogic extends BaseFlowCustomLogic {
@AutoValue.Builder @AutoValue.Builder
public abstract static class Builder { public abstract static class Builder {
public abstract Builder setExistingDomain(DomainResource existingDomain); public abstract Builder setExistingDomain(DomainBase existingDomain);
public abstract AfterValidationParameters build(); public abstract AfterValidationParameters build();
} }
@ -91,9 +91,9 @@ public class DomainUpdateFlowCustomLogic extends BaseFlowCustomLogic {
@AutoValue @AutoValue
public abstract static class BeforeSaveParameters extends ImmutableObject { 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(); public abstract HistoryEntry historyEntry();
@ -107,9 +107,9 @@ public class DomainUpdateFlowCustomLogic extends BaseFlowCustomLogic {
@AutoValue.Builder @AutoValue.Builder
public abstract static class 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); public abstract Builder setHistoryEntry(HistoryEntry historyEntry);

View file

@ -42,8 +42,8 @@ import google.registry.flows.custom.DomainCheckFlowCustomLogic;
import google.registry.flows.custom.DomainCheckFlowCustomLogic.BeforeResponseParameters; import google.registry.flows.custom.DomainCheckFlowCustomLogic.BeforeResponseParameters;
import google.registry.flows.custom.DomainCheckFlowCustomLogic.BeforeResponseReturnData; import google.registry.flows.custom.DomainCheckFlowCustomLogic.BeforeResponseReturnData;
import google.registry.flows.domain.token.AllocationTokenFlowUtils; 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.DomainCommand.Check;
import google.registry.model.domain.DomainResource;
import google.registry.model.domain.fee.FeeCheckCommandExtension; import google.registry.model.domain.fee.FeeCheckCommandExtension;
import google.registry.model.domain.fee.FeeCheckCommandExtensionItem; import google.registry.model.domain.fee.FeeCheckCommandExtensionItem;
import google.registry.model.domain.fee.FeeCheckResponseExtensionItem; 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. // TODO: Use as of date from fee extension v0.12 instead of now, if specified.
.setAsOfDate(now) .setAsOfDate(now)
.build()); .build());
Set<String> existingIds = checkResourcesExist(DomainResource.class, targetIds, now); Set<String> existingIds = checkResourcesExist(DomainBase.class, targetIds, now);
Optional<AllocationTokenExtension> allocationTokenExtension = Optional<AllocationTokenExtension> allocationTokenExtension =
eppInput.getSingleExtension(AllocationTokenExtension.class); eppInput.getSingleExtension(AllocationTokenExtension.class);
ImmutableMap<InternetDomainName, String> tokenCheckResults = ImmutableMap<InternetDomainName, String> tokenCheckResults =

View file

@ -76,9 +76,9 @@ import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Flag; import google.registry.model.billing.BillingEvent.Flag;
import google.registry.model.billing.BillingEvent.Reason; import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.billing.BillingEvent.Recurring; 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;
import google.registry.model.domain.DomainCommand.Create; import google.registry.model.domain.DomainCommand.Create;
import google.registry.model.domain.DomainResource;
import google.registry.model.domain.GracePeriod; import google.registry.model.domain.GracePeriod;
import google.registry.model.domain.Period; import google.registry.model.domain.Period;
import google.registry.model.domain.fee.FeeCreateCommandExtension; import google.registry.model.domain.fee.FeeCreateCommandExtension;
@ -221,7 +221,7 @@ public class DomainCreateFlow implements TransactionalFlow {
verifyUnitIsYears(period); verifyUnitIsYears(period);
int years = period.getValue(); int years = period.getValue();
validateRegistrationPeriod(years); 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. // Validate that this is actually a legal domain name on a TLD that the registrar has access to.
InternetDomainName domainName = validateDomainName(command.getFullyQualifiedDomainName()); InternetDomainName domainName = validateDomainName(command.getFullyQualifiedDomainName());
String domainLabel = domainName.parts().get(0); String domainLabel = domainName.parts().get(0);
@ -334,8 +334,8 @@ public class DomainCreateFlow implements TransactionalFlow {
createNameCollisionOneTimePollMessage(targetId, historyEntry, clientId, now)); createNameCollisionOneTimePollMessage(targetId, historyEntry, clientId, now));
} }
DomainResource newDomain = DomainBase newDomain =
new DomainResource.Builder() new DomainBase.Builder()
.setCreationClientId(clientId) .setCreationClientId(clientId)
.setPersistedCurrentSponsorClientId(clientId) .setPersistedCurrentSponsorClientId(clientId)
.setRepoId(repoId) .setRepoId(repoId)
@ -477,7 +477,7 @@ public class DomainCreateFlow implements TransactionalFlow {
.setType(HistoryEntry.Type.DOMAIN_CREATE) .setType(HistoryEntry.Type.DOMAIN_CREATE)
.setPeriod(period) .setPeriod(period)
.setModificationTime(now) .setModificationTime(now)
.setParent(Key.create(DomainResource.class, repoId)) .setParent(Key.create(DomainBase.class, repoId))
.build(); .build();
} }
@ -573,12 +573,12 @@ public class DomainCreateFlow implements TransactionalFlow {
} }
private void enqueueTasks( private void enqueueTasks(
DomainResource newDomain, boolean hasSignedMarks, boolean hasClaimsNotice) { DomainBase newDomain, boolean hasSignedMarks, boolean hasClaimsNotice) {
if (newDomain.shouldPublishToDns()) { if (newDomain.shouldPublishToDns()) {
dnsQueue.addDomainRefreshTask(newDomain.getFullyQualifiedDomainName()); dnsQueue.addDomainRefreshTask(newDomain.getFullyQualifiedDomainName());
} }
if (hasClaimsNotice || hasSignedMarks) { if (hasClaimsNotice || hasSignedMarks) {
LordnTaskUtils.enqueueDomainResourceTask(newDomain); LordnTaskUtils.enqueueDomainBaseTask(newDomain);
} }
} }

View file

@ -61,8 +61,8 @@ import google.registry.flows.custom.DomainDeleteFlowCustomLogic.BeforeSaveParame
import google.registry.flows.custom.EntityChanges; import google.registry.flows.custom.EntityChanges;
import google.registry.model.ImmutableObject; import google.registry.model.ImmutableObject;
import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent;
import google.registry.model.domain.DomainResource; import google.registry.model.domain.DomainBase;
import google.registry.model.domain.DomainResource.Builder; import google.registry.model.domain.DomainBase.Builder;
import google.registry.model.domain.GracePeriod; import google.registry.model.domain.GracePeriod;
import google.registry.model.domain.fee.BaseFee.FeeType; import google.registry.model.domain.fee.BaseFee.FeeType;
import google.registry.model.domain.fee.Credit; import google.registry.model.domain.fee.Credit;
@ -143,7 +143,7 @@ public final class DomainDeleteFlow implements TransactionalFlow {
validateClientIsLoggedIn(clientId); validateClientIsLoggedIn(clientId);
DateTime now = ofy().getTransactionTime(); DateTime now = ofy().getTransactionTime();
// Loads the target resource if it exists // 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()); Registry registry = Registry.get(existingDomain.getTld());
verifyDeleteAllowed(existingDomain, registry, now); verifyDeleteAllowed(existingDomain, registry, now);
flowCustomLogic.afterValidation( 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 // message are produced (since we are ending the autorenew recurrences at "now" below). For
// now at least this is working as intended. // now at least this is working as intended.
} }
DomainResource newDomain = builder.build(); DomainBase newDomain = builder.build();
updateForeignKeyIndexDeletionTime(newDomain); updateForeignKeyIndexDeletionTime(newDomain);
handlePendingTransferOnDelete(existingDomain, newDomain, now, historyEntry); handlePendingTransferOnDelete(existingDomain, newDomain, now, historyEntry);
// Close the autorenew billing event and poll message. This may delete the poll message. // 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(); .build();
} }
private void verifyDeleteAllowed(DomainResource existingDomain, Registry registry, DateTime now) private void verifyDeleteAllowed(DomainBase existingDomain, Registry registry, DateTime now)
throws EppException { throws EppException {
verifyNoDisallowedStatuses(existingDomain, DISALLOWED_STATUSES); verifyNoDisallowedStatuses(existingDomain, DISALLOWED_STATUSES);
verifyOptionalAuthInfo(authInfo, existingDomain); verifyOptionalAuthInfo(authInfo, existingDomain);
@ -260,7 +260,7 @@ public final class DomainDeleteFlow implements TransactionalFlow {
} }
private HistoryEntry buildHistoryEntry( private HistoryEntry buildHistoryEntry(
DomainResource existingResource, DomainBase existingResource,
Registry registry, Registry registry,
DateTime now, DateTime now,
Duration durationUntilDelete, Duration durationUntilDelete,
@ -298,7 +298,7 @@ public final class DomainDeleteFlow implements TransactionalFlow {
} }
private OneTime createDeletePollMessage( private OneTime createDeletePollMessage(
DomainResource existingResource, HistoryEntry historyEntry, DateTime deletionTime) { DomainBase existingResource, HistoryEntry historyEntry, DateTime deletionTime) {
return new PollMessage.OneTime.Builder() return new PollMessage.OneTime.Builder()
.setClientId(existingResource.getCurrentSponsorClientId()) .setClientId(existingResource.getCurrentSponsorClientId())
.setEventTime(deletionTime) .setEventTime(deletionTime)
@ -312,7 +312,7 @@ public final class DomainDeleteFlow implements TransactionalFlow {
@Nullable @Nullable
private ImmutableList<FeeTransformResponseExtension> getResponseExtensions( private ImmutableList<FeeTransformResponseExtension> getResponseExtensions(
DomainResource existingDomain, DateTime now) { DomainBase existingDomain, DateTime now) {
FeeTransformResponseExtension.Builder feeResponseBuilder = getDeleteResponseBuilder(); FeeTransformResponseExtension.Builder feeResponseBuilder = getDeleteResponseBuilder();
if (feeResponseBuilder == null) { if (feeResponseBuilder == null) {
return ImmutableList.of(); return ImmutableList.of();

View file

@ -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.difference;
import static com.google.common.collect.Sets.intersection; import static com.google.common.collect.Sets.intersection;
import static com.google.common.collect.Sets.union; import static com.google.common.collect.Sets.union;
import static google.registry.model.domain.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.ofy.ObjectifyService.ofy;
import static google.registry.model.registry.Registries.findTldForName; import static google.registry.model.registry.Registries.findTldForName;
import static google.registry.model.registry.Registries.getTlds; 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.CreateOrUpdate;
import google.registry.model.domain.DomainCommand.InvalidReferencesException; import google.registry.model.domain.DomainCommand.InvalidReferencesException;
import google.registry.model.domain.DomainCommand.Update; import google.registry.model.domain.DomainCommand.Update;
import google.registry.model.domain.DomainResource;
import google.registry.model.domain.ForeignKeyedDesignatedContact; import google.registry.model.domain.ForeignKeyedDesignatedContact;
import google.registry.model.domain.Period; import google.registry.model.domain.Period;
import google.registry.model.domain.fee.BaseFee.FeeType; 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 * 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. * 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() return new BillingEvent.Recurring.Builder()
.setReason(Reason.RENEW) .setReason(Reason.RENEW)
.setFlags(ImmutableSet.of(Flag.AUTO_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 * 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. * 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() return new PollMessage.Autorenew.Builder()
.setTargetId(domain.getFullyQualifiedDomainName()) .setTargetId(domain.getFullyQualifiedDomainName())
.setClientId(domain.getCurrentSponsorClientId()) .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). * time earlier than its event time (i.e. if it's being ended before it was ever triggered).
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static void updateAutorenewRecurrenceEndTime(DomainResource domain, DateTime newEndTime) { public static void updateAutorenewRecurrenceEndTime(DomainBase domain, DateTime newEndTime) {
Optional<PollMessage.Autorenew> autorenewPollMessage = Optional<PollMessage.Autorenew> autorenewPollMessage =
Optional.ofNullable(ofy().load().key(domain.getAutorenewPollMessage()).now()); 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 * 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 * @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 * 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 * @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. * the most recent HistoryEntry that fits the above criteria, with negated reportAmounts.
*/ */
static ImmutableSet<DomainTransactionRecord> createCancelingRecords( static ImmutableSet<DomainTransactionRecord> createCancelingRecords(
DomainResource domainResource, DomainBase domainBase,
final DateTime now, final DateTime now,
Duration maxSearchPeriod, Duration maxSearchPeriod,
final ImmutableSet<TransactionReportField> cancelableFields) { final ImmutableSet<TransactionReportField> cancelableFields) {
@ -1028,7 +1027,7 @@ public class DomainFlowUtils {
ofy() ofy()
.load() .load()
.type(HistoryEntry.class) .type(HistoryEntry.class)
.ancestor(domainResource) .ancestor(domainBase)
.filter("modificationTime >=", now.minus(maxSearchPeriod)) .filter("modificationTime >=", now.minus(maxSearchPeriod))
.order("modificationTime") .order("modificationTime")
.list(); .list();

View file

@ -37,10 +37,10 @@ import google.registry.flows.custom.DomainInfoFlowCustomLogic;
import google.registry.flows.custom.DomainInfoFlowCustomLogic.AfterValidationParameters; import google.registry.flows.custom.DomainInfoFlowCustomLogic.AfterValidationParameters;
import google.registry.flows.custom.DomainInfoFlowCustomLogic.BeforeResponseParameters; import google.registry.flows.custom.DomainInfoFlowCustomLogic.BeforeResponseParameters;
import google.registry.flows.custom.DomainInfoFlowCustomLogic.BeforeResponseReturnData; 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;
import google.registry.model.domain.DomainCommand.Info.HostsRequest; import google.registry.model.domain.DomainCommand.Info.HostsRequest;
import google.registry.model.domain.DomainInfoData; 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.FeeInfoCommandExtensionV06;
import google.registry.model.domain.fee06.FeeInfoResponseExtensionV06; import google.registry.model.domain.fee06.FeeInfoResponseExtensionV06;
import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.domain.rgp.GracePeriodStatus;
@ -95,8 +95,8 @@ public final class DomainInfoFlow implements Flow {
extensionManager.validate(); extensionManager.validate();
validateClientIsLoggedIn(clientId); validateClientIsLoggedIn(clientId);
DateTime now = clock.nowUtc(); DateTime now = clock.nowUtc();
DomainResource domain = verifyExistence( DomainBase domain = verifyExistence(
DomainResource.class, targetId, loadByForeignKey(DomainResource.class, targetId, now)); DomainBase.class, targetId, loadByForeignKey(DomainBase.class, targetId, now));
verifyOptionalAuthInfo(authInfo, domain); verifyOptionalAuthInfo(authInfo, domain);
flowCustomLogic.afterValidation( flowCustomLogic.afterValidation(
AfterValidationParameters.newBuilder().setDomain(domain).build()); AfterValidationParameters.newBuilder().setDomain(domain).build());
@ -145,7 +145,7 @@ public final class DomainInfoFlow implements Flow {
} }
private ImmutableList<ResponseExtension> getDomainResponseExtensions( private ImmutableList<ResponseExtension> getDomainResponseExtensions(
DomainResource domain, DateTime now) throws EppException { DomainBase domain, DateTime now) throws EppException {
ImmutableList.Builder<ResponseExtension> extensions = new ImmutableList.Builder<>(); ImmutableList.Builder<ResponseExtension> extensions = new ImmutableList.Builder<>();
addSecDnsExtensionIfPresent(extensions, domain.getDsData()); addSecDnsExtensionIfPresent(extensions, domain.getDsData());
ImmutableSet<GracePeriodStatus> gracePeriodStatuses = domain.getGracePeriodStatuses(); ImmutableSet<GracePeriodStatus> gracePeriodStatuses = domain.getGracePeriodStatuses();

View file

@ -51,9 +51,9 @@ import google.registry.flows.custom.EntityChanges;
import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.OneTime; import google.registry.model.billing.BillingEvent.OneTime;
import google.registry.model.billing.BillingEvent.Reason; 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.DomainCommand.Renew;
import google.registry.model.domain.DomainRenewData; import google.registry.model.domain.DomainRenewData;
import google.registry.model.domain.DomainResource;
import google.registry.model.domain.GracePeriod; import google.registry.model.domain.GracePeriod;
import google.registry.model.domain.Period; import google.registry.model.domain.Period;
import google.registry.model.domain.fee.BaseFee.FeeType; import google.registry.model.domain.fee.BaseFee.FeeType;
@ -139,7 +139,7 @@ public final class DomainRenewFlow implements TransactionalFlow {
DateTime now = ofy().getTransactionTime(); DateTime now = ofy().getTransactionTime();
Renew command = (Renew) resourceCommand; Renew command = (Renew) resourceCommand;
// Loads the target resource if it exists // 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); verifyRenewAllowed(authInfo, existingDomain, command);
int years = command.getPeriod().getValue(); int years = command.getPeriod().getValue();
DateTime newExpirationTime = DateTime newExpirationTime =
@ -174,7 +174,7 @@ public final class DomainRenewFlow implements TransactionalFlow {
.build(); .build();
// End the old autorenew billing event and poll message now. This may delete the poll message. // End the old autorenew billing event and poll message now. This may delete the poll message.
updateAutorenewRecurrenceEndTime(existingDomain, now); updateAutorenewRecurrenceEndTime(existingDomain, now);
DomainResource newDomain = DomainBase newDomain =
existingDomain existingDomain
.asBuilder() .asBuilder()
.setLastEppUpdateTime(now) .setLastEppUpdateTime(now)
@ -220,7 +220,7 @@ public final class DomainRenewFlow implements TransactionalFlow {
} }
private HistoryEntry buildHistoryEntry( private HistoryEntry buildHistoryEntry(
DomainResource existingDomain, DateTime now, Period period, Duration renewGracePeriod) { DomainBase existingDomain, DateTime now, Period period, Duration renewGracePeriod) {
return historyBuilder return historyBuilder
.setType(HistoryEntry.Type.DOMAIN_RENEW) .setType(HistoryEntry.Type.DOMAIN_RENEW)
.setPeriod(period) .setPeriod(period)
@ -238,7 +238,7 @@ public final class DomainRenewFlow implements TransactionalFlow {
private void verifyRenewAllowed( private void verifyRenewAllowed(
Optional<AuthInfo> authInfo, Optional<AuthInfo> authInfo,
DomainResource existingDomain, DomainBase existingDomain,
Renew command) throws EppException { Renew command) throws EppException {
verifyOptionalAuthInfo(authInfo, existingDomain); verifyOptionalAuthInfo(authInfo, existingDomain);
verifyNoDisallowedStatuses(existingDomain, RENEW_DISALLOWED_STATUSES); verifyNoDisallowedStatuses(existingDomain, RENEW_DISALLOWED_STATUSES);

View file

@ -48,8 +48,8 @@ import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.OneTime; import google.registry.model.billing.BillingEvent.OneTime;
import google.registry.model.billing.BillingEvent.OneTime.Builder; import google.registry.model.billing.BillingEvent.OneTime.Builder;
import google.registry.model.billing.BillingEvent.Reason; 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;
import google.registry.model.domain.DomainResource;
import google.registry.model.domain.fee.BaseFee.FeeType; import google.registry.model.domain.fee.BaseFee.FeeType;
import google.registry.model.domain.fee.Fee; import google.registry.model.domain.fee.Fee;
import google.registry.model.domain.fee.FeeTransformResponseExtension; import google.registry.model.domain.fee.FeeTransformResponseExtension;
@ -134,7 +134,7 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow {
verifyRegistrarIsActive(clientId); verifyRegistrarIsActive(clientId);
Update command = (Update) resourceCommand; Update command = (Update) resourceCommand;
DateTime now = ofy().getTransactionTime(); DateTime now = ofy().getTransactionTime();
DomainResource existingDomain = loadAndVerifyExistence(DomainResource.class, targetId, now); DomainBase existingDomain = loadAndVerifyExistence(DomainBase.class, targetId, now);
FeesAndCredits feesAndCredits = FeesAndCredits feesAndCredits =
pricingLogic.getRestorePrice(Registry.get(existingDomain.getTld()), targetId, now); pricingLogic.getRestorePrice(Registry.get(existingDomain.getTld()), targetId, now);
Optional<FeeUpdateCommandExtension> feeUpdate = Optional<FeeUpdateCommandExtension> feeUpdate =
@ -160,7 +160,7 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow {
.setAutorenewEndTime(END_OF_TIME) .setAutorenewEndTime(END_OF_TIME)
.setParent(historyEntry) .setParent(historyEntry)
.build(); .build();
DomainResource newDomain = DomainBase newDomain =
performRestore( performRestore(
existingDomain, newExpirationTime, autorenewEvent, autorenewPollMessage, now, clientId); existingDomain, newExpirationTime, autorenewEvent, autorenewPollMessage, now, clientId);
updateForeignKeyIndexDeletionTime(newDomain); updateForeignKeyIndexDeletionTime(newDomain);
@ -175,7 +175,7 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow {
.build(); .build();
} }
private HistoryEntry buildHistoryEntry(DomainResource existingDomain, DateTime now) { private HistoryEntry buildHistoryEntry(DomainBase existingDomain, DateTime now) {
return historyBuilder return historyBuilder
.setType(HistoryEntry.Type.DOMAIN_RESTORE) .setType(HistoryEntry.Type.DOMAIN_RESTORE)
.setModificationTime(now) .setModificationTime(now)
@ -189,7 +189,7 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow {
private void verifyRestoreAllowed( private void verifyRestoreAllowed(
Update command, Update command,
DomainResource existingDomain, DomainBase existingDomain,
Optional<FeeUpdateCommandExtension> feeUpdate, Optional<FeeUpdateCommandExtension> feeUpdate,
FeesAndCredits feesAndCredits, FeesAndCredits feesAndCredits,
DateTime now) throws EppException { DateTime now) throws EppException {
@ -223,8 +223,8 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow {
return ImmutableSet.of(restoreEvent, renewEvent); return ImmutableSet.of(restoreEvent, renewEvent);
} }
private static DomainResource performRestore( private static DomainBase performRestore(
DomainResource existingDomain, DomainBase existingDomain,
DateTime newExpirationTime, DateTime newExpirationTime,
BillingEvent.Recurring autorenewEvent, BillingEvent.Recurring autorenewEvent,
PollMessage.Autorenew autorenewPollMessage, PollMessage.Autorenew autorenewPollMessage,

View file

@ -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.createGainingTransferPollMessage;
import static google.registry.flows.domain.DomainTransferUtils.createTransferResponse; import static google.registry.flows.domain.DomainTransferUtils.createTransferResponse;
import static google.registry.model.ResourceTransferUtils.approvePendingTransfer; 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.ofy.ObjectifyService.ofy;
import static google.registry.model.reporting.DomainTransactionRecord.TransactionReportField.TRANSFER_SUCCESSFUL; import static google.registry.model.reporting.DomainTransactionRecord.TransactionReportField.TRANSFER_SUCCESSFUL;
import static google.registry.pricing.PricingEngineProxy.getDomainRenewCost; 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;
import google.registry.model.billing.BillingEvent.Flag; import google.registry.model.billing.BillingEvent.Flag;
import google.registry.model.billing.BillingEvent.Reason; 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.GracePeriod;
import google.registry.model.domain.metadata.MetadataExtension; import google.registry.model.domain.metadata.MetadataExtension;
import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.domain.rgp.GracePeriodStatus;
@ -95,7 +95,7 @@ public final class DomainTransferApproveFlow implements TransactionalFlow {
/** /**
* <p>The logic in this flow, which handles client approvals, very closely parallels the logic in * <p>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 @Override
public final EppResponse run() throws EppException { public final EppResponse run() throws EppException {
@ -103,7 +103,7 @@ public final class DomainTransferApproveFlow implements TransactionalFlow {
extensionManager.validate(); extensionManager.validate();
validateClientIsLoggedIn(clientId); validateClientIsLoggedIn(clientId);
DateTime now = ofy().getTransactionTime(); DateTime now = ofy().getTransactionTime();
DomainResource existingDomain = loadAndVerifyExistence(DomainResource.class, targetId, now); DomainBase existingDomain = loadAndVerifyExistence(DomainBase.class, targetId, now);
verifyOptionalAuthInfo(authInfo, existingDomain); verifyOptionalAuthInfo(authInfo, existingDomain);
verifyHasPendingTransfer(existingDomain); verifyHasPendingTransfer(existingDomain);
verifyResourceOwnership(clientId, existingDomain); verifyResourceOwnership(clientId, existingDomain);
@ -173,9 +173,9 @@ public final class DomainTransferApproveFlow implements TransactionalFlow {
.setParent(historyEntry) .setParent(historyEntry)
.build(); .build();
// Construct the post-transfer domain. // Construct the post-transfer domain.
DomainResource partiallyApprovedDomain = DomainBase partiallyApprovedDomain =
approvePendingTransfer(existingDomain, TransferStatus.CLIENT_APPROVED, now); approvePendingTransfer(existingDomain, TransferStatus.CLIENT_APPROVED, now);
DomainResource newDomain = DomainBase newDomain =
partiallyApprovedDomain partiallyApprovedDomain
.asBuilder() .asBuilder()
// Update the transferredRegistrationExpirationTime here since approvePendingTransfer() // Update the transferredRegistrationExpirationTime here since approvePendingTransfer()
@ -223,7 +223,7 @@ public final class DomainTransferApproveFlow implements TransactionalFlow {
} }
private HistoryEntry buildHistoryEntry( private HistoryEntry buildHistoryEntry(
DomainResource existingDomain, Registry registry, DateTime now, String gainingClientId) { DomainBase existingDomain, Registry registry, DateTime now, String gainingClientId) {
ImmutableSet<DomainTransactionRecord> cancelingRecords = ImmutableSet<DomainTransactionRecord> cancelingRecords =
createCancelingRecords( createCancelingRecords(
existingDomain, existingDomain,

View file

@ -39,7 +39,7 @@ import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.TransactionalFlow; import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec; import google.registry.flows.annotations.ReportingSpec;
import google.registry.model.ImmutableObject; 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.domain.metadata.MetadataExtension;
import google.registry.model.eppcommon.AuthInfo; import google.registry.model.eppcommon.AuthInfo;
import google.registry.model.eppoutput.EppResponse; import google.registry.model.eppoutput.EppResponse;
@ -88,7 +88,7 @@ public final class DomainTransferCancelFlow implements TransactionalFlow {
extensionManager.validate(); extensionManager.validate();
validateClientIsLoggedIn(clientId); validateClientIsLoggedIn(clientId);
DateTime now = ofy().getTransactionTime(); DateTime now = ofy().getTransactionTime();
DomainResource existingDomain = loadAndVerifyExistence(DomainResource.class, targetId, now); DomainBase existingDomain = loadAndVerifyExistence(DomainBase.class, targetId, now);
verifyOptionalAuthInfo(authInfo, existingDomain); verifyOptionalAuthInfo(authInfo, existingDomain);
verifyHasPendingTransfer(existingDomain); verifyHasPendingTransfer(existingDomain);
verifyTransferInitiator(clientId, existingDomain); verifyTransferInitiator(clientId, existingDomain);
@ -97,7 +97,7 @@ public final class DomainTransferCancelFlow implements TransactionalFlow {
} }
Registry registry = Registry.get(existingDomain.getTld()); Registry registry = Registry.get(existingDomain.getTld());
HistoryEntry historyEntry = buildHistoryEntry(existingDomain, registry, now); HistoryEntry historyEntry = buildHistoryEntry(existingDomain, registry, now);
DomainResource newDomain = DomainBase newDomain =
denyPendingTransfer(existingDomain, TransferStatus.CLIENT_CANCELLED, now, clientId); denyPendingTransfer(existingDomain, TransferStatus.CLIENT_CANCELLED, now, clientId);
ofy().save().<ImmutableObject>entities( ofy().save().<ImmutableObject>entities(
newDomain, newDomain,
@ -116,7 +116,7 @@ public final class DomainTransferCancelFlow implements TransactionalFlow {
} }
private HistoryEntry buildHistoryEntry( private HistoryEntry buildHistoryEntry(
DomainResource existingDomain, Registry registry, DateTime now) { DomainBase existingDomain, Registry registry, DateTime now) {
ImmutableSet<DomainTransactionRecord> cancelingRecords = ImmutableSet<DomainTransactionRecord> cancelingRecords =
createCancelingRecords( createCancelingRecords(
existingDomain, existingDomain,

View file

@ -18,7 +18,7 @@ import static google.registry.flows.FlowUtils.validateClientIsLoggedIn;
import static google.registry.flows.ResourceFlowUtils.loadAndVerifyExistence; import static google.registry.flows.ResourceFlowUtils.loadAndVerifyExistence;
import static google.registry.flows.ResourceFlowUtils.verifyOptionalAuthInfo; import static google.registry.flows.ResourceFlowUtils.verifyOptionalAuthInfo;
import static google.registry.flows.domain.DomainTransferUtils.createTransferResponse; 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.EppException;
import google.registry.flows.ExtensionManager; 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.annotations.ReportingSpec;
import google.registry.flows.exceptions.NoTransferHistoryToQueryException; import google.registry.flows.exceptions.NoTransferHistoryToQueryException;
import google.registry.flows.exceptions.NotAuthorizedToViewTransferException; 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.eppcommon.AuthInfo;
import google.registry.model.eppoutput.EppResponse; import google.registry.model.eppoutput.EppResponse;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; 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. extensionManager.validate(); // There are no legal extensions for this flow.
validateClientIsLoggedIn(clientId); validateClientIsLoggedIn(clientId);
DateTime now = clock.nowUtc(); DateTime now = clock.nowUtc();
DomainResource domain = loadAndVerifyExistence(DomainResource.class, targetId, now); DomainBase domain = loadAndVerifyExistence(DomainBase.class, targetId, now);
verifyOptionalAuthInfo(authInfo, domain); verifyOptionalAuthInfo(authInfo, domain);
// Most of the fields on the transfer response are required, so there's no way to return valid // 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). // XML if the object has never been transferred (and hence the fields aren't populated).

View file

@ -41,7 +41,7 @@ import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.TransactionalFlow; import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec; import google.registry.flows.annotations.ReportingSpec;
import google.registry.model.ImmutableObject; 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.domain.metadata.MetadataExtension;
import google.registry.model.eppcommon.AuthInfo; import google.registry.model.eppcommon.AuthInfo;
import google.registry.model.eppoutput.EppResponse; import google.registry.model.eppoutput.EppResponse;
@ -90,7 +90,7 @@ public final class DomainTransferRejectFlow implements TransactionalFlow {
extensionManager.validate(); extensionManager.validate();
validateClientIsLoggedIn(clientId); validateClientIsLoggedIn(clientId);
DateTime now = ofy().getTransactionTime(); DateTime now = ofy().getTransactionTime();
DomainResource existingDomain = loadAndVerifyExistence(DomainResource.class, targetId, now); DomainBase existingDomain = loadAndVerifyExistence(DomainBase.class, targetId, now);
Registry registry = Registry.get(existingDomain.getTld()); Registry registry = Registry.get(existingDomain.getTld());
HistoryEntry historyEntry = buildHistoryEntry(existingDomain, registry, now); HistoryEntry historyEntry = buildHistoryEntry(existingDomain, registry, now);
verifyOptionalAuthInfo(authInfo, existingDomain); verifyOptionalAuthInfo(authInfo, existingDomain);
@ -99,7 +99,7 @@ public final class DomainTransferRejectFlow implements TransactionalFlow {
if (!isSuperuser) { if (!isSuperuser) {
checkAllowedAccessToTld(clientId, existingDomain.getTld()); checkAllowedAccessToTld(clientId, existingDomain.getTld());
} }
DomainResource newDomain = DomainBase newDomain =
denyPendingTransfer(existingDomain, TransferStatus.CLIENT_REJECTED, now, clientId); denyPendingTransfer(existingDomain, TransferStatus.CLIENT_REJECTED, now, clientId);
ofy().save().<ImmutableObject>entities( ofy().save().<ImmutableObject>entities(
newDomain, newDomain,
@ -118,7 +118,7 @@ public final class DomainTransferRejectFlow implements TransactionalFlow {
} }
private HistoryEntry buildHistoryEntry( private HistoryEntry buildHistoryEntry(
DomainResource existingDomain, Registry registry, DateTime now) { DomainBase existingDomain, Registry registry, DateTime now) {
ImmutableSet<DomainTransactionRecord> cancelingRecords = ImmutableSet<DomainTransactionRecord> cancelingRecords =
createCancelingRecords( createCancelingRecords(
existingDomain, existingDomain,

View file

@ -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.createPendingTransferData;
import static google.registry.flows.domain.DomainTransferUtils.createTransferResponse; import static google.registry.flows.domain.DomainTransferUtils.createTransferResponse;
import static google.registry.flows.domain.DomainTransferUtils.createTransferServerApproveEntities; 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.eppoutput.Result.Code.SUCCESS_WITH_ACTION_PENDING;
import static google.registry.model.ofy.ObjectifyService.ofy; 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.ObjectAlreadySponsoredException;
import google.registry.flows.exceptions.TransferPeriodMustBeOneYearException; import google.registry.flows.exceptions.TransferPeriodMustBeOneYearException;
import google.registry.flows.exceptions.TransferPeriodZeroAndFeeTransferExtensionException; import google.registry.flows.exceptions.TransferPeriodZeroAndFeeTransferExtensionException;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.DomainCommand.Transfer; import google.registry.model.domain.DomainCommand.Transfer;
import google.registry.model.domain.DomainResource;
import google.registry.model.domain.Period; import google.registry.model.domain.Period;
import google.registry.model.domain.fee.FeeTransferCommandExtension; import google.registry.model.domain.fee.FeeTransferCommandExtension;
import google.registry.model.domain.fee.FeeTransformResponseExtension; import google.registry.model.domain.fee.FeeTransformResponseExtension;
@ -143,7 +143,7 @@ public final class DomainTransferRequestFlow implements TransactionalFlow {
validateClientIsLoggedIn(gainingClientId); validateClientIsLoggedIn(gainingClientId);
verifyRegistrarIsActive(gainingClientId); verifyRegistrarIsActive(gainingClientId);
DateTime now = ofy().getTransactionTime(); DateTime now = ofy().getTransactionTime();
DomainResource existingDomain = loadAndVerifyExistence(DomainResource.class, targetId, now); DomainBase existingDomain = loadAndVerifyExistence(DomainBase.class, targetId, now);
Optional<DomainTransferRequestSuperuserExtension> superuserExtension = Optional<DomainTransferRequestSuperuserExtension> superuserExtension =
eppInput.getSingleExtension(DomainTransferRequestSuperuserExtension.class); eppInput.getSingleExtension(DomainTransferRequestSuperuserExtension.class);
Period period = 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 // 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. // policy documentation for transfers subsuming autorenews within the autorenew grace period.
int extraYears = period.getValue(); int extraYears = period.getValue();
DomainResource domainAtTransferTime = DomainBase domainAtTransferTime =
existingDomain.cloneProjectedAtTime(automaticTransferTime); existingDomain.cloneProjectedAtTime(automaticTransferTime);
if (!domainAtTransferTime.getGracePeriodsOfType(GracePeriodStatus.AUTO_RENEW).isEmpty()) { if (!domainAtTransferTime.getGracePeriodsOfType(GracePeriodStatus.AUTO_RENEW).isEmpty()) {
extraYears = 0; extraYears = 0;
@ -225,7 +225,7 @@ public final class DomainTransferRequestFlow implements TransactionalFlow {
// cloneProjectedAtTime() will replace these old autorenew entities with the server approve ones // cloneProjectedAtTime() will replace these old autorenew entities with the server approve ones
// that we've created in this flow and stored in pendingTransferData. // that we've created in this flow and stored in pendingTransferData.
updateAutorenewRecurrenceEndTime(existingDomain, automaticTransferTime); updateAutorenewRecurrenceEndTime(existingDomain, automaticTransferTime);
DomainResource newDomain = DomainBase newDomain =
existingDomain existingDomain
.asBuilder() .asBuilder()
.setTransferData(pendingTransferData) .setTransferData(pendingTransferData)
@ -248,7 +248,7 @@ public final class DomainTransferRequestFlow implements TransactionalFlow {
} }
private void verifyTransferAllowed( private void verifyTransferAllowed(
DomainResource existingDomain, DomainBase existingDomain,
Period period, Period period,
DateTime now, DateTime now,
Optional<DomainTransferRequestSuperuserExtension> superuserExtension) Optional<DomainTransferRequestSuperuserExtension> superuserExtension)
@ -310,7 +310,7 @@ public final class DomainTransferRequestFlow implements TransactionalFlow {
} }
private HistoryEntry buildHistoryEntry( private HistoryEntry buildHistoryEntry(
DomainResource existingDomain, Registry registry, DateTime now, Period period) { DomainBase existingDomain, Registry registry, DateTime now, Period period) {
return historyBuilder return historyBuilder
.setType(HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST) .setType(HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST)
.setOtherClientId(existingDomain.getCurrentSponsorClientId()) .setOtherClientId(existingDomain.getCurrentSponsorClientId())
@ -329,7 +329,7 @@ public final class DomainTransferRequestFlow implements TransactionalFlow {
} }
private DomainTransferResponse createResponse( 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, // 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 // 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. // approval new expiration time, which is capped at 10 years from the server approve time.

View file

@ -24,7 +24,7 @@ import com.googlecode.objectify.Key;
import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Flag; import google.registry.model.billing.BillingEvent.Flag;
import google.registry.model.billing.BillingEvent.Reason; 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.GracePeriod;
import google.registry.model.domain.Period; import google.registry.model.domain.Period;
import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.domain.rgp.GracePeriodStatus;
@ -106,7 +106,7 @@ public final class DomainTransferUtils {
DateTime automaticTransferTime, DateTime automaticTransferTime,
DateTime serverApproveNewExpirationTime, DateTime serverApproveNewExpirationTime,
HistoryEntry historyEntry, HistoryEntry historyEntry,
DomainResource existingDomain, DomainBase existingDomain,
Trid trid, Trid trid,
String gainingClientId, String gainingClientId,
Optional<Money> transferCost, Optional<Money> transferCost,
@ -258,9 +258,9 @@ public final class DomainTransferUtils {
DateTime automaticTransferTime, DateTime automaticTransferTime,
HistoryEntry historyEntry, HistoryEntry historyEntry,
String targetId, String targetId,
DomainResource existingDomain, DomainBase existingDomain,
Optional<Money> transferCost) { Optional<Money> transferCost) {
DomainResource domainAtTransferTime = DomainBase domainAtTransferTime =
existingDomain.cloneProjectedAtTime(automaticTransferTime); existingDomain.cloneProjectedAtTime(automaticTransferTime);
GracePeriod autorenewGracePeriod = GracePeriod autorenewGracePeriod =
getOnlyElement( getOnlyElement(

View file

@ -62,10 +62,10 @@ import google.registry.flows.domain.DomainFlowUtils.MissingRegistrantException;
import google.registry.model.ImmutableObject; import google.registry.model.ImmutableObject;
import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Reason; 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;
import google.registry.model.domain.DomainCommand.Update.AddRemove; import google.registry.model.domain.DomainCommand.Update.AddRemove;
import google.registry.model.domain.DomainCommand.Update.Change; 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.fee.FeeUpdateCommandExtension;
import google.registry.model.domain.metadata.MetadataExtension; import google.registry.model.domain.metadata.MetadataExtension;
import google.registry.model.domain.secdns.SecDnsUpdateExtension; import google.registry.model.domain.secdns.SecDnsUpdateExtension;
@ -162,12 +162,12 @@ public final class DomainUpdateFlow implements TransactionalFlow {
validateClientIsLoggedIn(clientId); validateClientIsLoggedIn(clientId);
DateTime now = ofy().getTransactionTime(); DateTime now = ofy().getTransactionTime();
Update command = cloneAndLinkReferences((Update) resourceCommand, now); Update command = cloneAndLinkReferences((Update) resourceCommand, now);
DomainResource existingDomain = loadAndVerifyExistence(DomainResource.class, targetId, now); DomainBase existingDomain = loadAndVerifyExistence(DomainBase.class, targetId, now);
verifyUpdateAllowed(command, existingDomain, now); verifyUpdateAllowed(command, existingDomain, now);
flowCustomLogic.afterValidation( flowCustomLogic.afterValidation(
AfterValidationParameters.newBuilder().setExistingDomain(existingDomain).build()); AfterValidationParameters.newBuilder().setExistingDomain(existingDomain).build());
HistoryEntry historyEntry = buildHistoryEntry(existingDomain, now); HistoryEntry historyEntry = buildHistoryEntry(existingDomain, now);
DomainResource newDomain = performUpdate(command, existingDomain, now); DomainBase newDomain = performUpdate(command, existingDomain, now);
validateNewState(newDomain); validateNewState(newDomain);
dnsQueue.addDomainRefreshTask(targetId); dnsQueue.addDomainRefreshTask(targetId);
ImmutableSet.Builder<ImmutableObject> entitiesToSave = new ImmutableSet.Builder<>(); ImmutableSet.Builder<ImmutableObject> entitiesToSave = new ImmutableSet.Builder<>();
@ -189,7 +189,7 @@ public final class DomainUpdateFlow implements TransactionalFlow {
} }
/** Fail if the object doesn't exist or was deleted. */ /** 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 { throws EppException {
verifyOptionalAuthInfo(authInfo, existingDomain); verifyOptionalAuthInfo(authInfo, existingDomain);
AddRemove add = command.getInnerAdd(); AddRemove add = command.getInnerAdd();
@ -225,7 +225,7 @@ public final class DomainUpdateFlow implements TransactionalFlow {
domainName, nullToEmpty(add.getNameserverFullyQualifiedHostNames())); domainName, nullToEmpty(add.getNameserverFullyQualifiedHostNames()));
} }
private HistoryEntry buildHistoryEntry(DomainResource existingDomain, DateTime now) { private HistoryEntry buildHistoryEntry(DomainBase existingDomain, DateTime now) {
return historyBuilder return historyBuilder
.setType(HistoryEntry.Type.DOMAIN_UPDATE) .setType(HistoryEntry.Type.DOMAIN_UPDATE)
.setModificationTime(now) .setModificationTime(now)
@ -233,7 +233,7 @@ public final class DomainUpdateFlow implements TransactionalFlow {
.build(); .build();
} }
private DomainResource performUpdate(Update command, DomainResource domain, DateTime now) private DomainBase performUpdate(Update command, DomainBase domain, DateTime now)
throws EppException { throws EppException {
AddRemove add = command.getInnerAdd(); AddRemove add = command.getInnerAdd();
AddRemove remove = command.getInnerRemove(); AddRemove remove = command.getInnerRemove();
@ -244,7 +244,7 @@ public final class DomainUpdateFlow implements TransactionalFlow {
validateRegistrantIsntBeingRemoved(change); validateRegistrantIsntBeingRemoved(change);
Optional<SecDnsUpdateExtension> secDnsUpdate = Optional<SecDnsUpdateExtension> secDnsUpdate =
eppInput.getSingleExtension(SecDnsUpdateExtension.class); eppInput.getSingleExtension(SecDnsUpdateExtension.class);
DomainResource.Builder domainBuilder = DomainBase.Builder domainBuilder =
domain domain
.asBuilder() .asBuilder()
// Handle the secDNS extension. // 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()); validateNoDuplicateContacts(newDomain.getContacts());
validateRequiredContactsPresent(newDomain.getRegistrant(), newDomain.getContacts()); validateRequiredContactsPresent(newDomain.getRegistrant(), newDomain.getContacts());
validateDsData(newDomain.getDsData()); 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. */ /** Some status updates cost money. Bill only once no matter how many of them are changed. */
private Optional<BillingEvent.OneTime> createBillingEventForStatusUpdates( private Optional<BillingEvent.OneTime> createBillingEventForStatusUpdates(
DomainResource existingDomain, DomainBase existingDomain,
DomainResource newDomain, DomainBase newDomain,
HistoryEntry historyEntry, HistoryEntry historyEntry,
DateTime now) { DateTime now) {
Optional<MetadataExtension> metadataExtension = Optional<MetadataExtension> metadataExtension =

View file

@ -38,7 +38,7 @@ import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.TransactionalFlow; import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec; import google.registry.flows.annotations.ReportingSpec;
import google.registry.model.ImmutableObject; 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.domain.metadata.MetadataExtension;
import google.registry.model.eppinput.ResourceCommand; import google.registry.model.eppinput.ResourceCommand;
import google.registry.model.eppoutput.CreateData.HostCreateData; 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 // 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 // creating an external host. This is looked up before we actually create the Host object so
// we can detect error conditions earlier. // we can detect error conditions earlier.
Optional<DomainResource> superordinateDomain = Optional<DomainBase> superordinateDomain =
lookupSuperordinateDomain(validateHostName(targetId), now); lookupSuperordinateDomain(validateHostName(targetId), now);
verifySuperordinateDomainNotInPendingDelete(superordinateDomain.orElse(null)); verifySuperordinateDomainNotInPendingDelete(superordinateDomain.orElse(null));
verifySuperordinateDomainOwnership(clientId, superordinateDomain.orElse(null)); verifySuperordinateDomainOwnership(clientId, superordinateDomain.orElse(null));

View file

@ -29,7 +29,7 @@ import google.registry.flows.EppException.ParameterValuePolicyErrorException;
import google.registry.flows.EppException.ParameterValueRangeErrorException; import google.registry.flows.EppException.ParameterValueRangeErrorException;
import google.registry.flows.EppException.ParameterValueSyntaxErrorException; import google.registry.flows.EppException.ParameterValueSyntaxErrorException;
import google.registry.flows.EppException.StatusProhibitsOperationException; 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.model.eppcommon.StatusValue;
import google.registry.util.Idn; import google.registry.util.Idn;
import java.util.Optional; 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. */ /** Return the {@link DomainBase} this host is subordinate to, or null for external hosts. */
public static Optional<DomainResource> lookupSuperordinateDomain( public static Optional<DomainBase> lookupSuperordinateDomain(
InternetDomainName hostName, DateTime now) throws EppException { InternetDomainName hostName, DateTime now) throws EppException {
Optional<InternetDomainName> tld = findTldForName(hostName); Optional<InternetDomainName> tld = findTldForName(hostName);
if (!tld.isPresent()) { if (!tld.isPresent()) {
@ -90,8 +90,8 @@ public class HostFlowUtils {
hostName.parts().stream() hostName.parts().stream()
.skip(hostName.parts().size() - (tld.get().parts().size() + 1)) .skip(hostName.parts().size() - (tld.get().parts().size() + 1))
.collect(joining(".")); .collect(joining("."));
Optional<DomainResource> superordinateDomain = Optional<DomainBase> superordinateDomain =
loadByForeignKey(DomainResource.class, domainName, now); loadByForeignKey(DomainBase.class, domainName, now);
if (!superordinateDomain.isPresent() || !isActive(superordinateDomain.get(), now)) { if (!superordinateDomain.isPresent() || !isActive(superordinateDomain.get(), now)) {
throw new SuperordinateDomainDoesNotExistException(domainName); throw new SuperordinateDomainDoesNotExistException(domainName);
} }
@ -101,13 +101,13 @@ public class HostFlowUtils {
/** Superordinate domain for this hostname does not exist. */ /** Superordinate domain for this hostname does not exist. */
static class SuperordinateDomainDoesNotExistException extends ObjectDoesNotExistException { static class SuperordinateDomainDoesNotExistException extends ObjectDoesNotExistException {
public SuperordinateDomainDoesNotExistException(String domainName) { public SuperordinateDomainDoesNotExistException(String domainName) {
super(DomainResource.class, domainName); super(DomainBase.class, domainName);
} }
} }
/** Ensure that the superordinate domain is sponsored by the provided clientId. */ /** Ensure that the superordinate domain is sponsored by the provided clientId. */
static void verifySuperordinateDomainOwnership( static void verifySuperordinateDomainOwnership(
String clientId, DomainResource superordinateDomain) throws EppException { String clientId, DomainBase superordinateDomain) throws EppException {
if (superordinateDomain != null if (superordinateDomain != null
&& !clientId.equals(superordinateDomain.getCurrentSponsorClientId())) { && !clientId.equals(superordinateDomain.getCurrentSponsorClientId())) {
throw new HostDomainNotOwnedException(); throw new HostDomainNotOwnedException();
@ -122,7 +122,7 @@ public class HostFlowUtils {
} }
/** Ensure that the superordinate domain is not in pending delete. */ /** Ensure that the superordinate domain is not in pending delete. */
static void verifySuperordinateDomainNotInPendingDelete(DomainResource superordinateDomain) static void verifySuperordinateDomainNotInPendingDelete(DomainBase superordinateDomain)
throws EppException { throws EppException {
if ((superordinateDomain != null) if ((superordinateDomain != null)
&& superordinateDomain.getStatusValues().contains(StatusValue.PENDING_DELETE)) { && superordinateDomain.getStatusValues().contains(StatusValue.PENDING_DELETE)) {

View file

@ -28,7 +28,7 @@ import google.registry.flows.Flow;
import google.registry.flows.FlowModule.ClientId; import google.registry.flows.FlowModule.ClientId;
import google.registry.flows.FlowModule.TargetId; import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.annotations.ReportingSpec; 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.eppcommon.StatusValue;
import google.registry.model.eppoutput.EppResponse; import google.registry.model.eppoutput.EppResponse;
import google.registry.model.host.HostInfoData; 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 // 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. // there is no superordinate domain, the host's own values for these fields will be correct.
if (host.isSubordinate()) { if (host.isSubordinate()) {
DomainResource superordinateDomain = DomainBase superordinateDomain =
ofy().load().key(host.getSuperordinateDomain()).now().cloneProjectedAtTime(now); ofy().load().key(host.getSuperordinateDomain()).now().cloneProjectedAtTime(now);
hostInfoDataBuilder hostInfoDataBuilder
.setCurrentSponsorClientId(superordinateDomain.getCurrentSponsorClientId()) .setCurrentSponsorClientId(superordinateDomain.getCurrentSponsorClientId())

View file

@ -47,7 +47,7 @@ import google.registry.flows.annotations.ReportingSpec;
import google.registry.flows.exceptions.ResourceHasClientUpdateProhibitedException; import google.registry.flows.exceptions.ResourceHasClientUpdateProhibitedException;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.model.ImmutableObject; 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.domain.metadata.MetadataExtension;
import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.StatusValue;
import google.registry.model.eppinput.ResourceCommand; import google.registry.model.eppinput.ResourceCommand;
@ -135,11 +135,11 @@ public final class HostUpdateFlow implements TransactionalFlow {
boolean isHostRename = suppliedNewHostName != null; boolean isHostRename = suppliedNewHostName != null;
String oldHostName = targetId; String oldHostName = targetId;
String newHostName = firstNonNull(suppliedNewHostName, oldHostName); String newHostName = firstNonNull(suppliedNewHostName, oldHostName);
DomainResource oldSuperordinateDomain = existingHost.isSubordinate() DomainBase oldSuperordinateDomain = existingHost.isSubordinate()
? ofy().load().key(existingHost.getSuperordinateDomain()).now().cloneProjectedAtTime(now) ? ofy().load().key(existingHost.getSuperordinateDomain()).now().cloneProjectedAtTime(now)
: null; : null;
// Note that lookupSuperordinateDomain calls cloneProjectedAtTime on the domain for us. // Note that lookupSuperordinateDomain calls cloneProjectedAtTime on the domain for us.
Optional<DomainResource> newSuperordinateDomain = Optional<DomainBase> newSuperordinateDomain =
lookupSuperordinateDomain(validateHostName(newHostName), now); lookupSuperordinateDomain(validateHostName(newHostName), now);
verifySuperordinateDomainNotInPendingDelete(newSuperordinateDomain.orElse(null)); verifySuperordinateDomainNotInPendingDelete(newSuperordinateDomain.orElse(null));
EppResource owningResource = firstNonNull(oldSuperordinateDomain, existingHost); EppResource owningResource = firstNonNull(oldSuperordinateDomain, existingHost);
@ -152,7 +152,7 @@ public final class HostUpdateFlow implements TransactionalFlow {
AddRemove remove = command.getInnerRemove(); AddRemove remove = command.getInnerRemove();
checkSameValuesNotAddedAndRemoved(add.getStatusValues(), remove.getStatusValues()); checkSameValuesNotAddedAndRemoved(add.getStatusValues(), remove.getStatusValues());
checkSameValuesNotAddedAndRemoved(add.getInetAddresses(), remove.getInetAddresses()); checkSameValuesNotAddedAndRemoved(add.getInetAddresses(), remove.getInetAddresses());
Key<DomainResource> newSuperordinateDomainKey = Key<DomainBase> newSuperordinateDomainKey =
newSuperordinateDomain.map(Key::create).orElse(null); newSuperordinateDomain.map(Key::create).orElse(null);
// If the superordinateDomain field is changing, set the lastSuperordinateChange to now. // If the superordinateDomain field is changing, set the lastSuperordinateChange to now.
DateTime lastSuperordinateChange = DateTime lastSuperordinateChange =
@ -209,7 +209,7 @@ public final class HostUpdateFlow implements TransactionalFlow {
private void verifyUpdateAllowed( private void verifyUpdateAllowed(
Update command, Update command,
HostResource existingHost, HostResource existingHost,
DomainResource newSuperordinateDomain, DomainBase newSuperordinateDomain,
EppResource owningResource, EppResource owningResource,
boolean isHostRename) boolean isHostRename)
throws EppException { throws EppException {

View file

@ -40,7 +40,7 @@ abstract class EppResourceBaseReader<T> extends RetryingInputReader<EppResourceI
* The resource kinds to filter for. * The resource kinds to filter for.
* *
* <p>This can be empty, or any of {"ContactResource", "HostResource", "DomainBase"}. It will * <p>This 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<String> filterKinds; private final ImmutableSet<String> filterKinds;

View file

@ -67,7 +67,7 @@ class EppResourceEntityReader<R extends EppResource> extends EppResourceBaseRead
logger.atSevere().log("EppResourceIndex key %s points at a missing resource", key); logger.atSevere().log("EppResourceIndex key %s points at a missing resource", key);
continue; continue;
} }
// Postfilter to distinguish polymorphic types (e.g. DomainBase and DomainResource). // Postfilter to distinguish polymorphic types (e.g. EppResources).
for (Class<? extends R> resourceClass : resourceClasses) { for (Class<? extends R> resourceClass : resourceClasses) {
if (resourceClass.isAssignableFrom(resource.getClass())) { if (resourceClass.isAssignableFrom(resource.getClass())) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")

View file

@ -16,12 +16,10 @@ package google.registry.mapreduce.inputs;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.collect.Lists.asList; 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.appengine.tools.mapreduce.Input;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.EntitySubclass;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.model.ImmutableObject; import google.registry.model.ImmutableObject;
import google.registry.model.index.EppResourceIndex; import google.registry.model.index.EppResourceIndex;
@ -84,13 +82,8 @@ public final class EppResourceInputs {
*/ */
@SafeVarargs @SafeVarargs
public static <R extends EppResource> Input<Key<R>> createKeyInput( public static <R extends EppResource> Input<Key<R>> createKeyInput(
Class<? extends R> resourceClass, Class<? extends R> resourceClass, Class<? extends R>... moreResourceClasses) {
Class<? extends R>... moreResourceClasses) { return new EppResourceKeyInput<>(
ImmutableSet<Class<? extends R>> resourceClasses = ImmutableSet.copyOf(asList(resourceClass, moreResourceClasses)));
ImmutableSet.copyOf(asList(resourceClass, moreResourceClasses));
checkArgument(
resourceClasses.stream().noneMatch(hasAnnotation(EntitySubclass.class)),
"Mapping over keys requires a non-polymorphic Entity");
return new EppResourceKeyInput<>(resourceClasses);
} }
} }

View file

@ -21,7 +21,6 @@ import google.registry.model.common.EntityGroupRoot;
import google.registry.model.common.GaeUserIdConverter; import google.registry.model.common.GaeUserIdConverter;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.DomainBase;
import google.registry.model.domain.DomainResource;
import google.registry.model.domain.token.AllocationToken; import google.registry.model.domain.token.AllocationToken;
import google.registry.model.host.HostResource; import google.registry.model.host.HostResource;
import google.registry.model.index.EppResourceIndex; import google.registry.model.index.EppResourceIndex;
@ -73,7 +72,6 @@ public final class EntityClasses {
ContactResource.class, ContactResource.class,
Cursor.class, Cursor.class,
DomainBase.class, DomainBase.class,
DomainResource.class,
EntityGroupRoot.class, EntityGroupRoot.class,
EppResourceIndex.class, EppResourceIndex.class,
EppResourceIndexBucket.class, EppResourceIndexBucket.class,

View file

@ -17,7 +17,7 @@ package google.registry.model;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState; 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 static google.registry.model.ofy.ObjectifyService.ofy;
import com.google.common.collect.ImmutableList; 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.ForeignKeyedEppResource;
import google.registry.model.EppResource.ResourceWithTransferData; import google.registry.model.EppResource.ResourceWithTransferData;
import google.registry.model.contact.ContactResource; 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.StatusValue;
import google.registry.model.eppcommon.Trid; import google.registry.model.eppcommon.Trid;
import google.registry.model.index.ForeignKeyIndex; import google.registry.model.index.ForeignKeyIndex;
@ -64,7 +64,7 @@ public final class ResourceTransferUtils {
if (eppResource instanceof ContactResource) { if (eppResource instanceof ContactResource) {
builder = new ContactTransferResponse.Builder().setContactId(eppResource.getForeignKey()); builder = new ContactTransferResponse.Builder().setContactId(eppResource.getForeignKey());
} else { } else {
DomainResource domain = (DomainResource) eppResource; DomainBase domain = (DomainBase) eppResource;
builder = builder =
new DomainTransferResponse.Builder() new DomainTransferResponse.Builder()
.setFullyQualifiedDomainName(eppResource.getForeignKey()) .setFullyQualifiedDomainName(eppResource.getForeignKey())
@ -102,7 +102,7 @@ public final class ResourceTransferUtils {
} }
private static void assertIsContactOrDomain(EppResource eppResource) { 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. */ /** Update the relevant {@link ForeignKeyIndex} to cache the new deletion time. */

View file

@ -193,7 +193,7 @@ public class ContactResource extends EppResource implements
/** A builder for constructing {@link ContactResource}, since it is immutable. */ /** A builder for constructing {@link ContactResource}, since it is immutable. */
public static class Builder extends EppResource.Builder<ContactResource, Builder> public static class Builder extends EppResource.Builder<ContactResource, Builder>
implements BuilderWithTransferData<Builder>{ implements BuilderWithTransferData<Builder> {
public Builder() {} public Builder() {}

View file

@ -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.ImmutableSet.toImmutableSet;
import static com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet; import static com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet;
import static com.google.common.collect.Sets.difference; import static com.google.common.collect.Sets.difference;
import static com.google.common.collect.Sets.intersection;
import static com.google.common.collect.Sets.union; 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.model.ofy.ObjectifyService.ofy;
import static google.registry.util.CollectionUtils.forceEmptyToNull; import static google.registry.util.CollectionUtils.forceEmptyToNull;
import static google.registry.util.CollectionUtils.nullToEmpty; import static google.registry.util.CollectionUtils.nullToEmpty;
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy; import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
import static google.registry.util.CollectionUtils.nullToEmptyImmutableSortedCopy; import static google.registry.util.CollectionUtils.nullToEmptyImmutableSortedCopy;
import static google.registry.util.CollectionUtils.union; 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.canonicalizeDomainName;
import static google.registry.util.DomainNameUtils.getTldFromDomainName; import static google.registry.util.DomainNameUtils.getTldFromDomainName;
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull; import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
@ -40,21 +46,57 @@ import com.googlecode.objectify.annotation.IgnoreSave;
import com.googlecode.objectify.annotation.Index; import com.googlecode.objectify.annotation.Index;
import com.googlecode.objectify.condition.IfNull; import com.googlecode.objectify.condition.IfNull;
import google.registry.model.EppResource; 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.annotations.ReportedOn;
import google.registry.model.billing.BillingEvent;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DesignatedContact.Type; import google.registry.model.domain.DesignatedContact.Type;
import google.registry.model.domain.launch.LaunchNotice; 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.domain.secdns.DelegationSignerData;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource; 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.Objects;
import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.function.Predicate; 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.
*
* <p>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 <a href="https://tools.ietf.org/html/rfc5731">RFC 5731</a>
*/
@ReportedOn @ReportedOn
@Entity @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<StatusValue> 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. * 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) @IgnoreSave(IfNull.class)
String idnTableName; String idnTableName;
/** Fully qualified host names of this domain's active subordinate hosts. */
Set<String> subordinateHosts;
/** When this domain's registration will expire. */
DateTime registrationExpirationTime;
/**
* The poll message associated with this domain being deleted.
*
* <p>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<PollMessage.OneTime> deletePollMessage;
/**
* The recurring billing event associated with this domain's autorenewals.
*
* <p>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<BillingEvent.Recurring> autorenewBillingEvent;
/**
* The recurring poll message associated with this domain's autorenewals.
*
* <p>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<PollMessage.Autorenew> autorenewPollMessage;
/** The unexpired grace periods for this domain (some of which may not be active yet). */
Set<GracePeriod> gracePeriods;
/**
* The id of the signed mark that was used to create this domain in sunrise.
*
* <p>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.
*
* <p>Can be null if the resource has never been transferred.
*/
DateTime lastTransferTime;
public ImmutableSet<String> getSubordinateHosts() {
return nullToEmptyImmutableCopy(subordinateHosts);
}
public DateTime getRegistrationExpirationTime() {
return registrationExpirationTime;
}
public Key<PollMessage.OneTime> getDeletePollMessage() {
return deletePollMessage;
}
public Key<BillingEvent.Recurring> getAutorenewBillingEvent() {
return autorenewBillingEvent;
}
public Key<PollMessage.Autorenew> getAutorenewPollMessage() {
return autorenewPollMessage;
}
public ImmutableSet<GracePeriod> 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() { public String getFullyQualifiedDomainName() {
return fullyQualifiedDomainName; return fullyQualifiedDomainName;
} }
@ -133,6 +274,174 @@ public abstract class DomainBase extends EppResource {
return getPersistedCurrentSponsorClientId(); 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.
*
* <p>This collects all statuses from the domain's {@link GracePeriod} entries and also adds the
* PENDING_DELETE status if needed.
*/
public ImmutableSet<GracePeriodStatus> getGracePeriodStatuses() {
Set<GracePeriodStatus> 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<GracePeriod> getGracePeriodsOfType(GracePeriodStatus gracePeriodType) {
ImmutableSet.Builder<GracePeriod> 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<DateTime> 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. */ /** Loads and returns the fully qualified host names of all linked nameservers. */
public ImmutableSortedSet<String> loadNameserverFullyQualifiedHostNames() { public ImmutableSortedSet<String> loadNameserverFullyQualifiedHostNames() {
return ofy() return ofy()
@ -185,21 +494,34 @@ public abstract class DomainBase extends EppResource {
/** An override of {@link EppResource#asBuilder} with tighter typing. */ /** An override of {@link EppResource#asBuilder} with tighter typing. */
@Override @Override
public abstract Builder<?, ?> asBuilder(); public Builder asBuilder() {
return new Builder(clone(this));
}
/** A builder for constructing {@link DomainBase}, since it is immutable. */ /** A builder for constructing {@link DomainBase}, since it is immutable. */
public abstract static class Builder<T extends DomainBase, B extends Builder<?, ?>> public static class Builder extends EppResource.Builder<DomainBase, Builder>
extends EppResource.Builder<T, B> { implements BuilderWithTransferData<Builder> {
protected Builder() {} public Builder() {}
protected Builder(T instance) { Builder(DomainBase instance) {
super(instance); super(instance);
} }
@Override @Override
public T build() { public DomainBase build() {
T instance = getInstance(); 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( checkArgumentNotNull(
emptyToNull(instance.fullyQualifiedDomainName), "Missing fullyQualifiedDomainName"); emptyToNull(instance.fullyQualifiedDomainName), "Missing fullyQualifiedDomainName");
checkArgument(instance.allContacts.stream().anyMatch(IS_REGISTRANT), "Missing registrant"); checkArgument(instance.allContacts.stream().anyMatch(IS_REGISTRANT), "Missing registrant");
@ -207,7 +529,7 @@ public abstract class DomainBase extends EppResource {
return super.build(); return super.build();
} }
public B setFullyQualifiedDomainName(String fullyQualifiedDomainName) { public Builder setFullyQualifiedDomainName(String fullyQualifiedDomainName) {
checkArgument( checkArgument(
fullyQualifiedDomainName.equals(canonicalizeDomainName(fullyQualifiedDomainName)), fullyQualifiedDomainName.equals(canonicalizeDomainName(fullyQualifiedDomainName)),
"Domain name must be in puny-coded, lower-case form"); "Domain name must be in puny-coded, lower-case form");
@ -215,12 +537,12 @@ public abstract class DomainBase extends EppResource {
return thisCastToDerived(); return thisCastToDerived();
} }
public B setDsData(ImmutableSet<DelegationSignerData> dsData) { public Builder setDsData(ImmutableSet<DelegationSignerData> dsData) {
getInstance().dsData = dsData; getInstance().dsData = dsData;
return thisCastToDerived(); return thisCastToDerived();
} }
public B setRegistrant(Key<ContactResource> registrant) { public Builder setRegistrant(Key<ContactResource> registrant) {
// Replace the registrant contact inside allContacts. // Replace the registrant contact inside allContacts.
getInstance().allContacts = union( getInstance().allContacts = union(
getInstance().getContacts(), getInstance().getContacts(),
@ -228,44 +550,44 @@ public abstract class DomainBase extends EppResource {
return thisCastToDerived(); return thisCastToDerived();
} }
public B setAuthInfo(DomainAuthInfo authInfo) { public Builder setAuthInfo(DomainAuthInfo authInfo) {
getInstance().authInfo = authInfo; getInstance().authInfo = authInfo;
return thisCastToDerived(); return thisCastToDerived();
} }
public B setNameservers(Key<HostResource> nameserver) { public Builder setNameservers(Key<HostResource> nameserver) {
getInstance().nsHosts = ImmutableSet.of(nameserver); getInstance().nsHosts = ImmutableSet.of(nameserver);
return thisCastToDerived(); return thisCastToDerived();
} }
public B setNameservers(ImmutableSet<Key<HostResource>> nameservers) { public Builder setNameservers(ImmutableSet<Key<HostResource>> nameservers) {
getInstance().nsHosts = forceEmptyToNull(nameservers); getInstance().nsHosts = forceEmptyToNull(nameservers);
return thisCastToDerived(); return thisCastToDerived();
} }
public B addNameserver(Key<HostResource> nameserver) { public Builder addNameserver(Key<HostResource> nameserver) {
return addNameservers(ImmutableSet.of(nameserver)); return addNameservers(ImmutableSet.of(nameserver));
} }
public B addNameservers(ImmutableSet<Key<HostResource>> nameservers) { public Builder addNameservers(ImmutableSet<Key<HostResource>> nameservers) {
return setNameservers( return setNameservers(
ImmutableSet.copyOf(union(getInstance().getNameservers(), nameservers))); ImmutableSet.copyOf(union(getInstance().getNameservers(), nameservers)));
} }
public B removeNameserver(Key<HostResource> nameserver) { public Builder removeNameserver(Key<HostResource> nameserver) {
return removeNameservers(ImmutableSet.of(nameserver)); return removeNameservers(ImmutableSet.of(nameserver));
} }
public B removeNameservers(ImmutableSet<Key<HostResource>> nameservers) { public Builder removeNameservers(ImmutableSet<Key<HostResource>> nameservers) {
return setNameservers( return setNameservers(
ImmutableSet.copyOf(difference(getInstance().getNameservers(), nameservers))); ImmutableSet.copyOf(difference(getInstance().getNameservers(), nameservers)));
} }
public B setContacts(DesignatedContact contact) { public Builder setContacts(DesignatedContact contact) {
return setContacts(ImmutableSet.of(contact)); return setContacts(ImmutableSet.of(contact));
} }
public B setContacts(ImmutableSet<DesignatedContact> contacts) { public Builder setContacts(ImmutableSet<DesignatedContact> contacts) {
checkArgument(contacts.stream().noneMatch(IS_REGISTRANT), "Registrant cannot be a contact"); checkArgument(contacts.stream().noneMatch(IS_REGISTRANT), "Registrant cannot be a contact");
// Replace the non-registrant contacts inside allContacts. // Replace the non-registrant contacts inside allContacts.
getInstance().allContacts = getInstance().allContacts =
@ -276,22 +598,92 @@ public abstract class DomainBase extends EppResource {
return thisCastToDerived(); return thisCastToDerived();
} }
public B addContacts(ImmutableSet<DesignatedContact> contacts) { public Builder addContacts(ImmutableSet<DesignatedContact> contacts) {
return setContacts(ImmutableSet.copyOf(union(getInstance().getContacts(), contacts))); return setContacts(ImmutableSet.copyOf(union(getInstance().getContacts(), contacts)));
} }
public B removeContacts(ImmutableSet<DesignatedContact> contacts) { public Builder removeContacts(ImmutableSet<DesignatedContact> contacts) {
return setContacts(ImmutableSet.copyOf(difference(getInstance().getContacts(), contacts))); return setContacts(ImmutableSet.copyOf(difference(getInstance().getContacts(), contacts)));
} }
public B setLaunchNotice(LaunchNotice launchNotice) { public Builder setLaunchNotice(LaunchNotice launchNotice) {
getInstance().launchNotice = launchNotice; getInstance().launchNotice = launchNotice;
return thisCastToDerived(); return thisCastToDerived();
} }
public B setIdnTableName(String idnTableName) { public Builder setIdnTableName(String idnTableName) {
getInstance().idnTableName = idnTableName; getInstance().idnTableName = idnTableName;
return thisCastToDerived(); return thisCastToDerived();
} }
public Builder setSubordinateHosts(ImmutableSet<String> 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<PollMessage.OneTime> deletePollMessage) {
getInstance().deletePollMessage = deletePollMessage;
return this;
}
public Builder setAutorenewBillingEvent(
Key<BillingEvent.Recurring> autorenewBillingEvent) {
getInstance().autorenewBillingEvent = autorenewBillingEvent;
return this;
}
public Builder setAutorenewPollMessage(
Key<PollMessage.Autorenew> autorenewPollMessage) {
getInstance().autorenewPollMessage = autorenewPollMessage;
return this;
}
public Builder setSmdId(String smdId) {
getInstance().smdId = smdId;
return this;
}
public Builder setGracePeriods(ImmutableSet<GracePeriod> 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();
}
} }
} }

View file

@ -54,7 +54,7 @@ import javax.xml.bind.annotation.XmlValue;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.joda.time.LocalDate; import org.joda.time.LocalDate;
/** A collection of {@link DomainResource} commands. */ /** A collection of {@link DomainBase} commands. */
public class DomainCommand { public class DomainCommand {
/** The default validity period (if not specified) is 1 year for all operations. */ /** 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"}. */ /** The fields on "chgType" from {@link "http://tools.ietf.org/html/rfc5731"}. */
@XmlTransient @XmlTransient
public static class DomainCreateOrChange<B extends DomainBase.Builder<?, ?>> public static class DomainCreateOrChange<B extends DomainBase.Builder>
extends ImmutableObject implements ResourceCreateOrChange<B> { extends ImmutableObject implements ResourceCreateOrChange<B> {
/** The contactId of the registrant who registered this domain. */ /** The contactId of the registrant who registered this domain. */
@ -112,7 +112,7 @@ public class DomainCommand {
"foreignKeyedDesignatedContacts", "foreignKeyedDesignatedContacts",
"authInfo"}) "authInfo"})
public static class Create public static class Create
extends DomainCreateOrChange<DomainBase.Builder<?, ?>> extends DomainCreateOrChange<DomainBase.Builder>
implements CreateOrUpdate<Create> { implements CreateOrUpdate<Create> {
/** Fully qualified domain name, which serves as a unique identifier for this domain. */ /** 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 @XmlRootElement
public static class Check extends ResourceCheck {} public static class Check extends ResourceCheck {}
/** A renew command for a {@link DomainResource}. */ /** A renew command for a {@link DomainBase}. */
@XmlRootElement @XmlRootElement
public static class Renew extends AbstractSingleResourceCommand { public static class Renew extends AbstractSingleResourceCommand {
@XmlElement(name = "curExpDate") @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 @XmlRootElement
public static class Transfer extends AbstractSingleResourceCommand { public static class Transfer extends AbstractSingleResourceCommand {
/** The period to extend this domain's registration upon completion of the transfer. */ /** The period to extend this domain's registration upon completion of the transfer. */
@ -304,7 +304,7 @@ public class DomainCommand {
@XmlRootElement @XmlRootElement
@XmlType(propOrder = {"targetId", "innerAdd", "innerRemove", "innerChange"}) @XmlType(propOrder = {"targetId", "innerAdd", "innerRemove", "innerChange"})
public static class Update public static class Update
extends ResourceUpdate<Update.AddRemove, DomainBase.Builder<?, ?>, Update.Change> extends ResourceUpdate<Update.AddRemove, DomainBase.Builder, Update.Change>
implements CreateOrUpdate<Update> { implements CreateOrUpdate<Update> {
@XmlElement(name = "chg") @XmlElement(name = "chg")
@ -384,7 +384,7 @@ public class DomainCommand {
/** The inner change type on a domain update command. */ /** The inner change type on a domain update command. */
@XmlType(propOrder = {"registrantContactId", "authInfo"}) @XmlType(propOrder = {"registrantContactId", "authInfo"})
public static class Change extends DomainCreateOrChange<DomainBase.Builder<?, ?>> { public static class Change extends DomainCreateOrChange<DomainBase.Builder> {
/** Creates a copy of this {@link Change} with hard links to hosts and contacts. */ /** Creates a copy of this {@link Change} with hard links to hosts and contacts. */
Change cloneAndLinkReferences(DateTime now) throws InvalidReferencesException { Change cloneAndLinkReferences(DateTime now) throws InvalidReferencesException {
Change clone = clone(this); Change clone = clone(this);

View file

@ -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 <a href="https://tools.ietf.org/html/rfc5731">RFC 5731</a>
*/
@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<StatusValue> 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<String> subordinateHosts;
/** When this domain's registration will expire. */
DateTime registrationExpirationTime;
/**
* The poll message associated with this domain being deleted.
*
* <p>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<PollMessage.OneTime> deletePollMessage;
/**
* The recurring billing event associated with this domain's autorenewals.
*
* <p>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<BillingEvent.Recurring> autorenewBillingEvent;
/**
* The recurring poll message associated with this domain's autorenewals.
*
* <p>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<PollMessage.Autorenew> autorenewPollMessage;
/** The unexpired grace periods for this domain (some of which may not be active yet). */
Set<GracePeriod> gracePeriods;
/**
* The id of the signed mark that was used to create this domain in sunrise.
*
* <p>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.
*
* <p>Can be null if the resource has never been transferred.
*/
DateTime lastTransferTime;
public ImmutableSet<String> getSubordinateHosts() {
return nullToEmptyImmutableCopy(subordinateHosts);
}
public DateTime getRegistrationExpirationTime() {
return registrationExpirationTime;
}
public Key<PollMessage.OneTime> getDeletePollMessage() {
return deletePollMessage;
}
public Key<BillingEvent.Recurring> getAutorenewBillingEvent() {
return autorenewBillingEvent;
}
public Key<PollMessage.Autorenew> getAutorenewPollMessage() {
return autorenewPollMessage;
}
public ImmutableSet<GracePeriod> 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.
*
* <p>This collects all statuses from the domain's {@link GracePeriod} entries and also adds the
* PENDING_DELETE status if needed.
*/
public ImmutableSet<GracePeriodStatus> getGracePeriodStatuses() {
Set<GracePeriodStatus> 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<GracePeriod> getGracePeriodsOfType(GracePeriodStatus gracePeriodType) {
ImmutableSet.Builder<GracePeriod> 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<DateTime> 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<DomainResource, Builder>
implements BuilderWithTransferData<Builder> {
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<String> 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<PollMessage.OneTime> deletePollMessage) {
getInstance().deletePollMessage = deletePollMessage;
return this;
}
public Builder setAutorenewBillingEvent(Key<BillingEvent.Recurring> autorenewBillingEvent) {
getInstance().autorenewBillingEvent = autorenewBillingEvent;
return this;
}
public Builder setAutorenewPollMessage(Key<PollMessage.Autorenew> autorenewPollMessage) {
getInstance().autorenewPollMessage = autorenewPollMessage;
return this;
}
public Builder setSmdId(String smdId) {
getInstance().smdId = smdId;
return this;
}
public Builder setGracePeriods(ImmutableSet<GracePeriod> 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();
}
}
}

View file

@ -28,7 +28,7 @@ import org.joda.time.DateTime;
/** /**
* A domain grace period with an expiration time. * A domain grace period with an expiration time.
* *
* <p>When a grace period expires, it is lazily removed from the {@link DomainResource} the next * <p>When a grace period expires, it is lazily removed from the {@link DomainBase} the next
* time the resource is loaded from Datastore. * time the resource is loaded from Datastore.
*/ */
@Embed @Embed

View file

@ -21,7 +21,7 @@ import static com.google.common.base.Strings.nullToEmpty;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.model.contact.ContactResource; 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.host.HostResource;
import google.registry.model.translators.EnumToAttributeAdapter.EppEnum; import google.registry.model.translators.EnumToAttributeAdapter.EppEnum;
import google.registry.model.translators.StatusValueAdapter; 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. */ /** Enum to help clearly list which resource types a status value is allowed to be present on. */
private enum AllowedOn { private enum AllowedOn {
ALL(ContactResource.class, DomainResource.class, HostResource.class), ALL(ContactResource.class, DomainBase.class, HostResource.class),
NONE, NONE,
DOMAINS(DomainResource.class); DOMAINS(DomainBase.class);
private final ImmutableSet<Class<? extends EppResource>> classes; private final ImmutableSet<Class<? extends EppResource>> classes;

View file

@ -110,8 +110,8 @@ public class EppInput extends ImmutableObject {
return Optional.empty(); return Optional.empty();
} }
/** Returns whether this EppInput represents a command that operates on domain resources. */ /** Returns whether this EppInput represents a command that operates on domains. */
public boolean isDomainResourceType() { public boolean isDomainType() {
return getResourceType().orElse("").equals("domain"); return getResourceType().orElse("").equals("domain");
} }

View file

@ -31,7 +31,7 @@ import google.registry.model.EppResource;
import google.registry.model.EppResource.ForeignKeyedEppResource; import google.registry.model.EppResource.ForeignKeyedEppResource;
import google.registry.model.annotations.ExternalMessagingName; import google.registry.model.annotations.ExternalMessagingName;
import google.registry.model.annotations.ReportedOn; 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 google.registry.model.transfer.TransferData;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.Optional; import java.util.Optional;
@ -70,7 +70,7 @@ public class HostResource extends EppResource implements ForeignKeyedEppResource
@Index @Index
@IgnoreSave(IfNull.class) @IgnoreSave(IfNull.class)
@DoNotHydrate @DoNotHydrate
Key<DomainResource> superordinateDomain; Key<DomainBase> superordinateDomain;
/** /**
* The time that this resource was last transferred. * The time that this resource was last transferred.
@ -92,7 +92,7 @@ public class HostResource extends EppResource implements ForeignKeyedEppResource
return fullyQualifiedHostName; return fullyQualifiedHostName;
} }
public Key<DomainResource> getSuperordinateDomain() { public Key<DomainBase> getSuperordinateDomain() {
return superordinateDomain; 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 * the {@link #superordinateDomain} field. Passing it as a parameter allows the caller to
* control the degree of consistency used to load it. * control the degree of consistency used to load it.
*/ */
public DateTime computeLastTransferTime(@Nullable DomainResource superordinateDomain) { public DateTime computeLastTransferTime(@Nullable DomainBase superordinateDomain) {
if (!isSubordinate()) { if (!isSubordinate()) {
checkArgument(superordinateDomain == null); checkArgument(superordinateDomain == null);
return getLastTransferTime(); return getLastTransferTime();
@ -195,7 +195,7 @@ public class HostResource extends EppResource implements ForeignKeyedEppResource
difference(getInstance().getInetAddresses(), inetAddresses))); difference(getInstance().getInetAddresses(), inetAddresses)));
} }
public Builder setSuperordinateDomain(Key<DomainResource> superordinateDomain) { public Builder setSuperordinateDomain(Key<DomainBase> superordinateDomain) {
getInstance().superordinateDomain = superordinateDomain; getInstance().superordinateDomain = superordinateDomain;
return this; return this;
} }

View file

@ -40,7 +40,7 @@ import google.registry.model.BackupGroupRoot;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.model.annotations.ReportedOn; import google.registry.model.annotations.ReportedOn;
import google.registry.model.contact.ContactResource; 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.host.HostResource;
import google.registry.util.NonFinalForTesting; import google.registry.util.NonFinalForTesting;
import java.util.Map; import java.util.Map;
@ -62,10 +62,10 @@ public abstract class ForeignKeyIndex<E extends EppResource> extends BackupGroup
@Entity @Entity
public static class ForeignKeyContactIndex extends ForeignKeyIndex<ContactResource> {} public static class ForeignKeyContactIndex extends ForeignKeyIndex<ContactResource> {}
/** The {@link ForeignKeyIndex} type for {@link DomainResource} entities. */ /** The {@link ForeignKeyIndex} type for {@link DomainBase} entities. */
@ReportedOn @ReportedOn
@Entity @Entity
public static class ForeignKeyDomainIndex extends ForeignKeyIndex<DomainResource> {} public static class ForeignKeyDomainIndex extends ForeignKeyIndex<DomainBase> {}
/** The {@link ForeignKeyIndex} type for {@link HostResource} entities. */ /** The {@link ForeignKeyIndex} type for {@link HostResource} entities. */
@ReportedOn @ReportedOn
@ -77,7 +77,7 @@ public abstract class ForeignKeyIndex<E extends EppResource> extends BackupGroup
RESOURCE_CLASS_TO_FKI_CLASS = RESOURCE_CLASS_TO_FKI_CLASS =
ImmutableMap.of( ImmutableMap.of(
ContactResource.class, ForeignKeyContactIndex.class, ContactResource.class, ForeignKeyContactIndex.class,
DomainResource.class, ForeignKeyDomainIndex.class, DomainBase.class, ForeignKeyDomainIndex.class,
HostResource.class, ForeignKeyHostIndex.class); HostResource.class, ForeignKeyHostIndex.class);
@Id @Id

View file

@ -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 * This package defines all entities which are managed via EPP XML and persisted to the Datastore
* via Objectify. * via Objectify.
* *
* <p>All first class entities are represented as a "Resource" class - {@link DomainResource}, * <p>All first class entities are represented as a resource class - {@link
* {@link HostResource}, {@link ContactResource}, and {@link RegistrarResource}. Resource objects * google.registry.model.domain.DomainBase}, {@link google.registry.model.host.HostResource}, {@link
* are written in a single shared entity group per TLD. All commands that operate on those entities * google.registry.model.contact.ContactResource}, and {@link
* are grouped in a "Command" class- {@link DomainCommand}, {@link HostCommand}, * google.registry.model.registrar.Registrar}. Resource objects are written in a single shared
* {@link ContactCommand}. The Resource does double duty as both the persisted representation and as * entity group per TLD. All commands that operate on those entities are grouped in a "Command"
* the XML-marshallable object returned in respond to Info commands. * 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.
* *
* <p>Command classes are never persisted, and the Objectify annotations on the Create and Update * <p>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. * classes are purely for the benefit of the derived Resource classes that inherit from them.

View file

@ -22,7 +22,7 @@ import static google.registry.util.DateTimeUtils.START_OF_TIME;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import google.registry.flows.EppException; 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.RdapJsonFormatter.OutputDataType;
import google.registry.rdap.RdapMetrics.EndpointType; import google.registry.rdap.RdapMetrics.EndpointType;
import google.registry.request.Action; import google.registry.request.Action;
@ -75,14 +75,14 @@ public class RdapDomainAction extends RdapActionBase {
pathSearchString, getHumanReadableObjectTypeName(), e.getMessage())); pathSearchString, getHumanReadableObjectTypeName(), e.getMessage()));
} }
// The query string is not used; the RDAP syntax is /rdap/domain/mydomain.com. // The query string is not used; the RDAP syntax is /rdap/domain/mydomain.com.
Optional<DomainResource> domainResource = Optional<DomainBase> domainBase =
loadByForeignKey( loadByForeignKey(
DomainResource.class, pathSearchString, shouldIncludeDeleted() ? START_OF_TIME : now); DomainBase.class, pathSearchString, shouldIncludeDeleted() ? START_OF_TIME : now);
if (!shouldBeVisible(domainResource, now)) { if (!shouldBeVisible(domainBase, now)) {
throw new NotFoundException(pathSearchString + " not found"); throw new NotFoundException(pathSearchString + " not found");
} }
return rdapJsonFormatter.makeRdapJsonForDomain( return rdapJsonFormatter.makeRdapJsonForDomain(
domainResource.get(), domainBase.get(),
true, true,
fullServletPath, fullServletPath,
rdapWhoisServer, rdapWhoisServer,

View file

@ -31,7 +31,7 @@ import com.google.common.net.InetAddresses;
import com.google.common.primitives.Booleans; import com.google.common.primitives.Booleans;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import com.googlecode.objectify.cmd.Query; 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.model.host.HostResource;
import google.registry.rdap.RdapJsonFormatter.BoilerplateType; import google.registry.rdap.RdapJsonFormatter.BoilerplateType;
import google.registry.rdap.RdapJsonFormatter.OutputDataType; import google.registry.rdap.RdapJsonFormatter.OutputDataType;
@ -216,11 +216,11 @@ public class RdapDomainSearchAction extends RdapSearchActionBase {
*/ */
private RdapSearchResults searchByDomainNameWithoutWildcard( private RdapSearchResults searchByDomainNameWithoutWildcard(
final RdapSearchPattern partialStringQuery, final DateTime now) { final RdapSearchPattern partialStringQuery, final DateTime now) {
Optional<DomainResource> domainResource = Optional<DomainBase> domainBase =
loadByForeignKey(DomainResource.class, partialStringQuery.getInitialString(), now); loadByForeignKey(DomainBase.class, partialStringQuery.getInitialString(), now);
return makeSearchResults( return makeSearchResults(
shouldBeVisible(domainResource, now) shouldBeVisible(domainBase, now)
? ImmutableList.of(domainResource.get()) ? ImmutableList.of(domainBase.get())
: ImmutableList.of(), : ImmutableList.of(),
now); 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 // domains directly, rather than the foreign keys, because then we have an index on TLD if we
// need it. // need it.
int querySizeLimit = RESULT_SET_SIZE_SCALING_FACTOR * rdapResultSetMaxSize; int querySizeLimit = RESULT_SET_SIZE_SCALING_FACTOR * rdapResultSetMaxSize;
Query<DomainResource> query = Query<DomainBase> query =
ofy() ofy()
.load() .load()
.type(DomainResource.class) .type(DomainBase.class)
.filter("fullyQualifiedDomainName <", partialStringQuery.getNextInitialString()) .filter("fullyQualifiedDomainName <", partialStringQuery.getNextInitialString())
.filter("fullyQualifiedDomainName >=", partialStringQuery.getInitialString()); .filter("fullyQualifiedDomainName >=", partialStringQuery.getInitialString());
if (cursorString.isPresent()) { if (cursorString.isPresent()) {
@ -262,10 +262,10 @@ public class RdapDomainSearchAction extends RdapSearchActionBase {
// searchByDomainNameWithInitialString, unable to perform an inequality query on deletion time. // searchByDomainNameWithInitialString, unable to perform an inequality query on deletion time.
// Don't use queryItems, because it doesn't handle pending deletes. // Don't use queryItems, because it doesn't handle pending deletes.
int querySizeLimit = RESULT_SET_SIZE_SCALING_FACTOR * rdapResultSetMaxSize; int querySizeLimit = RESULT_SET_SIZE_SCALING_FACTOR * rdapResultSetMaxSize;
Query<DomainResource> query = Query<DomainBase> query =
ofy() ofy()
.load() .load()
.type(DomainResource.class) .type(DomainBase.class)
.filter("tld", tld); .filter("tld", tld);
if (cursorString.isPresent()) { if (cursorString.isPresent()) {
query = query.filter("fullyQualifiedDomainName >", cursorString.get()); 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 // 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 // through the subordinate hosts. This is more efficient, and lets us permit wildcard searches
// with no initial string. // with no initial string.
DomainResource domainResource = DomainBase domainBase =
loadByForeignKey( loadByForeignKey(
DomainResource.class, DomainBase.class,
partialStringQuery.getSuffix(), partialStringQuery.getSuffix(),
shouldIncludeDeleted() ? START_OF_TIME : now) shouldIncludeDeleted() ? START_OF_TIME : now)
.orElseThrow( .orElseThrow(
@ -380,7 +380,7 @@ public class RdapDomainSearchAction extends RdapSearchActionBase {
+ "must be a domain defined in the system")); + "must be a domain defined in the system"));
Optional<String> desiredRegistrar = getDesiredRegistrar(); Optional<String> desiredRegistrar = getDesiredRegistrar();
ImmutableList.Builder<Key<HostResource>> builder = new ImmutableList.Builder<>(); ImmutableList.Builder<Key<HostResource>> 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 // 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. // then the query ns.exam*.example.com would match against nameserver ns.example.com.
if (partialStringQuery.matches(fqhn)) { 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. // 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 // 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 // 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 // and fetch all domains, to make sure that we can return the first domains in alphabetical
// order. // order.
ImmutableSortedSet.Builder<DomainResource> domainSetBuilder = ImmutableSortedSet.Builder<DomainBase> domainSetBuilder =
ImmutableSortedSet.orderedBy( ImmutableSortedSet.orderedBy(
Comparator.comparing(DomainResource::getFullyQualifiedDomainName)); Comparator.comparing(DomainBase::getFullyQualifiedDomainName));
int numHostKeysSearched = 0; int numHostKeysSearched = 0;
for (List<Key<HostResource>> chunk : Iterables.partition(hostKeys, 30)) { for (List<Key<HostResource>> chunk : Iterables.partition(hostKeys, 30)) {
numHostKeysSearched += chunk.size(); numHostKeysSearched += chunk.size();
Query<DomainResource> query = ofy().load() Query<DomainBase> query = ofy().load()
.type(DomainResource.class) .type(DomainBase.class)
.filter("nsHosts in", chunk); .filter("nsHosts in", chunk);
if (!shouldIncludeDeleted()) { if (!shouldIncludeDeleted()) {
query = query.filter("deletionTime >", now); query = query.filter("deletionTime >", now);
@ -470,7 +470,7 @@ public class RdapDomainSearchAction extends RdapSearchActionBase {
} else if (cursorString.isPresent()) { } else if (cursorString.isPresent()) {
query = query.filter("fullyQualifiedDomainName >", cursorString.get()); query = query.filter("fullyQualifiedDomainName >", cursorString.get());
} }
Stream<DomainResource> stream = Stream<DomainBase> stream =
Streams.stream(query).filter(domain -> isAuthorized(domain, now)); Streams.stream(query).filter(domain -> isAuthorized(domain, now));
if (cursorString.isPresent()) { if (cursorString.isPresent()) {
stream = stream =
@ -479,7 +479,7 @@ public class RdapDomainSearchAction extends RdapSearchActionBase {
} }
stream.forEach(domainSetBuilder::add); stream.forEach(domainSetBuilder::add);
} }
List<DomainResource> domains = domainSetBuilder.build().asList(); List<DomainBase> domains = domainSetBuilder.build().asList();
metricInformationBuilder.setNumHostsRetrieved(numHostKeysSearched); metricInformationBuilder.setNumHostsRetrieved(numHostKeysSearched);
if (domains.size() > rdapResultSetMaxSize) { if (domains.size() > rdapResultSetMaxSize) {
return makeSearchResults( return makeSearchResults(
@ -502,14 +502,14 @@ public class RdapDomainSearchAction extends RdapSearchActionBase {
} }
/** Output JSON for a list of domains, with no incompleteness warnings. */ /** Output JSON for a list of domains, with no incompleteness warnings. */
private RdapSearchResults makeSearchResults(List<DomainResource> domains, DateTime now) { private RdapSearchResults makeSearchResults(List<DomainBase> domains, DateTime now) {
return makeSearchResults( return makeSearchResults(
domains, IncompletenessWarningType.COMPLETE, Optional.of((long) domains.size()), now); domains, IncompletenessWarningType.COMPLETE, Optional.of((long) domains.size()), now);
} }
/** Output JSON from data in an {@link RdapResultSet} object. */ /** Output JSON from data in an {@link RdapResultSet} object. */
private RdapSearchResults makeSearchResults( private RdapSearchResults makeSearchResults(
RdapResultSet<DomainResource> resultSet, DateTime now) { RdapResultSet<DomainBase> resultSet, DateTime now) {
return makeSearchResults( return makeSearchResults(
resultSet.resources(), resultSet.resources(),
resultSet.incompletenessWarningType(), resultSet.incompletenessWarningType(),
@ -525,7 +525,7 @@ public class RdapDomainSearchAction extends RdapSearchActionBase {
* maximum number of nameservers in the first stage query. * maximum number of nameservers in the first stage query.
*/ */
private RdapSearchResults makeSearchResults( private RdapSearchResults makeSearchResults(
List<DomainResource> domains, List<DomainBase> domains,
IncompletenessWarningType incompletenessWarningType, IncompletenessWarningType incompletenessWarningType,
Optional<Long> numDomainsRetrieved, Optional<Long> numDomainsRetrieved,
DateTime now) { DateTime now) {
@ -535,7 +535,7 @@ public class RdapDomainSearchAction extends RdapSearchActionBase {
RdapAuthorization authorization = getAuthorization(); RdapAuthorization authorization = getAuthorization();
List<ImmutableMap<String, Object>> jsonList = new ArrayList<>(); List<ImmutableMap<String, Object>> jsonList = new ArrayList<>();
Optional<String> newCursor = Optional.empty(); Optional<String> newCursor = Optional.empty();
for (DomainResource domain : domains) { for (DomainBase domain : domains) {
newCursor = Optional.of(domain.getFullyQualifiedDomainName()); newCursor = Optional.of(domain.getFullyQualifiedDomainName());
jsonList.add( jsonList.add(
rdapJsonFormatter.makeRdapJsonForDomain( rdapJsonFormatter.makeRdapJsonForDomain(

View file

@ -39,7 +39,7 @@ import google.registry.model.contact.ContactResource;
import google.registry.model.contact.PostalInfo; import google.registry.model.contact.PostalInfo;
import google.registry.model.domain.DesignatedContact; import google.registry.model.domain.DesignatedContact;
import google.registry.model.domain.DesignatedContact.Type; 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.Address;
import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource; 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 isTopLevel if true, the top-level boilerplate will be added
* @param linkBase the URL base to be used when creating links * @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 * @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 * registrar owning the domain, no contact information is included
*/ */
ImmutableMap<String, Object> makeRdapJsonForDomain( ImmutableMap<String, Object> makeRdapJsonForDomain(
DomainResource domainResource, DomainBase domainBase,
boolean isTopLevel, boolean isTopLevel,
@Nullable String linkBase, @Nullable String linkBase,
@Nullable String whoisServer, @Nullable String whoisServer,
@ -478,22 +478,22 @@ public class RdapJsonFormatter {
// Start with the domain-level information. // Start with the domain-level information.
ImmutableMap.Builder<String, Object> jsonBuilder = new ImmutableMap.Builder<>(); ImmutableMap.Builder<String, Object> jsonBuilder = new ImmutableMap.Builder<>();
jsonBuilder.put("objectClassName", "domain"); jsonBuilder.put("objectClassName", "domain");
jsonBuilder.put("handle", domainResource.getRepoId()); jsonBuilder.put("handle", domainBase.getRepoId());
jsonBuilder.put("ldhName", domainResource.getFullyQualifiedDomainName()); jsonBuilder.put("ldhName", domainBase.getFullyQualifiedDomainName());
// Only include the unicodeName field if there are unicode characters. // Only include the unicodeName field if there are unicode characters.
if (hasUnicodeComponents(domainResource.getFullyQualifiedDomainName())) { if (hasUnicodeComponents(domainBase.getFullyQualifiedDomainName())) {
jsonBuilder.put("unicodeName", Idn.toUnicode(domainResource.getFullyQualifiedDomainName())); jsonBuilder.put("unicodeName", Idn.toUnicode(domainBase.getFullyQualifiedDomainName()));
} }
jsonBuilder.put( jsonBuilder.put(
"status", "status",
makeStatusValueList( makeStatusValueList(
domainResource.getStatusValues(), domainBase.getStatusValues(),
false, // isRedacted false, // isRedacted
domainResource.getDeletionTime().isBefore(now))); domainBase.getDeletionTime().isBefore(now)));
jsonBuilder.put("links", ImmutableList.of( jsonBuilder.put("links", ImmutableList.of(
makeLink("domain", domainResource.getFullyQualifiedDomainName(), linkBase))); makeLink("domain", domainBase.getFullyQualifiedDomainName(), linkBase)));
boolean displayContacts = 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, // 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 // contacts and events (history entries). If we are outputting summary data, instead add a
// remark indicating that fact. // remark indicating that fact.
@ -504,26 +504,26 @@ public class RdapJsonFormatter {
remarks = displayContacts remarks = displayContacts
? ImmutableList.of() ? ImmutableList.of()
: ImmutableList.of(RdapIcannStandardInformation.DOMAIN_CONTACTS_HIDDEN_DATA_REMARK); : ImmutableList.of(RdapIcannStandardInformation.DOMAIN_CONTACTS_HIDDEN_DATA_REMARK);
ImmutableList<Object> events = makeEvents(domainResource, now); ImmutableList<Object> events = makeEvents(domainBase, now);
if (!events.isEmpty()) { if (!events.isEmpty()) {
jsonBuilder.put("events", events); jsonBuilder.put("events", events);
} }
// Kick off the database loads of the nameservers that we will need, so it can load // Kick off the database loads of the nameservers that we will need, so it can load
// asynchronously while we load and process the contacts. // asynchronously while we load and process the contacts.
Map<Key<HostResource>, HostResource> loadedHosts = Map<Key<HostResource>, HostResource> loadedHosts =
ofy().load().keys(domainResource.getNameservers()); ofy().load().keys(domainBase.getNameservers());
// Load the registrant and other contacts and add them to the data. // Load the registrant and other contacts and add them to the data.
ImmutableList<ImmutableMap<String, Object>> entities; ImmutableList<ImmutableMap<String, Object>> entities;
if (!displayContacts) { if (!displayContacts) {
entities = ImmutableList.of(); entities = ImmutableList.of();
} else { } else {
Map<Key<ContactResource>, ContactResource> loadedContacts = Map<Key<ContactResource>, ContactResource> loadedContacts =
ofy().load().keys(domainResource.getReferencedContacts()); ofy().load().keys(domainBase.getReferencedContacts());
entities = entities =
Streams.concat( Streams.concat(
domainResource.getContacts().stream(), domainBase.getContacts().stream(),
Stream.of( Stream.of(
DesignatedContact.create(Type.REGISTRANT, domainResource.getRegistrant()))) DesignatedContact.create(Type.REGISTRANT, domainBase.getRegistrant())))
.sorted(DESIGNATED_CONTACT_ORDERING) .sorted(DESIGNATED_CONTACT_ORDERING)
.map( .map(
designatedContact -> designatedContact ->
@ -540,7 +540,7 @@ public class RdapJsonFormatter {
} }
entities = entities =
addRegistrarEntity( addRegistrarEntity(
entities, domainResource.getCurrentSponsorClientId(), linkBase, whoisServer, now); entities, domainBase.getCurrentSponsorClientId(), linkBase, whoisServer, now);
if (!entities.isEmpty()) { if (!entities.isEmpty()) {
jsonBuilder.put("entities", entities); jsonBuilder.put("entities", entities);
} }
@ -1022,8 +1022,8 @@ public class RdapJsonFormatter {
eventsBuilder.add(makeEvent( eventsBuilder.add(makeEvent(
eventAction, historyEntry.getClientId(), historyEntry.getModificationTime())); eventAction, historyEntry.getClientId(), historyEntry.getModificationTime()));
} }
if (resource instanceof DomainResource) { if (resource instanceof DomainBase) {
DateTime expirationTime = ((DomainResource) resource).getRegistrationExpirationTime(); DateTime expirationTime = ((DomainBase) resource).getRegistrationExpirationTime();
if (expirationTime != null) { if (expirationTime != null) {
eventsBuilder.add(makeEvent(RdapEventAction.EXPIRATION, null, expirationTime)); eventsBuilder.add(makeEvent(RdapEventAction.EXPIRATION, null, expirationTime));
} }

View file

@ -25,7 +25,7 @@ import com.google.common.collect.Iterables;
import com.google.common.net.InetAddresses; import com.google.common.net.InetAddresses;
import com.google.common.primitives.Booleans; import com.google.common.primitives.Booleans;
import com.googlecode.objectify.cmd.Query; 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.model.host.HostResource;
import google.registry.rdap.RdapJsonFormatter.BoilerplateType; import google.registry.rdap.RdapJsonFormatter.BoilerplateType;
import google.registry.rdap.RdapJsonFormatter.OutputDataType; 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. */ /** Searches for nameservers by name using the superordinate domain as a suffix. */
private RdapSearchResults searchByNameUsingSuperordinateDomain( private RdapSearchResults searchByNameUsingSuperordinateDomain(
final RdapSearchPattern partialStringQuery, final DateTime now) { final RdapSearchPattern partialStringQuery, final DateTime now) {
Optional<DomainResource> domainResource = Optional<DomainBase> domainBase =
loadByForeignKey(DomainResource.class, partialStringQuery.getSuffix(), now); loadByForeignKey(DomainBase.class, partialStringQuery.getSuffix(), now);
if (!domainResource.isPresent()) { if (!domainBase.isPresent()) {
// Don't allow wildcards with suffixes which are not domains we manage. That would risk a // 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, // 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 // 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"); "A suffix after a wildcard in a nameserver lookup must be an in-bailiwick domain");
} }
List<HostResource> hostList = new ArrayList<>(); List<HostResource> 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)) { if (cursorString.isPresent() && (fqhn.compareTo(cursorString.get()) <= 0)) {
continue; continue;
} }
@ -235,7 +235,7 @@ public class RdapNameserverSearchAction extends RdapSearchActionBase {
return makeSearchResults( return makeSearchResults(
hostList, hostList,
IncompletenessWarningType.COMPLETE, IncompletenessWarningType.COMPLETE,
domainResource.get().getSubordinateHosts().size(), domainBase.get().getSubordinateHosts().size(),
CursorType.NAME, CursorType.NAME,
now); now);
} }

View file

@ -24,7 +24,7 @@ import com.google.common.flogger.FluentLogger;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DesignatedContact; 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.rgp.GracePeriodStatus;
import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.domain.secdns.DelegationSignerData;
import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.StatusValue;
@ -47,18 +47,18 @@ import google.registry.xjc.secdns.XjcSecdnsDsDataType;
import google.registry.xjc.secdns.XjcSecdnsDsOrKeyType; import google.registry.xjc.secdns.XjcSecdnsDsOrKeyType;
import org.joda.time.DateTime; import org.joda.time.DateTime;
/** Utility class that turns {@link DomainResource} as {@link XjcRdeDomainElement}. */ /** Utility class that turns {@link DomainBase} as {@link XjcRdeDomainElement}. */
final class DomainResourceToXjcConverter { final class DomainBaseToXjcConverter {
private static final FluentLogger logger = FluentLogger.forEnclosingClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
/** Converts {@link DomainResource} to {@link XjcRdeDomainElement}. */ /** Converts {@link DomainBase} to {@link XjcRdeDomainElement}. */
static XjcRdeDomainElement convert(DomainResource domain, RdeMode mode) { static XjcRdeDomainElement convert(DomainBase domain, RdeMode mode) {
return new XjcRdeDomainElement(convertDomain(domain, mode)); return new XjcRdeDomainElement(convertDomain(domain, mode));
} }
/** Converts {@link DomainResource} to {@link XjcRdeDomain}. */ /** Converts {@link DomainBase} to {@link XjcRdeDomain}. */
static XjcRdeDomain convertDomain(DomainResource model, RdeMode mode) { static XjcRdeDomain convertDomain(DomainBase model, RdeMode mode) {
XjcRdeDomain bean = new XjcRdeDomain(); XjcRdeDomain bean = new XjcRdeDomain();
// o A <name> element that contains the fully qualified name of the // o A <name> element that contains the fully qualified name of the
@ -236,7 +236,7 @@ final class DomainResourceToXjcConverter {
// * An OPTIONAL <exDate> element that contains the end of the // * An OPTIONAL <exDate> element that contains the end of the
// domain name object's validity period (expiry date) if the // domain name object's validity period (expiry date) if the
// transfer caused or causes a change in the validity period. // 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 // Temporary check to make sure that there really was a transfer. A bug caused spurious
// empty transfer records to get generated for deleted domains. // empty transfer records to get generated for deleted domains.
// TODO(b/33289763): remove the hasGainingAndLosingRegistrars check in February 2017 // TODO(b/33289763): remove the hasGainingAndLosingRegistrars check in February 2017
@ -254,7 +254,7 @@ final class DomainResourceToXjcConverter {
return bean; return bean;
} }
private static boolean hasGainingAndLosingRegistrars(DomainResource model) { private static boolean hasGainingAndLosingRegistrars(DomainBase model) {
return return
!Strings.isNullOrEmpty(model.getTransferData().getGainingClientId()) !Strings.isNullOrEmpty(model.getTransferData().getGainingClientId())
&& !Strings.isNullOrEmpty(model.getTransferData().getLosingClientId()); && !Strings.isNullOrEmpty(model.getTransferData().getLosingClientId());
@ -324,5 +324,5 @@ final class DomainResourceToXjcConverter {
return bean; return bean;
} }
private DomainResourceToXjcConverter() {} private DomainBaseToXjcConverter() {}
} }

View file

@ -18,7 +18,7 @@ import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.net.InetAddresses; import com.google.common.net.InetAddresses;
import com.googlecode.objectify.Key; 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.eppcommon.StatusValue;
import google.registry.model.host.HostResource; import google.registry.model.host.HostResource;
import google.registry.xjc.host.XjcHostAddrType; import google.registry.xjc.host.XjcHostAddrType;
@ -36,7 +36,7 @@ final class HostResourceToXjcConverter {
/** Converts a subordinate {@link HostResource} to {@link XjcRdeHostElement}. */ /** Converts a subordinate {@link HostResource} to {@link XjcRdeHostElement}. */
static XjcRdeHostElement convertSubordinate( static XjcRdeHostElement convertSubordinate(
HostResource host, DomainResource superordinateDomain) { HostResource host, DomainBase superordinateDomain) {
checkArgument(Key.create(superordinateDomain).equals(host.getSuperordinateDomain())); checkArgument(Key.create(superordinateDomain).equals(host.getSuperordinateDomain()));
return new XjcRdeHostElement(convertSubordinateHost(host, superordinateDomain)); return new XjcRdeHostElement(convertSubordinateHost(host, superordinateDomain));
} }
@ -48,7 +48,7 @@ final class HostResourceToXjcConverter {
} }
/** Converts {@link HostResource} to {@link XjcRdeHost}. */ /** Converts {@link HostResource} to {@link XjcRdeHost}. */
static XjcRdeHost convertSubordinateHost(HostResource model, DomainResource superordinateDomain) { static XjcRdeHost convertSubordinateHost(HostResource model, DomainBase superordinateDomain) {
XjcRdeHost bean = convertHostCommon( XjcRdeHost bean = convertHostCommon(
model, model,
superordinateDomain.getCurrentSponsorClientId(), superordinateDomain.getCurrentSponsorClientId(),

View file

@ -21,7 +21,7 @@ import com.google.common.flogger.FluentLogger;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.model.ImmutableObject; import google.registry.model.ImmutableObject;
import google.registry.model.contact.ContactResource; 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.host.HostResource;
import google.registry.model.rde.RdeMode; import google.registry.model.rde.RdeMode;
import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar;
@ -123,15 +123,15 @@ public final class RdeMarshaller implements Serializable {
ContactResourceToXjcConverter.convert(contact)); ContactResourceToXjcConverter.convert(contact));
} }
/** Turns {@link DomainResource} object into an XML fragment. */ /** Turns {@link DomainBase} object into an XML fragment. */
public DepositFragment marshalDomain(DomainResource domain, RdeMode mode) { public DepositFragment marshalDomain(DomainBase domain, RdeMode mode) {
return marshalResource(RdeResourceType.DOMAIN, domain, return marshalResource(RdeResourceType.DOMAIN, domain,
DomainResourceToXjcConverter.convert(domain, mode)); DomainBaseToXjcConverter.convert(domain, mode));
} }
/** Turns {@link HostResource} object into an XML fragment. */ /** Turns {@link HostResource} object into an XML fragment. */
public DepositFragment marshalSubordinateHost( public DepositFragment marshalSubordinateHost(
HostResource host, DomainResource superordinateDomain) { HostResource host, DomainBase superordinateDomain) {
return marshalResource(RdeResourceType.HOST, host, return marshalResource(RdeResourceType.HOST, host,
HostResourceToXjcConverter.convertSubordinate(host, superordinateDomain)); HostResourceToXjcConverter.convertSubordinate(host, superordinateDomain));
} }

View file

@ -28,7 +28,7 @@ import com.google.common.collect.Maps;
import com.googlecode.objectify.Result; import com.googlecode.objectify.Result;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.model.contact.ContactResource; 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.host.HostResource;
import google.registry.model.rde.RdeMode; import google.registry.model.rde.RdeMode;
import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar;
@ -75,7 +75,7 @@ public final class RdeStagingMapper extends Mapper<EppResource, PendingDeposit,
// Skip polymorphic entities that share Datastore kind. // Skip polymorphic entities that share Datastore kind.
if (!(resource instanceof ContactResource if (!(resource instanceof ContactResource
|| resource instanceof DomainResource || resource instanceof DomainBase
|| resource instanceof HostResource)) { || resource instanceof HostResource)) {
getContext().incrementCounter("polymorphic entities skipped"); getContext().incrementCounter("polymorphic entities skipped");
return; return;
@ -91,16 +91,16 @@ public final class RdeStagingMapper extends Mapper<EppResource, PendingDeposit,
// The set of all TLDs to which this resource should be emitted. // The set of all TLDs to which this resource should be emitted.
ImmutableSet<String> tlds; ImmutableSet<String> tlds;
if (resource instanceof DomainResource) { if (resource instanceof DomainBase) {
String tld = ((DomainResource) resource).getTld(); String tld = ((DomainBase) resource).getTld();
if (!pendings.containsKey(tld)) { if (!pendings.containsKey(tld)) {
getContext().incrementCounter("DomainResource of an unneeded TLD skipped"); getContext().incrementCounter("DomainBase of an unneeded TLD skipped");
return; return;
} }
getContext().incrementCounter("DomainResource instances"); getContext().incrementCounter("DomainBase instances");
tlds = ImmutableSet.of(tld); tlds = ImmutableSet.of(tld);
} else { } 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. // Contacts and hosts get emitted on all TLDs, even if domains don't reference them.
tlds = pendings.keySet(); tlds = pendings.keySet();
} }
@ -175,8 +175,8 @@ public final class RdeStagingMapper extends Mapper<EppResource, PendingDeposit,
return result; return result;
} }
resourcesFound++; resourcesFound++;
if (resource instanceof DomainResource) { if (resource instanceof DomainBase) {
result = Optional.of(marshaller.marshalDomain((DomainResource) resource, mode)); result = Optional.of(marshaller.marshalDomain((DomainBase) resource, mode));
cache.put(WatermarkModePair.create(watermark, mode), result); cache.put(WatermarkModePair.create(watermark, mode), result);
return result; return result;
} else if (resource instanceof ContactResource) { } else if (resource instanceof ContactResource) {

View file

@ -18,7 +18,7 @@ import static google.registry.flows.domain.DomainTransferUtils.createLosingTrans
import static google.registry.flows.domain.DomainTransferUtils.createPendingTransferData; import static google.registry.flows.domain.DomainTransferUtils.createPendingTransferData;
import static google.registry.flows.domain.DomainTransferUtils.createTransferServerApproveEntities; import static google.registry.flows.domain.DomainTransferUtils.createTransferServerApproveEntities;
import static google.registry.mapreduce.MapreduceRunner.PARAM_MAP_SHARDS; import static google.registry.mapreduce.MapreduceRunner.PARAM_MAP_SHARDS;
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.ofy.ObjectifyService.ofy;
import static google.registry.pricing.PricingEngineProxy.getDomainRenewCost; import static google.registry.pricing.PricingEngineProxy.getDomainRenewCost;
import static google.registry.rde.imports.RdeImportUtils.createAutoRenewBillingEventForDomainImport; import static google.registry.rde.imports.RdeImportUtils.createAutoRenewBillingEventForDomainImport;
@ -40,7 +40,7 @@ import google.registry.dns.DnsQueue;
import google.registry.gcs.GcsUtils; import google.registry.gcs.GcsUtils;
import google.registry.mapreduce.MapreduceRunner; import google.registry.mapreduce.MapreduceRunner;
import google.registry.model.billing.BillingEvent; 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;
import google.registry.model.domain.Period.Unit; import google.registry.model.domain.Period.Unit;
import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.domain.rgp.GracePeriodStatus;
@ -199,8 +199,8 @@ public class RdeDomainImportAction implements Runnable {
createAutoRenewBillingEventForDomainImport(xjcDomain, historyEntry); createAutoRenewBillingEventForDomainImport(xjcDomain, historyEntry);
PollMessage.Autorenew autorenewPollMessage = PollMessage.Autorenew autorenewPollMessage =
createAutoRenewPollMessageForDomainImport(xjcDomain, historyEntry); createAutoRenewPollMessageForDomainImport(xjcDomain, historyEntry);
DomainResource domain = DomainBase domain =
XjcToDomainResourceConverter.convertDomain( XjcToDomainBaseConverter.convertDomain(
xjcDomain, autorenewBillingEvent, autorenewPollMessage, stringGenerator); xjcDomain, autorenewBillingEvent, autorenewPollMessage, stringGenerator);
getDnsQueue().addDomainRefreshTask(domain.getFullyQualifiedDomainName()); getDnsQueue().addDomainRefreshTask(domain.getFullyQualifiedDomainName());
// Keep a list of "extra objects" that need to be saved along with the domain // Keep a list of "extra objects" that need to be saved along with the domain
@ -227,7 +227,7 @@ public class RdeDomainImportAction implements Runnable {
// the actual transfer time to avoid hitting the transfer-handling part of // the actual transfer time to avoid hitting the transfer-handling part of
// cloneProjectedAtTime(), since unlike in the DomainTransferRequestFlow case, // cloneProjectedAtTime(), since unlike in the DomainTransferRequestFlow case,
// this domain already has a pending transfer. // this domain already has a pending transfer.
DomainResource domainAtTransferTime = DomainBase domainAtTransferTime =
domain.cloneProjectedAtTime(automaticTransferTime.minusMillis(1)); domain.cloneProjectedAtTime(automaticTransferTime.minusMillis(1));
boolean inAutorenewGraceAtTransfer = boolean inAutorenewGraceAtTransfer =
!domainAtTransferTime.getGracePeriodsOfType(GracePeriodStatus.AUTO_RENEW).isEmpty(); !domainAtTransferTime.getGracePeriodsOfType(GracePeriodStatus.AUTO_RENEW).isEmpty();

View file

@ -27,7 +27,7 @@ import com.google.appengine.tools.mapreduce.InputReader;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import google.registry.config.RegistryConfig.ConfigModule; import google.registry.config.RegistryConfig.ConfigModule;
import google.registry.gcs.GcsUtils; import google.registry.gcs.GcsUtils;
import google.registry.model.domain.DomainResource; import google.registry.model.domain.DomainBase;
import google.registry.rde.imports.RdeParser.RdeHeader; import google.registry.rde.imports.RdeParser.RdeHeader;
import google.registry.xjc.JaxbFragment; import google.registry.xjc.JaxbFragment;
import google.registry.xjc.rdedomain.XjcRdeDomainElement; import google.registry.xjc.rdedomain.XjcRdeDomainElement;
@ -36,7 +36,7 @@ import java.util.List;
import java.util.Optional; import java.util.Optional;
/** /**
* A MapReduce {@link Input} that imports {@link DomainResource} objects from an escrow file. * A MapReduce {@link Input} that imports {@link DomainBase} objects from an escrow file.
* *
* <p>If a mapShards parameter has been specified, up to that many readers will be created * <p>If 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 * so that each map shard has one reader. If a mapShards parameter has not been specified, a

View file

@ -30,7 +30,7 @@ import google.registry.config.RegistryConfig.Config;
import google.registry.flows.host.HostFlowUtils; import google.registry.flows.host.HostFlowUtils;
import google.registry.mapreduce.MapreduceRunner; import google.registry.mapreduce.MapreduceRunner;
import google.registry.model.EppResource; 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.eppcommon.StatusValue;
import google.registry.model.host.HostResource; import google.registry.model.host.HostResource;
import google.registry.request.Action; import google.registry.request.Action;
@ -49,7 +49,7 @@ import org.joda.time.DateTime;
* *
* <p>This mapreduce is run as the last step of the process of importing escrow files. For each host * <p>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 * 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 * 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. * 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()); final InternetDomainName hostName = InternetDomainName.from(xjcHost.getName());
HostLinkResult hostLinkResult = ofy().transact(() -> { HostLinkResult hostLinkResult = ofy().transact(() -> {
Optional<DomainResource> superordinateDomain = Optional<DomainBase> superordinateDomain =
lookupSuperordinateDomain(hostName, ofy().getTransactionTime()); lookupSuperordinateDomain(hostName, ofy().getTransactionTime());
// if suporordinateDomain is absent, this is an out of zone host and can't be linked. // 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 // 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)) { if (superordinateDomain.get().getStatusValues().contains(StatusValue.PENDING_DELETE)) {
return HostLinkResult.SUPERORDINATE_DOMAIN_IN_PENDING_DELETE; return HostLinkResult.SUPERORDINATE_DOMAIN_IN_PENDING_DELETE;
} }
Key<DomainResource> superordinateDomainKey = Key.create(superordinateDomain.get()); Key<DomainBase> superordinateDomainKey = Key.create(superordinateDomain.get());
// link host to superordinate domain and set time of last superordinate change to // link host to superordinate domain and set time of last superordinate change to
// the time of the import // the time of the import
HostResource host = 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. * hosts.
* *
* <p>We use this instead of {@link HostFlowUtils#lookupSuperordinateDomain} because we don't * <p>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 * @throws IllegalStateException for hosts without superordinate domains
*/ */
private static Optional<DomainResource> lookupSuperordinateDomain( private static Optional<DomainBase> lookupSuperordinateDomain(
InternetDomainName hostName, DateTime now) { InternetDomainName hostName, DateTime now) {
Optional<InternetDomainName> tld = findTldForName(hostName); Optional<InternetDomainName> tld = findTldForName(hostName);
// out of zone hosts cannot be linked // out of zone hosts cannot be linked
@ -195,8 +195,8 @@ public class RdeHostLinkAction implements Runnable {
.stream() .stream()
.skip(hostName.parts().size() - (tld.get().parts().size() + 1)) .skip(hostName.parts().size() - (tld.get().parts().size() + 1))
.collect(joining(".")); .collect(joining("."));
Optional<DomainResource> superordinateDomain = Optional<DomainBase> superordinateDomain =
loadByForeignKey(DomainResource.class, domainName, now); loadByForeignKey(DomainBase.class, domainName, now);
// Hosts can't be linked if domains import hasn't been run // Hosts can't be linked if domains import hasn't been run
checkState( checkState(
superordinateDomain.isPresent(), superordinateDomain.isPresent(),

View file

@ -38,7 +38,7 @@ import google.registry.model.EppResource.ForeignKeyedEppResource;
import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Flag; import google.registry.model.billing.BillingEvent.Flag;
import google.registry.model.billing.BillingEvent.Reason; 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.eppcommon.Trid;
import google.registry.model.index.EppResourceIndex; import google.registry.model.index.EppResourceIndex;
import google.registry.model.index.ForeignKeyIndex; import google.registry.model.index.ForeignKeyIndex;
@ -223,7 +223,7 @@ public class RdeImportUtils {
.setBySuperuser(true) .setBySuperuser(true)
.setReason("RDE Import") .setReason("RDE Import")
.setRequestedByRegistrar(false) .setRequestedByRegistrar(false)
.setParent(Key.create(null, DomainResource.class, domain.getRoid())) .setParent(Key.create(null, DomainBase.class, domain.getRoid()))
.build(); .build();
} }

View file

@ -29,7 +29,7 @@ import google.registry.model.billing.BillingEvent;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DesignatedContact; import google.registry.model.domain.DesignatedContact;
import google.registry.model.domain.DomainAuthInfo; 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.GracePeriod;
import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.domain.rgp.GracePeriodStatus;
import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.domain.secdns.DelegationSignerData;
@ -55,8 +55,8 @@ import google.registry.xjc.secdns.XjcSecdnsDsDataType;
import java.util.function.Function; import java.util.function.Function;
import org.joda.time.DateTime; import org.joda.time.DateTime;
/** Utility class that converts an {@link XjcRdeDomainElement} into a {@link DomainResource}. */ /** Utility class that converts an {@link XjcRdeDomainElement} into a {@link DomainBase}. */
final class XjcToDomainResourceConverter extends XjcToEppResourceConverter { final class XjcToDomainBaseConverter extends XjcToEppResourceConverter {
private static final XmlToEnumMapper<TransferStatus> TRANSFER_STATUS_MAPPER = private static final XmlToEnumMapper<TransferStatus> TRANSFER_STATUS_MAPPER =
XmlToEnumMapper.create(TransferStatus.values()); XmlToEnumMapper.create(TransferStatus.values());
@ -131,16 +131,16 @@ final class XjcToDomainResourceConverter extends XjcToEppResourceConverter {
} }
} }
/** Converts {@link XjcRdeDomain} to {@link DomainResource}. */ /** Converts {@link XjcRdeDomain} to {@link DomainBase}. */
static DomainResource convertDomain( static DomainBase convertDomain(
XjcRdeDomain domain, XjcRdeDomain domain,
BillingEvent.Recurring autoRenewBillingEvent, BillingEvent.Recurring autoRenewBillingEvent,
PollMessage.Autorenew autoRenewPollMessage, PollMessage.Autorenew autoRenewPollMessage,
StringGenerator stringGenerator) { StringGenerator stringGenerator) {
GracePeriodConverter gracePeriodConverter = GracePeriodConverter gracePeriodConverter =
new GracePeriodConverter(domain, Key.create(autoRenewBillingEvent)); new GracePeriodConverter(domain, Key.create(autoRenewBillingEvent));
DomainResource.Builder builder = DomainBase.Builder builder =
new DomainResource.Builder() new DomainBase.Builder()
.setFullyQualifiedDomainName(canonicalizeDomainName(domain.getName())) .setFullyQualifiedDomainName(canonicalizeDomainName(domain.getName()))
.setRepoId(domain.getRoid()) .setRepoId(domain.getRoid())
.setIdnTableName(domain.getIdnTableId()) .setIdnTableName(domain.getIdnTableId())
@ -157,7 +157,7 @@ final class XjcToDomainResourceConverter extends XjcToEppResourceConverter {
domain domain
.getStatuses() .getStatuses()
.stream() .stream()
.map(XjcToDomainResourceConverter::convertStatusType) .map(XjcToDomainBaseConverter::convertStatusType)
.collect(toImmutableSet())) .collect(toImmutableSet()))
.setNameservers(convertNameservers(domain.getNs())) .setNameservers(convertNameservers(domain.getNs()))
.setGracePeriods( .setGracePeriods(
@ -170,7 +170,7 @@ final class XjcToDomainResourceConverter extends XjcToEppResourceConverter {
domain domain
.getContacts() .getContacts()
.stream() .stream()
.map(XjcToDomainResourceConverter::convertContactType) .map(XjcToDomainBaseConverter::convertContactType)
.collect(toImmutableSet())) .collect(toImmutableSet()))
.setDsData( .setDsData(
domain.getSecDNS() == null domain.getSecDNS() == null
@ -179,7 +179,7 @@ final class XjcToDomainResourceConverter extends XjcToEppResourceConverter {
.getSecDNS() .getSecDNS()
.getDsDatas() .getDsDatas()
.stream() .stream()
.map(XjcToDomainResourceConverter::convertSecdnsDsDataType) .map(XjcToDomainBaseConverter::convertSecdnsDsDataType)
.collect(toImmutableSet())) .collect(toImmutableSet()))
.setTransferData(convertDomainTransferData(domain.getTrnData())) .setTransferData(convertDomainTransferData(domain.getTrnData()))
// authInfo pw must be a token between 6 and 16 characters in length // 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); return DesignatedContact.create(type, key);
} }
private XjcToDomainResourceConverter() {} private XjcToDomainBaseConverter() {}
} }

View file

@ -32,7 +32,6 @@ JOIN
ON ON
currentSponsorClientId = registrar_table.__key__.name currentSponsorClientId = registrar_table.__key__.name
WHERE WHERE
domain_table._d = 'DomainResource' registrar_table.type = 'REAL' OR registrar_table.type = 'INTERNAL'
AND (registrar_table.type = 'REAL' OR registrar_table.type = 'INTERNAL')
GROUP BY tld, registrarName GROUP BY tld, registrarName
ORDER BY tld, registrarName ORDER BY tld, registrarName

View file

@ -44,8 +44,7 @@ JOIN (
FROM FROM
`%PROJECT_ID%.%DATASTORE_EXPORT_DATA_SET%.%DOMAINBASE_TABLE%`, `%PROJECT_ID%.%DATASTORE_EXPORT_DATA_SET%.%DOMAINBASE_TABLE%`,
UNNEST(nsHosts) AS hosts UNNEST(nsHosts) AS hosts
WHERE _d = 'DomainResource' WHERE creationTime <= TIMESTAMP("%LATEST_REPORT_TIME%")
AND creationTime <= TIMESTAMP("%LATEST_REPORT_TIME%")
AND deletionTime > TIMESTAMP("%LATEST_REPORT_TIME%") ) AS domain_table AND deletionTime > TIMESTAMP("%LATEST_REPORT_TIME%") ) AS domain_table
ON ON
host_table.__key__.name = domain_table.referencedHostName host_table.__key__.name = domain_table.referencedHostName

View file

@ -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;
import com.google.appengine.api.taskqueue.TaskOptions.Method; import com.google.appengine.api.taskqueue.TaskOptions.Method;
import com.google.common.base.Joiner; 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 google.registry.model.registrar.Registrar;
import java.util.Optional; import java.util.Optional;
import org.joda.time.DateTime; import org.joda.time.DateTime;
/** /**
* Helper methods for creating tasks containing CSV line data in the lordn-sunrise and lordn-claims * 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.
* *
* <p>Note that, per the <a href="https://tools.ietf.org/html/draft-ietf-regext-tmch-func-spec-04"> * <p>Note that, per the <a href="https://tools.ietf.org/html/draft-ietf-regext-tmch-func-spec-04">
* TMCH RFC</a>, while the application-datetime data is optional (which we never send because there * TMCH RFC</a>, 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. * 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(); 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. // CreationTime isn't yet populated when this method is called during the resource flow.
String tld = domain.getTld(); String tld = domain.getTld();
if (domain.getLaunchNotice() == null) { if (domain.getLaunchNotice() == null) {
@ -65,7 +65,7 @@ public final class LordnTaskUtils {
} }
/** Returns the corresponding CSV LORDN line for a sunrise domain. */ /** 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(',') return Joiner.on(',')
.join( .join(
domain.getRepoId(), domain.getRepoId(),
@ -76,7 +76,7 @@ public final class LordnTaskUtils {
} }
/** Returns the corresponding CSV LORDN line for a claims domain. */ /** 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(',') return Joiner.on(',')
.join( .join(
domain.getRepoId(), domain.getRepoId(),

View file

@ -21,7 +21,7 @@ import com.google.common.base.Strings;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.model.contact.ContactResource; 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.host.HostResource;
import google.registry.model.index.ForeignKeyIndex; import google.registry.model.index.ForeignKeyIndex;
import org.joda.time.DateTime; import org.joda.time.DateTime;
@ -33,7 +33,7 @@ class CommandUtilities {
public enum ResourceType { public enum ResourceType {
CONTACT(ContactResource.class), CONTACT(ContactResource.class),
HOST(HostResource.class), HOST(HostResource.class),
DOMAIN(DomainResource.class); DOMAIN(DomainBase.class);
private Class<? extends EppResource> clazz; private Class<? extends EppResource> clazz;

View file

@ -20,7 +20,7 @@ import static google.registry.model.registry.Registries.assertTldsExist;
import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters; import com.beust.jcommander.Parameters;
import com.google.common.collect.Iterators; import com.google.common.collect.Iterators;
import google.registry.model.domain.DomainResource; import google.registry.model.domain.DomainBase;
import google.registry.util.Clock; import google.registry.util.Clock;
import java.util.List; import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
@ -46,7 +46,7 @@ final class CountDomainsCommand implements CommandWithRemoteApi {
return Iterators.size( return Iterators.size(
ofy() ofy()
.load() .load()
.type(DomainResource.class) .type(DomainBase.class)
.filter("tld", tld) .filter("tld", tld)
.filter("deletionTime >", now) .filter("deletionTime >", now)
.chunkAll() .chunkAll()

View file

@ -19,7 +19,7 @@ import static google.registry.model.ofy.ObjectifyService.ofy;
import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters; 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.registrar.Registrar;
import google.registry.model.registry.Registry; import google.registry.model.registry.Registry;
import google.registry.model.registry.Registry.TldType; import google.registry.model.registry.Registry.TldType;
@ -62,7 +62,7 @@ final class DeleteTldCommand extends ConfirmingCommand implements CommandWithRem
} }
int count = ofy().load() int count = ofy().load()
.type(DomainResource.class) .type(DomainBase.class)
.filter("tld", tld) .filter("tld", tld)
.limit(1) .limit(1)
.count(); .count();

View file

@ -25,7 +25,7 @@ import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters; import com.beust.jcommander.Parameters;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; 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.model.host.HostResource;
import google.registry.tools.params.PathParameter; import google.registry.tools.params.PathParameter;
import google.registry.util.Clock; import google.registry.util.Clock;
@ -71,8 +71,8 @@ final class GenerateDnsReportCommand implements CommandWithRemoteApi {
String generate() { String generate() {
result.append("[\n"); result.append("[\n");
Iterable<DomainResource> domains = ofy().load().type(DomainResource.class).filter("tld", tld); Iterable<DomainBase> domains = ofy().load().type(DomainBase.class).filter("tld", tld);
for (DomainResource domain : domains) { for (DomainBase domain : domains) {
// Skip deleted domains and domains that don't get published to DNS. // Skip deleted domains and domains that don't get published to DNS.
if (isBeforeOrAt(domain.getDeletionTime(), now) || !domain.shouldPublishToDns()) { if (isBeforeOrAt(domain.getDeletionTime(), now) || !domain.shouldPublishToDns()) {
continue; continue;
@ -93,7 +93,7 @@ final class GenerateDnsReportCommand implements CommandWithRemoteApi {
return result.append("\n]\n").toString(); return result.append("\n]\n").toString();
} }
private void write(DomainResource domain) { private void write(DomainBase domain) {
ImmutableList<String> nameservers = ImmutableList<String> nameservers =
ImmutableList.sortedCopyOf(domain.loadNameserverFullyQualifiedHostNames()); ImmutableList.sortedCopyOf(domain.loadNameserverFullyQualifiedHostNames());
ImmutableList<Map<String, ?>> dsData = ImmutableList<Map<String, ?>> dsData =

View file

@ -21,7 +21,7 @@ import static org.joda.time.DateTimeZone.UTC;
import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters; import com.beust.jcommander.Parameters;
import com.google.common.collect.ImmutableList; 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.tmch.LordnTaskUtils;
import google.registry.tools.params.PathParameter; import google.registry.tools.params.PathParameter;
import java.io.IOException; import java.io.IOException;
@ -58,7 +58,7 @@ final class GenerateLordnCommand implements CommandWithRemoteApi {
DateTime now = DateTime.now(UTC); DateTime now = DateTime.now(UTC);
ImmutableList.Builder<String> claimsCsv = new ImmutableList.Builder<>(); ImmutableList.Builder<String> claimsCsv = new ImmutableList.Builder<>();
ImmutableList.Builder<String> sunriseCsv = new ImmutableList.Builder<>(); ImmutableList.Builder<String> 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 = " "; String status = " ";
if (domain.getLaunchNotice() == null && domain.getSmdId() != null) { if (domain.getLaunchNotice() == null && domain.getSmdId() != null) {
sunriseCsv.add(LordnTaskUtils.getCsvLineForSunriseDomain(domain, domain.getCreationTime())); sunriseCsv.add(LordnTaskUtils.getCsvLineForSunriseDomain(domain, domain.getCreationTime()));

View file

@ -18,7 +18,7 @@ import static google.registry.model.EppResourceUtils.loadByForeignKey;
import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters; import com.beust.jcommander.Parameters;
import google.registry.model.domain.DomainResource; import google.registry.model.domain.DomainBase;
import java.util.List; import java.util.List;
/** Command to show a domain resource. */ /** Command to show a domain resource. */
@ -34,7 +34,7 @@ final class GetDomainCommand extends GetEppResourceCommand {
public void runAndPrint() { public void runAndPrint() {
for (String domainName : mainParameters) { for (String domainName : mainParameters) {
printResource( printResource(
"Domain", domainName, loadByForeignKey(DomainResource.class, domainName, readTimestamp)); "Domain", domainName, loadByForeignKey(DomainBase.class, domainName, readTimestamp));
} }
} }
} }

View file

@ -25,7 +25,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import com.google.template.soy.data.SoyMapData; 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.model.eppcommon.StatusValue;
import google.registry.tools.soy.DomainUpdateSoyInfo; import google.registry.tools.soy.DomainUpdateSoyInfo;
import java.util.Optional; 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. // Project all domains as of the same time so that argument order doesn't affect behavior.
DateTime now = DateTime.now(UTC); DateTime now = DateTime.now(UTC);
for (String domain : getDomains()) { for (String domain : getDomains()) {
Optional<DomainResource> domainResource = loadByForeignKey(DomainResource.class, domain, now); Optional<DomainBase> domainBase = loadByForeignKey(DomainBase.class, domain, now);
checkArgumentPresent(domainResource, "Domain '%s' does not exist or is deleted", domain); checkArgumentPresent(domainBase, "Domain '%s' does not exist or is deleted", domain);
ImmutableSet<StatusValue> statusesToAdd = ImmutableSet<StatusValue> statusesToAdd =
Sets.difference(REGISTRY_LOCK_STATUSES, domainResource.get().getStatusValues()) Sets.difference(REGISTRY_LOCK_STATUSES, domainBase.get().getStatusValues())
.immutableCopy(); .immutableCopy();
if (statusesToAdd.isEmpty()) { if (statusesToAdd.isEmpty()) {
logger.atInfo().log("Domain '%s' is already locked and needs no updates.", domain); logger.atInfo().log("Domain '%s' is already locked and needs no updates.", domain);

View file

@ -23,7 +23,7 @@ import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters; import com.beust.jcommander.Parameters;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.template.soy.data.SoyMapData; 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.tools.soy.RenewDomainSoyInfo;
import google.registry.util.Clock; import google.registry.util.Clock;
import java.util.List; import java.util.List;
@ -57,11 +57,11 @@ final class RenewDomainCommand extends MutatingEppToolCommand {
checkArgument(period < 10, "Cannot renew domains for 10 or more years"); checkArgument(period < 10, "Cannot renew domains for 10 or more years");
DateTime now = clock.nowUtc(); DateTime now = clock.nowUtc();
for (String domainName : mainParameters) { for (String domainName : mainParameters) {
Optional<DomainResource> domainOptional = Optional<DomainBase> domainOptional =
loadByForeignKey(DomainResource.class, domainName, now); loadByForeignKey(DomainBase.class, domainName, now);
checkArgumentPresent(domainOptional, "Domain '%s' does not exist or is deleted", domainName); checkArgumentPresent(domainOptional, "Domain '%s' does not exist or is deleted", domainName);
setSoyTemplate(RenewDomainSoyInfo.getInstance(), RenewDomainSoyInfo.RENEWDOMAIN); setSoyTemplate(RenewDomainSoyInfo.getInstance(), RenewDomainSoyInfo.RENEWDOMAIN);
DomainResource domain = domainOptional.get(); DomainBase domain = domainOptional.get();
addSoyRecord( addSoyRecord(
domain.getCurrentSponsorClientId(), domain.getCurrentSponsorClientId(),
new SoyMapData( new SoyMapData(

View file

@ -30,7 +30,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.ImmutableSortedSet;
import com.google.template.soy.data.SoyMapData; 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.domain.secdns.DelegationSignerData;
import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource; import google.registry.model.host.HostResource;
@ -121,7 +121,7 @@ final class UniformRapidSuspensionCommand extends MutatingEppToolCommand {
} catch (ClassCastException | ParseException e) { } catch (ClassCastException | ParseException e) {
throw new IllegalArgumentException("Invalid --dsdata JSON", e); throw new IllegalArgumentException("Invalid --dsdata JSON", e);
} }
Optional<DomainResource> domain = loadByForeignKey(DomainResource.class, domainName, now); Optional<DomainBase> domain = loadByForeignKey(DomainBase.class, domainName, now);
checkArgumentPresent(domain, "Domain '%s' does not exist or is deleted", domainName); checkArgumentPresent(domain, "Domain '%s' does not exist or is deleted", domainName);
Set<String> missingHosts = Set<String> missingHosts =
difference(newHostsSet, checkResourcesExist(HostResource.class, newHosts, now)); difference(newHostsSet, checkResourcesExist(HostResource.class, newHosts, now));
@ -146,7 +146,7 @@ final class UniformRapidSuspensionCommand extends MutatingEppToolCommand {
"reason", (undo ? "Undo " : "") + "Uniform Rapid Suspension")); "reason", (undo ? "Undo " : "") + "Uniform Rapid Suspension"));
} }
private ImmutableSortedSet<String> getExistingNameservers(DomainResource domain) { private ImmutableSortedSet<String> getExistingNameservers(DomainBase domain) {
ImmutableSortedSet.Builder<String> nameservers = ImmutableSortedSet.naturalOrder(); ImmutableSortedSet.Builder<String> nameservers = ImmutableSortedSet.naturalOrder();
for (HostResource host : ofy().load().keys(domain.getNameservers()).values()) { for (HostResource host : ofy().load().keys(domain.getNameservers()).values()) {
nameservers.add(host.getForeignKey()); nameservers.add(host.getForeignKey());
@ -154,7 +154,7 @@ final class UniformRapidSuspensionCommand extends MutatingEppToolCommand {
return nameservers.build(); return nameservers.build();
} }
private ImmutableSortedSet<String> getExistingLocks(DomainResource domain) { private ImmutableSortedSet<String> getExistingLocks(DomainBase domain) {
ImmutableSortedSet.Builder<String> locks = ImmutableSortedSet.naturalOrder(); ImmutableSortedSet.Builder<String> locks = ImmutableSortedSet.naturalOrder();
for (StatusValue lock : domain.getStatusValues()) { for (StatusValue lock : domain.getStatusValues()) {
if (URS_LOCKS.contains(lock.getXmlName())) { if (URS_LOCKS.contains(lock.getXmlName())) {
@ -164,7 +164,7 @@ final class UniformRapidSuspensionCommand extends MutatingEppToolCommand {
return locks.build(); return locks.build();
} }
private ImmutableSortedSet<String> getExistingDsData(DomainResource domain) { private ImmutableSortedSet<String> getExistingDsData(DomainBase domain) {
ImmutableSortedSet.Builder<String> dsDataJsons = ImmutableSortedSet.naturalOrder(); ImmutableSortedSet.Builder<String> dsDataJsons = ImmutableSortedSet.naturalOrder();
HexBinaryAdapter hexBinaryAdapter = new HexBinaryAdapter(); HexBinaryAdapter hexBinaryAdapter = new HexBinaryAdapter();
for (DelegationSignerData dsData : domain.getDsData()) { for (DelegationSignerData dsData : domain.getDsData()) {

View file

@ -25,7 +25,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import com.google.template.soy.data.SoyMapData; 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.model.eppcommon.StatusValue;
import google.registry.tools.soy.DomainUpdateSoyInfo; import google.registry.tools.soy.DomainUpdateSoyInfo;
import java.util.Optional; 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. // Project all domains as of the same time so that argument order doesn't affect behavior.
DateTime now = DateTime.now(UTC); DateTime now = DateTime.now(UTC);
for (String domain : getDomains()) { for (String domain : getDomains()) {
Optional<DomainResource> domainResource = loadByForeignKey(DomainResource.class, domain, now); Optional<DomainBase> domainBase = loadByForeignKey(DomainBase.class, domain, now);
checkArgumentPresent(domainResource, "Domain '%s' does not exist or is deleted", domain); checkArgumentPresent(domainBase, "Domain '%s' does not exist or is deleted", domain);
ImmutableSet<StatusValue> statusesToRemove = ImmutableSet<StatusValue> statusesToRemove =
Sets.intersection(domainResource.get().getStatusValues(), REGISTRY_LOCK_STATUSES) Sets.intersection(domainBase.get().getStatusValues(), REGISTRY_LOCK_STATUSES)
.immutableCopy(); .immutableCopy();
if (statusesToRemove.isEmpty()) { if (statusesToRemove.isEmpty()) {
logger.atInfo().log("Domain '%s' is already unlocked and needs no updates.", domain); logger.atInfo().log("Domain '%s' is already unlocked and needs no updates.", domain);

View file

@ -32,7 +32,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.model.billing.BillingEvent; 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;
import google.registry.model.domain.Period.Unit; import google.registry.model.domain.Period.Unit;
import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.StatusValue;
@ -91,7 +91,7 @@ class UnrenewDomainCommand extends ConfirmingCommand implements CommandWithRemot
domainsNonexistentBuilder.add(domainName); domainsNonexistentBuilder.add(domainName);
continue; continue;
} }
Optional<DomainResource> domain = loadByForeignKey(DomainResource.class, domainName, now); Optional<DomainBase> domain = loadByForeignKey(DomainBase.class, domainName, now);
if (!domain.isPresent() if (!domain.isPresent()
|| domain.get().getStatusValues().contains(StatusValue.PENDING_DELETE)) { || domain.get().getStatusValues().contains(StatusValue.PENDING_DELETE)) {
domainsDeletingBuilder.add(domainName); domainsDeletingBuilder.add(domainName);
@ -151,8 +151,8 @@ class UnrenewDomainCommand extends ConfirmingCommand implements CommandWithRemot
private void unrenewDomain(String domainName) { private void unrenewDomain(String domainName) {
ofy().assertInTransaction(); ofy().assertInTransaction();
DateTime now = ofy().getTransactionTime(); DateTime now = ofy().getTransactionTime();
Optional<DomainResource> domainOptional = Optional<DomainBase> domainOptional =
loadByForeignKey(DomainResource.class, domainName, now); loadByForeignKey(DomainBase.class, domainName, now);
// Transactional sanity checks on the off chance that something changed between init() running // Transactional sanity checks on the off chance that something changed between init() running
// and here. // and here.
checkState( checkState(
@ -160,7 +160,7 @@ class UnrenewDomainCommand extends ConfirmingCommand implements CommandWithRemot
&& !domainOptional.get().getStatusValues().contains(StatusValue.PENDING_DELETE), && !domainOptional.get().getStatusValues().contains(StatusValue.PENDING_DELETE),
"Domain %s was deleted or is pending deletion", "Domain %s was deleted or is pending deletion",
domainName); domainName);
DomainResource domain = domainOptional.get(); DomainBase domain = domainOptional.get();
checkState( checkState(
Sets.intersection(domain.getStatusValues(), DISALLOWED_STATUSES).isEmpty(), Sets.intersection(domain.getStatusValues(), DISALLOWED_STATUSES).isEmpty(),
"Domain %s has prohibited status values", "Domain %s has prohibited status values",
@ -206,7 +206,7 @@ class UnrenewDomainCommand extends ConfirmingCommand implements CommandWithRemot
.build(); .build();
// End the old autorenew billing event and poll message now. // End the old autorenew billing event and poll message now.
updateAutorenewRecurrenceEndTime(domain, now); updateAutorenewRecurrenceEndTime(domain, now);
DomainResource newDomain = DomainBase newDomain =
domain domain
.asBuilder() .asBuilder()
.setRegistrationExpirationTime(newExpirationTime) .setRegistrationExpirationTime(newExpirationTime)

View file

@ -30,7 +30,7 @@ import com.google.common.collect.Sets;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import com.google.template.soy.data.SoyMapData; import com.google.template.soy.data.SoyMapData;
import google.registry.model.domain.DesignatedContact; 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.model.eppcommon.StatusValue;
import google.registry.tools.params.NameserversParameter; import google.registry.tools.params.NameserversParameter;
import google.registry.tools.soy.DomainUpdateSoyInfo; import google.registry.tools.soy.DomainUpdateSoyInfo;
@ -173,18 +173,18 @@ final class UpdateDomainCommand extends CreateOrUpdateDomainCommand {
if (!nameservers.isEmpty() || !admins.isEmpty() || !techs.isEmpty() || !statuses.isEmpty()) { if (!nameservers.isEmpty() || !admins.isEmpty() || !techs.isEmpty() || !statuses.isEmpty()) {
DateTime now = DateTime.now(UTC); DateTime now = DateTime.now(UTC);
Optional<DomainResource> domainOptional = Optional<DomainBase> domainOptional =
loadByForeignKey(DomainResource.class, domain, now); loadByForeignKey(DomainBase.class, domain, now);
checkArgumentPresent(domainOptional, "Domain '%s' does not exist or is deleted", domain); checkArgumentPresent(domainOptional, "Domain '%s' does not exist or is deleted", domain);
DomainResource domainResource = domainOptional.get(); DomainBase domainBase = domainOptional.get();
checkArgument( 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 " "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.", + "to make updates, and if so, use the domain_unlock command to enable updates.",
domain); domain);
if (!nameservers.isEmpty()) { if (!nameservers.isEmpty()) {
ImmutableSortedSet<String> existingNameservers = ImmutableSortedSet<String> existingNameservers =
domainResource.loadNameserverFullyQualifiedHostNames(); domainBase.loadNameserverFullyQualifiedHostNames();
populateAddRemoveLists( populateAddRemoveLists(
ImmutableSet.copyOf(nameservers), ImmutableSet.copyOf(nameservers),
existingNameservers, existingNameservers,
@ -201,9 +201,9 @@ final class UpdateDomainCommand extends CreateOrUpdateDomainCommand {
} }
if (!admins.isEmpty() || !techs.isEmpty()) { if (!admins.isEmpty() || !techs.isEmpty()) {
ImmutableSet<String> existingAdmins = ImmutableSet<String> existingAdmins =
getContactsOfType(domainResource, DesignatedContact.Type.ADMIN); getContactsOfType(domainBase, DesignatedContact.Type.ADMIN);
ImmutableSet<String> existingTechs = ImmutableSet<String> existingTechs =
getContactsOfType(domainResource, DesignatedContact.Type.TECH); getContactsOfType(domainBase, DesignatedContact.Type.TECH);
if (!admins.isEmpty()) { if (!admins.isEmpty()) {
populateAddRemoveLists( populateAddRemoveLists(
@ -222,7 +222,7 @@ final class UpdateDomainCommand extends CreateOrUpdateDomainCommand {
} }
if (!statuses.isEmpty()) { if (!statuses.isEmpty()) {
Set<String> currentStatusValues = new HashSet<>(); Set<String> currentStatusValues = new HashSet<>();
for (StatusValue statusValue : domainResource.getStatusValues()) { for (StatusValue statusValue : domainBase.getStatusValues()) {
currentStatusValues.add(statusValue.getXmlName()); currentStatusValues.add(statusValue.getXmlName());
} }
populateAddRemoveLists( populateAddRemoveLists(
@ -290,8 +290,8 @@ final class UpdateDomainCommand extends CreateOrUpdateDomainCommand {
} }
ImmutableSet<String> getContactsOfType( ImmutableSet<String> getContactsOfType(
DomainResource domainResource, final DesignatedContact.Type contactType) { DomainBase domainBase, final DesignatedContact.Type contactType) {
return domainResource return domainBase
.getContacts() .getContacts()
.stream() .stream()
.filter(contact -> contact.getType().equals(contactType)) .filter(contact -> contact.getType().equals(contactType))

View file

@ -38,7 +38,7 @@ import google.registry.gcs.GcsUtils;
import google.registry.mapreduce.MapreduceRunner; import google.registry.mapreduce.MapreduceRunner;
import google.registry.mapreduce.inputs.NullInput; import google.registry.mapreduce.inputs.NullInput;
import google.registry.model.EppResource; 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.domain.secdns.DelegationSignerData;
import google.registry.model.host.HostResource; import google.registry.model.host.HostResource;
import google.registry.request.Action; import google.registry.request.Action;
@ -140,7 +140,7 @@ public class GenerateZoneFilesAction implements Runnable, JsonActionRunner.JsonA
new GenerateBindFileMapper( new GenerateBindFileMapper(
tlds, exportTime, dnsDefaultATtl, dnsDefaultNsTtl, dnsDefaultDsTtl), tlds, exportTime, dnsDefaultATtl, dnsDefaultNsTtl, dnsDefaultDsTtl),
new GenerateBindFileReducer(bucket, exportTime, gcsBufferSize), new GenerateBindFileReducer(bucket, exportTime, gcsBufferSize),
ImmutableList.of(new NullInput<>(), createEntityInput(DomainResource.class))) ImmutableList.of(new NullInput<>(), createEntityInput(DomainBase.class)))
.getLinkToMapreduceConsole(); .getLinkToMapreduceConsole();
ImmutableList<String> filenames = ImmutableList<String> filenames =
tlds.stream() tlds.stream()
@ -185,7 +185,7 @@ public class GenerateZoneFilesAction implements Runnable, JsonActionRunner.JsonA
emit(tld, null); emit(tld, null);
} }
} else { } 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 // 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 // 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. // 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. // Domains never change their tld, so we can check if it's from the wrong tld right away.
if (tlds.contains(domain.getTld())) { if (tlds.contains(domain.getTld())) {
domain = loadAtPointInTime(domain, exportTime).now(); 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<String> subordinateHosts = domain.getSubordinateHosts(); ImmutableSet<String> subordinateHosts = domain.getSubordinateHosts();
if (!subordinateHosts.isEmpty()) { if (!subordinateHosts.isEmpty()) {
for (HostResource unprojectedHost : ofy().load().keys(domain.getNameservers()).values()) { for (HostResource unprojectedHost : ofy().load().keys(domain.getNameservers()).values()) {
@ -276,7 +276,7 @@ public class GenerateZoneFilesAction implements Runnable, JsonActionRunner.JsonA
* } * }
*/ */
private static String domainStanza( private static String domainStanza(
DomainResource domain, DomainBase domain,
DateTime exportTime, DateTime exportTime,
Duration dnsDefaultNsTtl, Duration dnsDefaultNsTtl,
Duration dnsDefaultDsTtl) { Duration dnsDefaultDsTtl) {

View file

@ -29,7 +29,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.model.EppResourceUtils; 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.Action;
import google.registry.request.Parameter; import google.registry.request.Parameter;
import google.registry.request.auth.Auth; import google.registry.request.auth.Auth;
@ -45,7 +45,7 @@ import org.joda.time.DateTime;
path = ListDomainsAction.PATH, path = ListDomainsAction.PATH,
method = {GET, POST}, method = {GET, POST},
auth = Auth.AUTH_INTERNAL_OR_ADMIN) auth = Auth.AUTH_INTERNAL_OR_ADMIN)
public final class ListDomainsAction extends ListObjectsAction<DomainResource> { public final class ListDomainsAction extends ListObjectsAction<DomainBase> {
/** An App Engine limitation on how many subqueries can be used in a single query. */ /** An App Engine limitation on how many subqueries can be used in a single query. */
@VisibleForTesting @NonFinalForTesting static int maxNumSubqueries = 30; @VisibleForTesting @NonFinalForTesting static int maxNumSubqueries = 30;
@ -71,16 +71,16 @@ public final class ListDomainsAction extends ListObjectsAction<DomainResource> {
} }
@Override @Override
public ImmutableSet<DomainResource> loadObjects() { public ImmutableSet<DomainBase> loadObjects() {
checkArgument(!tlds.isEmpty(), "Must specify TLDs to query"); checkArgument(!tlds.isEmpty(), "Must specify TLDs to query");
assertTldsExist(tlds); assertTldsExist(tlds);
DateTime now = clock.nowUtc(); DateTime now = clock.nowUtc();
ImmutableList.Builder<DomainResource> domainsBuilder = new ImmutableList.Builder<>(); ImmutableList.Builder<DomainBase> domainsBuilder = new ImmutableList.Builder<>();
for (List<String> tldsBatch : Lists.partition(tlds.asList(), maxNumSubqueries)) { for (List<String> tldsBatch : Lists.partition(tlds.asList(), maxNumSubqueries)) {
domainsBuilder.addAll( domainsBuilder.addAll(
ofy() ofy()
.load() .load()
.type(DomainResource.class) .type(DomainBase.class)
.filter("tld in", tldsBatch) .filter("tld in", tldsBatch)
// Get the N most recently created domains (requires ordering in descending order). // Get the N most recently created domains (requires ordering in descending order).
.order("-creationTime") .order("-creationTime")

View file

@ -26,7 +26,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import google.registry.dns.DnsQueue; import google.registry.dns.DnsQueue;
import google.registry.mapreduce.MapreduceRunner; 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.Action;
import google.registry.request.Parameter; import google.registry.request.Parameter;
import google.registry.request.Response; import google.registry.request.Response;
@ -69,13 +69,13 @@ public class RefreshDnsForAllDomainsAction implements Runnable {
.setDefaultMapShards(10) .setDefaultMapShards(10)
.runMapOnly( .runMapOnly(
new RefreshDnsForAllDomainsActionMapper(tlds), new RefreshDnsForAllDomainsActionMapper(tlds),
ImmutableList.of(createEntityInput(DomainResource.class))) ImmutableList.of(createEntityInput(DomainBase.class)))
.sendLinkToMapreduceConsole(response); .sendLinkToMapreduceConsole(response);
} }
/** Mapper to refresh DNS for all active domain resources. */ /** Mapper to refresh DNS for all active domain resources. */
public static class RefreshDnsForAllDomainsActionMapper public static class RefreshDnsForAllDomainsActionMapper
extends Mapper<DomainResource, Void, Void> { extends Mapper<DomainBase, Void, Void> {
private static final long serialVersionUID = 1455544013508953083L; private static final long serialVersionUID = 1455544013508953083L;
@ -88,7 +88,7 @@ public class RefreshDnsForAllDomainsAction implements Runnable {
} }
@Override @Override
public void map(final DomainResource domain) { public void map(final DomainBase domain) {
String domainName = domain.getFullyQualifiedDomainName(); String domainName = domain.getFullyQualifiedDomainName();
if (tlds.contains(domain.getTld())) { if (tlds.contains(domain.getTld())) {
if (isActive(domain, DateTime.now(DateTimeZone.UTC))) { if (isActive(domain, DateTime.now(DateTimeZone.UTC))) {

View file

@ -17,7 +17,7 @@ package google.registry.whois;
import static google.registry.model.EppResourceUtils.loadByForeignKeyCached; import static google.registry.model.EppResourceUtils.loadByForeignKeyCached;
import com.google.common.net.InternetDomainName; import com.google.common.net.InternetDomainName;
import google.registry.model.domain.DomainResource; import google.registry.model.domain.DomainBase;
import java.util.Optional; import java.util.Optional;
import org.joda.time.DateTime; import org.joda.time.DateTime;
@ -33,7 +33,7 @@ public class DomainLookupCommand extends DomainOrHostLookupCommand {
@Override @Override
protected Optional<WhoisResponse> getResponse(InternetDomainName domainName, DateTime now) { protected Optional<WhoisResponse> 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)); .map(domain -> new DomainWhoisResponse(domain, fullOutput, now));
} }
} }

View file

@ -29,7 +29,7 @@ import google.registry.model.contact.ContactResource;
import google.registry.model.contact.PostalInfo; import google.registry.model.contact.PostalInfo;
import google.registry.model.domain.DesignatedContact; import google.registry.model.domain.DesignatedContact;
import google.registry.model.domain.DesignatedContact.Type; 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.domain.GracePeriod;
import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.StatusValue;
import google.registry.model.registrar.Registrar; 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"; "For more information on Whois status codes, please visit https://icann.org/epp\r\n";
/** Domain which was the target of this WHOIS command. */ /** 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. */ /** Whether the full WHOIS output is to be displayed. */
private final boolean fullOutput; private final boolean fullOutput;
/** Creates new WHOIS domain response on the given domain. */ /** 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); super(timestamp);
this.domain = checkNotNull(domain, "domain"); this.domain = checkNotNull(domain, "domain");
this.fullOutput = fullOutput; this.fullOutput = fullOutput;

View file

@ -37,7 +37,7 @@ import static google.registry.testing.DatastoreHelper.getOnlyHistoryEntryOfType;
import static google.registry.testing.DatastoreHelper.getOnlyPollMessageForHistoryEntry; import static google.registry.testing.DatastoreHelper.getOnlyPollMessageForHistoryEntry;
import static google.registry.testing.DatastoreHelper.getPollMessages; import static google.registry.testing.DatastoreHelper.getPollMessages;
import static google.registry.testing.DatastoreHelper.newContactResource; 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.newHostResource;
import static google.registry.testing.DatastoreHelper.persistActiveContact; import static google.registry.testing.DatastoreHelper.persistActiveContact;
import static google.registry.testing.DatastoreHelper.persistActiveHost; 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.ContactPhoneNumber;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.ContactResource;
import google.registry.model.contact.PostalInfo; 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.StatusValue;
import google.registry.model.eppcommon.Trid; import google.registry.model.eppcommon.Trid;
import google.registry.model.eppoutput.EppResponse.ResponseData; 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.FakeResponse;
import google.registry.testing.FakeSleeper; import google.registry.testing.FakeSleeper;
import google.registry.testing.InjectRule; import google.registry.testing.InjectRule;
import google.registry.testing.MockitoJUnitRule;
import google.registry.testing.TaskQueueHelper.TaskMatcher; import google.registry.testing.TaskQueueHelper.TaskMatcher;
import google.registry.testing.mapreduce.MapreduceTestCase; import google.registry.testing.mapreduce.MapreduceTestCase;
import google.registry.util.AppEngineServiceUtils; import google.registry.util.AppEngineServiceUtils;
@ -120,7 +119,6 @@ public class DeleteContactsAndHostsActionTest
extends MapreduceTestCase<DeleteContactsAndHostsAction> { extends MapreduceTestCase<DeleteContactsAndHostsAction> {
@Rule public final InjectRule inject = new InjectRule(); @Rule public final InjectRule inject = new InjectRule();
@Rule public final MockitoJUnitRule mocks = MockitoJUnitRule.create();
private AsyncTaskEnqueuer enqueuer; private AsyncTaskEnqueuer enqueuer;
private final FakeClock clock = new FakeClock(DateTime.parse("2015-01-15T11:22:33Z")); private final FakeClock clock = new FakeClock(DateTime.parse("2015-01-15T11:22:33Z"));
@ -181,7 +179,7 @@ public class DeleteContactsAndHostsActionTest
@Test @Test
public void testSuccess_contact_referencedByActiveDomain_doesNotGetDeleted() throws Exception { public void testSuccess_contact_referencedByActiveDomain_doesNotGetDeleted() throws Exception {
ContactResource contact = persistContactPendingDelete("blah8221"); ContactResource contact = persistContactPendingDelete("blah8221");
persistResource(newDomainResource("example.tld", contact)); persistResource(newDomainBase("example.tld", contact));
DateTime timeEnqueued = clock.nowUtc(); DateTime timeEnqueued = clock.nowUtc();
enqueuer.enqueueAsyncDelete( enqueuer.enqueueAsyncDelete(
contact, contact,
@ -197,8 +195,8 @@ public class DeleteContactsAndHostsActionTest
.doesNotHaveStatusValue(PENDING_DELETE) .doesNotHaveStatusValue(PENDING_DELETE)
.and() .and()
.hasDeletionTime(END_OF_TIME); .hasDeletionTime(END_OF_TIME);
DomainResource domainReloaded = DomainBase domainReloaded =
loadByForeignKey(DomainResource.class, "example.tld", clock.nowUtc()).get(); loadByForeignKey(DomainBase.class, "example.tld", clock.nowUtc()).get();
assertThat(domainReloaded.getReferencedContacts()).contains(Key.create(contactUpdated)); assertThat(domainReloaded.getReferencedContacts()).contains(Key.create(contactUpdated));
HistoryEntry historyEntry = HistoryEntry historyEntry =
getOnlyHistoryEntryOfType(contactUpdated, HistoryEntry.Type.CONTACT_DELETE_FAILURE); getOnlyHistoryEntryOfType(contactUpdated, HistoryEntry.Type.CONTACT_DELETE_FAILURE);
@ -237,7 +235,7 @@ public class DeleteContactsAndHostsActionTest
@Test @Test
public void test_mapreduceHasWorkToDo_lockIsAcquired() { public void test_mapreduceHasWorkToDo_lockIsAcquired() {
ContactResource contact = persistContactPendingDelete("blah8221"); ContactResource contact = persistContactPendingDelete("blah8221");
persistResource(newDomainResource("example.tld", contact)); persistResource(newDomainBase("example.tld", contact));
DateTime timeEnqueued = clock.nowUtc(); DateTime timeEnqueued = clock.nowUtc();
enqueuer.enqueueAsyncDelete( enqueuer.enqueueAsyncDelete(
contact, contact,
@ -380,7 +378,7 @@ public class DeleteContactsAndHostsActionTest
public void testSuccess_contact_referencedByDeletedDomain_getsDeleted() throws Exception { public void testSuccess_contact_referencedByDeletedDomain_getsDeleted() throws Exception {
ContactResource contactUsed = persistContactPendingDelete("blah1234"); ContactResource contactUsed = persistContactPendingDelete("blah1234");
persistResource( persistResource(
newDomainResource("example.tld", contactUsed) newDomainBase("example.tld", contactUsed)
.asBuilder() .asBuilder()
.setDeletionTime(clock.nowUtc().minusDays(3)) .setDeletionTime(clock.nowUtc().minusDays(3))
.build()); .build());
@ -614,8 +612,8 @@ public class DeleteContactsAndHostsActionTest
.doesNotHaveStatusValue(PENDING_DELETE) .doesNotHaveStatusValue(PENDING_DELETE)
.and() .and()
.hasDeletionTime(END_OF_TIME); .hasDeletionTime(END_OF_TIME);
DomainResource domain = DomainBase domain =
loadByForeignKey(DomainResource.class, "example.tld", clock.nowUtc()).get(); loadByForeignKey(DomainBase.class, "example.tld", clock.nowUtc()).get();
assertThat(domain.getNameservers()).contains(Key.create(hostAfter)); assertThat(domain.getNameservers()).contains(Key.create(hostAfter));
HistoryEntry historyEntry = getOnlyHistoryEntryOfType(hostAfter, HOST_DELETE_FAILURE); HistoryEntry historyEntry = getOnlyHistoryEntryOfType(hostAfter, HOST_DELETE_FAILURE);
assertPollMessageFor( assertPollMessageFor(
@ -684,7 +682,7 @@ public class DeleteContactsAndHostsActionTest
public void testSuccess_host_referencedByDeletedDomain_getsDeleted() throws Exception { public void testSuccess_host_referencedByDeletedDomain_getsDeleted() throws Exception {
HostResource host = persistHostPendingDelete("ns1.example.tld"); HostResource host = persistHostPendingDelete("ns1.example.tld");
persistResource( persistResource(
newDomainResource("example.tld") newDomainBase("example.tld")
.asBuilder() .asBuilder()
.setNameservers(ImmutableSet.of(Key.create(host))) .setNameservers(ImmutableSet.of(Key.create(host)))
.setDeletionTime(clock.nowUtc().minusDays(5)) .setDeletionTime(clock.nowUtc().minusDays(5))
@ -722,9 +720,9 @@ public class DeleteContactsAndHostsActionTest
@Test @Test
public void testSuccess_subordinateHost_getsDeleted() throws Exception { public void testSuccess_subordinateHost_getsDeleted() throws Exception {
DomainResource domain = DomainBase domain =
persistResource( persistResource(
newDomainResource("example.tld") newDomainBase("example.tld")
.asBuilder() .asBuilder()
.setSubordinateHosts(ImmutableSet.of("ns2.example.tld")) .setSubordinateHosts(ImmutableSet.of("ns2.example.tld"))
.build()); .build());
@ -745,7 +743,7 @@ public class DeleteContactsAndHostsActionTest
assertThat(loadByForeignKey(HostResource.class, "ns2.example.tld", clock.nowUtc())).isEmpty(); assertThat(loadByForeignKey(HostResource.class, "ns2.example.tld", clock.nowUtc())).isEmpty();
assertNoBillingEvents(); assertNoBillingEvents();
assertThat( assertThat(
loadByForeignKey(DomainResource.class, "example.tld", clock.nowUtc()) loadByForeignKey(DomainBase.class, "example.tld", clock.nowUtc())
.get() .get()
.getSubordinateHosts()) .getSubordinateHosts())
.isEmpty(); .isEmpty();
@ -940,10 +938,10 @@ public class DeleteContactsAndHostsActionTest
newHostResource(hostName).asBuilder().addStatusValue(PENDING_DELETE).build()); newHostResource(hostName).asBuilder().addStatusValue(PENDING_DELETE).build());
} }
private static DomainResource persistUsedDomain( private static DomainBase persistUsedDomain(
String domainName, ContactResource contact, HostResource host) { String domainName, ContactResource contact, HostResource host) {
return persistResource( return persistResource(
newDomainResource(domainName, contact) newDomainBase(domainName, contact)
.asBuilder() .asBuilder()
.setNameservers(ImmutableSet.of(Key.create(host))) .setNameservers(ImmutableSet.of(Key.create(host)))
.build()); .build());

View file

@ -19,7 +19,7 @@ import static com.google.common.truth.Truth8.assertThat;
import static google.registry.model.EppResourceUtils.loadByForeignKey; import static google.registry.model.EppResourceUtils.loadByForeignKey;
import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.testing.DatastoreHelper.createTld; 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.persistActiveDomain;
import static google.registry.testing.DatastoreHelper.persistActiveHost; import static google.registry.testing.DatastoreHelper.persistActiveHost;
import static google.registry.testing.DatastoreHelper.persistDeletedDomain; 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.ImmutableObject;
import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Reason; 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.EppResourceIndex;
import google.registry.model.index.ForeignKeyIndex; import google.registry.model.index.ForeignKeyIndex;
import google.registry.model.poll.PollMessage; import google.registry.model.poll.PollMessage;
@ -163,9 +163,9 @@ public class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDa
@Test @Test
public void testSuccess_doesntDeleteNicDomainForProbers() throws Exception { public void testSuccess_doesntDeleteNicDomainForProbers() throws Exception {
DomainResource nic = persistActiveDomain("nic.ib-any.test"); DomainBase nic = persistActiveDomain("nic.ib-any.test");
ForeignKeyIndex<DomainResource> fkiNic = ForeignKeyIndex<DomainBase> fkiNic =
ForeignKeyIndex.load(DomainResource.class, "nic.ib-any.test", START_OF_TIME); ForeignKeyIndex.load(DomainBase.class, "nic.ib-any.test", START_OF_TIME);
Set<ImmutableObject> ibEntities = persistLotsOfDomains("ib-any.test"); Set<ImmutableObject> ibEntities = persistLotsOfDomains("ib-any.test");
runMapreduce(); runMapreduce();
assertDeleted(ibEntities); assertDeleted(ibEntities);
@ -184,14 +184,14 @@ public class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDa
@Test @Test
public void testSuccess_activeDomain_isSoftDeleted() throws Exception { public void testSuccess_activeDomain_isSoftDeleted() throws Exception {
DomainResource domain = persistResource( DomainBase domain = persistResource(
newDomainResource("blah.ib-any.test") newDomainBase("blah.ib-any.test")
.asBuilder() .asBuilder()
.setCreationTimeForTest(DateTime.now(UTC).minusYears(1)) .setCreationTimeForTest(DateTime.now(UTC).minusYears(1))
.build()); .build());
runMapreduce(); runMapreduce();
DateTime timeAfterDeletion = DateTime.now(UTC); DateTime timeAfterDeletion = DateTime.now(UTC);
assertThat(loadByForeignKey(DomainResource.class, "blah.ib-any.test", timeAfterDeletion)) assertThat(loadByForeignKey(DomainBase.class, "blah.ib-any.test", timeAfterDeletion))
.isEmpty(); .isEmpty();
assertThat(ofy().load().entity(domain).now().getDeletionTime()).isLessThan(timeAfterDeletion); assertThat(ofy().load().entity(domain).now().getDeletionTime()).isLessThan(timeAfterDeletion);
assertDnsTasksEnqueued("blah.ib-any.test"); assertDnsTasksEnqueued("blah.ib-any.test");
@ -199,8 +199,8 @@ public class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDa
@Test @Test
public void testSuccess_activeDomain_doubleMapSoftDeletes() throws Exception { public void testSuccess_activeDomain_doubleMapSoftDeletes() throws Exception {
DomainResource domain = persistResource( DomainBase domain = persistResource(
newDomainResource("blah.ib-any.test") newDomainBase("blah.ib-any.test")
.asBuilder() .asBuilder()
.setCreationTimeForTest(DateTime.now(UTC).minusYears(1)) .setCreationTimeForTest(DateTime.now(UTC).minusYears(1))
.build()); .build());
@ -208,7 +208,7 @@ public class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDa
DateTime timeAfterDeletion = DateTime.now(UTC); DateTime timeAfterDeletion = DateTime.now(UTC);
resetAction(); resetAction();
runMapreduce(); runMapreduce();
assertThat(loadByForeignKey(DomainResource.class, "blah.ib-any.test", timeAfterDeletion)) assertThat(loadByForeignKey(DomainBase.class, "blah.ib-any.test", timeAfterDeletion))
.isEmpty(); .isEmpty();
assertThat(ofy().load().entity(domain).now().getDeletionTime()).isLessThan(timeAfterDeletion); assertThat(ofy().load().entity(domain).now().getDeletionTime()).isLessThan(timeAfterDeletion);
assertDnsTasksEnqueued("blah.ib-any.test"); assertDnsTasksEnqueued("blah.ib-any.test");
@ -217,21 +217,21 @@ public class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDa
@Test @Test
public void test_recentlyCreatedDomain_isntDeletedYet() throws Exception { public void test_recentlyCreatedDomain_isntDeletedYet() throws Exception {
persistResource( persistResource(
newDomainResource("blah.ib-any.test") newDomainBase("blah.ib-any.test")
.asBuilder() .asBuilder()
.setCreationTimeForTest(DateTime.now(UTC).minusSeconds(1)) .setCreationTimeForTest(DateTime.now(UTC).minusSeconds(1))
.build()); .build());
runMapreduce(); runMapreduce();
Optional<DomainResource> domain = Optional<DomainBase> domain =
loadByForeignKey(DomainResource.class, "blah.ib-any.test", DateTime.now(UTC)); loadByForeignKey(DomainBase.class, "blah.ib-any.test", DateTime.now(UTC));
assertThat(domain).isPresent(); assertThat(domain).isPresent();
assertThat(domain.get().getDeletionTime()).isEqualTo(END_OF_TIME); assertThat(domain.get().getDeletionTime()).isEqualTo(END_OF_TIME);
} }
@Test @Test
public void testDryRun_doesntSoftDeleteData() throws Exception { public void testDryRun_doesntSoftDeleteData() throws Exception {
DomainResource domain = persistResource( DomainBase domain = persistResource(
newDomainResource("blah.ib-any.test") newDomainBase("blah.ib-any.test")
.asBuilder() .asBuilder()
.setCreationTimeForTest(DateTime.now(UTC).minusYears(1)) .setCreationTimeForTest(DateTime.now(UTC).minusYears(1))
.build()); .build());
@ -243,11 +243,11 @@ public class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDa
@Test @Test
public void test_domainWithSubordinateHosts_isSkipped() throws Exception { public void test_domainWithSubordinateHosts_isSkipped() throws Exception {
persistActiveHost("ns1.blah.ib-any.test"); persistActiveHost("ns1.blah.ib-any.test");
DomainResource nakedDomain = DomainBase nakedDomain =
persistDeletedDomain("todelete.ib-any.test", DateTime.now(UTC).minusYears(1)); persistDeletedDomain("todelete.ib-any.test", DateTime.now(UTC).minusYears(1));
DomainResource domainWithSubord = DomainBase domainWithSubord =
persistDomainAsDeleted( persistDomainAsDeleted(
newDomainResource("blah.ib-any.test") newDomainBase("blah.ib-any.test")
.asBuilder() .asBuilder()
.setSubordinateHosts(ImmutableSet.of("ns1.blah.ib-any.test")) .setSubordinateHosts(ImmutableSet.of("ns1.blah.ib-any.test"))
.build(), .build(),
@ -260,7 +260,7 @@ public class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDa
@Test @Test
public void testFailure_registryAdminClientId_isRequiredForSoftDeletion() { public void testFailure_registryAdminClientId_isRequiredForSoftDeletion() {
persistResource( persistResource(
newDomainResource("blah.ib-any.test") newDomainBase("blah.ib-any.test")
.asBuilder() .asBuilder()
.setCreationTimeForTest(DateTime.now(UTC).minusYears(1)) .setCreationTimeForTest(DateTime.now(UTC).minusYears(1))
.build()); .build());
@ -274,7 +274,7 @@ public class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDa
* along with the ForeignKeyIndex and EppResourceIndex. * along with the ForeignKeyIndex and EppResourceIndex.
*/ */
private static Set<ImmutableObject> persistDomainAndDescendants(String fqdn) { private static Set<ImmutableObject> persistDomainAndDescendants(String fqdn) {
DomainResource domain = persistDeletedDomain(fqdn, DELETION_TIME); DomainBase domain = persistDeletedDomain(fqdn, DELETION_TIME);
HistoryEntry historyEntry = persistSimpleResource( HistoryEntry historyEntry = persistSimpleResource(
new HistoryEntry.Builder() new HistoryEntry.Builder()
.setParent(domain) .setParent(domain)
@ -298,8 +298,8 @@ public class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDa
.setClientId("TheRegistrar") .setClientId("TheRegistrar")
.setMsg("Domain registered") .setMsg("Domain registered")
.build()); .build());
ForeignKeyIndex<DomainResource> fki = ForeignKeyIndex<DomainBase> fki =
ForeignKeyIndex.load(DomainResource.class, fqdn, START_OF_TIME); ForeignKeyIndex.load(DomainBase.class, fqdn, START_OF_TIME);
EppResourceIndex eppIndex = EppResourceIndex eppIndex =
ofy().load().entity(EppResourceIndex.create(Key.create(domain))).now(); ofy().load().entity(EppResourceIndex.create(Key.create(domain))).now();
return ImmutableSet.of( return ImmutableSet.of(

View file

@ -42,7 +42,7 @@ import google.registry.model.billing.BillingEvent.Flag;
import google.registry.model.billing.BillingEvent.OneTime; import google.registry.model.billing.BillingEvent.OneTime;
import google.registry.model.billing.BillingEvent.Reason; import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.common.Cursor; 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.domain.Period;
import google.registry.model.ofy.Ofy; import google.registry.model.ofy.Ofy;
import google.registry.model.registry.Registry; 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 DateTime beginningOfTest = DateTime.parse("2000-10-02T00:00:00Z");
private final FakeClock clock = new FakeClock(beginningOfTest); private final FakeClock clock = new FakeClock(beginningOfTest);
DomainResource domain; DomainBase domain;
HistoryEntry historyEntry; HistoryEntry historyEntry;
BillingEvent.Recurring recurring; BillingEvent.Recurring recurring;
@ -118,7 +118,7 @@ public class ExpandRecurringBillingEventsActionTest
} }
void assertHistoryEntryMatches( void assertHistoryEntryMatches(
DomainResource domain, HistoryEntry actual, String clientId, DateTime billingTime) { DomainBase domain, HistoryEntry actual, String clientId, DateTime billingTime) {
assertThat(actual.getBySuperuser()).isFalse(); assertThat(actual.getBySuperuser()).isFalse();
assertThat(actual.getClientId()).isEqualTo(clientId); assertThat(actual.getClientId()).isEqualTo(clientId);
assertThat(actual.getParent()).isEqualTo(Key.create(domain)); assertThat(actual.getParent()).isEqualTo(Key.create(domain));
@ -168,7 +168,7 @@ public class ExpandRecurringBillingEventsActionTest
@Test @Test
public void testSuccess_expandSingleEvent_deletedDomain() throws Exception { public void testSuccess_expandSingleEvent_deletedDomain() throws Exception {
DateTime deletionTime = DateTime.parse("2000-08-01T00:00:00Z"); 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()); historyEntry = persistResource(new HistoryEntry.Builder().setParent(deletedDomain).build());
recurring = persistResource(new BillingEvent.Recurring.Builder() recurring = persistResource(new BillingEvent.Recurring.Builder()
.setParent(historyEntry) .setParent(historyEntry)

View file

@ -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.batch.AsyncTaskMetrics.OperationType.DNS_REFRESH;
import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.testing.DatastoreHelper.createTld; 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.newHostResource;
import static google.registry.testing.DatastoreHelper.persistActiveHost; import static google.registry.testing.DatastoreHelper.persistActiveHost;
import static google.registry.testing.DatastoreHelper.persistDeletedHost; 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.FakeResponse;
import google.registry.testing.FakeSleeper; import google.registry.testing.FakeSleeper;
import google.registry.testing.InjectRule; import google.registry.testing.InjectRule;
import google.registry.testing.MockitoJUnitRule;
import google.registry.testing.TaskQueueHelper.TaskMatcher; import google.registry.testing.TaskQueueHelper.TaskMatcher;
import google.registry.testing.mapreduce.MapreduceTestCase; import google.registry.testing.mapreduce.MapreduceTestCase;
import google.registry.util.AppEngineServiceUtils; import google.registry.util.AppEngineServiceUtils;
@ -77,7 +76,6 @@ public class RefreshDnsOnHostRenameActionTest
extends MapreduceTestCase<RefreshDnsOnHostRenameAction> { extends MapreduceTestCase<RefreshDnsOnHostRenameAction> {
@Rule public final InjectRule inject = new InjectRule(); @Rule public final InjectRule inject = new InjectRule();
@Rule public final MockitoJUnitRule mocks = MockitoJUnitRule.create();
private AsyncTaskEnqueuer enqueuer; private AsyncTaskEnqueuer enqueuer;
private final FakeClock clock = new FakeClock(DateTime.parse("2015-01-15T11:22:33Z")); private final FakeClock clock = new FakeClock(DateTime.parse("2015-01-15T11:22:33Z"));
@ -135,9 +133,9 @@ public class RefreshDnsOnHostRenameActionTest
@Test @Test
public void testSuccess_dnsUpdateEnqueued() throws Exception { public void testSuccess_dnsUpdateEnqueued() throws Exception {
HostResource host = persistActiveHost("ns1.example.tld"); HostResource host = persistActiveHost("ns1.example.tld");
persistResource(newDomainResource("example.tld", host)); persistResource(newDomainBase("example.tld", host));
persistResource(newDomainResource("otherexample.tld", host)); persistResource(newDomainBase("otherexample.tld", host));
persistResource(newDomainResource("untouched.tld", persistActiveHost("ns2.example.tld"))); persistResource(newDomainBase("untouched.tld", persistActiveHost("ns2.example.tld")));
DateTime timeEnqueued = clock.nowUtc(); DateTime timeEnqueued = clock.nowUtc();
enqueuer.enqueueAsyncDnsRefresh(host, timeEnqueued); enqueuer.enqueueAsyncDnsRefresh(host, timeEnqueued);
runMapreduce(); runMapreduce();
@ -154,9 +152,9 @@ public class RefreshDnsOnHostRenameActionTest
HostResource host1 = persistActiveHost("ns1.example.tld"); HostResource host1 = persistActiveHost("ns1.example.tld");
HostResource host2 = persistActiveHost("ns2.example.tld"); HostResource host2 = persistActiveHost("ns2.example.tld");
HostResource host3 = persistActiveHost("ns3.example.tld"); HostResource host3 = persistActiveHost("ns3.example.tld");
persistResource(newDomainResource("example1.tld", host1)); persistResource(newDomainBase("example1.tld", host1));
persistResource(newDomainResource("example2.tld", host2)); persistResource(newDomainBase("example2.tld", host2));
persistResource(newDomainResource("example3.tld", host3)); persistResource(newDomainBase("example3.tld", host3));
DateTime timeEnqueued = clock.nowUtc(); DateTime timeEnqueued = clock.nowUtc();
DateTime laterTimeEnqueued = timeEnqueued.plus(standardSeconds(10)); DateTime laterTimeEnqueued = timeEnqueued.plus(standardSeconds(10));
enqueuer.enqueueAsyncDnsRefresh(host1, timeEnqueued); enqueuer.enqueueAsyncDnsRefresh(host1, timeEnqueued);
@ -176,7 +174,7 @@ public class RefreshDnsOnHostRenameActionTest
@Test @Test
public void testSuccess_deletedHost_doesntTriggerDnsRefresh() throws Exception { public void testSuccess_deletedHost_doesntTriggerDnsRefresh() throws Exception {
HostResource host = persistDeletedHost("ns11.fakesss.tld", clock.nowUtc().minusDays(4)); HostResource host = persistDeletedHost("ns11.fakesss.tld", clock.nowUtc().minusDays(4));
persistResource(newDomainResource("example1.tld", host)); persistResource(newDomainBase("example1.tld", host));
DateTime timeEnqueued = clock.nowUtc(); DateTime timeEnqueued = clock.nowUtc();
enqueuer.enqueueAsyncDnsRefresh(host, timeEnqueued); enqueuer.enqueueAsyncDnsRefresh(host, timeEnqueued);
runMapreduce(); runMapreduce();
@ -192,7 +190,7 @@ public class RefreshDnsOnHostRenameActionTest
public void testSuccess_noDnsTasksForDeletedDomain() throws Exception { public void testSuccess_noDnsTasksForDeletedDomain() throws Exception {
HostResource renamedHost = persistActiveHost("ns1.example.tld"); HostResource renamedHost = persistActiveHost("ns1.example.tld");
persistResource( persistResource(
newDomainResource("example.tld", renamedHost) newDomainBase("example.tld", renamedHost)
.asBuilder() .asBuilder()
.setDeletionTime(START_OF_TIME) .setDeletionTime(START_OF_TIME)
.build()); .build());

View file

@ -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.batch.AsyncTaskEnqueuer.QUEUE_ASYNC_HOST_RENAME;
import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.testing.DatastoreHelper.createTld; 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.persistActiveContact;
import static google.registry.testing.DatastoreHelper.persistDomainWithDependentResources; import static google.registry.testing.DatastoreHelper.persistDomainWithDependentResources;
import static google.registry.testing.DatastoreHelper.persistDomainWithPendingTransfer; 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.google.common.collect.ImmutableSortedSet;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.model.ImmutableObject; 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.GracePeriod;
import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.domain.rgp.GracePeriodStatus;
import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.StatusValue;
@ -106,7 +106,7 @@ public class ResaveEntityActionTest extends ShardableTestCase {
@Test @Test
public void test_domainPendingTransfer_isResavedAndTransferCompleted() { public void test_domainPendingTransfer_isResavedAndTransferCompleted() {
DomainResource domain = DomainBase domain =
persistDomainWithPendingTransfer( persistDomainWithPendingTransfer(
persistDomainWithDependentResources( persistDomainWithDependentResources(
"domain", "domain",
@ -122,16 +122,16 @@ public class ResaveEntityActionTest extends ShardableTestCase {
clock.advanceOneMilli(); clock.advanceOneMilli();
assertThat(domain.getCurrentSponsorClientId()).isEqualTo("TheRegistrar"); assertThat(domain.getCurrentSponsorClientId()).isEqualTo("TheRegistrar");
runAction(Key.create(domain), DateTime.parse("2016-02-06T10:00:01Z"), ImmutableSortedSet.of()); 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"); assertThat(resavedDomain.getCurrentSponsorClientId()).isEqualTo("NewRegistrar");
verify(response).setPayload("Entity re-saved."); verify(response).setPayload("Entity re-saved.");
} }
@Test @Test
public void test_domainPendingDeletion_isResavedAndReenqueued() { public void test_domainPendingDeletion_isResavedAndReenqueued() {
DomainResource domain = DomainBase domain =
persistResource( persistResource(
newDomainResource("domain.tld") newDomainBase("domain.tld")
.asBuilder() .asBuilder()
.setDeletionTime(clock.nowUtc().plusDays(35)) .setDeletionTime(clock.nowUtc().plusDays(35))
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE)) .setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
@ -147,7 +147,7 @@ public class ResaveEntityActionTest extends ShardableTestCase {
assertThat(domain.getGracePeriods()).isNotEmpty(); assertThat(domain.getGracePeriods()).isNotEmpty();
runAction(Key.create(domain), requestedTime, ImmutableSortedSet.of(requestedTime.plusDays(5))); 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(); assertThat(resavedDomain.getGracePeriods()).isEmpty();
assertTasksEnqueued( assertTasksEnqueued(

View file

@ -33,7 +33,7 @@ import google.registry.dns.DnsMetrics.ActionStatus;
import google.registry.dns.DnsMetrics.CommitStatus; import google.registry.dns.DnsMetrics.CommitStatus;
import google.registry.dns.DnsMetrics.PublishStatus; import google.registry.dns.DnsMetrics.PublishStatus;
import google.registry.dns.writer.DnsWriter; 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.ofy.Ofy;
import google.registry.model.registry.Registry; import google.registry.model.registry.Registry;
import google.registry.request.HttpException.ServiceUnavailableException; import google.registry.request.HttpException.ServiceUnavailableException;
@ -78,10 +78,10 @@ public class PublishDnsUpdatesActionTest {
.asBuilder() .asBuilder()
.setDnsWriters(ImmutableSet.of("correctWriter")) .setDnsWriters(ImmutableSet.of("correctWriter"))
.build()); .build());
DomainResource domain1 = persistActiveDomain("example.xn--q9jyb4c"); DomainBase domain1 = persistActiveDomain("example.xn--q9jyb4c");
persistActiveSubordinateHost("ns1.example.xn--q9jyb4c", domain1); persistActiveSubordinateHost("ns1.example.xn--q9jyb4c", domain1);
persistActiveSubordinateHost("ns2.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); persistActiveSubordinateHost("ns1.example.xn--q9jyb4c", domain2);
clock.advanceOneMilli(); clock.advanceOneMilli();
} }

View file

@ -25,7 +25,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
import google.registry.dns.DnsConstants.TargetType; 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.BadRequestException;
import google.registry.request.HttpException.NotFoundException; import google.registry.request.HttpException.NotFoundException;
import google.registry.testing.AppEngineRule; import google.registry.testing.AppEngineRule;
@ -64,7 +64,7 @@ public class RefreshDnsActionTest {
@Test @Test
public void testSuccess_host() { public void testSuccess_host() {
DomainResource domain = persistActiveDomain("example.xn--q9jyb4c"); DomainBase domain = persistActiveDomain("example.xn--q9jyb4c");
persistActiveSubordinateHost("ns1.example.xn--q9jyb4c", domain); persistActiveSubordinateHost("ns1.example.xn--q9jyb4c", domain);
run(TargetType.HOST, "ns1.example.xn--q9jyb4c"); run(TargetType.HOST, "ns1.example.xn--q9jyb4c");
verify(dnsQueue).addHostRefreshTask("ns1.example.xn--q9jyb4c"); verify(dnsQueue).addHostRefreshTask("ns1.example.xn--q9jyb4c");

View file

@ -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.io.BaseEncoding.base16;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.DatastoreHelper.createTld; 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.newHostResource;
import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.DatastoreHelper.persistResource;
import static org.mockito.Matchers.anyString; 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.google.common.util.concurrent.RateLimiter;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.dns.writer.clouddns.CloudDnsWriter.ZoneStateException; 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.domain.secdns.DelegationSignerData;
import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource; import google.registry.model.host.HostResource;
@ -281,7 +281,7 @@ public class CloudDnsWriterTest {
} }
/** Returns a domain to be persisted in Datastore. */ /** Returns a domain to be persisted in Datastore. */
private static DomainResource fakeDomain( private static DomainBase fakeDomain(
String domainName, ImmutableSet<HostResource> nameservers, int numDsRecords) { String domainName, ImmutableSet<HostResource> nameservers, int numDsRecords) {
ImmutableSet.Builder<DelegationSignerData> dsDataBuilder = new ImmutableSet.Builder<>(); ImmutableSet.Builder<DelegationSignerData> dsDataBuilder = new ImmutableSet.Builder<>();
@ -294,7 +294,7 @@ public class CloudDnsWriterTest {
hostResourceRefBuilder.add(Key.create(nameserver)); hostResourceRefBuilder.add(Key.create(nameserver));
} }
return newDomainResource(domainName) return newDomainBase(domainName)
.asBuilder() .asBuilder()
.setNameservers(hostResourceRefBuilder.build()) .setNameservers(hostResourceRefBuilder.build())
.setDsData(dsDataBuilder.build()) .setDsData(dsDataBuilder.build())

View file

@ -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.assertThat;
import static com.google.common.truth.Truth.assert_; import static com.google.common.truth.Truth.assert_;
import static google.registry.testing.DatastoreHelper.createTld; 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.newHostResource;
import static google.registry.testing.DatastoreHelper.persistActiveDomain; import static google.registry.testing.DatastoreHelper.persistActiveDomain;
import static google.registry.testing.DatastoreHelper.persistActiveHost; 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.collect.ImmutableSet;
import com.google.common.net.InetAddresses; import com.google.common.net.InetAddresses;
import com.googlecode.objectify.Key; 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.domain.secdns.DelegationSignerData;
import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource; import google.registry.model.host.HostResource;
@ -102,7 +102,7 @@ public class DnsUpdateWriterTest {
public void testPublishDomainCreate_publishesNameServers() throws Exception { public void testPublishDomainCreate_publishesNameServers() throws Exception {
HostResource host1 = persistActiveHost("ns1.example.tld"); HostResource host1 = persistActiveHost("ns1.example.tld");
HostResource host2 = persistActiveHost("ns2.example.tld"); HostResource host2 = persistActiveHost("ns2.example.tld");
DomainResource domain = DomainBase domain =
persistActiveDomain("example.tld") persistActiveDomain("example.tld")
.asBuilder() .asBuilder()
.setNameservers(ImmutableSet.of(Key.create(host1), Key.create(host2))) .setNameservers(ImmutableSet.of(Key.create(host1), Key.create(host2)))
@ -123,7 +123,7 @@ public class DnsUpdateWriterTest {
@Test @Test
public void testPublishAtomic_noCommit() { public void testPublishAtomic_noCommit() {
HostResource host1 = persistActiveHost("ns.example1.tld"); HostResource host1 = persistActiveHost("ns.example1.tld");
DomainResource domain1 = DomainBase domain1 =
persistActiveDomain("example1.tld") persistActiveDomain("example1.tld")
.asBuilder() .asBuilder()
.setNameservers(ImmutableSet.of(Key.create(host1))) .setNameservers(ImmutableSet.of(Key.create(host1)))
@ -131,7 +131,7 @@ public class DnsUpdateWriterTest {
persistResource(domain1); persistResource(domain1);
HostResource host2 = persistActiveHost("ns.example2.tld"); HostResource host2 = persistActiveHost("ns.example2.tld");
DomainResource domain2 = DomainBase domain2 =
persistActiveDomain("example2.tld") persistActiveDomain("example2.tld")
.asBuilder() .asBuilder()
.setNameservers(ImmutableSet.of(Key.create(host2))) .setNameservers(ImmutableSet.of(Key.create(host2)))
@ -147,7 +147,7 @@ public class DnsUpdateWriterTest {
@Test @Test
public void testPublishAtomic_oneUpdate() throws Exception { public void testPublishAtomic_oneUpdate() throws Exception {
HostResource host1 = persistActiveHost("ns.example1.tld"); HostResource host1 = persistActiveHost("ns.example1.tld");
DomainResource domain1 = DomainBase domain1 =
persistActiveDomain("example1.tld") persistActiveDomain("example1.tld")
.asBuilder() .asBuilder()
.setNameservers(ImmutableSet.of(Key.create(host1))) .setNameservers(ImmutableSet.of(Key.create(host1)))
@ -155,7 +155,7 @@ public class DnsUpdateWriterTest {
persistResource(domain1); persistResource(domain1);
HostResource host2 = persistActiveHost("ns.example2.tld"); HostResource host2 = persistActiveHost("ns.example2.tld");
DomainResource domain2 = DomainBase domain2 =
persistActiveDomain("example2.tld") persistActiveDomain("example2.tld")
.asBuilder() .asBuilder()
.setNameservers(ImmutableSet.of(Key.create(host2))) .setNameservers(ImmutableSet.of(Key.create(host2)))
@ -178,7 +178,7 @@ public class DnsUpdateWriterTest {
@Test @Test
public void testPublishDomainCreate_publishesDelegationSigner() throws Exception { public void testPublishDomainCreate_publishesDelegationSigner() throws Exception {
DomainResource domain = DomainBase domain =
persistActiveDomain("example.tld") persistActiveDomain("example.tld")
.asBuilder() .asBuilder()
.setNameservers(ImmutableSet.of(Key.create(persistActiveHost("ns1.example.tld")))) .setNameservers(ImmutableSet.of(Key.create(persistActiveHost("ns1.example.tld"))))
@ -202,7 +202,7 @@ public class DnsUpdateWriterTest {
@Test @Test
public void testPublishDomainWhenNotActive_removesDnsRecords() throws Exception { public void testPublishDomainWhenNotActive_removesDnsRecords() throws Exception {
DomainResource domain = DomainBase domain =
persistActiveDomain("example.tld") persistActiveDomain("example.tld")
.asBuilder() .asBuilder()
.addStatusValue(StatusValue.SERVER_HOLD) .addStatusValue(StatusValue.SERVER_HOLD)
@ -247,7 +247,7 @@ public class DnsUpdateWriterTest {
InetAddresses.forString("fd0e:a5c8:6dfb:6a5e:0:0:0:1"))) InetAddresses.forString("fd0e:a5c8:6dfb:6a5e:0:0:0:1")))
.build()); .build());
persistResource( persistResource(
newDomainResource("example.tld") newDomainBase("example.tld")
.asBuilder() .asBuilder()
.addSubordinateHost("ns1.example.tld") .addSubordinateHost("ns1.example.tld")
.addNameserver(Key.create(host)) .addNameserver(Key.create(host))
@ -319,7 +319,7 @@ public class DnsUpdateWriterTest {
.build()); .build());
persistResource( persistResource(
newDomainResource("example.tld") newDomainBase("example.tld")
.asBuilder() .asBuilder()
.addSubordinateHost("ns1.example.tld") .addSubordinateHost("ns1.example.tld")
.addNameservers( .addNameservers(
@ -354,7 +354,7 @@ public class DnsUpdateWriterTest {
.build()); .build());
persistResource( persistResource(
newDomainResource("example.tld") newDomainBase("example.tld")
.asBuilder() .asBuilder()
.addSubordinateHost("ns1.example.tld") .addSubordinateHost("ns1.example.tld")
.addSubordinateHost("foo.example.tld") .addSubordinateHost("foo.example.tld")
@ -378,7 +378,7 @@ public class DnsUpdateWriterTest {
@Test @Test
public void testPublishDomainFails_whenDnsUpdateReturnsError() throws Exception { public void testPublishDomainFails_whenDnsUpdateReturnsError() throws Exception {
DomainResource domain = DomainBase domain =
persistActiveDomain("example.tld") persistActiveDomain("example.tld")
.asBuilder() .asBuilder()
.setNameservers(ImmutableSet.of(Key.create(persistActiveHost("ns1.example.tld")))) .setNameservers(ImmutableSet.of(Key.create(persistActiveHost("ns1.example.tld"))))

View file

@ -27,7 +27,7 @@ import static org.joda.time.Duration.standardDays;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.flows.EppTestComponent.FakesAndMocksModule; 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.model.ofy.Ofy;
import google.registry.monitoring.whitebox.EppMetric; import google.registry.monitoring.whitebox.EppMetric;
import google.registry.testing.AppEngineRule; 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")); eppLoader = new EppLoader(this, "domain_create.xml", ImmutableMap.of("DOMAIN", "example.tld"));
runFlow(); runFlow();
ofy().clearSessionCache(); ofy().clearSessionCache();
Key<DomainResource> key = Key.create(ofy().load().type(DomainResource.class).first().now()); Key<DomainBase> key = Key.create(ofy().load().type(DomainBase.class).first().now());
DomainResource domainAfterCreate = ofy().load().key(key).now(); DomainBase domainAfterCreate = ofy().load().key(key).now();
assertThat(domainAfterCreate.getFullyQualifiedDomainName()).isEqualTo("example.tld"); assertThat(domainAfterCreate.getFullyQualifiedDomainName()).isEqualTo("example.tld");
clock.advanceBy(standardDays(2)); clock.advanceBy(standardDays(2));
@ -114,7 +114,7 @@ public class EppCommitLogsTest extends ShardableTestCase {
runFlow(); runFlow();
ofy().clearSessionCache(); ofy().clearSessionCache();
DomainResource domainAfterFirstUpdate = ofy().load().key(key).now(); DomainBase domainAfterFirstUpdate = ofy().load().key(key).now();
assertThat(domainAfterCreate).isNotEqualTo(domainAfterFirstUpdate); assertThat(domainAfterCreate).isNotEqualTo(domainAfterFirstUpdate);
clock.advanceOneMilli(); // same day as first update 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"); eppLoader = new EppLoader(this, "domain_update_dsdata_rem.xml");
runFlow(); runFlow();
ofy().clearSessionCache(); ofy().clearSessionCache();
DomainResource domainAfterSecondUpdate = ofy().load().key(key).now(); DomainBase domainAfterSecondUpdate = ofy().load().key(key).now();
clock.advanceBy(standardDays(2)); clock.advanceBy(standardDays(2));
DateTime timeAtDelete = clock.nowUtc(); // before 'add' grace period ends DateTime timeAtDelete = clock.nowUtc(); // before 'add' grace period ends
@ -133,7 +133,7 @@ public class EppCommitLogsTest extends ShardableTestCase {
assertThat(domainAfterFirstUpdate).isNotEqualTo(domainAfterSecondUpdate); assertThat(domainAfterFirstUpdate).isNotEqualTo(domainAfterSecondUpdate);
// Point-in-time can only rewind an object from the current version, not roll forward. // 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. // Creation time has millisecond granularity due to isActive() check.
ofy().clearSessionCache(); ofy().clearSessionCache();

View file

@ -38,7 +38,7 @@ import com.google.re2j.Pattern;
import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.OneTime; import google.registry.model.billing.BillingEvent.OneTime;
import google.registry.model.billing.BillingEvent.Reason; 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;
import google.registry.model.registry.Registry.TldState; import google.registry.model.registry.Registry.TldState;
import google.registry.model.reporting.HistoryEntry.Type; import google.registry.model.reporting.HistoryEntry.Type;
@ -110,8 +110,8 @@ public class EppLifecycleDomainTest extends EppTestCase {
"CRDATE", "2000-06-01T00:02:00.0Z", "CRDATE", "2000-06-01T00:02:00.0Z",
"EXDATE", "2002-06-01T00:02:00.0Z")); "EXDATE", "2002-06-01T00:02:00.0Z"));
DomainResource domain = DomainBase domain =
loadByForeignKey(DomainResource.class, "example.tld", createTime.plusHours(1)).get(); loadByForeignKey(DomainBase.class, "example.tld", createTime.plusHours(1)).get();
// Delete domain example.tld within the add grace period. // Delete domain example.tld within the add grace period.
DateTime deleteTime = createTime.plusDays(1); DateTime deleteTime = createTime.plusDays(1);
@ -186,9 +186,9 @@ public class EppLifecycleDomainTest extends EppTestCase {
ImmutableMap.of( ImmutableMap.of(
"CODE", "2303", "MSG", "The domain with given ID (example.tld) doesn't exist.")); "CODE", "2303", "MSG", "The domain with given ID (example.tld) doesn't exist."));
DomainResource domain = DomainBase domain =
loadByForeignKey( loadByForeignKey(
DomainResource.class, "example.tld", DateTime.parse("2000-08-01T00:02:00Z")) DomainBase.class, "example.tld", DateTime.parse("2000-08-01T00:02:00Z"))
.get(); .get();
// Verify that the autorenew was ended and that the one-time billing event is not canceled. // Verify that the autorenew was ended and that the one-time billing event is not canceled.
assertBillingEventsForResource( assertBillingEventsForResource(
@ -221,9 +221,9 @@ public class EppLifecycleDomainTest extends EppTestCase {
.atTime(createTime) .atTime(createTime)
.hasResponse("domain_create_response_eap_fee.xml"); .hasResponse("domain_create_response_eap_fee.xml");
DomainResource domain = DomainBase domain =
loadByForeignKey( loadByForeignKey(
DomainResource.class, "example.tld", DateTime.parse("2000-06-01T00:03:00Z")) DomainBase.class, "example.tld", DateTime.parse("2000-06-01T00:03:00Z"))
.get(); .get();
// Delete domain example.tld within the add grade period. // Delete domain example.tld within the add grade period.

View file

@ -25,7 +25,7 @@ import static google.registry.testing.HostResourceSubject.assertAboutHosts;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.googlecode.objectify.Key; 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.model.host.HostResource;
import google.registry.testing.AppEngineRule; import google.registry.testing.AppEngineRule;
import org.joda.time.DateTime; import org.joda.time.DateTime;
@ -219,8 +219,8 @@ public class EppLifecycleHostTest extends EppTestCase {
HostResource exampleBarFooTldHost = HostResource exampleBarFooTldHost =
loadByForeignKey(HostResource.class, "ns1.example.bar.foo.tld", timeAfterCreates).get(); loadByForeignKey(HostResource.class, "ns1.example.bar.foo.tld", timeAfterCreates).get();
DomainResource exampleBarFooTldDomain = DomainBase exampleBarFooTldDomain =
loadByForeignKey(DomainResource.class, "example.bar.foo.tld", timeAfterCreates).get(); loadByForeignKey(DomainBase.class, "example.bar.foo.tld", timeAfterCreates).get();
assertAboutHosts() assertAboutHosts()
.that(exampleBarFooTldHost) .that(exampleBarFooTldHost)
.hasSuperordinateDomain(Key.create(exampleBarFooTldDomain)); .hasSuperordinateDomain(Key.create(exampleBarFooTldDomain));
@ -229,8 +229,8 @@ public class EppLifecycleHostTest extends EppTestCase {
HostResource exampleFooTldHost = HostResource exampleFooTldHost =
loadByForeignKey(HostResource.class, "ns1.example.foo.tld", timeAfterCreates).get(); loadByForeignKey(HostResource.class, "ns1.example.foo.tld", timeAfterCreates).get();
DomainResource exampleFooTldDomain = DomainBase exampleFooTldDomain =
loadByForeignKey(DomainResource.class, "example.foo.tld", timeAfterCreates).get(); loadByForeignKey(DomainBase.class, "example.foo.tld", timeAfterCreates).get();
assertAboutHosts() assertAboutHosts()
.that(exampleFooTldHost) .that(exampleFooTldHost)
.hasSuperordinateDomain(Key.create(exampleFooTldDomain)); .hasSuperordinateDomain(Key.create(exampleFooTldDomain));
@ -238,8 +238,8 @@ public class EppLifecycleHostTest extends EppTestCase {
HostResource exampleTldHost = HostResource exampleTldHost =
loadByForeignKey(HostResource.class, "ns1.example.tld", timeAfterCreates).get(); loadByForeignKey(HostResource.class, "ns1.example.tld", timeAfterCreates).get();
DomainResource exampleTldDomain = DomainBase exampleTldDomain =
loadByForeignKey(DomainResource.class, "example.tld", timeAfterCreates).get(); loadByForeignKey(DomainBase.class, "example.tld", timeAfterCreates).get();
assertAboutHosts().that(exampleTldHost).hasSuperordinateDomain(Key.create(exampleTldDomain)); assertAboutHosts().that(exampleTldHost).hasSuperordinateDomain(Key.create(exampleTldDomain));
assertThat(exampleTldDomain.getSubordinateHosts()).containsExactly("ns1.example.tld"); assertThat(exampleTldDomain.getSubordinateHosts()).containsExactly("ns1.example.tld");

View file

@ -34,7 +34,7 @@ import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Flag; import google.registry.model.billing.BillingEvent.Flag;
import google.registry.model.billing.BillingEvent.OneTime; import google.registry.model.billing.BillingEvent.OneTime;
import google.registry.model.billing.BillingEvent.Reason; 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.eppcommon.EppXmlTransformer;
import google.registry.model.ofy.Ofy; import google.registry.model.ofy.Ofy;
import google.registry.model.registry.Registry; 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. */ /** Makes a one-time billing event corresponding to the given domain's creation. */
protected static BillingEvent.OneTime makeOneTimeCreateBillingEvent( protected static BillingEvent.OneTime makeOneTimeCreateBillingEvent(
DomainResource domain, DateTime createTime) { DomainBase domain, DateTime createTime) {
return new BillingEvent.OneTime.Builder() return new BillingEvent.OneTime.Builder()
.setReason(Reason.CREATE) .setReason(Reason.CREATE)
.setTargetId(domain.getFullyQualifiedDomainName()) .setTargetId(domain.getFullyQualifiedDomainName())
@ -291,14 +291,14 @@ public class EppTestCase extends ShardableTestCase {
/** Makes a recurring billing event corresponding to the given domain's creation. */ /** Makes a recurring billing event corresponding to the given domain's creation. */
protected static BillingEvent.Recurring makeRecurringCreateBillingEvent( protected static BillingEvent.Recurring makeRecurringCreateBillingEvent(
DomainResource domain, DateTime eventTime, DateTime endTime) { DomainBase domain, DateTime eventTime, DateTime endTime) {
return makeRecurringCreateBillingEvent( return makeRecurringCreateBillingEvent(
domain, getOnlyHistoryEntryOfType(domain, Type.DOMAIN_CREATE), eventTime, endTime); domain, getOnlyHistoryEntryOfType(domain, Type.DOMAIN_CREATE), eventTime, endTime);
} }
/** Makes a recurring billing event corresponding to the given history entry. */ /** Makes a recurring billing event corresponding to the given history entry. */
protected static BillingEvent.Recurring makeRecurringCreateBillingEvent( 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() return new BillingEvent.Recurring.Builder()
.setReason(Reason.RENEW) .setReason(Reason.RENEW)
.setFlags(ImmutableSet.of(Flag.AUTO_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. */ /** Makes a cancellation billing event cancelling out the given domain create billing event. */
protected static BillingEvent.Cancellation makeCancellationBillingEventFor( protected static BillingEvent.Cancellation makeCancellationBillingEventFor(
DomainResource domain, DomainBase domain,
OneTime billingEventToCancel, OneTime billingEventToCancel,
DateTime createTime, DateTime createTime,
DateTime deleteTime) { DateTime deleteTime) {

View file

@ -76,7 +76,7 @@ public class FlowReporterTest extends ShardableTestCase {
@Test @Test
public void testRecordToLogs_metadata_basic() throws Exception { 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")); when(flowReporter.eppInput.getResourceType()).thenReturn(Optional.of("domain"));
flowReporter.recordToLogs(); flowReporter.recordToLogs();
assertThat(parseJsonMap(findFirstLogMessageByPrefix(handler, "FLOW-LOG-SIGNATURE-METADATA: "))) assertThat(parseJsonMap(findFirstLogMessageByPrefix(handler, "FLOW-LOG-SIGNATURE-METADATA: ")))
@ -114,7 +114,7 @@ public class FlowReporterTest extends ShardableTestCase {
@Test @Test
public void testRecordToLogs_metadata_notResourceFlow_noResourceTypeOrTld() throws Exception { 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()); when(flowReporter.eppInput.getResourceType()).thenReturn(Optional.empty());
flowReporter.recordToLogs(); flowReporter.recordToLogs();
Map<String, Object> json = Map<String, Object> json =
@ -127,7 +127,7 @@ public class FlowReporterTest extends ShardableTestCase {
@Test @Test
public void testRecordToLogs_metadata_notDomainFlow_noTld() throws Exception { 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")); when(flowReporter.eppInput.getResourceType()).thenReturn(Optional.of("contact"));
flowReporter.recordToLogs(); flowReporter.recordToLogs();
Map<String, Object> json = Map<String, Object> json =
@ -139,7 +139,7 @@ public class FlowReporterTest extends ShardableTestCase {
@Test @Test
public void testRecordToLogs_metadata_multipartDomainName_multipartTld() throws Exception { 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.getResourceType()).thenReturn(Optional.of("domain"));
when(flowReporter.eppInput.getSingleTargetId()).thenReturn(Optional.of("target.co.uk")); when(flowReporter.eppInput.getSingleTargetId()).thenReturn(Optional.of("target.co.uk"));
when(flowReporter.eppInput.getTargetIds()).thenReturn(ImmutableList.of("target.co.uk")); when(flowReporter.eppInput.getTargetIds()).thenReturn(ImmutableList.of("target.co.uk"));
@ -154,7 +154,7 @@ public class FlowReporterTest extends ShardableTestCase {
@Test @Test
public void testRecordToLogs_metadata_multipleTargetIds_uniqueTldSet() throws Exception { 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.getSingleTargetId()).thenReturn(Optional.empty());
when(flowReporter.eppInput.getTargetIds()) when(flowReporter.eppInput.getTargetIds())
.thenReturn(ImmutableList.of("target.co.uk", "foo.uk", "bar.uk", "baz.com")); .thenReturn(ImmutableList.of("target.co.uk", "foo.uk", "bar.uk", "baz.com"));
@ -170,7 +170,7 @@ public class FlowReporterTest extends ShardableTestCase {
@Test @Test
public void testRecordToLogs_metadata_uppercaseDomainName_lowercaseTld() throws Exception { 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.getSingleTargetId()).thenReturn(Optional.of("TARGET.FOO"));
when(flowReporter.eppInput.getTargetIds()).thenReturn(ImmutableList.of("TARGET.FOO")); when(flowReporter.eppInput.getTargetIds()).thenReturn(ImmutableList.of("TARGET.FOO"));
flowReporter.recordToLogs(); flowReporter.recordToLogs();
@ -184,7 +184,7 @@ public class FlowReporterTest extends ShardableTestCase {
@Test @Test
public void testRecordToLogs_metadata_invalidDomainName_stillGuessesTld() throws Exception { 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("<foo@bar.com>")); when(flowReporter.eppInput.getSingleTargetId()).thenReturn(Optional.of("<foo@bar.com>"));
when(flowReporter.eppInput.getTargetIds()).thenReturn(ImmutableList.of("<foo@bar.com>")); when(flowReporter.eppInput.getTargetIds()).thenReturn(ImmutableList.of("<foo@bar.com>"));
flowReporter.recordToLogs(); flowReporter.recordToLogs();
@ -198,7 +198,7 @@ public class FlowReporterTest extends ShardableTestCase {
@Test @Test
public void testRecordToLogs_metadata_domainWithoutPeriod_noTld() throws Exception { 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.getSingleTargetId()).thenReturn(Optional.of("target,foo"));
when(flowReporter.eppInput.getTargetIds()).thenReturn(ImmutableList.of("target,foo")); when(flowReporter.eppInput.getTargetIds()).thenReturn(ImmutableList.of("target,foo"));
flowReporter.recordToLogs(); flowReporter.recordToLogs();

View file

@ -19,7 +19,7 @@ import static google.registry.testing.ContactResourceSubject.assertAboutContacts
import static google.registry.testing.DatastoreHelper.assertNoBillingEvents; import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.newContactResource; 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.persistActiveContact;
import static google.registry.testing.DatastoreHelper.persistDeletedContact; import static google.registry.testing.DatastoreHelper.persistDeletedContact;
import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.DatastoreHelper.persistResource;
@ -166,7 +166,7 @@ public class ContactDeleteFlowTest
public void testFailure_failfastWhenLinkedToDomain() throws Exception { public void testFailure_failfastWhenLinkedToDomain() throws Exception {
createTld("tld"); createTld("tld");
persistResource( persistResource(
newDomainResource("example.tld", persistActiveContact(getUniqueIdFromCommand()))); newDomainBase("example.tld", persistActiveContact(getUniqueIdFromCommand())));
EppException thrown = assertThrows(ResourceToDeleteIsReferencedException.class, this::runFlow); EppException thrown = assertThrows(ResourceToDeleteIsReferencedException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@ -175,7 +175,7 @@ public class ContactDeleteFlowTest
public void testFailure_failfastWhenLinkedToApplication() throws Exception { public void testFailure_failfastWhenLinkedToApplication() throws Exception {
createTld("tld"); createTld("tld");
persistResource( persistResource(
newDomainResource("example.tld", persistActiveContact(getUniqueIdFromCommand()))); newDomainBase("example.tld", persistActiveContact(getUniqueIdFromCommand())));
EppException thrown = assertThrows(ResourceToDeleteIsReferencedException.class, this::runFlow); EppException thrown = assertThrows(ResourceToDeleteIsReferencedException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }

View file

@ -18,7 +18,7 @@ import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.EppResourceUtils.isDeleted; import static google.registry.model.EppResourceUtils.isDeleted;
import static google.registry.testing.DatastoreHelper.assertNoBillingEvents; import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
import static google.registry.testing.DatastoreHelper.createTld; 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.DatastoreHelper.persistResource;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions; import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.testing.JUnitBackports.assertThrows; import static google.registry.testing.JUnitBackports.assertThrows;
@ -110,7 +110,7 @@ public class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, C
@Test @Test
public void testSuccess_linked() throws Exception { public void testSuccess_linked() throws Exception {
createTld("foobar"); createTld("foobar");
persistResource(newDomainResource("example.foobar", persistContactResource(true))); persistResource(newDomainBase("example.foobar", persistContactResource(true)));
// Check that the persisted contact info was returned. // Check that the persisted contact info was returned.
assertTransactionalFlow(false); assertTransactionalFlow(false);
runFlowAssertResponse( runFlowAssertResponse(

View file

@ -59,7 +59,7 @@ import google.registry.flows.domain.DomainFlowUtils.TrailingDashException;
import google.registry.flows.domain.DomainFlowUtils.TransfersAreAlwaysForOneYearException; import google.registry.flows.domain.DomainFlowUtils.TransfersAreAlwaysForOneYearException;
import google.registry.flows.domain.DomainFlowUtils.UnknownFeeCommandException; import google.registry.flows.domain.DomainFlowUtils.UnknownFeeCommandException;
import google.registry.flows.exceptions.TooManyResourceChecksException; import google.registry.flows.exceptions.TooManyResourceChecksException;
import google.registry.model.domain.DomainResource; import google.registry.model.domain.DomainBase;
import google.registry.model.domain.token.AllocationToken; import google.registry.model.domain.token.AllocationToken;
import google.registry.model.registry.Registry; import google.registry.model.registry.Registry;
import google.registry.model.registry.Registry.TldState; import google.registry.model.registry.Registry.TldState;
@ -74,7 +74,7 @@ import org.junit.Test;
/** Unit tests for {@link DomainCheckFlow}. */ /** Unit tests for {@link DomainCheckFlow}. */
public class DomainCheckFlowTest public class DomainCheckFlowTest
extends ResourceCheckFlowTestCase<DomainCheckFlow, DomainResource> { extends ResourceCheckFlowTestCase<DomainCheckFlow, DomainBase> {
public DomainCheckFlowTest() { public DomainCheckFlowTest() {
setEppInput("domain_check_one_tld.xml"); setEppInput("domain_check_one_tld.xml");

View file

@ -33,7 +33,7 @@ import google.registry.flows.domain.DomainFlowUtils.ClaimsPeriodEndedException;
import google.registry.flows.domain.DomainFlowUtils.NotAuthorizedForTldException; import google.registry.flows.domain.DomainFlowUtils.NotAuthorizedForTldException;
import google.registry.flows.domain.DomainFlowUtils.TldDoesNotExistException; import google.registry.flows.domain.DomainFlowUtils.TldDoesNotExistException;
import google.registry.flows.exceptions.TooManyResourceChecksException; 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;
import google.registry.model.registry.Registry.TldState; import google.registry.model.registry.Registry.TldState;
import org.junit.Before; import org.junit.Before;
@ -41,7 +41,7 @@ import org.junit.Test;
/** Unit tests for {@link DomainClaimsCheckFlow}. */ /** Unit tests for {@link DomainClaimsCheckFlow}. */
public class DomainClaimsCheckFlowTest public class DomainClaimsCheckFlowTest
extends ResourceFlowTestCase<DomainClaimsCheckFlow, DomainResource> { extends ResourceFlowTestCase<DomainClaimsCheckFlow, DomainBase> {
public DomainClaimsCheckFlowTest() { public DomainClaimsCheckFlowTest() {
setEppInput("domain_check_claims.xml"); setEppInput("domain_check_claims.xml");

Some files were not shown because too many files have changed in this diff Show more