diff --git a/java/google/registry/flows/ExtensionManager.java b/java/google/registry/flows/ExtensionManager.java index 7b9a7eb07..eead2dcd0 100644 --- a/java/google/registry/flows/ExtensionManager.java +++ b/java/google/registry/flows/ExtensionManager.java @@ -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> implementedBuilder = new ImmutableSet.Builder<>(); - private final ImmutableSet.Builder> implementedGroupsBuilder = - new ImmutableSet.Builder<>(); @Inject EppInput eppInput; @Inject SessionMetadata sessionMetadata; @@ -64,12 +65,6 @@ public final class ExtensionManager { implementedBuilder.add(extension); } - public void registerAsGroup( - Collection> extensions) { - implementedBuilder.addAll(extensions); - implementedGroupsBuilder.add(ImmutableSet.copyOf(extensions)); - } - public void validate() throws EppException { ImmutableSet.Builder> suppliedBuilder = new ImmutableSet.Builder<>(); @@ -79,27 +74,12 @@ public final class ExtensionManager { ImmutableSet> suppliedExtensions = suppliedBuilder.build(); ImmutableSet> implementedExtensions = implementedBuilder.build(); - ImmutableSet> implementedExtensionGroups = - implementedGroupsBuilder.build(); - checkForDuplicateExtensions(suppliedExtensions, implementedExtensionGroups); + ImmutableList suppliedExtensionInstances = + eppInput.getCommandWrapper().getExtensions(); checkForUndeclaredExtensions(suppliedExtensions); checkForRestrictedExtensions(suppliedExtensions); - checkForUnimplementedExtensions(suppliedExtensions, implementedExtensions); - } - - private void checkForDuplicateExtensions( - ImmutableSet> suppliedExtensions, - 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> suppliedExtensions, + private static void checkForDuplicateExtensions( + ImmutableList suppliedExtensionInstances, ImmutableSet> implementedExtensions) - throws UnimplementedExtensionException { - Set> unimplementedExtensions = - difference(suppliedExtensions, implementedExtensions); - if (!unimplementedExtensions.isEmpty()) { - logger.infofmt("Unimplemented extensions: %s", unimplementedExtensions); - throw new UnimplementedExtensionException(); + throws UnsupportedRepeatedExtensionException { + for (Class 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 suppliedExtensionInstances, + ImmutableSet> implementedExtensionClasses) + throws UnimplementedExtensionException { + ImmutableSet.Builder> unimplementedExtensionsBuilder = + new ImmutableSet.Builder<>(); + for (final CommandExtension instance : suppliedExtensionInstances) { + if (!any( + implementedExtensionClasses, + new Predicate>() { + @Override + public boolean apply(Class implementedExtensionClass) { + return implementedExtensionClass.isInstance(instance); + }})) { + unimplementedExtensionsBuilder.add(instance.getClass()); + } + } + ImmutableSet> 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"); + } + } } diff --git a/java/google/registry/flows/domain/DomainAllocateFlow.java b/java/google/registry/flows/domain/DomainAllocateFlow.java index 4ca97cf6b..73d302c3b 100644 --- a/java/google/registry/flows/domain/DomainAllocateFlow.java +++ b/java/google/registry/flows/domain/DomainAllocateFlow.java @@ -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)); diff --git a/java/google/registry/flows/domain/DomainApplicationCreateFlow.java b/java/google/registry/flows/domain/DomainApplicationCreateFlow.java index 377f6053a..c45eaf386 100644 --- a/java/google/registry/flows/domain/DomainApplicationCreateFlow.java +++ b/java/google/registry/flows/domain/DomainApplicationCreateFlow.java @@ -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)); diff --git a/java/google/registry/flows/domain/DomainApplicationUpdateFlow.java b/java/google/registry/flows/domain/DomainApplicationUpdateFlow.java index 2653d15fc..9c9bd568d 100644 --- a/java/google/registry/flows/domain/DomainApplicationUpdateFlow.java +++ b/java/google/registry/flows/domain/DomainApplicationUpdateFlow.java @@ -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(); diff --git a/java/google/registry/flows/domain/DomainCheckFlow.java b/java/google/registry/flows/domain/DomainCheckFlow.java index 062c7a333..bcfbb83f2 100644 --- a/java/google/registry/flows/domain/DomainCheckFlow.java +++ b/java/google/registry/flows/domain/DomainCheckFlow.java @@ -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 targetIds = ((Check) resourceCommand).getTargetIds(); @@ -177,7 +175,7 @@ public final class DomainCheckFlow implements Flow { private ImmutableList getResponseExtensions( ImmutableMap 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, diff --git a/java/google/registry/flows/domain/DomainCreateFlow.java b/java/google/registry/flows/domain/DomainCreateFlow.java index 78bd80a9e..6c3a80f3d 100644 --- a/java/google/registry/flows/domain/DomainCreateFlow.java +++ b/java/google/registry/flows/domain/DomainCreateFlow.java @@ -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 createResponseExtensions( - FeeTransformCommandExtension feeCreate, EppCommandOperations commandOperations) { + FeeCreateCommandExtension feeCreate, EppCommandOperations commandOperations) { return (feeCreate == null) ? null : ImmutableList.of(createFeeCreateResponse(feeCreate, commandOperations)); diff --git a/java/google/registry/flows/domain/DomainFlowUtils.java b/java/google/registry/flows/domain/DomainFlowUtils.java index cf99373fb..4974e4a1d 100644 --- a/java/google/registry/flows/domain/DomainFlowUtils.java +++ b/java/google/registry/flows/domain/DomainFlowUtils.java @@ -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 fees = ImmutableList.of(); + ImmutableList fees = ImmutableList.of(); switch (feeRequest.getCommandName()) { case CREATE: if (isReserved(domain, isSunrise)) { // Don't return a create price for reserved names. diff --git a/java/google/registry/flows/domain/DomainRenewFlow.java b/java/google/registry/flows/domain/DomainRenewFlow.java index 9ff6e62f6..a9a5f8a5a 100644 --- a/java/google/registry/flows/domain/DomainRenewFlow.java +++ b/java/google/registry/flows/domain/DomainRenewFlow.java @@ -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 createResponseExtensions( - Money renewCost, FeeTransformCommandExtension feeRenew) { + Money renewCost, FeeRenewCommandExtension feeRenew) { return (feeRenew == null) ? null : ImmutableList.of(feeRenew .createResponseBuilder() .setCurrency(renewCost.getCurrencyUnit()) diff --git a/java/google/registry/flows/domain/DomainRestoreRequestFlow.java b/java/google/registry/flows/domain/DomainRestoreRequestFlow.java index 68bcc4ba3..94a1958b3 100644 --- a/java/google/registry/flows/domain/DomainRestoreRequestFlow.java +++ b/java/google/registry/flows/domain/DomainRestoreRequestFlow.java @@ -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 createResponseExtensions( - Money restoreCost, Money renewCost, FeeTransformCommandExtension feeUpdate) { + Money restoreCost, Money renewCost, FeeUpdateCommandExtension feeUpdate) { return (feeUpdate == null) ? null : ImmutableList.of( feeUpdate.createResponseBuilder() .setCurrency(restoreCost.getCurrencyUnit()) diff --git a/java/google/registry/flows/domain/DomainTransferRequestFlow.java b/java/google/registry/flows/domain/DomainTransferRequestFlow.java index 5f652691b..c82a73196 100644 --- a/java/google/registry/flows/domain/DomainTransferRequestFlow.java +++ b/java/google/registry/flows/domain/DomainTransferRequestFlow.java @@ -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 createResponseExtensions(Money renewCost, - FeeTransformCommandExtension feeTransfer) { + FeeTransferCommandExtension feeTransfer) { return feeTransfer == null ? null : ImmutableList.of(feeTransfer.createResponseBuilder() diff --git a/java/google/registry/flows/domain/DomainUpdateFlow.java b/java/google/registry/flows/domain/DomainUpdateFlow.java index 23af372b7..78ddcb501 100644 --- a/java/google/registry/flows/domain/DomainUpdateFlow.java +++ b/java/google/registry/flows/domain/DomainUpdateFlow.java @@ -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. diff --git a/java/google/registry/model/domain/fee/Fee.java b/java/google/registry/model/domain/fee/Fee.java index 4868117c7..a5742ab28 100644 --- a/java/google/registry/model/domain/fee/Fee.java +++ b/java/google/registry/model/domain/fee/Fee.java @@ -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>>> - FEE_CHECK_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER = - ImmutableList.< - Class>>>of( - FeeCheckCommandExtensionV12.class, - FeeCheckCommandExtensionV11.class, - FeeCheckCommandExtensionV06.class); - - public static final ImmutableList> - FEE_CREATE_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER = - ImmutableList.>of( - FeeCreateCommandExtensionV12.class, - FeeCreateCommandExtensionV11.class, - FeeCreateCommandExtensionV06.class); - - public static final ImmutableList> - FEE_RENEW_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER = - ImmutableList.>of( - FeeRenewCommandExtensionV12.class, - FeeRenewCommandExtensionV11.class, - FeeRenewCommandExtensionV06.class); - - public static final ImmutableList> - FEE_TRANSFER_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER = - ImmutableList.>of( - FeeTransferCommandExtensionV12.class, - FeeTransferCommandExtensionV11.class, - FeeTransferCommandExtensionV06.class); - - public static final ImmutableList> - FEE_UPDATE_COMMAND_EXTENSIONS_IN_PREFERENCE_ORDER = - ImmutableList.>of( - FeeUpdateCommandExtensionV12.class, - FeeUpdateCommandExtensionV11.class, - FeeUpdateCommandExtensionV06.class); - - public static final ImmutableSet FEE_EXTENSION_URIS = - ImmutableSet.of( - ServiceExtension.FEE_0_12.getUri(), - ServiceExtension.FEE_0_11.getUri(), - ServiceExtension.FEE_0_6.getUri()); + public static final ImmutableSet FEE_EXTENSION_URIS = ImmutableSet.of( + ServiceExtension.FEE_0_12.getUri(), + ServiceExtension.FEE_0_11.getUri(), + ServiceExtension.FEE_0_6.getUri()); } diff --git a/java/google/registry/model/domain/fee/FeeCheckCommandExtensionItem.java b/java/google/registry/model/domain/fee/FeeCheckCommandExtensionItem.java index 4602c5d3a..36e9a345d 100644 --- a/java/google/registry/model/domain/fee/FeeCheckCommandExtensionItem.java +++ b/java/google/registry/model/domain/fee/FeeCheckCommandExtensionItem.java @@ -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(); } diff --git a/java/google/registry/model/domain/fee/FeeCheckResponseExtensionItem.java b/java/google/registry/model/domain/fee/FeeCheckResponseExtensionItem.java index ad6c5d867..64c82cb1a 100644 --- a/java/google/registry/model/domain/fee/FeeCheckResponseExtensionItem.java +++ b/java/google/registry/model/domain/fee/FeeCheckResponseExtensionItem.java @@ -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 + extends FeeQueryResponseExtensionItem.Builder> { /** 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 setDomainNameIfSupported(@SuppressWarnings("unused") String name) { + return this; // Default impl is a noop. + } } } diff --git a/java/google/registry/model/domain/fee/FeeCreateCommandExtension.java b/java/google/registry/model/domain/fee/FeeCreateCommandExtension.java new file mode 100644 index 000000000..003eaa97f --- /dev/null +++ b/java/google/registry/model/domain/fee/FeeCreateCommandExtension.java @@ -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 {} diff --git a/java/google/registry/model/domain/fee/FeeQueryCommandExtensionItem.java b/java/google/registry/model/domain/fee/FeeQueryCommandExtensionItem.java index 05c2d7225..e1e863c21 100644 --- a/java/google/registry/model/domain/fee/FeeQueryCommandExtensionItem.java +++ b/java/google/registry/model/domain/fee/FeeQueryCommandExtensionItem.java @@ -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. * *

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 getEffectiveDate(); + public abstract Optional 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); + } } diff --git a/java/google/registry/model/domain/fee/FeeQueryCommandExtensionItemImpl.java b/java/google/registry/model/domain/fee/FeeQueryCommandExtensionItemImpl.java deleted file mode 100644 index e2655e7db..000000000 --- a/java/google/registry/model/domain/fee/FeeQueryCommandExtensionItemImpl.java +++ /dev/null @@ -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); - } -} diff --git a/java/google/registry/model/domain/fee/FeeQueryResponseExtensionItem.java b/java/google/registry/model/domain/fee/FeeQueryResponseExtensionItem.java index 43fe402cb..f50e25a94 100644 --- a/java/google/registry/model/domain/fee/FeeQueryResponseExtensionItem.java +++ b/java/google/registry/model/domain/fee/FeeQueryResponseExtensionItem.java @@ -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. + * + *

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. + * + *

This is a list because a single operation can involve multiple fees. + * + *

This field is exposed to JAXB only via the getter so that subclasses can override it. + */ + @XmlTransient + List 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. + * + *

We will use "premium" for fees on premium names, and omit the field otherwise. + * + *

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 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> + extends GenericBuilder { - 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 fees); + public B setFees(ImmutableList 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. + } } } - diff --git a/java/google/registry/model/domain/fee/FeeQueryResponseExtensionItemImpl.java b/java/google/registry/model/domain/fee/FeeQueryResponseExtensionItemImpl.java deleted file mode 100644 index 46b8c5320..000000000 --- a/java/google/registry/model/domain/fee/FeeQueryResponseExtensionItemImpl.java +++ /dev/null @@ -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. - * - *

This is a list because a single operation can involve multiple fees. - */ - List fee; - - /** - * The type of the fee. - * - *

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> - extends GenericBuilder 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 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 fees) { - getInstance().fee = forceEmptyToNull(ImmutableList.copyOf(fees)); - return thisCastToDerived(); - } - - @Override - public B setClass(String feeClass) { - getInstance().feeClass = feeClass; - return thisCastToDerived(); - } - } -} diff --git a/java/google/registry/model/domain/fee/FeeRenewCommandExtension.java b/java/google/registry/model/domain/fee/FeeRenewCommandExtension.java new file mode 100644 index 000000000..67020537a --- /dev/null +++ b/java/google/registry/model/domain/fee/FeeRenewCommandExtension.java @@ -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 {} diff --git a/java/google/registry/model/domain/fee/FeeTransferCommandExtension.java b/java/google/registry/model/domain/fee/FeeTransferCommandExtension.java new file mode 100644 index 000000000..a9c3f76e9 --- /dev/null +++ b/java/google/registry/model/domain/fee/FeeTransferCommandExtension.java @@ -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 {} diff --git a/java/google/registry/model/domain/fee/FeeTransformCommandExtension.java b/java/google/registry/model/domain/fee/FeeTransformCommandExtension.java index b02ed330b..556f4396e 100644 --- a/java/google/registry/model/domain/fee/FeeTransformCommandExtension.java +++ b/java/google/registry/model/domain/fee/FeeTransformCommandExtension.java @@ -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 getFees(); - List 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. + * + *

This is a list because a single operation can involve multiple fees. + */ + @XmlElement(name = "fee") + List fees; + + public CurrencyUnit getCurrency() { + return currency; + } + + public ImmutableList getFees() { + return nullToEmptyImmutableCopy(fees); + } + + public abstract ImmutableList getCredits(); + + public abstract FeeTransformResponseExtension.Builder createResponseBuilder(); } diff --git a/java/google/registry/model/domain/fee/FeeTransformCommandExtensionImpl.java b/java/google/registry/model/domain/fee/FeeTransformCommandExtensionImpl.java deleted file mode 100644 index 6da32b975..000000000 --- a/java/google/registry/model/domain/fee/FeeTransformCommandExtensionImpl.java +++ /dev/null @@ -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. - * - *

This is a list because a single operation can involve multiple fees. - */ - @XmlElement(name = "fee") - List fees; - - @XmlElement(name = "credit") - List credits; - - @Override - public CurrencyUnit getCurrency() { - return currency; - } - - @Override - public List getFees() { - return fees; - } - - @Override - public List getCredits() { - return nullToEmpty(credits); - } -} diff --git a/java/google/registry/model/domain/fee/FeeTransformCommandExtensionImplNoCredits.java b/java/google/registry/model/domain/fee/FeeTransformCommandExtensionImplNoCredits.java deleted file mode 100644 index 30e69acc4..000000000 --- a/java/google/registry/model/domain/fee/FeeTransformCommandExtensionImplNoCredits.java +++ /dev/null @@ -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. - * - *

This is a list because a single operation can involve multiple fees. - */ - @XmlElement(name = "fee") - List fees; - - @Override - public CurrencyUnit getCurrency() { - return currency; - } - - @Override - public List getFees() { - return fees; - } - - @Override - public List getCredits() { - return ImmutableList.of(); - } -} diff --git a/java/google/registry/model/domain/fee/FeeTransformResponseExtension.java b/java/google/registry/model/domain/fee/FeeTransformResponseExtension.java index 75f6eb0c4..9484d3623 100644 --- a/java/google/registry/model/domain/fee/FeeTransformResponseExtension.java +++ b/java/google/registry/model/domain/fee/FeeTransformResponseExtension.java @@ -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 fees); - Builder setCredits(List credits); - FeeTransformResponseExtension build(); + /** The currency of the fee. */ + CurrencyUnit currency; + + /** + * The magnitude of the fee, in the specified units, with an optional description. + * + *

This is a list because a single operation can involve multiple fees. + */ + @XmlElement(name = "fee") + List fees; + + /** This field is exposed to JAXB only via the getter so that subclasses can override it. */ + @XmlTransient + List credits; + + @XmlElement(name = "credit") + public ImmutableList getCredits() { + return nullToEmptyImmutableCopy(credits); + } + + /** Abstract builder for {@link FeeTransformResponseExtensionImpl}. */ + public static class Builder extends Buildable.Builder { + + public Builder(FeeTransformResponseExtension instance) { + super(instance); + } + + public Builder setCurrency(CurrencyUnit currency) { + getInstance().currency = currency; + return this; + } + + public Builder setFees(List fees) { + getInstance().fees = fees; + return this; + } + + public Builder setCredits(List credits) { + getInstance().credits = forceEmptyToNull(credits); + return this; + } } } diff --git a/java/google/registry/model/domain/fee/FeeTransformResponseExtensionImpl.java b/java/google/registry/model/domain/fee/FeeTransformResponseExtensionImpl.java deleted file mode 100644 index 40b949bf8..000000000 --- a/java/google/registry/model/domain/fee/FeeTransformResponseExtensionImpl.java +++ /dev/null @@ -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. - * - *

This is a list because a single operation can involve multiple fees. - */ - @XmlElement(name = "fee") - List fees; - - @XmlElement(name = "credit") - List credits; - - /** Abstract builder for {@link FeeTransformResponseExtensionImpl}. */ - public abstract static class - Builder> - extends GenericBuilder implements FeeTransformResponseExtension.Builder { - - @Override - public B setCurrency(CurrencyUnit currency) { - getInstance().currency = currency; - return thisCastToDerived(); - } - - @Override - public B setFees(List fees) { - getInstance().fees = fees; - return thisCastToDerived(); - } - - @Override - public B setCredits(List credits) { - getInstance().credits = forceEmptyToNull(credits); - return thisCastToDerived(); - } - } -} diff --git a/java/google/registry/model/domain/fee/FeeTransformResponseExtensionImplNoCredits.java b/java/google/registry/model/domain/fee/FeeTransformResponseExtensionImplNoCredits.java deleted file mode 100644 index 6a2e4e2cd..000000000 --- a/java/google/registry/model/domain/fee/FeeTransformResponseExtensionImplNoCredits.java +++ /dev/null @@ -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. - * - *

This is a list because a single operation can involve multiple fees. - */ - @XmlElement(name = "fee") - List fees; - - /** Abstract builder for {@link FeeTransformResponseExtensionImplNoCredits}. */ - public abstract static class - Builder> - extends GenericBuilder implements FeeTransformResponseExtension.Builder { - - @Override - public B setCurrency(CurrencyUnit currency) { - getInstance().currency = currency; - return thisCastToDerived(); - } - - @Override - public B setFees(List fees) { - getInstance().fees = fees; - return thisCastToDerived(); - } - - @Override - public B setCredits(List credits) { - return thisCastToDerived(); - } - } -} diff --git a/java/google/registry/model/domain/fee/FeeUpdateCommandExtension.java b/java/google/registry/model/domain/fee/FeeUpdateCommandExtension.java new file mode 100644 index 000000000..e8e979a97 --- /dev/null +++ b/java/google/registry/model/domain/fee/FeeUpdateCommandExtension.java @@ -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 {} diff --git a/java/google/registry/model/domain/fee06/FeeCheckCommandExtensionItemV06.java b/java/google/registry/model/domain/fee06/FeeCheckCommandExtensionItemV06.java index c2a79469f..7ba97155c 100644 --- a/java/google/registry/model/domain/fee06/FeeCheckCommandExtensionItemV06.java +++ b/java/google/registry/model/domain/fee06/FeeCheckCommandExtensionItemV06.java @@ -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(); } diff --git a/java/google/registry/model/domain/fee06/FeeCheckResponseExtensionItemV06.java b/java/google/registry/model/domain/fee06/FeeCheckResponseExtensionItemV06.java index 81a802f55..2c065469f 100644 --- a/java/google/registry/model/domain/fee06/FeeCheckResponseExtensionItemV06.java +++ b/java/google/registry/model/domain/fee06/FeeCheckResponseExtensionItemV06.java @@ -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 - implements FeeCheckResponseExtensionItem.Builder { + extends FeeCheckResponseExtensionItem.Builder { + + @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; - } - } } diff --git a/java/google/registry/model/domain/fee06/FeeCreateCommandExtensionV06.java b/java/google/registry/model/domain/fee06/FeeCreateCommandExtensionV06.java index 0777361f7..e0be36842 100644 --- a/java/google/registry/model/domain/fee06/FeeCreateCommandExtensionV06.java +++ b/java/google/registry/model/domain/fee06/FeeCreateCommandExtensionV06.java @@ -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 getCredits() { + return ImmutableList.of(); } } diff --git a/java/google/registry/model/domain/fee06/FeeCreateResponseExtensionV06.java b/java/google/registry/model/domain/fee06/FeeCreateResponseExtensionV06.java index 2082f62ce..f80d157ae 100644 --- a/java/google/registry/model/domain/fee06/FeeCreateResponseExtensionV06.java +++ b/java/google/registry/model/domain/fee06/FeeCreateResponseExtensionV06.java @@ -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 {} +public class FeeCreateResponseExtensionV06 extends FeeTransformResponseExtension { + + /** This version of the extension doesn't support the "credit" field. */ + @Override + public ImmutableList getCredits() { + return ImmutableList.of(); + } } diff --git a/java/google/registry/model/domain/fee06/FeeDeleteResponseExtensionV06.java b/java/google/registry/model/domain/fee06/FeeDeleteResponseExtensionV06.java index 52f127b23..c680bcbf5 100644 --- a/java/google/registry/model/domain/fee06/FeeDeleteResponseExtensionV06.java +++ b/java/google/registry/model/domain/fee06/FeeDeleteResponseExtensionV06.java @@ -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 {} + public static class Builder extends FeeTransformResponseExtension.Builder { + public Builder() { + super(new FeeDeleteResponseExtensionV06()); + } + } } diff --git a/java/google/registry/model/domain/fee06/FeeInfoCommandExtensionV06.java b/java/google/registry/model/domain/fee06/FeeInfoCommandExtensionV06.java index a96dac197..3089cb793 100644 --- a/java/google/registry/model/domain/fee06/FeeInfoCommandExtensionV06.java +++ b/java/google/registry/model/domain/fee06/FeeInfoCommandExtensionV06.java @@ -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; diff --git a/java/google/registry/model/domain/fee06/FeeInfoResponseExtensionV06.java b/java/google/registry/model/domain/fee06/FeeInfoResponseExtensionV06.java index 841e4fbbd..7fb5f99a0 100644 --- a/java/google/registry/model/domain/fee06/FeeInfoResponseExtensionV06.java +++ b/java/google/registry/model/domain/fee06/FeeInfoResponseExtensionV06.java @@ -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 { + extends FeeQueryResponseExtensionItem.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; - } } } diff --git a/java/google/registry/model/domain/fee06/FeeRenewCommandExtensionV06.java b/java/google/registry/model/domain/fee06/FeeRenewCommandExtensionV06.java index 1c83dbc26..69d8046f1 100644 --- a/java/google/registry/model/domain/fee06/FeeRenewCommandExtensionV06.java +++ b/java/google/registry/model/domain/fee06/FeeRenewCommandExtensionV06.java @@ -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 getCredits() { + return ImmutableList.of(); } } diff --git a/java/google/registry/model/domain/fee06/FeeRenewResponseExtensionV06.java b/java/google/registry/model/domain/fee06/FeeRenewResponseExtensionV06.java index b6a24d07a..446217731 100644 --- a/java/google/registry/model/domain/fee06/FeeRenewResponseExtensionV06.java +++ b/java/google/registry/model/domain/fee06/FeeRenewResponseExtensionV06.java @@ -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 {} +public class FeeRenewResponseExtensionV06 extends FeeTransformResponseExtension { + + /** This version of the extension doesn't support the "credit" field. */ + @Override + public ImmutableList getCredits() { + return super.getCredits(); + } } diff --git a/java/google/registry/model/domain/fee06/FeeTransferCommandExtensionV06.java b/java/google/registry/model/domain/fee06/FeeTransferCommandExtensionV06.java index 6e5273850..17cafa2c4 100644 --- a/java/google/registry/model/domain/fee06/FeeTransferCommandExtensionV06.java +++ b/java/google/registry/model/domain/fee06/FeeTransferCommandExtensionV06.java @@ -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 getCredits() { + return ImmutableList.of(); } } diff --git a/java/google/registry/model/domain/fee06/FeeTransferResponseExtensionV06.java b/java/google/registry/model/domain/fee06/FeeTransferResponseExtensionV06.java index a6a339b73..b60e57043 100644 --- a/java/google/registry/model/domain/fee06/FeeTransferResponseExtensionV06.java +++ b/java/google/registry/model/domain/fee06/FeeTransferResponseExtensionV06.java @@ -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 {} +public class FeeTransferResponseExtensionV06 extends FeeTransformResponseExtension { + + /** This version of the extension doesn't support the "credit" field. */ + @Override + public ImmutableList getCredits() { + return super.getCredits(); + } } diff --git a/java/google/registry/model/domain/fee06/FeeUpdateCommandExtensionV06.java b/java/google/registry/model/domain/fee06/FeeUpdateCommandExtensionV06.java index 76a99c83b..75f476df9 100644 --- a/java/google/registry/model/domain/fee06/FeeUpdateCommandExtensionV06.java +++ b/java/google/registry/model/domain/fee06/FeeUpdateCommandExtensionV06.java @@ -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 getCredits() { + return ImmutableList.of(); } } diff --git a/java/google/registry/model/domain/fee06/FeeUpdateResponseExtensionV06.java b/java/google/registry/model/domain/fee06/FeeUpdateResponseExtensionV06.java index ea8287c9c..166347931 100644 --- a/java/google/registry/model/domain/fee06/FeeUpdateResponseExtensionV06.java +++ b/java/google/registry/model/domain/fee06/FeeUpdateResponseExtensionV06.java @@ -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 {} +public class FeeUpdateResponseExtensionV06 extends FeeTransformResponseExtension { + + /** This version of the extension doesn't support the "credit" field. */ + @Override + public ImmutableList getCredits() { + return super.getCredits(); + } } diff --git a/java/google/registry/model/domain/fee11/FeeCheckCommandExtensionV11.java b/java/google/registry/model/domain/fee11/FeeCheckCommandExtensionV11.java index d4b6f7077..c9fbe03f5 100644 --- a/java/google/registry/model/domain/fee11/FeeCheckCommandExtensionV11.java +++ b/java/google/registry/model/domain/fee11/FeeCheckCommandExtensionV11.java @@ -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(); } diff --git a/java/google/registry/model/domain/fee11/FeeCheckResponseExtensionItemV11.java b/java/google/registry/model/domain/fee11/FeeCheckResponseExtensionItemV11.java index 706c57060..a36df5443 100644 --- a/java/google/registry/model/domain/fee11/FeeCheckResponseExtensionItemV11.java +++ b/java/google/registry/model/domain/fee11/FeeCheckResponseExtensionItemV11.java @@ -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 - implements FeeCheckResponseExtensionItem.Builder { + extends FeeCheckResponseExtensionItem.Builder { + + @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; - } } } diff --git a/java/google/registry/model/domain/fee11/FeeCreateCommandExtensionV11.java b/java/google/registry/model/domain/fee11/FeeCreateCommandExtensionV11.java index 610c7e9f6..4033e7ec8 100644 --- a/java/google/registry/model/domain/fee11/FeeCreateCommandExtensionV11.java +++ b/java/google/registry/model/domain/fee11/FeeCreateCommandExtensionV11.java @@ -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 credits; + + @Override + public ImmutableList getCredits() { + return nullToEmptyImmutableCopy(credits); + } @Override public FeeTransformResponseExtension.Builder createResponseBuilder() { - return new FeeCreateResponseExtensionV11.Builder(); + return new FeeTransformResponseExtension.Builder(new FeeCreateResponseExtensionV11()); } } diff --git a/java/google/registry/model/domain/fee11/FeeCreateResponseExtensionV11.java b/java/google/registry/model/domain/fee11/FeeCreateResponseExtensionV11.java index f3321150e..8d1f551ae 100644 --- a/java/google/registry/model/domain/fee11/FeeCreateResponseExtensionV11.java +++ b/java/google/registry/model/domain/fee11/FeeCreateResponseExtensionV11.java @@ -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 {} -} +public class FeeCreateResponseExtensionV11 extends FeeTransformResponseExtension {} diff --git a/java/google/registry/model/domain/fee11/FeeDeleteResponseExtensionV11.java b/java/google/registry/model/domain/fee11/FeeDeleteResponseExtensionV11.java index 24bbb892f..df7a4cc60 100644 --- a/java/google/registry/model/domain/fee11/FeeDeleteResponseExtensionV11.java +++ b/java/google/registry/model/domain/fee11/FeeDeleteResponseExtensionV11.java @@ -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 {} + public static class Builder extends FeeTransformResponseExtension.Builder { + public Builder() { + super(new FeeDeleteResponseExtensionV11()); + } + } } diff --git a/java/google/registry/model/domain/fee11/FeeRenewCommandExtensionV11.java b/java/google/registry/model/domain/fee11/FeeRenewCommandExtensionV11.java index 553394def..77a03b5ca 100644 --- a/java/google/registry/model/domain/fee11/FeeRenewCommandExtensionV11.java +++ b/java/google/registry/model/domain/fee11/FeeRenewCommandExtensionV11.java @@ -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 credits; + + @Override + public ImmutableList getCredits() { + return nullToEmptyImmutableCopy(credits); + } @Override public FeeTransformResponseExtension.Builder createResponseBuilder() { - return new FeeRenewResponseExtensionV11.Builder(); + return new FeeTransformResponseExtension.Builder(new FeeRenewResponseExtensionV11()); } } diff --git a/java/google/registry/model/domain/fee11/FeeRenewResponseExtensionV11.java b/java/google/registry/model/domain/fee11/FeeRenewResponseExtensionV11.java index 12b09013d..76f4f3598 100644 --- a/java/google/registry/model/domain/fee11/FeeRenewResponseExtensionV11.java +++ b/java/google/registry/model/domain/fee11/FeeRenewResponseExtensionV11.java @@ -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 {} -} +public class FeeRenewResponseExtensionV11 extends FeeTransformResponseExtension {} diff --git a/java/google/registry/model/domain/fee11/FeeTransferCommandExtensionV11.java b/java/google/registry/model/domain/fee11/FeeTransferCommandExtensionV11.java index 9169a1d6f..2ea4a3410 100644 --- a/java/google/registry/model/domain/fee11/FeeTransferCommandExtensionV11.java +++ b/java/google/registry/model/domain/fee11/FeeTransferCommandExtensionV11.java @@ -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 credits; + + @Override + public ImmutableList getCredits() { + return nullToEmptyImmutableCopy(credits); + } @Override public FeeTransformResponseExtension.Builder createResponseBuilder() { - return new FeeTransferResponseExtensionV11.Builder(); + return new FeeTransformResponseExtension.Builder(new FeeTransferResponseExtensionV11()); } } diff --git a/java/google/registry/model/domain/fee11/FeeTransferResponseExtensionV11.java b/java/google/registry/model/domain/fee11/FeeTransferResponseExtensionV11.java index 0a4e4ca71..1b87d3af7 100644 --- a/java/google/registry/model/domain/fee11/FeeTransferResponseExtensionV11.java +++ b/java/google/registry/model/domain/fee11/FeeTransferResponseExtensionV11.java @@ -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 {} -} +public class FeeTransferResponseExtensionV11 extends FeeTransformResponseExtension {} diff --git a/java/google/registry/model/domain/fee11/FeeUpdateCommandExtensionV11.java b/java/google/registry/model/domain/fee11/FeeUpdateCommandExtensionV11.java index de2b08877..76707a5a8 100644 --- a/java/google/registry/model/domain/fee11/FeeUpdateCommandExtensionV11.java +++ b/java/google/registry/model/domain/fee11/FeeUpdateCommandExtensionV11.java @@ -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 credits; + + @Override + public ImmutableList getCredits() { + return nullToEmptyImmutableCopy(credits); + } @Override public FeeTransformResponseExtension.Builder createResponseBuilder() { - return new FeeUpdateResponseExtensionV11.Builder(); + return new FeeTransformResponseExtension.Builder(new FeeUpdateResponseExtensionV11()); } } diff --git a/java/google/registry/model/domain/fee11/FeeUpdateResponseExtensionV11.java b/java/google/registry/model/domain/fee11/FeeUpdateResponseExtensionV11.java index 0cbc4e242..02772d686 100644 --- a/java/google/registry/model/domain/fee11/FeeUpdateResponseExtensionV11.java +++ b/java/google/registry/model/domain/fee11/FeeUpdateResponseExtensionV11.java @@ -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 {} -} +public class FeeUpdateResponseExtensionV11 extends FeeTransformResponseExtension {} diff --git a/java/google/registry/model/domain/fee12/FeeCheckCommandExtensionItemV12.java b/java/google/registry/model/domain/fee12/FeeCheckCommandExtensionItemV12.java index 236202e7a..5e55c917a 100644 --- a/java/google/registry/model/domain/fee12/FeeCheckCommandExtensionItemV12.java +++ b/java/google/registry/model/domain/fee12/FeeCheckCommandExtensionItemV12.java @@ -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(); } diff --git a/java/google/registry/model/domain/fee12/FeeCheckResponseExtensionItemV12.java b/java/google/registry/model/domain/fee12/FeeCheckResponseExtensionItemV12.java index dda847fa1..fb0603a1a 100644 --- a/java/google/registry/model/domain/fee12/FeeCheckResponseExtensionItemV12.java +++ b/java/google/registry/model/domain/fee12/FeeCheckResponseExtensionItemV12.java @@ -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 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 - implements FeeCheckResponseExtensionItem.Builder { + extends FeeCheckResponseExtensionItem.Builder { - 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 fees) { + public Builder setFees(ImmutableList 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(); diff --git a/java/google/registry/model/domain/fee12/FeeCreateCommandExtensionV12.java b/java/google/registry/model/domain/fee12/FeeCreateCommandExtensionV12.java index c9517eb76..1d143559b 100644 --- a/java/google/registry/model/domain/fee12/FeeCreateCommandExtensionV12.java +++ b/java/google/registry/model/domain/fee12/FeeCreateCommandExtensionV12.java @@ -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 credits; + + @Override + public ImmutableList getCredits() { + return nullToEmptyImmutableCopy(credits); + } @Override public FeeTransformResponseExtension.Builder createResponseBuilder() { - return new FeeCreateResponseExtensionV12.Builder(); + return new FeeTransformResponseExtension.Builder(new FeeCreateResponseExtensionV12()); } } diff --git a/java/google/registry/model/domain/fee12/FeeCreateResponseExtensionV12.java b/java/google/registry/model/domain/fee12/FeeCreateResponseExtensionV12.java index 889cce3ae..5fc2fdb46 100644 --- a/java/google/registry/model/domain/fee12/FeeCreateResponseExtensionV12.java +++ b/java/google/registry/model/domain/fee12/FeeCreateResponseExtensionV12.java @@ -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 {} -} +public class FeeCreateResponseExtensionV12 extends FeeTransformResponseExtension {} diff --git a/java/google/registry/model/domain/fee12/FeeDeleteResponseExtensionV12.java b/java/google/registry/model/domain/fee12/FeeDeleteResponseExtensionV12.java index b04a2183e..70df8acc6 100644 --- a/java/google/registry/model/domain/fee12/FeeDeleteResponseExtensionV12.java +++ b/java/google/registry/model/domain/fee12/FeeDeleteResponseExtensionV12.java @@ -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 {} + public static class Builder extends FeeTransformResponseExtension.Builder { + public Builder() { + super(new FeeDeleteResponseExtensionV12()); + } + } } diff --git a/java/google/registry/model/domain/fee12/FeeRenewCommandExtensionV12.java b/java/google/registry/model/domain/fee12/FeeRenewCommandExtensionV12.java index 23cd43317..0cfdf6605 100644 --- a/java/google/registry/model/domain/fee12/FeeRenewCommandExtensionV12.java +++ b/java/google/registry/model/domain/fee12/FeeRenewCommandExtensionV12.java @@ -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 credits; + + @Override + public ImmutableList getCredits() { + return nullToEmptyImmutableCopy(credits); + } @Override public FeeTransformResponseExtension.Builder createResponseBuilder() { - return new FeeRenewResponseExtensionV12.Builder(); + return new FeeTransformResponseExtension.Builder(new FeeRenewResponseExtensionV12()); } } diff --git a/java/google/registry/model/domain/fee12/FeeRenewResponseExtensionV12.java b/java/google/registry/model/domain/fee12/FeeRenewResponseExtensionV12.java index 37da63828..8d56857c3 100644 --- a/java/google/registry/model/domain/fee12/FeeRenewResponseExtensionV12.java +++ b/java/google/registry/model/domain/fee12/FeeRenewResponseExtensionV12.java @@ -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 {} -} +public class FeeRenewResponseExtensionV12 extends FeeTransformResponseExtension {} diff --git a/java/google/registry/model/domain/fee12/FeeTransferCommandExtensionV12.java b/java/google/registry/model/domain/fee12/FeeTransferCommandExtensionV12.java index bc6cee3b7..ffdd010d1 100644 --- a/java/google/registry/model/domain/fee12/FeeTransferCommandExtensionV12.java +++ b/java/google/registry/model/domain/fee12/FeeTransferCommandExtensionV12.java @@ -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 credits; + + @Override + public ImmutableList getCredits() { + return nullToEmptyImmutableCopy(credits); + } @Override public FeeTransformResponseExtension.Builder createResponseBuilder() { - return new FeeTransferResponseExtensionV12.Builder(); + return new FeeTransformResponseExtension.Builder(new FeeTransferResponseExtensionV12()); } } diff --git a/java/google/registry/model/domain/fee12/FeeTransferResponseExtensionV12.java b/java/google/registry/model/domain/fee12/FeeTransferResponseExtensionV12.java index dd074257b..16342d881 100644 --- a/java/google/registry/model/domain/fee12/FeeTransferResponseExtensionV12.java +++ b/java/google/registry/model/domain/fee12/FeeTransferResponseExtensionV12.java @@ -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 {} -} +public class FeeTransferResponseExtensionV12 extends FeeTransformResponseExtension {} diff --git a/java/google/registry/model/domain/fee12/FeeUpdateCommandExtensionV12.java b/java/google/registry/model/domain/fee12/FeeUpdateCommandExtensionV12.java index 622cd2ee2..e8126ff0e 100644 --- a/java/google/registry/model/domain/fee12/FeeUpdateCommandExtensionV12.java +++ b/java/google/registry/model/domain/fee12/FeeUpdateCommandExtensionV12.java @@ -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 credits; + + @Override + public ImmutableList getCredits() { + return nullToEmptyImmutableCopy(credits); + } @Override public FeeTransformResponseExtension.Builder createResponseBuilder() { - return new FeeUpdateResponseExtensionV12.Builder(); + return new FeeTransformResponseExtension.Builder(new FeeUpdateResponseExtensionV12()); } } diff --git a/java/google/registry/model/domain/fee12/FeeUpdateResponseExtensionV12.java b/java/google/registry/model/domain/fee12/FeeUpdateResponseExtensionV12.java index e5a792cc9..158e3d8b7 100644 --- a/java/google/registry/model/domain/fee12/FeeUpdateResponseExtensionV12.java +++ b/java/google/registry/model/domain/fee12/FeeUpdateResponseExtensionV12.java @@ -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 {} -} +public class FeeUpdateResponseExtensionV12 extends FeeTransformResponseExtension {} diff --git a/java/google/registry/model/eppinput/EppInput.java b/java/google/registry/model/eppinput/EppInput.java index 97c56e45c..9266a2197 100644 --- a/java/google/registry/model/eppinput/EppInput.java +++ b/java/google/registry/model/eppinput/EppInput.java @@ -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 getFirstExtensionOfClasses(ImmutableList> classes) { - for (Class clazz : classes) { - Optional extension = FluentIterable.from( - getCommandWrapper().getExtensions()).filter(clazz).first(); - if (extension.isPresent()) { - return extension.get(); - } - } - return null; - } - - @SafeVarargs - @Nullable - public final - E getFirstExtensionOfClasses(Class... classes) { - return getFirstExtensionOfClasses(ImmutableList.copyOf(classes)); - } - /** A tag that goes inside of an EPP {@literal }. */ public static class InnerCommand extends ImmutableObject {} diff --git a/java/google/registry/tools/server/VerifyOteAction.java b/java/google/registry/tools/server/VerifyOteAction.java index 4a27b426e..63c6db0f9 100644 --- a/java/google/registry/tools/server/VerifyOteAction.java +++ b/java/google/registry/tools/server/VerifyOteAction.java @@ -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 HAS_FEE = new Predicate() { @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 HAS_SEC_DNS = new Predicate() { diff --git a/javatests/google/registry/flows/ExtensionManagerTest.java b/javatests/google/registry/flows/ExtensionManagerTest.java index b11f9ec84..62ff4a004 100644 --- a/javatests/google/registry/flows/ExtensionManagerTest.java +++ b/javatests/google/registry/flows/ExtensionManagerTest.java @@ -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();