Add an unrenew_domain command to nomulus tool

This is used to reduce the expiration time of domain(s) by some number of years
(if enough length remains in the registration term to do so). This does not back
out the previously saved BillingEvent entities as they may have already been
sent out and invoiced, so any related refunds must be handled out of band.

In addition to reducing the registration expiration time on the domain itself,
this command writes out a new history entry, one-time poll message informing the
registrar of this change, auto-renew billing event and poll message, and
updates/ends the old auto-renew billing event and poll message.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=224999285
This commit is contained in:
mcilwain 2018-12-11 07:31:30 -08:00 committed by jianglai
parent 9c706e79fd
commit f58211402a
21 changed files with 801 additions and 15 deletions

View file

@ -520,7 +520,7 @@ public class DomainFlowUtils {
* Fills in a builder with the data needed for an autorenew billing event for this domain. This
* does not copy over the id of the current autorenew billing event.
*/
static BillingEvent.Recurring.Builder newAutorenewBillingEvent(DomainResource domain) {
public static BillingEvent.Recurring.Builder newAutorenewBillingEvent(DomainResource domain) {
return new BillingEvent.Recurring.Builder()
.setReason(Reason.RENEW)
.setFlags(ImmutableSet.of(Flag.AUTO_RENEW))
@ -533,7 +533,7 @@ public class DomainFlowUtils {
* Fills in a builder with the data needed for an autorenew poll message for this domain. This
* does not copy over the id of the current autorenew poll message.
*/
static PollMessage.Autorenew.Builder newAutorenewPollMessage(DomainResource domain) {
public static PollMessage.Autorenew.Builder newAutorenewPollMessage(DomainResource domain) {
return new PollMessage.Autorenew.Builder()
.setTargetId(domain.getFullyQualifiedDomainName())
.setClientId(domain.getCurrentSponsorClientId())
@ -542,12 +542,14 @@ public class DomainFlowUtils {
}
/**
* Re-saves the current autorenew billing event and poll message with a new end time. This may end
* up deleting the poll message (if closing the message interval) or recreating it (if opening the
* message interval).
* Re-saves the current autorenew billing event and poll message with a new end time.
*
* <p>This may end up deleting the poll message (if closing the message interval) or recreating it
* (if opening the message interval). This may cause an autorenew billing event to have an end
* time earlier than its event time (i.e. if it's being ended before it was ever triggered).
*/
@SuppressWarnings("unchecked")
static void updateAutorenewRecurrenceEndTime(DomainResource domain, DateTime newEndTime) {
public static void updateAutorenewRecurrenceEndTime(DomainResource domain, DateTime newEndTime) {
Optional<PollMessage.Autorenew> autorenewPollMessage =
Optional.ofNullable(ofy().load().key(domain.getAutorenewPollMessage()).now());