mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 16:07:15 +02:00
Support multiple versions of the EPP Fee Extension
We want to support multiple versions of the fee extension, to allow new features while maintaining backward compatibility. This CL extends the framework and adds one new version, 0.11 (spec version 7), to the existing version 0.6 (spec version 3). A follow-on CL will add version 0.12 (spec version 8). ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=127849044
This commit is contained in:
parent
f75bb65fd3
commit
8443da5c5c
170 changed files with 4376 additions and 586 deletions
|
@ -17,6 +17,8 @@ package google.registry.flows.domain;
|
|||
import static google.registry.flows.domain.DomainFlowUtils.getReservationType;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.handleFeeRequest;
|
||||
import static google.registry.model.EppResourceUtils.checkResourcesExist;
|
||||
import static google.registry.model.domain.fee.Fee.FEE_CHECK_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER;
|
||||
import static google.registry.model.domain.fee.Fee.FEE_EXTENSION_URIS;
|
||||
import static google.registry.model.index.DomainApplicationIndex.loadActiveApplicationsByDomainName;
|
||||
import static google.registry.model.registry.label.ReservationType.UNRESERVED;
|
||||
import static google.registry.pricing.PricingEngineProxy.getPricesForDomainName;
|
||||
|
@ -26,16 +28,17 @@ import static google.registry.util.DomainNameUtils.getTldFromDomainName;
|
|||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.net.InternetDomainName;
|
||||
import google.registry.flows.EppException;
|
||||
import google.registry.flows.EppException.ParameterValuePolicyErrorException;
|
||||
import google.registry.model.domain.DomainApplication;
|
||||
import google.registry.model.domain.fee.FeeCheckExtension;
|
||||
import google.registry.model.domain.fee.FeeCheckCommandExtension;
|
||||
import google.registry.model.domain.fee.FeeCheckCommandExtensionItem;
|
||||
import google.registry.model.domain.fee.FeeCheckResponseExtension;
|
||||
import google.registry.model.domain.fee.FeeCheckResponseExtension.FeeCheck;
|
||||
import google.registry.model.domain.fee.FeeCheckResponseExtensionItem;
|
||||
import google.registry.model.domain.launch.LaunchCheckExtension;
|
||||
import google.registry.model.eppcommon.ProtocolDefinition.ServiceExtension;
|
||||
import google.registry.model.eppoutput.CheckData;
|
||||
import google.registry.model.eppoutput.CheckData.DomainCheck;
|
||||
import google.registry.model.eppoutput.CheckData.DomainCheckData;
|
||||
|
@ -43,8 +46,10 @@ import google.registry.model.eppoutput.EppResponse.ResponseExtension;
|
|||
import google.registry.model.registry.Registry;
|
||||
import google.registry.model.registry.Registry.TldState;
|
||||
import google.registry.model.registry.label.ReservationType;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import javax.inject.Inject;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
|
||||
/**
|
||||
* An EPP flow that checks whether a domain can be provisioned.
|
||||
|
@ -81,7 +86,8 @@ public class DomainCheckFlow extends BaseDomainCheckFlow {
|
|||
|
||||
@Override
|
||||
protected void initDomainCheckFlow() throws EppException {
|
||||
registerExtensions(LaunchCheckExtension.class, FeeCheckExtension.class);
|
||||
registerExtensions(LaunchCheckExtension.class);
|
||||
registerExtensions(FEE_CHECK_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER);
|
||||
}
|
||||
|
||||
private String getMessageForCheck(String targetId, Set<String> existingIds) {
|
||||
|
@ -103,8 +109,9 @@ public class DomainCheckFlow extends BaseDomainCheckFlow {
|
|||
if (reservationType == UNRESERVED
|
||||
&& getPricesForDomainName(domainName.toString(), now).isPremium()
|
||||
&& registry.getPremiumPriceAckRequired()
|
||||
&& !nullToEmpty(sessionMetadata.getServiceExtensionUris()).contains(
|
||||
ServiceExtension.FEE_0_6.getUri())) {
|
||||
&& Collections.disjoint(
|
||||
nullToEmpty(sessionMetadata.getServiceExtensionUris()),
|
||||
FEE_EXTENSION_URIS)) {
|
||||
return "Premium names require EPP ext.";
|
||||
}
|
||||
return reservationType.getMessageForCheck();
|
||||
|
@ -121,30 +128,59 @@ public class DomainCheckFlow extends BaseDomainCheckFlow {
|
|||
return DomainCheckData.create(checks.build());
|
||||
}
|
||||
|
||||
/** Handle the fee check extension. */
|
||||
@Override
|
||||
protected ImmutableList<? extends ResponseExtension> getResponseExtensions() throws EppException {
|
||||
FeeCheckExtension feeCheck = eppInput.getSingleExtension(FeeCheckExtension.class);
|
||||
if (feeCheck == null) {
|
||||
return null; // No fee checks were requested.
|
||||
}
|
||||
ImmutableList.Builder<FeeCheck> feeChecksBuilder = new ImmutableList.Builder<>();
|
||||
for (FeeCheckExtension.DomainCheck domainCheck : feeCheck.getDomains()) {
|
||||
String domainName = domainCheck.getName();
|
||||
if (!domainNames.containsKey(domainName)) {
|
||||
/**
|
||||
* Return the domains to be checked for a particular fee check item. Some versions of the fee
|
||||
* extension specify the domain name in the extension item, while others use the list of domain
|
||||
* names from the regular check domain availability list.
|
||||
*/
|
||||
private Set<String> getDomainNamesToCheck(FeeCheckCommandExtensionItem feeCheckItem)
|
||||
throws OnlyCheckedNamesCanBeFeeCheckedException {
|
||||
if (feeCheckItem.isDomainNameSupported()) {
|
||||
String domainNameInExtension = feeCheckItem.getDomainName();
|
||||
if (!domainNames.containsKey(domainNameInExtension)) {
|
||||
// Although the fee extension explicitly says it's ok to fee check a domain name that you
|
||||
// aren't also availability checking, we forbid it. This makes the experience simpler and
|
||||
// also means we can assume any domain names in the fee checks have been validated.
|
||||
throw new OnlyCheckedNamesCanBeFeeCheckedException();
|
||||
}
|
||||
FeeCheck.Builder builder = new FeeCheck.Builder();
|
||||
handleFeeRequest(
|
||||
domainCheck, builder, domainName, getTldFromDomainName(domainName), now);
|
||||
feeChecksBuilder.add(builder.setName(domainName).build());
|
||||
return ImmutableSet.of(domainNameInExtension);
|
||||
} else {
|
||||
// If this version of the fee extension is nameless, use the full list of domains.
|
||||
return domainNames.keySet();
|
||||
}
|
||||
return ImmutableList.of(FeeCheckResponseExtension.create(feeChecksBuilder.build()));
|
||||
}
|
||||
}
|
||||
|
||||
/** Handle the fee check extension. */
|
||||
@Override
|
||||
protected ImmutableList<ResponseExtension> getResponseExtensions() throws EppException {
|
||||
FeeCheckCommandExtension<
|
||||
? extends FeeCheckCommandExtensionItem, ? extends FeeCheckResponseExtension<?>>
|
||||
feeCheck = eppInput.getFirstExtensionOfClasses(
|
||||
FEE_CHECK_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER);
|
||||
if (feeCheck == null) {
|
||||
return null; // No fee checks were requested.
|
||||
}
|
||||
CurrencyUnit topLevelCurrency = feeCheck.isCurrencySupported() ? feeCheck.getCurrency() : null;
|
||||
ImmutableList.Builder<FeeCheckResponseExtensionItem> feeCheckResponseItemsBuilder =
|
||||
new ImmutableList.Builder<>();
|
||||
for (FeeCheckCommandExtensionItem feeCheckItem : feeCheck.getItems()) {
|
||||
for (String domainName : getDomainNamesToCheck(feeCheckItem)) {
|
||||
FeeCheckResponseExtensionItem.Builder builder = feeCheckItem.createResponseBuilder();
|
||||
handleFeeRequest(
|
||||
feeCheckItem,
|
||||
builder,
|
||||
domainName,
|
||||
getTldFromDomainName(domainName),
|
||||
topLevelCurrency,
|
||||
now);
|
||||
feeCheckResponseItemsBuilder
|
||||
.add(builder.setDomainNameIfSupported(domainName).build());
|
||||
}
|
||||
}
|
||||
return ImmutableList.<ResponseExtension>of(
|
||||
feeCheck.createResponse(feeCheckResponseItemsBuilder.build()));
|
||||
}
|
||||
|
||||
/** By server policy, fee check names must be listed in the availability check. */
|
||||
static class OnlyCheckedNamesCanBeFeeCheckedException extends ParameterValuePolicyErrorException {
|
||||
OnlyCheckedNamesCanBeFeeCheckedException() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue