diff --git a/java/com/google/domain/registry/flows/domain/DomainCreateOrAllocateFlow.java b/java/com/google/domain/registry/flows/domain/DomainCreateOrAllocateFlow.java index 32316aac6..9497f54da 100644 --- a/java/com/google/domain/registry/flows/domain/DomainCreateOrAllocateFlow.java +++ b/java/com/google/domain/registry/flows/domain/DomainCreateOrAllocateFlow.java @@ -19,9 +19,11 @@ import static com.google.domain.registry.util.DateTimeUtils.END_OF_TIME; import static com.google.domain.registry.util.DateTimeUtils.leapSafeAddYears; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; import com.google.domain.registry.dns.DnsQueue; import com.google.domain.registry.flows.EppException; import com.google.domain.registry.model.billing.BillingEvent; +import com.google.domain.registry.model.billing.BillingEvent.Flag; import com.google.domain.registry.model.billing.BillingEvent.Reason; import com.google.domain.registry.model.domain.DomainResource; import com.google.domain.registry.model.domain.DomainResource.Builder; @@ -59,7 +61,8 @@ public abstract class DomainCreateOrAllocateFlow DateTime registrationExpirationTime = leapSafeAddYears(now, command.getPeriod().getValue()); // Create a new autorenew billing event and poll message starting at the expiration time. BillingEvent.Recurring autorenewEvent = new BillingEvent.Recurring.Builder() - .setReason(Reason.AUTO_RENEW) + .setReason(Reason.RENEW) + .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setTargetId(targetId) .setClientId(getClientId()) .setEventTime(registrationExpirationTime) diff --git a/java/com/google/domain/registry/flows/domain/DomainFlowUtils.java b/java/com/google/domain/registry/flows/domain/DomainFlowUtils.java index b825be507..66de9dd3d 100644 --- a/java/com/google/domain/registry/flows/domain/DomainFlowUtils.java +++ b/java/com/google/domain/registry/flows/domain/DomainFlowUtils.java @@ -49,6 +49,7 @@ import com.google.domain.registry.flows.EppException.StatusProhibitsOperationExc import com.google.domain.registry.flows.EppException.UnimplementedOptionException; import com.google.domain.registry.model.EppResource; import com.google.domain.registry.model.billing.BillingEvent; +import com.google.domain.registry.model.billing.BillingEvent.Flag; import com.google.domain.registry.model.billing.BillingEvent.Reason; import com.google.domain.registry.model.contact.ContactResource; import com.google.domain.registry.model.domain.DesignatedContact; @@ -412,7 +413,8 @@ public class DomainFlowUtils { */ static BillingEvent.Recurring.Builder newAutorenewBillingEvent(DomainResource domain) { return new BillingEvent.Recurring.Builder() - .setReason(Reason.AUTO_RENEW) + .setReason(Reason.RENEW) + .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setTargetId(domain.getFullyQualifiedDomainName()) .setClientId(domain.getCurrentSponsorClientId()) .setEventTime(domain.getRegistrationExpirationTime()); diff --git a/java/com/google/domain/registry/flows/domain/DomainTransferApproveFlow.java b/java/com/google/domain/registry/flows/domain/DomainTransferApproveFlow.java index 5d1f265d9..a20961f94 100644 --- a/java/com/google/domain/registry/flows/domain/DomainTransferApproveFlow.java +++ b/java/com/google/domain/registry/flows/domain/DomainTransferApproveFlow.java @@ -27,6 +27,7 @@ import com.google.common.collect.Iterables; import com.google.domain.registry.flows.EppException; import com.google.domain.registry.flows.ResourceTransferApproveFlow; import com.google.domain.registry.model.billing.BillingEvent; +import com.google.domain.registry.model.billing.BillingEvent.Flag; import com.google.domain.registry.model.billing.BillingEvent.Reason; import com.google.domain.registry.model.domain.DomainCommand.Transfer; import com.google.domain.registry.model.domain.DomainResource; @@ -104,7 +105,8 @@ public class DomainTransferApproveFlow extends now, existingResource.getRegistrationExpirationTime(), extraYears); // Create a new autorenew event starting at the expiration time. BillingEvent.Recurring autorenewEvent = new BillingEvent.Recurring.Builder() - .setReason(Reason.AUTO_RENEW) + .setReason(Reason.RENEW) + .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setTargetId(targetId) .setClientId(gainingClientId) .setEventTime(newExpirationTime) diff --git a/java/com/google/domain/registry/flows/domain/DomainTransferRequestFlow.java b/java/com/google/domain/registry/flows/domain/DomainTransferRequestFlow.java index c5c362d7b..efea8f6ef 100644 --- a/java/com/google/domain/registry/flows/domain/DomainTransferRequestFlow.java +++ b/java/com/google/domain/registry/flows/domain/DomainTransferRequestFlow.java @@ -25,9 +25,11 @@ import static com.google.domain.registry.model.ofy.ObjectifyService.ofy; import static com.google.domain.registry.util.DateTimeUtils.END_OF_TIME; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; import com.google.domain.registry.flows.EppException; import com.google.domain.registry.flows.ResourceTransferRequestFlow; import com.google.domain.registry.model.billing.BillingEvent; +import com.google.domain.registry.model.billing.BillingEvent.Flag; import com.google.domain.registry.model.billing.BillingEvent.Reason; import com.google.domain.registry.model.domain.DomainCommand.Transfer; import com.google.domain.registry.model.domain.DomainResource; @@ -126,7 +128,8 @@ public class DomainTransferRequestFlow existingResource.getRegistrationExpirationTime(), command.getPeriod().getValue()); gainingClientAutorenewEvent = new BillingEvent.Recurring.Builder() - .setReason(Reason.AUTO_RENEW) + .setReason(Reason.RENEW) + .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setTargetId(targetId) .setClientId(gainingClient.getId()) .setEventTime(newExpirationTime) @@ -196,7 +199,8 @@ public class DomainTransferRequestFlow if (automaticTransferTime.isAfter(expirationTime) && automaticTransferTime.isBefore( expirationTime.plus(registry.getAutoRenewGracePeriodLength()))) { BillingEvent.Cancellation autorenewCancellation = new BillingEvent.Cancellation.Builder() - .setReason(Reason.AUTO_RENEW) + .setReason(Reason.RENEW) + .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setTargetId(targetId) .setClientId(existingResource.getCurrentSponsorClientId()) .setEventTime(automaticTransferTime) diff --git a/java/com/google/domain/registry/model/billing/BillingEvent.java b/java/com/google/domain/registry/model/billing/BillingEvent.java index bf7334edf..6ffecd9bd 100644 --- a/java/com/google/domain/registry/model/billing/BillingEvent.java +++ b/java/com/google/domain/registry/model/billing/BillingEvent.java @@ -19,6 +19,7 @@ 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 com.google.domain.registry.util.CollectionUtils.nullToEmptyImmutableCopy; +import static com.google.domain.registry.util.CollectionUtils.union; import static com.google.domain.registry.util.DateTimeUtils.END_OF_TIME; import com.google.common.base.Optional; @@ -39,6 +40,7 @@ import com.googlecode.objectify.annotation.Entity; import com.googlecode.objectify.annotation.Id; import com.googlecode.objectify.annotation.IgnoreSave; import com.googlecode.objectify.annotation.Index; +import com.googlecode.objectify.annotation.OnLoad; import com.googlecode.objectify.annotation.Parent; import com.googlecode.objectify.condition.IfNull; @@ -282,6 +284,15 @@ public abstract class BillingEvent extends ImmutableObject @Entity public static class Recurring extends BillingEvent { + // TODO(b/27777398): Remove after migration is complete and Reason.AUTO_RENEW is removed. + @OnLoad + void setAutorenewFlag() { + if (Reason.AUTO_RENEW.equals(reason)) { + reason = Reason.RENEW; + flags = union(getFlags(), Flag.AUTO_RENEW); + } + } + /** * The billing event recurs every year between {@link #eventTime} and this time on the * [month, day, time] specified in {@link #recurrenceTimeOfYear}. @@ -378,7 +389,7 @@ public abstract class BillingEvent extends ImmutableObject static final ImmutableMap GRACE_PERIOD_TO_REASON = ImmutableMap.of( GracePeriodStatus.ADD, Reason.CREATE, - GracePeriodStatus.AUTO_RENEW, Reason.AUTO_RENEW, + GracePeriodStatus.AUTO_RENEW, Reason.RENEW, GracePeriodStatus.RENEW, Reason.RENEW, GracePeriodStatus.TRANSFER, Reason.TRANSFER); diff --git a/javatests/com/google/domain/registry/flows/domain/DomainAllocateFlowTest.java b/javatests/com/google/domain/registry/flows/domain/DomainAllocateFlowTest.java index 10cbcfdce..6b9bc125e 100644 --- a/javatests/com/google/domain/registry/flows/domain/DomainAllocateFlowTest.java +++ b/javatests/com/google/domain/registry/flows/domain/DomainAllocateFlowTest.java @@ -197,7 +197,8 @@ public class DomainAllocateFlowTest assertBillingEvents( createBillingEvent, new BillingEvent.Recurring.Builder() - .setReason(Reason.AUTO_RENEW) + .setReason(Reason.RENEW) + .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setTargetId(domainName) .setClientId(CLIENT_ID) .setEventTime(domain.getRegistrationExpirationTime()) diff --git a/javatests/com/google/domain/registry/flows/domain/DomainCreateFlowTest.java b/javatests/com/google/domain/registry/flows/domain/DomainCreateFlowTest.java index dafd574fb..86d4ded84 100644 --- a/javatests/com/google/domain/registry/flows/domain/DomainCreateFlowTest.java +++ b/javatests/com/google/domain/registry/flows/domain/DomainCreateFlowTest.java @@ -97,6 +97,7 @@ import com.google.domain.registry.flows.domain.DomainFlowUtils.TooManyNameserver import com.google.domain.registry.flows.domain.DomainFlowUtils.TrailingDashException; import com.google.domain.registry.flows.domain.DomainFlowUtils.UnsupportedFeeAttributeException; import com.google.domain.registry.model.billing.BillingEvent; +import com.google.domain.registry.model.billing.BillingEvent.Flag; import com.google.domain.registry.model.billing.BillingEvent.Reason; import com.google.domain.registry.model.domain.DomainResource; import com.google.domain.registry.model.domain.GracePeriod; @@ -189,7 +190,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase .build()); BillingEvent.Recurring autorenewEvent = persistResource( new BillingEvent.Recurring.Builder() - .setReason(Reason.AUTO_RENEW) + .setReason(Reason.RENEW) + .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setTargetId(label + "." + tld) .setClientId("TheRegistrar") .setEventTime(REGISTRATION_EXPIRATION_TIME) @@ -190,7 +192,8 @@ public class DomainTransferFlowTestCase /** Get the autorenew event that the losing client will have after a SERVER_APPROVED transfer. */ protected BillingEvent.Recurring getLosingClientAutorenewEvent() { return new BillingEvent.Recurring.Builder() - .setReason(Reason.AUTO_RENEW) + .setReason(Reason.RENEW) + .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setTargetId(domain.getFullyQualifiedDomainName()) .setClientId("TheRegistrar") .setEventTime(REGISTRATION_EXPIRATION_TIME) @@ -202,7 +205,8 @@ public class DomainTransferFlowTestCase /** Get the autorenew event that the gaining client will have after a SERVER_APPROVED transfer. */ protected BillingEvent.Recurring getGainingClientAutorenewEvent() { return new BillingEvent.Recurring.Builder() - .setReason(Reason.AUTO_RENEW) + .setReason(Reason.RENEW) + .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setTargetId(domain.getFullyQualifiedDomainName()) .setClientId("NewRegistrar") .setEventTime(EXTENDED_REGISTRATION_EXPIRATION_TIME) diff --git a/javatests/com/google/domain/registry/flows/domain/DomainTransferRequestFlowTest.java b/javatests/com/google/domain/registry/flows/domain/DomainTransferRequestFlowTest.java index 319a57af6..988010116 100644 --- a/javatests/com/google/domain/registry/flows/domain/DomainTransferRequestFlowTest.java +++ b/javatests/com/google/domain/registry/flows/domain/DomainTransferRequestFlowTest.java @@ -56,6 +56,7 @@ import com.google.domain.registry.flows.domain.DomainFlowUtils.UnsupportedFeeAtt import com.google.domain.registry.model.EppResource; import com.google.domain.registry.model.billing.BillingEvent; import com.google.domain.registry.model.billing.BillingEvent.Cancellation.Builder; +import com.google.domain.registry.model.billing.BillingEvent.Flag; import com.google.domain.registry.model.billing.BillingEvent.Reason; import com.google.domain.registry.model.contact.ContactAuthInfo; import com.google.domain.registry.model.domain.DomainAuthInfo; @@ -399,7 +400,8 @@ public class DomainTransferRequestFlowTest "domain_transfer_request_response_2_years.xml", clock.nowUtc().plusDays(1).plusYears(2), new BillingEvent.Cancellation.Builder() - .setReason(Reason.AUTO_RENEW) + .setReason(Reason.RENEW) + .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setTargetId("example.tld") .setClientId("TheRegistrar") // The cancellation happens at the moment of transfer. diff --git a/javatests/com/google/domain/registry/model/billing/BillingEventTest.java b/javatests/com/google/domain/registry/model/billing/BillingEventTest.java index 4076f8e37..d335ad09f 100644 --- a/javatests/com/google/domain/registry/model/billing/BillingEventTest.java +++ b/javatests/com/google/domain/registry/model/billing/BillingEventTest.java @@ -25,6 +25,7 @@ import static org.joda.time.DateTimeZone.UTC; import com.google.common.collect.ImmutableSet; import com.google.domain.registry.model.EntityTestCase; +import com.google.domain.registry.model.billing.BillingEvent.Flag; import com.google.domain.registry.model.billing.BillingEvent.Reason; import com.google.domain.registry.model.domain.DomainResource; import com.google.domain.registry.model.domain.GracePeriod; @@ -85,7 +86,8 @@ public class BillingEventTest extends EntityTestCase { recurring = persistResource(commonInit( new BillingEvent.Recurring.Builder() .setParent(historyEntry) - .setReason(Reason.AUTO_RENEW) + .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) + .setReason(Reason.RENEW) .setEventTime(now.plusYears(1)) .setRecurrenceEndTime(END_OF_TIME))); cancellationOneTime = persistResource(commonInit( @@ -98,7 +100,7 @@ public class BillingEventTest extends EntityTestCase { cancellationRecurring = persistResource(commonInit( new BillingEvent.Cancellation.Builder() .setParent(historyEntry2) - .setReason(Reason.AUTO_RENEW) + .setReason(Reason.RENEW) .setEventTime(now.plusDays(1)) .setBillingTime(now.plusYears(1).plusDays(45)) .setRecurringEventRef(Ref.create(recurring)))); diff --git a/javatests/com/google/domain/registry/model/transfer/TransferDataTest.java b/javatests/com/google/domain/registry/model/transfer/TransferDataTest.java index 5f39d36fb..8f712dd77 100644 --- a/javatests/com/google/domain/registry/model/transfer/TransferDataTest.java +++ b/javatests/com/google/domain/registry/model/transfer/TransferDataTest.java @@ -23,6 +23,7 @@ import static org.joda.time.DateTimeZone.UTC; import com.google.common.collect.ImmutableSet; import com.google.domain.registry.model.billing.BillingEvent; +import com.google.domain.registry.model.billing.BillingEvent.Flag; import com.google.domain.registry.model.billing.BillingEvent.Reason; import com.google.domain.registry.model.domain.DomainResource; import com.google.domain.registry.model.poll.PollMessage; @@ -75,7 +76,8 @@ public class TransferDataTest { recurringBillingEvent = persistResource( new BillingEvent.Recurring.Builder() - .setReason(Reason.AUTO_RENEW) + .setReason(Reason.RENEW) + .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setClientId("TheRegistrar") .setTargetId("foo.tld") .setEventTime(now) diff --git a/javatests/com/google/domain/registry/rde/DomainResourceToXjcConverterTest.java b/javatests/com/google/domain/registry/rde/DomainResourceToXjcConverterTest.java index 9ff14d391..bb53f4a01 100644 --- a/javatests/com/google/domain/registry/rde/DomainResourceToXjcConverterTest.java +++ b/javatests/com/google/domain/registry/rde/DomainResourceToXjcConverterTest.java @@ -32,6 +32,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.net.InetAddresses; import com.google.domain.registry.model.billing.BillingEvent; +import com.google.domain.registry.model.billing.BillingEvent.Flag; import com.google.domain.registry.model.billing.BillingEvent.Reason; import com.google.domain.registry.model.contact.ContactAddress; import com.google.domain.registry.model.contact.ContactPhoneNumber; @@ -309,7 +310,8 @@ public class DomainResourceToXjcConverterTest { .setAutorenewBillingEvent( Ref.create(persistResource( new BillingEvent.Recurring.Builder() - .setReason(Reason.AUTO_RENEW) + .setReason(Reason.RENEW) + .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setTargetId("lol") .setClientId("TheRegistrar") .setEventTime(END_OF_TIME) @@ -335,13 +337,14 @@ public class DomainResourceToXjcConverterTest { .setServerApproveAutorenewEvent( Ref.create(persistResource( new BillingEvent.Recurring.Builder() - .setReason(Reason.AUTO_RENEW) + .setReason(Reason.RENEW) + .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setTargetId("example.xn--q9jyb4c") - .setClientId("TheRegistrar") - .setEventTime(END_OF_TIME) - .setRecurrenceEndTime(END_OF_TIME) - .setParent(historyEntry) - .build()))) + .setClientId("TheRegistrar") + .setEventTime(END_OF_TIME) + .setRecurrenceEndTime(END_OF_TIME) + .setParent(historyEntry) + .build()))) .setServerApproveAutorenewPollMessage(Ref.create(persistResource( new Autorenew.Builder() .setTargetId("example.xn--q9jyb4c") diff --git a/javatests/com/google/domain/registry/rde/RdeFixtures.java b/javatests/com/google/domain/registry/rde/RdeFixtures.java index 9e71dfabd..d50999b35 100644 --- a/javatests/com/google/domain/registry/rde/RdeFixtures.java +++ b/javatests/com/google/domain/registry/rde/RdeFixtures.java @@ -27,6 +27,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.net.InetAddresses; import com.google.domain.registry.model.billing.BillingEvent; +import com.google.domain.registry.model.billing.BillingEvent.Flag; import com.google.domain.registry.model.billing.BillingEvent.Reason; import com.google.domain.registry.model.contact.ContactAddress; import com.google.domain.registry.model.contact.ContactPhoneNumber; @@ -133,7 +134,8 @@ final class RdeFixtures { .setAutorenewBillingEvent( Ref.create(persistResource( new BillingEvent.Recurring.Builder() - .setReason(Reason.AUTO_RENEW) + .setReason(Reason.RENEW) + .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setTargetId(tld) .setClientId("TheRegistrar") .setEventTime(END_OF_TIME) @@ -159,13 +161,14 @@ final class RdeFixtures { .setServerApproveAutorenewEvent( Ref.create(persistResource( new BillingEvent.Recurring.Builder() - .setReason(Reason.AUTO_RENEW) + .setReason(Reason.RENEW) + .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setTargetId("example." + tld) - .setClientId("TheRegistrar") - .setEventTime(END_OF_TIME) - .setRecurrenceEndTime(END_OF_TIME) - .setParent(historyEntry) - .build()))) + .setClientId("TheRegistrar") + .setEventTime(END_OF_TIME) + .setRecurrenceEndTime(END_OF_TIME) + .setParent(historyEntry) + .build()))) .setServerApproveAutorenewPollMessage(Ref.create(persistResource( new Autorenew.Builder() .setTargetId("example." + tld) diff --git a/javatests/com/google/domain/registry/testing/DatastoreHelper.java b/javatests/com/google/domain/registry/testing/DatastoreHelper.java index 46f81edc9..84385b9c2 100644 --- a/javatests/com/google/domain/registry/testing/DatastoreHelper.java +++ b/javatests/com/google/domain/registry/testing/DatastoreHelper.java @@ -50,6 +50,7 @@ import com.google.domain.registry.model.EppResource; import com.google.domain.registry.model.EppResource.ForeignKeyedEppResource; import com.google.domain.registry.model.ImmutableObject; import com.google.domain.registry.model.billing.BillingEvent; +import com.google.domain.registry.model.billing.BillingEvent.Flag; import com.google.domain.registry.model.billing.BillingEvent.Reason; import com.google.domain.registry.model.contact.ContactAuthInfo; import com.google.domain.registry.model.contact.ContactResource; @@ -501,7 +502,8 @@ public class DatastoreHelper { extendedRegistrationYears)); BillingEvent.Recurring gainingClientAutorenewEvent = persistResource( new BillingEvent.Recurring.Builder() - .setReason(Reason.AUTO_RENEW) + .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) + .setReason(Reason.RENEW) .setTargetId(domain.getFullyQualifiedDomainName()) .setClientId("NewRegistrar") .setEventTime(extendedRegistrationExpirationTime)