mirror of
https://github.com/google/nomulus.git
synced 2025-05-16 17:37:13 +02:00
Begin writing AUTO_RENEW flag alongside reason
Backfill [] to follow, and the Recurring billing events will eventually be replicated as OneTime via a regular job. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=119883652
This commit is contained in:
parent
fbe076b5da
commit
4112bca925
18 changed files with 87 additions and 36 deletions
|
@ -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)
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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<GracePeriodStatus, Reason> 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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue