mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Remove commitAdditionalLogicChanges(), part 1
Now that the flows are flattened, the commitAdditionalLogicChanges() call, which used to come later in the flow to actually save the Datastore objects, is now happening right after the performAdditionalXXXLogic() call. So we can instead just do the saves in performAdditionalXXXLogic(), and get rid of the separate call. As a first step, this CL simply makes commitAdditionalLogicChanges() a private method that gets called internally by the extra logic manager. Later, we can move the saves into their proper position, affecting only the extra logic class itself. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=137529991
This commit is contained in:
parent
bbd20ec71d
commit
78a36925f4
12 changed files with 43 additions and 93 deletions
|
@ -353,7 +353,6 @@ public final class DomainApplicationCreateFlow extends Flow implements Transacti
|
||||||
years,
|
years,
|
||||||
eppInput,
|
eppInput,
|
||||||
historyEntry);
|
historyEntry);
|
||||||
extraFlowLogic.get().commitAdditionalLogicChanges();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -404,7 +404,6 @@ public class DomainCreateFlow extends Flow implements TransactionalFlow {
|
||||||
years,
|
years,
|
||||||
eppInput,
|
eppInput,
|
||||||
historyEntry);
|
historyEntry);
|
||||||
extraFlowLogic.get().commitAdditionalLogicChanges();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -198,7 +198,6 @@ public final class DomainDeleteFlow extends Flow implements TransactionalFlow {
|
||||||
if (extraFlowLogic.isPresent()) {
|
if (extraFlowLogic.isPresent()) {
|
||||||
extraFlowLogic.get().performAdditionalDomainDeleteLogic(
|
extraFlowLogic.get().performAdditionalDomainDeleteLogic(
|
||||||
existingResource, clientId, now, eppInput, historyEntry);
|
existingResource, clientId, now, eppInput, historyEntry);
|
||||||
extraFlowLogic.get().commitAdditionalLogicChanges();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -161,7 +161,6 @@ public final class DomainRenewFlow extends Flow implements TransactionalFlow {
|
||||||
if (extraFlowLogic.isPresent()) {
|
if (extraFlowLogic.isPresent()) {
|
||||||
extraFlowLogic.get().performAdditionalDomainRenewLogic(
|
extraFlowLogic.get().performAdditionalDomainRenewLogic(
|
||||||
existingDomain, clientId, now, years, eppInput, historyEntry);
|
existingDomain, clientId, now, years, eppInput, historyEntry);
|
||||||
extraFlowLogic.get().commitAdditionalLogicChanges();
|
|
||||||
}
|
}
|
||||||
DomainResource newDomain = existingDomain.asBuilder()
|
DomainResource newDomain = existingDomain.asBuilder()
|
||||||
.setRegistrationExpirationTime(newExpirationTime)
|
.setRegistrationExpirationTime(newExpirationTime)
|
||||||
|
|
|
@ -155,7 +155,6 @@ public final class DomainRestoreRequestFlow extends Flow implements Transactiona
|
||||||
if (extraFlowLogic.isPresent()) {
|
if (extraFlowLogic.isPresent()) {
|
||||||
extraFlowLogic.get().performAdditionalDomainRestoreLogic(
|
extraFlowLogic.get().performAdditionalDomainRestoreLogic(
|
||||||
existingDomain, clientId, now, eppInput, historyEntry);
|
existingDomain, clientId, now, eppInput, historyEntry);
|
||||||
extraFlowLogic.get().commitAdditionalLogicChanges();
|
|
||||||
}
|
}
|
||||||
DomainResource newDomain =
|
DomainResource newDomain =
|
||||||
performRestore(existingDomain, newExpirationTime, autorenewEvent, autorenewPollMessage);
|
performRestore(existingDomain, newExpirationTime, autorenewEvent, autorenewPollMessage);
|
||||||
|
|
|
@ -372,7 +372,6 @@ public final class DomainTransferRequestFlow extends Flow implements Transaction
|
||||||
if (extraFlowLogic.isPresent()) {
|
if (extraFlowLogic.isPresent()) {
|
||||||
extraFlowLogic.get().performAdditionalDomainTransferLogic(
|
extraFlowLogic.get().performAdditionalDomainTransferLogic(
|
||||||
existingDomain, gainingClientId, now, years, eppInput, historyEntry);
|
existingDomain, gainingClientId, now, years, eppInput, historyEntry);
|
||||||
extraFlowLogic.get().commitAdditionalLogicChanges();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -333,7 +333,6 @@ public final class DomainUpdateFlow extends Flow implements TransactionalFlow {
|
||||||
if (extraFlowLogic.isPresent()) {
|
if (extraFlowLogic.isPresent()) {
|
||||||
extraFlowLogic.get().performAdditionalDomainUpdateLogic(
|
extraFlowLogic.get().performAdditionalDomainUpdateLogic(
|
||||||
existingDomain, clientId, now, eppInput, historyEntry);
|
existingDomain, clientId, now, eppInput, historyEntry);
|
||||||
extraFlowLogic.get().commitAdditionalLogicChanges();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,12 +63,7 @@ public interface RegistryExtraFlowLogic {
|
||||||
int years,
|
int years,
|
||||||
EppInput eppInput) throws EppException;
|
EppInput eppInput) throws EppException;
|
||||||
|
|
||||||
/**
|
/** Performs additional tasks required for a create command. */
|
||||||
* Performs additional tasks required for a create command.
|
|
||||||
*
|
|
||||||
* <p>Any changes should not be persisted to Datastore until commitAdditionalLogicChanges is
|
|
||||||
* called.
|
|
||||||
*/
|
|
||||||
public void performAdditionalDomainCreateLogic(
|
public void performAdditionalDomainCreateLogic(
|
||||||
DomainResource domain,
|
DomainResource domain,
|
||||||
String clientId,
|
String clientId,
|
||||||
|
@ -77,12 +72,7 @@ public interface RegistryExtraFlowLogic {
|
||||||
EppInput eppInput,
|
EppInput eppInput,
|
||||||
HistoryEntry historyEntry) throws EppException;
|
HistoryEntry historyEntry) throws EppException;
|
||||||
|
|
||||||
/**
|
/** Performs additional tasks required for a delete command. */
|
||||||
* Performs additional tasks required for a delete command.
|
|
||||||
*
|
|
||||||
* <p>Any changes should not be persisted to Datastore until commitAdditionalLogicChanges is
|
|
||||||
* called.
|
|
||||||
*/
|
|
||||||
public void performAdditionalDomainDeleteLogic(
|
public void performAdditionalDomainDeleteLogic(
|
||||||
DomainResource domain,
|
DomainResource domain,
|
||||||
String clientId,
|
String clientId,
|
||||||
|
@ -102,12 +92,7 @@ public interface RegistryExtraFlowLogic {
|
||||||
int years,
|
int years,
|
||||||
EppInput eppInput) throws EppException;
|
EppInput eppInput) throws EppException;
|
||||||
|
|
||||||
/**
|
/** Performs additional tasks required for a renew command. */
|
||||||
* Performs additional tasks required for a renew command.
|
|
||||||
*
|
|
||||||
* <p>Any changes should not be persisted to Datastore until commitAdditionalLogicChanges is
|
|
||||||
* called.
|
|
||||||
*/
|
|
||||||
public void performAdditionalDomainRenewLogic(
|
public void performAdditionalDomainRenewLogic(
|
||||||
DomainResource domain,
|
DomainResource domain,
|
||||||
String clientId,
|
String clientId,
|
||||||
|
@ -116,12 +101,7 @@ public interface RegistryExtraFlowLogic {
|
||||||
EppInput eppInput,
|
EppInput eppInput,
|
||||||
HistoryEntry historyEntry) throws EppException;
|
HistoryEntry historyEntry) throws EppException;
|
||||||
|
|
||||||
/**
|
/** Performs additional tasks required for a restore command. */
|
||||||
* Performs additional tasks required for a restore command.
|
|
||||||
*
|
|
||||||
* <p>Any changes should not be persisted to Datastore until commitAdditionalLogicChanges is
|
|
||||||
* called.
|
|
||||||
*/
|
|
||||||
public void performAdditionalDomainRestoreLogic(
|
public void performAdditionalDomainRestoreLogic(
|
||||||
DomainResource domain,
|
DomainResource domain,
|
||||||
String clientId,
|
String clientId,
|
||||||
|
@ -129,12 +109,7 @@ public interface RegistryExtraFlowLogic {
|
||||||
EppInput eppInput,
|
EppInput eppInput,
|
||||||
HistoryEntry historyEntry) throws EppException;
|
HistoryEntry historyEntry) throws EppException;
|
||||||
|
|
||||||
/**
|
/** Performs additional tasks required for a transfer command. */
|
||||||
* Performs additional tasks required for a transfer command.
|
|
||||||
*
|
|
||||||
* <p>Any changes should not be persisted to Datastore until commitAdditionalLogicChanges is
|
|
||||||
* called.
|
|
||||||
*/
|
|
||||||
public void performAdditionalDomainTransferLogic(
|
public void performAdditionalDomainTransferLogic(
|
||||||
DomainResource domain,
|
DomainResource domain,
|
||||||
String clientId,
|
String clientId,
|
||||||
|
@ -154,19 +129,11 @@ public interface RegistryExtraFlowLogic {
|
||||||
DateTime asOfDate,
|
DateTime asOfDate,
|
||||||
EppInput eppInput) throws EppException;
|
EppInput eppInput) throws EppException;
|
||||||
|
|
||||||
/**
|
/** Performs additional tasks required for an update command. */
|
||||||
* Performs additional tasks required for an update command.
|
|
||||||
*
|
|
||||||
* <p>Any changes should not be persisted to Datastore until commitAdditionalLogicChanges is
|
|
||||||
* called.
|
|
||||||
*/
|
|
||||||
public void performAdditionalDomainUpdateLogic(
|
public void performAdditionalDomainUpdateLogic(
|
||||||
DomainResource domain,
|
DomainResource domain,
|
||||||
String clientId,
|
String clientId,
|
||||||
DateTime asOfDate,
|
DateTime asOfDate,
|
||||||
EppInput eppInput,
|
EppInput eppInput,
|
||||||
HistoryEntry historyEntry) throws EppException;
|
HistoryEntry historyEntry) throws EppException;
|
||||||
|
|
||||||
/** Commits any changes made as a result of a call to one of the performXXX methods. */
|
|
||||||
public void commitAdditionalLogicChanges();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@ public abstract class FlowTestCase<F extends Flow> extends ShardableTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the EPP data loaded by a previous call to setEppInput. */
|
/** Returns the EPP data loaded by a previous call to setEppInput. */
|
||||||
protected EppInput getEppInput() throws Exception {
|
protected EppInput getEppInput() throws EppException {
|
||||||
return eppLoader.getEpp();
|
return eppLoader.getEpp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
17
javatests/google/registry/flows/dotapp/testdata/domain_update_restore_request.xml
vendored
Normal file
17
javatests/google/registry/flows/dotapp/testdata/domain_update_restore_request.xml
vendored
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||||
|
<command>
|
||||||
|
<update>
|
||||||
|
<domain:update
|
||||||
|
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||||
|
<domain:name>example.tld</domain:name>
|
||||||
|
<domain:chg/>
|
||||||
|
</domain:update>
|
||||||
|
</update>
|
||||||
|
<extension>
|
||||||
|
<rgp:update xmlns:rgp="urn:ietf:params:xml:ns:rgp-1.0">
|
||||||
|
<rgp:restore op="request"/>
|
||||||
|
</rgp:update>
|
||||||
|
</extension>
|
||||||
|
<clTRID>ABC-12345</clTRID>
|
||||||
|
</command>
|
||||||
|
</epp>
|
|
@ -15,7 +15,6 @@
|
||||||
package google.registry.model.domain;
|
package google.registry.model.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
import com.google.common.base.Ascii;
|
import com.google.common.base.Ascii;
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
|
@ -43,11 +42,9 @@ import org.joda.time.DateTime;
|
||||||
*/
|
*/
|
||||||
public class TestExtraLogicManager implements RegistryExtraFlowLogic {
|
public class TestExtraLogicManager implements RegistryExtraFlowLogic {
|
||||||
|
|
||||||
private String messageToThrow = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dummy exception used to signal success. This is thrown by the commitAdditionalLogicChanges
|
* Dummy exception used to signal success. This is thrown by the performAdditionalXXXLogic()
|
||||||
* method to indicate to the test that everything worked properly, because the
|
* methods to indicate to the test that everything worked properly, because the
|
||||||
* TestExtraLogicManager instance used by the flow will have been created deep in the flow and is
|
* TestExtraLogicManager instance used by the flow will have been created deep in the flow and is
|
||||||
* not accessible to the test code directly. We should fix this when we make the extra flow logic
|
* not accessible to the test code directly. We should fix this when we make the extra flow logic
|
||||||
* injected.
|
* injected.
|
||||||
|
@ -116,7 +113,7 @@ public class TestExtraLogicManager implements RegistryExtraFlowLogic {
|
||||||
if (flags == null) {
|
if (flags == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
messageToThrow = Joiner.on(',').join(flags.getFlags());
|
throw new TestExtraLogicManagerSuccessException(Joiner.on(',').join(flags.getFlags()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Computes the expected create cost, for use in fee challenges and the like. */
|
/** Computes the expected create cost, for use in fee challenges and the like. */
|
||||||
|
@ -130,10 +127,7 @@ public class TestExtraLogicManager implements RegistryExtraFlowLogic {
|
||||||
return domainNameToFeeOrCredit(domainName);
|
return domainNameToFeeOrCredit(domainName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Performs additional tasks required for a create command. */
|
||||||
* Performs additional tasks required for a create command. Any changes should not be persisted to
|
|
||||||
* Datastore until commitAdditionalLogicChanges is called.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void performAdditionalDomainCreateLogic(
|
public void performAdditionalDomainCreateLogic(
|
||||||
DomainResource domain,
|
DomainResource domain,
|
||||||
|
@ -147,13 +141,10 @@ public class TestExtraLogicManager implements RegistryExtraFlowLogic {
|
||||||
if (flags == null) {
|
if (flags == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
messageToThrow = Joiner.on(',').join(flags.getFlags());
|
throw new TestExtraLogicManagerSuccessException(Joiner.on(',').join(flags.getFlags()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Performs additional tasks required for a delete command. */
|
||||||
* Performs additional tasks required for a delete command. Any changes should not be persisted to
|
|
||||||
* Datastore until commitAdditionalLogicChanges is called.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void performAdditionalDomainDeleteLogic(
|
public void performAdditionalDomainDeleteLogic(
|
||||||
DomainResource domainResource,
|
DomainResource domainResource,
|
||||||
|
@ -161,7 +152,7 @@ public class TestExtraLogicManager implements RegistryExtraFlowLogic {
|
||||||
DateTime asOfDate,
|
DateTime asOfDate,
|
||||||
EppInput eppInput,
|
EppInput eppInput,
|
||||||
HistoryEntry historyEntry) throws EppException {
|
HistoryEntry historyEntry) throws EppException {
|
||||||
messageToThrow = "deleted";
|
throw new TestExtraLogicManagerSuccessException("deleted");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Computes the expected renewal cost, for use in fee challenges and the like. */
|
/** Computes the expected renewal cost, for use in fee challenges and the like. */
|
||||||
|
@ -175,10 +166,7 @@ public class TestExtraLogicManager implements RegistryExtraFlowLogic {
|
||||||
return domainNameToFeeOrCredit(domain.getFullyQualifiedDomainName());
|
return domainNameToFeeOrCredit(domain.getFullyQualifiedDomainName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Performs additional tasks required for a renew command. */
|
||||||
* Performs additional tasks required for a renew command. Any changes should not be persisted
|
|
||||||
* to Datastore until commitAdditionalLogicChanges is called.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void performAdditionalDomainRenewLogic(
|
public void performAdditionalDomainRenewLogic(
|
||||||
DomainResource domainResource,
|
DomainResource domainResource,
|
||||||
|
@ -187,13 +175,10 @@ public class TestExtraLogicManager implements RegistryExtraFlowLogic {
|
||||||
int years,
|
int years,
|
||||||
EppInput eppInput,
|
EppInput eppInput,
|
||||||
HistoryEntry historyEntry) throws EppException {
|
HistoryEntry historyEntry) throws EppException {
|
||||||
messageToThrow = "renewed";
|
throw new TestExtraLogicManagerSuccessException("renewed");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Performs additional tasks required for a restore command. */
|
||||||
* Performs additional tasks required for a restore command. Any changes should not be persisted
|
|
||||||
* to Datastore until commitAdditionalLogicChanges is called.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void performAdditionalDomainRestoreLogic(
|
public void performAdditionalDomainRestoreLogic(
|
||||||
DomainResource domainResource,
|
DomainResource domainResource,
|
||||||
|
@ -201,13 +186,10 @@ public class TestExtraLogicManager implements RegistryExtraFlowLogic {
|
||||||
DateTime asOfDate,
|
DateTime asOfDate,
|
||||||
EppInput eppInput,
|
EppInput eppInput,
|
||||||
HistoryEntry historyEntry) throws EppException {
|
HistoryEntry historyEntry) throws EppException {
|
||||||
messageToThrow = "restored";
|
throw new TestExtraLogicManagerSuccessException("restored");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Performs additional tasks required for a transfer command. */
|
||||||
* Performs additional tasks required for a transfer command. Any changes should not be persisted
|
|
||||||
* to Datastore until commitAdditionalLogicChanges is called.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void performAdditionalDomainTransferLogic(
|
public void performAdditionalDomainTransferLogic(
|
||||||
DomainResource domainResource,
|
DomainResource domainResource,
|
||||||
|
@ -221,11 +203,11 @@ public class TestExtraLogicManager implements RegistryExtraFlowLogic {
|
||||||
if (flags == null) {
|
if (flags == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
messageToThrow =
|
throw new TestExtraLogicManagerSuccessException(
|
||||||
"add:"
|
"add:"
|
||||||
+ Joiner.on(',').join(flags.getAddFlags().getFlags())
|
+ Joiner.on(',').join(flags.getAddFlags().getFlags())
|
||||||
+ ";remove:"
|
+ ";remove:"
|
||||||
+ Joiner.on(',').join(flags.getRemoveFlags().getFlags());
|
+ Joiner.on(',').join(flags.getRemoveFlags().getFlags()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Computes the expected update cost, for use in fee challenges and the like. */
|
/** Computes the expected update cost, for use in fee challenges and the like. */
|
||||||
|
@ -238,10 +220,7 @@ public class TestExtraLogicManager implements RegistryExtraFlowLogic {
|
||||||
return domainNameToFeeOrCredit(domain.getFullyQualifiedDomainName());
|
return domainNameToFeeOrCredit(domain.getFullyQualifiedDomainName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Performs additional tasks required for an update command. */
|
||||||
* Performs additional tasks required for an update command. Any changes should not be persisted
|
|
||||||
* to Datastore until commitAdditionalLogicChanges is called.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void performAdditionalDomainUpdateLogic(
|
public void performAdditionalDomainUpdateLogic(
|
||||||
DomainResource domainResource,
|
DomainResource domainResource,
|
||||||
|
@ -254,17 +233,10 @@ public class TestExtraLogicManager implements RegistryExtraFlowLogic {
|
||||||
if (flags == null) {
|
if (flags == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
messageToThrow =
|
throw new TestExtraLogicManagerSuccessException(
|
||||||
"add:"
|
"add:"
|
||||||
+ Joiner.on(',').join(flags.getAddFlags().getFlags())
|
+ Joiner.on(',').join(flags.getAddFlags().getFlags())
|
||||||
+ ";remove:"
|
+ ";remove:"
|
||||||
+ Joiner.on(',').join(flags.getRemoveFlags().getFlags());
|
+ Joiner.on(',').join(flags.getRemoveFlags().getFlags()));
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void commitAdditionalLogicChanges() {
|
|
||||||
checkNotNull(messageToThrow);
|
|
||||||
// Throw a specific exception as a signal to the test code that we made it through to here.
|
|
||||||
throw new TestExtraLogicManagerSuccessException(messageToThrow);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import google.registry.flows.EppException;
|
||||||
import google.registry.model.eppinput.EppInput;
|
import google.registry.model.eppinput.EppInput;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -35,7 +36,7 @@ public class EppLoader {
|
||||||
this.eppXml = loadFileWithSubstitutions(context.getClass(), eppXmlFilename, substitutions);
|
this.eppXml = loadFileWithSubstitutions(context.getClass(), eppXmlFilename, substitutions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EppInput getEpp() throws Exception {
|
public EppInput getEpp() throws EppException {
|
||||||
return unmarshal(EppInput.class, eppXml.getBytes(UTF_8));
|
return unmarshal(EppInput.class, eppXml.getBytes(UTF_8));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue