mirror of
https://github.com/google/nomulus.git
synced 2025-06-27 06:44:51 +02:00
DeReference the codebase
This change replaces all Ref objects in the code with Key objects. These are stored in datastore as the same object (raw datastore keys), so this is not a model change. Our best practices doc says to use Keys not Refs because: * The .get() method obscures what's actually going on - Much harder to visually audit the code for datastore loads - Hard to distinguish Ref<T> get()'s from Optional get()'s and Supplier get()'s * Implicit ofy().load() offers much less control - Antipattern for ultimate goal of making Ofy injectable - Can't control cache use or batch loading without making ofy() explicit anyway * Serialization behavior is surprising and could be quite dangerous/incorrect - Can lead to serialization errors. If it actually worked "as intended", it would lead to a Ref<> on a serialized object being replaced upon deserialization with a stale copy of the old value, which could potentially break all kinds of transactional expectations * Having both Ref<T> and Key<T> introduces extra boilerplate everywhere - E.g. helper methods all need to have Ref and Key overloads, or you need to call .key() to get the Key<T> for every Ref<T> you want to pass in - Creating a Ref<T> is more cumbersome, since it doesn't have all the create() overloads that Key<T> has, only create(Key<T>) and create(Entity) - no way to create directly from kind+ID/name, raw Key, websafe key string, etc. (Note that Refs are treated specially by Objectify's @Load method and Keys are not; we don't use that feature, but it is the one advantage Refs have over Keys.) The direct impetus for this change is that I am trying to audit our use of memcache, and the implicit .get() calls to datastore were making that very hard. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=131965491
This commit is contained in:
parent
1a60073b24
commit
5098b03af4
119 changed files with 772 additions and 817 deletions
|
@ -17,7 +17,7 @@ package google.registry.flows;
|
||||||
import static google.registry.model.eppoutput.Result.Code.SuccessWithActionPending;
|
import static google.registry.model.eppoutput.Result.Code.SuccessWithActionPending;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
|
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Work;
|
import com.googlecode.objectify.Work;
|
||||||
import google.registry.flows.EppException.AssociationProhibitsOperationException;
|
import google.registry.flows.EppException.AssociationProhibitsOperationException;
|
||||||
import google.registry.model.EppResource;
|
import google.registry.model.EppResource;
|
||||||
|
@ -50,7 +50,7 @@ public abstract class ResourceAsyncDeleteFlow
|
||||||
// that would be hard to reason about, and there's no real gain in doing so.
|
// that would be hard to reason about, and there's no real gain in doing so.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return isLinkedForFailfast(fki.getReference());
|
return isLinkedForFailfast(fki.getResourceKey());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (isLinked) {
|
if (isLinked) {
|
||||||
|
@ -58,8 +58,8 @@ public abstract class ResourceAsyncDeleteFlow
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Subclasses must override this to check if the supplied reference has incoming links. */
|
/** Subclasses must override this to check if the supplied key has incoming links. */
|
||||||
protected abstract boolean isLinkedForFailfast(Ref<R> ref);
|
protected abstract boolean isLinkedForFailfast(Key<R> key);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected final R createOrMutateResource() {
|
protected final R createOrMutateResource() {
|
||||||
|
|
|
@ -16,7 +16,7 @@ package google.registry.flows.async;
|
||||||
|
|
||||||
import static google.registry.flows.ResourceFlowUtils.handlePendingTransferOnDelete;
|
import static google.registry.flows.ResourceFlowUtils.handlePendingTransferOnDelete;
|
||||||
|
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.model.contact.ContactResource;
|
import google.registry.model.contact.ContactResource;
|
||||||
import google.registry.model.domain.DomainBase;
|
import google.registry.model.domain.DomainBase;
|
||||||
import google.registry.model.reporting.HistoryEntry;
|
import google.registry.model.reporting.HistoryEntry;
|
||||||
|
@ -46,8 +46,8 @@ public class DeleteContactResourceAction extends DeleteEppResourceAction<Contact
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isLinked(
|
protected boolean isLinked(
|
||||||
DomainBase domain, Ref<ContactResource> targetResourceRef) {
|
DomainBase domain, Key<ContactResource> targetResourceKey) {
|
||||||
return domain.getReferencedContacts().contains(targetResourceRef);
|
return domain.getReferencedContacts().contains(targetResourceKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,6 @@ import com.google.appengine.tools.mapreduce.ReducerInput;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Iterators;
|
import com.google.common.collect.Iterators;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import com.googlecode.objectify.Work;
|
import com.googlecode.objectify.Work;
|
||||||
import google.registry.mapreduce.MapreduceRunner;
|
import google.registry.mapreduce.MapreduceRunner;
|
||||||
import google.registry.mapreduce.inputs.EppResourceInputs;
|
import google.registry.mapreduce.inputs.EppResourceInputs;
|
||||||
|
@ -142,7 +141,7 @@ public abstract class DeleteEppResourceAction<T extends EppResource> implements
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Determine whether the target resource is a linked resource on the domain. */
|
/** Determine whether the target resource is a linked resource on the domain. */
|
||||||
protected abstract boolean isLinked(DomainBase domain, Ref<T> targetResourceRef);
|
protected abstract boolean isLinked(DomainBase domain, Key<T> targetResourceKey);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void map(DomainBase domain) {
|
public void map(DomainBase domain) {
|
||||||
|
@ -154,12 +153,8 @@ public abstract class DeleteEppResourceAction<T extends EppResource> implements
|
||||||
emit(targetEppResourceKey, false);
|
emit(targetEppResourceKey, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// The Ref can't be a field on the Mapper, because when a Ref<?> is serialized (required for
|
|
||||||
// each MapShardTask), it uses the DeadRef version, which contains the Ref's value, which
|
|
||||||
// isn't serializable. Thankfully, this isn't expensive.
|
|
||||||
// See: https://github.com/objectify/objectify/blob/master/src/main/java/com/googlecode/objectify/impl/ref/DeadRef.java
|
|
||||||
if (isActive(domain, targetResourceUpdateTimestamp)
|
if (isActive(domain, targetResourceUpdateTimestamp)
|
||||||
&& isLinked(domain, Ref.create(targetEppResourceKey))) {
|
&& isLinked(domain, targetEppResourceKey)) {
|
||||||
emit(targetEppResourceKey, true);
|
emit(targetEppResourceKey, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ package google.registry.flows.async;
|
||||||
|
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
|
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.dns.DnsQueue;
|
import google.registry.dns.DnsQueue;
|
||||||
import google.registry.model.domain.DomainBase;
|
import google.registry.model.domain.DomainBase;
|
||||||
import google.registry.model.host.HostResource;
|
import google.registry.model.host.HostResource;
|
||||||
|
@ -46,8 +46,8 @@ public class DeleteHostResourceAction extends DeleteEppResourceAction<HostResour
|
||||||
private static final long serialVersionUID = 1941092742903217194L;
|
private static final long serialVersionUID = 1941092742903217194L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isLinked(DomainBase domain, Ref<HostResource> targetResourceRef) {
|
protected boolean isLinked(DomainBase domain, Key<HostResource> targetResourceKey) {
|
||||||
return domain.getNameservers().contains(targetResourceRef);
|
return domain.getNameservers().contains(targetResourceKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ public class DeleteHostResourceAction extends DeleteEppResourceAction<HostResour
|
||||||
if (targetResource.getSuperordinateDomain() != null) {
|
if (targetResource.getSuperordinateDomain() != null) {
|
||||||
DnsQueue.create().addHostRefreshTask(targetResource.getFullyQualifiedHostName());
|
DnsQueue.create().addHostRefreshTask(targetResource.getFullyQualifiedHostName());
|
||||||
ofy().save().entity(
|
ofy().save().entity(
|
||||||
targetResource.getSuperordinateDomain().get().asBuilder()
|
ofy().load().key(targetResource.getSuperordinateDomain()).now().asBuilder()
|
||||||
.removeSubordinateHost(targetResource.getFullyQualifiedHostName())
|
.removeSubordinateHost(targetResource.getFullyQualifiedHostName())
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
||||||
import com.google.appengine.tools.mapreduce.Mapper;
|
import com.google.appengine.tools.mapreduce.Mapper;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import google.registry.dns.DnsQueue;
|
import google.registry.dns.DnsQueue;
|
||||||
import google.registry.mapreduce.MapreduceRunner;
|
import google.registry.mapreduce.MapreduceRunner;
|
||||||
import google.registry.mapreduce.inputs.EppResourceInputs;
|
import google.registry.mapreduce.inputs.EppResourceInputs;
|
||||||
|
@ -92,7 +91,7 @@ public class DnsRefreshForHostRenameAction implements Runnable {
|
||||||
@Override
|
@Override
|
||||||
public final void map(DomainResource domain) {
|
public final void map(DomainResource domain) {
|
||||||
if (isActive(domain, hostUpdateTime)
|
if (isActive(domain, hostUpdateTime)
|
||||||
&& domain.getNameservers().contains(Ref.create(targetHostKey))) {
|
&& domain.getNameservers().contains(targetHostKey)) {
|
||||||
try {
|
try {
|
||||||
dnsQueue.addDomainRefreshTask(domain.getFullyQualifiedDomainName());
|
dnsQueue.addDomainRefreshTask(domain.getFullyQualifiedDomainName());
|
||||||
logger.infofmt("Enqueued refresh for domain %s", domain.getFullyQualifiedDomainName());
|
logger.infofmt("Enqueued refresh for domain %s", domain.getFullyQualifiedDomainName());
|
||||||
|
|
|
@ -21,7 +21,6 @@ import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import google.registry.config.RegistryEnvironment;
|
import google.registry.config.RegistryEnvironment;
|
||||||
import google.registry.flows.EppException;
|
import google.registry.flows.EppException;
|
||||||
import google.registry.flows.ResourceAsyncDeleteFlow;
|
import google.registry.flows.ResourceAsyncDeleteFlow;
|
||||||
|
@ -51,7 +50,7 @@ public class ContactDeleteFlow extends ResourceAsyncDeleteFlow<ContactResource,
|
||||||
@Inject ContactDeleteFlow() {}
|
@Inject ContactDeleteFlow() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isLinkedForFailfast(final Ref<ContactResource> ref) {
|
protected boolean isLinkedForFailfast(final Key<ContactResource> key) {
|
||||||
// Query for the first few linked domains, and if found, actually load them. The query is
|
// Query for the first few linked domains, and if found, actually load them. The query is
|
||||||
// eventually consistent and so might be very stale, but the direct load will not be stale,
|
// eventually consistent and so might be very stale, but the direct load will not be stale,
|
||||||
// just non-transactional. If we find at least one actual reference then we can reliably
|
// just non-transactional. If we find at least one actual reference then we can reliably
|
||||||
|
@ -59,11 +58,11 @@ public class ContactDeleteFlow extends ResourceAsyncDeleteFlow<ContactResource,
|
||||||
return Iterables.any(
|
return Iterables.any(
|
||||||
ofy().load().keys(
|
ofy().load().keys(
|
||||||
queryDomainsUsingResource(
|
queryDomainsUsingResource(
|
||||||
ContactResource.class, ref, now, FAILFAST_CHECK_COUNT)).values(),
|
ContactResource.class, key, now, FAILFAST_CHECK_COUNT)).values(),
|
||||||
new Predicate<DomainBase>() {
|
new Predicate<DomainBase>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(DomainBase domain) {
|
public boolean apply(DomainBase domain) {
|
||||||
return domain.getReferencedContacts().contains(ref);
|
return domain.getReferencedContacts().contains(key);
|
||||||
}});
|
}});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ import static google.registry.util.CollectionUtils.isNullOrEmpty;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.flows.EppException;
|
import google.registry.flows.EppException;
|
||||||
import google.registry.flows.EppException.AuthorizationErrorException;
|
import google.registry.flows.EppException.AuthorizationErrorException;
|
||||||
import google.registry.flows.EppException.ObjectDoesNotExistException;
|
import google.registry.flows.EppException.ObjectDoesNotExistException;
|
||||||
|
@ -173,7 +173,7 @@ public class DomainAllocateFlow extends DomainCreateOrAllocateFlow {
|
||||||
sunrushAddGracePeriod ? GracePeriodStatus.SUNRUSH_ADD : GracePeriodStatus.ADD,
|
sunrushAddGracePeriod ? GracePeriodStatus.SUNRUSH_ADD : GracePeriodStatus.ADD,
|
||||||
billingEvent))
|
billingEvent))
|
||||||
.setApplicationTime(allocateCreate.getApplicationTime())
|
.setApplicationTime(allocateCreate.getApplicationTime())
|
||||||
.setApplication(Ref.create(application))
|
.setApplication(Key.create(application))
|
||||||
.setSmdId(allocateCreate.getSmdId())
|
.setSmdId(allocateCreate.getSmdId())
|
||||||
.setLaunchNotice(allocateCreate.getNotice());
|
.setLaunchNotice(allocateCreate.getNotice());
|
||||||
// Names on the collision list will not be delegated. Set server hold.
|
// Names on the collision list will not be delegated. Set server hold.
|
||||||
|
|
|
@ -19,7 +19,7 @@ import static google.registry.flows.domain.DomainFlowUtils.validateFeeChallenge;
|
||||||
import static google.registry.model.domain.fee.Fee.FEE_CREATE_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER;
|
import static google.registry.model.domain.fee.Fee.FEE_CREATE_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER;
|
||||||
import static google.registry.model.eppoutput.Result.Code.Success;
|
import static google.registry.model.eppoutput.Result.Code.Success;
|
||||||
import static google.registry.model.index.DomainApplicationIndex.loadActiveApplicationsByDomainName;
|
import static google.registry.model.index.DomainApplicationIndex.loadActiveApplicationsByDomainName;
|
||||||
import static google.registry.model.index.ForeignKeyIndex.loadAndGetReference;
|
import static google.registry.model.index.ForeignKeyIndex.loadAndGetKey;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.collect.FluentIterable;
|
import com.google.common.collect.FluentIterable;
|
||||||
|
@ -156,7 +156,7 @@ public class DomainApplicationCreateFlow extends BaseDomainCreateFlow<DomainAppl
|
||||||
}
|
}
|
||||||
// Fail if the domain is already registered (e.g. this is a landrush application but the domain
|
// Fail if the domain is already registered (e.g. this is a landrush application but the domain
|
||||||
// was awarded at the end of sunrise).
|
// was awarded at the end of sunrise).
|
||||||
if (loadAndGetReference(DomainResource.class, targetId, now) != null) {
|
if (loadAndGetKey(DomainResource.class, targetId, now) != null) {
|
||||||
throw new ResourceAlreadyExistsException(targetId);
|
throw new ResourceAlreadyExistsException(targetId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ import static google.registry.util.DateTimeUtils.leapSafeAddYears;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.dns.DnsQueue;
|
import google.registry.dns.DnsQueue;
|
||||||
import google.registry.flows.EppException;
|
import google.registry.flows.EppException;
|
||||||
import google.registry.model.billing.BillingEvent;
|
import google.registry.model.billing.BillingEvent;
|
||||||
|
@ -74,8 +74,8 @@ public abstract class DomainCreateOrAllocateFlow
|
||||||
|
|
||||||
builder
|
builder
|
||||||
.setRegistrationExpirationTime(registrationExpirationTime)
|
.setRegistrationExpirationTime(registrationExpirationTime)
|
||||||
.setAutorenewBillingEvent(Ref.create(autorenewEvent))
|
.setAutorenewBillingEvent(Key.create(autorenewEvent))
|
||||||
.setAutorenewPollMessage(Ref.create(autorenewPollMessage));
|
.setAutorenewPollMessage(Key.create(autorenewPollMessage));
|
||||||
setDomainCreateOrAllocateProperties(builder);
|
setDomainCreateOrAllocateProperties(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,8 +114,8 @@ public class DomainDeleteFlow extends ResourceSyncDeleteFlow<DomainResource, Bui
|
||||||
.build();
|
.build();
|
||||||
builder.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
|
builder.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
|
||||||
.setDeletionTime(deletionTime)
|
.setDeletionTime(deletionTime)
|
||||||
// Clear out all old grace periods and add REDEMPTION, which does not include a ref
|
// Clear out all old grace periods and add REDEMPTION, which does not include a key to a
|
||||||
// to a billing event because there isn't one for a domain delete.
|
// billing event because there isn't one for a domain delete.
|
||||||
.setGracePeriods(ImmutableSet.of(GracePeriod.createWithoutBillingEvent(
|
.setGracePeriods(ImmutableSet.of(GracePeriod.createWithoutBillingEvent(
|
||||||
GracePeriodStatus.REDEMPTION,
|
GracePeriodStatus.REDEMPTION,
|
||||||
now.plus(registry.getRedemptionGracePeriodLength()),
|
now.plus(registry.getRedemptionGracePeriodLength()),
|
||||||
|
@ -142,11 +142,13 @@ public class DomainDeleteFlow extends ResourceSyncDeleteFlow<DomainResource, Bui
|
||||||
Money cost;
|
Money cost;
|
||||||
if (gracePeriod.getType() == GracePeriodStatus.AUTO_RENEW) {
|
if (gracePeriod.getType() == GracePeriodStatus.AUTO_RENEW) {
|
||||||
TimeOfYear recurrenceTimeOfYear =
|
TimeOfYear recurrenceTimeOfYear =
|
||||||
checkNotNull(gracePeriod.getRecurringBillingEvent()).get().getRecurrenceTimeOfYear();
|
ofy().load().key(checkNotNull(gracePeriod.getRecurringBillingEvent())).now()
|
||||||
|
.getRecurrenceTimeOfYear();
|
||||||
DateTime autoRenewTime = recurrenceTimeOfYear.getLastInstanceBeforeOrAt(now);
|
DateTime autoRenewTime = recurrenceTimeOfYear.getLastInstanceBeforeOrAt(now);
|
||||||
cost = getDomainRenewCost(targetId, autoRenewTime, 1);
|
cost = getDomainRenewCost(targetId, autoRenewTime, 1);
|
||||||
} else {
|
} else {
|
||||||
cost = checkNotNull(gracePeriod.getOneTimeBillingEvent()).get().getCost();
|
cost =
|
||||||
|
ofy().load().key(checkNotNull(gracePeriod.getOneTimeBillingEvent())).now().getCost();
|
||||||
}
|
}
|
||||||
creditsBuilder.add(Credit.create(
|
creditsBuilder.add(Credit.create(
|
||||||
cost.negated().getAmount(),
|
cost.negated().getAmount(),
|
||||||
|
|
|
@ -40,7 +40,6 @@ import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.common.net.InternetDomainName;
|
import com.google.common.net.InternetDomainName;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import google.registry.flows.EppException;
|
import google.registry.flows.EppException;
|
||||||
import google.registry.flows.EppException.AuthorizationErrorException;
|
import google.registry.flows.EppException.AuthorizationErrorException;
|
||||||
import google.registry.flows.EppException.ObjectDoesNotExistException;
|
import google.registry.flows.EppException.ObjectDoesNotExistException;
|
||||||
|
@ -246,23 +245,23 @@ public class DomainFlowUtils {
|
||||||
/** Verify that no linked resources have disallowed statuses. */
|
/** Verify that no linked resources have disallowed statuses. */
|
||||||
static void verifyNotInPendingDelete(
|
static void verifyNotInPendingDelete(
|
||||||
Set<DesignatedContact> contacts,
|
Set<DesignatedContact> contacts,
|
||||||
Ref<ContactResource> registrant,
|
Key<ContactResource> registrant,
|
||||||
Set<Ref<HostResource>> nameservers) throws EppException {
|
Set<Key<HostResource>> nameservers) throws EppException {
|
||||||
for (DesignatedContact contact : nullToEmpty(contacts)) {
|
for (DesignatedContact contact : nullToEmpty(contacts)) {
|
||||||
verifyNotInPendingDelete(contact.getContactRef());
|
verifyNotInPendingDelete(contact.getContactKey());
|
||||||
}
|
}
|
||||||
if (registrant != null) {
|
if (registrant != null) {
|
||||||
verifyNotInPendingDelete(registrant);
|
verifyNotInPendingDelete(registrant);
|
||||||
}
|
}
|
||||||
for (Ref<HostResource> host : nullToEmpty(nameservers)) {
|
for (Key<HostResource> host : nullToEmpty(nameservers)) {
|
||||||
verifyNotInPendingDelete(host);
|
verifyNotInPendingDelete(host);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void verifyNotInPendingDelete(
|
private static void verifyNotInPendingDelete(
|
||||||
Ref<? extends EppResource> resourceRef) throws EppException {
|
Key<? extends EppResource> resourceKey) throws EppException {
|
||||||
|
|
||||||
EppResource resource = resourceRef.get();
|
EppResource resource = ofy().load().key(resourceKey).now();
|
||||||
if (resource.getStatusValues().contains(StatusValue.PENDING_DELETE)) {
|
if (resource.getStatusValues().contains(StatusValue.PENDING_DELETE)) {
|
||||||
throw new LinkedResourceInPendingDeleteProhibitsOperationException(resource.getForeignKey());
|
throw new LinkedResourceInPendingDeleteProhibitsOperationException(resource.getForeignKey());
|
||||||
}
|
}
|
||||||
|
@ -302,7 +301,7 @@ public class DomainFlowUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void validateRequiredContactsPresent(
|
static void validateRequiredContactsPresent(
|
||||||
Ref<ContactResource> registrant, Set<DesignatedContact> contacts)
|
Key<ContactResource> registrant, Set<DesignatedContact> contacts)
|
||||||
throws RequiredParameterMissingException {
|
throws RequiredParameterMissingException {
|
||||||
if (registrant == null) {
|
if (registrant == null) {
|
||||||
throw new MissingRegistrantException();
|
throw new MissingRegistrantException();
|
||||||
|
@ -446,14 +445,14 @@ public class DomainFlowUtils {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
static void updateAutorenewRecurrenceEndTime(DomainResource domain, DateTime newEndTime) {
|
static void updateAutorenewRecurrenceEndTime(DomainResource domain, DateTime newEndTime) {
|
||||||
Optional<PollMessage.Autorenew> autorenewPollMessage =
|
Optional<PollMessage.Autorenew> autorenewPollMessage =
|
||||||
Optional.fromNullable(domain.getAutorenewPollMessage().get());
|
Optional.fromNullable(ofy().load().key(domain.getAutorenewPollMessage()).now());
|
||||||
|
|
||||||
// Construct an updated autorenew poll message. If the autorenew poll message no longer exists,
|
// Construct an updated autorenew poll message. If the autorenew poll message no longer exists,
|
||||||
// create a new one at the same id. This can happen if a transfer was requested on a domain
|
// create a new one at the same id. This can happen if a transfer was requested on a domain
|
||||||
// where all autorenew poll messages had already been delivered (this would cause the poll
|
// where all autorenew poll messages had already been delivered (this would cause the poll
|
||||||
// message to be deleted), and then subsequently the transfer was canceled, rejected, or deleted
|
// message to be deleted), and then subsequently the transfer was canceled, rejected, or deleted
|
||||||
// (which would cause the poll message to be recreated here).
|
// (which would cause the poll message to be recreated here).
|
||||||
Key<PollMessage.Autorenew> existingAutorenewKey = domain.getAutorenewPollMessage().key();
|
Key<PollMessage.Autorenew> existingAutorenewKey = domain.getAutorenewPollMessage();
|
||||||
PollMessage.Autorenew updatedAutorenewPollMessage = autorenewPollMessage.isPresent()
|
PollMessage.Autorenew updatedAutorenewPollMessage = autorenewPollMessage.isPresent()
|
||||||
? autorenewPollMessage.get().asBuilder().setAutorenewEndTime(newEndTime).build()
|
? autorenewPollMessage.get().asBuilder().setAutorenewEndTime(newEndTime).build()
|
||||||
: newAutorenewPollMessage(domain)
|
: newAutorenewPollMessage(domain)
|
||||||
|
@ -472,7 +471,7 @@ public class DomainFlowUtils {
|
||||||
ofy().save().entity(updatedAutorenewPollMessage);
|
ofy().save().entity(updatedAutorenewPollMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
ofy().save().entity(domain.getAutorenewBillingEvent().get().asBuilder()
|
ofy().save().entity(ofy().load().key(domain.getAutorenewBillingEvent()).now().asBuilder()
|
||||||
.setRecurrenceEndTime(newEndTime)
|
.setRecurrenceEndTime(newEndTime)
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ import static google.registry.util.DateTimeUtils.leapSafeAddYears;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.flows.EppException;
|
import google.registry.flows.EppException;
|
||||||
import google.registry.flows.EppException.ObjectPendingTransferException;
|
import google.registry.flows.EppException.ObjectPendingTransferException;
|
||||||
import google.registry.flows.EppException.ParameterValueRangeErrorException;
|
import google.registry.flows.EppException.ParameterValueRangeErrorException;
|
||||||
|
@ -145,8 +145,8 @@ public class DomainRenewFlow extends OwnedResourceMutateFlow<DomainResource, Ren
|
||||||
ofy().save().<Object>entities(explicitRenewEvent, newAutorenewEvent, newAutorenewPollMessage);
|
ofy().save().<Object>entities(explicitRenewEvent, newAutorenewEvent, newAutorenewPollMessage);
|
||||||
return existingResource.asBuilder()
|
return existingResource.asBuilder()
|
||||||
.setRegistrationExpirationTime(newExpirationTime)
|
.setRegistrationExpirationTime(newExpirationTime)
|
||||||
.setAutorenewBillingEvent(Ref.create(newAutorenewEvent))
|
.setAutorenewBillingEvent(Key.create(newAutorenewEvent))
|
||||||
.setAutorenewPollMessage(Ref.create(newAutorenewPollMessage))
|
.setAutorenewPollMessage(Key.create(newAutorenewPollMessage))
|
||||||
.addGracePeriod(GracePeriod.forBillingEvent(GracePeriodStatus.RENEW, explicitRenewEvent))
|
.addGracePeriod(GracePeriod.forBillingEvent(GracePeriodStatus.RENEW, explicitRenewEvent))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.net.InternetDomainName;
|
import com.google.common.net.InternetDomainName;
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.dns.DnsQueue;
|
import google.registry.dns.DnsQueue;
|
||||||
import google.registry.flows.EppException;
|
import google.registry.flows.EppException;
|
||||||
import google.registry.flows.EppException.CommandUseErrorException;
|
import google.registry.flows.EppException.CommandUseErrorException;
|
||||||
|
@ -160,8 +160,8 @@ public class DomainRestoreRequestFlow extends OwnedResourceMutateFlow<DomainReso
|
||||||
.setStatusValues(null)
|
.setStatusValues(null)
|
||||||
.setGracePeriods(null)
|
.setGracePeriods(null)
|
||||||
.setDeletePollMessage(null)
|
.setDeletePollMessage(null)
|
||||||
.setAutorenewBillingEvent(Ref.create(autorenewEvent))
|
.setAutorenewBillingEvent(Key.create(autorenewEvent))
|
||||||
.setAutorenewPollMessage(Ref.create(autorenewPollMessage))
|
.setAutorenewPollMessage(Key.create(autorenewPollMessage))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.FluentIterable;
|
import com.google.common.collect.FluentIterable;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.flows.EppException;
|
import google.registry.flows.EppException;
|
||||||
import google.registry.flows.ResourceTransferApproveFlow;
|
import google.registry.flows.ResourceTransferApproveFlow;
|
||||||
import google.registry.model.billing.BillingEvent;
|
import google.registry.model.billing.BillingEvent;
|
||||||
|
@ -127,8 +127,8 @@ public class DomainTransferApproveFlow extends
|
||||||
ofy().save().entity(gainingClientAutorenewPollMessage);
|
ofy().save().entity(gainingClientAutorenewPollMessage);
|
||||||
builder
|
builder
|
||||||
.setRegistrationExpirationTime(newExpirationTime)
|
.setRegistrationExpirationTime(newExpirationTime)
|
||||||
.setAutorenewBillingEvent(Ref.create(autorenewEvent))
|
.setAutorenewBillingEvent(Key.create(autorenewEvent))
|
||||||
.setAutorenewPollMessage(Ref.create(gainingClientAutorenewPollMessage))
|
.setAutorenewPollMessage(Key.create(gainingClientAutorenewPollMessage))
|
||||||
// Remove all the old grace periods and add a new one for the transfer.
|
// Remove all the old grace periods and add a new one for the transfer.
|
||||||
.setGracePeriods(ImmutableSet.of(
|
.setGracePeriods(ImmutableSet.of(
|
||||||
GracePeriod.forBillingEvent(GracePeriodStatus.TRANSFER, billingEvent)));
|
GracePeriod.forBillingEvent(GracePeriodStatus.TRANSFER, billingEvent)));
|
||||||
|
|
|
@ -28,7 +28,6 @@ import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import google.registry.flows.EppException;
|
import google.registry.flows.EppException;
|
||||||
import google.registry.flows.ResourceTransferRequestFlow;
|
import google.registry.flows.ResourceTransferRequestFlow;
|
||||||
import google.registry.model.billing.BillingEvent;
|
import google.registry.model.billing.BillingEvent;
|
||||||
|
@ -174,9 +173,9 @@ public class DomainTransferRequestFlow
|
||||||
@Override
|
@Override
|
||||||
protected void setTransferDataProperties(TransferData.Builder builder) {
|
protected void setTransferDataProperties(TransferData.Builder builder) {
|
||||||
builder
|
builder
|
||||||
.setServerApproveBillingEvent(Ref.create(transferBillingEvent))
|
.setServerApproveBillingEvent(Key.create(transferBillingEvent))
|
||||||
.setServerApproveAutorenewEvent(Ref.create(gainingClientAutorenewEvent))
|
.setServerApproveAutorenewEvent(Key.create(gainingClientAutorenewEvent))
|
||||||
.setServerApproveAutorenewPollMessage(Ref.create(gainingClientAutorenewPollMessage))
|
.setServerApproveAutorenewPollMessage(Key.create(gainingClientAutorenewPollMessage))
|
||||||
.setExtendedRegistrationYears(command.getPeriod().getValue());
|
.setExtendedRegistrationYears(command.getPeriod().getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,7 +207,7 @@ public class DomainTransferRequestFlow
|
||||||
.setClientId(existingResource.getCurrentSponsorClientId())
|
.setClientId(existingResource.getCurrentSponsorClientId())
|
||||||
.setEventTime(automaticTransferTime)
|
.setEventTime(automaticTransferTime)
|
||||||
.setBillingTime(expirationTime.plus(registry.getAutoRenewGracePeriodLength()))
|
.setBillingTime(expirationTime.plus(registry.getAutoRenewGracePeriodLength()))
|
||||||
.setRecurringEventRef(existingResource.getAutorenewBillingEvent())
|
.setRecurringEventKey(existingResource.getAutorenewBillingEvent())
|
||||||
.setParent(historyEntry)
|
.setParent(historyEntry)
|
||||||
.build();
|
.build();
|
||||||
ofy().save().entity(autorenewCancellation);
|
ofy().save().entity(autorenewCancellation);
|
||||||
|
|
|
@ -109,7 +109,7 @@ public class DomainUpdateFlow extends BaseDomainUpdateFlow<DomainResource, Build
|
||||||
// occur at the same time as the sunrush add grace period, as the event time will differ
|
// occur at the same time as the sunrush add grace period, as the event time will differ
|
||||||
// between them.
|
// between them.
|
||||||
BillingEvent.OneTime originalAddEvent =
|
BillingEvent.OneTime originalAddEvent =
|
||||||
sunrushAddGracePeriod.get().getOneTimeBillingEvent().get();
|
ofy().load().key(sunrushAddGracePeriod.get().getOneTimeBillingEvent()).now();
|
||||||
BillingEvent.OneTime billingEvent = new BillingEvent.OneTime.Builder()
|
BillingEvent.OneTime billingEvent = new BillingEvent.OneTime.Builder()
|
||||||
.setReason(Reason.CREATE)
|
.setReason(Reason.CREATE)
|
||||||
.setTargetId(targetId)
|
.setTargetId(targetId)
|
||||||
|
|
|
@ -23,7 +23,7 @@ import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static google.registry.util.CollectionUtils.isNullOrEmpty;
|
import static google.registry.util.CollectionUtils.isNullOrEmpty;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.dns.DnsQueue;
|
import google.registry.dns.DnsQueue;
|
||||||
import google.registry.flows.EppException;
|
import google.registry.flows.EppException;
|
||||||
import google.registry.flows.EppException.ParameterValueRangeErrorException;
|
import google.registry.flows.EppException.ParameterValueRangeErrorException;
|
||||||
|
@ -64,7 +64,7 @@ public class HostCreateFlow extends ResourceCreateFlow<HostResource, Builder, Cr
|
||||||
* to the actual object creation, which is why this class looks up and stores the superordinate
|
* to the actual object creation, which is why this class looks up and stores the superordinate
|
||||||
* domain ahead of time.
|
* domain ahead of time.
|
||||||
*/
|
*/
|
||||||
private Optional<Ref<DomainResource>> superordinateDomain;
|
private Optional<Key<DomainResource>> superordinateDomain;
|
||||||
|
|
||||||
@Inject HostCreateFlow() {}
|
@Inject HostCreateFlow() {}
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ public class HostCreateFlow extends ResourceCreateFlow<HostResource, Builder, Cr
|
||||||
@Override
|
@Override
|
||||||
protected void modifyCreateRelatedResources() {
|
protected void modifyCreateRelatedResources() {
|
||||||
if (superordinateDomain.isPresent()) {
|
if (superordinateDomain.isPresent()) {
|
||||||
ofy().save().entity(superordinateDomain.get().get().asBuilder()
|
ofy().save().entity(ofy().load().key(superordinateDomain.get()).now().asBuilder()
|
||||||
.addSubordinateHost(command.getFullyQualifiedHostName())
|
.addSubordinateHost(command.getFullyQualifiedHostName())
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import google.registry.config.RegistryEnvironment;
|
import google.registry.config.RegistryEnvironment;
|
||||||
import google.registry.flows.EppException;
|
import google.registry.flows.EppException;
|
||||||
import google.registry.flows.ResourceAsyncDeleteFlow;
|
import google.registry.flows.ResourceAsyncDeleteFlow;
|
||||||
|
@ -51,7 +50,7 @@ public class HostDeleteFlow extends ResourceAsyncDeleteFlow<HostResource, Builde
|
||||||
@Inject HostDeleteFlow() {}
|
@Inject HostDeleteFlow() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isLinkedForFailfast(final Ref<HostResource> ref) {
|
protected boolean isLinkedForFailfast(final Key<HostResource> key) {
|
||||||
// Query for the first few linked domains, and if found, actually load them. The query is
|
// Query for the first few linked domains, and if found, actually load them. The query is
|
||||||
// eventually consistent and so might be very stale, but the direct load will not be stale,
|
// eventually consistent and so might be very stale, but the direct load will not be stale,
|
||||||
// just non-transactional. If we find at least one actual reference then we can reliably
|
// just non-transactional. If we find at least one actual reference then we can reliably
|
||||||
|
@ -59,11 +58,11 @@ public class HostDeleteFlow extends ResourceAsyncDeleteFlow<HostResource, Builde
|
||||||
return Iterables.any(
|
return Iterables.any(
|
||||||
ofy().load().keys(
|
ofy().load().keys(
|
||||||
queryDomainsUsingResource(
|
queryDomainsUsingResource(
|
||||||
HostResource.class, ref, now, FAILFAST_CHECK_COUNT)).values(),
|
HostResource.class, key, now, FAILFAST_CHECK_COUNT)).values(),
|
||||||
new Predicate<DomainBase>() {
|
new Predicate<DomainBase>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(DomainBase domain) {
|
public boolean apply(DomainBase domain) {
|
||||||
return domain.getNameservers().contains(ref);
|
return domain.getNameservers().contains(key);
|
||||||
}});
|
}});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,13 +16,14 @@ package google.registry.flows.host;
|
||||||
|
|
||||||
import static google.registry.model.EppResourceUtils.isActive;
|
import static google.registry.model.EppResourceUtils.isActive;
|
||||||
import static google.registry.model.EppResourceUtils.loadByUniqueId;
|
import static google.registry.model.EppResourceUtils.loadByUniqueId;
|
||||||
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static google.registry.model.registry.Registries.findTldForName;
|
import static google.registry.model.registry.Registries.findTldForName;
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.net.InternetDomainName;
|
import com.google.common.net.InternetDomainName;
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.flows.EppException;
|
import google.registry.flows.EppException;
|
||||||
import google.registry.flows.EppException.AuthorizationErrorException;
|
import google.registry.flows.EppException.AuthorizationErrorException;
|
||||||
import google.registry.flows.EppException.ObjectDoesNotExistException;
|
import google.registry.flows.EppException.ObjectDoesNotExistException;
|
||||||
|
@ -75,7 +76,7 @@ public class HostFlowUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return the {@link DomainResource} this host is subordinate to, or null for external hosts. */
|
/** Return the {@link DomainResource} this host is subordinate to, or null for external hosts. */
|
||||||
static Ref<DomainResource> lookupSuperordinateDomain(
|
static Key<DomainResource> lookupSuperordinateDomain(
|
||||||
InternetDomainName hostName, DateTime now) throws EppException {
|
InternetDomainName hostName, DateTime now) throws EppException {
|
||||||
Optional<InternetDomainName> tldParsed = findTldForName(hostName);
|
Optional<InternetDomainName> tldParsed = findTldForName(hostName);
|
||||||
if (!tldParsed.isPresent()) {
|
if (!tldParsed.isPresent()) {
|
||||||
|
@ -91,7 +92,7 @@ public class HostFlowUtils {
|
||||||
if (superordinateDomain == null || !isActive(superordinateDomain, now)) {
|
if (superordinateDomain == null || !isActive(superordinateDomain, now)) {
|
||||||
throw new SuperordinateDomainDoesNotExistException(domainName);
|
throw new SuperordinateDomainDoesNotExistException(domainName);
|
||||||
}
|
}
|
||||||
return Ref.create(superordinateDomain);
|
return Key.create(superordinateDomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Superordinate domain for this hostname does not exist. */
|
/** Superordinate domain for this hostname does not exist. */
|
||||||
|
@ -103,10 +104,11 @@ public class HostFlowUtils {
|
||||||
|
|
||||||
/** Ensure that the superordinate domain is sponsored by the provided clientId. */
|
/** Ensure that the superordinate domain is sponsored by the provided clientId. */
|
||||||
static void verifyDomainIsSameRegistrar(
|
static void verifyDomainIsSameRegistrar(
|
||||||
Ref<DomainResource> superordinateDomain,
|
Key<DomainResource> superordinateDomain,
|
||||||
String clientId) throws EppException {
|
String clientId) throws EppException {
|
||||||
if (superordinateDomain != null
|
if (superordinateDomain != null
|
||||||
&& !clientId.equals(superordinateDomain.get().getCurrentSponsorClientId())) {
|
&& !clientId.equals(
|
||||||
|
ofy().load().key(superordinateDomain).now().getCurrentSponsorClientId())) {
|
||||||
throw new HostDomainNotOwnedException();
|
throw new HostDomainNotOwnedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,13 +18,12 @@ import static com.google.common.base.MoreObjects.firstNonNull;
|
||||||
import static google.registry.flows.host.HostFlowUtils.lookupSuperordinateDomain;
|
import static google.registry.flows.host.HostFlowUtils.lookupSuperordinateDomain;
|
||||||
import static google.registry.flows.host.HostFlowUtils.validateHostName;
|
import static google.registry.flows.host.HostFlowUtils.validateHostName;
|
||||||
import static google.registry.flows.host.HostFlowUtils.verifyDomainIsSameRegistrar;
|
import static google.registry.flows.host.HostFlowUtils.verifyDomainIsSameRegistrar;
|
||||||
import static google.registry.model.index.ForeignKeyIndex.loadAndGetReference;
|
import static google.registry.model.index.ForeignKeyIndex.loadAndGetKey;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static google.registry.util.CollectionUtils.isNullOrEmpty;
|
import static google.registry.util.CollectionUtils.isNullOrEmpty;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import google.registry.dns.DnsQueue;
|
import google.registry.dns.DnsQueue;
|
||||||
import google.registry.flows.EppException;
|
import google.registry.flows.EppException;
|
||||||
import google.registry.flows.EppException.ObjectAlreadyExistsException;
|
import google.registry.flows.EppException.ObjectAlreadyExistsException;
|
||||||
|
@ -63,7 +62,7 @@ import org.joda.time.Duration;
|
||||||
*/
|
*/
|
||||||
public class HostUpdateFlow extends ResourceUpdateFlow<HostResource, Builder, Update> {
|
public class HostUpdateFlow extends ResourceUpdateFlow<HostResource, Builder, Update> {
|
||||||
|
|
||||||
private Ref<DomainResource> superordinateDomain;
|
private Key<DomainResource> superordinateDomain;
|
||||||
|
|
||||||
private String oldHostName;
|
private String oldHostName;
|
||||||
private String newHostName;
|
private String newHostName;
|
||||||
|
@ -85,7 +84,7 @@ public class HostUpdateFlow extends ResourceUpdateFlow<HostResource, Builder, Up
|
||||||
protected void verifyUpdateIsAllowed() throws EppException {
|
protected void verifyUpdateIsAllowed() throws EppException {
|
||||||
verifyDomainIsSameRegistrar(superordinateDomain, getClientId());
|
verifyDomainIsSameRegistrar(superordinateDomain, getClientId());
|
||||||
if (isHostRename
|
if (isHostRename
|
||||||
&& loadAndGetReference(HostResource.class, newHostName, now) != null) {
|
&& loadAndGetKey(HostResource.class, newHostName, now) != null) {
|
||||||
throw new HostAlreadyExistsException(newHostName);
|
throw new HostAlreadyExistsException(newHostName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,24 +169,25 @@ public class HostUpdateFlow extends ResourceUpdateFlow<HostResource, Builder, Up
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSuperordinateDomains() {
|
private void updateSuperordinateDomains() {
|
||||||
Ref<DomainResource> oldSuperordinateDomain = existingResource.getSuperordinateDomain();
|
Key<DomainResource> oldSuperordinateDomain = existingResource.getSuperordinateDomain();
|
||||||
if (oldSuperordinateDomain != null || superordinateDomain != null) {
|
if (oldSuperordinateDomain != null || superordinateDomain != null) {
|
||||||
if (Objects.equals(oldSuperordinateDomain, superordinateDomain)) {
|
if (Objects.equals(oldSuperordinateDomain, superordinateDomain)) {
|
||||||
ofy().save().entity(oldSuperordinateDomain.get().asBuilder()
|
ofy().save().entity(
|
||||||
.removeSubordinateHost(oldHostName)
|
ofy().load().key(oldSuperordinateDomain).now().asBuilder()
|
||||||
.addSubordinateHost(newHostName)
|
.removeSubordinateHost(oldHostName)
|
||||||
.build());
|
.addSubordinateHost(newHostName)
|
||||||
|
.build());
|
||||||
} else {
|
} else {
|
||||||
if (oldSuperordinateDomain != null) {
|
if (oldSuperordinateDomain != null) {
|
||||||
ofy().save().entity(
|
ofy().save().entity(
|
||||||
oldSuperordinateDomain.get()
|
ofy().load().key(oldSuperordinateDomain).now()
|
||||||
.asBuilder()
|
.asBuilder()
|
||||||
.removeSubordinateHost(oldHostName)
|
.removeSubordinateHost(oldHostName)
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
if (superordinateDomain != null) {
|
if (superordinateDomain != null) {
|
||||||
ofy().save().entity(
|
ofy().save().entity(
|
||||||
superordinateDomain.get()
|
ofy().load().key(superordinateDomain).now()
|
||||||
.asBuilder()
|
.asBuilder()
|
||||||
.addSubordinateHost(newHostName)
|
.addSubordinateHost(newHostName)
|
||||||
.build());
|
.build());
|
||||||
|
|
|
@ -14,10 +14,11 @@
|
||||||
|
|
||||||
package google.registry.mapreduce.inputs;
|
package google.registry.mapreduce.inputs;
|
||||||
|
|
||||||
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
|
|
||||||
import com.google.appengine.tools.mapreduce.InputReader;
|
import com.google.appengine.tools.mapreduce.InputReader;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import google.registry.model.EppResource;
|
import google.registry.model.EppResource;
|
||||||
import google.registry.model.index.EppResourceIndex;
|
import google.registry.model.index.EppResourceIndex;
|
||||||
import google.registry.model.index.EppResourceIndexBucket;
|
import google.registry.model.index.EppResourceIndexBucket;
|
||||||
|
@ -55,12 +56,12 @@ class EppResourceEntityReader<R extends EppResource> extends EppResourceBaseRead
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public R next() throws NoSuchElementException {
|
public R next() throws NoSuchElementException {
|
||||||
// Loop until we find a value, or nextRef() throws a NoSuchElementException.
|
// Loop until we find a value, or nextEri() throws a NoSuchElementException.
|
||||||
while (true) {
|
while (true) {
|
||||||
Ref<? extends EppResource> reference = nextEri().getReference();
|
Key<? extends EppResource> key = nextEri().getKey();
|
||||||
EppResource resource = reference.get();
|
EppResource resource = ofy().load().key(key).now();
|
||||||
if (resource == null) {
|
if (resource == null) {
|
||||||
logger.severefmt("Broken ERI reference: %s", reference.getKey());
|
logger.severefmt("EppResourceIndex key %s points at a missing resource", key);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Postfilter to distinguish polymorphic types (e.g. DomainBase and DomainResource).
|
// Postfilter to distinguish polymorphic types (e.g. DomainBase and DomainResource).
|
||||||
|
|
|
@ -49,6 +49,6 @@ class EppResourceKeyReader<R extends EppResource> extends EppResourceBaseReader<
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public Key<R> next() throws NoSuchElementException {
|
public Key<R> next() throws NoSuchElementException {
|
||||||
// This is a safe cast because we filtered on kind inside the query.
|
// This is a safe cast because we filtered on kind inside the query.
|
||||||
return (Key<R>) nextEri().getReference().getKey();
|
return (Key<R>) nextEri().getKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.ImmutableSortedMap;
|
import com.google.common.collect.ImmutableSortedMap;
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.annotation.Id;
|
import com.googlecode.objectify.annotation.Id;
|
||||||
import com.googlecode.objectify.annotation.Index;
|
import com.googlecode.objectify.annotation.Index;
|
||||||
import google.registry.model.eppcommon.StatusValue;
|
import google.registry.model.eppcommon.StatusValue;
|
||||||
|
@ -129,7 +129,7 @@ public abstract class EppResource extends BackupGroupRoot implements Buildable,
|
||||||
* @see google.registry.model.translators.CommitLogRevisionsTranslatorFactory
|
* @see google.registry.model.translators.CommitLogRevisionsTranslatorFactory
|
||||||
*/
|
*/
|
||||||
@XmlTransient
|
@XmlTransient
|
||||||
ImmutableSortedMap<DateTime, Ref<CommitLogManifest>> revisions = ImmutableSortedMap.of();
|
ImmutableSortedMap<DateTime, Key<CommitLogManifest>> revisions = ImmutableSortedMap.of();
|
||||||
|
|
||||||
public final String getRepoId() {
|
public final String getRepoId() {
|
||||||
return repoId;
|
return repoId;
|
||||||
|
@ -178,7 +178,7 @@ public abstract class EppResource extends BackupGroupRoot implements Buildable,
|
||||||
return deletionTime;
|
return deletionTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImmutableSortedMap<DateTime, Ref<CommitLogManifest>> getRevisions() {
|
public ImmutableSortedMap<DateTime, Key<CommitLogManifest>> getRevisions() {
|
||||||
return nullToEmptyImmutableCopy(revisions);
|
return nullToEmptyImmutableCopy(revisions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ package google.registry.model;
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.collect.Iterables.transform;
|
import static com.google.common.collect.Iterables.transform;
|
||||||
import static google.registry.model.RoidSuffixes.getRoidSuffixForTld;
|
import static google.registry.model.RoidSuffixes.getRoidSuffixForTld;
|
||||||
import static google.registry.model.index.ForeignKeyIndex.loadAndGetReference;
|
import static google.registry.model.index.ForeignKeyIndex.loadAndGetKey;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static google.registry.util.DateTimeUtils.isAtOrAfter;
|
import static google.registry.util.DateTimeUtils.isAtOrAfter;
|
||||||
import static google.registry.util.DateTimeUtils.isBeforeOrAt;
|
import static google.registry.util.DateTimeUtils.isBeforeOrAt;
|
||||||
|
@ -25,7 +25,6 @@ import static google.registry.util.DateTimeUtils.latestOf;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import com.googlecode.objectify.Result;
|
import com.googlecode.objectify.Result;
|
||||||
import com.googlecode.objectify.util.ResultNow;
|
import com.googlecode.objectify.util.ResultNow;
|
||||||
import google.registry.config.RegistryEnvironment;
|
import google.registry.config.RegistryEnvironment;
|
||||||
|
@ -98,20 +97,20 @@ public final class EppResourceUtils {
|
||||||
*/
|
*/
|
||||||
public static <T extends EppResource> T loadByUniqueId(
|
public static <T extends EppResource> T loadByUniqueId(
|
||||||
Class<T> clazz, String foreignKey, DateTime now) {
|
Class<T> clazz, String foreignKey, DateTime now) {
|
||||||
// For regular foreign-keyed resources, get the ref by loading the FKI; for domain applications,
|
// For regular foreign-keyed resources, get the key by loading the FKI; for domain applications,
|
||||||
// we can construct the ref directly, since the provided foreignKey is just the repoId.
|
// we can construct the key directly, since the provided foreignKey is just the repoId.
|
||||||
Ref<T> resourceRef = ForeignKeyedEppResource.class.isAssignableFrom(clazz)
|
Key<T> resourceKey = ForeignKeyedEppResource.class.isAssignableFrom(clazz)
|
||||||
? loadAndGetReference(clazz, foreignKey, now)
|
? loadAndGetKey(clazz, foreignKey, now)
|
||||||
: Ref.create(Key.create(null, clazz, foreignKey));
|
: Key.create(null, clazz, foreignKey);
|
||||||
if (resourceRef == null) {
|
if (resourceKey == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
T resource = resourceRef.get();
|
T resource = ofy().load().key(resourceKey).now();
|
||||||
if (resource == null
|
if (resource == null
|
||||||
// You'd think this couldn't happen, but it can. For polymorphic entities, a Ref or Key is
|
// You'd think this couldn't happen, but it can. For polymorphic entities, a Key is of
|
||||||
// of necessity a reference to the base type (since datastore doesn't have polymorphism and
|
// necessity a reference to the base type (since datastore doesn't have polymorphism and
|
||||||
// Objectify is faking it). In the non-foreign-key code path above where we directly create
|
// Objectify is faking it). In the non-foreign-key code path above where we directly create
|
||||||
// a Ref, there is no way to know whether the Ref points to an instance of the desired
|
// a Key, there is no way to know whether the Key points to an instance of the desired
|
||||||
// subclass without loading it. Due to type erasure, it gets stuffed into "resource" without
|
// subclass without loading it. Due to type erasure, it gets stuffed into "resource" without
|
||||||
// causing a ClassCastException even if it's the wrong type until you actually try to use it
|
// causing a ClassCastException even if it's the wrong type until you actually try to use it
|
||||||
// as the wrong type, at which point it blows up somewhere else in the code. Concretely,
|
// as the wrong type, at which point it blows up somewhere else in the code. Concretely,
|
||||||
|
@ -286,13 +285,13 @@ public final class EppResourceUtils {
|
||||||
private static <T extends EppResource> Result<T> loadMostRecentRevisionAtTime(
|
private static <T extends EppResource> Result<T> loadMostRecentRevisionAtTime(
|
||||||
final T resource, final DateTime timestamp) {
|
final T resource, final DateTime timestamp) {
|
||||||
final Key<T> resourceKey = Key.create(resource);
|
final Key<T> resourceKey = Key.create(resource);
|
||||||
final Ref<CommitLogManifest> revision = findMostRecentRevisionAtTime(resource, timestamp);
|
final Key<CommitLogManifest> revision = findMostRecentRevisionAtTime(resource, timestamp);
|
||||||
if (revision == null) {
|
if (revision == null) {
|
||||||
logger.severefmt("No revision found for %s, falling back to resource.", resourceKey);
|
logger.severefmt("No revision found for %s, falling back to resource.", resourceKey);
|
||||||
return new ResultNow<>(resource);
|
return new ResultNow<>(resource);
|
||||||
}
|
}
|
||||||
final Result<CommitLogMutation> mutationResult =
|
final Result<CommitLogMutation> mutationResult =
|
||||||
ofy().load().key(CommitLogMutation.createKey(revision.getKey(), resourceKey));
|
ofy().load().key(CommitLogMutation.createKey(revision, resourceKey));
|
||||||
return new Result<T>() {
|
return new Result<T>() {
|
||||||
@Override
|
@Override
|
||||||
public T now() {
|
public T now() {
|
||||||
|
@ -310,10 +309,10 @@ public final class EppResourceUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private static <T extends EppResource> Ref<CommitLogManifest>
|
private static <T extends EppResource> Key<CommitLogManifest>
|
||||||
findMostRecentRevisionAtTime(final T resource, final DateTime timestamp) {
|
findMostRecentRevisionAtTime(final T resource, final DateTime timestamp) {
|
||||||
final Key<T> resourceKey = Key.create(resource);
|
final Key<T> resourceKey = Key.create(resource);
|
||||||
Entry<?, Ref<CommitLogManifest>> revision = resource.getRevisions().floorEntry(timestamp);
|
Entry<?, Key<CommitLogManifest>> revision = resource.getRevisions().floorEntry(timestamp);
|
||||||
if (revision != null) {
|
if (revision != null) {
|
||||||
logger.infofmt("Found revision history at %s for %s: %s", timestamp, resourceKey, revision);
|
logger.infofmt("Found revision history at %s for %s: %s", timestamp, resourceKey, revision);
|
||||||
return revision.getValue();
|
return revision.getValue();
|
||||||
|
@ -336,19 +335,19 @@ public final class EppResourceUtils {
|
||||||
* <p>This is an eventually consistent query.
|
* <p>This is an eventually consistent query.
|
||||||
*
|
*
|
||||||
* @param clazz the referent type (contact or host)
|
* @param clazz the referent type (contact or host)
|
||||||
* @param ref the referent key
|
* @param key the referent key
|
||||||
* @param now the logical time of the check
|
* @param now the logical time of the check
|
||||||
* @param limit max number of keys to return
|
* @param limit max number of keys to return
|
||||||
*/
|
*/
|
||||||
public static List<Key<DomainBase>> queryDomainsUsingResource(
|
public static List<Key<DomainBase>> queryDomainsUsingResource(
|
||||||
Class<? extends EppResource> clazz, Ref<? extends EppResource> ref, DateTime now, int limit) {
|
Class<? extends EppResource> clazz, Key<? extends EppResource> key, DateTime now, int limit) {
|
||||||
checkArgument(ContactResource.class.equals(clazz) || HostResource.class.equals(clazz));
|
checkArgument(ContactResource.class.equals(clazz) || HostResource.class.equals(clazz));
|
||||||
return ofy().load().type(DomainBase.class)
|
return ofy().load().type(DomainBase.class)
|
||||||
.filter(
|
.filter(
|
||||||
clazz.equals(ContactResource.class)
|
clazz.equals(ContactResource.class)
|
||||||
? "allContacts.contactId.linked"
|
? "allContacts.contactId.linked"
|
||||||
: "nameservers.linked",
|
: "nameservers.linked",
|
||||||
ref)
|
key)
|
||||||
.filter("deletionTime >", now)
|
.filter("deletionTime >", now)
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
.keys()
|
.keys()
|
||||||
|
@ -358,7 +357,7 @@ public final class EppResourceUtils {
|
||||||
/** Clone a contact or host with an eventually-consistent notion of LINKED. */
|
/** Clone a contact or host with an eventually-consistent notion of LINKED. */
|
||||||
public static EppResource cloneResourceWithLinkedStatus(EppResource resource, DateTime now) {
|
public static EppResource cloneResourceWithLinkedStatus(EppResource resource, DateTime now) {
|
||||||
Builder<?, ?> builder = resource.asBuilder();
|
Builder<?, ?> builder = resource.asBuilder();
|
||||||
if (queryDomainsUsingResource(resource.getClass(), Ref.create(resource), now, 1).isEmpty()) {
|
if (queryDomainsUsingResource(resource.getClass(), Key.create(resource), now, 1).isEmpty()) {
|
||||||
builder.removeStatusValue(StatusValue.LINKED);
|
builder.removeStatusValue(StatusValue.LINKED);
|
||||||
} else {
|
} else {
|
||||||
builder.addStatusValue(StatusValue.LINKED);
|
builder.addStatusValue(StatusValue.LINKED);
|
||||||
|
|
|
@ -17,6 +17,7 @@ package google.registry.model;
|
||||||
import static com.google.common.base.Functions.identity;
|
import static com.google.common.base.Functions.identity;
|
||||||
import static com.google.common.collect.Iterables.transform;
|
import static com.google.common.collect.Iterables.transform;
|
||||||
import static com.google.common.collect.Maps.transformValues;
|
import static com.google.common.collect.Maps.transformValues;
|
||||||
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static java.lang.annotation.ElementType.TYPE;
|
import static java.lang.annotation.ElementType.TYPE;
|
||||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||||
|
|
||||||
|
@ -24,7 +25,7 @@ import com.google.common.base.Function;
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import com.google.common.collect.FluentIterable;
|
import com.google.common.collect.FluentIterable;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.annotation.Ignore;
|
import com.googlecode.objectify.annotation.Ignore;
|
||||||
import google.registry.model.domain.ReferenceUnion;
|
import google.registry.model.domain.ReferenceUnion;
|
||||||
import java.lang.annotation.Documented;
|
import java.lang.annotation.Documented;
|
||||||
|
@ -109,18 +110,16 @@ public abstract class ImmutableObject implements Cloneable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Similar to toString(), with a full expansion of embedded ImmutableObjects,
|
* Similar to toString(), with a full expansion of embedded ImmutableObjects,
|
||||||
* collections, and references.
|
* collections, and referenced keys.
|
||||||
*/
|
*/
|
||||||
public String toHydratedString() {
|
public String toHydratedString() {
|
||||||
return toStringHelper(new Function<Object, Object>() {
|
return toStringHelper(new Function<Object, Object>() {
|
||||||
@Override
|
@Override
|
||||||
public Object apply(Object input) {
|
public Object apply(Object input) {
|
||||||
if (input instanceof ReferenceUnion) {
|
if (input instanceof ReferenceUnion) {
|
||||||
return apply(((ReferenceUnion<?>) input).getLinked().get());
|
return apply(((ReferenceUnion<?>) input).getLinked());
|
||||||
} else if (input instanceof Ref) {
|
} else if (input instanceof Key) {
|
||||||
// Only follow references of type Ref, not of type Key (the latter deliberately used for
|
Object target = ofy().load().key((Key<?>) input).now();
|
||||||
// references that should not be followed)
|
|
||||||
Object target = ((Ref<?>) input).get();
|
|
||||||
return target != null && target.getClass().isAnnotationPresent(DoNotHydrate.class)
|
return target != null && target.getClass().isAnnotationPresent(DoNotHydrate.class)
|
||||||
? input
|
? input
|
||||||
: apply(target);
|
: apply(target);
|
||||||
|
|
|
@ -39,7 +39,6 @@ import com.google.common.collect.ImmutableSortedMap;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Ordering;
|
import com.google.common.collect.Ordering;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import com.googlecode.objectify.annotation.Id;
|
import com.googlecode.objectify.annotation.Id;
|
||||||
import com.googlecode.objectify.annotation.Ignore;
|
import com.googlecode.objectify.annotation.Ignore;
|
||||||
import com.googlecode.objectify.annotation.Parent;
|
import com.googlecode.objectify.annotation.Parent;
|
||||||
|
@ -159,12 +158,12 @@ public class ModelUtils {
|
||||||
|
|
||||||
// If the field's type is the same as the field's class object, then it's a non-parameterized
|
// If the field's type is the same as the field's class object, then it's a non-parameterized
|
||||||
// type, and thus we just add it directly. We also don't bother looking at the parameterized
|
// type, and thus we just add it directly. We also don't bother looking at the parameterized
|
||||||
// types of Key and Ref objects, since they are just references to other objects and don't
|
// types of Key objects, since they are just references to other objects and don't actually
|
||||||
// actual embed themselves in the persisted object anyway.
|
// embed themselves in the persisted object anyway.
|
||||||
Class<?> fieldClazz = field.getType();
|
Class<?> fieldClazz = field.getType();
|
||||||
Type fieldType = field.getGenericType();
|
Type fieldType = field.getGenericType();
|
||||||
builder.add(fieldClazz);
|
builder.add(fieldClazz);
|
||||||
if (fieldType.equals(fieldClazz) || Ref.class.equals(clazz) || Key.class.equals(clazz)) {
|
if (fieldType.equals(fieldClazz) || Key.class.equals(clazz)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ import static com.google.common.base.MoreObjects.firstNonNull;
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
|
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
|
||||||
import static google.registry.util.CollectionUtils.union;
|
import static google.registry.util.CollectionUtils.union;
|
||||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||||
|
@ -27,7 +28,6 @@ import com.google.common.collect.ImmutableMap;
|
||||||
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 com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import com.googlecode.objectify.annotation.Entity;
|
import com.googlecode.objectify.annotation.Entity;
|
||||||
import com.googlecode.objectify.annotation.Id;
|
import com.googlecode.objectify.annotation.Id;
|
||||||
import com.googlecode.objectify.annotation.IgnoreSave;
|
import com.googlecode.objectify.annotation.IgnoreSave;
|
||||||
|
@ -410,19 +410,27 @@ public abstract class BillingEvent extends ImmutableObject
|
||||||
@Index
|
@Index
|
||||||
DateTime billingTime;
|
DateTime billingTime;
|
||||||
|
|
||||||
/** The one-time billing event to cancel, or null for autorenew cancellations. */
|
/**
|
||||||
|
* The one-time billing event to cancel, or null for autorenew cancellations.
|
||||||
|
*
|
||||||
|
* <p>Although the type is {@link Key} the name "ref" is preserved for historical reasons.
|
||||||
|
*/
|
||||||
@IgnoreSave(IfNull.class)
|
@IgnoreSave(IfNull.class)
|
||||||
Ref<BillingEvent.OneTime> refOneTime = null;
|
Key<BillingEvent.OneTime> refOneTime = null;
|
||||||
|
|
||||||
/** The recurring billing event to cancel, or null for non-autorenew cancellations. */
|
/**
|
||||||
|
* The recurring billing event to cancel, or null for non-autorenew cancellations.
|
||||||
|
*
|
||||||
|
* <p>Although the type is {@link Key} the name "ref" is preserved for historical reasons.
|
||||||
|
*/
|
||||||
@IgnoreSave(IfNull.class)
|
@IgnoreSave(IfNull.class)
|
||||||
Ref<BillingEvent.Recurring> refRecurring = null;
|
Key<BillingEvent.Recurring> refRecurring = null;
|
||||||
|
|
||||||
public DateTime getBillingTime() {
|
public DateTime getBillingTime() {
|
||||||
return billingTime;
|
return billingTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ref<? extends BillingEvent> getEventRef() {
|
public Key<? extends BillingEvent> getEventKey() {
|
||||||
return firstNonNull(refOneTime, refRecurring);
|
return firstNonNull(refOneTime, refRecurring);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,9 +462,9 @@ public abstract class BillingEvent extends ImmutableObject
|
||||||
.setParent(historyEntry);
|
.setParent(historyEntry);
|
||||||
// Set the grace period's billing event using the appropriate Cancellation builder method.
|
// Set the grace period's billing event using the appropriate Cancellation builder method.
|
||||||
if (gracePeriod.getOneTimeBillingEvent() != null) {
|
if (gracePeriod.getOneTimeBillingEvent() != null) {
|
||||||
builder.setOneTimeEventRef(gracePeriod.getOneTimeBillingEvent());
|
builder.setOneTimeEventKey(gracePeriod.getOneTimeBillingEvent());
|
||||||
} else if (gracePeriod.getRecurringBillingEvent() != null) {
|
} else if (gracePeriod.getRecurringBillingEvent() != null) {
|
||||||
builder.setRecurringEventRef(gracePeriod.getRecurringBillingEvent());
|
builder.setRecurringEventKey(gracePeriod.getRecurringBillingEvent());
|
||||||
}
|
}
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
@ -480,13 +488,13 @@ public abstract class BillingEvent extends ImmutableObject
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setOneTimeEventRef(Ref<BillingEvent.OneTime> eventRef) {
|
public Builder setOneTimeEventKey(Key<BillingEvent.OneTime> eventKey) {
|
||||||
getInstance().refOneTime = eventRef;
|
getInstance().refOneTime = eventKey;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setRecurringEventRef(Ref<BillingEvent.Recurring> eventRef) {
|
public Builder setRecurringEventKey(Key<BillingEvent.Recurring> eventKey) {
|
||||||
getInstance().refRecurring = eventRef;
|
getInstance().refRecurring = eventKey;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,7 +504,7 @@ public abstract class BillingEvent extends ImmutableObject
|
||||||
checkNotNull(instance.billingTime);
|
checkNotNull(instance.billingTime);
|
||||||
checkNotNull(instance.reason);
|
checkNotNull(instance.reason);
|
||||||
checkState((instance.refOneTime == null) != (instance.refRecurring == null),
|
checkState((instance.refOneTime == null) != (instance.refRecurring == null),
|
||||||
"Cancellations must have exactly one billing event ref set");
|
"Cancellations must have exactly one billing event key set");
|
||||||
return super.build();
|
return super.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -512,7 +520,7 @@ public abstract class BillingEvent extends ImmutableObject
|
||||||
Money cost;
|
Money cost;
|
||||||
|
|
||||||
/** The one-time billing event to modify. */
|
/** The one-time billing event to modify. */
|
||||||
Ref<BillingEvent.OneTime> eventRef;
|
Key<BillingEvent.OneTime> eventRef;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of the modification (and presumably why it was issued). This text may appear as a
|
* Description of the modification (and presumably why it was issued). This text may appear as a
|
||||||
|
@ -524,7 +532,7 @@ public abstract class BillingEvent extends ImmutableObject
|
||||||
return cost;
|
return cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ref<BillingEvent.OneTime> getEventRef() {
|
public Key<BillingEvent.OneTime> getEventKey() {
|
||||||
return eventRef;
|
return eventRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -551,7 +559,7 @@ public abstract class BillingEvent extends ImmutableObject
|
||||||
.setFlags(billingEvent.getFlags())
|
.setFlags(billingEvent.getFlags())
|
||||||
.setReason(billingEvent.getReason())
|
.setReason(billingEvent.getReason())
|
||||||
.setTargetId(billingEvent.getTargetId())
|
.setTargetId(billingEvent.getTargetId())
|
||||||
.setEventRef(Ref.create(billingEvent))
|
.setEventKey(Key.create(billingEvent))
|
||||||
.setEventTime(historyEntry.getModificationTime())
|
.setEventTime(historyEntry.getModificationTime())
|
||||||
.setDescription(description)
|
.setDescription(description)
|
||||||
.setCost(billingEvent.getCost().negated())
|
.setCost(billingEvent.getCost().negated())
|
||||||
|
@ -573,8 +581,8 @@ public abstract class BillingEvent extends ImmutableObject
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setEventRef(Ref<BillingEvent.OneTime> eventRef) {
|
public Builder setEventKey(Key<BillingEvent.OneTime> eventKey) {
|
||||||
getInstance().eventRef = eventRef;
|
getInstance().eventRef = eventKey;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -589,7 +597,7 @@ public abstract class BillingEvent extends ImmutableObject
|
||||||
Modification instance = getInstance();
|
Modification instance = getInstance();
|
||||||
checkNotNull(instance.reason);
|
checkNotNull(instance.reason);
|
||||||
checkNotNull(instance.eventRef);
|
checkNotNull(instance.eventRef);
|
||||||
BillingEvent.OneTime billingEvent = instance.eventRef.get();
|
BillingEvent.OneTime billingEvent = ofy().load().key(instance.eventRef).now();
|
||||||
checkArgument(Objects.equals(
|
checkArgument(Objects.equals(
|
||||||
instance.cost.getCurrencyUnit(),
|
instance.cost.getCurrencyUnit(),
|
||||||
billingEvent.cost.getCurrencyUnit()),
|
billingEvent.cost.getCurrencyUnit()),
|
||||||
|
|
|
@ -25,7 +25,7 @@ import com.google.common.collect.ComparisonChain;
|
||||||
import com.google.common.collect.FluentIterable;
|
import com.google.common.collect.FluentIterable;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Ordering;
|
import com.google.common.collect.Ordering;
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.annotation.Entity;
|
import com.googlecode.objectify.annotation.Entity;
|
||||||
import com.googlecode.objectify.annotation.Id;
|
import com.googlecode.objectify.annotation.Id;
|
||||||
import com.googlecode.objectify.annotation.Parent;
|
import com.googlecode.objectify.annotation.Parent;
|
||||||
|
@ -71,7 +71,7 @@ public final class RegistrarCredit extends ImmutableObject implements Buildable
|
||||||
|
|
||||||
/** The registrar to whom this credit belongs. */
|
/** The registrar to whom this credit belongs. */
|
||||||
@Parent
|
@Parent
|
||||||
Ref<Registrar> parent;
|
Key<Registrar> parent;
|
||||||
|
|
||||||
/** The type of credit. */
|
/** The type of credit. */
|
||||||
CreditType type;
|
CreditType type;
|
||||||
|
@ -95,7 +95,7 @@ public final class RegistrarCredit extends ImmutableObject implements Buildable
|
||||||
*/
|
*/
|
||||||
String tld;
|
String tld;
|
||||||
|
|
||||||
public Ref<Registrar> getParent() {
|
public Key<Registrar> getParent() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ public final class RegistrarCredit extends ImmutableObject implements Buildable
|
||||||
/** Returns a string representation of this credit. */
|
/** Returns a string representation of this credit. */
|
||||||
public String getSummary() {
|
public String getSummary() {
|
||||||
String fields = Joiner.on(' ').join(type, creationTime, tld);
|
String fields = Joiner.on(' ').join(type, creationTime, tld);
|
||||||
return String.format("%s (%s/%d) - %s", description, parent.getKey().getName(), id, fields);
|
return String.format("%s (%s/%d) - %s", description, parent.getName(), id, fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the default description for this {@link RegistrarCredit} instance. */
|
/** Returns the default description for this {@link RegistrarCredit} instance. */
|
||||||
|
@ -144,7 +144,7 @@ public final class RegistrarCredit extends ImmutableObject implements Buildable
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setParent(Registrar parent) {
|
public Builder setParent(Registrar parent) {
|
||||||
getInstance().parent = Ref.create(parent);
|
getInstance().parent = Key.create(parent);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,15 +27,14 @@ import com.google.common.collect.ImmutableSortedMap;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Ordering;
|
import com.google.common.collect.Ordering;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import com.googlecode.objectify.annotation.Entity;
|
import com.googlecode.objectify.annotation.Entity;
|
||||||
import com.googlecode.objectify.annotation.Id;
|
import com.googlecode.objectify.annotation.Id;
|
||||||
import com.googlecode.objectify.annotation.Parent;
|
import com.googlecode.objectify.annotation.Parent;
|
||||||
import com.googlecode.objectify.impl.ref.DeadRef;
|
|
||||||
import google.registry.model.Buildable;
|
import google.registry.model.Buildable;
|
||||||
import google.registry.model.ImmutableObject;
|
import google.registry.model.ImmutableObject;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import org.joda.money.CurrencyUnit;
|
||||||
import org.joda.money.Money;
|
import org.joda.money.Money;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
|
||||||
|
@ -58,7 +57,7 @@ public final class RegistrarCreditBalance extends ImmutableObject implements Bui
|
||||||
|
|
||||||
/** The registrar credit object for which this represents a balance. */
|
/** The registrar credit object for which this represents a balance. */
|
||||||
@Parent
|
@Parent
|
||||||
Ref<RegistrarCredit> parent;
|
Key<RegistrarCredit> parent;
|
||||||
|
|
||||||
/** The time at which this balance amount should become effective. */
|
/** The time at which this balance amount should become effective. */
|
||||||
DateTime effectiveTime;
|
DateTime effectiveTime;
|
||||||
|
@ -74,7 +73,7 @@ public final class RegistrarCreditBalance extends ImmutableObject implements Bui
|
||||||
/** The monetary amount of credit balance remaining as of the effective time. */
|
/** The monetary amount of credit balance remaining as of the effective time. */
|
||||||
Money amount;
|
Money amount;
|
||||||
|
|
||||||
public Ref<RegistrarCredit> getParent() {
|
public Key<RegistrarCredit> getParent() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,6 +96,9 @@ public final class RegistrarCreditBalance extends ImmutableObject implements Bui
|
||||||
|
|
||||||
/** A Builder for an {@link RegistrarCreditBalance}. */
|
/** A Builder for an {@link RegistrarCreditBalance}. */
|
||||||
public static class Builder extends Buildable.Builder<RegistrarCreditBalance> {
|
public static class Builder extends Buildable.Builder<RegistrarCreditBalance> {
|
||||||
|
|
||||||
|
private CurrencyUnit currency;
|
||||||
|
|
||||||
public Builder() {}
|
public Builder() {}
|
||||||
|
|
||||||
public Builder(RegistrarCreditBalance instance) {
|
public Builder(RegistrarCreditBalance instance) {
|
||||||
|
@ -104,8 +106,8 @@ public final class RegistrarCreditBalance extends ImmutableObject implements Bui
|
||||||
}
|
}
|
||||||
|
|
||||||
public RegistrarCreditBalance.Builder setParent(RegistrarCredit parent) {
|
public RegistrarCreditBalance.Builder setParent(RegistrarCredit parent) {
|
||||||
// Use a DeadRef so that we can retrieve the actual instance provided later on in build().
|
this.currency = parent.getCurrency();
|
||||||
getInstance().parent = new DeadRef<>(Key.create(parent), parent);
|
getInstance().parent = Key.create(parent);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,12 +134,11 @@ public final class RegistrarCreditBalance extends ImmutableObject implements Bui
|
||||||
checkNotNull(instance.effectiveTime);
|
checkNotNull(instance.effectiveTime);
|
||||||
checkNotNull(instance.writtenTime);
|
checkNotNull(instance.writtenTime);
|
||||||
checkNotNull(instance.amount);
|
checkNotNull(instance.amount);
|
||||||
RegistrarCredit credit = instance.parent.get();
|
|
||||||
checkState(
|
checkState(
|
||||||
instance.amount.getCurrencyUnit().equals(credit.getCurrency()),
|
instance.amount.getCurrencyUnit().equals(currency),
|
||||||
"Currency of balance amount differs from credit currency (%s vs %s)",
|
"Currency of balance amount differs from credit currency (%s vs %s)",
|
||||||
instance.amount.getCurrencyUnit(),
|
instance.amount.getCurrencyUnit(),
|
||||||
credit.getCurrency());
|
currency);
|
||||||
return super.build();
|
return super.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
package google.registry.model.domain;
|
package google.registry.model.domain;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.annotation.Embed;
|
import com.googlecode.objectify.annotation.Embed;
|
||||||
import com.googlecode.objectify.annotation.Index;
|
import com.googlecode.objectify.annotation.Index;
|
||||||
import google.registry.model.ImmutableObject;
|
import google.registry.model.ImmutableObject;
|
||||||
|
@ -48,7 +48,7 @@ public class DesignatedContact extends ImmutableObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public static DesignatedContact create(Type type, Ref<ContactResource> contact) {
|
public static DesignatedContact create(Type type, Key<ContactResource> contact) {
|
||||||
DesignatedContact instance = new DesignatedContact();
|
DesignatedContact instance = new DesignatedContact();
|
||||||
instance.type = type;
|
instance.type = type;
|
||||||
instance.contactId = ReferenceUnion.create(contact);
|
instance.contactId = ReferenceUnion.create(contact);
|
||||||
|
@ -60,14 +60,14 @@ public class DesignatedContact extends ImmutableObject {
|
||||||
|
|
||||||
@Index
|
@Index
|
||||||
@XmlValue
|
@XmlValue
|
||||||
//TODO(b/28713909): Make this a Ref<ContactResource>.
|
//TODO(b/28713909): Make this a Key<ContactResource>.
|
||||||
ReferenceUnion<ContactResource> contactId;
|
ReferenceUnion<ContactResource> contactId;
|
||||||
|
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ref<ContactResource> getContactRef() {
|
public Key<ContactResource> getContactKey() {
|
||||||
return contactId.getLinked();
|
return contactId.getLinked();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,9 @@
|
||||||
package google.registry.model.domain;
|
package google.registry.model.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
|
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.annotation.Embed;
|
import com.googlecode.objectify.annotation.Embed;
|
||||||
import google.registry.model.EppResource;
|
import google.registry.model.EppResource;
|
||||||
import google.registry.model.contact.ContactResource;
|
import google.registry.model.contact.ContactResource;
|
||||||
|
@ -38,9 +39,9 @@ public class DomainAuthInfo extends AuthInfo {
|
||||||
checkNotNull(getPw());
|
checkNotNull(getPw());
|
||||||
if (getRepoId() != null) {
|
if (getRepoId() != null) {
|
||||||
// Make sure the repo id matches one of the contacts on the domain.
|
// Make sure the repo id matches one of the contacts on the domain.
|
||||||
Ref<ContactResource> foundContact = null;
|
Key<ContactResource> foundContact = null;
|
||||||
for (Ref<ContactResource> contact : domain.getReferencedContacts()) {
|
for (Key<ContactResource> contact : domain.getReferencedContacts()) {
|
||||||
String contactRepoId = contact.getKey().getName();
|
String contactRepoId = contact.getName();
|
||||||
if (getRepoId().equals(contactRepoId)) {
|
if (getRepoId().equals(contactRepoId)) {
|
||||||
foundContact = contact;
|
foundContact = contact;
|
||||||
break;
|
break;
|
||||||
|
@ -50,7 +51,7 @@ public class DomainAuthInfo extends AuthInfo {
|
||||||
throw new BadAuthInfoException();
|
throw new BadAuthInfoException();
|
||||||
}
|
}
|
||||||
// Check if the password provided matches the password on the referenced contact.
|
// Check if the password provided matches the password on the referenced contact.
|
||||||
if (!foundContact.get().getAuthInfo().getPw().getValue().equals(
|
if (!ofy().load().key(foundContact).now().getAuthInfo().getPw().getValue().equals(
|
||||||
getPw().getValue())) {
|
getPw().getValue())) {
|
||||||
throw new BadAuthInfoException();
|
throw new BadAuthInfoException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ import com.google.common.collect.FluentIterable;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.ImmutableSortedSet;
|
import com.google.common.collect.ImmutableSortedSet;
|
||||||
import com.google.common.collect.Ordering;
|
import com.google.common.collect.Ordering;
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.annotation.Entity;
|
import com.googlecode.objectify.annotation.Entity;
|
||||||
import com.googlecode.objectify.annotation.IgnoreSave;
|
import com.googlecode.objectify.annotation.IgnoreSave;
|
||||||
import com.googlecode.objectify.annotation.Index;
|
import com.googlecode.objectify.annotation.Index;
|
||||||
|
@ -78,7 +78,7 @@ public abstract class DomainBase extends EppResource {
|
||||||
|
|
||||||
/** References to hosts that are the nameservers for the domain. */
|
/** References to hosts that are the nameservers for the domain. */
|
||||||
@XmlTransient
|
@XmlTransient
|
||||||
//TODO(b/28713909): Make this a Set<Ref<HostResource>>.
|
//TODO(b/28713909): Make this a Set<Key<HostResource>>.
|
||||||
Set<ReferenceUnion<HostResource>> nameservers;
|
Set<ReferenceUnion<HostResource>> nameservers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -149,7 +149,7 @@ public abstract class DomainBase extends EppResource {
|
||||||
public ForeignKeyedDesignatedContact apply(DesignatedContact designated) {
|
public ForeignKeyedDesignatedContact apply(DesignatedContact designated) {
|
||||||
return ForeignKeyedDesignatedContact.create(
|
return ForeignKeyedDesignatedContact.create(
|
||||||
designated.getType(),
|
designated.getType(),
|
||||||
designated.getContactRef().get().getContactId());
|
ofy().load().key(designated.getContactKey()).now().getContactId());
|
||||||
}})
|
}})
|
||||||
.toSet();
|
.toSet();
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ public abstract class DomainBase extends EppResource {
|
||||||
@XmlElement(name = "registrant")
|
@XmlElement(name = "registrant")
|
||||||
private String getMarshalledRegistrant() {
|
private String getMarshalledRegistrant() {
|
||||||
preMarshal();
|
preMarshal();
|
||||||
return getRegistrant().get().getContactId();
|
return ofy().load().key(getRegistrant()).now().getContactId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFullyQualifiedDomainName() {
|
public String getFullyQualifiedDomainName() {
|
||||||
|
@ -177,8 +177,8 @@ public abstract class DomainBase extends EppResource {
|
||||||
return idnTableName;
|
return idnTableName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImmutableSet<Ref<HostResource>> getNameservers() {
|
public ImmutableSet<Key<HostResource>> getNameservers() {
|
||||||
ImmutableSet.Builder<Ref<HostResource>> builder = new ImmutableSet.Builder<>();
|
ImmutableSet.Builder<Key<HostResource>> builder = new ImmutableSet.Builder<>();
|
||||||
for (ReferenceUnion<HostResource> union : nullToEmptyImmutableCopy(nameservers)) {
|
for (ReferenceUnion<HostResource> union : nullToEmptyImmutableCopy(nameservers)) {
|
||||||
builder.add(union.getLinked());
|
builder.add(union.getLinked());
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ public abstract class DomainBase extends EppResource {
|
||||||
|
|
||||||
/** Loads and returns the fully qualified host names of all linked nameservers. */
|
/** Loads and returns the fully qualified host names of all linked nameservers. */
|
||||||
public ImmutableSortedSet<String> loadNameserverFullyQualifiedHostNames() {
|
public ImmutableSortedSet<String> loadNameserverFullyQualifiedHostNames() {
|
||||||
return FluentIterable.from(ofy().load().refs(getNameservers()).values())
|
return FluentIterable.from(ofy().load().keys(getNameservers()).values())
|
||||||
.transform(
|
.transform(
|
||||||
new Function<HostResource, String>() {
|
new Function<HostResource, String>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -198,14 +198,14 @@ public abstract class DomainBase extends EppResource {
|
||||||
.toSortedSet(Ordering.natural());
|
.toSortedSet(Ordering.natural());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A reference to the registrant who registered this domain. */
|
/** A key to the registrant who registered this domain. */
|
||||||
public Ref<ContactResource> getRegistrant() {
|
public Key<ContactResource> getRegistrant() {
|
||||||
return FluentIterable
|
return FluentIterable
|
||||||
.from(nullToEmpty(allContacts))
|
.from(nullToEmpty(allContacts))
|
||||||
.filter(IS_REGISTRANT)
|
.filter(IS_REGISTRANT)
|
||||||
.first()
|
.first()
|
||||||
.get()
|
.get()
|
||||||
.getContactRef();
|
.getContactKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Associated contacts for the domain (other than registrant). */
|
/** Associated contacts for the domain (other than registrant). */
|
||||||
|
@ -221,11 +221,11 @@ public abstract class DomainBase extends EppResource {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns all referenced contacts from this domain or application. */
|
/** Returns all referenced contacts from this domain or application. */
|
||||||
public ImmutableSet<Ref<ContactResource>> getReferencedContacts() {
|
public ImmutableSet<Key<ContactResource>> getReferencedContacts() {
|
||||||
ImmutableSet.Builder<Ref<ContactResource>> contactsBuilder =
|
ImmutableSet.Builder<Key<ContactResource>> contactsBuilder =
|
||||||
new ImmutableSet.Builder<>();
|
new ImmutableSet.Builder<>();
|
||||||
for (DesignatedContact designated : nullToEmptyImmutableCopy(allContacts)) {
|
for (DesignatedContact designated : nullToEmptyImmutableCopy(allContacts)) {
|
||||||
contactsBuilder.add(designated.getContactRef());
|
contactsBuilder.add(designated.getContactKey());
|
||||||
}
|
}
|
||||||
return contactsBuilder.build();
|
return contactsBuilder.build();
|
||||||
}
|
}
|
||||||
|
@ -276,7 +276,7 @@ public abstract class DomainBase extends EppResource {
|
||||||
return thisCastToDerived();
|
return thisCastToDerived();
|
||||||
}
|
}
|
||||||
|
|
||||||
public B setRegistrant(Ref<ContactResource> registrant) {
|
public B setRegistrant(Key<ContactResource> registrant) {
|
||||||
// Replace the registrant contact inside allContacts.
|
// Replace the registrant contact inside allContacts.
|
||||||
getInstance().allContacts = union(
|
getInstance().allContacts = union(
|
||||||
getInstance().getContacts(),
|
getInstance().getContacts(),
|
||||||
|
@ -289,21 +289,21 @@ public abstract class DomainBase extends EppResource {
|
||||||
return thisCastToDerived();
|
return thisCastToDerived();
|
||||||
}
|
}
|
||||||
|
|
||||||
public B setNameservers(ImmutableSet<Ref<HostResource>> nameservers) {
|
public B setNameservers(ImmutableSet<Key<HostResource>> nameservers) {
|
||||||
ImmutableSet.Builder<ReferenceUnion<HostResource>> builder = new ImmutableSet.Builder<>();
|
ImmutableSet.Builder<ReferenceUnion<HostResource>> builder = new ImmutableSet.Builder<>();
|
||||||
for (Ref<HostResource> ref : nullToEmpty(nameservers)) {
|
for (Key<HostResource> key : nullToEmpty(nameservers)) {
|
||||||
builder.add(ReferenceUnion.create(ref));
|
builder.add(ReferenceUnion.create(key));
|
||||||
}
|
}
|
||||||
getInstance().nameservers = builder.build();
|
getInstance().nameservers = builder.build();
|
||||||
return thisCastToDerived();
|
return thisCastToDerived();
|
||||||
}
|
}
|
||||||
|
|
||||||
public B addNameservers(ImmutableSet<Ref<HostResource>> nameservers) {
|
public B addNameservers(ImmutableSet<Key<HostResource>> nameservers) {
|
||||||
return setNameservers(
|
return setNameservers(
|
||||||
ImmutableSet.copyOf(union(getInstance().getNameservers(), nameservers)));
|
ImmutableSet.copyOf(union(getInstance().getNameservers(), nameservers)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public B removeNameservers(ImmutableSet<Ref<HostResource>> nameservers) {
|
public B removeNameservers(ImmutableSet<Key<HostResource>> nameservers) {
|
||||||
return setNameservers(
|
return setNameservers(
|
||||||
ImmutableSet.copyOf(difference(getInstance().getNameservers(), nameservers)));
|
ImmutableSet.copyOf(difference(getInstance().getNameservers(), nameservers)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ import com.google.common.base.Function;
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
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 com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Work;
|
import com.googlecode.objectify.Work;
|
||||||
import google.registry.model.EppResource;
|
import google.registry.model.EppResource;
|
||||||
import google.registry.model.ImmutableObject;
|
import google.registry.model.ImmutableObject;
|
||||||
|
@ -83,9 +83,9 @@ public class DomainCommand {
|
||||||
@XmlElement(name = "registrant")
|
@XmlElement(name = "registrant")
|
||||||
String registrantContactId;
|
String registrantContactId;
|
||||||
|
|
||||||
/** A resolved reference to the registrant who registered this domain. */
|
/** A resolved key to the registrant who registered this domain. */
|
||||||
@XmlTransient
|
@XmlTransient
|
||||||
Ref<ContactResource> registrant;
|
Key<ContactResource> registrant;
|
||||||
|
|
||||||
/** Authorization info (aka transfer secret) of the domain. */
|
/** Authorization info (aka transfer secret) of the domain. */
|
||||||
DomainAuthInfo authInfo;
|
DomainAuthInfo authInfo;
|
||||||
|
@ -94,7 +94,7 @@ public class DomainCommand {
|
||||||
return registrantContactId;
|
return registrantContactId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ref<ContactResource> getRegistrant() {
|
public Key<ContactResource> getRegistrant() {
|
||||||
return registrant;
|
return registrant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,15 +134,15 @@ public class DomainCommand {
|
||||||
@XmlElement(name = "hostObj")
|
@XmlElement(name = "hostObj")
|
||||||
Set<String> nameserverFullyQualifiedHostNames;
|
Set<String> nameserverFullyQualifiedHostNames;
|
||||||
|
|
||||||
/** Resolved references to hosts that are the nameservers for the domain. */
|
/** Resolved keys to hosts that are the nameservers for the domain. */
|
||||||
@XmlTransient
|
@XmlTransient
|
||||||
Set<Ref<HostResource>> nameservers;
|
Set<Key<HostResource>> nameservers;
|
||||||
|
|
||||||
/** Foreign keyed associated contacts for the domain (other than registrant). */
|
/** Foreign keyed associated contacts for the domain (other than registrant). */
|
||||||
@XmlElement(name = "contact")
|
@XmlElement(name = "contact")
|
||||||
Set<ForeignKeyedDesignatedContact> foreignKeyedDesignatedContacts;
|
Set<ForeignKeyedDesignatedContact> foreignKeyedDesignatedContacts;
|
||||||
|
|
||||||
/** Resolved references to associated contacts for the domain (other than registrant). */
|
/** Resolved keys to associated contacts for the domain (other than registrant). */
|
||||||
@XmlTransient
|
@XmlTransient
|
||||||
Set<DesignatedContact> contacts;
|
Set<DesignatedContact> contacts;
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ public class DomainCommand {
|
||||||
return nullSafeImmutableCopy(nameserverFullyQualifiedHostNames);
|
return nullSafeImmutableCopy(nameserverFullyQualifiedHostNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImmutableSet<Ref<HostResource>> getNameservers() {
|
public ImmutableSet<Key<HostResource>> getNameservers() {
|
||||||
return nullSafeImmutableCopy(nameservers);
|
return nullSafeImmutableCopy(nameservers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ public class DomainCommand {
|
||||||
now);
|
now);
|
||||||
for (DesignatedContact contact : contacts) {
|
for (DesignatedContact contact : contacts) {
|
||||||
if (DesignatedContact.Type.REGISTRANT.equals(contact.getType())) {
|
if (DesignatedContact.Type.REGISTRANT.equals(contact.getType())) {
|
||||||
clone.registrant = contact.getContactRef();
|
clone.registrant = contact.getContactKey();
|
||||||
clone.contacts = forceEmptyToNull(difference(contacts, contact));
|
clone.contacts = forceEmptyToNull(difference(contacts, contact));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -373,15 +373,15 @@ public class DomainCommand {
|
||||||
@XmlElement(name = "hostObj")
|
@XmlElement(name = "hostObj")
|
||||||
Set<String> nameserverFullyQualifiedHostNames;
|
Set<String> nameserverFullyQualifiedHostNames;
|
||||||
|
|
||||||
/** Resolved references to hosts that are the nameservers for the domain. */
|
/** Resolved keys to hosts that are the nameservers for the domain. */
|
||||||
@XmlTransient
|
@XmlTransient
|
||||||
Set<Ref<HostResource>> nameservers;
|
Set<Key<HostResource>> nameservers;
|
||||||
|
|
||||||
/** Foreign keyed associated contacts for the domain (other than registrant). */
|
/** Foreign keyed associated contacts for the domain (other than registrant). */
|
||||||
@XmlElement(name = "contact")
|
@XmlElement(name = "contact")
|
||||||
Set<ForeignKeyedDesignatedContact> foreignKeyedDesignatedContacts;
|
Set<ForeignKeyedDesignatedContact> foreignKeyedDesignatedContacts;
|
||||||
|
|
||||||
/** Resolved references to associated contacts for the domain (other than registrant). */
|
/** Resolved keys to associated contacts for the domain (other than registrant). */
|
||||||
@XmlTransient
|
@XmlTransient
|
||||||
Set<DesignatedContact> contacts;
|
Set<DesignatedContact> contacts;
|
||||||
|
|
||||||
|
@ -389,7 +389,7 @@ public class DomainCommand {
|
||||||
return nullSafeImmutableCopy(nameserverFullyQualifiedHostNames);
|
return nullSafeImmutableCopy(nameserverFullyQualifiedHostNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImmutableSet<Ref<HostResource>> getNameservers() {
|
public ImmutableSet<Key<HostResource>> getNameservers() {
|
||||||
return nullToEmptyImmutableCopy(nameservers);
|
return nullToEmptyImmutableCopy(nameservers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,7 +415,7 @@ public class DomainCommand {
|
||||||
clone.registrant = clone.registrantContactId == null
|
clone.registrant = clone.registrantContactId == null
|
||||||
? null
|
? null
|
||||||
: getOnlyElement(
|
: getOnlyElement(
|
||||||
loadReferences(
|
loadByForeignKey(
|
||||||
ImmutableSet.of(clone.registrantContactId), ContactResource.class, now)
|
ImmutableSet.of(clone.registrantContactId), ContactResource.class, now)
|
||||||
.values());
|
.values());
|
||||||
return clone;
|
return clone;
|
||||||
|
@ -456,13 +456,13 @@ public class DomainCommand {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Set<Ref<HostResource>> linkHosts(
|
private static Set<Key<HostResource>> linkHosts(
|
||||||
Set<String> fullyQualifiedHostNames, DateTime now) throws InvalidReferencesException {
|
Set<String> fullyQualifiedHostNames, DateTime now) throws InvalidReferencesException {
|
||||||
if (fullyQualifiedHostNames == null) {
|
if (fullyQualifiedHostNames == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return ImmutableSet.copyOf(
|
return ImmutableSet.copyOf(
|
||||||
loadReferences(fullyQualifiedHostNames, HostResource.class, now).values());
|
loadByForeignKey(fullyQualifiedHostNames, HostResource.class, now).values());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Set<DesignatedContact> linkContacts(
|
private static Set<DesignatedContact> linkContacts(
|
||||||
|
@ -474,8 +474,8 @@ public class DomainCommand {
|
||||||
for (ForeignKeyedDesignatedContact contact : contacts) {
|
for (ForeignKeyedDesignatedContact contact : contacts) {
|
||||||
foreignKeys.add(contact.contactId);
|
foreignKeys.add(contact.contactId);
|
||||||
}
|
}
|
||||||
ImmutableMap<String, Ref<ContactResource>> loadedContacts =
|
ImmutableMap<String, Key<ContactResource>> loadedContacts =
|
||||||
loadReferences(foreignKeys.build(), ContactResource.class, now);
|
loadByForeignKey(foreignKeys.build(), ContactResource.class, now);
|
||||||
ImmutableSet.Builder<DesignatedContact> linkedContacts = new ImmutableSet.Builder<>();
|
ImmutableSet.Builder<DesignatedContact> linkedContacts = new ImmutableSet.Builder<>();
|
||||||
for (ForeignKeyedDesignatedContact contact : contacts) {
|
for (ForeignKeyedDesignatedContact contact : contacts) {
|
||||||
linkedContacts.add(DesignatedContact.create(
|
linkedContacts.add(DesignatedContact.create(
|
||||||
|
@ -484,8 +484,8 @@ public class DomainCommand {
|
||||||
return linkedContacts.build();
|
return linkedContacts.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Load references to resources by their foreign keys. */
|
/** Load keys to resources by their foreign keys. */
|
||||||
private static <T extends EppResource> ImmutableMap<String, Ref<T>> loadReferences(
|
private static <T extends EppResource> ImmutableMap<String, Key<T>> loadByForeignKey(
|
||||||
final Set<String> foreignKeys, final Class<T> clazz, final DateTime now)
|
final Set<String> foreignKeys, final Class<T> clazz, final DateTime now)
|
||||||
throws InvalidReferencesException {
|
throws InvalidReferencesException {
|
||||||
Map<String, ForeignKeyIndex<T>> fkis = ofy().doTransactionless(
|
Map<String, ForeignKeyIndex<T>> fkis = ofy().doTransactionless(
|
||||||
|
@ -500,10 +500,10 @@ public class DomainCommand {
|
||||||
}
|
}
|
||||||
return ImmutableMap.copyOf(transformValues(
|
return ImmutableMap.copyOf(transformValues(
|
||||||
fkis,
|
fkis,
|
||||||
new Function<ForeignKeyIndex<T>, Ref<T>>() {
|
new Function<ForeignKeyIndex<T>, Key<T>>() {
|
||||||
@Override
|
@Override
|
||||||
public Ref<T> apply(ForeignKeyIndex<T> fki) {
|
public Key<T> apply(ForeignKeyIndex<T> fki) {
|
||||||
return fki.getReference();
|
return fki.getResourceKey();
|
||||||
}}));
|
}}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ import static google.registry.util.DateTimeUtils.leapSafeAddYears;
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import com.googlecode.objectify.annotation.Cache;
|
import com.googlecode.objectify.annotation.Cache;
|
||||||
import com.googlecode.objectify.annotation.EntitySubclass;
|
import com.googlecode.objectify.annotation.EntitySubclass;
|
||||||
import com.googlecode.objectify.annotation.IgnoreSave;
|
import com.googlecode.objectify.annotation.IgnoreSave;
|
||||||
|
@ -112,7 +111,7 @@ public class DomainResource extends DomainBase implements ForeignKeyedEppResourc
|
||||||
* should be created, and this field should be updated to point to the new one.
|
* should be created, and this field should be updated to point to the new one.
|
||||||
*/
|
*/
|
||||||
@XmlTransient
|
@XmlTransient
|
||||||
Ref<BillingEvent.Recurring> autorenewBillingEvent;
|
Key<BillingEvent.Recurring> autorenewBillingEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The recurring poll message associated with this domain's autorenewals.
|
* The recurring poll message associated with this domain's autorenewals.
|
||||||
|
@ -123,7 +122,7 @@ public class DomainResource extends DomainBase implements ForeignKeyedEppResourc
|
||||||
* should be created, and this field should be updated to point to the new one.
|
* should be created, and this field should be updated to point to the new one.
|
||||||
*/
|
*/
|
||||||
@XmlTransient
|
@XmlTransient
|
||||||
Ref<PollMessage.Autorenew> autorenewPollMessage;
|
Key<PollMessage.Autorenew> autorenewPollMessage;
|
||||||
|
|
||||||
/** The unexpired grace periods for this domain (some of which may not be active yet). */
|
/** The unexpired grace periods for this domain (some of which may not be active yet). */
|
||||||
@XmlTransient
|
@XmlTransient
|
||||||
|
@ -146,12 +145,12 @@ public class DomainResource extends DomainBase implements ForeignKeyedEppResourc
|
||||||
DateTime applicationTime;
|
DateTime applicationTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A reference to the application used to allocate this domain. Will only be populated for domains
|
* A key to the application used to allocate this domain. Will only be populated for domains
|
||||||
* allocated from an application.
|
* allocated from an application.
|
||||||
*/
|
*/
|
||||||
@IgnoreSave(IfNull.class)
|
@IgnoreSave(IfNull.class)
|
||||||
@XmlTransient
|
@XmlTransient
|
||||||
Ref<DomainApplication> application;
|
Key<DomainApplication> application;
|
||||||
|
|
||||||
public ImmutableSet<String> getSubordinateHosts() {
|
public ImmutableSet<String> getSubordinateHosts() {
|
||||||
return nullToEmptyImmutableCopy(subordinateHosts);
|
return nullToEmptyImmutableCopy(subordinateHosts);
|
||||||
|
@ -165,11 +164,11 @@ public class DomainResource extends DomainBase implements ForeignKeyedEppResourc
|
||||||
return deletePollMessage;
|
return deletePollMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ref<BillingEvent.Recurring> getAutorenewBillingEvent() {
|
public Key<BillingEvent.Recurring> getAutorenewBillingEvent() {
|
||||||
return autorenewBillingEvent;
|
return autorenewBillingEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ref<PollMessage.Autorenew> getAutorenewPollMessage() {
|
public Key<PollMessage.Autorenew> getAutorenewPollMessage() {
|
||||||
return autorenewPollMessage;
|
return autorenewPollMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +184,7 @@ public class DomainResource extends DomainBase implements ForeignKeyedEppResourc
|
||||||
return applicationTime;
|
return applicationTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ref<DomainApplication> getApplication() {
|
public Key<DomainApplication> getApplication() {
|
||||||
return application;
|
return application;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,13 +289,13 @@ public class DomainResource extends DomainBase implements ForeignKeyedEppResourc
|
||||||
// Set the speculatively-written new autorenew events as the domain's autorenew events.
|
// Set the speculatively-written new autorenew events as the domain's autorenew events.
|
||||||
.setAutorenewBillingEvent(transferData.getServerApproveAutorenewEvent())
|
.setAutorenewBillingEvent(transferData.getServerApproveAutorenewEvent())
|
||||||
.setAutorenewPollMessage(transferData.getServerApproveAutorenewPollMessage())
|
.setAutorenewPollMessage(transferData.getServerApproveAutorenewPollMessage())
|
||||||
// Set the grace period using a ref to the prescheduled transfer billing event. Not using
|
// Set the grace period using a key to the prescheduled transfer billing event. Not using
|
||||||
// GracePeriod.forBillingEvent() here in order to avoid the actual datastore fetch.
|
// GracePeriod.forBillingEvent() here in order to avoid the actual datastore fetch.
|
||||||
.setGracePeriods(ImmutableSet.of(GracePeriod.create(
|
.setGracePeriods(ImmutableSet.of(GracePeriod.create(
|
||||||
GracePeriodStatus.TRANSFER,
|
GracePeriodStatus.TRANSFER,
|
||||||
transferExpirationTime.plus(Registry.get(getTld()).getTransferGracePeriodLength()),
|
transferExpirationTime.plus(Registry.get(getTld()).getTransferGracePeriodLength()),
|
||||||
transferData.getGainingClientId(),
|
transferData.getGainingClientId(),
|
||||||
Ref.create(transferData.getServerApproveBillingEvent().key()))));
|
transferData.getServerApproveBillingEvent())));
|
||||||
// Set all remaining transfer properties.
|
// Set all remaining transfer properties.
|
||||||
setAutomaticTransferSuccessProperties(builder, transferData);
|
setAutomaticTransferSuccessProperties(builder, transferData);
|
||||||
// Finish projecting to now.
|
// Finish projecting to now.
|
||||||
|
@ -318,7 +317,7 @@ public class DomainResource extends DomainBase implements ForeignKeyedEppResourc
|
||||||
GracePeriodStatus.AUTO_RENEW,
|
GracePeriodStatus.AUTO_RENEW,
|
||||||
lastAutorenewTime.plus(Registry.get(getTld()).getAutoRenewGracePeriodLength()),
|
lastAutorenewTime.plus(Registry.get(getTld()).getAutoRenewGracePeriodLength()),
|
||||||
getCurrentSponsorClientId(),
|
getCurrentSponsorClientId(),
|
||||||
Ref.create(autorenewBillingEvent.key())));
|
autorenewBillingEvent));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove any grace periods that have expired.
|
// Remove any grace periods that have expired.
|
||||||
|
@ -398,12 +397,12 @@ public class DomainResource extends DomainBase implements ForeignKeyedEppResourc
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setAutorenewBillingEvent(Ref<BillingEvent.Recurring> autorenewBillingEvent) {
|
public Builder setAutorenewBillingEvent(Key<BillingEvent.Recurring> autorenewBillingEvent) {
|
||||||
getInstance().autorenewBillingEvent = autorenewBillingEvent;
|
getInstance().autorenewBillingEvent = autorenewBillingEvent;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setAutorenewPollMessage(Ref<PollMessage.Autorenew> autorenewPollMessage) {
|
public Builder setAutorenewPollMessage(Key<PollMessage.Autorenew> autorenewPollMessage) {
|
||||||
getInstance().autorenewPollMessage = autorenewPollMessage;
|
getInstance().autorenewPollMessage = autorenewPollMessage;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -418,7 +417,7 @@ public class DomainResource extends DomainBase implements ForeignKeyedEppResourc
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setApplication(Ref<DomainApplication> application) {
|
public Builder setApplication(Key<DomainApplication> application) {
|
||||||
getInstance().application = application;
|
getInstance().application = application;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ package google.registry.model.domain;
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
||||||
|
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.annotation.Embed;
|
import com.googlecode.objectify.annotation.Embed;
|
||||||
import google.registry.model.ImmutableObject;
|
import google.registry.model.ImmutableObject;
|
||||||
import google.registry.model.billing.BillingEvent;
|
import google.registry.model.billing.BillingEvent;
|
||||||
|
@ -49,14 +49,14 @@ public class GracePeriod extends ImmutableObject {
|
||||||
* {@code billingEventRecurring}) or for redemption grace periods (since deletes have no cost).
|
* {@code billingEventRecurring}) or for redemption grace periods (since deletes have no cost).
|
||||||
*/
|
*/
|
||||||
// NB: Would @IgnoreSave(IfNull.class), but not allowed for @Embed collections.
|
// NB: Would @IgnoreSave(IfNull.class), but not allowed for @Embed collections.
|
||||||
Ref<BillingEvent.OneTime> billingEventOneTime = null;
|
Key<BillingEvent.OneTime> billingEventOneTime = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The recurring billing event corresponding to the action that triggered this grace period, if
|
* The recurring billing event corresponding to the action that triggered this grace period, if
|
||||||
* applicable - i.e. if the action was an autorenew - or null in all other cases.
|
* applicable - i.e. if the action was an autorenew - or null in all other cases.
|
||||||
*/
|
*/
|
||||||
// NB: Would @IgnoreSave(IfNull.class), but not allowed for @Embed collections.
|
// NB: Would @IgnoreSave(IfNull.class), but not allowed for @Embed collections.
|
||||||
Ref<BillingEvent.Recurring> billingEventRecurring = null;
|
Key<BillingEvent.Recurring> billingEventRecurring = null;
|
||||||
|
|
||||||
public GracePeriodStatus getType() {
|
public GracePeriodStatus getType() {
|
||||||
// NB: We implicitly convert SUNRUSH_ADD to ADD, since they should be functionally equivalent.
|
// NB: We implicitly convert SUNRUSH_ADD to ADD, since they should be functionally equivalent.
|
||||||
|
@ -85,7 +85,7 @@ public class GracePeriod extends ImmutableObject {
|
||||||
* period is not AUTO_RENEW.
|
* period is not AUTO_RENEW.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Ref<BillingEvent.OneTime> getOneTimeBillingEvent() {
|
public Key<BillingEvent.OneTime> getOneTimeBillingEvent() {
|
||||||
return billingEventOneTime;
|
return billingEventOneTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ public class GracePeriod extends ImmutableObject {
|
||||||
* Returns the recurring billing event. The value will only be non-null if the type of this grace
|
* Returns the recurring billing event. The value will only be non-null if the type of this grace
|
||||||
* period is AUTO_RENEW.
|
* period is AUTO_RENEW.
|
||||||
*/
|
*/
|
||||||
public Ref<BillingEvent.Recurring> getRecurringBillingEvent() {
|
public Key<BillingEvent.Recurring> getRecurringBillingEvent() {
|
||||||
return billingEventRecurring;
|
return billingEventRecurring;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,8 +101,8 @@ public class GracePeriod extends ImmutableObject {
|
||||||
GracePeriodStatus type,
|
GracePeriodStatus type,
|
||||||
DateTime expirationTime,
|
DateTime expirationTime,
|
||||||
String clientId,
|
String clientId,
|
||||||
@Nullable Ref<BillingEvent.OneTime> billingEventOneTime,
|
@Nullable Key<BillingEvent.OneTime> billingEventOneTime,
|
||||||
@Nullable Ref<BillingEvent.Recurring> billingEventRecurring) {
|
@Nullable Key<BillingEvent.Recurring> billingEventRecurring) {
|
||||||
checkArgument((billingEventOneTime == null) || (billingEventRecurring == null),
|
checkArgument((billingEventOneTime == null) || (billingEventRecurring == null),
|
||||||
"A grace period can have at most one billing event");
|
"A grace period can have at most one billing event");
|
||||||
checkArgument((billingEventRecurring != null) == (GracePeriodStatus.AUTO_RENEW.equals(type)),
|
checkArgument((billingEventRecurring != null) == (GracePeriodStatus.AUTO_RENEW.equals(type)),
|
||||||
|
@ -127,7 +127,7 @@ public class GracePeriod extends ImmutableObject {
|
||||||
GracePeriodStatus type,
|
GracePeriodStatus type,
|
||||||
DateTime expirationTime,
|
DateTime expirationTime,
|
||||||
String clientId,
|
String clientId,
|
||||||
@Nullable Ref<BillingEvent.OneTime> billingEventOneTime) {
|
@Nullable Key<BillingEvent.OneTime> billingEventOneTime) {
|
||||||
return createInternal(type, expirationTime, clientId, billingEventOneTime, null);
|
return createInternal(type, expirationTime, clientId, billingEventOneTime, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ public class GracePeriod extends ImmutableObject {
|
||||||
GracePeriodStatus type,
|
GracePeriodStatus type,
|
||||||
DateTime expirationTime,
|
DateTime expirationTime,
|
||||||
String clientId,
|
String clientId,
|
||||||
Ref<BillingEvent.Recurring> billingEventRecurring) {
|
Key<BillingEvent.Recurring> billingEventRecurring) {
|
||||||
checkArgumentNotNull(billingEventRecurring);
|
checkArgumentNotNull(billingEventRecurring);
|
||||||
return createInternal(type, expirationTime, clientId, null, billingEventRecurring);
|
return createInternal(type, expirationTime, clientId, null, billingEventRecurring);
|
||||||
}
|
}
|
||||||
|
@ -151,6 +151,6 @@ public class GracePeriod extends ImmutableObject {
|
||||||
public static GracePeriod forBillingEvent(
|
public static GracePeriod forBillingEvent(
|
||||||
GracePeriodStatus type, BillingEvent.OneTime billingEvent) {
|
GracePeriodStatus type, BillingEvent.OneTime billingEvent) {
|
||||||
return create(
|
return create(
|
||||||
type, billingEvent.getBillingTime(), billingEvent.getClientId(), Ref.create(billingEvent));
|
type, billingEvent.getBillingTime(), billingEvent.getClientId(), Key.create(billingEvent));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
package google.registry.model.domain;
|
package google.registry.model.domain;
|
||||||
|
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.annotation.Embed;
|
import com.googlecode.objectify.annotation.Embed;
|
||||||
import com.googlecode.objectify.annotation.Index;
|
import com.googlecode.objectify.annotation.Index;
|
||||||
import google.registry.model.EppResource;
|
import google.registry.model.EppResource;
|
||||||
|
@ -22,7 +22,7 @@ import google.registry.model.ImmutableObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Legacy shell of a "union" type to represent referenced objects as either a foreign key or as a
|
* Legacy shell of a "union" type to represent referenced objects as either a foreign key or as a
|
||||||
* link to another object in the datastore. In its current form it merely wraps a {@link Ref}.
|
* link to another object in the datastore. In its current form it merely wraps a {@link Key}.
|
||||||
*
|
*
|
||||||
* @param <T> the type being referenced
|
* @param <T> the type being referenced
|
||||||
*/
|
*/
|
||||||
|
@ -30,13 +30,13 @@ import google.registry.model.ImmutableObject;
|
||||||
public class ReferenceUnion<T extends EppResource> extends ImmutableObject {
|
public class ReferenceUnion<T extends EppResource> extends ImmutableObject {
|
||||||
|
|
||||||
@Index
|
@Index
|
||||||
Ref<T> linked;
|
Key<T> linked;
|
||||||
|
|
||||||
public Ref<T> getLinked() {
|
public Key<T> getLinked() {
|
||||||
return linked;
|
return linked;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T extends EppResource> ReferenceUnion<T> create(Ref<T> linked) {
|
public static <T extends EppResource> ReferenceUnion<T> create(Key<T> linked) {
|
||||||
ReferenceUnion<T> instance = new ReferenceUnion<>();
|
ReferenceUnion<T> instance = new ReferenceUnion<>();
|
||||||
instance.linked = linked;
|
instance.linked = linked;
|
||||||
return instance;
|
return instance;
|
||||||
|
|
|
@ -17,13 +17,14 @@ package google.registry.model.host;
|
||||||
import static com.google.common.collect.Sets.difference;
|
import static com.google.common.collect.Sets.difference;
|
||||||
import static com.google.common.collect.Sets.union;
|
import static com.google.common.collect.Sets.union;
|
||||||
import static google.registry.model.EppResourceUtils.projectResourceOntoBuilderAtTime;
|
import static google.registry.model.EppResourceUtils.projectResourceOntoBuilderAtTime;
|
||||||
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static google.registry.model.ofy.Ofy.RECOMMENDED_MEMCACHE_EXPIRATION;
|
import static google.registry.model.ofy.Ofy.RECOMMENDED_MEMCACHE_EXPIRATION;
|
||||||
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
|
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
|
||||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.annotation.Cache;
|
import com.googlecode.objectify.annotation.Cache;
|
||||||
import com.googlecode.objectify.annotation.Entity;
|
import com.googlecode.objectify.annotation.Entity;
|
||||||
import com.googlecode.objectify.annotation.IgnoreSave;
|
import com.googlecode.objectify.annotation.IgnoreSave;
|
||||||
|
@ -88,7 +89,7 @@ public class HostResource extends EppResource implements ForeignKeyedEppResource
|
||||||
@Index
|
@Index
|
||||||
@IgnoreSave(IfNull.class)
|
@IgnoreSave(IfNull.class)
|
||||||
@XmlTransient
|
@XmlTransient
|
||||||
Ref<DomainResource> superordinateDomain;
|
Key<DomainResource> superordinateDomain;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The most recent time that the superordinate domain was changed, or null if this host is
|
* The most recent time that the superordinate domain was changed, or null if this host is
|
||||||
|
@ -102,7 +103,7 @@ public class HostResource extends EppResource implements ForeignKeyedEppResource
|
||||||
return fullyQualifiedHostName;
|
return fullyQualifiedHostName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ref<DomainResource> getSuperordinateDomain() {
|
public Key<DomainResource> getSuperordinateDomain() {
|
||||||
return superordinateDomain;
|
return superordinateDomain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +133,8 @@ public class HostResource extends EppResource implements ForeignKeyedEppResource
|
||||||
} else {
|
} else {
|
||||||
// For hosts with superordinate domains, the client id, last transfer time, and transfer data
|
// For hosts with superordinate domains, the client id, last transfer time, and transfer data
|
||||||
// need to be read off the domain projected to the correct time.
|
// need to be read off the domain projected to the correct time.
|
||||||
DomainResource domainAtTime = superordinateDomain.get().cloneProjectedAtTime(now);
|
DomainResource domainAtTime = ofy().load().key(superordinateDomain).now()
|
||||||
|
.cloneProjectedAtTime(now);
|
||||||
builder.setCurrentSponsorClientId(domainAtTime.getCurrentSponsorClientId());
|
builder.setCurrentSponsorClientId(domainAtTime.getCurrentSponsorClientId());
|
||||||
// If the superordinate domain's last transfer time is what is relevant, because the host's
|
// If the superordinate domain's last transfer time is what is relevant, because the host's
|
||||||
// superordinate domain was last changed less recently than the domain's last transfer, then
|
// superordinate domain was last changed less recently than the domain's last transfer, then
|
||||||
|
@ -192,7 +194,7 @@ public class HostResource extends EppResource implements ForeignKeyedEppResource
|
||||||
difference(getInstance().getInetAddresses(), inetAddresses)));
|
difference(getInstance().getInetAddresses(), inetAddresses)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setSuperordinateDomain(Ref<DomainResource> superordinateDomain) {
|
public Builder setSuperordinateDomain(Key<DomainResource> superordinateDomain) {
|
||||||
getInstance().superordinateDomain = superordinateDomain;
|
getInstance().superordinateDomain = superordinateDomain;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ import static google.registry.util.DateTimeUtils.latestOf;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import com.googlecode.objectify.annotation.Cache;
|
import com.googlecode.objectify.annotation.Cache;
|
||||||
import com.googlecode.objectify.annotation.Entity;
|
import com.googlecode.objectify.annotation.Entity;
|
||||||
import com.googlecode.objectify.annotation.Id;
|
import com.googlecode.objectify.annotation.Id;
|
||||||
|
@ -48,11 +47,13 @@ public class DomainApplicationIndex extends BackupGroupRoot {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A set of all domain applications with this fully qualified domain name. Never null or empty.
|
* A set of all domain applications with this fully qualified domain name. Never null or empty.
|
||||||
|
*
|
||||||
|
* <p>Although this stores {@link Key}s it is named "references" for historical reasons.
|
||||||
*/
|
*/
|
||||||
Set<Ref<DomainApplication>> references;
|
Set<Key<DomainApplication>> references;
|
||||||
|
|
||||||
/** Returns a cloned list of all references on this index. */
|
/** Returns a cloned list of all keys on this index. */
|
||||||
public ImmutableSet<Ref<DomainApplication>> getReferences() {
|
public ImmutableSet<Key<DomainApplication>> getKeys() {
|
||||||
return ImmutableSet.copyOf(references);
|
return ImmutableSet.copyOf(references);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,18 +62,18 @@ public class DomainApplicationIndex extends BackupGroupRoot {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a DomainApplicationIndex with the specified list of references. Only use this method
|
* Creates a DomainApplicationIndex with the specified list of keys. Only use this method for data
|
||||||
* for data migrations. You probably want {@link #createUpdatedInstance}.
|
* migrations. You probably want {@link #createUpdatedInstance}.
|
||||||
*/
|
*/
|
||||||
public static DomainApplicationIndex createWithSpecifiedReferences(
|
public static DomainApplicationIndex createWithSpecifiedKeys(
|
||||||
String fullyQualifiedDomainName,
|
String fullyQualifiedDomainName,
|
||||||
ImmutableSet<Ref<DomainApplication>> references) {
|
ImmutableSet<Key<DomainApplication>> keys) {
|
||||||
checkArgument(!isNullOrEmpty(fullyQualifiedDomainName),
|
checkArgument(!isNullOrEmpty(fullyQualifiedDomainName),
|
||||||
"fullyQualifiedDomainName must not be null or empty.");
|
"fullyQualifiedDomainName must not be null or empty.");
|
||||||
checkArgument(!isNullOrEmpty(references), "References must not be null or empty.");
|
checkArgument(!isNullOrEmpty(keys), "Keys must not be null or empty.");
|
||||||
DomainApplicationIndex instance = new DomainApplicationIndex();
|
DomainApplicationIndex instance = new DomainApplicationIndex();
|
||||||
instance.fullyQualifiedDomainName = fullyQualifiedDomainName;
|
instance.fullyQualifiedDomainName = fullyQualifiedDomainName;
|
||||||
instance.references = references;
|
instance.references = keys;
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +92,7 @@ public class DomainApplicationIndex extends BackupGroupRoot {
|
||||||
return ImmutableSet.of();
|
return ImmutableSet.of();
|
||||||
}
|
}
|
||||||
ImmutableSet.Builder<DomainApplication> apps = new ImmutableSet.Builder<>();
|
ImmutableSet.Builder<DomainApplication> apps = new ImmutableSet.Builder<>();
|
||||||
for (DomainApplication app : ofy().load().refs(index.getReferences()).values()) {
|
for (DomainApplication app : ofy().load().keys(index.getKeys()).values()) {
|
||||||
DateTime forwardedNow = latestOf(now, app.getUpdateAutoTimestamp().getTimestamp());
|
DateTime forwardedNow = latestOf(now, app.getUpdateAutoTimestamp().getTimestamp());
|
||||||
if (app.getDeletionTime().isAfter(forwardedNow)) {
|
if (app.getDeletionTime().isAfter(forwardedNow)) {
|
||||||
apps.add(app.cloneProjectedAtTime(forwardedNow));
|
apps.add(app.cloneProjectedAtTime(forwardedNow));
|
||||||
|
@ -121,9 +122,9 @@ public class DomainApplicationIndex extends BackupGroupRoot {
|
||||||
*/
|
*/
|
||||||
public static DomainApplicationIndex createUpdatedInstance(DomainApplication application) {
|
public static DomainApplicationIndex createUpdatedInstance(DomainApplication application) {
|
||||||
DomainApplicationIndex existing = load(application.getFullyQualifiedDomainName());
|
DomainApplicationIndex existing = load(application.getFullyQualifiedDomainName());
|
||||||
ImmutableSet<Ref<DomainApplication>> newReferences = CollectionUtils.union(
|
ImmutableSet<Key<DomainApplication>> newKeys = CollectionUtils.union(
|
||||||
(existing == null ? ImmutableSet.<Ref<DomainApplication>>of() : existing.getReferences()),
|
(existing == null ? ImmutableSet.<Key<DomainApplication>>of() : existing.getKeys()),
|
||||||
Ref.create(application));
|
Key.create(application));
|
||||||
return createWithSpecifiedReferences(application.getFullyQualifiedDomainName(), newReferences);
|
return createWithSpecifiedKeys(application.getFullyQualifiedDomainName(), newKeys);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ import static google.registry.util.TypeUtils.instantiate;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import com.googlecode.objectify.annotation.Entity;
|
import com.googlecode.objectify.annotation.Entity;
|
||||||
import com.googlecode.objectify.annotation.Id;
|
import com.googlecode.objectify.annotation.Id;
|
||||||
import com.googlecode.objectify.annotation.Index;
|
import com.googlecode.objectify.annotation.Index;
|
||||||
|
@ -36,7 +35,8 @@ public class EppResourceIndex extends BackupGroupRoot {
|
||||||
@Parent
|
@Parent
|
||||||
Key<EppResourceIndexBucket> bucket;
|
Key<EppResourceIndexBucket> bucket;
|
||||||
|
|
||||||
Ref<? extends EppResource> reference;
|
/** Although this field holds a {@link Key} it is named "reference" for historical reasons. */
|
||||||
|
Key<? extends EppResource> reference;
|
||||||
|
|
||||||
@Index
|
@Index
|
||||||
String kind;
|
String kind;
|
||||||
|
@ -49,7 +49,7 @@ public class EppResourceIndex extends BackupGroupRoot {
|
||||||
return kind;
|
return kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ref<? extends EppResource> getReference() {
|
public Key<? extends EppResource> getKey() {
|
||||||
return reference;
|
return reference;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ public class EppResourceIndex extends BackupGroupRoot {
|
||||||
public static <T extends EppResource> EppResourceIndex create(
|
public static <T extends EppResource> EppResourceIndex create(
|
||||||
Key<EppResourceIndexBucket> bucket, Key<T> resourceKey) {
|
Key<EppResourceIndexBucket> bucket, Key<T> resourceKey) {
|
||||||
EppResourceIndex instance = instantiate(EppResourceIndex.class);
|
EppResourceIndex instance = instantiate(EppResourceIndex.class);
|
||||||
instance.reference = Ref.create(resourceKey);
|
instance.reference = resourceKey;
|
||||||
instance.kind = resourceKey.getKind();
|
instance.kind = resourceKey.getKind();
|
||||||
instance.id = resourceKey.getString(); // creates a web-safe key string
|
instance.id = resourceKey.getString(); // creates a web-safe key string
|
||||||
instance.bucket = bucket;
|
instance.bucket = bucket;
|
||||||
|
|
|
@ -23,7 +23,6 @@ import com.google.common.base.Predicate;
|
||||||
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.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import com.googlecode.objectify.annotation.Cache;
|
import com.googlecode.objectify.annotation.Cache;
|
||||||
import com.googlecode.objectify.annotation.Entity;
|
import com.googlecode.objectify.annotation.Entity;
|
||||||
import com.googlecode.objectify.annotation.Id;
|
import com.googlecode.objectify.annotation.Id;
|
||||||
|
@ -81,9 +80,10 @@ public abstract class ForeignKeyIndex<E extends EppResource> extends BackupGroup
|
||||||
/**
|
/**
|
||||||
* The referenced resource.
|
* The referenced resource.
|
||||||
*
|
*
|
||||||
* <p>This field holds the only reference. It is named "topReference" for historical reasons.
|
* <p>This field holds a key to the only referenced resource. It is named "topReference" for
|
||||||
|
* historical reasons.
|
||||||
*/
|
*/
|
||||||
Ref<E> topReference;
|
Key<E> topReference;
|
||||||
|
|
||||||
public String getForeignKey() {
|
public String getForeignKey() {
|
||||||
return foreignKey;
|
return foreignKey;
|
||||||
|
@ -93,7 +93,7 @@ public abstract class ForeignKeyIndex<E extends EppResource> extends BackupGroup
|
||||||
return deletionTime;
|
return deletionTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ref<E> getReference() {
|
public Key<E> getResourceKey() {
|
||||||
return topReference;
|
return topReference;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ public abstract class ForeignKeyIndex<E extends EppResource> extends BackupGroup
|
||||||
public static <E extends EppResource> ForeignKeyIndex<E> create(
|
public static <E extends EppResource> ForeignKeyIndex<E> create(
|
||||||
E resource, DateTime deletionTime) {
|
E resource, DateTime deletionTime) {
|
||||||
ForeignKeyIndex<E> instance = instantiate(RESOURCE_CLASS_TO_FKI_CLASS.get(resource.getClass()));
|
ForeignKeyIndex<E> instance = instantiate(RESOURCE_CLASS_TO_FKI_CLASS.get(resource.getClass()));
|
||||||
instance.topReference = Ref.create(resource);
|
instance.topReference = Key.create(resource);
|
||||||
instance.foreignKey = resource.getForeignKey();
|
instance.foreignKey = resource.getForeignKey();
|
||||||
instance.deletionTime = deletionTime;
|
instance.deletionTime = deletionTime;
|
||||||
return instance;
|
return instance;
|
||||||
|
@ -116,7 +116,7 @@ public abstract class ForeignKeyIndex<E extends EppResource> extends BackupGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a reference to an {@link EppResource} from the datastore by foreign key.
|
* Loads a {@link Key} to an {@link EppResource} from the datastore by foreign key.
|
||||||
*
|
*
|
||||||
* <p>Returns absent if no foreign key index with this foreign key was ever created, or if the
|
* <p>Returns absent if no foreign key index with this foreign key was ever created, or if the
|
||||||
* most recently created foreign key index was deleted before time "now". This method does not
|
* most recently created foreign key index was deleted before time "now". This method does not
|
||||||
|
@ -128,10 +128,10 @@ public abstract class ForeignKeyIndex<E extends EppResource> extends BackupGroup
|
||||||
* @param now the current logical time to use when checking for soft deletion of the foreign key
|
* @param now the current logical time to use when checking for soft deletion of the foreign key
|
||||||
* index
|
* index
|
||||||
*/
|
*/
|
||||||
public static <E extends EppResource> Ref<E> loadAndGetReference(
|
public static <E extends EppResource> Key<E> loadAndGetKey(
|
||||||
Class<E> clazz, String foreignKey, DateTime now) {
|
Class<E> clazz, String foreignKey, DateTime now) {
|
||||||
ForeignKeyIndex<E> index = load(clazz, foreignKey, now);
|
ForeignKeyIndex<E> index = load(clazz, foreignKey, now);
|
||||||
return (index == null) ? null : index.getReference();
|
return (index == null) ? null : index.getResourceKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -130,14 +130,14 @@ public abstract class BaseDomainLabelList<T extends Comparable<?>, R extends Dom
|
||||||
ImmutableSet.Builder<String> builder = new ImmutableSet.Builder<>();
|
ImmutableSet.Builder<String> builder = new ImmutableSet.Builder<>();
|
||||||
Key<? extends BaseDomainLabelList<?, ?>> key = Key.create(this);
|
Key<? extends BaseDomainLabelList<?, ?>> key = Key.create(this);
|
||||||
for (String tld : getTlds()) {
|
for (String tld : getTlds()) {
|
||||||
if (hasReference(Registry.get(tld), key)) {
|
if (refersToKey(Registry.get(tld), key)) {
|
||||||
builder.add(tld);
|
builder.add(tld);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract boolean hasReference(
|
protected abstract boolean refersToKey(
|
||||||
Registry registry, Key<? extends BaseDomainLabelList<?, ?>> key);
|
Registry registry, Key<? extends BaseDomainLabelList<?, ?>> key);
|
||||||
|
|
||||||
protected static <R> Optional<R> getFromCache(String listName, LoadingCache<String, R> cache) {
|
protected static <R> Optional<R> getFromCache(String listName, LoadingCache<String, R> cache) {
|
||||||
|
|
|
@ -306,7 +306,7 @@ public final class PremiumList extends BaseDomainLabelList<Money, PremiumList.Pr
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasReference(Registry registry, Key<? extends BaseDomainLabelList<?, ?>> key) {
|
public boolean refersToKey(Registry registry, Key<? extends BaseDomainLabelList<?, ?>> key) {
|
||||||
return Objects.equals(registry.getPremiumList(), key);
|
return Objects.equals(registry.getPremiumList(), key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ public final class ReservedList
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean hasReference(Registry registry, Key<? extends BaseDomainLabelList<?, ?>> key) {
|
protected boolean refersToKey(Registry registry, Key<? extends BaseDomainLabelList<?, ?>> key) {
|
||||||
return registry.getReservedLists().contains(key);
|
return registry.getReservedLists().contains(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
package google.registry.model.reporting;
|
package google.registry.model.reporting;
|
||||||
|
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import com.googlecode.objectify.annotation.Entity;
|
import com.googlecode.objectify.annotation.Entity;
|
||||||
import com.googlecode.objectify.annotation.Id;
|
import com.googlecode.objectify.annotation.Id;
|
||||||
import com.googlecode.objectify.annotation.IgnoreSave;
|
import com.googlecode.objectify.annotation.IgnoreSave;
|
||||||
|
@ -25,12 +24,14 @@ import com.googlecode.objectify.condition.IfNull;
|
||||||
import google.registry.model.Buildable;
|
import google.registry.model.Buildable;
|
||||||
import google.registry.model.EppResource;
|
import google.registry.model.EppResource;
|
||||||
import google.registry.model.ImmutableObject;
|
import google.registry.model.ImmutableObject;
|
||||||
|
import google.registry.model.ImmutableObject.DoNotHydrate;
|
||||||
import google.registry.model.domain.Period;
|
import google.registry.model.domain.Period;
|
||||||
import google.registry.model.eppcommon.Trid;
|
import google.registry.model.eppcommon.Trid;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
|
||||||
/** A record of an EPP command that mutated a resource. */
|
/** A record of an EPP command that mutated a resource. */
|
||||||
@Entity
|
@Entity
|
||||||
|
@DoNotHydrate
|
||||||
public class HistoryEntry extends ImmutableObject implements Buildable {
|
public class HistoryEntry extends ImmutableObject implements Buildable {
|
||||||
|
|
||||||
/** Represents the type of history entry. */
|
/** Represents the type of history entry. */
|
||||||
|
@ -77,7 +78,7 @@ public class HistoryEntry extends ImmutableObject implements Buildable {
|
||||||
|
|
||||||
/** The resource this event mutated. */
|
/** The resource this event mutated. */
|
||||||
@Parent
|
@Parent
|
||||||
Ref<? extends EppResource> parent;
|
Key<? extends EppResource> parent;
|
||||||
|
|
||||||
/** The type of history entry. */
|
/** The type of history entry. */
|
||||||
Type type;
|
Type type;
|
||||||
|
@ -112,7 +113,7 @@ public class HistoryEntry extends ImmutableObject implements Buildable {
|
||||||
/** Whether this change was requested by a registrar. */
|
/** Whether this change was requested by a registrar. */
|
||||||
Boolean requestedByRegistrar;
|
Boolean requestedByRegistrar;
|
||||||
|
|
||||||
public Ref<? extends EppResource> getParent() {
|
public Key<? extends EppResource> getParent() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,12 +167,12 @@ public class HistoryEntry extends ImmutableObject implements Buildable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setParent(EppResource parent) {
|
public Builder setParent(EppResource parent) {
|
||||||
getInstance().parent = Ref.create(parent);
|
getInstance().parent = Key.create(parent);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setParent(Key<? extends EppResource> parentKey) {
|
public Builder setParent(Key<? extends EppResource> parentKey) {
|
||||||
getInstance().parent = Ref.create(parentKey);
|
getInstance().parent = parentKey;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import com.googlecode.objectify.annotation.Embed;
|
import com.googlecode.objectify.annotation.Embed;
|
||||||
import com.googlecode.objectify.annotation.IgnoreSave;
|
import com.googlecode.objectify.annotation.IgnoreSave;
|
||||||
import com.googlecode.objectify.annotation.Unindex;
|
import com.googlecode.objectify.annotation.Unindex;
|
||||||
|
@ -48,9 +47,6 @@ public class TransferData extends BaseTransferObject implements Buildable {
|
||||||
* a number of poll messages and billing events for both the gaining and losing registrars. If the
|
* a number of poll messages and billing events for both the gaining and losing registrars. If the
|
||||||
* pending transfer is explicitly approved, rejected or cancelled, the referenced entities should
|
* pending transfer is explicitly approved, rejected or cancelled, the referenced entities should
|
||||||
* be deleted.
|
* be deleted.
|
||||||
*
|
|
||||||
* <p>Keys are stored here instead of references to facilitate bulk deletion (the typical use
|
|
||||||
* case, as described above), since Objectify allows bulk deletion by key but not by reference.
|
|
||||||
*/
|
*/
|
||||||
@IgnoreSave(IfNull.class)
|
@IgnoreSave(IfNull.class)
|
||||||
Set<Key<? extends TransferServerApproveEntity>> serverApproveEntities;
|
Set<Key<? extends TransferServerApproveEntity>> serverApproveEntities;
|
||||||
|
@ -62,7 +58,7 @@ public class TransferData extends BaseTransferObject implements Buildable {
|
||||||
* being transferred is not a domain.
|
* being transferred is not a domain.
|
||||||
*/
|
*/
|
||||||
@IgnoreSave(IfNull.class)
|
@IgnoreSave(IfNull.class)
|
||||||
Ref<BillingEvent.OneTime> serverApproveBillingEvent;
|
Key<BillingEvent.OneTime> serverApproveBillingEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The autorenew billing event that should be associated with this resource after the transfer.
|
* The autorenew billing event that should be associated with this resource after the transfer.
|
||||||
|
@ -71,7 +67,7 @@ public class TransferData extends BaseTransferObject implements Buildable {
|
||||||
* being transferred is not a domain.
|
* being transferred is not a domain.
|
||||||
*/
|
*/
|
||||||
@IgnoreSave(IfNull.class)
|
@IgnoreSave(IfNull.class)
|
||||||
Ref<BillingEvent.Recurring> serverApproveAutorenewEvent;
|
Key<BillingEvent.Recurring> serverApproveAutorenewEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The autorenew poll message that should be associated with this resource after the transfer.
|
* The autorenew poll message that should be associated with this resource after the transfer.
|
||||||
|
@ -80,7 +76,7 @@ public class TransferData extends BaseTransferObject implements Buildable {
|
||||||
* being transferred is not a domain.
|
* being transferred is not a domain.
|
||||||
*/
|
*/
|
||||||
@IgnoreSave(IfNull.class)
|
@IgnoreSave(IfNull.class)
|
||||||
Ref<PollMessage.Autorenew> serverApproveAutorenewPollMessage;
|
Key<PollMessage.Autorenew> serverApproveAutorenewPollMessage;
|
||||||
|
|
||||||
/** The transaction id of the most recent transfer request (or null if there never was one). */
|
/** The transaction id of the most recent transfer request (or null if there never was one). */
|
||||||
Trid transferRequestTrid;
|
Trid transferRequestTrid;
|
||||||
|
@ -95,15 +91,15 @@ public class TransferData extends BaseTransferObject implements Buildable {
|
||||||
return nullToEmptyImmutableCopy(serverApproveEntities);
|
return nullToEmptyImmutableCopy(serverApproveEntities);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ref<BillingEvent.OneTime> getServerApproveBillingEvent() {
|
public Key<BillingEvent.OneTime> getServerApproveBillingEvent() {
|
||||||
return serverApproveBillingEvent;
|
return serverApproveBillingEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ref<BillingEvent.Recurring> getServerApproveAutorenewEvent() {
|
public Key<BillingEvent.Recurring> getServerApproveAutorenewEvent() {
|
||||||
return serverApproveAutorenewEvent;
|
return serverApproveAutorenewEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ref<PollMessage.Autorenew> getServerApproveAutorenewPollMessage() {
|
public Key<PollMessage.Autorenew> getServerApproveAutorenewPollMessage() {
|
||||||
return serverApproveAutorenewPollMessage;
|
return serverApproveAutorenewPollMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,19 +134,19 @@ public class TransferData extends BaseTransferObject implements Buildable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setServerApproveBillingEvent(
|
public Builder setServerApproveBillingEvent(
|
||||||
Ref<BillingEvent.OneTime> serverApproveBillingEvent) {
|
Key<BillingEvent.OneTime> serverApproveBillingEvent) {
|
||||||
getInstance().serverApproveBillingEvent = serverApproveBillingEvent;
|
getInstance().serverApproveBillingEvent = serverApproveBillingEvent;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setServerApproveAutorenewEvent(
|
public Builder setServerApproveAutorenewEvent(
|
||||||
Ref<BillingEvent.Recurring> serverApproveAutorenewEvent) {
|
Key<BillingEvent.Recurring> serverApproveAutorenewEvent) {
|
||||||
getInstance().serverApproveAutorenewEvent = serverApproveAutorenewEvent;
|
getInstance().serverApproveAutorenewEvent = serverApproveAutorenewEvent;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setServerApproveAutorenewPollMessage(
|
public Builder setServerApproveAutorenewPollMessage(
|
||||||
Ref<PollMessage.Autorenew> serverApproveAutorenewPollMessage) {
|
Key<PollMessage.Autorenew> serverApproveAutorenewPollMessage) {
|
||||||
getInstance().serverApproveAutorenewPollMessage = serverApproveAutorenewPollMessage;
|
getInstance().serverApproveAutorenewPollMessage = serverApproveAutorenewPollMessage;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,19 +20,19 @@ import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSortedMap;
|
import com.google.common.collect.ImmutableSortedMap;
|
||||||
import com.google.common.collect.Ordering;
|
import com.google.common.collect.Ordering;
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.config.RegistryEnvironment;
|
import google.registry.config.RegistryEnvironment;
|
||||||
import google.registry.model.ofy.CommitLogManifest;
|
import google.registry.model.ofy.CommitLogManifest;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Objectify translator for {@code ImmutableSortedMap<DateTime, Ref<CommitLogManifest>>} fields.
|
* Objectify translator for {@code ImmutableSortedMap<DateTime, Key<CommitLogManifest>>} fields.
|
||||||
*
|
*
|
||||||
* <p>This translator is responsible for doing three things:
|
* <p>This translator is responsible for doing three things:
|
||||||
* <ol>
|
* <ol>
|
||||||
* <li>Translating the data into two lists of {@code Date} and {@code Key} objects, in a manner
|
* <li>Translating the data into two lists of {@code Date} and {@code Key} objects, in a manner
|
||||||
* similar to {@code @Mapify}.
|
* similar to {@code @Mapify}.
|
||||||
* <li>Inserting a reference to the transaction's {@link CommitLogManifest} on save.
|
* <li>Inserting a key to the transaction's {@link CommitLogManifest} on save.
|
||||||
* <li>Truncating the map to include only the last key per day for the last 30 days.
|
* <li>Truncating the map to include only the last key per day for the last 30 days.
|
||||||
* </ol>
|
* </ol>
|
||||||
*
|
*
|
||||||
|
@ -45,7 +45,7 @@ import org.joda.time.DateTime;
|
||||||
* @see google.registry.model.EppResource
|
* @see google.registry.model.EppResource
|
||||||
*/
|
*/
|
||||||
public final class CommitLogRevisionsTranslatorFactory
|
public final class CommitLogRevisionsTranslatorFactory
|
||||||
extends ImmutableSortedMapTranslatorFactory<DateTime, Ref<CommitLogManifest>> {
|
extends ImmutableSortedMapTranslatorFactory<DateTime, Key<CommitLogManifest>> {
|
||||||
|
|
||||||
private static final RegistryEnvironment ENVIRONMENT = RegistryEnvironment.get();
|
private static final RegistryEnvironment ENVIRONMENT = RegistryEnvironment.get();
|
||||||
|
|
||||||
|
@ -62,14 +62,14 @@ public final class CommitLogRevisionsTranslatorFactory
|
||||||
* @see google.registry.config.RegistryConfig#getCommitLogDatastoreRetention()
|
* @see google.registry.config.RegistryConfig#getCommitLogDatastoreRetention()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
ImmutableSortedMap<DateTime, Ref<CommitLogManifest>> transformBeforeSave(
|
ImmutableSortedMap<DateTime, Key<CommitLogManifest>> transformBeforeSave(
|
||||||
ImmutableSortedMap<DateTime, Ref<CommitLogManifest>> revisions) {
|
ImmutableSortedMap<DateTime, Key<CommitLogManifest>> revisions) {
|
||||||
DateTime now = ofy().getTransactionTime();
|
DateTime now = ofy().getTransactionTime();
|
||||||
DateTime threshold = now.minus(ENVIRONMENT.config().getCommitLogDatastoreRetention());
|
DateTime threshold = now.minus(ENVIRONMENT.config().getCommitLogDatastoreRetention());
|
||||||
DateTime preThresholdTime = firstNonNull(revisions.floorKey(threshold), START_OF_TIME);
|
DateTime preThresholdTime = firstNonNull(revisions.floorKey(threshold), START_OF_TIME);
|
||||||
return new ImmutableSortedMap.Builder<DateTime, Ref<CommitLogManifest>>(Ordering.natural())
|
return new ImmutableSortedMap.Builder<DateTime, Key<CommitLogManifest>>(Ordering.natural())
|
||||||
.putAll(revisions.subMap(preThresholdTime, true, now.withTimeAtStartOfDay(), false))
|
.putAll(revisions.subMap(preThresholdTime, true, now.withTimeAtStartOfDay(), false))
|
||||||
.put(now, Ref.create(ofy().getCommitLogManifestKey()))
|
.put(now, ofy().getCommitLogManifestKey())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,6 @@ import com.google.common.collect.FluentIterable;
|
||||||
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 com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import google.registry.mapreduce.MapreduceRunner;
|
import google.registry.mapreduce.MapreduceRunner;
|
||||||
import google.registry.mapreduce.inputs.EppResourceInputs;
|
import google.registry.mapreduce.inputs.EppResourceInputs;
|
||||||
import google.registry.model.EppResource;
|
import google.registry.model.EppResource;
|
||||||
|
@ -77,8 +76,7 @@ import org.joda.time.DateTime;
|
||||||
* <p>Specifically this validates all of the following system invariants that are expected to hold
|
* <p>Specifically this validates all of the following system invariants that are expected to hold
|
||||||
* true for all {@link EppResource} entities and their related indexes:
|
* true for all {@link EppResource} entities and their related indexes:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>All {@link Key} and {@link Ref} fields (including nested ones) point to entities that
|
* <li>All {@link Key} fields (including nested ones) point to entities that exist.
|
||||||
* exist.
|
|
||||||
* <li>There is exactly one {@link EppResourceIndex} pointing to each {@link EppResource}.
|
* <li>There is exactly one {@link EppResourceIndex} pointing to each {@link EppResource}.
|
||||||
* <li>All contacts, hosts, and domains, when grouped by foreign key, have at most one active
|
* <li>All contacts, hosts, and domains, when grouped by foreign key, have at most one active
|
||||||
* resource, and exactly one {@link ForeignKeyIndex} of the appropriate type, which points to
|
* resource, and exactly one {@link ForeignKeyIndex} of the appropriate type, which points to
|
||||||
|
@ -241,8 +239,8 @@ public class VerifyEntityIntegrityAction implements Runnable {
|
||||||
if (resource instanceof DomainBase) {
|
if (resource instanceof DomainBase) {
|
||||||
DomainBase domainBase = (DomainBase) resource;
|
DomainBase domainBase = (DomainBase) resource;
|
||||||
Key<?> key = Key.create(domainBase);
|
Key<?> key = Key.create(domainBase);
|
||||||
verifyExistence(key, refsToKeys(domainBase.getReferencedContacts()));
|
verifyExistence(key, domainBase.getReferencedContacts());
|
||||||
verifyExistence(key, refsToKeys(domainBase.getNameservers()));
|
verifyExistence(key, domainBase.getNameservers());
|
||||||
verifyExistence(key, domainBase.getTransferData().getServerApproveAutorenewEvent());
|
verifyExistence(key, domainBase.getTransferData().getServerApproveAutorenewEvent());
|
||||||
verifyExistence(key, domainBase.getTransferData().getServerApproveAutorenewPollMessage());
|
verifyExistence(key, domainBase.getTransferData().getServerApproveAutorenewPollMessage());
|
||||||
verifyExistence(key, domainBase.getTransferData().getServerApproveBillingEvent());
|
verifyExistence(key, domainBase.getTransferData().getServerApproveBillingEvent());
|
||||||
|
@ -299,7 +297,7 @@ public class VerifyEntityIntegrityAction implements Runnable {
|
||||||
private void mapForeignKeyIndex(ForeignKeyIndex<?> fki) {
|
private void mapForeignKeyIndex(ForeignKeyIndex<?> fki) {
|
||||||
Key<ForeignKeyIndex<?>> fkiKey = Key.<ForeignKeyIndex<?>>create(fki);
|
Key<ForeignKeyIndex<?>> fkiKey = Key.<ForeignKeyIndex<?>>create(fki);
|
||||||
@SuppressWarnings("cast")
|
@SuppressWarnings("cast")
|
||||||
EppResource resource = verifyExistence(fkiKey, fki.getReference());
|
EppResource resource = verifyExistence(fkiKey, fki.getResourceKey());
|
||||||
if (resource != null) {
|
if (resource != null) {
|
||||||
// TODO(user): Traverse the chain of pointers to old FKIs instead once they are written.
|
// TODO(user): Traverse the chain of pointers to old FKIs instead once they are written.
|
||||||
if (isAtOrAfter(fki.getDeletionTime(), resource.getDeletionTime())) {
|
if (isAtOrAfter(fki.getDeletionTime(), resource.getDeletionTime())) {
|
||||||
|
@ -328,8 +326,8 @@ public class VerifyEntityIntegrityAction implements Runnable {
|
||||||
private void mapDomainApplicationIndex(DomainApplicationIndex dai) {
|
private void mapDomainApplicationIndex(DomainApplicationIndex dai) {
|
||||||
getContext().incrementCounter("domain application indexes");
|
getContext().incrementCounter("domain application indexes");
|
||||||
Key<DomainApplicationIndex> daiKey = Key.create(dai);
|
Key<DomainApplicationIndex> daiKey = Key.create(dai);
|
||||||
for (Ref<DomainApplication> ref : dai.getReferences()) {
|
for (Key<DomainApplication> key : dai.getKeys()) {
|
||||||
DomainApplication application = verifyExistence(daiKey, ref);
|
DomainApplication application = verifyExistence(daiKey, key);
|
||||||
if (application != null) {
|
if (application != null) {
|
||||||
integrity().check(
|
integrity().check(
|
||||||
dai.getFullyQualifiedDomainName().equals(application.getFullyQualifiedDomainName()),
|
dai.getFullyQualifiedDomainName().equals(application.getFullyQualifiedDomainName()),
|
||||||
|
@ -347,11 +345,11 @@ public class VerifyEntityIntegrityAction implements Runnable {
|
||||||
Key<EppResourceIndex> eriKey = Key.create(eri);
|
Key<EppResourceIndex> eriKey = Key.create(eri);
|
||||||
String eriRepoId = Key.create(eri.getId()).getName();
|
String eriRepoId = Key.create(eri.getId()).getName();
|
||||||
integrity().check(
|
integrity().check(
|
||||||
eriRepoId.equals(eri.getReference().getKey().getName()),
|
eriRepoId.equals(eri.getKey().getName()),
|
||||||
eriKey,
|
eriKey,
|
||||||
eri.getReference().getKey(),
|
eri.getKey(),
|
||||||
"EPP resource index id does not match repoId of reference");
|
"EPP resource index id does not match repoId of reference");
|
||||||
verifyExistence(eriKey, eri.getReference());
|
verifyExistence(eriKey, eri.getKey());
|
||||||
emit(MapperKey.create(EntityKind.EPP_RESOURCE, eriRepoId), eriKey);
|
emit(MapperKey.create(EntityKind.EPP_RESOURCE, eriRepoId), eriKey);
|
||||||
getContext().incrementCounter("EPP resource indexes to " + eri.getKind());
|
getContext().incrementCounter("EPP resource indexes to " + eri.getKind());
|
||||||
}
|
}
|
||||||
|
@ -366,14 +364,6 @@ public class VerifyEntityIntegrityAction implements Runnable {
|
||||||
"Target entity does not exist");
|
"Target entity does not exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
private <E> E verifyExistence(Key<?> source, @Nullable Ref<E> target) {
|
|
||||||
if (target == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return verifyExistence(source, target.getKey());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private <E> E verifyExistence(Key<?> source, @Nullable Key<E> target) {
|
private <E> E verifyExistence(Key<?> source, @Nullable Key<E> target) {
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
|
@ -383,17 +373,6 @@ public class VerifyEntityIntegrityAction implements Runnable {
|
||||||
integrity().check(entity != null, source, target, "Target entity does not exist");
|
integrity().check(entity != null, source, target, "Target entity does not exist");
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <E extends EppResource> ImmutableSet<Key<E>> refsToKeys(Iterable<Ref<E>> refs) {
|
|
||||||
return FluentIterable
|
|
||||||
.from(refs)
|
|
||||||
.transform(new Function<Ref<E>, Key<E>>() {
|
|
||||||
@Override
|
|
||||||
public Key<E> apply(Ref<E> ref) {
|
|
||||||
return ref.getKey();
|
|
||||||
}})
|
|
||||||
.toSet();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Reducer that checks integrity of foreign key entities. */
|
/** Reducer that checks integrity of foreign key entities. */
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
package google.registry.rdap;
|
package google.registry.rdap;
|
||||||
|
|
||||||
import static google.registry.model.EppResourceUtils.loadByUniqueId;
|
import static google.registry.model.EppResourceUtils.loadByUniqueId;
|
||||||
import static google.registry.model.index.ForeignKeyIndex.loadAndGetReference;
|
import static google.registry.model.index.ForeignKeyIndex.loadAndGetKey;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static google.registry.request.Action.Method.GET;
|
import static google.registry.request.Action.Method.GET;
|
||||||
import static google.registry.request.Action.Method.HEAD;
|
import static google.registry.request.Action.Method.HEAD;
|
||||||
|
@ -28,9 +28,7 @@ import com.google.common.collect.ImmutableSortedSet;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.primitives.Booleans;
|
import com.google.common.primitives.Booleans;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import com.googlecode.objectify.cmd.Query;
|
import com.googlecode.objectify.cmd.Query;
|
||||||
import com.googlecode.objectify.cmd.QueryKeys;
|
|
||||||
import google.registry.model.domain.DomainResource;
|
import google.registry.model.domain.DomainResource;
|
||||||
import google.registry.model.host.HostResource;
|
import google.registry.model.host.HostResource;
|
||||||
import google.registry.rdap.RdapJsonFormatter.BoilerplateType;
|
import google.registry.rdap.RdapJsonFormatter.BoilerplateType;
|
||||||
|
@ -164,31 +162,25 @@ public class RdapDomainSearchAction extends RdapActionBase {
|
||||||
private ImmutableList<ImmutableMap<String, Object>>
|
private ImmutableList<ImmutableMap<String, Object>>
|
||||||
searchByNameserverLdhName(final RdapSearchPattern partialStringQuery, final DateTime now)
|
searchByNameserverLdhName(final RdapSearchPattern partialStringQuery, final DateTime now)
|
||||||
throws HttpException {
|
throws HttpException {
|
||||||
ImmutableList<Ref<HostResource>> hostRefs;
|
Iterable<Key<HostResource>> hostKeys;
|
||||||
// Handle queries without a wildcard; just load the host by foreign key in the usual way.
|
// Handle queries without a wildcard; just load the host by foreign key in the usual way.
|
||||||
if (!partialStringQuery.getHasWildcard()) {
|
if (!partialStringQuery.getHasWildcard()) {
|
||||||
Ref<HostResource> hostRef = loadAndGetReference(
|
Key<HostResource> hostKey = loadAndGetKey(
|
||||||
HostResource.class, partialStringQuery.getInitialString(), now);
|
HostResource.class, partialStringQuery.getInitialString(), now);
|
||||||
if (hostRef == null) {
|
if (hostKey == null) {
|
||||||
return ImmutableList.of();
|
return ImmutableList.of();
|
||||||
}
|
}
|
||||||
hostRefs = ImmutableList.of(hostRef);
|
hostKeys = ImmutableList.of(hostKey);
|
||||||
// Handle queries with a wildcard, but no suffix. Query the host resources themselves, rather
|
// Handle queries with a wildcard, but no suffix. Query the host resources themselves, rather
|
||||||
// than the foreign key index, because then we have an index on fully qualified host name and
|
// than the foreign key index, because then we have an index on fully qualified host name and
|
||||||
// deletion time, so we can check the deletion status in the query itself. There are no pending
|
// deletion time, so we can check the deletion status in the query itself. There are no pending
|
||||||
// deletes for hosts, so we can call queryUndeleted.
|
// deletes for hosts, so we can call queryUndeleted.
|
||||||
} else if (partialStringQuery.getSuffix() == null) {
|
} else if (partialStringQuery.getSuffix() == null) {
|
||||||
// TODO (b/24463238): figure out how to limit the size of these queries effectively
|
// TODO (b/24463238): figure out how to limit the size of these queries effectively
|
||||||
Query<HostResource> query = queryUndeleted(
|
hostKeys =
|
||||||
HostResource.class,
|
queryUndeleted(HostResource.class, "fullyQualifiedHostName", partialStringQuery, 1000)
|
||||||
"fullyQualifiedHostName",
|
.keys();
|
||||||
partialStringQuery, 1000);
|
if (Iterables.isEmpty(hostKeys)) {
|
||||||
ImmutableList.Builder<Ref<HostResource>> builder = new ImmutableList.Builder<>();
|
|
||||||
for (Key<HostResource> hostResourceKey : query.keys()) {
|
|
||||||
builder.add(Ref.create(hostResourceKey));
|
|
||||||
}
|
|
||||||
hostRefs = builder.build();
|
|
||||||
if (hostRefs.isEmpty()) {
|
|
||||||
throw new NotFoundException("No matching nameservers found");
|
throw new NotFoundException("No matching nameservers found");
|
||||||
}
|
}
|
||||||
// Handle queries with a wildcard and a suffix. In this case, it is more efficient to do things
|
// Handle queries with a wildcard and a suffix. In this case, it is more efficient to do things
|
||||||
|
@ -200,24 +192,24 @@ public class RdapDomainSearchAction extends RdapActionBase {
|
||||||
if (domainResource == null) {
|
if (domainResource == null) {
|
||||||
throw new NotFoundException("No domain found for specified nameserver suffix");
|
throw new NotFoundException("No domain found for specified nameserver suffix");
|
||||||
}
|
}
|
||||||
ImmutableList.Builder<Ref<HostResource>> builder = new ImmutableList.Builder<>();
|
ImmutableList.Builder<Key<HostResource>> builder = new ImmutableList.Builder<>();
|
||||||
for (String fqhn : ImmutableSortedSet.copyOf(domainResource.getSubordinateHosts())) {
|
for (String fqhn : ImmutableSortedSet.copyOf(domainResource.getSubordinateHosts())) {
|
||||||
// We can't just check that the host name starts with the initial query string, because then
|
// 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.
|
// the query ns.exam*.example.com would match against nameserver ns.example.com.
|
||||||
if (partialStringQuery.matches(fqhn)) {
|
if (partialStringQuery.matches(fqhn)) {
|
||||||
Ref<HostResource> hostRef = loadAndGetReference(HostResource.class, fqhn, now);
|
Key<HostResource> hostKey = loadAndGetKey(HostResource.class, fqhn, now);
|
||||||
if (hostRef != null) {
|
if (hostKey != null) {
|
||||||
builder.add(hostRef);
|
builder.add(hostKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hostRefs = builder.build();
|
hostKeys = builder.build();
|
||||||
if (hostRefs.isEmpty()) {
|
if (Iterables.isEmpty(hostKeys)) {
|
||||||
throw new NotFoundException("No matching nameservers found");
|
throw new NotFoundException("No matching nameservers found");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Find all domains that link to any of these hosts, and return information about them.
|
// Find all domains that link to any of these hosts, and return information about them.
|
||||||
return searchByNameserverRefs(hostRefs, now);
|
return searchByNameserverRefs(hostKeys, now);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Searches for domains by nameserver address, returning a JSON array of domain info maps. */
|
/** Searches for domains by nameserver address, returning a JSON array of domain info maps. */
|
||||||
|
@ -226,35 +218,28 @@ public class RdapDomainSearchAction extends RdapActionBase {
|
||||||
// In theory, we could filter on the deletion time being in the future. But we can't do that in
|
// In theory, we could filter on the deletion time being in the future. But we can't do that in
|
||||||
// the query on nameserver name (because we're already using an inequality query), and it seems
|
// the query on nameserver name (because we're already using an inequality query), and it seems
|
||||||
// dangerous and confusing to filter on deletion time differently between the two queries.
|
// dangerous and confusing to filter on deletion time differently between the two queries.
|
||||||
QueryKeys<HostResource> query = ofy()
|
|
||||||
.load()
|
|
||||||
.type(HostResource.class)
|
|
||||||
.filter("inetAddresses", inetAddress.getHostAddress())
|
|
||||||
.filter("deletionTime", END_OF_TIME)
|
|
||||||
.limit(1000)
|
|
||||||
.keys();
|
|
||||||
ImmutableList.Builder<Ref<HostResource>> builder = new ImmutableList.Builder<>();
|
|
||||||
for (Key<HostResource> key : query) {
|
|
||||||
builder.add(Ref.create(key));
|
|
||||||
}
|
|
||||||
ImmutableList<Ref<HostResource>> hostRefs = builder.build();
|
|
||||||
if (hostRefs.isEmpty()) {
|
|
||||||
return ImmutableList.of();
|
|
||||||
}
|
|
||||||
// Find all domains that link to any of these hosts, and return information about them.
|
// Find all domains that link to any of these hosts, and return information about them.
|
||||||
return searchByNameserverRefs(hostRefs, now);
|
return searchByNameserverRefs(
|
||||||
|
ofy()
|
||||||
|
.load()
|
||||||
|
.type(HostResource.class)
|
||||||
|
.filter("inetAddresses", inetAddress.getHostAddress())
|
||||||
|
.filter("deletionTime", END_OF_TIME)
|
||||||
|
.limit(1000)
|
||||||
|
.keys(),
|
||||||
|
now);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Locates all domains which are linked to a set of host refs. This method is called by
|
* Locates all domains which are linked to a set of host keys. This method is called by
|
||||||
* {@link #searchByNameserverLdhName} and {@link #searchByNameserverIp} after they assemble the
|
* {@link #searchByNameserverLdhName} and {@link #searchByNameserverIp} after they assemble the
|
||||||
* relevant host refs.
|
* relevant host keys.
|
||||||
*/
|
*/
|
||||||
private ImmutableList<ImmutableMap<String, Object>>
|
private ImmutableList<ImmutableMap<String, Object>>
|
||||||
searchByNameserverRefs(final Iterable<Ref<HostResource>> hostRefs, final DateTime now) {
|
searchByNameserverRefs(final Iterable<Key<HostResource>> hostKeys, final DateTime now) {
|
||||||
// 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.
|
||||||
ImmutableList.Builder<ImmutableMap<String, Object>> builder = new ImmutableList.Builder<>();
|
ImmutableList.Builder<ImmutableMap<String, Object>> builder = new ImmutableList.Builder<>();
|
||||||
for (List<Ref<HostResource>> chunk : Iterables.partition(hostRefs, 30)) {
|
for (List<Key<HostResource>> chunk : Iterables.partition(hostKeys, 30)) {
|
||||||
Query<DomainResource> query = ofy().load()
|
Query<DomainResource> query = ofy().load()
|
||||||
.type(DomainResource.class)
|
.type(DomainResource.class)
|
||||||
.filter("nameservers.linked in", chunk)
|
.filter("nameservers.linked in", chunk)
|
||||||
|
|
|
@ -417,10 +417,10 @@ public class RdapJsonFormatter {
|
||||||
DateTime now) {
|
DateTime now) {
|
||||||
// Kick off the database loads of the nameservers that we will need.
|
// Kick off the database loads of the nameservers that we will need.
|
||||||
Map<Key<HostResource>, HostResource> loadedHosts =
|
Map<Key<HostResource>, HostResource> loadedHosts =
|
||||||
ofy().load().refs(domainResource.getNameservers());
|
ofy().load().keys(domainResource.getNameservers());
|
||||||
// And the registrant and other contacts.
|
// And the registrant and other contacts.
|
||||||
Map<Key<ContactResource>, ContactResource> loadedContacts =
|
Map<Key<ContactResource>, ContactResource> loadedContacts =
|
||||||
ofy().load().refs(domainResource.getReferencedContacts());
|
ofy().load().keys(domainResource.getReferencedContacts());
|
||||||
|
|
||||||
// Now, assemble the results, using the loaded objects as needed.
|
// Now, assemble the results, using the loaded objects as needed.
|
||||||
ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>();
|
ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>();
|
||||||
|
@ -453,8 +453,7 @@ public class RdapJsonFormatter {
|
||||||
for (DesignatedContact designatedContact : FluentIterable.from(domainResource.getContacts())
|
for (DesignatedContact designatedContact : FluentIterable.from(domainResource.getContacts())
|
||||||
.append(DesignatedContact.create(Type.REGISTRANT, domainResource.getRegistrant()))
|
.append(DesignatedContact.create(Type.REGISTRANT, domainResource.getRegistrant()))
|
||||||
.toSortedList(DESIGNATED_CONTACT_ORDERING)) {
|
.toSortedList(DESIGNATED_CONTACT_ORDERING)) {
|
||||||
ContactResource loadedContact =
|
ContactResource loadedContact = loadedContacts.get(designatedContact.getContactKey());
|
||||||
loadedContacts.get(designatedContact.getContactRef().key());
|
|
||||||
entitiesBuilder.add(makeRdapJsonForContact(
|
entitiesBuilder.add(makeRdapJsonForContact(
|
||||||
loadedContact, false, Optional.of(designatedContact.getType()), linkBase, null, now));
|
loadedContact, false, Optional.of(designatedContact.getType()), linkBase, null, now));
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,10 +14,12 @@
|
||||||
|
|
||||||
package google.registry.rde;
|
package google.registry.rde;
|
||||||
|
|
||||||
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
|
|
||||||
import com.google.common.base.Ascii;
|
import com.google.common.base.Ascii;
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.model.contact.ContactResource;
|
import google.registry.model.contact.ContactResource;
|
||||||
import google.registry.model.domain.DesignatedContact;
|
import google.registry.model.domain.DesignatedContact;
|
||||||
import google.registry.model.domain.DomainResource;
|
import google.registry.model.domain.DomainResource;
|
||||||
|
@ -161,9 +163,9 @@ final class DomainResourceToXjcConverter {
|
||||||
// o An OPTIONAL <registrant> element that contain the identifier for
|
// o An OPTIONAL <registrant> element that contain the identifier for
|
||||||
// the human or organizational social information object associated
|
// the human or organizational social information object associated
|
||||||
// as the holder of the domain name object.
|
// as the holder of the domain name object.
|
||||||
Ref<ContactResource> registrant = model.getRegistrant();
|
Key<ContactResource> registrant = model.getRegistrant();
|
||||||
if (registrant != null) {
|
if (registrant != null) {
|
||||||
bean.setRegistrant(registrant.get().getContactId());
|
bean.setRegistrant(ofy().load().key(registrant).now().getContactId());
|
||||||
}
|
}
|
||||||
|
|
||||||
// o Zero or more OPTIONAL <contact> elements that contain identifiers
|
// o Zero or more OPTIONAL <contact> elements that contain identifiers
|
||||||
|
@ -280,7 +282,7 @@ final class DomainResourceToXjcConverter {
|
||||||
/** Converts {@link DesignatedContact} to {@link XjcDomainContactType}. */
|
/** Converts {@link DesignatedContact} to {@link XjcDomainContactType}. */
|
||||||
private static XjcDomainContactType convertDesignatedContact(DesignatedContact model) {
|
private static XjcDomainContactType convertDesignatedContact(DesignatedContact model) {
|
||||||
XjcDomainContactType bean = new XjcDomainContactType();
|
XjcDomainContactType bean = new XjcDomainContactType();
|
||||||
ContactResource contact = model.getContactRef().get();
|
ContactResource contact = ofy().load().key(model.getContactKey()).now();
|
||||||
bean.setType(XjcDomainContactAttrType.fromValue(Ascii.toLowerCase(model.getType().toString())));
|
bean.setType(XjcDomainContactAttrType.fromValue(Ascii.toLowerCase(model.getType().toString())));
|
||||||
bean.setValue(contact.getContactId());
|
bean.setValue(contact.getContactId());
|
||||||
return bean;
|
return bean;
|
||||||
|
|
|
@ -136,14 +136,14 @@ final class AllocateDomainCommand extends MutatingEppToolCommand {
|
||||||
for (DesignatedContact contact : application.getContacts()) {
|
for (DesignatedContact contact : application.getContacts()) {
|
||||||
contactsMapBuilder.put(
|
contactsMapBuilder.put(
|
||||||
Ascii.toLowerCase(contact.getType().toString()),
|
Ascii.toLowerCase(contact.getType().toString()),
|
||||||
contact.getContactRef().get().getForeignKey());
|
ofy().load().key(contact.getContactKey()).now().getForeignKey());
|
||||||
}
|
}
|
||||||
LaunchNotice launchNotice = application.getLaunchNotice();
|
LaunchNotice launchNotice = application.getLaunchNotice();
|
||||||
addSoyRecord(application.getCurrentSponsorClientId(), new SoyMapData(
|
addSoyRecord(application.getCurrentSponsorClientId(), new SoyMapData(
|
||||||
"name", application.getFullyQualifiedDomainName(),
|
"name", application.getFullyQualifiedDomainName(),
|
||||||
"period", period.getValue(),
|
"period", period.getValue(),
|
||||||
"nameservers", application.loadNameserverFullyQualifiedHostNames(),
|
"nameservers", application.loadNameserverFullyQualifiedHostNames(),
|
||||||
"registrant", application.getRegistrant().get().getForeignKey(),
|
"registrant", ofy().load().key(application.getRegistrant()).now().getForeignKey(),
|
||||||
"contacts", contactsMapBuilder.build(),
|
"contacts", contactsMapBuilder.build(),
|
||||||
"authInfo", application.getAuthInfo().getPw().getValue(),
|
"authInfo", application.getAuthInfo().getPw().getValue(),
|
||||||
"smdId", application.getEncodedSignedMarks().isEmpty()
|
"smdId", application.getEncodedSignedMarks().isEmpty()
|
||||||
|
|
|
@ -101,7 +101,7 @@ final class AuctionStatusCommand implements RemoteApiCommand, GtechCommand {
|
||||||
new Function<DomainApplication, String>() {
|
new Function<DomainApplication, String>() {
|
||||||
@Override
|
@Override
|
||||||
public String apply(DomainApplication app) {
|
public String apply(DomainApplication app) {
|
||||||
ContactResource registrant = checkNotNull(app.getRegistrant().get());
|
ContactResource registrant = checkNotNull(ofy().load().key(app.getRegistrant()).now());
|
||||||
Object[] keysAndValues = new Object[] {
|
Object[] keysAndValues = new Object[] {
|
||||||
"Domain", app.getFullyQualifiedDomainName(),
|
"Domain", app.getFullyQualifiedDomainName(),
|
||||||
"Type", app.getEncodedSignedMarks().isEmpty() ? "Landrush" : "Sunrise",
|
"Type", app.getEncodedSignedMarks().isEmpty() ? "Landrush" : "Sunrise",
|
||||||
|
|
|
@ -93,7 +93,7 @@ final class DeleteEppResourceCommand extends MutatingCommand {
|
||||||
System.out.printf("Creating non-existent ForeignKeyIndex for: %s\n", key);
|
System.out.printf("Creating non-existent ForeignKeyIndex for: %s\n", key);
|
||||||
stageEntityChange(null, ForeignKeyIndex.create(resource, now));
|
stageEntityChange(null, ForeignKeyIndex.create(resource, now));
|
||||||
} else {
|
} else {
|
||||||
if (fki.getReference().key().equals(key)) {
|
if (fki.getResourceKey().equals(key)) {
|
||||||
if (isBeforeOrAt(fki.getDeletionTime(), now)) {
|
if (isBeforeOrAt(fki.getDeletionTime(), now)) {
|
||||||
System.out.printf("ForeignKeyIndex already deleted for: %s\n", key);
|
System.out.printf("ForeignKeyIndex already deleted for: %s\n", key);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -172,7 +172,7 @@ final class GenerateApplicationsReportCommand implements RemoteApiCommand, Gtech
|
||||||
domainApplication.getEncodedSignedMarks().isEmpty() ? "landrush" : "sunrise",
|
domainApplication.getEncodedSignedMarks().isEmpty() ? "landrush" : "sunrise",
|
||||||
domainApplication.getApplicationStatus(),
|
domainApplication.getApplicationStatus(),
|
||||||
domainApplication.getCurrentSponsorClientId(),
|
domainApplication.getCurrentSponsorClientId(),
|
||||||
domainApplication.getRegistrant().get().getEmailAddress(),
|
ofy().load().key(domainApplication.getRegistrant()).now().getEmailAddress(),
|
||||||
validityMessage);
|
validityMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,8 @@ final class GenerateAuctionDataCommand implements RemoteApiCommand, GtechCommand
|
||||||
+ "Can't process contending applications for %s because some applications "
|
+ "Can't process contending applications for %s because some applications "
|
||||||
+ "are not yet validated.", domainName);
|
+ "are not yet validated.", domainName);
|
||||||
|
|
||||||
ContactResource registrant = checkNotNull(domainApplication.getRegistrant().get());
|
ContactResource registrant =
|
||||||
|
ofy().load().key(checkNotNull(domainApplication.getRegistrant())).now();
|
||||||
result.add(emitApplication(domainApplication, registrant));
|
result.add(emitApplication(domainApplication, registrant));
|
||||||
|
|
||||||
// Ensure the registrant's email address is unique across the contending applications.
|
// Ensure the registrant's email address is unique across the contending applications.
|
||||||
|
|
|
@ -201,7 +201,7 @@ final class GenerateEscrowDepositCommand implements RemoteApiCommand {
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public Key<EppResource> apply(EppResourceIndex index) {
|
public Key<EppResource> apply(EppResourceIndex index) {
|
||||||
return (Key<EppResource>) index.getReference().getKey();
|
return (Key<EppResource>) index.getKey();
|
||||||
}}))
|
}}))
|
||||||
.values();
|
.values();
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import static com.google.common.base.Strings.nullToEmpty;
|
||||||
import static com.google.common.collect.Sets.difference;
|
import static com.google.common.collect.Sets.difference;
|
||||||
import static google.registry.model.EppResourceUtils.checkResourcesExist;
|
import static google.registry.model.EppResourceUtils.checkResourcesExist;
|
||||||
import static google.registry.model.EppResourceUtils.loadByUniqueId;
|
import static google.registry.model.EppResourceUtils.loadByUniqueId;
|
||||||
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static org.joda.time.DateTimeZone.UTC;
|
import static org.joda.time.DateTimeZone.UTC;
|
||||||
|
|
||||||
import com.beust.jcommander.Parameter;
|
import com.beust.jcommander.Parameter;
|
||||||
|
@ -28,7 +29,6 @@ import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.ImmutableSortedSet;
|
import com.google.common.collect.ImmutableSortedSet;
|
||||||
import com.google.template.soy.data.SoyMapData;
|
import com.google.template.soy.data.SoyMapData;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import google.registry.model.domain.DomainResource;
|
import google.registry.model.domain.DomainResource;
|
||||||
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;
|
||||||
|
@ -147,8 +147,8 @@ final class UniformRapidSuspensionCommand extends MutatingEppToolCommand impleme
|
||||||
|
|
||||||
private ImmutableSortedSet<String> getExistingNameservers(DomainResource domain) {
|
private ImmutableSortedSet<String> getExistingNameservers(DomainResource domain) {
|
||||||
ImmutableSortedSet.Builder<String> nameservers = ImmutableSortedSet.naturalOrder();
|
ImmutableSortedSet.Builder<String> nameservers = ImmutableSortedSet.naturalOrder();
|
||||||
for (Ref<HostResource> nameserverRef : domain.getNameservers()) {
|
for (HostResource host : ofy().load().keys(domain.getNameservers()).values()) {
|
||||||
nameservers.add(nameserverRef.get().getForeignKey());
|
nameservers.add(host.getForeignKey());
|
||||||
}
|
}
|
||||||
return nameservers.build();
|
return nameservers.build();
|
||||||
}
|
}
|
||||||
|
|
|
@ -272,7 +272,7 @@ public class GenerateZoneFilesAction implements Runnable, JsonActionRunner.JsonA
|
||||||
*/
|
*/
|
||||||
private static String domainStanza(DomainResource domain, DateTime exportTime) {
|
private static String domainStanza(DomainResource domain, DateTime exportTime) {
|
||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
for (HostResource nameserver : ofy().load().refs(domain.getNameservers()).values()) {
|
for (HostResource nameserver : ofy().load().keys(domain.getNameservers()).values()) {
|
||||||
result.append(String.format(
|
result.append(String.format(
|
||||||
NS_FORMAT,
|
NS_FORMAT,
|
||||||
domain.getFullyQualifiedDomainName(),
|
domain.getFullyQualifiedDomainName(),
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class KillAllEppResourcesAction implements Runnable {
|
||||||
public void map(final EppResourceIndex eri) {
|
public void map(final EppResourceIndex eri) {
|
||||||
Key<EppResourceIndex> eriKey = Key.create(eri);
|
Key<EppResourceIndex> eriKey = Key.create(eri);
|
||||||
emitAndIncrementCounter(eriKey, eriKey);
|
emitAndIncrementCounter(eriKey, eriKey);
|
||||||
Key<?> resourceKey = eri.getReference().getKey();
|
Key<?> resourceKey = eri.getKey();
|
||||||
for (Key<Object> key : ofy().load().ancestor(resourceKey).keys()) {
|
for (Key<Object> key : ofy().load().ancestor(resourceKey).keys()) {
|
||||||
emitAndIncrementCounter(resourceKey, key);
|
emitAndIncrementCounter(resourceKey, key);
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ public class KillAllEppResourcesAction implements Runnable {
|
||||||
new Work<EppResource>() {
|
new Work<EppResource>() {
|
||||||
@Override
|
@Override
|
||||||
public EppResource run() {
|
public EppResource run() {
|
||||||
return eri.getReference().get();
|
return ofy().load().key(eri.getKey()).now();
|
||||||
}});
|
}});
|
||||||
// TODO(b/28247733): What about FKI's for renamed hosts?
|
// TODO(b/28247733): What about FKI's for renamed hosts?
|
||||||
Key<?> indexKey = resource instanceof DomainApplication
|
Key<?> indexKey = resource instanceof DomainApplication
|
||||||
|
|
|
@ -16,6 +16,7 @@ package google.registry.whois;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.collect.Iterables.tryFind;
|
import static com.google.common.collect.Iterables.tryFind;
|
||||||
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static google.registry.util.CollectionUtils.isNullOrEmpty;
|
import static google.registry.util.CollectionUtils.isNullOrEmpty;
|
||||||
import static google.registry.xml.UtcDateTimeAdapter.getFormattedString;
|
import static google.registry.xml.UtcDateTimeAdapter.getFormattedString;
|
||||||
|
|
||||||
|
@ -23,7 +24,7 @@ import com.google.common.base.Function;
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.model.contact.ContactPhoneNumber;
|
import google.registry.model.contact.ContactPhoneNumber;
|
||||||
import google.registry.model.contact.ContactResource;
|
import google.registry.model.contact.ContactResource;
|
||||||
import google.registry.model.contact.PostalInfo;
|
import google.registry.model.contact.PostalInfo;
|
||||||
|
@ -100,14 +101,14 @@ final class DomainWhoisResponse extends WhoisResponseImpl {
|
||||||
|
|
||||||
/** Returns the contact of the given type, or null if it does not exist. */
|
/** Returns the contact of the given type, or null if it does not exist. */
|
||||||
@Nullable
|
@Nullable
|
||||||
private Ref<ContactResource> getContactReference(final Type type) {
|
private Key<ContactResource> getContactReference(final Type type) {
|
||||||
Optional<DesignatedContact> contactOfType = tryFind(domain.getContacts(),
|
Optional<DesignatedContact> contactOfType = tryFind(domain.getContacts(),
|
||||||
new Predicate<DesignatedContact>() {
|
new Predicate<DesignatedContact>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(DesignatedContact d) {
|
public boolean apply(DesignatedContact d) {
|
||||||
return d.getType() == type;
|
return d.getType() == type;
|
||||||
}});
|
}});
|
||||||
return contactOfType.isPresent() ? contactOfType.get().getContactRef() : null;
|
return contactOfType.isPresent() ? contactOfType.get().getContactKey() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Output emitter with logic for domains. */
|
/** Output emitter with logic for domains. */
|
||||||
|
@ -123,7 +124,7 @@ final class DomainWhoisResponse extends WhoisResponseImpl {
|
||||||
/** Emit the contact entry of the given type. */
|
/** Emit the contact entry of the given type. */
|
||||||
DomainEmitter emitContact(
|
DomainEmitter emitContact(
|
||||||
String contactType,
|
String contactType,
|
||||||
@Nullable Ref<ContactResource> contact,
|
@Nullable Key<ContactResource> contact,
|
||||||
boolean preferUnicode) {
|
boolean preferUnicode) {
|
||||||
if (contact == null) {
|
if (contact == null) {
|
||||||
return this;
|
return this;
|
||||||
|
@ -131,7 +132,7 @@ final class DomainWhoisResponse extends WhoisResponseImpl {
|
||||||
// If we refer to a contact that doesn't exist, that's a bug. It means referential integrity
|
// If we refer to a contact that doesn't exist, that's a bug. It means referential integrity
|
||||||
// has somehow been broken. We skip the rest of this contact, but log it to hopefully bring it
|
// has somehow been broken. We skip the rest of this contact, but log it to hopefully bring it
|
||||||
// someone's attention.
|
// someone's attention.
|
||||||
ContactResource contactResource = contact.get();
|
ContactResource contactResource = ofy().load().key(contact).now();
|
||||||
if (contactResource == null) {
|
if (contactResource == null) {
|
||||||
logger.severefmt("(BUG) Broken reference found from domain %s to contact %s",
|
logger.severefmt("(BUG) Broken reference found from domain %s to contact %s",
|
||||||
domain.getFullyQualifiedDomainName(), contact);
|
domain.getFullyQualifiedDomainName(), contact);
|
||||||
|
|
|
@ -37,7 +37,7 @@ import com.google.common.collect.ImmutableMap;
|
||||||
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 com.google.common.net.InetAddresses;
|
import com.google.common.net.InetAddresses;
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.dns.writer.clouddns.CloudDnsWriter.ZoneStateException;
|
import google.registry.dns.writer.clouddns.CloudDnsWriter.ZoneStateException;
|
||||||
import google.registry.model.domain.DomainResource;
|
import google.registry.model.domain.DomainResource;
|
||||||
import google.registry.model.domain.secdns.DelegationSignerData;
|
import google.registry.model.domain.secdns.DelegationSignerData;
|
||||||
|
@ -285,9 +285,9 @@ public class CloudDnsWriterTest {
|
||||||
i, DS_DATA.getAlgorithm(), DS_DATA.getDigestType(), DS_DATA.getDigest()));
|
i, DS_DATA.getAlgorithm(), DS_DATA.getDigestType(), DS_DATA.getDigest()));
|
||||||
}
|
}
|
||||||
|
|
||||||
ImmutableSet.Builder<Ref<HostResource>> hostResourceRefBuilder = new ImmutableSet.Builder<>();
|
ImmutableSet.Builder<Key<HostResource>> hostResourceRefBuilder = new ImmutableSet.Builder<>();
|
||||||
for (HostResource nameserver : nameservers) {
|
for (HostResource nameserver : nameservers) {
|
||||||
hostResourceRefBuilder.add(Ref.create(nameserver));
|
hostResourceRefBuilder.add(Key.create(nameserver));
|
||||||
}
|
}
|
||||||
|
|
||||||
return newDomainResource(domainName)
|
return newDomainResource(domainName)
|
||||||
|
|
|
@ -34,7 +34,7 @@ import com.google.common.base.VerifyException;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.net.InetAddresses;
|
import com.google.common.net.InetAddresses;
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.model.domain.DomainResource;
|
import google.registry.model.domain.DomainResource;
|
||||||
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;
|
||||||
|
@ -107,7 +107,7 @@ public class DnsUpdateWriterTest {
|
||||||
DomainResource domain =
|
DomainResource domain =
|
||||||
persistActiveDomain("example.tld")
|
persistActiveDomain("example.tld")
|
||||||
.asBuilder()
|
.asBuilder()
|
||||||
.setNameservers(ImmutableSet.of(Ref.create(host1), Ref.create(host2)))
|
.setNameservers(ImmutableSet.of(Key.create(host1), Key.create(host2)))
|
||||||
.build();
|
.build();
|
||||||
persistResource(domain);
|
persistResource(domain);
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ public class DnsUpdateWriterTest {
|
||||||
DomainResource domain =
|
DomainResource domain =
|
||||||
persistActiveDomain("example.tld")
|
persistActiveDomain("example.tld")
|
||||||
.asBuilder()
|
.asBuilder()
|
||||||
.setNameservers(ImmutableSet.of(Ref.create(persistActiveHost("ns1.example.tld"))))
|
.setNameservers(ImmutableSet.of(Key.create(persistActiveHost("ns1.example.tld"))))
|
||||||
.setDsData(
|
.setDsData(
|
||||||
ImmutableSet.of(
|
ImmutableSet.of(
|
||||||
DelegationSignerData.create(1, 3, 1, base16().decode("0123456789ABCDEF"))))
|
DelegationSignerData.create(1, 3, 1, base16().decode("0123456789ABCDEF"))))
|
||||||
|
@ -150,7 +150,7 @@ public class DnsUpdateWriterTest {
|
||||||
persistActiveDomain("example.tld")
|
persistActiveDomain("example.tld")
|
||||||
.asBuilder()
|
.asBuilder()
|
||||||
.addStatusValue(StatusValue.SERVER_HOLD)
|
.addStatusValue(StatusValue.SERVER_HOLD)
|
||||||
.setNameservers(ImmutableSet.of(Ref.create(persistActiveHost("ns1.example.tld"))))
|
.setNameservers(ImmutableSet.of(Key.create(persistActiveHost("ns1.example.tld"))))
|
||||||
.build();
|
.build();
|
||||||
persistResource(domain);
|
persistResource(domain);
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ public class DnsUpdateWriterTest {
|
||||||
newDomainResource("example.tld")
|
newDomainResource("example.tld")
|
||||||
.asBuilder()
|
.asBuilder()
|
||||||
.addSubordinateHost("ns1.example.tld")
|
.addSubordinateHost("ns1.example.tld")
|
||||||
.addNameservers(ImmutableSet.of(Ref.create(host)))
|
.addNameservers(ImmutableSet.of(Key.create(host)))
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
writer.publishHost("ns1.example.tld");
|
writer.publishHost("ns1.example.tld");
|
||||||
|
@ -229,7 +229,7 @@ public class DnsUpdateWriterTest {
|
||||||
persistResource(
|
persistResource(
|
||||||
persistActiveDomain("example.tld")
|
persistActiveDomain("example.tld")
|
||||||
.asBuilder()
|
.asBuilder()
|
||||||
.setNameservers(ImmutableSet.of(Ref.create(persistActiveHost("ns1.example.com"))))
|
.setNameservers(ImmutableSet.of(Key.create(persistActiveHost("ns1.example.com"))))
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
writer.publishHost("ns1.example.tld");
|
writer.publishHost("ns1.example.tld");
|
||||||
|
@ -262,7 +262,7 @@ public class DnsUpdateWriterTest {
|
||||||
.asBuilder()
|
.asBuilder()
|
||||||
.addSubordinateHost("ns1.example.tld")
|
.addSubordinateHost("ns1.example.tld")
|
||||||
.addNameservers(
|
.addNameservers(
|
||||||
ImmutableSet.of(Ref.create(externalNameserver), Ref.create(inBailiwickNameserver)))
|
ImmutableSet.of(Key.create(externalNameserver), Key.create(inBailiwickNameserver)))
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
writer.publishDomain("example.tld");
|
writer.publishDomain("example.tld");
|
||||||
|
@ -296,7 +296,7 @@ public class DnsUpdateWriterTest {
|
||||||
.asBuilder()
|
.asBuilder()
|
||||||
.addSubordinateHost("ns1.example.tld")
|
.addSubordinateHost("ns1.example.tld")
|
||||||
.addSubordinateHost("foo.example.tld")
|
.addSubordinateHost("foo.example.tld")
|
||||||
.addNameservers(ImmutableSet.of(Ref.create(inBailiwickNameserver)))
|
.addNameservers(ImmutableSet.of(Key.create(inBailiwickNameserver)))
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
writer.publishDomain("example.tld");
|
writer.publishDomain("example.tld");
|
||||||
|
@ -318,7 +318,7 @@ public class DnsUpdateWriterTest {
|
||||||
DomainResource domain =
|
DomainResource domain =
|
||||||
persistActiveDomain("example.tld")
|
persistActiveDomain("example.tld")
|
||||||
.asBuilder()
|
.asBuilder()
|
||||||
.setNameservers(ImmutableSet.of(Ref.create(persistActiveHost("ns1.example.tld"))))
|
.setNameservers(ImmutableSet.of(Key.create(persistActiveHost("ns1.example.tld"))))
|
||||||
.build();
|
.build();
|
||||||
persistResource(domain);
|
persistResource(domain);
|
||||||
when(mockResolver.send(any(Message.class))).thenReturn(messageWithResponseCode(Rcode.SERVFAIL));
|
when(mockResolver.send(any(Message.class))).thenReturn(messageWithResponseCode(Rcode.SERVFAIL));
|
||||||
|
|
|
@ -186,7 +186,7 @@ public class SyncRegistrarsSheetTest {
|
||||||
.setEmailAddress("pride@example.net")
|
.setEmailAddress("pride@example.net")
|
||||||
.setTypes(ImmutableSet.of(RegistrarContact.Type.TECH))
|
.setTypes(ImmutableSet.of(RegistrarContact.Type.TECH))
|
||||||
.build());
|
.build());
|
||||||
// Use registrar ref for contacts' parent.
|
// Use registrar key for contacts' parent.
|
||||||
persistSimpleResources(contacts);
|
persistSimpleResources(contacts);
|
||||||
persistResource(registrar);
|
persistResource(registrar);
|
||||||
|
|
||||||
|
|
|
@ -146,8 +146,8 @@ public class EppCommitLogsTest extends ShardableTestCase {
|
||||||
.isEqualTo(domainAfterCreate);
|
.isEqualTo(domainAfterCreate);
|
||||||
|
|
||||||
// Both updates happened on the same day. Since the revisions field has day granularity, the
|
// Both updates happened on the same day. Since the revisions field has day granularity, the
|
||||||
// reference to the first update should have been overwritten by the second, and its timestamp
|
// key to the first update should have been overwritten by the second, and its timestamp rolled
|
||||||
// rolled forward. So we have to fall back to the last revision before midnight.
|
// forward. So we have to fall back to the last revision before midnight.
|
||||||
ofy().clearSessionCache();
|
ofy().clearSessionCache();
|
||||||
assertThat(loadAtPointInTime(latest, timeAtFirstUpdate).now())
|
assertThat(loadAtPointInTime(latest, timeAtFirstUpdate).now())
|
||||||
.isEqualTo(domainAfterCreate);
|
.isEqualTo(domainAfterCreate);
|
||||||
|
|
|
@ -224,10 +224,11 @@ public abstract class FlowTestCase<F extends Flow> extends ShardableTestCase {
|
||||||
assertThat(gracePeriod.hasBillingEvent())
|
assertThat(gracePeriod.hasBillingEvent())
|
||||||
.named("Billing event is present for grace period: " + gracePeriod)
|
.named("Billing event is present for grace period: " + gracePeriod)
|
||||||
.isTrue();
|
.isTrue();
|
||||||
return firstNonNull(
|
return ofy().load()
|
||||||
gracePeriod.getOneTimeBillingEvent(),
|
.key(firstNonNull(
|
||||||
gracePeriod.getRecurringBillingEvent())
|
gracePeriod.getOneTimeBillingEvent(),
|
||||||
.get();
|
gracePeriod.getRecurringBillingEvent()))
|
||||||
|
.now();
|
||||||
}};
|
}};
|
||||||
assertThat(canonicalizeGracePeriods(Maps.toMap(actual, gracePeriodExpander)))
|
assertThat(canonicalizeGracePeriods(Maps.toMap(actual, gracePeriodExpander)))
|
||||||
.isEqualTo(canonicalizeGracePeriods(expected));
|
.isEqualTo(canonicalizeGracePeriods(expected));
|
||||||
|
|
|
@ -128,7 +128,8 @@ public abstract class ResourceFlowTestCase<F extends Flow, R extends EppResource
|
||||||
.filter(new Predicate<EppResourceIndex>() {
|
.filter(new Predicate<EppResourceIndex>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(EppResourceIndex index) {
|
public boolean apply(EppResourceIndex index) {
|
||||||
return index.getReference().get().equals(resource);
|
return Key.create(resource).equals(index.getKey())
|
||||||
|
&& ofy().load().key(index.getKey()).now().equals(resource);
|
||||||
}})
|
}})
|
||||||
.toList();
|
.toList();
|
||||||
assertThat(indices).hasSize(1);
|
assertThat(indices).hasSize(1);
|
||||||
|
|
|
@ -32,7 +32,6 @@ import com.google.common.collect.FluentIterable;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import google.registry.model.contact.ContactAddress;
|
import google.registry.model.contact.ContactAddress;
|
||||||
import google.registry.model.contact.ContactPhoneNumber;
|
import google.registry.model.contact.ContactPhoneNumber;
|
||||||
import google.registry.model.contact.ContactResource;
|
import google.registry.model.contact.ContactResource;
|
||||||
|
@ -75,7 +74,7 @@ public class DeleteContactResourceActionTest
|
||||||
assertAboutContacts().that(contactUsed).doesNotHaveStatusValue(StatusValue.PENDING_DELETE)
|
assertAboutContacts().that(contactUsed).doesNotHaveStatusValue(StatusValue.PENDING_DELETE)
|
||||||
.and().hasDeletionTime(END_OF_TIME);
|
.and().hasDeletionTime(END_OF_TIME);
|
||||||
domain = loadByUniqueId(DomainResource.class, "example.tld", now);
|
domain = loadByUniqueId(DomainResource.class, "example.tld", now);
|
||||||
assertThat(domain.getReferencedContacts()).contains(Ref.create(contactUsed));
|
assertThat(domain.getReferencedContacts()).contains(Key.create(contactUsed));
|
||||||
HistoryEntry historyEntry =
|
HistoryEntry historyEntry =
|
||||||
getOnlyHistoryEntryOfType(contactUsed, HistoryEntry.Type.CONTACT_DELETE_FAILURE);
|
getOnlyHistoryEntryOfType(contactUsed, HistoryEntry.Type.CONTACT_DELETE_FAILURE);
|
||||||
assertPollMessageFor(
|
assertPollMessageFor(
|
||||||
|
|
|
@ -28,7 +28,6 @@ import static google.registry.testing.DatastoreHelper.persistResource;
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import google.registry.mapreduce.MapreduceRunner;
|
import google.registry.mapreduce.MapreduceRunner;
|
||||||
import google.registry.model.contact.ContactResource;
|
import google.registry.model.contact.ContactResource;
|
||||||
import google.registry.model.domain.DomainResource;
|
import google.registry.model.domain.DomainResource;
|
||||||
|
@ -81,7 +80,7 @@ public abstract class DeleteEppResourceActionTestCase<T extends DeleteEppResourc
|
||||||
hostUsed = persistActiveHost("ns1.example.tld");
|
hostUsed = persistActiveHost("ns1.example.tld");
|
||||||
domain = persistResource(
|
domain = persistResource(
|
||||||
newDomainResource("example.tld", contactUsed).asBuilder()
|
newDomainResource("example.tld", contactUsed).asBuilder()
|
||||||
.setNameservers(ImmutableSet.of(Ref.create(hostUsed)))
|
.setNameservers(ImmutableSet.of(Key.create(hostUsed)))
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@ import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import google.registry.model.domain.DomainResource;
|
import google.registry.model.domain.DomainResource;
|
||||||
import google.registry.model.eppcommon.StatusValue;
|
import google.registry.model.eppcommon.StatusValue;
|
||||||
import google.registry.model.host.HostResource;
|
import google.registry.model.host.HostResource;
|
||||||
|
@ -64,7 +63,7 @@ public class DeleteHostResourceActionTest
|
||||||
assertAboutHosts().that(hostUsed).doesNotHaveStatusValue(StatusValue.PENDING_DELETE)
|
assertAboutHosts().that(hostUsed).doesNotHaveStatusValue(StatusValue.PENDING_DELETE)
|
||||||
.and().hasDeletionTime(END_OF_TIME);
|
.and().hasDeletionTime(END_OF_TIME);
|
||||||
domain = loadByUniqueId(DomainResource.class, "example.tld", now);
|
domain = loadByUniqueId(DomainResource.class, "example.tld", now);
|
||||||
assertThat(domain.getNameservers()).contains(Ref.create(hostUsed));
|
assertThat(domain.getNameservers()).contains(Key.create(hostUsed));
|
||||||
HistoryEntry historyEntry =
|
HistoryEntry historyEntry =
|
||||||
getOnlyHistoryEntryOfType(hostUsed, HistoryEntry.Type.HOST_DELETE_FAILURE);
|
getOnlyHistoryEntryOfType(hostUsed, HistoryEntry.Type.HOST_DELETE_FAILURE);
|
||||||
assertPollMessageFor(
|
assertPollMessageFor(
|
||||||
|
@ -126,7 +125,7 @@ public class DeleteHostResourceActionTest
|
||||||
persistResource(
|
persistResource(
|
||||||
hostUnused.asBuilder()
|
hostUnused.asBuilder()
|
||||||
.addStatusValue(StatusValue.PENDING_DELETE)
|
.addStatusValue(StatusValue.PENDING_DELETE)
|
||||||
.setSuperordinateDomain(Ref.create(domain))
|
.setSuperordinateDomain(Key.create(domain))
|
||||||
.build());
|
.build());
|
||||||
runMapreduceWithKeyParam(Key.create(hostUnused).getString());
|
runMapreduceWithKeyParam(Key.create(hostUnused).getString());
|
||||||
// Check that the host is deleted as of now.
|
// Check that the host is deleted as of now.
|
||||||
|
|
|
@ -29,7 +29,6 @@ import static org.mockito.Mockito.verifyZeroInteractions;
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import google.registry.dns.DnsQueue;
|
import google.registry.dns.DnsQueue;
|
||||||
import google.registry.mapreduce.MapreduceRunner;
|
import google.registry.mapreduce.MapreduceRunner;
|
||||||
import google.registry.model.host.HostResource;
|
import google.registry.model.host.HostResource;
|
||||||
|
@ -74,21 +73,21 @@ public class DnsRefreshForHostRenameActionTest
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_dnsUpdateEnqueued() throws Exception {
|
public void testSuccess_dnsUpdateEnqueued() throws Exception {
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
Ref<HostResource> renamedHostRef = Ref.create(persistActiveHost("ns1.example.tld"));
|
Key<HostResource> renamedHostKey = Key.create(persistActiveHost("ns1.example.tld"));
|
||||||
Ref<HostResource> otherHostRef = Ref.create(persistActiveHost("ns2.example.tld"));
|
Key<HostResource> otherHostKey = Key.create(persistActiveHost("ns2.example.tld"));
|
||||||
persistResource(newDomainApplication("notadomain.tld").asBuilder()
|
persistResource(newDomainApplication("notadomain.tld").asBuilder()
|
||||||
.setNameservers(ImmutableSet.of(renamedHostRef))
|
.setNameservers(ImmutableSet.of(renamedHostKey))
|
||||||
.build());
|
.build());
|
||||||
persistResource(newDomainResource("example.tld").asBuilder()
|
persistResource(newDomainResource("example.tld").asBuilder()
|
||||||
.setNameservers(ImmutableSet.of(renamedHostRef))
|
.setNameservers(ImmutableSet.of(renamedHostKey))
|
||||||
.build());
|
.build());
|
||||||
persistResource(newDomainResource("otherexample.tld").asBuilder()
|
persistResource(newDomainResource("otherexample.tld").asBuilder()
|
||||||
.setNameservers(ImmutableSet.of(renamedHostRef))
|
.setNameservers(ImmutableSet.of(renamedHostKey))
|
||||||
.build());
|
.build());
|
||||||
persistResource(newDomainResource("untouched.tld").asBuilder()
|
persistResource(newDomainResource("untouched.tld").asBuilder()
|
||||||
.setNameservers(ImmutableSet.of(otherHostRef))
|
.setNameservers(ImmutableSet.of(otherHostKey))
|
||||||
.build());
|
.build());
|
||||||
runMapreduce(renamedHostRef.getKey().getString());
|
runMapreduce(renamedHostKey.getString());
|
||||||
verify(dnsQueue).addDomainRefreshTask("example.tld");
|
verify(dnsQueue).addDomainRefreshTask("example.tld");
|
||||||
verify(dnsQueue).addDomainRefreshTask("otherexample.tld");
|
verify(dnsQueue).addDomainRefreshTask("otherexample.tld");
|
||||||
verifyNoMoreInteractions(dnsQueue);
|
verifyNoMoreInteractions(dnsQueue);
|
||||||
|
@ -97,12 +96,12 @@ public class DnsRefreshForHostRenameActionTest
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_noDnsTasksForDeletedDomain() throws Exception {
|
public void testSuccess_noDnsTasksForDeletedDomain() throws Exception {
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
Ref<HostResource> renamedHostRef = Ref.create(persistActiveHost("ns1.example.tld"));
|
Key<HostResource> renamedHostKey = Key.create(persistActiveHost("ns1.example.tld"));
|
||||||
persistResource(newDomainResource("example.tld").asBuilder()
|
persistResource(newDomainResource("example.tld").asBuilder()
|
||||||
.setNameservers(ImmutableSet.of(renamedHostRef))
|
.setNameservers(ImmutableSet.of(renamedHostKey))
|
||||||
.setDeletionTime(START_OF_TIME)
|
.setDeletionTime(START_OF_TIME)
|
||||||
.build());
|
.build());
|
||||||
runMapreduce(renamedHostRef.getKey().getString());
|
runMapreduce(renamedHostKey.getString());
|
||||||
verifyZeroInteractions(dnsQueue);
|
verifyZeroInteractions(dnsQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ package google.registry.flows.domain;
|
||||||
import static com.google.common.io.BaseEncoding.base16;
|
import static com.google.common.io.BaseEncoding.base16;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static google.registry.model.EppResourceUtils.loadByUniqueId;
|
import static google.registry.model.EppResourceUtils.loadByUniqueId;
|
||||||
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static google.registry.testing.DatastoreHelper.assertBillingEvents;
|
import static google.registry.testing.DatastoreHelper.assertBillingEvents;
|
||||||
import static google.registry.testing.DatastoreHelper.createTld;
|
import static google.registry.testing.DatastoreHelper.createTld;
|
||||||
import static google.registry.testing.DatastoreHelper.getOnlyHistoryEntryOfType;
|
import static google.registry.testing.DatastoreHelper.getOnlyHistoryEntryOfType;
|
||||||
|
@ -39,7 +40,7 @@ import static org.joda.money.CurrencyUnit.USD;
|
||||||
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 com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.flows.ResourceCreateFlow.ResourceAlreadyExistsException;
|
import google.registry.flows.ResourceCreateFlow.ResourceAlreadyExistsException;
|
||||||
import google.registry.flows.ResourceFlowTestCase;
|
import google.registry.flows.ResourceFlowTestCase;
|
||||||
import google.registry.flows.domain.DomainAllocateFlow.HasFinalStatusException;
|
import google.registry.flows.domain.DomainAllocateFlow.HasFinalStatusException;
|
||||||
|
@ -208,11 +209,11 @@ public class DomainAllocateFlowTest
|
||||||
CLIENT_ID,
|
CLIENT_ID,
|
||||||
null),
|
null),
|
||||||
createBillingEvent));
|
createBillingEvent));
|
||||||
assertThat(domain.getAutorenewBillingEvent().get().getEventTime())
|
assertThat(ofy().load().key(domain.getAutorenewBillingEvent()).now().getEventTime())
|
||||||
.isEqualTo(domain.getRegistrationExpirationTime());
|
.isEqualTo(domain.getRegistrationExpirationTime());
|
||||||
|
|
||||||
assertThat(domain.getApplicationTime()).isEqualTo(APPLICATION_TIME);
|
assertThat(domain.getApplicationTime()).isEqualTo(APPLICATION_TIME);
|
||||||
assertThat(domain.getApplication()).isEqualTo(Ref.create(application));
|
assertThat(domain.getApplication()).isEqualTo(Key.create(application));
|
||||||
if (nameservers == 0) {
|
if (nameservers == 0) {
|
||||||
assertNoDnsTasksEnqueued();
|
assertNoDnsTasksEnqueued();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -26,7 +26,7 @@ import static google.registry.testing.DatastoreHelper.persistResource;
|
||||||
import static google.registry.testing.GenericEppResourceSubject.assertAboutEppResources;
|
import static google.registry.testing.GenericEppResourceSubject.assertAboutEppResources;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.flows.EppException.UnimplementedExtensionException;
|
import google.registry.flows.EppException.UnimplementedExtensionException;
|
||||||
import google.registry.flows.ResourceFlow.BadCommandForRegistryPhaseException;
|
import google.registry.flows.ResourceFlow.BadCommandForRegistryPhaseException;
|
||||||
import google.registry.flows.ResourceFlowTestCase;
|
import google.registry.flows.ResourceFlowTestCase;
|
||||||
|
@ -85,10 +85,10 @@ public class DomainApplicationDeleteFlowTest
|
||||||
persistResource(newDomainApplication("example.tld").asBuilder()
|
persistResource(newDomainApplication("example.tld").asBuilder()
|
||||||
.setRepoId("1-TLD")
|
.setRepoId("1-TLD")
|
||||||
.setRegistrant(
|
.setRegistrant(
|
||||||
Ref.create(
|
Key.create(
|
||||||
loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc())))
|
loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc())))
|
||||||
.setNameservers(ImmutableSet.of(
|
.setNameservers(ImmutableSet.of(
|
||||||
Ref.create(
|
Key.create(
|
||||||
loadByUniqueId(HostResource.class, "ns1.example.net", clock.nowUtc()))))
|
loadByUniqueId(HostResource.class, "ns1.example.net", clock.nowUtc()))))
|
||||||
.build());
|
.build());
|
||||||
doSuccessfulTest();
|
doSuccessfulTest();
|
||||||
|
|
|
@ -25,7 +25,7 @@ import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
|
||||||
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 com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.flows.ResourceFlowTestCase;
|
import google.registry.flows.ResourceFlowTestCase;
|
||||||
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
|
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
|
||||||
import google.registry.flows.ResourceQueryFlow.ResourceToQueryDoesNotExistException;
|
import google.registry.flows.ResourceQueryFlow.ResourceToQueryDoesNotExistException;
|
||||||
|
@ -87,12 +87,12 @@ public class DomainApplicationInfoFlowTest
|
||||||
.setCreationTimeForTest(DateTime.parse("1999-04-03T22:00:00.0Z"))
|
.setCreationTimeForTest(DateTime.parse("1999-04-03T22:00:00.0Z"))
|
||||||
.setLastEppUpdateTime(DateTime.parse("1999-12-03T09:00:00.0Z"))
|
.setLastEppUpdateTime(DateTime.parse("1999-12-03T09:00:00.0Z"))
|
||||||
.setLastTransferTime(DateTime.parse("2000-04-08T09:00:00.0Z"))
|
.setLastTransferTime(DateTime.parse("2000-04-08T09:00:00.0Z"))
|
||||||
.setRegistrant(Ref.create(registrant))
|
.setRegistrant(Key.create(registrant))
|
||||||
.setContacts(ImmutableSet.of(
|
.setContacts(ImmutableSet.of(
|
||||||
DesignatedContact.create(Type.ADMIN, Ref.create(contact)),
|
DesignatedContact.create(Type.ADMIN, Key.create(contact)),
|
||||||
DesignatedContact.create(Type.TECH, Ref.create(contact))))
|
DesignatedContact.create(Type.TECH, Key.create(contact))))
|
||||||
.setNameservers(hostsState.equals(HostsState.HOSTS_EXIST) ? ImmutableSet.of(
|
.setNameservers(hostsState.equals(HostsState.HOSTS_EXIST) ? ImmutableSet.of(
|
||||||
Ref.create(host1), Ref.create(host2)) : null)
|
Key.create(host1), Key.create(host2)) : null)
|
||||||
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("2fooBAR")))
|
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("2fooBAR")))
|
||||||
.addStatusValue(StatusValue.PENDING_CREATE)
|
.addStatusValue(StatusValue.PENDING_CREATE)
|
||||||
.setApplicationStatus(ApplicationStatus.PENDING_VALIDATION)
|
.setApplicationStatus(ApplicationStatus.PENDING_VALIDATION)
|
||||||
|
@ -242,7 +242,7 @@ public class DomainApplicationInfoFlowTest
|
||||||
.setDsData(ImmutableSet.of(DelegationSignerData.create(
|
.setDsData(ImmutableSet.of(DelegationSignerData.create(
|
||||||
12345, 3, 1, base16().decode("49FD46E6C4B45C55D4AC"))))
|
12345, 3, 1, base16().decode("49FD46E6C4B45C55D4AC"))))
|
||||||
.setNameservers(ImmutableSet.of(
|
.setNameservers(ImmutableSet.of(
|
||||||
Ref.create(host1), Ref.create(host2)))
|
Key.create(host1), Key.create(host2)))
|
||||||
.build());
|
.build());
|
||||||
doSuccessfulTest("domain_info_sunrise_response_dsdata.xml", HostsState.NO_HOSTS_EXIST);
|
doSuccessfulTest("domain_info_sunrise_response_dsdata.xml", HostsState.NO_HOSTS_EXIST);
|
||||||
}
|
}
|
||||||
|
@ -275,7 +275,7 @@ public class DomainApplicationInfoFlowTest
|
||||||
.setRepoId("123-COM")
|
.setRepoId("123-COM")
|
||||||
.setFullyQualifiedDomainName("timber.com")
|
.setFullyQualifiedDomainName("timber.com")
|
||||||
.setDeletionTime(DateTime.now().minusDays(1))
|
.setDeletionTime(DateTime.now().minusDays(1))
|
||||||
.setRegistrant(Ref.create(persistActiveContact("jd1234")))
|
.setRegistrant(Key.create(persistActiveContact("jd1234")))
|
||||||
.build());
|
.build());
|
||||||
runFlow();
|
runFlow();
|
||||||
}
|
}
|
||||||
|
@ -296,7 +296,7 @@ public class DomainApplicationInfoFlowTest
|
||||||
persistResource(new DomainApplication.Builder()
|
persistResource(new DomainApplication.Builder()
|
||||||
.setRepoId("123-TLD")
|
.setRepoId("123-TLD")
|
||||||
.setFullyQualifiedDomainName("invalid.tld")
|
.setFullyQualifiedDomainName("invalid.tld")
|
||||||
.setRegistrant(Ref.create(persistActiveContact("jd1234")))
|
.setRegistrant(Key.create(persistActiveContact("jd1234")))
|
||||||
.setPhase(LaunchPhase.SUNRUSH)
|
.setPhase(LaunchPhase.SUNRUSH)
|
||||||
.build());
|
.build());
|
||||||
runFlow();
|
runFlow();
|
||||||
|
|
|
@ -29,7 +29,7 @@ import static google.registry.testing.DomainApplicationSubject.assertAboutApplic
|
||||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.flows.EppException.UnimplementedExtensionException;
|
import google.registry.flows.EppException.UnimplementedExtensionException;
|
||||||
import google.registry.flows.ResourceFlowTestCase;
|
import google.registry.flows.ResourceFlowTestCase;
|
||||||
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
|
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
|
||||||
|
@ -104,9 +104,9 @@ public class DomainApplicationUpdateFlowTest
|
||||||
private DomainApplication persistApplication() throws Exception {
|
private DomainApplication persistApplication() throws Exception {
|
||||||
return persistResource(newApplicationBuilder()
|
return persistResource(newApplicationBuilder()
|
||||||
.setContacts(ImmutableSet.of(
|
.setContacts(ImmutableSet.of(
|
||||||
DesignatedContact.create(Type.TECH, Ref.create(sh8013Contact)),
|
DesignatedContact.create(Type.TECH, Key.create(sh8013Contact)),
|
||||||
DesignatedContact.create(Type.ADMIN, Ref.create(unusedContact))))
|
DesignatedContact.create(Type.ADMIN, Key.create(unusedContact))))
|
||||||
.setNameservers(ImmutableSet.of(Ref.create(
|
.setNameservers(ImmutableSet.of(Key.create(
|
||||||
loadByUniqueId(HostResource.class, "ns1.example.tld", clock.nowUtc()))))
|
loadByUniqueId(HostResource.class, "ns1.example.tld", clock.nowUtc()))))
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ public class DomainApplicationUpdateFlowTest
|
||||||
persistReferencedEntities();
|
persistReferencedEntities();
|
||||||
ContactResource sh8013 = loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc());
|
ContactResource sh8013 = loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc());
|
||||||
persistResource(
|
persistResource(
|
||||||
newApplicationBuilder().setRegistrant(Ref.create(sh8013)).build());
|
newApplicationBuilder().setRegistrant(Key.create(sh8013)).build());
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
runFlowAssertResponse(readFile("domain_update_response.xml"));
|
runFlowAssertResponse(readFile("domain_update_response.xml"));
|
||||||
}
|
}
|
||||||
|
@ -180,13 +180,13 @@ public class DomainApplicationUpdateFlowTest
|
||||||
setEppInput("domain_update_sunrise_remove_multiple_contacts.xml");
|
setEppInput("domain_update_sunrise_remove_multiple_contacts.xml");
|
||||||
persistReferencedEntities();
|
persistReferencedEntities();
|
||||||
ContactResource sh8013 = loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc());
|
ContactResource sh8013 = loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc());
|
||||||
Ref<ContactResource> sh8013Ref = Ref.create(sh8013);
|
Key<ContactResource> sh8013Key = Key.create(sh8013);
|
||||||
persistResource(newApplicationBuilder()
|
persistResource(newApplicationBuilder()
|
||||||
.setRegistrant(sh8013Ref)
|
.setRegistrant(sh8013Key)
|
||||||
.setContacts(ImmutableSet.of(
|
.setContacts(ImmutableSet.of(
|
||||||
DesignatedContact.create(Type.ADMIN, sh8013Ref),
|
DesignatedContact.create(Type.ADMIN, sh8013Key),
|
||||||
DesignatedContact.create(Type.BILLING, sh8013Ref),
|
DesignatedContact.create(Type.BILLING, sh8013Key),
|
||||||
DesignatedContact.create(Type.TECH, sh8013Ref)))
|
DesignatedContact.create(Type.TECH, sh8013Key)))
|
||||||
.build());
|
.build());
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
runFlowAssertResponse(readFile("domain_update_response.xml"));
|
runFlowAssertResponse(readFile("domain_update_response.xml"));
|
||||||
|
@ -369,10 +369,10 @@ public class DomainApplicationUpdateFlowTest
|
||||||
}
|
}
|
||||||
|
|
||||||
private void modifyApplicationToHave13Nameservers() throws Exception {
|
private void modifyApplicationToHave13Nameservers() throws Exception {
|
||||||
ImmutableSet.Builder<Ref<HostResource>> nameservers = new ImmutableSet.Builder<>();
|
ImmutableSet.Builder<Key<HostResource>> nameservers = new ImmutableSet.Builder<>();
|
||||||
for (int i = 1; i < 15; i++) {
|
for (int i = 1; i < 15; i++) {
|
||||||
if (i != 2) { // Skip 2 since that's the one that the tests will add.
|
if (i != 2) { // Skip 2 since that's the one that the tests will add.
|
||||||
nameservers.add(Ref.create(loadByUniqueId(
|
nameservers.add(Key.create(loadByUniqueId(
|
||||||
HostResource.class, String.format("ns%d.example.tld", i), clock.nowUtc())));
|
HostResource.class, String.format("ns%d.example.tld", i), clock.nowUtc())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -492,7 +492,7 @@ public class DomainApplicationUpdateFlowTest
|
||||||
// Add a tech contact to the persisted entity, which should cause the flow to fail when it tries
|
// Add a tech contact to the persisted entity, which should cause the flow to fail when it tries
|
||||||
// to add "mak21" as a second tech contact.
|
// to add "mak21" as a second tech contact.
|
||||||
persistResource(reloadResourceByUniqueId().asBuilder().setContacts(ImmutableSet.of(
|
persistResource(reloadResourceByUniqueId().asBuilder().setContacts(ImmutableSet.of(
|
||||||
DesignatedContact.create(Type.TECH, Ref.create(
|
DesignatedContact.create(Type.TECH, Key.create(
|
||||||
loadByUniqueId(ContactResource.class, "foo", clock.nowUtc()))))).build());
|
loadByUniqueId(ContactResource.class, "foo", clock.nowUtc()))))).build());
|
||||||
runFlow();
|
runFlow();
|
||||||
}
|
}
|
||||||
|
@ -576,7 +576,7 @@ public class DomainApplicationUpdateFlowTest
|
||||||
setEppInput("domain_update_sunrise_add_remove_same_host.xml");
|
setEppInput("domain_update_sunrise_add_remove_same_host.xml");
|
||||||
persistReferencedEntities();
|
persistReferencedEntities();
|
||||||
persistResource(newApplicationBuilder()
|
persistResource(newApplicationBuilder()
|
||||||
.setNameservers(ImmutableSet.of(Ref.create(
|
.setNameservers(ImmutableSet.of(Key.create(
|
||||||
loadByUniqueId(HostResource.class, "ns1.example.tld", clock.nowUtc()))))
|
loadByUniqueId(HostResource.class, "ns1.example.tld", clock.nowUtc()))))
|
||||||
.build());
|
.build());
|
||||||
runFlow();
|
runFlow();
|
||||||
|
@ -590,7 +590,7 @@ public class DomainApplicationUpdateFlowTest
|
||||||
persistResource(newApplicationBuilder()
|
persistResource(newApplicationBuilder()
|
||||||
.setContacts(ImmutableSet.of(DesignatedContact.create(
|
.setContacts(ImmutableSet.of(DesignatedContact.create(
|
||||||
Type.TECH,
|
Type.TECH,
|
||||||
Ref.create(
|
Key.create(
|
||||||
loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc())))))
|
loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc())))))
|
||||||
.build());
|
.build());
|
||||||
runFlow();
|
runFlow();
|
||||||
|
@ -603,8 +603,8 @@ public class DomainApplicationUpdateFlowTest
|
||||||
persistReferencedEntities();
|
persistReferencedEntities();
|
||||||
persistResource(newApplicationBuilder()
|
persistResource(newApplicationBuilder()
|
||||||
.setContacts(ImmutableSet.of(
|
.setContacts(ImmutableSet.of(
|
||||||
DesignatedContact.create(Type.ADMIN, Ref.create(sh8013Contact)),
|
DesignatedContact.create(Type.ADMIN, Key.create(sh8013Contact)),
|
||||||
DesignatedContact.create(Type.TECH, Ref.create(sh8013Contact))))
|
DesignatedContact.create(Type.TECH, Key.create(sh8013Contact))))
|
||||||
.build());
|
.build());
|
||||||
runFlow();
|
runFlow();
|
||||||
}
|
}
|
||||||
|
@ -616,8 +616,8 @@ public class DomainApplicationUpdateFlowTest
|
||||||
persistReferencedEntities();
|
persistReferencedEntities();
|
||||||
persistResource(newApplicationBuilder()
|
persistResource(newApplicationBuilder()
|
||||||
.setContacts(ImmutableSet.of(
|
.setContacts(ImmutableSet.of(
|
||||||
DesignatedContact.create(Type.ADMIN, Ref.create(sh8013Contact)),
|
DesignatedContact.create(Type.ADMIN, Key.create(sh8013Contact)),
|
||||||
DesignatedContact.create(Type.TECH, Ref.create(sh8013Contact))))
|
DesignatedContact.create(Type.TECH, Key.create(sh8013Contact))))
|
||||||
.build());
|
.build());
|
||||||
runFlow();
|
runFlow();
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,7 +181,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
||||||
: null;
|
: null;
|
||||||
HistoryEntry historyEntry = getHistoryEntries(domain).get(0);
|
HistoryEntry historyEntry = getHistoryEntries(domain).get(0);
|
||||||
assertAboutDomains().that(domain)
|
assertAboutDomains().that(domain)
|
||||||
.hasRegistrationExpirationTime(domain.getAutorenewBillingEvent().get().getEventTime()).and()
|
.hasRegistrationExpirationTime(
|
||||||
|
ofy().load().key(domain.getAutorenewBillingEvent()).now().getEventTime()).and()
|
||||||
.hasOnlyOneHistoryEntryWhich()
|
.hasOnlyOneHistoryEntryWhich()
|
||||||
.hasType(HistoryEntry.Type.DOMAIN_CREATE).and()
|
.hasType(HistoryEntry.Type.DOMAIN_CREATE).and()
|
||||||
.hasPeriodYears(2);
|
.hasPeriodYears(2);
|
||||||
|
|
|
@ -42,7 +42,6 @@ import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.ImmutableSortedMap;
|
import com.google.common.collect.ImmutableSortedMap;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import google.registry.flows.EppRequestSource;
|
import google.registry.flows.EppRequestSource;
|
||||||
import google.registry.flows.ResourceCreateOrMutateFlow.OnlyToolCanPassMetadataException;
|
import google.registry.flows.ResourceCreateOrMutateFlow.OnlyToolCanPassMetadataException;
|
||||||
import google.registry.flows.ResourceFlowTestCase;
|
import google.registry.flows.ResourceFlowTestCase;
|
||||||
|
@ -111,8 +110,8 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
||||||
PollMessage.Autorenew autorenewPollMessage = persistResource(
|
PollMessage.Autorenew autorenewPollMessage = persistResource(
|
||||||
createAutorenewPollMessage("TheRegistrar").build());
|
createAutorenewPollMessage("TheRegistrar").build());
|
||||||
domain = persistResource(domain.asBuilder()
|
domain = persistResource(domain.asBuilder()
|
||||||
.setAutorenewBillingEvent(Ref.create(autorenewBillingEvent))
|
.setAutorenewBillingEvent(Key.create(autorenewBillingEvent))
|
||||||
.setAutorenewPollMessage(Ref.create(autorenewPollMessage))
|
.setAutorenewPollMessage(Key.create(autorenewPollMessage))
|
||||||
.build());
|
.build());
|
||||||
assertTransactionalFlow(true);
|
assertTransactionalFlow(true);
|
||||||
}
|
}
|
||||||
|
@ -122,7 +121,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
||||||
ContactResource contact = persistActiveContact("sh8013");
|
ContactResource contact = persistActiveContact("sh8013");
|
||||||
domain = newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
domain = newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
||||||
.setCreationTimeForTest(TIME_BEFORE_FLOW)
|
.setCreationTimeForTest(TIME_BEFORE_FLOW)
|
||||||
.setRegistrant(Ref.create(contact))
|
.setRegistrant(Key.create(contact))
|
||||||
.setRegistrationExpirationTime(expirationTime)
|
.setRegistrationExpirationTime(expirationTime)
|
||||||
.build();
|
.build();
|
||||||
earlierHistoryEntry = persistResource(
|
earlierHistoryEntry = persistResource(
|
||||||
|
@ -153,9 +152,9 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
||||||
GracePeriodStatus.AUTO_RENEW,
|
GracePeriodStatus.AUTO_RENEW,
|
||||||
A_MONTH_AGO.plusDays(45),
|
A_MONTH_AGO.plusDays(45),
|
||||||
"TheRegistrar",
|
"TheRegistrar",
|
||||||
Ref.create(autorenewBillingEvent))))
|
Key.create(autorenewBillingEvent))))
|
||||||
.setAutorenewBillingEvent(Ref.create(autorenewBillingEvent))
|
.setAutorenewBillingEvent(Key.create(autorenewBillingEvent))
|
||||||
.setAutorenewPollMessage(Ref.create(autorenewPollMessage))
|
.setAutorenewPollMessage(Key.create(autorenewPollMessage))
|
||||||
.build());
|
.build());
|
||||||
assertTransactionalFlow(true);
|
assertTransactionalFlow(true);
|
||||||
}
|
}
|
||||||
|
@ -175,7 +174,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
||||||
.setClientId("TheRegistrar")
|
.setClientId("TheRegistrar")
|
||||||
.setEventTime(eventTime)
|
.setEventTime(eventTime)
|
||||||
.setBillingTime(TIME_BEFORE_FLOW.plusDays(1))
|
.setBillingTime(TIME_BEFORE_FLOW.plusDays(1))
|
||||||
.setOneTimeEventRef(Ref.create(graceBillingEvent))
|
.setOneTimeEventKey(Key.create(graceBillingEvent))
|
||||||
.setParent(historyEntryDomainDelete)
|
.setParent(historyEntryDomainDelete)
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
@ -373,7 +372,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
||||||
// Modify the autorenew poll message so that it has unacked messages in the past. This should
|
// Modify the autorenew poll message so that it has unacked messages in the past. This should
|
||||||
// prevent it from being deleted when the domain is deleted.
|
// prevent it from being deleted when the domain is deleted.
|
||||||
persistResource(
|
persistResource(
|
||||||
reloadResourceByUniqueId().getAutorenewPollMessage().get().asBuilder()
|
ofy().load().key(reloadResourceByUniqueId().getAutorenewPollMessage()).now().asBuilder()
|
||||||
.setEventTime(A_MONTH_FROM_NOW.minusYears(3))
|
.setEventTime(A_MONTH_FROM_NOW.minusYears(3))
|
||||||
.build());
|
.build());
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
|
@ -531,9 +530,10 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
||||||
assertThat(domain.getTransferData().getServerApproveBillingEvent()).isNull();
|
assertThat(domain.getTransferData().getServerApproveBillingEvent()).isNull();
|
||||||
assertThat(domain.getTransferData().getServerApproveAutorenewEvent()).isNull();
|
assertThat(domain.getTransferData().getServerApproveAutorenewEvent()).isNull();
|
||||||
assertThat(domain.getTransferData().getServerApproveAutorenewPollMessage()).isNull();
|
assertThat(domain.getTransferData().getServerApproveAutorenewPollMessage()).isNull();
|
||||||
assertThat(oldTransferData.getServerApproveBillingEvent().get()).isNull();
|
assertThat(ofy().load().key(oldTransferData.getServerApproveBillingEvent()).now()).isNull();
|
||||||
assertThat(oldTransferData.getServerApproveAutorenewEvent().get()).isNull();
|
assertThat(ofy().load().key(oldTransferData.getServerApproveAutorenewEvent()).now()).isNull();
|
||||||
assertThat(oldTransferData.getServerApproveAutorenewPollMessage().get()).isNull();
|
assertThat(ofy().load().key(oldTransferData.getServerApproveAutorenewPollMessage()).now())
|
||||||
|
.isNull();
|
||||||
assertThat(oldTransferData.getServerApproveEntities()).isNotEmpty(); // Just a sanity check.
|
assertThat(oldTransferData.getServerApproveEntities()).isNotEmpty(); // Just a sanity check.
|
||||||
assertThat(ofy().load()
|
assertThat(ofy().load()
|
||||||
.keys(oldTransferData.getServerApproveEntities().toArray(new Key<?>[]{})))
|
.keys(oldTransferData.getServerApproveEntities().toArray(new Key<?>[]{})))
|
||||||
|
@ -554,12 +554,12 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
||||||
persistResource(loadByUniqueId(
|
persistResource(loadByUniqueId(
|
||||||
DomainResource.class, getUniqueIdFromCommand(), clock.nowUtc())
|
DomainResource.class, getUniqueIdFromCommand(), clock.nowUtc())
|
||||||
.asBuilder()
|
.asBuilder()
|
||||||
.setNameservers(ImmutableSet.of(Ref.create(host)))
|
.setNameservers(ImmutableSet.of(Key.create(host)))
|
||||||
.build());
|
.build());
|
||||||
// Persist another domain that's already been deleted and references this contact and host.
|
// Persist another domain that's already been deleted and references this contact and host.
|
||||||
persistResource(newDomainResource("example1.tld").asBuilder()
|
persistResource(newDomainResource("example1.tld").asBuilder()
|
||||||
.setRegistrant(Ref.create(loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc())))
|
.setRegistrant(Key.create(loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc())))
|
||||||
.setNameservers(ImmutableSet.of(Ref.create(host)))
|
.setNameservers(ImmutableSet.of(Key.create(host)))
|
||||||
.setDeletionTime(START_OF_TIME)
|
.setDeletionTime(START_OF_TIME)
|
||||||
.build());
|
.build());
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
|
@ -575,7 +575,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
||||||
setupSuccessfulTest();
|
setupSuccessfulTest();
|
||||||
persistResource(
|
persistResource(
|
||||||
newHostResource("ns1." + getUniqueIdFromCommand()).asBuilder()
|
newHostResource("ns1." + getUniqueIdFromCommand()).asBuilder()
|
||||||
.setSuperordinateDomain(Ref.create(reloadResourceByUniqueId()))
|
.setSuperordinateDomain(Key.create(reloadResourceByUniqueId()))
|
||||||
.setDeletionTime(clock.nowUtc().minusDays(1))
|
.setDeletionTime(clock.nowUtc().minusDays(1))
|
||||||
.build());
|
.build());
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
|
@ -607,7 +607,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
||||||
DomainResource domain = persistActiveDomain(getUniqueIdFromCommand());
|
DomainResource domain = persistActiveDomain(getUniqueIdFromCommand());
|
||||||
HostResource subordinateHost = persistResource(
|
HostResource subordinateHost = persistResource(
|
||||||
newHostResource("ns1." + getUniqueIdFromCommand()).asBuilder()
|
newHostResource("ns1." + getUniqueIdFromCommand()).asBuilder()
|
||||||
.setSuperordinateDomain(Ref.create(reloadResourceByUniqueId()))
|
.setSuperordinateDomain(Key.create(reloadResourceByUniqueId()))
|
||||||
.build());
|
.build());
|
||||||
domain = persistResource(domain.asBuilder()
|
domain = persistResource(domain.asBuilder()
|
||||||
.addSubordinateHost(subordinateHost.getFullyQualifiedHostName())
|
.addSubordinateHost(subordinateHost.getFullyQualifiedHostName())
|
||||||
|
|
|
@ -27,7 +27,6 @@ import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
|
||||||
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 com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import google.registry.flows.ResourceFlowTestCase;
|
import google.registry.flows.ResourceFlowTestCase;
|
||||||
import google.registry.flows.ResourceFlowUtils.BadAuthInfoForResourceException;
|
import google.registry.flows.ResourceFlowUtils.BadAuthInfoForResourceException;
|
||||||
import google.registry.flows.ResourceQueryFlow.ResourceToQueryDoesNotExistException;
|
import google.registry.flows.ResourceQueryFlow.ResourceToQueryDoesNotExistException;
|
||||||
|
@ -91,25 +90,25 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
|
||||||
.setLastEppUpdateTime(DateTime.parse("1999-12-03T09:00:00.0Z"))
|
.setLastEppUpdateTime(DateTime.parse("1999-12-03T09:00:00.0Z"))
|
||||||
.setLastTransferTime(DateTime.parse("2000-04-08T09:00:00.0Z"))
|
.setLastTransferTime(DateTime.parse("2000-04-08T09:00:00.0Z"))
|
||||||
.setRegistrationExpirationTime(DateTime.parse("2005-04-03T22:00:00.0Z"))
|
.setRegistrationExpirationTime(DateTime.parse("2005-04-03T22:00:00.0Z"))
|
||||||
.setRegistrant(Ref.create(registrant))
|
.setRegistrant(Key.create(registrant))
|
||||||
.setContacts(ImmutableSet.of(
|
.setContacts(ImmutableSet.of(
|
||||||
DesignatedContact.create(Type.ADMIN, Ref.create(contact)),
|
DesignatedContact.create(Type.ADMIN, Key.create(contact)),
|
||||||
DesignatedContact.create(Type.TECH, Ref.create(contact))))
|
DesignatedContact.create(Type.TECH, Key.create(contact))))
|
||||||
.setNameservers(inactive ? null : ImmutableSet.of(Ref.create(host1), Ref.create(host2)))
|
.setNameservers(inactive ? null : ImmutableSet.of(Key.create(host1), Key.create(host2)))
|
||||||
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("2fooBAR")))
|
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("2fooBAR")))
|
||||||
.build());
|
.build());
|
||||||
// Set the superordinate domain of ns1.example.com to example.com. In reality, this would have
|
// Set the superordinate domain of ns1.example.com to example.com. In reality, this would have
|
||||||
// happened in the flow that created it, but here we just overwrite it in the datastore.
|
// happened in the flow that created it, but here we just overwrite it in the datastore.
|
||||||
host1 = persistResource(
|
host1 = persistResource(
|
||||||
host1.asBuilder().setSuperordinateDomain(Ref.create(domain)).build());
|
host1.asBuilder().setSuperordinateDomain(Key.create(domain)).build());
|
||||||
// Create a subordinate host that is not delegated to by anyone.
|
// Create a subordinate host that is not delegated to by anyone.
|
||||||
host3 = persistResource(
|
host3 = persistResource(
|
||||||
new HostResource.Builder()
|
new HostResource.Builder()
|
||||||
.setFullyQualifiedHostName("ns2.example.tld")
|
.setFullyQualifiedHostName("ns2.example.tld")
|
||||||
.setRepoId("3FF-TLD")
|
.setRepoId("3FF-TLD")
|
||||||
.setSuperordinateDomain(Ref.create(domain))
|
.setSuperordinateDomain(Key.create(domain))
|
||||||
.build());
|
.build());
|
||||||
// Add the subordinate host references to the existing domain.
|
// Add the subordinate host keys to the existing domain.
|
||||||
domain = persistResource(domain.asBuilder()
|
domain = persistResource(domain.asBuilder()
|
||||||
.setSubordinateHosts(ImmutableSet.of(
|
.setSubordinateHosts(ImmutableSet.of(
|
||||||
host1.getFullyQualifiedHostName(),
|
host1.getFullyQualifiedHostName(),
|
||||||
|
@ -242,7 +241,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
|
||||||
persistResource(domain.asBuilder()
|
persistResource(domain.asBuilder()
|
||||||
.setDsData(ImmutableSet.of(DelegationSignerData.create(
|
.setDsData(ImmutableSet.of(DelegationSignerData.create(
|
||||||
12345, 3, 1, base16().decode("49FD46E6C4B45C55D4AC"))))
|
12345, 3, 1, base16().decode("49FD46E6C4B45C55D4AC"))))
|
||||||
.setNameservers(ImmutableSet.of(Ref.create(host1), Ref.create(host3)))
|
.setNameservers(ImmutableSet.of(Key.create(host1), Key.create(host3)))
|
||||||
.build());
|
.build());
|
||||||
doSuccessfulTest("domain_info_response_dsdata.xml", false);
|
doSuccessfulTest("domain_info_response_dsdata.xml", false);
|
||||||
}
|
}
|
||||||
|
@ -283,7 +282,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
|
||||||
GracePeriodStatus.AUTO_RENEW,
|
GracePeriodStatus.AUTO_RENEW,
|
||||||
clock.nowUtc().plusDays(1),
|
clock.nowUtc().plusDays(1),
|
||||||
"foo",
|
"foo",
|
||||||
Ref.create(Key.create(Recurring.class, 12345))))
|
Key.create(Recurring.class, 12345)))
|
||||||
.build());
|
.build());
|
||||||
doSuccessfulTest("domain_info_response_autorenewperiod.xml", false);
|
doSuccessfulTest("domain_info_response_autorenewperiod.xml", false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
package google.registry.flows.domain;
|
package google.registry.flows.domain;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static google.registry.flows.domain.DomainTransferFlowTestCase.persistWithPendingTransfer;
|
import static google.registry.flows.domain.DomainTransferFlowTestCase.persistWithPendingTransfer;
|
||||||
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static google.registry.testing.DatastoreHelper.assertBillingEvents;
|
import static google.registry.testing.DatastoreHelper.assertBillingEvents;
|
||||||
import static google.registry.testing.DatastoreHelper.createTld;
|
import static google.registry.testing.DatastoreHelper.createTld;
|
||||||
import static google.registry.testing.DatastoreHelper.getOnlyHistoryEntryOfType;
|
import static google.registry.testing.DatastoreHelper.getOnlyHistoryEntryOfType;
|
||||||
|
@ -32,7 +33,7 @@ import static org.joda.money.CurrencyUnit.USD;
|
||||||
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 com.google.common.collect.ImmutableSortedMap;
|
import com.google.common.collect.ImmutableSortedMap;
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.flows.ResourceFlowTestCase;
|
import google.registry.flows.ResourceFlowTestCase;
|
||||||
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
|
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
|
||||||
import google.registry.flows.ResourceMutateFlow.ResourceToMutateDoesNotExistException;
|
import google.registry.flows.ResourceMutateFlow.ResourceToMutateDoesNotExistException;
|
||||||
|
@ -116,8 +117,8 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
|
||||||
domain = persistResource(domain.asBuilder()
|
domain = persistResource(domain.asBuilder()
|
||||||
.setRegistrationExpirationTime(expirationTime)
|
.setRegistrationExpirationTime(expirationTime)
|
||||||
.setStatusValues(ImmutableSet.copyOf(statusValues))
|
.setStatusValues(ImmutableSet.copyOf(statusValues))
|
||||||
.setAutorenewBillingEvent(Ref.create(autorenewEvent))
|
.setAutorenewBillingEvent(Key.create(autorenewEvent))
|
||||||
.setAutorenewPollMessage(Ref.create(autorenewPollMessage))
|
.setAutorenewPollMessage(Key.create(autorenewPollMessage))
|
||||||
.build());
|
.build());
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
}
|
}
|
||||||
|
@ -136,7 +137,8 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
|
||||||
DomainResource domain = reloadResourceByUniqueId();
|
DomainResource domain = reloadResourceByUniqueId();
|
||||||
HistoryEntry historyEntryDomainRenew =
|
HistoryEntry historyEntryDomainRenew =
|
||||||
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_RENEW);
|
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_RENEW);
|
||||||
assertThat(domain.getAutorenewBillingEvent().get().getEventTime()).isEqualTo(newExpiration);
|
assertThat(ofy().load().key(domain.getAutorenewBillingEvent()).now().getEventTime())
|
||||||
|
.isEqualTo(newExpiration);
|
||||||
assertAboutDomains().that(domain)
|
assertAboutDomains().that(domain)
|
||||||
.isActiveAt(clock.nowUtc()).and()
|
.isActiveAt(clock.nowUtc()).and()
|
||||||
.hasRegistrationExpirationTime(newExpiration).and()
|
.hasRegistrationExpirationTime(newExpiration).and()
|
||||||
|
@ -345,7 +347,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
|
||||||
persistDomain();
|
persistDomain();
|
||||||
// Modify the autorenew poll message so that it has an undelivered message in the past.
|
// Modify the autorenew poll message so that it has an undelivered message in the past.
|
||||||
persistResource(
|
persistResource(
|
||||||
reloadResourceByUniqueId().getAutorenewPollMessage().get().asBuilder()
|
ofy().load().key(reloadResourceByUniqueId().getAutorenewPollMessage()).now().asBuilder()
|
||||||
.setEventTime(expirationTime.minusYears(1))
|
.setEventTime(expirationTime.minusYears(1))
|
||||||
.build());
|
.build());
|
||||||
runFlowAssertResponse(readFile("domain_renew_response.xml"));
|
runFlowAssertResponse(readFile("domain_renew_response.xml"));
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
package google.registry.flows.domain;
|
package google.registry.flows.domain;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static google.registry.testing.DatastoreHelper.assertBillingEvents;
|
import static google.registry.testing.DatastoreHelper.assertBillingEvents;
|
||||||
import static google.registry.testing.DatastoreHelper.createTld;
|
import static google.registry.testing.DatastoreHelper.createTld;
|
||||||
import static google.registry.testing.DatastoreHelper.getOnlyHistoryEntryOfType;
|
import static google.registry.testing.DatastoreHelper.getOnlyHistoryEntryOfType;
|
||||||
|
@ -126,7 +127,7 @@ public class DomainRestoreRequestFlowTest extends
|
||||||
DomainResource domain = reloadResourceByUniqueId();
|
DomainResource domain = reloadResourceByUniqueId();
|
||||||
HistoryEntry historyEntryDomainRestore =
|
HistoryEntry historyEntryDomainRestore =
|
||||||
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_RESTORE);
|
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_RESTORE);
|
||||||
assertThat(domain.getAutorenewBillingEvent().get().getEventTime())
|
assertThat(ofy().load().key(domain.getAutorenewBillingEvent()).now().getEventTime())
|
||||||
.isEqualTo(clock.nowUtc().plusYears(1));
|
.isEqualTo(clock.nowUtc().plusYears(1));
|
||||||
assertAboutDomains().that(domain)
|
assertAboutDomains().that(domain)
|
||||||
// New expiration time should be exactly a year from now.
|
// New expiration time should be exactly a year from now.
|
||||||
|
|
|
@ -16,6 +16,7 @@ package google.registry.flows.domain;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static google.registry.model.EppResourceUtils.loadByUniqueId;
|
import static google.registry.model.EppResourceUtils.loadByUniqueId;
|
||||||
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static google.registry.testing.DatastoreHelper.assertBillingEventsForResource;
|
import static google.registry.testing.DatastoreHelper.assertBillingEventsForResource;
|
||||||
import static google.registry.testing.DatastoreHelper.createTld;
|
import static google.registry.testing.DatastoreHelper.createTld;
|
||||||
import static google.registry.testing.DatastoreHelper.deleteResource;
|
import static google.registry.testing.DatastoreHelper.deleteResource;
|
||||||
|
@ -148,7 +149,7 @@ public class DomainTransferApproveFlowTest
|
||||||
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_TRANSFER_APPROVE);
|
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_TRANSFER_APPROVE);
|
||||||
assertTransferApproved(domain);
|
assertTransferApproved(domain);
|
||||||
assertAboutDomains().that(domain).hasRegistrationExpirationTime(expectedExpirationTime);
|
assertAboutDomains().that(domain).hasRegistrationExpirationTime(expectedExpirationTime);
|
||||||
assertThat(domain.getAutorenewBillingEvent().get().getEventTime())
|
assertThat(ofy().load().key(domain.getAutorenewBillingEvent()).now().getEventTime())
|
||||||
.isEqualTo(expectedExpirationTime);
|
.isEqualTo(expectedExpirationTime);
|
||||||
assertTransferApproved(reloadResourceAndCloneAtTime(subordinateHost, clock.nowUtc()));
|
assertTransferApproved(reloadResourceAndCloneAtTime(subordinateHost, clock.nowUtc()));
|
||||||
// We expect three billing events: one for the transfer, a closed autorenew for the losing
|
// We expect three billing events: one for the transfer, a closed autorenew for the losing
|
||||||
|
@ -372,7 +373,7 @@ public class DomainTransferApproveFlowTest
|
||||||
.setEventTime(clock.nowUtc()) // The cancellation happens at the moment of transfer.
|
.setEventTime(clock.nowUtc()) // The cancellation happens at the moment of transfer.
|
||||||
.setBillingTime(
|
.setBillingTime(
|
||||||
oldExpirationTime.plus(Registry.get("tld").getAutoRenewGracePeriodLength()))
|
oldExpirationTime.plus(Registry.get("tld").getAutoRenewGracePeriodLength()))
|
||||||
.setRecurringEventRef(domain.getAutorenewBillingEvent()));
|
.setRecurringEventKey(domain.getAutorenewBillingEvent()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -28,7 +28,7 @@ import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||||
|
|
||||||
import com.google.common.base.Ascii;
|
import com.google.common.base.Ascii;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.flows.Flow;
|
import google.registry.flows.Flow;
|
||||||
import google.registry.flows.ResourceFlowTestCase;
|
import google.registry.flows.ResourceFlowTestCase;
|
||||||
import google.registry.model.EppResource;
|
import google.registry.model.EppResource;
|
||||||
|
@ -120,14 +120,14 @@ public class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
|
||||||
.setCreationClientId("TheRegistrar")
|
.setCreationClientId("TheRegistrar")
|
||||||
.setCreationTimeForTest(DateTime.parse("1999-04-03T22:00:00.0Z"))
|
.setCreationTimeForTest(DateTime.parse("1999-04-03T22:00:00.0Z"))
|
||||||
.setRegistrationExpirationTime(REGISTRATION_EXPIRATION_TIME)
|
.setRegistrationExpirationTime(REGISTRATION_EXPIRATION_TIME)
|
||||||
.setRegistrant(Ref.create(loadByUniqueId(ContactResource.class, "jd1234", clock.nowUtc())))
|
.setRegistrant(Key.create(loadByUniqueId(ContactResource.class, "jd1234", clock.nowUtc())))
|
||||||
.setContacts(ImmutableSet.of(
|
.setContacts(ImmutableSet.of(
|
||||||
DesignatedContact.create(
|
DesignatedContact.create(
|
||||||
Type.ADMIN,
|
Type.ADMIN,
|
||||||
Ref.create(loadByUniqueId(ContactResource.class, "jd1234", clock.nowUtc()))),
|
Key.create(loadByUniqueId(ContactResource.class, "jd1234", clock.nowUtc()))),
|
||||||
DesignatedContact.create(
|
DesignatedContact.create(
|
||||||
Type.TECH,
|
Type.TECH,
|
||||||
Ref.create(loadByUniqueId(ContactResource.class, "jd1234", clock.nowUtc())))))
|
Key.create(loadByUniqueId(ContactResource.class, "jd1234", clock.nowUtc())))))
|
||||||
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("fooBAR")))
|
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("fooBAR")))
|
||||||
.addGracePeriod(GracePeriod.create(
|
.addGracePeriod(GracePeriod.create(
|
||||||
GracePeriodStatus.ADD, clock.nowUtc().plusDays(10), "foo", null))
|
GracePeriodStatus.ADD, clock.nowUtc().plusDays(10), "foo", null))
|
||||||
|
@ -163,11 +163,11 @@ public class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
|
||||||
.setCurrentSponsorClientId("TheRegistrar")
|
.setCurrentSponsorClientId("TheRegistrar")
|
||||||
.setCreationClientId("TheRegistrar")
|
.setCreationClientId("TheRegistrar")
|
||||||
.setCreationTimeForTest(DateTime.parse("1999-04-03T22:00:00.0Z"))
|
.setCreationTimeForTest(DateTime.parse("1999-04-03T22:00:00.0Z"))
|
||||||
.setSuperordinateDomain(Ref.create(domain))
|
.setSuperordinateDomain(Key.create(domain))
|
||||||
.build());
|
.build());
|
||||||
domain = persistResource(domain.asBuilder()
|
domain = persistResource(domain.asBuilder()
|
||||||
.setAutorenewBillingEvent(Ref.create(autorenewEvent))
|
.setAutorenewBillingEvent(Key.create(autorenewEvent))
|
||||||
.setAutorenewPollMessage(Ref.create(autorenewPollMessage))
|
.setAutorenewPollMessage(Key.create(autorenewPollMessage))
|
||||||
.addSubordinateHost(subordinateHost.getFullyQualifiedHostName())
|
.addSubordinateHost(subordinateHost.getFullyQualifiedHostName())
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
package google.registry.flows.domain;
|
package google.registry.flows.domain;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static google.registry.testing.DatastoreHelper.assertBillingEvents;
|
import static google.registry.testing.DatastoreHelper.assertBillingEvents;
|
||||||
import static google.registry.testing.DatastoreHelper.deleteResource;
|
import static google.registry.testing.DatastoreHelper.deleteResource;
|
||||||
import static google.registry.testing.DatastoreHelper.getOnlyHistoryEntryOfType;
|
import static google.registry.testing.DatastoreHelper.getOnlyHistoryEntryOfType;
|
||||||
|
@ -192,7 +193,8 @@ public class DomainTransferRequestFlowTest
|
||||||
.build())
|
.build())
|
||||||
.toArray(BillingEvent.class));
|
.toArray(BillingEvent.class));
|
||||||
// The domain's autorenew billing event should still point to the losing client's event.
|
// The domain's autorenew billing event should still point to the losing client's event.
|
||||||
BillingEvent.Recurring domainAutorenewEvent = domain.getAutorenewBillingEvent().get();
|
BillingEvent.Recurring domainAutorenewEvent =
|
||||||
|
ofy().load().key(domain.getAutorenewBillingEvent()).now();
|
||||||
assertThat(domainAutorenewEvent.getClientId()).isEqualTo("TheRegistrar");
|
assertThat(domainAutorenewEvent.getClientId()).isEqualTo("TheRegistrar");
|
||||||
assertThat(domainAutorenewEvent.getRecurrenceEndTime()).isEqualTo(implicitTransferTime);
|
assertThat(domainAutorenewEvent.getRecurrenceEndTime()).isEqualTo(implicitTransferTime);
|
||||||
// The original grace periods should remain untouched.
|
// The original grace periods should remain untouched.
|
||||||
|
@ -263,8 +265,9 @@ public class DomainTransferRequestFlowTest
|
||||||
|
|
||||||
assertAboutDomains().that(domainAfterAutomaticTransfer)
|
assertAboutDomains().that(domainAfterAutomaticTransfer)
|
||||||
.hasRegistrationExpirationTime(expectedExpirationTime);
|
.hasRegistrationExpirationTime(expectedExpirationTime);
|
||||||
assertThat(domainAfterAutomaticTransfer.getAutorenewBillingEvent().get().getEventTime())
|
assertThat(ofy().load().key(domainAfterAutomaticTransfer.getAutorenewBillingEvent()).now()
|
||||||
.isEqualTo(expectedExpirationTime);
|
.getEventTime())
|
||||||
|
.isEqualTo(expectedExpirationTime);
|
||||||
// And after the expected grace time, the grace period should be gone.
|
// And after the expected grace time, the grace period should be gone.
|
||||||
DomainResource afterGracePeriod = domain.cloneProjectedAtTime(
|
DomainResource afterGracePeriod = domain.cloneProjectedAtTime(
|
||||||
clock.nowUtc().plus(Registry.get("tld").getAutomaticTransferLength()).plus(
|
clock.nowUtc().plus(Registry.get("tld").getAutomaticTransferLength()).plus(
|
||||||
|
@ -516,7 +519,7 @@ public class DomainTransferRequestFlowTest
|
||||||
.setBillingTime(oldResource.getRegistrationExpirationTime().plus(
|
.setBillingTime(oldResource.getRegistrationExpirationTime().plus(
|
||||||
Registry.get("tld").getAutoRenewGracePeriodLength()))
|
Registry.get("tld").getAutoRenewGracePeriodLength()))
|
||||||
// The cancellation should refer to the old autorenew billing event.
|
// The cancellation should refer to the old autorenew billing event.
|
||||||
.setRecurringEventRef(oldResource.getAutorenewBillingEvent()));
|
.setRecurringEventKey(oldResource.getAutorenewBillingEvent()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -18,6 +18,7 @@ import static com.google.common.collect.Sets.union;
|
||||||
import static com.google.common.io.BaseEncoding.base16;
|
import static com.google.common.io.BaseEncoding.base16;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static google.registry.model.EppResourceUtils.loadByUniqueId;
|
import static google.registry.model.EppResourceUtils.loadByUniqueId;
|
||||||
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static google.registry.testing.DatastoreHelper.assertBillingEvents;
|
import static google.registry.testing.DatastoreHelper.assertBillingEvents;
|
||||||
import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
|
import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
|
||||||
import static google.registry.testing.DatastoreHelper.createTld;
|
import static google.registry.testing.DatastoreHelper.createTld;
|
||||||
|
@ -39,7 +40,6 @@ 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 com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import google.registry.flows.EppException.UnimplementedExtensionException;
|
import google.registry.flows.EppException.UnimplementedExtensionException;
|
||||||
import google.registry.flows.EppRequestSource;
|
import google.registry.flows.EppRequestSource;
|
||||||
import google.registry.flows.ResourceCreateOrMutateFlow.OnlyToolCanPassMetadataException;
|
import google.registry.flows.ResourceCreateOrMutateFlow.OnlyToolCanPassMetadataException;
|
||||||
|
@ -123,9 +123,9 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
||||||
DomainResource domain = persistResource(
|
DomainResource domain = persistResource(
|
||||||
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
||||||
.setContacts(ImmutableSet.of(
|
.setContacts(ImmutableSet.of(
|
||||||
DesignatedContact.create(Type.TECH, Ref.create(sh8013Contact)),
|
DesignatedContact.create(Type.TECH, Key.create(sh8013Contact)),
|
||||||
DesignatedContact.create(Type.ADMIN, Ref.create(unusedContact))))
|
DesignatedContact.create(Type.ADMIN, Key.create(unusedContact))))
|
||||||
.setNameservers(ImmutableSet.of(Ref.create(host)))
|
.setNameservers(ImmutableSet.of(Key.create(host)))
|
||||||
.build());
|
.build());
|
||||||
historyEntryDomainCreate = persistResource(
|
historyEntryDomainCreate = persistResource(
|
||||||
new HistoryEntry.Builder()
|
new HistoryEntry.Builder()
|
||||||
|
@ -180,7 +180,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
||||||
HistoryEntry historyEntryDomainUpdate =
|
HistoryEntry historyEntryDomainUpdate =
|
||||||
getOnlyHistoryEntryOfType(resource, HistoryEntry.Type.DOMAIN_UPDATE);
|
getOnlyHistoryEntryOfType(resource, HistoryEntry.Type.DOMAIN_UPDATE);
|
||||||
assertThat(resource.getNameservers()).containsExactly(
|
assertThat(resource.getNameservers()).containsExactly(
|
||||||
Ref.create(
|
Key.create(
|
||||||
loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc())));
|
loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc())));
|
||||||
BillingEvent.OneTime regularAddBillingEvent = new BillingEvent.OneTime.Builder()
|
BillingEvent.OneTime regularAddBillingEvent = new BillingEvent.OneTime.Builder()
|
||||||
.setReason(Reason.CREATE)
|
.setReason(Reason.CREATE)
|
||||||
|
@ -201,7 +201,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
||||||
.setClientId("TheRegistrar")
|
.setClientId("TheRegistrar")
|
||||||
.setEventTime(clock.nowUtc())
|
.setEventTime(clock.nowUtc())
|
||||||
.setBillingTime(sunrushAddBillingEvent.getBillingTime())
|
.setBillingTime(sunrushAddBillingEvent.getBillingTime())
|
||||||
.setOneTimeEventRef(Ref.create(sunrushAddBillingEvent))
|
.setOneTimeEventKey(Key.create(sunrushAddBillingEvent))
|
||||||
.setParent(historyEntryDomainUpdate)
|
.setParent(historyEntryDomainUpdate)
|
||||||
.build(),
|
.build(),
|
||||||
regularAddBillingEvent);
|
regularAddBillingEvent);
|
||||||
|
@ -278,7 +278,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
||||||
// serverHold on it.
|
// serverHold on it.
|
||||||
persistResource(
|
persistResource(
|
||||||
reloadResourceByUniqueId().asBuilder()
|
reloadResourceByUniqueId().asBuilder()
|
||||||
.setNameservers(ImmutableSet.of(Ref.create(
|
.setNameservers(ImmutableSet.of(Key.create(
|
||||||
loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc()))))
|
loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc()))))
|
||||||
.addGracePeriod(GracePeriod.forBillingEvent(
|
.addGracePeriod(GracePeriod.forBillingEvent(
|
||||||
GracePeriodStatus.SUNRUSH_ADD, sunrushAddBillingEvent))
|
GracePeriodStatus.SUNRUSH_ADD, sunrushAddBillingEvent))
|
||||||
|
@ -302,7 +302,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
||||||
// serverHold on it.
|
// serverHold on it.
|
||||||
persistResource(
|
persistResource(
|
||||||
reloadResourceByUniqueId().asBuilder()
|
reloadResourceByUniqueId().asBuilder()
|
||||||
.setNameservers(ImmutableSet.of(Ref.create(
|
.setNameservers(ImmutableSet.of(Key.create(
|
||||||
loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc()))))
|
loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc()))))
|
||||||
.addGracePeriod(GracePeriod.forBillingEvent(
|
.addGracePeriod(GracePeriod.forBillingEvent(
|
||||||
GracePeriodStatus.SUNRUSH_ADD, sunrushAddBillingEvent))
|
GracePeriodStatus.SUNRUSH_ADD, sunrushAddBillingEvent))
|
||||||
|
@ -345,10 +345,10 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
||||||
}
|
}
|
||||||
|
|
||||||
private void modifyDomainToHave13Nameservers() throws Exception {
|
private void modifyDomainToHave13Nameservers() throws Exception {
|
||||||
ImmutableSet.Builder<Ref<HostResource>> nameservers = new ImmutableSet.Builder<>();
|
ImmutableSet.Builder<Key<HostResource>> nameservers = new ImmutableSet.Builder<>();
|
||||||
for (int i = 1; i < 15; i++) {
|
for (int i = 1; i < 15; i++) {
|
||||||
if (i != 2) { // Skip 2 since that's the one that the tests will add.
|
if (i != 2) { // Skip 2 since that's the one that the tests will add.
|
||||||
nameservers.add(Ref.create(loadByUniqueId(
|
nameservers.add(Key.create(loadByUniqueId(
|
||||||
HostResource.class, String.format("ns%d.example.foo", i), clock.nowUtc())));
|
HostResource.class, String.format("ns%d.example.foo", i), clock.nowUtc())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -374,11 +374,11 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
||||||
persistDomain();
|
persistDomain();
|
||||||
setEppInput("domain_update_max_everything.xml");
|
setEppInput("domain_update_max_everything.xml");
|
||||||
// Create 26 hosts and 8 contacts. Start the domain with half of them.
|
// Create 26 hosts and 8 contacts. Start the domain with half of them.
|
||||||
ImmutableSet.Builder<Ref<HostResource>> nameservers = new ImmutableSet.Builder<>();
|
ImmutableSet.Builder<Key<HostResource>> nameservers = new ImmutableSet.Builder<>();
|
||||||
for (int i = 0; i < 26; i++) {
|
for (int i = 0; i < 26; i++) {
|
||||||
HostResource host = persistActiveHost(String.format("max_test_%d.example.tld", i));
|
HostResource host = persistActiveHost(String.format("max_test_%d.example.tld", i));
|
||||||
if (i < 13) {
|
if (i < 13) {
|
||||||
nameservers.add(Ref.create(host));
|
nameservers.add(Key.create(host));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImmutableList.Builder<DesignatedContact> contactsBuilder = new ImmutableList.Builder<>();
|
ImmutableList.Builder<DesignatedContact> contactsBuilder = new ImmutableList.Builder<>();
|
||||||
|
@ -386,14 +386,14 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
||||||
contactsBuilder.add(
|
contactsBuilder.add(
|
||||||
DesignatedContact.create(
|
DesignatedContact.create(
|
||||||
DesignatedContact.Type.values()[i % 4],
|
DesignatedContact.Type.values()[i % 4],
|
||||||
Ref.create(persistActiveContact(String.format("max_test_%d", i)))));
|
Key.create(persistActiveContact(String.format("max_test_%d", i)))));
|
||||||
}
|
}
|
||||||
ImmutableList<DesignatedContact> contacts = contactsBuilder.build();
|
ImmutableList<DesignatedContact> contacts = contactsBuilder.build();
|
||||||
persistResource(
|
persistResource(
|
||||||
reloadResourceByUniqueId().asBuilder()
|
reloadResourceByUniqueId().asBuilder()
|
||||||
.setNameservers(nameservers.build())
|
.setNameservers(nameservers.build())
|
||||||
.setContacts(ImmutableSet.copyOf(contacts.subList(0, 3)))
|
.setContacts(ImmutableSet.copyOf(contacts.subList(0, 3)))
|
||||||
.setRegistrant(contacts.get(3).getContactRef())
|
.setRegistrant(contacts.get(3).getContactKey())
|
||||||
.build());
|
.build());
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
assertTransactionalFlow(true);
|
assertTransactionalFlow(true);
|
||||||
|
@ -406,7 +406,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
||||||
assertThat(domain.getNameservers()).hasSize(13);
|
assertThat(domain.getNameservers()).hasSize(13);
|
||||||
// getContacts does not return contacts of type REGISTRANT, so check these separately.
|
// getContacts does not return contacts of type REGISTRANT, so check these separately.
|
||||||
assertThat(domain.getContacts()).hasSize(3);
|
assertThat(domain.getContacts()).hasSize(3);
|
||||||
assertThat(domain.getRegistrant().get().getContactId()).isEqualTo("max_test_7");
|
assertThat(ofy().load().key(domain.getRegistrant()).now().getContactId())
|
||||||
|
.isEqualTo("max_test_7");
|
||||||
assertNoBillingEvents();
|
assertNoBillingEvents();
|
||||||
assertDnsTasksEnqueued("example.tld");
|
assertDnsTasksEnqueued("example.tld");
|
||||||
}
|
}
|
||||||
|
@ -458,19 +459,19 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
||||||
domain = persistResource(domain.asBuilder()
|
domain = persistResource(domain.asBuilder()
|
||||||
.addSubordinateHost("ns1.example.tld")
|
.addSubordinateHost("ns1.example.tld")
|
||||||
.addSubordinateHost("ns2.example.tld")
|
.addSubordinateHost("ns2.example.tld")
|
||||||
.setNameservers(ImmutableSet.of(Ref.create(
|
.setNameservers(ImmutableSet.of(Key.create(
|
||||||
loadByUniqueId(HostResource.class, "ns1.example.tld", clock.nowUtc()))))
|
loadByUniqueId(HostResource.class, "ns1.example.tld", clock.nowUtc()))))
|
||||||
.build());
|
.build());
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
assertTransactionalFlow(true);
|
assertTransactionalFlow(true);
|
||||||
runFlowAssertResponse(readFile("domain_update_response.xml"));
|
runFlowAssertResponse(readFile("domain_update_response.xml"));
|
||||||
domain = reloadResourceByUniqueId();
|
domain = reloadResourceByUniqueId();
|
||||||
assertThat(domain.getNameservers()).containsExactly(Ref.create(addedHost));
|
assertThat(domain.getNameservers()).containsExactly(Key.create(addedHost));
|
||||||
assertThat(domain.getSubordinateHosts()).containsExactly("ns1.example.tld", "ns2.example.tld");
|
assertThat(domain.getSubordinateHosts()).containsExactly("ns1.example.tld", "ns2.example.tld");
|
||||||
existingHost = loadByUniqueId(HostResource.class, "ns1.example.tld", clock.nowUtc());
|
existingHost = loadByUniqueId(HostResource.class, "ns1.example.tld", clock.nowUtc());
|
||||||
addedHost = loadByUniqueId(HostResource.class, "ns2.example.tld", clock.nowUtc());
|
addedHost = loadByUniqueId(HostResource.class, "ns2.example.tld", clock.nowUtc());
|
||||||
assertThat(existingHost.getSuperordinateDomain()).isEqualTo(Ref.create(Key.create(domain)));
|
assertThat(existingHost.getSuperordinateDomain()).isEqualTo(Key.create(domain));
|
||||||
assertThat(addedHost.getSuperordinateDomain()).isEqualTo(Ref.create(Key.create(domain)));
|
assertThat(addedHost.getSuperordinateDomain()).isEqualTo(Key.create(domain));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -480,7 +481,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
||||||
ContactResource sh8013 = loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc());
|
ContactResource sh8013 = loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc());
|
||||||
persistResource(
|
persistResource(
|
||||||
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
||||||
.setRegistrant(Ref.create(sh8013))
|
.setRegistrant(Key.create(sh8013))
|
||||||
.build());
|
.build());
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
runFlowAssertResponse(readFile("domain_update_response.xml"));
|
runFlowAssertResponse(readFile("domain_update_response.xml"));
|
||||||
|
@ -491,14 +492,14 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
||||||
setEppInput("domain_update_remove_multiple_contacts.xml");
|
setEppInput("domain_update_remove_multiple_contacts.xml");
|
||||||
persistReferencedEntities();
|
persistReferencedEntities();
|
||||||
ContactResource sh8013 = loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc());
|
ContactResource sh8013 = loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc());
|
||||||
Ref<ContactResource> sh8013Ref = Ref.create(sh8013);
|
Key<ContactResource> sh8013Key = Key.create(sh8013);
|
||||||
persistResource(
|
persistResource(
|
||||||
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
||||||
.setRegistrant(sh8013Ref)
|
.setRegistrant(sh8013Key)
|
||||||
.setContacts(ImmutableSet.of(
|
.setContacts(ImmutableSet.of(
|
||||||
DesignatedContact.create(Type.ADMIN, sh8013Ref),
|
DesignatedContact.create(Type.ADMIN, sh8013Key),
|
||||||
DesignatedContact.create(Type.BILLING, sh8013Ref),
|
DesignatedContact.create(Type.BILLING, sh8013Key),
|
||||||
DesignatedContact.create(Type.TECH, sh8013Ref)))
|
DesignatedContact.create(Type.TECH, sh8013Key)))
|
||||||
.build());
|
.build());
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
runFlowAssertResponse(readFile("domain_update_response.xml"));
|
runFlowAssertResponse(readFile("domain_update_response.xml"));
|
||||||
|
@ -890,7 +891,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
||||||
persistResource(
|
persistResource(
|
||||||
reloadResourceByUniqueId().asBuilder()
|
reloadResourceByUniqueId().asBuilder()
|
||||||
.setContacts(ImmutableSet.of(
|
.setContacts(ImmutableSet.of(
|
||||||
DesignatedContact.create(Type.TECH, Ref.create(
|
DesignatedContact.create(Type.TECH, Key.create(
|
||||||
loadByUniqueId(ContactResource.class, "foo", clock.nowUtc())))))
|
loadByUniqueId(ContactResource.class, "foo", clock.nowUtc())))))
|
||||||
.build());
|
.build());
|
||||||
runFlow();
|
runFlow();
|
||||||
|
@ -986,7 +987,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
||||||
persistReferencedEntities();
|
persistReferencedEntities();
|
||||||
persistResource(
|
persistResource(
|
||||||
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
||||||
.setNameservers(ImmutableSet.of(Ref.create(
|
.setNameservers(ImmutableSet.of(Key.create(
|
||||||
loadByUniqueId(HostResource.class, "ns1.example.foo", clock.nowUtc()))))
|
loadByUniqueId(HostResource.class, "ns1.example.foo", clock.nowUtc()))))
|
||||||
.build());
|
.build());
|
||||||
runFlow();
|
runFlow();
|
||||||
|
@ -1001,7 +1002,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
||||||
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
||||||
.setContacts(ImmutableSet.of(DesignatedContact.create(
|
.setContacts(ImmutableSet.of(DesignatedContact.create(
|
||||||
Type.TECH,
|
Type.TECH,
|
||||||
Ref.create(
|
Key.create(
|
||||||
loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc())))))
|
loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc())))))
|
||||||
.build());
|
.build());
|
||||||
runFlow();
|
runFlow();
|
||||||
|
@ -1015,8 +1016,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
||||||
persistResource(
|
persistResource(
|
||||||
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
||||||
.setContacts(ImmutableSet.of(
|
.setContacts(ImmutableSet.of(
|
||||||
DesignatedContact.create(Type.ADMIN, Ref.create(sh8013Contact)),
|
DesignatedContact.create(Type.ADMIN, Key.create(sh8013Contact)),
|
||||||
DesignatedContact.create(Type.TECH, Ref.create(sh8013Contact))))
|
DesignatedContact.create(Type.TECH, Key.create(sh8013Contact))))
|
||||||
.build());
|
.build());
|
||||||
runFlow();
|
runFlow();
|
||||||
}
|
}
|
||||||
|
@ -1029,8 +1030,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
||||||
persistResource(
|
persistResource(
|
||||||
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
||||||
.setContacts(ImmutableSet.of(
|
.setContacts(ImmutableSet.of(
|
||||||
DesignatedContact.create(Type.ADMIN, Ref.create(sh8013Contact)),
|
DesignatedContact.create(Type.ADMIN, Key.create(sh8013Contact)),
|
||||||
DesignatedContact.create(Type.TECH, Ref.create(sh8013Contact))))
|
DesignatedContact.create(Type.TECH, Key.create(sh8013Contact))))
|
||||||
.build());
|
.build());
|
||||||
runFlow();
|
runFlow();
|
||||||
}
|
}
|
||||||
|
@ -1109,10 +1110,10 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
||||||
ImmutableSet.of("ns1.example.foo", "ns2.example.foo"))
|
ImmutableSet.of("ns1.example.foo", "ns2.example.foo"))
|
||||||
.build());
|
.build());
|
||||||
assertThat(reloadResourceByUniqueId().getNameservers()).doesNotContain(
|
assertThat(reloadResourceByUniqueId().getNameservers()).doesNotContain(
|
||||||
Ref.create(loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc())));
|
Key.create(loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc())));
|
||||||
runFlow();
|
runFlow();
|
||||||
assertThat(reloadResourceByUniqueId().getNameservers()).contains(
|
assertThat(reloadResourceByUniqueId().getNameservers()).contains(
|
||||||
Ref.create(loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc())));
|
Key.create(loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -1127,7 +1128,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
||||||
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns1.example.foo"))
|
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns1.example.foo"))
|
||||||
.build());
|
.build());
|
||||||
runFlow();
|
runFlow();
|
||||||
assertThat(reloadResourceByUniqueId().getRegistrant().get().getContactId()).isEqualTo("sh8013");
|
assertThat(ofy().load().key(reloadResourceByUniqueId().getRegistrant()).now().getContactId())
|
||||||
|
.isEqualTo("sh8013");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -1149,7 +1151,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
||||||
persistDomain();
|
persistDomain();
|
||||||
persistResource(
|
persistResource(
|
||||||
reloadResourceByUniqueId().asBuilder()
|
reloadResourceByUniqueId().asBuilder()
|
||||||
.addNameservers(ImmutableSet.of(Ref.create(
|
.addNameservers(ImmutableSet.of(Key.create(
|
||||||
loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc()))))
|
loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc()))))
|
||||||
.build());
|
.build());
|
||||||
persistResource(
|
persistResource(
|
||||||
|
@ -1158,11 +1160,11 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
||||||
ImmutableSet.of("ns1.example.foo", "ns2.example.foo"))
|
ImmutableSet.of("ns1.example.foo", "ns2.example.foo"))
|
||||||
.build());
|
.build());
|
||||||
assertThat(reloadResourceByUniqueId().getNameservers()).contains(
|
assertThat(reloadResourceByUniqueId().getNameservers()).contains(
|
||||||
Ref.create(loadByUniqueId(HostResource.class, "ns1.example.foo", clock.nowUtc())));
|
Key.create(loadByUniqueId(HostResource.class, "ns1.example.foo", clock.nowUtc())));
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
runFlow();
|
runFlow();
|
||||||
assertThat(reloadResourceByUniqueId().getNameservers()).doesNotContain(
|
assertThat(reloadResourceByUniqueId().getNameservers()).doesNotContain(
|
||||||
Ref.create(loadByUniqueId(HostResource.class, "ns1.example.foo", clock.nowUtc())));
|
Key.create(loadByUniqueId(HostResource.class, "ns1.example.foo", clock.nowUtc())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -104,10 +104,10 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_internalNeverExisted() throws Exception {
|
public void testSuccess_internalNeverExisted() throws Exception {
|
||||||
doSuccessfulInternalTest("tld");
|
doSuccessfulInternalTest("tld");
|
||||||
assertThat(ofy().load().ref(reloadResourceByUniqueId().getSuperordinateDomain())
|
assertThat(ofy().load().key(reloadResourceByUniqueId().getSuperordinateDomain())
|
||||||
.now().getFullyQualifiedDomainName())
|
.now().getFullyQualifiedDomainName())
|
||||||
.isEqualTo("example.tld");
|
.isEqualTo("example.tld");
|
||||||
assertThat(ofy().load().ref(reloadResourceByUniqueId().getSuperordinateDomain())
|
assertThat(ofy().load().key(reloadResourceByUniqueId().getSuperordinateDomain())
|
||||||
.now().getSubordinateHosts()).containsExactly("ns1.example.tld");
|
.now().getSubordinateHosts()).containsExactly("ns1.example.tld");
|
||||||
assertDnsTasksEnqueued("ns1.example.tld");
|
assertDnsTasksEnqueued("ns1.example.tld");
|
||||||
}
|
}
|
||||||
|
@ -123,10 +123,10 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
|
||||||
public void testSuccess_internalExistedButWasDeleted() throws Exception {
|
public void testSuccess_internalExistedButWasDeleted() throws Exception {
|
||||||
persistDeletedHost(getUniqueIdFromCommand(), clock.nowUtc());
|
persistDeletedHost(getUniqueIdFromCommand(), clock.nowUtc());
|
||||||
doSuccessfulInternalTest("tld");
|
doSuccessfulInternalTest("tld");
|
||||||
assertThat(ofy().load().ref(reloadResourceByUniqueId().getSuperordinateDomain())
|
assertThat(ofy().load().key(reloadResourceByUniqueId().getSuperordinateDomain())
|
||||||
.now().getFullyQualifiedDomainName())
|
.now().getFullyQualifiedDomainName())
|
||||||
.isEqualTo("example.tld");
|
.isEqualTo("example.tld");
|
||||||
assertThat(ofy().load().ref(reloadResourceByUniqueId().getSuperordinateDomain())
|
assertThat(ofy().load().key(reloadResourceByUniqueId().getSuperordinateDomain())
|
||||||
.now().getSubordinateHosts()).containsExactly("ns1.example.tld");
|
.now().getSubordinateHosts()).containsExactly("ns1.example.tld");
|
||||||
assertDnsTasksEnqueued("ns1.example.tld");
|
assertDnsTasksEnqueued("ns1.example.tld");
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,6 @@ import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import google.registry.flows.ResourceAsyncDeleteFlow.ResourceToDeleteIsReferencedException;
|
import google.registry.flows.ResourceAsyncDeleteFlow.ResourceToDeleteIsReferencedException;
|
||||||
import google.registry.flows.ResourceFlowTestCase;
|
import google.registry.flows.ResourceFlowTestCase;
|
||||||
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
|
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
|
||||||
|
@ -173,7 +172,7 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
persistResource(newDomainResource("example.tld").asBuilder()
|
persistResource(newDomainResource("example.tld").asBuilder()
|
||||||
.setNameservers(ImmutableSet.of(
|
.setNameservers(ImmutableSet.of(
|
||||||
Ref.create(persistActiveHost(getUniqueIdFromCommand()))))
|
Key.create(persistActiveHost(getUniqueIdFromCommand()))))
|
||||||
.build());
|
.build());
|
||||||
thrown.expect(ResourceToDeleteIsReferencedException.class);
|
thrown.expect(ResourceToDeleteIsReferencedException.class);
|
||||||
runFlow();
|
runFlow();
|
||||||
|
@ -184,7 +183,7 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
persistResource(newDomainApplication("example.tld").asBuilder()
|
persistResource(newDomainApplication("example.tld").asBuilder()
|
||||||
.setNameservers(ImmutableSet.of(
|
.setNameservers(ImmutableSet.of(
|
||||||
Ref.create(persistActiveHost(getUniqueIdFromCommand()))))
|
Key.create(persistActiveHost(getUniqueIdFromCommand()))))
|
||||||
.build());
|
.build());
|
||||||
thrown.expect(ResourceToDeleteIsReferencedException.class);
|
thrown.expect(ResourceToDeleteIsReferencedException.class);
|
||||||
runFlow();
|
runFlow();
|
||||||
|
|
|
@ -23,7 +23,7 @@ import static google.registry.testing.DatastoreHelper.persistResource;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.net.InetAddresses;
|
import com.google.common.net.InetAddresses;
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.flows.ResourceFlowTestCase;
|
import google.registry.flows.ResourceFlowTestCase;
|
||||||
import google.registry.flows.ResourceQueryFlow.ResourceToQueryDoesNotExistException;
|
import google.registry.flows.ResourceQueryFlow.ResourceToQueryDoesNotExistException;
|
||||||
import google.registry.model.domain.DomainResource;
|
import google.registry.model.domain.DomainResource;
|
||||||
|
@ -88,8 +88,7 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
|
||||||
persistHostResource(true);
|
persistHostResource(true);
|
||||||
persistResource(
|
persistResource(
|
||||||
newDomainResource("example.foobar").asBuilder()
|
newDomainResource("example.foobar").asBuilder()
|
||||||
.addNameservers(
|
.addNameservers(ImmutableSet.of(Key.create(persistHostResource(true))))
|
||||||
ImmutableSet.of(Ref.<HostResource>create(persistHostResource(true))))
|
|
||||||
.build());
|
.build());
|
||||||
assertTransactionalFlow(false);
|
assertTransactionalFlow(false);
|
||||||
// Check that the persisted host info was returned.
|
// Check that the persisted host info was returned.
|
||||||
|
@ -112,7 +111,7 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
|
||||||
persistResource(
|
persistResource(
|
||||||
persistHostResource(true).asBuilder()
|
persistHostResource(true).asBuilder()
|
||||||
.setRepoId("CEEF-FOOBAR")
|
.setRepoId("CEEF-FOOBAR")
|
||||||
.setSuperordinateDomain(Ref.create(domain))
|
.setSuperordinateDomain(Key.create(domain))
|
||||||
.setLastSuperordinateChange(lastSuperordinateChange)
|
.setLastSuperordinateChange(lastSuperordinateChange)
|
||||||
.build());
|
.build());
|
||||||
assertTransactionalFlow(false);
|
assertTransactionalFlow(false);
|
||||||
|
|
|
@ -40,7 +40,6 @@ import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.net.InetAddresses;
|
import com.google.common.net.InetAddresses;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import google.registry.flows.EppRequestSource;
|
import google.registry.flows.EppRequestSource;
|
||||||
import google.registry.flows.ResourceFlowTestCase;
|
import google.registry.flows.ResourceFlowTestCase;
|
||||||
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
|
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
|
||||||
|
@ -143,7 +142,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
||||||
ForeignKeyIndex<HostResource> oldFkiBeforeRename =
|
ForeignKeyIndex<HostResource> oldFkiBeforeRename =
|
||||||
ForeignKeyIndex.load(
|
ForeignKeyIndex.load(
|
||||||
HostResource.class, oldHostName(), clock.nowUtc().minusMillis(1));
|
HostResource.class, oldHostName(), clock.nowUtc().minusMillis(1));
|
||||||
assertThat(oldFkiBeforeRename.getReference()).isEqualTo(Ref.create(renamedHost));
|
assertThat(oldFkiBeforeRename.getResourceKey()).isEqualTo(Key.create(renamedHost));
|
||||||
assertThat(oldFkiBeforeRename.getDeletionTime()).isEqualTo(clock.nowUtc());
|
assertThat(oldFkiBeforeRename.getDeletionTime()).isEqualTo(clock.nowUtc());
|
||||||
ForeignKeyIndex<HostResource> oldFkiAfterRename =
|
ForeignKeyIndex<HostResource> oldFkiAfterRename =
|
||||||
ForeignKeyIndex.load(
|
ForeignKeyIndex.load(
|
||||||
|
@ -157,7 +156,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
||||||
persistResource(
|
persistResource(
|
||||||
newDomainResource("test.xn--q9jyb4c").asBuilder()
|
newDomainResource("test.xn--q9jyb4c").asBuilder()
|
||||||
.setDeletionTime(END_OF_TIME)
|
.setDeletionTime(END_OF_TIME)
|
||||||
.setNameservers(ImmutableSet.of(Ref.create(host)))
|
.setNameservers(ImmutableSet.of(Key.create(host)))
|
||||||
.build());
|
.build());
|
||||||
HostResource renamedHost = doSuccessfulTest();
|
HostResource renamedHost = doSuccessfulTest();
|
||||||
assertThat(renamedHost.getSuperordinateDomain()).isNull();
|
assertThat(renamedHost.getSuperordinateDomain()).isNull();
|
||||||
|
@ -202,7 +201,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
||||||
DomainResource.class, "example.tld", clock.nowUtc()).getSubordinateHosts())
|
DomainResource.class, "example.tld", clock.nowUtc()).getSubordinateHosts())
|
||||||
.containsExactly("ns1.example.tld");
|
.containsExactly("ns1.example.tld");
|
||||||
HostResource renamedHost = doSuccessfulTest();
|
HostResource renamedHost = doSuccessfulTest();
|
||||||
assertThat(renamedHost.getSuperordinateDomain()).isEqualTo(Ref.create(domain));
|
assertThat(renamedHost.getSuperordinateDomain()).isEqualTo(Key.create(domain));
|
||||||
assertThat(
|
assertThat(
|
||||||
loadByUniqueId(
|
loadByUniqueId(
|
||||||
DomainResource.class, "example.tld", clock.nowUtc()).getSubordinateHosts())
|
DomainResource.class, "example.tld", clock.nowUtc()).getSubordinateHosts())
|
||||||
|
@ -234,7 +233,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
||||||
DomainResource.class, "example.tld", clock.nowUtc()).getSubordinateHosts())
|
DomainResource.class, "example.tld", clock.nowUtc()).getSubordinateHosts())
|
||||||
.isEmpty();
|
.isEmpty();
|
||||||
HostResource renamedHost = doSuccessfulTest();
|
HostResource renamedHost = doSuccessfulTest();
|
||||||
assertThat(renamedHost.getSuperordinateDomain()).isEqualTo(Ref.create(example));
|
assertThat(renamedHost.getSuperordinateDomain()).isEqualTo(Key.create(example));
|
||||||
assertThat(
|
assertThat(
|
||||||
loadByUniqueId(
|
loadByUniqueId(
|
||||||
DomainResource.class, "foo.tld", clock.nowUtc()).getSubordinateHosts())
|
DomainResource.class, "foo.tld", clock.nowUtc()).getSubordinateHosts())
|
||||||
|
@ -297,7 +296,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
||||||
DomainResource.class, "example.tld", clock.nowUtc()).getSubordinateHosts())
|
DomainResource.class, "example.tld", clock.nowUtc()).getSubordinateHosts())
|
||||||
.isEmpty();
|
.isEmpty();
|
||||||
HostResource renamedHost = doSuccessfulTest();
|
HostResource renamedHost = doSuccessfulTest();
|
||||||
assertThat(renamedHost.getSuperordinateDomain()).isEqualTo(Ref.create(tldDomain));
|
assertThat(renamedHost.getSuperordinateDomain()).isEqualTo(Key.create(tldDomain));
|
||||||
assertThat(loadByUniqueId(
|
assertThat(loadByUniqueId(
|
||||||
DomainResource.class, "example.tld", clock.nowUtc()).getSubordinateHosts())
|
DomainResource.class, "example.tld", clock.nowUtc()).getSubordinateHosts())
|
||||||
.containsExactly("ns2.example.tld");
|
.containsExactly("ns2.example.tld");
|
||||||
|
@ -328,7 +327,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
||||||
DomainResource.class, "example.tld", clock.nowUtc()).getSubordinateHosts())
|
DomainResource.class, "example.tld", clock.nowUtc()).getSubordinateHosts())
|
||||||
.isEmpty();
|
.isEmpty();
|
||||||
HostResource renamedHost = doSuccessfulTest();
|
HostResource renamedHost = doSuccessfulTest();
|
||||||
assertThat(renamedHost.getSuperordinateDomain()).isEqualTo(Ref.create(domain));
|
assertThat(renamedHost.getSuperordinateDomain()).isEqualTo(Key.create(domain));
|
||||||
assertThat(loadByUniqueId(
|
assertThat(loadByUniqueId(
|
||||||
DomainResource.class, "example.tld", clock.nowUtc()).getSubordinateHosts())
|
DomainResource.class, "example.tld", clock.nowUtc()).getSubordinateHosts())
|
||||||
.containsExactly("ns2.example.tld");
|
.containsExactly("ns2.example.tld");
|
||||||
|
@ -380,7 +379,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
||||||
|
|
||||||
persistResource(
|
persistResource(
|
||||||
newHostResource(oldHostName()).asBuilder()
|
newHostResource(oldHostName()).asBuilder()
|
||||||
.setSuperordinateDomain(Ref.create(foo))
|
.setSuperordinateDomain(Key.create(foo))
|
||||||
.setLastTransferTime(null)
|
.setLastTransferTime(null)
|
||||||
.build());
|
.build());
|
||||||
persistResource(
|
persistResource(
|
||||||
|
@ -412,7 +411,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
||||||
.build());
|
.build());
|
||||||
HostResource host = persistResource(
|
HostResource host = persistResource(
|
||||||
newHostResource(oldHostName()).asBuilder()
|
newHostResource(oldHostName()).asBuilder()
|
||||||
.setSuperordinateDomain(Ref.create(domain))
|
.setSuperordinateDomain(Key.create(domain))
|
||||||
.setLastTransferTime(clock.nowUtc().minusDays(20))
|
.setLastTransferTime(clock.nowUtc().minusDays(20))
|
||||||
.setLastSuperordinateChange(clock.nowUtc().minusDays(3))
|
.setLastSuperordinateChange(clock.nowUtc().minusDays(3))
|
||||||
.build());
|
.build());
|
||||||
|
@ -442,7 +441,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
||||||
|
|
||||||
persistResource(
|
persistResource(
|
||||||
newHostResource(oldHostName()).asBuilder()
|
newHostResource(oldHostName()).asBuilder()
|
||||||
.setSuperordinateDomain(Ref.create(foo))
|
.setSuperordinateDomain(Key.create(foo))
|
||||||
.setLastTransferTime(lastTransferTime)
|
.setLastTransferTime(lastTransferTime)
|
||||||
.setLastSuperordinateChange(clock.nowUtc().minusDays(3))
|
.setLastSuperordinateChange(clock.nowUtc().minusDays(3))
|
||||||
.build());
|
.build());
|
||||||
|
@ -476,7 +475,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
||||||
|
|
||||||
persistResource(
|
persistResource(
|
||||||
newHostResource(oldHostName()).asBuilder()
|
newHostResource(oldHostName()).asBuilder()
|
||||||
.setSuperordinateDomain(Ref.create(foo))
|
.setSuperordinateDomain(Key.create(foo))
|
||||||
.setLastTransferTime(lastTransferTime)
|
.setLastTransferTime(lastTransferTime)
|
||||||
.setLastSuperordinateChange(clock.nowUtc().minusDays(10))
|
.setLastSuperordinateChange(clock.nowUtc().minusDays(10))
|
||||||
.build());
|
.build());
|
||||||
|
@ -508,7 +507,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
||||||
.build());
|
.build());
|
||||||
persistResource(
|
persistResource(
|
||||||
newHostResource(oldHostName()).asBuilder()
|
newHostResource(oldHostName()).asBuilder()
|
||||||
.setSuperordinateDomain(Ref.create(foo))
|
.setSuperordinateDomain(Key.create(foo))
|
||||||
.setLastTransferTime(null)
|
.setLastTransferTime(null)
|
||||||
.setLastSuperordinateChange(clock.nowUtc().minusDays(3))
|
.setLastSuperordinateChange(clock.nowUtc().minusDays(3))
|
||||||
.build());
|
.build());
|
||||||
|
@ -530,7 +529,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
||||||
DomainResource domain = persistActiveDomain("example.foo");
|
DomainResource domain = persistActiveDomain("example.foo");
|
||||||
persistResource(
|
persistResource(
|
||||||
newHostResource(oldHostName()).asBuilder()
|
newHostResource(oldHostName()).asBuilder()
|
||||||
.setSuperordinateDomain(Ref.create(domain))
|
.setSuperordinateDomain(Key.create(domain))
|
||||||
.build());
|
.build());
|
||||||
DateTime lastTransferTime = clock.nowUtc().minusDays(2);
|
DateTime lastTransferTime = clock.nowUtc().minusDays(2);
|
||||||
persistResource(
|
persistResource(
|
||||||
|
@ -563,7 +562,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
||||||
|
|
||||||
persistResource(
|
persistResource(
|
||||||
newHostResource(oldHostName()).asBuilder()
|
newHostResource(oldHostName()).asBuilder()
|
||||||
.setSuperordinateDomain(Ref.create(domain))
|
.setSuperordinateDomain(Key.create(domain))
|
||||||
.setLastTransferTime(lastTransferTime)
|
.setLastTransferTime(lastTransferTime)
|
||||||
.setLastSuperordinateChange(clock.nowUtc().minusDays(4))
|
.setLastSuperordinateChange(clock.nowUtc().minusDays(4))
|
||||||
.build());
|
.build());
|
||||||
|
@ -592,7 +591,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
||||||
DomainResource domain = persistActiveDomain("example.foo");
|
DomainResource domain = persistActiveDomain("example.foo");
|
||||||
persistResource(
|
persistResource(
|
||||||
newHostResource(oldHostName()).asBuilder()
|
newHostResource(oldHostName()).asBuilder()
|
||||||
.setSuperordinateDomain(Ref.create(domain))
|
.setSuperordinateDomain(Key.create(domain))
|
||||||
.setLastTransferTime(clock.nowUtc().minusDays(12))
|
.setLastTransferTime(clock.nowUtc().minusDays(12))
|
||||||
.setLastSuperordinateChange(clock.nowUtc().minusDays(4))
|
.setLastSuperordinateChange(clock.nowUtc().minusDays(4))
|
||||||
.build());
|
.build());
|
||||||
|
@ -730,7 +729,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
||||||
"<host:addr ip=\"v6\">1080:0:0:0:8:800:200C:417A</host:addr>");
|
"<host:addr ip=\"v6\">1080:0:0:0:8:800:200C:417A</host:addr>");
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
persistResource(newHostResource(oldHostName()).asBuilder()
|
persistResource(newHostResource(oldHostName()).asBuilder()
|
||||||
.setSuperordinateDomain(Ref.create(persistActiveDomain("example.tld")))
|
.setSuperordinateDomain(Key.create(persistActiveDomain("example.tld")))
|
||||||
.build());
|
.build());
|
||||||
thrown.expect(CannotRemoveSubordinateHostLastIpException.class);
|
thrown.expect(CannotRemoveSubordinateHostLastIpException.class);
|
||||||
runFlow();
|
runFlow();
|
||||||
|
@ -759,7 +758,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
||||||
persistResource(
|
persistResource(
|
||||||
newHostResource(oldHostName())
|
newHostResource(oldHostName())
|
||||||
.asBuilder()
|
.asBuilder()
|
||||||
.setSuperordinateDomain(Ref.create(persistActiveDomain("example.tld")))
|
.setSuperordinateDomain(Key.create(persistActiveDomain("example.tld")))
|
||||||
.setInetAddresses(ImmutableSet.of(InetAddresses.forString("127.0.0.1")))
|
.setInetAddresses(ImmutableSet.of(InetAddresses.forString("127.0.0.1")))
|
||||||
.build());
|
.build());
|
||||||
thrown.expect(RenameHostToExternalRemoveIpException.class);
|
thrown.expect(RenameHostToExternalRemoveIpException.class);
|
||||||
|
@ -775,7 +774,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
||||||
null);
|
null);
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
persistResource(newHostResource(oldHostName()).asBuilder()
|
persistResource(newHostResource(oldHostName()).asBuilder()
|
||||||
.setSuperordinateDomain(Ref.create(persistActiveDomain("example.tld")))
|
.setSuperordinateDomain(Key.create(persistActiveDomain("example.tld")))
|
||||||
.build());
|
.build());
|
||||||
thrown.expect(CannotAddIpToExternalHostException.class);
|
thrown.expect(CannotAddIpToExternalHostException.class);
|
||||||
runFlow();
|
runFlow();
|
||||||
|
|
|
@ -108,7 +108,7 @@ public class EppResourceUtilsTest {
|
||||||
@Test
|
@Test
|
||||||
public void testLoadAtPointInTime_brokenRevisionHistory_returnsResourceAsIs()
|
public void testLoadAtPointInTime_brokenRevisionHistory_returnsResourceAsIs()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
// Don't save a commit log, we want to test the handling of a broken revisions reference.
|
// Don't save a commit log since we want to test the handling of a broken revisions key.
|
||||||
HostResource oldHost = persistResource(
|
HostResource oldHost = persistResource(
|
||||||
newHostResource("ns1.cat.tld").asBuilder()
|
newHostResource("ns1.cat.tld").asBuilder()
|
||||||
.setCreationTimeForTest(START_OF_TIME)
|
.setCreationTimeForTest(START_OF_TIME)
|
||||||
|
|
|
@ -29,7 +29,6 @@ import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.ObjectifyService;
|
import com.googlecode.objectify.ObjectifyService;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import com.googlecode.objectify.annotation.Entity;
|
import com.googlecode.objectify.annotation.Entity;
|
||||||
import com.googlecode.objectify.annotation.Id;
|
import com.googlecode.objectify.annotation.Id;
|
||||||
import google.registry.model.ImmutableObject.DoNotHydrate;
|
import google.registry.model.ImmutableObject.DoNotHydrate;
|
||||||
|
@ -258,15 +257,13 @@ public class ImmutableObjectTest {
|
||||||
|
|
||||||
/** Subclass of ImmutableObject with keys to other objects. */
|
/** Subclass of ImmutableObject with keys to other objects. */
|
||||||
public static class RootObject extends ImmutableObject {
|
public static class RootObject extends ImmutableObject {
|
||||||
Ref<HydratableObject> hydratable;
|
Key<HydratableObject> hydratable;
|
||||||
|
|
||||||
Ref<UnhydratableObject> unhydratable;
|
Key<UnhydratableObject> unhydratable;
|
||||||
|
|
||||||
Key<HydratableObject> key;
|
Map<String, Key<?>> map;
|
||||||
|
|
||||||
Map<String, Ref<?>> map;
|
Set<Key<?>> set;
|
||||||
|
|
||||||
Set<Ref<?>> set;
|
|
||||||
|
|
||||||
ReferenceUnion<?> referenceUnion;
|
ReferenceUnion<?> referenceUnion;
|
||||||
}
|
}
|
||||||
|
@ -297,21 +294,12 @@ public class ImmutableObjectTest {
|
||||||
UnhydratableObject unhydratable = new UnhydratableObject();
|
UnhydratableObject unhydratable = new UnhydratableObject();
|
||||||
unhydratable.value = "unexpected";
|
unhydratable.value = "unexpected";
|
||||||
RootObject root = new RootObject();
|
RootObject root = new RootObject();
|
||||||
root.hydratable = Ref.create(persistResource(hydratable));
|
root.hydratable = Key.create(persistResource(hydratable));
|
||||||
root.unhydratable = Ref.create(persistResource(unhydratable));
|
root.unhydratable = Key.create(persistResource(unhydratable));
|
||||||
assertThat(root.toHydratedString()).contains("expected");
|
assertThat(root.toHydratedString()).contains("expected");
|
||||||
assertThat(root.toHydratedString()).doesNotContain("unexpected");
|
assertThat(root.toHydratedString()).doesNotContain("unexpected");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testToHydratedString_skipsKeys() {
|
|
||||||
HydratableObject hydratable = new HydratableObject();
|
|
||||||
hydratable.value = "unexpected";
|
|
||||||
RootObject root = new RootObject();
|
|
||||||
root.key = Key.create(persistResource(hydratable));
|
|
||||||
assertThat(root.toHydratedString()).doesNotContain("unexpected");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testToHydratedString_expandsMaps() {
|
public void testToHydratedString_expandsMaps() {
|
||||||
HydratableObject hydratable = new HydratableObject();
|
HydratableObject hydratable = new HydratableObject();
|
||||||
|
@ -319,9 +307,9 @@ public class ImmutableObjectTest {
|
||||||
UnhydratableObject unhydratable = new UnhydratableObject();
|
UnhydratableObject unhydratable = new UnhydratableObject();
|
||||||
unhydratable.value = "unexpected";
|
unhydratable.value = "unexpected";
|
||||||
RootObject root = new RootObject();
|
RootObject root = new RootObject();
|
||||||
root.map = ImmutableMap.<String, Ref<?>>of(
|
root.map = ImmutableMap.<String, Key<?>>of(
|
||||||
"hydratable", Ref.create(persistResource(hydratable)),
|
"hydratable", Key.create(persistResource(hydratable)),
|
||||||
"unhydratable", Ref.create(persistResource(unhydratable)));
|
"unhydratable", Key.create(persistResource(unhydratable)));
|
||||||
assertThat(root.toHydratedString()).contains("expected");
|
assertThat(root.toHydratedString()).contains("expected");
|
||||||
assertThat(root.toHydratedString()).doesNotContain("unexpected");
|
assertThat(root.toHydratedString()).doesNotContain("unexpected");
|
||||||
}
|
}
|
||||||
|
@ -333,9 +321,9 @@ public class ImmutableObjectTest {
|
||||||
UnhydratableObject unhydratable = new UnhydratableObject();
|
UnhydratableObject unhydratable = new UnhydratableObject();
|
||||||
unhydratable.value = "unexpected";
|
unhydratable.value = "unexpected";
|
||||||
RootObject root = new RootObject();
|
RootObject root = new RootObject();
|
||||||
root.set = ImmutableSet.<Ref<?>>of(
|
root.set = ImmutableSet.<Key<?>>of(
|
||||||
Ref.create(persistResource(hydratable)),
|
Key.create(persistResource(hydratable)),
|
||||||
Ref.create(persistResource(unhydratable)));
|
Key.create(persistResource(unhydratable)));
|
||||||
assertThat(root.toHydratedString()).contains("expected");
|
assertThat(root.toHydratedString()).contains("expected");
|
||||||
assertThat(root.toHydratedString()).doesNotContain("unexpected");
|
assertThat(root.toHydratedString()).doesNotContain("unexpected");
|
||||||
}
|
}
|
||||||
|
@ -343,7 +331,7 @@ public class ImmutableObjectTest {
|
||||||
@Test
|
@Test
|
||||||
public void testToHydratedString_expandsReferenceUnions() {
|
public void testToHydratedString_expandsReferenceUnions() {
|
||||||
RootObject root = new RootObject();
|
RootObject root = new RootObject();
|
||||||
root.referenceUnion = ReferenceUnion.create(Ref.create(persistActiveContact("expected")));
|
root.referenceUnion = ReferenceUnion.create(Key.create(persistActiveContact("expected")));
|
||||||
assertThat(root.toHydratedString()).contains("expected");
|
assertThat(root.toHydratedString()).contains("expected");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@ import static org.joda.time.DateTimeZone.UTC;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import google.registry.model.EntityTestCase;
|
import google.registry.model.EntityTestCase;
|
||||||
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;
|
||||||
|
@ -106,14 +105,14 @@ public class BillingEventTest extends EntityTestCase {
|
||||||
.setReason(Reason.CREATE)
|
.setReason(Reason.CREATE)
|
||||||
.setEventTime(now.plusDays(1))
|
.setEventTime(now.plusDays(1))
|
||||||
.setBillingTime(now.plusDays(5))
|
.setBillingTime(now.plusDays(5))
|
||||||
.setOneTimeEventRef(Ref.create(oneTime))));
|
.setOneTimeEventKey(Key.create(oneTime))));
|
||||||
cancellationRecurring = persistResource(commonInit(
|
cancellationRecurring = persistResource(commonInit(
|
||||||
new BillingEvent.Cancellation.Builder()
|
new BillingEvent.Cancellation.Builder()
|
||||||
.setParent(historyEntry2)
|
.setParent(historyEntry2)
|
||||||
.setReason(Reason.RENEW)
|
.setReason(Reason.RENEW)
|
||||||
.setEventTime(now.plusDays(1))
|
.setEventTime(now.plusDays(1))
|
||||||
.setBillingTime(now.plusYears(1).plusDays(45))
|
.setBillingTime(now.plusYears(1).plusDays(45))
|
||||||
.setRecurringEventRef(Ref.create(recurring))));
|
.setRecurringEventKey(Key.create(recurring))));
|
||||||
modification = persistResource(commonInit(
|
modification = persistResource(commonInit(
|
||||||
new BillingEvent.Modification.Builder()
|
new BillingEvent.Modification.Builder()
|
||||||
.setParent(historyEntry2)
|
.setParent(historyEntry2)
|
||||||
|
@ -121,7 +120,7 @@ public class BillingEventTest extends EntityTestCase {
|
||||||
.setCost(Money.of(USD, 1))
|
.setCost(Money.of(USD, 1))
|
||||||
.setDescription("Something happened")
|
.setDescription("Something happened")
|
||||||
.setEventTime(now.plusDays(1))
|
.setEventTime(now.plusDays(1))
|
||||||
.setEventRef(Ref.create(oneTime))));
|
.setEventKey(Key.create(oneTime))));
|
||||||
}
|
}
|
||||||
|
|
||||||
private <E extends BillingEvent, B extends BillingEvent.Builder<E, B>> E commonInit(B builder) {
|
private <E extends BillingEvent, B extends BillingEvent.Builder<E, B>> E commonInit(B builder) {
|
||||||
|
@ -241,7 +240,7 @@ public class BillingEventTest extends EntityTestCase {
|
||||||
GracePeriodStatus.AUTO_RENEW,
|
GracePeriodStatus.AUTO_RENEW,
|
||||||
now.plusYears(1).plusDays(45),
|
now.plusYears(1).plusDays(45),
|
||||||
"a registrar",
|
"a registrar",
|
||||||
Ref.create(recurring)),
|
Key.create(recurring)),
|
||||||
historyEntry2,
|
historyEntry2,
|
||||||
"foo.tld");
|
"foo.tld");
|
||||||
// Set ID to be the same to ignore for the purposes of comparison.
|
// Set ID to be the same to ignore for the purposes of comparison.
|
||||||
|
@ -264,15 +263,15 @@ public class BillingEventTest extends EntityTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_cancellationWithNoBillingEvent() {
|
public void testFailure_cancellationWithNoBillingEvent() {
|
||||||
thrown.expect(IllegalStateException.class, "exactly one billing event");
|
thrown.expect(IllegalStateException.class, "exactly one billing event");
|
||||||
cancellationOneTime.asBuilder().setOneTimeEventRef(null).setRecurringEventRef(null).build();
|
cancellationOneTime.asBuilder().setOneTimeEventKey(null).setRecurringEventKey(null).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_cancellationWithBothBillingEvents() {
|
public void testFailure_cancellationWithBothBillingEvents() {
|
||||||
thrown.expect(IllegalStateException.class, "exactly one billing event");
|
thrown.expect(IllegalStateException.class, "exactly one billing event");
|
||||||
cancellationOneTime.asBuilder()
|
cancellationOneTime.asBuilder()
|
||||||
.setOneTimeEventRef(Ref.create(oneTime))
|
.setOneTimeEventKey(Key.create(oneTime))
|
||||||
.setRecurringEventRef(Ref.create(recurring))
|
.setRecurringEventKey(Key.create(recurring))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@ import static org.joda.money.CurrencyUnit.USD;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import google.registry.model.EntityTestCase;
|
import google.registry.model.EntityTestCase;
|
||||||
import google.registry.model.billing.BillingEvent;
|
import google.registry.model.billing.BillingEvent;
|
||||||
import google.registry.model.domain.launch.ApplicationStatus;
|
import google.registry.model.domain.launch.ApplicationStatus;
|
||||||
|
@ -77,12 +76,12 @@ public class DomainApplicationTest extends EntityTestCase {
|
||||||
StatusValue.SERVER_UPDATE_PROHIBITED,
|
StatusValue.SERVER_UPDATE_PROHIBITED,
|
||||||
StatusValue.SERVER_RENEW_PROHIBITED,
|
StatusValue.SERVER_RENEW_PROHIBITED,
|
||||||
StatusValue.SERVER_HOLD))
|
StatusValue.SERVER_HOLD))
|
||||||
.setRegistrant(Ref.create(persistActiveContact("contact_id1")))
|
.setRegistrant(Key.create(persistActiveContact("contact_id1")))
|
||||||
.setContacts(ImmutableSet.of(DesignatedContact.create(
|
.setContacts(ImmutableSet.of(DesignatedContact.create(
|
||||||
DesignatedContact.Type.ADMIN,
|
DesignatedContact.Type.ADMIN,
|
||||||
Ref.create(persistActiveContact("contact_id2")))))
|
Key.create(persistActiveContact("contact_id2")))))
|
||||||
.setNameservers(
|
.setNameservers(
|
||||||
ImmutableSet.of(Ref.create(persistActiveHost("ns1.example.com"))))
|
ImmutableSet.of(Key.create(persistActiveHost("ns1.example.com"))))
|
||||||
.setCurrentSponsorClientId("a third registrar")
|
.setCurrentSponsorClientId("a third registrar")
|
||||||
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("password")))
|
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("password")))
|
||||||
.setDsData(ImmutableSet.of(DelegationSignerData.create(1, 2, 3, new byte[] {0, 1, 2})))
|
.setDsData(ImmutableSet.of(DelegationSignerData.create(1, 2, 3, new byte[] {0, 1, 2})))
|
||||||
|
@ -148,12 +147,12 @@ public class DomainApplicationTest extends EntityTestCase {
|
||||||
public void testEmptySetsAndArraysBecomeNull() {
|
public void testEmptySetsAndArraysBecomeNull() {
|
||||||
assertThat(emptyBuilder().setNameservers(null).build().nameservers).isNull();
|
assertThat(emptyBuilder().setNameservers(null).build().nameservers).isNull();
|
||||||
assertThat(emptyBuilder()
|
assertThat(emptyBuilder()
|
||||||
.setNameservers(ImmutableSet.<Ref<HostResource>>of())
|
.setNameservers(ImmutableSet.<Key<HostResource>>of())
|
||||||
.build()
|
.build()
|
||||||
.nameservers)
|
.nameservers)
|
||||||
.isNull();
|
.isNull();
|
||||||
assertThat(emptyBuilder()
|
assertThat(emptyBuilder()
|
||||||
.setNameservers(ImmutableSet.of(Ref.create(newHostResource("foo.example.tld"))))
|
.setNameservers(ImmutableSet.of(Key.create(newHostResource("foo.example.tld"))))
|
||||||
.build()
|
.build()
|
||||||
.nameservers)
|
.nameservers)
|
||||||
.isNotNull();
|
.isNotNull();
|
||||||
|
|
|
@ -36,7 +36,6 @@ import com.google.common.collect.ImmutableSortedMap;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Ordering;
|
import com.google.common.collect.Ordering;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import google.registry.flows.EppXmlTransformer;
|
import google.registry.flows.EppXmlTransformer;
|
||||||
import google.registry.model.EntityTestCase;
|
import google.registry.model.EntityTestCase;
|
||||||
import google.registry.model.billing.BillingEvent;
|
import google.registry.model.billing.BillingEvent;
|
||||||
|
@ -111,11 +110,11 @@ public class DomainResourceTest extends EntityTestCase {
|
||||||
StatusValue.SERVER_UPDATE_PROHIBITED,
|
StatusValue.SERVER_UPDATE_PROHIBITED,
|
||||||
StatusValue.SERVER_RENEW_PROHIBITED,
|
StatusValue.SERVER_RENEW_PROHIBITED,
|
||||||
StatusValue.SERVER_HOLD))
|
StatusValue.SERVER_HOLD))
|
||||||
.setRegistrant(Ref.create(contactResource1))
|
.setRegistrant(Key.create(contactResource1))
|
||||||
.setContacts(ImmutableSet.of(DesignatedContact.create(
|
.setContacts(ImmutableSet.of(DesignatedContact.create(
|
||||||
DesignatedContact.Type.ADMIN,
|
DesignatedContact.Type.ADMIN,
|
||||||
Ref.create(contactResource2))))
|
Key.create(contactResource2))))
|
||||||
.setNameservers(ImmutableSet.of(Ref.create(hostResource)))
|
.setNameservers(ImmutableSet.of(Key.create(hostResource)))
|
||||||
.setSubordinateHosts(ImmutableSet.of("ns1.example.com"))
|
.setSubordinateHosts(ImmutableSet.of("ns1.example.com"))
|
||||||
.setCurrentSponsorClientId("ThirdRegistrar")
|
.setCurrentSponsorClientId("ThirdRegistrar")
|
||||||
.setRegistrationExpirationTime(clock.nowUtc().plusYears(1))
|
.setRegistrationExpirationTime(clock.nowUtc().plusYears(1))
|
||||||
|
@ -135,21 +134,21 @@ public class DomainResourceTest extends EntityTestCase {
|
||||||
Key.create(BillingEvent.Recurring.class, 2),
|
Key.create(BillingEvent.Recurring.class, 2),
|
||||||
Key.create(PollMessage.Autorenew.class, 3)))
|
Key.create(PollMessage.Autorenew.class, 3)))
|
||||||
.setServerApproveBillingEvent(
|
.setServerApproveBillingEvent(
|
||||||
Ref.create(Key.create(BillingEvent.OneTime.class, 1)))
|
Key.create(BillingEvent.OneTime.class, 1))
|
||||||
.setServerApproveAutorenewEvent(
|
.setServerApproveAutorenewEvent(
|
||||||
Ref.create(Key.create(BillingEvent.Recurring.class, 2)))
|
Key.create(BillingEvent.Recurring.class, 2))
|
||||||
.setServerApproveAutorenewPollMessage(
|
.setServerApproveAutorenewPollMessage(
|
||||||
Ref.create(Key.create(PollMessage.Autorenew.class, 3)))
|
Key.create(PollMessage.Autorenew.class, 3))
|
||||||
.setTransferRequestTime(clock.nowUtc().plusDays(1))
|
.setTransferRequestTime(clock.nowUtc().plusDays(1))
|
||||||
.setTransferStatus(TransferStatus.SERVER_APPROVED)
|
.setTransferStatus(TransferStatus.SERVER_APPROVED)
|
||||||
.setTransferRequestTrid(Trid.create("client trid"))
|
.setTransferRequestTrid(Trid.create("client trid"))
|
||||||
.build())
|
.build())
|
||||||
.setDeletePollMessage(Key.create(PollMessage.OneTime.class, 1))
|
.setDeletePollMessage(Key.create(PollMessage.OneTime.class, 1))
|
||||||
.setAutorenewBillingEvent(Ref.create(Key.create(BillingEvent.Recurring.class, 1)))
|
.setAutorenewBillingEvent(Key.create(BillingEvent.Recurring.class, 1))
|
||||||
.setAutorenewPollMessage(Ref.create(Key.create(PollMessage.Autorenew.class, 2)))
|
.setAutorenewPollMessage(Key.create(PollMessage.Autorenew.class, 2))
|
||||||
.setSmdId("smdid")
|
.setSmdId("smdid")
|
||||||
.setApplicationTime(START_OF_TIME)
|
.setApplicationTime(START_OF_TIME)
|
||||||
.setApplication(Ref.create(Key.create(DomainApplication.class, 1)))
|
.setApplication(Key.create(DomainApplication.class, 1))
|
||||||
.addGracePeriod(GracePeriod.create(
|
.addGracePeriod(GracePeriod.create(
|
||||||
GracePeriodStatus.ADD, clock.nowUtc().plusDays(1), "registrar", null))
|
GracePeriodStatus.ADD, clock.nowUtc().plusDays(1), "registrar", null))
|
||||||
.build());
|
.build());
|
||||||
|
@ -198,10 +197,10 @@ public class DomainResourceTest extends EntityTestCase {
|
||||||
assertThat(newDomainResource("example.com").asBuilder()
|
assertThat(newDomainResource("example.com").asBuilder()
|
||||||
.setNameservers(null).build().nameservers).isNull();
|
.setNameservers(null).build().nameservers).isNull();
|
||||||
assertThat(newDomainResource("example.com").asBuilder()
|
assertThat(newDomainResource("example.com").asBuilder()
|
||||||
.setNameservers(ImmutableSet.<Ref<HostResource>>of()).build().nameservers)
|
.setNameservers(ImmutableSet.<Key<HostResource>>of()).build().nameservers)
|
||||||
.isNull();
|
.isNull();
|
||||||
assertThat(newDomainResource("example.com").asBuilder()
|
assertThat(newDomainResource("example.com").asBuilder()
|
||||||
.setNameservers(ImmutableSet.of(Ref.create(newHostResource("foo.example.tld"))))
|
.setNameservers(ImmutableSet.of(Key.create(newHostResource("foo.example.tld"))))
|
||||||
.build().nameservers)
|
.build().nameservers)
|
||||||
.isNotNull();
|
.isNotNull();
|
||||||
// This behavior should also hold true for ImmutableObjects nested in collections.
|
// This behavior should also hold true for ImmutableObjects nested in collections.
|
||||||
|
@ -230,8 +229,8 @@ public class DomainResourceTest extends EntityTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testImplicitStatusValues() {
|
public void testImplicitStatusValues() {
|
||||||
ImmutableSet<Ref<HostResource>> nameservers =
|
ImmutableSet<Key<HostResource>> nameservers =
|
||||||
ImmutableSet.of(Ref.create(newHostResource("foo.example.tld")));
|
ImmutableSet.of(Key.create(newHostResource("foo.example.tld")));
|
||||||
StatusValue[] statuses = {StatusValue.OK};
|
StatusValue[] statuses = {StatusValue.OK};
|
||||||
// OK is implicit if there's no other statuses but there are nameservers.
|
// OK is implicit if there's no other statuses but there are nameservers.
|
||||||
assertAboutDomains()
|
assertAboutDomains()
|
||||||
|
@ -284,7 +283,7 @@ public class DomainResourceTest extends EntityTestCase {
|
||||||
assertThat(domain.getCurrentSponsorClientId()).isEqualTo("winner");
|
assertThat(domain.getCurrentSponsorClientId()).isEqualTo("winner");
|
||||||
assertThat(domain.getLastTransferTime()).isEqualTo(clock.nowUtc().plusDays(1));
|
assertThat(domain.getLastTransferTime()).isEqualTo(clock.nowUtc().plusDays(1));
|
||||||
assertThat(domain.getRegistrationExpirationTime()).isEqualTo(newExpirationTime);
|
assertThat(domain.getRegistrationExpirationTime()).isEqualTo(newExpirationTime);
|
||||||
assertThat(domain.getAutorenewBillingEvent().getKey()).isEqualTo(newAutorenewEvent);
|
assertThat(domain.getAutorenewBillingEvent()).isEqualTo(newAutorenewEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doExpiredTransferTest(DateTime oldExpirationTime) {
|
private void doExpiredTransferTest(DateTime oldExpirationTime) {
|
||||||
|
@ -308,7 +307,7 @@ public class DomainResourceTest extends EntityTestCase {
|
||||||
.setTransferRequestTime(clock.nowUtc().minusDays(4))
|
.setTransferRequestTime(clock.nowUtc().minusDays(4))
|
||||||
.setPendingTransferExpirationTime(clock.nowUtc().plusDays(1))
|
.setPendingTransferExpirationTime(clock.nowUtc().plusDays(1))
|
||||||
.setGainingClientId("winner")
|
.setGainingClientId("winner")
|
||||||
.setServerApproveBillingEvent(Ref.create(Key.create(transferBillingEvent)))
|
.setServerApproveBillingEvent(Key.create(transferBillingEvent))
|
||||||
.setServerApproveEntities(ImmutableSet.<Key<? extends TransferServerApproveEntity>>of(
|
.setServerApproveEntities(ImmutableSet.<Key<? extends TransferServerApproveEntity>>of(
|
||||||
Key.create(transferBillingEvent)))
|
Key.create(transferBillingEvent)))
|
||||||
.setExtendedRegistrationYears(1)
|
.setExtendedRegistrationYears(1)
|
||||||
|
@ -321,14 +320,14 @@ public class DomainResourceTest extends EntityTestCase {
|
||||||
DomainResource afterTransfer = domain.cloneProjectedAtTime(clock.nowUtc().plusDays(1));
|
DomainResource afterTransfer = domain.cloneProjectedAtTime(clock.nowUtc().plusDays(1));
|
||||||
DateTime newExpirationTime = oldExpirationTime.plusYears(1);
|
DateTime newExpirationTime = oldExpirationTime.plusYears(1);
|
||||||
Key<BillingEvent.Recurring> serverApproveAutorenewEvent =
|
Key<BillingEvent.Recurring> serverApproveAutorenewEvent =
|
||||||
domain.getTransferData().getServerApproveAutorenewEvent().getKey();
|
domain.getTransferData().getServerApproveAutorenewEvent();
|
||||||
assertTransferred(afterTransfer, newExpirationTime, serverApproveAutorenewEvent);
|
assertTransferred(afterTransfer, newExpirationTime, serverApproveAutorenewEvent);
|
||||||
assertThat(afterTransfer.getGracePeriods())
|
assertThat(afterTransfer.getGracePeriods())
|
||||||
.containsExactly(GracePeriod.create(
|
.containsExactly(GracePeriod.create(
|
||||||
GracePeriodStatus.TRANSFER,
|
GracePeriodStatus.TRANSFER,
|
||||||
clock.nowUtc().plusDays(1).plus(Registry.get("com").getTransferGracePeriodLength()),
|
clock.nowUtc().plusDays(1).plus(Registry.get("com").getTransferGracePeriodLength()),
|
||||||
"winner",
|
"winner",
|
||||||
Ref.create(transferBillingEvent)));
|
Key.create(transferBillingEvent)));
|
||||||
// If we project after the grace period expires all should be the same except the grace period.
|
// If we project after the grace period expires all should be the same except the grace period.
|
||||||
DomainResource afterGracePeriod = domain.cloneProjectedAtTime(
|
DomainResource afterGracePeriod = domain.cloneProjectedAtTime(
|
||||||
clock.nowUtc().plusDays(2).plus(Registry.get("com").getTransferGracePeriodLength()));
|
clock.nowUtc().plusDays(2).plus(Registry.get("com").getTransferGracePeriodLength()));
|
||||||
|
@ -420,7 +419,7 @@ public class DomainResourceTest extends EntityTestCase {
|
||||||
oldExpirationTime.plusYears(2).plus(
|
oldExpirationTime.plusYears(2).plus(
|
||||||
Registry.get("com").getAutoRenewGracePeriodLength()),
|
Registry.get("com").getAutoRenewGracePeriodLength()),
|
||||||
renewedThreeTimes.getCurrentSponsorClientId(),
|
renewedThreeTimes.getCurrentSponsorClientId(),
|
||||||
Ref.create(renewedThreeTimes.autorenewBillingEvent.key())));
|
renewedThreeTimes.autorenewBillingEvent));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -18,7 +18,6 @@ import static com.google.common.truth.Truth.assertThat;
|
||||||
import static org.joda.time.DateTimeZone.UTC;
|
import static org.joda.time.DateTimeZone.UTC;
|
||||||
|
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
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.billing.BillingEvent.Recurring;
|
import google.registry.model.billing.BillingEvent.Recurring;
|
||||||
|
@ -68,7 +67,7 @@ public class GracePeriodTest {
|
||||||
public void testSuccess_forBillingEvent() {
|
public void testSuccess_forBillingEvent() {
|
||||||
GracePeriod gracePeriod = GracePeriod.forBillingEvent(GracePeriodStatus.ADD, onetime);
|
GracePeriod gracePeriod = GracePeriod.forBillingEvent(GracePeriodStatus.ADD, onetime);
|
||||||
assertThat(gracePeriod.getType()).isEqualTo(GracePeriodStatus.ADD);
|
assertThat(gracePeriod.getType()).isEqualTo(GracePeriodStatus.ADD);
|
||||||
assertThat(gracePeriod.getOneTimeBillingEvent()).isEqualTo(Ref.create(onetime));
|
assertThat(gracePeriod.getOneTimeBillingEvent()).isEqualTo(Key.create(onetime));
|
||||||
assertThat(gracePeriod.getRecurringBillingEvent()).isNull();
|
assertThat(gracePeriod.getRecurringBillingEvent()).isNull();
|
||||||
assertThat(gracePeriod.getClientId()).isEqualTo("TheRegistrar");
|
assertThat(gracePeriod.getClientId()).isEqualTo("TheRegistrar");
|
||||||
assertThat(gracePeriod.getExpirationTime()).isEqualTo(now.plusDays(1));
|
assertThat(gracePeriod.getExpirationTime()).isEqualTo(now.plusDays(1));
|
||||||
|
@ -108,6 +107,6 @@ public class GracePeriodTest {
|
||||||
GracePeriodStatus.RENEW,
|
GracePeriodStatus.RENEW,
|
||||||
now.plusDays(1),
|
now.plusDays(1),
|
||||||
"TheRegistrar",
|
"TheRegistrar",
|
||||||
Ref.create(Key.create(Recurring.class, 12345)));
|
Key.create(Recurring.class, 12345));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@ import static google.registry.testing.HostResourceSubject.assertAboutHosts;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.net.InetAddresses;
|
import com.google.common.net.InetAddresses;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
import google.registry.model.EntityTestCase;
|
import google.registry.model.EntityTestCase;
|
||||||
import google.registry.model.billing.BillingEvent;
|
import google.registry.model.billing.BillingEvent;
|
||||||
import google.registry.model.domain.DomainResource;
|
import google.registry.model.domain.DomainResource;
|
||||||
|
@ -84,7 +83,7 @@ public class HostResourceTest extends EntityTestCase {
|
||||||
.setInetAddresses(ImmutableSet.of(InetAddresses.forString("127.0.0.1")))
|
.setInetAddresses(ImmutableSet.of(InetAddresses.forString("127.0.0.1")))
|
||||||
.setStatusValues(ImmutableSet.of(StatusValue.OK))
|
.setStatusValues(ImmutableSet.of(StatusValue.OK))
|
||||||
.setSuperordinateDomain(
|
.setSuperordinateDomain(
|
||||||
Ref.create(loadByUniqueId(DomainResource.class, "example.com", clock.nowUtc())))
|
Key.create(loadByUniqueId(DomainResource.class, "example.com", clock.nowUtc())))
|
||||||
.build());
|
.build());
|
||||||
persistResource(hostResource);
|
persistResource(hostResource);
|
||||||
}
|
}
|
||||||
|
@ -265,7 +264,7 @@ public class HostResourceTest extends EntityTestCase {
|
||||||
.setPendingTransferExpirationTime(clock.nowUtc().plusDays(1))
|
.setPendingTransferExpirationTime(clock.nowUtc().plusDays(1))
|
||||||
.setGainingClientId("winner")
|
.setGainingClientId("winner")
|
||||||
.setExtendedRegistrationYears(2)
|
.setExtendedRegistrationYears(2)
|
||||||
.setServerApproveBillingEvent(Ref.create(
|
.setServerApproveBillingEvent(Key.create(
|
||||||
new BillingEvent.OneTime.Builder()
|
new BillingEvent.OneTime.Builder()
|
||||||
.setParent(new HistoryEntry.Builder().setParent(domain).build())
|
.setParent(new HistoryEntry.Builder().setParent(domain).build())
|
||||||
.setCost(Money.parse("USD 100"))
|
.setCost(Money.parse("USD 100"))
|
||||||
|
|
|
@ -16,7 +16,7 @@ package google.registry.model.index;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static google.registry.model.index.DomainApplicationIndex.createUpdatedInstance;
|
import static google.registry.model.index.DomainApplicationIndex.createUpdatedInstance;
|
||||||
import static google.registry.model.index.DomainApplicationIndex.createWithSpecifiedReferences;
|
import static google.registry.model.index.DomainApplicationIndex.createWithSpecifiedKeys;
|
||||||
import static google.registry.model.index.DomainApplicationIndex.loadActiveApplicationsByDomainName;
|
import static google.registry.model.index.DomainApplicationIndex.loadActiveApplicationsByDomainName;
|
||||||
import static google.registry.testing.DatastoreHelper.createTld;
|
import static google.registry.testing.DatastoreHelper.createTld;
|
||||||
import static google.registry.testing.DatastoreHelper.newDomainApplication;
|
import static google.registry.testing.DatastoreHelper.newDomainApplication;
|
||||||
|
@ -24,7 +24,7 @@ import static google.registry.testing.DatastoreHelper.persistResource;
|
||||||
import static google.registry.testing.DatastoreHelper.persistSimpleResource;
|
import static google.registry.testing.DatastoreHelper.persistSimpleResource;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.model.EntityTestCase;
|
import google.registry.model.EntityTestCase;
|
||||||
import google.registry.model.domain.DomainApplication;
|
import google.registry.model.domain.DomainApplication;
|
||||||
import google.registry.testing.ExceptionRule;
|
import google.registry.testing.ExceptionRule;
|
||||||
|
@ -46,14 +46,14 @@ public class DomainApplicationIndexTest extends EntityTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_create_nullReferences() {
|
public void testFailure_create_nullReferences() {
|
||||||
thrown.expect(IllegalArgumentException.class, "References must not be null or empty.");
|
thrown.expect(IllegalArgumentException.class, "Keys must not be null or empty.");
|
||||||
DomainApplicationIndex.createWithSpecifiedReferences("blah.com", null);
|
DomainApplicationIndex.createWithSpecifiedKeys("blah.com", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_create_emptyReferences() {
|
public void testFailure_create_emptyReferences() {
|
||||||
thrown.expect(IllegalArgumentException.class, "References must not be null or empty.");
|
thrown.expect(IllegalArgumentException.class, "Keys must not be null or empty.");
|
||||||
createWithSpecifiedReferences("blah.com", ImmutableSet.<Ref<DomainApplication>>of());
|
createWithSpecifiedKeys("blah.com", ImmutableSet.<Key<DomainApplication>>of());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -62,7 +62,7 @@ public class DomainApplicationIndexTest extends EntityTestCase {
|
||||||
persistResource(createUpdatedInstance(application));
|
persistResource(createUpdatedInstance(application));
|
||||||
DomainApplicationIndex savedIndex = DomainApplicationIndex.load("example.com");
|
DomainApplicationIndex savedIndex = DomainApplicationIndex.load("example.com");
|
||||||
assertThat(savedIndex).isNotNull();
|
assertThat(savedIndex).isNotNull();
|
||||||
assertThat(savedIndex.getReferences()).containsExactly(Ref.create(application));
|
assertThat(savedIndex.getKeys()).containsExactly(Key.create(application));
|
||||||
assertThat(loadActiveApplicationsByDomainName("example.com", DateTime.now()))
|
assertThat(loadActiveApplicationsByDomainName("example.com", DateTime.now()))
|
||||||
.containsExactly(application);
|
.containsExactly(application);
|
||||||
}
|
}
|
||||||
|
@ -83,8 +83,8 @@ public class DomainApplicationIndexTest extends EntityTestCase {
|
||||||
persistResource(createUpdatedInstance(application3));
|
persistResource(createUpdatedInstance(application3));
|
||||||
DomainApplicationIndex savedIndex = DomainApplicationIndex.load("example.com");
|
DomainApplicationIndex savedIndex = DomainApplicationIndex.load("example.com");
|
||||||
assertThat(savedIndex).isNotNull();
|
assertThat(savedIndex).isNotNull();
|
||||||
assertThat(savedIndex.getReferences()).containsExactly(
|
assertThat(savedIndex.getKeys()).containsExactly(
|
||||||
Ref.create(application1), Ref.create(application2), Ref.create(application3));
|
Key.create(application1), Key.create(application2), Key.create(application3));
|
||||||
assertThat(loadActiveApplicationsByDomainName("example.com", DateTime.now()))
|
assertThat(loadActiveApplicationsByDomainName("example.com", DateTime.now()))
|
||||||
.containsExactly(application1, application2, application3);
|
.containsExactly(application1, application2, application3);
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ public class DomainApplicationIndexTest extends EntityTestCase {
|
||||||
persistResource(createUpdatedInstance(application2));
|
persistResource(createUpdatedInstance(application2));
|
||||||
DomainApplicationIndex savedIndex =
|
DomainApplicationIndex savedIndex =
|
||||||
DomainApplicationIndex.load(application1.getFullyQualifiedDomainName());
|
DomainApplicationIndex.load(application1.getFullyQualifiedDomainName());
|
||||||
assertThat(savedIndex.getReferences()).hasSize(2);
|
assertThat(savedIndex.getKeys()).hasSize(2);
|
||||||
assertThat(loadActiveApplicationsByDomainName("example.com", DateTime.now()))
|
assertThat(loadActiveApplicationsByDomainName("example.com", DateTime.now()))
|
||||||
.containsExactly(application1);
|
.containsExactly(application1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class EppResourceIndexTest extends EntityTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testPersistence() throws Exception {
|
public void testPersistence() throws Exception {
|
||||||
EppResourceIndex loadedIndex = Iterables.getOnlyElement(getEppResourceIndexObjects());
|
EppResourceIndex loadedIndex = Iterables.getOnlyElement(getEppResourceIndexObjects());
|
||||||
assertThat(loadedIndex.reference.get()).isEqualTo(contact);
|
assertThat(ofy().load().key(loadedIndex.reference).now()).isEqualTo(contact);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -56,7 +56,7 @@ public class EppResourceIndexTest extends EntityTestCase {
|
||||||
public void testIdempotentOnUpdate() throws Exception {
|
public void testIdempotentOnUpdate() throws Exception {
|
||||||
contact = persistResource(contact.asBuilder().setEmailAddress("abc@def.fake").build());
|
contact = persistResource(contact.asBuilder().setEmailAddress("abc@def.fake").build());
|
||||||
EppResourceIndex loadedIndex = Iterables.getOnlyElement(getEppResourceIndexObjects());
|
EppResourceIndex loadedIndex = Iterables.getOnlyElement(getEppResourceIndexObjects());
|
||||||
assertThat(loadedIndex.reference.get()).isEqualTo(contact);
|
assertThat(ofy().load().key(loadedIndex.reference).now()).isEqualTo(contact);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -15,13 +15,14 @@
|
||||||
package google.registry.model.index;
|
package google.registry.model.index;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static google.registry.testing.DatastoreHelper.createTld;
|
import static google.registry.testing.DatastoreHelper.createTld;
|
||||||
import static google.registry.testing.DatastoreHelper.persistActiveHost;
|
import static google.registry.testing.DatastoreHelper.persistActiveHost;
|
||||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.googlecode.objectify.Ref;
|
import com.googlecode.objectify.Key;
|
||||||
import google.registry.model.EntityTestCase;
|
import google.registry.model.EntityTestCase;
|
||||||
import google.registry.model.host.HostResource;
|
import google.registry.model.host.HostResource;
|
||||||
import google.registry.model.index.ForeignKeyIndex.ForeignKeyHostIndex;
|
import google.registry.model.index.ForeignKeyIndex.ForeignKeyHostIndex;
|
||||||
|
@ -47,7 +48,7 @@ public class ForeignKeyIndexTest extends EntityTestCase {
|
||||||
HostResource host = persistActiveHost("ns1.example.com");
|
HostResource host = persistActiveHost("ns1.example.com");
|
||||||
ForeignKeyIndex<HostResource> fki =
|
ForeignKeyIndex<HostResource> fki =
|
||||||
ForeignKeyIndex.load(HostResource.class, "ns1.example.com", clock.nowUtc());
|
ForeignKeyIndex.load(HostResource.class, "ns1.example.com", clock.nowUtc());
|
||||||
assertThat(fki.getReference().get()).isEqualTo(host);
|
assertThat(ofy().load().key(fki.getResourceKey()).now()).isEqualTo(host);
|
||||||
assertThat(fki.getDeletionTime()).isEqualTo(END_OF_TIME);
|
assertThat(fki.getDeletionTime()).isEqualTo(END_OF_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +81,7 @@ public class ForeignKeyIndexTest extends EntityTestCase {
|
||||||
clock.advanceOneMilli();
|
clock.advanceOneMilli();
|
||||||
ForeignKeyHostIndex fki = new ForeignKeyHostIndex();
|
ForeignKeyHostIndex fki = new ForeignKeyHostIndex();
|
||||||
fki.foreignKey = "ns1.example.com";
|
fki.foreignKey = "ns1.example.com";
|
||||||
fki.topReference = Ref.create(host1);
|
fki.topReference = Key.create(host1);
|
||||||
fki.deletionTime = clock.nowUtc();
|
fki.deletionTime = clock.nowUtc();
|
||||||
persistResource(fki);
|
persistResource(fki);
|
||||||
assertThat(ForeignKeyIndex.load(
|
assertThat(ForeignKeyIndex.load(
|
||||||
|
|
|
@ -88,7 +88,8 @@ public class OfyTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doBackupGroupRootTimestampInversionTest(VoidWork work) {
|
private void doBackupGroupRootTimestampInversionTest(VoidWork work) {
|
||||||
DateTime groupTimestamp = someObject.getParent().get().getUpdateAutoTimestamp().getTimestamp();
|
DateTime groupTimestamp = ofy().load().key(someObject.getParent()).now()
|
||||||
|
.getUpdateAutoTimestamp().getTimestamp();
|
||||||
// Set the clock in Ofy to the same time as the backup group root's save time.
|
// Set the clock in Ofy to the same time as the backup group root's save time.
|
||||||
Ofy ofy = new Ofy(new FakeClock(groupTimestamp));
|
Ofy ofy = new Ofy(new FakeClock(groupTimestamp));
|
||||||
thrown.expect(
|
thrown.expect(
|
||||||
|
|
|
@ -11,8 +11,8 @@ class google.registry.model.UpdateAutoTimestamp {
|
||||||
class google.registry.model.billing.BillingEvent$Cancellation {
|
class google.registry.model.billing.BillingEvent$Cancellation {
|
||||||
@Id long id;
|
@Id long id;
|
||||||
@Parent com.googlecode.objectify.Key<google.registry.model.reporting.HistoryEntry> parent;
|
@Parent com.googlecode.objectify.Key<google.registry.model.reporting.HistoryEntry> parent;
|
||||||
com.googlecode.objectify.Ref<google.registry.model.billing.BillingEvent$OneTime> refOneTime;
|
com.googlecode.objectify.Key<google.registry.model.billing.BillingEvent$OneTime> refOneTime;
|
||||||
com.googlecode.objectify.Ref<google.registry.model.billing.BillingEvent$Recurring> refRecurring;
|
com.googlecode.objectify.Key<google.registry.model.billing.BillingEvent$Recurring> refRecurring;
|
||||||
google.registry.model.billing.BillingEvent$Reason reason;
|
google.registry.model.billing.BillingEvent$Reason reason;
|
||||||
java.lang.String clientId;
|
java.lang.String clientId;
|
||||||
java.lang.String targetId;
|
java.lang.String targetId;
|
||||||
|
@ -31,7 +31,7 @@ enum google.registry.model.billing.BillingEvent$Flag {
|
||||||
class google.registry.model.billing.BillingEvent$Modification {
|
class google.registry.model.billing.BillingEvent$Modification {
|
||||||
@Id long id;
|
@Id long id;
|
||||||
@Parent com.googlecode.objectify.Key<google.registry.model.reporting.HistoryEntry> parent;
|
@Parent com.googlecode.objectify.Key<google.registry.model.reporting.HistoryEntry> parent;
|
||||||
com.googlecode.objectify.Ref<google.registry.model.billing.BillingEvent$OneTime> eventRef;
|
com.googlecode.objectify.Key<google.registry.model.billing.BillingEvent$OneTime> eventRef;
|
||||||
google.registry.model.billing.BillingEvent$Reason reason;
|
google.registry.model.billing.BillingEvent$Reason reason;
|
||||||
java.lang.String clientId;
|
java.lang.String clientId;
|
||||||
java.lang.String description;
|
java.lang.String description;
|
||||||
|
@ -86,7 +86,7 @@ class google.registry.model.billing.RegistrarBillingEntry {
|
||||||
}
|
}
|
||||||
class google.registry.model.billing.RegistrarCredit {
|
class google.registry.model.billing.RegistrarCredit {
|
||||||
@Id long id;
|
@Id long id;
|
||||||
@Parent com.googlecode.objectify.Ref<google.registry.model.registrar.Registrar> parent;
|
@Parent com.googlecode.objectify.Key<google.registry.model.registrar.Registrar> parent;
|
||||||
google.registry.model.billing.RegistrarCredit$CreditType type;
|
google.registry.model.billing.RegistrarCredit$CreditType type;
|
||||||
java.lang.String description;
|
java.lang.String description;
|
||||||
java.lang.String tld;
|
java.lang.String tld;
|
||||||
|
@ -99,7 +99,7 @@ enum google.registry.model.billing.RegistrarCredit$CreditType {
|
||||||
}
|
}
|
||||||
class google.registry.model.billing.RegistrarCreditBalance {
|
class google.registry.model.billing.RegistrarCreditBalance {
|
||||||
@Id long id;
|
@Id long id;
|
||||||
@Parent com.googlecode.objectify.Ref<google.registry.model.billing.RegistrarCredit> parent;
|
@Parent com.googlecode.objectify.Key<google.registry.model.billing.RegistrarCredit> parent;
|
||||||
org.joda.money.Money amount;
|
org.joda.money.Money amount;
|
||||||
org.joda.time.DateTime effectiveTime;
|
org.joda.time.DateTime effectiveTime;
|
||||||
org.joda.time.DateTime writtenTime;
|
org.joda.time.DateTime writtenTime;
|
||||||
|
@ -142,7 +142,7 @@ class google.registry.model.contact.ContactPhoneNumber {
|
||||||
}
|
}
|
||||||
class google.registry.model.contact.ContactResource {
|
class google.registry.model.contact.ContactResource {
|
||||||
@Id java.lang.String repoId;
|
@Id java.lang.String repoId;
|
||||||
com.google.common.collect.ImmutableSortedMap<org.joda.time.DateTime, com.googlecode.objectify.Ref<google.registry.model.ofy.CommitLogManifest>> revisions;
|
com.google.common.collect.ImmutableSortedMap<org.joda.time.DateTime, com.googlecode.objectify.Key<google.registry.model.ofy.CommitLogManifest>> revisions;
|
||||||
google.registry.model.CreateAutoTimestamp creationTime;
|
google.registry.model.CreateAutoTimestamp creationTime;
|
||||||
google.registry.model.UpdateAutoTimestamp updateTimestamp;
|
google.registry.model.UpdateAutoTimestamp updateTimestamp;
|
||||||
google.registry.model.contact.ContactAuthInfo authInfo;
|
google.registry.model.contact.ContactAuthInfo authInfo;
|
||||||
|
@ -197,7 +197,7 @@ enum google.registry.model.domain.DesignatedContact$Type {
|
||||||
}
|
}
|
||||||
class google.registry.model.domain.DomainApplication {
|
class google.registry.model.domain.DomainApplication {
|
||||||
@Id java.lang.String repoId;
|
@Id java.lang.String repoId;
|
||||||
com.google.common.collect.ImmutableSortedMap<org.joda.time.DateTime, com.googlecode.objectify.Ref<google.registry.model.ofy.CommitLogManifest>> revisions;
|
com.google.common.collect.ImmutableSortedMap<org.joda.time.DateTime, com.googlecode.objectify.Key<google.registry.model.ofy.CommitLogManifest>> revisions;
|
||||||
google.registry.model.CreateAutoTimestamp creationTime;
|
google.registry.model.CreateAutoTimestamp creationTime;
|
||||||
google.registry.model.UpdateAutoTimestamp updateTimestamp;
|
google.registry.model.UpdateAutoTimestamp updateTimestamp;
|
||||||
google.registry.model.domain.DomainAuthInfo authInfo;
|
google.registry.model.domain.DomainAuthInfo authInfo;
|
||||||
|
@ -227,7 +227,7 @@ class google.registry.model.domain.DomainAuthInfo {
|
||||||
}
|
}
|
||||||
class google.registry.model.domain.DomainBase {
|
class google.registry.model.domain.DomainBase {
|
||||||
@Id java.lang.String repoId;
|
@Id java.lang.String repoId;
|
||||||
com.google.common.collect.ImmutableSortedMap<org.joda.time.DateTime, com.googlecode.objectify.Ref<google.registry.model.ofy.CommitLogManifest>> revisions;
|
com.google.common.collect.ImmutableSortedMap<org.joda.time.DateTime, com.googlecode.objectify.Key<google.registry.model.ofy.CommitLogManifest>> revisions;
|
||||||
google.registry.model.CreateAutoTimestamp creationTime;
|
google.registry.model.CreateAutoTimestamp creationTime;
|
||||||
google.registry.model.UpdateAutoTimestamp updateTimestamp;
|
google.registry.model.UpdateAutoTimestamp updateTimestamp;
|
||||||
google.registry.model.domain.DomainAuthInfo authInfo;
|
google.registry.model.domain.DomainAuthInfo authInfo;
|
||||||
|
@ -249,11 +249,11 @@ class google.registry.model.domain.DomainBase {
|
||||||
}
|
}
|
||||||
class google.registry.model.domain.DomainResource {
|
class google.registry.model.domain.DomainResource {
|
||||||
@Id java.lang.String repoId;
|
@Id java.lang.String repoId;
|
||||||
com.google.common.collect.ImmutableSortedMap<org.joda.time.DateTime, com.googlecode.objectify.Ref<google.registry.model.ofy.CommitLogManifest>> revisions;
|
com.google.common.collect.ImmutableSortedMap<org.joda.time.DateTime, com.googlecode.objectify.Key<google.registry.model.ofy.CommitLogManifest>> revisions;
|
||||||
com.googlecode.objectify.Key<google.registry.model.poll.PollMessage$OneTime> deletePollMessage;
|
com.googlecode.objectify.Key<google.registry.model.poll.PollMessage$OneTime> deletePollMessage;
|
||||||
com.googlecode.objectify.Ref<google.registry.model.billing.BillingEvent$Recurring> autorenewBillingEvent;
|
com.googlecode.objectify.Key<google.registry.model.billing.BillingEvent$Recurring> autorenewBillingEvent;
|
||||||
com.googlecode.objectify.Ref<google.registry.model.domain.DomainApplication> application;
|
com.googlecode.objectify.Key<google.registry.model.domain.DomainApplication> application;
|
||||||
com.googlecode.objectify.Ref<google.registry.model.poll.PollMessage$Autorenew> autorenewPollMessage;
|
com.googlecode.objectify.Key<google.registry.model.poll.PollMessage$Autorenew> autorenewPollMessage;
|
||||||
google.registry.model.CreateAutoTimestamp creationTime;
|
google.registry.model.CreateAutoTimestamp creationTime;
|
||||||
google.registry.model.UpdateAutoTimestamp updateTimestamp;
|
google.registry.model.UpdateAutoTimestamp updateTimestamp;
|
||||||
google.registry.model.domain.DomainAuthInfo authInfo;
|
google.registry.model.domain.DomainAuthInfo authInfo;
|
||||||
|
@ -279,8 +279,8 @@ class google.registry.model.domain.DomainResource {
|
||||||
org.joda.time.DateTime registrationExpirationTime;
|
org.joda.time.DateTime registrationExpirationTime;
|
||||||
}
|
}
|
||||||
class google.registry.model.domain.GracePeriod {
|
class google.registry.model.domain.GracePeriod {
|
||||||
com.googlecode.objectify.Ref<google.registry.model.billing.BillingEvent$OneTime> billingEventOneTime;
|
com.googlecode.objectify.Key<google.registry.model.billing.BillingEvent$OneTime> billingEventOneTime;
|
||||||
com.googlecode.objectify.Ref<google.registry.model.billing.BillingEvent$Recurring> billingEventRecurring;
|
com.googlecode.objectify.Key<google.registry.model.billing.BillingEvent$Recurring> billingEventRecurring;
|
||||||
google.registry.model.domain.rgp.GracePeriodStatus type;
|
google.registry.model.domain.rgp.GracePeriodStatus type;
|
||||||
java.lang.String clientId;
|
java.lang.String clientId;
|
||||||
org.joda.time.DateTime expirationTime;
|
org.joda.time.DateTime expirationTime;
|
||||||
|
@ -301,7 +301,7 @@ enum google.registry.model.domain.Period$Unit {
|
||||||
YEARS;
|
YEARS;
|
||||||
}
|
}
|
||||||
class google.registry.model.domain.ReferenceUnion {
|
class google.registry.model.domain.ReferenceUnion {
|
||||||
com.googlecode.objectify.Ref<T> linked;
|
com.googlecode.objectify.Key<T> linked;
|
||||||
}
|
}
|
||||||
enum google.registry.model.domain.launch.ApplicationStatus {
|
enum google.registry.model.domain.launch.ApplicationStatus {
|
||||||
ALLOCATED;
|
ALLOCATED;
|
||||||
|
@ -384,8 +384,8 @@ class google.registry.model.export.LogsExportCursor {
|
||||||
}
|
}
|
||||||
class google.registry.model.host.HostResource {
|
class google.registry.model.host.HostResource {
|
||||||
@Id java.lang.String repoId;
|
@Id java.lang.String repoId;
|
||||||
com.google.common.collect.ImmutableSortedMap<org.joda.time.DateTime, com.googlecode.objectify.Ref<google.registry.model.ofy.CommitLogManifest>> revisions;
|
com.google.common.collect.ImmutableSortedMap<org.joda.time.DateTime, com.googlecode.objectify.Key<google.registry.model.ofy.CommitLogManifest>> revisions;
|
||||||
com.googlecode.objectify.Ref<google.registry.model.domain.DomainResource> superordinateDomain;
|
com.googlecode.objectify.Key<google.registry.model.domain.DomainResource> superordinateDomain;
|
||||||
google.registry.model.CreateAutoTimestamp creationTime;
|
google.registry.model.CreateAutoTimestamp creationTime;
|
||||||
google.registry.model.UpdateAutoTimestamp updateTimestamp;
|
google.registry.model.UpdateAutoTimestamp updateTimestamp;
|
||||||
google.registry.model.transfer.TransferData transferData;
|
google.registry.model.transfer.TransferData transferData;
|
||||||
|
@ -403,12 +403,12 @@ class google.registry.model.host.HostResource {
|
||||||
class google.registry.model.index.DomainApplicationIndex {
|
class google.registry.model.index.DomainApplicationIndex {
|
||||||
@Id java.lang.String fullyQualifiedDomainName;
|
@Id java.lang.String fullyQualifiedDomainName;
|
||||||
google.registry.model.UpdateAutoTimestamp updateTimestamp;
|
google.registry.model.UpdateAutoTimestamp updateTimestamp;
|
||||||
java.util.Set<com.googlecode.objectify.Ref<google.registry.model.domain.DomainApplication>> references;
|
java.util.Set<com.googlecode.objectify.Key<google.registry.model.domain.DomainApplication>> references;
|
||||||
}
|
}
|
||||||
class google.registry.model.index.EppResourceIndex {
|
class google.registry.model.index.EppResourceIndex {
|
||||||
@Id java.lang.String id;
|
@Id java.lang.String id;
|
||||||
@Parent com.googlecode.objectify.Key<google.registry.model.index.EppResourceIndexBucket> bucket;
|
@Parent com.googlecode.objectify.Key<google.registry.model.index.EppResourceIndexBucket> bucket;
|
||||||
com.googlecode.objectify.Ref<? extends google.registry.model.EppResource> reference;
|
com.googlecode.objectify.Key<? extends google.registry.model.EppResource> reference;
|
||||||
google.registry.model.UpdateAutoTimestamp updateTimestamp;
|
google.registry.model.UpdateAutoTimestamp updateTimestamp;
|
||||||
java.lang.String kind;
|
java.lang.String kind;
|
||||||
}
|
}
|
||||||
|
@ -417,19 +417,19 @@ class google.registry.model.index.EppResourceIndexBucket {
|
||||||
}
|
}
|
||||||
class google.registry.model.index.ForeignKeyIndex$ForeignKeyContactIndex {
|
class google.registry.model.index.ForeignKeyIndex$ForeignKeyContactIndex {
|
||||||
@Id java.lang.String foreignKey;
|
@Id java.lang.String foreignKey;
|
||||||
com.googlecode.objectify.Ref<E> topReference;
|
com.googlecode.objectify.Key<E> topReference;
|
||||||
google.registry.model.UpdateAutoTimestamp updateTimestamp;
|
google.registry.model.UpdateAutoTimestamp updateTimestamp;
|
||||||
org.joda.time.DateTime deletionTime;
|
org.joda.time.DateTime deletionTime;
|
||||||
}
|
}
|
||||||
class google.registry.model.index.ForeignKeyIndex$ForeignKeyDomainIndex {
|
class google.registry.model.index.ForeignKeyIndex$ForeignKeyDomainIndex {
|
||||||
@Id java.lang.String foreignKey;
|
@Id java.lang.String foreignKey;
|
||||||
com.googlecode.objectify.Ref<E> topReference;
|
com.googlecode.objectify.Key<E> topReference;
|
||||||
google.registry.model.UpdateAutoTimestamp updateTimestamp;
|
google.registry.model.UpdateAutoTimestamp updateTimestamp;
|
||||||
org.joda.time.DateTime deletionTime;
|
org.joda.time.DateTime deletionTime;
|
||||||
}
|
}
|
||||||
class google.registry.model.index.ForeignKeyIndex$ForeignKeyHostIndex {
|
class google.registry.model.index.ForeignKeyIndex$ForeignKeyHostIndex {
|
||||||
@Id java.lang.String foreignKey;
|
@Id java.lang.String foreignKey;
|
||||||
com.googlecode.objectify.Ref<E> topReference;
|
com.googlecode.objectify.Key<E> topReference;
|
||||||
google.registry.model.UpdateAutoTimestamp updateTimestamp;
|
google.registry.model.UpdateAutoTimestamp updateTimestamp;
|
||||||
org.joda.time.DateTime deletionTime;
|
org.joda.time.DateTime deletionTime;
|
||||||
}
|
}
|
||||||
|
@ -773,7 +773,7 @@ class google.registry.model.registry.label.ReservedList$ReservedListEntry {
|
||||||
}
|
}
|
||||||
class google.registry.model.reporting.HistoryEntry {
|
class google.registry.model.reporting.HistoryEntry {
|
||||||
@Id long id;
|
@Id long id;
|
||||||
@Parent com.googlecode.objectify.Ref<? extends google.registry.model.EppResource> parent;
|
@Parent com.googlecode.objectify.Key<? extends google.registry.model.EppResource> parent;
|
||||||
boolean bySuperuser;
|
boolean bySuperuser;
|
||||||
byte[] xmlBytes;
|
byte[] xmlBytes;
|
||||||
google.registry.model.domain.Period period;
|
google.registry.model.domain.Period period;
|
||||||
|
@ -858,9 +858,9 @@ class google.registry.model.tmch.TmchCrl {
|
||||||
org.joda.time.DateTime updated;
|
org.joda.time.DateTime updated;
|
||||||
}
|
}
|
||||||
class google.registry.model.transfer.TransferData {
|
class google.registry.model.transfer.TransferData {
|
||||||
com.googlecode.objectify.Ref<google.registry.model.billing.BillingEvent$OneTime> serverApproveBillingEvent;
|
com.googlecode.objectify.Key<google.registry.model.billing.BillingEvent$OneTime> serverApproveBillingEvent;
|
||||||
com.googlecode.objectify.Ref<google.registry.model.billing.BillingEvent$Recurring> serverApproveAutorenewEvent;
|
com.googlecode.objectify.Key<google.registry.model.billing.BillingEvent$Recurring> serverApproveAutorenewEvent;
|
||||||
com.googlecode.objectify.Ref<google.registry.model.poll.PollMessage$Autorenew> serverApproveAutorenewPollMessage;
|
com.googlecode.objectify.Key<google.registry.model.poll.PollMessage$Autorenew> serverApproveAutorenewPollMessage;
|
||||||
google.registry.model.eppcommon.Trid transferRequestTrid;
|
google.registry.model.eppcommon.Trid transferRequestTrid;
|
||||||
google.registry.model.transfer.TransferStatus transferStatus;
|
google.registry.model.transfer.TransferStatus transferStatus;
|
||||||
java.lang.Integer extendedRegistrationYears;
|
java.lang.Integer extendedRegistrationYears;
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
package google.registry.model.transfer;
|
package google.registry.model.transfer;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static google.registry.testing.DatastoreHelper.createTld;
|
import static google.registry.testing.DatastoreHelper.createTld;
|
||||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||||
|
@ -23,7 +24,6 @@ import static org.joda.time.DateTimeZone.UTC;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.googlecode.objectify.Key;
|
import com.googlecode.objectify.Key;
|
||||||
import com.googlecode.objectify.Ref;
|
|
||||||
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;
|
||||||
|
@ -125,10 +125,12 @@ public class TransferDataTest {
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_GetStoredBillingEventNoEntities() throws Exception {
|
public void testSuccess_GetStoredBillingEventNoEntities() throws Exception {
|
||||||
transferData = new TransferData.Builder()
|
transferData = new TransferData.Builder()
|
||||||
.setServerApproveBillingEvent(Ref.create(Key.create(transferBillingEvent)))
|
.setServerApproveBillingEvent(Key.create(transferBillingEvent))
|
||||||
.build();
|
.build();
|
||||||
assertThat(transferData.serverApproveBillingEvent.get()).isEqualTo(transferBillingEvent);
|
assertThat(ofy().load().key(transferData.serverApproveBillingEvent).now())
|
||||||
assertThat(transferData.getServerApproveBillingEvent().get()).isEqualTo(transferBillingEvent);
|
.isEqualTo(transferBillingEvent);
|
||||||
|
assertThat(ofy().load().key(transferData.getServerApproveBillingEvent()).now())
|
||||||
|
.isEqualTo(transferBillingEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -139,9 +141,11 @@ public class TransferDataTest {
|
||||||
Key.create(recurringBillingEvent),
|
Key.create(recurringBillingEvent),
|
||||||
Key.create(PollMessage.OneTime.class, 1));
|
Key.create(PollMessage.OneTime.class, 1));
|
||||||
transferData = transferData.asBuilder()
|
transferData = transferData.asBuilder()
|
||||||
.setServerApproveBillingEvent(Ref.create(Key.create(transferBillingEvent)))
|
.setServerApproveBillingEvent(Key.create(transferBillingEvent))
|
||||||
.build();
|
.build();
|
||||||
assertThat(transferData.serverApproveBillingEvent.get()).isEqualTo(transferBillingEvent);
|
assertThat(ofy().load().key(transferData.serverApproveBillingEvent).now())
|
||||||
assertThat(transferData.getServerApproveBillingEvent().get()).isEqualTo(transferBillingEvent);
|
.isEqualTo(transferBillingEvent);
|
||||||
|
assertThat(ofy().load().key(transferData.getServerApproveBillingEvent()).now())
|
||||||
|
.isEqualTo(transferBillingEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue