mirror of
https://github.com/google/nomulus.git
synced 2025-08-11 20:19:37 +02:00
Turn Flow into an interface and inject all its fields
This concludes your flow flattening experience. Please fill out a flow flattening satisfaction survey before exiting. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=137903095
This commit is contained in:
parent
82b0bff9b5
commit
053538b1b5
49 changed files with 630 additions and 569 deletions
|
@ -28,7 +28,6 @@ import static google.registry.flows.domain.DomainFlowUtils.verifyUnitIsYears;
|
|||
import static google.registry.model.domain.DomainResource.MAX_REGISTRATION_YEARS;
|
||||
import static google.registry.model.domain.DomainResource.extendRegistrationWithCap;
|
||||
import static google.registry.model.domain.fee.Fee.FEE_RENEW_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER;
|
||||
import static google.registry.model.eppoutput.Result.Code.SUCCESS;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.util.DateTimeUtils.leapSafeAddYears;
|
||||
|
||||
|
@ -40,8 +39,8 @@ import google.registry.flows.EppException;
|
|||
import google.registry.flows.EppException.ObjectPendingTransferException;
|
||||
import google.registry.flows.EppException.ParameterValueRangeErrorException;
|
||||
import google.registry.flows.ExtensionManager;
|
||||
import google.registry.flows.Flow;
|
||||
import google.registry.flows.FlowModule.ClientId;
|
||||
import google.registry.flows.FlowModule.Superuser;
|
||||
import google.registry.flows.FlowModule.TargetId;
|
||||
import google.registry.flows.TransactionalFlow;
|
||||
import google.registry.flows.domain.TldSpecificLogicProxy.EppCommandOperations;
|
||||
|
@ -60,8 +59,9 @@ import google.registry.model.domain.metadata.MetadataExtension;
|
|||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
||||
import google.registry.model.eppcommon.AuthInfo;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.eppinput.EppInput;
|
||||
import google.registry.model.eppinput.ResourceCommand;
|
||||
import google.registry.model.eppoutput.EppOutput;
|
||||
import google.registry.model.eppoutput.EppResponse;
|
||||
import google.registry.model.poll.PollMessage;
|
||||
import google.registry.model.registry.Registry;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
|
@ -97,7 +97,7 @@ import org.joda.time.DateTime;
|
|||
* @error {@link DomainRenewFlow.ExceedsMaxRegistrationYearsException}
|
||||
* @error {@link DomainRenewFlow.IncorrectCurrentExpirationDateException}
|
||||
*/
|
||||
public final class DomainRenewFlow extends Flow implements TransactionalFlow {
|
||||
public final class DomainRenewFlow implements TransactionalFlow {
|
||||
|
||||
private static final ImmutableSet<StatusValue> RENEW_DISALLOWED_STATUSES = ImmutableSet.of(
|
||||
StatusValue.CLIENT_RENEW_PROHIBITED,
|
||||
|
@ -106,18 +106,22 @@ public final class DomainRenewFlow extends Flow implements TransactionalFlow {
|
|||
|
||||
@Inject ResourceCommand resourceCommand;
|
||||
@Inject ExtensionManager extensionManager;
|
||||
@Inject EppInput eppInput;
|
||||
@Inject Optional<AuthInfo> authInfo;
|
||||
@Inject @ClientId String clientId;
|
||||
@Inject @TargetId String targetId;
|
||||
@Inject @Superuser boolean isSuperuser;
|
||||
@Inject HistoryEntry.Builder historyBuilder;
|
||||
@Inject EppResponse.Builder responseBuilder;
|
||||
@Inject DomainRenewFlow() {}
|
||||
|
||||
@Override
|
||||
public final EppOutput run() throws EppException {
|
||||
public final EppResponse run() throws EppException {
|
||||
extensionManager.register(MetadataExtension.class);
|
||||
extensionManager.registerAsGroup(FEE_RENEW_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER);
|
||||
extensionManager.validate();
|
||||
validateClientIsLoggedIn(clientId);
|
||||
DateTime now = ofy().getTransactionTime();
|
||||
Renew command = (Renew) resourceCommand;
|
||||
// Loads the target resource if it exists
|
||||
DomainResource existingDomain = loadAndVerifyExistence(DomainResource.class, targetId, now);
|
||||
|
@ -143,7 +147,7 @@ public final class DomainRenewFlow extends Flow implements TransactionalFlow {
|
|||
String tld = existingDomain.getTld();
|
||||
// Bill for this explicit renew itself.
|
||||
BillingEvent.OneTime explicitRenewEvent =
|
||||
createRenewBillingEvent(tld, commandOperations.getTotalCost(), years, historyEntry);
|
||||
createRenewBillingEvent(tld, commandOperations.getTotalCost(), years, historyEntry, now);
|
||||
// Create a new autorenew billing event and poll message starting at the new expiration time.
|
||||
BillingEvent.Recurring newAutorenewEvent = newAutorenewBillingEvent(existingDomain)
|
||||
.setEventTime(newExpirationTime)
|
||||
|
@ -170,10 +174,10 @@ public final class DomainRenewFlow extends Flow implements TransactionalFlow {
|
|||
.build();
|
||||
ofy().save().<Object>entities(
|
||||
newDomain, historyEntry, explicitRenewEvent, newAutorenewEvent, newAutorenewPollMessage);
|
||||
return createOutput(
|
||||
SUCCESS,
|
||||
DomainRenewData.create(targetId, newExpirationTime),
|
||||
createResponseExtensions(commandOperations.getTotalCost(), feeRenew));
|
||||
return responseBuilder
|
||||
.setResData(DomainRenewData.create(targetId, newExpirationTime))
|
||||
.setExtensions(createResponseExtensions(commandOperations.getTotalCost(), feeRenew))
|
||||
.build();
|
||||
}
|
||||
|
||||
private void verifyRenewAllowed(
|
||||
|
@ -199,7 +203,7 @@ public final class DomainRenewFlow extends Flow implements TransactionalFlow {
|
|||
}
|
||||
|
||||
private OneTime createRenewBillingEvent(
|
||||
String tld, Money renewCost, int years, HistoryEntry historyEntry) {
|
||||
String tld, Money renewCost, int years, HistoryEntry historyEntry, DateTime now) {
|
||||
return new BillingEvent.OneTime.Builder()
|
||||
.setReason(Reason.RENEW)
|
||||
.setTargetId(targetId)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue