mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +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.ofy.ObjectifyService.ofy;
|
||||
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Work;
|
||||
import google.registry.flows.EppException.AssociationProhibitsOperationException;
|
||||
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.
|
||||
return false;
|
||||
}
|
||||
return isLinkedForFailfast(fki.getReference());
|
||||
return isLinkedForFailfast(fki.getResourceKey());
|
||||
}
|
||||
});
|
||||
if (isLinked) {
|
||||
|
@ -58,8 +58,8 @@ public abstract class ResourceAsyncDeleteFlow
|
|||
}
|
||||
}
|
||||
|
||||
/** Subclasses must override this to check if the supplied reference has incoming links. */
|
||||
protected abstract boolean isLinkedForFailfast(Ref<R> ref);
|
||||
/** Subclasses must override this to check if the supplied key has incoming links. */
|
||||
protected abstract boolean isLinkedForFailfast(Key<R> key);
|
||||
|
||||
@Override
|
||||
protected final R createOrMutateResource() {
|
||||
|
|
|
@ -16,7 +16,7 @@ package google.registry.flows.async;
|
|||
|
||||
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.domain.DomainBase;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
|
@ -46,8 +46,8 @@ public class DeleteContactResourceAction extends DeleteEppResourceAction<Contact
|
|||
|
||||
@Override
|
||||
protected boolean isLinked(
|
||||
DomainBase domain, Ref<ContactResource> targetResourceRef) {
|
||||
return domain.getReferencedContacts().contains(targetResourceRef);
|
||||
DomainBase domain, Key<ContactResource> targetResourceKey) {
|
||||
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.Iterators;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.Work;
|
||||
import google.registry.mapreduce.MapreduceRunner;
|
||||
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. */
|
||||
protected abstract boolean isLinked(DomainBase domain, Ref<T> targetResourceRef);
|
||||
protected abstract boolean isLinked(DomainBase domain, Key<T> targetResourceKey);
|
||||
|
||||
@Override
|
||||
public void map(DomainBase domain) {
|
||||
|
@ -154,12 +153,8 @@ public abstract class DeleteEppResourceAction<T extends EppResource> implements
|
|||
emit(targetEppResourceKey, false);
|
||||
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)
|
||||
&& isLinked(domain, Ref.create(targetEppResourceKey))) {
|
||||
&& isLinked(domain, targetEppResourceKey)) {
|
||||
emit(targetEppResourceKey, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ package google.registry.flows.async;
|
|||
|
||||
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.model.domain.DomainBase;
|
||||
import google.registry.model.host.HostResource;
|
||||
|
@ -46,8 +46,8 @@ public class DeleteHostResourceAction extends DeleteEppResourceAction<HostResour
|
|||
private static final long serialVersionUID = 1941092742903217194L;
|
||||
|
||||
@Override
|
||||
protected boolean isLinked(DomainBase domain, Ref<HostResource> targetResourceRef) {
|
||||
return domain.getNameservers().contains(targetResourceRef);
|
||||
protected boolean isLinked(DomainBase domain, Key<HostResource> targetResourceKey) {
|
||||
return domain.getNameservers().contains(targetResourceKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class DeleteHostResourceAction extends DeleteEppResourceAction<HostResour
|
|||
if (targetResource.getSuperordinateDomain() != null) {
|
||||
DnsQueue.create().addHostRefreshTask(targetResource.getFullyQualifiedHostName());
|
||||
ofy().save().entity(
|
||||
targetResource.getSuperordinateDomain().get().asBuilder()
|
||||
ofy().load().key(targetResource.getSuperordinateDomain()).now().asBuilder()
|
||||
.removeSubordinateHost(targetResource.getFullyQualifiedHostName())
|
||||
.build());
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
|||
import com.google.appengine.tools.mapreduce.Mapper;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import google.registry.dns.DnsQueue;
|
||||
import google.registry.mapreduce.MapreduceRunner;
|
||||
import google.registry.mapreduce.inputs.EppResourceInputs;
|
||||
|
@ -92,7 +91,7 @@ public class DnsRefreshForHostRenameAction implements Runnable {
|
|||
@Override
|
||||
public final void map(DomainResource domain) {
|
||||
if (isActive(domain, hostUpdateTime)
|
||||
&& domain.getNameservers().contains(Ref.create(targetHostKey))) {
|
||||
&& domain.getNameservers().contains(targetHostKey)) {
|
||||
try {
|
||||
dnsQueue.addDomainRefreshTask(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.Iterables;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import google.registry.config.RegistryEnvironment;
|
||||
import google.registry.flows.EppException;
|
||||
import google.registry.flows.ResourceAsyncDeleteFlow;
|
||||
|
@ -51,7 +50,7 @@ public class ContactDeleteFlow extends ResourceAsyncDeleteFlow<ContactResource,
|
|||
@Inject ContactDeleteFlow() {}
|
||||
|
||||
@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
|
||||
// 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
|
||||
|
@ -59,11 +58,11 @@ public class ContactDeleteFlow extends ResourceAsyncDeleteFlow<ContactResource,
|
|||
return Iterables.any(
|
||||
ofy().load().keys(
|
||||
queryDomainsUsingResource(
|
||||
ContactResource.class, ref, now, FAILFAST_CHECK_COUNT)).values(),
|
||||
ContactResource.class, key, now, FAILFAST_CHECK_COUNT)).values(),
|
||||
new Predicate<DomainBase>() {
|
||||
@Override
|
||||
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.ImmutableSet;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.flows.EppException;
|
||||
import google.registry.flows.EppException.AuthorizationErrorException;
|
||||
import google.registry.flows.EppException.ObjectDoesNotExistException;
|
||||
|
@ -173,7 +173,7 @@ public class DomainAllocateFlow extends DomainCreateOrAllocateFlow {
|
|||
sunrushAddGracePeriod ? GracePeriodStatus.SUNRUSH_ADD : GracePeriodStatus.ADD,
|
||||
billingEvent))
|
||||
.setApplicationTime(allocateCreate.getApplicationTime())
|
||||
.setApplication(Ref.create(application))
|
||||
.setApplication(Key.create(application))
|
||||
.setSmdId(allocateCreate.getSmdId())
|
||||
.setLaunchNotice(allocateCreate.getNotice());
|
||||
// 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.eppoutput.Result.Code.Success;
|
||||
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.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
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import static google.registry.util.DateTimeUtils.leapSafeAddYears;
|
|||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.dns.DnsQueue;
|
||||
import google.registry.flows.EppException;
|
||||
import google.registry.model.billing.BillingEvent;
|
||||
|
@ -74,8 +74,8 @@ public abstract class DomainCreateOrAllocateFlow
|
|||
|
||||
builder
|
||||
.setRegistrationExpirationTime(registrationExpirationTime)
|
||||
.setAutorenewBillingEvent(Ref.create(autorenewEvent))
|
||||
.setAutorenewPollMessage(Ref.create(autorenewPollMessage));
|
||||
.setAutorenewBillingEvent(Key.create(autorenewEvent))
|
||||
.setAutorenewPollMessage(Key.create(autorenewPollMessage));
|
||||
setDomainCreateOrAllocateProperties(builder);
|
||||
}
|
||||
|
||||
|
|
|
@ -114,8 +114,8 @@ public class DomainDeleteFlow extends ResourceSyncDeleteFlow<DomainResource, Bui
|
|||
.build();
|
||||
builder.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
|
||||
.setDeletionTime(deletionTime)
|
||||
// Clear out all old grace periods and add REDEMPTION, which does not include a ref
|
||||
// to a billing event because there isn't one for a domain delete.
|
||||
// Clear out all old grace periods and add REDEMPTION, which does not include a key to a
|
||||
// billing event because there isn't one for a domain delete.
|
||||
.setGracePeriods(ImmutableSet.of(GracePeriod.createWithoutBillingEvent(
|
||||
GracePeriodStatus.REDEMPTION,
|
||||
now.plus(registry.getRedemptionGracePeriodLength()),
|
||||
|
@ -142,11 +142,13 @@ public class DomainDeleteFlow extends ResourceSyncDeleteFlow<DomainResource, Bui
|
|||
Money cost;
|
||||
if (gracePeriod.getType() == GracePeriodStatus.AUTO_RENEW) {
|
||||
TimeOfYear recurrenceTimeOfYear =
|
||||
checkNotNull(gracePeriod.getRecurringBillingEvent()).get().getRecurrenceTimeOfYear();
|
||||
ofy().load().key(checkNotNull(gracePeriod.getRecurringBillingEvent())).now()
|
||||
.getRecurrenceTimeOfYear();
|
||||
DateTime autoRenewTime = recurrenceTimeOfYear.getLastInstanceBeforeOrAt(now);
|
||||
cost = getDomainRenewCost(targetId, autoRenewTime, 1);
|
||||
} else {
|
||||
cost = checkNotNull(gracePeriod.getOneTimeBillingEvent()).get().getCost();
|
||||
cost =
|
||||
ofy().load().key(checkNotNull(gracePeriod.getOneTimeBillingEvent())).now().getCost();
|
||||
}
|
||||
creditsBuilder.add(Credit.create(
|
||||
cost.negated().getAmount(),
|
||||
|
|
|
@ -40,7 +40,6 @@ import com.google.common.collect.ImmutableSet;
|
|||
import com.google.common.collect.Sets;
|
||||
import com.google.common.net.InternetDomainName;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import google.registry.flows.EppException;
|
||||
import google.registry.flows.EppException.AuthorizationErrorException;
|
||||
import google.registry.flows.EppException.ObjectDoesNotExistException;
|
||||
|
@ -246,23 +245,23 @@ public class DomainFlowUtils {
|
|||
/** Verify that no linked resources have disallowed statuses. */
|
||||
static void verifyNotInPendingDelete(
|
||||
Set<DesignatedContact> contacts,
|
||||
Ref<ContactResource> registrant,
|
||||
Set<Ref<HostResource>> nameservers) throws EppException {
|
||||
Key<ContactResource> registrant,
|
||||
Set<Key<HostResource>> nameservers) throws EppException {
|
||||
for (DesignatedContact contact : nullToEmpty(contacts)) {
|
||||
verifyNotInPendingDelete(contact.getContactRef());
|
||||
verifyNotInPendingDelete(contact.getContactKey());
|
||||
}
|
||||
if (registrant != null) {
|
||||
verifyNotInPendingDelete(registrant);
|
||||
}
|
||||
for (Ref<HostResource> host : nullToEmpty(nameservers)) {
|
||||
for (Key<HostResource> host : nullToEmpty(nameservers)) {
|
||||
verifyNotInPendingDelete(host);
|
||||
}
|
||||
}
|
||||
|
||||
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)) {
|
||||
throw new LinkedResourceInPendingDeleteProhibitsOperationException(resource.getForeignKey());
|
||||
}
|
||||
|
@ -302,7 +301,7 @@ public class DomainFlowUtils {
|
|||
}
|
||||
|
||||
static void validateRequiredContactsPresent(
|
||||
Ref<ContactResource> registrant, Set<DesignatedContact> contacts)
|
||||
Key<ContactResource> registrant, Set<DesignatedContact> contacts)
|
||||
throws RequiredParameterMissingException {
|
||||
if (registrant == null) {
|
||||
throw new MissingRegistrantException();
|
||||
|
@ -446,14 +445,14 @@ public class DomainFlowUtils {
|
|||
@SuppressWarnings("unchecked")
|
||||
static void updateAutorenewRecurrenceEndTime(DomainResource domain, DateTime newEndTime) {
|
||||
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,
|
||||
// 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
|
||||
// message to be deleted), and then subsequently the transfer was canceled, rejected, or deleted
|
||||
// (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()
|
||||
? autorenewPollMessage.get().asBuilder().setAutorenewEndTime(newEndTime).build()
|
||||
: newAutorenewPollMessage(domain)
|
||||
|
@ -472,7 +471,7 @@ public class DomainFlowUtils {
|
|||
ofy().save().entity(updatedAutorenewPollMessage);
|
||||
}
|
||||
|
||||
ofy().save().entity(domain.getAutorenewBillingEvent().get().asBuilder()
|
||||
ofy().save().entity(ofy().load().key(domain.getAutorenewBillingEvent()).now().asBuilder()
|
||||
.setRecurrenceEndTime(newEndTime)
|
||||
.build());
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ import static google.registry.util.DateTimeUtils.leapSafeAddYears;
|
|||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
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.ObjectPendingTransferException;
|
||||
import google.registry.flows.EppException.ParameterValueRangeErrorException;
|
||||
|
@ -145,8 +145,8 @@ public class DomainRenewFlow extends OwnedResourceMutateFlow<DomainResource, Ren
|
|||
ofy().save().<Object>entities(explicitRenewEvent, newAutorenewEvent, newAutorenewPollMessage);
|
||||
return existingResource.asBuilder()
|
||||
.setRegistrationExpirationTime(newExpirationTime)
|
||||
.setAutorenewBillingEvent(Ref.create(newAutorenewEvent))
|
||||
.setAutorenewPollMessage(Ref.create(newAutorenewPollMessage))
|
||||
.setAutorenewBillingEvent(Key.create(newAutorenewEvent))
|
||||
.setAutorenewPollMessage(Key.create(newAutorenewPollMessage))
|
||||
.addGracePeriod(GracePeriod.forBillingEvent(GracePeriodStatus.RENEW, explicitRenewEvent))
|
||||
.build();
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
|||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.net.InternetDomainName;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.dns.DnsQueue;
|
||||
import google.registry.flows.EppException;
|
||||
import google.registry.flows.EppException.CommandUseErrorException;
|
||||
|
@ -160,8 +160,8 @@ public class DomainRestoreRequestFlow extends OwnedResourceMutateFlow<DomainReso
|
|||
.setStatusValues(null)
|
||||
.setGracePeriods(null)
|
||||
.setDeletePollMessage(null)
|
||||
.setAutorenewBillingEvent(Ref.create(autorenewEvent))
|
||||
.setAutorenewPollMessage(Ref.create(autorenewPollMessage))
|
||||
.setAutorenewBillingEvent(Key.create(autorenewEvent))
|
||||
.setAutorenewPollMessage(Key.create(autorenewPollMessage))
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import com.google.common.base.Predicate;
|
|||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
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.ResourceTransferApproveFlow;
|
||||
import google.registry.model.billing.BillingEvent;
|
||||
|
@ -127,8 +127,8 @@ public class DomainTransferApproveFlow extends
|
|||
ofy().save().entity(gainingClientAutorenewPollMessage);
|
||||
builder
|
||||
.setRegistrationExpirationTime(newExpirationTime)
|
||||
.setAutorenewBillingEvent(Ref.create(autorenewEvent))
|
||||
.setAutorenewPollMessage(Ref.create(gainingClientAutorenewPollMessage))
|
||||
.setAutorenewBillingEvent(Key.create(autorenewEvent))
|
||||
.setAutorenewPollMessage(Key.create(gainingClientAutorenewPollMessage))
|
||||
// Remove all the old grace periods and add a new one for the transfer.
|
||||
.setGracePeriods(ImmutableSet.of(
|
||||
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.ImmutableSet;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import google.registry.flows.EppException;
|
||||
import google.registry.flows.ResourceTransferRequestFlow;
|
||||
import google.registry.model.billing.BillingEvent;
|
||||
|
@ -174,9 +173,9 @@ public class DomainTransferRequestFlow
|
|||
@Override
|
||||
protected void setTransferDataProperties(TransferData.Builder builder) {
|
||||
builder
|
||||
.setServerApproveBillingEvent(Ref.create(transferBillingEvent))
|
||||
.setServerApproveAutorenewEvent(Ref.create(gainingClientAutorenewEvent))
|
||||
.setServerApproveAutorenewPollMessage(Ref.create(gainingClientAutorenewPollMessage))
|
||||
.setServerApproveBillingEvent(Key.create(transferBillingEvent))
|
||||
.setServerApproveAutorenewEvent(Key.create(gainingClientAutorenewEvent))
|
||||
.setServerApproveAutorenewPollMessage(Key.create(gainingClientAutorenewPollMessage))
|
||||
.setExtendedRegistrationYears(command.getPeriod().getValue());
|
||||
}
|
||||
|
||||
|
@ -208,7 +207,7 @@ public class DomainTransferRequestFlow
|
|||
.setClientId(existingResource.getCurrentSponsorClientId())
|
||||
.setEventTime(automaticTransferTime)
|
||||
.setBillingTime(expirationTime.plus(registry.getAutoRenewGracePeriodLength()))
|
||||
.setRecurringEventRef(existingResource.getAutorenewBillingEvent())
|
||||
.setRecurringEventKey(existingResource.getAutorenewBillingEvent())
|
||||
.setParent(historyEntry)
|
||||
.build();
|
||||
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
|
||||
// between them.
|
||||
BillingEvent.OneTime originalAddEvent =
|
||||
sunrushAddGracePeriod.get().getOneTimeBillingEvent().get();
|
||||
ofy().load().key(sunrushAddGracePeriod.get().getOneTimeBillingEvent()).now();
|
||||
BillingEvent.OneTime billingEvent = new BillingEvent.OneTime.Builder()
|
||||
.setReason(Reason.CREATE)
|
||||
.setTargetId(targetId)
|
||||
|
|
|
@ -23,7 +23,7 @@ import static google.registry.model.ofy.ObjectifyService.ofy;
|
|||
import static google.registry.util.CollectionUtils.isNullOrEmpty;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.dns.DnsQueue;
|
||||
import google.registry.flows.EppException;
|
||||
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
|
||||
* domain ahead of time.
|
||||
*/
|
||||
private Optional<Ref<DomainResource>> superordinateDomain;
|
||||
private Optional<Key<DomainResource>> superordinateDomain;
|
||||
|
||||
@Inject HostCreateFlow() {}
|
||||
|
||||
|
@ -103,7 +103,7 @@ public class HostCreateFlow extends ResourceCreateFlow<HostResource, Builder, Cr
|
|||
@Override
|
||||
protected void modifyCreateRelatedResources() {
|
||||
if (superordinateDomain.isPresent()) {
|
||||
ofy().save().entity(superordinateDomain.get().get().asBuilder()
|
||||
ofy().save().entity(ofy().load().key(superordinateDomain.get()).now().asBuilder()
|
||||
.addSubordinateHost(command.getFullyQualifiedHostName())
|
||||
.build());
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ import com.google.common.base.Predicate;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import google.registry.config.RegistryEnvironment;
|
||||
import google.registry.flows.EppException;
|
||||
import google.registry.flows.ResourceAsyncDeleteFlow;
|
||||
|
@ -51,7 +50,7 @@ public class HostDeleteFlow extends ResourceAsyncDeleteFlow<HostResource, Builde
|
|||
@Inject HostDeleteFlow() {}
|
||||
|
||||
@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
|
||||
// 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
|
||||
|
@ -59,11 +58,11 @@ public class HostDeleteFlow extends ResourceAsyncDeleteFlow<HostResource, Builde
|
|||
return Iterables.any(
|
||||
ofy().load().keys(
|
||||
queryDomainsUsingResource(
|
||||
HostResource.class, ref, now, FAILFAST_CHECK_COUNT)).values(),
|
||||
HostResource.class, key, now, FAILFAST_CHECK_COUNT)).values(),
|
||||
new Predicate<DomainBase>() {
|
||||
@Override
|
||||
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.loadByUniqueId;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.model.registry.Registries.findTldForName;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.Iterables;
|
||||
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.AuthorizationErrorException;
|
||||
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. */
|
||||
static Ref<DomainResource> lookupSuperordinateDomain(
|
||||
static Key<DomainResource> lookupSuperordinateDomain(
|
||||
InternetDomainName hostName, DateTime now) throws EppException {
|
||||
Optional<InternetDomainName> tldParsed = findTldForName(hostName);
|
||||
if (!tldParsed.isPresent()) {
|
||||
|
@ -91,7 +92,7 @@ public class HostFlowUtils {
|
|||
if (superordinateDomain == null || !isActive(superordinateDomain, now)) {
|
||||
throw new SuperordinateDomainDoesNotExistException(domainName);
|
||||
}
|
||||
return Ref.create(superordinateDomain);
|
||||
return Key.create(superordinateDomain);
|
||||
}
|
||||
|
||||
/** 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. */
|
||||
static void verifyDomainIsSameRegistrar(
|
||||
Ref<DomainResource> superordinateDomain,
|
||||
Key<DomainResource> superordinateDomain,
|
||||
String clientId) throws EppException {
|
||||
if (superordinateDomain != null
|
||||
&& !clientId.equals(superordinateDomain.get().getCurrentSponsorClientId())) {
|
||||
&& !clientId.equals(
|
||||
ofy().load().key(superordinateDomain).now().getCurrentSponsorClientId())) {
|
||||
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.validateHostName;
|
||||
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.util.CollectionUtils.isNullOrEmpty;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import google.registry.dns.DnsQueue;
|
||||
import google.registry.flows.EppException;
|
||||
import google.registry.flows.EppException.ObjectAlreadyExistsException;
|
||||
|
@ -63,7 +62,7 @@ import org.joda.time.Duration;
|
|||
*/
|
||||
public class HostUpdateFlow extends ResourceUpdateFlow<HostResource, Builder, Update> {
|
||||
|
||||
private Ref<DomainResource> superordinateDomain;
|
||||
private Key<DomainResource> superordinateDomain;
|
||||
|
||||
private String oldHostName;
|
||||
private String newHostName;
|
||||
|
@ -85,7 +84,7 @@ public class HostUpdateFlow extends ResourceUpdateFlow<HostResource, Builder, Up
|
|||
protected void verifyUpdateIsAllowed() throws EppException {
|
||||
verifyDomainIsSameRegistrar(superordinateDomain, getClientId());
|
||||
if (isHostRename
|
||||
&& loadAndGetReference(HostResource.class, newHostName, now) != null) {
|
||||
&& loadAndGetKey(HostResource.class, newHostName, now) != null) {
|
||||
throw new HostAlreadyExistsException(newHostName);
|
||||
}
|
||||
}
|
||||
|
@ -170,24 +169,25 @@ public class HostUpdateFlow extends ResourceUpdateFlow<HostResource, Builder, Up
|
|||
}
|
||||
|
||||
private void updateSuperordinateDomains() {
|
||||
Ref<DomainResource> oldSuperordinateDomain = existingResource.getSuperordinateDomain();
|
||||
Key<DomainResource> oldSuperordinateDomain = existingResource.getSuperordinateDomain();
|
||||
if (oldSuperordinateDomain != null || superordinateDomain != null) {
|
||||
if (Objects.equals(oldSuperordinateDomain, superordinateDomain)) {
|
||||
ofy().save().entity(oldSuperordinateDomain.get().asBuilder()
|
||||
.removeSubordinateHost(oldHostName)
|
||||
.addSubordinateHost(newHostName)
|
||||
.build());
|
||||
ofy().save().entity(
|
||||
ofy().load().key(oldSuperordinateDomain).now().asBuilder()
|
||||
.removeSubordinateHost(oldHostName)
|
||||
.addSubordinateHost(newHostName)
|
||||
.build());
|
||||
} else {
|
||||
if (oldSuperordinateDomain != null) {
|
||||
ofy().save().entity(
|
||||
oldSuperordinateDomain.get()
|
||||
ofy().load().key(oldSuperordinateDomain).now()
|
||||
.asBuilder()
|
||||
.removeSubordinateHost(oldHostName)
|
||||
.build());
|
||||
}
|
||||
if (superordinateDomain != null) {
|
||||
ofy().save().entity(
|
||||
superordinateDomain.get()
|
||||
ofy().load().key(superordinateDomain).now()
|
||||
.asBuilder()
|
||||
.addSubordinateHost(newHostName)
|
||||
.build());
|
||||
|
|
|
@ -14,10 +14,11 @@
|
|||
|
||||
package google.registry.mapreduce.inputs;
|
||||
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
|
||||
import com.google.appengine.tools.mapreduce.InputReader;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import google.registry.model.EppResource;
|
||||
import google.registry.model.index.EppResourceIndex;
|
||||
import google.registry.model.index.EppResourceIndexBucket;
|
||||
|
@ -55,12 +56,12 @@ class EppResourceEntityReader<R extends EppResource> extends EppResourceBaseRead
|
|||
*/
|
||||
@Override
|
||||
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) {
|
||||
Ref<? extends EppResource> reference = nextEri().getReference();
|
||||
EppResource resource = reference.get();
|
||||
Key<? extends EppResource> key = nextEri().getKey();
|
||||
EppResource resource = ofy().load().key(key).now();
|
||||
if (resource == null) {
|
||||
logger.severefmt("Broken ERI reference: %s", reference.getKey());
|
||||
logger.severefmt("EppResourceIndex key %s points at a missing resource", key);
|
||||
continue;
|
||||
}
|
||||
// Postfilter to distinguish polymorphic types (e.g. DomainBase and DomainResource).
|
||||
|
|
|
@ -49,6 +49,6 @@ class EppResourceKeyReader<R extends EppResource> extends EppResourceBaseReader<
|
|||
@SuppressWarnings("unchecked")
|
||||
public Key<R> next() throws NoSuchElementException {
|
||||
// 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.collect.ImmutableSet;
|
||||
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.Index;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
|
@ -129,7 +129,7 @@ public abstract class EppResource extends BackupGroupRoot implements Buildable,
|
|||
* @see google.registry.model.translators.CommitLogRevisionsTranslatorFactory
|
||||
*/
|
||||
@XmlTransient
|
||||
ImmutableSortedMap<DateTime, Ref<CommitLogManifest>> revisions = ImmutableSortedMap.of();
|
||||
ImmutableSortedMap<DateTime, Key<CommitLogManifest>> revisions = ImmutableSortedMap.of();
|
||||
|
||||
public final String getRepoId() {
|
||||
return repoId;
|
||||
|
@ -178,7 +178,7 @@ public abstract class EppResource extends BackupGroupRoot implements Buildable,
|
|||
return deletionTime;
|
||||
}
|
||||
|
||||
public ImmutableSortedMap<DateTime, Ref<CommitLogManifest>> getRevisions() {
|
||||
public ImmutableSortedMap<DateTime, Key<CommitLogManifest>> getRevisions() {
|
||||
return nullToEmptyImmutableCopy(revisions);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ package google.registry.model;
|
|||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.collect.Iterables.transform;
|
||||
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.util.DateTimeUtils.isAtOrAfter;
|
||||
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.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.Result;
|
||||
import com.googlecode.objectify.util.ResultNow;
|
||||
import google.registry.config.RegistryEnvironment;
|
||||
|
@ -98,20 +97,20 @@ public final class EppResourceUtils {
|
|||
*/
|
||||
public static <T extends EppResource> T loadByUniqueId(
|
||||
Class<T> clazz, String foreignKey, DateTime now) {
|
||||
// For regular foreign-keyed resources, get the ref by loading the FKI; for domain applications,
|
||||
// we can construct the ref directly, since the provided foreignKey is just the repoId.
|
||||
Ref<T> resourceRef = ForeignKeyedEppResource.class.isAssignableFrom(clazz)
|
||||
? loadAndGetReference(clazz, foreignKey, now)
|
||||
: Ref.create(Key.create(null, clazz, foreignKey));
|
||||
if (resourceRef == null) {
|
||||
// For regular foreign-keyed resources, get the key by loading the FKI; for domain applications,
|
||||
// we can construct the key directly, since the provided foreignKey is just the repoId.
|
||||
Key<T> resourceKey = ForeignKeyedEppResource.class.isAssignableFrom(clazz)
|
||||
? loadAndGetKey(clazz, foreignKey, now)
|
||||
: Key.create(null, clazz, foreignKey);
|
||||
if (resourceKey == null) {
|
||||
return null;
|
||||
}
|
||||
T resource = resourceRef.get();
|
||||
T resource = ofy().load().key(resourceKey).now();
|
||||
if (resource == null
|
||||
// You'd think this couldn't happen, but it can. For polymorphic entities, a Ref or Key is
|
||||
// of necessity a reference to the base type (since datastore doesn't have polymorphism and
|
||||
// You'd think this couldn't happen, but it can. For polymorphic entities, a Key is of
|
||||
// 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
|
||||
// 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
|
||||
// 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,
|
||||
|
@ -286,13 +285,13 @@ public final class EppResourceUtils {
|
|||
private static <T extends EppResource> Result<T> loadMostRecentRevisionAtTime(
|
||||
final T resource, final DateTime timestamp) {
|
||||
final Key<T> resourceKey = Key.create(resource);
|
||||
final Ref<CommitLogManifest> revision = findMostRecentRevisionAtTime(resource, timestamp);
|
||||
final Key<CommitLogManifest> revision = findMostRecentRevisionAtTime(resource, timestamp);
|
||||
if (revision == null) {
|
||||
logger.severefmt("No revision found for %s, falling back to resource.", resourceKey);
|
||||
return new ResultNow<>(resource);
|
||||
}
|
||||
final Result<CommitLogMutation> mutationResult =
|
||||
ofy().load().key(CommitLogMutation.createKey(revision.getKey(), resourceKey));
|
||||
ofy().load().key(CommitLogMutation.createKey(revision, resourceKey));
|
||||
return new Result<T>() {
|
||||
@Override
|
||||
public T now() {
|
||||
|
@ -310,10 +309,10 @@ public final class EppResourceUtils {
|
|||
}
|
||||
|
||||
@Nullable
|
||||
private static <T extends EppResource> Ref<CommitLogManifest>
|
||||
private static <T extends EppResource> Key<CommitLogManifest>
|
||||
findMostRecentRevisionAtTime(final T resource, final DateTime timestamp) {
|
||||
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) {
|
||||
logger.infofmt("Found revision history at %s for %s: %s", timestamp, resourceKey, revision);
|
||||
return revision.getValue();
|
||||
|
@ -336,19 +335,19 @@ public final class EppResourceUtils {
|
|||
* <p>This is an eventually consistent query.
|
||||
*
|
||||
* @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 limit max number of keys to return
|
||||
*/
|
||||
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));
|
||||
return ofy().load().type(DomainBase.class)
|
||||
.filter(
|
||||
clazz.equals(ContactResource.class)
|
||||
? "allContacts.contactId.linked"
|
||||
: "nameservers.linked",
|
||||
ref)
|
||||
key)
|
||||
.filter("deletionTime >", now)
|
||||
.limit(limit)
|
||||
.keys()
|
||||
|
@ -358,7 +357,7 @@ public final class EppResourceUtils {
|
|||
/** Clone a contact or host with an eventually-consistent notion of LINKED. */
|
||||
public static EppResource cloneResourceWithLinkedStatus(EppResource resource, DateTime now) {
|
||||
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);
|
||||
} else {
|
||||
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.collect.Iterables.transform;
|
||||
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.RetentionPolicy.RUNTIME;
|
||||
|
||||
|
@ -24,7 +25,7 @@ import com.google.common.base.Function;
|
|||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.annotation.Ignore;
|
||||
import google.registry.model.domain.ReferenceUnion;
|
||||
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,
|
||||
* collections, and references.
|
||||
* collections, and referenced keys.
|
||||
*/
|
||||
public String toHydratedString() {
|
||||
return toStringHelper(new Function<Object, Object>() {
|
||||
@Override
|
||||
public Object apply(Object input) {
|
||||
if (input instanceof ReferenceUnion) {
|
||||
return apply(((ReferenceUnion<?>) input).getLinked().get());
|
||||
} else if (input instanceof Ref) {
|
||||
// Only follow references of type Ref, not of type Key (the latter deliberately used for
|
||||
// references that should not be followed)
|
||||
Object target = ((Ref<?>) input).get();
|
||||
return apply(((ReferenceUnion<?>) input).getLinked());
|
||||
} else if (input instanceof Key) {
|
||||
Object target = ofy().load().key((Key<?>) input).now();
|
||||
return target != null && target.getClass().isAnnotationPresent(DoNotHydrate.class)
|
||||
? input
|
||||
: apply(target);
|
||||
|
|
|
@ -39,7 +39,6 @@ import com.google.common.collect.ImmutableSortedMap;
|
|||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Ordering;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.annotation.Id;
|
||||
import com.googlecode.objectify.annotation.Ignore;
|
||||
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
|
||||
// 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
|
||||
// actual embed themselves in the persisted object anyway.
|
||||
// types of Key objects, since they are just references to other objects and don't actually
|
||||
// embed themselves in the persisted object anyway.
|
||||
Class<?> fieldClazz = field.getType();
|
||||
Type fieldType = field.getGenericType();
|
||||
builder.add(fieldClazz);
|
||||
if (fieldType.equals(fieldClazz) || Ref.class.equals(clazz) || Key.class.equals(clazz)) {
|
||||
if (fieldType.equals(fieldClazz) || Key.class.equals(clazz)) {
|
||||
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.checkNotNull;
|
||||
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.union;
|
||||
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.Sets;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.annotation.Entity;
|
||||
import com.googlecode.objectify.annotation.Id;
|
||||
import com.googlecode.objectify.annotation.IgnoreSave;
|
||||
|
@ -410,19 +410,27 @@ public abstract class BillingEvent extends ImmutableObject
|
|||
@Index
|
||||
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)
|
||||
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)
|
||||
Ref<BillingEvent.Recurring> refRecurring = null;
|
||||
Key<BillingEvent.Recurring> refRecurring = null;
|
||||
|
||||
public DateTime getBillingTime() {
|
||||
return billingTime;
|
||||
}
|
||||
|
||||
public Ref<? extends BillingEvent> getEventRef() {
|
||||
public Key<? extends BillingEvent> getEventKey() {
|
||||
return firstNonNull(refOneTime, refRecurring);
|
||||
}
|
||||
|
||||
|
@ -454,9 +462,9 @@ public abstract class BillingEvent extends ImmutableObject
|
|||
.setParent(historyEntry);
|
||||
// Set the grace period's billing event using the appropriate Cancellation builder method.
|
||||
if (gracePeriod.getOneTimeBillingEvent() != null) {
|
||||
builder.setOneTimeEventRef(gracePeriod.getOneTimeBillingEvent());
|
||||
builder.setOneTimeEventKey(gracePeriod.getOneTimeBillingEvent());
|
||||
} else if (gracePeriod.getRecurringBillingEvent() != null) {
|
||||
builder.setRecurringEventRef(gracePeriod.getRecurringBillingEvent());
|
||||
builder.setRecurringEventKey(gracePeriod.getRecurringBillingEvent());
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
@ -480,13 +488,13 @@ public abstract class BillingEvent extends ImmutableObject
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder setOneTimeEventRef(Ref<BillingEvent.OneTime> eventRef) {
|
||||
getInstance().refOneTime = eventRef;
|
||||
public Builder setOneTimeEventKey(Key<BillingEvent.OneTime> eventKey) {
|
||||
getInstance().refOneTime = eventKey;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setRecurringEventRef(Ref<BillingEvent.Recurring> eventRef) {
|
||||
getInstance().refRecurring = eventRef;
|
||||
public Builder setRecurringEventKey(Key<BillingEvent.Recurring> eventKey) {
|
||||
getInstance().refRecurring = eventKey;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -496,7 +504,7 @@ public abstract class BillingEvent extends ImmutableObject
|
|||
checkNotNull(instance.billingTime);
|
||||
checkNotNull(instance.reason);
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -512,7 +520,7 @@ public abstract class BillingEvent extends ImmutableObject
|
|||
Money cost;
|
||||
|
||||
/** 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
|
||||
|
@ -524,7 +532,7 @@ public abstract class BillingEvent extends ImmutableObject
|
|||
return cost;
|
||||
}
|
||||
|
||||
public Ref<BillingEvent.OneTime> getEventRef() {
|
||||
public Key<BillingEvent.OneTime> getEventKey() {
|
||||
return eventRef;
|
||||
}
|
||||
|
||||
|
@ -551,7 +559,7 @@ public abstract class BillingEvent extends ImmutableObject
|
|||
.setFlags(billingEvent.getFlags())
|
||||
.setReason(billingEvent.getReason())
|
||||
.setTargetId(billingEvent.getTargetId())
|
||||
.setEventRef(Ref.create(billingEvent))
|
||||
.setEventKey(Key.create(billingEvent))
|
||||
.setEventTime(historyEntry.getModificationTime())
|
||||
.setDescription(description)
|
||||
.setCost(billingEvent.getCost().negated())
|
||||
|
@ -573,8 +581,8 @@ public abstract class BillingEvent extends ImmutableObject
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder setEventRef(Ref<BillingEvent.OneTime> eventRef) {
|
||||
getInstance().eventRef = eventRef;
|
||||
public Builder setEventKey(Key<BillingEvent.OneTime> eventKey) {
|
||||
getInstance().eventRef = eventKey;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -589,7 +597,7 @@ public abstract class BillingEvent extends ImmutableObject
|
|||
Modification instance = getInstance();
|
||||
checkNotNull(instance.reason);
|
||||
checkNotNull(instance.eventRef);
|
||||
BillingEvent.OneTime billingEvent = instance.eventRef.get();
|
||||
BillingEvent.OneTime billingEvent = ofy().load().key(instance.eventRef).now();
|
||||
checkArgument(Objects.equals(
|
||||
instance.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.ImmutableList;
|
||||
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.Id;
|
||||
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. */
|
||||
@Parent
|
||||
Ref<Registrar> parent;
|
||||
Key<Registrar> parent;
|
||||
|
||||
/** The type of credit. */
|
||||
CreditType type;
|
||||
|
@ -95,7 +95,7 @@ public final class RegistrarCredit extends ImmutableObject implements Buildable
|
|||
*/
|
||||
String tld;
|
||||
|
||||
public Ref<Registrar> getParent() {
|
||||
public Key<Registrar> getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ public final class RegistrarCredit extends ImmutableObject implements Buildable
|
|||
/** Returns a string representation of this credit. */
|
||||
public String getSummary() {
|
||||
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. */
|
||||
|
@ -144,7 +144,7 @@ public final class RegistrarCredit extends ImmutableObject implements Buildable
|
|||
}
|
||||
|
||||
public Builder setParent(Registrar parent) {
|
||||
getInstance().parent = Ref.create(parent);
|
||||
getInstance().parent = Key.create(parent);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,15 +27,14 @@ import com.google.common.collect.ImmutableSortedMap;
|
|||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Ordering;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.annotation.Entity;
|
||||
import com.googlecode.objectify.annotation.Id;
|
||||
import com.googlecode.objectify.annotation.Parent;
|
||||
import com.googlecode.objectify.impl.ref.DeadRef;
|
||||
import google.registry.model.Buildable;
|
||||
import google.registry.model.ImmutableObject;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
import org.joda.money.Money;
|
||||
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. */
|
||||
@Parent
|
||||
Ref<RegistrarCredit> parent;
|
||||
Key<RegistrarCredit> parent;
|
||||
|
||||
/** The time at which this balance amount should become effective. */
|
||||
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. */
|
||||
Money amount;
|
||||
|
||||
public Ref<RegistrarCredit> getParent() {
|
||||
public Key<RegistrarCredit> getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
|
@ -97,6 +96,9 @@ public final class RegistrarCreditBalance extends ImmutableObject implements Bui
|
|||
|
||||
/** A Builder for an {@link RegistrarCreditBalance}. */
|
||||
public static class Builder extends Buildable.Builder<RegistrarCreditBalance> {
|
||||
|
||||
private CurrencyUnit currency;
|
||||
|
||||
public Builder() {}
|
||||
|
||||
public Builder(RegistrarCreditBalance instance) {
|
||||
|
@ -104,8 +106,8 @@ public final class RegistrarCreditBalance extends ImmutableObject implements Bui
|
|||
}
|
||||
|
||||
public RegistrarCreditBalance.Builder setParent(RegistrarCredit parent) {
|
||||
// Use a DeadRef so that we can retrieve the actual instance provided later on in build().
|
||||
getInstance().parent = new DeadRef<>(Key.create(parent), parent);
|
||||
this.currency = parent.getCurrency();
|
||||
getInstance().parent = Key.create(parent);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -132,12 +134,11 @@ public final class RegistrarCreditBalance extends ImmutableObject implements Bui
|
|||
checkNotNull(instance.effectiveTime);
|
||||
checkNotNull(instance.writtenTime);
|
||||
checkNotNull(instance.amount);
|
||||
RegistrarCredit credit = instance.parent.get();
|
||||
checkState(
|
||||
instance.amount.getCurrencyUnit().equals(credit.getCurrency()),
|
||||
instance.amount.getCurrencyUnit().equals(currency),
|
||||
"Currency of balance amount differs from credit currency (%s vs %s)",
|
||||
instance.amount.getCurrencyUnit(),
|
||||
credit.getCurrency());
|
||||
currency);
|
||||
return super.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
package google.registry.model.domain;
|
||||
|
||||
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.Index;
|
||||
import google.registry.model.ImmutableObject;
|
||||
|
@ -48,7 +48,7 @@ public class DesignatedContact extends ImmutableObject {
|
|||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public static DesignatedContact create(Type type, Ref<ContactResource> contact) {
|
||||
public static DesignatedContact create(Type type, Key<ContactResource> contact) {
|
||||
DesignatedContact instance = new DesignatedContact();
|
||||
instance.type = type;
|
||||
instance.contactId = ReferenceUnion.create(contact);
|
||||
|
@ -60,14 +60,14 @@ public class DesignatedContact extends ImmutableObject {
|
|||
|
||||
@Index
|
||||
@XmlValue
|
||||
//TODO(b/28713909): Make this a Ref<ContactResource>.
|
||||
//TODO(b/28713909): Make this a Key<ContactResource>.
|
||||
ReferenceUnion<ContactResource> contactId;
|
||||
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public Ref<ContactResource> getContactRef() {
|
||||
public Key<ContactResource> getContactKey() {
|
||||
return contactId.getLinked();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,8 +15,9 @@
|
|||
package google.registry.model.domain;
|
||||
|
||||
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 google.registry.model.EppResource;
|
||||
import google.registry.model.contact.ContactResource;
|
||||
|
@ -38,9 +39,9 @@ public class DomainAuthInfo extends AuthInfo {
|
|||
checkNotNull(getPw());
|
||||
if (getRepoId() != null) {
|
||||
// Make sure the repo id matches one of the contacts on the domain.
|
||||
Ref<ContactResource> foundContact = null;
|
||||
for (Ref<ContactResource> contact : domain.getReferencedContacts()) {
|
||||
String contactRepoId = contact.getKey().getName();
|
||||
Key<ContactResource> foundContact = null;
|
||||
for (Key<ContactResource> contact : domain.getReferencedContacts()) {
|
||||
String contactRepoId = contact.getName();
|
||||
if (getRepoId().equals(contactRepoId)) {
|
||||
foundContact = contact;
|
||||
break;
|
||||
|
@ -50,7 +51,7 @@ public class DomainAuthInfo extends AuthInfo {
|
|||
throw new BadAuthInfoException();
|
||||
}
|
||||
// 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())) {
|
||||
throw new BadAuthInfoException();
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ import com.google.common.collect.FluentIterable;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
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.IgnoreSave;
|
||||
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. */
|
||||
@XmlTransient
|
||||
//TODO(b/28713909): Make this a Set<Ref<HostResource>>.
|
||||
//TODO(b/28713909): Make this a Set<Key<HostResource>>.
|
||||
Set<ReferenceUnion<HostResource>> nameservers;
|
||||
|
||||
/**
|
||||
|
@ -149,7 +149,7 @@ public abstract class DomainBase extends EppResource {
|
|||
public ForeignKeyedDesignatedContact apply(DesignatedContact designated) {
|
||||
return ForeignKeyedDesignatedContact.create(
|
||||
designated.getType(),
|
||||
designated.getContactRef().get().getContactId());
|
||||
ofy().load().key(designated.getContactKey()).now().getContactId());
|
||||
}})
|
||||
.toSet();
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ public abstract class DomainBase extends EppResource {
|
|||
@XmlElement(name = "registrant")
|
||||
private String getMarshalledRegistrant() {
|
||||
preMarshal();
|
||||
return getRegistrant().get().getContactId();
|
||||
return ofy().load().key(getRegistrant()).now().getContactId();
|
||||
}
|
||||
|
||||
public String getFullyQualifiedDomainName() {
|
||||
|
@ -177,8 +177,8 @@ public abstract class DomainBase extends EppResource {
|
|||
return idnTableName;
|
||||
}
|
||||
|
||||
public ImmutableSet<Ref<HostResource>> getNameservers() {
|
||||
ImmutableSet.Builder<Ref<HostResource>> builder = new ImmutableSet.Builder<>();
|
||||
public ImmutableSet<Key<HostResource>> getNameservers() {
|
||||
ImmutableSet.Builder<Key<HostResource>> builder = new ImmutableSet.Builder<>();
|
||||
for (ReferenceUnion<HostResource> union : nullToEmptyImmutableCopy(nameservers)) {
|
||||
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. */
|
||||
public ImmutableSortedSet<String> loadNameserverFullyQualifiedHostNames() {
|
||||
return FluentIterable.from(ofy().load().refs(getNameservers()).values())
|
||||
return FluentIterable.from(ofy().load().keys(getNameservers()).values())
|
||||
.transform(
|
||||
new Function<HostResource, String>() {
|
||||
@Override
|
||||
|
@ -198,14 +198,14 @@ public abstract class DomainBase extends EppResource {
|
|||
.toSortedSet(Ordering.natural());
|
||||
}
|
||||
|
||||
/** A reference to the registrant who registered this domain. */
|
||||
public Ref<ContactResource> getRegistrant() {
|
||||
/** A key to the registrant who registered this domain. */
|
||||
public Key<ContactResource> getRegistrant() {
|
||||
return FluentIterable
|
||||
.from(nullToEmpty(allContacts))
|
||||
.filter(IS_REGISTRANT)
|
||||
.first()
|
||||
.get()
|
||||
.getContactRef();
|
||||
.getContactKey();
|
||||
}
|
||||
|
||||
/** 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. */
|
||||
public ImmutableSet<Ref<ContactResource>> getReferencedContacts() {
|
||||
ImmutableSet.Builder<Ref<ContactResource>> contactsBuilder =
|
||||
public ImmutableSet<Key<ContactResource>> getReferencedContacts() {
|
||||
ImmutableSet.Builder<Key<ContactResource>> contactsBuilder =
|
||||
new ImmutableSet.Builder<>();
|
||||
for (DesignatedContact designated : nullToEmptyImmutableCopy(allContacts)) {
|
||||
contactsBuilder.add(designated.getContactRef());
|
||||
contactsBuilder.add(designated.getContactKey());
|
||||
}
|
||||
return contactsBuilder.build();
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ public abstract class DomainBase extends EppResource {
|
|||
return thisCastToDerived();
|
||||
}
|
||||
|
||||
public B setRegistrant(Ref<ContactResource> registrant) {
|
||||
public B setRegistrant(Key<ContactResource> registrant) {
|
||||
// Replace the registrant contact inside allContacts.
|
||||
getInstance().allContacts = union(
|
||||
getInstance().getContacts(),
|
||||
|
@ -289,21 +289,21 @@ public abstract class DomainBase extends EppResource {
|
|||
return thisCastToDerived();
|
||||
}
|
||||
|
||||
public B setNameservers(ImmutableSet<Ref<HostResource>> nameservers) {
|
||||
public B setNameservers(ImmutableSet<Key<HostResource>> nameservers) {
|
||||
ImmutableSet.Builder<ReferenceUnion<HostResource>> builder = new ImmutableSet.Builder<>();
|
||||
for (Ref<HostResource> ref : nullToEmpty(nameservers)) {
|
||||
builder.add(ReferenceUnion.create(ref));
|
||||
for (Key<HostResource> key : nullToEmpty(nameservers)) {
|
||||
builder.add(ReferenceUnion.create(key));
|
||||
}
|
||||
getInstance().nameservers = builder.build();
|
||||
return thisCastToDerived();
|
||||
}
|
||||
|
||||
public B addNameservers(ImmutableSet<Ref<HostResource>> nameservers) {
|
||||
public B addNameservers(ImmutableSet<Key<HostResource>> nameservers) {
|
||||
return setNameservers(
|
||||
ImmutableSet.copyOf(union(getInstance().getNameservers(), nameservers)));
|
||||
}
|
||||
|
||||
public B removeNameservers(ImmutableSet<Ref<HostResource>> nameservers) {
|
||||
public B removeNameservers(ImmutableSet<Key<HostResource>> nameservers) {
|
||||
return setNameservers(
|
||||
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.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Work;
|
||||
import google.registry.model.EppResource;
|
||||
import google.registry.model.ImmutableObject;
|
||||
|
@ -83,9 +83,9 @@ public class DomainCommand {
|
|||
@XmlElement(name = "registrant")
|
||||
String registrantContactId;
|
||||
|
||||
/** A resolved reference to the registrant who registered this domain. */
|
||||
/** A resolved key to the registrant who registered this domain. */
|
||||
@XmlTransient
|
||||
Ref<ContactResource> registrant;
|
||||
Key<ContactResource> registrant;
|
||||
|
||||
/** Authorization info (aka transfer secret) of the domain. */
|
||||
DomainAuthInfo authInfo;
|
||||
|
@ -94,7 +94,7 @@ public class DomainCommand {
|
|||
return registrantContactId;
|
||||
}
|
||||
|
||||
public Ref<ContactResource> getRegistrant() {
|
||||
public Key<ContactResource> getRegistrant() {
|
||||
return registrant;
|
||||
}
|
||||
|
||||
|
@ -134,15 +134,15 @@ public class DomainCommand {
|
|||
@XmlElement(name = "hostObj")
|
||||
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
|
||||
Set<Ref<HostResource>> nameservers;
|
||||
Set<Key<HostResource>> nameservers;
|
||||
|
||||
/** Foreign keyed associated contacts for the domain (other than registrant). */
|
||||
@XmlElement(name = "contact")
|
||||
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
|
||||
Set<DesignatedContact> contacts;
|
||||
|
||||
|
@ -166,7 +166,7 @@ public class DomainCommand {
|
|||
return nullSafeImmutableCopy(nameserverFullyQualifiedHostNames);
|
||||
}
|
||||
|
||||
public ImmutableSet<Ref<HostResource>> getNameservers() {
|
||||
public ImmutableSet<Key<HostResource>> getNameservers() {
|
||||
return nullSafeImmutableCopy(nameservers);
|
||||
}
|
||||
|
||||
|
@ -210,7 +210,7 @@ public class DomainCommand {
|
|||
now);
|
||||
for (DesignatedContact contact : contacts) {
|
||||
if (DesignatedContact.Type.REGISTRANT.equals(contact.getType())) {
|
||||
clone.registrant = contact.getContactRef();
|
||||
clone.registrant = contact.getContactKey();
|
||||
clone.contacts = forceEmptyToNull(difference(contacts, contact));
|
||||
break;
|
||||
}
|
||||
|
@ -373,15 +373,15 @@ public class DomainCommand {
|
|||
@XmlElement(name = "hostObj")
|
||||
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
|
||||
Set<Ref<HostResource>> nameservers;
|
||||
Set<Key<HostResource>> nameservers;
|
||||
|
||||
/** Foreign keyed associated contacts for the domain (other than registrant). */
|
||||
@XmlElement(name = "contact")
|
||||
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
|
||||
Set<DesignatedContact> contacts;
|
||||
|
||||
|
@ -389,7 +389,7 @@ public class DomainCommand {
|
|||
return nullSafeImmutableCopy(nameserverFullyQualifiedHostNames);
|
||||
}
|
||||
|
||||
public ImmutableSet<Ref<HostResource>> getNameservers() {
|
||||
public ImmutableSet<Key<HostResource>> getNameservers() {
|
||||
return nullToEmptyImmutableCopy(nameservers);
|
||||
}
|
||||
|
||||
|
@ -415,7 +415,7 @@ public class DomainCommand {
|
|||
clone.registrant = clone.registrantContactId == null
|
||||
? null
|
||||
: getOnlyElement(
|
||||
loadReferences(
|
||||
loadByForeignKey(
|
||||
ImmutableSet.of(clone.registrantContactId), ContactResource.class, now)
|
||||
.values());
|
||||
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 {
|
||||
if (fullyQualifiedHostNames == null) {
|
||||
return null;
|
||||
}
|
||||
return ImmutableSet.copyOf(
|
||||
loadReferences(fullyQualifiedHostNames, HostResource.class, now).values());
|
||||
loadByForeignKey(fullyQualifiedHostNames, HostResource.class, now).values());
|
||||
}
|
||||
|
||||
private static Set<DesignatedContact> linkContacts(
|
||||
|
@ -474,8 +474,8 @@ public class DomainCommand {
|
|||
for (ForeignKeyedDesignatedContact contact : contacts) {
|
||||
foreignKeys.add(contact.contactId);
|
||||
}
|
||||
ImmutableMap<String, Ref<ContactResource>> loadedContacts =
|
||||
loadReferences(foreignKeys.build(), ContactResource.class, now);
|
||||
ImmutableMap<String, Key<ContactResource>> loadedContacts =
|
||||
loadByForeignKey(foreignKeys.build(), ContactResource.class, now);
|
||||
ImmutableSet.Builder<DesignatedContact> linkedContacts = new ImmutableSet.Builder<>();
|
||||
for (ForeignKeyedDesignatedContact contact : contacts) {
|
||||
linkedContacts.add(DesignatedContact.create(
|
||||
|
@ -484,8 +484,8 @@ public class DomainCommand {
|
|||
return linkedContacts.build();
|
||||
}
|
||||
|
||||
/** Load references to resources by their foreign keys. */
|
||||
private static <T extends EppResource> ImmutableMap<String, Ref<T>> loadReferences(
|
||||
/** Load keys to resources by their foreign keys. */
|
||||
private static <T extends EppResource> ImmutableMap<String, Key<T>> loadByForeignKey(
|
||||
final Set<String> foreignKeys, final Class<T> clazz, final DateTime now)
|
||||
throws InvalidReferencesException {
|
||||
Map<String, ForeignKeyIndex<T>> fkis = ofy().doTransactionless(
|
||||
|
@ -500,10 +500,10 @@ public class DomainCommand {
|
|||
}
|
||||
return ImmutableMap.copyOf(transformValues(
|
||||
fkis,
|
||||
new Function<ForeignKeyIndex<T>, Ref<T>>() {
|
||||
new Function<ForeignKeyIndex<T>, Key<T>>() {
|
||||
@Override
|
||||
public Ref<T> apply(ForeignKeyIndex<T> fki) {
|
||||
return fki.getReference();
|
||||
public Key<T> apply(ForeignKeyIndex<T> fki) {
|
||||
return fki.getResourceKey();
|
||||
}}));
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ import static google.registry.util.DateTimeUtils.leapSafeAddYears;
|
|||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.annotation.Cache;
|
||||
import com.googlecode.objectify.annotation.EntitySubclass;
|
||||
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.
|
||||
*/
|
||||
@XmlTransient
|
||||
Ref<BillingEvent.Recurring> autorenewBillingEvent;
|
||||
Key<BillingEvent.Recurring> autorenewBillingEvent;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@XmlTransient
|
||||
Ref<PollMessage.Autorenew> autorenewPollMessage;
|
||||
Key<PollMessage.Autorenew> autorenewPollMessage;
|
||||
|
||||
/** The unexpired grace periods for this domain (some of which may not be active yet). */
|
||||
@XmlTransient
|
||||
|
@ -146,12 +145,12 @@ public class DomainResource extends DomainBase implements ForeignKeyedEppResourc
|
|||
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.
|
||||
*/
|
||||
@IgnoreSave(IfNull.class)
|
||||
@XmlTransient
|
||||
Ref<DomainApplication> application;
|
||||
Key<DomainApplication> application;
|
||||
|
||||
public ImmutableSet<String> getSubordinateHosts() {
|
||||
return nullToEmptyImmutableCopy(subordinateHosts);
|
||||
|
@ -165,11 +164,11 @@ public class DomainResource extends DomainBase implements ForeignKeyedEppResourc
|
|||
return deletePollMessage;
|
||||
}
|
||||
|
||||
public Ref<BillingEvent.Recurring> getAutorenewBillingEvent() {
|
||||
public Key<BillingEvent.Recurring> getAutorenewBillingEvent() {
|
||||
return autorenewBillingEvent;
|
||||
}
|
||||
|
||||
public Ref<PollMessage.Autorenew> getAutorenewPollMessage() {
|
||||
public Key<PollMessage.Autorenew> getAutorenewPollMessage() {
|
||||
return autorenewPollMessage;
|
||||
}
|
||||
|
||||
|
@ -185,7 +184,7 @@ public class DomainResource extends DomainBase implements ForeignKeyedEppResourc
|
|||
return applicationTime;
|
||||
}
|
||||
|
||||
public Ref<DomainApplication> getApplication() {
|
||||
public Key<DomainApplication> getApplication() {
|
||||
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.
|
||||
.setAutorenewBillingEvent(transferData.getServerApproveAutorenewEvent())
|
||||
.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.
|
||||
.setGracePeriods(ImmutableSet.of(GracePeriod.create(
|
||||
GracePeriodStatus.TRANSFER,
|
||||
transferExpirationTime.plus(Registry.get(getTld()).getTransferGracePeriodLength()),
|
||||
transferData.getGainingClientId(),
|
||||
Ref.create(transferData.getServerApproveBillingEvent().key()))));
|
||||
transferData.getServerApproveBillingEvent())));
|
||||
// Set all remaining transfer properties.
|
||||
setAutomaticTransferSuccessProperties(builder, transferData);
|
||||
// Finish projecting to now.
|
||||
|
@ -318,7 +317,7 @@ public class DomainResource extends DomainBase implements ForeignKeyedEppResourc
|
|||
GracePeriodStatus.AUTO_RENEW,
|
||||
lastAutorenewTime.plus(Registry.get(getTld()).getAutoRenewGracePeriodLength()),
|
||||
getCurrentSponsorClientId(),
|
||||
Ref.create(autorenewBillingEvent.key())));
|
||||
autorenewBillingEvent));
|
||||
}
|
||||
|
||||
// Remove any grace periods that have expired.
|
||||
|
@ -398,12 +397,12 @@ public class DomainResource extends DomainBase implements ForeignKeyedEppResourc
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder setAutorenewBillingEvent(Ref<BillingEvent.Recurring> autorenewBillingEvent) {
|
||||
public Builder setAutorenewBillingEvent(Key<BillingEvent.Recurring> autorenewBillingEvent) {
|
||||
getInstance().autorenewBillingEvent = autorenewBillingEvent;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setAutorenewPollMessage(Ref<PollMessage.Autorenew> autorenewPollMessage) {
|
||||
public Builder setAutorenewPollMessage(Key<PollMessage.Autorenew> autorenewPollMessage) {
|
||||
getInstance().autorenewPollMessage = autorenewPollMessage;
|
||||
return this;
|
||||
}
|
||||
|
@ -418,7 +417,7 @@ public class DomainResource extends DomainBase implements ForeignKeyedEppResourc
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder setApplication(Ref<DomainApplication> application) {
|
||||
public Builder setApplication(Key<DomainApplication> application) {
|
||||
getInstance().application = application;
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ package google.registry.model.domain;
|
|||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
||||
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.annotation.Embed;
|
||||
import google.registry.model.ImmutableObject;
|
||||
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).
|
||||
*/
|
||||
// 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
|
||||
* 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.
|
||||
Ref<BillingEvent.Recurring> billingEventRecurring = null;
|
||||
Key<BillingEvent.Recurring> billingEventRecurring = null;
|
||||
|
||||
public GracePeriodStatus getType() {
|
||||
// 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.
|
||||
*/
|
||||
|
||||
public Ref<BillingEvent.OneTime> getOneTimeBillingEvent() {
|
||||
public Key<BillingEvent.OneTime> getOneTimeBillingEvent() {
|
||||
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
|
||||
* period is AUTO_RENEW.
|
||||
*/
|
||||
public Ref<BillingEvent.Recurring> getRecurringBillingEvent() {
|
||||
public Key<BillingEvent.Recurring> getRecurringBillingEvent() {
|
||||
return billingEventRecurring;
|
||||
}
|
||||
|
||||
|
@ -101,8 +101,8 @@ public class GracePeriod extends ImmutableObject {
|
|||
GracePeriodStatus type,
|
||||
DateTime expirationTime,
|
||||
String clientId,
|
||||
@Nullable Ref<BillingEvent.OneTime> billingEventOneTime,
|
||||
@Nullable Ref<BillingEvent.Recurring> billingEventRecurring) {
|
||||
@Nullable Key<BillingEvent.OneTime> billingEventOneTime,
|
||||
@Nullable Key<BillingEvent.Recurring> billingEventRecurring) {
|
||||
checkArgument((billingEventOneTime == null) || (billingEventRecurring == null),
|
||||
"A grace period can have at most one billing event");
|
||||
checkArgument((billingEventRecurring != null) == (GracePeriodStatus.AUTO_RENEW.equals(type)),
|
||||
|
@ -127,7 +127,7 @@ public class GracePeriod extends ImmutableObject {
|
|||
GracePeriodStatus type,
|
||||
DateTime expirationTime,
|
||||
String clientId,
|
||||
@Nullable Ref<BillingEvent.OneTime> billingEventOneTime) {
|
||||
@Nullable Key<BillingEvent.OneTime> billingEventOneTime) {
|
||||
return createInternal(type, expirationTime, clientId, billingEventOneTime, null);
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ public class GracePeriod extends ImmutableObject {
|
|||
GracePeriodStatus type,
|
||||
DateTime expirationTime,
|
||||
String clientId,
|
||||
Ref<BillingEvent.Recurring> billingEventRecurring) {
|
||||
Key<BillingEvent.Recurring> billingEventRecurring) {
|
||||
checkArgumentNotNull(billingEventRecurring);
|
||||
return createInternal(type, expirationTime, clientId, null, billingEventRecurring);
|
||||
}
|
||||
|
@ -151,6 +151,6 @@ public class GracePeriod extends ImmutableObject {
|
|||
public static GracePeriod forBillingEvent(
|
||||
GracePeriodStatus type, BillingEvent.OneTime billingEvent) {
|
||||
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;
|
||||
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.annotation.Embed;
|
||||
import com.googlecode.objectify.annotation.Index;
|
||||
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
|
||||
* 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
|
||||
*/
|
||||
|
@ -30,13 +30,13 @@ import google.registry.model.ImmutableObject;
|
|||
public class ReferenceUnion<T extends EppResource> extends ImmutableObject {
|
||||
|
||||
@Index
|
||||
Ref<T> linked;
|
||||
Key<T> linked;
|
||||
|
||||
public Ref<T> getLinked() {
|
||||
public Key<T> getLinked() {
|
||||
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<>();
|
||||
instance.linked = linked;
|
||||
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.union;
|
||||
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.util.CollectionUtils.nullToEmptyImmutableCopy;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
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.Entity;
|
||||
import com.googlecode.objectify.annotation.IgnoreSave;
|
||||
|
@ -88,7 +89,7 @@ public class HostResource extends EppResource implements ForeignKeyedEppResource
|
|||
@Index
|
||||
@IgnoreSave(IfNull.class)
|
||||
@XmlTransient
|
||||
Ref<DomainResource> superordinateDomain;
|
||||
Key<DomainResource> superordinateDomain;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
public Ref<DomainResource> getSuperordinateDomain() {
|
||||
public Key<DomainResource> getSuperordinateDomain() {
|
||||
return superordinateDomain;
|
||||
}
|
||||
|
||||
|
@ -132,7 +133,8 @@ public class HostResource extends EppResource implements ForeignKeyedEppResource
|
|||
} else {
|
||||
// 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.
|
||||
DomainResource domainAtTime = superordinateDomain.get().cloneProjectedAtTime(now);
|
||||
DomainResource domainAtTime = ofy().load().key(superordinateDomain).now()
|
||||
.cloneProjectedAtTime(now);
|
||||
builder.setCurrentSponsorClientId(domainAtTime.getCurrentSponsorClientId());
|
||||
// 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
|
||||
|
@ -192,7 +194,7 @@ public class HostResource extends EppResource implements ForeignKeyedEppResource
|
|||
difference(getInstance().getInetAddresses(), inetAddresses)));
|
||||
}
|
||||
|
||||
public Builder setSuperordinateDomain(Ref<DomainResource> superordinateDomain) {
|
||||
public Builder setSuperordinateDomain(Key<DomainResource> superordinateDomain) {
|
||||
getInstance().superordinateDomain = superordinateDomain;
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ import static google.registry.util.DateTimeUtils.latestOf;
|
|||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.annotation.Cache;
|
||||
import com.googlecode.objectify.annotation.Entity;
|
||||
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.
|
||||
*
|
||||
* <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. */
|
||||
public ImmutableSet<Ref<DomainApplication>> getReferences() {
|
||||
/** Returns a cloned list of all keys on this index. */
|
||||
public ImmutableSet<Key<DomainApplication>> getKeys() {
|
||||
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
|
||||
* for data migrations. You probably want {@link #createUpdatedInstance}.
|
||||
* Creates a DomainApplicationIndex with the specified list of keys. Only use this method for data
|
||||
* migrations. You probably want {@link #createUpdatedInstance}.
|
||||
*/
|
||||
public static DomainApplicationIndex createWithSpecifiedReferences(
|
||||
public static DomainApplicationIndex createWithSpecifiedKeys(
|
||||
String fullyQualifiedDomainName,
|
||||
ImmutableSet<Ref<DomainApplication>> references) {
|
||||
ImmutableSet<Key<DomainApplication>> keys) {
|
||||
checkArgument(!isNullOrEmpty(fullyQualifiedDomainName),
|
||||
"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();
|
||||
instance.fullyQualifiedDomainName = fullyQualifiedDomainName;
|
||||
instance.references = references;
|
||||
instance.references = keys;
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
@ -91,7 +92,7 @@ public class DomainApplicationIndex extends BackupGroupRoot {
|
|||
return ImmutableSet.of();
|
||||
}
|
||||
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());
|
||||
if (app.getDeletionTime().isAfter(forwardedNow)) {
|
||||
apps.add(app.cloneProjectedAtTime(forwardedNow));
|
||||
|
@ -121,9 +122,9 @@ public class DomainApplicationIndex extends BackupGroupRoot {
|
|||
*/
|
||||
public static DomainApplicationIndex createUpdatedInstance(DomainApplication application) {
|
||||
DomainApplicationIndex existing = load(application.getFullyQualifiedDomainName());
|
||||
ImmutableSet<Ref<DomainApplication>> newReferences = CollectionUtils.union(
|
||||
(existing == null ? ImmutableSet.<Ref<DomainApplication>>of() : existing.getReferences()),
|
||||
Ref.create(application));
|
||||
return createWithSpecifiedReferences(application.getFullyQualifiedDomainName(), newReferences);
|
||||
ImmutableSet<Key<DomainApplication>> newKeys = CollectionUtils.union(
|
||||
(existing == null ? ImmutableSet.<Key<DomainApplication>>of() : existing.getKeys()),
|
||||
Key.create(application));
|
||||
return createWithSpecifiedKeys(application.getFullyQualifiedDomainName(), newKeys);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ import static google.registry.util.TypeUtils.instantiate;
|
|||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.annotation.Entity;
|
||||
import com.googlecode.objectify.annotation.Id;
|
||||
import com.googlecode.objectify.annotation.Index;
|
||||
|
@ -36,7 +35,8 @@ public class EppResourceIndex extends BackupGroupRoot {
|
|||
@Parent
|
||||
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
|
||||
String kind;
|
||||
|
@ -49,7 +49,7 @@ public class EppResourceIndex extends BackupGroupRoot {
|
|||
return kind;
|
||||
}
|
||||
|
||||
public Ref<? extends EppResource> getReference() {
|
||||
public Key<? extends EppResource> getKey() {
|
||||
return reference;
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class EppResourceIndex extends BackupGroupRoot {
|
|||
public static <T extends EppResource> EppResourceIndex create(
|
||||
Key<EppResourceIndexBucket> bucket, Key<T> resourceKey) {
|
||||
EppResourceIndex instance = instantiate(EppResourceIndex.class);
|
||||
instance.reference = Ref.create(resourceKey);
|
||||
instance.reference = resourceKey;
|
||||
instance.kind = resourceKey.getKind();
|
||||
instance.id = resourceKey.getString(); // creates a web-safe key string
|
||||
instance.bucket = bucket;
|
||||
|
|
|
@ -23,7 +23,6 @@ import com.google.common.base.Predicate;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.annotation.Cache;
|
||||
import com.googlecode.objectify.annotation.Entity;
|
||||
import com.googlecode.objectify.annotation.Id;
|
||||
|
@ -81,9 +80,10 @@ public abstract class ForeignKeyIndex<E extends EppResource> extends BackupGroup
|
|||
/**
|
||||
* 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() {
|
||||
return foreignKey;
|
||||
|
@ -93,7 +93,7 @@ public abstract class ForeignKeyIndex<E extends EppResource> extends BackupGroup
|
|||
return deletionTime;
|
||||
}
|
||||
|
||||
public Ref<E> getReference() {
|
||||
public Key<E> getResourceKey() {
|
||||
return topReference;
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ public abstract class ForeignKeyIndex<E extends EppResource> extends BackupGroup
|
|||
public static <E extends EppResource> ForeignKeyIndex<E> create(
|
||||
E resource, DateTime deletionTime) {
|
||||
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.deletionTime = deletionTime;
|
||||
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
|
||||
* 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
|
||||
* index
|
||||
*/
|
||||
public static <E extends EppResource> Ref<E> loadAndGetReference(
|
||||
public static <E extends EppResource> Key<E> loadAndGetKey(
|
||||
Class<E> clazz, String foreignKey, DateTime 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<>();
|
||||
Key<? extends BaseDomainLabelList<?, ?>> key = Key.create(this);
|
||||
for (String tld : getTlds()) {
|
||||
if (hasReference(Registry.get(tld), key)) {
|
||||
if (refersToKey(Registry.get(tld), key)) {
|
||||
builder.add(tld);
|
||||
}
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
protected abstract boolean hasReference(
|
||||
protected abstract boolean refersToKey(
|
||||
Registry registry, Key<? extends BaseDomainLabelList<?, ?>> key);
|
||||
|
||||
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
|
||||
public boolean hasReference(Registry registry, Key<? extends BaseDomainLabelList<?, ?>> key) {
|
||||
public boolean refersToKey(Registry registry, Key<? extends BaseDomainLabelList<?, ?>> key) {
|
||||
return Objects.equals(registry.getPremiumList(), key);
|
||||
}
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ public final class ReservedList
|
|||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasReference(Registry registry, Key<? extends BaseDomainLabelList<?, ?>> key) {
|
||||
protected boolean refersToKey(Registry registry, Key<? extends BaseDomainLabelList<?, ?>> key) {
|
||||
return registry.getReservedLists().contains(key);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
package google.registry.model.reporting;
|
||||
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.annotation.Entity;
|
||||
import com.googlecode.objectify.annotation.Id;
|
||||
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.EppResource;
|
||||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.model.ImmutableObject.DoNotHydrate;
|
||||
import google.registry.model.domain.Period;
|
||||
import google.registry.model.eppcommon.Trid;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/** A record of an EPP command that mutated a resource. */
|
||||
@Entity
|
||||
@DoNotHydrate
|
||||
public class HistoryEntry extends ImmutableObject implements Buildable {
|
||||
|
||||
/** Represents the type of history entry. */
|
||||
|
@ -77,7 +78,7 @@ public class HistoryEntry extends ImmutableObject implements Buildable {
|
|||
|
||||
/** The resource this event mutated. */
|
||||
@Parent
|
||||
Ref<? extends EppResource> parent;
|
||||
Key<? extends EppResource> parent;
|
||||
|
||||
/** The type of history entry. */
|
||||
Type type;
|
||||
|
@ -112,7 +113,7 @@ public class HistoryEntry extends ImmutableObject implements Buildable {
|
|||
/** Whether this change was requested by a registrar. */
|
||||
Boolean requestedByRegistrar;
|
||||
|
||||
public Ref<? extends EppResource> getParent() {
|
||||
public Key<? extends EppResource> getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
|
@ -166,12 +167,12 @@ public class HistoryEntry extends ImmutableObject implements Buildable {
|
|||
}
|
||||
|
||||
public Builder setParent(EppResource parent) {
|
||||
getInstance().parent = Ref.create(parent);
|
||||
getInstance().parent = Key.create(parent);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setParent(Key<? extends EppResource> parentKey) {
|
||||
getInstance().parent = Ref.create(parentKey);
|
||||
getInstance().parent = parentKey;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
|
|||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.annotation.Embed;
|
||||
import com.googlecode.objectify.annotation.IgnoreSave;
|
||||
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
|
||||
* pending transfer is explicitly approved, rejected or cancelled, the referenced entities should
|
||||
* 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)
|
||||
Set<Key<? extends TransferServerApproveEntity>> serverApproveEntities;
|
||||
|
@ -62,7 +58,7 @@ public class TransferData extends BaseTransferObject implements Buildable {
|
|||
* being transferred is not a domain.
|
||||
*/
|
||||
@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.
|
||||
|
@ -71,7 +67,7 @@ public class TransferData extends BaseTransferObject implements Buildable {
|
|||
* being transferred is not a domain.
|
||||
*/
|
||||
@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.
|
||||
|
@ -80,7 +76,7 @@ public class TransferData extends BaseTransferObject implements Buildable {
|
|||
* being transferred is not a domain.
|
||||
*/
|
||||
@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). */
|
||||
Trid transferRequestTrid;
|
||||
|
@ -95,15 +91,15 @@ public class TransferData extends BaseTransferObject implements Buildable {
|
|||
return nullToEmptyImmutableCopy(serverApproveEntities);
|
||||
}
|
||||
|
||||
public Ref<BillingEvent.OneTime> getServerApproveBillingEvent() {
|
||||
public Key<BillingEvent.OneTime> getServerApproveBillingEvent() {
|
||||
return serverApproveBillingEvent;
|
||||
}
|
||||
|
||||
public Ref<BillingEvent.Recurring> getServerApproveAutorenewEvent() {
|
||||
public Key<BillingEvent.Recurring> getServerApproveAutorenewEvent() {
|
||||
return serverApproveAutorenewEvent;
|
||||
}
|
||||
|
||||
public Ref<PollMessage.Autorenew> getServerApproveAutorenewPollMessage() {
|
||||
public Key<PollMessage.Autorenew> getServerApproveAutorenewPollMessage() {
|
||||
return serverApproveAutorenewPollMessage;
|
||||
}
|
||||
|
||||
|
@ -138,19 +134,19 @@ public class TransferData extends BaseTransferObject implements Buildable {
|
|||
}
|
||||
|
||||
public Builder setServerApproveBillingEvent(
|
||||
Ref<BillingEvent.OneTime> serverApproveBillingEvent) {
|
||||
Key<BillingEvent.OneTime> serverApproveBillingEvent) {
|
||||
getInstance().serverApproveBillingEvent = serverApproveBillingEvent;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setServerApproveAutorenewEvent(
|
||||
Ref<BillingEvent.Recurring> serverApproveAutorenewEvent) {
|
||||
Key<BillingEvent.Recurring> serverApproveAutorenewEvent) {
|
||||
getInstance().serverApproveAutorenewEvent = serverApproveAutorenewEvent;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setServerApproveAutorenewPollMessage(
|
||||
Ref<PollMessage.Autorenew> serverApproveAutorenewPollMessage) {
|
||||
Key<PollMessage.Autorenew> serverApproveAutorenewPollMessage) {
|
||||
getInstance().serverApproveAutorenewPollMessage = serverApproveAutorenewPollMessage;
|
||||
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.Ordering;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.config.RegistryEnvironment;
|
||||
import google.registry.model.ofy.CommitLogManifest;
|
||||
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:
|
||||
* <ol>
|
||||
* <li>Translating the data into two lists of {@code Date} and {@code Key} objects, in a manner
|
||||
* 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.
|
||||
* </ol>
|
||||
*
|
||||
|
@ -45,7 +45,7 @@ import org.joda.time.DateTime;
|
|||
* @see google.registry.model.EppResource
|
||||
*/
|
||||
public final class CommitLogRevisionsTranslatorFactory
|
||||
extends ImmutableSortedMapTranslatorFactory<DateTime, Ref<CommitLogManifest>> {
|
||||
extends ImmutableSortedMapTranslatorFactory<DateTime, Key<CommitLogManifest>> {
|
||||
|
||||
private static final RegistryEnvironment ENVIRONMENT = RegistryEnvironment.get();
|
||||
|
||||
|
@ -62,14 +62,14 @@ public final class CommitLogRevisionsTranslatorFactory
|
|||
* @see google.registry.config.RegistryConfig#getCommitLogDatastoreRetention()
|
||||
*/
|
||||
@Override
|
||||
ImmutableSortedMap<DateTime, Ref<CommitLogManifest>> transformBeforeSave(
|
||||
ImmutableSortedMap<DateTime, Ref<CommitLogManifest>> revisions) {
|
||||
ImmutableSortedMap<DateTime, Key<CommitLogManifest>> transformBeforeSave(
|
||||
ImmutableSortedMap<DateTime, Key<CommitLogManifest>> revisions) {
|
||||
DateTime now = ofy().getTransactionTime();
|
||||
DateTime threshold = now.minus(ENVIRONMENT.config().getCommitLogDatastoreRetention());
|
||||
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))
|
||||
.put(now, Ref.create(ofy().getCommitLogManifestKey()))
|
||||
.put(now, ofy().getCommitLogManifestKey())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ import com.google.common.collect.FluentIterable;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import google.registry.mapreduce.MapreduceRunner;
|
||||
import google.registry.mapreduce.inputs.EppResourceInputs;
|
||||
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
|
||||
* true for all {@link EppResource} entities and their related indexes:
|
||||
* <ul>
|
||||
* <li>All {@link Key} and {@link Ref} fields (including nested ones) point to entities that
|
||||
* exist.
|
||||
* <li>All {@link Key} fields (including nested ones) point to entities that exist.
|
||||
* <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
|
||||
* 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) {
|
||||
DomainBase domainBase = (DomainBase) resource;
|
||||
Key<?> key = Key.create(domainBase);
|
||||
verifyExistence(key, refsToKeys(domainBase.getReferencedContacts()));
|
||||
verifyExistence(key, refsToKeys(domainBase.getNameservers()));
|
||||
verifyExistence(key, domainBase.getReferencedContacts());
|
||||
verifyExistence(key, domainBase.getNameservers());
|
||||
verifyExistence(key, domainBase.getTransferData().getServerApproveAutorenewEvent());
|
||||
verifyExistence(key, domainBase.getTransferData().getServerApproveAutorenewPollMessage());
|
||||
verifyExistence(key, domainBase.getTransferData().getServerApproveBillingEvent());
|
||||
|
@ -299,7 +297,7 @@ public class VerifyEntityIntegrityAction implements Runnable {
|
|||
private void mapForeignKeyIndex(ForeignKeyIndex<?> fki) {
|
||||
Key<ForeignKeyIndex<?>> fkiKey = Key.<ForeignKeyIndex<?>>create(fki);
|
||||
@SuppressWarnings("cast")
|
||||
EppResource resource = verifyExistence(fkiKey, fki.getReference());
|
||||
EppResource resource = verifyExistence(fkiKey, fki.getResourceKey());
|
||||
if (resource != null) {
|
||||
// TODO(user): Traverse the chain of pointers to old FKIs instead once they are written.
|
||||
if (isAtOrAfter(fki.getDeletionTime(), resource.getDeletionTime())) {
|
||||
|
@ -328,8 +326,8 @@ public class VerifyEntityIntegrityAction implements Runnable {
|
|||
private void mapDomainApplicationIndex(DomainApplicationIndex dai) {
|
||||
getContext().incrementCounter("domain application indexes");
|
||||
Key<DomainApplicationIndex> daiKey = Key.create(dai);
|
||||
for (Ref<DomainApplication> ref : dai.getReferences()) {
|
||||
DomainApplication application = verifyExistence(daiKey, ref);
|
||||
for (Key<DomainApplication> key : dai.getKeys()) {
|
||||
DomainApplication application = verifyExistence(daiKey, key);
|
||||
if (application != null) {
|
||||
integrity().check(
|
||||
dai.getFullyQualifiedDomainName().equals(application.getFullyQualifiedDomainName()),
|
||||
|
@ -347,11 +345,11 @@ public class VerifyEntityIntegrityAction implements Runnable {
|
|||
Key<EppResourceIndex> eriKey = Key.create(eri);
|
||||
String eriRepoId = Key.create(eri.getId()).getName();
|
||||
integrity().check(
|
||||
eriRepoId.equals(eri.getReference().getKey().getName()),
|
||||
eriRepoId.equals(eri.getKey().getName()),
|
||||
eriKey,
|
||||
eri.getReference().getKey(),
|
||||
eri.getKey(),
|
||||
"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);
|
||||
getContext().incrementCounter("EPP resource indexes to " + eri.getKind());
|
||||
}
|
||||
|
@ -366,14 +364,6 @@ public class VerifyEntityIntegrityAction implements Runnable {
|
|||
"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
|
||||
private <E> E verifyExistence(Key<?> source, @Nullable Key<E> target) {
|
||||
if (target == null) {
|
||||
|
@ -383,17 +373,6 @@ public class VerifyEntityIntegrityAction implements Runnable {
|
|||
integrity().check(entity != null, source, target, "Target entity does not exist");
|
||||
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. */
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
package google.registry.rdap;
|
||||
|
||||
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.request.Action.Method.GET;
|
||||
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.primitives.Booleans;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.cmd.Query;
|
||||
import com.googlecode.objectify.cmd.QueryKeys;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.rdap.RdapJsonFormatter.BoilerplateType;
|
||||
|
@ -164,31 +162,25 @@ public class RdapDomainSearchAction extends RdapActionBase {
|
|||
private ImmutableList<ImmutableMap<String, Object>>
|
||||
searchByNameserverLdhName(final RdapSearchPattern partialStringQuery, final DateTime now)
|
||||
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.
|
||||
if (!partialStringQuery.getHasWildcard()) {
|
||||
Ref<HostResource> hostRef = loadAndGetReference(
|
||||
Key<HostResource> hostKey = loadAndGetKey(
|
||||
HostResource.class, partialStringQuery.getInitialString(), now);
|
||||
if (hostRef == null) {
|
||||
if (hostKey == null) {
|
||||
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
|
||||
// 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
|
||||
// deletes for hosts, so we can call queryUndeleted.
|
||||
} else if (partialStringQuery.getSuffix() == null) {
|
||||
// TODO (b/24463238): figure out how to limit the size of these queries effectively
|
||||
Query<HostResource> query = queryUndeleted(
|
||||
HostResource.class,
|
||||
"fullyQualifiedHostName",
|
||||
partialStringQuery, 1000);
|
||||
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()) {
|
||||
hostKeys =
|
||||
queryUndeleted(HostResource.class, "fullyQualifiedHostName", partialStringQuery, 1000)
|
||||
.keys();
|
||||
if (Iterables.isEmpty(hostKeys)) {
|
||||
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
|
||||
|
@ -200,24 +192,24 @@ public class RdapDomainSearchAction extends RdapActionBase {
|
|||
if (domainResource == null) {
|
||||
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())) {
|
||||
// We can't just check that the host name starts with the initial query string, because then
|
||||
// the query ns.exam*.example.com would match against nameserver ns.example.com.
|
||||
if (partialStringQuery.matches(fqhn)) {
|
||||
Ref<HostResource> hostRef = loadAndGetReference(HostResource.class, fqhn, now);
|
||||
if (hostRef != null) {
|
||||
builder.add(hostRef);
|
||||
Key<HostResource> hostKey = loadAndGetKey(HostResource.class, fqhn, now);
|
||||
if (hostKey != null) {
|
||||
builder.add(hostKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
hostRefs = builder.build();
|
||||
if (hostRefs.isEmpty()) {
|
||||
hostKeys = builder.build();
|
||||
if (Iterables.isEmpty(hostKeys)) {
|
||||
throw new NotFoundException("No matching nameservers found");
|
||||
}
|
||||
}
|
||||
// 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. */
|
||||
|
@ -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
|
||||
// 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.
|
||||
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.
|
||||
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
|
||||
* relevant host refs.
|
||||
* relevant host keys.
|
||||
*/
|
||||
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.
|
||||
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()
|
||||
.type(DomainResource.class)
|
||||
.filter("nameservers.linked in", chunk)
|
||||
|
|
|
@ -417,10 +417,10 @@ public class RdapJsonFormatter {
|
|||
DateTime now) {
|
||||
// Kick off the database loads of the nameservers that we will need.
|
||||
Map<Key<HostResource>, HostResource> loadedHosts =
|
||||
ofy().load().refs(domainResource.getNameservers());
|
||||
ofy().load().keys(domainResource.getNameservers());
|
||||
// And the registrant and other contacts.
|
||||
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.
|
||||
ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>();
|
||||
|
@ -453,8 +453,7 @@ public class RdapJsonFormatter {
|
|||
for (DesignatedContact designatedContact : FluentIterable.from(domainResource.getContacts())
|
||||
.append(DesignatedContact.create(Type.REGISTRANT, domainResource.getRegistrant()))
|
||||
.toSortedList(DESIGNATED_CONTACT_ORDERING)) {
|
||||
ContactResource loadedContact =
|
||||
loadedContacts.get(designatedContact.getContactRef().key());
|
||||
ContactResource loadedContact = loadedContacts.get(designatedContact.getContactKey());
|
||||
entitiesBuilder.add(makeRdapJsonForContact(
|
||||
loadedContact, false, Optional.of(designatedContact.getType()), linkBase, null, now));
|
||||
}
|
||||
|
|
|
@ -14,10 +14,12 @@
|
|||
|
||||
package google.registry.rde;
|
||||
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
|
||||
import com.google.common.base.Ascii;
|
||||
import com.google.common.base.Optional;
|
||||
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.domain.DesignatedContact;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
|
@ -161,9 +163,9 @@ final class DomainResourceToXjcConverter {
|
|||
// o An OPTIONAL <registrant> element that contain the identifier for
|
||||
// the human or organizational social information object associated
|
||||
// as the holder of the domain name object.
|
||||
Ref<ContactResource> registrant = model.getRegistrant();
|
||||
Key<ContactResource> registrant = model.getRegistrant();
|
||||
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
|
||||
|
@ -280,7 +282,7 @@ final class DomainResourceToXjcConverter {
|
|||
/** Converts {@link DesignatedContact} to {@link XjcDomainContactType}. */
|
||||
private static XjcDomainContactType convertDesignatedContact(DesignatedContact model) {
|
||||
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.setValue(contact.getContactId());
|
||||
return bean;
|
||||
|
|
|
@ -136,14 +136,14 @@ final class AllocateDomainCommand extends MutatingEppToolCommand {
|
|||
for (DesignatedContact contact : application.getContacts()) {
|
||||
contactsMapBuilder.put(
|
||||
Ascii.toLowerCase(contact.getType().toString()),
|
||||
contact.getContactRef().get().getForeignKey());
|
||||
ofy().load().key(contact.getContactKey()).now().getForeignKey());
|
||||
}
|
||||
LaunchNotice launchNotice = application.getLaunchNotice();
|
||||
addSoyRecord(application.getCurrentSponsorClientId(), new SoyMapData(
|
||||
"name", application.getFullyQualifiedDomainName(),
|
||||
"period", period.getValue(),
|
||||
"nameservers", application.loadNameserverFullyQualifiedHostNames(),
|
||||
"registrant", application.getRegistrant().get().getForeignKey(),
|
||||
"registrant", ofy().load().key(application.getRegistrant()).now().getForeignKey(),
|
||||
"contacts", contactsMapBuilder.build(),
|
||||
"authInfo", application.getAuthInfo().getPw().getValue(),
|
||||
"smdId", application.getEncodedSignedMarks().isEmpty()
|
||||
|
|
|
@ -101,7 +101,7 @@ final class AuctionStatusCommand implements RemoteApiCommand, GtechCommand {
|
|||
new Function<DomainApplication, String>() {
|
||||
@Override
|
||||
public String apply(DomainApplication app) {
|
||||
ContactResource registrant = checkNotNull(app.getRegistrant().get());
|
||||
ContactResource registrant = checkNotNull(ofy().load().key(app.getRegistrant()).now());
|
||||
Object[] keysAndValues = new Object[] {
|
||||
"Domain", app.getFullyQualifiedDomainName(),
|
||||
"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);
|
||||
stageEntityChange(null, ForeignKeyIndex.create(resource, now));
|
||||
} else {
|
||||
if (fki.getReference().key().equals(key)) {
|
||||
if (fki.getResourceKey().equals(key)) {
|
||||
if (isBeforeOrAt(fki.getDeletionTime(), now)) {
|
||||
System.out.printf("ForeignKeyIndex already deleted for: %s\n", key);
|
||||
} else {
|
||||
|
|
|
@ -172,7 +172,7 @@ final class GenerateApplicationsReportCommand implements RemoteApiCommand, Gtech
|
|||
domainApplication.getEncodedSignedMarks().isEmpty() ? "landrush" : "sunrise",
|
||||
domainApplication.getApplicationStatus(),
|
||||
domainApplication.getCurrentSponsorClientId(),
|
||||
domainApplication.getRegistrant().get().getEmailAddress(),
|
||||
ofy().load().key(domainApplication.getRegistrant()).now().getEmailAddress(),
|
||||
validityMessage);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,7 +114,8 @@ final class GenerateAuctionDataCommand implements RemoteApiCommand, GtechCommand
|
|||
+ "Can't process contending applications for %s because some applications "
|
||||
+ "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));
|
||||
|
||||
// Ensure the registrant's email address is unique across the contending applications.
|
||||
|
|
|
@ -201,7 +201,7 @@ final class GenerateEscrowDepositCommand implements RemoteApiCommand {
|
|||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Key<EppResource> apply(EppResourceIndex index) {
|
||||
return (Key<EppResource>) index.getReference().getKey();
|
||||
return (Key<EppResource>) index.getKey();
|
||||
}}))
|
||||
.values();
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import static com.google.common.base.Strings.nullToEmpty;
|
|||
import static com.google.common.collect.Sets.difference;
|
||||
import static google.registry.model.EppResourceUtils.checkResourcesExist;
|
||||
import static google.registry.model.EppResourceUtils.loadByUniqueId;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
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.ImmutableSortedSet;
|
||||
import com.google.template.soy.data.SoyMapData;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.secdns.DelegationSignerData;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
|
@ -147,8 +147,8 @@ final class UniformRapidSuspensionCommand extends MutatingEppToolCommand impleme
|
|||
|
||||
private ImmutableSortedSet<String> getExistingNameservers(DomainResource domain) {
|
||||
ImmutableSortedSet.Builder<String> nameservers = ImmutableSortedSet.naturalOrder();
|
||||
for (Ref<HostResource> nameserverRef : domain.getNameservers()) {
|
||||
nameservers.add(nameserverRef.get().getForeignKey());
|
||||
for (HostResource host : ofy().load().keys(domain.getNameservers()).values()) {
|
||||
nameservers.add(host.getForeignKey());
|
||||
}
|
||||
return nameservers.build();
|
||||
}
|
||||
|
|
|
@ -272,7 +272,7 @@ public class GenerateZoneFilesAction implements Runnable, JsonActionRunner.JsonA
|
|||
*/
|
||||
private static String domainStanza(DomainResource domain, DateTime exportTime) {
|
||||
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(
|
||||
NS_FORMAT,
|
||||
domain.getFullyQualifiedDomainName(),
|
||||
|
|
|
@ -81,7 +81,7 @@ public class KillAllEppResourcesAction implements Runnable {
|
|||
public void map(final EppResourceIndex eri) {
|
||||
Key<EppResourceIndex> eriKey = Key.create(eri);
|
||||
emitAndIncrementCounter(eriKey, eriKey);
|
||||
Key<?> resourceKey = eri.getReference().getKey();
|
||||
Key<?> resourceKey = eri.getKey();
|
||||
for (Key<Object> key : ofy().load().ancestor(resourceKey).keys()) {
|
||||
emitAndIncrementCounter(resourceKey, key);
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ public class KillAllEppResourcesAction implements Runnable {
|
|||
new Work<EppResource>() {
|
||||
@Override
|
||||
public EppResource run() {
|
||||
return eri.getReference().get();
|
||||
return ofy().load().key(eri.getKey()).now();
|
||||
}});
|
||||
// TODO(b/28247733): What about FKI's for renamed hosts?
|
||||
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.collect.Iterables.tryFind;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.util.CollectionUtils.isNullOrEmpty;
|
||||
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.Predicate;
|
||||
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.ContactResource;
|
||||
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. */
|
||||
@Nullable
|
||||
private Ref<ContactResource> getContactReference(final Type type) {
|
||||
private Key<ContactResource> getContactReference(final Type type) {
|
||||
Optional<DesignatedContact> contactOfType = tryFind(domain.getContacts(),
|
||||
new Predicate<DesignatedContact>() {
|
||||
@Override
|
||||
public boolean apply(DesignatedContact d) {
|
||||
return d.getType() == type;
|
||||
}});
|
||||
return contactOfType.isPresent() ? contactOfType.get().getContactRef() : null;
|
||||
return contactOfType.isPresent() ? contactOfType.get().getContactKey() : null;
|
||||
}
|
||||
|
||||
/** Output emitter with logic for domains. */
|
||||
|
@ -123,7 +124,7 @@ final class DomainWhoisResponse extends WhoisResponseImpl {
|
|||
/** Emit the contact entry of the given type. */
|
||||
DomainEmitter emitContact(
|
||||
String contactType,
|
||||
@Nullable Ref<ContactResource> contact,
|
||||
@Nullable Key<ContactResource> contact,
|
||||
boolean preferUnicode) {
|
||||
if (contact == null) {
|
||||
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
|
||||
// has somehow been broken. We skip the rest of this contact, but log it to hopefully bring it
|
||||
// someone's attention.
|
||||
ContactResource contactResource = contact.get();
|
||||
ContactResource contactResource = ofy().load().key(contact).now();
|
||||
if (contactResource == null) {
|
||||
logger.severefmt("(BUG) Broken reference found from domain %s to contact %s",
|
||||
domain.getFullyQualifiedDomainName(), contact);
|
||||
|
|
|
@ -37,7 +37,7 @@ import com.google.common.collect.ImmutableMap;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
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.model.domain.DomainResource;
|
||||
import google.registry.model.domain.secdns.DelegationSignerData;
|
||||
|
@ -285,9 +285,9 @@ public class CloudDnsWriterTest {
|
|||
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) {
|
||||
hostResourceRefBuilder.add(Ref.create(nameserver));
|
||||
hostResourceRefBuilder.add(Key.create(nameserver));
|
||||
}
|
||||
|
||||
return newDomainResource(domainName)
|
||||
|
|
|
@ -34,7 +34,7 @@ import com.google.common.base.VerifyException;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
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.secdns.DelegationSignerData;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
|
@ -107,7 +107,7 @@ public class DnsUpdateWriterTest {
|
|||
DomainResource domain =
|
||||
persistActiveDomain("example.tld")
|
||||
.asBuilder()
|
||||
.setNameservers(ImmutableSet.of(Ref.create(host1), Ref.create(host2)))
|
||||
.setNameservers(ImmutableSet.of(Key.create(host1), Key.create(host2)))
|
||||
.build();
|
||||
persistResource(domain);
|
||||
|
||||
|
@ -126,7 +126,7 @@ public class DnsUpdateWriterTest {
|
|||
DomainResource domain =
|
||||
persistActiveDomain("example.tld")
|
||||
.asBuilder()
|
||||
.setNameservers(ImmutableSet.of(Ref.create(persistActiveHost("ns1.example.tld"))))
|
||||
.setNameservers(ImmutableSet.of(Key.create(persistActiveHost("ns1.example.tld"))))
|
||||
.setDsData(
|
||||
ImmutableSet.of(
|
||||
DelegationSignerData.create(1, 3, 1, base16().decode("0123456789ABCDEF"))))
|
||||
|
@ -150,7 +150,7 @@ public class DnsUpdateWriterTest {
|
|||
persistActiveDomain("example.tld")
|
||||
.asBuilder()
|
||||
.addStatusValue(StatusValue.SERVER_HOLD)
|
||||
.setNameservers(ImmutableSet.of(Ref.create(persistActiveHost("ns1.example.tld"))))
|
||||
.setNameservers(ImmutableSet.of(Key.create(persistActiveHost("ns1.example.tld"))))
|
||||
.build();
|
||||
persistResource(domain);
|
||||
|
||||
|
@ -192,7 +192,7 @@ public class DnsUpdateWriterTest {
|
|||
newDomainResource("example.tld")
|
||||
.asBuilder()
|
||||
.addSubordinateHost("ns1.example.tld")
|
||||
.addNameservers(ImmutableSet.of(Ref.create(host)))
|
||||
.addNameservers(ImmutableSet.of(Key.create(host)))
|
||||
.build());
|
||||
|
||||
writer.publishHost("ns1.example.tld");
|
||||
|
@ -229,7 +229,7 @@ public class DnsUpdateWriterTest {
|
|||
persistResource(
|
||||
persistActiveDomain("example.tld")
|
||||
.asBuilder()
|
||||
.setNameservers(ImmutableSet.of(Ref.create(persistActiveHost("ns1.example.com"))))
|
||||
.setNameservers(ImmutableSet.of(Key.create(persistActiveHost("ns1.example.com"))))
|
||||
.build());
|
||||
|
||||
writer.publishHost("ns1.example.tld");
|
||||
|
@ -262,7 +262,7 @@ public class DnsUpdateWriterTest {
|
|||
.asBuilder()
|
||||
.addSubordinateHost("ns1.example.tld")
|
||||
.addNameservers(
|
||||
ImmutableSet.of(Ref.create(externalNameserver), Ref.create(inBailiwickNameserver)))
|
||||
ImmutableSet.of(Key.create(externalNameserver), Key.create(inBailiwickNameserver)))
|
||||
.build());
|
||||
|
||||
writer.publishDomain("example.tld");
|
||||
|
@ -296,7 +296,7 @@ public class DnsUpdateWriterTest {
|
|||
.asBuilder()
|
||||
.addSubordinateHost("ns1.example.tld")
|
||||
.addSubordinateHost("foo.example.tld")
|
||||
.addNameservers(ImmutableSet.of(Ref.create(inBailiwickNameserver)))
|
||||
.addNameservers(ImmutableSet.of(Key.create(inBailiwickNameserver)))
|
||||
.build());
|
||||
|
||||
writer.publishDomain("example.tld");
|
||||
|
@ -318,7 +318,7 @@ public class DnsUpdateWriterTest {
|
|||
DomainResource domain =
|
||||
persistActiveDomain("example.tld")
|
||||
.asBuilder()
|
||||
.setNameservers(ImmutableSet.of(Ref.create(persistActiveHost("ns1.example.tld"))))
|
||||
.setNameservers(ImmutableSet.of(Key.create(persistActiveHost("ns1.example.tld"))))
|
||||
.build();
|
||||
persistResource(domain);
|
||||
when(mockResolver.send(any(Message.class))).thenReturn(messageWithResponseCode(Rcode.SERVFAIL));
|
||||
|
|
|
@ -186,7 +186,7 @@ public class SyncRegistrarsSheetTest {
|
|||
.setEmailAddress("pride@example.net")
|
||||
.setTypes(ImmutableSet.of(RegistrarContact.Type.TECH))
|
||||
.build());
|
||||
// Use registrar ref for contacts' parent.
|
||||
// Use registrar key for contacts' parent.
|
||||
persistSimpleResources(contacts);
|
||||
persistResource(registrar);
|
||||
|
||||
|
|
|
@ -146,8 +146,8 @@ public class EppCommitLogsTest extends ShardableTestCase {
|
|||
.isEqualTo(domainAfterCreate);
|
||||
|
||||
// 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
|
||||
// rolled forward. So we have to fall back to the last revision before midnight.
|
||||
// key to the first update should have been overwritten by the second, and its timestamp rolled
|
||||
// forward. So we have to fall back to the last revision before midnight.
|
||||
ofy().clearSessionCache();
|
||||
assertThat(loadAtPointInTime(latest, timeAtFirstUpdate).now())
|
||||
.isEqualTo(domainAfterCreate);
|
||||
|
|
|
@ -224,10 +224,11 @@ public abstract class FlowTestCase<F extends Flow> extends ShardableTestCase {
|
|||
assertThat(gracePeriod.hasBillingEvent())
|
||||
.named("Billing event is present for grace period: " + gracePeriod)
|
||||
.isTrue();
|
||||
return firstNonNull(
|
||||
gracePeriod.getOneTimeBillingEvent(),
|
||||
gracePeriod.getRecurringBillingEvent())
|
||||
.get();
|
||||
return ofy().load()
|
||||
.key(firstNonNull(
|
||||
gracePeriod.getOneTimeBillingEvent(),
|
||||
gracePeriod.getRecurringBillingEvent()))
|
||||
.now();
|
||||
}};
|
||||
assertThat(canonicalizeGracePeriods(Maps.toMap(actual, gracePeriodExpander)))
|
||||
.isEqualTo(canonicalizeGracePeriods(expected));
|
||||
|
|
|
@ -128,7 +128,8 @@ public abstract class ResourceFlowTestCase<F extends Flow, R extends EppResource
|
|||
.filter(new Predicate<EppResourceIndex>() {
|
||||
@Override
|
||||
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();
|
||||
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.Iterables;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import google.registry.model.contact.ContactAddress;
|
||||
import google.registry.model.contact.ContactPhoneNumber;
|
||||
import google.registry.model.contact.ContactResource;
|
||||
|
@ -75,7 +74,7 @@ public class DeleteContactResourceActionTest
|
|||
assertAboutContacts().that(contactUsed).doesNotHaveStatusValue(StatusValue.PENDING_DELETE)
|
||||
.and().hasDeletionTime(END_OF_TIME);
|
||||
domain = loadByUniqueId(DomainResource.class, "example.tld", now);
|
||||
assertThat(domain.getReferencedContacts()).contains(Ref.create(contactUsed));
|
||||
assertThat(domain.getReferencedContacts()).contains(Key.create(contactUsed));
|
||||
HistoryEntry historyEntry =
|
||||
getOnlyHistoryEntryOfType(contactUsed, HistoryEntry.Type.CONTACT_DELETE_FAILURE);
|
||||
assertPollMessageFor(
|
||||
|
|
|
@ -28,7 +28,6 @@ import static google.registry.testing.DatastoreHelper.persistResource;
|
|||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import google.registry.mapreduce.MapreduceRunner;
|
||||
import google.registry.model.contact.ContactResource;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
|
@ -81,7 +80,7 @@ public abstract class DeleteEppResourceActionTestCase<T extends DeleteEppResourc
|
|||
hostUsed = persistActiveHost("ns1.example.tld");
|
||||
domain = persistResource(
|
||||
newDomainResource("example.tld", contactUsed).asBuilder()
|
||||
.setNameservers(ImmutableSet.of(Ref.create(hostUsed)))
|
||||
.setNameservers(ImmutableSet.of(Key.create(hostUsed)))
|
||||
.build());
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
|||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.host.HostResource;
|
||||
|
@ -64,7 +63,7 @@ public class DeleteHostResourceActionTest
|
|||
assertAboutHosts().that(hostUsed).doesNotHaveStatusValue(StatusValue.PENDING_DELETE)
|
||||
.and().hasDeletionTime(END_OF_TIME);
|
||||
domain = loadByUniqueId(DomainResource.class, "example.tld", now);
|
||||
assertThat(domain.getNameservers()).contains(Ref.create(hostUsed));
|
||||
assertThat(domain.getNameservers()).contains(Key.create(hostUsed));
|
||||
HistoryEntry historyEntry =
|
||||
getOnlyHistoryEntryOfType(hostUsed, HistoryEntry.Type.HOST_DELETE_FAILURE);
|
||||
assertPollMessageFor(
|
||||
|
@ -126,7 +125,7 @@ public class DeleteHostResourceActionTest
|
|||
persistResource(
|
||||
hostUnused.asBuilder()
|
||||
.addStatusValue(StatusValue.PENDING_DELETE)
|
||||
.setSuperordinateDomain(Ref.create(domain))
|
||||
.setSuperordinateDomain(Key.create(domain))
|
||||
.build());
|
||||
runMapreduceWithKeyParam(Key.create(hostUnused).getString());
|
||||
// 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.collect.ImmutableSet;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import google.registry.dns.DnsQueue;
|
||||
import google.registry.mapreduce.MapreduceRunner;
|
||||
import google.registry.model.host.HostResource;
|
||||
|
@ -74,21 +73,21 @@ public class DnsRefreshForHostRenameActionTest
|
|||
@Test
|
||||
public void testSuccess_dnsUpdateEnqueued() throws Exception {
|
||||
createTld("tld");
|
||||
Ref<HostResource> renamedHostRef = Ref.create(persistActiveHost("ns1.example.tld"));
|
||||
Ref<HostResource> otherHostRef = Ref.create(persistActiveHost("ns2.example.tld"));
|
||||
Key<HostResource> renamedHostKey = Key.create(persistActiveHost("ns1.example.tld"));
|
||||
Key<HostResource> otherHostKey = Key.create(persistActiveHost("ns2.example.tld"));
|
||||
persistResource(newDomainApplication("notadomain.tld").asBuilder()
|
||||
.setNameservers(ImmutableSet.of(renamedHostRef))
|
||||
.setNameservers(ImmutableSet.of(renamedHostKey))
|
||||
.build());
|
||||
persistResource(newDomainResource("example.tld").asBuilder()
|
||||
.setNameservers(ImmutableSet.of(renamedHostRef))
|
||||
.setNameservers(ImmutableSet.of(renamedHostKey))
|
||||
.build());
|
||||
persistResource(newDomainResource("otherexample.tld").asBuilder()
|
||||
.setNameservers(ImmutableSet.of(renamedHostRef))
|
||||
.setNameservers(ImmutableSet.of(renamedHostKey))
|
||||
.build());
|
||||
persistResource(newDomainResource("untouched.tld").asBuilder()
|
||||
.setNameservers(ImmutableSet.of(otherHostRef))
|
||||
.setNameservers(ImmutableSet.of(otherHostKey))
|
||||
.build());
|
||||
runMapreduce(renamedHostRef.getKey().getString());
|
||||
runMapreduce(renamedHostKey.getString());
|
||||
verify(dnsQueue).addDomainRefreshTask("example.tld");
|
||||
verify(dnsQueue).addDomainRefreshTask("otherexample.tld");
|
||||
verifyNoMoreInteractions(dnsQueue);
|
||||
|
@ -97,12 +96,12 @@ public class DnsRefreshForHostRenameActionTest
|
|||
@Test
|
||||
public void testSuccess_noDnsTasksForDeletedDomain() throws Exception {
|
||||
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()
|
||||
.setNameservers(ImmutableSet.of(renamedHostRef))
|
||||
.setNameservers(ImmutableSet.of(renamedHostKey))
|
||||
.setDeletionTime(START_OF_TIME)
|
||||
.build());
|
||||
runMapreduce(renamedHostRef.getKey().getString());
|
||||
runMapreduce(renamedHostKey.getString());
|
||||
verifyZeroInteractions(dnsQueue);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ package google.registry.flows.domain;
|
|||
import static com.google.common.io.BaseEncoding.base16;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
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.createTld;
|
||||
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.ImmutableMap;
|
||||
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.ResourceFlowTestCase;
|
||||
import google.registry.flows.domain.DomainAllocateFlow.HasFinalStatusException;
|
||||
|
@ -208,11 +209,11 @@ public class DomainAllocateFlowTest
|
|||
CLIENT_ID,
|
||||
null),
|
||||
createBillingEvent));
|
||||
assertThat(domain.getAutorenewBillingEvent().get().getEventTime())
|
||||
assertThat(ofy().load().key(domain.getAutorenewBillingEvent()).now().getEventTime())
|
||||
.isEqualTo(domain.getRegistrationExpirationTime());
|
||||
|
||||
assertThat(domain.getApplicationTime()).isEqualTo(APPLICATION_TIME);
|
||||
assertThat(domain.getApplication()).isEqualTo(Ref.create(application));
|
||||
assertThat(domain.getApplication()).isEqualTo(Key.create(application));
|
||||
if (nameservers == 0) {
|
||||
assertNoDnsTasksEnqueued();
|
||||
} else {
|
||||
|
|
|
@ -26,7 +26,7 @@ import static google.registry.testing.DatastoreHelper.persistResource;
|
|||
import static google.registry.testing.GenericEppResourceSubject.assertAboutEppResources;
|
||||
|
||||
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.ResourceFlow.BadCommandForRegistryPhaseException;
|
||||
import google.registry.flows.ResourceFlowTestCase;
|
||||
|
@ -85,10 +85,10 @@ public class DomainApplicationDeleteFlowTest
|
|||
persistResource(newDomainApplication("example.tld").asBuilder()
|
||||
.setRepoId("1-TLD")
|
||||
.setRegistrant(
|
||||
Ref.create(
|
||||
Key.create(
|
||||
loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc())))
|
||||
.setNameservers(ImmutableSet.of(
|
||||
Ref.create(
|
||||
Key.create(
|
||||
loadByUniqueId(HostResource.class, "ns1.example.net", clock.nowUtc()))))
|
||||
.build());
|
||||
doSuccessfulTest();
|
||||
|
|
|
@ -25,7 +25,7 @@ import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
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.ResourceFlowUtils.ResourceNotOwnedException;
|
||||
import google.registry.flows.ResourceQueryFlow.ResourceToQueryDoesNotExistException;
|
||||
|
@ -87,12 +87,12 @@ public class DomainApplicationInfoFlowTest
|
|||
.setCreationTimeForTest(DateTime.parse("1999-04-03T22:00:00.0Z"))
|
||||
.setLastEppUpdateTime(DateTime.parse("1999-12-03T09:00:00.0Z"))
|
||||
.setLastTransferTime(DateTime.parse("2000-04-08T09:00:00.0Z"))
|
||||
.setRegistrant(Ref.create(registrant))
|
||||
.setRegistrant(Key.create(registrant))
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.ADMIN, Ref.create(contact)),
|
||||
DesignatedContact.create(Type.TECH, Ref.create(contact))))
|
||||
DesignatedContact.create(Type.ADMIN, Key.create(contact)),
|
||||
DesignatedContact.create(Type.TECH, Key.create(contact))))
|
||||
.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")))
|
||||
.addStatusValue(StatusValue.PENDING_CREATE)
|
||||
.setApplicationStatus(ApplicationStatus.PENDING_VALIDATION)
|
||||
|
@ -242,7 +242,7 @@ public class DomainApplicationInfoFlowTest
|
|||
.setDsData(ImmutableSet.of(DelegationSignerData.create(
|
||||
12345, 3, 1, base16().decode("49FD46E6C4B45C55D4AC"))))
|
||||
.setNameservers(ImmutableSet.of(
|
||||
Ref.create(host1), Ref.create(host2)))
|
||||
Key.create(host1), Key.create(host2)))
|
||||
.build());
|
||||
doSuccessfulTest("domain_info_sunrise_response_dsdata.xml", HostsState.NO_HOSTS_EXIST);
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ public class DomainApplicationInfoFlowTest
|
|||
.setRepoId("123-COM")
|
||||
.setFullyQualifiedDomainName("timber.com")
|
||||
.setDeletionTime(DateTime.now().minusDays(1))
|
||||
.setRegistrant(Ref.create(persistActiveContact("jd1234")))
|
||||
.setRegistrant(Key.create(persistActiveContact("jd1234")))
|
||||
.build());
|
||||
runFlow();
|
||||
}
|
||||
|
@ -296,7 +296,7 @@ public class DomainApplicationInfoFlowTest
|
|||
persistResource(new DomainApplication.Builder()
|
||||
.setRepoId("123-TLD")
|
||||
.setFullyQualifiedDomainName("invalid.tld")
|
||||
.setRegistrant(Ref.create(persistActiveContact("jd1234")))
|
||||
.setRegistrant(Key.create(persistActiveContact("jd1234")))
|
||||
.setPhase(LaunchPhase.SUNRUSH)
|
||||
.build());
|
||||
runFlow();
|
||||
|
|
|
@ -29,7 +29,7 @@ import static google.registry.testing.DomainApplicationSubject.assertAboutApplic
|
|||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
|
||||
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.ResourceFlowTestCase;
|
||||
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
|
||||
|
@ -104,9 +104,9 @@ public class DomainApplicationUpdateFlowTest
|
|||
private DomainApplication persistApplication() throws Exception {
|
||||
return persistResource(newApplicationBuilder()
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.TECH, Ref.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.ADMIN, Ref.create(unusedContact))))
|
||||
.setNameservers(ImmutableSet.of(Ref.create(
|
||||
DesignatedContact.create(Type.TECH, Key.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.ADMIN, Key.create(unusedContact))))
|
||||
.setNameservers(ImmutableSet.of(Key.create(
|
||||
loadByUniqueId(HostResource.class, "ns1.example.tld", clock.nowUtc()))))
|
||||
.build());
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ public class DomainApplicationUpdateFlowTest
|
|||
persistReferencedEntities();
|
||||
ContactResource sh8013 = loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc());
|
||||
persistResource(
|
||||
newApplicationBuilder().setRegistrant(Ref.create(sh8013)).build());
|
||||
newApplicationBuilder().setRegistrant(Key.create(sh8013)).build());
|
||||
clock.advanceOneMilli();
|
||||
runFlowAssertResponse(readFile("domain_update_response.xml"));
|
||||
}
|
||||
|
@ -180,13 +180,13 @@ public class DomainApplicationUpdateFlowTest
|
|||
setEppInput("domain_update_sunrise_remove_multiple_contacts.xml");
|
||||
persistReferencedEntities();
|
||||
ContactResource sh8013 = loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc());
|
||||
Ref<ContactResource> sh8013Ref = Ref.create(sh8013);
|
||||
Key<ContactResource> sh8013Key = Key.create(sh8013);
|
||||
persistResource(newApplicationBuilder()
|
||||
.setRegistrant(sh8013Ref)
|
||||
.setRegistrant(sh8013Key)
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.ADMIN, sh8013Ref),
|
||||
DesignatedContact.create(Type.BILLING, sh8013Ref),
|
||||
DesignatedContact.create(Type.TECH, sh8013Ref)))
|
||||
DesignatedContact.create(Type.ADMIN, sh8013Key),
|
||||
DesignatedContact.create(Type.BILLING, sh8013Key),
|
||||
DesignatedContact.create(Type.TECH, sh8013Key)))
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
runFlowAssertResponse(readFile("domain_update_response.xml"));
|
||||
|
@ -369,10 +369,10 @@ public class DomainApplicationUpdateFlowTest
|
|||
}
|
||||
|
||||
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++) {
|
||||
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())));
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
// to add "mak21" as a second tech contact.
|
||||
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());
|
||||
runFlow();
|
||||
}
|
||||
|
@ -576,7 +576,7 @@ public class DomainApplicationUpdateFlowTest
|
|||
setEppInput("domain_update_sunrise_add_remove_same_host.xml");
|
||||
persistReferencedEntities();
|
||||
persistResource(newApplicationBuilder()
|
||||
.setNameservers(ImmutableSet.of(Ref.create(
|
||||
.setNameservers(ImmutableSet.of(Key.create(
|
||||
loadByUniqueId(HostResource.class, "ns1.example.tld", clock.nowUtc()))))
|
||||
.build());
|
||||
runFlow();
|
||||
|
@ -590,7 +590,7 @@ public class DomainApplicationUpdateFlowTest
|
|||
persistResource(newApplicationBuilder()
|
||||
.setContacts(ImmutableSet.of(DesignatedContact.create(
|
||||
Type.TECH,
|
||||
Ref.create(
|
||||
Key.create(
|
||||
loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc())))))
|
||||
.build());
|
||||
runFlow();
|
||||
|
@ -603,8 +603,8 @@ public class DomainApplicationUpdateFlowTest
|
|||
persistReferencedEntities();
|
||||
persistResource(newApplicationBuilder()
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.ADMIN, Ref.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.TECH, Ref.create(sh8013Contact))))
|
||||
DesignatedContact.create(Type.ADMIN, Key.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.TECH, Key.create(sh8013Contact))))
|
||||
.build());
|
||||
runFlow();
|
||||
}
|
||||
|
@ -616,8 +616,8 @@ public class DomainApplicationUpdateFlowTest
|
|||
persistReferencedEntities();
|
||||
persistResource(newApplicationBuilder()
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.ADMIN, Ref.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.TECH, Ref.create(sh8013Contact))))
|
||||
DesignatedContact.create(Type.ADMIN, Key.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.TECH, Key.create(sh8013Contact))))
|
||||
.build());
|
||||
runFlow();
|
||||
}
|
||||
|
|
|
@ -181,7 +181,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
|||
: null;
|
||||
HistoryEntry historyEntry = getHistoryEntries(domain).get(0);
|
||||
assertAboutDomains().that(domain)
|
||||
.hasRegistrationExpirationTime(domain.getAutorenewBillingEvent().get().getEventTime()).and()
|
||||
.hasRegistrationExpirationTime(
|
||||
ofy().load().key(domain.getAutorenewBillingEvent()).now().getEventTime()).and()
|
||||
.hasOnlyOneHistoryEntryWhich()
|
||||
.hasType(HistoryEntry.Type.DOMAIN_CREATE).and()
|
||||
.hasPeriodYears(2);
|
||||
|
|
|
@ -42,7 +42,6 @@ import com.google.common.collect.ImmutableSet;
|
|||
import com.google.common.collect.ImmutableSortedMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import google.registry.flows.EppRequestSource;
|
||||
import google.registry.flows.ResourceCreateOrMutateFlow.OnlyToolCanPassMetadataException;
|
||||
import google.registry.flows.ResourceFlowTestCase;
|
||||
|
@ -111,8 +110,8 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
|||
PollMessage.Autorenew autorenewPollMessage = persistResource(
|
||||
createAutorenewPollMessage("TheRegistrar").build());
|
||||
domain = persistResource(domain.asBuilder()
|
||||
.setAutorenewBillingEvent(Ref.create(autorenewBillingEvent))
|
||||
.setAutorenewPollMessage(Ref.create(autorenewPollMessage))
|
||||
.setAutorenewBillingEvent(Key.create(autorenewBillingEvent))
|
||||
.setAutorenewPollMessage(Key.create(autorenewPollMessage))
|
||||
.build());
|
||||
assertTransactionalFlow(true);
|
||||
}
|
||||
|
@ -122,7 +121,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
|||
ContactResource contact = persistActiveContact("sh8013");
|
||||
domain = newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
||||
.setCreationTimeForTest(TIME_BEFORE_FLOW)
|
||||
.setRegistrant(Ref.create(contact))
|
||||
.setRegistrant(Key.create(contact))
|
||||
.setRegistrationExpirationTime(expirationTime)
|
||||
.build();
|
||||
earlierHistoryEntry = persistResource(
|
||||
|
@ -153,9 +152,9 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
|||
GracePeriodStatus.AUTO_RENEW,
|
||||
A_MONTH_AGO.plusDays(45),
|
||||
"TheRegistrar",
|
||||
Ref.create(autorenewBillingEvent))))
|
||||
.setAutorenewBillingEvent(Ref.create(autorenewBillingEvent))
|
||||
.setAutorenewPollMessage(Ref.create(autorenewPollMessage))
|
||||
Key.create(autorenewBillingEvent))))
|
||||
.setAutorenewBillingEvent(Key.create(autorenewBillingEvent))
|
||||
.setAutorenewPollMessage(Key.create(autorenewPollMessage))
|
||||
.build());
|
||||
assertTransactionalFlow(true);
|
||||
}
|
||||
|
@ -175,7 +174,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
|||
.setClientId("TheRegistrar")
|
||||
.setEventTime(eventTime)
|
||||
.setBillingTime(TIME_BEFORE_FLOW.plusDays(1))
|
||||
.setOneTimeEventRef(Ref.create(graceBillingEvent))
|
||||
.setOneTimeEventKey(Key.create(graceBillingEvent))
|
||||
.setParent(historyEntryDomainDelete)
|
||||
.build());
|
||||
}
|
||||
|
@ -238,7 +237,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
|||
throws Exception {
|
||||
doImmediateDeleteTest(gracePeriodStatus, responseFilename, ImmutableMap.<String, String>of());
|
||||
}
|
||||
|
||||
|
||||
private void doImmediateDeleteTest(
|
||||
GracePeriodStatus gracePeriodStatus,
|
||||
String responseFilename,
|
||||
|
@ -296,7 +295,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
|||
private void doSuccessfulTest_noAddGracePeriod(String responseFilename) throws Exception {
|
||||
doSuccessfulTest_noAddGracePeriod(responseFilename, ImmutableMap.<String, String>of());
|
||||
}
|
||||
|
||||
|
||||
private void doSuccessfulTest_noAddGracePeriod(
|
||||
String responseFilename, Map<String, String> substitutions) throws Exception {
|
||||
// Persist the billing event so it can be retrieved for cancellation generation and checking.
|
||||
|
@ -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
|
||||
// prevent it from being deleted when the domain is deleted.
|
||||
persistResource(
|
||||
reloadResourceByUniqueId().getAutorenewPollMessage().get().asBuilder()
|
||||
ofy().load().key(reloadResourceByUniqueId().getAutorenewPollMessage()).now().asBuilder()
|
||||
.setEventTime(A_MONTH_FROM_NOW.minusYears(3))
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
|
@ -531,9 +530,10 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
|||
assertThat(domain.getTransferData().getServerApproveBillingEvent()).isNull();
|
||||
assertThat(domain.getTransferData().getServerApproveAutorenewEvent()).isNull();
|
||||
assertThat(domain.getTransferData().getServerApproveAutorenewPollMessage()).isNull();
|
||||
assertThat(oldTransferData.getServerApproveBillingEvent().get()).isNull();
|
||||
assertThat(oldTransferData.getServerApproveAutorenewEvent().get()).isNull();
|
||||
assertThat(oldTransferData.getServerApproveAutorenewPollMessage().get()).isNull();
|
||||
assertThat(ofy().load().key(oldTransferData.getServerApproveBillingEvent()).now()).isNull();
|
||||
assertThat(ofy().load().key(oldTransferData.getServerApproveAutorenewEvent()).now()).isNull();
|
||||
assertThat(ofy().load().key(oldTransferData.getServerApproveAutorenewPollMessage()).now())
|
||||
.isNull();
|
||||
assertThat(oldTransferData.getServerApproveEntities()).isNotEmpty(); // Just a sanity check.
|
||||
assertThat(ofy().load()
|
||||
.keys(oldTransferData.getServerApproveEntities().toArray(new Key<?>[]{})))
|
||||
|
@ -554,12 +554,12 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
|||
persistResource(loadByUniqueId(
|
||||
DomainResource.class, getUniqueIdFromCommand(), clock.nowUtc())
|
||||
.asBuilder()
|
||||
.setNameservers(ImmutableSet.of(Ref.create(host)))
|
||||
.setNameservers(ImmutableSet.of(Key.create(host)))
|
||||
.build());
|
||||
// Persist another domain that's already been deleted and references this contact and host.
|
||||
persistResource(newDomainResource("example1.tld").asBuilder()
|
||||
.setRegistrant(Ref.create(loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc())))
|
||||
.setNameservers(ImmutableSet.of(Ref.create(host)))
|
||||
.setRegistrant(Key.create(loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc())))
|
||||
.setNameservers(ImmutableSet.of(Key.create(host)))
|
||||
.setDeletionTime(START_OF_TIME)
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
|
@ -575,7 +575,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
|||
setupSuccessfulTest();
|
||||
persistResource(
|
||||
newHostResource("ns1." + getUniqueIdFromCommand()).asBuilder()
|
||||
.setSuperordinateDomain(Ref.create(reloadResourceByUniqueId()))
|
||||
.setSuperordinateDomain(Key.create(reloadResourceByUniqueId()))
|
||||
.setDeletionTime(clock.nowUtc().minusDays(1))
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
|
@ -607,7 +607,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
|||
DomainResource domain = persistActiveDomain(getUniqueIdFromCommand());
|
||||
HostResource subordinateHost = persistResource(
|
||||
newHostResource("ns1." + getUniqueIdFromCommand()).asBuilder()
|
||||
.setSuperordinateDomain(Ref.create(reloadResourceByUniqueId()))
|
||||
.setSuperordinateDomain(Key.create(reloadResourceByUniqueId()))
|
||||
.build());
|
||||
domain = persistResource(domain.asBuilder()
|
||||
.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.ImmutableSet;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import google.registry.flows.ResourceFlowTestCase;
|
||||
import google.registry.flows.ResourceFlowUtils.BadAuthInfoForResourceException;
|
||||
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"))
|
||||
.setLastTransferTime(DateTime.parse("2000-04-08T09:00:00.0Z"))
|
||||
.setRegistrationExpirationTime(DateTime.parse("2005-04-03T22:00:00.0Z"))
|
||||
.setRegistrant(Ref.create(registrant))
|
||||
.setRegistrant(Key.create(registrant))
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.ADMIN, Ref.create(contact)),
|
||||
DesignatedContact.create(Type.TECH, Ref.create(contact))))
|
||||
.setNameservers(inactive ? null : ImmutableSet.of(Ref.create(host1), Ref.create(host2)))
|
||||
DesignatedContact.create(Type.ADMIN, Key.create(contact)),
|
||||
DesignatedContact.create(Type.TECH, Key.create(contact))))
|
||||
.setNameservers(inactive ? null : ImmutableSet.of(Key.create(host1), Key.create(host2)))
|
||||
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("2fooBAR")))
|
||||
.build());
|
||||
// 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.
|
||||
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.
|
||||
host3 = persistResource(
|
||||
new HostResource.Builder()
|
||||
.setFullyQualifiedHostName("ns2.example.tld")
|
||||
.setRepoId("3FF-TLD")
|
||||
.setSuperordinateDomain(Ref.create(domain))
|
||||
.setSuperordinateDomain(Key.create(domain))
|
||||
.build());
|
||||
// Add the subordinate host references to the existing domain.
|
||||
// Add the subordinate host keys to the existing domain.
|
||||
domain = persistResource(domain.asBuilder()
|
||||
.setSubordinateHosts(ImmutableSet.of(
|
||||
host1.getFullyQualifiedHostName(),
|
||||
|
@ -242,7 +241,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
|
|||
persistResource(domain.asBuilder()
|
||||
.setDsData(ImmutableSet.of(DelegationSignerData.create(
|
||||
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());
|
||||
doSuccessfulTest("domain_info_response_dsdata.xml", false);
|
||||
}
|
||||
|
@ -283,7 +282,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
|
|||
GracePeriodStatus.AUTO_RENEW,
|
||||
clock.nowUtc().plusDays(1),
|
||||
"foo",
|
||||
Ref.create(Key.create(Recurring.class, 12345))))
|
||||
Key.create(Recurring.class, 12345)))
|
||||
.build());
|
||||
doSuccessfulTest("domain_info_response_autorenewperiod.xml", false);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.flows.domain;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
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.createTld;
|
||||
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.ImmutableSet;
|
||||
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.ResourceFlowUtils.ResourceNotOwnedException;
|
||||
import google.registry.flows.ResourceMutateFlow.ResourceToMutateDoesNotExistException;
|
||||
|
@ -116,8 +117,8 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
|
|||
domain = persistResource(domain.asBuilder()
|
||||
.setRegistrationExpirationTime(expirationTime)
|
||||
.setStatusValues(ImmutableSet.copyOf(statusValues))
|
||||
.setAutorenewBillingEvent(Ref.create(autorenewEvent))
|
||||
.setAutorenewPollMessage(Ref.create(autorenewPollMessage))
|
||||
.setAutorenewBillingEvent(Key.create(autorenewEvent))
|
||||
.setAutorenewPollMessage(Key.create(autorenewPollMessage))
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
}
|
||||
|
@ -136,7 +137,8 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
|
|||
DomainResource domain = reloadResourceByUniqueId();
|
||||
HistoryEntry historyEntryDomainRenew =
|
||||
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)
|
||||
.isActiveAt(clock.nowUtc()).and()
|
||||
.hasRegistrationExpirationTime(newExpiration).and()
|
||||
|
@ -345,7 +347,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
|
|||
persistDomain();
|
||||
// Modify the autorenew poll message so that it has an undelivered message in the past.
|
||||
persistResource(
|
||||
reloadResourceByUniqueId().getAutorenewPollMessage().get().asBuilder()
|
||||
ofy().load().key(reloadResourceByUniqueId().getAutorenewPollMessage()).now().asBuilder()
|
||||
.setEventTime(expirationTime.minusYears(1))
|
||||
.build());
|
||||
runFlowAssertResponse(readFile("domain_renew_response.xml"));
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.flows.domain;
|
||||
|
||||
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.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.getOnlyHistoryEntryOfType;
|
||||
|
@ -126,7 +127,7 @@ public class DomainRestoreRequestFlowTest extends
|
|||
DomainResource domain = reloadResourceByUniqueId();
|
||||
HistoryEntry historyEntryDomainRestore =
|
||||
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_RESTORE);
|
||||
assertThat(domain.getAutorenewBillingEvent().get().getEventTime())
|
||||
assertThat(ofy().load().key(domain.getAutorenewBillingEvent()).now().getEventTime())
|
||||
.isEqualTo(clock.nowUtc().plusYears(1));
|
||||
assertAboutDomains().that(domain)
|
||||
// New expiration time should be exactly a year from now.
|
||||
|
@ -386,7 +387,7 @@ public class DomainRestoreRequestFlowTest extends
|
|||
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR)))
|
||||
.setServerStatusChangeBillingCost(Money.of(EUR, 19))
|
||||
.build());
|
||||
runFlow();
|
||||
runFlow();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -16,6 +16,7 @@ package google.registry.flows.domain;
|
|||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
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.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.deleteResource;
|
||||
|
@ -148,7 +149,7 @@ public class DomainTransferApproveFlowTest
|
|||
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_TRANSFER_APPROVE);
|
||||
assertTransferApproved(domain);
|
||||
assertAboutDomains().that(domain).hasRegistrationExpirationTime(expectedExpirationTime);
|
||||
assertThat(domain.getAutorenewBillingEvent().get().getEventTime())
|
||||
assertThat(ofy().load().key(domain.getAutorenewBillingEvent()).now().getEventTime())
|
||||
.isEqualTo(expectedExpirationTime);
|
||||
assertTransferApproved(reloadResourceAndCloneAtTime(subordinateHost, clock.nowUtc()));
|
||||
// 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.
|
||||
.setBillingTime(
|
||||
oldExpirationTime.plus(Registry.get("tld").getAutoRenewGracePeriodLength()))
|
||||
.setRecurringEventRef(domain.getAutorenewBillingEvent()));
|
||||
.setRecurringEventKey(domain.getAutorenewBillingEvent()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -28,7 +28,7 @@ import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
|||
|
||||
import com.google.common.base.Ascii;
|
||||
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.ResourceFlowTestCase;
|
||||
import google.registry.model.EppResource;
|
||||
|
@ -120,14 +120,14 @@ public class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
|
|||
.setCreationClientId("TheRegistrar")
|
||||
.setCreationTimeForTest(DateTime.parse("1999-04-03T22:00:00.0Z"))
|
||||
.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(
|
||||
DesignatedContact.create(
|
||||
Type.ADMIN,
|
||||
Ref.create(loadByUniqueId(ContactResource.class, "jd1234", clock.nowUtc()))),
|
||||
Key.create(loadByUniqueId(ContactResource.class, "jd1234", clock.nowUtc()))),
|
||||
DesignatedContact.create(
|
||||
Type.TECH,
|
||||
Ref.create(loadByUniqueId(ContactResource.class, "jd1234", clock.nowUtc())))))
|
||||
Key.create(loadByUniqueId(ContactResource.class, "jd1234", clock.nowUtc())))))
|
||||
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("fooBAR")))
|
||||
.addGracePeriod(GracePeriod.create(
|
||||
GracePeriodStatus.ADD, clock.nowUtc().plusDays(10), "foo", null))
|
||||
|
@ -163,11 +163,11 @@ public class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
|
|||
.setCurrentSponsorClientId("TheRegistrar")
|
||||
.setCreationClientId("TheRegistrar")
|
||||
.setCreationTimeForTest(DateTime.parse("1999-04-03T22:00:00.0Z"))
|
||||
.setSuperordinateDomain(Ref.create(domain))
|
||||
.setSuperordinateDomain(Key.create(domain))
|
||||
.build());
|
||||
domain = persistResource(domain.asBuilder()
|
||||
.setAutorenewBillingEvent(Ref.create(autorenewEvent))
|
||||
.setAutorenewPollMessage(Ref.create(autorenewPollMessage))
|
||||
.setAutorenewBillingEvent(Key.create(autorenewEvent))
|
||||
.setAutorenewPollMessage(Key.create(autorenewPollMessage))
|
||||
.addSubordinateHost(subordinateHost.getFullyQualifiedHostName())
|
||||
.build());
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.flows.domain;
|
||||
|
||||
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.deleteResource;
|
||||
import static google.registry.testing.DatastoreHelper.getOnlyHistoryEntryOfType;
|
||||
|
@ -192,7 +193,8 @@ public class DomainTransferRequestFlowTest
|
|||
.build())
|
||||
.toArray(BillingEvent.class));
|
||||
// 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.getRecurrenceEndTime()).isEqualTo(implicitTransferTime);
|
||||
// The original grace periods should remain untouched.
|
||||
|
@ -263,8 +265,9 @@ public class DomainTransferRequestFlowTest
|
|||
|
||||
assertAboutDomains().that(domainAfterAutomaticTransfer)
|
||||
.hasRegistrationExpirationTime(expectedExpirationTime);
|
||||
assertThat(domainAfterAutomaticTransfer.getAutorenewBillingEvent().get().getEventTime())
|
||||
.isEqualTo(expectedExpirationTime);
|
||||
assertThat(ofy().load().key(domainAfterAutomaticTransfer.getAutorenewBillingEvent()).now()
|
||||
.getEventTime())
|
||||
.isEqualTo(expectedExpirationTime);
|
||||
// And after the expected grace time, the grace period should be gone.
|
||||
DomainResource afterGracePeriod = domain.cloneProjectedAtTime(
|
||||
clock.nowUtc().plus(Registry.get("tld").getAutomaticTransferLength()).plus(
|
||||
|
@ -315,7 +318,7 @@ public class DomainTransferRequestFlowTest
|
|||
assertTransactionalFlow(true);
|
||||
runFlow(CommitMode.LIVE, userPrivileges);
|
||||
}
|
||||
|
||||
|
||||
private void runTest(String commandFilename, UserPrivileges userPrivileges) throws Exception {
|
||||
runTest(commandFilename, userPrivileges, ImmutableMap.<String, String>of());
|
||||
}
|
||||
|
@ -516,7 +519,7 @@ public class DomainTransferRequestFlowTest
|
|||
.setBillingTime(oldResource.getRegistrationExpirationTime().plus(
|
||||
Registry.get("tld").getAutoRenewGracePeriodLength()))
|
||||
// The cancellation should refer to the old autorenew billing event.
|
||||
.setRecurringEventRef(oldResource.getAutorenewBillingEvent()));
|
||||
.setRecurringEventKey(oldResource.getAutorenewBillingEvent()));
|
||||
}
|
||||
|
||||
@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.truth.Truth.assertThat;
|
||||
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.assertNoBillingEvents;
|
||||
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.ImmutableSet;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import google.registry.flows.EppException.UnimplementedExtensionException;
|
||||
import google.registry.flows.EppRequestSource;
|
||||
import google.registry.flows.ResourceCreateOrMutateFlow.OnlyToolCanPassMetadataException;
|
||||
|
@ -123,9 +123,9 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
DomainResource domain = persistResource(
|
||||
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.TECH, Ref.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.ADMIN, Ref.create(unusedContact))))
|
||||
.setNameservers(ImmutableSet.of(Ref.create(host)))
|
||||
DesignatedContact.create(Type.TECH, Key.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.ADMIN, Key.create(unusedContact))))
|
||||
.setNameservers(ImmutableSet.of(Key.create(host)))
|
||||
.build());
|
||||
historyEntryDomainCreate = persistResource(
|
||||
new HistoryEntry.Builder()
|
||||
|
@ -180,7 +180,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
HistoryEntry historyEntryDomainUpdate =
|
||||
getOnlyHistoryEntryOfType(resource, HistoryEntry.Type.DOMAIN_UPDATE);
|
||||
assertThat(resource.getNameservers()).containsExactly(
|
||||
Ref.create(
|
||||
Key.create(
|
||||
loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc())));
|
||||
BillingEvent.OneTime regularAddBillingEvent = new BillingEvent.OneTime.Builder()
|
||||
.setReason(Reason.CREATE)
|
||||
|
@ -201,7 +201,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
.setClientId("TheRegistrar")
|
||||
.setEventTime(clock.nowUtc())
|
||||
.setBillingTime(sunrushAddBillingEvent.getBillingTime())
|
||||
.setOneTimeEventRef(Ref.create(sunrushAddBillingEvent))
|
||||
.setOneTimeEventKey(Key.create(sunrushAddBillingEvent))
|
||||
.setParent(historyEntryDomainUpdate)
|
||||
.build(),
|
||||
regularAddBillingEvent);
|
||||
|
@ -278,7 +278,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
// serverHold on it.
|
||||
persistResource(
|
||||
reloadResourceByUniqueId().asBuilder()
|
||||
.setNameservers(ImmutableSet.of(Ref.create(
|
||||
.setNameservers(ImmutableSet.of(Key.create(
|
||||
loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc()))))
|
||||
.addGracePeriod(GracePeriod.forBillingEvent(
|
||||
GracePeriodStatus.SUNRUSH_ADD, sunrushAddBillingEvent))
|
||||
|
@ -302,7 +302,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
// serverHold on it.
|
||||
persistResource(
|
||||
reloadResourceByUniqueId().asBuilder()
|
||||
.setNameservers(ImmutableSet.of(Ref.create(
|
||||
.setNameservers(ImmutableSet.of(Key.create(
|
||||
loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc()))))
|
||||
.addGracePeriod(GracePeriod.forBillingEvent(
|
||||
GracePeriodStatus.SUNRUSH_ADD, sunrushAddBillingEvent))
|
||||
|
@ -345,10 +345,10 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
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++) {
|
||||
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())));
|
||||
}
|
||||
}
|
||||
|
@ -374,11 +374,11 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
persistDomain();
|
||||
setEppInput("domain_update_max_everything.xml");
|
||||
// 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++) {
|
||||
HostResource host = persistActiveHost(String.format("max_test_%d.example.tld", i));
|
||||
if (i < 13) {
|
||||
nameservers.add(Ref.create(host));
|
||||
nameservers.add(Key.create(host));
|
||||
}
|
||||
}
|
||||
ImmutableList.Builder<DesignatedContact> contactsBuilder = new ImmutableList.Builder<>();
|
||||
|
@ -386,14 +386,14 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
contactsBuilder.add(
|
||||
DesignatedContact.create(
|
||||
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();
|
||||
persistResource(
|
||||
reloadResourceByUniqueId().asBuilder()
|
||||
.setNameservers(nameservers.build())
|
||||
.setContacts(ImmutableSet.copyOf(contacts.subList(0, 3)))
|
||||
.setRegistrant(contacts.get(3).getContactRef())
|
||||
.setRegistrant(contacts.get(3).getContactKey())
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
assertTransactionalFlow(true);
|
||||
|
@ -406,7 +406,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
assertThat(domain.getNameservers()).hasSize(13);
|
||||
// getContacts does not return contacts of type REGISTRANT, so check these separately.
|
||||
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();
|
||||
assertDnsTasksEnqueued("example.tld");
|
||||
}
|
||||
|
@ -458,19 +459,19 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
domain = persistResource(domain.asBuilder()
|
||||
.addSubordinateHost("ns1.example.tld")
|
||||
.addSubordinateHost("ns2.example.tld")
|
||||
.setNameservers(ImmutableSet.of(Ref.create(
|
||||
.setNameservers(ImmutableSet.of(Key.create(
|
||||
loadByUniqueId(HostResource.class, "ns1.example.tld", clock.nowUtc()))))
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
assertTransactionalFlow(true);
|
||||
runFlowAssertResponse(readFile("domain_update_response.xml"));
|
||||
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");
|
||||
existingHost = loadByUniqueId(HostResource.class, "ns1.example.tld", clock.nowUtc());
|
||||
addedHost = loadByUniqueId(HostResource.class, "ns2.example.tld", clock.nowUtc());
|
||||
assertThat(existingHost.getSuperordinateDomain()).isEqualTo(Ref.create(Key.create(domain)));
|
||||
assertThat(addedHost.getSuperordinateDomain()).isEqualTo(Ref.create(Key.create(domain)));
|
||||
assertThat(existingHost.getSuperordinateDomain()).isEqualTo(Key.create(domain));
|
||||
assertThat(addedHost.getSuperordinateDomain()).isEqualTo(Key.create(domain));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -480,7 +481,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
ContactResource sh8013 = loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc());
|
||||
persistResource(
|
||||
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
||||
.setRegistrant(Ref.create(sh8013))
|
||||
.setRegistrant(Key.create(sh8013))
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
runFlowAssertResponse(readFile("domain_update_response.xml"));
|
||||
|
@ -491,14 +492,14 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
setEppInput("domain_update_remove_multiple_contacts.xml");
|
||||
persistReferencedEntities();
|
||||
ContactResource sh8013 = loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc());
|
||||
Ref<ContactResource> sh8013Ref = Ref.create(sh8013);
|
||||
Key<ContactResource> sh8013Key = Key.create(sh8013);
|
||||
persistResource(
|
||||
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
||||
.setRegistrant(sh8013Ref)
|
||||
.setRegistrant(sh8013Key)
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.ADMIN, sh8013Ref),
|
||||
DesignatedContact.create(Type.BILLING, sh8013Ref),
|
||||
DesignatedContact.create(Type.TECH, sh8013Ref)))
|
||||
DesignatedContact.create(Type.ADMIN, sh8013Key),
|
||||
DesignatedContact.create(Type.BILLING, sh8013Key),
|
||||
DesignatedContact.create(Type.TECH, sh8013Key)))
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
runFlowAssertResponse(readFile("domain_update_response.xml"));
|
||||
|
@ -890,7 +891,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
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());
|
||||
runFlow();
|
||||
|
@ -986,7 +987,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
persistReferencedEntities();
|
||||
persistResource(
|
||||
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
||||
.setNameservers(ImmutableSet.of(Ref.create(
|
||||
.setNameservers(ImmutableSet.of(Key.create(
|
||||
loadByUniqueId(HostResource.class, "ns1.example.foo", clock.nowUtc()))))
|
||||
.build());
|
||||
runFlow();
|
||||
|
@ -1001,7 +1002,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
||||
.setContacts(ImmutableSet.of(DesignatedContact.create(
|
||||
Type.TECH,
|
||||
Ref.create(
|
||||
Key.create(
|
||||
loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc())))))
|
||||
.build());
|
||||
runFlow();
|
||||
|
@ -1015,8 +1016,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
persistResource(
|
||||
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.ADMIN, Ref.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.TECH, Ref.create(sh8013Contact))))
|
||||
DesignatedContact.create(Type.ADMIN, Key.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.TECH, Key.create(sh8013Contact))))
|
||||
.build());
|
||||
runFlow();
|
||||
}
|
||||
|
@ -1029,8 +1030,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
persistResource(
|
||||
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.ADMIN, Ref.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.TECH, Ref.create(sh8013Contact))))
|
||||
DesignatedContact.create(Type.ADMIN, Key.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.TECH, Key.create(sh8013Contact))))
|
||||
.build());
|
||||
runFlow();
|
||||
}
|
||||
|
@ -1109,10 +1110,10 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
ImmutableSet.of("ns1.example.foo", "ns2.example.foo"))
|
||||
.build());
|
||||
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();
|
||||
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
|
||||
|
@ -1127,7 +1128,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns1.example.foo"))
|
||||
.build());
|
||||
runFlow();
|
||||
assertThat(reloadResourceByUniqueId().getRegistrant().get().getContactId()).isEqualTo("sh8013");
|
||||
assertThat(ofy().load().key(reloadResourceByUniqueId().getRegistrant()).now().getContactId())
|
||||
.isEqualTo("sh8013");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1149,7 +1151,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
persistDomain();
|
||||
persistResource(
|
||||
reloadResourceByUniqueId().asBuilder()
|
||||
.addNameservers(ImmutableSet.of(Ref.create(
|
||||
.addNameservers(ImmutableSet.of(Key.create(
|
||||
loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc()))))
|
||||
.build());
|
||||
persistResource(
|
||||
|
@ -1158,11 +1160,11 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
ImmutableSet.of("ns1.example.foo", "ns2.example.foo"))
|
||||
.build());
|
||||
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();
|
||||
runFlow();
|
||||
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
|
||||
|
|
|
@ -104,10 +104,10 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
|
|||
@Test
|
||||
public void testSuccess_internalNeverExisted() throws Exception {
|
||||
doSuccessfulInternalTest("tld");
|
||||
assertThat(ofy().load().ref(reloadResourceByUniqueId().getSuperordinateDomain())
|
||||
assertThat(ofy().load().key(reloadResourceByUniqueId().getSuperordinateDomain())
|
||||
.now().getFullyQualifiedDomainName())
|
||||
.isEqualTo("example.tld");
|
||||
assertThat(ofy().load().ref(reloadResourceByUniqueId().getSuperordinateDomain())
|
||||
assertThat(ofy().load().key(reloadResourceByUniqueId().getSuperordinateDomain())
|
||||
.now().getSubordinateHosts()).containsExactly("ns1.example.tld");
|
||||
assertDnsTasksEnqueued("ns1.example.tld");
|
||||
}
|
||||
|
@ -123,10 +123,10 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
|
|||
public void testSuccess_internalExistedButWasDeleted() throws Exception {
|
||||
persistDeletedHost(getUniqueIdFromCommand(), clock.nowUtc());
|
||||
doSuccessfulInternalTest("tld");
|
||||
assertThat(ofy().load().ref(reloadResourceByUniqueId().getSuperordinateDomain())
|
||||
assertThat(ofy().load().key(reloadResourceByUniqueId().getSuperordinateDomain())
|
||||
.now().getFullyQualifiedDomainName())
|
||||
.isEqualTo("example.tld");
|
||||
assertThat(ofy().load().ref(reloadResourceByUniqueId().getSuperordinateDomain())
|
||||
assertThat(ofy().load().key(reloadResourceByUniqueId().getSuperordinateDomain())
|
||||
.now().getSubordinateHosts()).containsExactly("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.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import google.registry.flows.ResourceAsyncDeleteFlow.ResourceToDeleteIsReferencedException;
|
||||
import google.registry.flows.ResourceFlowTestCase;
|
||||
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
|
||||
|
@ -173,7 +172,7 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
|
|||
createTld("tld");
|
||||
persistResource(newDomainResource("example.tld").asBuilder()
|
||||
.setNameservers(ImmutableSet.of(
|
||||
Ref.create(persistActiveHost(getUniqueIdFromCommand()))))
|
||||
Key.create(persistActiveHost(getUniqueIdFromCommand()))))
|
||||
.build());
|
||||
thrown.expect(ResourceToDeleteIsReferencedException.class);
|
||||
runFlow();
|
||||
|
@ -184,7 +183,7 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
|
|||
createTld("tld");
|
||||
persistResource(newDomainApplication("example.tld").asBuilder()
|
||||
.setNameservers(ImmutableSet.of(
|
||||
Ref.create(persistActiveHost(getUniqueIdFromCommand()))))
|
||||
Key.create(persistActiveHost(getUniqueIdFromCommand()))))
|
||||
.build());
|
||||
thrown.expect(ResourceToDeleteIsReferencedException.class);
|
||||
runFlow();
|
||||
|
|
|
@ -23,7 +23,7 @@ import static google.registry.testing.DatastoreHelper.persistResource;
|
|||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
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.ResourceQueryFlow.ResourceToQueryDoesNotExistException;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
|
@ -88,8 +88,7 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
|
|||
persistHostResource(true);
|
||||
persistResource(
|
||||
newDomainResource("example.foobar").asBuilder()
|
||||
.addNameservers(
|
||||
ImmutableSet.of(Ref.<HostResource>create(persistHostResource(true))))
|
||||
.addNameservers(ImmutableSet.of(Key.create(persistHostResource(true))))
|
||||
.build());
|
||||
assertTransactionalFlow(false);
|
||||
// Check that the persisted host info was returned.
|
||||
|
@ -112,7 +111,7 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
|
|||
persistResource(
|
||||
persistHostResource(true).asBuilder()
|
||||
.setRepoId("CEEF-FOOBAR")
|
||||
.setSuperordinateDomain(Ref.create(domain))
|
||||
.setSuperordinateDomain(Key.create(domain))
|
||||
.setLastSuperordinateChange(lastSuperordinateChange)
|
||||
.build());
|
||||
assertTransactionalFlow(false);
|
||||
|
|
|
@ -40,7 +40,6 @@ import com.google.common.collect.ImmutableMap;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.net.InetAddresses;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import google.registry.flows.EppRequestSource;
|
||||
import google.registry.flows.ResourceFlowTestCase;
|
||||
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
|
||||
|
@ -143,7 +142,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
ForeignKeyIndex<HostResource> oldFkiBeforeRename =
|
||||
ForeignKeyIndex.load(
|
||||
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());
|
||||
ForeignKeyIndex<HostResource> oldFkiAfterRename =
|
||||
ForeignKeyIndex.load(
|
||||
|
@ -157,7 +156,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
persistResource(
|
||||
newDomainResource("test.xn--q9jyb4c").asBuilder()
|
||||
.setDeletionTime(END_OF_TIME)
|
||||
.setNameservers(ImmutableSet.of(Ref.create(host)))
|
||||
.setNameservers(ImmutableSet.of(Key.create(host)))
|
||||
.build());
|
||||
HostResource renamedHost = doSuccessfulTest();
|
||||
assertThat(renamedHost.getSuperordinateDomain()).isNull();
|
||||
|
@ -202,7 +201,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
DomainResource.class, "example.tld", clock.nowUtc()).getSubordinateHosts())
|
||||
.containsExactly("ns1.example.tld");
|
||||
HostResource renamedHost = doSuccessfulTest();
|
||||
assertThat(renamedHost.getSuperordinateDomain()).isEqualTo(Ref.create(domain));
|
||||
assertThat(renamedHost.getSuperordinateDomain()).isEqualTo(Key.create(domain));
|
||||
assertThat(
|
||||
loadByUniqueId(
|
||||
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())
|
||||
.isEmpty();
|
||||
HostResource renamedHost = doSuccessfulTest();
|
||||
assertThat(renamedHost.getSuperordinateDomain()).isEqualTo(Ref.create(example));
|
||||
assertThat(renamedHost.getSuperordinateDomain()).isEqualTo(Key.create(example));
|
||||
assertThat(
|
||||
loadByUniqueId(
|
||||
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())
|
||||
.isEmpty();
|
||||
HostResource renamedHost = doSuccessfulTest();
|
||||
assertThat(renamedHost.getSuperordinateDomain()).isEqualTo(Ref.create(tldDomain));
|
||||
assertThat(renamedHost.getSuperordinateDomain()).isEqualTo(Key.create(tldDomain));
|
||||
assertThat(loadByUniqueId(
|
||||
DomainResource.class, "example.tld", clock.nowUtc()).getSubordinateHosts())
|
||||
.containsExactly("ns2.example.tld");
|
||||
|
@ -328,7 +327,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
DomainResource.class, "example.tld", clock.nowUtc()).getSubordinateHosts())
|
||||
.isEmpty();
|
||||
HostResource renamedHost = doSuccessfulTest();
|
||||
assertThat(renamedHost.getSuperordinateDomain()).isEqualTo(Ref.create(domain));
|
||||
assertThat(renamedHost.getSuperordinateDomain()).isEqualTo(Key.create(domain));
|
||||
assertThat(loadByUniqueId(
|
||||
DomainResource.class, "example.tld", clock.nowUtc()).getSubordinateHosts())
|
||||
.containsExactly("ns2.example.tld");
|
||||
|
@ -380,7 +379,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
|
||||
persistResource(
|
||||
newHostResource(oldHostName()).asBuilder()
|
||||
.setSuperordinateDomain(Ref.create(foo))
|
||||
.setSuperordinateDomain(Key.create(foo))
|
||||
.setLastTransferTime(null)
|
||||
.build());
|
||||
persistResource(
|
||||
|
@ -412,7 +411,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
.build());
|
||||
HostResource host = persistResource(
|
||||
newHostResource(oldHostName()).asBuilder()
|
||||
.setSuperordinateDomain(Ref.create(domain))
|
||||
.setSuperordinateDomain(Key.create(domain))
|
||||
.setLastTransferTime(clock.nowUtc().minusDays(20))
|
||||
.setLastSuperordinateChange(clock.nowUtc().minusDays(3))
|
||||
.build());
|
||||
|
@ -442,7 +441,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
|
||||
persistResource(
|
||||
newHostResource(oldHostName()).asBuilder()
|
||||
.setSuperordinateDomain(Ref.create(foo))
|
||||
.setSuperordinateDomain(Key.create(foo))
|
||||
.setLastTransferTime(lastTransferTime)
|
||||
.setLastSuperordinateChange(clock.nowUtc().minusDays(3))
|
||||
.build());
|
||||
|
@ -476,7 +475,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
|
||||
persistResource(
|
||||
newHostResource(oldHostName()).asBuilder()
|
||||
.setSuperordinateDomain(Ref.create(foo))
|
||||
.setSuperordinateDomain(Key.create(foo))
|
||||
.setLastTransferTime(lastTransferTime)
|
||||
.setLastSuperordinateChange(clock.nowUtc().minusDays(10))
|
||||
.build());
|
||||
|
@ -508,7 +507,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
.build());
|
||||
persistResource(
|
||||
newHostResource(oldHostName()).asBuilder()
|
||||
.setSuperordinateDomain(Ref.create(foo))
|
||||
.setSuperordinateDomain(Key.create(foo))
|
||||
.setLastTransferTime(null)
|
||||
.setLastSuperordinateChange(clock.nowUtc().minusDays(3))
|
||||
.build());
|
||||
|
@ -530,7 +529,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
DomainResource domain = persistActiveDomain("example.foo");
|
||||
persistResource(
|
||||
newHostResource(oldHostName()).asBuilder()
|
||||
.setSuperordinateDomain(Ref.create(domain))
|
||||
.setSuperordinateDomain(Key.create(domain))
|
||||
.build());
|
||||
DateTime lastTransferTime = clock.nowUtc().minusDays(2);
|
||||
persistResource(
|
||||
|
@ -563,7 +562,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
|
||||
persistResource(
|
||||
newHostResource(oldHostName()).asBuilder()
|
||||
.setSuperordinateDomain(Ref.create(domain))
|
||||
.setSuperordinateDomain(Key.create(domain))
|
||||
.setLastTransferTime(lastTransferTime)
|
||||
.setLastSuperordinateChange(clock.nowUtc().minusDays(4))
|
||||
.build());
|
||||
|
@ -592,7 +591,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
DomainResource domain = persistActiveDomain("example.foo");
|
||||
persistResource(
|
||||
newHostResource(oldHostName()).asBuilder()
|
||||
.setSuperordinateDomain(Ref.create(domain))
|
||||
.setSuperordinateDomain(Key.create(domain))
|
||||
.setLastTransferTime(clock.nowUtc().minusDays(12))
|
||||
.setLastSuperordinateChange(clock.nowUtc().minusDays(4))
|
||||
.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>");
|
||||
createTld("tld");
|
||||
persistResource(newHostResource(oldHostName()).asBuilder()
|
||||
.setSuperordinateDomain(Ref.create(persistActiveDomain("example.tld")))
|
||||
.setSuperordinateDomain(Key.create(persistActiveDomain("example.tld")))
|
||||
.build());
|
||||
thrown.expect(CannotRemoveSubordinateHostLastIpException.class);
|
||||
runFlow();
|
||||
|
@ -759,7 +758,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
persistResource(
|
||||
newHostResource(oldHostName())
|
||||
.asBuilder()
|
||||
.setSuperordinateDomain(Ref.create(persistActiveDomain("example.tld")))
|
||||
.setSuperordinateDomain(Key.create(persistActiveDomain("example.tld")))
|
||||
.setInetAddresses(ImmutableSet.of(InetAddresses.forString("127.0.0.1")))
|
||||
.build());
|
||||
thrown.expect(RenameHostToExternalRemoveIpException.class);
|
||||
|
@ -775,7 +774,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
null);
|
||||
createTld("tld");
|
||||
persistResource(newHostResource(oldHostName()).asBuilder()
|
||||
.setSuperordinateDomain(Ref.create(persistActiveDomain("example.tld")))
|
||||
.setSuperordinateDomain(Key.create(persistActiveDomain("example.tld")))
|
||||
.build());
|
||||
thrown.expect(CannotAddIpToExternalHostException.class);
|
||||
runFlow();
|
||||
|
|
|
@ -108,7 +108,7 @@ public class EppResourceUtilsTest {
|
|||
@Test
|
||||
public void testLoadAtPointInTime_brokenRevisionHistory_returnsResourceAsIs()
|
||||
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(
|
||||
newHostResource("ns1.cat.tld").asBuilder()
|
||||
.setCreationTimeForTest(START_OF_TIME)
|
||||
|
|
|
@ -29,7 +29,6 @@ import com.google.common.collect.ImmutableSet;
|
|||
import com.google.common.collect.Iterables;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.ObjectifyService;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.annotation.Entity;
|
||||
import com.googlecode.objectify.annotation.Id;
|
||||
import google.registry.model.ImmutableObject.DoNotHydrate;
|
||||
|
@ -258,15 +257,13 @@ public class ImmutableObjectTest {
|
|||
|
||||
/** Subclass of ImmutableObject with keys to other objects. */
|
||||
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<Ref<?>> set;
|
||||
Set<Key<?>> set;
|
||||
|
||||
ReferenceUnion<?> referenceUnion;
|
||||
}
|
||||
|
@ -297,21 +294,12 @@ public class ImmutableObjectTest {
|
|||
UnhydratableObject unhydratable = new UnhydratableObject();
|
||||
unhydratable.value = "unexpected";
|
||||
RootObject root = new RootObject();
|
||||
root.hydratable = Ref.create(persistResource(hydratable));
|
||||
root.unhydratable = Ref.create(persistResource(unhydratable));
|
||||
root.hydratable = Key.create(persistResource(hydratable));
|
||||
root.unhydratable = Key.create(persistResource(unhydratable));
|
||||
assertThat(root.toHydratedString()).contains("expected");
|
||||
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
|
||||
public void testToHydratedString_expandsMaps() {
|
||||
HydratableObject hydratable = new HydratableObject();
|
||||
|
@ -319,9 +307,9 @@ public class ImmutableObjectTest {
|
|||
UnhydratableObject unhydratable = new UnhydratableObject();
|
||||
unhydratable.value = "unexpected";
|
||||
RootObject root = new RootObject();
|
||||
root.map = ImmutableMap.<String, Ref<?>>of(
|
||||
"hydratable", Ref.create(persistResource(hydratable)),
|
||||
"unhydratable", Ref.create(persistResource(unhydratable)));
|
||||
root.map = ImmutableMap.<String, Key<?>>of(
|
||||
"hydratable", Key.create(persistResource(hydratable)),
|
||||
"unhydratable", Key.create(persistResource(unhydratable)));
|
||||
assertThat(root.toHydratedString()).contains("expected");
|
||||
assertThat(root.toHydratedString()).doesNotContain("unexpected");
|
||||
}
|
||||
|
@ -333,9 +321,9 @@ public class ImmutableObjectTest {
|
|||
UnhydratableObject unhydratable = new UnhydratableObject();
|
||||
unhydratable.value = "unexpected";
|
||||
RootObject root = new RootObject();
|
||||
root.set = ImmutableSet.<Ref<?>>of(
|
||||
Ref.create(persistResource(hydratable)),
|
||||
Ref.create(persistResource(unhydratable)));
|
||||
root.set = ImmutableSet.<Key<?>>of(
|
||||
Key.create(persistResource(hydratable)),
|
||||
Key.create(persistResource(unhydratable)));
|
||||
assertThat(root.toHydratedString()).contains("expected");
|
||||
assertThat(root.toHydratedString()).doesNotContain("unexpected");
|
||||
}
|
||||
|
@ -343,7 +331,7 @@ public class ImmutableObjectTest {
|
|||
@Test
|
||||
public void testToHydratedString_expandsReferenceUnions() {
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import static org.joda.time.DateTimeZone.UTC;
|
|||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import google.registry.model.EntityTestCase;
|
||||
import google.registry.model.billing.BillingEvent.Flag;
|
||||
import google.registry.model.billing.BillingEvent.Reason;
|
||||
|
@ -106,14 +105,14 @@ public class BillingEventTest extends EntityTestCase {
|
|||
.setReason(Reason.CREATE)
|
||||
.setEventTime(now.plusDays(1))
|
||||
.setBillingTime(now.plusDays(5))
|
||||
.setOneTimeEventRef(Ref.create(oneTime))));
|
||||
.setOneTimeEventKey(Key.create(oneTime))));
|
||||
cancellationRecurring = persistResource(commonInit(
|
||||
new BillingEvent.Cancellation.Builder()
|
||||
.setParent(historyEntry2)
|
||||
.setReason(Reason.RENEW)
|
||||
.setEventTime(now.plusDays(1))
|
||||
.setBillingTime(now.plusYears(1).plusDays(45))
|
||||
.setRecurringEventRef(Ref.create(recurring))));
|
||||
.setRecurringEventKey(Key.create(recurring))));
|
||||
modification = persistResource(commonInit(
|
||||
new BillingEvent.Modification.Builder()
|
||||
.setParent(historyEntry2)
|
||||
|
@ -121,7 +120,7 @@ public class BillingEventTest extends EntityTestCase {
|
|||
.setCost(Money.of(USD, 1))
|
||||
.setDescription("Something happened")
|
||||
.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) {
|
||||
|
@ -169,7 +168,7 @@ public class BillingEventTest extends EntityTestCase {
|
|||
.getCancellationMatchingBillingEvent();
|
||||
assertThat(ofy().load().key(recurringKey).now()).isEqualTo(recurring);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testIndexing() throws Exception {
|
||||
verifyIndexing(oneTime, "clientId", "eventTime", "billingTime", "syntheticCreationTime");
|
||||
|
@ -241,7 +240,7 @@ public class BillingEventTest extends EntityTestCase {
|
|||
GracePeriodStatus.AUTO_RENEW,
|
||||
now.plusYears(1).plusDays(45),
|
||||
"a registrar",
|
||||
Ref.create(recurring)),
|
||||
Key.create(recurring)),
|
||||
historyEntry2,
|
||||
"foo.tld");
|
||||
// Set ID to be the same to ignore for the purposes of comparison.
|
||||
|
@ -264,15 +263,15 @@ public class BillingEventTest extends EntityTestCase {
|
|||
@Test
|
||||
public void testFailure_cancellationWithNoBillingEvent() {
|
||||
thrown.expect(IllegalStateException.class, "exactly one billing event");
|
||||
cancellationOneTime.asBuilder().setOneTimeEventRef(null).setRecurringEventRef(null).build();
|
||||
cancellationOneTime.asBuilder().setOneTimeEventKey(null).setRecurringEventKey(null).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_cancellationWithBothBillingEvents() {
|
||||
thrown.expect(IllegalStateException.class, "exactly one billing event");
|
||||
cancellationOneTime.asBuilder()
|
||||
.setOneTimeEventRef(Ref.create(oneTime))
|
||||
.setRecurringEventRef(Ref.create(recurring))
|
||||
.setOneTimeEventKey(Key.create(oneTime))
|
||||
.setRecurringEventKey(Key.create(recurring))
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ import static org.joda.money.CurrencyUnit.USD;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import google.registry.model.EntityTestCase;
|
||||
import google.registry.model.billing.BillingEvent;
|
||||
import google.registry.model.domain.launch.ApplicationStatus;
|
||||
|
@ -77,12 +76,12 @@ public class DomainApplicationTest extends EntityTestCase {
|
|||
StatusValue.SERVER_UPDATE_PROHIBITED,
|
||||
StatusValue.SERVER_RENEW_PROHIBITED,
|
||||
StatusValue.SERVER_HOLD))
|
||||
.setRegistrant(Ref.create(persistActiveContact("contact_id1")))
|
||||
.setRegistrant(Key.create(persistActiveContact("contact_id1")))
|
||||
.setContacts(ImmutableSet.of(DesignatedContact.create(
|
||||
DesignatedContact.Type.ADMIN,
|
||||
Ref.create(persistActiveContact("contact_id2")))))
|
||||
Key.create(persistActiveContact("contact_id2")))))
|
||||
.setNameservers(
|
||||
ImmutableSet.of(Ref.create(persistActiveHost("ns1.example.com"))))
|
||||
ImmutableSet.of(Key.create(persistActiveHost("ns1.example.com"))))
|
||||
.setCurrentSponsorClientId("a third registrar")
|
||||
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("password")))
|
||||
.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() {
|
||||
assertThat(emptyBuilder().setNameservers(null).build().nameservers).isNull();
|
||||
assertThat(emptyBuilder()
|
||||
.setNameservers(ImmutableSet.<Ref<HostResource>>of())
|
||||
.setNameservers(ImmutableSet.<Key<HostResource>>of())
|
||||
.build()
|
||||
.nameservers)
|
||||
.isNull();
|
||||
assertThat(emptyBuilder()
|
||||
.setNameservers(ImmutableSet.of(Ref.create(newHostResource("foo.example.tld"))))
|
||||
.setNameservers(ImmutableSet.of(Key.create(newHostResource("foo.example.tld"))))
|
||||
.build()
|
||||
.nameservers)
|
||||
.isNotNull();
|
||||
|
|
|
@ -36,7 +36,6 @@ import com.google.common.collect.ImmutableSortedMap;
|
|||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Ordering;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import google.registry.flows.EppXmlTransformer;
|
||||
import google.registry.model.EntityTestCase;
|
||||
import google.registry.model.billing.BillingEvent;
|
||||
|
@ -111,11 +110,11 @@ public class DomainResourceTest extends EntityTestCase {
|
|||
StatusValue.SERVER_UPDATE_PROHIBITED,
|
||||
StatusValue.SERVER_RENEW_PROHIBITED,
|
||||
StatusValue.SERVER_HOLD))
|
||||
.setRegistrant(Ref.create(contactResource1))
|
||||
.setRegistrant(Key.create(contactResource1))
|
||||
.setContacts(ImmutableSet.of(DesignatedContact.create(
|
||||
DesignatedContact.Type.ADMIN,
|
||||
Ref.create(contactResource2))))
|
||||
.setNameservers(ImmutableSet.of(Ref.create(hostResource)))
|
||||
Key.create(contactResource2))))
|
||||
.setNameservers(ImmutableSet.of(Key.create(hostResource)))
|
||||
.setSubordinateHosts(ImmutableSet.of("ns1.example.com"))
|
||||
.setCurrentSponsorClientId("ThirdRegistrar")
|
||||
.setRegistrationExpirationTime(clock.nowUtc().plusYears(1))
|
||||
|
@ -135,21 +134,21 @@ public class DomainResourceTest extends EntityTestCase {
|
|||
Key.create(BillingEvent.Recurring.class, 2),
|
||||
Key.create(PollMessage.Autorenew.class, 3)))
|
||||
.setServerApproveBillingEvent(
|
||||
Ref.create(Key.create(BillingEvent.OneTime.class, 1)))
|
||||
Key.create(BillingEvent.OneTime.class, 1))
|
||||
.setServerApproveAutorenewEvent(
|
||||
Ref.create(Key.create(BillingEvent.Recurring.class, 2)))
|
||||
Key.create(BillingEvent.Recurring.class, 2))
|
||||
.setServerApproveAutorenewPollMessage(
|
||||
Ref.create(Key.create(PollMessage.Autorenew.class, 3)))
|
||||
Key.create(PollMessage.Autorenew.class, 3))
|
||||
.setTransferRequestTime(clock.nowUtc().plusDays(1))
|
||||
.setTransferStatus(TransferStatus.SERVER_APPROVED)
|
||||
.setTransferRequestTrid(Trid.create("client trid"))
|
||||
.build())
|
||||
.setDeletePollMessage(Key.create(PollMessage.OneTime.class, 1))
|
||||
.setAutorenewBillingEvent(Ref.create(Key.create(BillingEvent.Recurring.class, 1)))
|
||||
.setAutorenewPollMessage(Ref.create(Key.create(PollMessage.Autorenew.class, 2)))
|
||||
.setAutorenewBillingEvent(Key.create(BillingEvent.Recurring.class, 1))
|
||||
.setAutorenewPollMessage(Key.create(PollMessage.Autorenew.class, 2))
|
||||
.setSmdId("smdid")
|
||||
.setApplicationTime(START_OF_TIME)
|
||||
.setApplication(Ref.create(Key.create(DomainApplication.class, 1)))
|
||||
.setApplication(Key.create(DomainApplication.class, 1))
|
||||
.addGracePeriod(GracePeriod.create(
|
||||
GracePeriodStatus.ADD, clock.nowUtc().plusDays(1), "registrar", null))
|
||||
.build());
|
||||
|
@ -198,10 +197,10 @@ public class DomainResourceTest extends EntityTestCase {
|
|||
assertThat(newDomainResource("example.com").asBuilder()
|
||||
.setNameservers(null).build().nameservers).isNull();
|
||||
assertThat(newDomainResource("example.com").asBuilder()
|
||||
.setNameservers(ImmutableSet.<Ref<HostResource>>of()).build().nameservers)
|
||||
.setNameservers(ImmutableSet.<Key<HostResource>>of()).build().nameservers)
|
||||
.isNull();
|
||||
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)
|
||||
.isNotNull();
|
||||
// This behavior should also hold true for ImmutableObjects nested in collections.
|
||||
|
@ -230,8 +229,8 @@ public class DomainResourceTest extends EntityTestCase {
|
|||
|
||||
@Test
|
||||
public void testImplicitStatusValues() {
|
||||
ImmutableSet<Ref<HostResource>> nameservers =
|
||||
ImmutableSet.of(Ref.create(newHostResource("foo.example.tld")));
|
||||
ImmutableSet<Key<HostResource>> nameservers =
|
||||
ImmutableSet.of(Key.create(newHostResource("foo.example.tld")));
|
||||
StatusValue[] statuses = {StatusValue.OK};
|
||||
// OK is implicit if there's no other statuses but there are nameservers.
|
||||
assertAboutDomains()
|
||||
|
@ -284,7 +283,7 @@ public class DomainResourceTest extends EntityTestCase {
|
|||
assertThat(domain.getCurrentSponsorClientId()).isEqualTo("winner");
|
||||
assertThat(domain.getLastTransferTime()).isEqualTo(clock.nowUtc().plusDays(1));
|
||||
assertThat(domain.getRegistrationExpirationTime()).isEqualTo(newExpirationTime);
|
||||
assertThat(domain.getAutorenewBillingEvent().getKey()).isEqualTo(newAutorenewEvent);
|
||||
assertThat(domain.getAutorenewBillingEvent()).isEqualTo(newAutorenewEvent);
|
||||
}
|
||||
|
||||
private void doExpiredTransferTest(DateTime oldExpirationTime) {
|
||||
|
@ -308,7 +307,7 @@ public class DomainResourceTest extends EntityTestCase {
|
|||
.setTransferRequestTime(clock.nowUtc().minusDays(4))
|
||||
.setPendingTransferExpirationTime(clock.nowUtc().plusDays(1))
|
||||
.setGainingClientId("winner")
|
||||
.setServerApproveBillingEvent(Ref.create(Key.create(transferBillingEvent)))
|
||||
.setServerApproveBillingEvent(Key.create(transferBillingEvent))
|
||||
.setServerApproveEntities(ImmutableSet.<Key<? extends TransferServerApproveEntity>>of(
|
||||
Key.create(transferBillingEvent)))
|
||||
.setExtendedRegistrationYears(1)
|
||||
|
@ -321,14 +320,14 @@ public class DomainResourceTest extends EntityTestCase {
|
|||
DomainResource afterTransfer = domain.cloneProjectedAtTime(clock.nowUtc().plusDays(1));
|
||||
DateTime newExpirationTime = oldExpirationTime.plusYears(1);
|
||||
Key<BillingEvent.Recurring> serverApproveAutorenewEvent =
|
||||
domain.getTransferData().getServerApproveAutorenewEvent().getKey();
|
||||
domain.getTransferData().getServerApproveAutorenewEvent();
|
||||
assertTransferred(afterTransfer, newExpirationTime, serverApproveAutorenewEvent);
|
||||
assertThat(afterTransfer.getGracePeriods())
|
||||
.containsExactly(GracePeriod.create(
|
||||
GracePeriodStatus.TRANSFER,
|
||||
clock.nowUtc().plusDays(1).plus(Registry.get("com").getTransferGracePeriodLength()),
|
||||
"winner",
|
||||
Ref.create(transferBillingEvent)));
|
||||
Key.create(transferBillingEvent)));
|
||||
// If we project after the grace period expires all should be the same except the grace period.
|
||||
DomainResource afterGracePeriod = domain.cloneProjectedAtTime(
|
||||
clock.nowUtc().plusDays(2).plus(Registry.get("com").getTransferGracePeriodLength()));
|
||||
|
@ -420,7 +419,7 @@ public class DomainResourceTest extends EntityTestCase {
|
|||
oldExpirationTime.plusYears(2).plus(
|
||||
Registry.get("com").getAutoRenewGracePeriodLength()),
|
||||
renewedThreeTimes.getCurrentSponsorClientId(),
|
||||
Ref.create(renewedThreeTimes.autorenewBillingEvent.key())));
|
||||
renewedThreeTimes.autorenewBillingEvent));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -18,7 +18,6 @@ import static com.google.common.truth.Truth.assertThat;
|
|||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import google.registry.model.billing.BillingEvent;
|
||||
import google.registry.model.billing.BillingEvent.Reason;
|
||||
import google.registry.model.billing.BillingEvent.Recurring;
|
||||
|
@ -68,7 +67,7 @@ public class GracePeriodTest {
|
|||
public void testSuccess_forBillingEvent() {
|
||||
GracePeriod gracePeriod = GracePeriod.forBillingEvent(GracePeriodStatus.ADD, onetime);
|
||||
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.getClientId()).isEqualTo("TheRegistrar");
|
||||
assertThat(gracePeriod.getExpirationTime()).isEqualTo(now.plusDays(1));
|
||||
|
@ -108,6 +107,6 @@ public class GracePeriodTest {
|
|||
GracePeriodStatus.RENEW,
|
||||
now.plusDays(1),
|
||||
"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.net.InetAddresses;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import google.registry.model.EntityTestCase;
|
||||
import google.registry.model.billing.BillingEvent;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
|
@ -84,7 +83,7 @@ public class HostResourceTest extends EntityTestCase {
|
|||
.setInetAddresses(ImmutableSet.of(InetAddresses.forString("127.0.0.1")))
|
||||
.setStatusValues(ImmutableSet.of(StatusValue.OK))
|
||||
.setSuperordinateDomain(
|
||||
Ref.create(loadByUniqueId(DomainResource.class, "example.com", clock.nowUtc())))
|
||||
Key.create(loadByUniqueId(DomainResource.class, "example.com", clock.nowUtc())))
|
||||
.build());
|
||||
persistResource(hostResource);
|
||||
}
|
||||
|
@ -265,7 +264,7 @@ public class HostResourceTest extends EntityTestCase {
|
|||
.setPendingTransferExpirationTime(clock.nowUtc().plusDays(1))
|
||||
.setGainingClientId("winner")
|
||||
.setExtendedRegistrationYears(2)
|
||||
.setServerApproveBillingEvent(Ref.create(
|
||||
.setServerApproveBillingEvent(Key.create(
|
||||
new BillingEvent.OneTime.Builder()
|
||||
.setParent(new HistoryEntry.Builder().setParent(domain).build())
|
||||
.setCost(Money.parse("USD 100"))
|
||||
|
|
|
@ -16,7 +16,7 @@ package google.registry.model.index;
|
|||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
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.testing.DatastoreHelper.createTld;
|
||||
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 com.google.common.collect.ImmutableSet;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.model.EntityTestCase;
|
||||
import google.registry.model.domain.DomainApplication;
|
||||
import google.registry.testing.ExceptionRule;
|
||||
|
@ -46,14 +46,14 @@ public class DomainApplicationIndexTest extends EntityTestCase {
|
|||
|
||||
@Test
|
||||
public void testFailure_create_nullReferences() {
|
||||
thrown.expect(IllegalArgumentException.class, "References must not be null or empty.");
|
||||
DomainApplicationIndex.createWithSpecifiedReferences("blah.com", null);
|
||||
thrown.expect(IllegalArgumentException.class, "Keys must not be null or empty.");
|
||||
DomainApplicationIndex.createWithSpecifiedKeys("blah.com", null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_create_emptyReferences() {
|
||||
thrown.expect(IllegalArgumentException.class, "References must not be null or empty.");
|
||||
createWithSpecifiedReferences("blah.com", ImmutableSet.<Ref<DomainApplication>>of());
|
||||
thrown.expect(IllegalArgumentException.class, "Keys must not be null or empty.");
|
||||
createWithSpecifiedKeys("blah.com", ImmutableSet.<Key<DomainApplication>>of());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -62,7 +62,7 @@ public class DomainApplicationIndexTest extends EntityTestCase {
|
|||
persistResource(createUpdatedInstance(application));
|
||||
DomainApplicationIndex savedIndex = DomainApplicationIndex.load("example.com");
|
||||
assertThat(savedIndex).isNotNull();
|
||||
assertThat(savedIndex.getReferences()).containsExactly(Ref.create(application));
|
||||
assertThat(savedIndex.getKeys()).containsExactly(Key.create(application));
|
||||
assertThat(loadActiveApplicationsByDomainName("example.com", DateTime.now()))
|
||||
.containsExactly(application);
|
||||
}
|
||||
|
@ -83,8 +83,8 @@ public class DomainApplicationIndexTest extends EntityTestCase {
|
|||
persistResource(createUpdatedInstance(application3));
|
||||
DomainApplicationIndex savedIndex = DomainApplicationIndex.load("example.com");
|
||||
assertThat(savedIndex).isNotNull();
|
||||
assertThat(savedIndex.getReferences()).containsExactly(
|
||||
Ref.create(application1), Ref.create(application2), Ref.create(application3));
|
||||
assertThat(savedIndex.getKeys()).containsExactly(
|
||||
Key.create(application1), Key.create(application2), Key.create(application3));
|
||||
assertThat(loadActiveApplicationsByDomainName("example.com", DateTime.now()))
|
||||
.containsExactly(application1, application2, application3);
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ public class DomainApplicationIndexTest extends EntityTestCase {
|
|||
persistResource(createUpdatedInstance(application2));
|
||||
DomainApplicationIndex savedIndex =
|
||||
DomainApplicationIndex.load(application1.getFullyQualifiedDomainName());
|
||||
assertThat(savedIndex.getReferences()).hasSize(2);
|
||||
assertThat(savedIndex.getKeys()).hasSize(2);
|
||||
assertThat(loadActiveApplicationsByDomainName("example.com", DateTime.now()))
|
||||
.containsExactly(application1);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public class EppResourceIndexTest extends EntityTestCase {
|
|||
@Test
|
||||
public void testPersistence() throws Exception {
|
||||
EppResourceIndex loadedIndex = Iterables.getOnlyElement(getEppResourceIndexObjects());
|
||||
assertThat(loadedIndex.reference.get()).isEqualTo(contact);
|
||||
assertThat(ofy().load().key(loadedIndex.reference).now()).isEqualTo(contact);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -56,7 +56,7 @@ public class EppResourceIndexTest extends EntityTestCase {
|
|||
public void testIdempotentOnUpdate() throws Exception {
|
||||
contact = persistResource(contact.asBuilder().setEmailAddress("abc@def.fake").build());
|
||||
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;
|
||||
|
||||
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.persistActiveHost;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||
|
||||
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.host.HostResource;
|
||||
import google.registry.model.index.ForeignKeyIndex.ForeignKeyHostIndex;
|
||||
|
@ -47,7 +48,7 @@ public class ForeignKeyIndexTest extends EntityTestCase {
|
|||
HostResource host = persistActiveHost("ns1.example.com");
|
||||
ForeignKeyIndex<HostResource> fki =
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -80,7 +81,7 @@ public class ForeignKeyIndexTest extends EntityTestCase {
|
|||
clock.advanceOneMilli();
|
||||
ForeignKeyHostIndex fki = new ForeignKeyHostIndex();
|
||||
fki.foreignKey = "ns1.example.com";
|
||||
fki.topReference = Ref.create(host1);
|
||||
fki.topReference = Key.create(host1);
|
||||
fki.deletionTime = clock.nowUtc();
|
||||
persistResource(fki);
|
||||
assertThat(ForeignKeyIndex.load(
|
||||
|
|
|
@ -88,7 +88,8 @@ public class OfyTest {
|
|||
}
|
||||
|
||||
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.
|
||||
Ofy ofy = new Ofy(new FakeClock(groupTimestamp));
|
||||
thrown.expect(
|
||||
|
|
|
@ -11,8 +11,8 @@ class google.registry.model.UpdateAutoTimestamp {
|
|||
class google.registry.model.billing.BillingEvent$Cancellation {
|
||||
@Id long id;
|
||||
@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.Ref<google.registry.model.billing.BillingEvent$Recurring> refRecurring;
|
||||
com.googlecode.objectify.Key<google.registry.model.billing.BillingEvent$OneTime> refOneTime;
|
||||
com.googlecode.objectify.Key<google.registry.model.billing.BillingEvent$Recurring> refRecurring;
|
||||
google.registry.model.billing.BillingEvent$Reason reason;
|
||||
java.lang.String clientId;
|
||||
java.lang.String targetId;
|
||||
|
@ -31,7 +31,7 @@ enum google.registry.model.billing.BillingEvent$Flag {
|
|||
class google.registry.model.billing.BillingEvent$Modification {
|
||||
@Id long id;
|
||||
@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;
|
||||
java.lang.String clientId;
|
||||
java.lang.String description;
|
||||
|
@ -86,7 +86,7 @@ class google.registry.model.billing.RegistrarBillingEntry {
|
|||
}
|
||||
class google.registry.model.billing.RegistrarCredit {
|
||||
@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;
|
||||
java.lang.String description;
|
||||
java.lang.String tld;
|
||||
|
@ -99,7 +99,7 @@ enum google.registry.model.billing.RegistrarCredit$CreditType {
|
|||
}
|
||||
class google.registry.model.billing.RegistrarCreditBalance {
|
||||
@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.time.DateTime effectiveTime;
|
||||
org.joda.time.DateTime writtenTime;
|
||||
|
@ -142,7 +142,7 @@ class google.registry.model.contact.ContactPhoneNumber {
|
|||
}
|
||||
class google.registry.model.contact.ContactResource {
|
||||
@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.UpdateAutoTimestamp updateTimestamp;
|
||||
google.registry.model.contact.ContactAuthInfo authInfo;
|
||||
|
@ -197,7 +197,7 @@ enum google.registry.model.domain.DesignatedContact$Type {
|
|||
}
|
||||
class google.registry.model.domain.DomainApplication {
|
||||
@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.UpdateAutoTimestamp updateTimestamp;
|
||||
google.registry.model.domain.DomainAuthInfo authInfo;
|
||||
|
@ -227,7 +227,7 @@ class google.registry.model.domain.DomainAuthInfo {
|
|||
}
|
||||
class google.registry.model.domain.DomainBase {
|
||||
@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.UpdateAutoTimestamp updateTimestamp;
|
||||
google.registry.model.domain.DomainAuthInfo authInfo;
|
||||
|
@ -249,11 +249,11 @@ class google.registry.model.domain.DomainBase {
|
|||
}
|
||||
class google.registry.model.domain.DomainResource {
|
||||
@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.Ref<google.registry.model.billing.BillingEvent$Recurring> autorenewBillingEvent;
|
||||
com.googlecode.objectify.Ref<google.registry.model.domain.DomainApplication> application;
|
||||
com.googlecode.objectify.Ref<google.registry.model.poll.PollMessage$Autorenew> autorenewPollMessage;
|
||||
com.googlecode.objectify.Key<google.registry.model.billing.BillingEvent$Recurring> autorenewBillingEvent;
|
||||
com.googlecode.objectify.Key<google.registry.model.domain.DomainApplication> application;
|
||||
com.googlecode.objectify.Key<google.registry.model.poll.PollMessage$Autorenew> autorenewPollMessage;
|
||||
google.registry.model.CreateAutoTimestamp creationTime;
|
||||
google.registry.model.UpdateAutoTimestamp updateTimestamp;
|
||||
google.registry.model.domain.DomainAuthInfo authInfo;
|
||||
|
@ -279,8 +279,8 @@ class google.registry.model.domain.DomainResource {
|
|||
org.joda.time.DateTime registrationExpirationTime;
|
||||
}
|
||||
class google.registry.model.domain.GracePeriod {
|
||||
com.googlecode.objectify.Ref<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$OneTime> billingEventOneTime;
|
||||
com.googlecode.objectify.Key<google.registry.model.billing.BillingEvent$Recurring> billingEventRecurring;
|
||||
google.registry.model.domain.rgp.GracePeriodStatus type;
|
||||
java.lang.String clientId;
|
||||
org.joda.time.DateTime expirationTime;
|
||||
|
@ -301,7 +301,7 @@ enum google.registry.model.domain.Period$Unit {
|
|||
YEARS;
|
||||
}
|
||||
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 {
|
||||
ALLOCATED;
|
||||
|
@ -384,8 +384,8 @@ class google.registry.model.export.LogsExportCursor {
|
|||
}
|
||||
class google.registry.model.host.HostResource {
|
||||
@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.googlecode.objectify.Ref<google.registry.model.domain.DomainResource> superordinateDomain;
|
||||
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.domain.DomainResource> superordinateDomain;
|
||||
google.registry.model.CreateAutoTimestamp creationTime;
|
||||
google.registry.model.UpdateAutoTimestamp updateTimestamp;
|
||||
google.registry.model.transfer.TransferData transferData;
|
||||
|
@ -403,12 +403,12 @@ class google.registry.model.host.HostResource {
|
|||
class google.registry.model.index.DomainApplicationIndex {
|
||||
@Id java.lang.String fullyQualifiedDomainName;
|
||||
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 {
|
||||
@Id java.lang.String id;
|
||||
@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;
|
||||
java.lang.String kind;
|
||||
}
|
||||
|
@ -417,19 +417,19 @@ class google.registry.model.index.EppResourceIndexBucket {
|
|||
}
|
||||
class google.registry.model.index.ForeignKeyIndex$ForeignKeyContactIndex {
|
||||
@Id java.lang.String foreignKey;
|
||||
com.googlecode.objectify.Ref<E> topReference;
|
||||
com.googlecode.objectify.Key<E> topReference;
|
||||
google.registry.model.UpdateAutoTimestamp updateTimestamp;
|
||||
org.joda.time.DateTime deletionTime;
|
||||
}
|
||||
class google.registry.model.index.ForeignKeyIndex$ForeignKeyDomainIndex {
|
||||
@Id java.lang.String foreignKey;
|
||||
com.googlecode.objectify.Ref<E> topReference;
|
||||
com.googlecode.objectify.Key<E> topReference;
|
||||
google.registry.model.UpdateAutoTimestamp updateTimestamp;
|
||||
org.joda.time.DateTime deletionTime;
|
||||
}
|
||||
class google.registry.model.index.ForeignKeyIndex$ForeignKeyHostIndex {
|
||||
@Id java.lang.String foreignKey;
|
||||
com.googlecode.objectify.Ref<E> topReference;
|
||||
com.googlecode.objectify.Key<E> topReference;
|
||||
google.registry.model.UpdateAutoTimestamp updateTimestamp;
|
||||
org.joda.time.DateTime deletionTime;
|
||||
}
|
||||
|
@ -773,7 +773,7 @@ class google.registry.model.registry.label.ReservedList$ReservedListEntry {
|
|||
}
|
||||
class google.registry.model.reporting.HistoryEntry {
|
||||
@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;
|
||||
byte[] xmlBytes;
|
||||
google.registry.model.domain.Period period;
|
||||
|
@ -858,9 +858,9 @@ class google.registry.model.tmch.TmchCrl {
|
|||
org.joda.time.DateTime updated;
|
||||
}
|
||||
class google.registry.model.transfer.TransferData {
|
||||
com.googlecode.objectify.Ref<google.registry.model.billing.BillingEvent$OneTime> serverApproveBillingEvent;
|
||||
com.googlecode.objectify.Ref<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.billing.BillingEvent$OneTime> serverApproveBillingEvent;
|
||||
com.googlecode.objectify.Key<google.registry.model.billing.BillingEvent$Recurring> serverApproveAutorenewEvent;
|
||||
com.googlecode.objectify.Key<google.registry.model.poll.PollMessage$Autorenew> serverApproveAutorenewPollMessage;
|
||||
google.registry.model.eppcommon.Trid transferRequestTrid;
|
||||
google.registry.model.transfer.TransferStatus transferStatus;
|
||||
java.lang.Integer extendedRegistrationYears;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.model.transfer;
|
||||
|
||||
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.persistResource;
|
||||
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.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import google.registry.model.billing.BillingEvent;
|
||||
import google.registry.model.billing.BillingEvent.Flag;
|
||||
import google.registry.model.billing.BillingEvent.Reason;
|
||||
|
@ -125,10 +125,12 @@ public class TransferDataTest {
|
|||
@Test
|
||||
public void testSuccess_GetStoredBillingEventNoEntities() throws Exception {
|
||||
transferData = new TransferData.Builder()
|
||||
.setServerApproveBillingEvent(Ref.create(Key.create(transferBillingEvent)))
|
||||
.setServerApproveBillingEvent(Key.create(transferBillingEvent))
|
||||
.build();
|
||||
assertThat(transferData.serverApproveBillingEvent.get()).isEqualTo(transferBillingEvent);
|
||||
assertThat(transferData.getServerApproveBillingEvent().get()).isEqualTo(transferBillingEvent);
|
||||
assertThat(ofy().load().key(transferData.serverApproveBillingEvent).now())
|
||||
.isEqualTo(transferBillingEvent);
|
||||
assertThat(ofy().load().key(transferData.getServerApproveBillingEvent()).now())
|
||||
.isEqualTo(transferBillingEvent);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -139,9 +141,11 @@ public class TransferDataTest {
|
|||
Key.create(recurringBillingEvent),
|
||||
Key.create(PollMessage.OneTime.class, 1));
|
||||
transferData = transferData.asBuilder()
|
||||
.setServerApproveBillingEvent(Ref.create(Key.create(transferBillingEvent)))
|
||||
.setServerApproveBillingEvent(Key.create(transferBillingEvent))
|
||||
.build();
|
||||
assertThat(transferData.serverApproveBillingEvent.get()).isEqualTo(transferBillingEvent);
|
||||
assertThat(transferData.getServerApproveBillingEvent().get()).isEqualTo(transferBillingEvent);
|
||||
assertThat(ofy().load().key(transferData.serverApproveBillingEvent).now())
|
||||
.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