Rename DomainBase -> Domain (#1725)

* Rename DomainBase -> Domain

This was a long time coming, but we couldn't do it until we left Datastore, as
the Java class name has to match the Datastore entity name.

Subsequent PRs will rename ContactResource to Contact and HostResource to Host,
so that everything matches the SQL table names (and is shorter!).

* Merge branch 'master' into rename-domainbase
This commit is contained in:
Ben McIlwain 2022-08-02 16:03:30 -04:00 committed by GitHub
parent 344b7c29ae
commit 68c80d3205
226 changed files with 1746 additions and 2630 deletions

View file

@ -32,7 +32,7 @@ import google.registry.flows.EppController;
import google.registry.flows.EppRequestSource; import google.registry.flows.EppRequestSource;
import google.registry.flows.PasswordOnlyTransportCredentials; import google.registry.flows.PasswordOnlyTransportCredentials;
import google.registry.flows.StatelessRequestSessionMetadata; import google.registry.flows.StatelessRequestSessionMetadata;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.eppcommon.ProtocolDefinition; import google.registry.model.eppcommon.ProtocolDefinition;
import google.registry.model.eppoutput.EppOutput; import google.registry.model.eppoutput.EppOutput;
import google.registry.persistence.transaction.QueryComposer.Comparator; import google.registry.persistence.transaction.QueryComposer.Comparator;
@ -128,10 +128,10 @@ public class DeleteExpiredDomainsAction implements Runnable {
logger.atInfo().log( logger.atInfo().log(
"Deleting non-renewing domains with autorenew end times up through %s.", runTime); "Deleting non-renewing domains with autorenew end times up through %s.", runTime);
ImmutableList<DomainBase> domainsToDelete = ImmutableList<Domain> domainsToDelete =
tm().transact( tm().transact(
() -> () ->
tm().createQueryComposer(DomainBase.class) tm().createQueryComposer(Domain.class)
.where("autorenewEndTime", Comparator.LTE, runTime) .where("autorenewEndTime", Comparator.LTE, runTime)
.where("deletionTime", Comparator.EQ, END_OF_TIME) .where("deletionTime", Comparator.EQ, END_OF_TIME)
.list()); .list());
@ -145,10 +145,9 @@ public class DeleteExpiredDomainsAction implements Runnable {
"Found %d domains to delete: %s.", "Found %d domains to delete: %s.",
domainsToDelete.size(), domainsToDelete.size(),
String.join( String.join(
", ", ", ", domainsToDelete.stream().map(Domain::getDomainName).collect(toImmutableList())));
domainsToDelete.stream().map(DomainBase::getDomainName).collect(toImmutableList())));
int successes = 0; int successes = 0;
for (DomainBase domain : domainsToDelete) { for (Domain domain : domainsToDelete) {
if (runDomainDeleteFlow(domain)) { if (runDomainDeleteFlow(domain)) {
successes++; successes++;
} }
@ -163,7 +162,7 @@ public class DeleteExpiredDomainsAction implements Runnable {
} }
/** Runs the actual domain delete flow and returns whether the deletion was successful. */ /** Runs the actual domain delete flow and returns whether the deletion was successful. */
private boolean runDomainDeleteFlow(DomainBase domain) { private boolean runDomainDeleteFlow(Domain domain) {
logger.atInfo().log("Attempting to delete domain '%s'.", domain.getDomainName()); logger.atInfo().log("Attempting to delete domain '%s'.", domain.getDomainName());
// Create a new transaction that the flow's execution will be enlisted in that loads the domain // Create a new transaction that the flow's execution will be enlisted in that loads the domain
// transactionally. This way we can ensure that nothing else has modified the domain in question // transactionally. This way we can ensure that nothing else has modified the domain in question
@ -171,7 +170,7 @@ public class DeleteExpiredDomainsAction implements Runnable {
Optional<EppOutput> eppOutput = Optional<EppOutput> eppOutput =
tm().transact( tm().transact(
() -> { () -> {
DomainBase transDomain = tm().loadByKey(domain.createVKey()); Domain transDomain = tm().loadByKey(domain.createVKey());
if (!domain.getAutorenewEndTime().isPresent() if (!domain.getAutorenewEndTime().isPresent()
|| domain.getAutorenewEndTime().get().isAfter(tm().getTransactionTime())) { || domain.getAutorenewEndTime().get().isAfter(tm().getTransactionTime())) {
logger.atSevere().log( logger.atSevere().log(

View file

@ -30,7 +30,7 @@ import google.registry.flows.poll.PollFlowUtils;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.model.EppResourceUtils; import google.registry.model.EppResourceUtils;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.host.HostResource; import google.registry.model.host.HostResource;
import google.registry.model.poll.PollMessage; import google.registry.model.poll.PollMessage;
import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.HistoryEntry;
@ -129,7 +129,7 @@ public class DeleteLoadTestDataAction implements Runnable {
} }
VKey<HostResource> hostVKey = host.createVKey(); VKey<HostResource> hostVKey = host.createVKey();
// We can remove hosts from linked domains, so we should do so then delete the hosts // We can remove hosts from linked domains, so we should do so then delete the hosts
ImmutableSet<VKey<DomainBase>> linkedDomains = ImmutableSet<VKey<Domain>> linkedDomains =
EppResourceUtils.getLinkedDomainKeys(hostVKey, clock.nowUtc(), null); EppResourceUtils.getLinkedDomainKeys(hostVKey, clock.nowUtc(), null);
tm().loadByKeys(linkedDomains) tm().loadByKeys(linkedDomains)
.values() .values()

View file

@ -37,7 +37,7 @@ import google.registry.config.RegistryEnvironment;
import google.registry.dns.DnsQueue; import google.registry.dns.DnsQueue;
import google.registry.model.CreateAutoTimestamp; import google.registry.model.CreateAutoTimestamp;
import google.registry.model.EppResourceUtils; import google.registry.model.EppResourceUtils;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory; import google.registry.model.domain.DomainHistory;
import google.registry.model.tld.Registry.TldType; import google.registry.model.tld.Registry.TldType;
import google.registry.request.Action; import google.registry.request.Action;
@ -53,8 +53,8 @@ import org.joda.time.DateTime;
import org.joda.time.Duration; import org.joda.time.Duration;
/** /**
* Deletes all prober DomainBases and their subordinate history entries, poll messages, and billing * Deletes all prober {@link Domain}s and their subordinate history entries, poll messages, and
* events, along with their ForeignKeyDomainIndex and EppResourceIndex entities. * billing events, along with their ForeignKeyDomainIndex and EppResourceIndex entities.
*/ */
@Action( @Action(
service = Action.Service.BACKEND, service = Action.Service.BACKEND,
@ -154,7 +154,7 @@ public class DeleteProberDataAction implements Runnable {
// keeping track of which domains to hard-delete (there can be many, so we batch them up) // keeping track of which domains to hard-delete (there can be many, so we batch them up)
ScrollableResults scrollableResult = ScrollableResults scrollableResult =
jpaTm() jpaTm()
.query(DOMAIN_QUERY_STRING, DomainBase.class) .query(DOMAIN_QUERY_STRING, Domain.class)
.setParameter("tlds", deletableTlds) .setParameter("tlds", deletableTlds)
.setParameter( .setParameter(
"creationTimeCutoff", CreateAutoTimestamp.create(now.minus(DOMAIN_USED_DURATION))) "creationTimeCutoff", CreateAutoTimestamp.create(now.minus(DOMAIN_USED_DURATION)))
@ -166,7 +166,7 @@ public class DeleteProberDataAction implements Runnable {
ImmutableList.Builder<String> domainRepoIdsToHardDelete = new ImmutableList.Builder<>(); ImmutableList.Builder<String> domainRepoIdsToHardDelete = new ImmutableList.Builder<>();
ImmutableList.Builder<String> hostNamesToHardDelete = new ImmutableList.Builder<>(); ImmutableList.Builder<String> hostNamesToHardDelete = new ImmutableList.Builder<>();
for (int i = 1; scrollableResult.next(); i = (i + 1) % BATCH_SIZE) { for (int i = 1; scrollableResult.next(); i = (i + 1) % BATCH_SIZE) {
DomainBase domain = (DomainBase) scrollableResult.get(0); Domain domain = (Domain) scrollableResult.get(0);
processDomain( processDomain(
domain, domain,
domainRepoIdsToHardDelete, domainRepoIdsToHardDelete,
@ -187,7 +187,7 @@ public class DeleteProberDataAction implements Runnable {
} }
private void processDomain( private void processDomain(
DomainBase domain, Domain domain,
ImmutableList.Builder<String> domainRepoIdsToHardDelete, ImmutableList.Builder<String> domainRepoIdsToHardDelete,
ImmutableList.Builder<String> hostNamesToHardDelete, ImmutableList.Builder<String> hostNamesToHardDelete,
AtomicInteger softDeletedDomains, AtomicInteger softDeletedDomains,
@ -251,8 +251,8 @@ public class DeleteProberDataAction implements Runnable {
} }
// Take a DNS queue + admin registrar id as input so that it can be called from the mapper as well // Take a DNS queue + admin registrar id as input so that it can be called from the mapper as well
private void softDeleteDomain(DomainBase domain) { private void softDeleteDomain(Domain domain) {
DomainBase deletedDomain = Domain deletedDomain =
domain.asBuilder().setDeletionTime(tm().getTransactionTime()).setStatusValues(null).build(); domain.asBuilder().setDeletionTime(tm().getTransactionTime()).setStatusValues(null).build();
DomainHistory historyEntry = DomainHistory historyEntry =
new DomainHistory.Builder() new DomainHistory.Builder()

View file

@ -43,7 +43,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.DomainBase; import google.registry.model.domain.Domain;
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.reporting.DomainTransactionRecord; import google.registry.model.reporting.DomainTransactionRecord;
@ -253,7 +253,7 @@ public class ExpandRecurringBillingEventsAction implements Runnable {
final ImmutableSet<DateTime> billingTimes = final ImmutableSet<DateTime> billingTimes =
getBillingTimesInScope(eventTimes, cursorTime, executeTime, tld); getBillingTimesInScope(eventTimes, cursorTime, executeTime, tld);
VKey<DomainBase> domainKey = VKey.createSql(DomainBase.class, recurring.getDomainRepoId()); VKey<Domain> domainKey = VKey.createSql(Domain.class, recurring.getDomainRepoId());
Iterable<OneTime> oneTimesForDomain; Iterable<OneTime> oneTimesForDomain;
oneTimesForDomain = oneTimesForDomain =
tm().createQueryComposer(OneTime.class) tm().createQueryComposer(OneTime.class)

View file

@ -27,7 +27,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import com.google.common.net.MediaType; import com.google.common.net.MediaType;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.domain.RegistryLock; import google.registry.model.domain.RegistryLock;
import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.StatusValue;
import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar;
@ -125,7 +125,7 @@ public class RelockDomainAction implements Runnable {
private void relockDomain() { private void relockDomain() {
RegistryLock oldLock = null; RegistryLock oldLock = null;
DomainBase domain; Domain domain;
try { try {
oldLock = oldLock =
RegistryLockDao.getByRevisionId(oldUnlockRevisionId) RegistryLockDao.getByRevisionId(oldUnlockRevisionId)
@ -134,7 +134,7 @@ public class RelockDomainAction implements Runnable {
new IllegalArgumentException( new IllegalArgumentException(
String.format("Unknown revision ID %d", oldUnlockRevisionId))); String.format("Unknown revision ID %d", oldUnlockRevisionId)));
domain = domain =
tm().loadByKey(VKey.create(DomainBase.class, oldLock.getRepoId())) tm().loadByKey(VKey.create(Domain.class, oldLock.getRepoId()))
.cloneProjectedAtTime(tm().getTransactionTime()); .cloneProjectedAtTime(tm().getTransactionTime());
} catch (Throwable t) { } catch (Throwable t) {
handleTransientFailure(Optional.ofNullable(oldLock), t); handleTransientFailure(Optional.ofNullable(oldLock), t);
@ -180,7 +180,7 @@ public class RelockDomainAction implements Runnable {
} }
} }
private void verifyDomainAndLockState(RegistryLock oldLock, DomainBase domain) { private void verifyDomainAndLockState(RegistryLock oldLock, Domain domain) {
// Domain shouldn't be deleted or have a pending transfer/delete // Domain shouldn't be deleted or have a pending transfer/delete
String domainName = domain.getDomainName(); String domainName = domain.getDomainName();
ImmutableSet<StatusValue> statusValues = domain.getStatusValues(); ImmutableSet<StatusValue> statusValues = domain.getStatusValues();

View file

@ -20,6 +20,7 @@ import dagger.Lazy;
import google.registry.config.CredentialModule; import google.registry.config.CredentialModule;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
import google.registry.config.RegistryConfig.ConfigModule; import google.registry.config.RegistryConfig.ConfigModule;
import google.registry.model.domain.Domain;
import google.registry.persistence.PersistenceModule; import google.registry.persistence.PersistenceModule;
import google.registry.persistence.PersistenceModule.BeamBulkQueryJpaTm; import google.registry.persistence.PersistenceModule.BeamBulkQueryJpaTm;
import google.registry.persistence.PersistenceModule.BeamJpaTm; import google.registry.persistence.PersistenceModule.BeamJpaTm;
@ -53,8 +54,7 @@ public interface RegistryPipelineComponent {
/** /**
* Returns a {@link JpaTransactionManager} optimized for bulk loading multi-level JPA entities * Returns a {@link JpaTransactionManager} optimized for bulk loading multi-level JPA entities
* ({@link google.registry.model.domain.DomainBase} and {@link * ({@link Domain} and {@link google.registry.model.domain.DomainHistory}). Please refer to {@link
* google.registry.model.domain.DomainHistory}). Please refer to {@link
* google.registry.model.bulkquery.BulkQueryEntities} for more information. * google.registry.model.bulkquery.BulkQueryEntities} for more information.
*/ */
@BeamBulkQueryJpaTm @BeamBulkQueryJpaTm

View file

@ -47,7 +47,7 @@ import google.registry.gcs.GcsUtils;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.model.contact.ContactHistory; import google.registry.model.contact.ContactHistory;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory; import google.registry.model.domain.DomainHistory;
import google.registry.model.host.HostHistory; import google.registry.model.host.HostHistory;
import google.registry.model.host.HostResource; import google.registry.model.host.HostResource;
@ -132,7 +132,7 @@ import org.joda.time.DateTime;
* that are soft-deleted by watermark. The history is emitted as pairs of (resource repo ID: history * that are soft-deleted by watermark. The history is emitted as pairs of (resource repo ID: history
* revision ID) from the SQL query. * revision ID) from the SQL query.
* *
* <h3>{@link DomainBase}</h3> * <h3>{@link Domain}</h3>
* *
* After the most recent (live) domain resources are loaded from the corresponding history objects, * After the most recent (live) domain resources are loaded from the corresponding history objects,
* we marshall them to deposit fragments and emit the (pending deposit: deposit fragment) pairs for * we marshall them to deposit fragments and emit the (pending deposit: deposit fragment) pairs for
@ -477,8 +477,8 @@ public class RdePipeline implements Serializable {
public void processElement( public void processElement(
@Element KV<String, Long> kv, MultiOutputReceiver receiver) { @Element KV<String, Long> kv, MultiOutputReceiver receiver) {
activeDomainCounter.inc(); activeDomainCounter.inc();
DomainBase domain = Domain domain =
(DomainBase) (Domain)
loadResourceByHistoryEntryId( loadResourceByHistoryEntryId(
DomainHistory.class, kv.getKey(), kv.getValue()); DomainHistory.class, kv.getKey(), kv.getValue());
pendingDeposits.stream() pendingDeposits.stream()
@ -654,8 +654,8 @@ public class RdePipeline implements Serializable {
TypeDescriptor.of(DepositFragment.class))) TypeDescriptor.of(DepositFragment.class)))
.via( .via(
(KV<String, CoGbkResult> kv) -> { (KV<String, CoGbkResult> kv) -> {
DomainBase superordinateDomain = Domain superordinateDomain =
(DomainBase) (Domain)
loadResourceByHistoryEntryId( loadResourceByHistoryEntryId(
DomainHistory.class, DomainHistory.class,
kv.getKey(), kv.getKey(),

View file

@ -23,7 +23,7 @@ import google.registry.beam.common.RegistryJpaIO;
import google.registry.beam.common.RegistryJpaIO.Read; 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.DomainBase; import google.registry.model.domain.Domain;
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;
@ -51,7 +51,7 @@ import org.joda.time.DateTime;
public class ResaveAllEppResourcesPipeline implements Serializable { public class ResaveAllEppResourcesPipeline implements Serializable {
private static final ImmutableSet<Class<? extends EppResource>> EPP_RESOURCE_CLASSES = private static final ImmutableSet<Class<? extends EppResource>> EPP_RESOURCE_CLASSES =
ImmutableSet.of(ContactResource.class, DomainBase.class, HostResource.class); ImmutableSet.of(ContactResource.class, Domain.class, HostResource.class);
/** /**
* There exist three possible situations where we know we'll want to project domains to the * There exist three possible situations where we know we'll want to project domains to the
@ -114,13 +114,13 @@ public class ResaveAllEppResourcesPipeline implements Serializable {
* google.registry.model.domain.DomainContent#cloneProjectedAtTime(DateTime)}. * google.registry.model.domain.DomainContent#cloneProjectedAtTime(DateTime)}.
*/ */
private void fastResaveDomains(Pipeline pipeline) { private void fastResaveDomains(Pipeline pipeline) {
Read<DomainBase, DomainBase> read = Read<Domain, Domain> read =
RegistryJpaIO.read( RegistryJpaIO.read(
DOMAINS_TO_PROJECT_QUERY, DOMAINS_TO_PROJECT_QUERY,
ImmutableMap.of("END_OF_TIME", DateTimeUtils.END_OF_TIME), ImmutableMap.of("END_OF_TIME", DateTimeUtils.END_OF_TIME),
DomainBase.class, Domain.class,
d -> d); d -> d);
projectAndResaveResources(pipeline, DomainBase.class, read); projectAndResaveResources(pipeline, Domain.class, read);
} }
/** Projects all resources to the current time and saves them. */ /** Projects all resources to the current time and saves them. */

View file

@ -26,7 +26,7 @@ import google.registry.beam.common.RegistryJpaIO;
import google.registry.beam.common.RegistryJpaIO.Read; import google.registry.beam.common.RegistryJpaIO.Read;
import google.registry.beam.spec11.SafeBrowsingTransforms.EvaluateSafeBrowsingFn; import google.registry.beam.spec11.SafeBrowsingTransforms.EvaluateSafeBrowsingFn;
import google.registry.config.RegistryConfig.ConfigModule; import google.registry.config.RegistryConfig.ConfigModule;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.reporting.Spec11ThreatMatch; import google.registry.model.reporting.Spec11ThreatMatch;
import google.registry.model.reporting.Spec11ThreatMatch.ThreatType; import google.registry.model.reporting.Spec11ThreatMatch.ThreatType;
import google.registry.persistence.PersistenceModule.TransactionIsolationLevel; import google.registry.persistence.PersistenceModule.TransactionIsolationLevel;
@ -127,22 +127,21 @@ public class Spec11Pipeline implements Serializable {
@ProcessElement @ProcessElement
public void processElement( public void processElement(
@Element KV<String, String> input, OutputReceiver<DomainNameInfo> output) { @Element KV<String, String> input, OutputReceiver<DomainNameInfo> output) {
DomainBase domainBase = Domain domain =
jpaTm() jpaTm()
.transact( .transact(
() -> () ->
jpaTm() jpaTm()
.loadByKey( .loadByKey(VKey.createSql(Domain.class, input.getKey())));
VKey.createSql(DomainBase.class, input.getKey())));
String emailAddress = input.getValue(); String emailAddress = input.getValue();
if (emailAddress == null) { if (emailAddress == null) {
emailAddress = ""; emailAddress = "";
} }
DomainNameInfo domainNameInfo = DomainNameInfo domainNameInfo =
DomainNameInfo.create( DomainNameInfo.create(
domainBase.getDomainName(), domain.getDomainName(),
domainBase.getRepoId(), domain.getRepoId(),
domainBase.getCurrentSponsorRegistrarId(), domain.getCurrentSponsorRegistrarId(),
emailAddress); emailAddress);
output.output(domainNameInfo); output.output(domainNameInfo);
} }

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.DomainBase; import google.registry.model.domain.Domain;
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;
@ -62,7 +62,7 @@ public final class RefreshDnsAction implements Runnable {
} }
switch (type) { switch (type) {
case DOMAIN: case DOMAIN:
loadAndVerifyExistence(DomainBase.class, domainOrHostName); loadAndVerifyExistence(Domain.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.DomainBase; import google.registry.model.domain.Domain;
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.tld.Registries; import google.registry.model.tld.Registries;
@ -121,13 +121,12 @@ 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<DomainBase> domainBase = Optional<Domain> domain = loadByForeignKey(Domain.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 (!domainBase.isPresent() || !domainBase.get().shouldPublishToDns()) { if (!domain.isPresent() || !domain.get().shouldPublishToDns()) {
desiredRecords.put(absoluteDomainName, ImmutableSet.of()); desiredRecords.put(absoluteDomainName, ImmutableSet.of());
return; return;
} }
@ -135,7 +134,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 = domainBase.get().getDsData(); Set<DelegationSignerData> dsData = domain.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 +153,8 @@ public class CloudDnsWriter extends BaseDnsWriter {
} }
// Construct NS records (if any). // Construct NS records (if any).
Set<String> nameserverData = domainBase.get().loadNameserverHostNames(); Set<String> nameserverData = domain.get().loadNameserverHostNames();
Set<String> subordinateHosts = domainBase.get().getSubordinateHosts(); Set<String> subordinateHosts = domain.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.DomainBase; import google.registry.model.domain.Domain;
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.tld.Registries; import google.registry.model.tld.Registries;
@ -127,12 +127,11 @@ 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<DomainBase> domainOptional = Optional<Domain> domainOptional = loadByForeignKey(Domain.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()) {
DomainBase domain = domainOptional.get(); Domain 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 +183,7 @@ public class DnsUpdateWriter extends BaseDnsWriter {
} }
} }
private RRset makeDelegationSignerSet(DomainBase domain) { private RRset makeDelegationSignerSet(Domain 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 +201,7 @@ public class DnsUpdateWriter extends BaseDnsWriter {
} }
private void deleteSubordinateHostAddressSet( private void deleteSubordinateHostAddressSet(
DomainBase domain, String additionalHost, Update update) { Domain domain, String additionalHost, Update update) {
for (String hostName : for (String hostName :
union( union(
domain.getSubordinateHosts(), domain.getSubordinateHosts(),
@ -213,7 +212,7 @@ public class DnsUpdateWriter extends BaseDnsWriter {
} }
} }
private void addInBailiwickNameServerSet(DomainBase domain, Update update) { private void addInBailiwickNameServerSet(Domain domain, Update update) {
for (String hostName : for (String hostName :
intersection(domain.loadNameserverHostNames(), domain.getSubordinateHosts())) { intersection(domain.loadNameserverHostNames(), domain.getSubordinateHosts())) {
Optional<HostResource> host = loadByForeignKey(HostResource.class, hostName, clock.nowUtc()); Optional<HostResource> host = loadByForeignKey(HostResource.class, hostName, clock.nowUtc());
@ -223,7 +222,7 @@ public class DnsUpdateWriter extends BaseDnsWriter {
} }
} }
private RRset makeNameServerSet(DomainBase domain) { private RRset makeNameServerSet(Domain domain) {
RRset nameServerSet = new RRset(); RRset nameServerSet = new RRset();
for (String hostName : domain.loadNameserverHostNames()) { for (String hostName : domain.loadNameserverHostNames()) {
NSRecord record = NSRecord record =

View file

@ -6,22 +6,22 @@
<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"> <datastore-index kind="Domain" 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"> <datastore-index kind="Domain" ancestor="false" source="manual">
<property name="tld" direction="asc"/> <property name="tld" direction="asc"/>
<property name="deletionTime" direction="asc"/> <property name="deletionTime" 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"> <datastore-index kind="Domain" 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 the most recently created domain resources. --> <!-- For finding the most recently created domain resources. -->
<datastore-index kind="DomainBase" ancestor="false" source="manual"> <datastore-index kind="Domain" ancestor="false" source="manual">
<property name="tld" direction="asc"/> <property name="tld" direction="asc"/>
<property name="creationTime" direction="desc"/> <property name="creationTime" direction="desc"/>
</datastore-index> </datastore-index>
@ -32,22 +32,22 @@
<property name="fullyQualifiedHostName" direction="asc"/> <property name="fullyQualifiedHostName" direction="asc"/>
</datastore-index> </datastore-index>
<!-- For determining the active domains linked to a given contact. --> <!-- For determining the active domains linked to a given contact. -->
<datastore-index kind="DomainBase" ancestor="false" source="manual"> <datastore-index kind="Domain" ancestor="false" source="manual">
<property name="allContacts.contact" direction="asc"/> <property name="allContacts.contact" direction="asc"/>
<property name="deletionTime" direction="asc"/> <property name="deletionTime" direction="asc"/>
</datastore-index> </datastore-index>
<!-- For determining the active domains linked to a given host. --> <!-- For determining the active domains linked to a given host. -->
<datastore-index kind="DomainBase" ancestor="false" source="manual"> <datastore-index kind="Domain" ancestor="false" source="manual">
<property name="nsHosts" direction="asc"/> <property name="nsHosts" direction="asc"/>
<property name="deletionTime" direction="asc"/> <property name="deletionTime" direction="asc"/>
</datastore-index> </datastore-index>
<!-- For deleting expired not-previously-deleted domains. --> <!-- For deleting expired not-previously-deleted domains. -->
<datastore-index kind="DomainBase" ancestor="false" source="manual"> <datastore-index kind="Domain" ancestor="false" source="manual">
<property name="deletionTime" direction="asc"/> <property name="deletionTime" direction="asc"/>
<property name="autorenewEndTime" direction="asc"/> <property name="autorenewEndTime" 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"> <datastore-index kind="Domain" ancestor="false" source="manual">
<property name="nsHosts" direction="asc"/> <property name="nsHosts" direction="asc"/>
<property name="deletionTime" direction="asc"/> <property name="deletionTime" direction="asc"/>
</datastore-index> </datastore-index>
@ -74,16 +74,16 @@
<property name="modificationTime" direction="asc"/> <property name="modificationTime" direction="asc"/>
</datastore-index> </datastore-index>
<!-- For RDAP. --> <!-- For RDAP. -->
<datastore-index kind="DomainBase" ancestor="false" source="manual"> <datastore-index kind="Domain" ancestor="false" source="manual">
<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="Domain" ancestor="false" source="manual">
<property name="currentSponsorClientId" direction="asc"/> <property name="currentSponsorClientId" 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>
<datastore-index kind="DomainBase" ancestor="false" source="manual"> <datastore-index kind="Domain" ancestor="false" source="manual">
<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

@ -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.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.index.ForeignKeyIndex; import google.registry.model.index.ForeignKeyIndex;
import google.registry.model.tld.Registry; import google.registry.model.tld.Registry;
import google.registry.model.tld.label.ReservationType; import google.registry.model.tld.label.ReservationType;
@ -156,8 +156,7 @@ public class CheckApiAction implements Runnable {
} }
private boolean checkExists(String domainString, DateTime now) { private boolean checkExists(String domainString, DateTime now) {
return !ForeignKeyIndex.loadCached(DomainBase.class, ImmutableList.of(domainString), now) return !ForeignKeyIndex.loadCached(Domain.class, ImmutableList.of(domainString), now).isEmpty();
.isEmpty();
} }
private Optional<String> checkReserved(InternetDomainName domainName) { private Optional<String> checkReserved(InternetDomainName domainName) {

View file

@ -39,7 +39,7 @@ import google.registry.model.EppResource;
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.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainContent; import google.registry.model.domain.DomainContent;
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;
@ -147,7 +147,7 @@ public final class ResourceFlowUtils {
} }
/** Check that the given AuthInfo is either missing or else is valid for the given resource. */ /** Check that the given AuthInfo is either missing or else is valid for the given resource. */
public static void verifyOptionalAuthInfo(Optional<AuthInfo> authInfo, DomainBase domain) public static void verifyOptionalAuthInfo(Optional<AuthInfo> authInfo, Domain domain)
throws EppException { throws EppException {
if (authInfo.isPresent()) { if (authInfo.isPresent()) {
verifyAuthInfo(authInfo.get(), domain); verifyAuthInfo(authInfo.get(), domain);
@ -155,7 +155,7 @@ public final class ResourceFlowUtils {
} }
/** Check that the given {@link AuthInfo} is valid for the given domain. */ /** Check that the given {@link AuthInfo} is valid for the given domain. */
public static void verifyAuthInfo(AuthInfo authInfo, DomainBase domain) throws EppException { public static void verifyAuthInfo(AuthInfo authInfo, Domain domain) throws EppException {
final String authRepoId = authInfo.getPw().getRepoId(); final String authRepoId = authInfo.getPw().getRepoId();
String authPassword = authInfo.getPw().getValue(); String authPassword = authInfo.getPw().getValue();
if (authRepoId == null) { if (authRepoId == null) {
@ -246,7 +246,7 @@ public final class ResourceFlowUtils {
if (period.getValue() == 0) { if (period.getValue() == 0) {
inAutoRenew = false; inAutoRenew = false;
} }
return DomainBase.extendRegistrationWithCap( return Domain.extendRegistrationWithCap(
approvalTime, approvalTime,
domain.getRegistrationExpirationTime(), domain.getRegistrationExpirationTime(),
period.getValue() - (inAutoRenew ? 1 : 0)); period.getValue() - (inAutoRenew ? 1 : 0));

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.DomainBase; import google.registry.model.domain.Domain;
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,9 @@ public class DomainCreateFlowCustomLogic extends BaseFlowCustomLogic {
public abstract static class BeforeSaveParameters extends ImmutableObject { public abstract static class BeforeSaveParameters extends ImmutableObject {
/** /**
* The new {@link DomainBase} entity that is going to be persisted at the end of the * The new {@link Domain} entity that is going to be persisted at the end of the transaction.
* transaction.
*/ */
public abstract DomainBase newDomain(); public abstract Domain 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 +161,7 @@ public class DomainCreateFlowCustomLogic extends BaseFlowCustomLogic {
@AutoValue.Builder @AutoValue.Builder
public abstract static class Builder { public abstract static class Builder {
public abstract Builder setNewDomain(DomainBase newDomain); public abstract Builder setNewDomain(Domain 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.DomainBase; import google.registry.model.domain.Domain;
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 DomainBase existingDomain(); public abstract Domain 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(DomainBase existingDomain); public abstract Builder setExistingDomain(Domain 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 DomainBase existingDomain(); public abstract Domain existingDomain();
public abstract DomainBase newDomain(); public abstract Domain 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(DomainBase existingDomain); public abstract Builder setExistingDomain(Domain existingDomain);
public abstract Builder setNewDomain(DomainBase newDomain); public abstract Builder setNewDomain(Domain 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.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.Domain;
import google.registry.model.domain.DomainInfoData; import google.registry.model.domain.DomainInfoData;
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,8 +53,8 @@ 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 DomainBase} and {@link ResponseExtension}s as input and returns * <p>This takes the {@link Domain} and {@link ResponseExtension}s as input and returns them,
* them, potentially with modifications. * potentially with modifications.
*/ */
@SuppressWarnings("unused") @SuppressWarnings("unused")
public BeforeResponseReturnData beforeResponse(BeforeResponseParameters parameters) public BeforeResponseReturnData beforeResponse(BeforeResponseParameters parameters)
@ -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 DomainBase domain(); public abstract Domain 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(DomainBase domain); public abstract Builder setDomain(Domain 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 DomainBase domain(); public abstract Domain 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(DomainBase domain); public abstract Builder setDomain(Domain 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.DomainBase; import google.registry.model.domain.Domain;
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,8 +68,8 @@ 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 DomainBase} and {@link ResponseExtension}s as input and returns * <p>This takes the {@link Domain} and {@link ResponseExtension}s as input and returns them,
* them, potentially with modifications. * potentially with modifications.
*/ */
@SuppressWarnings("unused") @SuppressWarnings("unused")
public BeforeResponseReturnData beforeResponse(BeforeResponseParameters parameters) public BeforeResponseReturnData beforeResponse(BeforeResponseParameters parameters)
@ -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 DomainBase existingDomain(); public abstract Domain 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(DomainBase existingDomain); public abstract Builder setExistingDomain(Domain 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 DomainBase existingDomain(); public abstract Domain existingDomain();
public abstract DomainBase newDomain(); public abstract Domain 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(DomainBase existingDomain); public abstract Builder setExistingDomain(Domain existingDomain);
public abstract Builder setNewDomain(DomainBase newDomain); public abstract Builder setNewDomain(Domain 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 DomainBase domain(); public abstract Domain 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(DomainBase domain); public abstract BeforeResponseParameters.Builder setDomain(Domain 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.DomainBase; import google.registry.model.domain.Domain;
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 DomainBase existingDomain(); public abstract Domain 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(DomainBase existingDomain); public abstract Builder setExistingDomain(Domain 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 DomainBase existingDomain(); public abstract Domain existingDomain();
public abstract DomainBase newDomain(); public abstract Domain 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(DomainBase existingDomain); public abstract Builder setExistingDomain(Domain existingDomain);
public abstract Builder setNewDomain(DomainBase newDomain); public abstract Builder setNewDomain(Domain newDomain);
public abstract Builder setHistoryEntry(HistoryEntry historyEntry); public abstract Builder setHistoryEntry(HistoryEntry historyEntry);

View file

@ -54,7 +54,7 @@ import google.registry.flows.domain.token.AllocationTokenDomainCheckResults;
import google.registry.flows.domain.token.AllocationTokenFlowUtils; import google.registry.flows.domain.token.AllocationTokenFlowUtils;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainCommand.Check; import google.registry.model.domain.DomainCommand.Check;
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;
@ -169,8 +169,8 @@ 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());
ImmutableMap<String, ForeignKeyIndex<DomainBase>> existingDomains = ImmutableMap<String, ForeignKeyIndex<Domain>> existingDomains =
ForeignKeyIndex.load(DomainBase.class, domainNames, now); ForeignKeyIndex.load(Domain.class, domainNames, now);
Optional<AllocationTokenExtension> allocationTokenExtension = Optional<AllocationTokenExtension> allocationTokenExtension =
eppInput.getSingleExtension(AllocationTokenExtension.class); eppInput.getSingleExtension(AllocationTokenExtension.class);
Optional<AllocationTokenDomainCheckResults> tokenDomainCheckResults = Optional<AllocationTokenDomainCheckResults> tokenDomainCheckResults =
@ -227,7 +227,7 @@ public final class DomainCheckFlow implements Flow {
private Optional<String> getMessageForCheck( private Optional<String> getMessageForCheck(
InternetDomainName domainName, InternetDomainName domainName,
ImmutableMap<String, ForeignKeyIndex<DomainBase>> existingDomains, ImmutableMap<String, ForeignKeyIndex<Domain>> existingDomains,
ImmutableMap<InternetDomainName, String> tokenCheckResults, ImmutableMap<InternetDomainName, String> tokenCheckResults,
ImmutableMap<String, TldState> tldStates, ImmutableMap<String, TldState> tldStates,
Optional<AllocationToken> allocationToken) { Optional<AllocationToken> allocationToken) {
@ -251,7 +251,7 @@ public final class DomainCheckFlow implements Flow {
/** Handle the fee check extension. */ /** Handle the fee check extension. */
private ImmutableList<? extends ResponseExtension> getResponseExtensions( private ImmutableList<? extends ResponseExtension> getResponseExtensions(
ImmutableMap<String, InternetDomainName> domainNames, ImmutableMap<String, InternetDomainName> domainNames,
ImmutableMap<String, ForeignKeyIndex<DomainBase>> existingDomains, ImmutableMap<String, ForeignKeyIndex<Domain>> existingDomains,
ImmutableSet<String> availableDomains, ImmutableSet<String> availableDomains,
DateTime now, DateTime now,
Optional<AllocationToken> allocationToken) Optional<AllocationToken> allocationToken)
@ -264,7 +264,7 @@ public final class DomainCheckFlow implements Flow {
FeeCheckCommandExtension<?, ?> feeCheck = feeCheckOpt.get(); FeeCheckCommandExtension<?, ?> feeCheck = feeCheckOpt.get();
ImmutableList.Builder<FeeCheckResponseExtensionItem> responseItems = ImmutableList.Builder<FeeCheckResponseExtensionItem> responseItems =
new ImmutableList.Builder<>(); new ImmutableList.Builder<>();
ImmutableMap<String, DomainBase> domainObjs = ImmutableMap<String, Domain> domainObjs =
loadDomainsForRestoreChecks(feeCheck, domainNames, existingDomains); loadDomainsForRestoreChecks(feeCheck, domainNames, existingDomains);
ImmutableMap<String, BillingEvent.Recurring> recurrences = ImmutableMap<String, BillingEvent.Recurring> recurrences =
loadRecurrencesForDomains(domainObjs); loadRecurrencesForDomains(domainObjs);
@ -272,12 +272,12 @@ public final class DomainCheckFlow implements Flow {
for (FeeCheckCommandExtensionItem feeCheckItem : feeCheck.getItems()) { for (FeeCheckCommandExtensionItem feeCheckItem : feeCheck.getItems()) {
for (String domainName : getDomainNamesToCheckForFee(feeCheckItem, domainNames.keySet())) { for (String domainName : getDomainNamesToCheckForFee(feeCheckItem, domainNames.keySet())) {
FeeCheckResponseExtensionItem.Builder<?> builder = feeCheckItem.createResponseBuilder(); FeeCheckResponseExtensionItem.Builder<?> builder = feeCheckItem.createResponseBuilder();
Optional<DomainBase> domainBase = Optional.ofNullable(domainObjs.get(domainName)); Optional<Domain> domain = Optional.ofNullable(domainObjs.get(domainName));
handleFeeRequest( handleFeeRequest(
feeCheckItem, feeCheckItem,
builder, builder,
domainNames.get(domainName), domainNames.get(domainName),
domainBase, domain,
feeCheck.getCurrency(), feeCheck.getCurrency(),
now, now,
pricingLogic, pricingLogic,
@ -301,10 +301,10 @@ public final class DomainCheckFlow implements Flow {
* nicer in Cloud SQL when we can SELECT just the fields we want rather than having to load the * nicer in Cloud SQL when we can SELECT just the fields we want rather than having to load the
* entire entity. * entire entity.
*/ */
private ImmutableMap<String, DomainBase> loadDomainsForRestoreChecks( private ImmutableMap<String, Domain> loadDomainsForRestoreChecks(
FeeCheckCommandExtension<?, ?> feeCheck, FeeCheckCommandExtension<?, ?> feeCheck,
ImmutableMap<String, InternetDomainName> domainNames, ImmutableMap<String, InternetDomainName> domainNames,
ImmutableMap<String, ForeignKeyIndex<DomainBase>> existingDomains) { ImmutableMap<String, ForeignKeyIndex<Domain>> existingDomains) {
ImmutableList<String> restoreCheckDomains; ImmutableList<String> restoreCheckDomains;
if (feeCheck instanceof FeeCheckCommandExtensionV06) { if (feeCheck instanceof FeeCheckCommandExtensionV06) {
// The V06 fee extension supports specifying the command fees to check on a per-domain basis. // The V06 fee extension supports specifying the command fees to check on a per-domain basis.
@ -326,25 +326,25 @@ public final class DomainCheckFlow implements Flow {
} }
// Filter down to just domains we know exist and then use the EppResource cache to load them. // Filter down to just domains we know exist and then use the EppResource cache to load them.
ImmutableMap<String, VKey<DomainBase>> existingDomainsToLoad = ImmutableMap<String, VKey<Domain>> existingDomainsToLoad =
restoreCheckDomains.stream() restoreCheckDomains.stream()
.filter(existingDomains::containsKey) .filter(existingDomains::containsKey)
.collect(toImmutableMap(d -> d, d -> existingDomains.get(d).getResourceKey())); .collect(toImmutableMap(d -> d, d -> existingDomains.get(d).getResourceKey()));
ImmutableMap<VKey<? extends EppResource>, EppResource> loadedDomains = ImmutableMap<VKey<? extends EppResource>, EppResource> loadedDomains =
EppResource.loadCached(ImmutableList.copyOf(existingDomainsToLoad.values())); EppResource.loadCached(ImmutableList.copyOf(existingDomainsToLoad.values()));
return ImmutableMap.copyOf( return ImmutableMap.copyOf(
Maps.transformEntries(existingDomainsToLoad, (k, v) -> (DomainBase) loadedDomains.get(v))); Maps.transformEntries(existingDomainsToLoad, (k, v) -> (Domain) loadedDomains.get(v)));
} }
private ImmutableMap<String, BillingEvent.Recurring> loadRecurrencesForDomains( private ImmutableMap<String, BillingEvent.Recurring> loadRecurrencesForDomains(
ImmutableMap<String, DomainBase> domainObjs) { ImmutableMap<String, Domain> domainObjs) {
return tm().transact( return tm().transact(
() -> { () -> {
ImmutableMap<VKey<? extends BillingEvent.Recurring>, BillingEvent.Recurring> ImmutableMap<VKey<? extends BillingEvent.Recurring>, BillingEvent.Recurring>
recurrences = recurrences =
tm().loadByKeys( tm().loadByKeys(
domainObjs.values().stream() domainObjs.values().stream()
.map(DomainBase::getAutorenewBillingEvent) .map(Domain::getAutorenewBillingEvent)
.collect(toImmutableSet())); .collect(toImmutableSet()));
return ImmutableMap.copyOf( return ImmutableMap.copyOf(
Maps.transformValues( Maps.transformValues(

View file

@ -83,7 +83,7 @@ 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.billing.BillingEvent.RenewalPriceBehavior; import google.registry.model.billing.BillingEvent.RenewalPriceBehavior;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.Domain;
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.DomainHistory; import google.registry.model.domain.DomainHistory;
@ -247,7 +247,7 @@ public final class DomainCreateFlow implements TransactionalFlow {
verifyUnitIsYears(period); verifyUnitIsYears(period);
int years = period.getValue(); int years = period.getValue();
validateRegistrationPeriod(years); validateRegistrationPeriod(years);
verifyResourceDoesNotExist(DomainBase.class, targetId, now, registrarId); verifyResourceDoesNotExist(Domain.class, targetId, now, registrarId);
// 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);
@ -368,8 +368,8 @@ public final class DomainCreateFlow implements TransactionalFlow {
reservationTypes.contains(NAME_COLLISION) reservationTypes.contains(NAME_COLLISION)
? ImmutableSet.of(SERVER_HOLD) ? ImmutableSet.of(SERVER_HOLD)
: ImmutableSet.of(); : ImmutableSet.of();
DomainBase domain = Domain domain =
new DomainBase.Builder() new Domain.Builder()
.setCreationRegistrarId(registrarId) .setCreationRegistrarId(registrarId)
.setPersistedCurrentSponsorRegistrarId(registrarId) .setPersistedCurrentSponsorRegistrarId(registrarId)
.setRepoId(repoId) .setRepoId(repoId)
@ -530,7 +530,7 @@ public final class DomainCreateFlow implements TransactionalFlow {
} }
private DomainHistory buildDomainHistory( private DomainHistory buildDomainHistory(
DomainBase domain, Registry registry, DateTime now, Period period, Duration addGracePeriod) { Domain domain, Registry registry, DateTime now, Period period, Duration addGracePeriod) {
// We ignore prober transactions // We ignore prober transactions
if (registry.getTldType() == TldType.REAL) { if (registry.getTldType() == TldType.REAL) {
historyBuilder historyBuilder
@ -645,13 +645,12 @@ public final class DomainCreateFlow implements TransactionalFlow {
.build(); .build();
} }
private void enqueueTasks( private void enqueueTasks(Domain newDomain, boolean hasSignedMarks, boolean hasClaimsNotice) {
DomainBase newDomain, boolean hasSignedMarks, boolean hasClaimsNotice) {
if (newDomain.shouldPublishToDns()) { if (newDomain.shouldPublishToDns()) {
dnsQueue.addDomainRefreshTask(newDomain.getDomainName()); dnsQueue.addDomainRefreshTask(newDomain.getDomainName());
} }
if (hasClaimsNotice || hasSignedMarks) { if (hasClaimsNotice || hasSignedMarks) {
LordnTaskUtils.enqueueDomainBaseTask(newDomain); LordnTaskUtils.enqueueDomainTask(newDomain);
} }
} }

View file

@ -64,7 +64,7 @@ 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.DomainBase; import google.registry.model.domain.Domain;
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.GracePeriod; import google.registry.model.domain.GracePeriod;
@ -146,13 +146,13 @@ public final class DomainDeleteFlow implements TransactionalFlow {
extensionManager.validate(); extensionManager.validate();
DateTime now = tm().getTransactionTime(); DateTime now = tm().getTransactionTime();
// Loads the target resource if it exists // Loads the target resource if it exists
DomainBase existingDomain = loadAndVerifyExistence(DomainBase.class, targetId, now); Domain existingDomain = loadAndVerifyExistence(Domain.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(
AfterValidationParameters.newBuilder().setExistingDomain(existingDomain).build()); AfterValidationParameters.newBuilder().setExistingDomain(existingDomain).build());
ImmutableSet.Builder<ImmutableObject> entitiesToSave = new ImmutableSet.Builder<>(); ImmutableSet.Builder<ImmutableObject> entitiesToSave = new ImmutableSet.Builder<>();
DomainBase.Builder builder; Domain.Builder builder;
if (existingDomain.getStatusValues().contains(StatusValue.PENDING_TRANSFER)) { if (existingDomain.getStatusValues().contains(StatusValue.PENDING_TRANSFER)) {
builder = builder =
denyPendingTransfer(existingDomain, TransferStatus.SERVER_CANCELLED, now, registrarId) denyPendingTransfer(existingDomain, TransferStatus.SERVER_CANCELLED, now, registrarId)
@ -253,7 +253,7 @@ public final class DomainDeleteFlow implements TransactionalFlow {
} }
builder.setRegistrationExpirationTime(newExpirationTime); builder.setRegistrationExpirationTime(newExpirationTime);
DomainBase newDomain = builder.build(); Domain newDomain = builder.build();
DomainHistory domainHistory = DomainHistory domainHistory =
buildDomainHistory(newDomain, registry, now, durationUntilDelete, inAddGracePeriod); buildDomainHistory(newDomain, registry, now, durationUntilDelete, inAddGracePeriod);
updateForeignKeyIndexDeletionTime(newDomain); updateForeignKeyIndexDeletionTime(newDomain);
@ -294,7 +294,7 @@ public final class DomainDeleteFlow implements TransactionalFlow {
.build(); .build();
} }
private void verifyDeleteAllowed(DomainBase existingDomain, Registry registry, DateTime now) private void verifyDeleteAllowed(Domain existingDomain, Registry registry, DateTime now)
throws EppException { throws EppException {
verifyNoDisallowedStatuses(existingDomain, DISALLOWED_STATUSES); verifyNoDisallowedStatuses(existingDomain, DISALLOWED_STATUSES);
verifyOptionalAuthInfo(authInfo, existingDomain); verifyOptionalAuthInfo(authInfo, existingDomain);
@ -309,7 +309,7 @@ public final class DomainDeleteFlow implements TransactionalFlow {
} }
private DomainHistory buildDomainHistory( private DomainHistory buildDomainHistory(
DomainBase domain, Domain domain,
Registry registry, Registry registry,
DateTime now, DateTime now,
Duration durationUntilDelete, Duration durationUntilDelete,
@ -342,7 +342,7 @@ public final class DomainDeleteFlow implements TransactionalFlow {
} }
private PollMessage.OneTime createDeletePollMessage( private PollMessage.OneTime createDeletePollMessage(
DomainBase existingDomain, Key<DomainHistory> domainHistoryKey, DateTime deletionTime) { Domain existingDomain, Key<DomainHistory> domainHistoryKey, DateTime deletionTime) {
Optional<MetadataExtension> metadataExtension = Optional<MetadataExtension> metadataExtension =
eppInput.getSingleExtension(MetadataExtension.class); eppInput.getSingleExtension(MetadataExtension.class);
boolean hasMetadataMessage = boolean hasMetadataMessage =
@ -367,7 +367,7 @@ public final class DomainDeleteFlow implements TransactionalFlow {
} }
private PollMessage.OneTime createImmediateDeletePollMessage( private PollMessage.OneTime createImmediateDeletePollMessage(
DomainBase existingDomain, Domain existingDomain,
Key<DomainHistory> domainHistoryKey, Key<DomainHistory> domainHistoryKey,
DateTime now, DateTime now,
DateTime deletionTime) { DateTime deletionTime) {
@ -389,7 +389,7 @@ public final class DomainDeleteFlow implements TransactionalFlow {
@Nullable @Nullable
private ImmutableList<FeeTransformResponseExtension> getResponseExtensions( private ImmutableList<FeeTransformResponseExtension> getResponseExtensions(
BillingEvent.Recurring recurringBillingEvent, DomainBase existingDomain, DateTime now) { BillingEvent.Recurring recurringBillingEvent, Domain 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

@ -25,7 +25,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.DomainBase.MAX_REGISTRATION_YEARS; import static google.registry.model.domain.Domain.MAX_REGISTRATION_YEARS;
import static google.registry.model.tld.Registries.findTldForName; import static google.registry.model.tld.Registries.findTldForName;
import static google.registry.model.tld.Registries.getTlds; import static google.registry.model.tld.Registries.getTlds;
import static google.registry.model.tld.Registry.TldState.GENERAL_AVAILABILITY; import static google.registry.model.tld.Registry.TldState.GENERAL_AVAILABILITY;
@ -82,7 +82,7 @@ import google.registry.model.billing.BillingEvent.Recurring;
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.DesignatedContact.Type; import google.registry.model.domain.DesignatedContact.Type;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainCommand.Create; 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;
@ -553,7 +553,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(DomainBase domain) { public static BillingEvent.Recurring.Builder newAutorenewBillingEvent(Domain 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))
@ -566,7 +566,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(DomainBase domain) { public static PollMessage.Autorenew.Builder newAutorenewPollMessage(Domain domain) {
return new PollMessage.Autorenew.Builder() return new PollMessage.Autorenew.Builder()
.setTargetId(domain.getDomainName()) .setTargetId(domain.getDomainName())
.setRegistrarId(domain.getCurrentSponsorRegistrarId()) .setRegistrarId(domain.getCurrentSponsorRegistrarId())
@ -583,7 +583,7 @@ public class DomainFlowUtils {
* *
* <p>Returns the new autorenew recurring billing event. * <p>Returns the new autorenew recurring billing event.
*/ */
public static Recurring updateAutorenewRecurrenceEndTime(DomainBase domain, DateTime newEndTime) { public static Recurring updateAutorenewRecurrenceEndTime(Domain domain, DateTime newEndTime) {
Optional<PollMessage.Autorenew> autorenewPollMessage = Optional<PollMessage.Autorenew> autorenewPollMessage =
tm().loadByKeyIfPresent(domain.getAutorenewPollMessage()); tm().loadByKeyIfPresent(domain.getAutorenewPollMessage());
@ -628,7 +628,7 @@ public class DomainFlowUtils {
FeeQueryCommandExtensionItem feeRequest, FeeQueryCommandExtensionItem feeRequest,
FeeQueryResponseExtensionItem.Builder<?, ?> builder, FeeQueryResponseExtensionItem.Builder<?, ?> builder,
InternetDomainName domainName, InternetDomainName domainName,
Optional<DomainBase> domain, Optional<Domain> domain,
@Nullable CurrencyUnit topLevelCurrency, @Nullable CurrencyUnit topLevelCurrency,
DateTime currentDate, DateTime currentDate,
DomainPricingLogic pricingLogic, DomainPricingLogic pricingLogic,
@ -878,7 +878,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 DomainBase#MAX_REGISTRATION_YEARS}) from "now". * years (e.g. {@link Domain#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
*/ */
@ -891,7 +891,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 DomainBase#MAX_REGISTRATION_YEARS}). * years (e.g. {@link Domain#MAX_REGISTRATION_YEARS}).
* *
* @throws ExceedsMaxRegistrationYearsException if the new registration period is too long * @throws ExceedsMaxRegistrationYearsException if the new registration period is too long
*/ */
@ -947,7 +947,7 @@ public class DomainFlowUtils {
} }
/** If a domain "clientUpdateProhibited" set, updates must clear it or fail. */ /** If a domain "clientUpdateProhibited" set, updates must clear it or fail. */
static void verifyClientUpdateNotProhibited(Update command, DomainBase existingResource) static void verifyClientUpdateNotProhibited(Update command, Domain existingResource)
throws ResourceHasClientUpdateProhibitedException { throws ResourceHasClientUpdateProhibitedException {
if (existingResource.getStatusValues().contains(StatusValue.CLIENT_UPDATE_PROHIBITED) if (existingResource.getStatusValues().contains(StatusValue.CLIENT_UPDATE_PROHIBITED)
&& !command && !command
@ -1120,13 +1120,13 @@ 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(
DomainBase domainBase, Domain domain,
final DateTime now, final DateTime now,
Duration maxSearchPeriod, Duration maxSearchPeriod,
final ImmutableSet<TransactionReportField> cancelableFields) { final ImmutableSet<TransactionReportField> cancelableFields) {
List<? extends HistoryEntry> recentHistoryEntries = List<? extends HistoryEntry> recentHistoryEntries =
findRecentHistoryEntries(domainBase, now, maxSearchPeriod); findRecentHistoryEntries(domain, now, maxSearchPeriod);
Optional<? extends HistoryEntry> entryToCancel = Optional<? extends HistoryEntry> entryToCancel =
Streams.findLast( Streams.findLast(
recentHistoryEntries.stream() recentHistoryEntries.stream()
@ -1165,14 +1165,14 @@ public class DomainFlowUtils {
} }
private static List<? extends HistoryEntry> findRecentHistoryEntries( private static List<? extends HistoryEntry> findRecentHistoryEntries(
DomainBase domainBase, DateTime now, Duration maxSearchPeriod) { Domain domain, DateTime now, Duration maxSearchPeriod) {
return jpaTm() return jpaTm()
.query( .query(
"FROM DomainHistory WHERE modificationTime >= :beginning AND domainRepoId = " "FROM DomainHistory WHERE modificationTime >= :beginning AND domainRepoId = "
+ ":repoId ORDER BY modificationTime ASC", + ":repoId ORDER BY modificationTime ASC",
DomainHistory.class) DomainHistory.class)
.setParameter("beginning", now.minus(maxSearchPeriod)) .setParameter("beginning", now.minus(maxSearchPeriod))
.setParameter("repoId", domainBase.getRepoId()) .setParameter("repoId", domain.getRepoId())
.getResultList(); .getResultList();
} }

View file

@ -36,7 +36,7 @@ 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.Domain;
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;
@ -96,8 +96,8 @@ public final class DomainInfoFlow implements Flow {
validateRegistrarIsLoggedIn(registrarId); validateRegistrarIsLoggedIn(registrarId);
extensionManager.validate(); extensionManager.validate();
DateTime now = clock.nowUtc(); DateTime now = clock.nowUtc();
DomainBase domain = verifyExistence( Domain domain =
DomainBase.class, targetId, loadByForeignKey(DomainBase.class, targetId, now)); verifyExistence(Domain.class, targetId, loadByForeignKey(Domain.class, targetId, now));
verifyOptionalAuthInfo(authInfo, domain); verifyOptionalAuthInfo(authInfo, domain);
flowCustomLogic.afterValidation( flowCustomLogic.afterValidation(
AfterValidationParameters.newBuilder().setDomain(domain).build()); AfterValidationParameters.newBuilder().setDomain(domain).build());
@ -142,8 +142,8 @@ public final class DomainInfoFlow implements Flow {
.build(); .build();
} }
private ImmutableList<ResponseExtension> getDomainResponseExtensions( private ImmutableList<ResponseExtension> getDomainResponseExtensions(Domain domain, DateTime now)
DomainBase domain, DateTime now) throws EppException { 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

@ -57,7 +57,7 @@ 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.billing.BillingEvent.Recurring; import google.registry.model.billing.BillingEvent.Recurring;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainCommand.Renew; import google.registry.model.domain.DomainCommand.Renew;
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;
@ -166,7 +166,7 @@ public final class DomainRenewFlow implements TransactionalFlow {
DateTime now = tm().getTransactionTime(); DateTime now = tm().getTransactionTime();
Renew command = (Renew) resourceCommand; Renew command = (Renew) resourceCommand;
// Loads the target resource if it exists // Loads the target resource if it exists
DomainBase existingDomain = loadAndVerifyExistence(DomainBase.class, targetId, now); Domain existingDomain = loadAndVerifyExistence(Domain.class, targetId, now);
Optional<AllocationToken> allocationToken = Optional<AllocationToken> allocationToken =
allocationTokenFlowUtils.verifyAllocationTokenIfPresent( allocationTokenFlowUtils.verifyAllocationTokenIfPresent(
existingDomain, existingDomain,
@ -223,7 +223,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);
DomainBase newDomain = Domain newDomain =
existingDomain existingDomain
.asBuilder() .asBuilder()
.setLastEppUpdateTime(now) .setLastEppUpdateTime(now)
@ -275,7 +275,7 @@ public final class DomainRenewFlow implements TransactionalFlow {
} }
private DomainHistory buildDomainHistory( private DomainHistory buildDomainHistory(
DomainBase newDomain, DateTime now, Period period, Duration renewGracePeriod) { Domain newDomain, DateTime now, Period period, Duration renewGracePeriod) {
Optional<MetadataExtension> metadataExtensionOpt = Optional<MetadataExtension> metadataExtensionOpt =
eppInput.getSingleExtension(MetadataExtension.class); eppInput.getSingleExtension(MetadataExtension.class);
if (metadataExtensionOpt.isPresent()) { if (metadataExtensionOpt.isPresent()) {
@ -299,10 +299,8 @@ public final class DomainRenewFlow implements TransactionalFlow {
.build(); .build();
} }
private void verifyRenewAllowed( private void verifyRenewAllowed(Optional<AuthInfo> authInfo, Domain existingDomain, Renew command)
Optional<AuthInfo> authInfo, throws EppException {
DomainBase existingDomain,
Renew command) throws EppException {
verifyOptionalAuthInfo(authInfo, existingDomain); verifyOptionalAuthInfo(authInfo, existingDomain);
verifyNoDisallowedStatuses(existingDomain, RENEW_DISALLOWED_STATUSES); verifyNoDisallowedStatuses(existingDomain, RENEW_DISALLOWED_STATUSES);
if (!isSuperuser) { if (!isSuperuser) {

View file

@ -50,7 +50,7 @@ import google.registry.model.ImmutableObject;
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.Domain;
import google.registry.model.domain.DomainCommand.Update; import google.registry.model.domain.DomainCommand.Update;
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;
@ -140,7 +140,7 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow {
extensionManager.validate(); extensionManager.validate();
Update command = (Update) resourceCommand; Update command = (Update) resourceCommand;
DateTime now = tm().getTransactionTime(); DateTime now = tm().getTransactionTime();
DomainBase existingDomain = loadAndVerifyExistence(DomainBase.class, targetId, now); Domain existingDomain = loadAndVerifyExistence(Domain.class, targetId, now);
boolean isExpired = existingDomain.getRegistrationExpirationTime().isBefore(now); boolean isExpired = existingDomain.getRegistrationExpirationTime().isBefore(now);
FeesAndCredits feesAndCredits = FeesAndCredits feesAndCredits =
pricingLogic.getRestorePrice( pricingLogic.getRestorePrice(
@ -180,7 +180,7 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow {
new DomainHistoryId( new DomainHistoryId(
domainHistoryKey.getParent().getName(), domainHistoryKey.getId())) domainHistoryKey.getParent().getName(), domainHistoryKey.getId()))
.build(); .build();
DomainBase newDomain = Domain newDomain =
performRestore( performRestore(
existingDomain, existingDomain,
newExpirationTime, newExpirationTime,
@ -199,7 +199,7 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow {
.build(); .build();
} }
private DomainHistory buildDomainHistory(DomainBase newDomain, DateTime now) { private DomainHistory buildDomainHistory(Domain newDomain, DateTime now) {
return historyBuilder return historyBuilder
.setType(DOMAIN_RESTORE) .setType(DOMAIN_RESTORE)
.setDomain(newDomain) .setDomain(newDomain)
@ -212,10 +212,11 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow {
private void verifyRestoreAllowed( private void verifyRestoreAllowed(
Update command, Update command,
DomainBase existingDomain, Domain existingDomain,
Optional<FeeUpdateCommandExtension> feeUpdate, Optional<FeeUpdateCommandExtension> feeUpdate,
FeesAndCredits feesAndCredits, FeesAndCredits feesAndCredits,
DateTime now) throws EppException { DateTime now)
throws EppException {
verifyOptionalAuthInfo(authInfo, existingDomain); verifyOptionalAuthInfo(authInfo, existingDomain);
if (!isSuperuser) { if (!isSuperuser) {
verifyResourceOwnership(registrarId, existingDomain); verifyResourceOwnership(registrarId, existingDomain);
@ -235,8 +236,8 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow {
validateFeeChallenge(targetId, now, feeUpdate, feesAndCredits); validateFeeChallenge(targetId, now, feeUpdate, feesAndCredits);
} }
private static DomainBase performRestore( private static Domain performRestore(
DomainBase existingDomain, Domain existingDomain,
DateTime newExpirationTime, DateTime newExpirationTime,
BillingEvent.Recurring autorenewEvent, BillingEvent.Recurring autorenewEvent,
PollMessage.Autorenew autorenewPollMessage, PollMessage.Autorenew autorenewPollMessage,

View file

@ -49,7 +49,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.DomainBase; import google.registry.model.domain.Domain;
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.GracePeriod; import google.registry.model.domain.GracePeriod;
@ -100,7 +100,7 @@ public final class DomainTransferApproveFlow implements TransactionalFlow {
/** /**
* The logic in this flow, which handles client approvals, very closely parallels the logic in * The logic in this flow, which handles client approvals, very closely parallels the logic in
* {@link DomainBase#cloneProjectedAtTime} which handles implicit server approvals. * {@link Domain#cloneProjectedAtTime} which handles implicit server approvals.
*/ */
@Override @Override
public EppResponse run() throws EppException { public EppResponse run() throws EppException {
@ -108,7 +108,7 @@ public final class DomainTransferApproveFlow implements TransactionalFlow {
validateRegistrarIsLoggedIn(registrarId); validateRegistrarIsLoggedIn(registrarId);
extensionManager.validate(); extensionManager.validate();
DateTime now = tm().getTransactionTime(); DateTime now = tm().getTransactionTime();
DomainBase existingDomain = loadAndVerifyExistence(DomainBase.class, targetId, now); Domain existingDomain = loadAndVerifyExistence(Domain.class, targetId, now);
verifyOptionalAuthInfo(authInfo, existingDomain); verifyOptionalAuthInfo(authInfo, existingDomain);
verifyHasPendingTransfer(existingDomain); verifyHasPendingTransfer(existingDomain);
verifyResourceOwnership(registrarId, existingDomain); verifyResourceOwnership(registrarId, existingDomain);
@ -190,9 +190,9 @@ public final class DomainTransferApproveFlow implements TransactionalFlow {
domainHistoryKey.getParent().getName(), domainHistoryKey.getId())) domainHistoryKey.getParent().getName(), domainHistoryKey.getId()))
.build(); .build();
// Construct the post-transfer domain. // Construct the post-transfer domain.
DomainBase partiallyApprovedDomain = Domain partiallyApprovedDomain =
approvePendingTransfer(existingDomain, TransferStatus.CLIENT_APPROVED, now); approvePendingTransfer(existingDomain, TransferStatus.CLIENT_APPROVED, now);
DomainBase newDomain = Domain newDomain =
partiallyApprovedDomain partiallyApprovedDomain
.asBuilder() .asBuilder()
// Update the transferredRegistrationExpirationTime here since approvePendingTransfer() // Update the transferredRegistrationExpirationTime here since approvePendingTransfer()
@ -246,7 +246,7 @@ public final class DomainTransferApproveFlow implements TransactionalFlow {
} }
private DomainHistory buildDomainHistory( private DomainHistory buildDomainHistory(
DomainBase newDomain, Registry registry, DateTime now, String gainingRegistrarId) { Domain newDomain, Registry registry, DateTime now, String gainingRegistrarId) {
ImmutableSet<DomainTransactionRecord> cancelingRecords = ImmutableSet<DomainTransactionRecord> cancelingRecords =
createCancelingRecords( createCancelingRecords(
newDomain, newDomain,

View file

@ -40,7 +40,7 @@ import google.registry.flows.FlowModule.Superuser;
import google.registry.flows.FlowModule.TargetId; 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.domain.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory; import google.registry.model.domain.DomainHistory;
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;
@ -90,7 +90,7 @@ public final class DomainTransferCancelFlow implements TransactionalFlow {
validateRegistrarIsLoggedIn(registrarId); validateRegistrarIsLoggedIn(registrarId);
extensionManager.validate(); extensionManager.validate();
DateTime now = tm().getTransactionTime(); DateTime now = tm().getTransactionTime();
DomainBase existingDomain = loadAndVerifyExistence(DomainBase.class, targetId, now); Domain existingDomain = loadAndVerifyExistence(Domain.class, targetId, now);
verifyOptionalAuthInfo(authInfo, existingDomain); verifyOptionalAuthInfo(authInfo, existingDomain);
verifyHasPendingTransfer(existingDomain); verifyHasPendingTransfer(existingDomain);
verifyTransferInitiator(registrarId, existingDomain); verifyTransferInitiator(registrarId, existingDomain);
@ -104,7 +104,7 @@ public final class DomainTransferCancelFlow implements TransactionalFlow {
.setId(domainHistoryKey.getId()) .setId(domainHistoryKey.getId())
.setOtherRegistrarId(existingDomain.getTransferData().getLosingRegistrarId()); .setOtherRegistrarId(existingDomain.getTransferData().getLosingRegistrarId());
DomainBase newDomain = Domain newDomain =
denyPendingTransfer(existingDomain, TransferStatus.CLIENT_CANCELLED, now, registrarId); denyPendingTransfer(existingDomain, TransferStatus.CLIENT_CANCELLED, now, registrarId);
DomainHistory domainHistory = buildDomainHistory(newDomain, registry, now); DomainHistory domainHistory = buildDomainHistory(newDomain, registry, now);
tm().putAll( tm().putAll(
@ -123,7 +123,7 @@ public final class DomainTransferCancelFlow implements TransactionalFlow {
.build(); .build();
} }
private DomainHistory buildDomainHistory(DomainBase newDomain, Registry registry, DateTime now) { private DomainHistory buildDomainHistory(Domain newDomain, Registry registry, DateTime now) {
ImmutableSet<DomainTransactionRecord> cancelingRecords = ImmutableSet<DomainTransactionRecord> cancelingRecords =
createCancelingRecords( createCancelingRecords(
newDomain, newDomain,

View file

@ -28,7 +28,7 @@ import google.registry.flows.ResourceFlowUtils;
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.DomainBase; import google.registry.model.domain.Domain;
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;
@ -71,7 +71,7 @@ public final class DomainTransferQueryFlow implements Flow {
validateRegistrarIsLoggedIn(registrarId); validateRegistrarIsLoggedIn(registrarId);
extensionManager.validate(); // There are no legal extensions for this flow. extensionManager.validate(); // There are no legal extensions for this flow.
DateTime now = clock.nowUtc(); DateTime now = clock.nowUtc();
DomainBase domain = loadAndVerifyExistence(DomainBase.class, targetId, now); Domain domain = loadAndVerifyExistence(Domain.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

@ -42,7 +42,7 @@ import google.registry.flows.FlowModule.Superuser;
import google.registry.flows.FlowModule.TargetId; 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.domain.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory; import google.registry.model.domain.DomainHistory;
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;
@ -92,7 +92,7 @@ public final class DomainTransferRejectFlow implements TransactionalFlow {
validateRegistrarIsLoggedIn(registrarId); validateRegistrarIsLoggedIn(registrarId);
extensionManager.validate(); extensionManager.validate();
DateTime now = tm().getTransactionTime(); DateTime now = tm().getTransactionTime();
DomainBase existingDomain = loadAndVerifyExistence(DomainBase.class, targetId, now); Domain existingDomain = loadAndVerifyExistence(Domain.class, targetId, now);
Registry registry = Registry.get(existingDomain.getTld()); Registry registry = Registry.get(existingDomain.getTld());
Key<DomainHistory> domainHistoryKey = createHistoryKey(existingDomain, DomainHistory.class); Key<DomainHistory> domainHistoryKey = createHistoryKey(existingDomain, DomainHistory.class);
historyBuilder historyBuilder
@ -105,7 +105,7 @@ public final class DomainTransferRejectFlow implements TransactionalFlow {
if (!isSuperuser) { if (!isSuperuser) {
checkAllowedAccessToTld(registrarId, existingDomain.getTld()); checkAllowedAccessToTld(registrarId, existingDomain.getTld());
} }
DomainBase newDomain = Domain newDomain =
denyPendingTransfer(existingDomain, TransferStatus.CLIENT_REJECTED, now, registrarId); denyPendingTransfer(existingDomain, TransferStatus.CLIENT_REJECTED, now, registrarId);
DomainHistory domainHistory = buildDomainHistory(newDomain, registry, now); DomainHistory domainHistory = buildDomainHistory(newDomain, registry, now);
tm().putAll( tm().putAll(
@ -124,7 +124,7 @@ public final class DomainTransferRejectFlow implements TransactionalFlow {
.build(); .build();
} }
private DomainHistory buildDomainHistory(DomainBase newDomain, Registry registry, DateTime now) { private DomainHistory buildDomainHistory(Domain newDomain, Registry registry, DateTime now) {
ImmutableSet<DomainTransactionRecord> cancelingRecords = ImmutableSet<DomainTransactionRecord> cancelingRecords =
createCancelingRecords( createCancelingRecords(
newDomain, newDomain,

View file

@ -52,7 +52,7 @@ 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.Domain;
import google.registry.model.domain.DomainCommand.Transfer; import google.registry.model.domain.DomainCommand.Transfer;
import google.registry.model.domain.DomainHistory; import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.Period; import google.registry.model.domain.Period;
@ -149,7 +149,7 @@ public final class DomainTransferRequestFlow implements TransactionalFlow {
verifyRegistrarIsActive(gainingClientId); verifyRegistrarIsActive(gainingClientId);
extensionManager.validate(); extensionManager.validate();
DateTime now = tm().getTransactionTime(); DateTime now = tm().getTransactionTime();
DomainBase existingDomain = loadAndVerifyExistence(DomainBase.class, targetId, now); Domain existingDomain = loadAndVerifyExistence(Domain.class, targetId, now);
Optional<DomainTransferRequestSuperuserExtension> superuserExtension = Optional<DomainTransferRequestSuperuserExtension> superuserExtension =
eppInput.getSingleExtension(DomainTransferRequestSuperuserExtension.class); eppInput.getSingleExtension(DomainTransferRequestSuperuserExtension.class);
Period period = Period period =
@ -190,7 +190,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.
DomainBase domainAtTransferTime = existingDomain.cloneProjectedAtTime(automaticTransferTime); Domain domainAtTransferTime = existingDomain.cloneProjectedAtTime(automaticTransferTime);
// The new expiration time if there is a server approval. // The new expiration time if there is a server approval.
DateTime serverApproveNewExpirationTime = DateTime serverApproveNewExpirationTime =
computeExDateForApprovalTime(domainAtTransferTime, automaticTransferTime, period); computeExDateForApprovalTime(domainAtTransferTime, automaticTransferTime, period);
@ -231,7 +231,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);
DomainBase newDomain = Domain newDomain =
existingDomain existingDomain
.asBuilder() .asBuilder()
.setTransferData(pendingTransferData) .setTransferData(pendingTransferData)
@ -255,7 +255,7 @@ public final class DomainTransferRequestFlow implements TransactionalFlow {
} }
private void verifyTransferAllowed( private void verifyTransferAllowed(
DomainBase existingDomain, Domain existingDomain,
Period period, Period period,
DateTime now, DateTime now,
Optional<DomainTransferRequestSuperuserExtension> superuserExtension) Optional<DomainTransferRequestSuperuserExtension> superuserExtension)
@ -320,7 +320,7 @@ public final class DomainTransferRequestFlow implements TransactionalFlow {
} }
private DomainHistory buildDomainHistory( private DomainHistory buildDomainHistory(
DomainBase newDomain, Registry registry, DateTime now, Period period) { Domain newDomain, Registry registry, DateTime now, Period period) {
return historyBuilder return historyBuilder
.setType(DOMAIN_TRANSFER_REQUEST) .setType(DOMAIN_TRANSFER_REQUEST)
.setPeriod(period) .setPeriod(period)
@ -337,7 +337,7 @@ public final class DomainTransferRequestFlow implements TransactionalFlow {
} }
private DomainTransferResponse createResponse( private DomainTransferResponse createResponse(
Period period, DomainBase existingDomain, DomainBase newDomain, DateTime now) { Period period, Domain existingDomain, Domain 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.DomainBase; import google.registry.model.domain.Domain;
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.GracePeriod; import google.registry.model.domain.GracePeriod;
@ -109,7 +109,7 @@ public final class DomainTransferUtils {
DateTime automaticTransferTime, DateTime automaticTransferTime,
DateTime serverApproveNewExpirationTime, DateTime serverApproveNewExpirationTime,
Key<DomainHistory> domainHistoryKey, Key<DomainHistory> domainHistoryKey,
DomainBase existingDomain, Domain existingDomain,
Trid trid, Trid trid,
String gainingRegistrarId, String gainingRegistrarId,
Optional<Money> transferCost, Optional<Money> transferCost,
@ -276,10 +276,9 @@ public final class DomainTransferUtils {
DateTime now, DateTime now,
Key<DomainHistory> domainHistoryKey, Key<DomainHistory> domainHistoryKey,
String targetId, String targetId,
DomainBase existingDomain, Domain existingDomain,
Optional<Money> transferCost) { Optional<Money> transferCost) {
DomainBase domainAtTransferTime = Domain domainAtTransferTime = existingDomain.cloneProjectedAtTime(automaticTransferTime);
existingDomain.cloneProjectedAtTime(automaticTransferTime);
GracePeriod autorenewGracePeriod = GracePeriod autorenewGracePeriod =
getOnlyElement( getOnlyElement(
domainAtTransferTime.getGracePeriodsOfType(GracePeriodStatus.AUTO_RENEW), null); domainAtTransferTime.getGracePeriodsOfType(GracePeriodStatus.AUTO_RENEW), null);

View file

@ -67,7 +67,7 @@ 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.DesignatedContact; import google.registry.model.domain.DesignatedContact;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.Domain;
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;
@ -173,11 +173,11 @@ public final class DomainUpdateFlow implements TransactionalFlow {
extensionManager.validate(); extensionManager.validate();
DateTime now = tm().getTransactionTime(); DateTime now = tm().getTransactionTime();
Update command = cloneAndLinkReferences((Update) resourceCommand, now); Update command = cloneAndLinkReferences((Update) resourceCommand, now);
DomainBase existingDomain = loadAndVerifyExistence(DomainBase.class, targetId, now); Domain existingDomain = loadAndVerifyExistence(Domain.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());
DomainBase newDomain = performUpdate(command, existingDomain, now); Domain newDomain = performUpdate(command, existingDomain, now);
DomainHistory domainHistory = DomainHistory domainHistory =
historyBuilder.setType(DOMAIN_UPDATE).setDomain(newDomain).build(); historyBuilder.setType(DOMAIN_UPDATE).setDomain(newDomain).build();
validateNewState(newDomain); validateNewState(newDomain);
@ -204,7 +204,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, DomainBase existingDomain, DateTime now) private void verifyUpdateAllowed(Update command, Domain existingDomain, DateTime now)
throws EppException { throws EppException {
verifyOptionalAuthInfo(authInfo, existingDomain); verifyOptionalAuthInfo(authInfo, existingDomain);
AddRemove add = command.getInnerAdd(); AddRemove add = command.getInnerAdd();
@ -233,8 +233,7 @@ public final class DomainUpdateFlow implements TransactionalFlow {
tld, add.getNameserverFullyQualifiedHostNames()); tld, add.getNameserverFullyQualifiedHostNames());
} }
private DomainBase performUpdate(Update command, DomainBase domain, DateTime now) private Domain performUpdate(Update command, Domain domain, DateTime now) throws EppException {
throws EppException {
AddRemove add = command.getInnerAdd(); AddRemove add = command.getInnerAdd();
AddRemove remove = command.getInnerRemove(); AddRemove remove = command.getInnerRemove();
checkSameValuesNotAddedAndRemoved(add.getNameservers(), remove.getNameservers()); checkSameValuesNotAddedAndRemoved(add.getNameservers(), remove.getNameservers());
@ -251,7 +250,7 @@ public final class DomainUpdateFlow implements TransactionalFlow {
Sets.union(Sets.difference(domain.getContacts(), remove.getContacts()), add.getContacts()); Sets.union(Sets.difference(domain.getContacts(), remove.getContacts()), add.getContacts());
validateNoDuplicateContacts(newContacts); validateNoDuplicateContacts(newContacts);
DomainBase.Builder domainBuilder = Domain.Builder domainBuilder =
domain domain
.asBuilder() .asBuilder()
// Handle the secDNS extension. As dsData in secDnsUpdate is read from EPP input and // Handle the secDNS extension. As dsData in secDnsUpdate is read from EPP input and
@ -293,7 +292,7 @@ public final class DomainUpdateFlow implements TransactionalFlow {
} }
} }
private void validateNewState(DomainBase newDomain) throws EppException { private void validateNewState(Domain newDomain) throws EppException {
validateRequiredContactsPresent(newDomain.getRegistrant(), newDomain.getContacts()); validateRequiredContactsPresent(newDomain.getRegistrant(), newDomain.getContacts());
validateDsData(newDomain.getDsData()); validateDsData(newDomain.getDsData());
validateNameserversCountForTld( validateNameserversCountForTld(
@ -304,7 +303,7 @@ 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(
DomainBase existingDomain, DomainBase newDomain, DomainHistory historyEntry, DateTime now) { Domain existingDomain, Domain newDomain, DomainHistory historyEntry, DateTime now) {
Optional<MetadataExtension> metadataExtension = Optional<MetadataExtension> metadataExtension =
eppInput.getSingleExtension(MetadataExtension.class); eppInput.getSingleExtension(MetadataExtension.class);
if (metadataExtension.isPresent() && metadataExtension.get().getRequestedByRegistrar()) { if (metadataExtension.isPresent() && metadataExtension.get().getRequestedByRegistrar()) {
@ -330,7 +329,7 @@ public final class DomainUpdateFlow implements TransactionalFlow {
/** Enqueues a poll message iff a superuser is adding/removing server statuses. */ /** Enqueues a poll message iff a superuser is adding/removing server statuses. */
private Optional<PollMessage.OneTime> createPollMessageForServerStatusUpdates( private Optional<PollMessage.OneTime> createPollMessageForServerStatusUpdates(
DomainBase existingDomain, DomainBase newDomain, DomainHistory historyEntry, DateTime now) { Domain existingDomain, Domain newDomain, DomainHistory historyEntry, DateTime now) {
if (registrarId.equals(existingDomain.getPersistedCurrentSponsorRegistrarId())) { if (registrarId.equals(existingDomain.getPersistedCurrentSponsorRegistrarId())) {
// Don't send a poll message when a superuser registrar is updating its own domain. // Don't send a poll message when a superuser registrar is updating its own domain.
return Optional.empty(); return Optional.empty();

View file

@ -19,7 +19,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.net.InternetDomainName; import com.google.common.net.InternetDomainName;
import google.registry.flows.EppException; import google.registry.flows.EppException;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainCommand; import google.registry.model.domain.DomainCommand;
import google.registry.model.domain.token.AllocationToken; import google.registry.model.domain.token.AllocationToken;
import google.registry.model.tld.Registry; import google.registry.model.tld.Registry;
@ -46,7 +46,7 @@ public class AllocationTokenCustomLogic {
/** Performs additional custom logic for validating a token on an existing domain. */ /** Performs additional custom logic for validating a token on an existing domain. */
public AllocationToken validateToken( public AllocationToken validateToken(
DomainBase domain, AllocationToken token, Registry registry, String registrarId, DateTime now) Domain domain, AllocationToken token, Registry registry, String registrarId, DateTime now)
throws EppException { throws EppException {
// Do nothing. // Do nothing.
return token; return token;

View file

@ -26,7 +26,7 @@ import google.registry.flows.EppException;
import google.registry.flows.EppException.AssociationProhibitsOperationException; import google.registry.flows.EppException.AssociationProhibitsOperationException;
import google.registry.flows.EppException.AuthorizationErrorException; import google.registry.flows.EppException.AuthorizationErrorException;
import google.registry.flows.EppException.StatusProhibitsOperationException; import google.registry.flows.EppException.StatusProhibitsOperationException;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainCommand; import google.registry.model.domain.DomainCommand;
import google.registry.model.domain.token.AllocationToken; import google.registry.model.domain.token.AllocationToken;
import google.registry.model.domain.token.AllocationToken.TokenStatus; import google.registry.model.domain.token.AllocationToken.TokenStatus;
@ -171,7 +171,7 @@ public class AllocationTokenFlowUtils {
/** Verifies and returns the allocation token if one is specified, otherwise does nothing. */ /** Verifies and returns the allocation token if one is specified, otherwise does nothing. */
public Optional<AllocationToken> verifyAllocationTokenIfPresent( public Optional<AllocationToken> verifyAllocationTokenIfPresent(
DomainBase existingDomain, Domain existingDomain,
Registry registry, Registry registry,
String registrarId, String registrarId,
DateTime now, DateTime now,

View file

@ -41,7 +41,7 @@ import google.registry.flows.annotations.ReportingSpec;
import google.registry.flows.exceptions.ResourceAlreadyExistsForThisClientException; import google.registry.flows.exceptions.ResourceAlreadyExistsForThisClientException;
import google.registry.flows.exceptions.ResourceCreateContentionException; import google.registry.flows.exceptions.ResourceCreateContentionException;
import google.registry.model.ImmutableObject; import google.registry.model.ImmutableObject;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.Domain;
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;
@ -109,7 +109,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<DomainBase> superordinateDomain = Optional<Domain> superordinateDomain =
lookupSuperordinateDomain(validateHostName(targetId), now); lookupSuperordinateDomain(validateHostName(targetId), now);
verifySuperordinateDomainNotInPendingDelete(superordinateDomain.orElse(null)); verifySuperordinateDomainNotInPendingDelete(superordinateDomain.orElse(null));
verifySuperordinateDomainOwnership(registrarId, superordinateDomain.orElse(null)); verifySuperordinateDomainOwnership(registrarId, superordinateDomain.orElse(null));
@ -128,7 +128,7 @@ public final class HostCreateFlow implements TransactionalFlow {
.setHostName(targetId) .setHostName(targetId)
.setInetAddresses(command.getInetAddresses()) .setInetAddresses(command.getInetAddresses())
.setRepoId(createRepoId(allocateId(), roidSuffix)) .setRepoId(createRepoId(allocateId(), roidSuffix))
.setSuperordinateDomain(superordinateDomain.map(DomainBase::createVKey).orElse(null)) .setSuperordinateDomain(superordinateDomain.map(Domain::createVKey).orElse(null))
.build(); .build();
historyBuilder.setType(HOST_CREATE).setHost(newHost); historyBuilder.setType(HOST_CREATE).setHost(newHost);
ImmutableSet<ImmutableObject> entitiesToSave = ImmutableSet<ImmutableObject> entitiesToSave =

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.DomainBase; import google.registry.model.domain.Domain;
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 DomainBase} this host is subordinate to, or null for external hosts. */ /** Return the {@link Domain} this host is subordinate to, or null for external hosts. */
public static Optional<DomainBase> lookupSuperordinateDomain( public static Optional<Domain> 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,7 @@ 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<DomainBase> superordinateDomain = Optional<Domain> superordinateDomain = loadByForeignKey(Domain.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,12 +100,12 @@ 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(DomainBase.class, domainName); super(Domain.class, domainName);
} }
} }
/** Ensure that the superordinate domain is sponsored by the provided registrar ID. */ /** Ensure that the superordinate domain is sponsored by the provided registrar ID. */
static void verifySuperordinateDomainOwnership(String registrarId, DomainBase superordinateDomain) static void verifySuperordinateDomainOwnership(String registrarId, Domain superordinateDomain)
throws EppException { throws EppException {
if (superordinateDomain != null if (superordinateDomain != null
&& !registrarId.equals(superordinateDomain.getCurrentSponsorRegistrarId())) { && !registrarId.equals(superordinateDomain.getCurrentSponsorRegistrarId())) {
@ -122,7 +121,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(DomainBase superordinateDomain) static void verifySuperordinateDomainNotInPendingDelete(Domain 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

@ -27,7 +27,7 @@ import google.registry.flows.Flow;
import google.registry.flows.FlowModule.RegistrarId; import google.registry.flows.FlowModule.RegistrarId;
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.DomainBase; import google.registry.model.domain.Domain;
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;
@ -76,7 +76,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()) {
DomainBase superordinateDomain = Domain superordinateDomain =
tm().transact( tm().transact(
() -> tm().loadByKey(host.getSuperordinateDomain()).cloneProjectedAtTime(now)); () -> tm().loadByKey(host.getSuperordinateDomain()).cloneProjectedAtTime(now));
hostInfoDataBuilder hostInfoDataBuilder

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.DomainBase; import google.registry.model.domain.Domain;
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;
@ -137,12 +137,12 @@ 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);
DomainBase oldSuperordinateDomain = Domain oldSuperordinateDomain =
existingHost.isSubordinate() existingHost.isSubordinate()
? tm().loadByKey(existingHost.getSuperordinateDomain()).cloneProjectedAtTime(now) ? tm().loadByKey(existingHost.getSuperordinateDomain()).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<DomainBase> newSuperordinateDomain = Optional<Domain> 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);
@ -155,8 +155,8 @@ 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());
VKey<DomainBase> newSuperordinateDomainKey = VKey<Domain> newSuperordinateDomainKey =
newSuperordinateDomain.map(DomainBase::createVKey).orElse(null); newSuperordinateDomain.map(Domain::createVKey).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 =
Objects.equals(newSuperordinateDomainKey, existingHost.getSuperordinateDomain()) Objects.equals(newSuperordinateDomainKey, existingHost.getSuperordinateDomain())
@ -211,7 +211,7 @@ public final class HostUpdateFlow implements TransactionalFlow {
private void verifyUpdateAllowed( private void verifyUpdateAllowed(
Update command, Update command,
HostResource existingHost, HostResource existingHost,
DomainBase newSuperordinateDomain, Domain newSuperordinateDomain,
EppResource owningResource, EppResource owningResource,
boolean isHostRename) boolean isHostRename)
throws EppException { throws EppException {

View file

@ -20,7 +20,7 @@ import google.registry.model.common.EntityGroupRoot;
import google.registry.model.common.GaeUserIdConverter; import google.registry.model.common.GaeUserIdConverter;
import google.registry.model.contact.ContactHistory; import google.registry.model.contact.ContactHistory;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory; import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.token.AllocationToken; import google.registry.model.domain.token.AllocationToken;
import google.registry.model.host.HostHistory; import google.registry.model.host.HostHistory;
@ -45,7 +45,7 @@ public final class EntityClasses {
AllocationToken.class, AllocationToken.class,
ContactHistory.class, ContactHistory.class,
ContactResource.class, ContactResource.class,
DomainBase.class, Domain.class,
DomainHistory.class, DomainHistory.class,
EntityGroupRoot.class, EntityGroupRoot.class,
EppResourceIndex.class, EppResourceIndex.class,

View file

@ -33,7 +33,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.DomainBase; import google.registry.model.domain.Domain;
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.model.index.ForeignKeyIndex; import google.registry.model.index.ForeignKeyIndex;
@ -342,7 +342,7 @@ public final class EppResourceUtils {
* @param now the logical time of the check * @param now the logical time of the check
* @param limit the maximum number of returned keys, unlimited if null * @param limit the maximum number of returned keys, unlimited if null
*/ */
public static ImmutableSet<VKey<DomainBase>> getLinkedDomainKeys( public static ImmutableSet<VKey<Domain>> getLinkedDomainKeys(
VKey<? extends EppResource> key, DateTime now, @Nullable Integer limit) { VKey<? extends EppResource> key, DateTime now, @Nullable Integer limit) {
checkArgument( checkArgument(
key.getKind().equals(ContactResource.class) || key.getKind().equals(HostResource.class), key.getKind().equals(ContactResource.class) || key.getKind().equals(HostResource.class),
@ -350,16 +350,16 @@ public final class EppResourceUtils {
key); key);
boolean isContactKey = key.getKind().equals(ContactResource.class); boolean isContactKey = key.getKind().equals(ContactResource.class);
if (tm().isOfy()) { if (tm().isOfy()) {
com.googlecode.objectify.cmd.Query<DomainBase> query = com.googlecode.objectify.cmd.Query<Domain> query =
auditedOfy() auditedOfy()
.load() .load()
.type(DomainBase.class) .type(Domain.class)
.filter(isContactKey ? "allContacts.contact" : "nsHosts", key.getOfyKey()) .filter(isContactKey ? "allContacts.contact" : "nsHosts", key.getOfyKey())
.filter("deletionTime >", now); .filter("deletionTime >", now);
if (limit != null) { if (limit != null) {
query.limit(limit); query.limit(limit);
} }
return query.keys().list().stream().map(DomainBase::createVKey).collect(toImmutableSet()); return query.keys().list().stream().map(Domain::createVKey).collect(toImmutableSet());
} else { } else {
return tm().transact( return tm().transact(
() -> { () -> {
@ -382,16 +382,15 @@ public final class EppResourceUtils {
query.setMaxResults(limit); query.setMaxResults(limit);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
ImmutableSet<VKey<DomainBase>> domainBaseKeySet = ImmutableSet<VKey<Domain>> domainKeySet =
(ImmutableSet<VKey<DomainBase>>) (ImmutableSet<VKey<Domain>>)
query query
.getResultStream() .getResultStream()
.map( .map(
repoId -> repoId ->
DomainBase.createVKey( Domain.createVKey(Key.create(Domain.class, (String) repoId)))
Key.create(DomainBase.class, (String) repoId)))
.collect(toImmutableSet()); .collect(toImmutableSet());
return domainBaseKeySet; return domainKeySet;
}); });
} }
} }

View file

@ -26,7 +26,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.DomainBase; import google.registry.model.domain.Domain;
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;
@ -101,7 +101,7 @@ public final class ResourceTransferUtils {
} }
private static void assertIsContactOrDomain(EppResource eppResource) { private static void assertIsContactOrDomain(EppResource eppResource) {
checkState(eppResource instanceof ContactResource || eppResource instanceof DomainBase); checkState(eppResource instanceof ContactResource || eppResource instanceof Domain);
} }
/** Update the relevant {@link ForeignKeyIndex} to cache the new deletion time. */ /** Update the relevant {@link ForeignKeyIndex} to cache the new deletion time. */

View file

@ -19,7 +19,7 @@ import static com.google.common.collect.ImmutableSet.toImmutableSet;
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 com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainContent; import google.registry.model.domain.DomainContent;
import google.registry.model.domain.DomainHistory; import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.GracePeriod; import google.registry.model.domain.GracePeriod;
@ -33,14 +33,14 @@ import google.registry.persistence.transaction.JpaTransactionManager;
/** /**
* Utilities for managing an alternative JPA entity model optimized for bulk loading multi-level * Utilities for managing an alternative JPA entity model optimized for bulk loading multi-level
* entities such as {@link DomainBase} and {@link DomainHistory}. * entities such as {@link Domain} and {@link DomainHistory}.
* *
* <p>In a bulk query for a multi-level JPA entity type, the JPA framework only generates a bulk * <p>In a bulk query for a multi-level JPA entity type, the JPA framework only generates a bulk
* query (SELECT * FROM table) for the base table. Then, for each row in the base table, additional * query (SELECT * FROM table) for the base table. Then, for each row in the base table, additional
* queries are issued to load associated rows in child tables. This can be very slow when an entity * queries are issued to load associated rows in child tables. This can be very slow when an entity
* type has multiple child tables. * type has multiple child tables.
* *
* <p>We have defined an alternative entity model for {@code DomainBase} and {@code DomainHistory}, * <p>We have defined an alternative entity model for {@link Domain} and {@link DomainHistory},
* where the base table as well as the child tables are mapped to single-level entity types. The * where the base table as well as the child tables are mapped to single-level entity types. The
* idea is to load each of these types using a bulk query, and assemble them into the target type in * idea is to load each of these types using a bulk query, and assemble them into the target type in
* memory in a pipeline. The main use case is Datastore-Cloud SQL validation during the Registry * memory in a pipeline. The main use case is Datastore-Cloud SQL validation during the Registry
@ -53,8 +53,8 @@ public class BulkQueryEntities {
*/ */
public static final ImmutableMap<String, String> JPA_ENTITIES_REPLACEMENTS = public static final ImmutableMap<String, String> JPA_ENTITIES_REPLACEMENTS =
ImmutableMap.of( ImmutableMap.of(
DomainBase.class.getCanonicalName(), Domain.class.getCanonicalName(),
DomainBaseLite.class.getCanonicalName(), DomainLite.class.getCanonicalName(),
DomainHistory.class.getCanonicalName(), DomainHistory.class.getCanonicalName(),
DomainHistoryLite.class.getCanonicalName()); DomainHistoryLite.class.getCanonicalName());
@ -64,18 +64,18 @@ public class BulkQueryEntities {
ImmutableList.of( ImmutableList.of(
DomainHost.class.getCanonicalName(), DomainHistoryHost.class.getCanonicalName()); DomainHost.class.getCanonicalName(), DomainHistoryHost.class.getCanonicalName());
public static DomainBase assembleDomainBase( public static Domain assembleDomain(
DomainBaseLite domainBaseLite, DomainLite domainLite,
ImmutableSet<GracePeriod> gracePeriods, ImmutableSet<GracePeriod> gracePeriods,
ImmutableSet<DelegationSignerData> delegationSignerData, ImmutableSet<DelegationSignerData> delegationSignerData,
ImmutableSet<VKey<HostResource>> nsHosts) { ImmutableSet<VKey<HostResource>> nsHosts) {
DomainBase.Builder builder = new DomainBase.Builder(); Domain.Builder builder = new Domain.Builder();
builder.copyFrom(domainBaseLite); builder.copyFrom(domainLite);
builder.setGracePeriods(gracePeriods); builder.setGracePeriods(gracePeriods);
builder.setDsData(delegationSignerData); builder.setDsData(delegationSignerData);
builder.setNameservers(nsHosts); builder.setNameservers(nsHosts);
// Restore the original update timestamp (this gets cleared when we set nameservers or DS data). // Restore the original update timestamp (this gets cleared when we set nameservers or DS data).
builder.setUpdateTimestamp(domainBaseLite.getUpdateTimestamp()); builder.setUpdateTimestamp(domainLite.getUpdateTimestamp());
return builder.build(); return builder.build();
} }

View file

@ -15,7 +15,7 @@
package google.registry.model.bulkquery; package google.registry.model.bulkquery;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainContent; import google.registry.model.domain.DomainContent;
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;
@ -49,7 +49,7 @@ import javax.persistence.PostLoad;
@IdClass(DomainHistoryId.class) @IdClass(DomainHistoryId.class)
public class DomainHistoryLite extends HistoryEntry { public class DomainHistoryLite extends HistoryEntry {
// Store DomainContent instead of DomainBase so we don't pick up its @Id // Store DomainContent 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 DomainContent domainContent;
@ -64,7 +64,7 @@ public class DomainHistoryLite extends HistoryEntry {
/** This method is private because it is only used by Hibernate. */ /** This method is private because it is only used by Hibernate. */
@SuppressWarnings("unused") @SuppressWarnings("unused")
private void setDomainRepoId(String domainRepoId) { private void setDomainRepoId(String domainRepoId) {
parent = Key.create(DomainBase.class, domainRepoId); parent = Key.create(Domain.class, domainRepoId);
} }
@Override @Override
@ -101,9 +101,9 @@ public class DomainHistoryLite extends HistoryEntry {
return super.getId(); return super.getId();
} }
/** The key to the {@link DomainBase} this is based off of. */ /** The key to the {@link Domain} this is based off of. */
public VKey<DomainBase> getParentVKey() { public VKey<Domain> getParentVKey() {
return VKey.create(DomainBase.class, getDomainRepoId()); return VKey.create(Domain.class, getDomainRepoId());
} }
public DomainHistoryId getDomainHistoryId() { public DomainHistoryId getDomainHistoryId() {

View file

@ -14,7 +14,7 @@
package google.registry.model.bulkquery; package google.registry.model.bulkquery;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainContent; import google.registry.model.domain.DomainContent;
import google.registry.persistence.VKey; import google.registry.persistence.VKey;
import google.registry.persistence.WithStringVKey; import google.registry.persistence.WithStringVKey;
@ -23,17 +23,17 @@ import javax.persistence.AccessType;
import javax.persistence.Entity; import javax.persistence.Entity;
/** /**
* A 'light' version of {@link DomainBase} with only base table ("Domain") attributes, which allows * A 'light' version of {@link Domain} with only base table ("Domain") attributes, which allows fast
* fast bulk loading. They are used in in-memory assembly of {@code DomainBase} instances along with * bulk loading. They are used in in-memory assembly of {@code Domain} instances along with
* bulk-loaded child entities ({@code GracePeriod} etc). The in-memory assembly achieves much higher * bulk-loaded child entities ({@code GracePeriod} etc). The in-memory assembly achieves much higher
* performance than loading {@code DomainBase} directly. * performance than loading {@code Domain} directly.
* *
* <p>Please refer to {@link BulkQueryEntities} for more information. * <p>Please refer to {@link BulkQueryEntities} for more information.
*/ */
@Entity(name = "Domain") @Entity(name = "Domain")
@WithStringVKey @WithStringVKey
@Access(AccessType.FIELD) @Access(AccessType.FIELD)
public class DomainBaseLite extends DomainContent { public class DomainLite extends DomainContent {
@Override @Override
@javax.persistence.Id @javax.persistence.Id
@ -42,7 +42,7 @@ public class DomainBaseLite extends DomainContent {
return super.getRepoId(); return super.getRepoId();
} }
public static VKey<DomainBaseLite> createVKey(String repoId) { public static VKey<DomainLite> createVKey(String repoId) {
return VKey.createSql(DomainBaseLite.class, repoId); return VKey.createSql(DomainLite.class, repoId);
} }
} }

View file

@ -43,15 +43,11 @@ import org.joda.time.DateTime;
/** /**
* A persistable domain resource including mutable and non-mutable fields. * 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> * @see <a href="https://tools.ietf.org/html/rfc5731">RFC 5731</a>
*/ */
@ReportedOn @ReportedOn
@com.googlecode.objectify.annotation.Entity @com.googlecode.objectify.annotation.Entity
@Entity(name = "Domain") @Entity
@Table( @Table(
name = "Domain", name = "Domain",
indexes = { indexes = {
@ -73,7 +69,7 @@ import org.joda.time.DateTime;
@WithStringVKey @WithStringVKey
@ExternalMessagingName("domain") @ExternalMessagingName("domain")
@Access(AccessType.FIELD) @Access(AccessType.FIELD)
public class DomainBase extends DomainContent implements ForeignKeyedEppResource { public class Domain extends DomainContent implements ForeignKeyedEppResource {
@Override @Override
@javax.persistence.Id @javax.persistence.Id
@ -157,17 +153,17 @@ public class DomainBase extends DomainContent implements ForeignKeyedEppResource
} }
@Override @Override
public VKey<DomainBase> createVKey() { public VKey<Domain> createVKey() {
return VKey.create(DomainBase.class, getRepoId(), Key.create(this)); return VKey.create(Domain.class, getRepoId(), Key.create(this));
} }
@Override @Override
public DomainBase cloneProjectedAtTime(final DateTime now) { public Domain cloneProjectedAtTime(final DateTime now) {
return cloneDomainProjectedAtTime(this, now); return cloneDomainProjectedAtTime(this, now);
} }
public static VKey<DomainBase> createVKey(Key<DomainBase> key) { public static VKey<Domain> createVKey(Key<Domain> key) {
return VKey.create(DomainBase.class, key.getName(), key); return VKey.create(Domain.class, key.getName(), key);
} }
/** An override of {@link EppResource#asBuilder} with tighter typing. */ /** An override of {@link EppResource#asBuilder} with tighter typing. */
@ -176,12 +172,12 @@ public class DomainBase extends DomainContent implements ForeignKeyedEppResource
return new Builder(clone(this)); return new Builder(clone(this));
} }
/** A builder for constructing {@link DomainBase}, since it is immutable. */ /** A builder for constructing {@link Domain}, since it is immutable. */
public static class Builder extends DomainContent.Builder<DomainBase, Builder> { public static class Builder extends DomainContent.Builder<Domain, Builder> {
public Builder() {} public Builder() {}
Builder(DomainBase instance) { Builder(Domain instance) {
super(instance); super(instance);
} }

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 DomainBase} commands. */ /** A collection of {@link Domain} 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 <a href="http://tools.ietf.org/html/rfc5731">RFC5731</a>. */ /** The fields on "chgType" from <a href="http://tools.ietf.org/html/rfc5731">RFC5731</a>. */
@XmlTransient @XmlTransient
public static class DomainCreateOrChange<B extends DomainBase.Builder> extends ImmutableObject public static class DomainCreateOrChange<B extends Domain.Builder> extends ImmutableObject
implements ResourceCreateOrChange<B> { implements ResourceCreateOrChange<B> {
/** The contactId of the registrant who registered this domain. */ /** The contactId of the registrant who registered this domain. */
@ -100,7 +100,7 @@ public class DomainCommand {
} }
/** /**
* A create command for a {@link DomainBase}, mapping "createType" from <a * A create command for a {@link Domain}, mapping "createType" from <a
* href="http://tools.ietf.org/html/rfc5731">RFC5731</a>. * href="http://tools.ietf.org/html/rfc5731">RFC5731</a>.
*/ */
@XmlRootElement @XmlRootElement
@ -113,7 +113,7 @@ public class DomainCommand {
"foreignKeyedDesignatedContacts", "foreignKeyedDesignatedContacts",
"authInfo" "authInfo"
}) })
public static class Create extends DomainCreateOrChange<DomainBase.Builder> public static class Create extends DomainCreateOrChange<Domain.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. */
@ -196,11 +196,11 @@ public class DomainCommand {
} }
} }
/** A delete command for a {@link DomainBase}. */ /** A delete command for a {@link Domain}. */
@XmlRootElement @XmlRootElement
public static class Delete extends AbstractSingleResourceCommand {} public static class Delete extends AbstractSingleResourceCommand {}
/** An info request for a {@link DomainBase}. */ /** An info request for a {@link Domain}. */
@XmlRootElement @XmlRootElement
public static class Info extends ImmutableObject implements SingleResourceCommand { public static class Info extends ImmutableObject implements SingleResourceCommand {
@ -259,11 +259,11 @@ public class DomainCommand {
} }
} }
/** A check request for {@link DomainBase}. */ /** A check request for {@link Domain}. */
@XmlRootElement @XmlRootElement
public static class Check extends ResourceCheck {} public static class Check extends ResourceCheck {}
/** A renew command for a {@link DomainBase}. */ /** A renew command for a {@link Domain}. */
@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 DomainBase}. */ /** A transfer operation for a {@link Domain}. */
@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. */
@ -300,11 +300,10 @@ public class DomainCommand {
} }
} }
/** An update to a {@link DomainBase}. */ /** An update to a {@link Domain}. */
@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, Domain.Builder, Update.Change>
extends ResourceUpdate<Update.AddRemove, DomainBase.Builder, Update.Change>
implements CreateOrUpdate<Update> { implements CreateOrUpdate<Update> {
@XmlElement(name = "chg") @XmlElement(name = "chg")
@ -383,7 +382,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<Domain.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

@ -91,11 +91,6 @@ import org.joda.time.Interval;
* foreign-keyed fields can refer to the proper parent entity's ID, whether we're storing this in * foreign-keyed fields can refer to the proper parent entity's ID, whether we're storing this in
* the DB itself or as part of another entity. * the DB itself or as part of another entity.
* *
* <p>For historical reasons, the name of this class is "DomainContent". Ideally it would be
* "DomainBase" for parallelism with the other {@link EppResource} entity classes, but because that
* name is already taken by {@link DomainBase} (also for historical reasons), we can't use it. Once
* we are no longer on Datastore, we can rename the classes.
*
* @see <a href="https://tools.ietf.org/html/rfc5731">RFC 5731</a> * @see <a href="https://tools.ietf.org/html/rfc5731">RFC 5731</a>
*/ */
@MappedSuperclass @MappedSuperclass
@ -294,7 +289,7 @@ public class DomainContent extends EppResource
return Optional.ofNullable(dnsRefreshRequestTime); return Optional.ofNullable(dnsRefreshRequestTime);
} }
public static <T> VKey<T> restoreOfyFrom(Key<DomainBase> domainKey, VKey<T> key, Long historyId) { public static <T> VKey<T> restoreOfyFrom(Key<Domain> domainKey, VKey<T> key, Long historyId) {
if (historyId == null) { if (historyId == null) {
// This is a legacy key (or a null key, in which case this works too) // This is a legacy key (or a null key, in which case this works too)
return VKey.restoreOfyFrom(key, EntityGroupRoot.class, "per-tld"); return VKey.restoreOfyFrom(key, EntityGroupRoot.class, "per-tld");
@ -707,10 +702,10 @@ public class DomainContent extends EppResource
} }
@Override @Override
public VKey<DomainBase> createVKey() { public VKey<Domain> createVKey() {
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
"DomainContent is not an actual persisted entity you can create a key to;" "DomainContent is not an actual persisted entity you can create a key to;"
+ " use DomainBase 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. */
@ -723,7 +718,7 @@ public class DomainContent extends EppResource
return new Builder<>(clone(this)); return new Builder<>(clone(this));
} }
/** A builder for constructing {@link DomainBase}, 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 DomainContent, B extends Builder<T, B>>
extends EppResource.Builder<T, B> implements BuilderWithTransferData<DomainTransferData, B> { extends EppResource.Builder<T, B> implements BuilderWithTransferData<DomainTransferData, B> {
@ -740,7 +735,7 @@ public class DomainContent extends EppResource
if (DomainTransferData.EMPTY.equals(getInstance().transferData)) { if (DomainTransferData.EMPTY.equals(getInstance().transferData)) {
setTransferData(null); setTransferData(null);
} }
// A DomainBase has status INACTIVE if there are no nameservers. // A Domain has status INACTIVE if there are no nameservers.
if (getInstance().getNameservers().isEmpty()) { if (getInstance().getNameservers().isEmpty()) {
addStatusValue(StatusValue.INACTIVE); addStatusValue(StatusValue.INACTIVE);
} else { // There are nameservers, so make sure INACTIVE isn't there. } else { // There are nameservers, so make sure INACTIVE isn't there.

View file

@ -80,7 +80,7 @@ import org.hibernate.Hibernate;
@IdClass(DomainHistoryId.class) @IdClass(DomainHistoryId.class)
public class DomainHistory extends HistoryEntry { public class DomainHistory extends HistoryEntry {
// Store DomainContent instead of DomainBase so we don't pick up its @Id // Store DomainContent 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 DomainContent domainContent;
@ -95,7 +95,7 @@ public class DomainHistory extends HistoryEntry {
/** This method is private because it is only used by Hibernate. */ /** This method is private because it is only used by Hibernate. */
@SuppressWarnings("unused") @SuppressWarnings("unused")
private void setDomainRepoId(String domainRepoId) { private void setDomainRepoId(String domainRepoId) {
parent = Key.create(DomainBase.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 domainContent.nsHosts here, but Hibernate throws a weird exception after
@ -241,9 +241,9 @@ public class DomainHistory extends HistoryEntry {
return Optional.ofNullable(domainContent); return Optional.ofNullable(domainContent);
} }
/** The key to the {@link DomainBase} this is based off of. */ /** The key to the {@link Domain} this is based off of. */
public VKey<DomainBase> getParentVKey() { public VKey<Domain> getParentVKey() {
return VKey.create(DomainBase.class, getDomainRepoId()); return VKey.create(Domain.class, getDomainRepoId());
} }
public Set<GracePeriodHistory> getGracePeriodHistories() { public Set<GracePeriodHistory> getGracePeriodHistories() {
@ -260,7 +260,7 @@ public class DomainHistory extends HistoryEntry {
@Override @Override
public Optional<? extends EppResource> getResourceAtPointInTime() { public Optional<? extends EppResource> getResourceAtPointInTime() {
return getDomainContent() return getDomainContent()
.map(domainContent -> new DomainBase.Builder().copyFrom(domainContent).build()); .map(domainContent -> new Domain.Builder().copyFrom(domainContent).build());
} }
@PostLoad @PostLoad
@ -377,20 +377,20 @@ public class DomainHistory extends HistoryEntry {
if (domainContent == null) { if (domainContent == null) {
return this; return this;
} }
// TODO(b/203609982): if actual type of domainContent is DomainBase, convert to DomainContent // TODO(b/203609982): if actual type of domainContent is Domain, convert to DomainContent
// Note: a DomainHistory fetched by JPA has DomainContent in this field. Allowing DomainBase // Note: a DomainHistory fetched by JPA has DomainContent in this field. Allowing Domain
// in the setter makes equality checks messy. // in the setter makes equality checks messy.
getInstance().domainContent = domainContent; getInstance().domainContent = domainContent;
if (domainContent instanceof DomainBase) { if (domainContent instanceof Domain) {
super.setParent(domainContent); super.setParent(domainContent);
} else { } else {
super.setParent(Key.create(DomainBase.class, domainContent.getRepoId())); super.setParent(Key.create(Domain.class, domainContent.getRepoId()));
} }
return this; return this;
} }
public Builder setDomainRepoId(String domainRepoId) { public Builder setDomainRepoId(String domainRepoId) {
getInstance().parent = Key.create(DomainBase.class, domainRepoId); getInstance().parent = Key.create(Domain.class, domainRepoId);
return this; return this;
} }

View file

@ -37,8 +37,8 @@ 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 DomainBase} the next time * <p>When a grace period expires, it is lazily removed from the {@link Domain} the next time the
* the resource is loaded from Datastore. * resource is loaded from Datastore.
*/ */
@Embed @Embed
@Entity @Entity

View file

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

View file

@ -26,7 +26,7 @@ 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.domain.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.transfer.TransferData; import google.registry.model.transfer.TransferData;
import google.registry.persistence.VKey; import google.registry.persistence.VKey;
import java.net.InetAddress; import java.net.InetAddress;
@ -76,7 +76,7 @@ public class HostBase extends EppResource {
@Index @Index
@IgnoreSave(IfNull.class) @IgnoreSave(IfNull.class)
@DoNotHydrate @DoNotHydrate
VKey<DomainBase> superordinateDomain; VKey<Domain> superordinateDomain;
/** /**
* The time that this resource was last transferred. * The time that this resource was last transferred.
@ -98,7 +98,7 @@ public class HostBase extends EppResource {
return fullyQualifiedHostName; return fullyQualifiedHostName;
} }
public VKey<DomainBase> getSuperordinateDomain() { public VKey<Domain> getSuperordinateDomain() {
return superordinateDomain; return superordinateDomain;
} }
@ -155,7 +155,7 @@ public class HostBase extends EppResource {
* {@link #superordinateDomain} field. Passing it as a parameter allows the caller to control * {@link #superordinateDomain} field. Passing it as a parameter allows the caller to control
* the degree of consistency used to load it. * the degree of consistency used to load it.
*/ */
public DateTime computeLastTransferTime(@Nullable DomainBase superordinateDomain) { public DateTime computeLastTransferTime(@Nullable Domain superordinateDomain) {
if (!isSubordinate()) { if (!isSubordinate()) {
checkArgument(superordinateDomain == null); checkArgument(superordinateDomain == null);
return getLastTransferTime(); return getLastTransferTime();
@ -222,7 +222,7 @@ public class HostBase extends EppResource {
ImmutableSet.copyOf(difference(getInstance().getInetAddresses(), inetAddresses))); ImmutableSet.copyOf(difference(getInstance().getInetAddresses(), inetAddresses)));
} }
public B setSuperordinateDomain(VKey<DomainBase> superordinateDomain) { public B setSuperordinateDomain(VKey<Domain> superordinateDomain) {
getInstance().superordinateDomain = superordinateDomain; getInstance().superordinateDomain = superordinateDomain;
return thisCastToDerived(); return thisCastToDerived();
} }

View file

@ -48,7 +48,7 @@ import google.registry.model.EppResource;
import google.registry.model.annotations.DeleteAfterMigration; import google.registry.model.annotations.DeleteAfterMigration;
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.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.host.HostResource; import google.registry.model.host.HostResource;
import google.registry.persistence.VKey; import google.registry.persistence.VKey;
import google.registry.persistence.transaction.CriteriaQueryBuilder; import google.registry.persistence.transaction.CriteriaQueryBuilder;
@ -75,10 +75,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 DomainBase} entities. */ /** The {@link ForeignKeyIndex} type for {@link Domain} entities. */
@ReportedOn @ReportedOn
@Entity @Entity
public static class ForeignKeyDomainIndex extends ForeignKeyIndex<DomainBase> {} public static class ForeignKeyDomainIndex extends ForeignKeyIndex<Domain> {}
/** The {@link ForeignKeyIndex} type for {@link HostResource} entities. */ /** The {@link ForeignKeyIndex} type for {@link HostResource} entities. */
@ReportedOn @ReportedOn
@ -90,14 +90,14 @@ public abstract class ForeignKeyIndex<E extends EppResource> extends BackupGroup
RESOURCE_CLASS_TO_FKI_CLASS = RESOURCE_CLASS_TO_FKI_CLASS =
ImmutableBiMap.of( ImmutableBiMap.of(
ContactResource.class, ForeignKeyContactIndex.class, ContactResource.class, ForeignKeyContactIndex.class,
DomainBase.class, ForeignKeyDomainIndex.class, Domain.class, ForeignKeyDomainIndex.class,
HostResource.class, ForeignKeyHostIndex.class); HostResource.class, ForeignKeyHostIndex.class);
private static final ImmutableMap<Class<? extends EppResource>, String> private static final ImmutableMap<Class<? extends EppResource>, String>
RESOURCE_CLASS_TO_FKI_PROPERTY = RESOURCE_CLASS_TO_FKI_PROPERTY =
ImmutableMap.of( ImmutableMap.of(
ContactResource.class, "contactId", ContactResource.class, "contactId",
DomainBase.class, "fullyQualifiedDomainName", Domain.class, "fullyQualifiedDomainName",
HostResource.class, "fullyQualifiedHostName"); HostResource.class, "fullyQualifiedHostName");
@Id String foreignKey; @Id String foreignKey;

View file

@ -33,7 +33,7 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
* via Objectify. * via Objectify.
* *
* <p>All first class entities are represented as a resource class - {@link * <p>All first class entities are represented as a resource class - {@link
* google.registry.model.domain.DomainBase}, {@link google.registry.model.host.HostResource}, {@link * google.registry.model.domain.Domain}, {@link google.registry.model.host.HostResource}, {@link
* google.registry.model.contact.ContactResource}, and {@link * google.registry.model.contact.ContactResource}, and {@link
* google.registry.model.registrar.Registrar}. Resource objects are written in a single shared * google.registry.model.registrar.Registrar}. Resource objects are written in a single shared
* entity group per TLD. All commands that operate on those entities are grouped in a "Command" * entity group per TLD. All commands that operate on those entities are grouped in a "Command"

View file

@ -35,7 +35,7 @@ import google.registry.model.annotations.ReportedOn;
import google.registry.model.contact.ContactHistory; 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.DomainBase; import google.registry.model.domain.Domain;
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.DomainRenewData; import google.registry.model.domain.DomainRenewData;
@ -103,7 +103,7 @@ public abstract class PollMessage extends ImmutableObject
/** Indicates the type of entity the poll message is for. */ /** Indicates the type of entity the poll message is for. */
public enum Type { public enum Type {
DOMAIN(1L, DomainBase.class), DOMAIN(1L, Domain.class),
CONTACT(2L, ContactResource.class), CONTACT(2L, ContactResource.class),
HOST(3L, HostResource.class); HOST(3L, HostResource.class);

View file

@ -38,7 +38,7 @@ import google.registry.model.contact.ContactBase;
import google.registry.model.contact.ContactHistory; 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.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainContent; import google.registry.model.domain.DomainContent;
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;
@ -386,7 +386,7 @@ public class HistoryEntry extends ImmutableObject implements Buildable, UnsafeSe
String parentKind = getParent().getKind(); String parentKind = getParent().getKind();
final HistoryEntry resultEntity; final HistoryEntry resultEntity;
// can't use a switch statement since we're calling getKind() // can't use a switch statement since we're calling getKind()
if (parentKind.equals(getKind(DomainBase.class))) { if (parentKind.equals(getKind(Domain.class))) {
resultEntity = resultEntity =
new DomainHistory.Builder().copyFrom(this).setDomainRepoId(parent.getName()).build(); new DomainHistory.Builder().copyFrom(this).setDomainRepoId(parent.getName()).build();
} else if (parentKind.equals(getKind(HostResource.class))) { } else if (parentKind.equals(getKind(HostResource.class))) {
@ -408,7 +408,7 @@ public class HistoryEntry extends ImmutableObject implements Buildable, UnsafeSe
long id = key.getId(); long id = key.getId();
Key<EppResource> parent = key.getParent(); Key<EppResource> parent = key.getParent();
String parentKind = parent.getKind(); String parentKind = parent.getKind();
if (parentKind.equals(getKind(DomainBase.class))) { if (parentKind.equals(getKind(Domain.class))) {
return VKey.create( return VKey.create(
DomainHistory.class, DomainHistory.class,
new DomainHistoryId(repoId, id), new DomainHistoryId(repoId, id),

View file

@ -27,7 +27,7 @@ import com.google.common.collect.Streams;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.model.contact.ContactHistory; import google.registry.model.contact.ContactHistory;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory; import google.registry.model.domain.DomainHistory;
import google.registry.model.host.HostHistory; import google.registry.model.host.HostHistory;
import google.registry.model.host.HostResource; import google.registry.model.host.HostResource;
@ -53,7 +53,7 @@ public class HistoryEntryDao {
ImmutableMap.of( ImmutableMap.of(
ContactResource.class, ContactResource.class,
ContactHistory.class, ContactHistory.class,
DomainBase.class, Domain.class,
DomainHistory.class, DomainHistory.class,
HostResource.class, HostResource.class,
HostHistory.class); HostHistory.class);

View file

@ -17,16 +17,16 @@ package google.registry.persistence;
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull; import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.Domain;
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.reporting.HistoryEntry; import google.registry.model.reporting.HistoryEntry;
import java.io.Serializable; import java.io.Serializable;
import javax.persistence.Embeddable; import javax.persistence.Embeddable;
/** {@link VKey} for {@link HistoryEntry} which parent is {@link DomainBase}. */ /** {@link VKey} for {@link HistoryEntry} which parent is {@link Domain}. */
@Embeddable @Embeddable
public class DomainHistoryVKey extends EppHistoryVKey<HistoryEntry, DomainBase> { public class DomainHistoryVKey extends EppHistoryVKey<HistoryEntry, Domain> {
// Hibernate requires a default constructor // Hibernate requires a default constructor
private DomainHistoryVKey() {} private DomainHistoryVKey() {}
@ -52,6 +52,6 @@ public class DomainHistoryVKey extends EppHistoryVKey<HistoryEntry, DomainBase>
return VKey.create( return VKey.create(
DomainHistory.class, DomainHistory.class,
createSqlKey(), createSqlKey(),
Key.create(Key.create(DomainBase.class, repoId), DomainHistory.class, historyRevisionId)); Key.create(Key.create(Domain.class, repoId), DomainHistory.class, historyRevisionId));
} }
} }

View file

@ -78,7 +78,7 @@ public abstract class EppHistoryVKey<K, E extends EppResource> extends Immutable
* Creates the kind path for the given ofyKey}. * Creates the kind path for the given ofyKey}.
* *
* <p>The kind path is a string including all kind names(delimited by slash) of a hierarchical * <p>The kind path is a string including all kind names(delimited by slash) of a hierarchical
* {@link Key}, e.g., the kind path for BillingEvent.OneTime is "DomainBase/HistoryEntry/OneTime". * {@link Key}, e.g., the kind path for BillingEvent.OneTime is "Domain/HistoryEntry/OneTime".
*/ */
@Nullable @Nullable
public static String createKindPath(@Nullable Key<?> ofyKey) { public static String createKindPath(@Nullable Key<?> ofyKey) {

View file

@ -177,10 +177,10 @@ public class VKey<T> extends ImmutableObject implements Serializable {
* kind of the ancestor key and the value is either a String or a Long. * kind of the ancestor key and the value is either a String or a Long.
* *
* <p>For example, to restore the objectify key for * <p>For example, to restore the objectify key for
* DomainBase("COM-1234")/HistoryEntry(123)/PollEvent(567), one might use: * Domain("COM-1234")/HistoryEntry(123)/PollEvent(567), one might use:
* *
* <pre>{@code * <pre>{@code
* pollEvent.restoreOfy(DomainBase.class, "COM-1234", HistoryEntry.class, 567) * pollEvent.restoreOfy(Domain.class, "COM-1234", HistoryEntry.class, 567)
* }</pre> * }</pre>
* *
* <p>The final key id or name is obtained from the SQL key. It is assumed that this value must be * <p>The final key id or name is obtained from the SQL key. It is assumed that this value must be

View file

@ -21,7 +21,7 @@ import static google.registry.request.Action.Method.HEAD;
import static google.registry.util.DateTimeUtils.START_OF_TIME; import static google.registry.util.DateTimeUtils.START_OF_TIME;
import google.registry.flows.EppException; import google.registry.flows.EppException;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.Domain;
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.rdap.RdapObjectClasses.RdapDomain; import google.registry.rdap.RdapObjectClasses.RdapDomain;
@ -59,12 +59,12 @@ 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<DomainBase> domainBase = Optional<Domain> domain =
loadByForeignKey( loadByForeignKey(
DomainBase.class, Domain.class,
pathSearchString, pathSearchString,
shouldIncludeDeleted() ? START_OF_TIME : rdapJsonFormatter.getRequestTime()); shouldIncludeDeleted() ? START_OF_TIME : rdapJsonFormatter.getRequestTime());
if (!domainBase.isPresent() || !isAuthorized(domainBase.get())) { if (!domain.isPresent() || !isAuthorized(domain.get())) {
// RFC7480 5.3 - if the server wishes to respond that it doesn't have data satisfying the // RFC7480 5.3 - if the server wishes to respond that it doesn't have data satisfying the
// query, it MUST reply with 404 response code. // query, it MUST reply with 404 response code.
// //
@ -72,6 +72,6 @@ public class RdapDomainAction extends RdapActionBase {
// exists but we don't want to show it to you", because we DON'T wish to say that. // exists but we don't want to show it to you", because we DON'T wish to say that.
throw new NotFoundException(pathSearchString + " not found"); throw new NotFoundException(pathSearchString + " not found");
} }
return rdapJsonFormatter.createRdapDomain(domainBase.get(), OutputDataType.FULL); return rdapJsonFormatter.createRdapDomain(domain.get(), OutputDataType.FULL);
} }
} }

View file

@ -36,7 +36,7 @@ import com.google.common.flogger.FluentLogger;
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.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.host.HostResource; import google.registry.model.host.HostResource;
import google.registry.persistence.VKey; import google.registry.persistence.VKey;
import google.registry.persistence.transaction.CriteriaQueryBuilder; import google.registry.persistence.transaction.CriteriaQueryBuilder;
@ -187,10 +187,10 @@ public class RdapDomainSearchAction extends RdapSearchActionBase {
/** Searches for domains by domain name without a wildcard or interest in deleted entries. */ /** Searches for domains by domain name without a wildcard or interest in deleted entries. */
private DomainSearchResponse searchByDomainNameWithoutWildcard( private DomainSearchResponse searchByDomainNameWithoutWildcard(
final RdapSearchPattern partialStringQuery) { final RdapSearchPattern partialStringQuery) {
Optional<DomainBase> domainBase = Optional<Domain> domain =
loadByForeignKey(DomainBase.class, partialStringQuery.getInitialString(), getRequestTime()); loadByForeignKey(Domain.class, partialStringQuery.getInitialString(), getRequestTime());
return makeSearchResults( return makeSearchResults(
shouldBeVisible(domainBase) ? ImmutableList.of(domainBase.get()) : ImmutableList.of()); shouldBeVisible(domain) ? ImmutableList.of(domain.get()) : ImmutableList.of());
} }
/** Searches for domains by domain name with an initial string, wildcard and possible suffix. */ /** Searches for domains by domain name with an initial string, wildcard and possible suffix. */
@ -206,12 +206,12 @@ 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;
RdapResultSet<DomainBase> resultSet; RdapResultSet<Domain> resultSet;
if (tm().isOfy()) { if (tm().isOfy()) {
Query<DomainBase> query = Query<Domain> query =
auditedOfy() auditedOfy()
.load() .load()
.type(DomainBase.class) .type(Domain.class)
.filter("fullyQualifiedDomainName <", partialStringQuery.getNextInitialString()) .filter("fullyQualifiedDomainName <", partialStringQuery.getNextInitialString())
.filter("fullyQualifiedDomainName >=", partialStringQuery.getInitialString()); .filter("fullyQualifiedDomainName >=", partialStringQuery.getInitialString());
if (cursorString.isPresent()) { if (cursorString.isPresent()) {
@ -230,8 +230,8 @@ public class RdapDomainSearchAction extends RdapSearchActionBase {
() -> { () -> {
CriteriaBuilder criteriaBuilder = CriteriaBuilder criteriaBuilder =
replicaJpaTm().getEntityManager().getCriteriaBuilder(); replicaJpaTm().getEntityManager().getCriteriaBuilder();
CriteriaQueryBuilder<DomainBase> queryBuilder = CriteriaQueryBuilder<Domain> queryBuilder =
CriteriaQueryBuilder.create(replicaJpaTm(), DomainBase.class) CriteriaQueryBuilder.create(replicaJpaTm(), Domain.class)
.where( .where(
"fullyQualifiedDomainName", "fullyQualifiedDomainName",
criteriaBuilder::like, criteriaBuilder::like,
@ -262,9 +262,9 @@ 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;
RdapResultSet<DomainBase> resultSet; RdapResultSet<Domain> resultSet;
if (tm().isOfy()) { if (tm().isOfy()) {
Query<DomainBase> query = auditedOfy().load().type(DomainBase.class).filter("tld", tld); Query<Domain> query = auditedOfy().load().type(Domain.class).filter("tld", tld);
if (cursorString.isPresent()) { if (cursorString.isPresent()) {
query = query.filter("fullyQualifiedDomainName >", cursorString.get()); query = query.filter("fullyQualifiedDomainName >", cursorString.get());
} }
@ -275,9 +275,9 @@ public class RdapDomainSearchAction extends RdapSearchActionBase {
replicaJpaTm() replicaJpaTm()
.transact( .transact(
() -> { () -> {
CriteriaQueryBuilder<DomainBase> builder = CriteriaQueryBuilder<Domain> builder =
queryItemsSql( queryItemsSql(
DomainBase.class, Domain.class,
"tld", "tld",
tld, tld,
Optional.of("fullyQualifiedDomainName"), Optional.of("fullyQualifiedDomainName"),
@ -414,9 +414,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.
DomainBase domainBase = Domain domain =
loadByForeignKey( loadByForeignKey(
DomainBase.class, Domain.class,
partialStringQuery.getSuffix(), partialStringQuery.getSuffix(),
shouldIncludeDeleted() ? START_OF_TIME : getRequestTime()) shouldIncludeDeleted() ? START_OF_TIME : getRequestTime())
.orElseThrow( .orElseThrow(
@ -426,7 +426,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<VKey<HostResource>> builder = new ImmutableList.Builder<>(); ImmutableList.Builder<VKey<HostResource>> builder = new ImmutableList.Builder<>();
for (String fqhn : ImmutableSortedSet.copyOf(domainBase.getSubordinateHosts())) { for (String fqhn : ImmutableSortedSet.copyOf(domain.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)) {
@ -542,19 +542,19 @@ 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 DomainBase} objects. Use a sorted set, // domain), we must create a set of resulting {@link Domain} 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<DomainBase> domainSetBuilder = ImmutableSortedSet.Builder<Domain> domainSetBuilder =
ImmutableSortedSet.orderedBy(Comparator.comparing(DomainBase::getDomainName)); ImmutableSortedSet.orderedBy(Comparator.comparing(Domain::getDomainName));
int numHostKeysSearched = 0; int numHostKeysSearched = 0;
for (List<VKey<HostResource>> chunk : Iterables.partition(hostKeys, 30)) { for (List<VKey<HostResource>> chunk : Iterables.partition(hostKeys, 30)) {
numHostKeysSearched += chunk.size(); numHostKeysSearched += chunk.size();
if (tm().isOfy()) { if (tm().isOfy()) {
Query<DomainBase> query = Query<Domain> query =
auditedOfy() auditedOfy()
.load() .load()
.type(DomainBase.class) .type(Domain.class)
.filter( .filter(
"nsHosts in", chunk.stream().map(VKey::getOfyKey).collect(toImmutableSet())); "nsHosts in", chunk.stream().map(VKey::getOfyKey).collect(toImmutableSet()));
if (!shouldIncludeDeleted()) { if (!shouldIncludeDeleted()) {
@ -564,7 +564,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<DomainBase> stream = Streams.stream(query).filter(this::isAuthorized); Stream<Domain> stream = Streams.stream(query).filter(this::isAuthorized);
if (cursorString.isPresent()) { if (cursorString.isPresent()) {
stream = stream =
stream.filter(domain -> (domain.getDomainName().compareTo(cursorString.get()) > 0)); stream.filter(domain -> (domain.getDomainName().compareTo(cursorString.get()) > 0));
@ -575,8 +575,8 @@ public class RdapDomainSearchAction extends RdapSearchActionBase {
.transact( .transact(
() -> { () -> {
for (VKey<HostResource> hostKey : hostKeys) { for (VKey<HostResource> hostKey : hostKeys) {
CriteriaQueryBuilder<DomainBase> queryBuilder = CriteriaQueryBuilder<Domain> queryBuilder =
CriteriaQueryBuilder.create(replicaJpaTm(), DomainBase.class) CriteriaQueryBuilder.create(replicaJpaTm(), Domain.class)
.whereFieldContains("nsHosts", hostKey) .whereFieldContains("nsHosts", hostKey)
.orderByAsc("fullyQualifiedDomainName"); .orderByAsc("fullyQualifiedDomainName");
CriteriaBuilder criteriaBuilder = CriteriaBuilder criteriaBuilder =
@ -606,7 +606,7 @@ public class RdapDomainSearchAction extends RdapSearchActionBase {
}); });
} }
} }
List<DomainBase> domains = domainSetBuilder.build().asList(); List<Domain> domains = domainSetBuilder.build().asList();
metricInformationBuilder.setNumHostsRetrieved(numHostKeysSearched); metricInformationBuilder.setNumHostsRetrieved(numHostKeysSearched);
// If everything that we found will fit in the result, check whether there might have been // If everything that we found will fit in the result, check whether there might have been
// more results that got dropped because the first stage limit on number of nameservers. If // more results that got dropped because the first stage limit on number of nameservers. If
@ -620,13 +620,13 @@ 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 DomainSearchResponse makeSearchResults(List<DomainBase> domains) { private DomainSearchResponse makeSearchResults(List<Domain> domains) {
return makeSearchResults( return makeSearchResults(
domains, IncompletenessWarningType.COMPLETE, Optional.of((long) domains.size())); domains, IncompletenessWarningType.COMPLETE, Optional.of((long) domains.size()));
} }
/** Output JSON from data in an {@link RdapResultSet} object. */ /** Output JSON from data in an {@link RdapResultSet} object. */
private DomainSearchResponse makeSearchResults(RdapResultSet<DomainBase> resultSet) { private DomainSearchResponse makeSearchResults(RdapResultSet<Domain> resultSet) {
return makeSearchResults( return makeSearchResults(
resultSet.resources(), resultSet.resources(),
resultSet.incompletenessWarningType(), resultSet.incompletenessWarningType(),
@ -641,7 +641,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 DomainSearchResponse makeSearchResults( private DomainSearchResponse makeSearchResults(
List<DomainBase> domains, List<Domain> domains,
IncompletenessWarningType incompletenessWarningType, IncompletenessWarningType incompletenessWarningType,
Optional<Long> numDomainsRetrieved) { Optional<Long> numDomainsRetrieved) {
numDomainsRetrieved.ifPresent(metricInformationBuilder::setNumDomainsRetrieved); numDomainsRetrieved.ifPresent(metricInformationBuilder::setNumDomainsRetrieved);
@ -650,7 +650,7 @@ public class RdapDomainSearchAction extends RdapSearchActionBase {
DomainSearchResponse.Builder builder = DomainSearchResponse.Builder builder =
DomainSearchResponse.builder().setIncompletenessWarningType(incompletenessWarningType); DomainSearchResponse.builder().setIncompletenessWarningType(incompletenessWarningType);
Optional<String> newCursor = Optional.empty(); Optional<String> newCursor = Optional.empty();
for (DomainBase domain : Iterables.limit(domains, rdapResultSetMaxSize)) { for (Domain domain : Iterables.limit(domains, rdapResultSetMaxSize)) {
newCursor = Optional.of(domain.getDomainName()); newCursor = Optional.of(domain.getDomainName());
builder builder
.domainSearchResultsBuilder() .domainSearchResultsBuilder()

View file

@ -45,7 +45,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.DomainBase; import google.registry.model.domain.Domain;
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;
@ -267,7 +267,7 @@ public class RdapJsonFormatter {
} }
/** /**
* Creates a JSON object for a {@link DomainBase}. * Creates a JSON object for a {@link Domain}.
* *
* <p>NOTE that domain searches aren't in the spec yet - they're in the RFC 9082 that describes * <p>NOTE that domain searches aren't in the spec yet - they're in the RFC 9082 that describes
* the query format, but they aren't in the RDAP Technical Implementation Guide 15feb19, meaning * the query format, but they aren't in the RDAP Technical Implementation Guide 15feb19, meaning
@ -276,20 +276,20 @@ public class RdapJsonFormatter {
* <p>We're implementing domain searches anyway, BUT we won't have the response for searches * <p>We're implementing domain searches anyway, BUT we won't have the response for searches
* conform to the RDAP Response Profile. * conform to the RDAP Response Profile.
* *
* @param domainBase the domain resource object from which the JSON object should be created * @param domain the domain resource object from which the JSON object should be created
* @param outputDataType whether to generate FULL or SUMMARY data. Domains are never INTERNAL. * @param outputDataType whether to generate FULL or SUMMARY data. Domains are never INTERNAL.
*/ */
RdapDomain createRdapDomain(DomainBase domainBase, OutputDataType outputDataType) { RdapDomain createRdapDomain(Domain domain, OutputDataType outputDataType) {
RdapDomain.Builder builder = RdapDomain.builder(); RdapDomain.Builder builder = RdapDomain.builder();
builder.linksBuilder().add(makeSelfLink("domain", domainBase.getDomainName())); builder.linksBuilder().add(makeSelfLink("domain", domain.getDomainName()));
if (outputDataType != OutputDataType.FULL) { if (outputDataType != OutputDataType.FULL) {
builder.remarksBuilder().add(RdapIcannStandardInformation.SUMMARY_DATA_REMARK); builder.remarksBuilder().add(RdapIcannStandardInformation.SUMMARY_DATA_REMARK);
} }
// RDAP Response Profile 15feb19 section 2.1 discusses the domain name. // RDAP Response Profile 15feb19 section 2.1 discusses the domain name.
builder.setLdhName(domainBase.getDomainName()); builder.setLdhName(domain.getDomainName());
// RDAP Response Profile 15feb19 section 2.2: // RDAP Response Profile 15feb19 section 2.2:
// The domain handle MUST be the ROID // The domain handle MUST be the ROID
builder.setHandle(domainBase.getRepoId()); builder.setHandle(domain.getRepoId());
// If this is a summary (search result) - we'll return now. Since there's no requirement for // If this is a summary (search result) - we'll return now. Since there's no requirement for
// domain searches at all, having the name, handle, and self link is enough. // domain searches at all, having the name, handle, and self link is enough.
if (outputDataType == OutputDataType.SUMMARY) { if (outputDataType == OutputDataType.SUMMARY) {
@ -304,12 +304,12 @@ public class RdapJsonFormatter {
Event.builder() Event.builder()
.setEventAction(EventAction.REGISTRATION) .setEventAction(EventAction.REGISTRATION)
.setEventActor( .setEventActor(
Optional.ofNullable(domainBase.getCreationRegistrarId()).orElse("(none)")) Optional.ofNullable(domain.getCreationRegistrarId()).orElse("(none)"))
.setEventDate(domainBase.getCreationTime()) .setEventDate(domain.getCreationTime())
.build(), .build(),
Event.builder() Event.builder()
.setEventAction(EventAction.EXPIRATION) .setEventAction(EventAction.EXPIRATION)
.setEventDate(domainBase.getRegistrationExpirationTime()) .setEventDate(domain.getRegistrationExpirationTime())
.build(), .build(),
Event.builder() Event.builder()
.setEventAction(EventAction.LAST_UPDATE_OF_RDAP_DATABASE) .setEventAction(EventAction.LAST_UPDATE_OF_RDAP_DATABASE)
@ -317,18 +317,18 @@ public class RdapJsonFormatter {
.build()); .build());
// RDAP Response Profile 15feb19 section 2.3.2 discusses optional events. We add some of those // RDAP Response Profile 15feb19 section 2.3.2 discusses optional events. We add some of those
// here. We also add a few others we find interesting. // here. We also add a few others we find interesting.
builder.eventsBuilder().addAll(makeOptionalEvents(domainBase)); builder.eventsBuilder().addAll(makeOptionalEvents(domain));
// RDAP Response Profile 15feb19 section 2.4.1: // RDAP Response Profile 15feb19 section 2.4.1:
// The domain object in the RDAP response MUST contain an entity with the Registrar role. // The domain object in the RDAP response MUST contain an entity with the Registrar role.
// //
// See {@link createRdapRegistrarEntity} for details of section 2.4 conformance // See {@link createRdapRegistrarEntity} for details of section 2.4 conformance
Registrar registrar = Registrar registrar =
Registrar.loadRequiredRegistrarCached(domainBase.getCurrentSponsorRegistrarId()); Registrar.loadRequiredRegistrarCached(domain.getCurrentSponsorRegistrarId());
builder.entitiesBuilder().add(createRdapRegistrarEntity(registrar, OutputDataType.INTERNAL)); builder.entitiesBuilder().add(createRdapRegistrarEntity(registrar, OutputDataType.INTERNAL));
// RDAP Technical Implementation Guide 3.2: must have link to the registrar's RDAP URL for this // RDAP Technical Implementation Guide 3.2: must have link to the registrar's RDAP URL for this
// domain, with rel=related. // domain, with rel=related.
for (String registrarRdapBase : registrar.getRdapBaseUrls()) { for (String registrarRdapBase : registrar.getRdapBaseUrls()) {
String href = makeServerRelativeUrl(registrarRdapBase, "domain", domainBase.getDomainName()); String href = makeServerRelativeUrl(registrarRdapBase, "domain", domain.getDomainName());
builder builder
.linksBuilder() .linksBuilder()
.add( .add(
@ -342,14 +342,14 @@ public class RdapJsonFormatter {
// makeStatusValueList should in theory always contain one of either "active" or "inactive". // makeStatusValueList should in theory always contain one of either "active" or "inactive".
ImmutableSet<RdapStatus> status = ImmutableSet<RdapStatus> status =
makeStatusValueList( makeStatusValueList(
domainBase.getStatusValues(), domain.getStatusValues(),
false, // isRedacted false, // isRedacted
domainBase.getDeletionTime().isBefore(getRequestTime())); domain.getDeletionTime().isBefore(getRequestTime()));
builder.statusBuilder().addAll(status); builder.statusBuilder().addAll(status);
if (status.isEmpty()) { if (status.isEmpty()) {
logger.atWarning().log( logger.atWarning().log(
"Domain %s (ROID %s) doesn't have any status.", "Domain %s (ROID %s) doesn't have any status.",
domainBase.getDomainName(), domainBase.getRepoId()); domain.getDomainName(), domain.getRepoId());
} }
// RDAP Response Profile 2.6.3, must have a notice about statuses. That is in {@link // RDAP Response Profile 2.6.3, must have a notice about statuses. That is in {@link
// RdapIcannStandardInformation#domainBoilerplateNotices} // RdapIcannStandardInformation#domainBoilerplateNotices}
@ -357,11 +357,10 @@ public class RdapJsonFormatter {
// 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.
ImmutableSet<HostResource> loadedHosts = ImmutableSet<HostResource> loadedHosts =
tm().transact( tm().transact(() -> ImmutableSet.copyOf(tm().loadByKeys(domain.getNameservers()).values()));
() -> ImmutableSet.copyOf(tm().loadByKeys(domainBase.getNameservers()).values()));
// Load the registrant and other contacts and add them to the data. // Load the registrant and other contacts and add them to the data.
ImmutableMap<VKey<? extends ContactResource>, ContactResource> loadedContacts = ImmutableMap<VKey<? extends ContactResource>, ContactResource> loadedContacts =
tm().transact(() -> tm().loadByKeysIfPresent(domainBase.getReferencedContacts())); tm().transact(() -> tm().loadByKeysIfPresent(domain.getReferencedContacts()));
// RDAP Response Profile 2.7.3, A domain MUST have the REGISTRANT, ADMIN, TECH roles and MAY // RDAP Response Profile 2.7.3, A domain MUST have the REGISTRANT, ADMIN, TECH roles and MAY
// have others. We also add the BILLING. // have others. We also add the BILLING.
// //
@ -371,8 +370,8 @@ public class RdapJsonFormatter {
// the GDPR redaction is handled in createRdapContactEntity // the GDPR redaction is handled in createRdapContactEntity
ImmutableSetMultimap<VKey<ContactResource>, Type> contactsToRoles = ImmutableSetMultimap<VKey<ContactResource>, Type> contactsToRoles =
Streams.concat( Streams.concat(
domainBase.getContacts().stream(), domain.getContacts().stream(),
Stream.of(DesignatedContact.create(Type.REGISTRANT, domainBase.getRegistrant()))) Stream.of(DesignatedContact.create(Type.REGISTRANT, domain.getRegistrant())))
.sorted(DESIGNATED_CONTACT_ORDERING) .sorted(DESIGNATED_CONTACT_ORDERING)
.collect( .collect(
toImmutableSetMultimap( toImmutableSetMultimap(
@ -404,7 +403,7 @@ public class RdapJsonFormatter {
// //
// TODO(b/133310221): get the zoneSigned value from the config files. // TODO(b/133310221): get the zoneSigned value from the config files.
SecureDns.Builder secureDnsBuilder = SecureDns.builder().setZoneSigned(true); SecureDns.Builder secureDnsBuilder = SecureDns.builder().setZoneSigned(true);
domainBase.getDsData().forEach(secureDnsBuilder::addDsData); domain.getDsData().forEach(secureDnsBuilder::addDsData);
builder.setSecureDns(secureDnsBuilder.build()); builder.setSecureDns(secureDnsBuilder.build());
return builder.build(); return builder.build();

View file

@ -27,7 +27,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.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.host.HostResource; import google.registry.model.host.HostResource;
import google.registry.persistence.transaction.CriteriaQueryBuilder; import google.registry.persistence.transaction.CriteriaQueryBuilder;
import google.registry.rdap.RdapJsonFormatter.OutputDataType; import google.registry.rdap.RdapJsonFormatter.OutputDataType;
@ -176,9 +176,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 NameserverSearchResponse searchByNameUsingSuperordinateDomain( private NameserverSearchResponse searchByNameUsingSuperordinateDomain(
RdapSearchPattern partialStringQuery) { RdapSearchPattern partialStringQuery) {
Optional<DomainBase> domainBase = Optional<Domain> domain =
loadByForeignKey(DomainBase.class, partialStringQuery.getSuffix(), getRequestTime()); loadByForeignKey(Domain.class, partialStringQuery.getSuffix(), getRequestTime());
if (!domainBase.isPresent()) { if (!domain.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
@ -188,7 +188,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(domainBase.get().getSubordinateHosts())) { for (String fqhn : ImmutableSortedSet.copyOf(domain.get().getSubordinateHosts())) {
if (cursorString.isPresent() && (fqhn.compareTo(cursorString.get()) <= 0)) { if (cursorString.isPresent() && (fqhn.compareTo(cursorString.get()) <= 0)) {
continue; continue;
} }
@ -208,7 +208,7 @@ public class RdapNameserverSearchAction extends RdapSearchActionBase {
return makeSearchResults( return makeSearchResults(
hostList, hostList,
IncompletenessWarningType.COMPLETE, IncompletenessWarningType.COMPLETE,
domainBase.get().getSubordinateHosts().size(), domain.get().getSubordinateHosts().size(),
CursorType.NAME); CursorType.NAME);
} }

View file

@ -23,7 +23,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
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.DomainBase; import google.registry.model.domain.Domain;
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;
@ -46,18 +46,18 @@ import google.registry.xjc.rgp.XjcRgpStatusValueType;
import google.registry.xjc.secdns.XjcSecdnsDsDataType; import google.registry.xjc.secdns.XjcSecdnsDsDataType;
import google.registry.xjc.secdns.XjcSecdnsDsOrKeyType; import google.registry.xjc.secdns.XjcSecdnsDsOrKeyType;
/** Utility class that turns {@link DomainBase} as {@link XjcRdeDomainElement}. */ /** Utility class that turns {@link Domain} as {@link XjcRdeDomainElement}. */
final class DomainBaseToXjcConverter { final class DomainToXjcConverter {
private static final FluentLogger logger = FluentLogger.forEnclosingClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
/** Converts {@link DomainBase} to {@link XjcRdeDomainElement}. */ /** Converts {@link Domain} to {@link XjcRdeDomainElement}. */
static XjcRdeDomainElement convert(DomainBase domain, RdeMode mode) { static XjcRdeDomainElement convert(Domain domain, RdeMode mode) {
return new XjcRdeDomainElement(convertDomain(domain, mode)); return new XjcRdeDomainElement(convertDomain(domain, mode));
} }
/** Converts {@link DomainBase} to {@link XjcRdeDomain}. */ /** Converts {@link Domain} to {@link XjcRdeDomain}. */
static XjcRdeDomain convertDomain(DomainBase model, RdeMode mode) { static XjcRdeDomain convertDomain(Domain 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
@ -252,7 +252,7 @@ final class DomainBaseToXjcConverter {
return bean; return bean;
} }
private static boolean hasGainingAndLosingRegistrars(DomainBase model) { private static boolean hasGainingAndLosingRegistrars(Domain model) {
return !Strings.isNullOrEmpty(model.getTransferData().getGainingRegistrarId()) return !Strings.isNullOrEmpty(model.getTransferData().getGainingRegistrarId())
&& !Strings.isNullOrEmpty(model.getTransferData().getLosingRegistrarId()); && !Strings.isNullOrEmpty(model.getTransferData().getLosingRegistrarId());
} }
@ -315,5 +315,5 @@ final class DomainBaseToXjcConverter {
return bean; return bean;
} }
private DomainBaseToXjcConverter() {} private DomainToXjcConverter() {}
} }

View file

@ -17,7 +17,7 @@ package google.registry.rde;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.net.InetAddresses; import com.google.common.net.InetAddresses;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.Domain;
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;
@ -34,7 +34,7 @@ import org.joda.time.DateTime;
final class HostResourceToXjcConverter { final class HostResourceToXjcConverter {
/** Converts a subordinate {@link HostResource} to {@link XjcRdeHostElement}. */ /** Converts a subordinate {@link HostResource} to {@link XjcRdeHostElement}. */
static XjcRdeHostElement convertSubordinate(HostResource host, DomainBase superordinateDomain) { static XjcRdeHostElement convertSubordinate(HostResource host, Domain superordinateDomain) {
checkArgument(superordinateDomain.createVKey().equals(host.getSuperordinateDomain())); checkArgument(superordinateDomain.createVKey().equals(host.getSuperordinateDomain()));
return new XjcRdeHostElement(convertSubordinateHost(host, superordinateDomain)); return new XjcRdeHostElement(convertSubordinateHost(host, superordinateDomain));
} }
@ -46,7 +46,7 @@ final class HostResourceToXjcConverter {
} }
/** Converts {@link HostResource} to {@link XjcRdeHost}. */ /** Converts {@link HostResource} to {@link XjcRdeHost}. */
static XjcRdeHost convertSubordinateHost(HostResource model, DomainBase superordinateDomain) { static XjcRdeHost convertSubordinateHost(HostResource model, Domain superordinateDomain) {
XjcRdeHost bean = XjcRdeHost bean =
convertHostCommon( convertHostCommon(
model, model,

View file

@ -21,7 +21,7 @@ import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
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.DomainBase; import google.registry.model.domain.Domain;
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 java.util.HashMap; import java.util.HashMap;
@ -62,8 +62,8 @@ public class RdeFragmenter {
return result; return result;
} }
resourcesFound++; resourcesFound++;
if (resource instanceof DomainBase) { if (resource instanceof Domain) {
result = Optional.of(marshaller.marshalDomain((DomainBase) resource, mode)); result = Optional.of(marshaller.marshalDomain((Domain) 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

@ -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.DomainBase; import google.registry.model.domain.Domain;
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,14 @@ public final class RdeMarshaller implements Serializable {
ContactResourceToXjcConverter.convert(contact)); ContactResourceToXjcConverter.convert(contact));
} }
/** Turns {@link DomainBase} object into an XML fragment. */ /** Turns {@link Domain} object into an XML fragment. */
public DepositFragment marshalDomain(DomainBase domain, RdeMode mode) { public DepositFragment marshalDomain(Domain domain, RdeMode mode) {
return marshalResource(RdeResourceType.DOMAIN, domain, return marshalResource(
DomainBaseToXjcConverter.convert(domain, mode)); RdeResourceType.DOMAIN, domain, DomainToXjcConverter.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, Domain 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

@ -46,7 +46,7 @@ import google.registry.keyring.api.KeyModule.Key;
import google.registry.model.common.Cursor; import google.registry.model.common.Cursor;
import google.registry.model.common.Cursor.CursorType; import google.registry.model.common.Cursor.CursorType;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.host.HostResource; import google.registry.model.host.HostResource;
import google.registry.model.index.EppResourceIndex; import google.registry.model.index.EppResourceIndex;
import google.registry.model.rde.RdeMode; import google.registry.model.rde.RdeMode;
@ -83,7 +83,7 @@ import org.joda.time.Duration;
* account for things like pending transfer. * account for things like pending transfer.
* *
* <p>Only {@link ContactResource}s and {@link HostResource}s that are referenced by an included * <p>Only {@link ContactResource}s and {@link HostResource}s that are referenced by an included
* {@link DomainBase} will be included in the corresponding pending deposit. * {@link Domain} will be included in the corresponding pending deposit.
* *
* <p>{@link Registrar} entities, both active and inactive, are included in all deposits. They are * <p>{@link Registrar} entities, both active and inactive, are included in all deposits. They are
* not rewinded point-in-time. * not rewinded point-in-time.

View file

@ -14,8 +14,6 @@
package google.registry.reporting.icann; package google.registry.reporting.icann;
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
import static google.registry.reporting.icann.IcannReportingModule.DATASTORE_EXPORT_DATA_SET;
import static google.registry.reporting.icann.IcannReportingModule.ICANN_REPORTING_DATA_SET; import static google.registry.reporting.icann.IcannReportingModule.ICANN_REPORTING_DATA_SET;
import static google.registry.reporting.icann.QueryBuilderUtils.getQueryFromFile; import static google.registry.reporting.icann.QueryBuilderUtils.getQueryFromFile;
import static google.registry.reporting.icann.QueryBuilderUtils.getTableName; import static google.registry.reporting.icann.QueryBuilderUtils.getTableName;
@ -72,134 +70,46 @@ public final class TransactionsReportingQueryBuilder implements QueryBuilder {
DateTime latestReportTime = earliestReportTime.plusMonths(1).minusMillis(1); DateTime latestReportTime = earliestReportTime.plusMonths(1).minusMillis(1);
ImmutableMap.Builder<String, String> queriesBuilder = ImmutableMap.builder(); ImmutableMap.Builder<String, String> queriesBuilder = ImmutableMap.builder();
String registrarIanaIdQuery; String registrarIanaIdQuery =
if (tm().isOfy()) {
registrarIanaIdQuery =
SqlTemplate.create(getQueryFromFile("registrar_iana_id.sql"))
.put("PROJECT_ID", projectId)
.put("DATASTORE_EXPORT_DATA_SET", DATASTORE_EXPORT_DATA_SET)
.put("REGISTRAR_TABLE", "Registrar")
.build();
} else {
registrarIanaIdQuery =
SqlTemplate.create(getQueryFromFile("cloud_sql_registrar_iana_id.sql")) SqlTemplate.create(getQueryFromFile("cloud_sql_registrar_iana_id.sql"))
.put("PROJECT_ID", projectId) .put("PROJECT_ID", projectId)
.build(); .build();
}
queriesBuilder.put(getTableName(REGISTRAR_IANA_ID, yearMonth), registrarIanaIdQuery); queriesBuilder.put(getTableName(REGISTRAR_IANA_ID, yearMonth), registrarIanaIdQuery);
String totalDomainsQuery; String totalDomainsQuery =
if (tm().isOfy()) {
totalDomainsQuery =
SqlTemplate.create(getQueryFromFile("total_domains.sql"))
.put("PROJECT_ID", projectId)
.put("DATASTORE_EXPORT_DATA_SET", DATASTORE_EXPORT_DATA_SET)
.put("DOMAINBASE_TABLE", "DomainBase")
.put("REGISTRAR_TABLE", "Registrar")
.build();
} else {
totalDomainsQuery =
SqlTemplate.create(getQueryFromFile("cloud_sql_total_domains.sql")) SqlTemplate.create(getQueryFromFile("cloud_sql_total_domains.sql"))
.put("PROJECT_ID", projectId) .put("PROJECT_ID", projectId)
.build(); .build();
}
queriesBuilder.put(getTableName(TOTAL_DOMAINS, yearMonth), totalDomainsQuery); queriesBuilder.put(getTableName(TOTAL_DOMAINS, yearMonth), totalDomainsQuery);
DateTimeFormatter timestampFormatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSS"); DateTimeFormatter timestampFormatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSS");
String totalNameserversQuery; String totalNameserversQuery =
if (tm().isOfy()) {
totalNameserversQuery =
SqlTemplate.create(getQueryFromFile("total_nameservers.sql"))
.put("PROJECT_ID", projectId)
.put("DATASTORE_EXPORT_DATA_SET", DATASTORE_EXPORT_DATA_SET)
.put("HOSTRESOURCE_TABLE", "HostResource")
.put("DOMAINBASE_TABLE", "DomainBase")
.put("REGISTRAR_TABLE", "Registrar")
.put("LATEST_REPORT_TIME", timestampFormatter.print(latestReportTime))
.build();
} else {
totalNameserversQuery =
SqlTemplate.create(getQueryFromFile("cloud_sql_total_nameservers.sql")) SqlTemplate.create(getQueryFromFile("cloud_sql_total_nameservers.sql"))
.put("PROJECT_ID", projectId) .put("PROJECT_ID", projectId)
.put("LATEST_REPORT_TIME", timestampFormatter.print(latestReportTime)) .put("LATEST_REPORT_TIME", timestampFormatter.print(latestReportTime))
.build(); .build();
}
queriesBuilder.put(getTableName(TOTAL_NAMESERVERS, yearMonth), totalNameserversQuery); queriesBuilder.put(getTableName(TOTAL_NAMESERVERS, yearMonth), totalNameserversQuery);
String transactionCountsQuery; String transactionCountsQuery =
if (tm().isOfy()) {
transactionCountsQuery =
SqlTemplate.create(getQueryFromFile("transaction_counts.sql"))
.put("PROJECT_ID", projectId)
.put("DATASTORE_EXPORT_DATA_SET", DATASTORE_EXPORT_DATA_SET)
.put("REGISTRAR_TABLE", "Registrar")
.put("HISTORYENTRY_TABLE", "HistoryEntry")
.put("EARLIEST_REPORT_TIME", timestampFormatter.print(earliestReportTime))
.put("LATEST_REPORT_TIME", timestampFormatter.print(latestReportTime))
.put("CLIENT_ID", "clientId")
.put("OTHER_CLIENT_ID", "otherClientId")
.put("TRANSFER_SUCCESS_FIELD", "TRANSFER_GAINING_SUCCESSFUL")
.put("TRANSFER_NACKED_FIELD", "TRANSFER_GAINING_NACKED")
.put("DEFAULT_FIELD", "field")
.build();
} else {
transactionCountsQuery =
SqlTemplate.create(getQueryFromFile("cloud_sql_transaction_counts.sql")) SqlTemplate.create(getQueryFromFile("cloud_sql_transaction_counts.sql"))
.put("PROJECT_ID", projectId) .put("PROJECT_ID", projectId)
.put("EARLIEST_REPORT_TIME", timestampFormatter.print(earliestReportTime)) .put("EARLIEST_REPORT_TIME", timestampFormatter.print(earliestReportTime))
.put("LATEST_REPORT_TIME", timestampFormatter.print(latestReportTime)) .put("LATEST_REPORT_TIME", timestampFormatter.print(latestReportTime))
.build(); .build();
}
queriesBuilder.put(getTableName(TRANSACTION_COUNTS, yearMonth), transactionCountsQuery); queriesBuilder.put(getTableName(TRANSACTION_COUNTS, yearMonth), transactionCountsQuery);
String transactionTransferLosingQuery; String transactionTransferLosingQuery =
if (tm().isOfy()) {
transactionTransferLosingQuery =
SqlTemplate.create(getQueryFromFile("transaction_counts.sql"))
.put("PROJECT_ID", projectId)
.put("DATASTORE_EXPORT_DATA_SET", DATASTORE_EXPORT_DATA_SET)
.put("REGISTRAR_TABLE", "Registrar")
.put("HISTORYENTRY_TABLE", "HistoryEntry")
.put("EARLIEST_REPORT_TIME", timestampFormatter.print(earliestReportTime))
.put("LATEST_REPORT_TIME", timestampFormatter.print(latestReportTime))
// Roles are reversed for losing queries
.put("CLIENT_ID", "otherClientId")
.put("OTHER_CLIENT_ID", "clientId")
.put("TRANSFER_SUCCESS_FIELD", "TRANSFER_LOSING_SUCCESSFUL")
.put("TRANSFER_NACKED_FIELD", "TRANSFER_LOSING_NACKED")
.put("DEFAULT_FIELD", "NULL")
.build();
} else {
transactionTransferLosingQuery =
SqlTemplate.create(getQueryFromFile("cloud_sql_transaction_transfer_losing.sql")) SqlTemplate.create(getQueryFromFile("cloud_sql_transaction_transfer_losing.sql"))
.put("PROJECT_ID", projectId) .put("PROJECT_ID", projectId)
.put("EARLIEST_REPORT_TIME", timestampFormatter.print(earliestReportTime)) .put("EARLIEST_REPORT_TIME", timestampFormatter.print(earliestReportTime))
.put("LATEST_REPORT_TIME", timestampFormatter.print(latestReportTime)) .put("LATEST_REPORT_TIME", timestampFormatter.print(latestReportTime))
.build(); .build();
}
queriesBuilder.put( queriesBuilder.put(
getTableName(TRANSACTION_TRANSFER_LOSING, yearMonth), transactionTransferLosingQuery); getTableName(TRANSACTION_TRANSFER_LOSING, yearMonth), transactionTransferLosingQuery);
// App Engine log table suffixes use YYYYMMDD format // App Engine log table suffixes use YYYYMMDD format
DateTimeFormatter logTableFormatter = DateTimeFormat.forPattern("yyyyMMdd"); DateTimeFormatter logTableFormatter = DateTimeFormat.forPattern("yyyyMMdd");
String attemptedAddsQuery; String attemptedAddsQuery =
if (tm().isOfy()) {
attemptedAddsQuery =
SqlTemplate.create(getQueryFromFile("attempted_adds.sql"))
.put("PROJECT_ID", projectId)
.put("DATASTORE_EXPORT_DATA_SET", DATASTORE_EXPORT_DATA_SET)
.put("REGISTRAR_TABLE", "Registrar")
.put("APPENGINE_LOGS_DATA_SET", "appengine_logs")
.put("REQUEST_TABLE", "appengine_googleapis_com_request_log_")
.put("FIRST_DAY_OF_MONTH", logTableFormatter.print(earliestReportTime))
.put("LAST_DAY_OF_MONTH", logTableFormatter.print(latestReportTime))
// All metadata logs for reporting come from google.registry.flows.FlowReporter.
.put(
"METADATA_LOG_PREFIX",
"google.registry.flows.FlowReporter recordToLogs: FLOW-LOG-SIGNATURE-METADATA")
.build();
} else {
attemptedAddsQuery =
SqlTemplate.create(getQueryFromFile("cloud_sql_attempted_adds.sql")) SqlTemplate.create(getQueryFromFile("cloud_sql_attempted_adds.sql"))
.put("PROJECT_ID", projectId) .put("PROJECT_ID", projectId)
.put("APPENGINE_LOGS_DATA_SET", "appengine_logs") .put("APPENGINE_LOGS_DATA_SET", "appengine_logs")
@ -211,28 +121,9 @@ public final class TransactionsReportingQueryBuilder implements QueryBuilder {
"METADATA_LOG_PREFIX", "METADATA_LOG_PREFIX",
"google.registry.flows.FlowReporter recordToLogs: FLOW-LOG-SIGNATURE-METADATA") "google.registry.flows.FlowReporter recordToLogs: FLOW-LOG-SIGNATURE-METADATA")
.build(); .build();
}
queriesBuilder.put(getTableName(ATTEMPTED_ADDS, yearMonth), attemptedAddsQuery); queriesBuilder.put(getTableName(ATTEMPTED_ADDS, yearMonth), attemptedAddsQuery);
String aggregateQuery; String aggregateQuery =
if (tm().isOfy()) {
aggregateQuery =
SqlTemplate.create(getQueryFromFile("transactions_report_aggregation.sql"))
.put("PROJECT_ID", projectId)
.put("DATASTORE_EXPORT_DATA_SET", DATASTORE_EXPORT_DATA_SET)
.put("REGISTRY_TABLE", "Registry")
.put("ICANN_REPORTING_DATA_SET", icannReportingDataSet)
.put("REGISTRAR_IANA_ID_TABLE", getTableName(REGISTRAR_IANA_ID, yearMonth))
.put("TOTAL_DOMAINS_TABLE", getTableName(TOTAL_DOMAINS, yearMonth))
.put("TOTAL_NAMESERVERS_TABLE", getTableName(TOTAL_NAMESERVERS, yearMonth))
.put("TRANSACTION_COUNTS_TABLE", getTableName(TRANSACTION_COUNTS, yearMonth))
.put(
"TRANSACTION_TRANSFER_LOSING_TABLE",
getTableName(TRANSACTION_TRANSFER_LOSING, yearMonth))
.put("ATTEMPTED_ADDS_TABLE", getTableName(ATTEMPTED_ADDS, yearMonth))
.build();
} else {
aggregateQuery =
SqlTemplate.create(getQueryFromFile("cloud_sql_transactions_report_aggregation.sql")) SqlTemplate.create(getQueryFromFile("cloud_sql_transactions_report_aggregation.sql"))
.put("PROJECT_ID", projectId) .put("PROJECT_ID", projectId)
.put("ICANN_REPORTING_DATA_SET", icannReportingDataSet) .put("ICANN_REPORTING_DATA_SET", icannReportingDataSet)
@ -245,7 +136,6 @@ public final class TransactionsReportingQueryBuilder implements QueryBuilder {
getTableName(TRANSACTION_TRANSFER_LOSING, yearMonth)) getTableName(TRANSACTION_TRANSFER_LOSING, yearMonth))
.put("ATTEMPTED_ADDS_TABLE", getTableName(ATTEMPTED_ADDS, yearMonth)) .put("ATTEMPTED_ADDS_TABLE", getTableName(ATTEMPTED_ADDS, yearMonth))
.build(); .build();
}
queriesBuilder.put(getTableName(TRANSACTIONS_REPORT_AGGREGATION, yearMonth), aggregateQuery); queriesBuilder.put(getTableName(TRANSACTIONS_REPORT_AGGREGATION, yearMonth), aggregateQuery);
return queriesBuilder.build(); return queriesBuilder.build();

View file

@ -1,73 +0,0 @@
#standardSQL
-- 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.
-- Determine the number of attempted adds each registrar made.
-- Since the specification requests all 'attempted' adds, we regex the
-- monthly App Engine logs, searching for all create commands and associating
-- them with their corresponding registrars.
-- Example log generated by FlowReporter in App Engine logs:
--google.registry.flows.FlowReporter
-- recordToLogs: FLOW-LOG-SIGNATURE-METADATA:
--{"serverTrid":"oNwL2J2eRya7bh7c9oHIzg==-2360a","clientId":"ipmirror"
-- ,"commandType":"hello", "resourceType":"","flowClassName":"HelloFlow"
-- ,"targetId":"","targetIds":[],"tld":"",
-- "tlds":[],"icannActivityReportField":""}
-- This outer select just converts the registrar's clientId to their name.
SELECT
tld,
registrar_table.registrarName AS registrar_name,
'ATTEMPTED_ADDS' AS metricName,
count AS metricValue
FROM (
SELECT
JSON_EXTRACT_SCALAR(json, '$.tld') AS tld,
JSON_EXTRACT_SCALAR(json, '$.clientId') AS clientId,
COUNT(json) AS count
FROM (
-- Extract JSON metadata package from monthly logs
SELECT
REGEXP_EXTRACT(logMessages, r'FLOW-LOG-SIGNATURE-METADATA: (.*)\n?$')
AS json
FROM (
SELECT
protoPayload.resource AS requestPath,
ARRAY(
SELECT logMessage
FROM UNNEST(protoPayload.line)) AS logMessage
FROM
`%PROJECT_ID%.%APPENGINE_LOGS_DATA_SET%.%REQUEST_TABLE%*`
WHERE _TABLE_SUFFIX
BETWEEN '%FIRST_DAY_OF_MONTH%'
AND '%LAST_DAY_OF_MONTH%')
JOIN UNNEST(logMessage) AS logMessages
-- Look for metadata logs from epp and registrar console requests
WHERE requestPath IN ('/_dr/epp', '/_dr/epptool', '/registrar-xhr')
AND STARTS_WITH(logMessages, "%METADATA_LOG_PREFIX%")
-- Look for domain creates
AND REGEXP_CONTAINS(
logMessages, r'"commandType":"create","resourceType":"domain"')
-- Filter prober data
AND NOT REGEXP_CONTAINS(
logMessages, r'"prober-[a-z]{2}-((any)|(canary))"') )
GROUP BY tld, clientId ) AS logs_table
JOIN
`%PROJECT_ID%.%DATASTORE_EXPORT_DATA_SET%.%REGISTRAR_TABLE%`
AS registrar_table
ON logs_table.clientId = registrar_table.__key__.name
ORDER BY tld, registrar_name

View file

@ -1,30 +0,0 @@
#standardSQL
-- 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.
-- Gather a list of all tld-registrar pairs, with their IANA IDs.
-- This establishes which registrars will appear in the reports.
SELECT
allowed_tlds AS tld,
registrarName AS registrar_name,
ianaIdentifier AS iana_id
FROM
`%PROJECT_ID%.%DATASTORE_EXPORT_DATA_SET%.%REGISTRAR_TABLE%`,
UNNEST(allowedTlds) as allowed_tlds
WHERE (type = 'REAL' OR type = 'INTERNAL')
-- Filter out prober data
AND NOT ENDS_WITH(allowed_tlds, ".test")
ORDER BY tld, registrarName

View file

@ -1,37 +0,0 @@
#standardSQL
-- 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.
-- Determine the number of domains each registrar sponsors per tld.
-- This is just the number of fullyQualifiedDomainNames under each
-- tld-registrar pair.
SELECT
tld,
registrarName as registrar_name,
'TOTAL_DOMAINS' as metricName,
COUNT(fullyQualifiedDomainName) as metricValue
FROM
`%PROJECT_ID%.%DATASTORE_EXPORT_DATA_SET%.%DOMAINBASE_TABLE%`
AS domain_table
JOIN
`%PROJECT_ID%.%DATASTORE_EXPORT_DATA_SET%.%REGISTRAR_TABLE%`
AS registrar_table
ON
currentSponsorClientId = registrar_table.__key__.name
WHERE
registrar_table.type = 'REAL' OR registrar_table.type = 'INTERNAL'
GROUP BY tld, registrarName
ORDER BY tld, registrarName

View file

@ -1,55 +0,0 @@
#standardSQL
-- 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.
-- Determine the number of referenced nameservers for a registrar's domains.
-- We count the number of unique hosts under each tld-registrar combo by
-- collecting all domains' listed hosts that were still valid at the
-- end of the reporting month.
SELECT
tld,
registrarName AS registrar_name,
'TOTAL_NAMESERVERS' AS metricName,
COUNT(fullyQualifiedHostName) AS metricValue
FROM
`%PROJECT_ID%.%DATASTORE_EXPORT_DATA_SET%.%HOSTRESOURCE_TABLE%` AS host_table
JOIN (
SELECT
__key__.name AS clientId,
registrarName
FROM
`%PROJECT_ID%.%DATASTORE_EXPORT_DATA_SET%.%REGISTRAR_TABLE%`
WHERE
type = 'REAL'
OR type = 'INTERNAL') AS registrar_table
ON
currentSponsorClientId = registrar_table.clientId
JOIN (
SELECT
tld,
hosts.name AS referencedHostName
FROM
`%PROJECT_ID%.%DATASTORE_EXPORT_DATA_SET%.%DOMAINBASE_TABLE%`,
UNNEST(nsHosts) AS hosts
WHERE creationTime <= TIMESTAMP("%LATEST_REPORT_TIME%")
AND deletionTime > TIMESTAMP("%LATEST_REPORT_TIME%") ) AS domain_table
ON
host_table.__key__.name = domain_table.referencedHostName
WHERE creationTime <= TIMESTAMP("%LATEST_REPORT_TIME%")
AND deletionTime > TIMESTAMP("%LATEST_REPORT_TIME%")
GROUP BY tld, registrarName
ORDER BY tld, registrarName

View file

@ -1,85 +0,0 @@
#standardSQL
-- 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.
-- Counts the number of mutating transactions each registrar made.
-- We populate the fields through explicit logging of
-- DomainTransactionRecords, which contain all necessary information for
-- reporting (such as reporting time, report field, report amount, etc.
-- A special note on transfers: we only record 'TRANSFER_SUCCESSFUL' or
-- 'TRANSFER_NACKED', and we can infer the gaining and losing parties
-- from the enclosing HistoryEntry's clientId and otherClientId
-- respectively. This query templates the client ID, field for transfer
-- success, field for transfer nacks and default field. This allows us to
-- create one query for TRANSFER_GAINING and the other report fields,
-- and one query for TRANSFER_LOSING fields from the same template.
-- This outer select just converts the registrar's clientId to their name.
SELECT
tld,
registrar_table.registrarName AS registrar_name,
metricName,
metricValue
FROM (
SELECT
tld,
clientId,
CASE
WHEN field = 'TRANSFER_SUCCESSFUL' THEN '%TRANSFER_SUCCESS_FIELD%'
WHEN field = 'TRANSFER_NACKED' THEN '%TRANSFER_NACKED_FIELD%'
ELSE %DEFAULT_FIELD%
END AS metricName,
SUM(amount) AS metricValue
FROM (
SELECT
CASE
-- Explicit transfer acks (approve) and nacks (reject) are done
-- by the opposing registrar. Thus, for these specific actions,
-- we swap the 'otherClientId' with the 'clientId' to properly
-- account for this reversal.
WHEN (entries.type = 'DOMAIN_TRANSFER_APPROVE'
OR entries.type = 'DOMAIN_TRANSFER_REJECT')
THEN entries.%OTHER_CLIENT_ID%
ELSE entries.%CLIENT_ID%
END AS clientId,
entries.domainTransactionRecords.tld[SAFE_OFFSET(index)] AS tld,
entries.domainTransactionRecords.reportingTime[SAFE_OFFSET(index)]
AS reportingTime,
entries.domainTransactionRecords.reportField[SAFE_OFFSET(index)]
AS field,
entries.domainTransactionRecords.reportAmount[SAFE_OFFSET(index)]
AS amount
FROM
`%PROJECT_ID%.%DATASTORE_EXPORT_DATA_SET%.%HISTORYENTRY_TABLE%`
AS entries,
-- This allows us to 'loop' through the arrays in parallel by index
UNNEST(GENERATE_ARRAY(0, ARRAY_LENGTH(
entries.domainTransactionRecords.tld) - 1)) AS index
-- Ignore null entries
WHERE entries.domainTransactionRecords IS NOT NULL )
-- Only look at this month's data
WHERE reportingTime
BETWEEN TIMESTAMP('%EARLIEST_REPORT_TIME%')
AND TIMESTAMP('%LATEST_REPORT_TIME%')
GROUP BY
tld,
clientId,
field ) AS counts_table
JOIN
`%PROJECT_ID%.%DATASTORE_EXPORT_DATA_SET%.%REGISTRAR_TABLE%`
AS registrar_table
ON
counts_table.clientId = registrar_table.__key__.name

View file

@ -1,100 +0,0 @@
#standardSQL
-- 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.
-- Construct the transaction reports' rows from the intermediary data views.
-- This query pulls from all intermediary tables to create the activity
-- report csv, via a table transpose and sum over all activity report fields.
SELECT
registrars.tld as tld,
-- Surround registrar names with quotes to handle names containing a comma.
FORMAT("\"%s\"", registrars.registrar_name) as registrar_name,
registrars.iana_id as iana_id,
SUM(IF(metrics.metricName = 'TOTAL_DOMAINS', metrics.metricValue, 0)) AS total_domains,
SUM(IF(metrics.metricName = 'TOTAL_NAMESERVERS', metrics.metricValue, 0)) AS total_nameservers,
SUM(IF(metrics.metricName = 'NET_ADDS_1_YR', metrics.metricValue, 0)) AS net_adds_1_yr,
SUM(IF(metrics.metricName = 'NET_ADDS_2_YR', metrics.metricValue, 0)) AS net_adds_2_yr,
SUM(IF(metrics.metricName = 'NET_ADDS_3_YR', metrics.metricValue, 0)) AS net_adds_3_yr,
SUM(IF(metrics.metricName = 'NET_ADDS_4_YR', metrics.metricValue, 0)) AS net_adds_4_yr,
SUM(IF(metrics.metricName = 'NET_ADDS_5_YR', metrics.metricValue, 0)) AS net_adds_5_yr,
SUM(IF(metrics.metricName = 'NET_ADDS_6_YR', metrics.metricValue, 0)) AS net_adds_6_yr,
SUM(IF(metrics.metricName = 'NET_ADDS_7_YR', metrics.metricValue, 0)) AS net_adds_7_yr,
SUM(IF(metrics.metricName = 'NET_ADDS_8_YR', metrics.metricValue, 0)) AS net_adds_8_yr,
SUM(IF(metrics.metricName = 'NET_ADDS_9_YR', metrics.metricValue, 0)) AS net_adds_9_yr,
SUM(IF(metrics.metricName = 'NET_ADDS_10_Yr', metrics.metricValue, 0)) AS net_adds_10_yr,
SUM(IF(metrics.metricName = 'NET_RENEWS_1_YR', metrics.metricValue, 0)) AS net_renews_1_yr,
SUM(IF(metrics.metricName = 'NET_RENEWS_2_YR', metrics.metricValue, 0)) AS net_renews_2_yr,
SUM(IF(metrics.metricName = 'NET_RENEWS_3_YR', metrics.metricValue, 0)) AS net_renews_3_yr,
SUM(IF(metrics.metricName = 'NET_RENEWS_4_YR', metrics.metricValue, 0)) AS net_renews_4_yr,
SUM(IF(metrics.metricName = 'NET_RENEWS_5_YR', metrics.metricValue, 0)) AS net_renews_5_yr,
SUM(IF(metrics.metricName = 'NET_RENEWS_6_YR', metrics.metricValue, 0)) AS net_renews_6_yr,
SUM(IF(metrics.metricName = 'NET_RENEWS_7_YR', metrics.metricValue, 0)) AS net_renews_7_yr,
SUM(IF(metrics.metricName = 'NET_RENEWS_8_YR', metrics.metricValue, 0)) AS net_renews_8_yr,
SUM(IF(metrics.metricName = 'NET_RENEWS_9_YR', metrics.metricValue, 0)) AS net_renews_9_yr,
SUM(IF(metrics.metricName = 'NET_RENEWS_10_YR', metrics.metricValue, 0)) AS net_renews_10_yr,
SUM(IF(metrics.metricName = 'TRANSFER_GAINING_SUCCESSFUL', metrics.metricValue, 0)) AS transfer_gaining_successful,
SUM(IF(metrics.metricName = 'TRANSFER_GAINING_NACKED', metrics.metricValue, 0)) AS transfer_gaining_nacked,
SUM(IF(metrics.metricName = 'TRANSFER_LOSING_SUCCESSFUL', metrics.metricValue, 0)) AS transfer_losing_successful,
SUM(IF(metrics.metricName = 'TRANSFER_LOSING_NACKED', metrics.metricValue, 0)) AS transfer_losing_nacked,
-- We don't interact with transfer disputes
0 AS transfer_disputed_won,
0 AS transfer_disputed_lost,
0 AS transfer_disputed_nodecision,
SUM(IF(metrics.metricName = 'DELETED_DOMAINS_GRACE', metrics.metricValue, 0)) AS deleted_domains_grace,
SUM(IF(metrics.metricName = 'DELETED_DOMAINS_NOGRACE', metrics.metricValue, 0)) AS deleted_domains_nograce,
SUM(IF(metrics.metricName = 'RESTORED_DOMAINS', metrics.metricValue, 0)) AS restored_domains,
-- We don't require restore reports
0 AS restored_noreport,
-- We don't enforce AGP limits right now
0 AS agp_exemption_requests,
0 AS agp_exemptions_granted,
0 AS agp_exempted_domains,
SUM(IF(metrics.metricName = 'ATTEMPTED_ADDS', metrics.metricValue, 0)) AS attempted_adds
FROM
-- Only produce reports for real TLDs
(SELECT tldStr AS tld
FROM `%PROJECT_ID%.%DATASTORE_EXPORT_DATA_SET%.%REGISTRY_TABLE%`
WHERE tldType = 'REAL') AS registries
JOIN
(SELECT *
FROM `%PROJECT_ID%.%ICANN_REPORTING_DATA_SET%.%REGISTRAR_IANA_ID_TABLE%`)
AS registrars
ON registries.tld = registrars.tld
-- We LEFT JOIN to produce reports even if the registrar made no transactions
LEFT OUTER JOIN (
-- Gather all intermediary data views
SELECT *
FROM `%PROJECT_ID%.%ICANN_REPORTING_DATA_SET%.%TOTAL_DOMAINS_TABLE%`
UNION ALL
SELECT *
FROM `%PROJECT_ID%.%ICANN_REPORTING_DATA_SET%.%TOTAL_NAMESERVERS_TABLE%`
UNION ALL
SELECT *
FROM `%PROJECT_ID%.%ICANN_REPORTING_DATA_SET%.%TRANSACTION_COUNTS_TABLE%`
UNION ALL
SELECT *
FROM `%PROJECT_ID%.%ICANN_REPORTING_DATA_SET%.%TRANSACTION_TRANSFER_LOSING_TABLE%`
UNION ALL
SELECT *
FROM `%PROJECT_ID%.%ICANN_REPORTING_DATA_SET%.%ATTEMPTED_ADDS_TABLE%` ) AS metrics
-- Join on tld and registrar name
ON registrars.tld = metrics.tld
AND registrars.registrar_name = metrics.registrar_name
GROUP BY
tld, registrar_name, iana_id
ORDER BY
tld, registrar_name

View file

@ -31,7 +31,7 @@ import com.google.template.soy.tofu.SoyTofu;
import com.google.template.soy.tofu.SoyTofu.Renderer; import com.google.template.soy.tofu.SoyTofu.Renderer;
import google.registry.beam.spec11.ThreatMatch; import google.registry.beam.spec11.ThreatMatch;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar;
import google.registry.model.registrar.RegistrarPoc; import google.registry.model.registrar.RegistrarPoc;
import google.registry.reporting.spec11.soy.Spec11EmailSoyInfo; import google.registry.reporting.spec11.soy.Spec11EmailSoyInfo;
@ -136,13 +136,13 @@ public class Spec11EmailUtils {
.filter( .filter(
threatMatch -> threatMatch ->
tm() tm()
.createQueryComposer(DomainBase.class) .createQueryComposer(Domain.class)
.where( .where(
"fullyQualifiedDomainName", "fullyQualifiedDomainName",
Comparator.EQ, Comparator.EQ,
threatMatch.fullyQualifiedDomainName()) threatMatch.fullyQualifiedDomainName())
.stream() .stream()
.anyMatch(DomainBase::shouldPublishToDns)) .anyMatch(Domain::shouldPublishToDns))
.collect(toImmutableList()); .collect(toImmutableList());
}); });
return RegistrarThreatMatches.create(registrarThreatMatches.clientId(), filteredMatches); return RegistrarThreatMatches.create(registrarThreatMatches.clientId(), filteredMatches);

View file

@ -21,14 +21,14 @@ import static google.registry.persistence.transaction.TransactionManagerFactory.
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.DomainBase; import google.registry.model.domain.Domain;
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 DomainBase changes. * queues based on {@link Domain} 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
@ -43,12 +43,10 @@ public final class LordnTaskUtils {
public static final String COLUMNS_SUNRISE = "roid,domain-name,SMD-id,registrar-id," public static final String COLUMNS_SUNRISE = "roid,domain-name,SMD-id,registrar-id,"
+ "registration-datetime,application-datetime"; + "registration-datetime,application-datetime";
/** /** 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 enqueueDomainTask(Domain domain) {
*/
public static void enqueueDomainBaseTask(DomainBase domain) {
tm().assertInTransaction(); tm().assertInTransaction();
// This method needs to use ofy transactionTime as the DomainBase's creationTime because // This method needs to use ofy transactionTime as the Domain'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 +63,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(DomainBase domain, DateTime transactionTime) { public static String getCsvLineForSunriseDomain(Domain domain, DateTime transactionTime) {
return Joiner.on(',') return Joiner.on(',')
.join( .join(
domain.getRepoId(), domain.getRepoId(),
@ -76,7 +74,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(DomainBase domain, DateTime transactionTime) { public static String getCsvLineForClaimsDomain(Domain domain, DateTime transactionTime) {
return Joiner.on(',') return Joiner.on(',')
.join( .join(
domain.getRepoId(), domain.getRepoId(),

View file

@ -20,7 +20,7 @@ import com.google.common.base.Ascii;
import com.google.common.base.Strings; import com.google.common.base.Strings;
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.DomainBase; import google.registry.model.domain.Domain;
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 google.registry.persistence.VKey; import google.registry.persistence.VKey;
@ -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(DomainBase.class); DOMAIN(Domain.class);
private final Class<? extends EppResource> clazz; private final Class<? extends EppResource> clazz;

View file

@ -20,7 +20,7 @@ import static google.registry.persistence.transaction.TransactionManagerFactory.
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.DomainBase; import google.registry.model.domain.Domain;
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;
@ -48,7 +48,7 @@ final class CountDomainsCommand implements CommandWithRemoteApi {
private long getCountForTld(String tld, DateTime now) { private long getCountForTld(String tld, DateTime now) {
return tm().transact( return tm().transact(
() -> () ->
tm().createQueryComposer(DomainBase.class) tm().createQueryComposer(Domain.class)
.where("tld", Comparator.EQ, tld) .where("tld", Comparator.EQ, tld)
.where("deletionTime", Comparator.GT, now) .where("deletionTime", Comparator.GT, now)
.count()); .count());

View file

@ -19,7 +19,7 @@ import static google.registry.persistence.transaction.TransactionManagerFactory.
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.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar;
import google.registry.model.tld.Registry; import google.registry.model.tld.Registry;
import google.registry.model.tld.Registry.TldType; import google.registry.model.tld.Registry.TldType;
@ -79,7 +79,7 @@ final class DeleteTldCommand extends ConfirmingCommand implements CommandWithRem
private boolean tldContainsDomains(String tld) { private boolean tldContainsDomains(String tld) {
return tm().transact( return tm().transact(
() -> () ->
tm().createQueryComposer(DomainBase.class) tm().createQueryComposer(Domain.class)
.where("tld", Comparator.EQ, tld) .where("tld", Comparator.EQ, tld)
.first() .first()
.isPresent()); .isPresent());

View file

@ -28,7 +28,7 @@ import google.registry.batch.RelockDomainAction;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
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.Domain;
import google.registry.model.domain.DomainHistory; import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.RegistryLock; import google.registry.model.domain.RegistryLock;
import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.HistoryEntry;
@ -252,11 +252,11 @@ public final class DomainLockUtils {
private RegistryLock.Builder createLockBuilder( private RegistryLock.Builder createLockBuilder(
String domainName, String registrarId, @Nullable String registrarPocId, boolean isAdmin) { String domainName, String registrarId, @Nullable String registrarPocId, boolean isAdmin) {
DateTime now = jpaTm().getTransactionTime(); DateTime now = jpaTm().getTransactionTime();
DomainBase domainBase = getDomain(domainName, registrarId, now); Domain domain = getDomain(domainName, registrarId, now);
verifyDomainNotLocked(domainBase, isAdmin); verifyDomainNotLocked(domain, isAdmin);
// Multiple pending actions are not allowed for non-admins // Multiple pending actions are not allowed for non-admins
RegistryLockDao.getMostRecentByRepoId(domainBase.getRepoId()) RegistryLockDao.getMostRecentByRepoId(domain.getRepoId())
.ifPresent( .ifPresent(
previousLock -> previousLock ->
checkArgument( checkArgument(
@ -268,7 +268,7 @@ public final class DomainLockUtils {
return new RegistryLock.Builder() return new RegistryLock.Builder()
.setVerificationCode(stringGenerator.createString(VERIFICATION_CODE_LENGTH)) .setVerificationCode(stringGenerator.createString(VERIFICATION_CODE_LENGTH))
.setDomainName(domainName) .setDomainName(domainName)
.setRepoId(domainBase.getRepoId()) .setRepoId(domain.getRepoId())
.setRegistrarId(registrarId) .setRegistrarId(registrarId)
.setRegistrarPocId(registrarPocId) .setRegistrarPocId(registrarPocId)
.isSuperuser(isAdmin); .isSuperuser(isAdmin);
@ -277,11 +277,11 @@ public final class DomainLockUtils {
private RegistryLock.Builder createUnlockBuilder( private RegistryLock.Builder createUnlockBuilder(
String domainName, String registrarId, boolean isAdmin, Optional<Duration> relockDuration) { String domainName, String registrarId, boolean isAdmin, Optional<Duration> relockDuration) {
DateTime now = jpaTm().getTransactionTime(); DateTime now = jpaTm().getTransactionTime();
DomainBase domainBase = getDomain(domainName, registrarId, now); Domain domain = getDomain(domainName, registrarId, now);
Optional<RegistryLock> lockOptional = Optional<RegistryLock> lockOptional =
RegistryLockDao.getMostRecentVerifiedLockByRepoId(domainBase.getRepoId()); RegistryLockDao.getMostRecentVerifiedLockByRepoId(domain.getRepoId());
verifyDomainLocked(domainBase, isAdmin); verifyDomainLocked(domain, isAdmin);
RegistryLock.Builder newLockBuilder; RegistryLock.Builder newLockBuilder;
if (isAdmin) { if (isAdmin) {
@ -293,7 +293,7 @@ public final class DomainLockUtils {
.map(RegistryLock::asBuilder) .map(RegistryLock::asBuilder)
.orElse( .orElse(
new RegistryLock.Builder() new RegistryLock.Builder()
.setRepoId(domainBase.getRepoId()) .setRepoId(domain.getRepoId())
.setDomainName(domainName) .setDomainName(domainName)
.setLockCompletionTime(now) .setLockCompletionTime(now)
.setRegistrarId(registrarId)); .setRegistrarId(registrarId));
@ -325,24 +325,23 @@ public final class DomainLockUtils {
.setRegistrarId(registrarId); .setRegistrarId(registrarId);
} }
private static void verifyDomainNotLocked(DomainBase domainBase, boolean isAdmin) { private static void verifyDomainNotLocked(Domain domain, boolean isAdmin) {
checkArgument( checkArgument(
isAdmin || !domainBase.getStatusValues().containsAll(REGISTRY_LOCK_STATUSES), isAdmin || !domain.getStatusValues().containsAll(REGISTRY_LOCK_STATUSES),
"Domain %s is already locked", "Domain %s is already locked",
domainBase.getDomainName()); domain.getDomainName());
} }
private static void verifyDomainLocked(DomainBase domainBase, boolean isAdmin) { private static void verifyDomainLocked(Domain domain, boolean isAdmin) {
checkArgument( checkArgument(
isAdmin isAdmin || !Sets.intersection(domain.getStatusValues(), REGISTRY_LOCK_STATUSES).isEmpty(),
|| !Sets.intersection(domainBase.getStatusValues(), REGISTRY_LOCK_STATUSES).isEmpty(),
"Domain %s is already unlocked", "Domain %s is already unlocked",
domainBase.getDomainName()); domain.getDomainName());
} }
private DomainBase getDomain(String domainName, String registrarId, DateTime now) { private Domain getDomain(String domainName, String registrarId, DateTime now) {
DomainBase domain = Domain domain =
loadByForeignKeyCached(DomainBase.class, domainName, now) loadByForeignKeyCached(Domain.class, domainName, now)
.orElseThrow(() -> new IllegalArgumentException("Domain doesn't exist")); .orElseThrow(() -> new IllegalArgumentException("Domain doesn't exist"));
// The user must have specified either the correct registrar ID or the admin registrar ID // The user must have specified either the correct registrar ID or the admin registrar ID
checkArgument( checkArgument(
@ -363,10 +362,10 @@ public final class DomainLockUtils {
} }
private void applyLockStatuses(RegistryLock lock, DateTime lockTime, boolean isAdmin) { private void applyLockStatuses(RegistryLock lock, DateTime lockTime, boolean isAdmin) {
DomainBase domain = getDomain(lock.getDomainName(), lock.getRegistrarId(), lockTime); Domain domain = getDomain(lock.getDomainName(), lock.getRegistrarId(), lockTime);
verifyDomainNotLocked(domain, isAdmin); verifyDomainNotLocked(domain, isAdmin);
DomainBase newDomain = Domain newDomain =
domain domain
.asBuilder() .asBuilder()
.setStatusValues( .setStatusValues(
@ -376,10 +375,10 @@ public final class DomainLockUtils {
} }
private void removeLockStatuses(RegistryLock lock, boolean isAdmin, DateTime unlockTime) { private void removeLockStatuses(RegistryLock lock, boolean isAdmin, DateTime unlockTime) {
DomainBase domain = getDomain(lock.getDomainName(), lock.getRegistrarId(), unlockTime); Domain domain = getDomain(lock.getDomainName(), lock.getRegistrarId(), unlockTime);
verifyDomainLocked(domain, isAdmin); verifyDomainLocked(domain, isAdmin);
DomainBase newDomain = Domain newDomain =
domain domain
.asBuilder() .asBuilder()
.setStatusValues( .setStatusValues(
@ -389,8 +388,7 @@ public final class DomainLockUtils {
saveEntities(newDomain, lock, unlockTime, false); saveEntities(newDomain, lock, unlockTime, false);
} }
private static void saveEntities( private static void saveEntities(Domain domain, RegistryLock lock, DateTime now, boolean isLock) {
DomainBase domain, RegistryLock lock, DateTime now, boolean isLock) {
String reason = String reason =
String.format( String.format(
"%s of a domain through a RegistryLock operation", isLock ? "Lock" : "Unlock"); "%s of a domain through a RegistryLock operation", isLock ? "Lock" : "Unlock");

View file

@ -25,7 +25,7 @@ import com.beust.jcommander.Parameters;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.Streams; import com.google.common.collect.Streams;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory; import google.registry.model.domain.DomainHistory;
import google.registry.model.poll.PollMessage; import google.registry.model.poll.PollMessage;
import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar;
@ -85,11 +85,11 @@ class EnqueuePollMessageCommand extends MutatingCommand {
!sendToAll || isNullOrEmpty(clientIds), "Cannot specify both --all and --clients"); !sendToAll || isNullOrEmpty(clientIds), "Cannot specify both --all and --clients");
tm().transact( tm().transact(
() -> { () -> {
Optional<DomainBase> domainOpt = Optional<Domain> domainOpt =
loadByForeignKey(DomainBase.class, domainName, tm().getTransactionTime()); loadByForeignKey(Domain.class, domainName, tm().getTransactionTime());
checkArgument( checkArgument(
domainOpt.isPresent(), "Domain %s doesn't exist or isn't active", domainName); domainOpt.isPresent(), "Domain %s doesn't exist or isn't active", domainName);
DomainBase domain = domainOpt.get(); Domain domain = domainOpt.get();
ImmutableList<String> registrarIds; ImmutableList<String> registrarIds;
if (sendToAll) { if (sendToAll) {
registrarIds = registrarIds =

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.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.host.HostResource; import google.registry.model.host.HostResource;
import google.registry.persistence.transaction.QueryComposer.Comparator; import google.registry.persistence.transaction.QueryComposer.Comparator;
import google.registry.tools.params.PathParameter; import google.registry.tools.params.PathParameter;
@ -73,13 +73,13 @@ final class GenerateDnsReportCommand implements CommandWithRemoteApi {
String generate() { String generate() {
result.append("[\n"); result.append("[\n");
List<DomainBase> domains = List<Domain> domains =
tm().transact( tm().transact(
() -> () ->
tm().createQueryComposer(DomainBase.class) tm().createQueryComposer(Domain.class)
.where("tld", Comparator.EQ, tld) .where("tld", Comparator.EQ, tld)
.list()); .list());
for (DomainBase domain : domains) { for (Domain 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;
@ -100,7 +100,7 @@ final class GenerateDnsReportCommand implements CommandWithRemoteApi {
return result.append("\n]\n").toString(); return result.append("\n]\n").toString();
} }
private void write(DomainBase domain) { private void write(Domain domain) {
ImmutableList<String> nameservers = ImmutableList<String> nameservers =
ImmutableList.sortedCopyOf(domain.loadNameserverHostNames()); ImmutableList.sortedCopyOf(domain.loadNameserverHostNames());
ImmutableList<Map<String, ?>> dsData = ImmutableList<Map<String, ?>> dsData =

View file

@ -21,7 +21,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
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.DomainBase; import google.registry.model.domain.Domain;
import google.registry.tmch.LordnTaskUtils; import google.registry.tmch.LordnTaskUtils;
import google.registry.tools.params.PathParameter; import google.registry.tools.params.PathParameter;
import google.registry.util.Clock; import google.registry.util.Clock;
@ -65,7 +65,7 @@ final class GenerateLordnCommand implements CommandWithRemoteApi {
tm().transact( tm().transact(
() -> () ->
tm() tm()
.createQueryComposer(DomainBase.class) .createQueryComposer(Domain.class)
.where("tld", Comparator.EQ, tld) .where("tld", Comparator.EQ, tld)
.orderBy("repoId") .orderBy("repoId")
.stream() .stream()
@ -91,7 +91,7 @@ final class GenerateLordnCommand implements CommandWithRemoteApi {
private static void processDomain( private static void processDomain(
ImmutableList.Builder<String> claimsCsv, ImmutableList.Builder<String> claimsCsv,
ImmutableList.Builder<String> sunriseCsv, ImmutableList.Builder<String> sunriseCsv,
DomainBase domain) { Domain domain) {
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

@ -23,7 +23,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.domain.token.AllocationToken; import google.registry.model.domain.token.AllocationToken;
import google.registry.persistence.VKey; import google.registry.persistence.VKey;
import java.util.Collection; import java.util.Collection;
@ -55,7 +55,7 @@ final class GetAllocationTokenCommand implements CommandWithRemoteApi {
.forEach((k, v) -> builder.put(k.getSqlKey().toString(), v))); .forEach((k, v) -> builder.put(k.getSqlKey().toString(), v)));
} }
ImmutableMap<String, AllocationToken> loadedTokens = builder.build(); ImmutableMap<String, AllocationToken> loadedTokens = builder.build();
ImmutableMap<VKey<DomainBase>, DomainBase> domains = ImmutableMap<VKey<Domain>, Domain> domains =
tm().transact(() -> loadRedeemedDomains(loadedTokens.values())); tm().transact(() -> loadRedeemedDomains(loadedTokens.values()));
for (String token : mainParameters) { for (String token : mainParameters) {
@ -65,10 +65,10 @@ final class GetAllocationTokenCommand implements CommandWithRemoteApi {
if (!loadedToken.getRedemptionHistoryEntry().isPresent()) { if (!loadedToken.getRedemptionHistoryEntry().isPresent()) {
System.out.printf("Token %s was not redeemed.\n", token); System.out.printf("Token %s was not redeemed.\n", token);
} else { } else {
Key<DomainBase> domainOfyKey = Key<Domain> domainOfyKey =
loadedToken.getRedemptionHistoryEntry().get().getOfyKey().getParent(); loadedToken.getRedemptionHistoryEntry().get().getOfyKey().getParent();
DomainBase domain = Domain domain =
domains.get(VKey.create(DomainBase.class, domainOfyKey.getName(), domainOfyKey)); domains.get(VKey.create(Domain.class, domainOfyKey.getName(), domainOfyKey));
if (domain == null) { if (domain == null) {
System.out.printf("ERROR: Token %s was redeemed but domain can't be loaded.\n", token); System.out.printf("ERROR: Token %s was redeemed but domain can't be loaded.\n", token);
} else { } else {
@ -85,22 +85,21 @@ final class GetAllocationTokenCommand implements CommandWithRemoteApi {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private static ImmutableMap<VKey<DomainBase>, DomainBase> loadRedeemedDomains( private static ImmutableMap<VKey<Domain>, Domain> loadRedeemedDomains(
Collection<AllocationToken> tokens) { Collection<AllocationToken> tokens) {
ImmutableList<VKey<DomainBase>> domainKeys = ImmutableList<VKey<Domain>> domainKeys =
tokens.stream() tokens.stream()
.map(AllocationToken::getRedemptionHistoryEntry) .map(AllocationToken::getRedemptionHistoryEntry)
.filter(Optional::isPresent) .filter(Optional::isPresent)
.map(Optional::get) .map(Optional::get)
.map(key -> tm().loadByKey(key)) .map(key -> tm().loadByKey(key))
.map(he -> (Key<DomainBase>) he.getParent()) .map(he -> (Key<Domain>) he.getParent())
.map(key -> VKey.create(DomainBase.class, key.getName(), key)) .map(key -> VKey.create(Domain.class, key.getName(), key))
.collect(toImmutableList()); .collect(toImmutableList());
ImmutableMap.Builder<VKey<DomainBase>, DomainBase> domainsBuilder = ImmutableMap.Builder<VKey<Domain>, Domain> domainsBuilder = new ImmutableMap.Builder<>();
new ImmutableMap.Builder<>(); for (List<VKey<Domain>> keys : Lists.partition(domainKeys, BATCH_SIZE)) {
for (List<VKey<DomainBase>> keys : Lists.partition(domainKeys, BATCH_SIZE)) {
tm().loadByKeys(ImmutableList.copyOf(keys)) tm().loadByKeys(ImmutableList.copyOf(keys))
.forEach((k, v) -> domainsBuilder.put((VKey<DomainBase>) k, v)); .forEach((k, v) -> domainsBuilder.put((VKey<Domain>) k, v));
} }
return domainsBuilder.build(); return domainsBuilder.build();
} }

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.DomainBase; import google.registry.model.domain.Domain;
import google.registry.util.DomainNameUtils; import google.registry.util.DomainNameUtils;
import java.util.List; import java.util.List;
@ -38,7 +38,7 @@ final class GetDomainCommand extends GetEppResourceCommand {
printResource( printResource(
"Domain", "Domain",
canonicalDomain, canonicalDomain,
loadByForeignKey(DomainBase.class, canonicalDomain, readTimestamp)); loadByForeignKey(Domain.class, canonicalDomain, readTimestamp));
} }
} }
} }

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.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.DomainBase; import google.registry.model.domain.Domain;
import google.registry.tools.soy.DomainRenewSoyInfo; import google.registry.tools.soy.DomainRenewSoyInfo;
import google.registry.util.Clock; import google.registry.util.Clock;
import java.util.List; import java.util.List;
@ -77,11 +77,10 @@ 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<DomainBase> domainOptional = Optional<Domain> domainOptional = loadByForeignKey(Domain.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(DomainRenewSoyInfo.getInstance(), DomainRenewSoyInfo.RENEWDOMAIN); setSoyTemplate(DomainRenewSoyInfo.getInstance(), DomainRenewSoyInfo.RENEWDOMAIN);
DomainBase domain = domainOptional.get(); Domain domain = domainOptional.get();
SoyMapData soyMapData = SoyMapData soyMapData =
new SoyMapData( new SoyMapData(

View file

@ -32,7 +32,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.ImmutableSortedSet;
import com.google.template.soy.data.SoyListData; import com.google.template.soy.data.SoyListData;
import com.google.template.soy.data.SoyMapData; import com.google.template.soy.data.SoyMapData;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.Domain;
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;
@ -126,9 +126,9 @@ final class UniformRapidSuspensionCommand extends MutatingEppToolCommand {
ImmutableList<String> newCanonicalHosts = ImmutableList<String> newCanonicalHosts =
newHosts.stream().map(DomainNameUtils::canonicalizeHostname).collect(toImmutableList()); newHosts.stream().map(DomainNameUtils::canonicalizeHostname).collect(toImmutableList());
ImmutableSet<String> newHostsSet = ImmutableSet.copyOf(newCanonicalHosts); ImmutableSet<String> newHostsSet = ImmutableSet.copyOf(newCanonicalHosts);
Optional<DomainBase> domainOpt = loadByForeignKey(DomainBase.class, domainName, now); Optional<Domain> domainOpt = loadByForeignKey(Domain.class, domainName, now);
checkArgumentPresent(domainOpt, "Domain '%s' does not exist or is deleted", domainName); checkArgumentPresent(domainOpt, "Domain '%s' does not exist or is deleted", domainName);
DomainBase domain = domainOpt.get(); Domain domain = domainOpt.get();
Set<String> missingHosts = Set<String> missingHosts =
difference(newHostsSet, checkResourcesExist(HostResource.class, newCanonicalHosts, now)); difference(newHostsSet, checkResourcesExist(HostResource.class, newCanonicalHosts, now));
checkArgument(missingHosts.isEmpty(), "Hosts do not exist: %s", missingHosts); checkArgument(missingHosts.isEmpty(), "Hosts do not exist: %s", missingHosts);
@ -202,7 +202,7 @@ final class UniformRapidSuspensionCommand extends MutatingEppToolCommand {
Boolean.toString(undo))); Boolean.toString(undo)));
} }
private ImmutableSortedSet<String> getExistingNameservers(DomainBase domain) { private ImmutableSortedSet<String> getExistingNameservers(Domain domain) {
ImmutableSortedSet.Builder<String> nameservers = ImmutableSortedSet.naturalOrder(); ImmutableSortedSet.Builder<String> nameservers = ImmutableSortedSet.naturalOrder();
for (HostResource host : for (HostResource host :
tm().transact(() -> tm().loadByKeys(domain.getNameservers()).values())) { tm().transact(() -> tm().loadByKeys(domain.getNameservers()).values())) {
@ -211,7 +211,7 @@ final class UniformRapidSuspensionCommand extends MutatingEppToolCommand {
return nameservers.build(); return nameservers.build();
} }
private ImmutableSortedSet<String> getExistingLocks(DomainBase domain) { private ImmutableSortedSet<String> getExistingLocks(Domain 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())) {
@ -221,7 +221,7 @@ final class UniformRapidSuspensionCommand extends MutatingEppToolCommand {
return locks.build(); return locks.build();
} }
private boolean hasClientHold(DomainBase domain) { private boolean hasClientHold(Domain domain) {
for (StatusValue status : domain.getStatusValues()) { for (StatusValue status : domain.getStatusValues()) {
if (status == StatusValue.CLIENT_HOLD) { if (status == StatusValue.CLIENT_HOLD) {
return true; return true;
@ -230,7 +230,7 @@ final class UniformRapidSuspensionCommand extends MutatingEppToolCommand {
return false; return false;
} }
private ImmutableList<ImmutableMap<String, Object>> getExistingDsData(DomainBase domain) { private ImmutableList<ImmutableMap<String, Object>> getExistingDsData(Domain domain) {
ImmutableList.Builder<ImmutableMap<String, Object>> dsDataJsons = new ImmutableList.Builder(); ImmutableList.Builder<ImmutableMap<String, Object>> dsDataJsons = new ImmutableList.Builder();
HexBinaryAdapter hexBinaryAdapter = new HexBinaryAdapter(); HexBinaryAdapter hexBinaryAdapter = new HexBinaryAdapter();
for (DelegationSignerData dsData : domain.getDsData()) { for (DelegationSignerData dsData : domain.getDsData()) {

View file

@ -32,7 +32,7 @@ import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.Domain;
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.domain.Period.Unit; import google.registry.model.domain.Period.Unit;
@ -87,11 +87,11 @@ class UnrenewDomainCommand extends ConfirmingCommand implements CommandWithRemot
new ImmutableMap.Builder<>(); new ImmutableMap.Builder<>();
for (String domainName : mainParameters) { for (String domainName : mainParameters) {
if (ForeignKeyIndex.load(DomainBase.class, domainName, START_OF_TIME) == null) { if (ForeignKeyIndex.load(Domain.class, domainName, START_OF_TIME) == null) {
domainsNonexistentBuilder.add(domainName); domainsNonexistentBuilder.add(domainName);
continue; continue;
} }
Optional<DomainBase> domain = loadByForeignKey(DomainBase.class, domainName, now); Optional<Domain> domain = loadByForeignKey(Domain.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);
@ -139,7 +139,7 @@ class UnrenewDomainCommand extends ConfirmingCommand implements CommandWithRemot
StringBuilder resultBuilder = new StringBuilder(); StringBuilder resultBuilder = new StringBuilder();
DateTime now = clock.nowUtc(); DateTime now = clock.nowUtc();
for (String domainName : mainParameters) { for (String domainName : mainParameters) {
DomainBase domain = loadByForeignKey(DomainBase.class, domainName, now).get(); Domain domain = loadByForeignKey(Domain.class, domainName, now).get();
DateTime previousTime = domain.getRegistrationExpirationTime(); DateTime previousTime = domain.getRegistrationExpirationTime();
DateTime newTime = leapSafeSubtractYears(previousTime, period); DateTime newTime = leapSafeSubtractYears(previousTime, period);
resultBuilder.append( resultBuilder.append(
@ -162,8 +162,7 @@ class UnrenewDomainCommand extends ConfirmingCommand implements CommandWithRemot
private void unrenewDomain(String domainName) { private void unrenewDomain(String domainName) {
tm().assertInTransaction(); tm().assertInTransaction();
DateTime now = tm().getTransactionTime(); DateTime now = tm().getTransactionTime();
Optional<DomainBase> domainOptional = Optional<Domain> domainOptional = loadByForeignKey(Domain.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(
@ -171,7 +170,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);
DomainBase domain = domainOptional.get(); Domain 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",
@ -217,7 +216,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);
DomainBase newDomain = Domain newDomain =
domain domain
.asBuilder() .asBuilder()
.setRegistrationExpirationTime(newExpirationTime) .setRegistrationExpirationTime(newExpirationTime)

View file

@ -32,7 +32,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.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.domain.GracePeriodBase; import google.registry.model.domain.GracePeriodBase;
import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.StatusValue;
import google.registry.tools.params.NameserversParameter; import google.registry.tools.params.NameserversParameter;
@ -183,21 +183,21 @@ final class UpdateDomainCommand extends CreateOrUpdateDomainCommand {
ImmutableSet.Builder<String> autorenewGracePeriodWarningDomains = new ImmutableSet.Builder<>(); ImmutableSet.Builder<String> autorenewGracePeriodWarningDomains = new ImmutableSet.Builder<>();
DateTime now = clock.nowUtc(); DateTime now = clock.nowUtc();
for (String domain : domains) { for (String domainName : domains) {
Optional<DomainBase> domainOptional = loadByForeignKey(DomainBase.class, domain, now); Optional<Domain> domainOptional = loadByForeignKey(Domain.class, domainName, now);
checkArgumentPresent(domainOptional, "Domain '%s' does not exist or is deleted", domain); checkArgumentPresent(domainOptional, "Domain '%s' does not exist or is deleted", domainName);
DomainBase domainBase = domainOptional.get(); Domain domain = domainOptional.get();
checkArgument( checkArgument(
!domainBase.getStatusValues().contains(SERVER_UPDATE_PROHIBITED), !domain.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); domainName);
checkArgument( checkArgument(
!domainBase.getStatusValues().contains(PENDING_DELETE) || forceInPendingDelete, !domain.getStatusValues().contains(PENDING_DELETE) || forceInPendingDelete,
"The domain '%s' has status PENDING_DELETE. Verify that you really are intending to " "The domain '%s' has status PENDING_DELETE. Verify that you really are intending to "
+ "update a domain in pending delete (this is uncommon), and if so, pass the " + "update a domain in pending delete (this is uncommon), and if so, pass the "
+ "--force_in_pending_delete parameter to allow this update.", + "--force_in_pending_delete parameter to allow this update.",
domain); domainName);
// Use TreeSets so that the results are always in the same order (this makes testing easier). // Use TreeSets so that the results are always in the same order (this makes testing easier).
Set<String> addAdminsThisDomain = new TreeSet<>(addAdmins); Set<String> addAdminsThisDomain = new TreeSet<>(addAdmins);
@ -211,7 +211,7 @@ final class UpdateDomainCommand extends CreateOrUpdateDomainCommand {
if (!nameservers.isEmpty() || !admins.isEmpty() || !techs.isEmpty() || !statuses.isEmpty()) { if (!nameservers.isEmpty() || !admins.isEmpty() || !techs.isEmpty() || !statuses.isEmpty()) {
if (!nameservers.isEmpty()) { if (!nameservers.isEmpty()) {
ImmutableSortedSet<String> existingNameservers = domainBase.loadNameserverHostNames(); ImmutableSortedSet<String> existingNameservers = domain.loadNameserverHostNames();
populateAddRemoveLists( populateAddRemoveLists(
ImmutableSet.copyOf(nameservers), ImmutableSet.copyOf(nameservers),
existingNameservers, existingNameservers,
@ -224,13 +224,13 @@ final class UpdateDomainCommand extends CreateOrUpdateDomainCommand {
checkArgument( checkArgument(
numNameservers <= 13, numNameservers <= 13,
"The resulting nameservers count for domain %s would be more than 13", "The resulting nameservers count for domain %s would be more than 13",
domain); domainName);
} }
if (!admins.isEmpty() || !techs.isEmpty()) { if (!admins.isEmpty() || !techs.isEmpty()) {
ImmutableSet<String> existingAdmins = ImmutableSet<String> existingAdmins =
getContactsOfType(domainBase, DesignatedContact.Type.ADMIN); getContactsOfType(domain, DesignatedContact.Type.ADMIN);
ImmutableSet<String> existingTechs = ImmutableSet<String> existingTechs =
getContactsOfType(domainBase, DesignatedContact.Type.TECH); getContactsOfType(domain, DesignatedContact.Type.TECH);
if (!admins.isEmpty()) { if (!admins.isEmpty()) {
populateAddRemoveLists( populateAddRemoveLists(
@ -249,7 +249,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 : domainBase.getStatusValues()) { for (StatusValue statusValue : domain.getStatusValues()) {
currentStatusValues.add(statusValue.getXmlName()); currentStatusValues.add(statusValue.getXmlName());
} }
populateAddRemoveLists( populateAddRemoveLists(
@ -280,24 +280,24 @@ final class UpdateDomainCommand extends CreateOrUpdateDomainCommand {
|| clearDsRecords); || clearDsRecords);
if (!add && !remove && !change && !secDns && autorenews == null) { if (!add && !remove && !change && !secDns && autorenews == null) {
logger.atInfo().log("No changes need to be made to domain '%s'.", domain); logger.atInfo().log("No changes need to be made to domain '%s'.", domainName);
continue; continue;
} }
// If autorenew is being turned off and this domain is already in the autorenew grace period, // If autorenew is being turned off and this domain is already in the autorenew grace period,
// then we want to warn the user that they might want to delete it instead. // then we want to warn the user that they might want to delete it instead.
if (Boolean.FALSE.equals(autorenews)) { if (Boolean.FALSE.equals(autorenews)) {
if (domainBase.getGracePeriods().stream() if (domain.getGracePeriods().stream()
.map(GracePeriodBase::getType) .map(GracePeriodBase::getType)
.anyMatch(isEqual(AUTO_RENEW))) { .anyMatch(isEqual(AUTO_RENEW))) {
autorenewGracePeriodWarningDomains.add(domain); autorenewGracePeriodWarningDomains.add(domainName);
} }
} }
setSoyTemplate(DomainUpdateSoyInfo.getInstance(), DomainUpdateSoyInfo.DOMAINUPDATE); setSoyTemplate(DomainUpdateSoyInfo.getInstance(), DomainUpdateSoyInfo.DOMAINUPDATE);
SoyMapData soyMapData = SoyMapData soyMapData =
new SoyMapData( new SoyMapData(
"domain", domain, "domain", domainName,
"add", add, "add", add,
"addNameservers", addNameserversThisDomain, "addNameservers", addNameserversThisDomain,
"addAdmins", addAdminsThisDomain, "addAdmins", addAdminsThisDomain,
@ -341,11 +341,10 @@ final class UpdateDomainCommand extends CreateOrUpdateDomainCommand {
removeSet.addAll(Sets.difference(oldSet, targetSet)); removeSet.addAll(Sets.difference(oldSet, targetSet));
} }
ImmutableSet<String> getContactsOfType( ImmutableSet<String> getContactsOfType(Domain domain, final DesignatedContact.Type contactType) {
DomainBase domainBase, final DesignatedContact.Type contactType) {
return tm().transact( return tm().transact(
() -> () ->
domainBase.getContacts().stream() domain.getContacts().stream()
.filter(contact -> contact.getType().equals(contactType)) .filter(contact -> contact.getType().equals(contactType))
.map(contact -> tm().loadByKey(contact.getContactKey()).getContactId()) .map(contact -> tm().loadByKey(contact.getContactKey()).getContactId())
.collect(toImmutableSet())); .collect(toImmutableSet()));

View file

@ -16,13 +16,13 @@ package google.registry.tools.params;
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.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.host.HostResource; import google.registry.model.host.HostResource;
/** Enum to make it easy for a command to accept a flag that specifies an EppResource subclass. */ /** Enum to make it easy for a command to accept a flag that specifies an EppResource subclass. */
public enum EppResourceTypeParameter { public enum EppResourceTypeParameter {
CONTACT(ContactResource.class), CONTACT(ContactResource.class),
DOMAIN(DomainBase.class), DOMAIN(Domain.class),
HOST(HostResource.class); HOST(HostResource.class);
private final Class<? extends EppResource> type; private final Class<? extends EppResource> type;

View file

@ -29,7 +29,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
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.model.domain.DomainBase; import google.registry.model.domain.Domain;
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;
@ -168,7 +168,7 @@ public class GenerateZoneFilesAction implements Runnable, JsonActionRunner.JsonA
.setCacheMode(CacheMode.IGNORE) .setCacheMode(CacheMode.IGNORE)
.scroll(ScrollMode.FORWARD_ONLY); .scroll(ScrollMode.FORWARD_ONLY);
for (int i = 1; scrollableResults.next(); i = (i + 1) % BATCH_SIZE) { for (int i = 1; scrollableResults.next(); i = (i + 1) % BATCH_SIZE) {
DomainBase domain = (DomainBase) scrollableResults.get(0); Domain domain = (Domain) scrollableResults.get(0);
populateStanzasForDomain(domain, exportTime, result); populateStanzasForDomain(domain, exportTime, result);
if (i == 0) { if (i == 0) {
jpaTm().getEntityManager().flush(); jpaTm().getEntityManager().flush();
@ -179,7 +179,7 @@ public class GenerateZoneFilesAction implements Runnable, JsonActionRunner.JsonA
} }
private void populateStanzasForDomain( private void populateStanzasForDomain(
DomainBase domain, DateTime exportTime, ImmutableList.Builder<String> result) { Domain domain, DateTime exportTime, ImmutableList.Builder<String> result) {
domain = loadAtPointInTime(domain, exportTime); domain = loadAtPointInTime(domain, exportTime);
// A null means the domain was deleted (or not created) at this time. // A null means the domain was deleted (or not created) at this time.
if (domain == null || !domain.shouldPublishToDns()) { if (domain == null || !domain.shouldPublishToDns()) {
@ -193,7 +193,7 @@ public class GenerateZoneFilesAction implements Runnable, JsonActionRunner.JsonA
} }
private void populateStanzasForSubordinateHosts( private void populateStanzasForSubordinateHosts(
DomainBase domain, DateTime exportTime, ImmutableList.Builder<String> result) { Domain domain, DateTime exportTime, ImmutableList.Builder<String> result) {
ImmutableSet<String> subordinateHosts = domain.getSubordinateHosts(); ImmutableSet<String> subordinateHosts = domain.getSubordinateHosts();
if (!subordinateHosts.isEmpty()) { if (!subordinateHosts.isEmpty()) {
for (HostResource unprojectedHost : tm().loadByKeys(domain.getNameservers()).values()) { for (HostResource unprojectedHost : tm().loadByKeys(domain.getNameservers()).values()) {
@ -229,7 +229,7 @@ public class GenerateZoneFilesAction implements Runnable, JsonActionRunner.JsonA
* } * }
* </pre> * </pre>
*/ */
private String domainStanza(DomainBase domain, DateTime exportTime) { private String domainStanza(Domain domain, DateTime exportTime) {
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
String domainLabel = stripTld(domain.getDomainName(), domain.getTld()); String domainLabel = stripTld(domain.getDomainName(), domain.getTld());
for (HostResource nameserver : tm().loadByKeys(domain.getNameservers()).values()) { for (HostResource nameserver : tm().loadByKeys(domain.getNameservers()).values()) {

View file

@ -31,7 +31,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.DomainBase; import google.registry.model.domain.Domain;
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;
@ -47,7 +47,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<DomainBase> { public final class ListDomainsAction extends ListObjectsAction<Domain> {
/** 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;
@ -73,22 +73,22 @@ public final class ListDomainsAction extends ListObjectsAction<DomainBase> {
} }
@Override @Override
public ImmutableSet<DomainBase> loadObjects() { public ImmutableSet<Domain> loadObjects() {
checkArgument(!tlds.isEmpty(), "Must specify TLDs to query"); checkArgument(!tlds.isEmpty(), "Must specify TLDs to query");
assertTldsExist(tlds); assertTldsExist(tlds);
ImmutableList<DomainBase> domains = tm().isOfy() ? loadDomainsOfy() : loadDomainsSql(); ImmutableList<Domain> domains = tm().isOfy() ? loadDomainsOfy() : loadDomainsSql();
return ImmutableSet.copyOf(domains.reverse()); return ImmutableSet.copyOf(domains.reverse());
} }
private ImmutableList<DomainBase> loadDomainsOfy() { private ImmutableList<Domain> loadDomainsOfy() {
DateTime now = clock.nowUtc(); DateTime now = clock.nowUtc();
ImmutableList.Builder<DomainBase> domainsBuilder = new ImmutableList.Builder<>(); ImmutableList.Builder<Domain> domainsBuilder = new ImmutableList.Builder<>();
// Combine the batches together by sorting all domains together with newest first, applying the // Combine the batches together by sorting all domains together with newest first, applying the
// limit, and then reversing for display order. // limit, and then reversing for display order.
for (List<String> tldsBatch : Lists.partition(tlds.asList(), maxNumSubqueries)) { for (List<String> tldsBatch : Lists.partition(tlds.asList(), maxNumSubqueries)) {
auditedOfy() auditedOfy()
.load() .load()
.type(DomainBase.class) .type(Domain.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")
@ -107,7 +107,7 @@ public final class ListDomainsAction extends ListObjectsAction<DomainBase> {
.collect(toImmutableList()); .collect(toImmutableList());
} }
private ImmutableList<DomainBase> loadDomainsSql() { private ImmutableList<Domain> loadDomainsSql() {
return jpaTm() return jpaTm()
.transact( .transact(
() -> () ->
@ -115,7 +115,7 @@ public final class ListDomainsAction extends ListObjectsAction<DomainBase> {
.query( .query(
"FROM Domain WHERE tld IN (:tlds) AND deletionTime > " "FROM Domain WHERE tld IN (:tlds) AND deletionTime > "
+ "current_timestamp() ORDER BY creationTime DESC", + "current_timestamp() ORDER BY creationTime DESC",
DomainBase.class) Domain.class)
.setParameter("tlds", tlds) .setParameter("tlds", tlds)
.setMaxResults(limit) .setMaxResults(limit)
.getResultStream() .getResultStream()

View file

@ -18,7 +18,7 @@ import static google.registry.model.EppResourceUtils.loadByForeignKey;
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.DomainBase; import google.registry.model.domain.Domain;
import java.util.Optional; import java.util.Optional;
import org.joda.time.DateTime; import org.joda.time.DateTime;
@ -42,10 +42,10 @@ public class DomainLookupCommand extends DomainOrHostLookupCommand {
@Override @Override
protected Optional<WhoisResponse> getResponse(InternetDomainName domainName, DateTime now) { protected Optional<WhoisResponse> getResponse(InternetDomainName domainName, DateTime now) {
Optional<DomainBase> domainResource = Optional<Domain> domainResource =
cached cached
? loadByForeignKeyCached(DomainBase.class, domainName.toString(), now) ? loadByForeignKeyCached(Domain.class, domainName.toString(), now)
: loadByForeignKey(DomainBase.class, domainName.toString(), now); : loadByForeignKey(Domain.class, domainName.toString(), now);
return domainResource.map( return domainResource.map(
domain -> new DomainWhoisResponse(domain, fullOutput, whoisRedactedEmailText, now)); domain -> new DomainWhoisResponse(domain, fullOutput, whoisRedactedEmailText, now));
} }

View file

@ -28,7 +28,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.DomainBase; import google.registry.model.domain.Domain;
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,7 +54,7 @@ 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 DomainBase domain; private final Domain 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;
@ -64,7 +64,7 @@ final class DomainWhoisResponse extends WhoisResponseImpl {
/** Creates new WHOIS domain response on the given domain. */ /** Creates new WHOIS domain response on the given domain. */
DomainWhoisResponse( DomainWhoisResponse(
DomainBase domain, boolean fullOutput, String whoisRedactedEmailText, DateTime timestamp) { Domain domain, boolean fullOutput, String whoisRedactedEmailText, DateTime timestamp) {
super(timestamp); super(timestamp);
this.domain = checkNotNull(domain, "domain"); this.domain = checkNotNull(domain, "domain");
this.fullOutput = fullOutput; this.fullOutput = fullOutput;

View file

@ -45,7 +45,7 @@
<class>google.registry.model.common.DatabaseMigrationStateSchedule</class> <class>google.registry.model.common.DatabaseMigrationStateSchedule</class>
<class>google.registry.model.contact.ContactHistory</class> <class>google.registry.model.contact.ContactHistory</class>
<class>google.registry.model.contact.ContactResource</class> <class>google.registry.model.contact.ContactResource</class>
<class>google.registry.model.domain.DomainBase</class> <class>google.registry.model.domain.Domain</class>
<class>google.registry.model.domain.DomainHistory</class> <class>google.registry.model.domain.DomainHistory</class>
<class>google.registry.model.domain.GracePeriod</class> <class>google.registry.model.domain.GracePeriod</class>
<class>google.registry.model.domain.GracePeriod$GracePeriodHistory</class> <class>google.registry.model.domain.GracePeriod$GracePeriodHistory</class>
@ -102,7 +102,7 @@
<class>google.registry.model.billing.VKeyConverter_OneTime</class> <class>google.registry.model.billing.VKeyConverter_OneTime</class>
<class>google.registry.model.billing.VKeyConverter_Recurring</class> <class>google.registry.model.billing.VKeyConverter_Recurring</class>
<class>google.registry.model.contact.VKeyConverter_ContactResource</class> <class>google.registry.model.contact.VKeyConverter_ContactResource</class>
<class>google.registry.model.domain.VKeyConverter_DomainBase</class> <class>google.registry.model.domain.VKeyConverter_Domain</class>
<class>google.registry.model.domain.token.VKeyConverter_AllocationToken</class> <class>google.registry.model.domain.token.VKeyConverter_AllocationToken</class>
<class>google.registry.model.host.VKeyConverter_HostResource</class> <class>google.registry.model.host.VKeyConverter_HostResource</class>
<class>google.registry.model.poll.VKeyConverter_Autorenew</class> <class>google.registry.model.poll.VKeyConverter_Autorenew</class>

View file

@ -21,7 +21,6 @@ import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_CREATE;
import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.loadByEntity; import static google.registry.testing.DatabaseHelper.loadByEntity;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistActiveDomain; import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.util.DateTimeUtils.END_OF_TIME; import static google.registry.util.DateTimeUtils.END_OF_TIME;
@ -33,13 +32,14 @@ import google.registry.flows.EppTestComponent.FakesAndMocksModule;
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.DomainBase; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory; import google.registry.model.domain.DomainHistory;
import google.registry.model.ofy.Ofy; import google.registry.model.ofy.Ofy;
import google.registry.model.poll.PollMessage; import google.registry.model.poll.PollMessage;
import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.HistoryEntry;
import google.registry.persistence.transaction.QueryComposer.Comparator; import google.registry.persistence.transaction.QueryComposer.Comparator;
import google.registry.testing.AppEngineExtension; import google.registry.testing.AppEngineExtension;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.FakeClock; import google.registry.testing.FakeClock;
import google.registry.testing.FakeLockHandler; import google.registry.testing.FakeLockHandler;
import google.registry.testing.FakeResponse; import google.registry.testing.FakeResponse;
@ -82,21 +82,21 @@ class DeleteExpiredDomainsActionTest {
@Test @Test
void test_deletesOnlyExpiredDomain() { void test_deletesOnlyExpiredDomain() {
// A normal, active autorenewing domain that shouldn't be touched. // A normal, active autorenewing domain that shouldn't be touched.
DomainBase activeDomain = persistActiveDomain("foo.tld"); Domain activeDomain = persistActiveDomain("foo.tld");
// A non-autorenewing domain that is already pending delete and shouldn't be touched. // A non-autorenewing domain that is already pending delete and shouldn't be touched.
DomainBase alreadyDeletedDomain = Domain alreadyDeletedDomain =
persistResource( persistResource(
newDomainBase("bar.tld") DatabaseHelper.newDomain("bar.tld")
.asBuilder() .asBuilder()
.setAutorenewEndTime(Optional.of(clock.nowUtc().minusDays(10))) .setAutorenewEndTime(Optional.of(clock.nowUtc().minusDays(10)))
.setDeletionTime(clock.nowUtc().plusDays(17)) .setDeletionTime(clock.nowUtc().plusDays(17))
.build()); .build());
// A non-autorenewing domain that hasn't reached its expiration time and shouldn't be touched. // A non-autorenewing domain that hasn't reached its expiration time and shouldn't be touched.
DomainBase notYetExpiredDomain = Domain notYetExpiredDomain =
persistResource( persistResource(
newDomainBase("baz.tld") DatabaseHelper.newDomain("baz.tld")
.asBuilder() .asBuilder()
.setAutorenewEndTime(Optional.of(clock.nowUtc().plusDays(15))) .setAutorenewEndTime(Optional.of(clock.nowUtc().plusDays(15)))
.build()); .build());
@ -104,7 +104,7 @@ class DeleteExpiredDomainsActionTest {
// A non-autorenewing domain that is past its expiration time and should be deleted. // A non-autorenewing domain that is past its expiration time and should be deleted.
// (This is the only one that needs a full set of subsidiary resources, for the delete flow to // (This is the only one that needs a full set of subsidiary resources, for the delete flow to
// to operate on.) // to operate on.)
DomainBase pendingExpirationDomain = persistNonAutorenewingDomain("fizz.tld"); Domain pendingExpirationDomain = persistNonAutorenewingDomain("fizz.tld");
assertThat(loadByEntity(pendingExpirationDomain).getStatusValues()) assertThat(loadByEntity(pendingExpirationDomain).getStatusValues())
.doesNotContain(PENDING_DELETE); .doesNotContain(PENDING_DELETE);
@ -114,21 +114,21 @@ class DeleteExpiredDomainsActionTest {
clock.advanceOneMilli(); clock.advanceOneMilli();
action.run(); action.run();
DomainBase reloadedActiveDomain = loadByEntity(activeDomain); Domain reloadedActiveDomain = loadByEntity(activeDomain);
assertThat(reloadedActiveDomain).isEqualTo(activeDomain); assertThat(reloadedActiveDomain).isEqualTo(activeDomain);
assertThat(reloadedActiveDomain.getStatusValues()).doesNotContain(PENDING_DELETE); assertThat(reloadedActiveDomain.getStatusValues()).doesNotContain(PENDING_DELETE);
assertThat(loadByEntity(alreadyDeletedDomain)).isEqualTo(alreadyDeletedDomain); assertThat(loadByEntity(alreadyDeletedDomain)).isEqualTo(alreadyDeletedDomain);
assertThat(loadByEntity(notYetExpiredDomain)).isEqualTo(notYetExpiredDomain); assertThat(loadByEntity(notYetExpiredDomain)).isEqualTo(notYetExpiredDomain);
DomainBase reloadedExpiredDomain = loadByEntity(pendingExpirationDomain); Domain reloadedExpiredDomain = loadByEntity(pendingExpirationDomain);
assertThat(reloadedExpiredDomain.getStatusValues()).contains(PENDING_DELETE); assertThat(reloadedExpiredDomain.getStatusValues()).contains(PENDING_DELETE);
assertThat(reloadedExpiredDomain.getDeletionTime()).isEqualTo(clock.nowUtc().plusDays(35)); assertThat(reloadedExpiredDomain.getDeletionTime()).isEqualTo(clock.nowUtc().plusDays(35));
} }
@Test @Test
void test_deletesThreeDomainsInOneRun() throws Exception { void test_deletesThreeDomainsInOneRun() throws Exception {
DomainBase domain1 = persistNonAutorenewingDomain("ecck1.tld"); Domain domain1 = persistNonAutorenewingDomain("ecck1.tld");
DomainBase domain2 = persistNonAutorenewingDomain("veee2.tld"); Domain domain2 = persistNonAutorenewingDomain("veee2.tld");
DomainBase domain3 = persistNonAutorenewingDomain("tarm3.tld"); Domain domain3 = persistNonAutorenewingDomain("tarm3.tld");
// action.run() executes an ancestor-less query which is subject to eventual consistency (it // action.run() executes an ancestor-less query which is subject to eventual consistency (it
// uses an index that is updated asynchronously). For a deterministic test outcome, we busy // uses an index that is updated asynchronously). For a deterministic test outcome, we busy
@ -139,10 +139,10 @@ class DeleteExpiredDomainsActionTest {
tm().transact( tm().transact(
() -> () ->
tm() tm()
.createQueryComposer(DomainBase.class) .createQueryComposer(Domain.class)
.where("autorenewEndTime", Comparator.LTE, clock.nowUtc()) .where("autorenewEndTime", Comparator.LTE, clock.nowUtc())
.stream() .stream()
.map(DomainBase::getDomainName) .map(Domain::getDomainName)
.collect(toImmutableSet())); .collect(toImmutableSet()));
if (matchingDomains.containsAll(ImmutableSet.of("ecck1.tld", "veee2.tld", "tarm3.tld"))) { if (matchingDomains.containsAll(ImmutableSet.of("ecck1.tld", "veee2.tld", "tarm3.tld"))) {
break; break;
@ -164,8 +164,8 @@ class DeleteExpiredDomainsActionTest {
assertThat(loadByEntity(domain3).getStatusValues()).contains(PENDING_DELETE); assertThat(loadByEntity(domain3).getStatusValues()).contains(PENDING_DELETE);
} }
private DomainBase persistNonAutorenewingDomain(String domainName) { private Domain persistNonAutorenewingDomain(String domainName) {
DomainBase pendingExpirationDomain = persistActiveDomain(domainName); Domain pendingExpirationDomain = persistActiveDomain(domainName);
DomainHistory createHistoryEntry = DomainHistory createHistoryEntry =
persistResource( persistResource(
new DomainHistory.Builder() new DomainHistory.Builder()

View file

@ -22,7 +22,6 @@ import static google.registry.persistence.transaction.TransactionManagerFactory.
import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.loadByEntitiesIfPresent; import static google.registry.testing.DatabaseHelper.loadByEntitiesIfPresent;
import static google.registry.testing.DatabaseHelper.loadByEntity; import static google.registry.testing.DatabaseHelper.loadByEntity;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistActiveDomain; import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistActiveHost; import static google.registry.testing.DatabaseHelper.persistActiveHost;
import static google.registry.testing.DatabaseHelper.persistDeletedDomain; import static google.registry.testing.DatabaseHelper.persistDeletedDomain;
@ -42,7 +41,7 @@ import google.registry.dns.DnsQueue;
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.Domain;
import google.registry.model.domain.DomainHistory; import google.registry.model.domain.DomainHistory;
import google.registry.model.index.EppResourceIndex; import google.registry.model.index.EppResourceIndex;
import google.registry.model.index.ForeignKeyIndex; import google.registry.model.index.ForeignKeyIndex;
@ -51,6 +50,7 @@ import google.registry.model.reporting.HistoryEntry;
import google.registry.model.tld.Registry; import google.registry.model.tld.Registry;
import google.registry.model.tld.Registry.TldType; import google.registry.model.tld.Registry.TldType;
import google.registry.testing.AppEngineExtension; import google.registry.testing.AppEngineExtension;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.FakeClock; import google.registry.testing.FakeClock;
import google.registry.testing.SystemPropertyExtension; import google.registry.testing.SystemPropertyExtension;
import java.util.Optional; import java.util.Optional;
@ -173,7 +173,7 @@ class DeleteProberDataActionTest {
@Test @Test
void testSuccess_doesntDeleteNicDomainForProbers() throws Exception { void testSuccess_doesntDeleteNicDomainForProbers() throws Exception {
DomainBase nic = persistActiveDomain("nic.ib-any.test"); Domain nic = persistActiveDomain("nic.ib-any.test");
Set<ImmutableObject> ibEntities = persistLotsOfDomains("ib-any.test"); Set<ImmutableObject> ibEntities = persistLotsOfDomains("ib-any.test");
action.run(); action.run();
assertAllAbsent(ibEntities); assertAllAbsent(ibEntities);
@ -192,23 +192,24 @@ class DeleteProberDataActionTest {
@Test @Test
void testSuccess_activeDomain_isSoftDeleted() throws Exception { void testSuccess_activeDomain_isSoftDeleted() throws Exception {
DomainBase domain = Domain domain =
persistResource( persistResource(
newDomainBase("blah.ib-any.test") DatabaseHelper.newDomain("blah.ib-any.test")
.asBuilder() .asBuilder()
.setCreationTimeForTest(DateTime.now(UTC).minusYears(1)) .setCreationTimeForTest(DateTime.now(UTC).minusYears(1))
.build()); .build());
action.run(); action.run();
DateTime timeAfterDeletion = DateTime.now(UTC); DateTime timeAfterDeletion = DateTime.now(UTC);
assertThat(loadByForeignKey(DomainBase.class, "blah.ib-any.test", timeAfterDeletion)).isEmpty(); assertThat(loadByForeignKey(Domain.class, "blah.ib-any.test", timeAfterDeletion)).isEmpty();
assertThat(loadByEntity(domain).getDeletionTime()).isLessThan(timeAfterDeletion); assertThat(loadByEntity(domain).getDeletionTime()).isLessThan(timeAfterDeletion);
assertDnsTasksEnqueued("blah.ib-any.test"); assertDnsTasksEnqueued("blah.ib-any.test");
} }
@Test @Test
void testSuccess_activeDomain_doubleMapSoftDeletes() throws Exception { void testSuccess_activeDomain_doubleMapSoftDeletes() throws Exception {
DomainBase domain = persistResource( Domain domain =
newDomainBase("blah.ib-any.test") persistResource(
DatabaseHelper.newDomain("blah.ib-any.test")
.asBuilder() .asBuilder()
.setCreationTimeForTest(DateTime.now(UTC).minusYears(1)) .setCreationTimeForTest(DateTime.now(UTC).minusYears(1))
.build()); .build());
@ -216,8 +217,7 @@ class DeleteProberDataActionTest {
DateTime timeAfterDeletion = DateTime.now(UTC); DateTime timeAfterDeletion = DateTime.now(UTC);
resetAction(); resetAction();
action.run(); action.run();
assertThat(loadByForeignKey(DomainBase.class, "blah.ib-any.test", timeAfterDeletion)) assertThat(loadByForeignKey(Domain.class, "blah.ib-any.test", timeAfterDeletion)).isEmpty();
.isEmpty();
assertThat(loadByEntity(domain).getDeletionTime()).isLessThan(timeAfterDeletion); assertThat(loadByEntity(domain).getDeletionTime()).isLessThan(timeAfterDeletion);
assertDnsTasksEnqueued("blah.ib-any.test"); assertDnsTasksEnqueued("blah.ib-any.test");
} }
@ -225,22 +225,21 @@ class DeleteProberDataActionTest {
@Test @Test
void test_recentlyCreatedDomain_isntDeletedYet() throws Exception { void test_recentlyCreatedDomain_isntDeletedYet() throws Exception {
persistResource( persistResource(
newDomainBase("blah.ib-any.test") DatabaseHelper.newDomain("blah.ib-any.test")
.asBuilder() .asBuilder()
.setCreationTimeForTest(DateTime.now(UTC).minusSeconds(1)) .setCreationTimeForTest(DateTime.now(UTC).minusSeconds(1))
.build()); .build());
action.run(); action.run();
Optional<DomainBase> domain = Optional<Domain> domain = loadByForeignKey(Domain.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
void testDryRun_doesntSoftDeleteData() throws Exception { void testDryRun_doesntSoftDeleteData() throws Exception {
DomainBase domain = Domain domain =
persistResource( persistResource(
newDomainBase("blah.ib-any.test") DatabaseHelper.newDomain("blah.ib-any.test")
.asBuilder() .asBuilder()
.setCreationTimeForTest(DateTime.now(UTC).minusYears(1)) .setCreationTimeForTest(DateTime.now(UTC).minusYears(1))
.build()); .build());
@ -252,11 +251,11 @@ class DeleteProberDataActionTest {
@Test @Test
void test_domainWithSubordinateHosts_isSkipped() throws Exception { void test_domainWithSubordinateHosts_isSkipped() throws Exception {
persistActiveHost("ns1.blah.ib-any.test"); persistActiveHost("ns1.blah.ib-any.test");
DomainBase nakedDomain = Domain nakedDomain =
persistDeletedDomain("todelete.ib-any.test", DateTime.now(UTC).minusYears(1)); persistDeletedDomain("todelete.ib-any.test", DateTime.now(UTC).minusYears(1));
DomainBase domainWithSubord = Domain domainWithSubord =
persistDomainAsDeleted( persistDomainAsDeleted(
newDomainBase("blah.ib-any.test") DatabaseHelper.newDomain("blah.ib-any.test")
.asBuilder() .asBuilder()
.setSubordinateHosts(ImmutableSet.of("ns1.blah.ib-any.test")) .setSubordinateHosts(ImmutableSet.of("ns1.blah.ib-any.test"))
.build(), .build(),
@ -270,7 +269,7 @@ class DeleteProberDataActionTest {
@Test @Test
void testFailure_registryAdminClientId_isRequiredForSoftDeletion() { void testFailure_registryAdminClientId_isRequiredForSoftDeletion() {
persistResource( persistResource(
newDomainBase("blah.ib-any.test") DatabaseHelper.newDomain("blah.ib-any.test")
.asBuilder() .asBuilder()
.setCreationTimeForTest(DateTime.now(UTC).minusYears(1)) .setCreationTimeForTest(DateTime.now(UTC).minusYears(1))
.build()); .build());
@ -284,7 +283,7 @@ class DeleteProberDataActionTest {
* 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) {
DomainBase domain = persistDeletedDomain(fqdn, DELETION_TIME); Domain domain = persistDeletedDomain(fqdn, DELETION_TIME);
DomainHistory historyEntry = DomainHistory historyEntry =
persistSimpleResource( persistSimpleResource(
new DomainHistory.Builder() new DomainHistory.Builder()
@ -321,7 +320,7 @@ class DeleteProberDataActionTest {
.add(pollMessage); .add(pollMessage);
if (tm().isOfy()) { if (tm().isOfy()) {
builder builder
.add(ForeignKeyIndex.load(DomainBase.class, fqdn, START_OF_TIME)) .add(ForeignKeyIndex.load(Domain.class, fqdn, START_OF_TIME))
.add(loadByEntity(EppResourceIndex.create(Key.create(domain)))); .add(loadByEntity(EppResourceIndex.create(Key.create(domain))));
} }
return builder.build(); return builder.build();

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