Add extra logic for all relevant flows

This CL enhances various domain flows (check, create, delete, renew, restore, transfer, update) so that they invoke the appropriate methods on the object implementing the TLD's RegistryExtraFlowLogic (if any). TldSpecificLogicProxy is also updated to invoke RegistryExtraFlowLogic proxy (if any) to fetch the appropriate price. The tests use a made-up extra flow logic object which can be attached to a test TLD to make sure that the proper routines are being invoked.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=132486734
This commit is contained in:
mountford 2016-09-07 15:23:50 -07:00 committed by Ben McIlwain
parent a6db24c8bb
commit 95cc7ab3d8
46 changed files with 1173 additions and 394 deletions

View file

@ -15,8 +15,12 @@
package google.registry.flows.domain;
import com.google.common.base.Optional;
import google.registry.flows.EppException;
import google.registry.flows.EppException.CommandFailedException;
import google.registry.model.domain.DomainBase;
import google.registry.model.registry.Registry;
import java.util.HashMap;
import javax.annotation.Nullable;
/**
* Static class to return the correct {@link RegistryExtraFlowLogic} for a particular TLD.
@ -36,12 +40,23 @@ public class RegistryExtraFlowLogicProxy {
extraLogicOverrideMap.put(tld, extraLogicClass);
}
public static Optional<RegistryExtraFlowLogic> newInstanceForTld(String tld) {
public static <D extends DomainBase> Optional<RegistryExtraFlowLogic>
newInstanceForDomain(@Nullable D domain) throws EppException {
if (domain == null) {
return Optional.absent();
} else {
return newInstanceForTld(domain.getTld());
}
}
public static Optional<RegistryExtraFlowLogic>
newInstanceForTld(String tld) throws EppException {
if (extraLogicOverrideMap.containsKey(tld)) {
try {
return Optional.<RegistryExtraFlowLogic>of(extraLogicOverrideMap.get(tld).newInstance());
} catch (InstantiationException | IllegalAccessException e) {
return Optional.absent();
return Optional.<RegistryExtraFlowLogic>of(
extraLogicOverrideMap.get(tld).getConstructor().newInstance());
} catch (ReflectiveOperationException ex) {
throw new CommandFailedException();
}
}
return Optional.absent();