Rename DomainContent -> DomainBase (#1729)

* Rename DomainContent -> DomainBase

This is a follow-up to PR #1725 which renamed DomainBase to Domain. Now, the
class naming hierarchy has the same structure as ContactBase/HostBase.
This commit is contained in:
Ben McIlwain 2022-08-02 17:21:17 -04:00 committed by GitHub
parent 35530616d6
commit f6d2a7ff91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 131 additions and 138 deletions

View file

@ -195,7 +195,7 @@ public class RdePipeline implements Serializable {
private static final ImmutableMap<Class<? extends HistoryEntry>, String> EPP_RESOURCE_FIELD_NAME = private static final ImmutableMap<Class<? extends HistoryEntry>, String> EPP_RESOURCE_FIELD_NAME =
ImmutableMap.of( ImmutableMap.of(
DomainHistory.class, DomainHistory.class,
"domainContent", "domainBase",
ContactHistory.class, ContactHistory.class,
"contactBase", "contactBase",
HostHistory.class, HostHistory.class,

View file

@ -24,6 +24,7 @@ import google.registry.beam.common.RegistryJpaIO.Read;
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.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainBase;
import google.registry.model.host.HostResource; import google.registry.model.host.HostResource;
import google.registry.persistence.PersistenceModule.TransactionIsolationLevel; import google.registry.persistence.PersistenceModule.TransactionIsolationLevel;
import google.registry.persistence.transaction.CriteriaQueryBuilder; import google.registry.persistence.transaction.CriteriaQueryBuilder;
@ -111,7 +112,7 @@ public class ResaveAllEppResourcesPipeline implements Serializable {
* transfers, grace periods). * transfers, grace periods).
* *
* <p>The logic of what might have changed is paraphrased from {@link * <p>The logic of what might have changed is paraphrased from {@link
* google.registry.model.domain.DomainContent#cloneProjectedAtTime(DateTime)}. * DomainBase#cloneProjectedAtTime(DateTime)}.
*/ */
private void fastResaveDomains(Pipeline pipeline) { private void fastResaveDomains(Pipeline pipeline) {
Read<Domain, Domain> read = Read<Domain, Domain> read =

View file

@ -40,7 +40,7 @@ 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.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainContent; import google.registry.model.domain.DomainBase;
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;
import google.registry.model.eppcommon.AuthInfo; import google.registry.model.eppcommon.AuthInfo;
@ -236,7 +236,7 @@ public final class ResourceFlowUtils {
* @param domain is the domain already projected at approvalTime * @param domain is the domain already projected at approvalTime
*/ */
public static DateTime computeExDateForApprovalTime( public static DateTime computeExDateForApprovalTime(
DomainContent domain, DateTime approvalTime, Period period) { DomainBase domain, DateTime approvalTime, Period period) {
boolean inAutoRenew = domain.getGracePeriodStatuses().contains(GracePeriodStatus.AUTO_RENEW); boolean inAutoRenew = domain.getGracePeriodStatuses().contains(GracePeriodStatus.AUTO_RENEW);
// inAutoRenew is set to false if the period is zero because a zero-period transfer should not // inAutoRenew is set to false if the period is zero because a zero-period transfer should not
// subsume an autorenew. // subsume an autorenew.

View file

@ -20,7 +20,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainContent; import google.registry.model.domain.DomainBase;
import google.registry.model.domain.DomainHistory; import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.GracePeriod; import google.registry.model.domain.GracePeriod;
import google.registry.model.domain.GracePeriod.GracePeriodHistory; import google.registry.model.domain.GracePeriod.GracePeriodHistory;
@ -87,11 +87,11 @@ public class BulkQueryEntities {
ImmutableSet<DomainTransactionRecord> transactionRecords) { ImmutableSet<DomainTransactionRecord> transactionRecords) {
DomainHistory.Builder builder = new DomainHistory.Builder(); DomainHistory.Builder builder = new DomainHistory.Builder();
builder.copyFrom(domainHistoryLite); builder.copyFrom(domainHistoryLite);
DomainContent rawDomainContent = domainHistoryLite.domainContent; DomainBase rawDomainBase = domainHistoryLite.domainBase;
if (rawDomainContent != null) { if (rawDomainBase != null) {
DomainContent newDomainContent = DomainBase newDomainBase =
domainHistoryLite domainHistoryLite
.domainContent .domainBase
.asBuilder() .asBuilder()
.setNameservers(domainHistoryHosts) .setNameservers(domainHistoryHosts)
.setGracePeriods( .setGracePeriods(
@ -104,9 +104,9 @@ public class BulkQueryEntities {
.collect(toImmutableSet())) .collect(toImmutableSet()))
// Restore the original update timestamp (this gets cleared when we set nameservers or // Restore the original update timestamp (this gets cleared when we set nameservers or
// DS data). // DS data).
.setUpdateTimestamp(domainHistoryLite.domainContent.getUpdateTimestamp()) .setUpdateTimestamp(domainHistoryLite.domainBase.getUpdateTimestamp())
.build(); .build();
builder.setDomain(newDomainContent); builder.setDomain(newDomainBase);
} }
return builder.buildAndAssemble( return builder.buildAndAssemble(
dsDataHistories, domainHistoryHosts, gracePeriodHistories, transactionRecords); dsDataHistories, domainHistoryHosts, gracePeriodHistories, transactionRecords);

View file

@ -16,7 +16,7 @@ package google.registry.model.bulkquery;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainContent; import google.registry.model.domain.DomainBase;
import google.registry.model.domain.DomainHistory; import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.DomainHistory.DomainHistoryId; import google.registry.model.domain.DomainHistory.DomainHistoryId;
import google.registry.model.domain.Period; import google.registry.model.domain.Period;
@ -49,9 +49,9 @@ import javax.persistence.PostLoad;
@IdClass(DomainHistoryId.class) @IdClass(DomainHistoryId.class)
public class DomainHistoryLite extends HistoryEntry { public class DomainHistoryLite extends HistoryEntry {
// Store DomainContent instead of Domain so we don't pick up its @Id // Store DomainBase instead of Domain so we don't pick up its @Id
// Nullable for the sake of pre-Registry-3.0 history objects // Nullable for the sake of pre-Registry-3.0 history objects
@Nullable DomainContent domainContent; @Nullable DomainBase domainBase;
@Id @Id
@Access(AccessType.PROPERTY) @Access(AccessType.PROPERTY)
@ -112,14 +112,14 @@ public class DomainHistoryLite extends HistoryEntry {
@PostLoad @PostLoad
void postLoad() { void postLoad() {
if (domainContent == null) { if (domainBase == null) {
return; return;
} }
// See inline comments in DomainHistory.postLoad for reasons for the following lines. // See inline comments in DomainHistory.postLoad for reasons for the following lines.
if (domainContent.getDomainName() == null) { if (domainBase.getDomainName() == null) {
domainContent = null; domainBase = null;
} else if (domainContent.getRepoId() == null) { } else if (domainBase.getRepoId() == null) {
domainContent.setRepoId(parent.getName()); domainBase.setRepoId(parent.getName());
} }
} }
} }

View file

@ -15,7 +15,7 @@
package google.registry.model.bulkquery; package google.registry.model.bulkquery;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainContent; import google.registry.model.domain.DomainBase;
import google.registry.persistence.VKey; import google.registry.persistence.VKey;
import google.registry.persistence.WithStringVKey; import google.registry.persistence.WithStringVKey;
import javax.persistence.Access; import javax.persistence.Access;
@ -33,7 +33,7 @@ import javax.persistence.Entity;
@Entity(name = "Domain") @Entity(name = "Domain")
@WithStringVKey @WithStringVKey
@Access(AccessType.FIELD) @Access(AccessType.FIELD)
public class DomainLite extends DomainContent { public class DomainLite extends DomainBase {
@Override @Override
@javax.persistence.Id @javax.persistence.Id

View file

@ -69,7 +69,7 @@ import org.joda.time.DateTime;
@WithStringVKey @WithStringVKey
@ExternalMessagingName("domain") @ExternalMessagingName("domain")
@Access(AccessType.FIELD) @Access(AccessType.FIELD)
public class Domain extends DomainContent implements ForeignKeyedEppResource { public class Domain extends DomainBase implements ForeignKeyedEppResource {
@Override @Override
@javax.persistence.Id @javax.persistence.Id
@ -173,7 +173,7 @@ public class Domain extends DomainContent implements ForeignKeyedEppResource {
} }
/** A builder for constructing {@link Domain}, since it is immutable. */ /** A builder for constructing {@link Domain}, since it is immutable. */
public static class Builder extends DomainContent.Builder<Domain, Builder> { public static class Builder extends DomainBase.Builder<Domain, Builder> {
public Builder() {} public Builder() {}
@ -181,38 +181,36 @@ public class Domain extends DomainContent implements ForeignKeyedEppResource {
super(instance); super(instance);
} }
public Builder copyFrom(DomainContent domainContent) { public Builder copyFrom(DomainBase domainBase) {
this.getInstance().copyUpdateTimestamp(domainContent); this.getInstance().copyUpdateTimestamp(domainBase);
return this.setAuthInfo(domainContent.getAuthInfo()) return this.setAuthInfo(domainBase.getAuthInfo())
.setAutorenewPollMessage( .setAutorenewPollMessage(
domainContent.getAutorenewPollMessage(), domainBase.getAutorenewPollMessage(), domainBase.getAutorenewPollMessageHistoryId())
domainContent.getAutorenewPollMessageHistoryId()) .setAutorenewBillingEvent(domainBase.getAutorenewBillingEvent())
.setAutorenewBillingEvent(domainContent.getAutorenewBillingEvent()) .setAutorenewEndTime(domainBase.getAutorenewEndTime())
.setAutorenewEndTime(domainContent.getAutorenewEndTime()) .setContacts(domainBase.getContacts())
.setContacts(domainContent.getContacts()) .setCreationRegistrarId(domainBase.getCreationRegistrarId())
.setCreationRegistrarId(domainContent.getCreationRegistrarId()) .setCreationTime(domainBase.getCreationTime())
.setCreationTime(domainContent.getCreationTime()) .setDomainName(domainBase.getDomainName())
.setDomainName(domainContent.getDomainName()) .setDeletePollMessage(domainBase.getDeletePollMessage())
.setDeletePollMessage(domainContent.getDeletePollMessage()) .setDsData(domainBase.getDsData())
.setDsData(domainContent.getDsData()) .setDeletionTime(domainBase.getDeletionTime())
.setDeletionTime(domainContent.getDeletionTime()) .setGracePeriods(domainBase.getGracePeriods())
.setGracePeriods(domainContent.getGracePeriods()) .setIdnTableName(domainBase.getIdnTableName())
.setIdnTableName(domainContent.getIdnTableName()) .setLastTransferTime(domainBase.getLastTransferTime())
.setLastTransferTime(domainContent.getLastTransferTime()) .setLaunchNotice(domainBase.getLaunchNotice())
.setLaunchNotice(domainContent.getLaunchNotice()) .setLastEppUpdateRegistrarId(domainBase.getLastEppUpdateRegistrarId())
.setLastEppUpdateRegistrarId(domainContent.getLastEppUpdateRegistrarId()) .setLastEppUpdateTime(domainBase.getLastEppUpdateTime())
.setLastEppUpdateTime(domainContent.getLastEppUpdateTime()) .setNameservers(domainBase.getNameservers())
.setNameservers(domainContent.getNameservers()) .setPersistedCurrentSponsorRegistrarId(domainBase.getPersistedCurrentSponsorRegistrarId())
.setPersistedCurrentSponsorRegistrarId( .setRegistrant(domainBase.getRegistrant())
domainContent.getPersistedCurrentSponsorRegistrarId()) .setRegistrationExpirationTime(domainBase.getRegistrationExpirationTime())
.setRegistrant(domainContent.getRegistrant()) .setRepoId(domainBase.getRepoId())
.setRegistrationExpirationTime(domainContent.getRegistrationExpirationTime()) .setSmdId(domainBase.getSmdId())
.setRepoId(domainContent.getRepoId()) .setSubordinateHosts(domainBase.getSubordinateHosts())
.setSmdId(domainContent.getSmdId()) .setStatusValues(domainBase.getStatusValues())
.setSubordinateHosts(domainContent.getSubordinateHosts()) .setTransferData(domainBase.getTransferData())
.setStatusValues(domainContent.getStatusValues()) .setDnsRefreshRequestTime(domainBase.getDnsRefreshRequestTime());
.setTransferData(domainContent.getTransferData())
.setDnsRefreshRequestTime(domainContent.getDnsRefreshRequestTime());
} }
} }
} }

View file

@ -96,7 +96,7 @@ import org.joda.time.Interval;
@MappedSuperclass @MappedSuperclass
@Embeddable @Embeddable
@Access(AccessType.FIELD) @Access(AccessType.FIELD)
public class DomainContent extends EppResource public class DomainBase extends EppResource
implements ResourceWithTransferData<DomainTransferData> { implements ResourceWithTransferData<DomainTransferData> {
/** The max number of years that a domain can be registered for, as set by ICANN policy. */ /** The max number of years that a domain can be registered for, as set by ICANN policy. */
@ -454,7 +454,7 @@ public class DomainContent extends EppResource
} }
@Override @Override
public DomainContent cloneProjectedAtTime(final DateTime now) { public DomainBase cloneProjectedAtTime(final DateTime now) {
return cloneDomainProjectedAtTime(this, now); return cloneDomainProjectedAtTime(this, now);
} }
@ -463,7 +463,7 @@ public class DomainContent extends EppResource
* parallels the logic in {@code DomainTransferApproveFlow} which handles explicit client * parallels the logic in {@code DomainTransferApproveFlow} which handles explicit client
* approvals. * approvals.
*/ */
static <T extends DomainContent> T cloneDomainProjectedAtTime(T domain, DateTime now) { static <T extends DomainBase> T cloneDomainProjectedAtTime(T domain, DateTime now) {
DomainTransferData transferData = domain.getTransferData(); DomainTransferData transferData = domain.getTransferData();
DateTime transferExpirationTime = transferData.getPendingTransferExpirationTime(); DateTime transferExpirationTime = transferData.getPendingTransferExpirationTime();
@ -704,8 +704,7 @@ public class DomainContent extends EppResource
@Override @Override
public VKey<Domain> createVKey() { public VKey<Domain> createVKey() {
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
"DomainContent is not an actual persisted entity you can create a key to;" "DomainBase is not an actual persisted entity you can create a key to; use Domain instead");
+ " use Domain instead");
} }
/** Predicate to determine if a given {@link DesignatedContact} is the registrant. */ /** Predicate to determine if a given {@link DesignatedContact} is the registrant. */
@ -714,12 +713,12 @@ public class DomainContent extends EppResource
/** An override of {@link EppResource#asBuilder} with tighter typing. */ /** An override of {@link EppResource#asBuilder} with tighter typing. */
@Override @Override
public Builder<? extends DomainContent, ?> asBuilder() { public Builder<? extends DomainBase, ?> asBuilder() {
return new Builder<>(clone(this)); return new Builder<>(clone(this));
} }
/** A builder for constructing {@link Domain}, since it is immutable. */ /** A builder for constructing {@link Domain}, since it is immutable. */
public static class Builder<T extends DomainContent, B extends Builder<T, B>> public static class Builder<T extends DomainBase, B extends Builder<T, B>>
extends EppResource.Builder<T, B> implements BuilderWithTransferData<DomainTransferData, B> { extends EppResource.Builder<T, B> implements BuilderWithTransferData<DomainTransferData, B> {
public Builder() {} public Builder() {}

View file

@ -59,8 +59,8 @@ import org.hibernate.Hibernate;
* A persisted history entry representing an EPP modification to a domain. * A persisted history entry representing an EPP modification to a domain.
* *
* <p>In addition to the general history fields (e.g. action time, registrar ID) we also persist a * <p>In addition to the general history fields (e.g. action time, registrar ID) we also persist a
* copy of the domain entity at this point in time. We persist a raw {@link DomainContent} so that * copy of the domain entity at this point in time. We persist a raw {@link DomainBase} so that the
* the foreign-keyed fields in that class can refer to this object. * foreign-keyed fields in that class can refer to this object.
* *
* <p>This class is only marked as a Datastore entity subclass and registered with Objectify so that * <p>This class is only marked as a Datastore entity subclass and registered with Objectify so that
* when building it its ID can be auto-populated by Objectify. It is converted to its superclass * when building it its ID can be auto-populated by Objectify. It is converted to its superclass
@ -80,9 +80,9 @@ import org.hibernate.Hibernate;
@IdClass(DomainHistoryId.class) @IdClass(DomainHistoryId.class)
public class DomainHistory extends HistoryEntry { public class DomainHistory extends HistoryEntry {
// Store DomainContent instead of Domain so we don't pick up its @Id // Store DomainBase instead of Domain so we don't pick up its @Id
// Nullable for the sake of pre-Registry-3.0 history objects // Nullable for the sake of pre-Registry-3.0 history objects
@DoNotCompare @Nullable DomainContent domainContent; @DoNotCompare @Nullable DomainBase domainBase;
@Id @Id
@Access(AccessType.PROPERTY) @Access(AccessType.PROPERTY)
@ -98,9 +98,9 @@ public class DomainHistory extends HistoryEntry {
parent = Key.create(Domain.class, domainRepoId); parent = Key.create(Domain.class, domainRepoId);
} }
// We could have reused domainContent.nsHosts here, but Hibernate throws a weird exception after // We could have reused domainBase.nsHosts here, but Hibernate throws a weird exception after
// we change to use a composite primary key. // we change to use a composite primary key.
// TODO(b/166776754): Investigate if we can reuse domainContent.nsHosts for storing host keys. // TODO(b/166776754): Investigate if we can reuse domainBase.nsHosts for storing host keys.
@DoNotCompare @DoNotCompare
@ElementCollection @ElementCollection
@JoinTable( @JoinTable(
@ -232,13 +232,13 @@ public class DomainHistory extends HistoryEntry {
} }
/** /**
* The values of all the fields on the {@link DomainContent} object after the action represented * The values of all the fields on the {@link DomainBase} object after the action represented by
* by this history object was executed. * this history object was executed.
* *
* <p>Will be absent for objects created prior to the Registry 3.0 SQL migration. * <p>Will be absent for objects created prior to the Registry 3.0 SQL migration.
*/ */
public Optional<DomainContent> getDomainContent() { public Optional<DomainBase> getDomainBase() {
return Optional.ofNullable(domainContent); return Optional.ofNullable(domainBase);
} }
/** The key to the {@link Domain} this is based off of. */ /** The key to the {@link Domain} this is based off of. */
@ -259,8 +259,7 @@ public class DomainHistory extends HistoryEntry {
@Override @Override
public Optional<? extends EppResource> getResourceAtPointInTime() { public Optional<? extends EppResource> getResourceAtPointInTime() {
return getDomainContent() return getDomainBase().map(domainBase -> new Domain.Builder().copyFrom(domainBase).build());
.map(domainContent -> new Domain.Builder().copyFrom(domainContent).build());
} }
@PostLoad @PostLoad
@ -271,39 +270,39 @@ public class DomainHistory extends HistoryEntry {
Hibernate.initialize(dsDataHistories); Hibernate.initialize(dsDataHistories);
Hibernate.initialize(gracePeriodHistories); Hibernate.initialize(gracePeriodHistories);
if (domainContent != null) { if (domainBase != null) {
domainContent.nsHosts = nullToEmptyImmutableCopy(nsHosts); domainBase.nsHosts = nullToEmptyImmutableCopy(nsHosts);
domainContent.gracePeriods = domainBase.gracePeriods =
gracePeriodHistories.stream() gracePeriodHistories.stream()
.map(GracePeriod::createFromHistory) .map(GracePeriod::createFromHistory)
.collect(toImmutableSet()); .collect(toImmutableSet());
domainContent.dsData = domainBase.dsData =
dsDataHistories.stream().map(DelegationSignerData::create).collect(toImmutableSet()); dsDataHistories.stream().map(DelegationSignerData::create).collect(toImmutableSet());
// Normally Hibernate would see that the domain fields are all null and would fill // Normally Hibernate would see that the domain fields are all null and would fill
// domainContent with a null object. Unfortunately, the updateTimestamp is never null in SQL. // domainBase with a null object. Unfortunately, the updateTimestamp is never null in SQL.
if (domainContent.getDomainName() == null) { if (domainBase.getDomainName() == null) {
domainContent = null; domainBase = null;
} else { } else {
if (domainContent.getRepoId() == null) { if (domainBase.getRepoId() == null) {
// domainContent still hasn't been fully constructed yet, so it's ok to go in and mutate // domainBase still hasn't been fully constructed yet, so it's ok to go in and mutate
// it. In fact, we have to because going through the builder causes the hash codes of // it. In fact, we have to because going through the builder causes the hash codes of
// contained objects to be calculated prematurely. // contained objects to be calculated prematurely.
domainContent.setRepoId(parent.getName()); domainBase.setRepoId(parent.getName());
} }
} }
} }
} }
private static void fillAuxiliaryFieldsFromDomain(DomainHistory domainHistory) { private static void fillAuxiliaryFieldsFromDomain(DomainHistory domainHistory) {
if (domainHistory.domainContent != null) { if (domainHistory.domainBase != null) {
domainHistory.nsHosts = nullToEmptyImmutableCopy(domainHistory.domainContent.nsHosts); domainHistory.nsHosts = nullToEmptyImmutableCopy(domainHistory.domainBase.nsHosts);
domainHistory.dsDataHistories = domainHistory.dsDataHistories =
nullToEmptyImmutableCopy(domainHistory.domainContent.getDsData()).stream() nullToEmptyImmutableCopy(domainHistory.domainBase.getDsData()).stream()
.filter(dsData -> dsData.getDigest() != null && dsData.getDigest().length > 0) .filter(dsData -> dsData.getDigest() != null && dsData.getDigest().length > 0)
.map(dsData -> DomainDsDataHistory.createFrom(domainHistory.id, dsData)) .map(dsData -> DomainDsDataHistory.createFrom(domainHistory.id, dsData))
.collect(toImmutableSet()); .collect(toImmutableSet());
domainHistory.gracePeriodHistories = domainHistory.gracePeriodHistories =
nullToEmptyImmutableCopy(domainHistory.domainContent.getGracePeriods()).stream() nullToEmptyImmutableCopy(domainHistory.domainBase.getGracePeriods()).stream()
.map(gracePeriod -> GracePeriodHistory.createFrom(domainHistory.id, gracePeriod)) .map(gracePeriod -> GracePeriodHistory.createFrom(domainHistory.id, gracePeriod))
.collect(toImmutableSet()); .collect(toImmutableSet());
} else { } else {
@ -372,19 +371,19 @@ public class DomainHistory extends HistoryEntry {
super(instance); super(instance);
} }
public Builder setDomain(@Nullable DomainContent domainContent) { public Builder setDomain(@Nullable DomainBase domainBase) {
// Nullable for the sake of pre-Registry-3.0 history objects // Nullable for the sake of pre-Registry-3.0 history objects
if (domainContent == null) { if (domainBase == null) {
return this; return this;
} }
// TODO(b/203609982): if actual type of domainContent is Domain, convert to DomainContent // TODO(b/203609982): if actual type of domainBase is Domain, convert to DomainBase
// Note: a DomainHistory fetched by JPA has DomainContent in this field. Allowing Domain // Note: a DomainHistory fetched by JPA has DomainBase in this field. Allowing Domain
// in the setter makes equality checks messy. // in the setter makes equality checks messy.
getInstance().domainContent = domainContent; getInstance().domainBase = domainBase;
if (domainContent instanceof Domain) { if (domainBase instanceof Domain) {
super.setParent(domainContent); super.setParent(domainBase);
} else { } else {
super.setParent(Key.create(Domain.class, domainContent.getRepoId())); super.setParent(Key.create(Domain.class, domainBase.getRepoId()));
} }
return this; return this;
} }
@ -397,10 +396,10 @@ public class DomainHistory extends HistoryEntry {
@Override @Override
public DomainHistory build() { public DomainHistory build() {
DomainHistory instance = super.build(); DomainHistory instance = super.build();
// TODO(b/171990736): Assert instance.domainContent is not null after database migration. // TODO(b/171990736): Assert instance.domainBase is not null after database migration.
// Note that we cannot assert that instance.domainContent is not null here because this // Note that we cannot assert that instance.domainBase is not null here because this
// builder is also used to convert legacy HistoryEntry objects to DomainHistory, when // builder is also used to convert legacy HistoryEntry objects to DomainHistory, when
// domainContent is not available. // domainBase is not available.
fillAuxiliaryFieldsFromDomain(instance); fillAuxiliaryFieldsFromDomain(instance);
return instance; return instance;
} }

View file

@ -23,7 +23,7 @@ import google.registry.model.EppResource;
import google.registry.model.contact.ContactBase; import google.registry.model.contact.ContactBase;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.ContactResource;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainContent; import google.registry.model.domain.DomainBase;
import google.registry.model.host.HostBase; import google.registry.model.host.HostBase;
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;
@ -132,12 +132,12 @@ public enum StatusValue implements EppEnum {
ALL( ALL(
ContactBase.class, ContactBase.class,
ContactResource.class, ContactResource.class,
DomainContent.class, DomainBase.class,
Domain.class, Domain.class,
HostBase.class, HostBase.class,
HostResource.class), HostResource.class),
NONE, NONE,
DOMAINS(DomainContent.class, Domain.class); DOMAINS(DomainBase.class, Domain.class);
private final ImmutableSet<Class<? extends EppResource>> classes; private final ImmutableSet<Class<? extends EppResource>> classes;

View file

@ -39,7 +39,7 @@ import google.registry.model.contact.ContactHistory;
import google.registry.model.contact.ContactHistory.ContactHistoryId; import google.registry.model.contact.ContactHistory.ContactHistoryId;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.ContactResource;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainContent; import google.registry.model.domain.DomainBase;
import google.registry.model.domain.DomainHistory; import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.DomainHistory.DomainHistoryId; import google.registry.model.domain.DomainHistory.DomainHistoryId;
import google.registry.model.domain.Period; import google.registry.model.domain.Period;
@ -537,8 +537,8 @@ public class HistoryEntry extends ImmutableObject implements Buildable, UnsafeSe
public static <E extends EppResource> public static <E extends EppResource>
HistoryEntry.Builder<? extends HistoryEntry, ?> createBuilderForResource(E parent) { HistoryEntry.Builder<? extends HistoryEntry, ?> createBuilderForResource(E parent) {
if (parent instanceof DomainContent) { if (parent instanceof DomainBase) {
return new DomainHistory.Builder().setDomain((DomainContent) parent); return new DomainHistory.Builder().setDomain((DomainBase) parent);
} else if (parent instanceof ContactBase) { } else if (parent instanceof ContactBase) {
return new ContactHistory.Builder().setContact((ContactBase) parent); return new ContactHistory.Builder().setContact((ContactBase) parent);
} else if (parent instanceof HostBase) { } else if (parent instanceof HostBase) {

View file

@ -58,7 +58,7 @@ import google.registry.model.contact.ContactHistory;
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.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainContent; import google.registry.model.domain.DomainBase;
import google.registry.model.domain.DomainHistory; import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.Period; import google.registry.model.domain.Period;
import google.registry.model.eppcommon.Trid; import google.registry.model.eppcommon.Trid;
@ -187,7 +187,7 @@ public class RdePipelineTest {
.build()); .build());
} }
private DomainHistory persistDomainHistory(DomainContent domain) { private DomainHistory persistDomainHistory(DomainBase domain) {
DomainTransactionRecord transactionRecord = DomainTransactionRecord transactionRecord =
new DomainTransactionRecord.Builder() new DomainTransactionRecord.Builder()
.setTld("soy") .setTld("soy")

View file

@ -28,7 +28,7 @@ import com.google.common.testing.TestLogHandler;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.model.contact.ContactBase; import google.registry.model.contact.ContactBase;
import google.registry.model.contact.ContactHistory; import google.registry.model.contact.ContactHistory;
import google.registry.model.domain.DomainContent; import google.registry.model.domain.DomainBase;
import google.registry.model.domain.DomainHistory; import google.registry.model.domain.DomainHistory;
import google.registry.model.eppcommon.Trid; import google.registry.model.eppcommon.Trid;
import google.registry.model.eppinput.EppInput.ResourceCommandWrapper; import google.registry.model.eppinput.EppInput.ResourceCommandWrapper;
@ -155,10 +155,10 @@ public abstract class ResourceFlowTestCase<F extends Flow, R extends EppResource
assertAboutImmutableObjects() assertAboutImmutableObjects()
.that(contactHistory.getContactBase().get()) .that(contactHistory.getContactBase().get())
.hasFieldsEqualTo(resource); .hasFieldsEqualTo(resource);
} else if (resource instanceof DomainContent) { } else if (resource instanceof DomainBase) {
DomainHistory domainHistory = (DomainHistory) historyEntry; DomainHistory domainHistory = (DomainHistory) historyEntry;
assertAboutImmutableObjects() assertAboutImmutableObjects()
.that(domainHistory.getDomainContent().get()) .that(domainHistory.getDomainBase().get())
.isEqualExceptFields(resource, "gracePeriods", "dsData", "nsHosts"); .isEqualExceptFields(resource, "gracePeriods", "dsData", "nsHosts");
} else if (resource instanceof HostBase) { } else if (resource instanceof HostBase) {
HostHistory hostHistory = (HostHistory) historyEntry; HostHistory hostHistory = (HostHistory) historyEntry;

View file

@ -489,16 +489,16 @@ public class DomainSqlTest {
// reason is showing up as different. // reason is showing up as different.
assertEqualDomainExcept(persisted, "creationTime", "dsData", "gracePeriods"); assertEqualDomainExcept(persisted, "creationTime", "dsData", "gracePeriods");
// Verify that the DomainContent object from the history record sets the fields correctly. // Verify that the DomainBase object from the history record sets the fields correctly.
DomainHistory persistedHistoryEntry = loadByKey(historyEntry.createVKey()); DomainHistory persistedHistoryEntry = loadByKey(historyEntry.createVKey());
assertThat(persistedHistoryEntry.getDomainContent().get().getAutorenewPollMessage()) assertThat(persistedHistoryEntry.getDomainBase().get().getAutorenewPollMessage())
.isEqualTo(domain.getAutorenewPollMessage()); .isEqualTo(domain.getAutorenewPollMessage());
assertThat(persistedHistoryEntry.getDomainContent().get().getAutorenewBillingEvent()) assertThat(persistedHistoryEntry.getDomainBase().get().getAutorenewBillingEvent())
.isEqualTo(domain.getAutorenewBillingEvent()); .isEqualTo(domain.getAutorenewBillingEvent());
assertThat(persistedHistoryEntry.getDomainContent().get().getDeletePollMessage()) assertThat(persistedHistoryEntry.getDomainBase().get().getDeletePollMessage())
.isEqualTo(domain.getDeletePollMessage()); .isEqualTo(domain.getDeletePollMessage());
DomainTransferData persistedTransferData = DomainTransferData persistedTransferData =
persistedHistoryEntry.getDomainContent().get().getTransferData(); persistedHistoryEntry.getDomainBase().get().getTransferData();
DomainTransferData originalTransferData = domain.getTransferData(); DomainTransferData originalTransferData = domain.getTransferData();
assertThat(persistedTransferData.getServerApproveBillingEvent()) assertThat(persistedTransferData.getServerApproveBillingEvent())
.isEqualTo(originalTransferData.getServerApproveBillingEvent()); .isEqualTo(originalTransferData.getServerApproveBillingEvent());
@ -621,16 +621,16 @@ public class DomainSqlTest {
// reason is showing up as different. // reason is showing up as different.
assertEqualDomainExcept(persisted, "creationTime", "dsData", "gracePeriods"); assertEqualDomainExcept(persisted, "creationTime", "dsData", "gracePeriods");
// Verify that the DomainContent object from the history record sets the fields correctly. // Verify that the DomainBase object from the history record sets the fields correctly.
DomainHistory persistedHistoryEntry = loadByKey(historyEntry.createVKey()); DomainHistory persistedHistoryEntry = loadByKey(historyEntry.createVKey());
assertThat(persistedHistoryEntry.getDomainContent().get().getAutorenewPollMessage()) assertThat(persistedHistoryEntry.getDomainBase().get().getAutorenewPollMessage())
.isEqualTo(domain.getAutorenewPollMessage()); .isEqualTo(domain.getAutorenewPollMessage());
assertThat(persistedHistoryEntry.getDomainContent().get().getAutorenewBillingEvent()) assertThat(persistedHistoryEntry.getDomainBase().get().getAutorenewBillingEvent())
.isEqualTo(domain.getAutorenewBillingEvent()); .isEqualTo(domain.getAutorenewBillingEvent());
assertThat(persistedHistoryEntry.getDomainContent().get().getDeletePollMessage()) assertThat(persistedHistoryEntry.getDomainBase().get().getDeletePollMessage())
.isEqualTo(domain.getDeletePollMessage()); .isEqualTo(domain.getDeletePollMessage());
DomainTransferData persistedTransferData = DomainTransferData persistedTransferData =
persistedHistoryEntry.getDomainContent().get().getTransferData(); persistedHistoryEntry.getDomainBase().get().getTransferData();
DomainTransferData originalTransferData = domain.getTransferData(); DomainTransferData originalTransferData = domain.getTransferData();
assertThat(persistedTransferData.getServerApproveBillingEvent()) assertThat(persistedTransferData.getServerApproveBillingEvent())
.isEqualTo(originalTransferData.getServerApproveBillingEvent()); .isEqualTo(originalTransferData.getServerApproveBillingEvent());

View file

@ -230,7 +230,7 @@ public class DomainTest {
} }
@Test @Test
void testDomainContentToDomain() { void testDomainBaseToDomain() {
ImmutableObjectSubject.assertAboutImmutableObjects() ImmutableObjectSubject.assertAboutImmutableObjects()
.that(new Domain.Builder().copyFrom(domain).build()) .that(new Domain.Builder().copyFrom(domain).build())
.isEqualExceptFields(domain, "updateTimestamp", "revisions"); .isEqualExceptFields(domain, "updateTimestamp", "revisions");

View file

@ -29,7 +29,7 @@ import com.google.common.collect.ImmutableSet;
import google.registry.model.EntityTestCase; import google.registry.model.EntityTestCase;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.ContactResource;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainContent; import google.registry.model.domain.DomainBase;
import google.registry.model.domain.DomainHistory; import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.GracePeriod; import google.registry.model.domain.GracePeriod;
import google.registry.model.domain.Period; import google.registry.model.domain.Period;
@ -134,13 +134,13 @@ public class DomainHistoryTest extends EntityTestCase {
} }
static void assertDomainHistoriesEqual(DomainHistory one, DomainHistory two) { static void assertDomainHistoriesEqual(DomainHistory one, DomainHistory two) {
assertAboutImmutableObjects().that(one).isEqualExceptFields(two, "domainContent"); assertAboutImmutableObjects().that(one).isEqualExceptFields(two, "domainBase");
assertAboutImmutableObjects() assertAboutImmutableObjects()
.that(one.getDomainContent().get()) .that(one.getDomainBase().get())
.isEqualExceptFields(two.getDomainContent().get(), "updateTimestamp"); .isEqualExceptFields(two.getDomainBase().get(), "updateTimestamp");
} }
private DomainHistory createDomainHistory(DomainContent domain) { private DomainHistory createDomainHistory(DomainBase domain) {
DomainTransactionRecord transactionRecord = DomainTransactionRecord transactionRecord =
new DomainTransactionRecord.Builder() new DomainTransactionRecord.Builder()
.setTld("tld") .setTld("tld")

View file

@ -76,7 +76,7 @@ class HistoryEntryDaoTest extends EntityTestCase {
@Test @Test
void testSimpleLoadAll() { void testSimpleLoadAll() {
assertThat(HistoryEntryDao.loadAllHistoryObjects(START_OF_TIME, END_OF_TIME)) assertThat(HistoryEntryDao.loadAllHistoryObjects(START_OF_TIME, END_OF_TIME))
.comparingElementsUsing(immutableObjectCorrespondence("nsHosts", "domainContent")) .comparingElementsUsing(immutableObjectCorrespondence("nsHosts", "domainBase"))
.containsExactly(domainHistory); .containsExactly(domainHistory);
} }
@ -98,8 +98,7 @@ class HistoryEntryDaoTest extends EntityTestCase {
tm().transact( tm().transact(
() -> () ->
assertThat(HistoryEntryDao.loadHistoryObjectsForResource(domain.createVKey())) assertThat(HistoryEntryDao.loadHistoryObjectsForResource(domain.createVKey()))
.comparingElementsUsing( .comparingElementsUsing(immutableObjectCorrespondence("nsHosts", "domainBase"))
immutableObjectCorrespondence("nsHosts", "domainContent"))
.containsExactly(domainHistory)); .containsExactly(domainHistory));
} }

View file

@ -78,7 +78,7 @@ class HistoryEntryTest extends EntityTestCase {
DomainHistory fromDatabase = tm().loadByEntity(domainHistory); DomainHistory fromDatabase = tm().loadByEntity(domainHistory);
assertAboutImmutableObjects() assertAboutImmutableObjects()
.that(fromDatabase) .that(fromDatabase)
.isEqualExceptFields(domainHistory, "domainContent"); .isEqualExceptFields(domainHistory, "domainBase");
}); });
} }

View file

@ -80,7 +80,7 @@ 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.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainAuthInfo; import google.registry.model.domain.DomainAuthInfo;
import google.registry.model.domain.DomainContent; import google.registry.model.domain.DomainBase;
import google.registry.model.domain.DomainHistory; import google.registry.model.domain.DomainHistory;
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;
@ -906,7 +906,7 @@ public class DatabaseHelper {
assertPollMessagesEqual(getPollMessages(), asList(expected)); assertPollMessagesEqual(getPollMessages(), asList(expected));
} }
public static void assertPollMessagesForResource(DomainContent domain, PollMessage... expected) { public static void assertPollMessagesForResource(DomainBase domain, PollMessage... expected) {
assertPollMessagesEqual(getPollMessages(domain), asList(expected)); assertPollMessagesEqual(getPollMessages(domain), asList(expected));
} }
@ -922,7 +922,7 @@ public class DatabaseHelper {
.collect(toImmutableList())); .collect(toImmutableList()));
} }
public static ImmutableList<PollMessage> getPollMessages(DomainContent domain) { public static ImmutableList<PollMessage> getPollMessages(DomainBase domain) {
return tm().transact( return tm().transact(
() -> () ->
tm().loadAllOf(PollMessage.class).stream() tm().loadAllOf(PollMessage.class).stream()
@ -973,10 +973,7 @@ public class DatabaseHelper {
} }
public static PollMessage getOnlyPollMessage( public static PollMessage getOnlyPollMessage(
DomainContent domain, DomainBase domain, String registrarId, DateTime now, Class<? extends PollMessage> subType) {
String registrarId,
DateTime now,
Class<? extends PollMessage> subType) {
return getPollMessages(domain, registrarId, now).stream() return getPollMessages(domain, registrarId, now).stream()
.filter(subType::isInstance) .filter(subType::isInstance)
.map(subType::cast) .map(subType::cast)

View file

@ -129,7 +129,7 @@ class google.registry.model.domain.Domain {
class google.registry.model.domain.DomainAuthInfo { class google.registry.model.domain.DomainAuthInfo {
google.registry.model.eppcommon.AuthInfo$PasswordAuth pw; google.registry.model.eppcommon.AuthInfo$PasswordAuth pw;
} }
class google.registry.model.domain.DomainContent { class google.registry.model.domain.DomainBase {
@Id java.lang.String repoId; @Id java.lang.String repoId;
google.registry.model.domain.DomainAuthInfo authInfo; google.registry.model.domain.DomainAuthInfo authInfo;
google.registry.model.domain.launch.LaunchNotice launchNotice; google.registry.model.domain.launch.LaunchNotice launchNotice;
@ -163,7 +163,7 @@ class google.registry.model.domain.DomainHistory {
@Parent com.googlecode.objectify.Key<? extends google.registry.model.EppResource> parent; @Parent com.googlecode.objectify.Key<? extends google.registry.model.EppResource> parent;
boolean bySuperuser; boolean bySuperuser;
byte[] xmlBytes; byte[] xmlBytes;
google.registry.model.domain.DomainContent domainContent; google.registry.model.domain.DomainBase domainBase;
google.registry.model.domain.Period period; google.registry.model.domain.Period period;
google.registry.model.eppcommon.Trid trid; google.registry.model.eppcommon.Trid trid;
google.registry.model.reporting.HistoryEntry$Type type; google.registry.model.reporting.HistoryEntry$Type type;