From 718da70b717a28e7c9b72653a9d5661ad0543846 Mon Sep 17 00:00:00 2001 From: mountford Date: Thu, 28 Jul 2016 09:24:57 -0400 Subject: [PATCH] Add TLD extra flow logic for update This CL implements the TLD-specific extra flow logic for updates, with tests, based on the static helper classes of the previous CL. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=135683537 --- .../registry/flows/domain/DomainInfoFlow.java | 6 +- .../flows/domain/RegistryExtraFlowLogic.java | 64 +++++++++++++------ .../domain_update_add_one_flag_with_fee.xml | 22 ------- ...domain_update_remove_one_flag_with_fee.xml | 22 ------- .../model/domain/TestExtraLogicManager.java | 6 +- 5 files changed, 53 insertions(+), 67 deletions(-) delete mode 100644 javatests/google/registry/flows/dotapp/testdata/domain_update_add_one_flag_with_fee.xml delete mode 100644 javatests/google/registry/flows/dotapp/testdata/domain_update_remove_one_flag_with_fee.xml diff --git a/java/google/registry/flows/domain/DomainInfoFlow.java b/java/google/registry/flows/domain/DomainInfoFlow.java index af860ae19..652bb5283 100644 --- a/java/google/registry/flows/domain/DomainInfoFlow.java +++ b/java/google/registry/flows/domain/DomainInfoFlow.java @@ -42,7 +42,7 @@ import google.registry.model.eppcommon.AuthInfo; import google.registry.model.eppinput.ResourceCommand; import google.registry.model.eppoutput.EppOutput; import google.registry.model.eppoutput.EppResponse.ResponseExtension; -import java.util.List; +import java.util.Set; import javax.inject.Inject; /** @@ -136,10 +136,10 @@ public final class DomainInfoFlow extends LoggedInFlow { Optional extraLogicManager = RegistryExtraFlowLogicProxy.newInstanceForDomain(domain); if (extraLogicManager.isPresent()) { - List flags = extraLogicManager.get().getExtensionFlags( + Set flags = extraLogicManager.get().getExtensionFlags( domain, clientId, now); // As-of date is always now for info commands. if (!flags.isEmpty()) { - extensions.add(FlagsInfoResponseExtension.create(flags)); + extensions.add(FlagsInfoResponseExtension.create(ImmutableList.copyOf(flags))); } } return forceEmptyToNull(extensions.build()); diff --git a/java/google/registry/flows/domain/RegistryExtraFlowLogic.java b/java/google/registry/flows/domain/RegistryExtraFlowLogic.java index 2610dfe4b..b3ea6fd3e 100644 --- a/java/google/registry/flows/domain/RegistryExtraFlowLogic.java +++ b/java/google/registry/flows/domain/RegistryExtraFlowLogic.java @@ -19,7 +19,7 @@ import google.registry.model.domain.DomainResource; import google.registry.model.domain.fee.BaseFee; import google.registry.model.eppinput.EppInput; import google.registry.model.reporting.HistoryEntry; -import java.util.List; +import java.util.Set; import org.joda.time.DateTime; /** @@ -28,11 +28,19 @@ import org.joda.time.DateTime; */ public interface RegistryExtraFlowLogic { - /** Gets the flags to be used in the EPP flags extension. This is used for EPP info commands. */ - public List getExtensionFlags( + /** + * Gets the flags to be used in the EPP flags extension. + * + *

This is used for EPP info commands. + */ + public Set getExtensionFlags( DomainResource domainResource, String clientId, DateTime asOfDate); - /** Computes the expected creation fee, for use in fee challenges and the like. */ + /** + * Computes the expected creation fee. + * + *

For use in fee challenges and the like. + */ public BaseFee getCreateFeeOrCredit( String domainName, String clientId, @@ -41,8 +49,10 @@ public interface RegistryExtraFlowLogic { EppInput eppInput) throws EppException; /** - * Performs additional tasks required for a create command. Any changes should not be persisted to - * Datastore until commitAdditionalLogicChanges is called. + * Performs additional tasks required for a create command. + * + *

Any changes should not be persisted to Datastore until commitAdditionalLogicChanges is + * called. */ public void performAdditionalDomainCreateLogic( DomainResource domain, @@ -53,8 +63,10 @@ public interface RegistryExtraFlowLogic { HistoryEntry historyEntry) throws EppException; /** - * Performs additional tasks required for a delete command. Any changes should not be persisted to - * Datastore until commitAdditionalLogicChanges is called. + * Performs additional tasks required for a delete command. + * + *

Any changes should not be persisted to Datastore until commitAdditionalLogicChanges is + * called. */ public void performAdditionalDomainDeleteLogic( DomainResource domain, @@ -63,7 +75,11 @@ public interface RegistryExtraFlowLogic { EppInput eppInput, HistoryEntry historyEntry) throws EppException; - /** Computes the expected renewal fee, for use in fee challenges and the like. */ + /** + * Computes the expected renewal fee. + * + *

For use in fee challenges and the like. + */ public BaseFee getRenewFeeOrCredit( DomainResource domain, String clientId, @@ -72,8 +88,10 @@ public interface RegistryExtraFlowLogic { EppInput eppInput) throws EppException; /** - * Performs additional tasks required for a renew command. Any changes should not be persisted - * to Datastore until commitAdditionalLogicChanges is called. + * Performs additional tasks required for a renew command. + * + *

Any changes should not be persisted to Datastore until commitAdditionalLogicChanges is + * called. */ public void performAdditionalDomainRenewLogic( DomainResource domain, @@ -84,8 +102,10 @@ public interface RegistryExtraFlowLogic { HistoryEntry historyEntry) throws EppException; /** - * Performs additional tasks required for a restore command. Any changes should not be persisted - * to Datastore until commitAdditionalLogicChanges is called. + * Performs additional tasks required for a restore command. + * + *

Any changes should not be persisted to Datastore until commitAdditionalLogicChanges is + * called. */ public void performAdditionalDomainRestoreLogic( DomainResource domain, @@ -95,8 +115,10 @@ public interface RegistryExtraFlowLogic { HistoryEntry historyEntry) throws EppException; /** - * Performs additional tasks required for a transfer command. Any changes should not be persisted - * to Datastore until commitAdditionalLogicChanges is called. + * Performs additional tasks required for a transfer command. + * + *

Any changes should not be persisted to Datastore until commitAdditionalLogicChanges is + * called. */ public void performAdditionalDomainTransferLogic( DomainResource domain, @@ -106,7 +128,11 @@ public interface RegistryExtraFlowLogic { EppInput eppInput, HistoryEntry historyEntry) throws EppException; - /** Computes the expected update fee, for use in fee challenges and the like. */ + /** + * Computes the expected update fee. + * + *

For use in fee challenges and the like. + */ public BaseFee getUpdateFeeOrCredit( DomainResource domain, String clientId, @@ -114,8 +140,10 @@ public interface RegistryExtraFlowLogic { EppInput eppInput) throws EppException; /** - * Performs additional tasks required for an update command. Any changes should not be persisted - * to Datastore until commitAdditionalLogicChanges is called. + * Performs additional tasks required for an update command. + * + *

Any changes should not be persisted to Datastore until commitAdditionalLogicChanges is + * called. */ public void performAdditionalDomainUpdateLogic( DomainResource domain, diff --git a/javatests/google/registry/flows/dotapp/testdata/domain_update_add_one_flag_with_fee.xml b/javatests/google/registry/flows/dotapp/testdata/domain_update_add_one_flag_with_fee.xml deleted file mode 100644 index db5040060..000000000 --- a/javatests/google/registry/flows/dotapp/testdata/domain_update_add_one_flag_with_fee.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - example.tld - - - - - - %FLAG% - - - - USD - %FEE% - - - ABC-12345 - - diff --git a/javatests/google/registry/flows/dotapp/testdata/domain_update_remove_one_flag_with_fee.xml b/javatests/google/registry/flows/dotapp/testdata/domain_update_remove_one_flag_with_fee.xml deleted file mode 100644 index bf9e83356..000000000 --- a/javatests/google/registry/flows/dotapp/testdata/domain_update_remove_one_flag_with_fee.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - example.tld - - - - - - %FLAG% - - - - USD - %FEE% - - - ABC-12345 - - diff --git a/javatests/google/registry/model/domain/TestExtraLogicManager.java b/javatests/google/registry/model/domain/TestExtraLogicManager.java index a622fa1aa..b8dfa93c8 100644 --- a/javatests/google/registry/model/domain/TestExtraLogicManager.java +++ b/javatests/google/registry/model/domain/TestExtraLogicManager.java @@ -20,6 +20,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.base.Ascii; import com.google.common.base.Joiner; import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import google.registry.flows.EppException; import google.registry.flows.domain.RegistryExtraFlowLogic; @@ -34,6 +35,7 @@ import google.registry.model.eppinput.EppInput; import google.registry.model.reporting.HistoryEntry; import java.math.BigDecimal; import java.util.List; +import java.util.Set; import org.joda.time.DateTime; /** @@ -57,7 +59,7 @@ public class TestExtraLogicManager implements RegistryExtraFlowLogic { } @Override - public List getExtensionFlags( + public Set getExtensionFlags( DomainResource domainResource, String clientId, DateTime asOfDate) { // Take the part before the period, split by dashes, and treat each part after the first as // a flag. @@ -65,7 +67,7 @@ public class TestExtraLogicManager implements RegistryExtraFlowLogic { Splitter.on('-').splitToList( Iterables.getFirst( Splitter.on('.').split(domainResource.getFullyQualifiedDomainName()), "")); - return components.subList(1, components.size()); + return ImmutableSet.copyOf(components.subList(1, components.size())); } BaseFee domainNameToFeeOrCredit(String domainName) {