diff --git a/java/google/registry/flows/custom/DomainPricingCustomLogic.java b/java/google/registry/flows/custom/DomainPricingCustomLogic.java index 35599c7d4..67b7724e8 100644 --- a/java/google/registry/flows/custom/DomainPricingCustomLogic.java +++ b/java/google/registry/flows/custom/DomainPricingCustomLogic.java @@ -21,6 +21,7 @@ import google.registry.flows.SessionMetadata; import google.registry.flows.domain.DomainPricingLogic; import google.registry.flows.domain.DomainPricingLogic.FeesAndCredits; import google.registry.model.ImmutableObject; +import google.registry.model.domain.DomainApplication; import google.registry.model.eppinput.EppInput; import google.registry.model.registry.Registry; import org.joda.time.DateTime; @@ -36,11 +37,78 @@ public class DomainPricingCustomLogic extends BaseFlowCustomLogic { super(eppInput, sessionMetadata); } - /** A hook that customizes create price. */ + /** A hook that customizes the application update price. */ @SuppressWarnings("unused") - public FeesAndCredits customizeCreatePrice(CreatePriceParameters createPriceParameters) + public FeesAndCredits customizeApplicationUpdatePrice( + ApplicationUpdatePriceParameters priceParameters) throws EppException { + return priceParameters.feesAndCredits(); + } + + /** A hook that customizes the create price. */ + @SuppressWarnings("unused") + public FeesAndCredits customizeCreatePrice(CreatePriceParameters priceParameters) throws EppException { - return createPriceParameters.feesAndCredits(); + return priceParameters.feesAndCredits(); + } + + /** A hook that customizes the renew price. */ + @SuppressWarnings("unused") + public FeesAndCredits customizeRenewPrice(RenewPriceParameters priceParameters) + throws EppException { + return priceParameters.feesAndCredits(); + } + + /** A hook that customizes the restore price. */ + @SuppressWarnings("unused") + public FeesAndCredits customizeRestorePrice(RestorePriceParameters priceParameters) + throws EppException { + return priceParameters.feesAndCredits(); + } + + /** A hook that customizes the transfer price. */ + @SuppressWarnings("unused") + public FeesAndCredits customizeTransferPrice(TransferPriceParameters priceParameters) + throws EppException { + return priceParameters.feesAndCredits(); + } + + /** A hook that customizes the update price. */ + @SuppressWarnings("unused") + public FeesAndCredits customizeUpdatePrice(UpdatePriceParameters priceParameters) + throws EppException { + return priceParameters.feesAndCredits(); + } + + /** A class to encapsulate parameters for a call to {@link #customizeApplicationUpdatePrice} . */ + @AutoValue + public abstract static class ApplicationUpdatePriceParameters extends ImmutableObject { + + public abstract FeesAndCredits feesAndCredits(); + + public abstract Registry registry(); + + public abstract DomainApplication domainApplication(); + + public abstract DateTime asOfDate(); + + public static Builder newBuilder() { + return new AutoValue_DomainPricingCustomLogic_ApplicationUpdatePriceParameters.Builder(); + } + + /** Builder for {@link ApplicationUpdatePriceParameters}. */ + @AutoValue.Builder + public abstract static class Builder { + + public abstract Builder setFeesAndCredits(FeesAndCredits feesAndCredits); + + public abstract Builder setRegistry(Registry registry); + + public abstract Builder setDomainApplication(DomainApplication domainApplication); + + public abstract Builder setAsOfDate(DateTime asOfDate); + + public abstract ApplicationUpdatePriceParameters build(); + } } /** A class to encapsulate parameters for a call to {@link #customizeCreatePrice} . */ @@ -78,4 +146,140 @@ public class DomainPricingCustomLogic extends BaseFlowCustomLogic { public abstract CreatePriceParameters build(); } } + + /** A class to encapsulate parameters for a call to {@link #customizeRenewPrice} . */ + @AutoValue + public abstract static class RenewPriceParameters extends ImmutableObject { + + public abstract FeesAndCredits feesAndCredits(); + + public abstract Registry registry(); + + public abstract InternetDomainName domainName(); + + public abstract DateTime asOfDate(); + + public abstract int years(); + + public static Builder newBuilder() { + return new AutoValue_DomainPricingCustomLogic_RenewPriceParameters.Builder(); + } + + /** Builder for {@link RenewPriceParameters}. */ + @AutoValue.Builder + public abstract static class Builder { + + public abstract Builder setFeesAndCredits(FeesAndCredits feesAndCredits); + + public abstract Builder setRegistry(Registry registry); + + public abstract Builder setDomainName(InternetDomainName domainName); + + public abstract Builder setAsOfDate(DateTime asOfDate); + + public abstract Builder setYears(int years); + + public abstract RenewPriceParameters build(); + } + } + + /** A class to encapsulate parameters for a call to {@link #customizeRestorePrice} . */ + @AutoValue + public abstract static class RestorePriceParameters extends ImmutableObject { + + public abstract FeesAndCredits feesAndCredits(); + + public abstract Registry registry(); + + public abstract InternetDomainName domainName(); + + public abstract DateTime asOfDate(); + + public static Builder newBuilder() { + return new AutoValue_DomainPricingCustomLogic_RestorePriceParameters.Builder(); + } + + /** Builder for {@link RestorePriceParameters}. */ + @AutoValue.Builder + public abstract static class Builder { + + public abstract Builder setFeesAndCredits(FeesAndCredits feesAndCredits); + + public abstract Builder setRegistry(Registry registry); + + public abstract Builder setDomainName(InternetDomainName domainName); + + public abstract Builder setAsOfDate(DateTime asOfDate); + + public abstract RestorePriceParameters build(); + } + } + + /** A class to encapsulate parameters for a call to {@link #customizeTransferPrice} . */ + @AutoValue + public abstract static class TransferPriceParameters extends ImmutableObject { + + public abstract FeesAndCredits feesAndCredits(); + + public abstract Registry registry(); + + public abstract InternetDomainName domainName(); + + public abstract DateTime asOfDate(); + + public abstract int years(); + + public static Builder newBuilder() { + return new AutoValue_DomainPricingCustomLogic_TransferPriceParameters.Builder(); + } + + /** Builder for {@link TransferPriceParameters}. */ + @AutoValue.Builder + public abstract static class Builder { + + public abstract Builder setFeesAndCredits(FeesAndCredits feesAndCredits); + + public abstract Builder setRegistry(Registry registry); + + public abstract Builder setDomainName(InternetDomainName domainName); + + public abstract Builder setAsOfDate(DateTime asOfDate); + + public abstract Builder setYears(int years); + + public abstract TransferPriceParameters build(); + } + } + + /** A class to encapsulate parameters for a call to {@link #customizeUpdatePrice} . */ + @AutoValue + public abstract static class UpdatePriceParameters extends ImmutableObject { + + public abstract FeesAndCredits feesAndCredits(); + + public abstract Registry registry(); + + public abstract InternetDomainName domainName(); + + public abstract DateTime asOfDate(); + + public static Builder newBuilder() { + return new AutoValue_DomainPricingCustomLogic_UpdatePriceParameters.Builder(); + } + + /** Builder for {@link UpdatePriceParameters}. */ + @AutoValue.Builder + public abstract static class Builder { + + public abstract Builder setFeesAndCredits(FeesAndCredits feesAndCredits); + + public abstract Builder setRegistry(Registry registry); + + public abstract Builder setDomainName(InternetDomainName domainName); + + public abstract Builder setAsOfDate(DateTime asOfDate); + + public abstract UpdatePriceParameters build(); + } + } } diff --git a/java/google/registry/flows/domain/DomainAllocateFlow.java b/java/google/registry/flows/domain/DomainAllocateFlow.java index 831d61d15..69a662875 100644 --- a/java/google/registry/flows/domain/DomainAllocateFlow.java +++ b/java/google/registry/flows/domain/DomainAllocateFlow.java @@ -37,7 +37,6 @@ import static google.registry.util.CollectionUtils.isNullOrEmpty; import static google.registry.util.DateTimeUtils.END_OF_TIME; import static google.registry.util.DateTimeUtils.leapSafeAddYears; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.net.InternetDomainName; @@ -177,7 +176,6 @@ public class DomainAllocateFlow implements TransactionalFlow { .setNameservers(command.getNameservers()) .setContacts(command.getContacts()) .build(); - handleExtraFlowLogic(registry.getTldStr(), years, historyEntry, newDomain, now); entitiesToSave.add( newDomain, buildApplicationHistory(application, now), @@ -363,22 +361,6 @@ public class DomainAllocateFlow implements TransactionalFlow { && !matchesAnchorTenantReservation(domainName, authInfoToken); } - private void handleExtraFlowLogic( - String tld, int years, HistoryEntry historyEntry, DomainResource newDomain, DateTime now) - throws EppException { - Optional extraFlowLogic = - RegistryExtraFlowLogicProxy.newInstanceForTld(tld); - if (extraFlowLogic.isPresent()) { - extraFlowLogic.get().performAdditionalDomainAllocateLogic( - newDomain, - clientId, - now, - years, - eppInput, - historyEntry); - } - } - private void enqueueTasks(AllocateCreateExtension allocateCreate, DomainResource newDomain) { if (newDomain.shouldPublishToDns()) { DnsQueue.create().addDomainRefreshTask(newDomain.getFullyQualifiedDomainName()); diff --git a/java/google/registry/flows/domain/DomainApplicationCreateFlow.java b/java/google/registry/flows/domain/DomainApplicationCreateFlow.java index 94fb1c4d0..8a3125089 100644 --- a/java/google/registry/flows/domain/DomainApplicationCreateFlow.java +++ b/java/google/registry/flows/domain/DomainApplicationCreateFlow.java @@ -44,7 +44,6 @@ import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.registry.label.ReservedList.matchesAnchorTenantReservation; import com.google.common.base.Function; -import com.google.common.base.Optional; import com.google.common.collect.FluentIterable; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; @@ -260,8 +259,6 @@ public final class DomainApplicationCreateFlow implements TransactionalFlow { .build(); HistoryEntry historyEntry = buildHistory(newApplication.getRepoId(), command.getPeriod(), now); ImmutableSet.Builder entitiesToSave = new ImmutableSet.Builder<>(); - handleExtraFlowLogic( - registry.getTldStr(), command.getPeriod().getValue(), historyEntry, newApplication); entitiesToSave.add( newApplication, historyEntry, @@ -383,21 +380,6 @@ public final class DomainApplicationCreateFlow implements TransactionalFlow { return responseExtensionsBuilder.build(); } - private void handleExtraFlowLogic( - String tld, int years, HistoryEntry historyEntry, DomainApplication newApplication) - throws EppException { - Optional extraFlowLogic = - RegistryExtraFlowLogicProxy.newInstanceForTld(tld); - if (extraFlowLogic.isPresent()) { - extraFlowLogic.get().performAdditionalApplicationCreateLogic( - newApplication, - clientId, - years, - eppInput, - historyEntry); - } - } - /** Landrush applications are disallowed during sunrise. */ static class LandrushApplicationDisallowedDuringSunriseException extends RequiredParameterMissingException { diff --git a/java/google/registry/flows/domain/DomainApplicationDeleteFlow.java b/java/google/registry/flows/domain/DomainApplicationDeleteFlow.java index 9248b8889..b627b49be 100644 --- a/java/google/registry/flows/domain/DomainApplicationDeleteFlow.java +++ b/java/google/registry/flows/domain/DomainApplicationDeleteFlow.java @@ -108,21 +108,10 @@ public final class DomainApplicationDeleteFlow implements TransactionalFlow { .setParent(Key.create(existingApplication)) .build(); updateForeignKeyIndexDeletionTime(newApplication); - handleExtraFlowLogic(tld, historyEntry, existingApplication, now); ofy().save().entities(newApplication, historyEntry); return responseBuilder.build(); } - private void handleExtraFlowLogic(String tld, HistoryEntry historyEntry, - DomainApplication existingApplication, DateTime now) throws EppException { - Optional extraFlowLogic = - RegistryExtraFlowLogicProxy.newInstanceForTld(tld); - if (extraFlowLogic.isPresent()) { - extraFlowLogic.get().performAdditionalApplicationDeleteLogic( - existingApplication, clientId, now, eppInput, historyEntry); - } - } - /** A sunrise application cannot be deleted during landrush. */ static class SunriseApplicationCannotBeDeletedInLandrushException extends StatusProhibitsOperationException { diff --git a/java/google/registry/flows/domain/DomainApplicationInfoFlow.java b/java/google/registry/flows/domain/DomainApplicationInfoFlow.java index f42e13843..92898244c 100644 --- a/java/google/registry/flows/domain/DomainApplicationInfoFlow.java +++ b/java/google/registry/flows/domain/DomainApplicationInfoFlow.java @@ -35,7 +35,6 @@ import google.registry.flows.FlowModule.ClientId; import google.registry.flows.FlowModule.TargetId; import google.registry.model.domain.DomainApplication; import google.registry.model.domain.DomainCommand.Info; -import google.registry.model.domain.flags.FlagsInfoResponseExtension; import google.registry.model.domain.launch.LaunchInfoExtension; import google.registry.model.domain.launch.LaunchInfoResponseExtension; import google.registry.model.eppcommon.AuthInfo; @@ -47,7 +46,6 @@ import google.registry.model.mark.Mark; import google.registry.model.smd.EncodedSignedMark; import google.registry.model.smd.SignedMark; import google.registry.util.Clock; -import java.util.Set; import javax.inject.Inject; import org.joda.time.DateTime; @@ -136,16 +134,6 @@ public final class DomainApplicationInfoFlow implements Flow { .setMarks(marksBuilder.build()) .build()); addSecDnsExtensionIfPresent(extensions, application.getDsData()); - // If the TLD uses the flags extension, add it to the info response. - Optional extraLogicManager = - RegistryExtraFlowLogicProxy.newInstanceForDomain(application); - if (extraLogicManager.isPresent()) { - Set flags = extraLogicManager.get().getApplicationExtensionFlags( - application, clientId, now); // As-of date is always now for info commands. - if (!flags.isEmpty()) { - extensions.add(FlagsInfoResponseExtension.create(ImmutableList.copyOf(flags))); - } - } return extensions.build(); } diff --git a/java/google/registry/flows/domain/DomainApplicationUpdateFlow.java b/java/google/registry/flows/domain/DomainApplicationUpdateFlow.java index 2b933431a..c0b53ed8f 100644 --- a/java/google/registry/flows/domain/DomainApplicationUpdateFlow.java +++ b/java/google/registry/flows/domain/DomainApplicationUpdateFlow.java @@ -55,7 +55,7 @@ import google.registry.flows.FlowModule.Superuser; import google.registry.flows.FlowModule.TargetId; import google.registry.flows.TransactionalFlow; import google.registry.flows.domain.DomainFlowUtils.FeesRequiredForNonFreeUpdateException; -import google.registry.flows.domain.TldSpecificLogicProxy.EppCommandOperations; +import google.registry.flows.domain.DomainPricingLogic.FeesAndCredits; import google.registry.model.ImmutableObject; import google.registry.model.domain.DomainApplication; import google.registry.model.domain.DomainCommand.Update; @@ -137,6 +137,7 @@ public class DomainApplicationUpdateFlow implements TransactionalFlow { @Inject @Superuser boolean isSuperuser; @Inject HistoryEntry.Builder historyBuilder; @Inject EppResponse.Builder responseBuilder; + @Inject DomainPricingLogic pricingLogic; @Inject DomainApplicationUpdateFlow() {} @Override @@ -160,7 +161,6 @@ public class DomainApplicationUpdateFlow implements TransactionalFlow { HistoryEntry historyEntry = buildHistory(existingApplication, now); DomainApplication newApplication = updateApplication(existingApplication, command, now); validateNewApplication(newApplication); - handleExtraFlowLogic(newApplication.getTld(), historyEntry, newApplication, now); ofy().save().entities(newApplication, historyEntry); return responseBuilder.build(); } @@ -181,14 +181,14 @@ public class DomainApplicationUpdateFlow implements TransactionalFlow { throw new ApplicationStatusProhibitsUpdateException( existingApplication.getApplicationStatus()); } - EppCommandOperations commandOperations = TldSpecificLogicProxy.getApplicationUpdatePrice( - Registry.get(tld), existingApplication, clientId, now, eppInput); + FeesAndCredits feesAndCredits = + pricingLogic.getApplicationUpdatePrice(Registry.get(tld), existingApplication, now); FeeUpdateCommandExtension feeUpdate = eppInput.getSingleExtension(FeeUpdateCommandExtension.class); // If the fee extension is present, validate it (even if the cost is zero, to check for price // mismatches). Don't rely on the the validateFeeChallenge check for feeUpdate nullness, because // it throws an error if the name is premium, and we don't want to do that here. - Money totalCost = commandOperations.getTotalCost(); + Money totalCost = feesAndCredits.getTotalCost(); if (feeUpdate != null) { validateFeeChallenge(targetId, tld, now, feeUpdate, totalCost); } else if (!totalCost.isZero()) { @@ -248,16 +248,6 @@ public class DomainApplicationUpdateFlow implements TransactionalFlow { validateNameserversCountForTld(newApplication.getTld(), newApplication.getNameservers().size()); } - private void handleExtraFlowLogic(String tld, HistoryEntry historyEntry, - DomainApplication newApplication, DateTime now) throws EppException { - Optional extraFlowLogic = - RegistryExtraFlowLogicProxy.newInstanceForTld(tld); - if (extraFlowLogic.isPresent()) { - extraFlowLogic.get().performAdditionalApplicationUpdateLogic( - newApplication, clientId, now, eppInput, historyEntry); - } - } - /** Application status prohibits this domain update. */ static class ApplicationStatusProhibitsUpdateException extends StatusProhibitsOperationException { public ApplicationStatusProhibitsUpdateException(ApplicationStatus status) { diff --git a/java/google/registry/flows/domain/DomainCheckFlow.java b/java/google/registry/flows/domain/DomainCheckFlow.java index 9d17ef325..9c4f850b7 100644 --- a/java/google/registry/flows/domain/DomainCheckFlow.java +++ b/java/google/registry/flows/domain/DomainCheckFlow.java @@ -206,10 +206,8 @@ public final class DomainCheckFlow implements Flow { feeCheckItem, builder, domainNames.get(domainName), - clientId, feeCheck.getCurrency(), now, - eppInput, pricingLogic); responseItems.add(builder.setDomainNameIfSupported(domainName).build()); } diff --git a/java/google/registry/flows/domain/DomainDeleteFlow.java b/java/google/registry/flows/domain/DomainDeleteFlow.java index 2313d83b7..aa2a6ef23 100644 --- a/java/google/registry/flows/domain/DomainDeleteFlow.java +++ b/java/google/registry/flows/domain/DomainDeleteFlow.java @@ -156,7 +156,6 @@ public final class DomainDeleteFlow implements TransactionalFlow { clientId))) .setDeletePollMessage(Key.create(deletePollMessage)); } - handleExtraFlowLogic(existingDomain, historyEntry, now); DomainResource newDomain = builder.build(); updateForeignKeyIndexDeletionTime(newDomain); handlePendingTransferOnDelete(existingDomain, newDomain, now, historyEntry); @@ -233,17 +232,6 @@ public final class DomainDeleteFlow implements TransactionalFlow { .build(); } - private void handleExtraFlowLogic( - DomainResource existingResource, HistoryEntry historyEntry, DateTime now) - throws EppException { - Optional extraFlowLogic = - RegistryExtraFlowLogicProxy.newInstanceForDomain(existingResource); - if (extraFlowLogic.isPresent()) { - extraFlowLogic.get().performAdditionalDomainDeleteLogic( - existingResource, clientId, now, eppInput, historyEntry); - } - } - @Nullable private ImmutableList getResponseExtensions( DomainResource existingDomain, DateTime now) { diff --git a/java/google/registry/flows/domain/DomainFlowUtils.java b/java/google/registry/flows/domain/DomainFlowUtils.java index 75064f8fe..a305845d8 100644 --- a/java/google/registry/flows/domain/DomainFlowUtils.java +++ b/java/google/registry/flows/domain/DomainFlowUtils.java @@ -22,7 +22,7 @@ import static com.google.common.collect.Iterables.concat; import static com.google.common.collect.Sets.difference; import static com.google.common.collect.Sets.union; import static google.registry.flows.EppXmlTransformer.unmarshal; -import static google.registry.flows.domain.TldSpecificLogicProxy.getMatchingLrpToken; +import static google.registry.flows.domain.DomainPricingLogic.getMatchingLrpToken; import static google.registry.model.EppResourceUtils.loadByForeignKey; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.registry.Registries.findTldForName; @@ -94,7 +94,6 @@ import google.registry.model.domain.secdns.SecDnsUpdateExtension; import google.registry.model.domain.secdns.SecDnsUpdateExtension.Add; import google.registry.model.domain.secdns.SecDnsUpdateExtension.Remove; import google.registry.model.eppcommon.StatusValue; -import google.registry.model.eppinput.EppInput; import google.registry.model.eppoutput.EppResponse.ResponseExtension; import google.registry.model.host.HostResource; import google.registry.model.mark.Mark; @@ -586,10 +585,8 @@ public class DomainFlowUtils { FeeQueryCommandExtensionItem feeRequest, FeeQueryResponseExtensionItem.Builder builder, InternetDomainName domain, - String clientId, @Nullable CurrencyUnit topLevelCurrency, DateTime currentDate, - EppInput eppInput, DomainPricingLogic pricingLogic) throws EppException { DateTime now = currentDate; @@ -617,7 +614,7 @@ public class DomainFlowUtils { .setCommand(feeRequest.getCommandName(), feeRequest.getPhase(), feeRequest.getSubphase()) .setCurrencyIfSupported(registry.getCurrency()) .setPeriod(feeRequest.getPeriod()) - .setClass(TldSpecificLogicProxy.getFeeClass(domainNameString, now).orNull()); + .setClass(pricingLogic.getFeeClass(domainNameString, now).orNull()); ImmutableList fees = ImmutableList.of(); switch (feeRequest.getCommandName()) { @@ -633,26 +630,22 @@ public class DomainFlowUtils { break; case RENEW: builder.setAvailIfSupported(true); - fees = TldSpecificLogicProxy.getRenewPrice( - registry, domainNameString, clientId, now, years, eppInput).getFees(); + fees = pricingLogic.getRenewPrice(registry, domainNameString, now, years).getFees(); break; case RESTORE: if (years != 1) { throw new RestoresAreAlwaysForOneYearException(); } builder.setAvailIfSupported(true); - fees = TldSpecificLogicProxy.getRestorePrice( - registry, domainNameString, clientId, now, eppInput).getFees(); + fees = pricingLogic.getRestorePrice(registry, domainNameString, now).getFees(); break; case TRANSFER: builder.setAvailIfSupported(true); - fees = TldSpecificLogicProxy.getTransferPrice( - registry, domainNameString, clientId, now, years, eppInput).getFees(); + fees = pricingLogic.getTransferPrice(registry, domainNameString, now, years).getFees(); break; case UPDATE: builder.setAvailIfSupported(true); - fees = TldSpecificLogicProxy.getUpdatePrice( - registry, domainNameString, clientId, now, eppInput).getFees(); + fees = pricingLogic.getUpdatePrice(registry, domainNameString, now).getFees(); break; default: throw new UnknownFeeCommandException(feeRequest.getUnparsedCommandName()); diff --git a/java/google/registry/flows/domain/DomainInfoFlow.java b/java/google/registry/flows/domain/DomainInfoFlow.java index 888994241..e349474dd 100644 --- a/java/google/registry/flows/domain/DomainInfoFlow.java +++ b/java/google/registry/flows/domain/DomainInfoFlow.java @@ -39,7 +39,6 @@ import google.registry.model.domain.DomainResource; import google.registry.model.domain.DomainResource.Builder; import google.registry.model.domain.fee06.FeeInfoCommandExtensionV06; import google.registry.model.domain.fee06.FeeInfoResponseExtensionV06; -import google.registry.model.domain.flags.FlagsInfoResponseExtension; import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.domain.rgp.RgpInfoExtension; import google.registry.model.eppcommon.AuthInfo; @@ -48,7 +47,6 @@ import google.registry.model.eppinput.ResourceCommand; import google.registry.model.eppoutput.EppResponse; import google.registry.model.eppoutput.EppResponse.ResponseExtension; import google.registry.util.Clock; -import java.util.Set; import javax.inject.Inject; import org.joda.time.DateTime; @@ -149,26 +147,11 @@ public final class DomainInfoFlow implements Flow { feeInfo, builder, InternetDomainName.from(targetId), - clientId, null, now, - eppInput, pricingLogic); extensions.add(builder.build()); } - // If the TLD uses the flags extension, add it to the info response. - Optional extraLogicManager = - RegistryExtraFlowLogicProxy.newInstanceForDomain(domain); - if (extraLogicManager.isPresent()) { - Set flags = - extraLogicManager - .get() - .getExtensionFlags( - domain, clientId, now); // As-of date is always now for info commands. - if (!flags.isEmpty()) { - extensions.add(FlagsInfoResponseExtension.create(ImmutableList.copyOf(flags))); - } - } return extensions.build(); } } diff --git a/java/google/registry/flows/domain/DomainPricingLogic.java b/java/google/registry/flows/domain/DomainPricingLogic.java index b087767a5..50be79e34 100644 --- a/java/google/registry/flows/domain/DomainPricingLogic.java +++ b/java/google/registry/flows/domain/DomainPricingLogic.java @@ -14,7 +14,7 @@ package google.registry.flows.domain; -import static google.registry.model.EppResourceUtils.loadByForeignKey; +import static com.google.common.collect.Iterables.concat; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.pricing.PricingEngineProxy.getDomainCreateCost; import static google.registry.pricing.PricingEngineProxy.getDomainFeeClass; @@ -28,20 +28,21 @@ import com.google.common.net.InternetDomainName; import com.googlecode.objectify.Key; import google.registry.flows.EppException; import google.registry.flows.FlowScope; -import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException; import google.registry.flows.custom.DomainPricingCustomLogic; +import google.registry.flows.custom.DomainPricingCustomLogic.ApplicationUpdatePriceParameters; import google.registry.flows.custom.DomainPricingCustomLogic.CreatePriceParameters; +import google.registry.flows.custom.DomainPricingCustomLogic.RenewPriceParameters; +import google.registry.flows.custom.DomainPricingCustomLogic.RestorePriceParameters; +import google.registry.flows.custom.DomainPricingCustomLogic.TransferPriceParameters; +import google.registry.flows.custom.DomainPricingCustomLogic.UpdatePriceParameters; import google.registry.model.ImmutableObject; import google.registry.model.domain.DomainApplication; -import google.registry.model.domain.DomainResource; import google.registry.model.domain.LrpTokenEntity; import google.registry.model.domain.fee.BaseFee; import google.registry.model.domain.fee.BaseFee.FeeType; import google.registry.model.domain.fee.Credit; import google.registry.model.domain.fee.Fee; -import google.registry.model.eppinput.EppInput; import google.registry.model.registry.Registry; -import java.util.List; import javax.inject.Inject; import org.joda.money.CurrencyUnit; import org.joda.money.Money; @@ -62,11 +63,12 @@ public final class DomainPricingLogic { /** A collection of fees and credits for a specific EPP transform. */ public static final class FeesAndCredits extends ImmutableObject { + private final CurrencyUnit currency; private final ImmutableList fees; private final ImmutableList credits; - /** Constructs an FeesAndCredits object. The arguments are sorted into fees and credits. */ + /** Constructs a new instance. The currency must be the same across all fees and credits. */ public FeesAndCredits(CurrencyUnit currency, BaseFee... baseFees) { this.currency = checkArgumentNotNull(currency, "Currency may not be null in FeesAndCredits."); ImmutableList.Builder feeBuilder = new ImmutableList.Builder<>(); @@ -121,14 +123,19 @@ public final class DomainPricingLogic { } /** Returns the list of credits for the event. */ - public List getCredits() { - return nullToEmpty(credits); + public ImmutableList getCredits() { + return ImmutableList.copyOf(nullToEmpty(credits)); } /** Returns the currency for all fees in the event. */ public final CurrencyUnit getCurrency() { return currency; } + + /** Returns all fees and credits for the event. */ + public ImmutableList getFeesAndCredits() { + return ImmutableList.copyOf(concat(getFees(), getCredits())); + } } /** Returns a new create price for the Pricer. */ @@ -164,121 +171,97 @@ public final class DomainPricingLogic { // TODO: (b/33000134) clean up the rest of the pricing calls. - /** - * Computes the renew fee or credit. This is called by other methods which use the renew fee - * (renew, restore, etc). - */ - static BaseFee getRenewFeeOrCredit( - Registry registry, - String domainName, - String clientId, - DateTime date, - int years, - EppInput eppInput) - throws EppException { - Optional extraFlowLogic = - RegistryExtraFlowLogicProxy.newInstanceForTld(registry.getTldStr()); - if (extraFlowLogic.isPresent()) { - // TODO: Consider changing the method definition to have the domain passed in to begin with. - DomainResource domain = loadByForeignKey(DomainResource.class, domainName, date); - if (domain == null) { - throw new ResourceDoesNotExistException(DomainResource.class, domainName); - } - return extraFlowLogic.get().getRenewFeeOrCredit(domain, clientId, date, years, eppInput); - } else { - return Fee.create(getDomainRenewCost(domainName, date, years).getAmount(), FeeType.RENEW); - } - } - /** Returns a new renew price for the pricer. */ - public static FeesAndCredits getRenewPrice( + @SuppressWarnings("unused") + public FeesAndCredits getRenewPrice( Registry registry, String domainName, - String clientId, DateTime date, - int years, - EppInput eppInput) + int years) throws EppException { - return new FeesAndCredits( - registry.getCurrency(), - getRenewFeeOrCredit(registry, domainName, clientId, date, years, eppInput)); + Money renewCost = getDomainRenewCost(domainName, date, years); + return customLogic.customizeRenewPrice( + RenewPriceParameters.newBuilder() + .setFeesAndCredits( + new FeesAndCredits( + registry.getCurrency(), Fee.create(renewCost.getAmount(), FeeType.RENEW))) + .setRegistry(registry) + .setDomainName(InternetDomainName.from(domainName)) + .setAsOfDate(date) + .setYears(years) + .build()); } /** Returns a new restore price for the pricer. */ - public static FeesAndCredits getRestorePrice( - Registry registry, String domainName, String clientId, DateTime date, EppInput eppInput) + @SuppressWarnings("unused") + public FeesAndCredits getRestorePrice(Registry registry, String domainName, DateTime date) throws EppException { - return new FeesAndCredits( - registry.getCurrency(), - getRenewFeeOrCredit(registry, domainName, clientId, date, 1, eppInput), - Fee.create(registry.getStandardRestoreCost().getAmount(), FeeType.RESTORE)); + FeesAndCredits feesAndCredits = + new FeesAndCredits( + registry.getCurrency(), + Fee.create(getDomainRenewCost(domainName, date, 1).getAmount(), FeeType.RENEW), + Fee.create(registry.getStandardRestoreCost().getAmount(), FeeType.RESTORE)); + return customLogic.customizeRestorePrice( + RestorePriceParameters.newBuilder() + .setFeesAndCredits(feesAndCredits) + .setRegistry(registry) + .setDomainName(InternetDomainName.from(domainName)) + .setAsOfDate(date) + .build()); } /** Returns a new transfer price for the pricer. */ - public static FeesAndCredits getTransferPrice( + public FeesAndCredits getTransferPrice( Registry registry, String domainName, - String clientId, DateTime transferDate, - int years, - EppInput eppInput) + int years) throws EppException { - // Currently, all transfer prices = renew prices, so just pass through. - return getRenewPrice(registry, domainName, clientId, transferDate, years, eppInput); + Money renewCost = getDomainRenewCost(domainName, transferDate, years); + return customLogic.customizeTransferPrice( + TransferPriceParameters.newBuilder() + .setFeesAndCredits( + new FeesAndCredits( + registry.getCurrency(), Fee.create(renewCost.getAmount(), FeeType.RENEW))) + .setRegistry(registry) + .setDomainName(InternetDomainName.from(domainName)) + .setAsOfDate(transferDate) + .setYears(years) + .build()); } /** Returns a new update price for the pricer. */ - public static FeesAndCredits getUpdatePrice( - Registry registry, String domainName, String clientId, DateTime date, EppInput eppInput) + public FeesAndCredits getUpdatePrice(Registry registry, String domainName, DateTime date) throws EppException { CurrencyUnit currency = registry.getCurrency(); - - // If there is extra flow logic, it may specify an update price. Otherwise, there is none. - BaseFee feeOrCredit; - Optional extraFlowLogic = - RegistryExtraFlowLogicProxy.newInstanceForTld(registry.getTldStr()); - if (extraFlowLogic.isPresent()) { - // TODO: Consider changing the method definition to have the domain passed in to begin with. - DomainResource domain = loadByForeignKey(DomainResource.class, domainName, date); - if (domain == null) { - throw new ResourceDoesNotExistException(DomainResource.class, domainName); - } - feeOrCredit = extraFlowLogic.get().getUpdateFeeOrCredit(domain, clientId, date, eppInput); - } else { - feeOrCredit = Fee.create(Money.zero(registry.getCurrency()).getAmount(), FeeType.UPDATE); - } - - return new FeesAndCredits(currency, feeOrCredit); + BaseFee feeOrCredit = + Fee.create(Money.zero(registry.getCurrency()).getAmount(), FeeType.UPDATE); + return customLogic.customizeUpdatePrice( + UpdatePriceParameters.newBuilder() + .setFeesAndCredits(new FeesAndCredits(currency, feeOrCredit)) + .setRegistry(registry) + .setDomainName(InternetDomainName.from(domainName)) + .setAsOfDate(date) + .build()); } /** Returns a new domain application update price for the pricer. */ - public static FeesAndCredits getApplicationUpdatePrice( - Registry registry, - DomainApplication application, - String clientId, - DateTime date, - EppInput eppInput) - throws EppException { - CurrencyUnit currency = registry.getCurrency(); - - // If there is extra flow logic, it may specify an update price. Otherwise, there is none. - BaseFee feeOrCredit; - Optional extraFlowLogic = - RegistryExtraFlowLogicProxy.newInstanceForTld(registry.getTldStr()); - if (extraFlowLogic.isPresent()) { - feeOrCredit = - extraFlowLogic - .get() - .getApplicationUpdateFeeOrCredit(application, clientId, date, eppInput); - } else { - feeOrCredit = Fee.create(Money.zero(registry.getCurrency()).getAmount(), FeeType.UPDATE); - } - - return new FeesAndCredits(currency, feeOrCredit); + @SuppressWarnings("unused") + public FeesAndCredits getApplicationUpdatePrice( + Registry registry, DomainApplication application, DateTime date) throws EppException { + BaseFee feeOrCredit = + Fee.create(Money.zero(registry.getCurrency()).getAmount(), FeeType.UPDATE); + return customLogic.customizeApplicationUpdatePrice( + ApplicationUpdatePriceParameters.newBuilder() + .setFeesAndCredits(new FeesAndCredits(registry.getCurrency(), feeOrCredit)) + .setRegistry(registry) + .setDomainApplication(application) + .setAsOfDate(date) + .build()); } /** Returns the fee class for a given domain and date. */ - public static Optional getFeeClass(String domainName, DateTime date) { + public Optional getFeeClass(String domainName, DateTime date) { return getDomainFeeClass(domainName, date); } diff --git a/java/google/registry/flows/domain/DomainRenewFlow.java b/java/google/registry/flows/domain/DomainRenewFlow.java index deccd0b17..96e392b47 100644 --- a/java/google/registry/flows/domain/DomainRenewFlow.java +++ b/java/google/registry/flows/domain/DomainRenewFlow.java @@ -49,7 +49,7 @@ import google.registry.flows.custom.DomainRenewFlowCustomLogic.BeforeResponsePar import google.registry.flows.custom.DomainRenewFlowCustomLogic.BeforeResponseReturnData; import google.registry.flows.custom.DomainRenewFlowCustomLogic.BeforeSaveParameters; import google.registry.flows.custom.EntityChanges; -import google.registry.flows.domain.TldSpecificLogicProxy.EppCommandOperations; +import google.registry.flows.domain.DomainPricingLogic.FeesAndCredits; import google.registry.model.ImmutableObject; import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent.OneTime; @@ -121,6 +121,7 @@ public final class DomainRenewFlow implements TransactionalFlow { @Inject HistoryEntry.Builder historyBuilder; @Inject EppResponse.Builder responseBuilder; @Inject DomainRenewFlowCustomLogic customLogic; + @Inject DomainPricingLogic pricingLogic; @Inject DomainRenewFlow() {} @Override @@ -137,10 +138,10 @@ public final class DomainRenewFlow implements TransactionalFlow { int years = command.getPeriod().getValue(); FeeRenewCommandExtension feeRenew = eppInput.getSingleExtension(FeeRenewCommandExtension.class); - EppCommandOperations commandOperations = TldSpecificLogicProxy.getRenewPrice( - Registry.get(existingDomain.getTld()), targetId, clientId, now, years, eppInput); + FeesAndCredits feesAndCredits = + pricingLogic.getRenewPrice(Registry.get(existingDomain.getTld()), targetId, now, years); validateFeeChallenge( - targetId, existingDomain.getTld(), now, feeRenew, commandOperations.getTotalCost()); + targetId, existingDomain.getTld(), now, feeRenew, feesAndCredits.getTotalCost()); customLogic.afterValidation( AfterValidationParameters.newBuilder() .setExistingDomain(existingDomain) @@ -161,7 +162,7 @@ public final class DomainRenewFlow implements TransactionalFlow { String tld = existingDomain.getTld(); // Bill for this explicit renew itself. BillingEvent.OneTime explicitRenewEvent = - createRenewBillingEvent(tld, commandOperations.getTotalCost(), years, historyEntry, now); + createRenewBillingEvent(tld, feesAndCredits.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) @@ -173,13 +174,6 @@ public final class DomainRenewFlow implements TransactionalFlow { .build(); // End the old autorenew billing event and poll message now. This may delete the poll message. updateAutorenewRecurrenceEndTime(existingDomain, now); - // Handle extra flow logic, if any. - Optional extraFlowLogic = - RegistryExtraFlowLogicProxy.newInstanceForDomain(existingDomain); - if (extraFlowLogic.isPresent()) { - extraFlowLogic.get().performAdditionalDomainRenewLogic( - existingDomain, clientId, now, years, eppInput, historyEntry); - } DomainResource newDomain = existingDomain.asBuilder() .setRegistrationExpirationTime(newExpirationTime) .setAutorenewBillingEvent(Key.create(newAutorenewEvent)) @@ -212,7 +206,7 @@ public final class DomainRenewFlow implements TransactionalFlow { .setDomain(newDomain) .setResData(DomainRenewData.create(targetId, newExpirationTime)) .setResponseExtensions( - createResponseExtensions(commandOperations.getTotalCost(), feeRenew)) + createResponseExtensions(feesAndCredits.getTotalCost(), feeRenew)) .build()); return responseBuilder .setResData(responseData.resData()) diff --git a/java/google/registry/flows/domain/DomainRestoreRequestFlow.java b/java/google/registry/flows/domain/DomainRestoreRequestFlow.java index ca946ae32..6100b8dc2 100644 --- a/java/google/registry/flows/domain/DomainRestoreRequestFlow.java +++ b/java/google/registry/flows/domain/DomainRestoreRequestFlow.java @@ -42,7 +42,7 @@ 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; +import google.registry.flows.domain.DomainPricingLogic.FeesAndCredits; import google.registry.model.ImmutableObject; import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent.OneTime; @@ -114,6 +114,7 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow { @Inject HistoryEntry.Builder historyBuilder; @Inject DnsQueue dnsQueue; @Inject EppResponse.Builder responseBuilder; + @Inject DomainPricingLogic pricingLogic; @Inject DomainRestoreRequestFlow() {} @Override @@ -128,11 +129,11 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow { DateTime now = ofy().getTransactionTime(); DomainResource existingDomain = loadAndVerifyExistence(DomainResource.class, targetId, now); Money restoreCost = Registry.get(existingDomain.getTld()).getStandardRestoreCost(); - EppCommandOperations renewCommandOperations = TldSpecificLogicProxy.getRenewPrice( - Registry.get(existingDomain.getTld()), targetId, clientId, now, 1, eppInput); + FeesAndCredits feesAndCredits = + pricingLogic.getRenewPrice(Registry.get(existingDomain.getTld()), targetId, now, 1); FeeUpdateCommandExtension feeUpdate = eppInput.getSingleExtension(FeeUpdateCommandExtension.class); - Money totalCost = renewCommandOperations.getTotalCost(); + Money totalCost = feesAndCredits.getTotalCost(); verifyRestoreAllowed(command, existingDomain, restoreCost, totalCost, feeUpdate, now); HistoryEntry historyEntry = buildHistory(existingDomain, now); ImmutableSet.Builder entitiesToSave = new ImmutableSet.Builder<>(); @@ -153,13 +154,6 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow { .setAutorenewEndTime(END_OF_TIME) .setParent(historyEntry) .build(); - // Handle extra flow logic, if any. - Optional extraFlowLogic = - RegistryExtraFlowLogicProxy.newInstanceForDomain(existingDomain); - if (extraFlowLogic.isPresent()) { - extraFlowLogic.get().performAdditionalDomainRestoreLogic( - existingDomain, clientId, now, eppInput, historyEntry); - } DomainResource newDomain = performRestore(existingDomain, newExpirationTime, autorenewEvent, autorenewPollMessage); updateForeignKeyIndexDeletionTime(newDomain); diff --git a/java/google/registry/flows/domain/DomainTransferApproveFlow.java b/java/google/registry/flows/domain/DomainTransferApproveFlow.java index 1bc9d3deb..3b9d3b297 100644 --- a/java/google/registry/flows/domain/DomainTransferApproveFlow.java +++ b/java/google/registry/flows/domain/DomainTransferApproveFlow.java @@ -177,7 +177,6 @@ public final class DomainTransferApproveFlow implements TransactionalFlow { newDomain.getTransferData(), newExpirationTime, historyEntry); - handleExtraFlowLogic(tld, historyEntry, newDomain); ofy().save().entities( newDomain, historyEntry, @@ -193,16 +192,4 @@ public final class DomainTransferApproveFlow implements TransactionalFlow { targetId, newDomain.getTransferData(), newDomain.getRegistrationExpirationTime())) .build(); } - - private void handleExtraFlowLogic( - String tld, HistoryEntry historyEntry, DomainResource newDomain) throws EppException { - Optional extraFlowLogic = - RegistryExtraFlowLogicProxy.newInstanceForTld(tld); - if (extraFlowLogic.isPresent()) { - extraFlowLogic.get().performAdditionalDomainTransferApproveLogic( - newDomain, - clientId, - historyEntry); - } - } } diff --git a/java/google/registry/flows/domain/DomainTransferCancelFlow.java b/java/google/registry/flows/domain/DomainTransferCancelFlow.java index ad30a9dfb..8c0edd6fe 100644 --- a/java/google/registry/flows/domain/DomainTransferCancelFlow.java +++ b/java/google/registry/flows/domain/DomainTransferCancelFlow.java @@ -92,7 +92,6 @@ public final class DomainTransferCancelFlow implements TransactionalFlow { .build(); DomainResource newDomain = denyPendingTransfer(existingDomain, TransferStatus.CLIENT_CANCELLED, now); - handleExtraFlowLogic(existingDomain.getTld(), historyEntry, existingDomain); ofy().save().entities( newDomain, historyEntry, @@ -108,16 +107,4 @@ public final class DomainTransferCancelFlow implements TransactionalFlow { .setResData(createTransferResponse(targetId, newDomain.getTransferData(), null)) .build(); } - - private void handleExtraFlowLogic( - String tld, HistoryEntry historyEntry, DomainResource existingDomain) throws EppException { - Optional extraFlowLogic = - RegistryExtraFlowLogicProxy.newInstanceForTld(tld); - if (extraFlowLogic.isPresent()) { - extraFlowLogic.get().performAdditionalDomainTransferCancelLogic( - existingDomain, - clientId, - historyEntry); - } - } } diff --git a/java/google/registry/flows/domain/DomainTransferRejectFlow.java b/java/google/registry/flows/domain/DomainTransferRejectFlow.java index f6873c5f4..c716d7b7c 100644 --- a/java/google/registry/flows/domain/DomainTransferRejectFlow.java +++ b/java/google/registry/flows/domain/DomainTransferRejectFlow.java @@ -90,7 +90,6 @@ public final class DomainTransferRejectFlow implements TransactionalFlow { checkAllowedAccessToTld(clientId, existingDomain.getTld()); DomainResource newDomain = denyPendingTransfer(existingDomain, TransferStatus.CLIENT_REJECTED, now); - handleExtraFlowLogic(existingDomain.getTld(), historyEntry, existingDomain); ofy().save().entities( newDomain, historyEntry, @@ -106,16 +105,4 @@ public final class DomainTransferRejectFlow implements TransactionalFlow { .setResData(createTransferResponse(targetId, newDomain.getTransferData(), null)) .build(); } - - private void handleExtraFlowLogic( - String tld, HistoryEntry historyEntry, DomainResource existingDomain) throws EppException { - Optional extraFlowLogic = - RegistryExtraFlowLogicProxy.newInstanceForTld(tld); - if (extraFlowLogic.isPresent()) { - extraFlowLogic.get().performAdditionalDomainTransferRejectLogic( - existingDomain, - clientId, - historyEntry); - } - } } diff --git a/java/google/registry/flows/domain/DomainTransferRequestFlow.java b/java/google/registry/flows/domain/DomainTransferRequestFlow.java index 939fc7db6..22a9ebe51 100644 --- a/java/google/registry/flows/domain/DomainTransferRequestFlow.java +++ b/java/google/registry/flows/domain/DomainTransferRequestFlow.java @@ -176,7 +176,6 @@ public final class DomainTransferRequestFlow implements TransactionalFlow { // cloneProjectedAtTime() will replace these old autorenew entities with the server approve ones // that we've created in this flow and stored in pendingTransferData. updateAutorenewRecurrenceEndTime(existingDomain, automaticTransferTime); - handleExtraFlowLogic(years, existingDomain, historyEntry, now); DomainResource newDomain = existingDomain.asBuilder() .setTransferData(pendingTransferData) .addStatusValue(StatusValue.PENDING_TRANSFER) @@ -376,22 +375,6 @@ public final class DomainTransferRequestFlow implements TransactionalFlow { .build(); } - private void handleExtraFlowLogic( - int years, DomainResource existingDomain, HistoryEntry historyEntry, DateTime now) - throws EppException { - Optional extraFlowLogic = - RegistryExtraFlowLogicProxy.newInstanceForDomain(existingDomain); - if (extraFlowLogic.isPresent()) { - extraFlowLogic.get().performAdditionalDomainTransferRequestLogic( - existingDomain, - gainingClientId, - now, - years, - eppInput, - historyEntry); - } - } - private DomainTransferResponse createResponse( Period period, DomainResource existingDomain, DomainResource newDomain, DateTime now) { // If the registration were approved this instant, this is what the new expiration would be, diff --git a/java/google/registry/flows/domain/DomainUpdateFlow.java b/java/google/registry/flows/domain/DomainUpdateFlow.java index 15a1dc395..80602cda0 100644 --- a/java/google/registry/flows/domain/DomainUpdateFlow.java +++ b/java/google/registry/flows/domain/DomainUpdateFlow.java @@ -56,7 +56,7 @@ import google.registry.flows.custom.DomainUpdateFlowCustomLogic.AfterValidationP import google.registry.flows.custom.DomainUpdateFlowCustomLogic.BeforeSaveParameters; import google.registry.flows.custom.EntityChanges; import google.registry.flows.domain.DomainFlowUtils.FeesRequiredForNonFreeUpdateException; -import google.registry.flows.domain.TldSpecificLogicProxy.EppCommandOperations; +import google.registry.flows.domain.DomainPricingLogic.FeesAndCredits; import google.registry.model.ImmutableObject; import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent.Reason; @@ -146,7 +146,7 @@ public final class DomainUpdateFlow implements TransactionalFlow { @Inject DnsQueue dnsQueue; @Inject EppResponse.Builder responseBuilder; @Inject DomainUpdateFlowCustomLogic customLogic; - + @Inject DomainPricingLogic pricingLogic; @Inject DomainUpdateFlow() {} @Override @@ -179,7 +179,6 @@ public final class DomainUpdateFlow implements TransactionalFlow { } validateNewState(newDomain); dnsQueue.addDomainRefreshTask(targetId); - handleExtraFlowLogic(existingDomain, historyEntry, now); ImmutableSet.Builder entitiesToSave = new ImmutableSet.Builder<>(); entitiesToSave.add(newDomain, historyEntry); Optional statusUpdateBillingEvent = @@ -214,15 +213,13 @@ public final class DomainUpdateFlow implements TransactionalFlow { } String tld = existingDomain.getTld(); checkAllowedAccessToTld(clientId, tld); - EppCommandOperations commandOperations = TldSpecificLogicProxy.getUpdatePrice( - Registry.get(tld), targetId, clientId, now, eppInput); - FeeTransformCommandExtension feeUpdate = eppInput.getSingleExtension(FeeUpdateCommandExtension.class); // If the fee extension is present, validate it (even if the cost is zero, to check for price // mismatches). Don't rely on the the validateFeeChallenge check for feeUpdate nullness, because // it throws an error if the name is premium, and we don't want to do that here. - Money totalCost = commandOperations.getTotalCost(); + FeesAndCredits feesAndCredits = pricingLogic.getUpdatePrice(Registry.get(tld), targetId, now); + Money totalCost = feesAndCredits.getTotalCost(); if (feeUpdate != null) { validateFeeChallenge(targetId, existingDomain.getTld(), now, feeUpdate, totalCost); } else if (!totalCost.isZero()) { @@ -352,14 +349,4 @@ public final class DomainUpdateFlow implements TransactionalFlow { } return Optional.absent(); } - - private void handleExtraFlowLogic( - DomainResource existingDomain, HistoryEntry historyEntry, DateTime now) throws EppException { - Optional extraFlowLogic = - RegistryExtraFlowLogicProxy.newInstanceForDomain(existingDomain); - if (extraFlowLogic.isPresent()) { - extraFlowLogic.get().performAdditionalDomainUpdateLogic( - existingDomain, clientId, now, eppInput, historyEntry); - } - } } diff --git a/java/google/registry/flows/domain/RegistryExtraFlowLogic.java b/java/google/registry/flows/domain/RegistryExtraFlowLogic.java deleted file mode 100644 index 45b5c0df1..000000000 --- a/java/google/registry/flows/domain/RegistryExtraFlowLogic.java +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright 2016 The Nomulus Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package google.registry.flows.domain; - -import google.registry.flows.EppException; -import google.registry.model.domain.DomainApplication; -import google.registry.model.domain.DomainResource; -import google.registry.model.domain.fee.BaseFee; -import google.registry.model.eppinput.EppInput; -import google.registry.model.reporting.HistoryEntry; -import java.util.Set; -import org.joda.time.DateTime; - -/** - * Interface for classes which provide extra registry logic for things like TLD-specific rules and - * discounts. - */ -@Deprecated -public interface RegistryExtraFlowLogic { - - /** Gets the flags to be returned for application info commands. */ - public Set getApplicationExtensionFlags( - DomainApplication application, String clientId, DateTime asOfDate); - - /** Gets the flags to be returned for domain info commands. */ - public Set getExtensionFlags( - DomainResource domainResource, String clientId, DateTime asOfDate); - - /** Performs additional tasks required for an application create command. */ - public void performAdditionalApplicationCreateLogic( - DomainApplication application, - String clientId, - int years, - EppInput eppInput, - HistoryEntry historyEntry) throws EppException; - - /** Performs additional tasks required for an application delete command. */ - public void performAdditionalApplicationDeleteLogic( - DomainApplication application, - String clientId, - DateTime asOfDate, - EppInput eppInput, - HistoryEntry historyEntry) throws EppException; - - /** Computes the expected application update fee. */ - public BaseFee getApplicationUpdateFeeOrCredit( - DomainApplication application, - String clientId, - DateTime asOfDate, - EppInput eppInput) throws EppException; - - /** Performs additional tasks required for an application update command. */ - public void performAdditionalApplicationUpdateLogic( - DomainApplication application, - String clientId, - DateTime asOfDate, - EppInput eppInput, - HistoryEntry historyEntry) throws EppException; - - /** Performs additional tasks required for an allocate command. */ - public void performAdditionalDomainAllocateLogic( - DomainResource domain, - String clientId, - DateTime asOfDate, - int years, - EppInput eppInput, - HistoryEntry historyEntry) throws EppException; - - /** Computes the expected creation fee. */ - public BaseFee getCreateFeeOrCredit( - String domainName, - String clientId, - DateTime asOfDate, - int years, - EppInput eppInput) throws EppException; - - /** Performs additional tasks required for a create command. */ - public void performAdditionalDomainCreateLogic( - DomainResource domain, - String clientId, - int years, - EppInput eppInput, - HistoryEntry historyEntry) throws EppException; - - /** Performs additional tasks required for a delete command. */ - public void performAdditionalDomainDeleteLogic( - DomainResource domain, - String clientId, - DateTime asOfDate, - EppInput eppInput, - HistoryEntry historyEntry) throws EppException; - - /** Computes the expected renewal fee. */ - public BaseFee getRenewFeeOrCredit( - DomainResource domain, - String clientId, - DateTime asOfDate, - int years, - EppInput eppInput) throws EppException; - - /** Performs additional tasks required for a renew command. */ - public void performAdditionalDomainRenewLogic( - DomainResource domain, - String clientId, - DateTime asOfDate, - int years, - EppInput eppInput, - HistoryEntry historyEntry) throws EppException; - - /** Performs additional tasks required for a restore command. */ - public void performAdditionalDomainRestoreLogic( - DomainResource domain, - String clientId, - DateTime asOfDate, - EppInput eppInput, - HistoryEntry historyEntry) throws EppException; - - /** Performs additional tasks required for a domain transfer approve command. */ - public void performAdditionalDomainTransferApproveLogic( - DomainResource domain, - String clientId, - HistoryEntry historyEntry) throws EppException; - - /** Performs additional tasks required for a domain transfer cancel command. */ - public void performAdditionalDomainTransferCancelLogic( - DomainResource domain, - String clientId, - HistoryEntry historyEntry) throws EppException; - - /** Performs additional tasks required for a domain transfer reject command. */ - public void performAdditionalDomainTransferRejectLogic( - DomainResource domain, - String clientId, - HistoryEntry historyEntry) throws EppException; - - /** Performs additional tasks required for a transfer request command. */ - public void performAdditionalDomainTransferRequestLogic( - DomainResource domain, - String clientId, - DateTime asOfDate, - int years, - EppInput eppInput, - HistoryEntry historyEntry) throws EppException; - - /** Computes the expected update fee. */ - public BaseFee getUpdateFeeOrCredit( - DomainResource domain, - String clientId, - DateTime asOfDate, - EppInput eppInput) throws EppException; - - /** Performs additional tasks required for an update command. */ - public void performAdditionalDomainUpdateLogic( - DomainResource domain, - String clientId, - DateTime asOfDate, - EppInput eppInput, - HistoryEntry historyEntry) throws EppException; -} diff --git a/java/google/registry/flows/domain/RegistryExtraFlowLogicProxy.java b/java/google/registry/flows/domain/RegistryExtraFlowLogicProxy.java deleted file mode 100644 index 2bf9f3cbf..000000000 --- a/java/google/registry/flows/domain/RegistryExtraFlowLogicProxy.java +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2016 The Nomulus Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package google.registry.flows.domain; - -import com.google.common.base.Optional; -import google.registry.flows.EppException; -import google.registry.flows.EppException.CommandFailedException; -import google.registry.model.domain.DomainBase; -import google.registry.model.registry.Registry; -import java.util.HashMap; -import javax.annotation.Nullable; - -/** - * Static class to return the correct {@link RegistryExtraFlowLogic} for a particular TLD. - * Eventually, this will probably be replaced with dependency injection, barring unforeseen - * complications. - */ -public class RegistryExtraFlowLogicProxy { - - private static final HashMap> - extraLogicOverrideMap = new HashMap<>(); - - public static void setOverride( - String tld, Class extraLogicClass) { - if (Registry.get(tld) == null) { - throw new IllegalArgumentException(tld + " does not exist"); - } - extraLogicOverrideMap.put(tld, extraLogicClass); - } - - public static Optional - newInstanceForDomain(@Nullable D domain) throws EppException { - if (domain == null) { - return Optional.absent(); - } else { - return newInstanceForTld(domain.getTld()); - } - } - - public static Optional - newInstanceForTld(String tld) throws EppException { - if (extraLogicOverrideMap.containsKey(tld)) { - try { - return Optional.of( - extraLogicOverrideMap.get(tld).getConstructor().newInstance()); - } catch (ReflectiveOperationException ex) { - throw new CommandFailedException(); - } - } - return Optional.absent(); - } -} diff --git a/java/google/registry/flows/domain/TldSpecificLogicProxy.java b/java/google/registry/flows/domain/TldSpecificLogicProxy.java deleted file mode 100644 index 49d3b8700..000000000 --- a/java/google/registry/flows/domain/TldSpecificLogicProxy.java +++ /dev/null @@ -1,314 +0,0 @@ -// Copyright 2016 The Nomulus Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package google.registry.flows.domain; - -import static com.google.common.base.Preconditions.checkArgument; -import static google.registry.model.EppResourceUtils.loadByForeignKey; -import static google.registry.model.ofy.ObjectifyService.ofy; -import static google.registry.pricing.PricingEngineProxy.getDomainCreateCost; -import static google.registry.pricing.PricingEngineProxy.getDomainFeeClass; -import static google.registry.pricing.PricingEngineProxy.getDomainRenewCost; -import static google.registry.util.CollectionUtils.nullToEmpty; -import static google.registry.util.PreconditionsUtils.checkArgumentNotNull; - -import com.google.common.base.Optional; -import com.google.common.collect.ImmutableList; -import com.google.common.net.InternetDomainName; -import com.googlecode.objectify.Key; -import google.registry.flows.EppException; -import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException; -import google.registry.model.ImmutableObject; -import google.registry.model.domain.DomainApplication; -import google.registry.model.domain.DomainResource; -import google.registry.model.domain.LrpTokenEntity; -import google.registry.model.domain.fee.BaseFee; -import google.registry.model.domain.fee.BaseFee.FeeType; -import google.registry.model.domain.fee.Credit; -import google.registry.model.domain.fee.Fee; -import google.registry.model.eppinput.EppInput; -import google.registry.model.registry.Registry; -import java.util.List; -import org.joda.money.CurrencyUnit; -import org.joda.money.Money; -import org.joda.time.DateTime; - -/** - * Provides pricing, billing, and update logic, with call-outs that can be customized by providing - * implementations on a per-TLD basis. - */ -public final class TldSpecificLogicProxy { - /** A collection of fees and credits for a specific EPP transform. */ - public static final class EppCommandOperations extends ImmutableObject { - private final CurrencyUnit currency; - private final ImmutableList fees; - private final ImmutableList credits; - - /** Constructs an EppCommandOperations object using separate lists of fees and credits. */ - EppCommandOperations( - CurrencyUnit currency, ImmutableList fees, ImmutableList credits) { - this.currency = checkArgumentNotNull( - currency, "Currency may not be null in EppCommandOperations."); - checkArgument(!fees.isEmpty(), "You must specify one or more fees."); - this.fees = checkArgumentNotNull(fees, "Fees may not be null in EppCommandOperations."); - this.credits = - checkArgumentNotNull(credits, "Credits may not be null in EppCommandOperations."); - } - - /** - * Constructs an EppCommandOperations object. The arguments are sorted into fees and credits. - */ - EppCommandOperations(CurrencyUnit currency, BaseFee... feesAndCredits) { - this.currency = checkArgumentNotNull( - currency, "Currency may not be null in EppCommandOperations."); - ImmutableList.Builder feeBuilder = new ImmutableList.Builder<>(); - ImmutableList.Builder creditBuilder = new ImmutableList.Builder<>(); - for (BaseFee feeOrCredit : feesAndCredits) { - if (feeOrCredit instanceof Credit) { - creditBuilder.add((Credit) feeOrCredit); - } else { - feeBuilder.add((Fee) feeOrCredit); - } - } - this.fees = feeBuilder.build(); - this.credits = creditBuilder.build(); - } - - private Money getTotalCostForType(FeeType type) { - Money result = Money.zero(currency); - checkArgumentNotNull(type); - for (Fee fee : fees) { - if (fee.getType() == type) { - result = result.plus(fee.getCost()); - } - } - return result; - } - - /** Returns the total cost of all fees and credits for the event. */ - public Money getTotalCost() { - Money result = Money.zero(currency); - for (Fee fee : fees) { - result = result.plus(fee.getCost()); - } - for (Credit credit : credits) { - result = result.plus(credit.getCost()); - } - return result; - } - - /** Returns the create cost for the event. */ - public Money getCreateCost() { - return getTotalCostForType(FeeType.CREATE); - } - - /** Returns the EAP cost for the event. */ - public Money getEapCost() { - return getTotalCostForType(FeeType.EAP); - } - - /** Returns the list of fees for the event. */ - public ImmutableList getFees() { - return fees; - } - - /** Returns the list of credits for the event. */ - public List getCredits() { - return nullToEmpty(credits); - } - - /** Returns the currency for all fees in the event. */ - public final CurrencyUnit getCurrency() { - return currency; - } - } - - private TldSpecificLogicProxy() {} - - /** Returns a new create price for the Pricer. */ - public static EppCommandOperations getCreatePrice( - Registry registry, - String domainName, - String clientId, - DateTime date, - int years, - EppInput eppInput) throws EppException { - CurrencyUnit currency = registry.getCurrency(); - - // Get the create cost, either from the extra flow logic or straight from PricingEngineProxy. - BaseFee createFeeOrCredit; - Optional extraFlowLogic = - RegistryExtraFlowLogicProxy.newInstanceForTld(registry.getTldStr()); - if (extraFlowLogic.isPresent()) { - createFeeOrCredit = extraFlowLogic.get() - .getCreateFeeOrCredit(domainName, clientId, date, years, eppInput); - } else { - createFeeOrCredit = - Fee.create(getDomainCreateCost(domainName, date, years).getAmount(), FeeType.CREATE); - } - - // Create fees for the cost and the EAP fee, if any. - Fee eapFee = registry.getEapFeeFor(date); - if (!eapFee.hasZeroCost()) { - return new EppCommandOperations(currency, createFeeOrCredit, eapFee); - } else { - return new EppCommandOperations(currency, createFeeOrCredit); - } - } - - /** - * Computes the renew fee or credit. This is called by other methods which use the renew fee - * (renew, restore, etc). - */ - static BaseFee getRenewFeeOrCredit( - Registry registry, - String domainName, - String clientId, - DateTime date, - int years, - EppInput eppInput) throws EppException { - Optional extraFlowLogic = - RegistryExtraFlowLogicProxy.newInstanceForTld(registry.getTldStr()); - if (extraFlowLogic.isPresent()) { - // TODO: Consider changing the method definition to have the domain passed in to begin with. - DomainResource domain = loadByForeignKey(DomainResource.class, domainName, date); - if (domain == null) { - throw new ResourceDoesNotExistException(DomainResource.class, domainName); - } - return - extraFlowLogic.get().getRenewFeeOrCredit(domain, clientId, date, years, eppInput); - } else { - return Fee.create(getDomainRenewCost(domainName, date, years).getAmount(), FeeType.RENEW); - } - } - - /** Returns a new renew price for the pricer. */ - public static EppCommandOperations getRenewPrice( - Registry registry, - String domainName, - String clientId, - DateTime date, - int years, - EppInput eppInput) throws EppException { - return new EppCommandOperations( - registry.getCurrency(), - getRenewFeeOrCredit(registry, domainName, clientId, date, years, eppInput)); - } - - /** Returns a new restore price for the pricer. */ - public static EppCommandOperations getRestorePrice( - Registry registry, - String domainName, - String clientId, - DateTime date, - EppInput eppInput) throws EppException { - return new EppCommandOperations( - registry.getCurrency(), - getRenewFeeOrCredit(registry, domainName, clientId, date, 1, eppInput), - Fee.create(registry.getStandardRestoreCost().getAmount(), FeeType.RESTORE)); - } - - /** Returns a new transfer price for the pricer. */ - public static EppCommandOperations getTransferPrice( - Registry registry, - String domainName, - String clientId, - DateTime transferDate, - int years, - EppInput eppInput) throws EppException { - // Currently, all transfer prices = renew prices, so just pass through. - return getRenewPrice( - registry, domainName, clientId, transferDate, years, eppInput); - } - - /** Returns a new update price for the pricer. */ - public static EppCommandOperations getUpdatePrice( - Registry registry, - String domainName, - String clientId, - DateTime date, - EppInput eppInput) throws EppException { - CurrencyUnit currency = registry.getCurrency(); - - // If there is extra flow logic, it may specify an update price. Otherwise, there is none. - BaseFee feeOrCredit; - Optional extraFlowLogic = - RegistryExtraFlowLogicProxy.newInstanceForTld(registry.getTldStr()); - if (extraFlowLogic.isPresent()) { - // TODO: Consider changing the method definition to have the domain passed in to begin with. - DomainResource domain = loadByForeignKey(DomainResource.class, domainName, date); - if (domain == null) { - throw new ResourceDoesNotExistException(DomainResource.class, domainName); - } - feeOrCredit = - extraFlowLogic.get().getUpdateFeeOrCredit(domain, clientId, date, eppInput); - } else { - feeOrCredit = Fee.create(Money.zero(registry.getCurrency()).getAmount(), FeeType.UPDATE); - } - - return new EppCommandOperations(currency, feeOrCredit); - } - - /** Returns a new domain application update price for the pricer. */ - public static EppCommandOperations getApplicationUpdatePrice( - Registry registry, - DomainApplication application, - String clientId, - DateTime date, - EppInput eppInput) throws EppException { - CurrencyUnit currency = registry.getCurrency(); - - // If there is extra flow logic, it may specify an update price. Otherwise, there is none. - BaseFee feeOrCredit; - Optional extraFlowLogic = - RegistryExtraFlowLogicProxy.newInstanceForTld(registry.getTldStr()); - if (extraFlowLogic.isPresent()) { - feeOrCredit = extraFlowLogic.get() - .getApplicationUpdateFeeOrCredit(application, clientId, date, eppInput); - } else { - feeOrCredit = Fee.create(Money.zero(registry.getCurrency()).getAmount(), FeeType.UPDATE); - } - - return new EppCommandOperations(currency, feeOrCredit); - } - - /** Returns the fee class for a given domain and date. */ - public static Optional getFeeClass(String domainName, DateTime date) { - return getDomainFeeClass(domainName, date); - } - - /** - * Checks whether an LRP token String maps to a valid {@link LrpTokenEntity} for the domain name's - * TLD, and return that entity (wrapped in an {@link Optional}) if one exists. - * - *

This method has no knowledge of whether or not an auth code (interpreted here as an LRP - * token) has already been checked against the reserved list for QLP (anchor tenant), as auth - * codes are used for both types of registrations. - */ - public static Optional getMatchingLrpToken( - String lrpToken, InternetDomainName domainName) { - // Note that until the actual per-TLD logic is built out, what's being done here is a basic - // domain-name-to-assignee match. - if (!lrpToken.isEmpty()) { - LrpTokenEntity token = ofy().load().key(Key.create(LrpTokenEntity.class, lrpToken)).now(); - if (token != null - && token.getAssignee().equalsIgnoreCase(domainName.toString()) - && token.getRedemptionHistoryEntry() == null - && token.getValidTlds().contains(domainName.parent().toString())) { - return Optional.of(token); - } - } - return Optional.absent(); - } -} diff --git a/javatests/google/registry/flows/custom/TestDomainPricingCustomLogic.java b/javatests/google/registry/flows/custom/TestDomainPricingCustomLogic.java index 4d6994702..c1bb37d46 100644 --- a/javatests/google/registry/flows/custom/TestDomainPricingCustomLogic.java +++ b/javatests/google/registry/flows/custom/TestDomainPricingCustomLogic.java @@ -15,6 +15,8 @@ package google.registry.flows.custom; import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.collect.Iterables.toArray; +import static java.math.BigDecimal.TEN; import com.google.common.base.Ascii; import com.google.common.base.Splitter; @@ -61,13 +63,12 @@ public class TestDomainPricingCustomLogic extends DomainPricingCustomLogic { } } - /** A hook that customizes create price. */ @Override - public FeesAndCredits customizeCreatePrice(CreatePriceParameters createPriceParameters) + public FeesAndCredits customizeCreatePrice(CreatePriceParameters priceParameters) throws EppException { - InternetDomainName domainName = createPriceParameters.domainName(); + InternetDomainName domainName = priceParameters.domainName(); if (domainName.parent().toString().equals("flags")) { - FeesAndCredits feesAndCredits = createPriceParameters.feesAndCredits(); + FeesAndCredits feesAndCredits = priceParameters.feesAndCredits(); ImmutableList.Builder baseFeeBuilder = new ImmutableList.Builder<>(); baseFeeBuilder.addAll(feesAndCredits.getCredits()); for (BaseFee fee : feesAndCredits.getFees()) { @@ -77,7 +78,40 @@ public class TestDomainPricingCustomLogic extends DomainPricingCustomLogic { return new FeesAndCredits( feesAndCredits.getCurrency(), Iterables.toArray(baseFeeBuilder.build(), BaseFee.class)); } else { - return createPriceParameters.feesAndCredits(); + return priceParameters.feesAndCredits(); + } + } + + @Override + public FeesAndCredits customizeRenewPrice(RenewPriceParameters priceParameters) + throws EppException { + if (priceParameters.domainName().toString().startsWith("costly-renew")) { + FeesAndCredits feesAndCredits = priceParameters.feesAndCredits(); + List newFeesAndCredits = + new ImmutableList.Builder() + .addAll(feesAndCredits.getFeesAndCredits()) + .add(Fee.create(BigDecimal.valueOf(100), FeeType.RENEW)) + .build(); + return new FeesAndCredits( + feesAndCredits.getCurrency(), toArray(newFeesAndCredits, BaseFee.class)); + } else { + return priceParameters.feesAndCredits(); + } + } + + @Override + public FeesAndCredits customizeUpdatePrice(UpdatePriceParameters priceParameters) { + if (priceParameters.domainName().toString().startsWith("non-free-update")) { + FeesAndCredits feesAndCredits = priceParameters.feesAndCredits(); + List newFeesAndCredits = + new ImmutableList.Builder() + .addAll(feesAndCredits.getFeesAndCredits()) + .add(Fee.create(TEN, FeeType.UPDATE)) + .build(); + return new FeesAndCredits( + feesAndCredits.getCurrency(), toArray(newFeesAndCredits, BaseFee.class)); + } else { + return priceParameters.feesAndCredits(); } } } diff --git a/javatests/google/registry/flows/domain/DomainAllocateFlowTest.java b/javatests/google/registry/flows/domain/DomainAllocateFlowTest.java index dc0e4fee8..682abcd63 100644 --- a/javatests/google/registry/flows/domain/DomainAllocateFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainAllocateFlowTest.java @@ -52,8 +52,6 @@ import google.registry.model.billing.BillingEvent.Reason; import google.registry.model.domain.DomainApplication; import google.registry.model.domain.DomainResource; import google.registry.model.domain.GracePeriod; -import google.registry.model.domain.TestExtraLogicManager; -import google.registry.model.domain.TestExtraLogicManager.TestExtraLogicManagerSuccessException; import google.registry.model.domain.launch.ApplicationStatus; import google.registry.model.domain.launch.LaunchInfoResponseExtension; import google.registry.model.domain.launch.LaunchNotice; @@ -491,15 +489,4 @@ public class DomainAllocateFlowTest thrown.expect(OnlySuperuserCanAllocateException.class); runFlow(CommitMode.LIVE, UserPrivileges.NORMAL); } - - @Test - public void testSuccess_extra() throws Exception { - setEppInput( - "domain_allocate.xml", - ImmutableMap.of("APPLICATIONID", "2-EXTRA", "DOMAIN", "domain.extra")); - setupDomainApplication("extra", TldState.QUIET_PERIOD); - RegistryExtraFlowLogicProxy.setOverride("extra", TestExtraLogicManager.class); - thrown.expect(TestExtraLogicManagerSuccessException.class, "allocated"); - runFlowAsSuperuser(); - } } diff --git a/javatests/google/registry/flows/domain/DomainApplicationDeleteFlowTest.java b/javatests/google/registry/flows/domain/DomainApplicationDeleteFlowTest.java index 01059c759..8da20d810 100644 --- a/javatests/google/registry/flows/domain/DomainApplicationDeleteFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainApplicationDeleteFlowTest.java @@ -40,8 +40,6 @@ import google.registry.flows.domain.DomainFlowUtils.NotAuthorizedForTldException import google.registry.model.EppResource; import google.registry.model.contact.ContactResource; import google.registry.model.domain.DomainApplication; -import google.registry.model.domain.TestExtraLogicManager; -import google.registry.model.domain.TestExtraLogicManager.TestExtraLogicManagerSuccessException; import google.registry.model.domain.launch.LaunchPhase; import google.registry.model.eppcommon.StatusValue; import google.registry.model.host.HostResource; @@ -62,7 +60,6 @@ public class DomainApplicationDeleteFlowTest public void setUp() { createTld("tld", TldState.SUNRUSH); createTld("extra", TldState.LANDRUSH); - RegistryExtraFlowLogicProxy.setOverride("extra", TestExtraLogicManager.class); } public void doSuccessfulTest() throws Exception { @@ -306,17 +303,4 @@ public class DomainApplicationDeleteFlowTest thrown.expect(ApplicationDomainNameMismatchException.class); runFlow(); } - - @Test - public void testSuccess_extraLogic() throws Exception { - persistResource(newDomainApplication("example.extra") - .asBuilder() - .setRepoId("1-TLD") - .setPhase(LaunchPhase.LANDRUSH) - .build()); - setEppInput( - "domain_delete_application_landrush.xml", ImmutableMap.of("DOMAIN", "example.extra")); - thrown.expect(TestExtraLogicManagerSuccessException.class, "application deleted"); - runFlow(); - } } diff --git a/javatests/google/registry/flows/domain/DomainApplicationInfoFlowTest.java b/javatests/google/registry/flows/domain/DomainApplicationInfoFlowTest.java index 8e98e01a6..8f533f21c 100644 --- a/javatests/google/registry/flows/domain/DomainApplicationInfoFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainApplicationInfoFlowTest.java @@ -37,7 +37,6 @@ import google.registry.model.domain.DesignatedContact; import google.registry.model.domain.DesignatedContact.Type; import google.registry.model.domain.DomainApplication; import google.registry.model.domain.DomainAuthInfo; -import google.registry.model.domain.TestExtraLogicManager; import google.registry.model.domain.launch.ApplicationStatus; import google.registry.model.domain.launch.LaunchCreateExtension; import google.registry.model.domain.launch.LaunchPhase; @@ -71,9 +70,6 @@ public class DomainApplicationInfoFlowTest setEppInput("domain_info_sunrise.xml"); sessionMetadata.setClientId("NewRegistrar"); createTld("tld", TldState.SUNRUSH); - createTld("flags", TldState.SUNRUSH); - // For flags extension tests. - RegistryExtraFlowLogicProxy.setOverride("flags", TestExtraLogicManager.class); } private void persistTestEntities(HostsState hostsState, MarksState marksState) throws Exception { @@ -110,33 +106,6 @@ public class DomainApplicationInfoFlowTest .build()); } - private void persistFlagsTestEntities(String domainName, HostsState hostsState) throws Exception { - registrant = persistActiveContact("jd1234"); - contact = persistActiveContact("sh8013"); - host1 = persistActiveHost("ns1.example.net"); - host2 = persistActiveHost("ns1.example.tld"); - application = persistResource(new DomainApplication.Builder() - .setRepoId("123-TLD") - .setFullyQualifiedDomainName(domainName) - .setPhase(LaunchPhase.SUNRUSH) - .setCurrentSponsorClientId("NewRegistrar") - .setCreationClientId("TheRegistrar") - .setLastEppUpdateClientId("NewRegistrar") - .setCreationTimeForTest(DateTime.parse("1999-04-03T22:00:00.0Z")) - .setLastEppUpdateTime(DateTime.parse("1999-12-03T09:00:00.0Z")) - .setRegistrant(Key.create(registrant)) - .setContacts(ImmutableSet.of( - DesignatedContact.create(Type.ADMIN, Key.create(contact)), - DesignatedContact.create(Type.TECH, Key.create(contact)))) - .setNameservers(hostsState.equals(HostsState.HOSTS_EXIST) ? ImmutableSet.of( - Key.create(host1), Key.create(host2)) : null) - .setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("2fooBAR"))) - .addStatusValue(StatusValue.PENDING_CREATE) - .setApplicationStatus(ApplicationStatus.PENDING_VALIDATION) - .setEncodedSignedMarks(null) - .build()); - } - private void doSuccessfulTest(String expectedXmlFilename, HostsState hostsState) throws Exception { assertTransactionalFlow(false); @@ -348,21 +317,4 @@ public class DomainApplicationInfoFlowTest thrown.expect(ApplicationLaunchPhaseMismatchException.class); runFlow(); } - - - /** Test registry extra logic manager with no flags. */ - @Test - public void testExtraLogicManager_noFlags() throws Exception { - setEppInput("domain_info_sunrise_flags_none.xml"); - persistFlagsTestEntities("domain.flags", HostsState.NO_HOSTS_EXIST); - doSuccessfulTest("domain_info_response_sunrise_flags_none.xml", HostsState.NO_HOSTS_EXIST); - } - - /** Test registry extra logic manager with two flags. */ - @Test - public void testExtraLogicManager_twoFlags() throws Exception { - setEppInput("domain_info_sunrise_flags_two.xml"); - persistFlagsTestEntities("domain-flag1-flag2.flags", HostsState.NO_HOSTS_EXIST); - doSuccessfulTest("domain_info_response_sunrise_flags_two.xml", HostsState.NO_HOSTS_EXIST); - } } diff --git a/javatests/google/registry/flows/domain/DomainApplicationUpdateFlowTest.java b/javatests/google/registry/flows/domain/DomainApplicationUpdateFlowTest.java index 7706a70db..e72861fea 100644 --- a/javatests/google/registry/flows/domain/DomainApplicationUpdateFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainApplicationUpdateFlowTest.java @@ -61,8 +61,6 @@ import google.registry.model.domain.DesignatedContact; import google.registry.model.domain.DesignatedContact.Type; import google.registry.model.domain.DomainApplication; import google.registry.model.domain.DomainApplication.Builder; -import google.registry.model.domain.TestExtraLogicManager; -import google.registry.model.domain.TestExtraLogicManager.TestExtraLogicManagerSuccessException; import google.registry.model.domain.launch.ApplicationStatus; import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.eppcommon.StatusValue; @@ -94,7 +92,6 @@ public class DomainApplicationUpdateFlowTest public void setUp() { createTld("tld", TldState.SUNRUSH); createTld("flags", TldState.SUNRISE); - RegistryExtraFlowLogicProxy.setOverride("flags", TestExtraLogicManager.class); } private void persistReferencedEntities() { @@ -685,15 +682,4 @@ public class DomainApplicationUpdateFlowTest thrown.expect(FeesMismatchException.class); runFlow(); } - - @Test - public void testSuccess_flags() throws Exception { - persistReferencedEntities(); - persistResource( - newDomainApplication("update-42.flags").asBuilder().setRepoId("1-ROID").build()); - setEppInput("domain_update_sunrise_flags.xml", ImmutableMap.of("FEE", "42")); - clock.advanceOneMilli(); - thrown.expect(TestExtraLogicManagerSuccessException.class, "add:flag1;remove:flag2"); - runFlow(); - } } diff --git a/javatests/google/registry/flows/domain/DomainDeleteFlowTest.java b/javatests/google/registry/flows/domain/DomainDeleteFlowTest.java index 6f75e7df4..a74a9aad6 100644 --- a/javatests/google/registry/flows/domain/DomainDeleteFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainDeleteFlowTest.java @@ -58,8 +58,6 @@ import google.registry.model.billing.BillingEvent.Reason; import google.registry.model.contact.ContactResource; import google.registry.model.domain.DomainResource; import google.registry.model.domain.GracePeriod; -import google.registry.model.domain.TestExtraLogicManager; -import google.registry.model.domain.TestExtraLogicManager.TestExtraLogicManagerSuccessException; import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.eppcommon.ProtocolDefinition.ServiceExtension; import google.registry.model.eppcommon.StatusValue; @@ -107,7 +105,6 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCaseof()); } + + private void doSuccessfulTest( + String responseFilename, int renewalYears, Map substitutions) + throws Exception { + doSuccessfulTest( + responseFilename, + renewalYears, + substitutions, + Money.of(USD, 11).multipliedBy(renewalYears)); + } + private void doSuccessfulTest( String responseFilename, int renewalYears, - Map substitutions) throws Exception { + Map substitutions, + Money totalRenewCost) throws Exception { assertTransactionalFlow(true); DateTime currentExpiration = reloadResourceByForeignKey().getRegistrationExpirationTime(); DateTime newExpiration = currentExpiration.plusYears(renewalYears); @@ -155,7 +162,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase() + .put("DOMAIN", "costly-renew.tld") + .put("FEE_VERSION", "0.6") + .put("FEE_NS", "fee") + .put("AMOUNT", "111.00") + .put("EX_DATE", "2001-04-03T22:00:00.000Z") + .build(), + Money.of(USD, 111)); + } + @Test public void testSuccess_fee_v06() throws Exception { setEppInput("domain_renew_fee.xml", FEE_06_MAP); @@ -612,23 +640,4 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase eapValidPeriod = - Range.closedOpen(clock.nowUtc().minusDays(1), clock.nowUtc().plusDays(1)); - assertThat(createPrice.getTotalCost()).isEqualTo(basicCreateCost.plus(Money.of(USD, 100))); - assertThat(createPrice.getCurrency()).isEqualTo(USD); - assertThat(createPrice.getFees().get(0)) - .isEqualTo(Fee.create(basicCreateCost.getAmount(), FeeType.CREATE)); - assertThat(createPrice.getFees().get(1)) - .isEqualTo( - Fee.create( - new BigDecimal("100.00"), - FeeType.EAP, - eapValidPeriod, - clock.nowUtc().plusDays(1))); - assertThat(createPrice.getFees()) - .containsExactly( - Fee.create(basicCreateCost.getAmount(), FeeType.CREATE), - Fee.create( - new BigDecimal("100.00"), - FeeType.EAP, - eapValidPeriod, - clock.nowUtc().plusDays(1))) - .inOrder(); - } - - @Test - public void test_extraLogic_createPrice() throws Exception { - TldSpecificLogicProxy.EppCommandOperations price = - TldSpecificLogicProxy.getCreatePrice( - Registry.get("test"), "create-54.test", "clientId", clock.nowUtc(), 3, null); - assertThat(price.getCurrency()).isEqualTo(CurrencyUnit.USD); - assertThat(price.getFees()).hasSize(1); - assertThat(price.getFees().get(0).getCost()).isEqualTo(new BigDecimal(54)); - assertThat(price.getFees().get(0).getDescription()).isEqualTo("create"); - assertThat(price.getCredits()).isEmpty(); - } - - @Test - public void test_extraLogic_renewPrice() throws Exception { - persistActiveDomain("renew--13.test"); - TldSpecificLogicProxy.EppCommandOperations price = - TldSpecificLogicProxy.getRenewPrice( - Registry.get("test"), "renew--13.test", "clientId", clock.nowUtc(), 1, null); - assertThat(price.getCurrency()).isEqualTo(CurrencyUnit.USD); - assertThat(price.getFees()).isEmpty(); - assertThat(price.getCredits()).hasSize(1); - assertThat(price.getCredits().get(0).getCost()).isEqualTo(new BigDecimal(-13)); - assertThat(price.getCredits().get(0).getDescription()).isEqualTo("renew"); - } - - @Test - public void test_extraLogic_renewPrice_noDomain() throws Exception { - thrown.expect(ResourceDoesNotExistException.class); - TldSpecificLogicProxy.getRenewPrice( - Registry.get("test"), "renew--13.test", "clientId", clock.nowUtc(), 1, null); - } - - void persistPendingDeleteDomain(String domainName, DateTime now) throws Exception { - DomainResource domain = newDomainResource(domainName); - HistoryEntry historyEntry = - persistResource( - new HistoryEntry.Builder() - .setType(HistoryEntry.Type.DOMAIN_DELETE) - .setParent(domain) - .build()); - domain = - persistResource( - domain - .asBuilder() - .setRegistrationExpirationTime(now.plusYears(5).plusDays(45)) - .setDeletionTime(now.plusDays(35)) - .addGracePeriod( - GracePeriod.create(GracePeriodStatus.REDEMPTION, now.plusDays(1), "foo", null)) - .setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE)) - .setDeletePollMessage( - Key.create( - persistResource( - new PollMessage.OneTime.Builder() - .setClientId("TheRegistrar") - .setEventTime(now.plusDays(5)) - .setParent(historyEntry) - .build()))) - .build()); - clock.advanceOneMilli(); - } - - @Test - public void test_extraLogic_restorePrice() throws Exception { - persistPendingDeleteDomain("renew-13.test", clock.nowUtc()); - TldSpecificLogicProxy.EppCommandOperations price = - TldSpecificLogicProxy.getRestorePrice( - Registry.get("test"), "renew-13.test", "clientId", clock.nowUtc(), null); - assertThat(price.getCurrency()).isEqualTo(CurrencyUnit.USD); - assertThat(price.getFees()).hasSize(2); - assertThat(price.getFees().get(0).getCost()).isEqualTo(new BigDecimal(13)); - assertThat(price.getFees().get(0).getDescription()).isEqualTo("renew"); - assertThat(price.getFees().get(1).getDescription()).isEqualTo("restore"); - assertThat(price.getCredits()).isEmpty(); - } - - @Test - public void test_extraLogic_restorePrice_noDomain() throws Exception { - thrown.expect(ResourceDoesNotExistException.class); - TldSpecificLogicProxy.getRestorePrice( - Registry.get("test"), "renew-13.test", "clientId", clock.nowUtc(), null); - } - - @Test - public void test_extraLogic_transferPrice() throws Exception { - persistActiveDomain("renew-26.test"); - TldSpecificLogicProxy.EppCommandOperations price = - TldSpecificLogicProxy.getTransferPrice( - Registry.get("test"), "renew-26.test", "clientId", clock.nowUtc(), 2, null); - assertThat(price.getCurrency()).isEqualTo(CurrencyUnit.USD); - assertThat(price.getFees()).hasSize(1); - assertThat(price.getFees().get(0).getCost()).isEqualTo(new BigDecimal(26)); - assertThat(price.getFees().get(0).getDescription()).isEqualTo("renew"); - assertThat(price.getCredits()).isEmpty(); - } - - @Test - public void test_extraLogic_updatePrice() throws Exception { - persistActiveDomain("update-13.test"); - TldSpecificLogicProxy.EppCommandOperations price = - TldSpecificLogicProxy.getUpdatePrice( - Registry.get("test"), "update-13.test", "clientId", clock.nowUtc(), null); - assertThat(price.getCurrency()).isEqualTo(CurrencyUnit.USD); - assertThat(price.getFees()).hasSize(1); - assertThat(price.getFees().get(0).getCost()).isEqualTo(new BigDecimal(13)); - assertThat(price.getFees().get(0).getDescription()).isEqualTo("update"); - assertThat(price.getCredits()).isEmpty(); - } -} diff --git a/javatests/google/registry/flows/domain/testdata/domain_renew_fee_wildcard.xml b/javatests/google/registry/flows/domain/testdata/domain_renew_fee_wildcard.xml new file mode 100644 index 000000000..8fa516c9f --- /dev/null +++ b/javatests/google/registry/flows/domain/testdata/domain_renew_fee_wildcard.xml @@ -0,0 +1,19 @@ + + + + + %DOMAIN% + 2000-04-03 + 1 + + + + + USD + %AMOUNT% + + + ABC-12345 + + diff --git a/javatests/google/registry/flows/domain/testdata/domain_renew_response_fee_wildcard.xml b/javatests/google/registry/flows/domain/testdata/domain_renew_response_fee_wildcard.xml new file mode 100644 index 000000000..20175216c --- /dev/null +++ b/javatests/google/registry/flows/domain/testdata/domain_renew_response_fee_wildcard.xml @@ -0,0 +1,24 @@ + + + + Command completed successfully + + + + %DOMAIN% + %EX_DATE% + + + + <%FEE_NS%:renData xmlns:%FEE_NS%="urn:ietf:params:xml:ns:fee-%FEE_VERSION%"> + <%FEE_NS%:currency>USD + <%FEE_NS%:fee description="renew">%AMOUNT% + + + + ABC-12345 + server-trid + + + diff --git a/javatests/google/registry/flows/domain/testdata/domain_update_fee.xml b/javatests/google/registry/flows/domain/testdata/domain_update_fee.xml new file mode 100644 index 000000000..2a056b79f --- /dev/null +++ b/javatests/google/registry/flows/domain/testdata/domain_update_fee.xml @@ -0,0 +1,25 @@ + + + + + example.tld + + + + sh8013 + + 2BARfoo + + + + + + + USD + 5.00 + + + ABC-12345 + + diff --git a/javatests/google/registry/flows/domain/testdata/domain_update_wildcard.xml b/javatests/google/registry/flows/domain/testdata/domain_update_wildcard.xml new file mode 100644 index 000000000..dc0bc2f8c --- /dev/null +++ b/javatests/google/registry/flows/domain/testdata/domain_update_wildcard.xml @@ -0,0 +1,32 @@ + + + + + %DOMAIN% + + + ns2.example.foo + + mak21 + Payment overdue. + + + + ns1.example.foo + + sh8013 + + + + sh8013 + + 2BARfoo + + + + + ABC-12345 + + diff --git a/javatests/google/registry/model/domain/TestExtraLogicManager.java b/javatests/google/registry/model/domain/TestExtraLogicManager.java deleted file mode 100644 index 23bf7b100..000000000 --- a/javatests/google/registry/model/domain/TestExtraLogicManager.java +++ /dev/null @@ -1,328 +0,0 @@ -// Copyright 2016 The Nomulus Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package google.registry.model.domain; - -import static com.google.common.base.Preconditions.checkArgument; - -import com.google.common.base.Ascii; -import com.google.common.base.Joiner; -import com.google.common.base.Splitter; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import google.registry.flows.EppException; -import google.registry.flows.domain.RegistryExtraFlowLogic; -import google.registry.model.domain.fee.BaseFee; -import google.registry.model.domain.fee.BaseFee.FeeType; -import google.registry.model.domain.fee.Credit; -import google.registry.model.domain.fee.Fee; -import google.registry.model.domain.flags.FlagsCreateCommandExtension; -import google.registry.model.domain.flags.FlagsTransferCommandExtension; -import google.registry.model.domain.flags.FlagsUpdateCommandExtension; -import google.registry.model.eppinput.EppInput; -import google.registry.model.reporting.HistoryEntry; -import java.math.BigDecimal; -import java.util.List; -import java.util.Set; -import org.joda.time.DateTime; - -/** - * Fake extra logic manager which synthesizes information from the domain name for testing purposes. - */ -public class TestExtraLogicManager implements RegistryExtraFlowLogic { - - /** - * Dummy exception used to signal success. This is thrown by the performAdditionalXXXLogic() - * methods to indicate to the test that everything worked properly, because the - * TestExtraLogicManager instance used by the flow will have been created deep in the flow and is - * not accessible to the test code directly. We should fix this when we make the extra flow logic - * injected. - */ - public static class TestExtraLogicManagerSuccessException extends RuntimeException { - TestExtraLogicManagerSuccessException(String message) { - super(message); - } - } - - /** - * Gets the flags to be used in the EPP flags extension for info commands. - * - *

The test extra logic manager uses domain names differently for info commands than for other - * flows. In other flows, the test logic needs returns (via the success exception) the flags found - * in the incoming message. But for info commands, there aren't any incoming flags, only outgoing - * ones. So we need to specify the flags using a dummy domain name; those flags can then be - * inserted into the outgoing info response. - */ - @Override - public Set getExtensionFlags( - DomainResource domain, String clientId, DateTime asOfDate) { - // Take the part before the period, split by dashes, and treat each part after the first as - // a flag. - List components = - Splitter.on('-').splitToList( - Iterables.getFirst( - Splitter.on('.').split(domain.getFullyQualifiedDomainName()), "")); - return ImmutableSet.copyOf(components.subList(1, components.size())); - } - - /** - * Gets the flags to be used in the EPP flags extension for application info commands. - * - *

This method works the same way as getExtensionFlags(). - */ - @Override - public Set getApplicationExtensionFlags( - DomainApplication application, String clientId, DateTime asOfDate) { - // Take the part before the period, split by dashes, and treat each part after the first as - // a flag. - List components = - Splitter.on('-').splitToList( - Iterables.getFirst( - Splitter.on('.').split(application.getFullyQualifiedDomainName()), "")); - return ImmutableSet.copyOf(components.subList(1, components.size())); - } - - BaseFee domainNameToFeeOrCredit(String domainName) { - // The second-level domain should be of the form "description-price", where description is the - // description string of the fee or credit, and price is the price (credit if negative, fee - // otherwise). To make sure this is a valid domain name, don't use any spaces, and limit prices - // to integers. Don't use a two-character description for credits, since it is illegal to have - // both the third and fourth characters of a domain name label be hyphens. - List components = - Splitter.on('-').limit(2).splitToList( - Iterables.getFirst(Splitter.on('.').split(domainName), "")); - checkArgument(components.size() == 2, "Domain name must be of the form description-price.tld"); - int price = Integer.parseInt(components.get(1)); - if (price < 0) { - return Credit.create( - new BigDecimal(price), FeeType.valueOf(Ascii.toUpperCase(components.get(0)))); - } else { - return Fee.create( - new BigDecimal(price), FeeType.valueOf(Ascii.toUpperCase(components.get(0)))); - } - } - - /** Performs additional tasks required for an application create command. */ - @Override - public void performAdditionalApplicationCreateLogic( - DomainApplication application, - String clientId, - int years, - EppInput eppInput, - HistoryEntry historyEntry) throws EppException { - FlagsCreateCommandExtension flags = - eppInput.getSingleExtension(FlagsCreateCommandExtension.class); - if (flags == null) { - return; - } - throw new TestExtraLogicManagerSuccessException(Joiner.on(',').join(flags.getFlags())); - } - - /** Performs additional tasks required for an application create command. */ - @Override - public void performAdditionalApplicationDeleteLogic( - DomainApplication application, - String clientId, - DateTime asOfDate, - EppInput eppInput, - HistoryEntry historyEntry) throws EppException { - throw new TestExtraLogicManagerSuccessException("application deleted"); - } - - /** Computes the expected application update cost, for use in fee challenges and the like. */ - @Override - public BaseFee getApplicationUpdateFeeOrCredit( - DomainApplication application, - String clientId, - DateTime asOfDate, - EppInput eppInput) throws EppException { - return domainNameToFeeOrCredit(application.getFullyQualifiedDomainName()); - } - - /** Performs additional tasks required for an application update command. */ - @Override - public void performAdditionalApplicationUpdateLogic( - DomainApplication application, - String clientId, - DateTime asOfDate, - EppInput eppInput, - HistoryEntry historyEntry) throws EppException { - FlagsUpdateCommandExtension flags = - eppInput.getSingleExtension(FlagsUpdateCommandExtension.class); - if (flags == null) { - return; - } - throw new TestExtraLogicManagerSuccessException( - "add:" - + Joiner.on(',').join(flags.getAddFlags().getFlags()) - + ";remove:" - + Joiner.on(',').join(flags.getRemoveFlags().getFlags())); - } - - /** Computes the expected create cost, for use in fee challenges and the like. */ - @Override - public BaseFee getCreateFeeOrCredit( - String domainName, - String clientId, - DateTime asOfDate, - int years, - EppInput eppInput) throws EppException { - return domainNameToFeeOrCredit(domainName); - } - - /** Performs additional tasks required for an allocate command. */ - @Override - public void performAdditionalDomainAllocateLogic( - DomainResource domain, - String clientId, - DateTime asOfDate, - int years, - EppInput eppInput, - HistoryEntry historyEntry) throws EppException { - throw new TestExtraLogicManagerSuccessException("allocated"); - } - - /** Performs additional tasks required for a create command. */ - @Override - public void performAdditionalDomainCreateLogic( - DomainResource domain, - String clientId, - int years, - EppInput eppInput, - HistoryEntry historyEntry) throws EppException { - FlagsCreateCommandExtension flags = - eppInput.getSingleExtension(FlagsCreateCommandExtension.class); - if (flags == null) { - return; - } - throw new TestExtraLogicManagerSuccessException(Joiner.on(',').join(flags.getFlags())); - } - - /** Performs additional tasks required for a delete command. */ - @Override - public void performAdditionalDomainDeleteLogic( - DomainResource domainResource, - String clientId, - DateTime asOfDate, - EppInput eppInput, - HistoryEntry historyEntry) throws EppException { - throw new TestExtraLogicManagerSuccessException("deleted"); - } - - /** Computes the expected renewal cost, for use in fee challenges and the like. */ - @Override - public BaseFee getRenewFeeOrCredit( - DomainResource domain, - String clientId, - DateTime asOfDate, - int years, - EppInput eppInput) throws EppException { - return domainNameToFeeOrCredit(domain.getFullyQualifiedDomainName()); - } - - /** Performs additional tasks required for a renew command. */ - @Override - public void performAdditionalDomainRenewLogic( - DomainResource domainResource, - String clientId, - DateTime asOfDate, - int years, - EppInput eppInput, - HistoryEntry historyEntry) throws EppException { - throw new TestExtraLogicManagerSuccessException("renewed"); - } - - /** Performs additional tasks required for a restore command. */ - @Override - public void performAdditionalDomainRestoreLogic( - DomainResource domainResource, - String clientId, - DateTime asOfDate, - EppInput eppInput, - HistoryEntry historyEntry) throws EppException { - throw new TestExtraLogicManagerSuccessException("restored"); - } - - /** Performs additional tasks required for a transfer approve command. */ - @Override - public void performAdditionalDomainTransferApproveLogic( - DomainResource domain, String clientId, HistoryEntry historyEntry) throws EppException { - throw new TestExtraLogicManagerSuccessException("transfer approved"); - } - - /** Performs additional tasks required for a transfer cancel command. */ - @Override - public void performAdditionalDomainTransferCancelLogic( - DomainResource domain, String clientId, HistoryEntry historyEntry) throws EppException { - throw new TestExtraLogicManagerSuccessException("transfer cancelled"); - } - - /** Performs additional tasks required for a transfer reject command. */ - @Override - public void performAdditionalDomainTransferRejectLogic( - DomainResource domain, String clientId, HistoryEntry historyEntry) throws EppException { - throw new TestExtraLogicManagerSuccessException("transfer rejected"); - } - - /** Performs additional tasks required for a transfer request command. */ - @Override - public void performAdditionalDomainTransferRequestLogic( - DomainResource domainResource, - String clientId, - DateTime asOfDate, - int years, - EppInput eppInput, - HistoryEntry historyEntry) throws EppException { - FlagsTransferCommandExtension flags = - eppInput.getSingleExtension(FlagsTransferCommandExtension.class); - if (flags == null) { - return; - } - throw new TestExtraLogicManagerSuccessException( - "add:" - + Joiner.on(',').join(flags.getAddFlags().getFlags()) - + ";remove:" - + Joiner.on(',').join(flags.getRemoveFlags().getFlags())); - } - - /** Computes the expected update cost, for use in fee challenges and the like. */ - @Override - public BaseFee getUpdateFeeOrCredit( - DomainResource domain, - String clientId, - DateTime asOfDate, - EppInput eppInput) throws EppException { - return domainNameToFeeOrCredit(domain.getFullyQualifiedDomainName()); - } - - /** Performs additional tasks required for an update command. */ - @Override - public void performAdditionalDomainUpdateLogic( - DomainResource domainResource, - String clientId, - DateTime asOfDate, - EppInput eppInput, - HistoryEntry historyEntry) throws EppException { - FlagsUpdateCommandExtension flags = - eppInput.getSingleExtension(FlagsUpdateCommandExtension.class); - if (flags == null) { - return; - } - throw new TestExtraLogicManagerSuccessException( - "add:" - + Joiner.on(',').join(flags.getAddFlags().getFlags()) - + ";remove:" - + Joiner.on(',').join(flags.getRemoveFlags().getFlags())); - } -}