Simplify the fee extensions.

I added shared base classes to all of the Fee extension types that
make it possible to fully ignore the version in the flows. (You
ask for a FeeCreateCommandExtension, for example, and you get one
without having to worry about which). This is an improvement over
the old code that asked you to provide a list of possible fee
extensions and then ask for the first one in preference order.

As part of this I was able to make the Fee implementation a bit
simpler as well.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=137992390
This commit is contained in:
cgoldfeder 2016-11-02 14:18:47 -07:00 committed by Ben McIlwain
parent 2dd703ef3a
commit 8256120b3a
66 changed files with 786 additions and 954 deletions

View file

@ -14,12 +14,16 @@
package google.registry.flows;
import static com.google.common.collect.Iterables.any;
import static com.google.common.collect.Sets.difference;
import static com.google.common.collect.Sets.intersection;
import static google.registry.model.domain.fee.Fee.FEE_EXTENSION_URIS;
import static google.registry.model.eppcommon.ProtocolDefinition.ServiceExtension.getCommandExtensionUri;
import com.google.common.base.Joiner;
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 google.registry.flows.EppException.CommandUseErrorException;
import google.registry.flows.EppException.SyntaxErrorException;
@ -30,7 +34,6 @@ import google.registry.model.domain.metadata.MetadataExtension;
import google.registry.model.eppinput.EppInput;
import google.registry.model.eppinput.EppInput.CommandExtension;
import google.registry.util.FormattingLogger;
import java.util.Collection;
import java.util.Set;
import javax.inject.Inject;
@ -49,8 +52,6 @@ public final class ExtensionManager {
private final ImmutableSet.Builder<Class<? extends CommandExtension>> implementedBuilder =
new ImmutableSet.Builder<>();
private final ImmutableSet.Builder<ImmutableSet<?>> implementedGroupsBuilder =
new ImmutableSet.Builder<>();
@Inject EppInput eppInput;
@Inject SessionMetadata sessionMetadata;
@ -64,12 +65,6 @@ public final class ExtensionManager {
implementedBuilder.add(extension);
}
public <T extends CommandExtension> void registerAsGroup(
Collection<Class<? extends T>> extensions) {
implementedBuilder.addAll(extensions);
implementedGroupsBuilder.add(ImmutableSet.copyOf(extensions));
}
public void validate() throws EppException {
ImmutableSet.Builder<Class<? extends CommandExtension>> suppliedBuilder =
new ImmutableSet.Builder<>();
@ -79,27 +74,12 @@ public final class ExtensionManager {
ImmutableSet<Class<? extends CommandExtension>> suppliedExtensions = suppliedBuilder.build();
ImmutableSet<Class<? extends CommandExtension>> implementedExtensions =
implementedBuilder.build();
ImmutableSet<ImmutableSet<?>> implementedExtensionGroups =
implementedGroupsBuilder.build();
checkForDuplicateExtensions(suppliedExtensions, implementedExtensionGroups);
ImmutableList<CommandExtension> suppliedExtensionInstances =
eppInput.getCommandWrapper().getExtensions();
checkForUndeclaredExtensions(suppliedExtensions);
checkForRestrictedExtensions(suppliedExtensions);
checkForUnimplementedExtensions(suppliedExtensions, implementedExtensions);
}
private void checkForDuplicateExtensions(
ImmutableSet<Class<? extends CommandExtension>> suppliedExtensions,
ImmutableSet<ImmutableSet<?>> implementedExtensionGroups)
throws UnsupportedRepeatedExtensionException {
if (suppliedExtensions.size() < eppInput.getCommandWrapper().getExtensions().size()) {
throw new UnsupportedRepeatedExtensionException();
}
// No more than one extension in an extension group can be present.
for (ImmutableSet<?> group : implementedExtensionGroups) {
if (intersection(suppliedExtensions, group).size() > 1) {
throw new UnsupportedRepeatedExtensionException();
}
}
checkForDuplicateExtensions(suppliedExtensionInstances, suppliedExtensions);
checkForUnimplementedExtensions(suppliedExtensionInstances, implementedExtensions);
}
private void checkForUndeclaredExtensions(
@ -134,22 +114,39 @@ public final class ExtensionManager {
}
}
private void checkForUnimplementedExtensions(
ImmutableSet<Class<? extends CommandExtension>> suppliedExtensions,
private static void checkForDuplicateExtensions(
ImmutableList<CommandExtension> suppliedExtensionInstances,
ImmutableSet<Class<? extends CommandExtension>> implementedExtensions)
throws UnimplementedExtensionException {
Set<Class<? extends CommandExtension>> unimplementedExtensions =
difference(suppliedExtensions, implementedExtensions);
if (!unimplementedExtensions.isEmpty()) {
logger.infofmt("Unimplemented extensions: %s", unimplementedExtensions);
throw new UnimplementedExtensionException();
throws UnsupportedRepeatedExtensionException {
for (Class<? extends CommandExtension> implemented : implementedExtensions) {
if (FluentIterable.from(suppliedExtensionInstances).filter(implemented).size() > 1) {
throw new UnsupportedRepeatedExtensionException();
}
}
}
/** Unsupported repetition of an extension. */
static class UnsupportedRepeatedExtensionException extends SyntaxErrorException {
public UnsupportedRepeatedExtensionException() {
super("Unsupported repetition of an extension");
private static void checkForUnimplementedExtensions(
ImmutableList<CommandExtension> suppliedExtensionInstances,
ImmutableSet<Class<? extends CommandExtension>> implementedExtensionClasses)
throws UnimplementedExtensionException {
ImmutableSet.Builder<Class<? extends CommandExtension>> unimplementedExtensionsBuilder =
new ImmutableSet.Builder<>();
for (final CommandExtension instance : suppliedExtensionInstances) {
if (!any(
implementedExtensionClasses,
new Predicate<Class<? extends CommandExtension>>() {
@Override
public boolean apply(Class<? extends CommandExtension> implementedExtensionClass) {
return implementedExtensionClass.isInstance(instance);
}})) {
unimplementedExtensionsBuilder.add(instance.getClass());
}
}
ImmutableSet<Class<? extends CommandExtension>> unimplementedExtensions =
unimplementedExtensionsBuilder.build();
if (!unimplementedExtensions.isEmpty()) {
logger.infofmt("Unimplemented extensions: %s", unimplementedExtensions);
throw new UnimplementedExtensionException();
}
}
@ -160,4 +157,11 @@ public final class ExtensionManager {
Joiner.on(", ").join(undeclaredUris)));
}
}
/** Unsupported repetition of an extension. */
static class UnsupportedRepeatedExtensionException extends SyntaxErrorException {
public UnsupportedRepeatedExtensionException() {
super("Unsupported repetition of an extension");
}
}
}

View file

@ -30,7 +30,6 @@ import static google.registry.flows.domain.DomainFlowUtils.validateSecDnsExtensi
import static google.registry.flows.domain.DomainFlowUtils.verifyUnitIsYears;
import static google.registry.model.EppResourceUtils.createDomainRoid;
import static google.registry.model.EppResourceUtils.loadDomainApplication;
import static google.registry.model.domain.fee.Fee.FEE_CREATE_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.model.registry.label.ReservedList.matchesAnchorTenantReservation;
import static google.registry.pricing.PricingEngineProxy.getDomainCreateCost;
@ -63,7 +62,7 @@ import google.registry.model.domain.DomainResource;
import google.registry.model.domain.GracePeriod;
import google.registry.model.domain.Period;
import google.registry.model.domain.allocate.AllocateCreateExtension;
import google.registry.model.domain.fee.FeeTransformCommandExtension;
import google.registry.model.domain.fee.FeeCreateCommandExtension;
import google.registry.model.domain.fee.FeeTransformResponseExtension;
import google.registry.model.domain.flags.FlagsCreateCommandExtension;
import google.registry.model.domain.launch.ApplicationStatus;
@ -118,11 +117,11 @@ public class DomainAllocateFlow implements TransactionalFlow {
@Override
public final EppResponse run() throws EppException {
extensionManager.register(
FeeCreateCommandExtension.class,
SecDnsCreateExtension.class,
FlagsCreateCommandExtension.class,
MetadataExtension.class,
AllocateCreateExtension.class);
extensionManager.registerAsGroup(FEE_CREATE_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER);
extensionManager.validate();
validateClientIsLoggedIn(clientId);
verifyIsSuperuser();
@ -374,8 +373,8 @@ public class DomainAllocateFlow implements TransactionalFlow {
DateTime now, Registry registry, int years) throws EppException {
EppCommandOperations commandOperations = TldSpecificLogicProxy.getCreatePrice(
registry, targetId, clientId, now, years, eppInput);
FeeTransformCommandExtension feeCreate =
eppInput.getFirstExtensionOfClasses(FEE_CREATE_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER);
FeeCreateCommandExtension feeCreate =
eppInput.getSingleExtension(FeeCreateCommandExtension.class);
return (feeCreate == null)
? null
: ImmutableList.of(createFeeCreateResponse(feeCreate, commandOperations));

View file

@ -38,7 +38,6 @@ import static google.registry.flows.domain.DomainFlowUtils.verifyRegistryStateAl
import static google.registry.flows.domain.DomainFlowUtils.verifySignedMarks;
import static google.registry.flows.domain.DomainFlowUtils.verifyUnitIsYears;
import static google.registry.model.EppResourceUtils.createDomainRoid;
import static google.registry.model.domain.fee.Fee.FEE_CREATE_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER;
import static google.registry.model.index.DomainApplicationIndex.loadActiveApplicationsByDomainName;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.model.registry.label.ReservedList.matchesAnchorTenantReservation;
@ -65,6 +64,7 @@ import google.registry.model.domain.DomainApplication;
import google.registry.model.domain.DomainCommand.Create;
import google.registry.model.domain.DomainResource;
import google.registry.model.domain.Period;
import google.registry.model.domain.fee.FeeCreateCommandExtension;
import google.registry.model.domain.fee.FeeTransformCommandExtension;
import google.registry.model.domain.flags.FlagsCreateCommandExtension;
import google.registry.model.domain.launch.ApplicationStatus;
@ -172,11 +172,11 @@ public final class DomainApplicationCreateFlow implements TransactionalFlow {
@Override
public final EppResponse run() throws EppException {
extensionManager.register(
FeeCreateCommandExtension.class,
SecDnsCreateExtension.class,
FlagsCreateCommandExtension.class,
MetadataExtension.class,
LaunchCreateExtension.class);
extensionManager.registerAsGroup(FEE_CREATE_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER);
extensionManager.validate();
validateClientIsLoggedIn(clientId);
DateTime now = ofy().getTransactionTime();
@ -212,8 +212,8 @@ public final class DomainApplicationCreateFlow implements TransactionalFlow {
verifyNotReserved(domainName, isSunriseApplication);
}
}
FeeTransformCommandExtension feeCreate =
eppInput.getFirstExtensionOfClasses(FEE_CREATE_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER);
FeeCreateCommandExtension feeCreate =
eppInput.getSingleExtension(FeeCreateCommandExtension.class);
validateFeeChallenge(targetId, tld, now, feeCreate, commandOperations.getTotalCost());
SecDnsCreateExtension secDnsCreate =
validateSecDnsExtension(eppInput.getSingleExtension(SecDnsCreateExtension.class));

View file

@ -39,7 +39,6 @@ import static google.registry.flows.domain.DomainFlowUtils.verifyApplicationDoma
import static google.registry.flows.domain.DomainFlowUtils.verifyClientUpdateNotProhibited;
import static google.registry.flows.domain.DomainFlowUtils.verifyNotInPendingDelete;
import static google.registry.model.EppResourceUtils.loadDomainApplication;
import static google.registry.model.domain.fee.Fee.FEE_UPDATE_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER;
import static google.registry.model.ofy.ObjectifyService.ofy;
import com.google.common.base.Optional;
@ -138,7 +137,6 @@ public class DomainApplicationUpdateFlow implements TransactionalFlow {
LaunchUpdateExtension.class,
MetadataExtension.class,
SecDnsUpdateExtension.class);
extensionManager.registerAsGroup(FEE_UPDATE_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER);
extensionManager.validate();
validateClientIsLoggedIn(clientId);
DateTime now = ofy().getTransactionTime();

View file

@ -23,7 +23,6 @@ import static google.registry.flows.domain.DomainFlowUtils.validateDomainName;
import static google.registry.flows.domain.DomainFlowUtils.validateDomainNameWithIdnTables;
import static google.registry.flows.domain.DomainFlowUtils.verifyNotInPredelegation;
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.index.DomainApplicationIndex.loadActiveApplicationsByDomainName;
import static google.registry.model.registry.label.ReservationType.UNRESERVED;
import static google.registry.pricing.PricingEngineProxy.isDomainPremium;
@ -111,8 +110,7 @@ public final class DomainCheckFlow implements Flow {
@Override
public EppResponse run() throws EppException {
extensionManager.register(LaunchCheckExtension.class);
extensionManager.registerAsGroup(FEE_CHECK_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER);
extensionManager.register(FeeCheckCommandExtension.class, LaunchCheckExtension.class);
extensionManager.validate();
validateClientIsLoggedIn(clientId);
List<String> targetIds = ((Check) resourceCommand).getTargetIds();
@ -177,7 +175,7 @@ public final class DomainCheckFlow implements Flow {
private ImmutableList<? extends ResponseExtension> getResponseExtensions(
ImmutableMap<String, InternetDomainName> domainNames, DateTime now) throws EppException {
FeeCheckCommandExtension<?, ?> feeCheck =
eppInput.getFirstExtensionOfClasses(FEE_CHECK_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER);
eppInput.getSingleExtension(FeeCheckCommandExtension.class);
if (feeCheck == null) {
return null; // No fee checks were requested.
}
@ -185,7 +183,7 @@ public final class DomainCheckFlow implements Flow {
new ImmutableList.Builder<>();
for (FeeCheckCommandExtensionItem feeCheckItem : feeCheck.getItems()) {
for (String domainName : getDomainNamesToCheckForFee(feeCheckItem, domainNames.keySet())) {
FeeCheckResponseExtensionItem.Builder builder = feeCheckItem.createResponseBuilder();
FeeCheckResponseExtensionItem.Builder<?> builder = feeCheckItem.createResponseBuilder();
handleFeeRequest(
feeCheckItem,
builder,

View file

@ -36,7 +36,6 @@ import static google.registry.flows.domain.DomainFlowUtils.verifyPremiumNameIsNo
import static google.registry.flows.domain.DomainFlowUtils.verifySignedMarks;
import static google.registry.flows.domain.DomainFlowUtils.verifyUnitIsYears;
import static google.registry.model.EppResourceUtils.createDomainRoid;
import static google.registry.model.domain.fee.Fee.FEE_CREATE_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER;
import static google.registry.model.index.DomainApplicationIndex.loadActiveApplicationsByDomainName;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.model.registry.label.ReservedList.matchesAnchorTenantReservation;
@ -70,7 +69,7 @@ import google.registry.model.domain.DomainCommand.Create;
import google.registry.model.domain.DomainResource;
import google.registry.model.domain.GracePeriod;
import google.registry.model.domain.Period;
import google.registry.model.domain.fee.FeeTransformCommandExtension;
import google.registry.model.domain.fee.FeeCreateCommandExtension;
import google.registry.model.domain.fee.FeeTransformResponseExtension;
import google.registry.model.domain.flags.FlagsCreateCommandExtension;
import google.registry.model.domain.launch.LaunchCreateExtension;
@ -168,11 +167,11 @@ public class DomainCreateFlow implements TransactionalFlow {
@Override
public final EppResponse run() throws EppException {
extensionManager.register(
FeeCreateCommandExtension.class,
SecDnsCreateExtension.class,
FlagsCreateCommandExtension.class,
MetadataExtension.class,
LaunchCreateExtension.class);
extensionManager.registerAsGroup(FEE_CREATE_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER);
extensionManager.validate();
validateClientIsLoggedIn(clientId);
DateTime now = ofy().getTransactionTime();
@ -199,8 +198,8 @@ public class DomainCreateFlow implements TransactionalFlow {
if (hasSignedMarks) {
verifySignedMarksAllowed(tldState, isAnchorTenant);
}
FeeTransformCommandExtension feeCreate =
eppInput.getFirstExtensionOfClasses(FEE_CREATE_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER);
FeeCreateCommandExtension feeCreate =
eppInput.getSingleExtension(FeeCreateCommandExtension.class);
EppCommandOperations commandOperations = TldSpecificLogicProxy.getCreatePrice(
registry, targetId, clientId, now, years, eppInput);
validateFeeChallenge(
@ -423,7 +422,7 @@ public class DomainCreateFlow implements TransactionalFlow {
}
private ImmutableList<FeeTransformResponseExtension> createResponseExtensions(
FeeTransformCommandExtension feeCreate, EppCommandOperations commandOperations) {
FeeCreateCommandExtension feeCreate, EppCommandOperations commandOperations) {
return (feeCreate == null)
? null
: ImmutableList.of(createFeeCreateResponse(feeCreate, commandOperations));

View file

@ -584,7 +584,7 @@ public class DomainFlowUtils {
*/
static void handleFeeRequest(
FeeQueryCommandExtensionItem feeRequest,
FeeQueryResponseExtensionItem.Builder builder,
FeeQueryResponseExtensionItem.Builder<?, ?> builder,
InternetDomainName domain,
String clientId,
@Nullable CurrencyUnit topLevelCurrency,
@ -617,7 +617,7 @@ public class DomainFlowUtils {
.setPeriod(feeRequest.getPeriod())
.setClass(TldSpecificLogicProxy.getFeeClass(domainNameString, now).orNull());
List<Fee> fees = ImmutableList.of();
ImmutableList<Fee> fees = ImmutableList.of();
switch (feeRequest.getCommandName()) {
case CREATE:
if (isReserved(domain, isSunrise)) { // Don't return a create price for reserved names.

View file

@ -27,7 +27,6 @@ import static google.registry.flows.domain.DomainFlowUtils.validateFeeChallenge;
import static google.registry.flows.domain.DomainFlowUtils.verifyUnitIsYears;
import static google.registry.model.domain.DomainResource.MAX_REGISTRATION_YEARS;
import static google.registry.model.domain.DomainResource.extendRegistrationWithCap;
import static google.registry.model.domain.fee.Fee.FEE_RENEW_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.util.DateTimeUtils.leapSafeAddYears;
@ -53,7 +52,7 @@ import google.registry.model.domain.DomainResource;
import google.registry.model.domain.GracePeriod;
import google.registry.model.domain.fee.BaseFee.FeeType;
import google.registry.model.domain.fee.Fee;
import google.registry.model.domain.fee.FeeTransformCommandExtension;
import google.registry.model.domain.fee.FeeRenewCommandExtension;
import google.registry.model.domain.fee.FeeTransformResponseExtension;
import google.registry.model.domain.metadata.MetadataExtension;
import google.registry.model.domain.rgp.GracePeriodStatus;
@ -117,8 +116,7 @@ public final class DomainRenewFlow implements TransactionalFlow {
@Override
public final EppResponse run() throws EppException {
extensionManager.register(MetadataExtension.class);
extensionManager.registerAsGroup(FEE_RENEW_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER);
extensionManager.register(FeeRenewCommandExtension.class, MetadataExtension.class);
extensionManager.validate();
validateClientIsLoggedIn(clientId);
DateTime now = ofy().getTransactionTime();
@ -127,8 +125,8 @@ public final class DomainRenewFlow implements TransactionalFlow {
DomainResource existingDomain = loadAndVerifyExistence(DomainResource.class, targetId, now);
verifyRenewAllowed(authInfo, existingDomain, command);
int years = command.getPeriod().getValue();
FeeTransformCommandExtension feeRenew =
eppInput.getFirstExtensionOfClasses(FEE_RENEW_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER);
FeeRenewCommandExtension feeRenew =
eppInput.getSingleExtension(FeeRenewCommandExtension.class);
EppCommandOperations commandOperations = TldSpecificLogicProxy.getRenewPrice(
Registry.get(existingDomain.getTld()), targetId, clientId, now, years, eppInput);
validateFeeChallenge(
@ -217,7 +215,7 @@ public final class DomainRenewFlow implements TransactionalFlow {
}
private ImmutableList<FeeTransformResponseExtension> createResponseExtensions(
Money renewCost, FeeTransformCommandExtension feeRenew) {
Money renewCost, FeeRenewCommandExtension feeRenew) {
return (feeRenew == null) ? null : ImmutableList.of(feeRenew
.createResponseBuilder()
.setCurrency(renewCost.getCurrencyUnit())

View file

@ -25,7 +25,6 @@ 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.ofy.ObjectifyService.ofy;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
@ -53,8 +52,8 @@ import google.registry.model.domain.DomainCommand.Update;
import google.registry.model.domain.DomainResource;
import google.registry.model.domain.fee.BaseFee.FeeType;
import google.registry.model.domain.fee.Fee;
import google.registry.model.domain.fee.FeeTransformCommandExtension;
import google.registry.model.domain.fee.FeeTransformResponseExtension;
import google.registry.model.domain.fee.FeeUpdateCommandExtension;
import google.registry.model.domain.metadata.MetadataExtension;
import google.registry.model.domain.rgp.GracePeriodStatus;
import google.registry.model.domain.rgp.RgpUpdateExtension;
@ -119,8 +118,10 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow {
@Override
public final EppResponse run() throws EppException {
extensionManager.register(MetadataExtension.class, RgpUpdateExtension.class);
extensionManager.registerAsGroup(FEE_UPDATE_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER);
extensionManager.register(
FeeUpdateCommandExtension.class,
MetadataExtension.class,
RgpUpdateExtension.class);
extensionManager.validate();
validateClientIsLoggedIn(clientId);
Update command = (Update) resourceCommand;
@ -129,8 +130,8 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow {
Money restoreCost = Registry.get(existingDomain.getTld()).getStandardRestoreCost();
EppCommandOperations renewCommandOperations = TldSpecificLogicProxy.getRenewPrice(
Registry.get(existingDomain.getTld()), targetId, clientId, now, 1, eppInput);
FeeTransformCommandExtension feeUpdate = eppInput.getFirstExtensionOfClasses(
FEE_UPDATE_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER);
FeeUpdateCommandExtension feeUpdate =
eppInput.getSingleExtension(FeeUpdateCommandExtension.class);
Money totalCost = renewCommandOperations.getTotalCost();
verifyRestoreAllowed(command, existingDomain, restoreCost, totalCost, feeUpdate, now);
HistoryEntry historyEntry = buildHistory(existingDomain, now);
@ -184,7 +185,7 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow {
DomainResource existingDomain,
Money restoreCost,
Money renewCost,
FeeTransformCommandExtension feeUpdate,
FeeUpdateCommandExtension feeUpdate,
DateTime now) throws EppException {
verifyOptionalAuthInfo(authInfo, existingDomain);
if (!isSuperuser) {
@ -258,7 +259,7 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow {
}
private static ImmutableList<FeeTransformResponseExtension> createResponseExtensions(
Money restoreCost, Money renewCost, FeeTransformCommandExtension feeUpdate) {
Money restoreCost, Money renewCost, FeeUpdateCommandExtension feeUpdate) {
return (feeUpdate == null) ? null : ImmutableList.of(
feeUpdate.createResponseBuilder()
.setCurrency(restoreCost.getCurrencyUnit())

View file

@ -30,7 +30,6 @@ import static google.registry.flows.domain.DomainFlowUtils.validateFeeChallenge;
import static google.registry.flows.domain.DomainFlowUtils.verifyPremiumNameIsNotBlocked;
import static google.registry.flows.domain.DomainFlowUtils.verifyUnitIsYears;
import static google.registry.model.domain.DomainResource.extendRegistrationWithCap;
import static google.registry.model.domain.fee.Fee.FEE_TRANSFER_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER;
import static google.registry.model.eppoutput.Result.Code.SUCCESS_WITH_ACTION_PENDING;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.pricing.PricingEngineProxy.getDomainRenewCost;
@ -56,7 +55,7 @@ import google.registry.model.domain.DomainResource;
import google.registry.model.domain.Period;
import google.registry.model.domain.fee.BaseFee.FeeType;
import google.registry.model.domain.fee.Fee;
import google.registry.model.domain.fee.FeeTransformCommandExtension;
import google.registry.model.domain.fee.FeeTransferCommandExtension;
import google.registry.model.domain.fee.FeeTransformResponseExtension;
import google.registry.model.domain.flags.FlagsTransferCommandExtension;
import google.registry.model.domain.metadata.MetadataExtension;
@ -130,8 +129,10 @@ public final class DomainTransferRequestFlow implements TransactionalFlow {
@Override
public final EppResponse run() throws EppException {
extensionManager.register(FlagsTransferCommandExtension.class, MetadataExtension.class);
extensionManager.registerAsGroup(FEE_TRANSFER_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER);
extensionManager.register(
FeeTransferCommandExtension.class,
FlagsTransferCommandExtension.class,
MetadataExtension.class);
extensionManager.validate();
validateClientIsLoggedIn(gainingClientId);
Period period = ((Transfer) resourceCommand).getPeriod();
@ -144,8 +145,8 @@ public final class DomainTransferRequestFlow implements TransactionalFlow {
// The cost of the renewal implied by a transfer.
Money renewCost = getDomainRenewCost(targetId, now, years);
// An optional extension from the client specifying what they think the transfer should cost.
FeeTransformCommandExtension feeTransfer = eppInput.getFirstExtensionOfClasses(
FEE_TRANSFER_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER);
FeeTransferCommandExtension feeTransfer =
eppInput.getSingleExtension(FeeTransferCommandExtension.class);
validateFeeChallenge(targetId, tld, now, feeTransfer, renewCost);
HistoryEntry historyEntry = buildHistory(period, existingDomain, now);
DateTime automaticTransferTime = now.plus(registry.getAutomaticTransferLength());
@ -405,7 +406,7 @@ public final class DomainTransferRequestFlow implements TransactionalFlow {
}
private ImmutableList<FeeTransformResponseExtension> createResponseExtensions(Money renewCost,
FeeTransformCommandExtension feeTransfer) {
FeeTransferCommandExtension feeTransfer) {
return feeTransfer == null
? null
: ImmutableList.of(feeTransfer.createResponseBuilder()

View file

@ -37,7 +37,6 @@ import static google.registry.flows.domain.DomainFlowUtils.validateRegistrantAll
import static google.registry.flows.domain.DomainFlowUtils.validateRequiredContactsPresent;
import static google.registry.flows.domain.DomainFlowUtils.verifyClientUpdateNotProhibited;
import static google.registry.flows.domain.DomainFlowUtils.verifyNotInPendingDelete;
import static google.registry.model.domain.fee.Fee.FEE_UPDATE_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.util.DateTimeUtils.earliestOf;
@ -63,6 +62,7 @@ import google.registry.model.domain.DomainCommand.Update.Change;
import google.registry.model.domain.DomainResource;
import google.registry.model.domain.GracePeriod;
import google.registry.model.domain.fee.FeeTransformCommandExtension;
import google.registry.model.domain.fee.FeeUpdateCommandExtension;
import google.registry.model.domain.flags.FlagsUpdateCommandExtension;
import google.registry.model.domain.metadata.MetadataExtension;
import google.registry.model.domain.rgp.GracePeriodStatus;
@ -147,10 +147,10 @@ public final class DomainUpdateFlow implements TransactionalFlow {
@Override
public EppResponse run() throws EppException {
extensionManager.register(
FeeUpdateCommandExtension.class,
FlagsUpdateCommandExtension.class,
MetadataExtension.class,
SecDnsUpdateExtension.class);
extensionManager.registerAsGroup(FEE_UPDATE_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER);
extensionManager.validate();
validateClientIsLoggedIn(clientId);
DateTime now = ofy().getTransactionTime();
@ -201,7 +201,7 @@ public final class DomainUpdateFlow implements TransactionalFlow {
Registry.get(tld), targetId, clientId, now, eppInput);
FeeTransformCommandExtension feeUpdate =
eppInput.getFirstExtensionOfClasses(FEE_UPDATE_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER);
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.

View file

@ -17,24 +17,8 @@ package google.registry.model.domain.fee;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Range;
import google.registry.model.domain.fee06.FeeCheckCommandExtensionV06;
import google.registry.model.domain.fee06.FeeCreateCommandExtensionV06;
import google.registry.model.domain.fee06.FeeRenewCommandExtensionV06;
import google.registry.model.domain.fee06.FeeTransferCommandExtensionV06;
import google.registry.model.domain.fee06.FeeUpdateCommandExtensionV06;
import google.registry.model.domain.fee11.FeeCheckCommandExtensionV11;
import google.registry.model.domain.fee11.FeeCreateCommandExtensionV11;
import google.registry.model.domain.fee11.FeeRenewCommandExtensionV11;
import google.registry.model.domain.fee11.FeeTransferCommandExtensionV11;
import google.registry.model.domain.fee11.FeeUpdateCommandExtensionV11;
import google.registry.model.domain.fee12.FeeCheckCommandExtensionV12;
import google.registry.model.domain.fee12.FeeCreateCommandExtensionV12;
import google.registry.model.domain.fee12.FeeRenewCommandExtensionV12;
import google.registry.model.domain.fee12.FeeTransferCommandExtensionV12;
import google.registry.model.domain.fee12.FeeUpdateCommandExtensionV12;
import google.registry.model.eppcommon.ProtocolDefinition.ServiceExtension;
import java.math.BigDecimal;
import org.joda.time.DateTime;
@ -60,49 +44,8 @@ public class Fee extends BaseFee {
return instance;
}
public static final ImmutableList<
Class<? extends FeeCheckCommandExtension<
? extends FeeCheckCommandExtensionItem, ? extends FeeCheckResponseExtension<?>>>>
FEE_CHECK_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER =
ImmutableList.<
Class<? extends FeeCheckCommandExtension<
? extends FeeCheckCommandExtensionItem,
? extends FeeCheckResponseExtension<?>>>>of(
FeeCheckCommandExtensionV12.class,
FeeCheckCommandExtensionV11.class,
FeeCheckCommandExtensionV06.class);
public static final ImmutableList<Class<? extends FeeTransformCommandExtension>>
FEE_CREATE_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER =
ImmutableList.<Class<? extends FeeTransformCommandExtension>>of(
FeeCreateCommandExtensionV12.class,
FeeCreateCommandExtensionV11.class,
FeeCreateCommandExtensionV06.class);
public static final ImmutableList<Class<? extends FeeTransformCommandExtension>>
FEE_RENEW_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER =
ImmutableList.<Class<? extends FeeTransformCommandExtension>>of(
FeeRenewCommandExtensionV12.class,
FeeRenewCommandExtensionV11.class,
FeeRenewCommandExtensionV06.class);
public static final ImmutableList<Class<? extends FeeTransformCommandExtension>>
FEE_TRANSFER_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER =
ImmutableList.<Class<? extends FeeTransformCommandExtension>>of(
FeeTransferCommandExtensionV12.class,
FeeTransferCommandExtensionV11.class,
FeeTransferCommandExtensionV06.class);
public static final ImmutableList<Class<? extends FeeTransformCommandExtension>>
FEE_UPDATE_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER =
ImmutableList.<Class<? extends FeeTransformCommandExtension>>of(
FeeUpdateCommandExtensionV12.class,
FeeUpdateCommandExtensionV11.class,
FeeUpdateCommandExtensionV06.class);
public static final ImmutableSet<String> FEE_EXTENSION_URIS =
ImmutableSet.<String>of(
ServiceExtension.FEE_0_12.getUri(),
ServiceExtension.FEE_0_11.getUri(),
ServiceExtension.FEE_0_6.getUri());
public static final ImmutableSet<String> FEE_EXTENSION_URIS = ImmutableSet.of(
ServiceExtension.FEE_0_12.getUri(),
ServiceExtension.FEE_0_11.getUri(),
ServiceExtension.FEE_0_6.getUri());
}

View file

@ -14,19 +14,22 @@
package google.registry.model.domain.fee;
import javax.xml.bind.annotation.XmlTransient;
/**
* Interface for individual fee extension items in Check commands. These are derived from the more
* general query items (which cover Info commands as well), but may also contain a domain name,
* depending on the version of the fee extension.
*/
public interface FeeCheckCommandExtensionItem extends FeeQueryCommandExtensionItem {
@XmlTransient
public abstract class FeeCheckCommandExtensionItem extends FeeQueryCommandExtensionItem {
/** True if this version of the fee extension supports domain names in Check items. */
public boolean isDomainNameSupported();
public abstract boolean isDomainNameSupported();
/** The domain name being checked; throws an exception if domain names are not supported. */
public String getDomainName() throws UnsupportedOperationException;
public abstract String getDomainName();
/** Create a builder for a matching fee check response item. */
public FeeCheckResponseExtensionItem.Builder createResponseBuilder();
public abstract FeeCheckResponseExtensionItem.Builder<?> createResponseBuilder();
}

View file

@ -14,20 +14,24 @@
package google.registry.model.domain.fee;
/**
* Interface for individual fee extension items in Check responses. These are derived from the more
* general query items (which cover Info responses as well), but may also contain a domain name,
* depending on the version of the fee extension.
*/
public interface FeeCheckResponseExtensionItem extends FeeQueryResponseExtensionItem {
import javax.xml.bind.annotation.XmlTransient;
/** Builder for {@link FeeCheckResponseExtensionItem}. */
public interface Builder extends FeeQueryResponseExtensionItem.Builder {
/**
* Abstract class for individual fee extension items in Check responses. These are derived from the
* more general query items (which cover Info responses as well), but may also contain a domain
* name, depending on the version of the fee extension.
*/
@XmlTransient
public abstract class FeeCheckResponseExtensionItem extends FeeQueryResponseExtensionItem {
/** Abstract builder for {@link FeeCheckResponseExtensionItem}. */
public abstract static class Builder<T extends FeeCheckResponseExtensionItem>
extends FeeQueryResponseExtensionItem.Builder<T, Builder<T>> {
/** The name associated with the item. Has no effect if domain names are not supported. */
public Builder setDomainNameIfSupported(String name);
public FeeCheckResponseExtensionItem build();
public Builder<T> setDomainNameIfSupported(@SuppressWarnings("unused") String name) {
return this; // Default impl is a noop.
}
}
}

View file

@ -0,0 +1,21 @@
// 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.fee;
import javax.xml.bind.annotation.XmlTransient;
/** A fee extension that may be present on domain create commands. */
@XmlTransient
public abstract class FeeCreateCommandExtension extends FeeTransformCommandExtension {}

View file

@ -15,17 +15,20 @@
package google.registry.model.domain.fee;
import com.google.common.base.Optional;
import google.registry.model.ImmutableObject;
import google.registry.model.domain.Period;
import javax.xml.bind.annotation.XmlTransient;
import org.joda.money.CurrencyUnit;
import org.joda.time.DateTime;
/**
* Interface for individual query items in Check and Info commands. Each item indicates the command
* to be checked, and the number of years for which the prices is requested. It may also contain the
* currency, but some versions of the fee extension specify the currency at the top level of the
* extension.
* Abstract base class for the fee request query items used in Check and Info commands. It handles
* the period, which is always present. Derived classes must handle the command, which may be
* implemented in different ways, and the currency, which may or may not be present, depending on
* the version of the extension being used.
*/
public interface FeeQueryCommandExtensionItem {
@XmlTransient
public abstract class FeeQueryCommandExtensionItem extends ImmutableObject {
/** The name of a command that might have an associated fee. */
public enum CommandName {
@ -37,28 +40,35 @@ public interface FeeQueryCommandExtensionItem {
UPDATE
}
/** The default validity period (if not specified) is 1 year for all operations. */
static final Period DEFAULT_PERIOD = Period.create(1, Period.Unit.YEARS);
/** The period for the command being checked. */
Period period;
/**
* Three-character ISO4217 currency code.
*
* <p>Returns null if this version of the fee extension doesn't specify currency at the top level.
*/
public CurrencyUnit getCurrency();
public abstract CurrencyUnit getCurrency();
/** The as-of date for the fee extension to run. */
public Optional<DateTime> getEffectiveDate();
public abstract Optional<DateTime> getEffectiveDate();
/** The name of the command being checked. */
public CommandName getCommandName();
public abstract CommandName getCommandName();
/** The unparse name of the command being checked, for use in error strings. */
public String getUnparsedCommandName();
/** The command name before being parsed into an enum, for use in error strings. */
public abstract String getUnparsedCommandName();
/** The phase of the command being checked. */
public String getPhase();
public abstract String getPhase();
/** The subphase of the command being checked. */
public String getSubphase();
public abstract String getSubphase();
/** The period for the command being checked. */
public Period getPeriod();
public Period getPeriod() {
return Optional.fromNullable(period).or(DEFAULT_PERIOD);
}
}

View file

@ -1,68 +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.fee;
import com.google.common.base.Optional;
import google.registry.model.ImmutableObject;
import google.registry.model.domain.Period;
import javax.xml.bind.annotation.XmlTransient;
/**
* Abstract base class for the fee request query items used in Check and Info commands. It handles
* command and period, which are always present. Derived classes must handle currency, which may or
* may not be present, depending on the version of the extension being used.
*/
@XmlTransient
public abstract class FeeQueryCommandExtensionItemImpl
extends ImmutableObject implements FeeQueryCommandExtensionItem {
/** The default validity period (if not specified) is 1 year for all operations. */
static final Period DEFAULT_PERIOD = Period.create(1, Period.Unit.YEARS);
/** The command being checked. */
FeeExtensionCommandDescriptor command;
/** The period for the command being checked. */
Period period;
/** The name of the command being checked. */
@Override
public CommandName getCommandName() {
return command.getCommand();
}
/** The command name before being parsed into an enum, for use in error strings. */
@Override
public String getUnparsedCommandName() {
return command.getUnparsedCommandName();
}
/** The phase of the command being checked. */
@Override
public String getPhase() {
return command.getPhase();
}
/** The subphase of the command being checked. */
@Override
public String getSubphase() {
return command.getSubphase();
}
@Override
public Period getPeriod() {
return Optional.fromNullable(period).or(DEFAULT_PERIOD);
}
}

View file

@ -14,56 +14,112 @@
package google.registry.model.domain.fee;
import static google.registry.util.CollectionUtils.forceEmptyToNull;
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
import com.google.common.collect.ImmutableList;
import google.registry.model.Buildable.GenericBuilder;
import google.registry.model.ImmutableObject;
import google.registry.model.domain.Period;
import google.registry.model.domain.fee.FeeQueryCommandExtensionItem.CommandName;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import org.joda.money.CurrencyUnit;
import org.joda.time.DateTime;
/**
* Interface for individual query items in Check and Info response. Each item indicates the fees and
* class associated with a particular command and period. The currency may also be listed, but some
* versions of the fee extension specify the currency at the top level of the extension.
* Abstract base class for the fee request query items used in Check and Info responses. It handles
* command, period, fees and class, which are always present. Derived classes must handle currency,
* which may or may not be present, depending on the version of the extension being used.
*/
public interface FeeQueryResponseExtensionItem {
@XmlTransient
public class FeeQueryResponseExtensionItem extends ImmutableObject {
/**
* The type of the fee. We will use "premium" for fees on premium names, and omit the field
* otherwise.
* The period that was checked.
*
* <p>This field is exposed to JAXB only via the getter so that subclasses can override it.
*/
public String getFeeClass();
@XmlTransient
Period period;
/** Builder for {@link FeeCheckResponseExtensionItem}. */
public interface Builder {
/**
* The magnitude of the fee, in the specified units, with an optional description.
*
* <p>This is a list because a single operation can involve multiple fees.
*
* <p>This field is exposed to JAXB only via the getter so that subclasses can override it.
*/
@XmlTransient
List<Fee> fees;
/**
* If currency is not supported in this type of query response item for this version of the fee
* extension, this function has no effect.
*/
public Builder setCurrencyIfSupported(CurrencyUnit currency);
/**
* The type of the fee.
*
* <p>We will use "premium" for fees on premium names, and omit the field otherwise.
*
* <p>This field is exposed to JAXB only via the getter so that subclasses can override it.
*/
@XmlTransient
String feeClass;
/** Whether this check item can be calculated. If so, reason should be null. If not, fees
* should not be set.
*/
public Builder setAvailIfSupported(boolean avail);
@XmlElement(name = "period")
public Period getPeriod() {
return period;
}
/** The reason that the check item cannot be calculated. */
public Builder setReasonIfSupported(String reason);
@XmlElement(name = "fee")
public ImmutableList<Fee> getFees() {
return nullToEmptyImmutableCopy(fees);
}
/** The effective date that the check is run on. */
public Builder setEffectiveDateIfSupported(DateTime effectiveDate);
@XmlElement(name = "class")
public String getFeeClass() {
return feeClass;
}
/** The date after which the quoted fees are no longer valid. */
public Builder setNotAfterDateIfSupported(DateTime notAfterDate);
/** Abstract builder for {@link FeeQueryResponseExtensionItemImpl}. */
public abstract static class
Builder<T extends FeeQueryResponseExtensionItem, B extends Builder<?, ?>>
extends GenericBuilder<T, B> {
public Builder setCommand(CommandName commandName, String phase, String subphase);
public abstract B setCommand(CommandName commandName, String phase, String subphase);
public Builder setPeriod(Period period);
public B setPeriod(Period period) {
getInstance().period = period;
return thisCastToDerived();
}
public Builder setFees(List<Fee> fees);
public B setFees(ImmutableList<Fee> fees) {
// If there are no fees, set the field to null to suppress the 'fee' section in the xml.
getInstance().fees = forceEmptyToNull(ImmutableList.copyOf(fees));
return thisCastToDerived();
}
public Builder setClass(String feeClass);
public B setClass(String feeClass) {
getInstance().feeClass = feeClass;
return thisCastToDerived();
}
public B setAvailIfSupported(@SuppressWarnings("unused") boolean avail) {
return thisCastToDerived(); // Default impl is a noop.
}
public B setReasonIfSupported(@SuppressWarnings("unused") String reason) {
return thisCastToDerived(); // Default impl is a noop.
}
public B setEffectiveDateIfSupported(@SuppressWarnings("unused") DateTime effectiveDate) {
return thisCastToDerived(); // Default impl is a noop.
}
public B setNotAfterDateIfSupported(@SuppressWarnings("unused") DateTime notAfterDate) {
return thisCastToDerived(); // Default impl is a noop.
}
public B setCurrencyIfSupported(@SuppressWarnings("unused") CurrencyUnit currency) {
return thisCastToDerived(); // Default impl is a noop.
}
}
}

View file

@ -1,98 +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.fee;
import static google.registry.util.CollectionUtils.forceEmptyToNull;
import com.google.common.collect.ImmutableList;
import google.registry.model.Buildable.GenericBuilder;
import google.registry.model.ImmutableObject;
import google.registry.model.domain.Period;
import google.registry.model.domain.fee.FeeQueryCommandExtensionItem.CommandName;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
/**
* Abstract base class for the fee request query items used in Check and Info responses. It handles
* command, period, fees and class, which are always present. Derived classes must handle currency,
* which may or may not be present, depending on the version of the extension being used.
*/
@XmlTransient
public class FeeQueryResponseExtensionItemImpl
extends ImmutableObject implements FeeQueryResponseExtensionItem {
/** The command that was checked. */
FeeExtensionCommandDescriptor command;
/** The period that was checked. */
Period period;
/**
* The magnitude of the fee, in the specified units, with an optional description.
*
* <p>This is a list because a single operation can involve multiple fees.
*/
List<Fee> fee;
/**
* The type of the fee.
*
* <p>We will use "premium" for fees on premium names, and omit the field otherwise.
*/
@XmlElement(name = "class")
String feeClass;
@Override
public String getFeeClass() {
return feeClass;
}
/** Abstract builder for {@link FeeQueryResponseExtensionItemImpl}. */
public abstract static class
Builder<T extends FeeQueryResponseExtensionItemImpl, B extends Builder<?, ?>>
extends GenericBuilder<T, B> implements FeeQueryResponseExtensionItem.Builder {
@Override
public B setCommand(CommandName commandName, String phase, String subphase) {
getInstance().command = FeeExtensionCommandDescriptor.create(commandName, phase, subphase);
return thisCastToDerived();
}
@Override
public B setPeriod(Period period) {
getInstance().period = period;
return thisCastToDerived();
}
@Override
public B setFees(List<Fee> fees) {
// If there are no fees, set the field to null to suppress the 'fee' section in the xml.
getInstance().fee = forceEmptyToNull(ImmutableList.copyOf(fees));
return thisCastToDerived();
}
public B setFee(List<Fee> fees) {
getInstance().fee = forceEmptyToNull(ImmutableList.copyOf(fees));
return thisCastToDerived();
}
@Override
public B setClass(String feeClass) {
getInstance().feeClass = feeClass;
return thisCastToDerived();
}
}
}

View file

@ -0,0 +1,21 @@
// 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.fee;
import javax.xml.bind.annotation.XmlTransient;
/** A fee extension that may be present on domain renew commands. */
@XmlTransient
public abstract class FeeRenewCommandExtension extends FeeTransformCommandExtension {}

View file

@ -0,0 +1,21 @@
// 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.fee;
import javax.xml.bind.annotation.XmlTransient;
/** A fee extension that may be present on domain transfer commands. */
@XmlTransient
public abstract class FeeTransferCommandExtension extends FeeTransformCommandExtension {}

View file

@ -14,14 +14,41 @@
package google.registry.model.domain.fee;
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
import com.google.common.collect.ImmutableList;
import google.registry.model.ImmutableObject;
import google.registry.model.eppinput.EppInput.CommandExtension;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import org.joda.money.CurrencyUnit;
/** Interface for fee extensions in Create, Renew, Transfer and Update commands. */
public interface FeeTransformCommandExtension extends CommandExtension {
CurrencyUnit getCurrency();
List<Fee> getFees();
List<Credit> getCredits();
FeeTransformResponseExtension.Builder createResponseBuilder();
/** Base class for general transform commands with fees (create, renew, update, transfer). */
@XmlTransient
public abstract class FeeTransformCommandExtension
extends ImmutableObject implements CommandExtension {
/** The currency of the fee. */
CurrencyUnit currency;
/**
* The magnitude of the fee, in the specified units, with an optional description.
*
* <p>This is a list because a single operation can involve multiple fees.
*/
@XmlElement(name = "fee")
List<Fee> fees;
public CurrencyUnit getCurrency() {
return currency;
}
public ImmutableList<Fee> getFees() {
return nullToEmptyImmutableCopy(fees);
}
public abstract ImmutableList<Credit> getCredits();
public abstract FeeTransformResponseExtension.Builder createResponseBuilder();
}

View file

@ -1,58 +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.fee;
import static google.registry.util.CollectionUtils.nullToEmpty;
import google.registry.model.ImmutableObject;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import org.joda.money.CurrencyUnit;
/** Base class for general transform commands with fees (create, renew, update, transfer). */
@XmlTransient
public abstract class FeeTransformCommandExtensionImpl
extends ImmutableObject implements FeeTransformCommandExtension {
/** The currency of the fee. */
CurrencyUnit currency;
/**
* The magnitude of the fee, in the specified units, with an optional description.
*
* <p>This is a list because a single operation can involve multiple fees.
*/
@XmlElement(name = "fee")
List<Fee> fees;
@XmlElement(name = "credit")
List<Credit> credits;
@Override
public CurrencyUnit getCurrency() {
return currency;
}
@Override
public List<Fee> getFees() {
return fees;
}
@Override
public List<Credit> getCredits() {
return nullToEmpty(credits);
}
}

View file

@ -1,58 +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.fee;
import com.google.common.collect.ImmutableList;
import google.registry.model.ImmutableObject;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import org.joda.money.CurrencyUnit;
/**
* Base class for general transform commands with fees (create, renew, update, transfer). This
* version of the class is for fee extensions that do not support credits (certain older versions
* allow credits only for some commands).
*/
@XmlTransient
public abstract class FeeTransformCommandExtensionImplNoCredits
extends ImmutableObject implements FeeTransformCommandExtension {
/** The currency of the fee. */
CurrencyUnit currency;
/**
* The magnitude of the fee, in the specified units, with an optional description.
*
* <p>This is a list because a single operation can involve multiple fees.
*/
@XmlElement(name = "fee")
List<Fee> fees;
@Override
public CurrencyUnit getCurrency() {
return currency;
}
@Override
public List<Fee> getFees() {
return fees;
}
@Override
public List<Credit> getCredits() {
return ImmutableList.of();
}
}

View file

@ -14,18 +14,62 @@
package google.registry.model.domain.fee;
import static google.registry.util.CollectionUtils.forceEmptyToNull;
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
import com.google.common.collect.ImmutableList;
import google.registry.model.Buildable;
import google.registry.model.ImmutableObject;
import google.registry.model.eppoutput.EppResponse.ResponseExtension;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import org.joda.money.CurrencyUnit;
/** Interface for fee extensions in Create, Renew, Transfer and Update responses. */
public interface FeeTransformResponseExtension extends ResponseExtension {
/** Base class for fee responses on general transform commands (create, update, renew, transfer). */
@XmlTransient
public class FeeTransformResponseExtension extends ImmutableObject implements ResponseExtension {
/** Builder for {@link FeeTransformResponseExtension}. */
public interface Builder {
Builder setCurrency(CurrencyUnit currency);
Builder setFees(List<Fee> fees);
Builder setCredits(List<Credit> credits);
FeeTransformResponseExtension build();
/** The currency of the fee. */
CurrencyUnit currency;
/**
* The magnitude of the fee, in the specified units, with an optional description.
*
* <p>This is a list because a single operation can involve multiple fees.
*/
@XmlElement(name = "fee")
List<Fee> fees;
/** This field is exposed to JAXB only via the getter so that subclasses can override it. */
@XmlTransient
List<Credit> credits;
@XmlElement(name = "credit")
public ImmutableList<Credit> getCredits() {
return nullToEmptyImmutableCopy(credits);
}
/** Abstract builder for {@link FeeTransformResponseExtensionImpl}. */
public static class Builder extends Buildable.Builder<FeeTransformResponseExtension> {
public Builder(FeeTransformResponseExtension instance) {
super(instance);
}
public Builder setCurrency(CurrencyUnit currency) {
getInstance().currency = currency;
return this;
}
public Builder setFees(List<Fee> fees) {
getInstance().fees = fees;
return this;
}
public Builder setCredits(List<Credit> credits) {
getInstance().credits = forceEmptyToNull(credits);
return this;
}
}
}

View file

@ -1,68 +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.fee;
import static google.registry.util.CollectionUtils.forceEmptyToNull;
import google.registry.model.Buildable.GenericBuilder;
import google.registry.model.ImmutableObject;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import org.joda.money.CurrencyUnit;
/** Base class for fee responses on general transform commands (create, update, renew, transfer). */
@XmlTransient
public class FeeTransformResponseExtensionImpl extends ImmutableObject
implements FeeTransformResponseExtension {
/** The currency of the fee. */
CurrencyUnit currency;
/**
* The magnitude of the fee, in the specified units, with an optional description.
*
* <p>This is a list because a single operation can involve multiple fees.
*/
@XmlElement(name = "fee")
List<Fee> fees;
@XmlElement(name = "credit")
List<Credit> credits;
/** Abstract builder for {@link FeeTransformResponseExtensionImpl}. */
public abstract static class
Builder<T extends FeeTransformResponseExtensionImpl, B extends Builder<?, ?>>
extends GenericBuilder<T, B> implements FeeTransformResponseExtension.Builder {
@Override
public B setCurrency(CurrencyUnit currency) {
getInstance().currency = currency;
return thisCastToDerived();
}
@Override
public B setFees(List<Fee> fees) {
getInstance().fees = fees;
return thisCastToDerived();
}
@Override
public B setCredits(List<Credit> credits) {
getInstance().credits = forceEmptyToNull(credits);
return thisCastToDerived();
}
}
}

View file

@ -1,66 +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.fee;
import google.registry.model.Buildable.GenericBuilder;
import google.registry.model.ImmutableObject;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import org.joda.money.CurrencyUnit;
/**
* Base class for fee responses on general transform commands (create, update, renew, transfer).
* This version of the class is for fee extensions that do not support credits (certain older
* versions allow credits only for some commands).
*/
@XmlTransient
public class FeeTransformResponseExtensionImplNoCredits extends ImmutableObject
implements FeeTransformResponseExtension {
/** The currency of the fee. */
CurrencyUnit currency;
/**
* The magnitude of the fee, in the specified units, with an optional description.
*
* <p>This is a list because a single operation can involve multiple fees.
*/
@XmlElement(name = "fee")
List<Fee> fees;
/** Abstract builder for {@link FeeTransformResponseExtensionImplNoCredits}. */
public abstract static class
Builder<T extends FeeTransformResponseExtensionImplNoCredits, B extends Builder<?, ?>>
extends GenericBuilder<T, B> implements FeeTransformResponseExtension.Builder {
@Override
public B setCurrency(CurrencyUnit currency) {
getInstance().currency = currency;
return thisCastToDerived();
}
@Override
public B setFees(List<Fee> fees) {
getInstance().fees = fees;
return thisCastToDerived();
}
@Override
public B setCredits(List<Credit> credits) {
return thisCastToDerived();
}
}
}

View file

@ -0,0 +1,21 @@
// 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.fee;
import javax.xml.bind.annotation.XmlTransient;
/** A fee extension that may be present on domain update commands. */
@XmlTransient
public abstract class FeeUpdateCommandExtension extends FeeTransformCommandExtension {}

View file

@ -16,22 +16,47 @@ package google.registry.model.domain.fee06;
import com.google.common.base.Optional;
import google.registry.model.domain.fee.FeeCheckCommandExtensionItem;
import google.registry.model.domain.fee.FeeCheckResponseExtensionItem;
import google.registry.model.domain.fee.FeeQueryCommandExtensionItemImpl;
import google.registry.model.domain.fee.FeeExtensionCommandDescriptor;
import javax.xml.bind.annotation.XmlType;
import org.joda.money.CurrencyUnit;
import org.joda.time.DateTime;
/** An individual price check item in version 0.6 of the fee extension on Check commands. */
@XmlType(propOrder = {"name", "currency", "command", "period"})
public class FeeCheckCommandExtensionItemV06
extends FeeQueryCommandExtensionItemImpl implements FeeCheckCommandExtensionItem {
public class FeeCheckCommandExtensionItemV06 extends FeeCheckCommandExtensionItem {
/** The fully qualified domain name being checked. */
String name;
CurrencyUnit currency;
/** The command being checked. */
FeeExtensionCommandDescriptor command;
/** The name of the command being checked. */
@Override
public CommandName getCommandName() {
return command.getCommand();
}
/** The command name before being parsed into an enum, for use in error strings. */
@Override
public String getUnparsedCommandName() {
return command.getUnparsedCommandName();
}
/** The phase of the command being checked. */
@Override
public String getPhase() {
return command.getPhase();
}
/** The subphase of the command being checked. */
@Override
public String getSubphase() {
return command.getSubphase();
}
@Override
public boolean isDomainNameSupported() {
return true;
@ -48,7 +73,7 @@ public class FeeCheckCommandExtensionItemV06
}
@Override
public FeeCheckResponseExtensionItem.Builder createResponseBuilder() {
public FeeCheckResponseExtensionItemV06.Builder createResponseBuilder() {
return new FeeCheckResponseExtensionItemV06.Builder();
}

View file

@ -15,24 +15,31 @@
package google.registry.model.domain.fee06;
import google.registry.model.domain.fee.FeeCheckResponseExtensionItem;
import google.registry.model.domain.fee.FeeQueryResponseExtensionItemImpl;
import google.registry.model.domain.fee.FeeExtensionCommandDescriptor;
import google.registry.model.domain.fee.FeeQueryCommandExtensionItem.CommandName;
import javax.xml.bind.annotation.XmlType;
import org.joda.money.CurrencyUnit;
import org.joda.time.DateTime;
/** The version 0.6 response for a domain check on a single resource. */
@XmlType(propOrder = {"name", "currency", "command", "period", "fee", "feeClass"})
public class FeeCheckResponseExtensionItemV06
extends FeeQueryResponseExtensionItemImpl implements FeeCheckResponseExtensionItem {
@XmlType(propOrder = {"name", "currency", "command", "period", "fees", "feeClass"})
public class FeeCheckResponseExtensionItemV06 extends FeeCheckResponseExtensionItem {
/** The name of the domain that was checked, with an attribute indicating if it is premium. */
String name;
CurrencyUnit currency;
/** The command that was checked. */
FeeExtensionCommandDescriptor command;
/** Builder for {@link FeeCheckResponseExtensionItemV06}. */
public static class Builder
extends FeeQueryResponseExtensionItemImpl.Builder<FeeCheckResponseExtensionItemV06, Builder>
implements FeeCheckResponseExtensionItem.Builder {
extends FeeCheckResponseExtensionItem.Builder<FeeCheckResponseExtensionItemV06> {
@Override
public Builder setCommand(CommandName commandName, String phase, String subphase) {
getInstance().command = FeeExtensionCommandDescriptor.create(commandName, phase, subphase);
return this;
}
@Override
public Builder setDomainNameIfSupported(String name) {
@ -45,26 +52,5 @@ public class FeeCheckResponseExtensionItemV06
getInstance().currency = currency;
return this;
}
@Override
public Builder setAvailIfSupported(boolean avail) {
return this;
}
@Override
public Builder setReasonIfSupported(String reason) {
return this;
}
@Override
public Builder setEffectiveDateIfSupported(DateTime effectiveDate) {
return this;
}
@Override
public Builder setNotAfterDateIfSupported(DateTime notAfterDate) {
return this;
}
}
}

View file

@ -14,8 +14,9 @@
package google.registry.model.domain.fee06;
import google.registry.model.domain.fee.FeeTransformCommandExtension;
import google.registry.model.domain.fee.FeeTransformCommandExtensionImplNoCredits;
import com.google.common.collect.ImmutableList;
import google.registry.model.domain.fee.Credit;
import google.registry.model.domain.fee.FeeCreateCommandExtension;
import google.registry.model.domain.fee.FeeTransformResponseExtension;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@ -23,11 +24,19 @@ import javax.xml.bind.annotation.XmlType;
/** A fee extension that may be present on domain create commands. */
@XmlRootElement(name = "create")
@XmlType(propOrder = {"currency", "fees"})
public class FeeCreateCommandExtensionV06
extends FeeTransformCommandExtensionImplNoCredits implements FeeTransformCommandExtension {
public class FeeCreateCommandExtensionV06 extends FeeCreateCommandExtension {
@Override
public FeeTransformResponseExtension.Builder createResponseBuilder() {
return new FeeCreateResponseExtensionV06.Builder();
return new FeeTransformResponseExtension.Builder(new FeeCreateResponseExtensionV06());
}
/**
* This method is overridden and not annotated for JAXB because this version of the extension
* doesn't support the "credit" field.
*/
@Override
public ImmutableList<Credit> getCredits() {
return ImmutableList.of();
}
}

View file

@ -14,7 +14,9 @@
package google.registry.model.domain.fee06;
import google.registry.model.domain.fee.FeeTransformResponseExtensionImplNoCredits;
import com.google.common.collect.ImmutableList;
import google.registry.model.domain.fee.Credit;
import google.registry.model.domain.fee.FeeTransformResponseExtension;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@ -24,8 +26,11 @@ import javax.xml.bind.annotation.XmlType;
*/
@XmlRootElement(name = "creData")
@XmlType(propOrder = {"currency", "fees"})
public class FeeCreateResponseExtensionV06 extends FeeTransformResponseExtensionImplNoCredits {
/** A builder for {@link FeeCreateResponseExtensionV06}. */
public static class Builder extends
FeeTransformResponseExtensionImplNoCredits.Builder<FeeCreateResponseExtensionV06, Builder> {}
public class FeeCreateResponseExtensionV06 extends FeeTransformResponseExtension {
/** This version of the extension doesn't support the "credit" field. */
@Override
public ImmutableList<Credit> getCredits() {
return ImmutableList.of();
}
}

View file

@ -14,7 +14,7 @@
package google.registry.model.domain.fee06;
import google.registry.model.domain.fee.FeeTransformResponseExtensionImpl;
import google.registry.model.domain.fee.FeeTransformResponseExtension;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@ -24,9 +24,12 @@ import javax.xml.bind.annotation.XmlType;
*/
@XmlRootElement(name = "delData")
@XmlType(propOrder = {"currency", "fees", "credits"})
public class FeeDeleteResponseExtensionV06 extends FeeTransformResponseExtensionImpl {
public class FeeDeleteResponseExtensionV06 extends FeeTransformResponseExtension {
/** Builder for {@link FeeDeleteResponseExtensionV06}. */
public static class Builder
extends FeeTransformResponseExtensionImpl.Builder<FeeDeleteResponseExtensionV06, Builder> {}
public static class Builder extends FeeTransformResponseExtension.Builder {
public Builder() {
super(new FeeDeleteResponseExtensionV06());
}
}
}

View file

@ -15,7 +15,8 @@
package google.registry.model.domain.fee06;
import com.google.common.base.Optional;
import google.registry.model.domain.fee.FeeQueryCommandExtensionItemImpl;
import google.registry.model.domain.fee.FeeExtensionCommandDescriptor;
import google.registry.model.domain.fee.FeeQueryCommandExtensionItem;
import google.registry.model.eppinput.EppInput.CommandExtension;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@ -26,11 +27,38 @@ import org.joda.time.DateTime;
@XmlRootElement(name = "info")
@XmlType(propOrder = {"currency", "command", "period"})
public class FeeInfoCommandExtensionV06
extends FeeQueryCommandExtensionItemImpl implements CommandExtension {
extends FeeQueryCommandExtensionItem implements CommandExtension {
/** A three-character ISO4217 currency code. */
CurrencyUnit currency;
/** The command being checked. */
FeeExtensionCommandDescriptor command;
/** The name of the command being checked. */
@Override
public CommandName getCommandName() {
return command.getCommand();
}
/** The command name before being parsed into an enum, for use in error strings. */
@Override
public String getUnparsedCommandName() {
return command.getUnparsedCommandName();
}
/** The phase of the command being checked. */
@Override
public String getPhase() {
return command.getPhase();
}
/** The subphase of the command being checked. */
@Override
public String getSubphase() {
return command.getSubphase();
}
@Override
public CurrencyUnit getCurrency() {
return currency;

View file

@ -14,54 +14,43 @@
package google.registry.model.domain.fee06;
import google.registry.model.domain.fee.FeeExtensionCommandDescriptor;
import google.registry.model.domain.fee.FeeQueryCommandExtensionItem.CommandName;
import google.registry.model.domain.fee.FeeQueryResponseExtensionItem;
import google.registry.model.domain.fee.FeeQueryResponseExtensionItemImpl;
import google.registry.model.eppoutput.EppResponse.ResponseExtension;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.joda.money.CurrencyUnit;
import org.joda.time.DateTime;
/**
* An XML data object that represents a fee extension that may be present on the response to EPP
* domain info commands.
*/
@XmlRootElement(name = "infData")
@XmlType(propOrder = {"currency", "command", "period", "fee", "feeClass"})
@XmlType(propOrder = {"currency", "command", "period", "fees", "feeClass"})
public class FeeInfoResponseExtensionV06
extends FeeQueryResponseExtensionItemImpl implements ResponseExtension {
extends FeeQueryResponseExtensionItem implements ResponseExtension {
CurrencyUnit currency;
/** The command that was checked. */
FeeExtensionCommandDescriptor command;
/** Builder for {@link FeeInfoResponseExtensionV06}. */
public static class Builder
extends FeeQueryResponseExtensionItemImpl.Builder<FeeInfoResponseExtensionV06, Builder> {
extends FeeQueryResponseExtensionItem.Builder<FeeInfoResponseExtensionV06, Builder> {
@Override
public Builder setAvailIfSupported(boolean avail) {
return this;
public Builder setCommand(CommandName commandName, String phase, String subphase) {
getInstance().command = FeeExtensionCommandDescriptor.create(commandName, phase, subphase);
return thisCastToDerived();
}
@Override
public Builder setReasonIfSupported(String reason) {
return this;
}
@Override
public FeeQueryResponseExtensionItem.Builder
setCurrencyIfSupported(CurrencyUnit currency) {
public Builder setCurrencyIfSupported(CurrencyUnit currency) {
getInstance().currency = currency;
return this;
}
@Override
public Builder setEffectiveDateIfSupported(DateTime effectiveDate) {
return this;
}
@Override
public Builder setNotAfterDateIfSupported(DateTime notAfterDate) {
return this;
}
}
}

View file

@ -14,8 +14,9 @@
package google.registry.model.domain.fee06;
import google.registry.model.domain.fee.FeeTransformCommandExtension;
import google.registry.model.domain.fee.FeeTransformCommandExtensionImplNoCredits;
import com.google.common.collect.ImmutableList;
import google.registry.model.domain.fee.Credit;
import google.registry.model.domain.fee.FeeRenewCommandExtension;
import google.registry.model.domain.fee.FeeTransformResponseExtension;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@ -23,11 +24,16 @@ import javax.xml.bind.annotation.XmlType;
/** A fee extension that may be present on domain renew commands. */
@XmlRootElement(name = "renew")
@XmlType(propOrder = {"currency", "fees"})
public class FeeRenewCommandExtensionV06
extends FeeTransformCommandExtensionImplNoCredits implements FeeTransformCommandExtension {
public class FeeRenewCommandExtensionV06 extends FeeRenewCommandExtension {
@Override
public FeeTransformResponseExtension.Builder createResponseBuilder() {
return new FeeRenewResponseExtensionV06.Builder();
return new FeeTransformResponseExtension.Builder(new FeeRenewResponseExtensionV06());
}
/** This version of the extension doesn't support the "credit" field. */
@Override
public ImmutableList<Credit> getCredits() {
return ImmutableList.of();
}
}

View file

@ -14,7 +14,9 @@
package google.registry.model.domain.fee06;
import google.registry.model.domain.fee.FeeTransformResponseExtensionImplNoCredits;
import com.google.common.collect.ImmutableList;
import google.registry.model.domain.fee.Credit;
import google.registry.model.domain.fee.FeeTransformResponseExtension;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@ -24,8 +26,11 @@ import javax.xml.bind.annotation.XmlType;
*/
@XmlRootElement(name = "renData")
@XmlType(propOrder = {"currency", "fees"})
public class FeeRenewResponseExtensionV06 extends FeeTransformResponseExtensionImplNoCredits {
/** A builder for {@link FeeRenewResponseExtensionV06}. */
public static class Builder extends
FeeTransformResponseExtensionImplNoCredits.Builder<FeeRenewResponseExtensionV06, Builder> {}
public class FeeRenewResponseExtensionV06 extends FeeTransformResponseExtension {
/** This version of the extension doesn't support the "credit" field. */
@Override
public ImmutableList<Credit> getCredits() {
return super.getCredits();
}
}

View file

@ -14,8 +14,9 @@
package google.registry.model.domain.fee06;
import google.registry.model.domain.fee.FeeTransformCommandExtension;
import google.registry.model.domain.fee.FeeTransformCommandExtensionImplNoCredits;
import com.google.common.collect.ImmutableList;
import google.registry.model.domain.fee.Credit;
import google.registry.model.domain.fee.FeeTransferCommandExtension;
import google.registry.model.domain.fee.FeeTransformResponseExtension;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@ -23,11 +24,16 @@ import javax.xml.bind.annotation.XmlType;
/** A fee extension that may be present on domain transfer requests. */
@XmlRootElement(name = "transfer")
@XmlType(propOrder = {"currency", "fees"})
public class FeeTransferCommandExtensionV06
extends FeeTransformCommandExtensionImplNoCredits implements FeeTransformCommandExtension {
public class FeeTransferCommandExtensionV06 extends FeeTransferCommandExtension {
@Override
public FeeTransformResponseExtension.Builder createResponseBuilder() {
return new FeeTransferResponseExtensionV06.Builder();
return new FeeTransformResponseExtension.Builder(new FeeTransferResponseExtensionV06());
}
/** This version of the extension doesn't support the "credit" field. */
@Override
public ImmutableList<Credit> getCredits() {
return ImmutableList.of();
}
}

View file

@ -14,7 +14,9 @@
package google.registry.model.domain.fee06;
import google.registry.model.domain.fee.FeeTransformResponseExtensionImplNoCredits;
import com.google.common.collect.ImmutableList;
import google.registry.model.domain.fee.Credit;
import google.registry.model.domain.fee.FeeTransformResponseExtension;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@ -24,9 +26,11 @@ import javax.xml.bind.annotation.XmlType;
*/
@XmlRootElement(name = "trnData")
@XmlType(propOrder = {"currency", "fees"})
public class FeeTransferResponseExtensionV06 extends FeeTransformResponseExtensionImplNoCredits {
/** A builder for {@link FeeTransferResponseExtensionV06}. */
public static class Builder
extends FeeTransformResponseExtensionImplNoCredits
.Builder<FeeTransferResponseExtensionV06, Builder> {}
public class FeeTransferResponseExtensionV06 extends FeeTransformResponseExtension {
/** This version of the extension doesn't support the "credit" field. */
@Override
public ImmutableList<Credit> getCredits() {
return super.getCredits();
}
}

View file

@ -14,20 +14,26 @@
package google.registry.model.domain.fee06;
import google.registry.model.domain.fee.FeeTransformCommandExtension;
import google.registry.model.domain.fee.FeeTransformCommandExtensionImplNoCredits;
import com.google.common.collect.ImmutableList;
import google.registry.model.domain.fee.Credit;
import google.registry.model.domain.fee.FeeTransformResponseExtension;
import google.registry.model.domain.fee.FeeUpdateCommandExtension;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/** A fee extension that may be present on domain update commands. */
@XmlRootElement(name = "update")
@XmlType(propOrder = {"currency", "fees"})
public class FeeUpdateCommandExtensionV06
extends FeeTransformCommandExtensionImplNoCredits implements FeeTransformCommandExtension {
public class FeeUpdateCommandExtensionV06 extends FeeUpdateCommandExtension {
@Override
public FeeTransformResponseExtension.Builder createResponseBuilder() {
return new FeeUpdateResponseExtensionV06.Builder();
return new FeeTransformResponseExtension.Builder(new FeeUpdateResponseExtensionV06());
}
/** This version of the extension doesn't support the "credit" field. */
@Override
public ImmutableList<Credit> getCredits() {
return ImmutableList.of();
}
}

View file

@ -14,7 +14,9 @@
package google.registry.model.domain.fee06;
import google.registry.model.domain.fee.FeeTransformResponseExtensionImplNoCredits;
import com.google.common.collect.ImmutableList;
import google.registry.model.domain.fee.Credit;
import google.registry.model.domain.fee.FeeTransformResponseExtension;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@ -24,9 +26,11 @@ import javax.xml.bind.annotation.XmlType;
*/
@XmlRootElement(name = "updData")
@XmlType(propOrder = {"currency", "fees"})
public class FeeUpdateResponseExtensionV06 extends FeeTransformResponseExtensionImplNoCredits {
/** A builder for {@link FeeUpdateResponseExtensionV06}. */
public static class Builder
extends FeeTransformResponseExtensionImplNoCredits
.Builder<FeeUpdateResponseExtensionV06, Builder> {}
public class FeeUpdateResponseExtensionV06 extends FeeTransformResponseExtension {
/** This version of the extension doesn't support the "credit" field. */
@Override
public ImmutableList<Credit> getCredits() {
return super.getCredits();
}
}

View file

@ -24,7 +24,6 @@ import google.registry.model.domain.Period;
import google.registry.model.domain.fee.FeeCheckCommandExtension;
import google.registry.model.domain.fee.FeeCheckCommandExtensionItem;
import google.registry.model.domain.fee.FeeCheckResponseExtensionItem;
import google.registry.model.domain.fee.FeeCheckResponseExtensionItem.Builder;
import google.registry.model.domain.fee.FeeExtensionCommandDescriptor;
import google.registry.model.domain.fee11.FeeCheckCommandExtensionV11.FeeCheckCommandExtensionItemV11;
import javax.xml.bind.annotation.XmlElement;
@ -88,7 +87,7 @@ public class FeeCheckCommandExtensionV11 extends ImmutableObject
}
/** Implementation of the item interface, returning values of the single "item". */
class FeeCheckCommandExtensionItemV11 implements FeeCheckCommandExtensionItem {
class FeeCheckCommandExtensionItemV11 extends FeeCheckCommandExtensionItem {
/** The name of the command being checked. */
@Override
@ -135,7 +134,7 @@ public class FeeCheckCommandExtensionV11 extends ImmutableObject
}
@Override
public Builder createResponseBuilder() {
public FeeCheckResponseExtensionItemV11.Builder createResponseBuilder() {
return new FeeCheckResponseExtensionItemV11.Builder();
}

View file

@ -16,16 +16,15 @@ package google.registry.model.domain.fee11;
import google.registry.model.domain.DomainObjectSpec;
import google.registry.model.domain.fee.FeeCheckResponseExtensionItem;
import google.registry.model.domain.fee.FeeQueryResponseExtensionItemImpl;
import google.registry.model.domain.fee.FeeExtensionCommandDescriptor;
import google.registry.model.domain.fee.FeeQueryCommandExtensionItem.CommandName;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlType;
import org.joda.money.CurrencyUnit;
import org.joda.time.DateTime;
/** The version 0.11 response for a domain check on a single resource. */
@XmlType(propOrder = {"object", "command", "currency", "period", "fee", "feeClass", "reason"})
public class FeeCheckResponseExtensionItemV11
extends FeeQueryResponseExtensionItemImpl implements FeeCheckResponseExtensionItem {
@XmlType(propOrder = {"object", "command", "currency", "period", "fees", "feeClass", "reason"})
public class FeeCheckResponseExtensionItemV11 extends FeeCheckResponseExtensionItem {
/** Whether the domain is available. */
@XmlAttribute
@ -39,10 +38,18 @@ public class FeeCheckResponseExtensionItemV11
/** The reason that the check item cannot be calculated. */
String reason;
/** The command that was checked. */
FeeExtensionCommandDescriptor command;
/** Builder for {@link FeeCheckResponseExtensionItemV11}. */
public static class Builder
extends FeeQueryResponseExtensionItemImpl.Builder<FeeCheckResponseExtensionItemV11, Builder>
implements FeeCheckResponseExtensionItem.Builder {
extends FeeCheckResponseExtensionItem.Builder<FeeCheckResponseExtensionItemV11> {
@Override
public Builder setCommand(CommandName commandName, String phase, String subphase) {
getInstance().command = FeeExtensionCommandDescriptor.create(commandName, phase, subphase);
return this;
}
@Override
public Builder setDomainNameIfSupported(String name) {
@ -67,15 +74,5 @@ public class FeeCheckResponseExtensionItemV11
getInstance().reason = reason;
return this;
}
@Override
public Builder setEffectiveDateIfSupported(DateTime effectiveDate) {
return this;
}
@Override
public Builder setNotAfterDateIfSupported(DateTime notAfterDate) {
return this;
}
}
}

View file

@ -14,20 +14,32 @@
package google.registry.model.domain.fee11;
import google.registry.model.domain.fee.FeeTransformCommandExtension;
import google.registry.model.domain.fee.FeeTransformCommandExtensionImpl;
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
import com.google.common.collect.ImmutableList;
import google.registry.model.domain.fee.Credit;
import google.registry.model.domain.fee.FeeCreateCommandExtension;
import google.registry.model.domain.fee.FeeTransformResponseExtension;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/** A fee extension that may be present on domain create commands. */
@XmlRootElement(name = "create")
@XmlType(propOrder = {"currency", "fees", "credits"})
public class FeeCreateCommandExtensionV11
extends FeeTransformCommandExtensionImpl implements FeeTransformCommandExtension {
public class FeeCreateCommandExtensionV11 extends FeeCreateCommandExtension {
@XmlElement(name = "credit")
List<Credit> credits;
@Override
public ImmutableList<Credit> getCredits() {
return nullToEmptyImmutableCopy(credits);
}
@Override
public FeeTransformResponseExtension.Builder createResponseBuilder() {
return new FeeCreateResponseExtensionV11.Builder();
return new FeeTransformResponseExtension.Builder(new FeeCreateResponseExtensionV11());
}
}

View file

@ -14,7 +14,7 @@
package google.registry.model.domain.fee11;
import google.registry.model.domain.fee.FeeTransformResponseExtensionImpl;
import google.registry.model.domain.fee.FeeTransformResponseExtension;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@ -24,8 +24,4 @@ import javax.xml.bind.annotation.XmlType;
*/
@XmlRootElement(name = "creData")
@XmlType(propOrder = {"currency", "fees", "credits"})
public class FeeCreateResponseExtensionV11 extends FeeTransformResponseExtensionImpl {
/** A builder for {@link FeeCreateResponseExtensionV11}. */
public static class Builder
extends FeeTransformResponseExtensionImpl.Builder<FeeCreateResponseExtensionV11, Builder> {}
}
public class FeeCreateResponseExtensionV11 extends FeeTransformResponseExtension {}

View file

@ -14,7 +14,7 @@
package google.registry.model.domain.fee11;
import google.registry.model.domain.fee.FeeTransformResponseExtensionImpl;
import google.registry.model.domain.fee.FeeTransformResponseExtension;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@ -24,9 +24,12 @@ import javax.xml.bind.annotation.XmlType;
*/
@XmlRootElement(name = "delData")
@XmlType(propOrder = {"currency", "fees", "credits"})
public class FeeDeleteResponseExtensionV11 extends FeeTransformResponseExtensionImpl {
public class FeeDeleteResponseExtensionV11 extends FeeTransformResponseExtension {
/** Builder for {@link FeeDeleteResponseExtensionV11}. */
public static class Builder
extends FeeTransformResponseExtensionImpl.Builder<FeeDeleteResponseExtensionV11, Builder> {}
public static class Builder extends FeeTransformResponseExtension.Builder {
public Builder() {
super(new FeeDeleteResponseExtensionV11());
}
}
}

View file

@ -14,20 +14,32 @@
package google.registry.model.domain.fee11;
import google.registry.model.domain.fee.FeeTransformCommandExtension;
import google.registry.model.domain.fee.FeeTransformCommandExtensionImpl;
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
import com.google.common.collect.ImmutableList;
import google.registry.model.domain.fee.Credit;
import google.registry.model.domain.fee.FeeRenewCommandExtension;
import google.registry.model.domain.fee.FeeTransformResponseExtension;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/** A fee extension that may be present on domain renew commands. */
@XmlRootElement(name = "renew")
@XmlType(propOrder = {"currency", "fees", "credits"})
public class FeeRenewCommandExtensionV11
extends FeeTransformCommandExtensionImpl implements FeeTransformCommandExtension {
public class FeeRenewCommandExtensionV11 extends FeeRenewCommandExtension {
@XmlElement(name = "credit")
List<Credit> credits;
@Override
public ImmutableList<Credit> getCredits() {
return nullToEmptyImmutableCopy(credits);
}
@Override
public FeeTransformResponseExtension.Builder createResponseBuilder() {
return new FeeRenewResponseExtensionV11.Builder();
return new FeeTransformResponseExtension.Builder(new FeeRenewResponseExtensionV11());
}
}

View file

@ -14,7 +14,7 @@
package google.registry.model.domain.fee11;
import google.registry.model.domain.fee.FeeTransformResponseExtensionImpl;
import google.registry.model.domain.fee.FeeTransformResponseExtension;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@ -24,8 +24,4 @@ import javax.xml.bind.annotation.XmlType;
*/
@XmlRootElement(name = "renData")
@XmlType(propOrder = {"currency", "fees", "credits"})
public class FeeRenewResponseExtensionV11 extends FeeTransformResponseExtensionImpl {
/** A builder for {@link FeeRenewResponseExtensionV11}. */
public static class Builder
extends FeeTransformResponseExtensionImpl.Builder<FeeRenewResponseExtensionV11, Builder> {}
}
public class FeeRenewResponseExtensionV11 extends FeeTransformResponseExtension {}

View file

@ -14,20 +14,32 @@
package google.registry.model.domain.fee11;
import google.registry.model.domain.fee.FeeTransformCommandExtension;
import google.registry.model.domain.fee.FeeTransformCommandExtensionImpl;
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
import com.google.common.collect.ImmutableList;
import google.registry.model.domain.fee.Credit;
import google.registry.model.domain.fee.FeeTransferCommandExtension;
import google.registry.model.domain.fee.FeeTransformResponseExtension;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/** A fee extension that may be present on domain transfer requests. */
@XmlRootElement(name = "transfer")
@XmlType(propOrder = {"currency", "fees", "credits"})
public class FeeTransferCommandExtensionV11
extends FeeTransformCommandExtensionImpl implements FeeTransformCommandExtension {
public class FeeTransferCommandExtensionV11 extends FeeTransferCommandExtension {
@XmlElement(name = "credit")
List<Credit> credits;
@Override
public ImmutableList<Credit> getCredits() {
return nullToEmptyImmutableCopy(credits);
}
@Override
public FeeTransformResponseExtension.Builder createResponseBuilder() {
return new FeeTransferResponseExtensionV11.Builder();
return new FeeTransformResponseExtension.Builder(new FeeTransferResponseExtensionV11());
}
}

View file

@ -14,7 +14,7 @@
package google.registry.model.domain.fee11;
import google.registry.model.domain.fee.FeeTransformResponseExtensionImpl;
import google.registry.model.domain.fee.FeeTransformResponseExtension;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@ -24,8 +24,4 @@ import javax.xml.bind.annotation.XmlType;
*/
@XmlRootElement(name = "trnData")
@XmlType(propOrder = {"currency", "fees", "credits"})
public class FeeTransferResponseExtensionV11 extends FeeTransformResponseExtensionImpl {
/** A builder for {@link FeeTransferResponseExtensionV11}. */
public static class Builder
extends FeeTransformResponseExtensionImpl.Builder<FeeTransferResponseExtensionV11, Builder> {}
}
public class FeeTransferResponseExtensionV11 extends FeeTransformResponseExtension {}

View file

@ -14,20 +14,32 @@
package google.registry.model.domain.fee11;
import google.registry.model.domain.fee.FeeTransformCommandExtension;
import google.registry.model.domain.fee.FeeTransformCommandExtensionImpl;
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
import com.google.common.collect.ImmutableList;
import google.registry.model.domain.fee.Credit;
import google.registry.model.domain.fee.FeeTransformResponseExtension;
import google.registry.model.domain.fee.FeeUpdateCommandExtension;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/** A fee extension that may be present on domain update commands. */
@XmlRootElement(name = "update")
@XmlType(propOrder = {"currency", "fees", "credits"})
public class FeeUpdateCommandExtensionV11
extends FeeTransformCommandExtensionImpl implements FeeTransformCommandExtension {
public class FeeUpdateCommandExtensionV11 extends FeeUpdateCommandExtension {
@XmlElement(name = "credit")
List<Credit> credits;
@Override
public ImmutableList<Credit> getCredits() {
return nullToEmptyImmutableCopy(credits);
}
@Override
public FeeTransformResponseExtension.Builder createResponseBuilder() {
return new FeeUpdateResponseExtensionV11.Builder();
return new FeeTransformResponseExtension.Builder(new FeeUpdateResponseExtensionV11());
}
}

View file

@ -14,7 +14,7 @@
package google.registry.model.domain.fee11;
import google.registry.model.domain.fee.FeeTransformResponseExtensionImpl;
import google.registry.model.domain.fee.FeeTransformResponseExtension;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@ -24,8 +24,4 @@ import javax.xml.bind.annotation.XmlType;
*/
@XmlRootElement(name = "updData")
@XmlType(propOrder = {"currency", "fees", "credits"})
public class FeeUpdateResponseExtensionV11 extends FeeTransformResponseExtensionImpl {
/** A builder for {@link FeeUpdateResponseExtensionV11}. */
public static class Builder
extends FeeTransformResponseExtensionImpl.Builder<FeeUpdateResponseExtensionV11, Builder> {}
}
public class FeeUpdateResponseExtensionV11 extends FeeTransformResponseExtension {}

View file

@ -17,10 +17,8 @@ package google.registry.model.domain.fee12;
import com.google.common.base.Ascii;
import com.google.common.base.CharMatcher;
import com.google.common.base.Optional;
import google.registry.model.ImmutableObject;
import google.registry.model.domain.Period;
import google.registry.model.domain.fee.FeeCheckCommandExtensionItem;
import google.registry.model.domain.fee.FeeCheckResponseExtensionItem;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
@ -41,8 +39,7 @@ import org.joda.time.DateTime;
* the names from the non-extension check element are used.
*/
@XmlType(propOrder = {"period", "feeClass", "feeDate"})
public class FeeCheckCommandExtensionItemV12
extends ImmutableObject implements FeeCheckCommandExtensionItem {
public class FeeCheckCommandExtensionItemV12 extends FeeCheckCommandExtensionItem {
/** The default validity period (if not specified) is 1 year for all operations. */
static final Period DEFAULT_PERIOD = Period.create(1, Period.Unit.YEARS);
@ -56,9 +53,6 @@ public class FeeCheckCommandExtensionItemV12
@XmlAttribute
String subphase;
@XmlElement
Period period;
@XmlElement(name = "class")
String feeClass;
@ -110,12 +104,7 @@ public class FeeCheckCommandExtensionItemV12
}
@Override
public Period getPeriod() {
return Optional.fromNullable(period).or(DEFAULT_PERIOD);
}
@Override
public FeeCheckResponseExtensionItem.Builder createResponseBuilder() {
public FeeCheckResponseExtensionItemV12.Builder createResponseBuilder() {
return new FeeCheckResponseExtensionItemV12.Builder();
}

View file

@ -17,24 +17,19 @@ package google.registry.model.domain.fee12;
import static google.registry.util.CollectionUtils.forceEmptyToNull;
import com.google.common.collect.ImmutableList;
import google.registry.model.Buildable.GenericBuilder;
import google.registry.model.ImmutableObject;
import google.registry.model.domain.DomainObjectSpec;
import google.registry.model.domain.Period;
import google.registry.model.domain.fee.Fee;
import google.registry.model.domain.fee.FeeCheckResponseExtensionItem;
import google.registry.model.domain.fee.FeeQueryCommandExtensionItem.CommandName;
import java.util.List;
import javax.xml.bind.annotation.XmlType;
import org.joda.money.CurrencyUnit;
import org.joda.time.DateTime;
/**
* The version 0.12 response for a domain check on a single resource.
*/
@XmlType(propOrder = {"object", "command"})
public class FeeCheckResponseExtensionItemV12
extends ImmutableObject implements FeeCheckResponseExtensionItem {
public class FeeCheckResponseExtensionItemV12 extends FeeCheckResponseExtensionItem {
/** The domain that was checked. */
DomainObjectSpec object;
@ -42,6 +37,28 @@ public class FeeCheckResponseExtensionItemV12
/** The command that was checked. */
FeeCheckResponseExtensionItemCommandV12 command;
/**
* This method is overridden and not annotated for JAXB because this version of the extension
* doesn't support "period".
*/
@Override
public Period getPeriod() {
return super.getPeriod();
}
/**
* This method is overridden and not annotated for JAXB because this version of the extension
* doesn't support "fee".
*/
@Override
public ImmutableList<Fee> getFees() {
return super.getFees();
}
/**
* This method is not annotated for JAXB because this version of the extension doesn't support
* "feeClass" and because the data comes off of the command object rather than a field.
*/
@Override
public String getFeeClass() {
return command.getFeeClass();
@ -49,15 +66,10 @@ public class FeeCheckResponseExtensionItemV12
/** Builder for {@link FeeCheckResponseExtensionItemV12}. */
public static class Builder
extends GenericBuilder<FeeCheckResponseExtensionItemV12, Builder>
implements FeeCheckResponseExtensionItem.Builder {
extends FeeCheckResponseExtensionItem.Builder<FeeCheckResponseExtensionItemV12> {
final FeeCheckResponseExtensionItemCommandV12.Builder commandBuilder;
Builder() {
super();
commandBuilder = new FeeCheckResponseExtensionItemCommandV12.Builder();
}
final FeeCheckResponseExtensionItemCommandV12.Builder commandBuilder =
new FeeCheckResponseExtensionItemCommandV12.Builder();
@Override
public Builder setCommand(CommandName commandName, String phase, String subphase) {
@ -74,7 +86,7 @@ public class FeeCheckResponseExtensionItemV12
}
@Override
public Builder setFees(List<Fee> fees) {
public Builder setFees(ImmutableList<Fee> fees) {
commandBuilder.setFee(forceEmptyToNull(ImmutableList.copyOf(fees)));
return this;
}
@ -91,22 +103,6 @@ public class FeeCheckResponseExtensionItemV12
return this;
}
/** Version 0.12 does not support currency in check items. */
@Override
public Builder setCurrencyIfSupported(CurrencyUnit currency) {
return this;
}
@Override
public Builder setAvailIfSupported(boolean avail) {
return this;
}
@Override
public Builder setReasonIfSupported(String reason) {
return this;
}
@Override
public FeeCheckResponseExtensionItemV12 build() {
getInstance().command = commandBuilder.build();

View file

@ -14,20 +14,32 @@
package google.registry.model.domain.fee12;
import google.registry.model.domain.fee.FeeTransformCommandExtension;
import google.registry.model.domain.fee.FeeTransformCommandExtensionImpl;
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
import com.google.common.collect.ImmutableList;
import google.registry.model.domain.fee.Credit;
import google.registry.model.domain.fee.FeeCreateCommandExtension;
import google.registry.model.domain.fee.FeeTransformResponseExtension;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/** A fee extension that may be present on domain create commands. */
@XmlRootElement(name = "create")
@XmlType(propOrder = {"currency", "fees", "credits"})
public class FeeCreateCommandExtensionV12
extends FeeTransformCommandExtensionImpl implements FeeTransformCommandExtension {
public class FeeCreateCommandExtensionV12 extends FeeCreateCommandExtension {
@XmlElement(name = "credit")
List<Credit> credits;
@Override
public ImmutableList<Credit> getCredits() {
return nullToEmptyImmutableCopy(credits);
}
@Override
public FeeTransformResponseExtension.Builder createResponseBuilder() {
return new FeeCreateResponseExtensionV12.Builder();
return new FeeTransformResponseExtension.Builder(new FeeCreateResponseExtensionV12());
}
}

View file

@ -14,7 +14,7 @@
package google.registry.model.domain.fee12;
import google.registry.model.domain.fee.FeeTransformResponseExtensionImpl;
import google.registry.model.domain.fee.FeeTransformResponseExtension;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@ -24,8 +24,4 @@ import javax.xml.bind.annotation.XmlType;
*/
@XmlRootElement(name = "creData")
@XmlType(propOrder = {"currency", "fees", "credits"})
public class FeeCreateResponseExtensionV12 extends FeeTransformResponseExtensionImpl {
/** A builder for {@link FeeCreateResponseExtensionV12}. */
public static class Builder
extends FeeTransformResponseExtensionImpl.Builder<FeeCreateResponseExtensionV12, Builder> {}
}
public class FeeCreateResponseExtensionV12 extends FeeTransformResponseExtension {}

View file

@ -14,7 +14,7 @@
package google.registry.model.domain.fee12;
import google.registry.model.domain.fee.FeeTransformResponseExtensionImpl;
import google.registry.model.domain.fee.FeeTransformResponseExtension;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@ -24,9 +24,12 @@ import javax.xml.bind.annotation.XmlType;
*/
@XmlRootElement(name = "delData")
@XmlType(propOrder = {"currency", "fees", "credits"})
public class FeeDeleteResponseExtensionV12 extends FeeTransformResponseExtensionImpl {
public class FeeDeleteResponseExtensionV12 extends FeeTransformResponseExtension {
/** Builder for {@link FeeDeleteResponseExtensionV12}. */
public static class Builder
extends FeeTransformResponseExtensionImpl.Builder<FeeDeleteResponseExtensionV12, Builder> {}
public static class Builder extends FeeTransformResponseExtension.Builder {
public Builder() {
super(new FeeDeleteResponseExtensionV12());
}
}
}

View file

@ -14,20 +14,32 @@
package google.registry.model.domain.fee12;
import google.registry.model.domain.fee.FeeTransformCommandExtension;
import google.registry.model.domain.fee.FeeTransformCommandExtensionImpl;
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
import com.google.common.collect.ImmutableList;
import google.registry.model.domain.fee.Credit;
import google.registry.model.domain.fee.FeeRenewCommandExtension;
import google.registry.model.domain.fee.FeeTransformResponseExtension;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/** A fee extension that may be present on domain renew commands. */
@XmlRootElement(name = "renew")
@XmlType(propOrder = {"currency", "fees", "credits"})
public class FeeRenewCommandExtensionV12
extends FeeTransformCommandExtensionImpl implements FeeTransformCommandExtension {
public class FeeRenewCommandExtensionV12 extends FeeRenewCommandExtension {
@XmlElement(name = "credit")
List<Credit> credits;
@Override
public ImmutableList<Credit> getCredits() {
return nullToEmptyImmutableCopy(credits);
}
@Override
public FeeTransformResponseExtension.Builder createResponseBuilder() {
return new FeeRenewResponseExtensionV12.Builder();
return new FeeTransformResponseExtension.Builder(new FeeRenewResponseExtensionV12());
}
}

View file

@ -14,7 +14,7 @@
package google.registry.model.domain.fee12;
import google.registry.model.domain.fee.FeeTransformResponseExtensionImpl;
import google.registry.model.domain.fee.FeeTransformResponseExtension;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@ -24,8 +24,4 @@ import javax.xml.bind.annotation.XmlType;
*/
@XmlRootElement(name = "renData")
@XmlType(propOrder = {"currency", "fees", "credits"})
public class FeeRenewResponseExtensionV12 extends FeeTransformResponseExtensionImpl {
/** A builder for {@link FeeRenewResponseExtensionV12}. */
public static class Builder
extends FeeTransformResponseExtensionImpl.Builder<FeeRenewResponseExtensionV12, Builder> {}
}
public class FeeRenewResponseExtensionV12 extends FeeTransformResponseExtension {}

View file

@ -14,20 +14,32 @@
package google.registry.model.domain.fee12;
import google.registry.model.domain.fee.FeeTransformCommandExtension;
import google.registry.model.domain.fee.FeeTransformCommandExtensionImpl;
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
import com.google.common.collect.ImmutableList;
import google.registry.model.domain.fee.Credit;
import google.registry.model.domain.fee.FeeTransferCommandExtension;
import google.registry.model.domain.fee.FeeTransformResponseExtension;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/** A fee extension that may be present on domain transfer requests. */
@XmlRootElement(name = "transfer")
@XmlType(propOrder = {"currency", "fees", "credits"})
public class FeeTransferCommandExtensionV12
extends FeeTransformCommandExtensionImpl implements FeeTransformCommandExtension {
public class FeeTransferCommandExtensionV12 extends FeeTransferCommandExtension {
@XmlElement(name = "credit")
List<Credit> credits;
@Override
public ImmutableList<Credit> getCredits() {
return nullToEmptyImmutableCopy(credits);
}
@Override
public FeeTransformResponseExtension.Builder createResponseBuilder() {
return new FeeTransferResponseExtensionV12.Builder();
return new FeeTransformResponseExtension.Builder(new FeeTransferResponseExtensionV12());
}
}

View file

@ -14,7 +14,7 @@
package google.registry.model.domain.fee12;
import google.registry.model.domain.fee.FeeTransformResponseExtensionImpl;
import google.registry.model.domain.fee.FeeTransformResponseExtension;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@ -24,8 +24,4 @@ import javax.xml.bind.annotation.XmlType;
*/
@XmlRootElement(name = "trnData")
@XmlType(propOrder = {"currency", "fees", "credits"})
public class FeeTransferResponseExtensionV12 extends FeeTransformResponseExtensionImpl {
/** A builder for {@link FeeTransferResponseExtensionV12}. */
public static class Builder
extends FeeTransformResponseExtensionImpl.Builder<FeeTransferResponseExtensionV12, Builder> {}
}
public class FeeTransferResponseExtensionV12 extends FeeTransformResponseExtension {}

View file

@ -14,20 +14,32 @@
package google.registry.model.domain.fee12;
import google.registry.model.domain.fee.FeeTransformCommandExtension;
import google.registry.model.domain.fee.FeeTransformCommandExtensionImpl;
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
import com.google.common.collect.ImmutableList;
import google.registry.model.domain.fee.Credit;
import google.registry.model.domain.fee.FeeTransformResponseExtension;
import google.registry.model.domain.fee.FeeUpdateCommandExtension;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/** A fee extension that may be present on domain update commands. */
@XmlRootElement(name = "update")
@XmlType(propOrder = {"currency", "fees", "credits"})
public class FeeUpdateCommandExtensionV12
extends FeeTransformCommandExtensionImpl implements FeeTransformCommandExtension {
public class FeeUpdateCommandExtensionV12 extends FeeUpdateCommandExtension {
@XmlElement(name = "credit")
List<Credit> credits;
@Override
public ImmutableList<Credit> getCredits() {
return nullToEmptyImmutableCopy(credits);
}
@Override
public FeeTransformResponseExtension.Builder createResponseBuilder() {
return new FeeUpdateResponseExtensionV12.Builder();
return new FeeTransformResponseExtension.Builder(new FeeUpdateResponseExtensionV12());
}
}

View file

@ -14,7 +14,7 @@
package google.registry.model.domain.fee12;
import google.registry.model.domain.fee.FeeTransformResponseExtensionImpl;
import google.registry.model.domain.fee.FeeTransformResponseExtension;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@ -24,8 +24,4 @@ import javax.xml.bind.annotation.XmlType;
*/
@XmlRootElement(name = "updData")
@XmlType(propOrder = {"currency", "fees", "credits"})
public class FeeUpdateResponseExtensionV12 extends FeeTransformResponseExtensionImpl {
/** A builder for {@link FeeUpdateResponseExtensionV12}. */
public static class Builder
extends FeeTransformResponseExtensionImpl.Builder<FeeUpdateResponseExtensionV12, Builder> {}
}
public class FeeUpdateResponseExtensionV12 extends FeeTransformResponseExtension {}

View file

@ -17,7 +17,6 @@ package google.registry.model.eppinput;
import static google.registry.util.CollectionUtils.nullSafeImmutableCopy;
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
import com.google.common.base.Optional;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@ -111,34 +110,6 @@ public class EppInput extends ImmutableObject {
return FluentIterable.from(getCommandWrapper().getExtensions()).filter(clazz).first().orNull();
}
/** Get the extension based on type, or null, chosen from a list of possible extension classes.
* If there are extensions matching multiple classes, the first class listed is chosen. If there
* are multiple extensions of the same class, the first extension of that class is chosen
* (assuming that an extension matching a preceding class was not already chosen). This method is
* used to support multiple versions of an extension. Specify all supported versions, starting
* with the latest. The first-occurring extension of the latest version will be chosen, or failing
* that the first-occurring extension of the previous version, and so on.
*/
@Nullable
public <E extends CommandExtension>
E getFirstExtensionOfClasses(ImmutableList<Class<? extends E>> classes) {
for (Class<? extends E> clazz : classes) {
Optional<? extends E> extension = FluentIterable.from(
getCommandWrapper().getExtensions()).filter(clazz).first();
if (extension.isPresent()) {
return extension.get();
}
}
return null;
}
@SafeVarargs
@Nullable
public final <E extends CommandExtension>
E getFirstExtensionOfClasses(Class<? extends E>... classes) {
return getFirstExtensionOfClasses(ImmutableList.copyOf(classes));
}
/** A tag that goes inside of an EPP {@literal <command>}. */
public static class InnerCommand extends ImmutableObject {}

View file

@ -18,7 +18,6 @@ import static com.google.common.base.Predicates.not;
import static com.google.common.collect.Maps.toMap;
import static google.registry.flows.EppXmlTransformer.unmarshal;
import static google.registry.flows.picker.FlowPicker.getFlowClass;
import static google.registry.model.domain.fee.Fee.FEE_CREATE_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.util.CollectionUtils.isNullOrEmpty;
import static google.registry.util.DomainNameUtils.ACE_PREFIX;
@ -58,6 +57,7 @@ import google.registry.flows.host.HostCreateFlow;
import google.registry.flows.host.HostDeleteFlow;
import google.registry.flows.host.HostUpdateFlow;
import google.registry.model.domain.DomainCommand;
import google.registry.model.domain.fee.FeeCreateCommandExtension;
import google.registry.model.domain.launch.LaunchCreateExtension;
import google.registry.model.domain.secdns.SecDnsCreateExtension;
import google.registry.model.domain.secdns.SecDnsUpdateExtension;
@ -143,8 +143,7 @@ public class VerifyOteAction implements Runnable, JsonAction {
private static final Predicate<EppInput> HAS_FEE = new Predicate<EppInput>() {
@Override
public boolean apply(@Nonnull EppInput eppInput) {
return eppInput.getFirstExtensionOfClasses(
FEE_CREATE_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER) != null;
return eppInput.getSingleExtension(FeeCreateCommandExtension.class) != null;
}};
private static final Predicate<EppInput> HAS_SEC_DNS = new Predicate<EppInput>() {

View file

@ -24,7 +24,6 @@ import google.registry.flows.ExtensionManager.UndeclaredServiceExtensionExceptio
import google.registry.flows.ExtensionManager.UnsupportedRepeatedExtensionException;
import google.registry.flows.exceptions.OnlyToolCanPassMetadataException;
import google.registry.flows.session.HelloFlow;
import google.registry.model.domain.allocate.AllocateCreateExtension;
import google.registry.model.domain.fee06.FeeInfoCommandExtensionV06;
import google.registry.model.domain.launch.LaunchCreateExtension;
import google.registry.model.domain.metadata.MetadataExtension;
@ -68,23 +67,6 @@ public class ExtensionManagerTest {
manager.validate();
}
@Test
public void testMultipleExtensionsFromSameGroupForbidden() throws Exception {
ExtensionManager manager = new TestInstanceBuilder()
.setEppRequestSource(EppRequestSource.TOOL)
.setDeclaredUris(ServiceExtension.FEE_0_6.getUri())
.setSuppliedExtensions(
MetadataExtension.class,
LaunchCreateExtension.class,
AllocateCreateExtension.class)
.build();
manager.register(MetadataExtension.class);
manager.registerAsGroup(
ImmutableList.of(LaunchCreateExtension.class, AllocateCreateExtension.class));
thrown.expect(UnsupportedRepeatedExtensionException.class);
manager.validate();
}
@Test
public void testUndeclaredExtensionsLogged() throws Exception {
TestLogHandler handler = new TestLogHandler();