mirror of
https://github.com/google/nomulus
synced 2026-09-05 23:57:01 +00:00
Make GracePeriod OneTime vs Recurring logic explicit
This CL cleans up some old crufy logic in GracePeriod that overloaded methods to accept either OneTime or Recurring billing events refs, despite storing them in separate fields in the entity (since BillingEvent is not a polymorphic superclass, just a Java-only one, you can't store them as refs to BillingEvent). That overloading was ultimately only there as a convenience/hack from when we added Recurring events and didn't want to go back and change everything. It obfuscates what's really going on, requires extra casting/loss of type-safety, and relies on indirect signals (e.g. the grace period type being AUTO_RENEW) to guess what the right billing event type is. That latter aspect will likely no longer work in a monthly billing world, and was brittle in any case. A coming CL will rip the same logic out of Cancellation. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=117164286
This commit is contained in:
@@ -110,11 +110,10 @@ public class DomainDeleteFlow extends ResourceSyncDeleteFlow<DomainResource, Bui
|
||||
.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.
|
||||
.setGracePeriods(ImmutableSet.of(GracePeriod.create(
|
||||
.setGracePeriods(ImmutableSet.of(GracePeriod.createWithoutBillingEvent(
|
||||
GracePeriodStatus.REDEMPTION,
|
||||
now.plus(registry.getRedemptionGracePeriodLength()),
|
||||
getClientId(),
|
||||
null)))
|
||||
getClientId())))
|
||||
.setDeletePollMessage(Key.create(deletePollMessage));
|
||||
}
|
||||
}
|
||||
@@ -130,7 +129,7 @@ public class DomainDeleteFlow extends ResourceSyncDeleteFlow<DomainResource, Bui
|
||||
ImmutableList.Builder<Credit> creditsBuilder = new ImmutableList.Builder<>();
|
||||
for (GracePeriod gracePeriod : existingResource.getGracePeriods()) {
|
||||
// No cancellation is written if the grace period was not for a billable event.
|
||||
if (gracePeriod.getBillingEvent() != null) {
|
||||
if (gracePeriod.hasBillingEvent()) {
|
||||
ofy().save().entity(
|
||||
BillingEvent.Cancellation.forGracePeriod(gracePeriod, historyEntry, targetId));
|
||||
|
||||
|
||||
@@ -104,7 +104,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 =
|
||||
((BillingEvent.OneTime) sunrushAddGracePeriod.get().getBillingEvent().get());
|
||||
sunrushAddGracePeriod.get().getOneTimeBillingEvent().get();
|
||||
BillingEvent.OneTime billingEvent = new BillingEvent.OneTime.Builder()
|
||||
.setReason(Reason.CREATE)
|
||||
.setTargetId(targetId)
|
||||
|
||||
Reference in New Issue
Block a user