diff --git a/java/google/registry/flows/domain/DomainCheckFlow.java b/java/google/registry/flows/domain/DomainCheckFlow.java index 6686c068b..ac4daddb1 100644 --- a/java/google/registry/flows/domain/DomainCheckFlow.java +++ b/java/google/registry/flows/domain/DomainCheckFlow.java @@ -27,7 +27,7 @@ import static google.registry.model.domain.fee.Fee.FEE_EXTENSION_URIS; import static google.registry.model.eppoutput.Result.Code.SUCCESS; import static google.registry.model.index.DomainApplicationIndex.loadActiveApplicationsByDomainName; import static google.registry.model.registry.label.ReservationType.UNRESERVED; -import static google.registry.pricing.PricingEngineProxy.getPricesForDomainName; +import static google.registry.pricing.PricingEngineProxy.isDomainPremium; import static google.registry.util.CollectionUtils.nullToEmpty; import com.google.common.base.Predicate; @@ -158,7 +158,7 @@ public final class DomainCheckFlow extends LoggedInFlow { } ReservationType reservationType = getReservationType(domainName); if (reservationType == UNRESERVED - && getPricesForDomainName(domainName.toString(), now).isPremium() + && isDomainPremium(domainName.toString(), now) && registry.getPremiumPriceAckRequired() && Collections.disjoint( nullToEmpty(sessionMetadata.getServiceExtensionUris()), diff --git a/java/google/registry/flows/domain/DomainFlowUtils.java b/java/google/registry/flows/domain/DomainFlowUtils.java index 94c6508b8..e565fe11d 100644 --- a/java/google/registry/flows/domain/DomainFlowUtils.java +++ b/java/google/registry/flows/domain/DomainFlowUtils.java @@ -27,7 +27,7 @@ import static google.registry.model.EppResourceUtils.loadByForeignKey; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.registry.Registries.findTldForName; import static google.registry.model.registry.label.ReservedList.getReservation; -import static google.registry.pricing.PricingEngineProxy.getPricesForDomainName; +import static google.registry.pricing.PricingEngineProxy.isDomainPremium; import static google.registry.tldconfig.idn.IdnLabelValidator.findValidIdnTableForTld; import static google.registry.util.CollectionUtils.nullToEmpty; import static google.registry.util.DateTimeUtils.END_OF_TIME; @@ -413,7 +413,7 @@ public class DomainFlowUtils { */ static void verifyPremiumNameIsNotBlocked( String domainName, DateTime priceTime, String clientId) throws EppException { - if (getPricesForDomainName(domainName, priceTime).isPremium()) { + if (isDomainPremium(domainName, priceTime)) { // NB: The load of the Registar object is transactionless, which means that it should hit // memcache most of the time. if (Registrar.loadByClientId(clientId).getBlockPremiumNames()) { @@ -686,7 +686,7 @@ public class DomainFlowUtils { throws EppException { Registry registry = Registry.get(tld); if (registry.getPremiumPriceAckRequired() - && getPricesForDomainName(domainName, priceTime).isPremium() + && isDomainPremium(domainName, priceTime) && feeCommand == null) { throw new FeesRequiredForPremiumNameException(); } diff --git a/java/google/registry/flows/domain/TldSpecificLogicProxy.java b/java/google/registry/flows/domain/TldSpecificLogicProxy.java index ca8b6c81b..72d5c37f4 100644 --- a/java/google/registry/flows/domain/TldSpecificLogicProxy.java +++ b/java/google/registry/flows/domain/TldSpecificLogicProxy.java @@ -17,7 +17,9 @@ 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.getPricesForDomainName; +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; @@ -35,7 +37,6 @@ 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.pricing.PremiumPricingEngine.DomainPrices; import google.registry.model.registry.Registry; import java.util.List; import org.joda.money.CurrencyUnit; @@ -152,9 +153,8 @@ public final class TldSpecificLogicProxy { createFeeOrCredit = extraFlowLogic.get() .getCreateFeeOrCredit(domainName, clientId, date, years, eppInput); } else { - DomainPrices prices = getPricesForDomainName(domainName, date); createFeeOrCredit = - Fee.create(prices.getCreateCost().multipliedBy(years).getAmount(), FeeType.CREATE); + Fee.create(getDomainCreateCost(domainName, date, years).getAmount(), FeeType.CREATE); } // Create fees for the cost and the EAP fee, if any. @@ -188,8 +188,7 @@ public final class TldSpecificLogicProxy { return extraFlowLogic.get().getRenewFeeOrCredit(domain, clientId, date, years, eppInput); } else { - DomainPrices prices = getPricesForDomainName(domainName, date); - return Fee.create(prices.getRenewCost().multipliedBy(years).getAmount(), FeeType.RENEW); + return Fee.create(getDomainRenewCost(domainName, date, years).getAmount(), FeeType.RENEW); } } @@ -262,7 +261,7 @@ public final class TldSpecificLogicProxy { /** Returns the fee class for a given domain and date. */ public static Optional getFeeClass(String domainName, DateTime date) { - return getPricesForDomainName(domainName, date).getFeeClass(); + return getDomainFeeClass(domainName, date); } /** diff --git a/java/google/registry/pricing/PricingEngineProxy.java b/java/google/registry/pricing/PricingEngineProxy.java index 457f757a1..e5396fd70 100644 --- a/java/google/registry/pricing/PricingEngineProxy.java +++ b/java/google/registry/pricing/PricingEngineProxy.java @@ -18,6 +18,7 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import static google.registry.util.DomainNameUtils.getTldFromDomainName; +import com.google.common.base.Optional; import google.registry.model.pricing.PremiumPricingEngine; import google.registry.model.pricing.PremiumPricingEngine.DomainPrices; import google.registry.model.registry.Registry; @@ -46,6 +47,16 @@ public final class PricingEngineProxy { return getPricesForDomainName(domainName, priceTime).getRenewCost().multipliedBy(years); } + /** Returns true if the specified domain name is premium. */ + public static boolean isDomainPremium(String domainName, DateTime priceTime) { + return getPricesForDomainName(domainName, priceTime).isPremium(); + } + + /** Returns the fee class of the specified domain name. */ + public static Optional getDomainFeeClass(String domainName, DateTime priceTime) { + return getPricesForDomainName(domainName, priceTime).getFeeClass(); + } + /** * Returns the full {@link DomainPrices} details for the given domain name by dispatching to the * appropriate {@link PremiumPricingEngine} based on what is configured for the TLD that the diff --git a/javatests/google/registry/flows/domain/DomainCreateFlowTest.java b/javatests/google/registry/flows/domain/DomainCreateFlowTest.java index bc7b9c372..990f98d6b 100644 --- a/javatests/google/registry/flows/domain/DomainCreateFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainCreateFlowTest.java @@ -18,7 +18,7 @@ import static com.google.common.io.BaseEncoding.base16; import static com.google.common.truth.Truth.assertThat; import static google.registry.model.domain.fee.Fee.FEE_EXTENSION_URIS; import static google.registry.model.ofy.ObjectifyService.ofy; -import static google.registry.pricing.PricingEngineProxy.getPricesForDomainName; +import static google.registry.pricing.PricingEngineProxy.isDomainPremium; import static google.registry.testing.DatastoreHelper.assertBillingEvents; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.createTlds; @@ -173,7 +173,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase