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:
Brian Mountford 2016-07-19 10:54:56 -07:00 committed by Justine Tunney
parent f75bb65fd3
commit 8443da5c5c
170 changed files with 4376 additions and 586 deletions

View file

@ -20,6 +20,7 @@ import static google.registry.flows.domain.DomainFlowUtils.newAutorenewPollMessa
import static google.registry.flows.domain.DomainFlowUtils.validateFeeChallenge;
import static google.registry.flows.domain.DomainFlowUtils.verifyNotReserved;
import static google.registry.flows.domain.DomainFlowUtils.verifyPremiumNameIsNotBlocked;
import static google.registry.model.domain.fee.Fee.FEE_UPDATE_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER;
import static google.registry.model.eppoutput.Result.Code.Success;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.pricing.PricingEngineProxy.getDomainRenewCost;
@ -38,8 +39,7 @@ import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.domain.DomainCommand.Update;
import google.registry.model.domain.DomainResource;
import google.registry.model.domain.fee.Fee;
import google.registry.model.domain.fee.FeeUpdateExtension;
import google.registry.model.domain.fee.FeeUpdateResponseExtension;
import google.registry.model.domain.fee.FeeTransformCommandExtension;
import google.registry.model.domain.rgp.GracePeriodStatus;
import google.registry.model.domain.rgp.RgpUpdateExtension;
import google.registry.model.eppcommon.StatusValue;
@ -71,7 +71,7 @@ import org.joda.time.DateTime;
*/
public class DomainRestoreRequestFlow extends OwnedResourceMutateFlow<DomainResource, Update> {
protected FeeUpdateExtension feeUpdate;
protected FeeTransformCommandExtension feeUpdate;
protected Money restoreCost;
protected Money renewCost;
@ -79,7 +79,8 @@ public class DomainRestoreRequestFlow extends OwnedResourceMutateFlow<DomainReso
@Override
protected final void initResourceCreateOrMutateFlow() throws EppException {
registerExtensions(FeeUpdateExtension.class, RgpUpdateExtension.class);
registerExtensions(RgpUpdateExtension.class);
registerExtensions(FEE_UPDATE_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER);
}
@Override
@ -101,7 +102,8 @@ public class DomainRestoreRequestFlow extends OwnedResourceMutateFlow<DomainReso
verifyNotReserved(InternetDomainName.from(targetId), false);
verifyPremiumNameIsNotBlocked(targetId, now, getClientId());
}
feeUpdate = eppInput.getSingleExtension(FeeUpdateExtension.class);
feeUpdate = eppInput.getFirstExtensionOfClasses(
FEE_UPDATE_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER);
restoreCost = Registry.get(tld).getStandardRestoreCost();
renewCost = getDomainRenewCost(targetId, now, 1);
validateFeeChallenge(targetId, tld, now, feeUpdate, restoreCost, renewCost);
@ -186,9 +188,9 @@ public class DomainRestoreRequestFlow extends OwnedResourceMutateFlow<DomainReso
Success,
null,
(feeUpdate == null) ? null : ImmutableList.of(
new FeeUpdateResponseExtension.Builder()
feeUpdate.createResponseBuilder()
.setCurrency(restoreCost.getCurrencyUnit())
.setFee(ImmutableList.of(
.setFees(ImmutableList.of(
Fee.create(restoreCost.getAmount(), "restore"),
Fee.create(renewCost.getAmount(), "renew")))
.build()));